posthog-js 1.447.1 → 1.447.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 (57) 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.d.ts +1 -1
  11. package/dist/customizations.full.js +1 -1
  12. package/dist/customizations.js +1 -1
  13. package/dist/default-extensions.js +1 -1
  14. package/dist/extension-bundles.js +1 -1
  15. package/dist/integrity.json +29 -29
  16. package/dist/lazy-recorder.js +1 -1
  17. package/dist/lazy-recorder.js.map +1 -1
  18. package/dist/main.d.ts +1 -1
  19. package/dist/main.js +1 -1
  20. package/dist/module.d.ts +1 -1
  21. package/dist/module.full.cjs +1 -1
  22. package/dist/module.full.d.ts +1 -1
  23. package/dist/module.full.js +1 -1
  24. package/dist/module.full.js.map +1 -1
  25. package/dist/module.full.no-external.cjs +1 -1
  26. package/dist/module.full.no-external.d.ts +1 -1
  27. package/dist/module.full.no-external.js +1 -1
  28. package/dist/module.full.no-external.js.map +1 -1
  29. package/dist/module.js +1 -1
  30. package/dist/module.mjs +1 -1
  31. package/dist/module.no-external.cjs +1 -1
  32. package/dist/module.no-external.d.ts +1 -1
  33. package/dist/module.no-external.js +1 -1
  34. package/dist/module.slim.js +1 -1
  35. package/dist/module.slim.no-external.d.ts +1 -1
  36. package/dist/module.slim.no-external.js +1 -1
  37. package/dist/posthog-recorder.d.ts +2 -1
  38. package/dist/posthog-recorder.js +1 -1
  39. package/dist/posthog-recorder.js.map +1 -1
  40. package/dist/recorder-v2.js +1 -1
  41. package/dist/recorder-v2.js.map +1 -1
  42. package/dist/recorder.d.ts +2 -1
  43. package/dist/recorder.js +1 -1
  44. package/dist/recorder.js.map +1 -1
  45. package/dist/rrweb-plugin-console-record.d.ts +1 -1
  46. package/dist/rrweb-types.d.ts +1 -1
  47. package/dist/rrweb.d.ts +2 -1
  48. package/dist/rrweb.js +1 -1
  49. package/dist/rrweb.js.map +1 -1
  50. package/dist/src/extensions/replay/types/rrweb-types.d.ts +1 -1
  51. package/dist/src/extensions/replay/types/rrweb.d.ts +1 -0
  52. package/dist/surveys-preview.js +1 -1
  53. package/dist/surveys.js +1 -1
  54. package/lib/package.json +1 -1
  55. package/lib/src/extensions/replay/types/rrweb-types.d.ts +1 -1
  56. package/lib/src/extensions/replay/types/rrweb.d.ts +1 -0
  57. package/package.json +7 -7
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="u">typeof window?window:void 0,t="u">typeof globalThis?globalThis:e,i=null==t?void 0:t.navigator,n=null==t?void 0:t.document,s=null==t?void 0:t.location,r=null==t?void 0:t.fetch,o=(null==t?void 0:t.XMLHttpRequest)&&"withCredentials"in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,a=null==t?void 0:t.AbortController,l=null==t?void 0:t.CompressionStream,c=null==i?void 0:i.userAgent,u="undefined"!=typeof globalThis?globalThis:e;u&&"undefined"==typeof self&&(u.self=u),u&&"undefined"==typeof File&&(u.File=function(){});const d=null!=e?e:{},h="$early_access_features",p="$active_feature_flags",g="$feature_flag_details",_="$feature_flag_errors",f="$feature_flag_evaluated_at",v="$feature_flag_request_id",m="$minimal_flag_called_events",y="$enabled_feature_flags",b="$stored_group_properties",S="$stored_person_properties",w="$flag_call_reported",k="$flag_call_reported_session_id",C="$feature_flag_payloads",E="$override_feature_flags",T="$override_feature_flag_payloads",x="visibilitychange",I="$autocapture_disabled_server_side",R="$surveys",P="$surveys_loaded_at",M="PostHog loadExternalDependency extension not found.",F="$surveys_activated",A="$surveys_activated_session",L="$surveys_activated_timestamps",O="$people_distinct_id",D="distinct_id",N="$device_id",B="$device_model",q="__alias",H="__cmpns",U="$fbc",z="$fbc_persistence",W="$fbp",j="$fbp_persistence",V="__timers",G="$heatmaps_enabled_server_side",Q="$exception_capture_enabled_server_side",K="$error_tracking_suppression_rules",J="$error_tracking_capture_extension_exceptions",Y="$web_vitals_enabled_server_side",Z="$dead_clicks_enabled_server_side",X="$product_tours_enabled_server_side",ee="$logs_capture_enabled_server_side",te="$web_vitals_allowed_metrics",ie="$session_recording_remote_config",ne="$session_recording_enabled_server_side",se="$replay_sample_rate",re="$replay_override_sampling",oe="$replay_override_linked_flag",ae="$replay_override_url_trigger",le="$replay_override_event_trigger",ce="$sesid",ue="$session_is_sampled",de="$session_past_minimum_duration",he="$session_recording_url_trigger_activated_session",pe="$session_recording_event_trigger_activated_session",ge="$posthog_sr_group_event_trigger_",_e="$posthog_sr_group_url_trigger_",fe="$posthog_sr_group_sampling_",ve="$debug_first_full_snapshot_timestamp",me="$sess_rec_flush_size",ye="$groups",be="ph_product_tours",Se="$product_tours_activated",we="$product_tours_activated_session",ke="$conversations_widget_session_id",Ce="$conversations_ticket_id",Ee="$conversations_widget_state",Te="$conversations_user_traits",xe="$user_state",Ie="$client_session_props",Re="$capture_rate_limit",Pe="$initial_campaign_params",Me="$initial_referrer_info",Fe="$initial_person_info",Ae="$epp",Le="$posthog_cookieless",Oe="$cookieless_mode",De="$sdk_debug_extensions_init_method",$e="$sdk_debug_extensions_init_time_ms",Ne="$sdk_debug_recording_script_not_loaded",Be="$sdk_debug_replay_stale_config",qe="$sdk_debug_replay_event_trigger_status",He="$sdk_debug_replay_linked_flag_trigger_status",Ue="$sdk_debug_replay_matched_recording_trigger_groups",ze="$sdk_debug_replay_pending_trigger_conditions",We="$sdk_debug_replay_remote_trigger_matching_config",je="$sdk_debug_replay_trigger_groups_count",Ve="$sdk_debug_replay_url_trigger_status",Ge="$sdk_debug_rrweb_attached",Qe="$sdk_debug_rrweb_start_attempted",Ke="$session_recording_start_reason",Je="anonymous",Ye="identified",Ze="identified_only",Xe="beforeunload",et="$pageview",tt="$pageleave",it="$identify",nt="$groupidentify";function st(e,t,i,n,s,r,o){try{var a=e[r](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(n,s)}function rt(e){return function(){var t=this,i=arguments;return new Promise(function(n,s){var r=e.apply(t,i);function o(e){st(r,n,s,o,a,"next",e)}function a(e){st(r,n,s,o,a,"throw",e)}o(void 0)})}}function ot(e){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ot(e)}function at(e,t,i){return(t=function(e){var t=function(e){if("object"!=ot(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=ot(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ot(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function lt(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function ct(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(i),!0).forEach(function(t){at(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):lt(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var ut=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_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.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),dt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});const ht="min_length",pt="max_length",gt=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],_t=["token"];function ft(e,t){return-1!==e.indexOf(t)}const vt=function(e){return e.trim()},mt=function(e){return e.replace(/^\$/,"")};function yt(e){var t;const i=[];return null!==(t=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}}))&&void 0!==t?t:"null"}const bt=Object.prototype,St=bt.hasOwnProperty,wt=bt.toString,kt=Array.isArray||function(e){return"[object Array]"===wt.call(e)},Ct=e=>"function"==typeof e,Et=e=>e===Object(e)&&!kt(e),Tt=e=>{if(Et(e)){for(const t in e)if(St.call(e,t))return!1;return!0}return!1},xt=e=>void 0===e,It=e=>"[object String]"==wt.call(e),Rt=e=>It(e)&&0===e.trim().length,Pt=e=>null===e,Mt=e=>xt(e)||Pt(e),Ft=e=>"[object Number]"==wt.call(e)&&e==e,At=e=>Ft(e)&&e>0,Lt=e=>"[object Boolean]"===wt.call(e),Ot=e=>e instanceof FormData,Dt=e=>ft(gt,e),$t=e=>ft(_t,e);function Nt(e){return null===e||"object"!=typeof e}function Bt(e,t){return{}.toString.call(e)===`[object ${t}]`}function qt(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Ut(e,Error)}}function Ht(e){return"u">typeof Event&&Ut(e,Event)}function Ut(e,t){try{return e instanceof t}catch(e){return!1}}const zt=[!0,"true",1,"1","yes"],Wt=e=>ft(zt,e),jt=[!1,"false",0,"0","no"],Vt=["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","pinterestbot","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","lightpanda","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"],Gt=new Map,Qt=function(e,t=[]){if(!e)return!1;const i=function(e,t){let i="";for(let e=0;t.length>e;e++){const n=t[e];i+=n.length+":"+n}return e.length+":"+e+"|"+t.length+":"+i}(e,t),n=Gt.get(i);if(void 0!==n)return n;const s=e.toLowerCase(),r=Vt.concat(t).some(e=>-1!==s.indexOf(e.toLowerCase()));return 256>Gt.size||Gt.clear(),Gt.set(i,r),r};function Kt(e,t,i,n,s){return t>i&&(n.warn("min cannot be greater than max."),t=i),Ft(e)?e>i?(n.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(n.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(n.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),Kt(null!=s?s:i,t,i,n))}var Jt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Kt(e.bucketSize,0,100,e._logger),this._refillRate=Kt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Kt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){const 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;const i=Date.now(),n=String(e);let s=this._buckets[n];return s?this._applyRefill(s,i):(s={tokens:this._bucketSize,lastAccess:i},this._buckets[n]=s),0===s.tokens||(s.tokens--,0===s.tokens&&(null===(t=this._onBucketRateLimited)||void 0===t||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}};const Yt="Mobile",Zt="Android",Xt="Tablet",ei="Android Tablet",ti="iPad",ii="Apple Watch",ni="Safari",si="BlackBerry",ri="Samsung Internet",oi="Chrome",ai="Chrome iOS",li="Internet Explorer",ci="Internet Explorer Mobile",ui="Opera",di="Microsoft Edge",hi="Firefox",pi="Firefox iOS",gi="Nintendo",_i="PlayStation",fi="Xbox",vi="Android Mobile",mi="Mobile Safari",yi="Windows",bi="Windows Phone",Si="Nokia",wi="Ouya",ki="Generic tablet",Ci="Konqueror",Ei="Oculus Browser",Ti="Vivaldi",xi="Yandex",Ii="Whale",Ri="DuckDuckGo",Pi="Pale Moon",Mi="Waterfox",Fi="Brave",Ai="Claude",Li="Codex",Oi="ChatGPT",Di="Google Search App",$i=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ni=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Bi=new RegExp(fi,"i"),qi=new RegExp("PlayStation \\w+","i"),Hi=new RegExp("Nintendo \\w+","i"),Ui=new RegExp("BlackBerry|PlayBook|BB10","i"),zi={"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"},Wi=function(e,t,i,n){t=t||"";const s=function(e){return(null==e?void 0:e.brave)?Fi:null}(i);return s||((null==n?void 0:n.detectGoogleSearchApp)&&ft(e,"GSA/")?Di:ft(e," OPR/")&&ft(e,"Mini")?"Opera Mini":ft(e," OPR/")?ui:Ui.test(e)?si:ft(e,"IEMobile")||ft(e,"WPDesktop")?ci:ft(e,"OculusBrowser")?Ei:ft(e,"SamsungBrowser")?ri:ft(e,"Edge")||ft(e,"Edg/")?di:ft(e,"Vivaldi/")?Ti:ft(e,"YaBrowser/")?xi:ft(e,"Whale/")?Ii:ft(e,"DuckDuckGo/")||ft(e,"Ddg/")?Ri:ft(e,"Claude/")?Ai:ft(e,"Codex/")?Li:ft(e,"ChatGPT/")?Oi:ft(e,"FBIOS")?"Facebook Mobile":ft(e,"UCWEB")||ft(e,"UCBrowser")?"UC Browser":ft(e,"CriOS")?ai:ft(e,"CrMo")||ft(e,oi)?oi:ft(e,Zt)&&ft(e,ni)?vi:ft(e,"FxiOS")?pi:ft(e.toLowerCase(),Ci.toLowerCase())?Ci:ft(e,"Brave/")?Fi:((e,t)=>t&&ft(t,"Apple")||function(e){return ft(e,ni)&&!ft(e,oi)&&!ft(e,Zt)}(e))(e,t)?ft(e,Yt)?mi:ni:ft(e,"PaleMoon/")?Pi:ft(e,"Waterfox/")?Mi:ft(e,hi)?hi:ft(e,"MSIE")||ft(e,"Trident/")?li:ft(e,"Gecko")?hi:"")},ji={[ci]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[di]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[oi]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[ai]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ni]:[$i],[mi]:[$i],[ui]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[hi]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[pi]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[si]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),$i],[vi]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ri]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Ei]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[Ti]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[xi]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Ii]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Fi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Ai]:[Ni],[Li]:[Ni],[Oi]:[Ni],[Ri]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Pi]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Mi]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Di]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[li]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Vi=function(e,t,i,n){const s=Wi(e,t,i,n),r=ji[s];if(xt(r))return null;for(let t=0;r.length>t;t++){const i=e.match(r[t]);if(i)return parseFloat(i[i.length-2])}return null},Gi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[fi,e&&e[1]||""]],[new RegExp(gi,"i"),[gi,""]],[new RegExp(_i,"i"),[_i,""]],[Ui,[si,""]],[new RegExp(yi,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[bi,""];if(new RegExp(Yt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let e=zi[i[1]]||"";return/arm/i.test(t)&&(e="RT"),[yi,e]}return[yi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=xt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Zt,[e[2],e[3],e[4]||"0"].join(".")]:[Zt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const 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/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Qi=function(e){for(let t=0;Gi.length>t;t++){const[i,n]=Gi[t],s=i.exec(e),r=s&&(Ct(n)?n(s,e):n);if(r)return r}return["",""]},Ki=function(e){return Hi.test(e)?gi:qi.test(e)?_i:Bi.test(e)?fi:new RegExp(wi,"i").test(e)?wi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?bi:/iPad/.test(e)?ti:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ii:Ui.test(e)?si:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Si,"i").test(e)?Si:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Yt).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)?Zt:ei:new RegExp("(pda|Mobile)","i").test(e)?"Generic mobile":new RegExp(Xt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?ki:""},Ji=function(e,t){var i;const n=Ki(e);return n===ti||n===ei||"Kobo"===n||"Kindle Fire"===n||n===ki?Xt:n===gi||n===fi||n===_i||n===wi?"Console":n===ii?"Wearable":n?Yt:"Android"===(null==t?void 0:t.userAgentDataPlatform)&&(null!==(i=null==t?void 0:t.maxTouchPoints)&&void 0!==i?i:0)>0?600>Math.min(null!==(s=null==t?void 0:t.screenWidth)&&void 0!==s?s:0,null!==(r=null==t?void 0:t.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==t?void 0:t.devicePixelRatio)&&void 0!==o?o:1)?Yt:Xt:"Desktop";var s,r,o},Yi=/\bFBAV\/(\d+(?:\.\d+)*)/i,Zi=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Yi],[/\bFBAN\/EMA\b/i,"Facebook Lite",Yi],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Yi],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Xi="[Truncated]",en="[Unserializable]";function tn(e){let t="";for(let i=0;e.length>i;i++){const n=e.charCodeAt(i);if(55296>n||n>56319)t+=56320>n||n>57343?e[i]:"�";else{const n=e.charCodeAt(i+1);56320>n||n>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}function nn(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch(e){i=[]}for(const n of i){let i;try{i=t[n]}catch(e){i=en}Object.defineProperty(e,n,{value:i,enumerable:!0,writable:!0,configurable:!0})}return e}Date,Date;const sn=3e5;var rn=class{record(e){if("too-large"===e.kind)return;if("retry-later"!==e.kind)return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),i=Date.now(),n=Math.min(e.retryAfterMs,sn);if(!t)return this._installedAt=i,void(this._until=i+n);this._until=Math.max(this._until,Math.min(i+n,this._installedAt+sn))}remainingMs(){const e=Date.now();if(this._installedAt-5e3>e)return this.reset(),0;const t=Math.min(sn,Math.max(0,this._until-e));return 0===t&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this._until=0,this._installedAt=0}constructor(){this._until=0,this._installedAt=0}};const on=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function an(e,t){return"string"==typeof(i=e)&&on.test(i)?e:t();var i}function ln(e,t){const i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function cn(e){return e?e.split("#")[0]:e}function un(e){try{return e()}catch(e){return}}function dn(e,t){const i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function hn(e,t,i){return pn.apply(this,arguments)}function pn(){return(pn=rt(function*(e,t,i){let n;try{return yield Promise.race([e,new Promise((e,s)=>{n=dn(()=>{try{null==i||i(),e()}catch(e){s(e)}},t)})])}finally{clearTimeout(n)}})).apply(this,arguments)}let gn,_n,fn,vn;function mn(e){var t;const i=globalThis._posthogChunkIds,n=globalThis._debugIds;if(!i&&!n)return;const s=i?Object.keys(i):[],r=n?Object.keys(n):[];if(vn&&yn(i,s,_n)&&yn(n,r,fn))return vn;_n=i?ct({},i):void 0,fn=n?ct({},n):void 0,vn={},null!==(t=gn)&&void 0!==t||(gn={});const o=(t,i)=>{for(const s of t){const t=i[s];if(!t)continue;const r=null==gn?void 0:gn[s];if(r){vn[r]=t;continue}const o=e(s);for(let e=o.length-1;e>=0;e--){var n;const i=null===(n=o[e])||void 0===n?void 0:n.filename;if(i){vn[i]=t,gn[s]=i;break}}}};return n&&o(r,n),i&&o(s,i),vn}function yn(e,t,i){return e&&i?t.length===Object.keys(i).length&&t.every(t=>e[t]===i[t]):e===i}var bn=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){const i=t&&t.mechanism||{handled:!0,type:"generic"},n=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),r=this.parseStacktrace(n,s);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return rt(function*(){for(const i of e)i.stacktrace&&i.stacktrace.frames&&kt(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null===(t=e.syntheticException)||void 0===t?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i;let n,s;if(null!=e.cause&&(n=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack)try{s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch(e){}return ct(ct({},e),{},{cause:n,stack:s,errors:null===(i=e.errors)||void 0===i?void 0:i.map(e=>this.parseStacktrace(e,t))})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(const i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return rt(function*(){let i=e;for(const e of t.modifiers)i=yield e(i);return i})()}convertToExceptionList(e,t){const i=[],n=(e,s,r)=>{var o;const a=i.length,l=void 0===s?ct(ct({type:"string"==typeof t.type&&t.type.length>0?t.type:"generic"},"boolean"==typeof t.handled?{handled:t.handled}:void 0===t.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof t.synthetic?t.synthetic:e.synthetic,exception_id:a}):{type:"chained",source:r,synthetic:e.synthetic,exception_id:a,parent_id:s},c={type:e.type,value:e.value,mechanism:l};e.stack&&(c.stacktrace={type:"raw",frames:e.stack}),i.push(c),e.cause&&n(e.cause,a,"cause");for(const t of null!==(o=e.errors)&&void 0!==o?o:[])n(t,a,"member")};return n(e),i}buildParsingContext(e){var t;return{chunkIdMap:mn(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}getAggregateErrors(e){try{if(qt(e)){let i=Object.getPrototypeOf(e);for(let n=0;i&&100>n;n++){var t;const n=null===(t=Object.getOwnPropertyDescriptor(i,"constructor"))||void 0===t?void 0:t.value;if("function"==typeof n&&"AggregateError"===n.name){const t=e.errors;return kt(t)?t:void 0}i=Object.getPrototypeOf(i)}}}catch(e){}}buildCoercingContext(e,t,i=0){let n=0,s=0,r=!1;const o=new Set,a=[],l={},c=(e,t,i=0)=>{const c=u(t,i),d=c.apply;if(c.apply=t=>{a.push(e);try{return d(t)}finally{a.pop()}},i>4||i>0&&-1!==a.indexOf(e))return this.coerceFallback(c);const h="object"==typeof e&&null!==e||"function"==typeof e;if(0===i&&n>=50||h&&o.has(e))return;h&&o.add(e),0===i&&n++;const p=this.getAggregateErrors(e);let g,_;r||(r=!!p);try{if(g=this.applyCoercers(e,c),!g)throw l}catch(e){if(e===l)return void(0===i&&n--);if(!r)throw e;g=this.coerceFallback(c)}if(!p||n>=50)return g;try{_=p.length}catch(e){return g}if(!Number.isInteger(_)||0>_||_>4294967295)return g;const f=[];for(let e=0;50>n&&1e3>s&&_>e;e++){let i;s++;try{i=c.next(p[e])}catch(e){n++,i=this.coerceFallback(u(t+1))}i&&f.push(i)}return ct(ct({},g),{},{errors:f})},u=(i,n=0)=>ct(ct({},t),{},{syntheticException:0==i?t.syntheticException:void 0,mechanism:0==i?e:{},apply(e){const t=c(e,i,n+1);if(!t)throw l;return t},next:e=>c(e,i+1)}),d=u(i);return ct(ct({},d),{},{apply:e=>{var t;return null!==(t=c(e,i))&&void 0!==t?t:this.coerceFallback(d)}})}};const Sn=/^([a-z][a-z0-9.+-]+):/i,wn=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function kn(e){if(!e||"<anonymous>"===e)return!1;const t=Sn.exec(e);return!t||wn.includes(t[1].toLowerCase())}function Cn(e,t,i,n,s){const r={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:kn(t)};return xt(n)||(r.lineno=n),xt(s)||(r.colno=s),r}const En=(e,t)=>{const i=-1!==e.indexOf("safari-extension"),n=-1!==e.indexOf("safari-web-extension");return i||n?[-1!==e.indexOf("@")?e.split("@")[0]:"?",i?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Tn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,xn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,In=/\((\S*)(?::(\d+))(?::(\d+))\)/,Rn=(e,t)=>{const i=Tn.exec(e);if(i){const[,e,n,s]=i;return Cn(t,e,"?",+n,+s)}const n=xn.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){const e=In.exec(n[2]);e&&(n[2]=e[1],n[3]=e[2],n[4]=e[3])}const[e,i]=En(n[1]||"?",n[2]);return Cn(t,i,e,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},Pn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Mn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Fn=(e,t)=>{const i=Pn.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){const e=Mn.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="")}let e=i[3],n=i[1]||"?";return[n,e]=En(n,e),Cn(t,e,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},An=/\(error: (.*)\)/;function Ln(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function On(e){for(let t=1;10>=t;t++){const i=e.length-2*t;if(0>i)break;let n=!0;for(let s=0;t>s;s++)if(!Ln(e[i+s],e[i+t+s])){n=!1;break}if(n){for(let n=0;t>n;n++)e[i+n]=e[i+t+n];return e.length=i+t,{start:i,length:t}}}}function Dn(e,t){const i=t.start+t.length,n=Nn(e,t);n&&e.splice(i+n===e.length?i:t.start,n)}function $n(e,t){let i=t.start;for(;i>0&&Ln(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function Nn(e,t){const i=t.start+t.length;let n=i;for(;e.length>n&&Ln(e[n],e[n-t.length]);)n++;return n-i}function Bn(e,t){const i=t[0];let n=e.length-(i?$n(e,i):0);for(const i of t)n-=Nn(e,i);return n}function qn(e,t,i){for(let n=0;e.length>n;n++){const s=e[(t+n)%e.length],r=e[(i+n)%e.length];if(s!==r)return r>s}return!1}var Hn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const 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){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Bt(e,"DOMException")}isDOMError(e){return Bt(e,"DOMError")}},Un=class{match(e){return qt(e)}coerce(e,t){var i;const n=this.getStack(e),s=void 0===n?null===(i=t.syntheticException)||void 0===i?void 0:i.stack:void 0,r=!!s;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=n?n:s,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){try{const t=e.stacktrace;if("string"==typeof t&&t.length>0)return t;const i=e.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(e){return}}},zn=class{match(e){return!!Bt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);const n=t.apply(e.message);return ct(ct({},n),{},{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:n.stack,synthetic:!0})}_hasUsableMessage(e){return It(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i;const n=e,s=null!==(t=n.lineno)&&void 0!==t?t:0,r=null!==(i=n.colno)&&void 0!==i?i:0;if(It(n.filename)&&0!==n.filename.length&&0!==s)return`Error\n at ${n.filename}:${s}:${r}`}};const Wn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var jn=class{match(e){return"string"==typeof e}coerce(e,t){var i;const[n,s]=this.getInfos(e);return{type:null!=n?n:"Error",value:null!=s?s:e,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e;const n=e.match(Wn);return n&&(t=n[1],i=n[2]),[t,i]}};const Vn=["fatal","error","warning","log","info","debug"];function Gn(e,t=40){const i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let e=i.length;e>0;e--){const n=i.slice(0,e).join(", ");if(t>=n.length)return e===i.length?n:n.length>t?`${n.slice(0,t)}...`:n}return""}var Qn=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,n;const s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null===(n=t.syntheticException)||void 0===n?void 0:n.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Ht(e))return e.constructor.name;const t="name"in e?e.name:void 0;return It(t)&&!Rt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){let 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;const t=this.getObjectClassName(e);return`${t&&"Object"!==t?`'${t}'`:"Object"} captured as exception with keys: ${Gn(e)}`}isSeverityLevel(e){return It(e)&&!Rt(e)&&Vn.indexOf(e)>=0}getStack(e){try{return It(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:It(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=e[t];if(qt(i))return i}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},Kn=class{match(e){return Ht(e)}coerce(e,t){var i;const n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Gn(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},Jn=class{match(e){return Nt(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?void 0:i.stack,synthetic:!0}}},Yn=class{match(e){return Bt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ht(e))return!1;try{const t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i;const n=this.getUnhandledRejectionReason(e);return Nt(n)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}:t.apply(n)}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}};const Zn="$message",Xn="$timestamp",es=new Set([Zn,Xn]),ts={enabled:!0,max_bytes:32768};function is(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:ts.enabled,max_bytes:ss(e.max_bytes,ts.max_bytes)}:ct({},ts)}var ns=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=is(e)}setConfig(e){this._config=is(e),this._trimToMaxBytes()}add(e){const t=function(e){let t;try{t=yt(e)}catch(e){return}try{const e=JSON.parse(t);if(!Et(e))return;const i=e,n=i[Zn],s=i[Xn];if(!It(n)||0===n.trim().length)return;if(!It(s)&&!Ft(s))return;return{step:i,json:t}}catch(e){return}}(e);if(!t)return;const i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;const t=encodeURIComponent(e);let i=0;for(let e=0;t.length>e;e++)"%"===t[e]?(i+=1,e+=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;){const e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function ss(e,t){if(!Ft(e)||1/0===e||-1/0===e)return t;const i=Math.floor(e);return 0>i?t:i}const rs=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function os(e){return"string"==typeof e||e}function as(e){return"string"==typeof e?e:void 0}const ls=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],cs="NativeGzipValidationError",us=e=>e.length>=2&&31===e[0]&&139===e[1],ds=(e,t)=>e===dt.GZipJS||t===dt.GZipJS||"gzip"===t,hs=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),ps=e=>{if(!e||"object"!=typeof e)return!1;const t="name"in e?String(e.name):"";return hs(e)||t===cs};let gs;const _s=e=>{throw ln(cs,`Native gzip produced invalid output: ${e}`)},fs=function(){var e=rt(function*(e,t){18>e.size&&_s("too-short");const i=new Uint8Array(yield e.slice(0,10).arrayBuffer());us(i)&&8===i[2]||_s("invalid-header");const n=new DataView(yield e.slice(e.size-8).arrayBuffer());n.getUint32(0,!0)!==(e=>{const t=(()=>{if(gs)return gs;gs=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;gs[e]=t>>>0}return gs})();let i=4294967295;for(let n=0;e.length>n;n++)i=t[255&(i^e[n])]^i>>>8;return(4294967295^i)>>>0})(t)&&_s("invalid-crc");const s=t.length>>>0;n.getUint32(4,!0)!==s&&_s("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function vs(e){return ms.apply(this,arguments)}function ms(){return ms=rt(function*(e,t=!0,i){try{const t=(new TextEncoder).encode(e),i=new globalThis.CompressionStream("gzip"),s=i.writable.getWriter(),r=s.write(t).then(()=>s.close()).catch((n=rt(function*(e){try{yield s.abort(e)}catch(e){}throw e}),function(e){return n.apply(this,arguments)})),o=new Response(i.readable).blob(),[a]=yield Promise.all([o,r]);return yield fs(a,t),a}catch(e){if(null==i?void 0:i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}var n}),ms.apply(this,arguments)}function ys(e,t){if(null==e)return{};var i,n,s=function(e,t){if(null==e)return{};var i={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;i[n]=e[n]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;r.length>n;n++)t.includes(i=r[n])||{}.propertyIsEnumerable.call(e,i)&&(s[i]=e[i])}return s}const bs="[redacted]",Ss=/^[A-Za-z0-9+/\n\r]+=*$/,ws=/^[A-Za-z0-9_-]+={0,2}$/,ks=/[-_]/,Cs=/^data:[^,\s]*;base64,/i,Es=/^[A-Za-z0-9+/_-]+={0,2}$/,Ts=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,xs=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Is=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Rs=/[\s<>"]/,Ps=(()=>new RegExp(Is.source,"i"))(),Ms=/[a-z][a-z0-9+.-]{0,63}:\/\//i,Fs=(()=>new RegExp(`^${Ms.source}`,"i"))(),As=(()=>new RegExp(Ms.source,"gi"))(),Ls=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,Os=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,Ds=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,$s=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Ns=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,Bs=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,qs=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,Hs=/\b\d(?:[ ./-]?\d){12,}\b/g,Us=/\d+/g,zs=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Ws=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function js(e){return function(e){return xs.test(e)}(e)||Ls.test(e)||Os.test(e)}function Vs(e){return e.split("&",129).length>128}function Gs(e,t,i){return js(e)||t.includes(";")&&function(e){return e.split(";").some(e=>js(e.split("=",1)[0]))}(t)?bs:Ps.test(t)?i?Xs(t,{allowNestedUrls:!1,stripPunctuation:!0}):bs:t}function Qs(e,t){const i=new URLSearchParams;let n=!1,s=!1;for(const[r,o]of new URLSearchParams(e)){const e=er(r),a=er(o);n||(n=e!==r||a!==o);const l=Gs(e,a,t);n||(n=l!==a),s=js(e)||l!==a,i.append(e,l)}return{changed:n,lastFieldSensitive:s,serialized:i.toString()}}function Ks(e,t){if(!e.includes("="))return{value:Js(e,t),lastFieldSensitive:!1};const i=Qs(e,t);return{value:i.changed?i.serialized:e,lastFieldSensitive:i.lastFieldSensitive}}function Js(e,t){return t?Xs(e,{allowNestedUrls:!1,stripPunctuation:!0}):Ps.test(e)?bs:e}function Ys(e,t,i){return"#"===e?!t.fragment&&(t.fragment=!0):"?"===e&&(t.fragment?"="!==i&&!t.fragmentQuery&&(t.fragmentQuery=!0):!t.query&&(t.query=!0))}function Zs(e,t){var i;if(e.length>8192&&Fs.test(e))return bs;const{address:n,suffix:s}=t.stripPunctuation?function(e){let t=e.length;for(;t>0&&".,;:!?)]}'".includes(e[t-1]);)t--;return{address:e.slice(0,t),suffix:e.slice(t)}}(e):{address:e,suffix:""};let r;try{r=new URL(n)}catch(e){return bs+s}const o=r.search.slice(1),a=""!==r.hash,l=function(e){const t=e.slice(1),i=t.indexOf("?");return 0>i?{head:t,tail:null}:{head:t.slice(0,i),tail:t.slice(i+1)}}(r.hash);if(Vs(o)||Vs(l.head)||Vs(null!==(i=l.tail)&&void 0!==i?i:""))return bs+s;let c=!1;(r.username||r.password)&&(r.username=bs,r.password="",c=!0);const u=Qs(o,t.allowNestedUrls);u.changed&&(r.search=u.serialized,c=!0);const d=Ks(l.head,t.allowNestedUrls),h=null===l.tail?null:(p=l.tail,d.lastFieldSensitive?{value:""===p?"":bs,lastFieldSensitive:!0}:Ks(p,t.allowNestedUrls));var p;const g=null===h?d.value:`${d.value}?${h.value}`;g!==r.hash.slice(1)&&(r.hash=g,c=!0);const _=a?null!=h?h:d:u;return(c?er(r.toString()):n)+(_.lastFieldSensitive?"":s)}function Xs(e,t){return e.replace(Is,i=>function(e,t){const i=function(e){if(!e.includes("://"))return[];const t=[...e.matchAll(As)].map(e=>e.index),i=[],n={query:!1,fragment:!1,fragmentQuery:!1};let s=0,r=!1,o="";for(let a=0;e.length>a&&t.length>s;a++){t[s]===a&&(a>0&&"="!==o&&i.push(a),s++);const l=e[a];Ys(l,n,o)?(o=l,r=!0):r&&"=&".includes(l)&&(o=l)}return i}(e);if(0===i.length)return Zs(e,t);let n="",s=0;for(const r of i)n+=Zs(e.slice(s,r),ct(ct({},t),{},{stripPunctuation:!1})),s=r;return n+Zs(e.slice(s),t)}(i,ct(ct({},t),{},{stripPunctuation:t.stripPunctuation&&i.length!==e.length})))}function er(e){return e.replace(Ts,bs)}function tr(e,t){return function(e){return e.length>=10240&&(Ss.test(e)||function(e){const t=Cs.exec(e);if(!t)return!1;let i;try{i=decodeURIComponent(e.slice(t[0].length))}catch(e){return!1}return Es.test(i.replace(/[\r\n]/g,""))}(e)||ks.test(e)&&ws.test(e))}(e)?"[binary data redacted - not supported by PostHog MCP analytics]":function(e,t,i){const n=4*i.maxStringLength;if(e.length>n){const s=t(e.slice(0,function(e,t){let i=t;for(;i>0&&!Rs.test(e[i-1]);)i--;return i}(e,n)));if(s.length>=2*i.maxStringLength)return s+i.truncationSuffix}return t(e)}(e,e=>function(e){return Xs(e,{allowNestedUrls:!0,stripPunctuation:!0})}(function(e){let t=e.replace(Ds," ");return t=t.replace($s,bs),t=t.replace(Ns,bs),t=t.replace(Bs,`$1${bs}`),t=t.replace(Hs,nr),t=t.replace(qs,bs),t=t.replace(zs,`$1${bs}`),t=t.replace(Ws,`$1${bs}`),t}(er(e))),t)}function ir(e){let t=0,i=!1;for(let n=e.length-1;n>=0;n--){let s=e.charCodeAt(n)-48;if(0>s||s>9)return!1;i&&(s*=2,s>9&&(s-=9)),t+=s,i=!i}return t%10==0}function nr(e){const t=[];for(let i=Us.exec(e);null!==i;i=Us.exec(e))t.push({digits:i[0],start:i.index,end:i.index+i[0].length});let i="",n=0,s=0;for(;t.length>s;){let r="",o=-1;for(let e=s;t.length>e&&(r+=t[e].digits,19>=r.length);e++)r.length>=13&&ir(r)&&(o=e);0>o?s++:(i+=e.slice(n,t[s].start)+bs,n=t[o].end,s=o+1)}return i+e.slice(n)}const sr={}.propertyIsEnumerable;function rr(e,t){try{return lr(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function or(e,t,i,n){if(0>=i.remainingNodes)return{stringValue:Xi};if(i.remainingNodes--,Lt(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){const i=e.toString(),n=BigInt("9223372036854775808");return e>=n||-n>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}(e,t);if("number"==typeof e){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};const i=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:tn(e)};if("function"==typeof e)return{stringValue:"[Function]"};if("symbol"==typeof e)return{stringValue:String(e)};if("object"==typeof e&&null!==e){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(n>=20)return{stringValue:Xi};if(e instanceof Date){const t=e.getTime(),i=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:"string"==typeof i?tn(i):String(i)}}i.ancestors.add(e);try{try{const s=e.toJSON;if("function"==typeof s)return or(s.call(e),t,i,n+1)}catch(e){}return kt(e)?{arrayValue:{values:ar(e,t,i,n+1)}}:{kvlistValue:{values:lr(e,t,i,n+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:tn(String(e))}}function ar(e,t,i,n){const s=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&i.remainingNodes>0;o++)try{const r=o in e?e[o]:void 0;if(Mt(r))continue;s.push(or(r,t,i,n))}catch(e){s.push({stringValue:en})}return e.length>o&&s.push({stringValue:Xi}),s}function lr(e,t,i,n){const s=[];for(const r in e)if(sr.call(e,r)){if(!r){null==t||t.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(Pt(o)||xt(o))continue;s.push({key:tn(r),value:or(o,t,i,n)})}catch(e){s.push({key:tn(r),value:{stringValue:en}})}}return s}function cr(e,t,i){return ct(ct(ct(ct({},nn({},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":i})}const ur=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function dr(e,t){const i=nn({},e),n={};for(const e of ur)({}).hasOwnProperty.call(i,e)&&(n[e]=i[e],delete i[e]);return[...rr(i,t),...rr(n,t)]}const hr={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const pr={text:"INFO",number:9},gr={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:pr,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function _r(e){try{return tn(String(e))}catch(e){return en}}function fr(e,t,i,n){const s=e.level||"info",{text:r,number:o}=gr[s]||pr,a=function(e=Date.now()){return String(e)+"000000"}(Ft(n)?n:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),Mt(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),Mt(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=ct({},l),u=e.attributes;if(u){let e=[];try{e=Object.keys(u)}catch(t){e=[]}for(const t of e){let e;try{e=u[t]}catch(t){e=en}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:_r(e.body)},attributes:rr(c,i)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),xt(e.trace_flags)||(d.flags=e.trace_flags),d}function vr(e,t,i){return cr(e,t,i)}function mr(e,t,i,n){return{resourceLogs:[{resource:{attributes:dr(t)},scopeLogs:[{scope:{name:i,version:n},logRecords:e}]}]}}var yr=class{constructor(e){this._onFire=e,this._firesAt=0}get pending(){return!!this._timer}arm(e){this.clear(),this._firesAt=Date.now()+e,this._timer=dn(()=>{this._timer=void 0,this._onFire()},e)}armNoEarlierThan(e){this._timer&&Date.now()+e<=this._firesAt||this.arm(e)}clear(){this._timer&&(clearTimeout(this._timer),this._timer=void 0)}};function br(){return.75+.5*Math.random()}function Sr(e,t,i,n){const s=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,s);return Math.round((void 0===n?r:Math.min(r,Math.max(n,e)))*i)}var wr=class{constructor(e,t,i,n,s,r=()=>Promise.resolve(),o){var a;this._instance=e,this._config=t,this._logger=i,this._getContext=n,this._onReady=s,this._waitForStoragePersist=r,this._scopeName=o,this._flushTimer=new yr(()=>this._flushInBackground()),this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._retryAfter=new rn,this._consecutiveFlushFailures=0,this._flushJitter=1,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}clearQueue(){this._queueGeneration++,this._instance.setPersistedProperty(ut.LogsQueue,[])}reset(){this._flushTimer.clear(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.reset(),this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.isOpen()?this._hasQueuedRecords()&&this._armFlushTimer():this._flushInBackground()}captureLog(e,t){var i;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==e?void 0:e.body))return;const n=this._runBeforeSend(e);if(null===n)return;if(!n.body)return void this._logger.info("Log was rejected in beforeSend function");if(!this._checkRateLimit())return;const s={record:fr(n,null!==(i=null==t?void 0:t.context)&&void 0!==i?i:this._getContext(),this._logger,null==t?void 0:t.occurredAtMs)};this._onReady(()=>this._enqueue(s))}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let n=e;for(const e of i)try{const t=e(n);if(!t)return this._logger.info("Log was rejected in beforeSend function"),null;n=t}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return n}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;const 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 rt(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return rt(function*(){var t;e._flushTimer.clear();let i=null!==(t=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==t?t:[];if(0===i.length)return;const n=i.length;let s=0;for(;i.length>0&&n>s;){var r,o;const t=e._queueGeneration;e._evictedSinceAdvance=0;const n=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,n),l=mr(a.map(e=>e.record),e._buildResourceAttributes(),null!==(r=e._scopeName)&&void 0!==r?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(l);if(e._queueGeneration!==t)return;if("too-large"===c.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e._maxBatchRecordsPerPost}`);else{if(e._retryAfter.record(c),e._flushTimer.pending&&e._flushTimer.arm(Math.max(e._flushIntervalMs,e._retryAfter.remainingMs())),"retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.warn("Dropping a single log record 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(a.length),i=null!==(o=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==o?o:[],s+=a.length,"fatal"===c.kind)throw c.error}}})()}_persistQueueAdvance(e){var t=this;return rt(function*(){var i;const n=Math.max(0,e-t._evictedSinceAdvance),s=null!==(i=t._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(ut.LogsQueue,s.slice(n)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return vr(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(this._instance.optedOut)return;const i=null!==(t=this._instance.getPersistedProperty(ut.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(ut.LogsQueue,i),this._maxBufferSize>i.length||this._retryAfter.isOpen()?this._armFlushTimer():this._flushInBackground()}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(Math.max(this._flushIntervalMs,this._retryAfter.remainingMs()))}_nextFlushDelay(){return Math.max(Sr(this._flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_hasQueuedRecords(){const e=this._instance.getPersistedProperty(ut.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return rt(function*(){t._flushTimer.clear();const i=t.flush().catch(()=>{});void 0!==e?yield hn(i,e):yield i})()}flushWithTimeout(e){var t=this;return rt(function*(){const i=t.flush();yield hn(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0,this._flushJitter=1},e=>{this._consecutiveFlushFailures++,this._flushJitter=br(),this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._flushTimer.armNoEarlierThan(this._nextFlushDelay())})}};const kr=/^[0-9a-f]+$/;function Cr(e,t,i){return"string"==typeof e&&e.length===t&&e!==i&&kr.test(e)}const Er=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;const Tr="00",xr=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ir(e){return String(e)+"000000"}function Rr(e,t,i,n){let s="";return n&&(s=Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(n[e])}`).join(",")),`${e}\0${t}\0${null!=i?i:""}\0${s}`}var Pr=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushTimer=new yr(()=>this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})),this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsByHistogram=new Map,this._boundsConflictWarned=new Set,this._boundsCapWarned=!1,this._retryAfter=new rn,this._consecutiveFlushFailures=0,this._flushJitter=1,this._generation=0}count(e,t=1,i){this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:kt(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var e=this;const t=this._flushPromise,i=function(){var i=rt(function*(){t&&(yield t.catch(()=>{})),yield e._doFlush()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this._flushPromise===i&&(this._flushPromise=null)});return this._flushPromise=i,i}drainWindow(){if(0===this._series.size)return null;const e=this._series;return this._startWindow(),this._buildPayload(e)}reset(){this._generation++,this._retryAfter.reset(),this._consecutiveFlushFailures=0,this._flushJitter=1,this._flushTimer.clear(),this._flushPromise=null,this._startWindow(),this._boundsByHistogram=new Map,this._boundsCapWarned=!1}_startWindow(){this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsConflictWarned=new Set}_capture(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this._runBeforeSend(e);if(null===t)return;if(!t.name||"string"!=typeof t.name)return void this._logger.warn("Dropping metric with empty name");if("number"!=typeof t.value||!Number.isFinite(t.value))return void this._logger.warn(`Dropping metric '${t.name}': value must be a finite number`);if("count"!==t.type&&"gauge"!==t.type&&"histogram"!==t.type)return void this._logger.warn(`Dropping metric '${t.name}': unknown type '${String(t.type)}'`);if("count"===t.type&&0>t.value)return void this._logger.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,n;try{i=t.attributes?ct({},t.attributes):void 0,n=Rr(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e)}let s,r=this._series.get(n);if(!r&&!this._admitNewSeries())return;if("histogram"===t.type&&(s=this._histogramBounds(t.name,t.unit,t.bounds),!s))return;r||(r={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now(),hist:s&&Fr(s)},this._series.set(n,r));const o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn(`Metric name '${t.name}' is already used as a ${o}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this._fold(r,t.value);const a=this._activeTraceContext();a&&(r.exemplar=ct(ct({},a),{},{value:t.value,timeMs:Date.now()})),this._armFlushTimer()}_activeTraceContext(){try{var e,t;const i=function(e){const t=function(e){if("string"!=typeof e)return;const t=Er.exec(e.trim());if(!t)return;const[,i,n,s,r,o]=t;return"ff"===i||"00"===i&&o||!function(e){return Cr(e,32,"00000000000000000000000000000000")}(n)||!function(e){return Cr(e,16,"0000000000000000")}(s)?void 0:{version:i,traceId:n,spanId:s,flags:r}}(e);return t&&{traceId:t.traceId,spanId:t.spanId,flags:(i=t.flags,1&parseInt(i,16)?"01":Tr)};var i}(null===(e=(t=this._instance).getActiveSpan)||void 0===e||null===(e=e.call(t))||void 0===e?void 0:e.traceparent());if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(e){}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}_histogramBounds(e,t,i){if(void 0!==i&&!function(e){if(!kt(e)||0===e.length)return!1;for(let t=0;e.length>t;t++)if(!Number.isFinite(e[t])||t>0&&e[t-1]>=e[t])return!1;return!0}(i))return void this._logger.warn(`Dropping histogram '${e}': bounds must be a non-empty array of finite, strictly increasing numbers`);const n=Rr("histogram",e,t,void 0),s=this._boundsByHistogram.get(n);if(s)return this._warnOnBoundsConflict(e,n,s,i),s;if(this._boundsByHistogram.size>=this._config.maxSeriesPerFlush){if(this._boundsCapWarned||(this._boundsCapWarned=!0,this._logger.warn(`Histogram bounds limit reached (${this._config.maxSeriesPerFlush} distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.`)),i&&!Mr(i,xr))return;return xr}const r=i?i.slice():xr;return this._boundsByHistogram.set(n,r),r}_warnOnBoundsConflict(e,t,i,n){Mr(i,null!=n?n:xr)||this._boundsConflictWarned.has(t)||(this._boundsConflictWarned.add(t),this._logger.warn(`Histogram '${e}' already uses the bounds [${i.join(", ")}]; samples that pass different bounds are recorded in those buckets.`))}_fold(e,t){switch(e.type){case"count":var i;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":{const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[function(e,t){for(let i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,i.bounds)]+=1;break}}}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let n=e;for(const e of i)try{const t=e(n);if(!t)return this._logger.info("Metric was rejected in beforeSend function"),null;n=t}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return n}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(this._nextFlushDelay())}_nextFlushDelay(){return Math.max(Sr(this._config.flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_doFlush(){var e=this;return rt(function*(){if(e._flushTimer.clear(),0===e._series.size)return;const t=e._series;e._startWindow();const i=e._generation,n=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(e._retryAfter.record(n),"retry-later"===n.kind?(e._consecutiveFlushFailures++,e._flushJitter=br()):(e._consecutiveFlushFailures=0,e._flushJitter=1),e._flushTimer.pending&&e._flushTimer.arm(e._nextFlushDelay()),n.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._flushTimer.armNoEarlierThan(e._nextFlushDelay());case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",n.error)}})()}_buildPayload(e){return t=this._buildMetrics(e),i=function(e,t,i){return cr(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),n=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:dr(i)},scopeMetrics:[{scope:{name:n,version:s},metrics:t}]}]};var t,i,n,s}_buildMetrics(e){const t=Ir(Date.now()),i=new Map;for(const o of e.values()){var n;const e=Rr(o.type,o.name,o.unit,void 0);let a=i.get(e);a||(a=ct({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(e,a));const l=rr(null!==(n=o.attributes)&&void 0!==n?n:{},this._logger),c=Ir(o.windowStartMs),u=Ar(o.exemplar);if("count"===o.type){var s;const e=ct({attributes:l,startTimeUnixNano:c,timeUnixNano:t,asDouble:null!==(s=o.total)&&void 0!==s?s:0},u);a.sum.dataPoints.push(e)}else if("gauge"===o.type){var r;const e=ct({attributes:l,timeUnixNano:t,asDouble:null!==(r=o.last)&&void 0!==r?r:0},u);a.gauge.dataPoints.push(e)}else{const e=o.hist,i=ct({attributes:l,startTimeUnixNano:c,timeUnixNano:t,count:e.count,sum:e.sum,min:e.min,max:e.max,bucketCounts:e.bucketCounts,explicitBounds:e.bounds},u);a.histogram.dataPoints.push(i)}}return Array.from(i.values())}_mergeWindowBack(e){for(const[s,r]of e){var t;const e=this._series.get(s);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,r.windowStartMs),e.exemplar=null!==(t=e.exemplar)&&void 0!==t?t:r.exemplar,e.type){case"count":var i,n;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+(null!==(n=r.total)&&void 0!==n?n:0);break;case"gauge":break;case"histogram":{const t=e.hist,i=r.hist;t.count+=i.count,t.sum+=i.sum,t.min=Math.min(t.min,i.min),t.max=Math.max(t.max,i.max);for(let e=0;t.bucketCounts.length>e;e++)t.bucketCounts[e]+=i.bucketCounts[e];break}}else this._admitNewSeries()&&this._series.set(s,r)}}};function Mr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let i=0;e.length>i;i++)if(e[i]!==t[i])return!1;return!0}function Fr(e){return{bounds:e,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(e.length+1).fill(0)}}function Ar(e){return e?{exemplars:[{filteredAttributes:[],timeUnixNano:Ir(e.timeMs),asDouble:e.value,traceId:e.traceId,spanId:e.spanId}]}:{}}function Lr(e,t){if(!e)return;const i=e.find(e=>e.type===t);return null==i?void 0:i.value}const Or="0.10.7",Dr={DEBUG:!1,LIB_VERSION:Or,LIB_NAME:"browser-common",JS_SDK_VERSION:Or},$r=(e,{debugEnabled:t}={})=>{const i={_log(i,...n){let s;try{s=typeof window>"u"?void 0:window}catch(e){return}s&&(Dr.DEBUG||s.POSTHOG_DEBUG||t)&&!xt(s.console)&&s.console&&("__rrweb_original__"in s.console[i]?s.console[i].__rrweb_original__:s.console[i])(e,...n)},debug(...e){i._log("debug",...e)},info(...e){i._log("log",...e)},warn(...e){i._log("warn",...e)},error(...e){i._log("error",...e)},critical(...t){console.error(e,...t)},uninitializedWarning(e){i.error(`You must initialize PostHog before calling ${e}`)},createLogger:(t,i)=>$r(`${e} ${t}`,i)};return i},Nr=$r("[PostHog.js]"),Br=(e,t)=>Nr.createLogger(e,t);function qr(e,t){kt(e)&&e.forEach(t)}function Hr(e,t){if(!Mt(e))if(kt(e))e.forEach(t);else if(Ot(e))e.forEach((e,i)=>t(e,i));else for(const i in e)St.call(e,i)&&t(e[i],i)}const Ur=function(e,...t){for(const i of t)for(const t in i)void 0!==i[t]&&(e[t]=i[t]);return e};function zr(e){const t=Object.keys(e);let i=t.length;const n=new Array(i);for(;i--;)n[i]=[t[i],e[t[i]]];return n}const Wr=function(e){return function(...t){try{return e.apply(this,t)}catch(e){Nr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Nr.critical(e)}}},jr=function(e){const t={};return Hr(e,function(e,i){(It(e)&&e.length>0||Ft(e))&&(t[i]=e)}),t};function Vr(e){const t=ct({},e);for(const i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}const Gr=["herokuapp.com","vercel.app","netlify.app"];function Qr(e){const t=null==e?void 0:e.hostname;if(!It(t))return!1;const i=t.split(".").slice(-2).join(".");for(const e of Gr)if(i===e)return!1;return!0}function Kr(e,t,i,n){const{capture:s=!1,passive:r=!0}=null!=n?n:{};null==e||e.addEventListener(t,i,{capture:s,passive:r})}function Jr(e){return"ph_toolbar_internal"===e.name}const Yr=e=>{const t=typeof document>"u"?void 0:document,i=null==t?void 0:t.createElement("a");return xt(i)?null:(i.href=e,i)},Zr=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(e){return!1}},Xr=(e,t)=>e>=t&&Zr(),eo=(e,t,i,n)=>{if(0===e){if(Zr()){const e=t+1;return e===i&&n(),e}return t}return 0},to=["localhost","127.0.0.1"],io=(e,t)=>{try{let i;return JSON.stringify(e,(e,t)=>{var n;return qt(t)?(null!==(n=i)&&void 0!==n||(i=new WeakMap),i.has(t)||i.set(t,Vr(t)),i.get(t)):"bigint"==typeof t?t.toString():t},t)}catch(t){return yt(e)}},no=function(e,t="&"){let i,n;const s=[];return Hr(e,function(e,t){xt(e)||xt(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),n=encodeURIComponent(t),s[s.length]=n+"="+i)}),s.join(t)},so=function(e,t){const i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let n;for(let e=0;i.length>e;e++){const s=i[e].split(/=(.*)/);if(s[0]===t){n=s;break}}if(!kt(n)||2>n.length)return"";{let e=n[1].replace(/\+/g," ");try{e=decodeURIComponent(e)}catch(t){Nr.error("Skipping decoding for malformed query param: "+e)}return e}},ro=function(e,t,i){if(!e||!t||!t.length)return e;const n=e.split(/#(.*)/),s=n[1],r=(n[0]||"").split(/\?(.*)/),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let e=0;l.length>e;e++){const n=l[e].split("?");let s=0;for(;n.length>s&&!t.includes(n[s].split("=")[0]);)s++;c.push(n.length>s?n.slice(0,s).concat(n[s].split("=")[0]+"="+i).join("?"):l[e])}let u=a;return null!=o&&(u+="?"+c.join("&")),null!=s&&(u+="#"+s),u},oo=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null};function ao(e,t){var i;const n=null==e||null===(i=e.config)||void 0===i?void 0:i.get_current_url;if(!Ct(n))return t;try{const e=n(t);return It(e)&&e?e:t}catch(e){return Nr.error("Error in get_current_url, falling back to window.location.href",e),t}}function lo(e){var t;const i=typeof window>"u"?void 0:window,n=null==i||null===(t=i.location)||void 0===t?void 0:t.href;return xt(n)?void 0:ao(e,n)}function co(e){var t;return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!!(null===(t=e.closest)||void 0===t?void 0:t.call(e,".toolbar-global-fade-container")))}function uo(e){return!!e&&1===e.nodeType}function ho(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function po(e){return!!e&&3===e.nodeType}function go(e){return!!e&&11===e.nodeType&&uo(e.host)}function _o(e){return e?vt(e).split(/\s+/):[]}function fo(e,t){const i=lo(t);return!!(i&&e&&e.some(e=>i.match(e)))}function vo(e){let 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 _o(t)}function mo(e){return Mt(e)?null:vt(e).split(/(\s+)/).filter(e=>Jo(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function yo(e){let t="";return Ho(e)&&!Uo(e)&&e.childNodes&&e.childNodes.length&&Hr(e.childNodes,function(e){var i;po(e)&&e.textContent&&(t+=null!==(i=mo(e.textContent))&&void 0!==i?i:"")}),vt(t)}function bo(e){var t;return xt(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}const So=["a","button","form","input","select","textarea","label"];function wo(e,t){const i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}function ko(e,t){if(xt(t))return!0;for(const i of e)if(t.some(e=>wo(i,e)))return!0;return!1}function Co(e){const t=e.parentNode;return!(!t||!uo(t))&&t}const Eo=[".ph-no-autocapture","[data-ph-no-autocapture]"],To=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],xo=(()=>[...To,"+","-","−","–"])(),Io=(()=>xo.length+10)(),Ro=["button","a","input","select","textarea","label"],Po=["button","link","tab","menuitem","option"],Mo=(e,t)=>/[a-z0-9]/i.test(t)?ft(xo,t)?new RegExp(`\\b${t}\\b`).test(e):e.includes(t):e===t,Fo=e=>ft(Ro,e.tagName.toLowerCase())||ft(Po,(e.getAttribute("role")||"").toLowerCase());function Ao(e){let t="",i="";const n=e=>{uo(e)&&Ho(e)&&!Uo(e)&&(t+=` ${yo(e)}`,i=i||e.getAttribute("aria-label")||"",Hr(e.childNodes,n))};n(e),t=vt(t.replace(/\s+/g," "));const s=(Jo(t)?t:"").toLowerCase(),r=e.getAttribute("aria-label")||(s?"":i);return{safeText:s,ariaLabel:vt(r).toLowerCase()}}const Lo=[".ph-no-deadclick",".ph-no-capture"],Oo=[".ph-no-rageclick",".ph-no-capture"],Do=["","text","search","email","password","url","tel","number"];function $o(e){return!(!e||!uo(e))&&(!!ho(e,"textarea")||(ho(e,"input")?ft(Do,(e.getAttribute("type")||"").toLowerCase()):function(e){var t;if(e.isContentEditable)return!0;const i=null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return"true"===i||""===i}(e)))}function No(e,t){if(!(typeof window>"u"?void 0:window)||Bo(e))return!1;let i,n,s;var r,o;if(Lt(t)?(i=!!t&&Oo,n=void 0,s=!1):(i=null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:Oo,n=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&&$o(e))return!1;const{targetElementList:a}=qo(e,!1);return!(n&&function(e,{safeText:t,ariaLabel:i}){let n;if(!0===e)n=To;else{if(!kt(e))return!1;if(e.length>Io)return Nr.error(`[PostHog] content_ignorelist array cannot exceed ${Io} items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map(e=>e.toLowerCase())}return n.some(e=>Mo(t,e)||Mo(i,e))}(n,function(e,t){for(const e of t)if(Fo(e))return Ao(e);for(const e of t){try{var i;if("pointer"!==(null===(i=window)||void 0===i?void 0:i.getComputedStyle(e).getPropertyValue("cursor")))break}catch(e){break}const t=Ao(e);if(t.safeText||t.ariaLabel)return t}return Ao(e)}(e,a))||ko(a,i))}const Bo=e=>!e||ho(e,"html")||!uo(e),qo=(e,t)=>{const i=typeof window>"u"?void 0:window;if(!i||Bo(e))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const s=[e];let r=e;for(;r.parentNode&&!ho(r,"body");){if(go(r.parentNode)){s.push(r.parentNode.host),r=r.parentNode.host;continue}const e=Co(r);if(!e)break;if(t||So.indexOf(e.tagName.toLowerCase())>-1)n=!0;else try{const t=i.getComputedStyle(e);t&&"pointer"===t.getPropertyValue("cursor")&&(n=!0)}catch(e){}s.push(e),r=e}return{parentIsUsefulElement:n,targetElementList:s}};function Ho(e){const t=new Set;let i=0;for(let n=e;n.parentNode&&!ho(n,"body");n=n.parentNode){if(i++>=1e3||t.has(n))return!1;t.add(n);const e=vo(n);if(ft(e,"ph-sensitive")||ft(e,"ph-no-capture"))return!1}if(ft(vo(e),"ph-include"))return!0;const n=e.type||"";if(It(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}const 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 Uo(e){return!!(ho(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ho(e,"select")||ho(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const zo=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Wo=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,jo=[16,15,14,13],Vo=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Go=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Qo=/[0-9A-Za-z_]/;function Ko(e){let t=0,i=!1;for(let n=e.length-1;n>=0;n--){let s=e.charCodeAt(n)-48;i&&(s*=2,s>9&&(s-=9)),t+=s,i=!i}return t%10==0}function Jo(e,t=!0){if(Mt(e))return!1;if(It(e)){if(e=vt(e),t?zo.test((e||"").replace(/[- ]/g,"")):function(e){let t;for(Wo.lastIndex=0;t=Wo.exec(e);){const e=t[2];if(!e)continue;const i=e.replace(/[- ]/g,"");for(let e=0;i.length>e;e++)for(const t of jo){const n=e+t;if(i.length>=n){const t=i.slice(e,n);if(zo.test(t)&&Ko(t))return!0}}}return!1}(e))return!1;if(t?Vo.test(e):function(e){let t;for(Go.lastIndex=0;t=Go.exec(e);){const e=t[1],i=t[3];if(!(e&&i&&Qo.test(e)&&Qo.test(i)))return!0}return!1}(e))return!1}return!0}function Yo(e){let t=yo(e);return t=`${t} ${Zo(e)}`.trim(),Jo(t)?t:""}function Zo(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Hr(e.childNodes,function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=yo(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${Zo(e)}`.trim())}catch(e){Nr.error("[AutoCapture]",e)}}),t}function Xo(e){return e.replace(/"|\\"/g,'\\"')}function ea(e){const t=e.attr__class;if(t)return kt(t)?t:_o(t)}const ta=1e6;function ia(e){var t;return Math.min(ta,null!==(t=e.payloadSizeLimitBytes)&&void 0!==t?t:ta)}const na={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:ta,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","google-analytics.com","analytics.google.com","nr-data.net","datadoghq.com","datadoghq.eu","ddog-gov.com","segment.io","rudderstack.com","amplitude.com","mixpanel.com","hotjar.com","hotjar.io","fullstory.com"],streamNetworkBody:!1},sa=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],ra=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],oa=["auth","token","secret","session","api-key","apikey","api_key","credential","password","passwd","cookie","csrf","xsrf"],aa=e=>{Mt(e)||Hr(Object.keys(e),t=>{(e=>{const t=e.toLowerCase();return sa.includes(t)||oa.some(e=>t.includes(e))})(t)&&(e[t]="redacted")})},la=["/s/","/e/","/i/"];function ca(e,t,i,n){if(Mt(e))return e;let s=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return It(s)&&(s=parseInt(s)),s>i?`[SessionRecording] ${n} body too large to record (${s} bytes)`:e}function ua(e,t){if(Mt(e))return e;let i=e;return Jo(i,!1)||(i="[SessionRecording] "+t+" body redacted"),Hr(ra,e=>{(null==i?void 0:i.length)&&-1!==(null==i?void 0:i.indexOf(e))&&(i="[SessionRecording] "+t+" body redacted as might contain: "+e)}),i}const da=new WeakSet,ha="disabled",pa="sampled",ga="active",_a="buffering",fa="paused",va="lazy_loading",ma="rrweb_error",ya="trigger_activated",ba="trigger_pending",Sa="trigger_disabled";function wa(e,t,i,n,s,r){return 0===t?Sa:(null==e?void 0:e.get_property(i?n+i:s))===r?ya:ba}function ka(e,t,i){return t.some(t=>{var n;return"regex"===t.matching&&(null!==(n=null==i?void 0:i.get(t.url))&&void 0!==n?n:new RegExp(t.url)).test(e)})}function Ca(e){return e.includes("trigger_activated")?ya:e.includes("trigger_pending")?ba:Sa}function Ea(e){const t=new Set(e);switch(t.delete(Sa),t.size){case 0:return Sa;case 1:return Array.from(t)[0];default:return ba}}var Ta=class{constructor(e){this._matchers=e}triggerStatus(e){return Ca(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return Ca(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},xa=class{constructor(e){this._matchers=e}triggerStatus(e){return Ea(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return Ea(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},Ia=class{triggerStatus(){return this.triggerStatusNoSideEffects()}triggerStatusNoSideEffects(){return ya}stop(){}};const Ra=e=>"sessionRecording"in e;var Pa=class{constructor(e,t){this._instance=e,this._urlTriggers=[],this._urlBlocklist=[],this._compiledTriggerRegexes=new Map,this._compiledBlocklistRegexes=new Map,this._lastCheckedUrl="",this.urlBlocked=!1,this._groupId=t}onConfig(e){var t,i;this._urlTriggers=(Ra(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.urlTriggers:[]:null==e?void 0:e.urlTriggers)||[],this._urlBlocklist=(Ra(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.urlBlocklist:[]:null==e?void 0:e.urlBlocklist)||[],this._compileRegexCache()}_compileRegexCache(){this._compiledTriggerRegexes.clear(),this._compiledBlocklistRegexes.clear();for(const e of this._urlTriggers)if("regex"===e.matching&&!this._compiledTriggerRegexes.has(e.url))try{this._compiledTriggerRegexes.set(e.url,new RegExp(e.url))}catch(t){Nr.error("Invalid URL trigger regex pattern:",e.url,t)}for(const e of this._urlBlocklist)if("regex"===e.matching&&!this._compiledBlocklistRegexes.has(e.url))try{this._compiledBlocklistRegexes.set(e.url,new RegExp(e.url))}catch(t){Nr.error("Invalid URL blocklist regex pattern:",e.url,t)}}onRemoteConfig(e){this.onConfig(e)}_urlTriggerStatus(e){return wa(this._instance,this._urlTriggers.length,this._groupId,_e,he,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[Ve]:t}),t}triggerStatusNoSideEffects(e){return this._urlTriggerStatus(e)}isCurrentUrlBlocked(){const e=lo(this._instance);if(!e)return!1;try{return ka(e,this._urlBlocklist,this._compiledBlocklistRegexes)}catch(e){return!0}}checkUrlBlocklist(e,t){const i=lo(this._instance);if(!i)return;if(i===this._lastCheckedUrl)return;this._lastCheckedUrl=i;const n=this.urlBlocked,s=ka(i,this._urlBlocklist,this._compiledBlocklistRegexes);n&&s||(s&&!n?e():!s&&n&&t())}checkUrlTriggerConditions(e,t,i,n){const s=lo(this._instance);if(!s)return;if(s===this._lastCheckedUrl)return;this._lastCheckedUrl=s;const r=this.urlBlocked,o=ka(s,this._urlBlocklist,this._compiledBlocklistRegexes);o&&!r?e():!o&&r&&t();const a=this._urlTriggerStatus(n)===ya,l=ka(s,this._urlTriggers,this._compiledTriggerRegexes);!a&&l&&i("url",s)}stop(){this._lastCheckedUrl=""}},Ma=class{constructor(e){this._instance=e,this.linkedFlag=null,this.linkedFlagSeen=!1,this._flagListenerCleanup=()=>{}}triggerStatus(){const e=this.triggerStatusNoSideEffects();return this._instance.register_for_session({[He]:e}),e}triggerStatusNoSideEffects(){let e=ba;return Mt(this.linkedFlag)&&(e=Sa),this.linkedFlagSeen&&(e=ya),e}onConfig(e,t){var i;if(this.linkedFlag=(Ra(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.linkedFlag:null:null==e?void 0:e.linkedFlag)||null,!Mt(this.linkedFlag)&&!this.linkedFlagSeen){const e=It(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,i=It(this.linkedFlag)?null:this.linkedFlag.variant;this._flagListenerCleanup=this._instance.onFeatureFlags((n,s)=>{let r=!1;if(Et(s)&&e in s){const t=s[e];r=Lt(t)?!0===t:i?t===i:!!t}const o=r&&!this.linkedFlagSeen;this.linkedFlagSeen=r,o&&t(e,i)})}}onRemoteConfig(e,t){this.onConfig(e,t)}stop(){this._flagListenerCleanup()}},Fa=class{constructor(e,t){this._instance=e,this._eventTriggers=[],this._groupId=t}onConfig(e){var t;this._eventTriggers=(Ra(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.eventTriggers:[]:null==e?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}_eventTriggerStatus(e){return wa(this._instance,this._eventTriggers.length,this._groupId,ge,pe,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[qe]:t}),t}triggerStatusNoSideEffects(e){return this._eventTriggerStatus(e)}checkEventTriggerConditions(e,t,i){if(0===this._eventTriggers.length)return;const n=this._eventTriggerStatus(i)===ya,s=this._eventTriggers.includes(e);!n&&s&&t("event",e)}stop(){}},Aa=class{constructor(e,t,i){if(this._instance=e,this.group=t,this._urlTriggerMatching=new Pa(e,t.id),this._eventTriggerMatching=new Fa(e,t.id),this._linkedFlagMatching=new Ma(e),t.conditions.events&&t.conditions.events.length>0||t.conditions.urls&&t.conditions.urls.length>0||t.conditions.flag){const e=(t.conditions.events||[]).map(e=>e.name),n={urlTriggers:t.conditions.urls||[],eventTriggers:e,linkedFlag:t.conditions.flag||null,urlBlocklist:[]};this._urlTriggerMatching.onConfig(n),this._eventTriggerMatching.onConfig(n),this._linkedFlagMatching.onConfig(n,i);const s=[this._eventTriggerMatching,this._urlTriggerMatching,this._linkedFlagMatching];this._combinedMatching="any"===t.conditions.matchType?new Ta(s):new xa(s)}else this._combinedMatching=new Ia}triggerStatus(e){return this._combinedMatching.triggerStatus(e)}triggerStatusNoSideEffects(e){return this._combinedMatching.triggerStatusNoSideEffects(e)}getPendingTriggerConditions(e){return"trigger_pending"!==this.triggerStatusNoSideEffects(e)?[]:[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===ba).map(({label:e})=>e)}checkEventTriggerConditions(e,t,i){this._eventTriggerMatching.checkEventTriggerConditions(e,t,i)}checkUrlTriggerConditions(e,t,i,n){this._urlTriggerMatching.checkUrlTriggerConditions(e,t,i,n)}activateTrigger(e,t){var i;const n="url"===e?_e+this.group.id:ge+this.group.id;null===(i=this._instance.persistence)||void 0===i||i.register({[n]:t})}stop(){this._urlTriggerMatching.stop(),this._eventTriggerMatching.stop(),this._linkedFlagMatching.stop()}};function La(e){if(e.rrwebError)return ma;if(!e.receivedFlags)return _a;if(!e.isRecordingEnabled)return ha;if(e.urlTriggerMatching.urlBlocked)return fa;const t=!0===e.isSampled,i=new Ta([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId);return t?pa:"trigger_activated"===i?ga:"trigger_pending"===i?_a:!1===e.isSampled?ha:ga}function Oa(e){if(e.rrwebError)return ma;if(!e.receivedFlags)return _a;if(!e.isRecordingEnabled)return ha;if(e.urlTriggerMatching.urlBlocked)return fa;const t=new xa([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId),i=t!==Sa,n=Lt(e.isSampled);return i&&"trigger_pending"===t?_a:i&&"trigger_disabled"===t||n&&!e.isSampled?ha:!0===e.isSampled?pa:ga}function Da(){const e=[];return function(t,i){if(Et(i)||kt(i)){for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(i)?"[Circular]":(e.push(i),i)}return i}}function $a(e){try{const t=JSON.stringify(e,Da());return t?new Blob([t]).size:0}catch(e){return-1}}function Na(e){if(Pt(e))return 4;if(xt(e))return 0;switch(typeof e){case"string":return e.length+2;case"number":return String(e).length;case"boolean":return e?4:5;case"object":{if(kt(e)){let t=2;for(let i=0;e.length>i;i++){i>0&&(t+=1);const n=e[i];t+=xt(n)||Pt(n)?4:Na(n)}return t}const t=e;let i=2,n=!0;for(const e in t){if(!{}.hasOwnProperty.call(t,e))continue;const s=t[e];xt(s)||(n||(i+=1),n=!1,i+=e.length+3+Na(s))}return i}default:return 0}}function Ba(e,t=6606028.8){if(e.size>=t&&e.data.length>1){const t=Math.floor(e.data.length/2),i=e.sizes.slice(0,t),n=e.sizes.slice(t);return[Ba({size:i.reduce((e,t)=>e+t,0),data:e.data.slice(0,t),sizes:i,sessionId:e.sessionId,windowId:e.windowId}),Ba({size:n.reduce((e,t)=>e+t,0),data:e.data.slice(t),sizes:n,sessionId:e.sessionId,windowId:e.windowId})].flatMap(e=>e)}return[e]}var qa=Uint8Array,Ha=Uint16Array,Ua=Uint32Array,za=new qa([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]),Wa=new qa([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]),ja=new qa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Va=function(e,t){for(var i=new Ha(31),n=0;31>n;++n)i[n]=t+=1<<e[n-1];var s=new Ua(i[30]);for(n=1;30>n;++n)for(var r=i[n];i[n+1]>r;++r)s[r]=r-i[n]<<5|n;return[i,s]},Ga=Va(za,2),Qa=Ga[1];Ga[0][28]=258,Qa[258]=28;for(var Ka=Va(Wa,0)[1],Ja=new Ha(32768),Ya=0;32768>Ya;++Ya){var Za=(43690&Ya)>>>1|(21845&Ya)<<1;Ja[Ya]=((65280&(Za=(61680&(Za=(52428&Za)>>>2|(13107&Za)<<2))>>>4|(3855&Za)<<4))>>>8|(255&Za)<<8)>>>1}var Xa=function(e,t,i){for(var n=e.length,s=0,r=new Ha(t);n>s;++s)++r[e[s]-1];var o,a=new Ha(t);for(s=0;t>s;++s)a[s]=a[s-1]+r[s-1]<<1;if(i){o=new Ha(1<<t);var l=15-t;for(s=0;n>s;++s)if(e[s])for(var c=s<<4|e[s],u=t-e[s],d=a[e[s]-1]++<<u,h=d|(1<<u)-1;h>=d;++d)o[Ja[d]>>>l]=c}else for(o=new Ha(n),s=0;n>s;++s)o[s]=Ja[a[e[s]-1]++]>>>15-e[s];return o},el=new qa(288);for(Ya=0;144>Ya;++Ya)el[Ya]=8;for(Ya=144;256>Ya;++Ya)el[Ya]=9;for(Ya=256;280>Ya;++Ya)el[Ya]=7;for(Ya=280;288>Ya;++Ya)el[Ya]=8;var tl=new qa(32);for(Ya=0;32>Ya;++Ya)tl[Ya]=5;var il=Xa(el,9,0),nl=Xa(tl,5,0),sl=function(e){return(e/8|0)+(7&e&&1)},rl=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof Ha?Ha:e instanceof Ua?Ua:qa)(i-t);return n.set(e.subarray(t,i)),n},ol=function(e,t,i){var n=t/8|0;e[n]|=i<<=7&t,e[n+1]|=i>>>8},al=function(e,t,i){var n=t/8|0;e[n]|=i<<=7&t,e[n+1]|=i>>>8,e[n+2]|=i>>>16},ll=function(e,t){for(var i=[],n=0;e.length>n;++n)e[n]&&i.push({s:n,f:e[n]});var s=i.length,r=i.slice();if(!s)return[new qa(0),0];if(1==s){var o=new qa(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],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=i[i[d].f>i[c].f?c++:d++],l=i[c!=u&&i[d].f>i[c].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(n=1;s>n;++n)r[n].s>h&&(h=r[n].s);var p=new Ha(h+1),g=cl(i[u-1],p,0);if(g>t){n=0;var _=0,f=g-t,v=1<<f;for(r.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});s>n;++n){var m=r[n].s;if(t>=p[m])break;_+=v-(1<<g-p[m]),p[m]=t}for(_>>>=f;_>0;){var y=r[n].s;t>p[y]?_-=1<<t-p[y]++-1:++n}for(;n>=0&&_;--n){var b=r[n].s;p[b]==t&&(--p[b],++_)}g=t}return[new qa(p),g]},cl=function(e,t,i){return-1==e.s?Math.max(cl(e.l,t,i+1),cl(e.r,t,i+1)):t[e.s]=i},ul=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ha(++t),n=0,s=e[0],r=1,o=function(e){i[n++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++r;else{if(!s&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(s),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(s);r=1,s=e[a]}return[i.subarray(0,n),t]},dl=function(e,t){for(var i=0,n=0;t.length>n;++n)i+=e[n]*t[n];return i},hl=function(e,t,i){var n=i.length,s=sl(t+2);e[s]=255&n,e[s+1]=n>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var r=0;n>r;++r)e[s+r+4]=i[r];return 8*(s+4+n)},pl=function(e,t,i,n,s,r,o,a,l,c,u){ol(t,u++,i),++s[256];for(var d=ll(s,15),h=d[0],p=d[1],g=ll(r,15),_=g[0],f=g[1],v=ul(h),m=v[0],y=v[1],b=ul(_),S=b[0],w=b[1],k=new Ha(19),C=0;m.length>C;++C)k[31&m[C]]++;for(C=0;S.length>C;++C)k[31&S[C]]++;for(var E=ll(k,7),T=E[0],x=E[1],I=19;I>4&&!T[ja[I-1]];--I);var R,P,M,F,A=c+5<<3,L=dl(s,el)+dl(r,tl)+o,O=dl(s,h)+dl(r,_)+o+14+3*I+dl(k,T)+(2*k[16]+3*k[17]+7*k[18]);if(L>=A&&O>=A)return hl(t,u,e.subarray(l,l+c));if(ol(t,u,1+(L>O)),u+=2,L>O){R=Xa(h,p,0),P=h,M=Xa(_,f,0),F=_;var D=Xa(T,x,0);for(ol(t,u,y-257),ol(t,u+5,w-1),ol(t,u+10,I-4),u+=14,C=0;I>C;++C)ol(t,u+3*C,T[ja[C]]);u+=3*I;for(var N=[m,S],B=0;2>B;++B){var q=N[B];for(C=0;q.length>C;++C)ol(t,u,D[H=31&q[C]]),u+=T[H],H>15&&(ol(t,u,q[C]>>>5&127),u+=q[C]>>>12)}}else R=il,P=el,M=nl,F=tl;for(C=0;a>C;++C)if(n[C]>255){var H;al(t,u,R[257+(H=n[C]>>>18&31)]),u+=P[H+257],H>7&&(ol(t,u,n[C]>>>23&31),u+=za[H]);var U=31&n[C];al(t,u,M[U]),u+=F[U],U>3&&(al(t,u,n[C]>>>5&8191),u+=Wa[U])}else al(t,u,R[n[C]]),u+=P[n[C]];return al(t,u,R[256]),u+P[256]},gl=new Ua([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),_l=new qa(0),fl=function(){for(var e=new Ua(256),t=0;256>t;++t){for(var i=t,n=9;--n;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),vl=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ml(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,n=0;t.length>n;++n)i=fl[255&i^t[n]]^i>>>8;e=i},d(){return 4294967295^e}}}(),n=e.length;i.p(e);var s,r,o,a,l,c=(s=e,r=t,o=function(e){return 10+(e.filename&&e.filename.length+1||0)}(t),a=8,function(e,t,i,n,s,r){var o=e.length,a=new qa(n+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(n,a.length-s),c=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?c=hl(l,c,e.subarray(u,d)):(l[u]=r,c=hl(l,c,e.subarray(u,o)))}else{for(var h=gl[t-1],p=h>>>13,g=8191&h,_=(1<<i)-1,f=new Ha(32768),v=new Ha(_+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&_},S=new Ua(25e3),w=new Ha(288),k=new Ha(32),C=0,E=0,T=(u=0,0),x=0,I=0;o>u;++u){var R=b(u),P=32767&u,M=v[R];if(f[P]=M,v[R]=P,u>=x){var F=o-u;if((C>7e3||T>24576)&&F>423){c=pl(e,l,0,S,w,k,E,T,I,u-I,c),T=C=E=0,I=u;for(var A=0;286>A;++A)w[A]=0;for(A=0;30>A;++A)k[A]=0}var L=2,O=0,D=g,N=P-M&32767;if(F>2&&R==b(u-N))for(var B=Math.min(p,F)-1,q=Math.min(32767,u),H=Math.min(258,F);q>=N&&--D&&P!=M;){if(e[u+L]==e[u+L-N]){for(var U=0;H>U&&e[u+U]==e[u+U-N];++U);if(U>L){if(L=U,O=N,U>B)break;var z=Math.min(N,U-2),W=0;for(A=0;z>A;++A){var j=u-N+A+32768&32767,V=j-f[j]+32768&32767;V>W&&(W=V,M=j)}}}N+=(P=M)-(M=f[P])+32768&32767}if(O){S[T++]=268435456|Qa[L]<<18|Ka[O];var G=31&Qa[L],Q=31&Ka[O];E+=za[G]+Wa[Q],++w[257+G],++k[Q],x=u+L,++C}else S[T++]=e[u],++w[e[u]]}}c=pl(e,l,r,S,w,k,E,T,I,u-I,c),r||(c=hl(l,c,_l))}return rl(a,0,n+sl(c)+s)}(s,null==r.level?6:r.level,null==r.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(s.length)))):12+r.mem,o,a,!l)),u=c.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&&vl(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var n=0;i.length>=n;++n)e[n+10]=i.charCodeAt(n)}}(c,t),vl(c,u-8,i.d()),vl(c,u-4,n),c}function yl(e,t){var i=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new qa(e.length+(e.length>>>1)),s=0,r=function(e){n[s++]=e},o=0;i>o;++o){if(s+5>n.length){var a=new qa(s+8+(i-o<<1));a.set(n),n=a}var l=e.charCodeAt(o);128>l||t?r(l):2048>l?(r(192|l>>>6),r(128|63&l)):l>55295&&57344>l?(r(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),r(128|l>>>12&63),r(128|l>>>6&63),r(128|63&l)):(r(224|l>>>12),r(128|l>>>6&63),r(128|63&l))}return rl(n,0,s)}function bl(e,t){var i="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var n=0;e.length>n;){var s=e[n++];128>s||t?i+=String.fromCharCode(s):224>s?i+=String.fromCharCode((31&s)<<6|63&e[n++]):240>s?i+=String.fromCharCode((15&s)<<12|(63&e[n++])<<6|63&e[n++]):(s=((15&s)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,i+=String.fromCharCode(55296|s>>10,56320|1023&s))}return i}var Sl=class{constructor(e,t={}){var i,n,s,r;this._rrweb=e,this._options=t,this._loggedTracker={},this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0,this._refillByteBudget=()=>{const e=Date.now(),t=e-this._lastByteRefill;t>0?(this._byteTokens=Math.min(this._bytesBucketSize,this._byteTokens+t/1e3*this._bytesRefillRate),this._lastByteRefill=e):this._lastByteRefill=e},this._onNodeRateLimited=e=>{if(!this._loggedTracker[e]){var t,i;this._loggedTracker[e]=!0;const n=this._getNode(e);null===(t=(i=this._options).onBlockedNode)||void 0===t||t.call(i,e,n)}},this._getNodeOrRelevantParent=e=>{const t=this._getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){const e=t.closest("svg");if(e)return[this._rrweb.mirror.getId(e),e]}return[e,t]},this._getNode=e=>this._rrweb.mirror.getNode(e),this._numberOfChanges=e=>{var t,i,n,s,r,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(n=null===(s=e.attributes)||void 0===s?void 0:s.length)&&void 0!==n?n:0)+(null!==(r=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==r?r:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)},this.throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;const t=e.data,i=this._numberOfChanges(t);if(t.attributes){const e=t.attributes.length;t.attributes=t.attributes.filter(e=>{const[t]=this._getNodeOrRelevantParent(e.id);return!this._rateLimiter.consumeRateLimit(t)&&e});const i=e-t.attributes.length;var n,s;i>0&&(null===(n=(s=this._options).onDroppedAttributeMutations)||void 0===n||n.call(s,i))}const r=this._numberOfChanges(t);if(0===r&&i!==r)return;if(this._byteBudgetDisabled)return e;this._refillByteBudget();const o=Na(e);var a,l;return o>this._byteTokens?(null===(a=(l=this._options).onDroppedOversizedMutation)||void 0===a||a.call(l,o),void this._scheduleResync()):(this._byteTokens-=o,e)},this._scheduleResync=()=>{if(this._resyncTimer)return;const e=Math.max(0,this._resyncIntervalMs-(Date.now()-this._lastResyncAt));this._resyncTimer=setTimeout(()=>{var e,t;this._resyncTimer=void 0,this._lastResyncAt=Date.now(),null===(e=(t=this._options).requestFullSnapshot)||void 0===e||e.call(t)},e)},this._rateLimiter=new Jt({bucketSize:null!==(i=this._options.bucketSize)&&void 0!==i?i:100,refillRate:null!==(n=this._options.refillRate)&&void 0!==n?n:10,refillInterval:1e3,_onBucketRateLimited:this._onNodeRateLimited,_logger:Nr}),this._bytesBucketSize=null!==(s=this._options.bytesBucketSize)&&void 0!==s?s:0,this._bytesRefillRate=null!==(r=this._options.bytesRefillRate)&&void 0!==r?r:25600,this._byteBudgetDisabled=!Number.isFinite(this._bytesBucketSize)||0>=this._bytesBucketSize,this._byteTokens=this._bytesBucketSize;const o=this._options.resyncIntervalMs;this._resyncIntervalMs=Ft(o)&&Number.isFinite(o)&&o>0?o:3e5}reset(){this._loggedTracker={},this._resyncTimer&&(clearTimeout(this._resyncTimer),this._resyncTimer=void 0),this._lastResyncAt=Date.now()}stop(){this._rateLimiter.stop(),this.reset(),this._byteTokens=this._bytesBucketSize,this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0}};const wl=e=>{if(n){try{const t=e+"=",i=n.cookie.split(";").filter(e=>e.length);for(let e=0;i.length>e;e++){let n=i[e];for(;" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(t))return decodeURIComponent(n.substring(t.length,n.length))}}catch(e){}return null}};var kl=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,n,s){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(n)||!Number.isInteger(s)||0>t||0>i||0>n||0>s||t>0xffffffffffff||i>4095||n>1073741823||s>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|i>>>8,r[7]=i,r[8]=128|n>>>24,r[9]=n>>>16,r[10]=n>>>8,r[11]=n,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new e(r)}toString(){let e="";for(let 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 e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;16>t;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},Cl=class{generate(){const e=this.generateOrAbort();if(!xt(e))return e;{this._timestamp=0;const e=this.generateOrAbort();if(xt(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){const e=(()=>{const e=Date.now();return Ft(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();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 kl.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new xl}};const El=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};let Tl;var xl=class{nextUint32(){var e;return this._buffer.length>this._cursor||((null!==(e=Tl)&&void 0!==e?e:Tl="u">typeof window&&!xt(window.crypto)&&crypto.getRandomValues?e=>{try{return crypto.getRandomValues(e)}catch(t){return El(e)}}:El)(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}};let Il;const Rl=()=>Pl().toString(),Pl=()=>(Il||(Il=new Cl)).generate();let Ml="";const Fl=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Al=null;const Ll={_is_supported(){if(!Pt(Al))return Al;if(Al=!1,n)try{const e=`__ph_cookie_support_${Rl()}`;Ll._set(e,"xyz"),Al='"xyz"'===wl(e),Ll._remove(e)}catch(e){Al=!1}return Al},_error(e){Nr.error("cookieStore error: "+e)},_get:wl,_parse(e){let t;try{t=JSON.parse(Ll._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(!n)return!1;try{let o="",a="";const l=function(e,t){if(t){let t=function(e,t=n){if(Ml)return Ml;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let s=Math.min(i.length,8);const r="dmn_chk_"+Rl();for(;!Ml&&s--;){const e=i.slice(s).join("."),n=r+"=1;domain=."+e+";path=/";t.cookie=n+";max-age=3",t.cookie.includes(r)&&(t.cookie=n+";max-age=0",Ml=e)}return Ml}(e);if(!t){const i=(e=>{const t=e.match(Fl);return t?t[0]:""})(e);i!==t&&Nr.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}(n.location.hostname,s);if(i){const e=new Date;e.setTime(e.getTime()+864e5*i),o="; expires="+e.toUTCString()}r&&(a="; secure");const c=e+"="+encodeURIComponent(JSON.stringify(t))+o+"; SameSite=Lax; path=/"+l+a;return c.length>3686.4&&Nr.warn("cookieStore warning: large cookie, len="+c.length),n.cookie=c,!0}catch(e){return!1}},_remove(e,t){if((null==n?void 0:n.cookie)&&(!t||!Pt(wl(e))))try{Ll._set(e,"",-1,t)}catch(e){return}}};let Ol=null;const Dl={_is_supported(){if(!Pt(Ol))return Ol;let t=!0;if(xt(e))t=!1;else try{const e="__mplssupport__";Dl._set(e,"xyz"),'"xyz"'!==Dl._get(e)&&(t=!1),Dl._remove(e)}catch(e){t=!1}return t||Nr.error("localStorage unsupported; falling back to cookie store"),Ol=t,t},_error(e){Nr.error("localStorage error: "+e)},_get(t){try{return null==e?void 0:e.localStorage.getItem(t)}catch(e){Dl._error(e)}return null},_parse(e){try{return JSON.parse(Dl._get(e))||{}}catch(e){}return null},_set(t,i){try{return null==e||e.localStorage.setItem(t,JSON.stringify(i)),!0}catch(e){Dl._error(e)}return!1},_remove(t){try{null==e||e.localStorage.removeItem(t)}catch(e){Dl._error(e)}}},$l=[S,p,y,g,C,v,f,_,w],Nl=[N,D,ce,ue,Ae,Fe,z,xe],Bl=e=>e+"_cpm",ql=["__proto__","constructor","prototype"],Hl=e=>{if(!Et(e))return{};const t={};return Object.keys(e).forEach(i=>{-1===ql.indexOf(i)&&(t[i]=e[i])}),t},Ul=(e,t=[])=>{const i={};return[...Nl,...t].forEach(t=>{const n=e[t];xt(n)||Pt(n)||""===n||(i[t]=n)}),i},zl=e=>{let t=5381,i=2166136261;for(let n=0;e.length>n;n++){const s=e.charCodeAt(n);t=33*t^s,i=Math.imul(i^s,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},Wl=(e,t)=>({p:t,f:zl(JSON.stringify(e))}),jl=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const i=Ll._parse(Bl(e)),n=(null==i?void 0:i.f)===zl(t)&&kt(i.p);return{properties:n?i.p:[],isValid:n}}catch(e){return{properties:[],isValid:!1}}},Vl=(e,t)=>t+"|"+(Ll._get(Bl(e))||""),Gl={},Ql={_is_supported:()=>!0,_error(e){Nr.error("memoryStorage error: "+e)},_get:e=>e in Gl?Gl[e]:null,_parse:e=>e in Gl?Gl[e]:null,_set:(e,t)=>(Gl[e]=t,!0),_remove(e){delete Gl[e]}};let Kl=null;const Jl={_is_supported(){if(!Pt(Kl))return Kl;if(Kl=!0,xt(e))Kl=!1;else try{const e="__support__";Jl._set(e,"xyz"),'"xyz"'!==Jl._get(e)&&(Kl=!1),Jl._remove(e)}catch(e){Kl=!1}return Kl},_error(e){Nr.error("sessionStorage error: ",e)},_get(t){try{return null==e?void 0:e.sessionStorage.getItem(t)}catch(e){Jl._error(e)}return null},_parse(e){try{return JSON.parse(Jl._get(e))||null}catch(e){}return null},_set(t,i){try{return null==e||e.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(e){Jl._error(e)}return!1},_remove(t){try{null==e||e.sessionStorage.removeItem(t)}catch(e){Jl._error(e)}}};Dr.DEBUG=!1,Dr.LIB_VERSION="1.447.1",Dr.LIB_NAME="web";var Yl=Dr,Zl=class{constructor(e){if(!e.persistence)throw new Error("it is not valid to not have persistence and be this far into setting up the application");this._getProperty=e.get_property.bind(e),this._setProperty=e.persistence.set_property.bind(e.persistence)}trackSize(e,t){this._setProperty(me,{sessionId:e,size:this.currentTrackedSize(e)+t})}currentTrackedSize(e){const t=this._getProperty(me);return Et(i=t)&&It(i.sessionId)&&Ft(i.size)&&t.sessionId===e?t.size:0;var i}};function Xl(e,t){return function(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<Kt(100*t,0,100,Nr)}function ec(e){return`$survey_response_${e}`}function tc(e,t){if(!t)return null;const i=e[ec(t)];return kt(i)?[...i]:i}function ic({event:e,survey:t,responses:i={},submissionId:n,completed:s,surveyLanguage:r,questionSnapshots:o}){return ct(ct(ct(ct({},!xt(n)&&{$survey_submission_id:n}),"sent"===e?!xt(s)&&{$survey_completed:s}:{$survey_partially_completed:nc(i)}),r&&{$survey_language:r}),function(e={},t,i){const n={};return t.questions.forEach(t=>{if(xt(t.originalQuestionIndex))return;const i=0===(s=t.originalQuestionIndex)?"$survey_response":`$survey_response_${s}`;var s;const r=tc(e,t.id);xt(r)||(n[i]=r)}),ct(ct({$survey_questions:t.questions.map(t=>{var n,s;return{id:t.id,question:null!==(n=null==i?void 0:i[null!==(s=t.id)&&void 0!==s?s:""])&&void 0!==n?n:t.question,response:tc(e,t.id)}})},e),n)}(i,t,o))}function nc(e={}){return Object.values(e).some(e=>!Mt(e))}function sc(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function rc(e){return"string"==typeof e&&e.trim()?e.trim():null}function oc(e){return e.toLowerCase()}function ac(e,t,i){if(!e||!t)return null;const n=oc(t),s=Object.keys(e).find(e=>oc(e)===n);if(s)return null==i||i.debug(`Found exact translation match: ${s}`),s;if(n.includes("-")){const s=n.split("-")[0],r=Object.keys(e).find(e=>oc(e)===s);if(r)return null==i||i.debug(`Found base language translation match: ${r} (from ${t})`),r}return null}const lc=["thankYouMessageHeader","thankYouMessageDescription","thankYouMessageCloseButtonText","introScreenHeader","introScreenDescription","introScreenButtonText","submitButtonText","backButtonText"];function cc(e,t,i){var n;const s=ac(e.translations,t,i),r=ct({},e);let o=!1;if(s){var a;const t=null===(a=e.translations)||void 0===a?void 0:a[s];if(t)if(null==i||i.info(`Applying survey-level translation for language: ${s}`),xt(t.name)||(r.name=t.name,o=!0),r.appearance){const e=ct({},r.appearance);for(const i of lc){const n=t[i];xt(n)||(e[i]=n,o=!0)}r.appearance=e}else(function(e){return lc.some(t=>!xt(e[t]))})(t)&&(o=!0)}const l=e.questions.map(e=>function(e,t,i){var n;const s=ac(e.translations,t,i);if(!s)return{question:e,matchedKey:null,hasChanges:!1};const r=null===(n=e.translations)||void 0===n?void 0:n[s];if(!r)return{question:e,matchedKey:null,hasChanges:!1};const o=ct({},e);let a=!1;return xt(r.question)||(o.question=r.question,a=!0),xt(r.description)||(o.description=r.description,a=!0),xt(r.buttonText)||(o.buttonText=r.buttonText,a=!0),"link"in o&&!xt(r.link)&&(o.link=r.link,a=!0),"lowerBoundLabel"in o&&!xt(r.lowerBoundLabel)&&(o.lowerBoundLabel=r.lowerBoundLabel,a=!0),"upperBoundLabel"in o&&!xt(r.upperBoundLabel)&&(o.upperBoundLabel=r.upperBoundLabel,a=!0),"choices"in o&&function(e){return kt(e.choices)}(r)&&(o.choices=r.choices,a=!0),{question:a?o:e,matchedKey:a?s:null,hasChanges:a}}(e,t,i)),c=l.map(e=>e.question),u=l.some(e=>e.hasChanges);let d=null;return s||(d=(null===(n=l.find(e=>e.matchedKey))||void 0===n?void 0:n.matchedKey)||null),u&&(r.questions=c,o=!0,null==i||i.info(`Applied question-level translations for language: ${t}`)),{survey:r,matchedKey:o?s||d:null}}function uc(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}function dc(e){var t;return uc(e)&&!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t?void 0:t.repeatedActivation)||"always"===e.schedule}const hc=(e,t)=>{if(!(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}},pc=e=>e.toLowerCase(),gc={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=>hc(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!hc(t,e))),icontains:(e,t)=>t.map(pc).some(t=>e.map(pc).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(pc).every(t=>e.map(pc).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function _c(e,t){return!e||Object.entries(e).every(([e,i])=>{const n=null==t?void 0:t[e];if(null==n)return!1;const s=gc[i.operator];return!!s&&s(i.values.map(String),[String(n)])})}const fc=e=>{const t=[...e];for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}return t};function vc(e,t,i){return io({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}const mc=new Set(["is_not","not_icontains","not_regex"]);function yc(e,t,i){return!e||0===e.length||e.every(e=>{const n="person"===e.type?i:t,s=null==n?void 0:n[e.key],r=e.operator||"exact";if(xt(s)||Pt(s))return mc.has(r);const o=gc[r];return!!o&&!xt(e.value)&&!Pt(e.value)&&o(kt(e.value)?e.value.map(String):[String(e.value)],kt(s)?s.map(String):[String(s)])})}const bc=Br("[SessionRecording]");function Sc(e,t){return t?e:"!"+e}function wc(e,t){return e===t||e!=="!"+t&&null}var kc=class{constructor(e,t,i,n,s,r,o){this._instance=e,this._urlTriggerMatching=t,this._eventTriggerMatching=i,this._linkedFlagMatching=n,this._reportStarted=s,this._tryTakeFullSnapshot=r,this._onTriggerActivated=o,this._sampleRate=null,this._recordingStatusFunction=Oa}onRemoteConfig(e){this._sampleRate=Ft(e.sampleRate)?e.sampleRate:null,"any"===e.triggerMatchType?(this._triggerStatusMatcher=new Ta([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=La):(this._triggerStatusMatcher=new xa([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=Oa),this._instance.register_for_session({[We]:e.triggerMatchType}),this._urlTriggerMatching.onConfig(e),this._eventTriggerMatching.onConfig(e),this._linkedFlagMatching.onConfig(e,(e,t)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:t}),this._onTriggerActivated()})}getStatus(e){return this._recordingStatusFunction({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId})}getMinimumDuration(e){const t=this._instance.get_property("$session_recording_remote_config"),i=null==t?void 0:t.minimumDurationMilliseconds;return Ft(i)?i:null}checkUrlTriggers(e,t,i,n){this._urlTriggerMatching.checkUrlTriggerConditions(t,i,n,e)}setupEventTriggerListeners(e,t,i){if(0!==this._eventTriggerMatching._eventTriggers.length&&Mt(this._removeEventTriggerCaptureHook))return this._removeEventTriggerCaptureHook=e(e=>{try{this._eventTriggerMatching.checkEventTriggerConditions(e.event,i,t)}catch(e){bc.error("Could not activate event trigger",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){var t;const i=this._sampleRate;var n,s;if(!Ft(i))return null===(n=this._instance.persistence)||void 0===n||n.unregister("$session_is_sampled"),void(null===(s=this._instance.persistence)||void 0===s||s.unregister("$replay_sample_rate"));const r=this._instance.get_property(ue),o=this._instance.get_property(se),a=wc(r,e),l=Ft(o)&&o!==i,c=xt(o)&&r===e,u=l||c||!Lt(a),d=u?Xl(e,i):a;u&&(d?this._reportStarted("sampled"):bc.warn(`Sample rate (${i}) has determined that this sessionId (${e}) will not be sent to the server.`)),null===(t=this._instance.persistence)||void 0===t||t.register({$session_is_sampled:Sc(e,d),$replay_sample_rate:Pt(o)&&r===e?null:i})}ensureSamplingDecision(e){if(!Ft(this._sampleRate))return;const t=this._instance.get_property(ue);Lt(wc(t,e))||this.makeSamplingDecisions(e)}onFlushComplete(){}clearConditionalRecordingPersistence(){var e,t,i,n,s;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_recording_event_trigger_activated_session"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$session_recording_url_trigger_activated_session"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_is_sampled"),null===(n=this._instance.persistence)||void 0===n||n.unregister("$replay_sample_rate"),null===(s=this._instance.persistence)||void 0===s||s.unregister("$session_past_minimum_duration")}updateActiveTriggers(e){}hasPendingTriggers(e){var t;return(null===(t=this._triggerStatusMatcher)||void 0===t?void 0:t.triggerStatus(e))===ba}getPendingTriggerConditions(e){return[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===ba).map(({label:e})=>e)}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._eventTriggerMatching.stop(),this._urlTriggerMatching.stop(),this._linkedFlagMatching.stop()}},Cc=class{constructor(e,t,i,n,s){this._instance=e,this._urlTriggerMatching=t,this._reportStarted=i,this._tryAddCustomEvent=n,this._onTriggerActivated=s,this._triggerGroupMatchers=[],this._triggerGroupSamplingResults=new Map,this._hasCompletedInitialFlush=!1}onRemoteConfig(e){e.triggerGroups&&0!==e.triggerGroups.length?(this._setupTriggerGroups(e.triggerGroups),this._instance.register_for_session({[We]:"v2_trigger_groups",[je]:e.triggerGroups.length}),this._urlTriggerMatching.onConfig(e)):bc.warn("[V2Strategy] No trigger groups configured")}getStatus(e){return function(e){if(e.rrwebError)return ma;if(!e.receivedFlags)return _a;if(!e.isRecordingEnabled)return ha;if(e.urlTriggerMatching.urlBlocked)return fa;const t=e.triggerGroupMatchers,i=e.triggerGroupSamplingResults;if(0===t.length)return ha;let n=!1,s=!1;for(const r of t){const t=r.triggerStatus(e.sessionId);if("trigger_activated"===t){const e=r.group.id,t=i.get(e);xt(t)?Nr.warn("[V2 Triggers] Group activated but no sampling decision found",{groupId:e}):!0===t&&(s=!0)}else"trigger_pending"===t&&(n=!0)}return s?pa:n?_a:ha}({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId,triggerGroupMatchers:this._triggerGroupMatchers,triggerGroupSamplingResults:this._triggerGroupSamplingResults,minimumDuration:this.getMinimumDuration(e.sessionId)})}getMinimumDuration(e){let t=null;for(const i of this._triggerGroupMatchers)if("trigger_activated"===i.triggerStatus(e)){const e=i.group.minDurationMs;Ft(e)&&(Pt(t)||t>e)&&(t=e)}return t}checkUrlTriggers(e,t,i,n){this._urlTriggerMatching.checkUrlBlocklist(t,i);for(const n of this._triggerGroupMatchers)n.checkUrlTriggerConditions(t,i,t=>{this._checkGroupLevelProperties(n,void 0)&&(n.activateTrigger(t,e),this.updateActiveTriggers(e),this._onTriggerActivated(t))},e)}setupEventTriggerListeners(e,t,i){return this._removeEventTriggerCaptureHook=e(e=>{var i;if(this._hasCompletedInitialFlush)return bc.info("[SessionRecorder] Stopping trigger checks - initial buffer flushed"),null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),void(this._removeEventTriggerCaptureHook=void 0);try{for(const i of this._triggerGroupMatchers)i.checkEventTriggerConditions(e.event,n=>{if(!this._checkGroupLevelProperties(i,e.properties))return;const s=(i.group.conditions.events||[]).filter(t=>t.name===e.event),r=this._instance.get_property(S);s.some(t=>!t.properties||0===t.properties.length||yc(t.properties,e.properties,r))&&(i.activateTrigger(n,t),this.updateActiveTriggers(t),this._onTriggerActivated(n))},t)}catch(e){bc.error("Could not activate event trigger for trigger groups",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){for(const i of this._triggerGroupMatchers){var t;const n=i.group,s=n.id,r=n.sampleRate,o=fe+s,a=this._instance.get_property(o);let l=null,c=!1,u=!1,d=!1;if(Et(a)){const t=a.sessionId,i=a.sampleRate,n=a.sampled;c="string"==typeof t&&t!==e,u=Ft(i)&&i!==r,l=t===e&&Ft(i)&&i===r&&Lt(n)?n:null}else l=a===e||null,c="string"==typeof a&&a!==e,d=a===e;const h=c||u||d||!Lt(l),p=h?Xl(e+s,r):l;h&&this._tryAddCustomEvent("triggerGroupSamplingDecisionMade",{group_id:s,group_name:n.name,sampleRate:r,isSampled:p}),this._triggerGroupSamplingResults.set(s,p),null===(t=this._instance.persistence)||void 0===t||t.register({[o]:{sessionId:e,sampleRate:r,sampled:p}})}this.updateActiveTriggers(e)}ensureSamplingDecision(e){}onFlushComplete(){this._hasCompletedInitialFlush=!0}clearConditionalRecordingPersistence(){var e,t,i;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$replay_sample_rate"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_past_minimum_duration");for(const e of this._triggerGroupMatchers){var n,s,r;const t=e.group.id;null===(n=this._instance.persistence)||void 0===n||n.unregister("$posthog_sr_group_event_trigger_"+t),null===(s=this._instance.persistence)||void 0===s||s.unregister("$posthog_sr_group_url_trigger_"+t),null===(r=this._instance.persistence)||void 0===r||r.unregister("$posthog_sr_group_sampling_"+t)}}updateActiveTriggers(e){const t=[];for(const i of this._triggerGroupMatchers){const n=i.group,s=n.id,r="trigger_activated"===i.triggerStatus(e),o=!0===this._triggerGroupSamplingResults.get(s);r&&t.push({id:s,name:n.name,matched:!0,sampled:o})}this._instance.register_for_session({[Ue]:t})}hasPendingTriggers(e){for(const t of this._triggerGroupMatchers)if("trigger_pending"===t.triggerStatus(e))return!0;return!1}getPendingTriggerConditions(e){return this._triggerGroupMatchers.flatMap(t=>"trigger_pending"!==t.triggerStatusNoSideEffects(e)?[]:t.getPendingTriggerConditions(e).map(e=>`trigger group "${t.group.name}": ${e}`))}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear(),this._urlTriggerMatching.stop()}_checkGroupLevelProperties(e,t){const i=e.group.conditions.properties;return!i||0===i.length||yc(i,t,this._instance.get_property(S))}_setupTriggerGroups(e){this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear();for(const t of e){const e=new Aa(this._instance,t,(e,i)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:i,group_id:t.id,group_name:t.name}),this._onTriggerActivated()});this._triggerGroupMatchers.push(e)}}};function Ec(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}const Tc=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],xc=(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Tc])(),Ic="<masked>",Rc=["li_fat_id"];function Pc(e,t,i){if(!n)return{};const s=t?[...Tc,...i||[]]:[],r=Mc(ro(n.URL,s,Ic),e),o=function(){const e={};return Hr(Rc,function(t){const i=wl(t);e[t]=i||null}),e}();return Ur(o,r)}function Mc(e,t){const i=xc.concat(t||[]),n={};return Hr(i,function(t){const i=so(e,t);n[t]=i||null}),n}function Fc(e){const t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!Pt(t)){s.$search_engine=t;const e=n?so(n.referrer,i):"";e.length&&(s.ph_keyword=e)}return s}function Ac(){return navigator.language||navigator.userLanguage}function Lc(){const e=Ac();return"string"==typeof e?e.split("-")[0]:void 0}const Oc="$direct";function Dc(){return(null==n?void 0:n.referrer)||Oc}function $c(e,t,i=!1){const n=e?[...Tc,...t||[]]:[],r=i?cn(null==s?void 0:s.href):null==s?void 0:s.href,o=null==r?void 0:r.substring(0,1e3);return{r:Dc().substring(0,1e3),u:o?ro(o,n,Ic):void 0}}function Nc(e,t=!1){var i;const{r:n,u:s}=e,r=t?cn(s):s,o={$referrer:n,$referring_domain:null==n?void 0:n==Oc?Oc:null===(i=Yr(n))||void 0===i?void 0:i.host};if(r){o.$current_url=r;const e=Yr(r);o.$host=null==e?void 0:e.host,o.$pathname=null==e?void 0:e.pathname;const t=Mc(r);Ur(o,t)}if(n){const e=Fc(n);Ur(o,e)}return o}function Bc(){try{return(new Date).getTimezoneOffset()}catch(e){return}}const qc=1e5,Hc=/^[A-Za-z0-9]*[A-Za-z][A-Za-z0-9]*$/,Uc=[],zc=()=>!1,Wc="@type @id actionStatus availability bestRating contentRating encodingFormat eventAttendanceMode eventStatus highPrice inLanguage isAccessibleForFree isFamilyFriendly itemCondition itemListOrder lowPrice maximumAttendeeCapacity nonprofitStatus numberOfItems offerCount position price priceCurrency priceValidUntil publicAccess ratingCount ratingValue reviewCount smokingAllowed worstRating".split(" "),jc="Action BorrowAction ReadAction SearchAction SeekToAction SolveMathAction WatchAction".split(" "),Vc="AutoDealer Bakery BarOrPub CafeOrCoffeeShop CollegeOrUniversity Corporation DaySpa Dentist EducationalOrganization Electrician FoodEstablishment GovernmentOrganization HealthClub Hotel LegalService Library LibrarySystem LocalBusiness Locksmith LodgingBusiness MedicalBusiness NGO OnlineStore Organization PerformingGroup Pharmacy Physician Plumber RealEstateAgent Restaurant School SportsOrganization Store".split(" "),Gc="Accommodation AdministrativeArea Country Place State".split(" "),Qc={AggregateOffer:{offers:["Offer"]},Brand:{name:!0},BreadcrumbList:{itemListElement:["ListItem"]},CreativeWork:{genre:!0,dateCreated:!0,dateModified:!0,datePublished:!0,expires:!0,learningResourceType:!0,educationalLevel:!0,educationalUse:!0,interactivityType:!0,aggregateRating:["AggregateRating"],potentialAction:jc,publisher:Vc},Event:{startDate:!0,endDate:!0,previousStartDate:!0,aggregateRating:["AggregateRating"],offers:["AggregateOffer","Offer"]},ItemList:{itemListElement:["ListItem"]},ListItem:{item:Uc},Offer:{seller:Vc},Organization:{name:!0,legalName:!0,foundingDate:!0,dissolutionDate:!0,aggregateRating:["AggregateRating"],brand:["Brand"]},Place:{aggregateRating:["AggregateRating"]},Product:{name:!0,sku:!0,mpn:!0,gtin:!0,gtin8:!0,gtin12:!0,gtin13:!0,gtin14:!0,productID:!0,productGroupID:!0,asin:!0,model:!0,category:!0,color:!0,material:!0,pattern:!0,size:!0,productionDate:!0,releaseDate:!0,brand:["Brand","Organization"],manufacturer:Vc,offers:["Offer","AggregateOffer"],aggregateRating:["AggregateRating"]},Service:{name:!0,serviceType:!0,category:!0,provider:Vc,areaServed:Gc,offers:["AggregateOffer","Offer"],aggregateRating:["AggregateRating"]},OfferCatalog:{name:!0,itemListElement:Uc}},Kc=[["3DModel AboutPage Answer Article AudioObject Blog BlogPosting Book Clip CollectionPage Comment ContactPage Course CreativeWorkSeason CreativeWorkSeries DataCatalog DataDownload DataFeed Dataset DiscussionForumPosting Episode FAQPage Game HowTo HowToDirection HowToSection HowToStep HowToTip ImageObject LearningResource MediaObject Message MobileApplication Movie MusicPlaylist MusicRecording NewsArticle Photograph PodcastEpisode PodcastSeries ProfilePage QAPage Question Quiz Recipe Review ScholarlyArticle SearchResultsPage SiteNavigationElement SocialMediaPosting SoftwareApplication TVEpisode TVSeries TechArticle VacationRental VideoGame VideoObject WebApplication WebPage WebPageElement WebSite".split(" "),Qc.CreativeWork],["BroadcastEvent BusinessEvent EducationEvent Festival MusicEvent SportsEvent TheaterEvent".split(" "),Qc.Event],[Vc,Qc.Organization],[Gc,Qc.Place],["Car IndividualProduct ProductGroup ProductModel".split(" "),Qc.Product]];function Jc(e,t){return St.call(e,t)?e[t]:void 0}function Yc(e){const t=typeof e;return Pt(e)||"string"===t||"number"===t||"boolean"===t}function Zc(e,t){return t&&function(e){return It(e)&&/^(https?:\/\/|\/|\.\.?\/)/i.test(e.trim())}(e)?t(e.trim())||void 0:e}function Xc(e,t){return kt(e)&&e.every(Yc)?e.map(e=>Zc(e,t)).filter(e=>!xt(e)):Yc(e)?Zc(e,t):void 0}function eu(e,t){if("string"!=typeof e)return;const i=e.trim(),n=i.indexOf("#"),s=0>n?i:i.slice(n+1);if(!(!s||0>n&&(/^[a-z][a-z\d+.-]*:/i.test(i)||i.includes("/")||i.includes("?"))))try{return t(s)?s:void 0}catch(e){return}}function tu(e){if(St.call(Qc,e))return Qc[e];for(const[t,i]of Kc)if(t.includes(e))return i}function iu(e,t,i){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0})}function nu(e,t,i,n){if(kt(e)){const s=e.map(e=>nu(e,t,i,n)).filter(e=>!xt(e));return s.length?s:void 0}return su(e,t,i,n)||void 0}function su(e,t,i,n){if(!Et(e)||!function(e){return e.remainingNodes?(e.remainingNodes--,!0):(e.exceeded=!0,!1)}(i))return null;const s=Jc(e,"@type"),r=function(e){const t=new Set,i="string"==typeof e?[e]:kt(e)?e:[],n=[];for(const e of i){if("string"!=typeof e)continue;const i=e.replace(/^https?:\/\/schema\.org\//,"");if(100>=i.length&&Hc.test(i)&&!t.has(i)&&(t.add(i),n.push(i),20===n.length))break}return n}(s),o=r.filter(e=>!!tu(e)&&(!n||!n.length||n.includes(e))),a={};for(const n of Wc){const o="@type"===n?r.length?"string"==typeof s?r[0]:r:void 0:"@id"===n?eu(Jc(e,n),t):Xc(Jc(e,n),i.maskUrl);xt(o)||iu(a,n,o)}for(const n of o){const s=tu(n);for(const n of Object.keys(s)){const r=Jc(e,n),o=s[n];if(!0===o){const e=Xc(r,i.maskUrl);xt(e)||iu(a,n,e)}else{const e=nu(r,t,i,o);xt(e)||iu(a,n,e)}}}const l=nu(Jc(e,"@graph"),t,i);return xt(l)||iu(a,"@graph",l),Object.keys(a).length?a:null}function ru(e,t,i){if(!Et(e))return null;const n=Jc(e,"@context");if("string"!=typeof n||!/^https?:\/\/schema\.org\/?$/.test(n))return null;const s=su(e,t,i);return s?ct({"@context":"https://schema.org"},s):null}function ou(e){var t;return"SCRIPT"===e.nodeName&&"application/ld+json"===(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.trim().toLowerCase())}function au(e,t,i){if("string"==typeof t?e.classList.contains(t):t&&Array.from(e.classList).some(e=>(t.lastIndex=0,t.test(e))))return!0;try{return!!i&&e.matches(i)}catch(e){return!1}}function lu(e,t,i){for(let n=e;n;){if(au(n,t,i))return!0;const e=n.parentNode;n=n.parentElement||(e&&e.nodeType===e.DOCUMENT_FRAGMENT_NODE?e.host:null)}return!1}function cu(e){return ou(e)?[e]:e.nodeType!==e.ELEMENT_NODE?[]:Array.from(e.querySelectorAll("script")).filter(ou)}function uu(e){return Et(e)?e.network_timing:e}const du=Br("[SessionRecording]"),hu=[1,2,3,4,5,6,7,12],pu=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function gu(){var e;return null==d||null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.rrweb}function _u(){var e;return null===(e=gu())||void 0===e?void 0:e.record}function fu(e){try{return JSON.stringify(e)}catch(t){if(t instanceof RangeError)throw t;return JSON.stringify(e,Da())}}function vu(e){return bl(ml(yl(fu(e))),!0)}function mu(e){return yu.apply(this,arguments)}function yu(){return(yu=rt(function*(e){const t=yield vs(fu(e),Yl.DEBUG,{rethrow:!0});return bl(new Uint8Array(yield t.arrayBuffer()),!0)})).apply(this,arguments)}let bu,Su;const wu="undefined"!=typeof globalThis&&"CompressionStream"in globalThis&&"TextEncoder"in globalThis&&"Response"in globalThis&&"function"==typeof Response.prototype.blob;let ku=!1;function Cu(e){var t;return kt(e)&&0===e.length?(bu=null!==(t=bu)&&void 0!==t?t:vu([]),bu):vu(e)}function Eu(e){return Tu.apply(this,arguments)}function Tu(){return(Tu=rt(function*(e){var t;return kt(e)&&0===e.length?bu||(Su=null!==(t=Su)&&void 0!==t?t:mu([]).then(e=>(bu=e,e)).catch(e=>{throw bu=void 0,Su=void 0,e}),Su):mu(e)})).apply(this,arguments)}function xu(e){return wu&&!ku&&function(e){return 2===e.type||3===e.type&&(0===e.data.source||8===e.data.source)}(e)}function Iu(e){return{event:e,size:Na(e)}}function Ru(e,t){return ct(ct({},e),{},{data:t,cv:"2024-10"})}function Pu(e,t){return ct(ct({},e),{},{cv:"2024-10",data:ct(ct({},e.data),t)})}function Mu(e){try{if(2===e.type)return Iu(Ru(e,vu(e.data)));if(3===e.type&&0===e.data.source)return Iu(Pu(e,{texts:Cu(e.data.texts),attributes:Cu(e.data.attributes),removes:Cu(e.data.removes),adds:Cu(e.data.adds)}));if(3===e.type&&8===e.data.source)return Iu(Pu(e,{adds:e.data.adds?vu(e.data.adds):void 0,removes:e.data.removes?vu(e.data.removes):void 0}))}catch(e){du.warn("could not compress event - will use uncompressed event",e)}return{event:e,size:$a(e)}}function Fu(){return Fu=rt(function*(e){try{if(2===e.type)return Iu(Ru(e,yield mu(e.data)));if(3===e.type&&0===e.data.source){const[t,i,n,s]=yield Promise.all([Eu(e.data.texts),Eu(e.data.attributes),Eu(e.data.removes),Eu(e.data.adds)]);return Iu(Pu(e,{texts:t,attributes:i,removes:n,adds:s}))}if(3===e.type&&8===e.data.source){const[t,i]=yield Promise.all([e.data.adds?mu(e.data.adds):void 0,e.data.removes?mu(e.data.removes):void 0]);return Iu(Pu(e,{adds:t,removes:i}))}}catch(t){return ps(t)&&(ku=!0),du.warn("could not compress event asynchronously - trying synchronous compression",t),Mu(e)}return{event:e,size:$a(e)}}),Fu.apply(this,arguments)}function Au(e,t){return 5===e.type&&e.data.tag===t}function Lu(e){return Au(e,"sessionIdle")}function Ou(e){return Au(e,"$session_ending")}function Du(e){return Au(e,"$session_starting")}var $u=class{get sessionId(){return this._sessionId}get _sessionManager(){if(!this._instance.sessionManager)throw new Error("[SessionRecording] must be started with a valid sessionManager.");return this._instance.sessionManager}get _sessionIdleThresholdMilliseconds(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get _isSampled(){return wc(this._instance.get_property(ue),this.sessionId)}get _sampleRate(){var e;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.sampleRate;return Ft(t)?t:null}get _minimumDuration(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getMinimumDuration(this.sessionId))&&void 0!==e?e:null}constructor(e,t){this._instance=e,this._endpoint="/s/",this._forceAllowLocalhostNetworkCapture=!1,this._stopRrweb=void 0,this._jsonLdCaptureReady=!1,this._lastActivityTimestamp=Date.now(),this._isActivatingTrigger=!1,this._queuedRRWebEvents=[],this._isIdle="unknown",this._eventsDroppedWhileIdle=0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,this._unstringifiableEventsDropped=0,this._holdFlushUntilInteraction=!1,this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed=!1,this._suppressNextFreshStartHold=!1,this._rrwebError=!1,this._rrwebStartAttempted=!1,this._snapshotCostErrorLogged=!1,this._hasWarnedClientMaskingOverride=!1,this._hasWarnedExclusiveAttributeMasking=!1,this._maskRegionsFnFailed=!1,this._hasLoggedRecorderCallbackError=!1,this._lastFullSnapshotSessionId=void 0,this._fullSnapshotHealAttemptedFor=void 0,this._pendingBufferRestored=!1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueueGeneration=0,this._isStoppingAfterCompression=!1,this._removePageViewCaptureHook=void 0,this._removeEventTriggerCaptureHook=void 0,this._onSessionIdListener=void 0,this._onSessionIdleResetForcedListener=void 0,this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback=(e,t,i)=>{var n,s,r,o;if(!i)return;if(e===this._sessionId&&t===this._windowId)return;const a=!i.noSessionId&&(i.activityTimeout||i.sessionPastMaximumLength),l=this._sessionId,c=this._windowId;var u;if(a&&this._tryAddCustomEvent("$session_ending",{currentSessionId:l,currentWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp,flushed_size:null===(u=this._flushedSizeTracker)||void 0===u?void 0:u.currentTrackedSize(l)}),null===(n=this._instance.persistence)||void 0===n||n.unregister("$debug_first_full_snapshot_timestamp"),null===(s=gu())||void 0===s||null===(r=s.resetMaxDepthState)||void 0===r||r.call(s),this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),this._clearConditionalRecordingPersistence(),!(!1===this._isIdle&&this.isStarted||this._sessionId===e&&this._windowId===t)){const t=this._sessionId!==e&&!1!==this._isIdle;this._isIdle="unknown",this._restartForSessionIdChange(t)}a&&this._tryAddCustomEvent("$session_starting",{previousSessionId:l,previousWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp}),null===(o=this._strategy)||void 0===o||o.makeSamplingDecisions(e)},this._isRestartingForSessionIdChange=!1,this._hasPassedMinimumDuration=()=>{var e;return(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[de])===this._sessionId},this._getBufferDuration=()=>{var e,t;if(0===this._buffer.data.length)return null;const i=null===(e=this._buffer.data[0])||void 0===e?void 0:e.timestamp,n=null===(t=this._buffer.data[this._buffer.data.length-1])||void 0===t?void 0:t.timestamp;return Ft(i)&&Ft(n)?n-i:null},this._isBelowMinimumDuration=()=>{var e,t;const i=this._minimumDuration;if(!Ft(i))return!1;if(null===(e=null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.strictMinimumDuration)||void 0===e||!e){const e=this._sessionDuration;return Ft(e)&&e>=0&&i>e}if(this._hasPassedMinimumDuration())return!1;const n=this._getBufferDuration();return!!Pt(n)||i>n||(null===(s=this._instance.persistence)||void 0===s||s.register({$session_past_minimum_duration:this._sessionId}),!1);var s},this._onBeforeUnload=()=>{"buffering"!==this.status?(this._holdFlushUntilInteraction&&this._heldEpochShipsOnUnload&&this._documentWasEverVisible&&(this._setFlushHold(void 0),this._heldBufferOverflowed&&(this._heldBufferOverflowed=!1,this._tryTakeFullSnapshot())),this._drainCompressionQueueSync(),this._flushBuffer(!0)):this._clearBuffer()},this._onPageHide=()=>{this._onBeforeUnload()},this._onOffline=()=>{this._tryAddCustomEvent("browser offline",{})},this._onOnline=()=>{this._tryAddCustomEvent("browser online",{})},this._onVisibilityChange=()=>{(null==n?void 0:n.visibilityState)&&("visible"===n.visibilityState&&(this._documentWasEverVisible=!0),this._tryAddCustomEvent("window "+n.visibilityState,{}))},this._documentWasEverVisible=null==t||t;const{sessionId:i,windowId:s,sessionStartTimestamp:r}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=i,this._windowId=s,this._sessionStartTimestamp=r,this._linkedFlagMatching=new Ma(this._instance),this._urlTriggerMatching=new Pa(this._instance),this._eventTriggerMatching=new Fa(this._instance),this._buffer=this._clearBuffer(),this._pendingBufferStorageKey="ph_replay_pending_buffer_"+JSON.stringify([this._instance.config.persistence_name||this._instance.config.token,this._instance.config.token]),this._sessionManager.sessionTimeoutMs>this._sessionIdleThresholdMilliseconds||du.warn(`session_idle_threshold_ms (${this._sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this._sessionManager.sessionTimeoutMs}). Session will never be detected as idle`),this._flushedSizeTracker=new Zl(this._instance)}setDocumentWasEverVisible(e){e&&(this._documentWasEverVisible=!0)}get _masking(){var e,t,i,n,s,r,o,a,l;const c=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking,u={maskAllInputs:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.maskAllInputs,maskTextSelector:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.maskTextSelector,blockSelector:null===(n=this._instance.config.session_recording)||void 0===n?void 0:n.blockSelector,maskAllElementAttributes:null===(s=this._instance.config.session_recording)||void 0===s?void 0:s.maskAllElementAttributes},d=null!==(r=null==u?void 0:u.maskAllInputs)&&void 0!==r?r:null==c?void 0:c.maskAllInputs,h=null!==(o=null==u?void 0:u.maskTextSelector)&&void 0!==o?o:null==c?void 0:c.maskTextSelector,p=null!==(a=null==u?void 0:u.blockSelector)&&void 0!==a?a:null==c?void 0:c.blockSelector,g=null!==(l=null==u?void 0:u.maskAllElementAttributes)&&void 0!==l?l:null==c?void 0:c.maskAllElementAttributes;return xt(d)&&xt(h)&&xt(p)&&xt(g)?void 0:{maskAllInputs:null==d||d,maskTextSelector:h,blockSelector:p,maskAllElementAttributes:g}}_warnIfClientMaskingShadowsServer(){var e;if(this._hasWarnedClientMaskingOverride)return;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking;if(Mt(t))return;const i=this._instance.config.session_recording,n=["maskAllInputs","maskTextSelector","blockSelector","maskAllElementAttributes"].filter(e=>{const n=null==i?void 0:i[e],s=t[e];return!xt(n)&&n!==s});0!==n.length&&(this._hasWarnedClientMaskingOverride=!0,du.warn('Session recording masking is configured both in `posthog.init` and in your project settings, and they differ. The `session_recording` options in `posthog.init` take precedence, so the project ("Privacy and masking") setting is ignored for: '+n.join(", ")+". Remove these masking options from `posthog.init` to use the project setting instead. See https://posthog.com/docs/session-replay/privacy",{client:{maskAllInputs:null==i?void 0:i.maskAllInputs,maskTextSelector:null==i?void 0:i.maskTextSelector,blockSelector:null==i?void 0:i.blockSelector,maskAllElementAttributes:null==i?void 0:i.maskAllElementAttributes},project:t}))}get _canvasResolutionScale(){var e;return Kt(null===(e=this._instance.config.session_recording.canvasCapture)||void 0===e?void 0:e.resolutionScale,.1,1,Br("canvas recording resolution scale"),1)}get _canvasRecording(){var e,t,i,n,s,r,o;const a=this._instance.config.session_recording.captureCanvas,l=null===(e=this._remoteConfig)||void 0===e?void 0:e.canvasRecording,c=null!==(t=null!==(i=null==a?void 0:a.recordCanvas)&&void 0!==i?i:null==l?void 0:l.enabled)&&void 0!==t&&t,u=null!==(n=null!==(s=null==a?void 0:a.canvasFps)&&void 0!==s?s:null==l?void 0:l.fps)&&void 0!==n?n:4;let d=null!==(r=null!==(o=null==a?void 0:a.canvasQuality)&&void 0!==o?o:null==l?void 0:l.quality)&&void 0!==r?r:.4;if("string"==typeof d){const e=parseFloat(d);d=isNaN(e)?.4:e}return{enabled:c,fps:Kt(u,0,12,Br("canvas recording fps"),4),quality:Kt(d,0,1,Br("canvas recording quality"),.4)}}get _isConsoleLogCaptureEnabled(){var e;const t=!!(null===(e=this._remoteConfig)||void 0===e?void 0:e.consoleLogRecordingEnabled),i=this._instance.config.enable_recording_console_log;return null!=i?i:t}get _networkPayloadCapture(){var e,t,i;const n=null===(e=this._remoteConfig)||void 0===e?void 0:e.networkPayloadCapture,s={recordHeaders:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.recordHeaders,recordBody:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.recordBody},r=!1!==s.recordHeaders&&(s.recordHeaders||(null==n?void 0:n.recordHeaders)),o=!1!==s.recordBody&&(s.recordBody||(null==n?void 0:n.recordBody)),a=uu(this._instance.config.capture_performance),l=uu(null==n?void 0:n.capturePerformance),c=!!(Lt(a)?a:l);return r||o||c?{recordHeaders:r,recordBody:o,recordPerformance:c}:void 0}_gatherRRWebPlugins(){var e,t;const i=[],n=null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.rrwebPlugins)||void 0===e?void 0:e.getRecordConsolePlugin;n&&this._isConsoleLogCaptureEnabled&&i.push(n());const r=null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.rrwebPlugins)||void 0===t?void 0:t.getRecordNetworkPlugin;if(this._networkPayloadCapture&&Ct(r))if(!to.includes(s.hostname)||this._forceAllowLocalhostNetworkCapture){const e=Ct(this._instance.requestRouter.isIngestionEndpoint)?this._instance.requestRouter.isIngestionEndpoint.bind(this._instance.requestRouter):void 0;i.push(r(ct(ct({},((e,t,i)=>{const n={payloadSizeLimitBytes:na.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...na.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...na.payloadHostDenyList]},s=!1!==e.session_recording.recordHeaders&&t.recordHeaders,r=!1!==e.session_recording.recordBody&&t.recordBody,o=!1!==e.capture_performance&&t.recordPerformance,a=(e=>{const t=ia(e);return e=>((null==e?void 0:e.requestBody)&&(e.requestBody=ca(e.requestBody,e.requestHeaders,t,"Request")),(null==e?void 0:e.responseBody)&&(e.responseBody=ca(e.responseBody,e.responseHeaders,t,"Response")),e)})(n),l=t=>{return a(((e,t,i)=>{var n;if(null==i?void 0:i(e.name))return;const s=Yr(e.name);let r=0===t.indexOf("http")?null===(n=Yr(t))||void 0===n?void 0:n.pathname:t;"/"===r&&(r="");const o=null==s?void 0:s.pathname.replace(r||"","");return s&&o&&la.some(e=>0===o.indexOf(e))?void 0:e})((aa((n=t).requestHeaders),aa(n.responseHeaders),n),e.api_host,i));var n},c=Ct(e.session_recording.maskNetworkRequestFn);return c&&Ct(e.session_recording.maskCapturedNetworkRequestFn)?Nr.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."):c&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{const i=e.session_recording.maskNetworkRequestFn({url:t.name});if(i||!t.isInitial)return ct(ct({},t),{},{name:null==i?void 0:i.url})}),n.maskRequestFn=Ct(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,n;const s=l(t);if(!s)return;const r=s.isInitial?{name:"",entryType:s.entryType,startTime:s.startTime,duration:s.duration,endTime:s.endTime,timeOrigin:s.timeOrigin,timestamp:s.timestamp,isInitial:!0}:void 0,o=null===(i=(n=e.session_recording).maskCapturedNetworkRequestFn)||void 0===i?void 0:i.call(n,s);return Mt(o)&&r?(da.add(r),r):null!=o?o:void 0}:e=>function(e){if(!xt(e))return e.requestBody=ua(e.requestBody,"Request"),e.responseBody=ua(e.responseBody,"Response"),e}(l(e)),ct(ct(ct({},na),n),{},{recordHeaders:s,recordBody:r,recordPerformance:o,recordInitialRequests:o,streamNetworkBody:!0===e.session_recording.streamNetworkBody})})(this._instance.config,this._networkPayloadCapture,e)),{},{captureFetchSynchronously:!0===this._instance.config.__preview_replay_sync_fetch})))}else du.info("NetworkCapture not started because we are on localhost.");return i}_stripUrlHash(e){return this._instance.config.disable_capture_url_hashes?cn(e):e}_maskReplayUrl(e,t=!1){const i=t?cn(e):this._stripUrlHash(e),n=this._instance.config.mask_personal_data_properties?[...Tc,...this._instance.config.custom_personal_data_properties||[]]:[];return this._maskUrl(ro(i,n,Ic))}_maskUrl(e){const t=this._instance.config.session_recording;if(t.maskCapturedNetworkRequestFn){var i;const n=t.maskCapturedNetworkRequestFn({name:e});return null!==(i=null==n?void 0:n.name)&&void 0!==i?i:null==n?void 0:n.url}if(t.maskNetworkRequestFn){const i=t.maskNetworkRequestFn({url:e});return null==i?void 0:i.url}return e}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return 10>this._queuedRRWebEvents.length?this._queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt+1,rrwebMethod:e.rrwebMethod}):du.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(pu(()=>_u().addCustomEvent(e,t)))}_canCaptureJsonLd(){var e;return this._jsonLdCaptureReady&&!0===(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)&&!this._urlTriggerMatching.urlBlocked&&!0!==this._isIdle}_tryAddJsonLdEvent(e){if(!this._canCaptureJsonLd())return!1;try{const t=_u();return!!t&&(t.addCustomEvent("$json_ld",e),this._canCaptureJsonLd())}catch(e){return!1}}_scheduleJsonLdScan(e=!1){Promise.resolve().then(()=>{var t;return null===(t=this._jsonLdCapture)||void 0===t?void 0:t.scan(e)})}_pageViewFallBack(){try{if(this._instance.config.capture_pageview||!e)return;const t=new URL(e.location.href),i=this._maskReplayUrl(t.origin+t.pathname+t.search);this._lastHref!==i&&(this._lastHref=i,this._tryAddCustomEvent("$url_changed",{href:i}))}catch(e){}}_processQueuedEvents(){if(this._queuedRRWebEvents.length){const e=[...this._queuedRRWebEvents];this._queuedRRWebEvents=[],e.forEach(e=>{Date.now()-e.enqueuedAt>2e3||this._tryRRWebMethod(e)})}}_tryTakeFullSnapshot(){return this._tryRRWebMethod(pu(()=>_u().takeFullSnapshot()))}get _fullSnapshotIntervalMillis(){var e,t,i;if((null===(e=this._strategy)||void 0===e?void 0:e.hasPendingTriggers(this.sessionId))&&!["sampled","active"].includes(this.status)){var n;const e=null===(n=this._instance.config.session_recording)||void 0===n?void 0:n.trigger_pending_buffer_interval_millis;return Ft(e)&&Number.isFinite(e)&&e>=1e3&&36e5>=e?e:6e4}return null!==(t=null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.full_snapshot_interval_millis)&&void 0!==t?t:3e5}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0===this._isIdle)return;const e=this._fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},e))}_onTriggerActivated(e){"event"===e&&this._releaseHoldAndFlush(),!this._urlTriggerMatching.urlBlocked&&["sampled","active"].includes(this.status)&&this._scheduleFullSnapshot()}_pauseRecording(){var e;this._urlTriggerMatching.urlBlocked||(this._urlTriggerMatching.urlBlocked=!0,null===(e=this._jsonLdCapture)||void 0===e||e.scan(),clearInterval(this._fullSnapshotTimer),du.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){var e;this._urlTriggerMatching.urlBlocked&&(null===(e=this._jsonLdCapture)||void 0===e||e.scan(),this._urlTriggerMatching.urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),du.info("recording resumed"))}_activateTrigger(e,t){var i;if("event"===e&&this._releaseHoldAndFlush(),!this._isActivatingTrigger&&(null===(i=this._strategy)||void 0===i?void 0:i.hasPendingTriggers(this.sessionId))){this._isActivatingTrigger=!0;try{var n,s;const i="url"===e?he:pe;null===(n=this._instance.persistence)||void 0===n||n.register({[i]:this.sessionId}),null===(s=this._strategy)||void 0===s||s.updateActiveTriggers(this.sessionId),this._onTriggerActivated(),this._flushBuffer(),this._reportStarted(e+"_trigger_matched",{["url"===e?"matchedUrl":"matchedEvent"]:t})}finally{this._isActivatingTrigger=!1}}}get isStarted(){return!!this._stopRrweb}get _remoteConfig(){const e=this._instance.get_property(ie);if(!e)return;let t;try{t=Et(e)?e:JSON.parse(e)}catch(e){return void du.warn("persisted remote config for session recording is invalid and will be ignored",e)}if(!this.isStarted&&!this._isRestartingForSessionIdChange){var i;const n=null!==(i=t.cache_timestamp)&&void 0!==i?i:Date.now();if(Date.now()-n>36e5)return void du.info("persisted remote config for session recording is stale and will be ignored",{cacheTimestamp:n,persistedConfig:e})}return t}_checkOverride(e,t,i){this._instance.get_property(e)&&(t(),i())}start(t){var i,s;const r=this._remoteConfig;if(!r)return void du.info("remote config must be stored in persistence before recording can start");if(!this.isStarted){const e=!1!==this._isIdle&&!this._suppressNextFreshStartHold;this._setFlushHold(e?"no_interaction_since_recording_started":void 0),this._suppressNextFreshStartHold=!1,this._heldEpochShipsOnUnload=e,this._heldBufferOverflowed=!1}this._isStoppingAfterCompression&&(this._invalidateCompressionQueue(),this._clearBuffer());const{sessionId:o,windowId:a,sessionStartTimestamp:l}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=o,this._windowId=a,this._sessionStartTimestamp=l,this._restorePendingBuffer(),null===(i=this._instance.persistence)||void 0===i||i.unregister("$debug_first_full_snapshot_timestamp"),(null==r?void 0:r.endpoint)&&(this._endpoint=null==r?void 0:r.endpoint),this._strategy=2===(null==r?void 0:r.version)&&(null==r?void 0:r.triggerGroups)&&r.triggerGroups.length>0?new Cc(this._instance,this._urlTriggerMatching,this._reportStarted.bind(this),this._tryAddCustomEvent.bind(this),this._onTriggerActivated.bind(this)):new kc(this._instance,this._urlTriggerMatching,this._eventTriggerMatching,this._linkedFlagMatching,this._reportStarted.bind(this),this._tryTakeFullSnapshot.bind(this),this._onTriggerActivated.bind(this)),this._strategy.onRemoteConfig(r),null===(s=this._removeEventTriggerCaptureHook)||void 0===s||s.call(this),this._removeEventTriggerCaptureHook=this._strategy.setupEventTriggerListeners(this._instance.on.bind(this._instance,"eventCaptured"),this.sessionId,(e,t)=>this._activateTrigger(e,t)),this._checkOverride(re,()=>{this.overrideSampling()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(re)}),this._checkOverride(oe,()=>{this.overrideLinkedFlag()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(oe)}),this._checkOverride(le,()=>{this.overrideTrigger("event")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(le)}),this._checkOverride(ae,()=>{this.overrideTrigger("url")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(ae)}),this._strategy.makeSamplingDecisions(this.sessionId),this._startRecorder(),this._rrwebError||(Kr(e,"beforeunload",this._onBeforeUnload),Kr(e,"pagehide",this._onPageHide),Kr(e,"offline",this._onOffline),Kr(e,"online",this._onOnline),Kr(n,"visibilitychange",this._onVisibilityChange),!this._onSessionIdListener&&Ct(this._sessionManager.onSessionId)&&(this._onSessionIdListener=this._sessionManager.onSessionId(this._onSessionIdCallback)),!this._onSessionIdleResetForcedListener&&Ct(this._sessionManager.on)?this._onSessionIdleResetForcedListener=this._sessionManager.on("forcedIdleReset",()=>{this._clearConditionalRecordingPersistence(),this._isIdle="unknown",this.stop(),this._forceIdleSessionIdListener=this._sessionManager.onSessionId((e,t,i)=>{var n;null===(n=this._forceIdleSessionIdListener)||void 0===n||n.call(this),this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback(e,t,i)})}):Ct(this._sessionManager.on)||du.warn("bundled core has no SessionIdManager.on (requires posthog-js >= 1.268.6); recording will start but skip forced-idle-reset handling"),Mt(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this._instance.on("eventCaptured",e=>{try{if("$pageview"===e.event){const t=(null==e?void 0:e.properties.$current_url)?this._maskReplayUrl(e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){du.error("Could not add $pageview to rrweb session",e)}})),"active"===this.status&&this._reportStarted(t||"recording_initialized"))}_teardown(){var t,i,s,r,o,a;null==e||e.removeEventListener("beforeunload",this._onBeforeUnload),null==e||e.removeEventListener("pagehide",this._onPageHide),null==e||e.removeEventListener("offline",this._onOffline),null==e||e.removeEventListener("online",this._onOnline),null==n||n.removeEventListener("visibilitychange",this._onVisibilityChange),clearInterval(this._fullSnapshotTimer),this._clearFlushBufferTimer(),null===(t=this._removePageViewCaptureHook)||void 0===t||t.call(this),this._removePageViewCaptureHook=void 0,null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),this._removeEventTriggerCaptureHook=void 0,null===(s=this._onSessionIdListener)||void 0===s||s.call(this),this._onSessionIdListener=void 0,null===(r=this._onSessionIdleResetForcedListener)||void 0===r||r.call(this),this._onSessionIdleResetForcedListener=void 0,null===(o=this._forceIdleSessionIdListener)||void 0===o||o.call(this),this._forceIdleSessionIdListener=void 0,null===(a=this._strategy)||void 0===a||a.stop(),this._stopRecordingProducers(),this._invalidateCompressionQueue()}_invalidateCompressionQueue(){this._compressionQueueGeneration+=1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueue=void 0,this._isStoppingAfterCompression=!1}_stopRecordingProducers(){var e,t;null===(e=this._mutationThrottler)||void 0===e||e.stop(),this._queuedRRWebEvents=[],null===(t=this._jsonLdCapture)||void 0===t||t.stop(),this._jsonLdCapture=void 0,this._jsonLdCaptureReady=!1;try{var i;null===(i=this._stopRrweb)||void 0===i||i.call(this)}catch(e){du.warn("could not stop rrweb",e)}this._stopRrweb=void 0}_stopAfterCompressionQueueDrains(){if(!this._compressionQueue||0===this._queuedCompressionEvents)return!1;if(this._isStoppingAfterCompression)return!0;this._isStoppingAfterCompression=!0,this._flushHoldReason=void 0;const e=this._compressionQueueGeneration;return this._clearFlushBufferTimer(),this._stopRecordingProducers(),this._compressionQueue.catch(()=>{}).then(()=>{e===this._compressionQueueGeneration&&(this._isStoppingAfterCompression=!1,this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),du.info("stopped"))}).catch(()=>{this._isStoppingAfterCompression=!1,this._releaseHoldAfterStop(),this._teardown(),du.info("stopped")}),!0}stop(){if(this._stopRecordingProducers(),this._isRestartingForSessionIdChange)this._drainCompressionQueueSync();else if(this._stopAfterCompressionQueueDrains())return;this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),du.info("stopped")}_releaseHoldAfterStop(){this._setFlushHold(void 0,{preserveLogDedup:this._isRestartingForSessionIdChange}),this._heldEpochShipsOnUnload=!1}flushBeforeIdentityReset(){(this.isStarted||this._isStoppingAfterCompression)&&(this._drainCompressionQueueSync(),this._flushBuffer())}_restartForSessionIdChange(e){this._isRestartingForSessionIdChange=!0,this._lastActivityTimestamp=Date.now();try{var t,i;this.stop(),this._lastSeenSnapshotCost=void 0,this._unstringifiableEventsDropped=0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,null===(t=gu())||void 0===t||null===(i=t.resetSnapshotCostState)||void 0===i||i.call(t),this.start("session_id_changed")}finally{this._isRestartingForSessionIdChange=!1}this._setFlushHold(e?"no_interaction_since_session_rotated":void 0),this._heldEpochShipsOnUnload=!1}_setFlushHold(e,{preserveLogDedup:t=!1}={}){if(this._holdFlushUntilInteraction=!xt(e),this._flushHoldReason=e,xt(e))return void(t||(this._lastLoggedFlushHold=void 0));if(this._isRestartingForSessionIdChange)return;const i=`${this.sessionId}:${e}`;i!==this._lastLoggedFlushHold&&(this._lastLoggedFlushHold=i,du.info(`holding buffer: ${e}. nothing is uploaded until the user interacts with the page`))}_releaseHoldAndFlush(){this.isStarted||(this._suppressNextFreshStartHold=!0),this._holdFlushUntilInteraction&&(this._setFlushHold(void 0),this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed&&(this._heldBufferOverflowed=!1,this._tryTakeFullSnapshot()),this._scheduleFlushBuffer())}discard({discardProducerEvents:e=!1}={}){this._holdFlushUntilInteraction=!0,e&&(this._clearBuffer(),this._stopRecordingProducers()),this._clearBuffer(),this._teardown(),this._clearBuffer(),this._releaseHoldAfterStop(),du.info("discarded")}_captureProcessedEvent(e,t,i,n,s){if(-1===i)return this._unstringifiableEventsDropped+=1,void du.warn("could not stringify event - dropping it to keep the rest of the recording");const r={$snapshot_bytes:i,$snapshot_data:t,$session_id:n,$window_id:s};"disabled"!==this.status?(this._ensureFullSnapshotForSession(e,n),this._captureSnapshotBuffered(r)):this._clearBuffer()}_safeTrackFullSnapshotCost(){try{this._trackFullSnapshotCost()}catch(e){this._snapshotCostErrorLogged||(this._snapshotCostErrorLogged=!0,du.error("could not track full snapshot cost",e))}}_trackFullSnapshotCost(){var e,t;const i=null===(e=gu())||void 0===e||null===(t=e.getLastSnapshotCost)||void 0===t?void 0:t.call(e);i&&i!==this._lastSeenSnapshotCost&&(this._lastSeenSnapshotCost=i,500>i.durationMs||du.warn("full snapshot was slow, the page may have been unresponsive while it ran",{durationMs:Math.round(i.durationMs),stylesheetMs:Math.round(i.stylesheetMs),nodeCount:i.nodeCount,cssRuleCount:i.cssRuleCount,nonDeferrableCssRuleCount:i.nonDeferrableCssRuleCount,deferredStylesheetCount:i.deferredStylesheetCount}))}_ensureFullSnapshotForSession(e,t){2!==e.type?3===e.type&&(xt(this._lastFullSnapshotSessionId)||this._lastFullSnapshotSessionId===t||this._fullSnapshotHealAttemptedFor===t||(this._fullSnapshotHealAttemptedFor=t,du.info("incremental snapshot for a session with no full snapshot - requesting one",{sessionId:t}),this._tryTakeFullSnapshot())):this._lastFullSnapshotSessionId=t}_finishQueuedCompressionEvent(e){e.counted&&e.generation===this._compressionQueueGeneration&&(this._queuedCompressionEvents=Math.max(0,this._queuedCompressionEvents-1)),e.counted=!1,this._pendingCompressionEvents=this._pendingCompressionEvents.filter(t=>t!==e)}_captureQueuedCompressionEvent(e,t,i){e.processed||e.generation!==this._compressionQueueGeneration||(e.processed=!0,this._captureProcessedEvent(e.event,t,i,e.targetSessionId,e.targetWindowId))}_processQueuedCompressionEventSync(e){try{let t,i=e.event;if(e.compressionEnabled)try{({event:i,size:t}=Mu(e.event))}catch(e){du.warn("could not process queued compression event - will use uncompressed event",e)}xt(t)&&(t=$a(e.event));try{this._captureQueuedCompressionEvent(e,i,t)}catch(e){du.warn("could not capture queued compression event",e)}}finally{this._finishQueuedCompressionEvent(e)}}_drainCompressionQueueSync(){[...this._pendingCompressionEvents].forEach(e=>{try{this._processQueuedCompressionEventSync(e)}catch(e){du.warn("could not drain queued compression event",e)}})}_enqueueCompression(e,t,i,n){var s=this;const r={event:e,compressionEnabled:t,targetSessionId:i,targetWindowId:n,generation:this._compressionQueueGeneration,processed:!1,counted:!0};this._pendingCompressionEvents.push(r),this._queuedCompressionEvents+=1;const o=(a=rt(function*(){try{if(r.processed)return;let i,n;try{const s=t?xu(e)?yield function(e){return Fu.apply(this,arguments)}(e):Mu(e):{event:e,size:$a(e)};i=s.event,n=s.size}catch(t){du.warn("could not process queued compression event - will use uncompressed event",t),i=e,n=$a(e)}s._captureQueuedCompressionEvent(r,i,n)}finally{s._finishQueuedCompressionEvent(r)}}),function(){return a.apply(this,arguments)});var a;this._compressionQueue=this._compressionQueue?this._compressionQueue.catch(()=>{}).then(o):o()}onRRwebEmit(t){var i,n,s,r,o,a,l,c,u,d,h;if(!this._instance.sessionManager)return;if(this._processQueuedEvents(),!t||!Et(t))return;if(4===t.type){const e=this._maskReplayUrl(t.data.href);if(this._lastHref=e,!e)return;t.data.href=e}else this._pageViewFallBack();if(null===(i=this._strategy)||void 0===i||i.checkUrlTriggers(this.sessionId,()=>this._pauseRecording(),()=>this._resumeRecording(),(e,t)=>this._activateTrigger(e,t)),this._urlTriggerMatching.urlBlocked&&!function(e){return 5===e.type&&"recording paused"===e.data.tag}(t))return;2===t.type&&(this._safeTrackFullSnapshotCost(),Promise.resolve().then(()=>this._safeTrackFullSnapshotCost()),this._scheduleFullSnapshot(),null===(d=this._mutationThrottler)||void 0===d||d.reset(),null===(h=this._instance.persistence)||void 0===h||h.register_once({$debug_first_full_snapshot_timestamp:t.timestamp},void 0));const p=2===t.type&&(null===(n=this._strategy)||void 0===n?void 0:n.hasPendingTriggers(this.sessionId));p&&this._clearBufferBeforeMostRecentMeta();const g=this._mutationThrottler?this._mutationThrottler.throttleMutations(t):t;if(!g)return void(!0===this._isIdle&&this._eventsDroppedWhileIdle++);const _=function(e){const t=e;if(t&&Et(t)&&6===t.type&&Et(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));const i=[];for(let e=0;t.data.payload.payload.length>e;e++)i.push(t.data.payload.payload[e]&&t.data.payload.payload[e].length>2e3?t.data.payload.payload[e].slice(0,2e3)+"...[truncated]":t.data.payload.payload[e]);return t.data.payload.payload=i,e}return e}(g),f=function(e){return Ou(e)?e.data.payload:null}(_),v=function(e){return Du(e)?e.data.payload:null}(_),m=function(e){return Lu(e)?e.data.payload:null}(_);f||v?(null==f?void 0:f.lastActivityTimestamp)&&(_.timestamp=f.lastActivityTimestamp):(null==m?void 0:m.sessionId)||this._updateWindowAndSessionIds(_);const y=null!==(s=null!==(r=null!==(o=null==f?void 0:f.currentSessionId)&&void 0!==o?o:null==v?void 0:v.nextSessionId)&&void 0!==r?r:null==m?void 0:m.sessionId)&&void 0!==s?s:this._sessionId,b=null!==(a=null!==(l=null!==(c=null==f?void 0:f.currentWindowId)&&void 0!==c?c:null==v?void 0:v.nextWindowId)&&void 0!==l?l:null==m?void 0:m.windowId)&&void 0!==a?a:this._windowId;if(!0===this._isIdle&&!function(e){return Lu(e)||Ou(e)||Du(e)}(_))return void(function(e){return 2===e.type||4===e.type||3===e.type&&9!==e.data.source}(_)&&this._eventsDroppedWhileIdle++);2===_.type&&(this._eventsDroppedWhileIdle=0),m&&(_.timestamp=m.lastActivityTimestamp+m.threshold);const S=this._jsonLdCaptureReady;this._jsonLdCaptureReady=!0,p?this._scheduleJsonLdScan(!0):S||this._scheduleJsonLdScan();const w=null===(u=this._instance.config.session_recording.compress_events)||void 0===u||u;if(5===_.type&&"$json_ld"===_.data.tag){let t;try{t=e?this._maskReplayUrl(e.location.href):void 0}catch(e){}_.data.href=t}if(this._queuedCompressionEvents>0||w&&xu(_))return void this._enqueueCompression(_,w,y,b);const{event:k,size:C}=w?Mu(_):{event:_,size:$a(_)};this._captureProcessedEvent(_,k,C,y,b)}get status(){return this._strategy?this._strategy.getStatus({instance:this._instance,sessionId:this.sessionId,isSampled:this._isSampled,rrwebError:this._rrwebError,urlTriggerMatching:this._urlTriggerMatching,eventTriggerMatching:this._eventTriggerMatching,linkedFlagMatching:this._linkedFlagMatching,remoteConfig:this._remoteConfig}):ha}log(e,t="log"){var i;null===(i=this._instance.sessionRecording)||void 0===i||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}overrideLinkedFlag(){this._linkedFlagMatching.linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this._instance.persistence)||void 0===e||e.register({$session_is_sampled:this.sessionId,$replay_sample_rate:null}),this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e),this._releaseHoldAndFlush()}_currentMaskedHostname(){try{var t;const i=null==e||null===(t=e.location)||void 0===t?void 0:t.href;if(!i)return;const n=this._maskReplayUrl(i);if(!n)return;return new URL(n).hostname||void 0}catch(e){return}}_clearFlushBufferTimer(){this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0)}_scheduleFlushBuffer(){this._flushBufferTimer||(this._flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_wouldOpenRecordingWithMarkersOnly(){return this._lastFullSnapshotSessionId!==this._buffer.sessionId&&0!==this._buffer.data.length&&this._buffer.data.every(e=>5===(null==e?void 0:e.type)&&!Ou(e)&&!Du(e))}_describePendingTriggerConditions(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getPendingTriggerConditions(this.sessionId))&&void 0!==e?e:[]}_maybeLogBufferingReason(e){if("buffering"!==e)return xt(this._lastLoggedBufferingReason)||this._instance.register_for_session({[ze]:[]}),void(this._lastLoggedBufferingReason=void 0);const t=this._describePendingTriggerConditions();if(0===t.length)return xt(this._lastLoggedBufferingReason)||this._instance.register_for_session({[ze]:[]}),void(this._lastLoggedBufferingReason=void 0);const i=t.join(", "),n=`${this.sessionId}:${i}`;n!==this._lastLoggedBufferingReason&&(this._lastLoggedBufferingReason=n,this._instance.register_for_session({[ze]:t}),du.info(`buffering: ${i}`))}_canParkPendingBuffer(){var e;return"memory"!==this._instance.config.persistence&&!0!==(null===(e=this._instance.persistence)||void 0===e?void 0:e._disabled)&&Jl._is_supported()}_parkBufferForNextPage(){0!==this._buffer.data.length&&this._buffer.size!==this._lastParkedBufferSize&&943718.4>=this._buffer.size&&this._canParkPendingBuffer()&&(this._lastParkedBufferSize=this._buffer.size,Jl._set(this._pendingBufferStorageKey,this._buffer))}_restorePendingBuffer(){if(this._pendingBufferRestored||!this._canParkPendingBuffer())return;this._pendingBufferRestored=!0;const e=Jl._parse(this._pendingBufferStorageKey);Jl._remove(this._pendingBufferStorageKey),Et(e)&&kt(e.data)&&0!==e.data.length&&kt(e.sizes)&&e.sizes.length===e.data.length&&Ft(e.size)&&e.sessionId===this._sessionId&&e.windowId===this._windowId&&(this._buffer.data.length>0||(this._buffer=e))}_flushBuffer(e=!1){var t;if(this._clearFlushBufferTimer(),this._holdFlushUntilInteraction)return this._buffer;if(this._wouldOpenRecordingWithMarkersOnly())return this._buffer.size>943718.4?this._clearBuffer():(e&&this._parkBufferForNextPage(),this._buffer);const i=this._buffer;null===(t=this._strategy)||void 0===t||t.ensureSamplingDecision(this.sessionId);const n=this._isBelowMinimumDuration(),s=this.status;if(this._maybeLogBufferingReason(s),"buffering"===s||"paused"===s||"disabled"===s||n)return!e||"active"!==s&&"sampled"!==s||this._parkBufferForNextPage(),this._scheduleFlushBuffer(),this._buffer;if(this._buffer!==i)return this._buffer;if(i.data.length>0){var r;const e=this._currentMaskedHostname();Ba(i).forEach(t=>{try{var i;null===(i=this._flushedSizeTracker)||void 0===i||i.trackSize(t.sessionId,t.size),this._captureSnapshot(ct(ct(ct(ct({$snapshot_bytes:t.size,$snapshot_data:t.data,$session_id:t.sessionId,$window_id:t.windowId,$lib:Yl.LIB_NAME,$lib_version:Yl.LIB_VERSION,$snapshot_host:e},this._throttledMutationsDropped>0?{$sdk_debug_replay_throttled_mutations_dropped:this._throttledMutationsDropped}:{}),this._oversizedMutationsDropped>0?{$sdk_debug_replay_oversized_mutations_dropped:this._oversizedMutationsDropped}:{}),this._oversizedMutationBytesDropped>0?{$sdk_debug_replay_oversized_mutation_bytes_dropped:this._oversizedMutationBytesDropped}:{}),this._unstringifiableEventsDropped>0?{$sdk_debug_replay_unstringifiable_events_dropped:this._unstringifiableEventsDropped}:{}))}catch(e){du.warn("could not capture snapshot chunk - skipping it",e)}}),xt(this._lastParkedBufferSize)||(Jl._remove(this._pendingBufferStorageKey),this._lastParkedBufferSize=void 0),null===(r=this._strategy)||void 0===r||r.onFlushComplete()}return this._clearBuffer()}_captureSnapshotBuffered(e){var t;const i=2+((null===(t=this._buffer)||void 0===t?void 0:t.data.length)||0),n=e.$session_id,s=this._buffer.sessionId!==n;if(s||!0!==this._isIdle&&!this._holdFlushUntilInteraction&&this._buffer.size+e.$snapshot_bytes+i>943718.4){const t=this._sessionId;if(this._buffer=this._flushBuffer(),this._sessionId!==t)return;s&&this._buffer.data.length>0&&(this._buffer=this._clearBuffer()),this._buffer.sessionId=n,this._buffer.windowId=e.$window_id}this._holdFlushUntilInteraction&&(this._heldBufferOverflowed||this._buffer.size+e.$snapshot_bytes+i>943718.4)?this._heldBufferOverflowed=!0:(this._buffer.size+=e.$snapshot_bytes,this._buffer.data.push(e.$snapshot_data),this._buffer.sizes.push(e.$snapshot_bytes),!0===this._isIdle||this._holdFlushUntilInteraction||this._scheduleFlushBuffer())}_captureSnapshot(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}get _sessionDuration(){var e,t;const i=null===(e=this._buffer)||void 0===e?void 0:e.data[(null===(t=this._buffer)||void 0===t?void 0:t.data.length)-1];return i?i.timestamp-this._sessionStartTimestamp:null}_clearBufferBeforeMostRecentMeta(){if(!this._buffer||0===this._buffer.data.length)return this._clearBuffer();let e=-1;for(let t=this._buffer.data.length-1;t>=0;t--)if(4===this._buffer.data[t].type){e=t;break}return 0>e?this._clearBuffer():(this._buffer.data=this._buffer.data.slice(e),this._buffer.sizes=this._buffer.sizes.slice(e),this._buffer.size=this._buffer.sizes.reduce((e,t)=>e+t,0),this._buffer)}_clearBuffer(){return this._buffer={size:0,data:[],sizes:[],sessionId:this._sessionId,windowId:this._windowId},this._buffer}_reportStarted(e,t){this._instance.register_for_session({[Ke]:e}),du.info(e.replace("_"," "),t),"session_id_changed"!==e&&this._tryAddCustomEvent("$recording_started",ct({reason:e},t))}_isInteractiveEvent(e){var t;return 3===e.type&&-1!==hu.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){const t=this._isInteractiveEvent(e);t||!0===this._isIdle||e.timestamp-this._lastActivityTimestamp>this._sessionIdleThresholdMilliseconds&&(this._isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this._sessionIdleThresholdMilliseconds,bufferLength:this._buffer.data.length,bufferSize:this._buffer.size,sessionId:this._sessionId,windowId:this._windowId}),this._flushBuffer());const{windowId:i,sessionId:n}=this._sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp);let s=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this._isIdle)){const t="unknown"===this._isIdle;this._isIdle=!1,t||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),s=!0)}const r=this._sessionId!==n,o=this._windowId!==i;if(this._windowId=i,this._sessionId=n,r||o){const e=r&&!1!==this._isIdle;e&&(this._isIdle="unknown"),this._restartForSessionIdChange(e)}else if(t&&this._releaseHoldAndFlush(),s){var a;const e=["sampled","active"].includes(this.status)||(null===(a=this._strategy)||void 0===a?void 0:a.hasPendingTriggers(this.sessionId));this._eventsDroppedWhileIdle>0&&e&&this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot()}}_clearConditionalRecordingPersistence(){var e;null===(e=this._strategy)||void 0===e||e.clearConditionalRecordingPersistence()}get sdkDebugProperties(){var e;return{$recording_status:this.status,$sdk_debug_replay_flush_hold_reason:this._flushHoldReason,$sdk_debug_replay_internal_buffer_length:this._buffer.data.length,$sdk_debug_replay_internal_buffer_size:this._buffer.size,$sdk_debug_session_start:this._sessionStartTimestamp,$sdk_debug_replay_flushed_size:null===(e=this._flushedSizeTracker)||void 0===e?void 0:e.currentTrackedSize(this.sessionId),$sdk_debug_replay_rrweb_error:this._rrwebError,[Ge]:this._rrwebAttached,[Qe]:this._rrwebStartAttempted}}get _rrwebAttached(){var e,t,i;return!!this._stopRrweb&&(null===(e=null===(t=_u())||void 0===t||null===(i=t.isRecording)||void 0===i?void 0:i.call(t))||void 0===e||e)}_startRecorder(){var t;if(this._stopRrweb)return;this._rrwebStartAttempted=!0;const i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,maskAllElementAttributes:!1,maskAttributeFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,inlineStylesheetBudgetRules:1e4,recordCrossOriginIframes:!1,sampling:void 0,attributeFilter:void 0},s=this._instance.config.session_recording;for(const[e,t]of Object.entries(s||{}))if(e in i)if("maskInputOptions"===e)i.maskInputOptions=ct({password:!0},t);else if("sampling"===e){const e=null!=t?t:{},n={};xt(e.mousemove)||(n.mousemove=e.mousemove),xt(e.mouseInteraction)||(n.mouseInteraction=e.mouseInteraction),i.sampling=n}else i[e]=t;var r,o,a,l;!0===(null==s?void 0:s.captureJsonLd)&&!0!==i.slimDOMOptions&&"all"!==i.slimDOMOptions&&(i.slimDOMOptions=ct(ct({},i.slimDOMOptions),{},{script:!0})),this._canvasRecording&&this._canvasRecording.enabled&&(i.recordCanvas=!0,i.sampling=ct(ct({},i.sampling),{},{canvas:this._canvasRecording.fps}),i.dataURLOptions={type:"image/webp",quality:this._canvasRecording.quality},i.canvasResolutionScale=this._canvasResolutionScale,i.canvasMasking={configured:()=>{var e;return Ct(null===(e=this._instance.config.session_recording)||void 0===e||null===(e=e.canvasCapture)||void 0===e?void 0:e.maskRegionsFn)},regionsFn:e=>{var t;const i=null===(t=this._instance.config.session_recording)||void 0===t||null===(t=t.canvasCapture)||void 0===t?void 0:t.maskRegionsFn;if(Ct(i))try{var n;return null!==(n=i(e))&&void 0!==n?n:null}catch(e){return this._maskRegionsFnFailed||(this._maskRegionsFnFailed=!0,du.warn("canvasCapture.maskRegionsFn threw, canvas frames will be skipped",e)),null}}}),this._masking&&(i.maskAllInputs=null===(r=this._masking.maskAllInputs)||void 0===r||r,i.maskTextSelector=null!==(o=this._masking.maskTextSelector)&&void 0!==o?o:void 0,i.blockSelector=null!==(a=this._masking.blockSelector)&&void 0!==a?a:void 0,i.maskAllElementAttributes=null!==(l=this._masking.maskAllElementAttributes)&&void 0!==l&&l),i.maskAllElementAttributes&&i.maskAttributeFn&&(i.maskAttributeFn=void 0,this._hasWarnedExclusiveAttributeMasking||(this._hasWarnedExclusiveAttributeMasking=!0,du.warn('`maskAllElementAttributes` and `maskAttributeFn` are mutually exclusive, and `maskAttributeFn` is being ignored. Remove one of the two. Note that `maskAllElementAttributes` can also come from your project\'s "Privacy and masking" settings. See https://posthog.com/docs/session-replay/privacy'))),this._warnIfClientMaskingShadowsServer();const c=_u();if(!c)return void du.error("_startRecorder was called but rrwebRecord is not available. This indicates something has gone wrong.");this._mutationThrottler=null!==(t=this._mutationThrottler)&&void 0!==t?t:new Sl(c,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(e,t)=>{const i=`Too many mutations on node '${e}'. Rate limiting. This could be due to SVG animations or something similar`;du.info(i,{node:t}),this.log("[SessionRecording] "+i,"warn")},onDroppedAttributeMutations:e=>this._throttledMutationsDropped+=e,bytesRefillRate:this._instance.config.session_recording.__mutationBytesRefillRate,bytesBucketSize:this._instance.config.session_recording.__mutationBytesBucketSize,resyncIntervalMs:this._fullSnapshotIntervalMillis,onDroppedOversizedMutation:e=>{0===this._oversizedMutationsDropped&&this.log("[SessionRecording] Dropped an oversized DOM mutation to keep the recording playable. The recording will resync with a full snapshot.","warn"),this._oversizedMutationsDropped+=1,this._oversizedMutationBytesDropped+=e},requestFullSnapshot:()=>this._tryTakeFullSnapshot()});const u=this._gatherRRWebPlugins();if(this._stopRrweb=c(ct(ct({emit:e=>{this.onRRwebEmit(e)},plugins:u,errorHandler:(e,t)=>"rrweb"===t&&(this._hasLoggedRecorderCallbackError||(this._hasLoggedRecorderCallbackError=!0,du.error("rrweb internal error - recording will continue but may be incomplete",e)),!0)},i),{},{recordAfter:"DOMContentLoaded"})),!this._stopRrweb)return this._rrwebError=!0,void du.error("rrweb failed to start - Loss of recording data is possible. Check the browser console for rrweb errors.");this._rrwebError=!1,!0===(null==s?void 0:s.captureJsonLd)&&n&&(null==e?void 0:e.MutationObserver)&&!this._jsonLdCapture&&(this._jsonLdCapture=function(e,t,i){const n=new WeakMap,s=i.getCaptureState||(()=>!0);let r=qc;const o=function(e,t){const i=t.attributeFilter;return t.maskAllElementAttributes||t.maskAttributeFn||(null==i?void 0:i.length)&&!i.includes("id")?zc:i=>{const n=e.getElementById(i);return!!n&&"SCRIPT"!==n.nodeName&&(!t.isRecordedElement||t.isRecordedElement(n))&&!lu(n,t.blockClass,t.blockSelector)}}(e,i),a=t=>{try{const a=s();if(!r||!1===a||!t.isConnected||t.ownerDocument!==e||function(e,t){return lu(e,t.blockClass,t.blockSelector)||lu(e,t.maskTextClass,t.maskTextSelector)}(t,i))return;const l=function(e,t=zc,i){if(!e||e.length>qc)return null;try{const n=JSON.parse(e),s={maskUrl:i,remainingNodes:2048,exceeded:!1},r=kt(n)?n.map(e=>ru(e,t,s)):ru(n,t,s);if(s.exceeded||Pt(r)||kt(r)&&(!r.length||r.some(Pt)))return null;const o=JSON.stringify(r);return o.length>2e4?null:[r,o]}catch(e){return null}}(t.text,o,i.maskUrl);if(!l)return void n.delete(t);const[c,u]=l;if(Pt(a))return void n.set(t,u);if(n.get(t)!==u){if(u.length>r)return void(r=0);i.emit(c)&&(n.set(t,u),r-=u.length)}}catch(e){return}};try{const i=new t(e=>{try{if(!r||!1===s())return;const t=e=>{for(const t of cu(e))a(t)};for(const i of e)if("childList"===i.type)ou(i.target)&&a(i.target),i.addedNodes.forEach(t);else if("characterData"===i.type){const e=i.target.parentNode;e&&ou(e)&&a(e)}else"attributes"===i.type&&ou(i.target)&&a(i.target)}catch(e){return}});return i.observe(e,{attributes:!0,attributeFilter:["type"],characterData:!0,childList:!0,subtree:!0}),{scan(t=!1){r&&!1!==s()&&cu(e.documentElement).forEach(e=>{t&&n.delete(e),a(e)})},stop(){return i.disconnect()}}}catch(e){return{scan(){},stop(){}}}}(n,e.MutationObserver,{maskUrl:e=>this._maskReplayUrl(e),attributeFilter:i.attributeFilter,blockClass:i.blockClass,blockSelector:i.blockSelector,isRecordedElement:e=>c.mirror.getId(e)>0,maskAllElementAttributes:i.maskAllElementAttributes,maskAttributeFn:i.maskAttributeFn,maskTextClass:i.maskTextClass,maskTextSelector:i.maskTextSelector,getCaptureState:()=>{var e;return!0!==(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)||this._urlTriggerMatching.urlBlocked||this._urlTriggerMatching.isCurrentUrlBlocked()?null:this._canCaptureJsonLd()},emit:e=>this._tryAddJsonLdEvent(e)}),this._urlTriggerMatching.isCurrentUrlBlocked()&&this._jsonLdCapture.scan()),this._lastActivityTimestamp=Date.now(),this._isIdle=Lt(this._isIdle)?this._isIdle:"unknown",this.tryAddCustomEvent("$remote_config_received",this._remoteConfig),this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:i,activePlugins:u.map(e=>null==e?void 0:e.name)}),this._tryAddCustomEvent("$posthog_config",{config:this._instance.config})}tryAddCustomEvent(e,t){return this._tryAddCustomEvent(e,t)}};const Nu=["type"];var Bu=function(e){return e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e}({}),qu=function(e){return e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e}({}),Hu=function(e){return e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e}({}),Uu=function(e){return e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e}({}),zu=function(e){return e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e}({}),Wu=function(e){return e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e}({}),ju=function(e){return e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e}({});function Vu(e,t){return-1!==e.indexOf(t)}Date,Date;var Gu={Node:["childNodes","parentNode","parentElement","textContent","previousSibling","nextSibling","lastChild"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot"],MutationObserver:[]},Qu={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:["querySelector","querySelectorAll"],MutationObserver:["constructor"]},Ku={};function Ju(e){if(Ku[e])return Ku[e];const t=function(e){var t,i;const n=null===(t=globalThis)||void 0===t||null===(t=t.Zone)||void 0===t||null===(i=t.__symbol__)||void 0===i?void 0:i.call(t,e);return n&&globalThis[n]?globalThis[n]:void 0}(e)||globalThis[e],i=t.prototype,n=e in Gu?Gu[e]:void 0,s=Boolean(n&&n.every(e=>{var t;return Boolean(null===(t=Object.getOwnPropertyDescriptor(i,e))||void 0===t||null===(t=t.get)||void 0===t?void 0:t.toString().includes("[native code]"))})),r=e in Qu?Qu[e]:void 0,o=Boolean(r&&r.every(e=>{var t;return"function"==typeof i[e]&&(null===(t=i[e])||void 0===t?void 0:t.toString().includes("[native code]"))}));if(s&&o)return Ku[e]=t.prototype,t.prototype;const a=document.createElement("iframe");a.style.display="none";let l=!1;try{document.body.appendChild(a);const n=a.contentWindow;if(!n)return t.prototype;const s=n[e].prototype;return s?(function(e){return Vu(e,"AppleWebKit")&&!Vu(e,"Chrome")}(navigator.userAgent)&&(a.classList.add("rr-block","ph-no-capture"),a.setAttribute("__rrwebUntaintedPrototype",e),l=!0),Ku[e]=s):i}catch(e){return i}finally{!l&&a.parentNode&&document.body.removeChild(a)}}var Yu=Object.create(null);function Zu(e,t,i){var n;const s=Yu[e],r=s[i];if(r)return r.call(t);const o=Ju(e),a=null===(n=Object.getOwnPropertyDescriptor(o,i))||void 0===n?void 0:n.get;return a?(s[i]=a,a.call(t)):t[i]}Yu.Node=Object.create(null),Yu.ShadowRoot=Object.create(null),Yu.MutationObserver=Object.create(null),Yu.Element=Object.create(null);var Xu,ed={};function td(e,t,i){const n=`${e}.${String(i)}`;if(ed[n])return ed[n].bind(t);const s=Ju(e)[i];return"function"!=typeof s?t[i]:(ed[n]=s,s.bind(t))}function id(){return Ju("MutationObserver").constructor}function nd(e,t,i){try{if(!(t in e))return()=>{};const n=e[t],s={next:n},r=i(function(...e){return s.next.apply(this,e)});return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:n},__rrweb_layer__:{enumerable:!1,value:s}})),e[t]=r,()=>{if(e[t]===r)return void(e[t]=s.next);const i=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let n=e[t],o=i(n);for(;o;){if(o.next===r)return void(o.next=s.next);n=o.next,o=i(n)}}}catch(e){return()=>{}}}var sd={childNodes:e=>Zu("Node",e,"childNodes"),parentNode:e=>Zu("Node",e,"parentNode"),parentElement:e=>Zu("Node",e,"parentElement"),textContent:e=>Zu("Node",e,"textContent"),previousSibling:e=>Zu("Node",e,"previousSibling"),nextSibling:e=>Zu("Node",e,"nextSibling"),lastChild:e=>Zu("Node",e,"lastChild"),isConnected(e){if(void 0===Xu){var t;const e=null===(t=Object.getOwnPropertyDescriptor(Ju("Node"),"isConnected"))||void 0===t?void 0:t.get;Xu=(null==e?void 0:e.toString().includes("[native code]"))?e:null}return null==Xu?void 0:Xu.call(e)},contains:(e,t)=>td("Node",e,"contains")(t),getRootNode:e=>td("Node",e,"getRootNode")(),host:e=>e&&"host"in e?Zu("ShadowRoot",e,"host"):null,styleSheets:e=>e.styleSheets,shadowRoot:e=>e&&"shadowRoot"in e?Zu("Element",e,"shadowRoot"):null,querySelector:(e,t)=>td("Element",e,"querySelector")(t),querySelectorAll:(e,t)=>td("Element",e,"querySelectorAll")(t),mutationObserver:id,patch:nd};function rd(){try{if("undefined"!=typeof performance&&performance.now)return performance.now()}catch(e){}return Date.now()}var od=0;function ad(){od+=1}function ld(){return od}function cd(e,t){return(t!==od||e>6e4)&&!0}var ud=0,dd=0,hd=0,pd={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gd=null,_d=null,fd=[],vd=0,md=0,yd={slowestBatchMs:0},bd={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0};function Sd(e){(ud+=1)>1||(pd={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},fd=[],vd=0,_d=(e=>e&&e>0?e:null)(e),dd=rd(),hd=od)}function wd(){return 0===ud?gd||{durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0}:(ud-=1)>0?pd:(pd.durationMs=rd()-dd,pd.deferredStylesheetCount=vd,bd.deferredCount+=vd,_d=null,cd(pd.durationMs,hd)?pd:gd=pd)}function kd(e,t,i){let n=e.length;if(i>=32)return n;for(let s=0;e.length>s;s++){const r=e[s];try{const e=r.cssRules;if(e&&e.length)n+=kd(e,t,i+1);else if(t&&r.styleSheet){const e=r.styleSheet;if(!t.has(e)){t.add(e);const s=e.rules||e.cssRules;s&&(n+=kd(s,t,i+1))}}}catch(e){}}return n}function Cd(e){if(0===ud)return;const t=kd(e,null,0);pd.cssRuleCount+=t,md>0&&(pd.nonDeferrableCssRuleCount+=t)}function Ed(e){md+=1;try{return e()}finally{md-=1}}function Td(e){ud>0&&(pd.stylesheetMs+=e)}function xd(e){if(0===ud||null===_d)return!1;const t=pd.cssRuleCount-pd.nonDeferrableCssRuleCount;return t>=_d||t+function(e){try{const t=e&&(e.rules||e.cssRules);if(!t)return 0;const i=new WeakSet;return i.add(e),kd(t,i,0)}catch(e){return 0}}(e)>_d}function Id(){const e=fd;return fd=[],e}function Rd(){bd.failedCount+=1}function Pd(e){e>0&&(bd.abandonedCount+=e)}function Md(e){return Md="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Md(e)}function Fd(e,t,i){return(t=function(e){var t=function(e){if("object"!=Md(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=Md(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Md(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ad(e){return e.nodeType===e.ELEMENT_NODE}function Ld(e){const t=e&&"host"in e&&"mode"in e&&sd.host(e)||null;return Boolean(t&&"shadowRoot"in t&&sd.shadowRoot(t)===e)}function Od(e){return"[object ShadowRoot]"==={}.toString.call(e)}function Dd(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),e}function $d(e){const{cssText:t}=e;if(3>t.split('"').length)return t;const i=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?i.push("layer"):e.layerName&&i.push(`layer(${e.layerName})`),e.supportsText&&i.push(`supports(${e.supportsText})`),e.media.length&&i.push(e.media.mediaText),i.join(" ")+";"}var Nd=0;function Bd(e){const t=0===Nd,i=t?rd():0;Nd+=1;try{const t=e.rules||e.cssRules;if(!t)return null;Cd(t);let i=e.href;return!i&&e.ownerNode&&(i=e.ownerNode.baseURI),Dd(Array.from(t,e=>qd(e,i)).join(""))}catch(e){return null}finally{Nd-=1,t&&Td(rd()-i)}}function qd(e,t){if(Ud(e)){let t;try{t=Bd(e.styleSheet)||$d(e)}catch(i){t=e.cssText}try{var i;if(t&&(null===(i=e.styleSheet)||void 0===i?void 0:i.href))return sh(t,e.styleSheet.href)}catch(e){}return t}{let i=e.cssText;return zd(e)&&e.selectorText.includes(":")&&(i=Hd(i)),t?sh(i,t):i}}function Hd(e){return e.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")}function Ud(e){return"styleSheet"in e}function zd(e){return"selectorText"in e}var Wd=/^-?[A-Za-z_][\w-]*$/,jd=/^-?[A-Za-z_][\w-]*(\.-?[A-Za-z_][\w-]*)*$/;function Vd(e){const t=[];let i=!1,n=null;const s=new Map;function r(e){const s=t.pop();if("group"===s.kind){if(null===e){for(;t.length>0&&"group"===t[t.length-1].kind;)t.pop();return void r(null)}const i=t[t.length-1];return i.parts.push(e),void(i.index+=1)}if(!s.importRule)return i=!0,void(n=e);o(t[t.length-1],s.importRule,e)}function o(e,t,i){try{let s;try{s=i||$d(t)}catch(e){s=t.cssText}try{var n;s&&(null===(n=t.styleSheet)||void 0===n?void 0:n.href)&&(s=sh(s,t.styleSheet.href))}catch(e){}s&&e.parts.push(s),e.index+=1}catch(e){r(null)}}function a(e){const i=e.rules[e.index];if("sheet"===e.kind&&Ud(i)){const n=s.get(i);return null===n?(e.parts.push(i.cssText),void(e.index+=1)):n?void t.push({kind:"sheet",sheet:n.sheet,rules:n.rules,sheetHref:n.sheetHref,index:0,parts:[],importRule:i}):void o(e,i,null)}if(function(e,i){try{const n=function(e){const t=e;if(!t.cssRules||0===t.cssRules.length)return null;if(t.media&&"string"==typeof t.media.mediaText)return`@media ${t.media.mediaText} {`;if(zd(e)){if("number"==typeof t.type&&1!==t.type)return null;const i=t.style?t.style.cssText:"";return`${e.selectorText} {${i?" "+i:""}`}if("containerName"in t)return"string"!=typeof t.containerQuery||t.containerName&&!Wd.test(t.containerName)?null:`@container ${t.containerName?`${t.containerName} `:""}${t.containerQuery} {`;if("string"==typeof t.conditionText){let n="";try{var i;n=(null===(i=e.constructor)||void 0===i?void 0:i.name)||""}catch(e){return null}return""===n||"Object"===n||"CSSSupportsRule"===n?`@supports ${t.conditionText} {`:null}return"string"==typeof t.name?"keyText"in t.cssRules[0]?Wd.test(t.name)?`@keyframes ${t.name} {`:null:""===t.name?"@layer {":jd.test(t.name)?`@layer ${t.name} {`:null:null}(e);if(null===n)return!1;const s=i.sheetHref;return t.push({kind:"group",rules:Array.from(e.cssRules),sheetHref:s,index:0,parts:[],prelude:s?sh(n,s):n,fixColons:"sheet"===i.kind&&zd(e)&&e.selectorText.includes(":")}),!0}catch(e){return!1}}(i,e))return;let n=i.cssText;"sheet"===e.kind&&zd(i)&&i.selectorText.includes(":")&&(n=Hd(n)),e.parts.push(e.sheetHref?sh(n,e.sheetHref):n),e.index+=1}return function(e){try{const i=e.rules||e.cssRules;if(!i)return!1;Cd(i);let n=e.href;!n&&e.ownerNode&&(n=e.ownerNode.baseURI);const r=Array.from(i);return t.push({kind:"sheet",sheet:e,rules:r,sheetHref:n,index:0,parts:[],importRule:null}),function(e,t){const i=[{sheet:t,rules:e,index:0}];for(;i.length>0;){const e=i[i.length-1];if(e.index>=e.rules.length){i.pop();continue}const t=e.rules[e.index];if(e.index+=1,!Ud(t)||s.has(t))continue;let n=null;try{n=t.styleSheet}catch(e){s.set(t,null);continue}if(n&&!i.some(e=>e.sheet===n))try{const e=n.rules||n.cssRules;if(!e)continue;Cd(e);let r=n.href;!r&&n.ownerNode&&(r=n.ownerNode.baseURI);const o=Array.from(e);s.set(t,{sheet:n,rules:o,sheetHref:r}),i.push({sheet:n,rules:o,index:0})}catch(e){}}}(r,e),!0}catch(e){return!1}}(e)||(i=!0),{advance(e){if(i)return!0;const s=rd();let o=e>0?e:1;try{for(;!i&&o>0;){const e=t[t.length-1];if(e.index>=e.rules.length){let t=null;try{if("group"===e.kind){const i=e.prelude+e.parts.join("")+"}";t=e.fixColons?Hd(i):i}else t=Dd(e.parts.join(""))}catch(e){}r(t);continue}o-=1;try{a(e)}catch(e){r(null)}}}catch(e){i=!0,n=null}finally{Td(rd()-s)}return i},text:()=>i?n:null,remainingRules(){if(i)return 0;let e=0;for(const i of t)e+=i.rules.length-i.index;return e}}}var Gd=class{constructor(){Fd(this,"idNodeMap",new Map),Fd(this,"nodeMetaMap",new WeakMap)}getId(e){var t,i;return e&&null!==(t=null===(i=this.getMeta(e))||void 0===i?void 0:i.id)&&void 0!==t?t:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);if(this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e)),Ad(e)){const t=sd.shadowRoot(e);t&&this.removeNodeFromMap(t),"IFRAME"===e.nodeName&&e.contentDocument&&this.removeNodeFromMap(e.contentDocument)}}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){this.idNodeMap.set(t.id,e),this.nodeMetaMap.set(e,t)}replace(e,t){const i=this.getNode(e);if(i){const e=this.nodeMetaMap.get(i);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};function Qd({element:e,maskInputOptions:t,tagName:i,type:n,value:s,maskInputFn:r}){let o=s||"";const a=n&&Kd(n);return(t[i.toLowerCase()]||a&&t[a])&&(o=r?r(o,e):"*".repeat(o.length)),o}function Kd(e){return e.toLowerCase()}var Jd=new Set(["rr_width","rr_height","rr_left","rr_top","rr_position","rr_transform","rr_display","rr_scrollleft","rr_scrolltop","rr_mediastate","rr_open_mode"]);function Yd({element:e,name:t,value:i,maskAllElementAttributes:n,maskAttributeFn:s,isGenerated:r=!1}){return i?n?r&&Jd.has(Kd(t))?i:"*".repeat(i.length):s?s(t,i,e):i:i}var Zd="__rrweb_original__";function Xd(e){try{const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Kd(t):null}catch(e){return null}}var eh=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,th=/^(?:[a-z+]+:)?\/\//i,ih=/^www\..*/i,nh=/^(data:)([^,]*),(.*)/i;function sh(e,t){return(e||"").replace(eh,(e,i,n,s,r,o)=>{const a=n||r||o,l=i||s||"";if(!a)return e;if(th.test(a)||ih.test(a))return`url(${l}${a}${l})`;if(nh.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=a.split("#")[0],u=a.substring(c.length),d=t.split("#")[0].split("/"),h=c.split("/");d.pop();for(const e of h)"."!==e&&(".."===e?d.pop():d.push(e));return`url(${l}${d.join("/")}${u}${l})`})}var rh,oh,ah=new Map,lh=1,ch=new RegExp("[^a-z0-9-_:]");function uh(){return lh++}var dh=!1,hh=/^[^ \t\n\r\u000c]+/,ph=/^[, \t\n\r\u000c]+/,gh=new WeakMap;function _h(e,t){return t&&""!==t.trim()?fh(e,t):t}function fh(e,t){let i=gh.get(e);if(i||(i=e.createElement("a"),gh.set(e,i)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return i.setAttribute("href",t),i.href}function vh(e,t){return(null==t?void 0:t.maxBase64ImageLength)?function(e,t){return t&&e.length>t?"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==":e}(e,t.maxBase64ImageLength):e}function mh(e,t,i,n,s,r){if(!n)return n;if("src"===i||"href"===i&&("use"!==t||"#"!==n[0])){const i=_h(e,n);if(i.startsWith("data:")){if("img"===t&&s){let e=i;return((null==r?void 0:r.type)||void 0!==(null==r?void 0:r.quality))&&(e=function(e,t,i,n){if(1e5>t.length)return t;if(!e.complete||0===e.naturalWidth)return t;if(e.naturalWidth>4096||e.naturalHeight>4096)return t;const s=ah.get(t);if(s&&s.type===i&&s.quality===n)return s.result;try{const s=document.createElement("canvas");s.width=e.naturalWidth,s.height=e.naturalHeight;const r=s.getContext("2d");if(!r)return t;r.drawImage(e,0,0);const o=s.toDataURL(i||"image/webp",null!=n?n:.4),a=t.length>o.length?o:t;if(ah.size>=10){const e=ah.keys().next().value;void 0!==e&&ah.delete(e)}return ah.set(t,{type:i,quality:n,result:a}),a}catch(e){return t}}(s,i,r.type,r.quality)),vh(e,r)}if("image"===t)return vh(i,r)}return i}if("xlink:href"===i&&"#"!==n[0]){const i=_h(e,n);return"image"===t&&i.startsWith("data:")?vh(i,r):i}return"background"!==i||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===i?function(e,t){if(""===t.trim())return t;let i=0;function n(e){let n;const s=e.exec(t.substring(i));return s?(n=s[0],i+=n.length,n):""}const s=[];for(;n(ph),t.length>i;){let r=n(hh);if(","===r.slice(-1))r=_h(e,r.substring(0,r.length-1)),s.push(r);else{let n="";r=_h(e,r);let o=!1;for(;;){const e=t.charAt(i);if(""===e){s.push((r+n).trim());break}if(o)")"===e&&(o=!1);else{if(","===e){i+=1,s.push((r+n).trim());break}"("===e&&(o=!0)}n+=e,i+=1}}}return s.join(", ")}(e,n):"style"===i?sh(n,fh(e)):"object"===t&&"data"===i?_h(e,n):n:_h(e,n)}function yh(e,t,i){return("video"===e||"audio"===e)&&"autoplay"===Kd(t)}function bh(e){return"string"==typeof e&&Kd(e).split(/\s+/).includes("stylesheet")}function Sh(e,t,i){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!i&&Sh(sd.parentNode(e),t,i);for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;return!!i&&Sh(sd.parentNode(e),t,i)}function wh(e,t,i,n){let s;if(Ad(e)){if(s=e,!sd.childNodes(s).length)return!1}else{if(null===sd.parentElement(e))return!1;s=sd.parentElement(e)}try{if("string"==typeof t){if(n){if(s.closest(`.${t}`))return!0}else if(s.classList.contains(t))return!0}else if(Sh(s,t,n))return!0;if(i)if(n){if(s.closest(i))return!0}else if(s.matches(i))return!0}catch(e){}return!1}function kh(e,t,i){const n=e.removeEventListener;"function"==typeof n&&n.call(e,t,i)}var Ch=new Map;function Eh(e={}){Ch.forEach((t,i)=>{e.keepChangedLinks&&t.changedLinkBaseline||(t.controller.abort(),Ch.delete(i))})}function Th(e){try{return e.sheet}catch(e){return null}}function xh(e,t,i,n,s){const r=new AbortController,o=()=>{var t;(null===(t=Ch.get(e))||void 0===t?void 0:t.controller)===r&&Ch.delete(e),r.abort()};let a=!1;const l=()=>{if(!a){a=!0;try{t()}finally{o()}}};e.addEventListener("load",l,{signal:r.signal,once:!0}),e.addEventListener("error",o,{signal:r.signal,once:!0});const c=Date.now()+6e4;let u;const d=t=>{const s=n.length>t?n[t]:Math.max(n[n.length-1],1e3);u=setTimeout(()=>{e.isConnected?i()?l():Date.now()<c?d(t+1):o():o()},s)};r.signal.addEventListener("abort",()=>clearTimeout(u),{once:!0}),d(0),Ch.set(e,{controller:r,changedLinkBaseline:s})}var Ih=[100,200,400,800,1600,3200,6400,12800,25600];function Rh(e,t){return Array.from(e.styleSheets).find(e=>e.href===t)}function Ph(e){return null==e?"":e.toLowerCase()}var Mh=!1,Fh=!1;function Ah(e,t){const{doc:i,mirror:n,blockClass:s,blockSelector:r,maskTextClass:o,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p=!1,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f={},inlineImages:v=!1,recordCanvas:m=!1,canvasMaskingConfigured:y,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w=5e3,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E=5e3,keepIframeSrcFn:T=()=>!1,newlyAddedElement:x=!1,depth:I=0,maxDepth:R=50}=t;let{needsMask:P}=t,{preserveWhiteSpace:M=!0}=t;if(I>=R)return Fh=!0,Mh||(Mh=!0,console.warn(`[rrweb-snapshot] DOM tree depth exceeded max depth of ${R}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`)),null;P||(P=wh(e,o,a,void 0===P)),ud>0&&(pd.nodeCount+=1);const F=function(e,t){const{doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:o,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:u,maskAllElementAttributes:d=!1,maskAttributeFn:h,dataURLOptions:p={},inlineImages:g,recordCanvas:_,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const i=t.getId(e);return 1===i?void 0:i}(i,n);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:ju.Document,childNodes:[],compatMode:e.compatMode}:{type:ju.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:ju.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:i,blockClass:n,blockSelector:s,inlineStylesheet:r,maskInputOptions:o={},maskInputFn:a,maskAllElementAttributes:l=!1,maskAttributeFn:c,dataURLOptions:u={},inlineImages:d,recordCanvas:h,canvasMaskingConfigured:p,keepIframeSrcFn:g,newlyAddedElement:_=!1,rootId:f}=t,v=function(e,t,i){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;if(i)return e.matches(i)}catch(e){}return!1}(e,n,s),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=Kd(e.tagName);return ch.test(t)?"div":t}(e),y=new Set;let b={};const S=e.attributes.length;for(let t=0;S>t;t++){const n=e.attributes[t];yh(m,n.name)||(b[n.name]=mh(i,m,Kd(n.name),n.value,e,u))}if("link"===m&&"string"==typeof b.href){var w;const t=null===(w=Th(e))||void 0===w?void 0:w.href;t&&(b.href=t)}if("link"===m&&r&&!v&&bh(b.rel)){let t=e.sheet;if(!t){const n=function(e){return e.href}(e);n&&(t=Rh(i,n),!t&&n.includes(".css"))&&(t=Rh(i,window.location.origin+"/"+n.replace(window.location.href,"")))}let n=null;t&&(xd(t)?ud>0&&(fd.push(e),vd+=1):n=Bd(t)),n&&(delete b.rel,delete b.href,b._cssText=n)}var k;if("style"===m&&e.sheet&&!(e.innerText||sd.textContent(e)||"").trim().length){const t=Ed(()=>Bd(e.sheet));t&&(b._cssText=t)}if("input"===m||"textarea"===m||"select"===m){const t=e.value,i=e.checked;"radio"!==b.type&&"checkbox"!==b.type&&"submit"!==b.type&&"button"!==b.type&&t?b.value=Qd({element:e,type:Xd(e),tagName:m,value:t,maskInputOptions:o,maskInputFn:a}):i&&(b.checked=i)}if("option"===m&&(e.selected&&!o.select?b.selected=!0:delete b.selected),"dialog"===m&&e.open){try{b.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"}catch(e){b.rr_open_mode="modal",b.ph_rr_could_not_detect_modal=!0}y.add("rr_open_mode")}if("canvas"===m&&h&&!(null==p?void 0:p()))try{if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let i=0;e.width>i;i+=50)for(let n=0;e.height>n;n+=50){const s=t.getImageData,r=Zd in s?s[Zd]:s;let o;try{o=r.call(t,i,n,Math.min(50,e.width-i),Math.min(50,e.height-n))}catch(e){return!1}if(new Uint32Array(o.data.buffer).some(e=>0!==e))return!1}return!0})(e)||(b.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){const t=e.toDataURL(u.type,u.quality),n=i.createElement("canvas");n.width=e.width,n.height=e.height,t!==n.toDataURL(u.type,u.quality)&&(b.rr_dataURL=t)}}catch(e){"SecurityError"===(null==(k=e)?void 0:k.name)?dh||(dh=!0,console.warn("Cannot read canvas pixels, so this canvas is left out of the recording. A cross-origin image or video drawn into it taints it.",k)):console.warn("Cannot read canvas pixels, so this canvas is left out of the recording.",k)}let C,E=!1;if("img"===m&&d){rh||(rh=i.createElement("canvas"),oh=rh.getContext("2d"));const t=e,n=t.currentSrc||t.getAttribute("src")||"<unknown-src>",s=t.crossOrigin,r=(t,i)=>E?Yd({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c}):i,o=()=>{kh(t,"load",o);try{rh.width=t.naturalWidth,rh.height=t.naturalHeight,oh.drawImage(t,0,0);const e=rh.toDataURL(u.type,u.quality);b.rr_dataURL=r("rr_dataURL",e)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o));console.warn(`Cannot inline img src=${n}! Error: ${e}`)}"anonymous"===t.crossOrigin&&(s?b.crossOrigin=r("crossOrigin",s):t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}if("audio"===m||"video"===m){const t=b;t.rr_mediaState=e.paused?"paused":"played",y.add("rr_mediaState"),t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}if(_||(e.scrollLeft&&(b.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(b.rr_scrollTop=e.scrollTop)),v){var T,x,I;const{width:t,height:n,left:s,top:r}=e.getBoundingClientRect(),o=null===(T=i.defaultView)||void 0===T?void 0:T.getComputedStyle(e);b={class:b.class,rr_width:`${t}px`,rr_height:`${n}px`,rr_left:`${Math.floor(s+((null===(x=i.defaultView)||void 0===x?void 0:x.scrollX)||0))}px`,rr_top:`${Math.floor(r+((null===(I=i.defaultView)||void 0===I?void 0:I.scrollY)||0))}px`},y.add("rr_width"),y.add("rr_height"),y.add("rr_left"),y.add("rr_top"),o&&(b.rr_position=o.position||"static",y.add("rr_position"),o.transform&&"none"!==o.transform&&(b.rr_transform=o.transform,y.add("rr_transform")),o.display&&o.display.startsWith("inline")&&(b.rr_display=o.display,y.add("rr_display")))}if("iframe"!==m||g(b.src)||(e.contentDocument||(b.rr_src=b.src),delete b.src),l||c)for(const[t,i]of Object.entries(b))"string"!=typeof i&&null!==i||(b[t]=Yd({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c,isGenerated:y.has(t)}));E=!0;try{customElements.get(m)&&(C=!0)}catch(e){}return{type:ju.Element,tagName:m,attributes:b,childNodes:[],isSVG:(R=e,Boolean("svg"===R.tagName||R.ownerSVGElement)||void 0),needBlock:v,rootId:f,isCustom:C};var R}(e,{doc:i,blockClass:s,blockSelector:r,inlineStylesheet:a,maskInputOptions:l,maskInputFn:u,maskAllElementAttributes:d,maskAttributeFn:h,dataURLOptions:p,inlineImages:g,recordCanvas:_,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:i,maskTextFn:n,rootId:s}=t,r=sd.parentNode(e),o=r&&r.tagName;let a=sd.textContent(e);const l="STYLE"===o||void 0,c="SCRIPT"===o||void 0;if(l&&a){try{var u;if(e.nextSibling||e.previousSibling);else if(xd(r.sheet));else if(null===(u=r.sheet)||void 0===u?void 0:u.cssRules){const e=Bd(r.sheet);e&&!/(?:^|[\s;{}])-?[a-zA-Z][\w-]*\s*:\s*;/.test(e)&&(a=e)}}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}a=sh(a,fh(t.doc))}return c&&(a="SCRIPT_PLACEHOLDER"),!l&&!c&&a&&i&&(a=n?n(a,sd.parentElement(e)):a.replace(/[\S]/g,"*")),{type:ju.Text,textContent:a||"",isStyle:l,rootId:s}}(e,{doc:i,needsMask:o,maskTextFn:c,rootId:y});case e.CDATA_SECTION_NODE:return{type:ju.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:ju.Comment,textContent:sd.textContent(e)||"",rootId:y};default:return!1}}(e,{doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:P,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,keepIframeSrcFn:T,newlyAddedElement:x});if(!F)return console.warn(e,"not serialized"),null;let A;A=n.hasNode(e)?n.getId(e):function(e,t){if(t.comment&&e.type===ju.Comment)return!0;if(e.type===ju.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===function(e){var t;let i;try{i=new URL(e,window.location.href)}catch(e){return null}const n=i.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(t=null==n?void 0:n[1])&&void 0!==t?t:null}(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Ph(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Ph(e.attributes.name)||["icon","apple-touch-icon","shortcut icon"].includes(Ph(e.attributes.rel)))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Ph(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Ph(e.attributes.property).match(/^(og|twitter|fb):/)||Ph(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Ph(e.attributes.name)))return!0;if(t.headMetaRobots&&["robots","googlebot","bingbot"].includes(Ph(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&(["author","generator","framework","publisher","progid"].includes(Ph(e.attributes.name))||Ph(e.attributes.property).match(/^article:/)||Ph(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&["google-site-verification","yandex-verification","csrf-token","p:domain_verify","verify-v1","verification","shopify-checkout-api-token"].includes(Ph(e.attributes.name)))return!0}}return!1}(F,_)||!M&&F.type===ju.Text&&!F.isStyle&&!F.textContent.replace(/^\s+|\s+$/gm,"").length?-2:uh();const L=Object.assign(F,{id:A});if(n.add(e,L),-2===A)return null;b&&b(e);let O=!l;if(L.type===ju.Element){O=O&&!L.needBlock,delete L.needBlock;const t=sd.shadowRoot(e);t&&Od(t)&&(L.isShadowHost=!0)}if((L.type===ju.Document||L.type===ju.Element)&&O){_.headWhitespace&&L.type===ju.Element&&"head"===L.tagName&&(M=!1);const t={doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:P,maskTextClass:o,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:T,depth:I+1,maxDepth:R};if(L.type===ju.Element&&"textarea"===L.tagName&&void 0!==L.attributes.value);else for(const i of Array.from(sd.childNodes(e))){const e=Ah(i,t);e&&L.childNodes.push(e)}let x=null;if(Ad(e)&&(x=sd.shadowRoot(e)))for(const e of Array.from(sd.childNodes(x))){const i=Ah(e,t);i&&(Od(x)&&(i.isShadow=!0),L.childNodes.push(i))}}const D=sd.parentNode(e);if(D&&Ld(D)&&Od(D)&&(L.isShadow=!0),L.type===ju.Element&&"iframe"===L.tagName){const t=function(e,t,i){const n=()=>{},s=e.contentWindow;if(!s)return n;let r;try{r=s.document.readyState}catch(e){return n}const o=()=>t();if("complete"!==r){let n=!1,s=null;const r=()=>{n||(n=!0,null!==s&&(clearTimeout(s),s=null),kh(e,"load",a),e.addEventListener("load",o),t())},a=()=>r();return s=setTimeout(r,i),e.addEventListener("load",a),()=>{null!==s&&(clearTimeout(s),s=null),n?kh(e,"load",o):(n=!0,kh(e,"load",a))}}const a="about:blank";let l;try{l=s.location.href}catch(e){return n}if(l!==a||e.src===a||""===e.src){const i=setTimeout(t,0);return e.addEventListener("load",o),()=>{clearTimeout(i),kh(e,"load",o)}}return e.addEventListener("load",o),()=>{kh(e,"load",o)}}(e,()=>{const t=e.contentDocument;if(t&&S){const i=Ah(t,{doc:t,mirror:n,blockClass:s,blockSelector:r,needsMask:P,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:T,depth:I+1,maxDepth:R});i&&S(e,i)}},w);null==k||k(e,t)}var N,B,q;return L.type===ju.Element&&"link"===L.tagName&&bh(L.attributes.rel)&&(B=()=>{if(C){const t=n.getMeta(e),l=Ah(e,{doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:P,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:T,depth:I,maxDepth:R});l&&C(e,l,t)}},q=E,Ch.has(N=e)||Th(N)||xh(N,B,()=>Boolean(Th(N)),[q])),L}function Lh(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:!1===e?{}:e}var Oh=class e{constructor(...e){Fd(this,"parentElement",null),Fd(this,"parentNode",null),Fd(this,"ownerDocument",void 0),Fd(this,"firstChild",null),Fd(this,"lastChild",null),Fd(this,"previousSibling",null),Fd(this,"nextSibling",null),Fd(this,"ELEMENT_NODE",1),Fd(this,"TEXT_NODE",3),Fd(this,"nodeType",void 0),Fd(this,"nodeName",void 0),Fd(this,"RRNodeType",void 0)}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};function Dh(e,t,i=document){const n={capture:!0,passive:!0};return i.addEventListener(e,t,n),()=>$h(i,e,t,n)}function $h(e,t,i,n){Nh(()=>{const s=e.removeEventListener;"function"==typeof s&&(void 0!==n?s.call(e,t,i,n):s.call(e,t,i))})}function Nh(e){try{e()}catch(e){if(!(e instanceof DOMException&&"SecurityError"===e.name))throw e}}function Bh(e){e.forEach(e=>{if("function"==typeof e)try{e()}catch(e){}})}var qh="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",Hh={map:{},getId(){return console.warn(qh),-1},getNode(){return console.warn(qh),null},removeNodeFromMap(){console.warn(qh)},has(){return console.warn(qh),!1},reset(){console.warn(qh)}};function Uh(e,t,i={}){let n=null,s=0;return function(...r){const o=Date.now();s||!1!==i.leading||(s=o);const a=t-(o-s),l=this;0>=a||a>t?(n&&(clearTimeout(n),n=null),s=o,e.apply(l,r)):n||!1===i.trailing||(n=setTimeout(()=>{s=!1===i.leading?0:Date.now(),n=null,e.apply(l,r)},a))}}function zh(e,t,i,n,s=window){const r=s.Object.getOwnPropertyDescriptor(e,t),o=()=>zh(e,t,r||{},!0);if(n)return s.Object.defineProperty(e,t,i),o;const a=function(e){let t="function"==typeof e.setTimeout?e.setTimeout:void 0;try{var i,n;const s=null===(i=e.Zone)||void 0===i||null===(n=i.__symbol__)||void 0===n?void 0:n.call(i,"setTimeout"),r=s?e[s]:void 0;"function"==typeof r&&(t=r)}catch(e){}if(!t)return()=>{};const s=t;return t=>{try{s.call(e,t,0)}catch(e){}}}(s);return s.Object.defineProperty(e,t,{set(e){if(a(()=>{try{i.set.call(this,e)}catch(e){}}),r&&r.set){if(r.get)try{r.get.call(this)}catch(e){return}r.set.call(this,e)}}}),o}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Hh=new Proxy(Hh,{get(e,t,i){return"map"===t&&console.warn(qh),Reflect.get(e,t,i)}}));var Wh=Date.now;function jh(e){var t,i,n,s;const r=e.document;return{left:r.scrollingElement?r.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:r.documentElement.scrollLeft||(null==r?void 0:r.body)&&(null===(t=sd.parentElement(r.body))||void 0===t?void 0:t.scrollLeft)||(null==r||null===(i=r.body)||void 0===i?void 0:i.scrollLeft)||0,top:r.scrollingElement?r.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==r?void 0:r.documentElement.scrollTop)||(null==r?void 0:r.body)&&(null===(n=sd.parentElement(r.body))||void 0===n?void 0:n.scrollTop)||(null==r||null===(s=r.body)||void 0===s?void 0:s.scrollTop)||0}}function Vh(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Gh(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Qh(e){return e?e.nodeType===e.ELEMENT_NODE?e:sd.parentElement(e):null}function Kh(e,t,i,n){if(!e)return!1;const s=Qh(e);if(!s)return!1;try{if("string"==typeof t){if(s.classList.contains(t))return!0;if(n&&null!==s.closest("."+t))return!0}else if(Sh(s,t,n))return!0}catch(e){}if(i){if(s.matches(i))return!0;if(n&&null!==s.closest(i))return!0}return!1}function Jh(e,t,i){const n=t&&"string"!=typeof t&&(t.global||t.sticky)?new RegExp(t):null;for(;e;){if(n&&(n.lastIndex=0),Kh(e,n||t,i,!0))return!0;const s="getRootNode"in e?sd.getRootNode(e):null;e=(null==s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE?sd.host(s):null}return!1}function Yh(e,t,i){return!("TITLE"!==e.tagName||!i.headTitleMutations)||-2===t.getId(e)}function Zh(e,t){if(Ld(e))return!1;const i=t.getId(e);if(!t.has(i))return!0;const n=sd.parentNode(e);return(!n||n.nodeType!==e.DOCUMENT_NODE)&&(!n||Zh(n,t))}function Xh(e){return Boolean(e.changedTouches)}function ep(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function tp(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function ip(e){return!!e&&(e instanceof Oh&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(sd.shadowRoot(e)))}/[1-9][0-9]{12}/.test(Date.now().toString())||(Wh=()=>(new Date).getTime());var np=class{constructor(){Fd(this,"id",1),Fd(this,"styleIDMap",new WeakMap),Fd(this,"idStyleMap",new Map)}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let i;return i=void 0===t?this.id++:t,this.styleIDMap.set(e,i),this.idStyleMap.set(i,e),i}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};function sp(e){var t;let i=null;return"getRootNode"in e&&(null===(t=sd.getRootNode(e))||void 0===t?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&sd.host(sd.getRootNode(e))&&(i=sd.host(sd.getRootNode(e))),i}function rp(e){const t=e.ownerDocument;if(!t)return!1;if(sd.contains(t,e))return!0;const i=sd.isConnected(e);return"boolean"==typeof i?i:function(e){const t=e.ownerDocument;if(!t)return!1;const i=function(e){let t,i=e;for(;t=sp(i);)i=t;return i}(e);return sd.contains(t,i)}(e)}var op,ap=(e,t)=>`${e}@${t}`,lp=class{constructor(){Fd(this,"frozen",!1),Fd(this,"locked",!1),Fd(this,"takePendingRecords",void 0),Fd(this,"texts",[]),Fd(this,"attributes",[]),Fd(this,"attributeMap",new WeakMap),Fd(this,"generatedAttributes",new WeakMap),Fd(this,"removes",[]),Fd(this,"mapRemoves",new Set),Fd(this,"movedMap",{}),Fd(this,"addedSet",new Set),Fd(this,"movedSet",new Set),Fd(this,"droppedSet",new Set),Fd(this,"removesSubTreeCache",new Set),Fd(this,"mutationCb",void 0),Fd(this,"blockClass",void 0),Fd(this,"blockSelector",void 0),Fd(this,"maskTextClass",void 0),Fd(this,"maskTextSelector",void 0),Fd(this,"inlineStylesheet",void 0),Fd(this,"maskInputOptions",void 0),Fd(this,"maskTextFn",void 0),Fd(this,"maskInputFn",void 0),Fd(this,"maskAllElementAttributes",void 0),Fd(this,"maskAttributeFn",void 0),Fd(this,"keepIframeSrcFn",void 0),Fd(this,"recordCanvas",void 0),Fd(this,"canvasMaskingConfigured",void 0),Fd(this,"inlineImages",void 0),Fd(this,"slimDOMOptions",void 0),Fd(this,"dataURLOptions",void 0),Fd(this,"doc",void 0),Fd(this,"mirror",void 0),Fd(this,"iframeManager",void 0),Fd(this,"stylesheetManager",void 0),Fd(this,"shadowDomManager",void 0),Fd(this,"canvasManager",void 0),Fd(this,"processedNodeManager",void 0),Fd(this,"unattachedDoc",void 0),Fd(this,"canvasManagerReleased",!1),Fd(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),Fd(this,"emit",()=>{if(this.frozen||this.locked)return;const e=rd(),t=ld();try{this.processBufferedMutations()}finally{i=rd()-e,n=t,ud>0||cd(i,null!=n?n:od)||i>yd.slowestBatchMs&&(yd.slowestBatchMs=i)}var i,n}),Fd(this,"processBufferedMutations",()=>{const e=[],t=new Set,i=e=>{let t=e,i=-2;for(;-2===i;)t=t&&sd.nextSibling(t),i=t&&this.mirror.getId(t);return i};let n;const s=s=>{var r;const o=sd.parentNode(s);if(!o||!rp(s)||"TEXTAREA"===o.tagName)return!0;if(this.isBlockedAtEmission(o))return!0;const a=Ld(o)?this.mirror.getId(sp(s)):this.mirror.getId(o),l=i(s);if(-1===a||-1===l)return!1;null!==(r=n)&&void 0!==r||(n=this.buildSerializationOptions());const c=Ah(s,n);return c&&(e.push({parentId:a,nextId:l,node:c}),t.add(c.id)),!0};for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e);for(const e of this.movedSet)up(this.removesSubTreeCache,e)&&!this.movedSet.has(sd.parentNode(e))||this.addedSet.add(e);for(const e of Array.from(this.addedSet)){const t=dp(this.droppedSet,e),i=up(this.removesSubTreeCache,e),n=this.movedSet.has(e)||dp(this.movedSet,e);!t&&!i||n||(this.droppedSet.add(e),this.addedSet.delete(e))}const r=new Set;let o=null;const a=this.addedSet.values();let l=a.next();for(;this.addedSet.size;){let e=null;if(null!==o)for(e=sd.previousSibling(o);e&&-2===this.mirror.getId(e);)e=sd.previousSibling(e);if(e&&this.addedSet.has(e))o=e;else{for(this.addedSet.has(l.value)||(l=a.next()),o=l.value;;){const e=sd.parentNode(o),t=e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?sd.host(e):e;if(!t||!this.addedSet.has(t))break;o=t}const e=sd.parentNode(o);if(e&&this.addedSet.has(sd.lastChild(e)))o=sd.lastChild(e);else if(e)for(;;){let e=sd.nextSibling(o);for(;e&&-2===this.mirror.getId(e);)e=sd.nextSibling(e);if(!e||!this.addedSet.has(e))break;o=e}}this.addedSet.delete(o);const t=sd.parentNode(o),i=t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?sd.host(t):t;i&&r.has(i)?r.add(o):s(o)||r.add(o)}r.size>0&&console.warn(`[rrweb] dropped ${r.size} node(s) with unresolved parent at emit`);const c={texts:this.texts.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const t=e.node,i=sd.parentNode(t);return i&&"TEXTAREA"===i.tagName&&this.genTextAreaValueMutation(i),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const{attributes:t}=e;if(!this.maskAllElementAttributes&&!this.maskAttributeFn&&"string"==typeof t.style){const i=JSON.stringify(e.styleDiff),n=JSON.stringify(e._unchangedStyles);t.style.length>i.length&&(i+n).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}if(this.maskAllElementAttributes||this.maskAttributeFn)for(const[n,s]of Object.entries(t))if("string"==typeof s||null===s){var i;t[n]=Yd({element:e.node,name:n,value:s,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,isGenerated:null===(i=this.generatedAttributes.get(e.node))||void 0===i?void 0:i.has(n)})}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e},u=[];if(this.inlineStylesheet)for(const{id:e,attributes:t}of c.attributes){if(!("rel"in t)&&!("href"in t))continue;const i=this.mirror.getNode(e);i&&"link"===Kd(i.nodeName)&&bh(i.getAttribute("rel"))&&i.getAttribute("href")&&!i.disabled&&u.push(i)}if(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.generatedAttributes=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},c.texts.length||c.attributes.length||c.removes.length||c.adds.length){this.mutationCb(c);for(const e of u)this.stylesheetManager.inlineLinkStylesheetAfterChange(e,{currentId:()=>this.mirror.getId(e),reserializeWithoutCss:()=>({previous:this.mirror.getMeta(e),current:Ah(e,ct(ct({},this.buildSerializationOptions()),{},{inlineStylesheet:!1}))}),lastSerialization:()=>this.mirror.getMeta(e),readdAsMove:()=>this.recordReinsertion(e)})}}),Fd(this,"bufferBelongsToIframe",e=>this.doc===e.contentDocument),Fd(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const i=Array.from(sd.childNodes(e),e=>sd.textContent(e)||"").join("");t.attributes.value=Qd({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Xd(e),value:i,maskInputFn:this.maskInputFn})}),Fd(this,"processMutation",e=>{if(!Yh(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=sd.textContent(e.target);Kh(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:wh(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,Qh(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{var t;const n=e.target,s=Kd(n.tagName),r=e.attributeName,o=null!==(t=e.attributeNamespace)&&void 0!==t?t:null;let a=function(e,t,i){if(!i)return t;const n=e.getAttributeNodeNS(i,t);if(n)return n.name;if("http://www.w3.org/1999/xlink"===i)return`xlink:${t}`;if("http://www.w3.org/XML/1998/namespace"===i)return`xml:${t}`;if("http://www.w3.org/2000/xmlns/"===i)return"xmlns"===t?t:`xmlns:${t}`;const s=e.lookupPrefix(i);return s?`${s}:${t}`:t}(n,r,o),l=o?n.getAttributeNS(o,r):e.target.getAttribute(r);if("value"===a){const e=n,t=Xd(e);l=Qd({element:e,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:t,value:l,maskInputFn:this.maskInputFn})}if(Kh(e.target,this.blockClass,this.blockSelector,!1)||l===e.oldValue)return;let c=this.attributeMap.get(e.target);const u="iframe"===s&&"src"===a;if(u&&!this.keepIframeSrcFn(l)&&n.contentDocument)return;if("type"===a&&"input"===s&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!yh(s,a)){var i;c||(c={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(c),this.attributeMap.set(e.target,c));const t=mh(this.doc,s,Kd(a),l,n,this.dataURLOptions);if(u&&!this.keepIframeSrcFn(l)&&(a="rr_src"),c.attributes[a]=t,null===(i=this.generatedAttributes.get(e.target))||void 0===i||i.delete(a),"style"===a){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const t=this.unattachedDoc.createElement("span"),i=n.style;e.oldValue&&(t.style.cssText=e.oldValue);for(const e of Array.from(i)){const n=i.getPropertyValue(e),s=i.getPropertyPriority(e);n!==t.style.getPropertyValue(e)||s!==t.style.getPropertyPriority(e)?c.styleDiff[e]=""===s?n:[n,s]:c._unchangedStyles[e]=[n,s]}for(const e of Array.from(t.style))""===i.getPropertyValue(e)&&(c.styleDiff[e]=!1)}else if("open"===a&&"dialog"===s){c.attributes.rr_open_mode=n.matches("dialog:modal")?"modal":"non-modal";let t=this.generatedAttributes.get(e.target);t||(t=new Set,this.generatedAttributes.set(e.target,t)),t.add("rr_open_mode")}}break}case"childList":if(e.removedNodes.forEach(e=>{rp(e)||this.shadowDomManager.removeShadowRootsIn(e)}),Kh(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const i=this.mirror.getId(t),n=Ld(e.target)?this.mirror.getId(sd.host(e.target)):this.mirror.getId(e.target);Kh(e.target,this.blockClass,this.blockSelector,!1)||Yh(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(cp(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===i||Zh(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[ap(i,n)]?cp(this.movedSet,t):(this.removes.push({parentId:n,id:i,isShadow:!(!Ld(e.target)||!Od(e.target))||void 0}),function(e,t){const i=[e];for(;i.length;){const e=i.pop();t.has(e)||(t.add(e),sd.childNodes(e).forEach(e=>i.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.add(t))})}}),Fd(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)){if(this.addedSet.has(e))return this.addedSet.delete(e),void this.addedSet.add(e);if(!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(Yh(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let i=null;t&&this.mirror.hasNode(t)&&(i=this.mirror.getId(t)),i&&-1!==i&&(this.movedMap[ap(this.mirror.getId(e),i)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);if(!Kh(e,this.blockClass,this.blockSelector,!1)){if(e.nodeType===e.TEXT_NODE)return;const t=sd.childNodes(e);for(let e=0,i=t.length;i>e;e++){const i=t[e];i&&this.genAdds(i)}if(ip(e)){const t=sd.childNodes(sd.shadowRoot(e));for(let i=0,n=t.length;n>i;i++){const n=t[i];n&&(this.processedNodeManager.add(n,this),this.genAdds(n,e))}}}}}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","maskAllElementAttributes","maskAttributeFn","keepIframeSrcFn","recordCanvas","canvasMaskingConfigured","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]}),this.canvasManager.acquire()}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}readPendingRecordsFrom(e){this.takePendingRecords=()=>e.takeRecords()}reset(){this.releaseCanvasManager()}releaseCanvasManager(){this.canvasManagerReleased||(this.canvasManagerReleased=!0,this.canvasManager.reset())}bufferDoc(){return this.doc}destroy(){for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e)}isBlockedAtEmission(e){return Jh(e,this.blockClass,this.blockSelector)}recordReinsertion(e){var t;const i=sd.parentNode(e);if(!i)return;null===(t=this.takePendingRecords)||void 0===t||t.call(this).forEach(this.processMutation);const n=(e,t)=>({type:"childList",target:i,removedNodes:e,addedNodes:t,oldValue:null,attributeName:null});this.processMutation(n([e],[])),this.processMutation(n([],[e])),this.emit()}buildSerializationOptions(){return{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,canvasMaskingConfigured:this.canvasMaskingConfigured,inlineImages:this.inlineImages,onSerialize:e=>{ep(e,this.mirror)&&this.iframeManager.addIframe(e),tp(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ip(e)&&!Kh(e,this.blockClass,this.blockSelector,!0)&&this.shadowDomManager.addShadowRoot(sd.shadowRoot(e),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onIframeListenerRegistered:(e,t)=>{this.iframeManager.registerLoadListenerDisposer(e,t)},onStylesheetLoad:(e,t,i)=>{this.stylesheetManager.attachLinkElement(e,t,i)}}}};function cp(e,t){const i=[t];for(;i.length;){const t=i.pop();if(e.delete(t),t.nodeType===t.TEXT_NODE)continue;const n=sd.childNodes(t);for(let e=0,t=n.length;t>e;e++){const t=n[e];t&&i.push(t)}}}function up(e,t,i){return 0!==e.size&&function(e,t){const i=sd.parentNode(t);return!!i&&e.has(i)}(e,t)}function dp(e,t){if(0===e.size)return!1;let i=sd.parentNode(t);for(;i;){if(e.has(i))return!0;i=sd.parentNode(i)}return!1}function hp(e){op=e}function pp(){op=void 0}var gp=(e,t="rrweb")=>op?(...i)=>{try{return e(...i)}catch(e){if(op&&!0===op(e,t))return;throw e}}:e,_p=[];function fp(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function vp(e,t){const i=new lp;let n;i.init(e);try{n=new(id())(gp(i.processMutations.bind(i)));const s={attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};return e.attributeFilter&&e.attributeFilter.length>0&&(s.attributeFilter=e.attributeFilter),n.observe(t,s),i.readPendingRecordsFrom(n),_p.push(i),{observer:n,buffer:i}}catch(e){try{null==n||n.disconnect(),i.destroy(),i.reset()}catch(e){}throw e}}function mp({scrollCb:e,doc:t,mirror:i,blockClass:n,blockSelector:s,sampling:r}){const o=new Map,a=r=>{const a=fp(r);if(!a||Kh(a,n,s,!0))return;const l=i.getId(a);let c,u;if(a===t&&t.defaultView){const e=jh(t.defaultView);c=e.left,u=e.top}else c=a.scrollLeft,u=a.scrollTop;const d=`${c},${u}`;o.get(l)!==d&&(o.set(l,d),e({id:l,x:c,y:u}))},l=[Dh("scroll",gp(Uh(gp(e=>a(e)),r.scroll||100)),t)];return"onscrollend"in t&&l.push(Dh("scrollend",gp(a),t)),()=>l.forEach(e=>e())}function yp(e,t){for(let i=_p.length-1;i>=0;i--){const n=_p[i];if(!n)continue;let s=n.bufferBelongsToIframe(e);!s&&t&&t.has(n.bufferDoc())&&(s=!0),s&&(n.reset(),_p.splice(i,1))}}var bp=["INPUT","TEXTAREA","SELECT"],Sp=new WeakMap;function wp(e){return function e(t,i){if(xp("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||xp("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||xp("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||xp("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);return i.unshift(n),e(t.parentRule,i)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);i.unshift(e)}return i}(e,[])}function kp(e,t,i){let n,s;return e?(e.ownerNode?n=t.getId(e.ownerNode):s=i.getId(e),{styleId:s,id:n}):{}}function Cp({mirror:e,stylesheetManager:t},i){var n,s;let r=null;r=e.getId("#document"===i.nodeName?i:sd.host(i));const o="#document"===i.nodeName?null===(n=i.defaultView)||void 0===n?void 0:n.Document:null===(s=i.ownerDocument)||void 0===s||null===(s=s.defaultView)||void 0===s?void 0:s.ShadowRoot,a=(null==o?void 0:o.prototype)?Object.getOwnPropertyDescriptor(null==o?void 0:o.prototype,"adoptedStyleSheets"):void 0;return null!==r&&-1!==r&&o&&a?(Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var e;return null===(e=a.get)||void 0===e?void 0:e.call(this)},set(e){let i;try{var n;i=null===(n=a.set)||void 0===n?void 0:n.call(this,e)}catch(e){if(e&&"object"==typeof e&&"NotAllowedError"===e.name)return;throw e}if(null!==r&&-1!==r)try{t.adoptStyleSheets(e,r)}catch(e){}return i}}),gp(()=>{Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})):()=>{}}var Ep=new Set;function Tp(e,t={}){const i=e.doc.defaultView;if(!i)return()=>{};let n,s;!function(e,t){const{mutationCb:i,mousemoveCb:n,mouseInteractionCb:s,scrollCb:r,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p,customElementCb:g}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),i(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),n(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),s(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),r(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),o(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),g(...e)}}(e,t);const r=[],o=gp(()=>{try{if(s)try{s.destroy(),s.reset()}finally{const e=_p.indexOf(s);-1!==e&&_p.splice(e,1)}e.shadowDomManager.resetForDoc(e.doc),null==n||n.disconnect()}finally{Bh(r)}}),a=(e,t)=>{const i=gp(()=>{try{return t()}catch(t){throw Ep.add(e),t}})();"function"==typeof i&&r.push(i)};try{if(e.recordDOM&&a("mutation",()=>{const t=vp(e,e.doc);n=t.observer,s=t.buffer}),a("move",()=>function({mousemoveCb:e,sampling:t,doc:i,mirror:n}){if(!1===t.mousemove)return()=>{};const s="number"==typeof t.mousemove?t.mousemove:50,r="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let o,a=[];const l=Uh(gp(t=>{const i=Date.now()-o;e(a.map(e=>(e.timeOffset-=i,e)),t),a=[],o=null}),r),c=gp(Uh(gp(e=>{const t=fp(e),{clientX:i,clientY:s}=Xh(e)?e.changedTouches[0]:e;o||(o=Wh()),a.push({x:i,y:s,id:n.getId(t),timeOffset:Wh()-o}),l("drag"===e.type?qu.Drag:"touchmove"===e.type?qu.TouchMove:qu.MouseMove)}),s,{trailing:!1})),u=[Dh("mousemove",c,i),Dh("touchmove",c,i),Dh("drag",c,i)];return gp(()=>{u.forEach(e=>e())})}(e)),a("mouseInteraction",()=>function({mouseInteractionCb:e,doc:t,mirror:i,blockClass:n,blockSelector:s,sampling:r}){if(!1===r.mouseInteraction)return()=>{};const o=!0===r.mouseInteraction||void 0===r.mouseInteraction?{}:r.mouseInteraction,a=[];let l=null;return Object.keys(Hu).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==o[e]).forEach(r=>{let o=Kd(r);const c=(t=>r=>{const o=fp(r);if(Kh(o,n,s,!0))return;let a=null,c=t;if("pointerType"in r){switch(r.pointerType){case"mouse":a=Uu.Mouse;break;case"touch":a=Uu.Touch;break;case"pen":a=Uu.Pen}a===Uu.Touch&&(Hu[t]===Hu.MouseDown?c="TouchStart":Hu[t]===Hu.MouseUp&&(c="TouchEnd"))}else Xh(r)&&(a=Uu.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Uu.Touch||c.startsWith("Mouse")&&a===Uu.Mouse)&&(a=null)):Hu[t]===Hu.Click&&(a=l,l=null);const u=Xh(r)?r.changedTouches[0]:r;if(!u)return;const d=i.getId(o),{clientX:h,clientY:p}=u;gp(e)(ct({type:Hu[c],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(r);if(window.PointerEvent)switch(Hu[r]){case Hu.MouseDown:case Hu.MouseUp:o=o.replace("mouse","pointer");break;case Hu.TouchStart:case Hu.TouchEnd:return}a.push(Dh(o,c,t))}),gp(()=>{a.forEach(e=>e())})}(e)),a("scroll",()=>mp(e)),a("viewportResize",()=>function({viewportResizeCb:e},{win:t}){let i=-1,n=-1;return Dh("resize",gp(Uh(gp(()=>{const t=Vh(),s=Gh();i===t&&n===s||(e({width:Number(s),height:Number(t)}),i=t,n=s)}),200)),t)}(e,{win:i})),a("input",()=>function({inputCb:e,doc:t,mirror:i,blockClass:n,blockSelector:s,ignoreClass:r,ignoreSelector:o,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:u}){function d(e){let i=fp(e);const c=e.isTrusted,d=t.defaultView;if(i&&d&&!(i instanceof d.HTMLElement))return;const p=i&&i.tagName;if(i&&"OPTION"===p&&(i=sd.parentElement(i)),!i||!p||0>bp.indexOf(p)||Kh(i,n,s,!0))return;if(i.classList.contains(r)||o&&i.matches(o))return;let g=i.value,_=!1;const f=Xd(i)||"";"radio"===f||"checkbox"===f?_=i.checked:(a[p.toLowerCase()]||a[f])&&(g=Qd({element:i,maskInputOptions:a,tagName:p,type:f,value:g,maskInputFn:l})),h(i,u?{text:g,isChecked:_,userTriggered:c}:{text:g,isChecked:_});const v=i.name;"radio"===f&&v&&_&&t.querySelectorAll(`input[type="radio"][name="${v}"]`).forEach(e=>{if(e!==i){const t=e.value;h(e,u?{text:t,isChecked:!_,userTriggered:!1}:{text:t,isChecked:!_})}})}function h(t,n){const s=Sp.get(t);if(!s||s.text!==n.text||s.isChecked!==n.isChecked){Sp.set(t,n);const s=i.getId(t);gp(e)(ct(ct({},n),{},{id:s}))}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>Dh(e,gp(d),t)),g=t.defaultView;if(!g)return()=>{p.forEach(e=>e())};const _=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value");return _&&_.set&&p.push(...[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]].map(e=>zh(e[0],e[1],{set(){gp(d)({target:this,isTrusted:!1})}},!1,g))),gp(()=>{Bh(p)})}(e)),a("mediaInteraction",()=>function({mediaInteractionCb:e,blockClass:t,blockSelector:i,mirror:n,sampling:s,doc:r}){const o=gp(r=>Uh(gp(s=>{const o=fp(s);if(!o||Kh(o,t,i,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:u,loop:d}=o;e({type:r,id:n.getId(o),currentTime:a,volume:l,muted:c,playbackRate:u,loop:d})}),s.media||500)),a=[Dh("play",o(Wu.Play),r),Dh("pause",o(Wu.Pause),r),Dh("seeked",o(Wu.Seeked),r),Dh("volumechange",o(Wu.VolumeChange),r),Dh("ratechange",o(Wu.RateChange),r)];return gp(()=>{a.forEach(e=>e())})}(e)),e.recordDOM){const t=function(e){const t=new Map,i=new Set;let n=!0;const s=e=>{if(n)try{e()}catch(e){}},r=e=>{var i;const n=t.get(e);if(n){for(;null===(i=n[0])||void 0===i?void 0:i.ready;){const e=n.shift();(null==e?void 0:e.emit)&&s(e.emit)}0===n.length&&t.delete(e)}};return{queueMutation(e,i){if(!e)return void s(i);const n=t.get(e);n?(n.push({emit:i,ready:!0}),r(e)):s(i)},queuePendingMutation(o,a,l){if(!n)return()=>{};let c=t.get(o);c||(c=[],t.set(o,c));const u={emit:a,ready:!1};c.push(u);let d,h=!1,p=!1;const g=()=>{h||p||(h=!0,void 0!==d&&i.delete(d),u.ready=!0,u.emit=void 0,r(o))};try{d=e.setTimeout(g,5e3),h||p?e.clearTimeout(d):i.add(d)}catch(e){g()}return t=>{!p&&n&&(p=!0,void 0!==d&&(e.clearTimeout(d),i.delete(d)),h?t&&s(l):(u.ready=!0,t||(u.emit=void 0),r(o)))}},reset(){n=!1,i.forEach(t=>e.clearTimeout(t)),i.clear(),t.clear()}}}(i);r.push(t.reset),a("styleSheet",()=>function({styleSheetRuleCb:e,mirror:t,stylesheetManager:i},{win:n,mutationQueue:s}){if(!n.CSSStyleSheet||!n.CSSStyleSheet.prototype)return()=>{};const r=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=new Proxy(r,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=kp(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&s.queueMutation(r,()=>e({id:c,styleId:u,adds:[{rule:a,index:l}]})),l},"host")}),n.CSSStyleSheet.prototype.addRule=function(e,t,i=this.cssRules.length){return n.CSSStyleSheet.prototype.insertRule.apply(this,[`${e} { ${t} }`,i])};const o=n.CSSStyleSheet.prototype.deleteRule;let a,l;n.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=kp(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&s.queueMutation(r,()=>e({id:c,styleId:u,removes:[{index:a}]})),l},"host")}),n.CSSStyleSheet.prototype.removeRule=function(e){return n.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},n.CSSStyleSheet.prototype.replace&&(a=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);try{const n=null==l?void 0:l.then;if(r.ownerNode||!l||"function"!=typeof n)return l;i.onCssomSheetMutation(r);const{id:o,styleId:c}=kp(r,t,i.styleMirror);if(!(o&&-1!==o||c&&-1!==c))return l;const u=s.queuePendingMutation(r,()=>e({id:o,styleId:c,replace:a}),()=>{const t=Bd(r);null!==t&&e({id:o,styleId:c,replace:t})});try{n.call(l,()=>u(!0),()=>u(!1))}catch(e){u(!1)}}catch(e){}return l},"host")})),n.CSSStyleSheet.prototype.replaceSync&&(l=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=kp(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&s.queueMutation(r,()=>e({id:c,styleId:u,replaceSync:a})),l},"host")}));const c={};Ip("CSSGroupingRule")?c.CSSGroupingRule=n.CSSGroupingRule:(Ip("CSSMediaRule")&&(c.CSSMediaRule=n.CSSMediaRule),Ip("CSSConditionRule")&&(c.CSSConditionRule=n.CSSConditionRule),Ip("CSSSupportsRule")&&(c.CSSSupportsRule=n.CSSSupportsRule));const u={};return Object.entries(c).forEach(([n,r])=>{u[n]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=new Proxy(u[n].insertRule,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=kp(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...wp(r),l];s.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,adds:[{rule:a,index:t}]}))}return l},"host")}),r.prototype.deleteRule=new Proxy(u[n].deleteRule,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=kp(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...wp(r),a];s.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,removes:[{index:t}]}))}return l},"host")})}),gp(()=>{n.CSSStyleSheet.prototype.insertRule=r,n.CSSStyleSheet.prototype.deleteRule=o,a&&(n.CSSStyleSheet.prototype.replace=a),l&&(n.CSSStyleSheet.prototype.replaceSync=l),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule})})}(e,{win:i,mutationQueue:t})),a("adoptedStyleSheet",()=>Cp(e,e.doc)),a("styleDeclaration",()=>function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:i,stylesheetManager:n},{win:s,mutationQueue:r}){const o=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:gp((s,o,a)=>{var l;const[c,u,d]=a,h=s.apply(o,a);if(i.has(c))return h;const p=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;n.onCssomSheetMutation(p);const{id:g,styleId:_}=kp(p,t,n.styleMirror);if(g&&-1!==g||_&&-1!==_){const t=wp(o.parentRule);r.queueMutation(p,()=>e({id:g,styleId:_,set:{property:c,value:u,priority:d},index:t}))}return h},"host")});const a=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:gp((s,o,a)=>{var l;const[c]=a,u=s.apply(o,a);if(i.has(c))return u;const d=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;n.onCssomSheetMutation(d);const{id:h,styleId:p}=kp(d,t,n.styleMirror);if(h&&-1!==h||p&&-1!==p){const t=wp(o.parentRule);r.queueMutation(d,()=>e({id:h,styleId:p,remove:{property:c},index:t}))}return u},"host")}),gp(()=>{s.CSSStyleDeclaration.prototype.setProperty=o,s.CSSStyleDeclaration.prototype.removeProperty=a})}(e,{win:i,mutationQueue:t})),e.collectFonts&&a("font",()=>function({fontCb:e,doc:t}){const i=t.defaultView;if(!i)return()=>{};const n=[],s=new WeakMap,r=i.FontFace;i.FontFace=function(e,t,i){const n=new r(e,t,i);return s.set(n,{family:e,buffer:"string"!=typeof t,descriptors:i,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),n};const o=nd(t.fonts,"add",function(t){return function(i){return setTimeout(gp(()=>{const t=s.get(i);t&&(e(t),s.delete(i))}),0),t.apply(this,[i])}});return n.push(()=>{i.FontFace=r}),n.push(o),gp(()=>{n.forEach(e=>e())})}(e))}a("selection",()=>function(e){const{doc:t,mirror:i,blockClass:n,blockSelector:s,selectionCb:r}=e;let o=!0;const a=gp(()=>{const e=t.getSelection();if(!e||o&&(null==e?void 0:e.isCollapsed))return;o=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;l>t;t++){const{startContainer:r,startOffset:o,endContainer:l,endOffset:c}=e.getRangeAt(t);Kh(r,n,s,!0)||Kh(l,n,s,!0)||a.push({start:i.getId(r),startOffset:o,end:i.getId(l),endOffset:c})}r({ranges:a})});return a(),Dh("selectionchange",a)}(e)),a("customElement",()=>function({doc:e,customElementCb:t}){const i=e.defaultView;return i&&i.customElements?nd(i.customElements,"define",function(e){return function(i,n,s){try{t({define:{name:i}})}catch(e){console.warn(`Custom element callback failed for ${i}`)}return e.apply(this,[i,n,s])}}):()=>{}}(e));for(const t of e.plugins)a(`plugin:${t.name}`,()=>t.observer(t.callback,i,t.options))}catch(e){try{o()}catch(e){}throw e}return o}function xp(e){return void 0!==window[e]}function Ip(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function Rp(e){const t=window;if("function"==typeof t.requestIdleCallback){const i=t.requestIdleCallback(e,{timeout:2e3});return{cancel(){var e;return null===(e=t.cancelIdleCallback)||void 0===e?void 0:e.call(t,i)}}}const i=setTimeout(e,250);return{cancel:()=>clearTimeout(i)}}var Pp=class{constructor(e){Fd(this,"generateIdFn",void 0),Fd(this,"iframeRemoteIdToLocalIdMap",new WeakMap),Fd(this,"iframeLocalIdToRemoteIdMap",new WeakMap),this.generateIdFn=e}getId(e,t,i,n){if(0>t)return t;const s=i||this.getRemoteIdToLocalIdMap(e),r=n||this.getLocalIdToRemoteIdMap(e);let o=s.get(t);return void 0===o&&(o=this.generateIdFn(),s.set(t,o),r.set(o,t)),o}getIds(e,t){const i=this.getRemoteIdToLocalIdMap(e),n=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getId(e,t,i,n))}getRemoteId(e,t,i){var n;return"number"!=typeof t||0>t?t:null!==(n=(i||this.getLocalIdToRemoteIdMap(e)).get(t))&&void 0!==n?n:-1}getRemoteIds(e,t){const i=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getRemoteId(e,t,i))}reset(e){if(!e)return this.iframeRemoteIdToLocalIdMap=new WeakMap,void(this.iframeLocalIdToRemoteIdMap=new WeakMap);this.iframeRemoteIdToLocalIdMap.delete(e),this.iframeLocalIdToRemoteIdMap.delete(e)}getRemoteIdToLocalIdMap(e){let t=this.iframeRemoteIdToLocalIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToLocalIdMap.set(e,t)),t}getLocalIdToRemoteIdMap(e){let t=this.iframeLocalIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeLocalIdToRemoteIdMap.set(e,t)),t}},Mp=class{constructor(e){Fd(this,"iframes",new WeakMap),Fd(this,"crossOriginIframeMap",new WeakMap),Fd(this,"crossOriginIframeMirror",new Pp(uh)),Fd(this,"crossOriginIframeStyleMirror",void 0),Fd(this,"crossOriginIframeRootIdMap",new WeakMap),Fd(this,"mirror",void 0),Fd(this,"mutationCb",void 0),Fd(this,"wrappedEmit",void 0),Fd(this,"loadListener",void 0),Fd(this,"pageHideListener",void 0),Fd(this,"stylesheetManager",void 0),Fd(this,"recordCrossOriginIframes",void 0),Fd(this,"messageHandler",void 0),Fd(this,"nestedIframeListeners",new Map),Fd(this,"attachedWindows",new WeakMap),Fd(this,"attachedDocuments",new WeakMap),Fd(this,"attachedIframes",new Map),Fd(this,"loadListenerDisposers",new WeakMap),Fd(this,"iframeElementsById",new Map),Fd(this,"pageHideHandlers",new WeakMap),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Pp(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.messageHandler=this.handleMessage.bind(this),this.recordCrossOriginIframes&&window.addEventListener("message",this.messageHandler)}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}registerLoadListenerDisposer(e,t){let i=this.loadListenerDisposers.get(e);i||(i=new Set,this.loadListenerDisposers.set(e,i)),i.add(t);const n=this.mirror.getId(e);-1!==n&&this.iframeElementsById.set(n,e)}getIframeElementById(e){var t,i,n;return null!==(t=null!==(i=null===(n=this.attachedIframes.get(e))||void 0===n?void 0:n.element)&&void 0!==i?i:this.iframeElementsById.get(e))&&void 0!==t?t:null}forgetIframeId(e){this.attachedIframes.delete(e),this.iframeElementsById.delete(e)}disposeLoadListeners(e){const t=this.loadListenerDisposers.get(e);t&&(t.forEach(e=>Nh(e)),this.loadListenerDisposers.delete(e))}removePageHideListener(e){const t=this.pageHideHandlers.get(e);t&&(t.forEach(({win:e,handler:t})=>{$h(e,"pagehide",t)}),this.pageHideHandlers.delete(e))}addLoadListener(e){this.loadListener=e}addPageHideListener(e){this.pageHideListener=e}removeLoadListener(){this.loadListener=void 0}trackIframeContent(e,t){const i=this.mirror.getId(e);return this.attachedIframes.set(i,{element:e,content:t}),i}attachIframe(e,t){var i;const n=this.trackIframeContent(e,t);if(e.contentDocument){let t=this.attachedDocuments.get(e);t||(t=new Set,this.attachedDocuments.set(e,t)),t.add(e.contentDocument)}this.mutationCb({adds:[{parentId:n,nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0});const s=e.contentWindow;if(this.recordCrossOriginIframes&&s&&!this.nestedIframeListeners.has(s)){const t=this.handleMessage.bind(this);Nh(()=>{s.addEventListener("message",t),this.nestedIframeListeners.set(s,t);let i=this.attachedWindows.get(e);i||(i=new Set,this.attachedWindows.set(e,i)),i.add(s)})}Nh(()=>{const t=e.contentWindow;if(!t)return;let i=this.pageHideHandlers.get(e);if(i)for(const e of i)if(e.win===t)return;const n=()=>{var t;null===(t=this.pageHideListener)||void 0===t||t.call(this,e),e.contentDocument&&this.mirror.removeNodeFromMap(e.contentDocument)};t.addEventListener("pagehide",n),i||(i=new Set,this.pageHideHandlers.set(e,i)),i.add({win:t,handler:n})}),null===(i=this.loadListener)||void 0===i||i.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const i=this.crossOriginIframeMap.get(e.source);if(!i)return;const n=this.transformCrossOriginEvent(i,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}transformCrossOriginEvent(e,t){switch(t.type){case Bu.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const i=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,i),this.patchRootIdOnNode(t.data.node,i),this.trackIframeContent(e,t.data.node),{timestamp:t.timestamp,type:Bu.IncrementalSnapshot,data:{source:qu.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Bu.Meta:case Bu.Load:case Bu.DomContentLoaded:return!1;case Bu.Plugin:return t;case Bu.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Bu.IncrementalSnapshot:switch(t.data.source){case qu.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const i=this.crossOriginIframeRootIdMap.get(e);i&&this.patchRootIdOnNode(t.node,i)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case qu.Drag:case qu.TouchMove:case qu.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case qu.ViewportResize:return!1;case qu.MediaInteraction:case qu.MouseInteraction:case qu.Scroll:case qu.CanvasMutation:case qu.Input:return this.replaceIds(t.data,e,["id"]),t;case qu.StyleSheetRule:case qu.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case qu.Font:return t;case qu.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case qu.AdoptedStyleSheet:var i;return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(i=t.data.styles)||void 0===i||i.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,i,n){for(const s of n)(Array.isArray(t[s])||"number"==typeof t[s])&&(t[s]=Array.isArray(t[s])?e.getIds(i,t[s]):e.getId(i,t[s]));return t}replaceIds(e,t,i){return this.replace(this.crossOriginIframeMirror,e,t,i)}replaceStyleIds(e,t,i){return this.replace(this.crossOriginIframeStyleMirror,e,t,i)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===ju.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}removeIframeById(e){const t=this.attachedIframes.get(e),i=(null==t?void 0:t.element)||this.iframeElementsById.get(e)||this.mirror.getNode(e);if(this.iframeElementsById.delete(e),i){const e=i.contentWindow,t=this.attachedWindows.get(i);t&&(t.forEach(e=>{const t=this.nestedIframeListeners.get(e);t&&($h(e,"message",t),this.nestedIframeListeners.delete(e)),this.crossOriginIframeMap.delete(e)}),this.attachedWindows.delete(i)),e&&this.nestedIframeListeners.has(e)&&($h(e,"message",this.nestedIframeListeners.get(e)),this.nestedIframeListeners.delete(e)),e&&this.crossOriginIframeMap.delete(e),this.iframes.delete(i),this.disposeLoadListeners(i),this.removePageHideListener(i);const n=this.attachedDocuments.get(i);n&&(n.forEach(e=>{Nh(()=>this.mirror.removeNodeFromMap(e))}),Nh(()=>yp(i,n)),this.attachedDocuments.delete(i))}t&&this.attachedIframes.delete(e)}cleanupDetachedIframes(){if(0===this.attachedIframes.size)return;const e=[];this.attachedIframes.forEach((t,i)=>{this.mirror.has(i)||e.push(i)}),e.forEach(e=>this.removeIframeById(e))}reattachIframes(){this.attachedIframes.forEach(({content:e},t)=>{this.mirror.has(t)?this.mutationCb({adds:[{parentId:t,nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}):this.attachedIframes.delete(t)})}destroy(){this.recordCrossOriginIframes&&$h(window,"message",this.messageHandler),this.nestedIframeListeners.forEach((e,t)=>{$h(t,"message",e)}),this.nestedIframeListeners.clear();const e=new Set;this.iframeElementsById.forEach(t=>e.add(t)),this.attachedIframes.forEach(({element:t})=>e.add(t)),e.forEach(e=>{this.disposeLoadListeners(e),this.removePageHideListener(e)}),this.crossOriginIframeMirror.reset(),this.crossOriginIframeStyleMirror.reset(),this.attachedIframes.clear(),this.crossOriginIframeMap=new WeakMap,this.iframes=new WeakMap,this.crossOriginIframeRootIdMap=new WeakMap,this.loadListenerDisposers=new WeakMap,this.pageHideHandlers=new WeakMap,this.attachedDocuments=new WeakMap,this.attachedWindows=new WeakMap,this.iframeElementsById=new Map}},Fp=class{constructor(e){Fd(this,"shadowDoms",new Map),Fd(this,"mutationCb",void 0),Fd(this,"scrollCb",void 0),Fd(this,"bypassOptions",void 0),Fd(this,"mirror",void 0),Fd(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){var i,n;if(!Od(e))return;if(this.shadowDoms.has(e))return;const s=null!==(i=null===(n=sd.host(e))||void 0===n?void 0:n.ownerDocument)&&void 0!==i?i:t,r={doc:s,handlers:[]};this.shadowDoms.set(e,r);const{observer:o,buffer:a}=vp(ct(ct({},this.bypassOptions),{},{doc:s,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);r.handlers.push(()=>{o.disconnect(),a.destroy(),a.releaseCanvasManager();const e=_p.indexOf(a);-1!==e&&_p.splice(e,1)}),r.handlers.push(mp(ct(ct({},this.bypassOptions),{},{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(()=>{this.shadowDoms.get(e)===r&&(e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(sd.host(e))),r.handlers.push(Cp({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)))},0)}removeShadowRootsIn(e){if(0===this.shadowDoms.size)return;const t=sd.shadowRoot(e);t&&(this.shadowDoms.has(t)&&this.removeShadowRoot(t),this.removeShadowRootsIn(t)),sd.childNodes(e).forEach(e=>this.removeShadowRootsIn(e))}removeShadowRoot(e){const t=this.shadowDoms.get(e);this.shadowDoms.delete(e),null==t||t.handlers.forEach(Ap)}observeAttachShadow(e){Nh(()=>{const t=e.contentWindow,i=e.contentDocument;t&&i&&this.patchAttachShadow(t.Element,i)})}patchAttachShadow(e,t){const i=this;this.restoreHandlers.push({doc:t,handler:nd(e.prototype,"attachShadow",function(e){return function(n){const s=e.call(this,n),r=sd.shadowRoot(this);return r&&rp(this)&&i.addShadowRoot(r,t),s}})})}reset(){this.restoreHandlers.forEach(({handler:e})=>Ap(e)),this.restoreHandlers=[];const e=this.shadowDoms;this.shadowDoms=new Map,e.forEach(({handlers:e})=>e.forEach(Ap))}resetForDoc(e){const t=[];for(const i of this.restoreHandlers)i.doc===e?Ap(i.handler):t.push(i);this.restoreHandlers=t,this.shadowDoms.forEach((t,i)=>{t.doc===e&&this.removeShadowRoot(i)})}};function Ap(e){try{e()}catch(e){}}var Lp="skip-frame";function Op(e){if("object"!=typeof e||null===e)return!1;const{x:t,y:i,width:n,height:s}=e;return Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(s)&&n>=0&&s>=0}for(var Dp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$p="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Np=0;64>Np;Np++)$p[Dp.charCodeAt(Np)]=Np;var Bp=function(e){var t,i=new Uint8Array(e),n=i.length,s="";for(t=0;n>t;t+=3)s+=Dp[i[t]>>2],s+=Dp[(3&i[t])<<4|i[t+1]>>4],s+=Dp[(15&i[t+1])<<2|i[t+2]>>6],s+=Dp[63&i[t+2]];return n%3==2?s=s.substring(0,s.length-1)+"=":n%3==1&&(s=s.substring(0,s.length-2)+"=="),s},qp=!1,Hp=new Map,Up=(e,t,i)=>{if(!e||!jp(e,t)&&"object"!=typeof e)return;const n=function(e,t){let i=Hp.get(e);return i||(i=new Map,Hp.set(e,i)),i.has(t)||i.set(t,[]),i.get(t)}(i,e.constructor.name);let s=n.indexOf(e);return-1===s&&(s=n.length,n.push(e)),s};function zp(e,t,i,n){if(e instanceof Array)return e.map(e=>zp(e,t,i,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:Bp(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[zp(e.buffer,t,i,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:i}=e;return{rr_type:t,src:i}}if(e instanceof HTMLCanvasElement){const t="HTMLImageElement";let i;try{i=e.toDataURL(n.type,n.quality)}catch(e){throw function(e){"SecurityError"===(null==e?void 0:e.name)?qp||(qp=!0,console.warn("[replay] canvas capture: skipping a canvas draw because its pixels cannot be read. A cross-origin image or video drawn into it taints it.",e)):console.warn("[replay] canvas capture: skipping a canvas draw because its pixels cannot be read.",e)}(e),e}return{rr_type:t,src:i}}return e instanceof ImageData?{rr_type:e.constructor.name,args:[zp(e.data,t,i,n),e.width,e.height]}:jp(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Up(e,t,i)}:e}var Wp=(e,t,i,n)=>e.map(e=>zp(e,t,i,n)),jp=(e,t)=>{const i=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(i.find(i=>e instanceof t[i]))},Vp=["webgl","webgl2"];function Gp(e){return"nodeType"in e}function Qp(e,t,i,n){const s=[];try{if(n){const n=function(e,t,i){const n=e.GPUCanvasContext;if((null==n?void 0:n.prototype)&&"function"==typeof n.prototype.configure)return nd(n.prototype,"configure",function(n){return function(s){const r=function(e){const{canvas:t}=e;return t&&"object"==typeof t?t:null}(this);if(!r||Gp(r)&&Kh(r,t,i,!0))return n.call(this,s);Gp(r)&&!("__context"in r)&&(r.__context="webgpu");const o=function(e){const t=e.GPUTextureUsage;return t?t.COPY_SRC|t.RENDER_ATTACHMENT:null}(e);return n.call(this,null!==o&&s?ct(ct({},s),{},{usage:"number"==typeof s.usage?s.usage|o:o}):s)}})}(e,t,i);n&&s.push(n)}const r=nd(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(s,...r){const o=function(e){return"experimental-webgl"===e?"webgl":e}(s);if(!Kh(this,t,i,!0)&&("__context"in this||(this.__context=o),n&&Vp.includes(o)))if(r[0]&&"object"==typeof r[0]){const e=r[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else r.splice(0,1,{preserveDrawingBuffer:!0});return e.apply(this,[s,...r])}});s.push(r)}catch(e){console.warn("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{s.forEach(e=>e())}}function Kp(e,t,i,n,s,r,o){const a=[],l=Object.getOwnPropertyNames(e);for(const c of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const l=nd(e,c,function(e){return function(...a){const l=e.apply(this,a);if(Up(l,r,this),this.canvas&&"tagName"in this.canvas&&!Kh(this.canvas,n,s,!0)){let e;try{e=Wp(a,r,this,o)}catch(e){}e&&i(this.canvas,{type:t,property:c,args:e})}return l}});a.push(l)}catch(r){const o=zh(e,c,{set(e){this.canvas&&"tagName"in this.canvas&&!Kh(this.canvas,n,s,!0)&&i(this.canvas,{type:t,property:c,args:[e],setter:!0})}});a.push(o)}return a}var Jp='(function() {\n\t//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/base64-arraybuffer/1.0.2/f63fa6b5c318cf1c9f6bdd1d4292ad2f15f76f2ec78475025a2d44070e896fe9/node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js\n\tvar chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n\tvar lookup = typeof Uint8Array === "undefined" ? [] : /* @__PURE__ */ new Uint8Array(256);\n\tfor (var i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i;\n\tvar encode = function(arraybuffer) {\n\t\tvar bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";\n\t\tfor (i = 0; i < len; i += 3) {\n\t\t\tbase64 += chars[bytes[i] >> 2];\n\t\t\tbase64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n\t\t\tbase64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n\t\t\tbase64 += chars[bytes[i + 2] & 63];\n\t\t}\n\t\tif (len % 3 === 2) base64 = base64.substring(0, base64.length - 1) + "=";\n\t\telse if (len % 3 === 1) base64 = base64.substring(0, base64.length - 2) + "==";\n\t\treturn base64;\n\t};\n\t//#endregion\n\t//#region ../rrweb/src/record/workers/image-bitmap-data-url-worker.ts\n\tconst lastFingerprintMap = /* @__PURE__ */ new Map();\n\tconst transparentFingerprintMap = /* @__PURE__ */ new Map();\n\tconst lastSentAtMap = /* @__PURE__ */ new Map();\n\tconst PROVIDER_KEYFRAME_INTERVAL_MS = 3e4;\n\tfunction hashPixels(data) {\n\t\tconst view = new Uint32Array(data.buffer, data.byteOffset, data.byteLength >>> 2);\n\t\tlet primaryHash = 2166136261;\n\t\tlet secondaryHash = 2654435769;\n\t\tfor (let i = 0; i < view.length; i++) {\n\t\t\tprimaryHash ^= view[i];\n\t\t\tprimaryHash = Math.imul(primaryHash, 16777619);\n\t\t\tsecondaryHash ^= view[i];\n\t\t\tsecondaryHash = Math.imul(secondaryHash, 2246822507);\n\t\t}\n\t\treturn `${(primaryHash >>> 0).toString(16)}:${(secondaryHash >>> 0).toString(16)}`;\n\t}\n\tfunction frameFingerprint(width, height, data) {\n\t\treturn `${width}x${height}:${hashPixels(data)}`;\n\t}\n\tfunction transparentFingerprint(width, height) {\n\t\tconst pixelCount = width * height;\n\t\tlet hash = transparentFingerprintMap.get(pixelCount);\n\t\tif (hash === void 0) {\n\t\t\thash = hashPixels(new Uint8ClampedArray(pixelCount * 4));\n\t\t\ttransparentFingerprintMap.set(pixelCount, hash);\n\t\t}\n\t\treturn `${width}x${height}:${hash}`;\n\t}\n\tconst worker = self;\n\tlet reusableCanvas = null;\n\tlet reusableCtx = null;\n\tworker.onmessage = async function(e) {\n\t\tif ("resetFrameDedup" in e.data) {\n\t\t\tlastFingerprintMap.clear();\n\t\t\treturn;\n\t\t}\n\t\tif ("OffscreenCanvas" in globalThis) {\n\t\t\tconst { id, bitmap, width, height, displayWidth, displayHeight, dataURLOptions, maskRegions } = e.data;\n\t\t\ttry {\n\t\t\t\tif (!reusableCanvas || reusableCanvas.width !== width || reusableCanvas.height !== height) {\n\t\t\t\t\treusableCanvas = new OffscreenCanvas(width, height);\n\t\t\t\t\treusableCtx = reusableCanvas.getContext("2d", { willReadFrequently: true });\n\t\t\t\t}\n\t\t\t\tconst ctx = reusableCtx;\n\t\t\t\tctx.clearRect(0, 0, width, height);\n\t\t\t\tctx.drawImage(bitmap, 0, 0);\n\t\t\t\tbitmap.close();\n\t\t\t\tif (maskRegions) {\n\t\t\t\t\tctx.fillStyle = "black";\n\t\t\t\t\tfor (const region of maskRegions) ctx.fillRect(region.x, region.y, region.width, region.height);\n\t\t\t\t}\n\t\t\t\tconst fingerprint = frameFingerprint(width, height, ctx.getImageData(0, 0, width, height).data);\n\t\t\t\tif (fingerprint === (lastFingerprintMap.get(id) ?? transparentFingerprint(width, height))) {\n\t\t\t\t\tconst lastSentAt = lastSentAtMap.get(id);\n\t\t\t\t\tif (!(maskRegions !== void 0 && lastSentAt !== void 0 && Date.now() - lastSentAt >= PROVIDER_KEYFRAME_INTERVAL_MS)) return worker.postMessage({ id });\n\t\t\t\t}\n\t\t\t\tconst blob = await reusableCanvas.convertToBlob(dataURLOptions);\n\t\t\t\tconst arrayBuffer = await blob.arrayBuffer();\n\t\t\t\tworker.postMessage({\n\t\t\t\t\tid,\n\t\t\t\t\ttype: blob.type,\n\t\t\t\t\tbase64: encode(arrayBuffer),\n\t\t\t\t\tdisplayWidth,\n\t\t\t\t\tdisplayHeight\n\t\t\t\t});\n\t\t\t\tlastFingerprintMap.set(id, fingerprint);\n\t\t\t\tlastSentAtMap.set(id, Date.now());\n\t\t\t} catch {\n\t\t\t\tworker.postMessage({ id });\n\t\t\t}\n\t\t} else {\n\t\t\te.data.bitmap.close();\n\t\t\treturn worker.postMessage({ id: e.data.id });\n\t\t}\n\t};\n\t//#endregion\n})();\n',Yp="undefined"!=typeof self&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Jp],{type:"text/javascript;charset=utf-8"});function Zp(e){let t;try{if(t=Yp&&(self.URL||self.webkitURL).createObjectURL(Yp),!t)throw"";const i=new Worker(t,{name:null==e?void 0:e.name});return i.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),i}catch(t){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Jp),{name:null==e?void 0:e.name})}}var Xp="A page CSP that omits blob: from worker-src or script-src blocks it";function eg(e,...t){console.warn(`[replay] canvas capture: ${e}`,...t)}var tg=class{onFullSnapshot(){var e;null===(e=this.resetFrameDedup)||void 0===e||e.call(this)}acquire(){this.refCount+=1}reset(){this.refCount>0&&(this.refCount-=1),this.refCount>0||this.teardown()}teardown(){this.torndown||(this.torndown=!0,this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers(),null!==this.rafIdTimestamp&&(cancelAnimationFrame(this.rafIdTimestamp),this.rafIdTimestamp=null),null!==this.rafIdFlush&&(cancelAnimationFrame(this.rafIdFlush),this.rafIdFlush=null))}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){Fd(this,"pendingCanvasMutations",new Map),Fd(this,"rafStamps",{latestId:0,invokeId:null}),Fd(this,"mirror",void 0),Fd(this,"mutationCb",void 0),Fd(this,"resetObservers",void 0),Fd(this,"frozen",!1),Fd(this,"locked",!1),Fd(this,"rafIdTimestamp",null),Fd(this,"rafIdFlush",null),Fd(this,"refCount",0),Fd(this,"torndown",!1),Fd(this,"resetFrameDedup",null),Fd(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:i,blockClass:n,blockSelector:s,recordCanvas:r,dataURLOptions:o,resolutionScale:a,canvasMasking:l}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,r&&"all"===t&&this.initCanvasMutationObserver(i,n,s,o),r&&"number"==typeof t&&this.initCanvasFPSObserver(t,i,n,s,{dataURLOptions:o,resolutionScale:a,canvasMasking:l})}initCanvasFPSObserver(e,t,i,n,s){var r=this;if(!("OffscreenCanvas"in t))return void eg("disabled because this browser does not support OffscreenCanvas");const o="number"==typeof s.resolutionScale&&Number.isFinite(s.resolutionScale)?Math.min(1,Math.max(.1,s.resolutionScale)):1,a=Qp(t,i,n,!0),l=new Map;let c;try{c=new Zp}catch(e){return eg(`disabled because the encode worker did not start. ${Xp}`,e),void a()}let u=!1;c.onerror=e=>{var t;u=!0,eg(`stopped because the encode worker failed. ${Xp}`,e),cancelAnimationFrame(g),null===(t=c.terminate)||void 0===t||t.call(c),this.resetFrameDedup=null},this.resetFrameDedup=()=>{c.postMessage({resetFrameDedup:!0})},c.onmessage=e=>{const{id:t}=e.data;if(l.set(t,!1),!("base64"in e.data))return;const{base64:i,type:n,displayWidth:s,displayHeight:r}=e.data;this.mutationCb({id:t,type:zu["2D"],commands:[{property:"clearRect",args:[0,0,s,r]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:i}],type:n}]},0,0,s,r]}],displayWidth:s,displayHeight:r})};let d=!1,h=!1;const p=1e3/e;let g,_=0;const f=e=>{var a;u||(_&&p>e-_||(_=e,(()=>{const e=[],s=t=>{try{t.querySelectorAll("canvas").forEach(t=>{Kh(t,i,n,!0)||e.push(t)}),t.querySelectorAll("*").forEach(e=>{e.shadowRoot&&s(e.shadowRoot)})}catch(e){}};return s(t.document),e})().forEach((a=rt(function*(e){const t=r.mirror.getId(e);if(-1!==t&&!l.get(t)&&0!==e.width&&0!==e.height){l.set(t,!0);try{if(["webgl","webgl2"].includes(e.__context)){var i,n;const s=e.getContext(e.__context);if(null==s||null===(i=s.isContextLost)||void 0===i?void 0:i.call(s))return void l.set(t,!1);!1===(null==s||null===(n=s.getContextAttributes())||void 0===n?void 0:n.preserveDrawingBuffer)&&s.clear(s.COLOR_BUFFER_BIT)}const r=e.clientWidth||e.width,a=e.clientHeight||e.height,u=Math.max(1,Math.round(r*o)),h=Math.max(1,Math.round(a*o)),p=function(e,t,i,n,s,r){if(!e||"function"!=typeof e.regionsFn)return;let o;try{o=e.regionsFn(t)}catch(e){return Lp}if(void 0===o)return;if(!Array.isArray(o)||!o.every(Op))return Lp;const a=i/s,l=n/r;return o.filter(e=>e.width>0&&e.height>0).map(e=>{const t=Math.floor(e.x*a),i=Math.floor(e.y*l);return{x:t,y:i,width:Math.ceil((e.x+e.width)*a)-t,height:Math.ceil((e.y+e.height)*l)-i}})}(s.canvasMasking,e,u,h,r,a);if("skip-frame"===p)return d||(d=!0,eg("dropped a frame because the mask provider did not return valid regions. A provider that always fails records no canvas frames at all")),void l.set(t,!1);const g=yield createImageBitmap(e,1>o?{resizeWidth:u,resizeHeight:h,resizeQuality:"medium"}:{resizeWidth:u,resizeHeight:h});c.postMessage({id:t,bitmap:g,width:u,height:h,displayWidth:r,displayHeight:a,dataURLOptions:s.dataURLOptions,maskRegions:p},[g])}catch(e){h||(h=!0,eg("dropped a frame because the snapshot failed. A canvas that fails every frame records no canvas frames at all",e)),l.set(t,!1)}}}),function(e){return a.apply(this,arguments)}))),g=requestAnimationFrame(f))};g=requestAnimationFrame(f),this.resetObservers=()=>{var e;a(),cancelAnimationFrame(g),null===(e=c.terminate)||void 0===e||e.call(c),this.resetFrameDedup=null}}initCanvasMutationObserver(e,t,i,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=Qp(e,t,i,!1),r=function(e,t,i,n,s){const r=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const a of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[a])continue;const o=nd(t.CanvasRenderingContext2D.prototype,a,function(r){return function(...o){return Kh(this.canvas,i,n,!0)||setTimeout(()=>{let i;try{i=Wp(o,t,this,s)}catch(e){return}e(this.canvas,{type:zu["2D"],property:a,args:i})},0),r.apply(this,o)}});r.push(o)}catch(s){const o=zh(t.CanvasRenderingContext2D.prototype,a,{set(t){Kh(this.canvas,i,n,!0)||e(this.canvas,{type:zu["2D"],property:a,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,n),o=function(e,t,i,n,s){const r=[];return void 0!==t.WebGLRenderingContext&&r.push(...Kp(t.WebGLRenderingContext.prototype,zu.WebGL,e,i,n,t,s)),void 0!==t.WebGL2RenderingContext&&r.push(...Kp(t.WebGL2RenderingContext.prototype,zu.WebGL2,e,i,n,t,s)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,n);this.resetObservers=()=>{s(),r(),o()}}startPendingCanvasMutationFlusher(){this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,this.rafIdTimestamp=requestAnimationFrame(e)};this.rafIdTimestamp=requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const i=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,i)}),this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const i=this.pendingCanvasMutations.get(e);if(!i||-1===t)return;const n=i.map(e=>ys(e,Nu)),{type:s}=i[0];this.mutationCb({id:t,type:s,commands:n}),this.pendingCanvasMutations.delete(e)}};function ig(e){var t,i,n;const s={};for(const n of Object.keys(null!==(t=null===(i=e.previous)||void 0===i?void 0:i.attributes)&&void 0!==t?t:{}))s[n]=null;return Object.assign(s,null===(n=e.current)||void 0===n?void 0:n.attributes),delete s.rel,delete s.href,s}var ng,sg,rg,og=class{constructor(e){var t,i,n;Fd(this,"trackedLinkElements",new WeakSet),Fd(this,"pendingDeferredSheets",new Set),Fd(this,"stopped",!1),Fd(this,"changedLinkJobs",new Map),Fd(this,"linksInlinedSinceSnapshot",new WeakSet),Fd(this,"mutationCb",void 0),Fd(this,"adoptedStyleSheetCb",void 0),Fd(this,"maskAllElementAttributes",void 0),Fd(this,"maskAttributeFn",void 0),Fd(this,"blockClass",void 0),Fd(this,"blockSelector",void 0),Fd(this,"styleMirror",new np),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb,this.maskAllElementAttributes=null!==(t=e.maskAllElementAttributes)&&void 0!==t&&t,this.maskAttributeFn=e.maskAttributeFn,this.blockClass=null!==(i=e.blockClass)&&void 0!==i?i:"rr-block",this.blockSelector=null!==(n=e.blockSelector)&&void 0!==n?n:null}isLinkBlocked(e){return Jh(e,this.blockClass,this.blockSelector)}attachLinkElement(e,t,i=null){this.stopped||!("_cssText"in t.attributes)||this.isLinkBlocked(e)||(this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:ig({previous:i,current:t})}]}),this.linksInlinedSinceSnapshot.add(e)),this.trackLinkElement(e)}beginDeferredLinkInlining(e,t,i={}){var n;const s=null!==(n=i.emitCssText)&&void 0!==n?n:i=>this.emitCssTextMutation(e,t,i);if(-1===t||!e.isConnected)return null;let r=null,o=null;try{o=e.sheet,o&&(r=Vd(o))}catch(e){}var a;if(!r||!o)return Rd(),null===(a=i.onUninlinable)||void 0===a||a.call(i),null;const l=r;let c=!1;const u={sheet:o,invalidate(){c=!0}};this.pendingDeferredSheets.add(u);let d=!1;return{advance:t=>{if(d)return!0;const n=rd(),r=ld();let a=!0;try{if(c)return d=!0,i.onInvalidatedBySheetMutation?i.onInvalidatedBySheetMutation():Rd(),!0;if(!l.advance(t))return a=!1,!1;d=!0;const n=l.text();if(!e.isConnected)return!0;let r=null;try{r=e.sheet}catch(e){}return r!==o?(Rd(),!0):n?(this.isLinkBlocked(e)||s(n),!0):(Rd(),null===(h=i.onUninlinable)||void 0===h||h.call(i),!0);var h}finally{a&&this.pendingDeferredSheets.delete(u),cd(p=rd()-n,null!=(g=r)?g:od)||(bd.totalMs+=p,p>bd.slowestSliceMs&&(bd.slowestSliceMs=p))}var p,g},remainingRules:()=>l.remainingRules(),discard:()=>{this.pendingDeferredSheets.delete(u)}}}onCssomSheetMutation(e){if(e&&0!==this.pendingDeferredSheets.size)for(const t of this.pendingDeferredSheets)t.sheet===e&&(this.pendingDeferredSheets.delete(t),t.invalidate())}inlineLinkStylesheetAfterChange(e,t){this.stopped||-1===t.currentId()||function(e,t){const i=Th(e),n=Ch.get(e);if(n)return void(n.changedLinkBaseline&&(n.changedLinkBaseline.sheetAtLatestChange=i));const s={sheetAtLatestChange:i},r=()=>{const t=Th(e);return Boolean(t&&(t!==s.sheetAtLatestChange||t.href===e.href))};r()?t():xh(e,t,r,Ih,s)}(e,()=>this.inlineChangedLinkStylesheet(e,t,3))}inlineChangedLinkStylesheet(e,t,i){var n;const s=t.currentId();if(this.stopped||!e.isConnected||-1===s||this.isLinkBlocked(e))return;null===(n=this.changedLinkJobs.get(e))||void 0===n||n.drop();let r=!1;const o=this.beginDeferredLinkInlining(e,s,{emitCssText:i=>this.emitCssTextMutation(e,s,i,ig(t.reserializeWithoutCss())),onInvalidatedBySheetMutation(){r=!0},onUninlinable:()=>this.readdAsPlainLink(e,t)});if(!o)return;let a=null;const l=()=>{o.discard(),null==a||a.cancel(),a=null,this.changedLinkJobs.get(e)===c&&this.changedLinkJobs.delete(e)},c={remainingRules:()=>o.remainingRules(),runSlice:()=>{try{return this.stopped||this.changedLinkJobs.get(e)!==c||-1===t.currentId()||this.isLinkBlocked(e)?(l(),!0):!!o.advance(200)&&(l(),!r||(i>0?this.inlineChangedLinkStylesheet(e,t,i-1):Rd(),!0))}catch(e){return l(),!0}},drop:l};this.changedLinkJobs.set(e,c);const u=e=>{a=null;let t,i=0;do{t=c.runSlice(),i+=1}while(!t&&(e?!e.didTimeout&&e.timeRemaining()>5:10>i));t||(a=Rp(u))};a=Rp(u)}flushChangedLinkInlining(e){let t=0;for(const i of this.changedLinkJobs.values()){let n=!1;for(;!n;){if(Math.floor(i.remainingRules()/200)+1>e-t){i.drop(),Pd(1);break}n=i.runSlice(),t+=1}}return t}inlineDeferredLinkElement(e,t){var i;null===(i=this.beginDeferredLinkInlining(e,t))||void 0===i||i.advance(1/0)}emitCssTextMutation(e,t,i,n={}){this.stopped||(this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t,attributes:ct(ct({},n),{},{_cssText:Yd({element:e,name:"_cssText",value:i,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn})})}]}),this.linksInlinedSinceSnapshot.add(e))}readdAsPlainLink(e,t){try{var i,n;if(this.stopped||!e.isConnected||this.isLinkBlocked(e))return;if(!this.linksInlinedSinceSnapshot.has(e)&&!("_cssText"in(null!==(i=null===(n=t.lastSerialization())||void 0===n?void 0:n.attributes)&&void 0!==i?i:{})))return;this.linksInlinedSinceSnapshot.delete(e),t.readdAsMove()}catch(e){}}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const i={id:t,styleIds:[]},n=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{const i=this.styleMirror.add(t);e=i;const s=rd();try{Ed(()=>{try{const e=t.rules||t.cssRules;e&&Cd(e)}catch(e){}n.push({styleId:i,rules:Array.from(t.rules||CSSRule,(e,i)=>({rule:qd(e,t.href),index:i}))})})}finally{Td(rd()-s)}}i.styleIds.push(e)}n.length>0&&(i.styles=n),this.adoptedStyleSheetCb(i)}stop(){this.stopped=!0,this.dropChangedLinkJobs(),Eh()}dropChangedLinkJobs(){Array.from(this.changedLinkJobs.values()).forEach(e=>e.drop())}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet,this.pendingDeferredSheets.clear(),this.dropChangedLinkJobs(),this.linksInlinedSinceSnapshot=new WeakSet,Eh({keepChangedLinks:!0})}trackStylesheetInLinkElement(e){}},ag=class{constructor(){Fd(this,"nodeMap",new WeakMap),Fd(this,"active",!1)}inOtherBuffer(e,t){const i=this.nodeMap.get(e);return i&&Array.from(i).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},lg=!1;try{if(2!==Array.from([1],e=>2*e)[0]){var cg;const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null===(cg=e.contentWindow)||void 0===cg?void 0:cg.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}var ug=new Gd,dg=new Set([qu.Mutation,qu.MediaInteraction,qu.StyleSheetRule,qu.CanvasMutation,qu.Font,qu.Log,qu.StyleDeclaration,qu.AdoptedStyleSheet]);function hg(e={}){let t,i=!1,n=!1;const{emit:s,checkoutEveryNms:r,checkoutEveryNth:o,blockClass:a="rr-block",blockSelector:l=null,ignoreClass:c="rr-ignore",ignoreSelector:u=null,maskTextClass:d="rr-mask",maskTextSelector:h=null,inlineStylesheet:p=!0,inlineStylesheetBudgetRules:g,maskAllInputs:_,maskInputOptions:f,slimDOMOptions:v,maskInputFn:m,maskTextFn:y,maskAllElementAttributes:b=!1,maskAttributeFn:S,hooks:w,packFn:k,sampling:C={},dataURLOptions:E={},canvasResolutionScale:T,canvasMasking:x,mousemoveWait:I,recordDOM:R=!0,recordCanvas:P=!1,recordCrossOriginIframes:M=!1,recordAfter:F=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:A=!1,collectFonts:L=!1,inlineImages:O=!1,plugins:D,keepIframeSrcFn:N=()=>!1,ignoreCSSAttributes:B=new Set([]),attributeFilter:q,errorHandler:H}=e;hp(H);const U=ct({type:"image/webp",quality:.4,maxBase64ImageLength:1048576},E),z=!M||window.parent===window;let W=!1;if(!z)try{window.parent.document&&(W=!1)}catch(e){W=!0}if(z&&!s)throw new Error("emit function is required");if(!z&&!W)return()=>{};void 0!==I&&void 0===C.mousemove&&(C.mousemove=I),ug.reset(),Eh();const j=!0===_?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==f?f:{password:!0},V=Lh(void 0!==v&&v);let G;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=[].forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=[].forEach)}();let Q=0;const K=new Map;let J,Y;const Z=e=>{for(const t of D||[])t.eventProcessor&&(e=t.eventProcessor(e));return k&&!W&&(e=k(e)),e};ng=(e,t)=>{var i;const n=e;if(n.timestamp=Wh(),!(null===(i=_p[0])||void 0===i?void 0:i.isFrozen())||n.type===Bu.FullSnapshot||n.type===Bu.IncrementalSnapshot&&dg.has(n.data.source)||_p.forEach(e=>e.unfreeze()),z)null==s||s(Z(n),t);else if(W){const e={type:"rrweb",event:Z(n),origin:window.location.origin,isCheckout:t};window.parent.postMessage(e,"*")}if(n.type===Bu.FullSnapshot)G=n,Q=0;else if(n.type===Bu.IncrementalSnapshot){if(n.data.source===qu.Mutation&&n.data.isAttachIframe)return;Q++,(o&&Q>=o||r&&n.timestamp-G.timestamp>r)&&sg(!0)}};const X=e=>{if(e.removes&&e.removes.length>0){const t=e.adds.length>0?new Set(e.adds.map(e=>e.node.id)):null,i=new Set;if(e.adds.length>0)for(const t of e.adds){const e=ug.getNode(t.node.id);e&&"IFRAME"===e.nodeName&&i.add(e)}e.removes.forEach(({id:e})=>{if(t&&t.has(e))return;const n=re.getIframeElementById(e);n&&i.has(n)?re.forgetIframeId(e):(null==J||J(e),re.removeIframeById(e))}),null==Y||Y(),re.cleanupDetachedIframes()}ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Mutation},e)})},ee=e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Scroll},e)}),te=e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.CanvasMutation},e)}),ie=new og({mutationCb:X,adoptedStyleSheetCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.AdoptedStyleSheet},e)}),maskAllElementAttributes:b,maskAttributeFn:S,blockClass:a,blockSelector:l});let ne=!1;const se=()=>{if(!ne){ne=!0;try{var e;const i=null!==(e=null==t?void 0:t.flush())&&void 0!==e?e:0;ie.flushChangedLinkInlining(50-i)}finally{ne=!1}}},re=new Mp({mirror:ug,mutationCb:X,stylesheetManager:ie,recordCrossOriginIframes:M,wrappedEmit:ng});for(const e of D||[])e.getMirror&&e.getMirror({nodeMirror:ug,crossOriginIframeMirror:re.crossOriginIframeMirror,crossOriginIframeStyleMirror:re.crossOriginIframeStyleMirror});const oe=new ag,ae=null==x?void 0:x.configured;rg=new tg({recordCanvas:P,mutationCb:te,win:window,blockClass:a,blockSelector:l,mirror:ug,sampling:C.canvas,dataURLOptions:U,resolutionScale:T,canvasMasking:x});const le=new Fp({mutationCb:X,scrollCb:ee,bypassOptions:{blockClass:a,blockSelector:l,maskTextClass:d,maskTextSelector:h,inlineStylesheet:p,maskInputOptions:j,dataURLOptions:U,maskTextFn:y,maskInputFn:m,maskAllElementAttributes:b,maskAttributeFn:S,recordCanvas:P,canvasMaskingConfigured:ae,inlineImages:O,sampling:C,slimDOMOptions:V,iframeManager:re,stylesheetManager:ie,canvasManager:rg,keepIframeSrcFn:N,processedNodeManager:oe,attributeFilter:q},mirror:ug});sg=(e=!1)=>{if(R){Sd(g);try{if(ng({type:Bu.Meta,data:{href:window.location.href,width:Gh(),height:Vh()}},e),i)return;null==t||t.cancel(),t=void 0,ie.reset(),le.init(),_p.forEach(e=>e.lock());let n=null,s=[];try{n=function(e,t){const{mirror:i=new Gd,blockClass:n="rr-block",blockSelector:s=null,maskTextClass:r="rr-mask",maskTextSelector:o=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,canvasMaskingConfigured:u,maskAllInputs:d=!1,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:g=!1,maskAttributeFn:_,slimDOM:f=!1,dataURLOptions:v,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E=()=>!1,maxDepth:T,inlineStylesheetBudgetRules:x}=t||{},I=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,R=Lh(f);Sd(x);try{return Ah(e,{doc:e,mirror:i,blockClass:n,blockSelector:s,maskTextClass:r,maskTextSelector:o,skipChild:!1,inlineStylesheet:a,maskInputOptions:I,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:g,maskAttributeFn:_,slimDOMOptions:R,dataURLOptions:v,inlineImages:l,recordCanvas:c,canvasMaskingConfigured:u,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E,newlyAddedElement:!1,maxDepth:T})}finally{wd()}}(document,{mirror:ug,blockClass:a,blockSelector:l,maskTextClass:d,maskTextSelector:h,inlineStylesheet:p,maskAllInputs:j,inlineStylesheetBudgetRules:g,maskTextFn:y,maskInputFn:m,maskAllElementAttributes:b,maskAttributeFn:S,slimDOM:V,dataURLOptions:U,recordCanvas:P,canvasMaskingConfigured:ae,inlineImages:O,onSerialize(e){ep(e,ug)&&re.addIframe(e),tp(e,ug)&&ie.trackLinkElement(e),ip(e)&&le.addShadowRoot(sd.shadowRoot(e),document)},onIframeLoad(e,t){re.attachIframe(e,t),le.observeAttachShadow(e)},onIframeListenerRegistered(e,t){re.registerLoadListenerDisposer(e,t)},onStylesheetLoad(e,t,i){ie.attachLinkElement(e,t,i)},keepIframeSrcFn:N})}finally{s=Id()}if(i)return;if(!n)return console.warn("Failed to snapshot the document");if(ng({type:Bu.FullSnapshot,data:{node:n,initialOffset:jh(window)}},e),i)return;if(_p.forEach(e=>e.unlock()),rg.onFullSnapshot(),s.length){const e=function(e,t,i){let n=!1,s=null,r=0,o=null;const a=()=>null!==o||e.length>r,l=()=>{const i=e[r];e[r]=null,r+=1,i&&Nh(()=>{o=t.beginDeferredLinkInlining(i,ug.getId(i))})},c=()=>{if(!o)return;const e=o;let t=!0;Nh(()=>{t=e.advance(200)}),t&&(o=null)},u=()=>{o||l(),c()},d=e=>{if(s=null,n)return;let t=0;do{try{u()}catch(e){null==o||o.discard(),o=null,Pd(1)}t+=1}while(!n&&a()&&(e?!e.didTimeout&&e.timeRemaining()>5:10>t));n||(a()?s=Rp(d):i())};return s=Rp(d),{cancel(){n=!0,null==o||o.discard(),o=null,null==s||s.cancel(),s=null},flush(){if(n)return 0;n=!0,null==s||s.cancel(),s=null;let t=0,u=0;for(;a()&&50>t;){o||l();const e=o;if(e)if(Math.floor(e.remainingRules()/200)+1>50-t)e.discard(),o=null,u+=1;else{try{c()}catch(e){null==o||o.discard(),o=null,u+=1}t+=1}}if(a()||u>0){let t=u+(null!==o?1:0);for(let i=r;e.length>i;i++)null!==e[i]&&(t+=1);Pd(t),null==o||o.discard(),o=null}return i(),t}}}(s,ie,()=>{t===e&&(t=void 0)});t=e}M&&re.reattachIframes(),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&ie.adoptStyleSheets(document.adoptedStyleSheets,ug.getId(document))}finally{wd()}}};try{const e=[];e.push(Dh("pagehide",()=>{try{se()}catch(e){}t=void 0},window));for(const t of["visibilitychange","freeze","resume"])e.push(Dh(t,ad,document));J=t=>{const i=K.get(t);i&&(i.forEach(t=>{Nh(t);const i=e.indexOf(t);-1!==i&&e.splice(i,1)}),K.delete(t))},Y=()=>{for(const[e]of K){const t=ug.getNode(e);if(t)try{t.contentDocument&&t.contentDocument.defaultView||null==J||J(e)}catch(t){null==J||J(e)}else null==J||J(e)}};const s=e=>{var t;return gp(Tp)({mutationCb:X,mousemoveCb:(e,t)=>ng({type:Bu.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.MouseInteraction},e)}),scrollCb:ee,viewportResizeCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.ViewportResize},e)}),inputCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Input},e)}),mediaInteractionCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.MediaInteraction},e)}),styleSheetRuleCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.StyleSheetRule},e)}),styleDeclarationCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.StyleDeclaration},e)}),canvasMutationCb:te,fontCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Font},e)}),selectionCb(e){ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Selection},e)})},customElementCb(e){ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.CustomElement},e)})},blockClass:a,ignoreClass:c,ignoreSelector:u,maskTextClass:d,maskTextSelector:h,maskInputOptions:j,inlineStylesheet:p,sampling:C,recordDOM:R,recordCanvas:P,canvasMaskingConfigured:ae,inlineImages:O,userTriggeredOnInput:A,collectFonts:L,doc:e,maskInputFn:m,maskTextFn:y,maskAllElementAttributes:b,maskAttributeFn:S,keepIframeSrcFn:N,blockSelector:l,slimDOMOptions:V,dataURLOptions:U,mirror:ug,iframeManager:re,stylesheetManager:ie,shadowDomManager:le,processedNodeManager:oe,canvasManager:rg,ignoreCSSAttributes:B,attributeFilter:q,plugins:(null==D||null===(t=D.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({name:e.name,observer:e.observer,options:e.options,callback:t=>ng({type:Bu.Plugin,data:{plugin:e.name,payload:t}})})))||[]},w)},r=new WeakMap,o=new WeakMap;re.addLoadListener(t=>{try{const i=t.contentDocument,n=ug.getId(t);if(!i)return;const a=o.get(t);if(a){o.delete(t),Nh(a);const i=e.indexOf(a);-1!==i&&e.splice(i,1)}const l=r.get(i);if(-1!==n&&l){if(l())return;null==J||J(n)}const c=s(i);if("function"==typeof c){let s=!1;const a=Dh("rrweb-check-iframe-observers",()=>{s=!0},i);-1!==n&&r.set(i,()=>{s=!1;const e=i.createEvent("Event");return e.initEvent("rrweb-check-iframe-observers",!1,!1),i.dispatchEvent(e),s});const l=()=>{r.delete(i),a(),c()};if(e.push(l),-1!==n){let e=K.get(n);e||(e=new Set,K.set(n,e)),e.add(l)}else o.set(t,l)}}catch(e){console.warn(e)}}),re.addPageHideListener(e=>{const t=ug.getId(e);null==J||J(t),yp(e)});let g=-1;const _=e=>ng({type:Bu.Custom,data:{tag:"rrweb/fullscreen",payload:e}}),f=()=>{var e,t,i,n;const s=document,r=null!==(e=null!==(t=null!==(i=null!==(n=s.fullscreenElement)&&void 0!==n?n:s.webkitFullscreenElement)&&void 0!==i?i:s.mozFullScreenElement)&&void 0!==t?t:s.msFullscreenElement)&&void 0!==e?e:null,o=r?ug.getId(r):-1;o!==g&&(-1!==g&&_({id:g,enter:!1}),g=o,-1!==o&&_({id:o,enter:!0}))},v=()=>{if(i||n)return;if(n=!0,sg(),i)return;const t=s(document);i?"function"==typeof t&&Bh([t]):("function"==typeof t&&e.push(t),e.push(Dh("fullscreenchange",f)),e.push(Dh("webkitfullscreenchange",f)),e.push(Dh("mozfullscreenchange",f)),e.push(Dh("MSFullscreenChange",f)),lg=!0)};return["interactive","complete"].includes(document.readyState)?v():(e.push(Dh("DOMContentLoaded",()=>{ng({type:Bu.DomContentLoaded,data:{}}),"DOMContentLoaded"===F&&setTimeout(v,0)})),e.push(Dh("load",()=>{ng({type:Bu.Load,data:{}}),"load"===F&&v()},window))),()=>{i=!0;try{se()}catch(e){}t=void 0,ie.stop(),Bh(e),oe.destroy(),re.removeLoadListener(),re.destroy(),K.clear(),le.reset(),ug.reset(),lg=!1,pp()}}catch(e){console.warn(e)}}hg.addCustomEvent=(e,t)=>{if(!lg)throw new Error("please add custom event after start recording");ng({type:Bu.Custom,data:{tag:e,payload:t}})},hg.freezePage=()=>{_p.forEach(e=>e.freeze())},hg.takeFullSnapshot=e=>{if(!lg)throw new Error("please take full snapshot after start recording");sg(e)},hg.isRecording=()=>lg,hg.mirror=ug,Date,Date;var pg=Object.create(null);function gg(e){return gg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gg(e)}function _g(e,t,i){return(t=function(e){var t=function(e){if("object"!=gg(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=gg(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gg(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}pg.Node=Object.create(null),pg.ShadowRoot=Object.create(null),pg.MutationObserver=Object.create(null),pg.Element=Object.create(null);var fg=class{constructor(e){_g(this,"fileName",void 0),_g(this,"functionName",void 0),_g(this,"lineNumber",void 0),_g(this,"columnNumber",void 0),this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}toString(){const e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${e}:${t})`:`${this.fileName}:${e}:${t}`}},vg=/(^|@)\S+:\d+/,mg=/^\s*at .*(\S+:\d+|\(native\))/m,yg=/^(eval@)?(\[native code])?$/,bg={parse(e){return e?void 0!==e.stacktrace||void 0!==e["opera#sourceloc"]?this.parseOpera(e):e.stack&&e.stack.match(mg)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):[]:[]},extractLocation(e){if(-1===e.indexOf(":"))return[e];const t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error(`Cannot parse given url: ${e}`);return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE(e){return e.stack.split("\n").filter(function(e){return!!e.match(mg)},this).map(function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let t=e.replace(/^\s+/,"").replace(/\(eval code/g,"(");const i=t.match(/ (\((.+):(\d+):(\d+)\)$)/);t=i?t.replace(i[0],""):t;const n=t.split(/\s+/).slice(1),s=this.extractLocation(i?i[1]:n.pop());return new fg({functionName:n.join(" ")||void 0,fileName:["eval","<anonymous>"].indexOf(s[0])>-1?void 0:s[0],lineNumber:s[1],columnNumber:s[2]})},this)},parseFFOrSafari(e){return e.stack.split("\n").filter(function(e){return!e.match(yg)},this).map(function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new fg({functionName:e});{const t=/((.*".+"[^@]*)?[^@]*)(?:@)/,i=e.match(t),n=i&&i[1]?i[1]:void 0,s=this.extractLocation(e.replace(t,""));return new fg({functionName:n,fileName:s[0],lineNumber:s[1],columnNumber:s[2]})}},this)},parseOpera(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9(e){const t=/Line (\d+).*script (?:in )?(\S+)/i,i=e.message.split("\n"),n=[];for(let e=2,s=i.length;s>e;e+=2){const s=t.exec(i[e]);s&&n.push(new fg({fileName:s[2],lineNumber:parseFloat(s[1])}))}return n},parseOpera10(e){const t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=e.stacktrace.split("\n"),n=[];for(let e=0,s=i.length;s>e;e+=2){const s=t.exec(i[e]);s&&n.push(new fg({functionName:s[3]||void 0,fileName:s[2],lineNumber:parseFloat(s[1])}))}return n},parseOpera11(e){return e.stack.split("\n").filter(function(e){return!!e.match(vg)&&!e.match(/^Error created at/)},this).map(function(e){const t=e.split("@"),i=this.extractLocation(t.pop());return new fg({functionName:(t.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,fileName:i[0],lineNumber:i[1],columnNumber:i[2]})},this)}};function Sg(e){if(!e||!e.outerHTML)return"";let t="";for(;e.parentElement;){let i=e.localName;if(!i)break;i=i.toLowerCase();const n=e.parentElement,s=[];if(n.children&&n.children.length>0)for(let e=0;n.children.length>e;e++){const t=n.children[e];t.localName&&t.localName.toLowerCase&&t.localName.toLowerCase()===i&&s.push(t)}s.length>1&&(i+=`:eq(${s.indexOf(e)})`),t=i+(t?">"+t:""),e=n}return t}function wg(e){return Array.isArray(e)}function kg(e){return"object"==typeof e&&null!==e&&!wg(e)}function Cg(e,t){if(0===t)return!0;const i=Object.keys(e);for(const n of i)if(kg(e[n])&&Cg(e[n],t-1))return!0;return!1}function Eg(e,t){const i={numOfKeysLimit:50,depthOfLimit:4};Object.assign(i,t);const n=[],s=[];return JSON.stringify(e,function(e,t){if(n.length>0){const i=n.indexOf(this);~i?n.splice(i+1):n.push(this),~i?s.splice(i,1/0,e):s.push(e),~n.indexOf(t)&&(t=n[0]===t?"[Circular ~]":"[Circular ~."+s.slice(0,n.indexOf(t)).join(".")+"]")}else n.push(t);if(null===t)return t;if(void 0===t)return"undefined";if(kg(r=t)&&Object.keys(r).length>i.numOfKeysLimit||"function"==typeof r||kg(r)&&Cg(r,i.depthOfLimit))return function(e){let t=e.toString();return i.stringLengthLimit&&t.length>i.stringLengthLimit&&(t=`${t.slice(0,i.stringLengthLimit)}...`),t}(t);var r;if("bigint"==typeof t)return t.toString()+"n";if(t instanceof Event){const e={};for(const i in t){const n=t[i];e[i]=wg(n)?Sg(n.length?n[0]:null):n}return e}return t instanceof Node?t instanceof HTMLElement?t?t.outerHTML:"":t.nodeName:t instanceof Error?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t})}var Tg={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function xg(e,t,i){const n=i?Object.assign({},Tg,i):Tg,s=n.logger;if(!s)return()=>{};let r;r="string"==typeof s?t[s]:s;let o=0,a=!1,l=!0;const c=[];if(n.level.includes("error")){const i=t=>{const i=t.message;e({level:"error",trace:bg.parse(t.error).map(e=>e.toString()),payload:[Eg(i,n.stringifyOptions)]})};t.addEventListener("error",i),c.push(()=>{t.removeEventListener("error",i)});const s=t=>{let i,s;t.reason instanceof Error?(i=t.reason,s=[Eg(`Uncaught (in promise) ${i.name}: ${i.message}`,n.stringifyOptions)]):(i=new Error,s=[Eg("Uncaught (in promise)",n.stringifyOptions),Eg(t.reason,n.stringifyOptions)]),e({level:"error",trace:bg.parse(i).map(e=>e.toString()),payload:s})};t.addEventListener("unhandledrejection",s),c.push(()=>{t.removeEventListener("unhandledrejection",s)})}for(const e of n.level)c.push(u(r,e));return()=>{l=!1,c.forEach(e=>e())};function u(t,i){return t[i]?function(s,r){try{if(!(r in s))return()=>{};const c=s[r],u={next:c},d=(s=>(...r)=>{if(s.apply(t,r),l&&!("assert"===i&&r[0]||a)){a=!0;try{const t=bg.parse(new Error).map(e=>e.toString()).splice(1),s=("assert"===i?r.slice(1):r).map(e=>Eg(e,n.stringifyOptions));o++,n.lengthThreshold>o?e({level:i,trace:t,payload:s}):o===n.lengthThreshold&&e({level:"warn",trace:[],payload:[Eg("The number of log records reached the threshold.")]})}catch(e){s.apply(t,["rrweb logger error:",e,...r])}finally{a=!1}}})(function(...e){return u.next.apply(this,e)});return"function"==typeof d&&(d.prototype=d.prototype||{},Object.defineProperties(d,{__rrweb_original__:{enumerable:!1,value:c},__rrweb_layer__:{enumerable:!1,value:u}})),s[r]=d,()=>{if(s[r]===d)return void(s[r]=u.next);const e=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let t=s[r],i=e(t);for(;i;){if(i.next===d)return void(i.next=u.next);t=i.next,i=e(t)}}}catch(e){return()=>{}}}(t,i):()=>{}}}var Ig=e=>({name:"rrweb/console@1",observer:xg,options:e});const Rg=()=>{},Pg=e=>{var t;if(Ct(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Mg(e,t,i){try{if(!(t in e))return Rg;const n={next:e[t]},s=i(function(...e){return n.next.apply(this,e)});return Ct(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:n}})),e[t]=s,()=>{if(e[t]===s)return void(e[t]=n.next);let i=e[t],r=Pg(i);for(;r;){if(r.next===s)return void(r.next=n.next);i=r.next,r=Pg(i)}}}catch(e){return Rg}}function Fg(e,t){var i;const n=function(e){try{return"string"==typeof e?new URL(e).hostname:"url"in e?new URL(e.url).hostname:e.hostname}catch(e){return null}}(e),s={hostname:n,isHostDenied:!1};if(!(null===(i=t.payloadHostDenyList)||void 0===i?void 0:i.length)||!(null==n?void 0:n.trim().length))return s;for(const e of t.payloadHostDenyList)if(n.endsWith(e))return{hostname:n,isHostDenied:!0};return s}const Ag=Br("[Recorder]"),Lg=e=>"navigation"===e.entryType,Og=e=>"resource"===e.entryType,Dg=()=>{};function $g(e,t){var i;return Lg(t)&&"complete"===(null===(i=e.document)||void 0===i?void 0:i.readyState)&&t.loadEventEnd>0}function Ng(e,t){return t.recordInitialRequests?e.performance.getEntries().filter(i=>$g(e,i)||Og(i)&&t.initiatorTypes.includes(i.initiatorType)):t.performanceEntryTypeToObserve.includes("navigation")?function(e){var t;return"complete"!==(null===(t=e.document)||void 0===t?void 0:t.readyState)?[]:e.performance.getEntriesByType("navigation").filter(t=>$g(e,t))}(e):[]}function Bg(e,t){return!!t&&(Lt(t)||t[e])}function qg(e){if("undefined"==typeof Request)return!1;if(e instanceof Request)return!0;try{return"[object Request]"==={}.toString.call(e)}catch(e){return!1}}const Hg=["image/","video/","audio/","font/","application/octet-stream","application/pdf","application/zip","application/wasm"];function Ug({type:e,recordBody:t,headers:i,url:n}){function s(e){const t=Object.keys(i).find(e=>"content-type"===e.toLowerCase()),n=t&&i[t];return e.some(e=>null==n?void 0:n.toLowerCase().includes(e))}if(!t)return!1;if(function e(t){try{return"string"==typeof t?t.startsWith("blob:"):t instanceof URL?"blob:"===t.protocol:!!qg(t)&&e(t.url)}catch(e){return!1}}(n))return!1;if(s(Hg))return!1;if(Lt(t))return!0;if(kt(t))return s(t);const r=t[e];return Lt(r)?r:s(r)}function zg(e,t,i,n,s){return Wg.apply(this,arguments)}function Wg(){return Wg=rt(function*(e,t,i,n,s,r=0){if(r>10)return Ag.warn("Failed to get performance entry for request",{url:i,initiatorType:t}),null;const o=function(e,t){for(let i=e.length-1;i>=0;i-=1)if(t(e[i]))return e[i]}(e.performance.getEntriesByName(i),e=>Og(e)&&e.initiatorType===t&&(xt(n)||e.startTime>=n)&&(xt(s)||s>=e.startTime));return o||(yield new Promise(e=>setTimeout(e,50*r)),zg(e,t,i,n,s,r+1))}),Wg.apply(this,arguments)}function jg({body:e,options:t,url:i}){if(Mt(e))return null;const{hostname:n,isHostDenied:s}=Fg(i,t);if(s)return n+" is in deny list";if(It(e))return e;if((e=>"u">typeof Document&&e instanceof Document)(e))return e.textContent;if(Ot(e))return no(e);if(Et(e))try{return JSON.stringify(e)}catch(e){return"[SessionReplay] Failed to stringify response object"}return"[SessionReplay] Cannot read body of type "+toString.call(e)}const Vg=e=>!Pt(e)&&("navigation"===e.entryType||"resource"===e.entryType);function Gg(e,{entry:t,method:i,status:n,networkRequest:s,isInitial:r,start:o,end:a,url:l,initiatorType:c}){o=t?t.startTime:o,a=t?t.responseEnd:a;const u=Math.floor(Date.now()-e.performance.now()),d=Math.floor(u+(o||0)),h=[ct(ct({},t?JSON.parse(JSON.stringify(t.toJSON())):{name:l}),{},{startTime:xt(o)?void 0:Math.round(o),endTime:xt(a)?void 0:Math.round(a),timeOrigin:u,timestamp:d,method:i,initiatorType:c||(t?t.initiatorType:void 0),status:n,requestHeaders:s.requestHeaders,requestBody:s.requestBody,responseHeaders:s.responseHeaders,responseBody:s.responseBody,isInitial:r})];if(Vg(t))for(const e of t.serverTiming||[])h.push({timeOrigin:u,timestamp:d,startTime:Math.round(t.startTime),name:e.name,duration:e.duration,entryType:"serverTiming"});return h}const Qg=["video/","audio/"];function Kg(e){return Et(e)&&Ct(e.getReader)&&Ct(e.tee)}const Jg="[SessionReplay] Timeout while trying to read body",Yg="[SessionReplay] Failed to read body";function Zg(e){return`${Yg}: ${e}`}function Xg(e){return`[SessionReplay] Body too large to record (> ${e} bytes)`}function e_(e,t){if(!t.streamNetworkBody)return function(e){return new Promise(t=>{const i=setTimeout(()=>t(Jg),500);try{e.clone().text().then(e=>t(e),e=>t(Zg(e))).finally(()=>clearTimeout(i))}catch(e){clearTimeout(i),t(Yg)}})}(e);const i=ia(t);return function(e,t){try{var i,n;const s=null===(i=e.headers)||void 0===i||null===(n=i.get)||void 0===n?void 0:n.call(i,"content-length");if(!s)return!1;const r=parseInt(s,10);return Number.isFinite(r)&&r>t}catch(e){return!1}}(e,i)?Promise.resolve(Xg(i)):function(e,t){return new Promise(i=>{let n,s=!1;function r(){try{null==n||n.cancel().catch(()=>{})}catch(e){}}function o(e){s||(s=!0,clearTimeout(a),r(),i(e))}const a=setTimeout(()=>o(Jg),500);let l;try{l=e.clone()}catch(e){return void o(Yg)}const c=l.body;if(!Kg(c)||"undefined"==typeof TextDecoder){try{l.text().then(e=>o(e),e=>o(Zg(e)))}catch(e){o(Yg)}return}try{n=c.getReader()}catch(e){return void o(Yg)}const u=[];let d=0;!function e(){n.read().then(({done:i,value:n})=>{if(s)r();else if(i)o((new TextDecoder).decode(function(e,t){const i=new Uint8Array(t);let n=0;for(const t of e)i.set(t,n),n+=t.byteLength;return i}(u,d)));else{if(n){if(d+n.byteLength>t)return void o(Xg(t));d+=n.byteLength,u.push(n)}e()}},e=>o(Zg(e)))}()})}(e,i)}function t_(e){return i_.apply(this,arguments)}function i_(){return i_=rt(function*({r:e,options:t,url:i}){const{hostname:n,isHostDenied:s}=Fg(i,t);return s?Promise.resolve(n+" is in deny list"):e_(e,t)}),i_.apply(this,arguments)}function n_(e){return s_.apply(this,arguments)}function s_(){return s_=rt(function*({r:e,options:t,url:i}){const n=function({r:e,options:t,url:i}){var n;if("chunked"===e.headers.get("Transfer-Encoding"))return"Chunked Transfer-Encoding is not supported";const s=null===(n=e.headers.get("Content-Type"))||void 0===n?void 0:n.toLowerCase(),r=Qg.some(e=>null==s?void 0:s.startsWith(e));if(s&&r)return`Content-Type ${s} is not supported`;const{hostname:o,isHostDenied:a}=Fg(i,t);return a?o+" is in deny list":null}({r:e,options:t,url:i});return Pt(n)?e_(e,t):Promise.resolve(n)}),s_.apply(this,arguments)}let r_=null;function o_(e,t,i){if(!("performance"in t))return()=>{};if(r_)return Ag.warn("Network observer already initialised, doing nothing"),()=>{};const n=i?Object.assign({},na,i):na;let s=!0,r=!1;const o=t=>{if(!s)return;const i=[];let o=!1;t.requests.forEach(e=>{const t="serverTiming"===e.entryType;if(t&&o)return;let s;try{s=n.maskRequestFn(e)}catch(e){return r||(r=!0,Ag.warn("Network capture masking callback failed; dropping the record. Further masking failures will not be logged for this observer.")),void(t||(o=!0))}t||(o=!s||(e=>!!e&&da.has(e))(s)),s&&i.push(s)}),i.length>0&&e(ct(ct({},t),{},{requests:i}))},a=function(e,t,i){try{e({requests:Ng(t,i).flatMap(e=>Gg(t,{entry:e,method:void 0,status:void 0,networkRequest:{},isInitial:!0})),isInitial:!0})}catch(e){Ag.error("Failed to capture initial performance entries for network capture",e)}const n=t.PerformanceObserver,s=null==n?void 0:n.supportedEntryTypes;if(!n||!kt(s))return;const r=s.filter(e=>i.performanceEntryTypeToObserve.includes(e));if(!r.length)return;const o=new n(n=>{e({requests:n.getEntries().filter(e=>Lg(e)||Og(e)&&i.initiatorTypes.includes(e.initiatorType)&&(e=>!i.recordBody&&!i.recordHeaders||"xmlhttprequest"!==e.initiatorType&&"fetch"!==e.initiatorType)(e)).flatMap(e=>Gg(t,{entry:e,method:void 0,status:void 0,networkRequest:{}}))})});return o.observe({entryTypes:r}),()=>{o.disconnect()}}(o,t,n),l=n.recordHeaders||n.recordBody;if(!a&&!l)return s=!1,Dg;let c=()=>{},u=()=>{};return l&&(c=function(e,t,i){if(!i.initiatorTypes.includes("xmlhttprequest"))return()=>{};const n=Bg("request",i.recordHeaders),s=Bg("response",i.recordHeaders),r=Mg(t.XMLHttpRequest.prototype,"open",r=>function(o,a,l=!0,c,u){const d=this;try{const r=new Request(a),l={};let c,u;const h={},p=d.setRequestHeader.bind(d);d.setRequestHeader=(e,t)=>(h[e]=t,p(e,t)),n&&(l.requestHeaders=h);const g=d.send.bind(d);d.send=e=>(Ug({type:"request",headers:h,url:a,recordBody:i.recordBody})&&(l.requestBody=jg({body:e,options:i,url:a})),c=t.performance.now(),g(e));const _=()=>{d.removeEventListener("readystatechange",f),d.removeEventListener("error",_),d.removeEventListener("abort",_),d.removeEventListener("timeout",_)},f=()=>{if(d.readyState!==d.DONE)return;_(),u=t.performance.now();const n={};d.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),i=t.shift(),s=t.join(": ");i&&(n[i]=s)}),s&&(l.responseHeaders=n),Ug({type:"response",headers:n,url:a,recordBody:i.recordBody})&&(l.responseBody=jg({body:d.response,options:i,url:a})),zg(t,"xmlhttprequest",r.url,c,u).then(i=>{e({requests:Gg(t,{entry:i,method:o,status:null==d?void 0:d.status,networkRequest:l,start:c,end:u,url:a.toString(),initiatorType:"xmlhttprequest"})})}).catch(()=>{})};d.addEventListener("readystatechange",f),d.addEventListener("error",_),d.addEventListener("abort",_),d.addEventListener("timeout",_)}catch(e){Ag.error("Failed to instrument XHR for network capture",e)}r.call(d,o,a.toString(),l,c,u)});return()=>{r()}}(o,t,n),u=!0===n.captureFetchSynchronously?function(e,t,i){if(!i.initiatorTypes.includes("fetch"))return()=>{};const n=Bg("request",i.recordHeaders),s=Bg("response",i.recordHeaders),r=Mg(t,"fetch",r=>function(o,a){let l;try{l=new Request(o,a)}catch(e){Ag.error("Failed to instrument fetch for network capture",e);try{return Promise.resolve(r(o,a))}catch(e){return new Promise((t,i)=>i(e))}}const c={};let u,d;const h=rt(function*(){try{const e={};l.headers.forEach((t,i)=>{e[i]=t}),n&&(c.requestHeaders=e),!Kg(null==a?void 0:a.body)&&Ug({type:"request",headers:e,url:o,recordBody:i.recordBody})&&(c.requestBody=yield t_({r:l,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch request for network capture",e)}})(),p=(g=rt(function*(e){try{const t={};e.headers.forEach((e,i)=>{t[i]=e}),s&&(c.responseHeaders=t),Ug({type:"response",headers:t,url:o,recordBody:i.recordBody})&&(c.responseBody=yield n_({r:e,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch response for network capture",e)}}),function(e){return g.apply(this,arguments)});var g;try{u=t.performance.now()}catch(e){}let _;try{_=qg(o)?r(l):r(o,a)}catch(e){_=new Promise((t,i)=>i(e))}const f=Promise.resolve(_).then(e=>{try{d=t.performance.now()}catch(e){}return{status:"fulfilled",response:e}},e=>({status:"rejected",error:e}));return rt(function*(){let i;try{yield h;const e=yield f;if("rejected"===e.status)throw e.error;return i=e.response,yield p(i),i}finally{(n=i,zg(t,"fetch",l.url,u,d).then(i=>{e({requests:Gg(t,{entry:i,method:l.method,status:null==n?void 0:n.status,networkRequest:c,start:u,end:d,url:l.url,initiatorType:"fetch"})})})).catch(()=>{})}var n})()});return()=>{r()}}(o,t,n):function(e,t,i){if(!i.initiatorTypes.includes("fetch"))return()=>{};const n=Bg("request",i.recordHeaders),s=Bg("response",i.recordHeaders),r=Mg(t,"fetch",r=>function(){var o=rt(function*(o,a){let l,c;try{l=new Request(o,a)}catch(e){return Ag.error("Failed to instrument fetch for network capture",e),r(o,a)}const u={};let d,h;try{try{const e={};l.headers.forEach((t,i)=>{e[i]=t}),n&&(u.requestHeaders=e),!Kg(null==a?void 0:a.body)&&Ug({type:"request",headers:e,url:o,recordBody:i.recordBody})&&(u.requestBody=yield t_({r:l,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch request for network capture",e)}d=t.performance.now(),c=qg(o)?yield r(l):yield r(o,a),h=t.performance.now();try{const e={};c.headers.forEach((t,i)=>{e[i]=t}),s&&(u.responseHeaders=e),Ug({type:"response",headers:e,url:o,recordBody:i.recordBody})&&(u.responseBody=yield n_({r:c,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch response for network capture",e)}return c}finally{zg(t,"fetch",l.url,d,h).then(i=>{e({requests:Gg(t,{entry:i,method:l.method,status:null==c?void 0:c.status,networkRequest:u,start:d,end:h,url:l.url,initiatorType:"fetch"})})}).catch(()=>{})}});return function(e,t){return o.apply(this,arguments)}}());return()=>{r()}}(o,t,n)),r_=()=>{s=!1,null==a||a(),c(),u(),r_=null},r_}const a_=e=>({name:"rrweb/network@1",observer:o_,options:e});var l_,c_,u_,d_,h_,p_,g_,__,f_,v_,m_,y_,b_,S_,w_;d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.rrwebPlugins={getRecordConsolePlugin:Ig,getRecordNetworkPlugin:a_},d.__PosthogExtensions__.rrweb={record:hg,version:"v2",wasMaxDepthReached:()=>Fh,resetMaxDepthState(){Fh=!1,Mh=!1},getLastSnapshotCost:()=>gd,getMutationCost:()=>ct({},yd),getObserverInitFailures:()=>Ep.size?Array.from(Ep):void 0,resetSnapshotCostState(){ud=0,dd=0,hd=0,od=0,pd={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gd=null,_d=null,fd=[],vd=0,md=0,yd={slowestBatchMs:0},bd={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0}}},d.rrweb={record:hg,version:"v2"},d.rrwebConsoleRecord={getRecordConsolePlugin:Ig},d.getRecordNetworkPlugin=a_,d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.initSessionRecording=(e,t)=>new $u(e,t);var k_={},C_=[],E_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,T_=Array.isArray;function x_(e,t){for(var i in t)e[i]=t[i];return e}function I_(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function R_(e,t,i){var n,s,r,o={};for(r in t)"key"==r?n=t[r]:"ref"==r?s=t[r]:o[r]=t[r];if(arguments.length>2&&(o.children=arguments.length>3?l_.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===o[r]&&(o[r]=e.defaultProps[r]);return P_(e,o,n,s,null)}function P_(e,t,i,n,s){var r={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==s?++u_:s,__i:-1,__u:0};return null==s&&null!=c_.vnode&&c_.vnode(r),r}function M_(e){return e.children}function F_(e,t){this.props=e,this.context=t}function A_(e,t){if(null==t)return e.__?A_(e.__,e.__i+1):null;for(var i;e.__k.length>t;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?A_(e):null}function L_(e){if(e.__P&&e.__d){var t=e.__v,i=t.__e,n=[],s=[],r=x_({},t);r.__v=t.__v+1,c_.vnode&&c_.vnode(r),W_(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[i]:null,n,null==i?A_(t):i,!!(32&t.__u),s),r.__v=t.__v,r.__.__k[r.__i]=r,V_(n,r,s),t.__e=t.__=null,r.__e!=i&&O_(r)}}function O_(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),O_(e)}function D_(e){(!e.__d&&(e.__d=!0)&&d_.push(e)&&!$_.__r++||h_!=c_.debounceRendering)&&((h_=c_.debounceRendering)||p_)($_)}function $_(){try{for(var e,t=1;d_.length;)d_.length>t&&d_.sort(g_),e=d_.shift(),t=d_.length,L_(e)}finally{d_.length=$_.__r=0}}function N_(e,t,i,n,s,r,o,a,l,c,u){var d,h,p,g,_,f,v,m=n&&n.__k||C_,y=t.length;for(l=function(e,t,i,n,s){var r,o,a,l,c,u=i.length,d=u,h=0;for(e.__k=new Array(s),r=0;s>r;r++)null!=(o=t[r])&&"boolean"!=typeof o&&"function"!=typeof o?("string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?o=e.__k[r]=P_(null,o,null,null,null):T_(o)?o=e.__k[r]=P_(M_,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=e.__k[r]=P_(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[r]=o,l=r+h,o.__=e,o.__b=e.__b+1,a=null,-1!=(c=o.__i=q_(o,i,l,d))&&(d--,(a=i[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(s>u?h--:u>s&&h++),"function"!=typeof o.type&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[r]=null;if(d)for(r=0;u>r;r++)null!=(a=i[r])&&!(2&a.__u)&&(a.__e==n&&(n=A_(a)),K_(a,a));return n}(i,t,m,l,y),d=0;y>d;d++)null!=(p=i.__k[d])&&(h=-1!=p.__i&&m[p.__i]||k_,p.__i=d,f=W_(e,p,h,s,r,o,a,l,c,u),g=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&Q_(h.ref,null,p),u.push(p.ref,p.__c||g,p)),null==_&&null!=g&&(_=g),(v=!!(4&p.__u))||h.__k===p.__k?(l=B_(p,l,e,v),v&&h.__e&&(h.__e=null)):"function"==typeof p.type&&void 0!==f?l=f:g&&(l=g.nextSibling),p.__u&=-7);return i.__e=_,l}function B_(e,t,i,n){var s,r;if("function"==typeof e.type){for(s=e.__k,r=0;s&&s.length>r;r++)s[r]&&(s[r].__=e,t=B_(s[r],t,i,n));return t}e.__e!=t&&(n&&(t&&e.type&&!t.parentNode&&(t=A_(e)),i.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function q_(e,t,i,n){var s,r,o,a=e.key,l=e.type,c=t[i],u=null!=c&&!(2&c.__u);if(null===c&&null==a||u&&a==c.key&&l==c.type)return i;if(n>(u?1:0))for(s=i-1,r=i+1;s>=0||t.length>r;)if(null!=(c=t[o=0>s?r++:s--])&&!(2&c.__u)&&a==c.key&&l==c.type)return o;return-1}function H_(e,t,i){"-"==t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||E_.test(t)?i:i+"px"}function U_(e,t,i,n,s){var r,o;e:if("style"==t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof n&&(e.style.cssText=n=""),n)for(t in n)i&&t in i||H_(e.style,t,"");if(i)for(t in i)n&&i[t]==n[t]||H_(e.style,t,i[t])}else if("o"==t[0]&&"n"==t[1])r=t!=(t=t.replace(m_,"$1")),o=t.toLowerCase(),t=o in e||"onFocusOut"==t||"onFocusIn"==t?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=i,i?n?i[v_]=n[v_]:(i[v_]=y_,e.addEventListener(t,r?S_:b_,r)):e.removeEventListener(t,r?S_:b_,r);else{if("http://www.w3.org/2000/svg"==s)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==i?"":i))}}function z_(e){return function(t){if(this.l){var i=this.l[t.type+e];if(null==t[f_])t[f_]=y_++;else if(i[v_]>t[f_])return;return i(c_.event?c_.event(t):t)}}}function W_(e,t,i,n,s,r,o,a,l,c){var u,d,h,p,g,_,f,v,m,y,$,b,S,w,k,C,E=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),r=[a=t.__e=i.__e]),(u=c_.__b)&&u(t);e:if("function"==typeof E){d=o.length;try{if(m=t.props,y=E.prototype&&E.prototype.render,$=(u=E.contextType)&&n[u.__c],b=u?$?$.props.value:u.__:n,i.__c?v=(h=t.__c=i.__c).__=h.__E:(y?t.__c=h=new E(m,b):(t.__c=h=new F_(m,b),h.constructor=E,h.render=J_),$&&$.sub(h),h.state||(h.state={}),h.__n=n,p=h.__d=!0,h.__h=[],h._sb=[]),y&&null==h.__s&&(h.__s=h.state),y&&null!=E.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=x_({},h.__s)),x_(h.__s,E.getDerivedStateFromProps(m,h.__s))),g=h.props,_=h.state,h.__v=t,p)y&&null==E.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),y&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(y&&null==E.getDerivedStateFromProps&&m!==g&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,b),t.__v==i.__v||!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,b)){t.__v!=i.__v&&(h.props=m,h.state=h.__s,h.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.some(function(e){e&&(e.__=t)}),C_.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,b),y&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(g,_,f)})}if(h.context=b,h.props=m,h.__P=e,h.__e=!1,S=c_.__r,w=0,y)h.state=h.__s,h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),C_.push.apply(h.__h,h._sb),h._sb=[];else do{h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&25>++w);h.state=h.__s,null!=h.getChildContext&&(n=x_(x_({},n),h.getChildContext())),y&&!p&&null!=h.getSnapshotBeforeUpdate&&(f=h.getSnapshotBeforeUpdate(g,_)),k=null!=u&&u.type===M_&&null==u.key?G_(u.props.children):u,a=N_(e,T_(k)?k:[k],t,i,n,s,r,o,a,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),v&&(h.__E=h.__=null)}catch(e){if(o.length=d,t.__v=null,l||null!=r)if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;null!=r&&(r[r.indexOf(a)]=null),t.__e=a}else{if(null!=r)for(C=r.length;C--;)I_(r[C]);j_(t)}else t.__e=i.__e,!t.__k&&i.__k&&(t.__k=i.__k),e.then||j_(t);c_.__e(e,t,i)}}else null==r&&t.__v==i.__v?(t.__k=i.__k,t.__e=i.__e):a=t.__e=function(e,t,i,n,s,r,o,a,l){var c,u,d,h,p,g,_,f=i.props||k_,v=t.props,m=t.type;if("svg"==m?s="http://www.w3.org/2000/svg":"math"==m?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),null!=r)for(c=0;r.length>c;c++)if((p=r[c])&&"setAttribute"in p==!!m&&(m?p.localName==m:3==p.nodeType)){e=p,r[c]=null;break}if(null==e){if(null==m)return document.createTextNode(v);e=document.createElementNS(s,m,v.is&&v),a&&(c_.__m&&c_.__m(t,r),a=!1),r=null}if(null==m)f===v||a&&e.data==v||(e.data=v);else{if(r="textarea"==m&&null!=v.defaultValue?null:r&&l_.call(e.childNodes),!a&&null!=r)for(f={},c=0;e.attributes.length>c;c++)f[(p=e.attributes[c]).name]=p.value;for(c in f)p=f[c],"dangerouslySetInnerHTML"==c?d=p:"children"==c||c in v||"value"==c&&"defaultValue"in v||"checked"==c&&"defaultChecked"in v||U_(e,c,null,p,s);for(c in v)p=v[c],"children"==c?h=p:"dangerouslySetInnerHTML"==c?u=p:"value"==c?g=p:"checked"==c?_=p:a&&"function"!=typeof p||f[c]===p||U_(e,c,p,f[c],s);if(u)a||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),N_("template"==t.type?e.content:e,T_(h)?h:[h],t,i,n,"foreignObject"==m?"http://www.w3.org/1999/xhtml":s,r,o,r?r[0]:i.__k&&A_(i,0),a,l),null!=r)for(c=r.length;c--;)I_(r[c]);a&&"textarea"!=m||(c="value","progress"==m&&null==g?e.removeAttribute("value"):null!=g&&(g!==e[c]||"progress"==m&&!g||"option"==m&&g!=f[c])&&U_(e,c,g,f[c],s),c="checked",null!=_&&_!=e[c]&&U_(e,c,_,f[c],s))}return e}(i.__e,t,i,n,s,r,o,l,c);return(u=c_.diffed)&&u(t),128&t.__u?void 0:a}function j_(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(j_))}function V_(e,t,i){for(var n=0;i.length>n;n++)Q_(i[n],i[++n],i[++n]);c_.__c&&c_.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){c_.__e(e,t.__v)}})}function G_(e){return"object"!=typeof e||null==e||e.__b>0?e:T_(e)?e.map(G_):void 0!==e.constructor?null:x_({},e)}function Q_(e,t,i){try{if("function"==typeof e){var n="function"==typeof e.__u;n&&e.__u(),n&&null==t||(e.__u=e(t))}else e.current=t}catch(e){c_.__e(e,i)}}function K_(e,t,i){var n,s;if(c_.unmount&&c_.unmount(e),(n=e.ref)&&(n.current&&n.current!=e.__e||Q_(n,null,t)),null!=(n=e.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(e){c_.__e(e,t)}n.base=n.__P=n.__n=null}if(n=e.__k)for(s=0;n.length>s;s++)n[s]&&K_(n[s],t,i||"function"!=typeof e.type);i||I_(e.__e),e.__c=e.__=e.__e=void 0}function J_(e,t,i){return this.constructor(e,i)}function Y_(e,t,i){var n,s,r,o;t==document&&(t=document.documentElement),c_.__&&c_.__(e,t),s=(n="function"==typeof i)?null:i&&i.__k||t.__k,r=[],o=[],W_(t,e=(!n&&i||t).__k=R_(M_,null,[e]),s||k_,k_,t.namespaceURI,!n&&i?[i]:s?null:t.firstChild?l_.call(t.childNodes):null,r,!n&&i?i:s?s.__e:t.firstChild,n,o),V_(r,e,o),e.props.children=null}l_=C_.slice,c_={__e(e,t,i,n){for(var s,r,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((r=s.constructor)&&null!=r.getDerivedStateFromError&&(s.setState(r.getDerivedStateFromError(e)),o=s.__d),null!=s.componentDidCatch&&(s.componentDidCatch(e,n||{}),o=s.__d),o)return s.__E=s}catch(t){e=t}throw e}},u_=0,F_.prototype.setState=function(e,t){var i=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=x_({},this.state);"function"==typeof e&&(e=e(x_({},i),this.props)),e&&x_(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),D_(this))},F_.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),D_(this))},F_.prototype.render=M_,d_=[],p_="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,g_=function(e,t){return e.__v.__b-t.__v.__b},$_.__r=0,__=Math.random().toString(8),f_="__d"+__,v_="__a"+__,m_=/(PointerCapture)$|Capture$/i,y_=0,b_=z_(!1),S_=z_(!0),w_=0;var Z_=0;function X_(e,t,i,n,s,r){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)"ref"==a?o=t[a]:l[a]=t[a];var c={type:e,props:l,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Z_,__i:-1,__u:0,__source:s,__self:r};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return c_.vnode&&c_.vnode(c),c}const ef="featureFlagsCommon";function tf({client:e,config:t}){var i;if(!e||!t.uiHost)return;const n=null===(i=e.session)||void 0===i?void 0:i.sessionId;return n?`${t.uiHost}/project/${e.projectToken}/replay/${n}`:void 0}var nf,sf,rf,of,af=0,lf=[],cf=c_,uf=cf.__b,df=cf.__r,hf=cf.diffed,pf=cf.__c,gf=cf.unmount,_f=cf.__;function ff(e,t){cf.__h&&cf.__h(sf,e,af||t),af=0;var i=sf.__H||(sf.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({}),i.__[e]}function vf(e){return af=1,function(e,t){var i=ff(nf++,2);if(i.t=e,!i.__c&&(i.__=[If(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=sf,!sf.__f)){var n=function(e,t,n){if(!i.__c.__H)return!0;var r=!1,o=i.__c.props!==e;if(i.__c.__H.__.some(function(e){if(e.__N){r=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),s){var a=s.call(this,e,t,n);return r?a||o:a}return!r||o};sf.__f=!0;var s=sf.shouldComponentUpdate,r=sf.componentWillUpdate;sf.componentWillUpdate=function(e,t,i){if(this.__e){var o=s;s=void 0,n(e,t,i),s=o}r&&r.call(this,e,t,i)},sf.shouldComponentUpdate=n}return i.__N||i.__}(If,e)}function mf(e,t){var i=ff(nf++,3);!cf.__s&&xf(i.__H,t)&&(i.__=e,i.u=t,sf.__H.__h.push(i))}function yf(e){return af=5,bf(function(){return{current:e}},[])}function bf(e,t){var i=ff(nf++,7);return xf(i.__H,t)&&(i.__=e(),i.__H=t,i.__h=e),i.__}function Sf(e){var t=sf.context[e.__c],i=ff(nf++,9);return i.c=e,t?(null==i.__&&(i.__=!0,t.sub(sf)),t.props.value):e.__}function wf(){for(var e;e=lf.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ef),t.__h.some(Tf),t.__h=[]}catch(i){t.__h=[],cf.__e(i,e.__v)}}}cf.__b=function(e){sf=null,uf&&uf(e)},cf.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),_f&&_f(e,t)},cf.__r=function(e){df&&df(e),nf=0;var t=(sf=e.__c).__H;t&&(rf===sf?(t.__h=[],sf.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.length&&wf(),nf=0)),rf=sf},cf.diffed=function(e){hf&&hf(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==lf.push(t)&&of===cf.requestAnimationFrame||((of=cf.requestAnimationFrame)||Cf)(wf)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),rf=sf=null},cf.__c=function(e,t){t.some(function(e){try{e.__h.some(Ef),e.__h=e.__h.filter(function(e){return!e.__||Tf(e)})}catch(i){t.some(function(e){e.__h&&(e.__h=[])}),t=[],cf.__e(i,e.__v)}}),pf&&pf(e,t)},cf.unmount=function(e){gf&&gf(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.some(function(e){try{Ef(e)}catch(e){t=e}}),i.__H=void 0,t&&cf.__e(t,i.__v))};var kf="function"==typeof requestAnimationFrame;function Cf(e){var t,i=function(){clearTimeout(n),kf&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(i,35);kf&&(t=requestAnimationFrame(i))}function Ef(e){var t=sf,i=e.__c;"function"==typeof i&&(e.__c=void 0,i()),sf=t}function Tf(e){var t=sf;e.__c=e.__(),sf=t}function xf(e,t){return!e||e.length!==t.length||t.some(function(t,i){return t!==e[i]})}function If(e,t){return"function"==typeof t?t(e):t}const Rf={Activation:"events",Cancellation:"cancelEvents"},Pf={Button:"button",Tab:"tab",Selector:"selector"},Mf={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"},Ff={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Af={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Lf={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},Of={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Df={Once:"once",Recurring:"recurring",Always:"always"},$f={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Nf={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"},Bf={Popover:"popover",Inline:"inline"},qf=Br("[Surveys]"),Hf="PostHog is not capturing, so a survey response cannot be recorded";function Uf(e){return!(!e.start_date||e.end_date)}function zf(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}const Wf=(e,t)=>`${e}${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`,jf=e=>Wf("seenSurvey_",e),Vf=e=>{try{const t=jf(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){qf.error("Failed to persist survey seen state",e)}},Gf=[Af.Popover,Af.Widget,Af.API],Qf={ignoreConditions:!1,ignoreDelay:!1,displayType:Bf.Popover};function Kf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Jf(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,s,r,o,a=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t);else for(;!(l=(n=r.call(i)).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(c)throw s}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Kf(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Kf(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const Yf=Object.entries,Zf=Object.setPrototypeOf,Xf=Object.isFrozen,ev=Object.getPrototypeOf,tv=Object.getOwnPropertyDescriptor;let iv=Object.freeze,nv=Object.seal,sv=Object.create,rv="undefined"!=typeof Reflect&&Reflect,ov=rv.apply,av=rv.construct;iv||(iv=function(e){return e}),nv||(nv=function(e){return e}),ov||(ov=function(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),s=2;i>s;s++)n[s-2]=arguments[s];return e.apply(t,n)}),av||(av=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;t>n;n++)i[n-1]=arguments[n];return new e(...i)});const lv=Rv([].forEach),cv=Rv([].lastIndexOf),uv=Rv([].pop),dv=Rv([].push),hv=Rv([].splice),pv=Array.isArray,gv=Rv("".toLowerCase),_v=Rv("".toString),fv=Rv("".match),vv=Rv("".replace),mv=Rv("".indexOf),yv=Rv("".trim),bv=Rv((0).toString),Sv=Rv(Boolean.prototype.toString),wv="undefined"==typeof BigInt?null:Rv(BigInt.prototype.toString),kv="undefined"==typeof Symbol?null:Rv(Symbol.prototype.toString),Cv=Rv({}.hasOwnProperty),Ev=Rv({}.toString),Tv=Rv(/t/.test),xv=(Iv=TypeError,function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return av(Iv,t)});var Iv;function Rv(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;i>s;s++)n[s-1]=arguments[s];return ov(e,t,n)}}function Pv(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:gv;if(Zf&&Zf(e,null),!pv(t))return e;let n=t.length;for(;n--;){let s=t[n];if("string"==typeof s){const e=i(s);e!==s&&(Xf(t)||(t[n]=e),s=e)}e[s]=!0}return e}function Mv(e){for(let t=0;e.length>t;t++)Cv(e,t)||(e[t]=null);return e}function Fv(e){const t=sv(null);for(const n of Yf(e)){var i=Jf(n,2);const s=i[0],r=i[1];Cv(e,s)&&(t[s]=pv(r)?Mv(r):r&&"object"==typeof r&&r.constructor===Object?Fv(r):r)}return t}function Av(e,t){for(;null!==e;){const i=tv(e,t);if(i){if(i.get)return Rv(i.get);if("function"==typeof i.value)return Rv(i.value)}e=ev(e)}return function(){return null}}const Lv=iv(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ov=iv(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Dv=iv(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$v=iv(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Nv=iv(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Bv=iv(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qv=iv(["#text"]),Hv=iv(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Uv=iv(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),zv=iv(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wv=iv(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),jv=nv(/{{[\w\W]*|^[\w\W]*}}/g),Vv=nv(/<%[\w\W]*|^[\w\W]*%>/g),Gv=nv(/\${[\w\W]*/g),Qv=nv(/^data-[\-\w.\u00B7-\uFFFF]+$/),Kv=nv(/^aria-[\-\w]+$/),Jv=nv(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Yv=nv(/^(?:\w+script|data):/i),Zv=nv(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xv=nv(/^html$/i),em=nv(/^[a-z][.\w]*(-[.\w]+)+$/i),tm=nv(/<[/\w!]/g),im=nv(/<[/\w]/g),nm=nv(/<\/no(script|embed|frames)/i),sm=nv(/\/>/i),rm=function(){return"undefined"==typeof window?null:window},om=function(e,t,i,n){return Cv(e,t)&&pv(e[t])?Pv(n.base?Fv(n.base):{},e[t],n.transform):i};var am=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rm();const i=t=>e(t);if(i.version="3.4.13",i.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return i.isSupported=!1,i;let n=t.document;const s=n,r=s.currentScript,o=t.HTMLTemplateElement,a=t.Node,l=t.NodeFilter,c=t.DOMParser,u=t.trustedTypes,d=t.Element.prototype,h=Av(d,"cloneNode"),p=Av(d,"remove"),g=Av(d,"nextSibling"),_=Av(d,"childNodes"),f=Av(d,"parentNode"),v=Av(d,"shadowRoot"),m=Av(d,"attributes"),y=a&&a.prototype?Av(a.prototype,"nodeType"):null,b=a&&a.prototype?Av(a.prototype,"nodeName"):null,S=a&&a.prototype?Av(a.prototype,"ownerDocument"):null;if("function"==typeof o){const e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let w,k,C="",E=!1,T=0;const x=function(){if(T>0)throw xv('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},I=function(e){x(),T++;try{return w.createHTML(e)}finally{T--}},R=n.implementation,P=n.createNodeIterator,M=n.createDocumentFragment,F=n.getElementsByTagName,A=s.importNode;let L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof Yf&&"function"==typeof f&&R&&void 0!==R.createHTMLDocument;const O=jv,D=Vv,N=Gv,B=Qv,q=Kv,H=Yv,U=Zv,z=em;let W=Jv,j=null;const V=Pv({},[...Lv,...Ov,...Dv,...Nv,...qv]);let G=null;const Q=Pv({},[...Hv,...Uv,...zv,...Wv]);let K=Object.seal(sv(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),J=null,Y=null;const Z=Object.seal(sv(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let X=!0,ee=!0,te=!1,ie=!0,ne=!1,se=!0,re=!1,oe=!1,ae=null,le=null,ce=!1,ue=!1,de=!1,he=!1,pe=!0,ge=!1;const _e="user-content-";let fe=!0,ve=!1,me={},ye=null;const be=Pv({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Se=null;const we=Pv({},["audio","video","img","source","image","track"]);let ke=null;const Ce=Pv({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ee="http://www.w3.org/1998/Math/MathML",Te="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let Ie=xe,Re=!1,Pe=null;const Me=Pv({},[Ee,Te,xe],_v),Fe=iv(["mi","mo","mn","ms","mtext"]);let Ae=Pv({},Fe);const Le=iv(["annotation-xml"]);let Oe=Pv({},Le);const De=Pv({},["title","style","font","a","script"]);let $e=null;const Ne=["application/xhtml+xml","text/html"];let Be=null,qe=null;const He=n.createElement("form"),Ue=function(e){return e instanceof RegExp||e instanceof Function},ze=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(qe&&qe===e)return;e&&"object"==typeof e||(e={}),e=Fv(e),$e=-1===Ne.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Be="application/xhtml+xml"===$e?_v:gv,j=om(e,"ALLOWED_TAGS",V,{transform:Be}),G=om(e,"ALLOWED_ATTR",Q,{transform:Be}),Pe=om(e,"ALLOWED_NAMESPACES",Me,{transform:_v}),ke=om(e,"ADD_URI_SAFE_ATTR",Ce,{transform:Be,base:Ce}),Se=om(e,"ADD_DATA_URI_TAGS",we,{transform:Be,base:we}),ye=om(e,"FORBID_CONTENTS",be,{transform:Be}),J=om(e,"FORBID_TAGS",Fv({}),{transform:Be}),Y=om(e,"FORBID_ATTR",Fv({}),{transform:Be}),me=!!Cv(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?Fv(e.USE_PROFILES):e.USE_PROFILES),X=!1!==e.ALLOW_ARIA_ATTR,ee=!1!==e.ALLOW_DATA_ATTR,te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ie=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ne=e.SAFE_FOR_TEMPLATES||!1,se=!1!==e.SAFE_FOR_XML,re=e.WHOLE_DOCUMENT||!1,ue=e.RETURN_DOM||!1,de=e.RETURN_DOM_FRAGMENT||!1,he=e.RETURN_TRUSTED_TYPE||!1,ce=e.FORCE_BODY||!1,pe=!1!==e.SANITIZE_DOM,ge=e.SANITIZE_NAMED_PROPS||!1,fe=!1!==e.KEEP_CONTENT,ve=e.IN_PLACE||!1,W=function(e){try{return Tv(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Jv,Ie="string"==typeof e.NAMESPACE?e.NAMESPACE:xe,Ae=Cv(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?Fv(e.MATHML_TEXT_INTEGRATION_POINTS):Pv({},Fe),Oe=Cv(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?Fv(e.HTML_INTEGRATION_POINTS):Pv({},Le);const t=Cv(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?Fv(e.CUSTOM_ELEMENT_HANDLING):sv(null);if(K=sv(null),Cv(t,"tagNameCheck")&&Ue(t.tagNameCheck)&&(K.tagNameCheck=t.tagNameCheck),Cv(t,"attributeNameCheck")&&Ue(t.attributeNameCheck)&&(K.attributeNameCheck=t.attributeNameCheck),Cv(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(K.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),nv(K),ne&&(ee=!1),de&&(ue=!0),me&&(j=Pv({},qv),G=sv(null),!0===me.html&&(Pv(j,Lv),Pv(G,Hv)),!0===me.svg&&(Pv(j,Ov),Pv(G,Uv),Pv(G,Wv)),!0===me.svgFilters&&(Pv(j,Dv),Pv(G,Uv),Pv(G,Wv)),!0===me.mathMl&&(Pv(j,Nv),Pv(G,zv),Pv(G,Wv))),Z.tagCheck=null,Z.attributeCheck=null,Cv(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?Z.tagCheck=e.ADD_TAGS:pv(e.ADD_TAGS)&&(j===V&&(j=Fv(j)),Pv(j,e.ADD_TAGS,Be))),Cv(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?Z.attributeCheck=e.ADD_ATTR:pv(e.ADD_ATTR)&&(G===Q&&(G=Fv(G)),Pv(G,e.ADD_ATTR,Be))),Cv(e,"ADD_URI_SAFE_ATTR")&&pv(e.ADD_URI_SAFE_ATTR)&&Pv(ke,e.ADD_URI_SAFE_ATTR,Be),Cv(e,"FORBID_CONTENTS")&&pv(e.FORBID_CONTENTS)&&(ye===be&&(ye=Fv(ye)),Pv(ye,e.FORBID_CONTENTS,Be)),Cv(e,"ADD_FORBID_CONTENTS")&&pv(e.ADD_FORBID_CONTENTS)&&(ye===be&&(ye=Fv(ye)),Pv(ye,e.ADD_FORBID_CONTENTS,Be)),fe&&(j["#text"]=!0),re&&Pv(j,["html","head","body"]),j.table&&(Pv(j,["tbody"]),delete J.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw xv('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw xv('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=w;w=e.TRUSTED_TYPES_POLICY;try{C=I("")}catch(e){throw w=t,e}}else null===e.TRUSTED_TYPES_POLICY?(w=void 0,C=""):(void 0===w&&(E||(k=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let i=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(u,r),E=!0),w=k),w&&"string"==typeof C&&(C=I("")));iv&&iv(e),qe=e},We=Pv({},[...Ov,...Dv,...$v]),je=Pv({},[...Nv,...Bv]),Ve=function(e){dv(i.removed,{element:e});try{f(e).removeChild(e)}catch(t){if(p(e),!f(e))throw xv("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ge=function(e){Je(e);const t=_(e);if(t){const e=[];lv(t,t=>{dv(e,t)}),lv(e,e=>{try{p(e)}catch(e){}})}const i=m(e);if(i)for(let t=i.length-1;t>=0;--t){const n=i[t],s=n&&n.name;if("string"==typeof s)try{e.removeAttribute(s)}catch(e){}}},Qe=function(e,t){try{dv(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){dv(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ue||de)try{Ve(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ke=function(e){const t=m(e);if(t)for(let i=t.length-1;i>=0;--i){const n=t[i],s=n&&n.name;if("string"==typeof s&&!G[Be(s)])try{e.removeAttribute(s)}catch(e){}}},Je=function(e){const t=[e];for(;t.length>0;){const e=t.pop();1===(y?y(e):e.nodeType)&&Ke(e);const i=_(e);if(i)for(let e=i.length-1;e>=0;--e)t.push(i[e])}},Ye=function(e){let t=null,i=null;if(ce)e="<remove></remove>"+e;else{const t=fv(e,/^[\r\n\t ]+/);i=t&&t[0]}"application/xhtml+xml"===$e&&Ie===xe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=w?I(e):e;if(Ie===xe)try{t=(new c).parseFromString(s,$e)}catch(e){}if(!t||!t.documentElement){t=R.createDocument(Ie,"template",null);try{t.documentElement.innerHTML=Re?C:s}catch(e){}}const r=t.body||t.documentElement;return e&&i&&r.insertBefore(n.createTextNode(i),r.childNodes[0]||null),Ie===xe?F.call(t,re?"html":"body")[0]:re?t.documentElement:r},Ze=function(e){const t=S?S(e):e.ownerDocument;return P.call(t||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Xe=function(e){return e=vv(e,O," "),e=vv(e,D," "),vv(e,N," ")},et=function(e){var t;e.normalize();const i=S?S(e):e.ownerDocument,n=P.call(i||e,e,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let s=n.nextNode();for(;s;)s.data=Xe(s.data),s=n.nextNode();const r=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");r&&lv(r,e=>{it(e.content)&&et(e.content)})},tt=function(e){const t=b?b(e):null;return"string"==typeof t&&"form"===Be(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==m(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==y(e)||e.childNodes!==_(e))},it=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return 11===y(e)}catch(e){return!1}},nt=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return"number"==typeof y(e)}catch(e){return!1}};function st(e,t,n){0!==e.length&&lv(e,e=>{e.call(i,t,n,qe)})}const rt=function(e,t,i,n){return 0===e.length?t:t===i||t===n?Fv(t):t},ot=function(e,t){if(st(L.beforeSanitizeElements,e,null),e!==t&&null===f(e))return ve&&Je(e),!0;if(tt(e))return Ve(e),!0;const n=Be(b?b(e):e.nodeName);if(j=rt(L.uponSanitizeElement,j,V,ae),st(L.uponSanitizeElement,e,{tagName:n,allowedTags:j}),e!==t&&null===f(e))return ve&&Je(e),!0;if(function(e,t){return!!(se&&e.hasChildNodes()&&!nt(e.firstElementChild)&&Tv(tm,e.textContent)&&Tv(tm,e.innerHTML))||!(!se||e.namespaceURI!==xe||"style"!==t||!nt(e.firstElementChild))||7===e.nodeType||!(!se||8!==e.nodeType||!Tv(im,e.data))}(e,n))return Ve(e),!0;if(J[n]||!(Z.tagCheck instanceof Function&&Z.tagCheck(n))&&!j[n]){const i=function(e,t,i){if(!J[t]&&ct(t)){if(K.tagNameCheck instanceof RegExp&&Tv(K.tagNameCheck,t))return!1;if(K.tagNameCheck instanceof Function&&K.tagNameCheck(t))return!1}if(fe&&!ye[t]){const t=f(e),n=_(e);if(n&&t)for(let s=n.length-1;s>=0;--s){const r=e===i?h(n[s],!0):n[s];t.insertBefore(r,g(e))}}return Ve(e),!0}(e,n,t);return!1===i&&st(L.afterSanitizeElements,e,null),i}if(1===(y?y(e):e.nodeType)&&!function(e){let t=f(e);t&&t.tagName||(t={namespaceURI:Ie,tagName:"template"});const i=gv(e.tagName),n=gv(t.tagName);return!!Pe[e.namespaceURI]&&(e.namespaceURI===Te?function(e,t,i){return t.namespaceURI===xe?"svg"===e:t.namespaceURI===Ee?"svg"===e&&("annotation-xml"===i||Ae[i]):Boolean(We[e])}(i,t,n):e.namespaceURI===Ee?function(e,t,i){return t.namespaceURI===xe?"math"===e:t.namespaceURI===Te?"math"===e&&Oe[i]:Boolean(je[e])}(i,t,n):e.namespaceURI===xe?function(e,t,i){return!(t.namespaceURI===Te&&!Oe[i])&&!(t.namespaceURI===Ee&&!Ae[i])&&!je[e]&&(De[e]||!We[e])}(i,t,n):!("application/xhtml+xml"!==$e||!Pe[e.namespaceURI]))}(e))return Ve(e),!0;if(("noscript"===n||"noembed"===n||"noframes"===n)&&Tv(nm,e.innerHTML))return Ve(e),!0;if(ne&&3===e.nodeType){const t=Xe(e.textContent);e.textContent!==t&&(dv(i.removed,{element:e.cloneNode()}),e.textContent=t)}return st(L.afterSanitizeElements,e,null),!1},at=function(e,t,i){if(Y[t])return!1;if(se&&"patchsrc"===t)return!1;if(se&&"for"===t&&"label"!==e&&"output"!==e)return!1;if(pe&&("id"===t||"name"===t)&&(i in n||i in He))return!1;const s=G[t]||Z.attributeCheck instanceof Function&&Z.attributeCheck(t,e);if(ee&&Tv(B,t));else if(X&&Tv(q,t));else if(s){if(ke[t]);else if(Tv(W,vv(i,U,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==mv(i,"data:")||!Se[e])if(te&&!Tv(H,vv(i,U,"")));else if(i)return!1}else if(!(ct(e)&&(K.tagNameCheck instanceof RegExp&&Tv(K.tagNameCheck,e)||K.tagNameCheck instanceof Function&&K.tagNameCheck(e))&&(K.attributeNameCheck instanceof RegExp&&Tv(K.attributeNameCheck,t)||K.attributeNameCheck instanceof Function&&K.attributeNameCheck(t,e))||"is"===t&&K.allowCustomizedBuiltInElements&&(K.tagNameCheck instanceof RegExp&&Tv(K.tagNameCheck,i)||K.tagNameCheck instanceof Function&&K.tagNameCheck(i))))return!1;return!0},lt=Pv({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ct=function(e){return!lt[gv(e)]&&Tv(z,e)},ut=function(e,t,i,n){if(w&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!i)switch(u.getAttributeType(e,t)){case"TrustedHTML":return I(n);case"TrustedScriptURL":return function(e){x(),T++;try{return w.createScriptURL(e)}finally{T--}}(n)}return n},dt=function(e,t,n,s){try{n?e.setAttributeNS(n,t,s):e.setAttribute(t,s),tt(e)?Ve(e):uv(i.removed)}catch(i){Qe(t,e)}},ht=function(e){st(L.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||tt(e))return;G=rt(L.uponSanitizeAttribute,G,Q,le);const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let n=t.length;const s=Be(e.nodeName);for(;n--;){const r=t[n],o=r.name,a=r.namespaceURI,l=r.value,c=Be(o),u=l;let d="value"===o?u:yv(u);i.attrName=c,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,st(L.uponSanitizeAttribute,e,i),d=i.attrValue,!ge||"id"!==c&&"name"!==c||0===mv(d,_e)||(Qe(o,e),d=_e+d),se&&Tv(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)||"attributename"===c&&fv(d,"href")?Qe(o,e):i.forceKeepAttr||(!i.keepAttr||!ie&&Tv(sm,d)?Qe(o,e):(ne&&(d=Xe(d)),at(s,c,d)?(d=ut(s,c,a,d),d!==u&&dt(e,o,a,d)):Qe(o,e)))}st(L.afterSanitizeAttributes,e,null)},pt=function(e){let t=null;const i=Ze(e);for(st(L.beforeSanitizeShadowDOM,e,null);t=i.nextNode();)if(st(L.uponSanitizeShadowNode,t,null),ot(t,e),ht(t),it(t.content)&&pt(t.content),1===(y?y(t):t.nodeType)){const e=v(t);it(e)&&(gt(e),pt(e))}st(L.afterSanitizeShadowDOM,e,null)},gt=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){pt(e.shadow);continue}const i=e.node,n=1===(y?y(i):i.nodeType),s=_(i);if(s)for(let e=s.length-1;e>=0;--e)t.push({node:s[e],shadow:null});if(n){const e=b?b(i):null;if("string"==typeof e&&"template"===Be(e)){const e=i.content;it(e)&&t.push({node:e,shadow:null})}}if(n){const e=v(i);it(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,o=null,a=null;if(Re=!e,Re&&(e="\x3c!--\x3e"),"string"!=typeof e&&!nt(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return bv(e);case"boolean":return Sv(e);case"bigint":return wv?wv(e):"0";case"symbol":return kv?kv(e):"Symbol()";case"undefined":default:return Ev(e);case"function":case"object":{if(null===e)return Ev(e);const t=e,i=Av(t,"toString");if("function"==typeof i){const e=i(t);return"string"==typeof e?e:Ev(e)}return Ev(e)}}}(e)))throw xv("dirty is not a string, aborting");if(!i.isSupported)return e;oe?(j=ae,G=le):ze(t),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(j=Fv(j)),L.uponSanitizeAttribute.length>0&&(G=Fv(G)),i.removed=[];const l=ve&&"string"!=typeof e&&nt(e);if(l){!function(e){if(!se)return;const t=[e];for(;t.length>0;){const e=t.pop(),i=y?y(e):e.nodeType;if(7===i||8===i&&Tv(im,e.data)){try{p(e)}catch(e){}continue}if(1===i){const t=e,i=Be(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute("patchsrc")&&t.removeAttribute("patchsrc"),t.hasAttribute&&t.hasAttribute("for")&&"label"!==i&&"output"!==i&&t.removeAttribute("for")}catch(e){}}const n=_(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}}(e);const t=b?b(e):e.nodeName;if("string"==typeof t){const i=Be(t);if(!j[i]||J[i])throw Ge(e),xv("root node is forbidden and cannot be sanitized in-place")}if(tt(e))throw Ge(e),xv("root node is clobbered and cannot be sanitized in-place");try{gt(e)}catch(t){throw Ge(e),t}}else if(nt(e))n=Ye("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r),gt(r);else{if(!ue&&!ne&&!re&&-1===e.indexOf("<"))return w&&he?I(e):e;if(n=Ye(e),!n)return ue?null:he?C:""}n&&ce&&Ve(n.firstChild);const c=l?e:n;try{const e=Ze(c);for(;o=e.nextNode();)ot(o,c),ht(o),it(o.content)&&pt(o.content)}catch(t){throw l&&(Ge(e),lv(i.removed,e=>{e.element&&Je(e.element)})),t}if(l)return lv(i.removed,e=>{e.element&&Je(e.element)}),ne&&et(e),e;if(ue){if(ne&&et(n),de)for(a=M.call(n.ownerDocument);n.firstChild;)a.appendChild(n.firstChild);else a=n;return(G.shadowroot||G.shadowrootmode)&&(a=A.call(s,a,!0)),a}let u=re?n.outerHTML:n.innerHTML;return re&&j["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Tv(Xv,n.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+u),ne&&(u=Xe(u)),w&&he?I(u):u},i.setConfig=function(){ze(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,ae=j,le=G},i.clearConfig=function(){qe=null,oe=!1,ae=null,le=null,w=k,C=""},i.isValidAttribute=function(e,t,i){qe||ze({});const n=Be(e),s=Be(t);return at(n,s,i)},i.addHook=function(e,t){"function"==typeof t&&Cv(L,e)&&dv(L[e],t)},i.removeHook=function(e,t){if(Cv(L,e)){if(void 0!==t){const i=cv(L[e],t);return-1===i?void 0:hv(L[e],i,1)[0]}return uv(L[e])}},i.removeHooks=function(e){Cv(L,e)&&(L[e]=[])},i.removeAllHooks=function(){L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();const lm=["a","abbr","acronym","area","article","aside","b","bdi","bdo","blockquote","br","caption","center","cite","code","col","colgroup","data","dd","del","details","dfn","div","dl","dt","em","figcaption","figure","footer","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","img","ins","kbd","li","map","mark","nav","ol","p","pre","q","rp","rt","rtc","ruby","s","samp","small","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","time","tr","tt","u","ul","var","wbr"],cm=["style","lang","title","width","height"],um=["abbr","align","axis","bgcolor","char","charoff","colspan","headers","height","nowrap","rowspan","scope","valign","width"],dm={a:["href","hreflang","target","rel"],bdo:["dir"],blockquote:["cite"],col:["align","char","charoff","span"],colgroup:["align","char","charoff","span"],del:["cite","datetime"],hr:["align","size","width"],img:["align","alt","height","src","width"],ins:["cite","datetime"],ol:["start","type"],q:["cite"],table:["align","bgcolor","border","cellpadding","cellspacing","frame","rules","summary","width"],tbody:["align","char","charoff","valign"],td:um,tfoot:["align","char","charoff","valign"],th:um,thead:["align","char","charoff","valign"],tr:["align","bgcolor","char","charoff","valign"]};let hm;function pm(e){var t;const i=(null!==(t=hm)&&void 0!==t?t:hm=am()).sanitize(e,{ALLOWED_TAGS:lm,ALLOWED_ATTR:[],ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,ALLOWED_NAMESPACES:["http://www.w3.org/1999/xhtml"],ADD_ATTR:(e,t)=>-1!==cm.indexOf(e)||{}.hasOwnProperty.call(dm,t)&&-1!==(dm[t]||[]).indexOf(e),RETURN_DOM_FRAGMENT:!0}),n=i.querySelectorAll("a");for(let e=0;n.length>e;e++)n.item(e).relList.add("noopener");const s=document.createElement("div");return s.appendChild(i),s.innerHTML}const gm=Br("[Stylesheet Loader]"),_m="#020617",fm={fontFamily:"inherit",backgroundColor:"#eeeded",submitButtonColor:"black",submitButtonTextColor:"white",ratingButtonColor:"white",ratingButtonActiveColor:"black",borderColor:"#c9c6c6",whiteLabel:!1,displayThankYouMessage:!0,thankYouMessageHeader:"Thank you for your feedback!",position:Mf.Right,widgetType:Pf.Tab,widgetLabel:"Feedback",widgetColor:"black",zIndex:String(2147483645),disabledButtonOpacity:"0.6",maxWidth:"300px",textSubtleColor:"#939393",boxPadding:"20px 24px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",borderRadius:"10px",shuffleQuestions:!1,outlineColor:"rgba(59, 130, 246, 0.8)",inputBackground:"white",inputTextColor:_m,scrollbarThumbColor:"var(--ph-survey-border-color)",scrollbarTrackColor:"var(--ph-survey-background-color)"},vm=[Mf.Center,Mf.Left,Mf.Right];function mm(e){if(e.startsWith("#")){let t=e.replace(/^#/,"");return/^[0-9A-Fa-f]{3}$/.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),/^[0-9A-Fa-f]{6}$/.test(t)?`rgb(${parseInt(t.slice(0,2),16)},${parseInt(t.slice(2,4),16)},${parseInt(t.slice(4,6),16)})`:"rgb(255, 255, 255)"}return"rgb(255, 255, 255)"}function ym(e=fm.backgroundColor){let t;"#"===e[0]&&(t=mm(e)),e.startsWith("rgb")&&(t=e);const i={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}[e.toLowerCase()];if(i&&(t=mm(i)),!t)return _m;const n=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(n){const e=parseInt(n[1]),t=parseInt(n[2]),i=parseInt(n[3]);return Math.sqrt(e*e*.299+t*t*.587+i*i*.114)>127.5?_m:"white"}return _m}const bm=(e,t,i)=>{const n=Bm(e),s=document.querySelector(`.${n}`);if(s&&s.shadowRoot)return{shadow:s.shadowRoot,isNewlyCreated:!1};const r=document.createElement("div");((e,t,i)=>{const n=ct(ct({},fm),i),s=e.style,r=!vm.includes(n.position)||t===Af.Widget&&(null==i?void 0:i.widgetType)===Pf.Tab;s.setProperty("--ph-survey-font-family",function(e){if("inherit"===e)return"inherit";const t='BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';return e?`${e}, ${t}`:`-apple-system, ${t}`}(n.fontFamily)),s.setProperty("--ph-survey-box-padding",n.boxPadding),s.setProperty("--ph-survey-max-width",n.maxWidth),s.setProperty("--ph-survey-z-index",n.zIndex),s.setProperty("--ph-survey-border-color",n.borderColor),r?(s.setProperty("--ph-survey-border-radius",n.borderRadius),s.setProperty("--ph-survey-border-bottom","1.5px solid var(--ph-survey-border-color)")):(s.setProperty("--ph-survey-border-bottom","none"),s.setProperty("--ph-survey-border-radius",`${n.borderRadius} ${n.borderRadius} 0 0`)),s.setProperty("--ph-survey-background-color",n.backgroundColor),s.setProperty("--ph-survey-box-shadow",n.boxShadow),s.setProperty("--ph-survey-disabled-button-opacity",n.disabledButtonOpacity),s.setProperty("--ph-survey-submit-button-color",n.submitButtonColor),s.setProperty("--ph-survey-submit-button-text-color",(null==i?void 0:i.submitButtonTextColor)||ym(n.submitButtonColor)),s.setProperty("--ph-survey-rating-bg-color",n.ratingButtonColor),s.setProperty("--ph-survey-rating-active-bg-color",n.ratingButtonActiveColor),s.setProperty("--ph-survey-rating-active-text-color",ym(n.ratingButtonActiveColor)),s.setProperty("--ph-survey-text-primary-color",(null==i?void 0:i.textColor)||ym(n.backgroundColor)),s.setProperty("--ph-survey-text-subtle-color",n.textSubtleColor),s.setProperty("--ph-widget-color",n.widgetColor),s.setProperty("--ph-widget-text-color",ym(n.widgetColor)),s.setProperty("--ph-widget-z-index",n.zIndex);const o=(null==i?void 0:i.inputBackground)||(null==i?void 0:i.inputBackgroundColor);let a=o||n.inputBackground;o||"white"!==n.backgroundColor||(a="#f8f8f8"),s.setProperty("--ph-survey-input-background",a);const l=(null==i?void 0:i.inputTextColor)||ym(a);s.setProperty("--ph-survey-input-text-color",l),s.setProperty("--ph-survey-rating-text-color",l),s.setProperty("--ph-survey-scrollbar-thumb-color",n.scrollbarThumbColor),s.setProperty("--ph-survey-scrollbar-track-color",n.scrollbarTrackColor),s.setProperty("--ph-survey-outline-color",n.outlineColor)})(r,e.type,e.appearance),r.className=n;const o=r.attachShadow({mode:"open"}),a=function(e){const t=((e,t,i)=>{let n=e.createElement("style");n.innerText=t;const s=(e=>{var t;return Ct(e)?e:null==e||null===(t=e.config)||void 0===t?void 0:t.prepare_external_dependency_stylesheet})(i);return s&&(n=s(n)),n||(gm.error("prepare_external_dependency_stylesheet returned null"),null)})(document,':host{--ph-survey-font-family:-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--ph-survey-box-padding:20px 24px;--ph-survey-max-width:300px;--ph-survey-z-index:calc(2147480000 + 3645);--ph-survey-border-color:#dcdcdc;--ph-survey-border-bottom:1.5px solid var(--ph-survey-border-color);--ph-survey-border-radius:10px;--ph-survey-background-color:#eeeded;--ph-survey-box-shadow:0 4px 12px #00000026;--ph-survey-submit-button-color:black;--ph-survey-submit-button-text-color:white;--ph-survey-rating-bg-color:white;--ph-survey-rating-text-color:#020617;--ph-survey-rating-active-bg-color:black;--ph-survey-rating-active-text-color:white;--ph-survey-text-primary-color:#020617;--ph-survey-text-subtle-color:#939393;--ph-widget-color:#e0a045;--ph-widget-text-color:white;--ph-survey-scrollbar-thumb-color:var(--ph-survey-border-color);--ph-survey-scrollbar-track-color:var(--ph-survey-background-color);--ph-survey-outline-color:#3b82f6cc;--ph-survey-input-background:white;--ph-survey-input-text-color:#020617;--ph-survey-disabled-button-opacity:.6}.ph-survey{min-width:300px;width:var(--ph-survey-max-width);max-width:85%;z-index:var(--ph-survey-z-index);height:fit-content;margin:0;position:fixed;bottom:0}.ph-survey h3,.ph-survey p{margin:0}.ph-survey *{box-sizing:border-box;font-family:var(--ph-survey-font-family);color:var(--ph-survey-text-primary-color)}.ph-survey textarea,.ph-survey input[type=text],.ph-survey .multiple-choice-options label{color:var(--ph-survey-input-text-color);background:var(--ph-survey-input-background);border:1.5px solid var(--ph-survey-border-color);border-radius:4px;padding:10px;transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey textarea,.ph-survey input[type=text]{transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey input{margin:0}.ph-survey textarea:focus,.ph-survey textarea:focus-visible,.ph-survey input[type=text]:focus,.ph-survey input[type=text]:focus-visible,.ph-survey .form-submit:focus,.ph-survey .form-submit:focus-visible,.ph-survey input[type=checkbox]:focus,.ph-survey input[type=radio]:focus,.ph-survey input[type=checkbox]:focus-visible,.ph-survey input[type=radio]:focus-visible{outline:1.5px solid var(--ph-survey-outline-color);border-color:var(--ph-survey-rating-active-bg-color);outline-offset:2px}.ph-survey textarea:focus:not(:focus-visible),.ph-survey input[type=text]:focus:not(:focus-visible),.ph-survey button:focus:not(:focus-visible),.ph-survey input[type=checkbox]:focus:not(:focus-visible),.ph-survey input[type=radio]:focus:not(:focus-visible){outline:none}.ph-survey textarea:hover:not(:focus),.ph-survey input[type=text]:hover:not(:focus){border-color:var(--ph-survey-rating-active-bg-color)}@media (max-width:768px){.ph-survey textarea,.ph-survey input[type=text]{font-size:1rem}}.ph-survey .multiple-choice-options label,.ph-survey .rating-options-number,.ph-survey .form-cancel,.ph-survey input[type=checkbox],.ph-survey input[type=radio]{border:1.5px solid var(--ph-survey-border-color)}.ph-survey label,.ph-survey input[type=checkbox],.ph-survey input[type=radio],.ph-survey .ratings-emoji,.ph-survey .ratings-number,.ph-survey .footer-branding,.ph-survey .form-cancel,.ph-survey .form-submit{transition:all .2s ease-out}@media (prefers-reduced-motion:no-preference){.ph-survey button:active,.ph-survey input[type=checkbox]:active,.ph-survey input[type=radio]:active,.ph-survey label:active{transition-duration:.1s}}.ph-survey-widget-tab{background:var(--ph-widget-color);color:var(--ph-widget-text-color);text-align:center;cursor:pointer;z-index:var(--ph-survey-z-index);border:none;border-radius:3px 3px 0 0;padding:10px 12px;transition:padding .2s ease-out;position:fixed}.ph-survey-widget-tab:hover:not(.widget-tab-top){padding-bottom:16px}.ph-survey-widget-tab.widget-tab-top{border-radius:0 0 3px 3px}.ph-survey-widget-tab.widget-tab-top:hover{padding-top:16px}@keyframes ph-survey-fade-in{0%{opacity:0}to{opacity:1}}.survey-box{flex-direction:column;gap:16px;display:flex}.bottom-section{flex-direction:column;gap:8px;display:flex}.thank-you-message-header~.bottom-section,.intro-screen-header~.bottom-section{padding-top:16px}.question-container,.thank-you-message,.intro-screen{flex-direction:column;gap:8px;display:flex}.survey-question{font-size:14px;font-weight:500}.survey-question-description{opacity:.8;padding-top:4px;font-size:13px}.survey-question-description,.thank-you-message-body,.intro-screen-body{word-wrap:break-word;overflow-wrap:break-word}:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) img,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) video,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) iframe,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) embed,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) object,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) svg{max-width:100%;height:auto}.question-textarea-wrapper{flex-direction:column;display:flex}.survey-form{animation:.3s ease-out forwards ph-survey-fade-in}.survey-form,.thank-you-message,.intro-screen{text-align:left;width:100%;z-index:var(--ph-survey-z-index);border:1.5px solid var(--ph-survey-border-color);border-bottom:var(--ph-survey-border-bottom);background:var(--ph-survey-background-color);border-radius:var(--ph-survey-border-radius);box-shadow:var(--ph-survey-box-shadow);padding:var(--ph-survey-box-padding);margin:0;position:relative}.survey-form textarea,.survey-form input[type=text]{min-width:100%}.survey-form textarea:focus,.survey-form textarea:focus-visible{box-shadow:0 4px 12px #00000014}.survey-form textarea:focus:not(:focus-visible){box-shadow:none}.survey-box .question-header--empty~.multiple-choice-options,.survey-box .question-header--empty~textarea{margin-top:0}.multiple-choice-options{border:none;flex-direction:column;gap:8px;margin:0;padding:1px 0;font-size:14px;display:flex}.multiple-choice-options label,.multiple-choice-options .response-choice{color:inherit;align-items:center;gap:8px;display:flex}.multiple-choice-options label{cursor:pointer;font-size:13px}.multiple-choice-options label:hover:not(:has(input:checked)){border-color:var(--ph-survey-text-subtle-color);box-shadow:0 2px 8px #00000014}.multiple-choice-options label:has(input:checked){border-color:var(--ph-survey-rating-active-bg-color);box-shadow:0 1px 4px #0000000d}.multiple-choice-options label.choice-option-open{flex-wrap:wrap}.multiple-choice-options label span{color:inherit}.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--ph-survey-input-background);cursor:pointer;z-index:1;border-radius:3px;flex-shrink:0;width:1rem;height:1rem;transition:all .2s cubic-bezier(.4,0,.2,1),transform .15s ease-out;position:relative}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):focus{transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):hover{border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):active{transform:scale(.95)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked{background:var(--ph-survey-rating-active-bg-color);border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked:hover{transform:scale(1.05)}.multiple-choice-options input[type=checkbox]:checked:after{border:solid var(--ph-survey-rating-active-text-color);border-width:0 2px 2px 0;width:4px;height:8px;animation:.2s ease-out .1s forwards ph-survey-checkmark-reveal;left:4px;transform:rotate(45deg)scale(0)}.multiple-choice-options input[type=radio]:checked:after{background:var(--ph-survey-rating-active-text-color);border-radius:50%;width:6px;height:6px;animation:.15s ease-out 50ms forwards ph-survey-radio-reveal;top:5px;left:5px;transform:scale(0)}.multiple-choice-options input[type=checkbox]:checked:after,.multiple-choice-options input[type=radio]:checked:after{content:"";box-sizing:content-box;position:absolute}.multiple-choice-options input[type=radio]{border-radius:50%}.multiple-choice-options input[type=radio]:checked{border:none}:is(.multiple-choice-options input[type=checkbox]:checked,.multiple-choice-options input[type=radio]:checked)~*{font-weight:700}.multiple-choice-options .choice-option-open input[type=text]::placeholder{color:var(--ph-survey-text-subtle-color);font-weight:400}.rating-options-emoji{justify-content:space-between;display:flex}.rating-options-emoji-2{justify-content:space-around}.ratings-emoji{opacity:.5;background-color:#0000;border:none;padding:0;font-size:16px}.ratings-emoji:hover{cursor:pointer;opacity:1;transform:scale(1.15)}.ratings-emoji.rating-active{opacity:1}.ratings-emoji svg{fill:var(--ph-survey-text-primary-color);transition:fill .2s ease-out}.rating-options-number{border-radius:6px;grid-auto-columns:1fr;grid-auto-flow:column;display:grid;overflow:hidden}.rating-options-number .ratings-number{border-right:1px solid var(--ph-survey-border-color);text-align:center;cursor:pointer;color:var(--ph-survey-rating-text-color);border-top:none;border-bottom:none;border-left:none;font-weight:700}.rating-options-number .ratings-number:last-of-type{border-right:0}.rating-options-number .ratings-number.rating-active{background:var(--ph-survey-rating-active-bg-color);color:var(--ph-survey-rating-active-text-color)}.ratings-number{background-color:var(--ph-survey-rating-bg-color);border:none;padding:8px 0}.ratings-number .rating-active{background-color:var(--ph-survey-rating-active-bg-color)}.ratings-number{cursor:pointer}@media (hover:hover) and (pointer:fine){.ratings-number:hover:not(.rating-active){background-color:color-mix(in srgb, var(--ph-survey-rating-active-bg-color) 14%, var(--ph-survey-rating-bg-color))}}.rating-text{opacity:.7;flex-direction:row;justify-content:space-between;font-size:11px;display:flex}.form-buttons{flex-direction:row;gap:8px;width:100%;display:flex}.form-buttons-with-back>.form-submit{flex:auto;min-width:0}.form-submit{text-align:center;cursor:pointer;user-select:none;background:var(--ph-survey-submit-button-color);color:var(--ph-survey-submit-button-text-color);border:none;border-radius:6px;min-width:100%;padding:12px;font-weight:700;box-shadow:0 2px #0000000b}.form-submit:not([disabled]):hover{transform:scale(1.02);box-shadow:0 4px 8px #0000001a}.form-submit:not([disabled]):active{transform:scale(.98);box-shadow:0 1px 2px #0000000d}.form-submit[disabled]{opacity:var(--ph-survey-disabled-button-opacity);cursor:not-allowed}.form-back{text-align:center;cursor:pointer;user-select:none;color:var(--ph-survey-text-primary-color);border:1.5px solid var(--ph-survey-border-color);background:0 0;border-radius:6px;flex:none;padding:12px 16px;font-weight:600}.form-back:hover{transform:scale(1.02)}.form-back:active{transform:scale(.98)}.validation-hint{opacity:.7;margin-top:4px;font-size:12px}.form-cancel{cursor:pointer;background:#fff;border-radius:100%;padding:12px;line-height:0;position:absolute;top:0;right:0;transform:translate(50%,-50%)}.form-cancel:hover{opacity:.7;transform:translate(50%,-50%)scale(1.1)}.footer-branding{opacity:.6;justify-content:center;align-items:center;gap:4px;font-size:11px;font-weight:500;text-decoration:none;display:flex}.footer-branding:hover{opacity:1}.footer-branding a{text-decoration:none}.thank-you-message{text-align:center}.thank-you-message-header{margin:10px 0 0}.thank-you-message-body{opacity:.8;font-size:14px}.intro-screen{text-align:center;animation:.3s ease-out forwards ph-survey-fade-in}.intro-screen-header{margin:10px 0 0}.intro-screen-body{opacity:.8;font-size:14px}.limit-height{scrollbar-width:thin;scrollbar-color:var(--ph-survey-scrollbar-thumb-color) var(--ph-survey-scrollbar-track-color);max-height:256px;overflow:hidden auto}.limit-height::-webkit-scrollbar{width:8px}.limit-height::-webkit-scrollbar-track{background:var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb{background-color:var(--ph-survey-scrollbar-thumb-color);border:2px solid var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb:hover{background-color:var(--ph-survey-text-subtle-color)}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.ph-survey *{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@keyframes ph-survey-checkmark-reveal{0%{opacity:0;transform:rotate(45deg)scale(0)}50%{opacity:1;transform:rotate(45deg)scale(1.2)}to{opacity:1;transform:rotate(45deg)scale(1)}}@keyframes ph-survey-radio-reveal{0%{opacity:0;transform:scale(0)}50%{opacity:1;transform:scale(1.3)}to{opacity:1;transform:scale(1)}}',null==e?void 0:e.config.prepareStylesheet);return null==t||t.setAttribute("data-ph-survey-style","true"),t}(t);if(a){const e=o.querySelector("style");e&&o.removeChild(e),o.appendChild(a)}return(i||document.body).appendChild(r),{shadow:o,isNewlyCreated:!0}},Sm=e=>{try{const t=jf(e);localStorage.getItem(t)||localStorage.setItem(t,"true")}catch(e){qf.error("Failed to persist survey seen state",e)}},wm=({responses:e,survey:t,surveySubmissionId:i,posthog:n,isSurveyCompleted:s,properties:r,surveyLanguage:o,questionSnapshots:a})=>{var l,c,u;n?(null===(l=n.client)||void 0===l?void 0:l.canCapture)&&(Sm(t),s&&Nm(t),null===(c=n.client)||void 0===c||c.capture($f.SENT,ct(ct(ct({[Nf.SURVEY_NAME]:t.name,[Nf.SURVEY_ID]:t.id,[Nf.SURVEY_ITERATION]:t.current_iteration,[Nf.SURVEY_ITERATION_START_DATE]:t.current_iteration_start_date,sessionRecordingUrl:tf(n)},ic(ct(ct({event:"sent",survey:t,responses:e,submissionId:i,completed:s},!xt(o)&&{surveyLanguage:o}),!xt(a)&&{questionSnapshots:a}))),r),{},{$set:{[sc(t,"responded")]:!0}})),s&&(window.dispatchEvent(new CustomEvent("PHSurveySent",{detail:{surveyId:t.id}})),null===(u=n.client)||void 0===u||null===(u=u.getExtension("featureFlagsCommon"))||void 0===u||u.reloadFeatureFlags())):qf.error("[survey sent] event not captured, PostHog instance not found.")},km=(e,t,i,n)=>ct({[Nf.SURVEY_NAME]:t.name,[Nf.SURVEY_ID]:t.id,[Nf.SURVEY_ITERATION]:t.current_iteration,[Nf.SURVEY_ITERATION_START_DATE]:t.current_iteration_start_date,sessionRecordingUrl:tf(n)},ic(ct(ct(ct(ct({event:e,survey:t},!xt(null==i?void 0:i.responses)&&{responses:i.responses}),!xt(null==i?void 0:i.surveySubmissionId)&&{submissionId:i.surveySubmissionId}),!xt(null==i?void 0:i.surveyLanguage)&&{surveyLanguage:i.surveyLanguage}),!xt(null==i?void 0:i.questionSnapshots)&&{questionSnapshots:i.questionSnapshots}))),Cm=(e,t,i,n)=>{var s;if(!t)return void qf.error("[survey dismissed] event not captured, PostHog instance not found.");if(i)return;const r=Dm(e),o=r?r.surveyLanguage:n,a=ct(ct(ct({},km("dismissed",e,r,t)),o&&{[Nf.SURVEY_LANGUAGE]:o}),{},{$set:{[sc(e,"dismissed")]:!0}});Nm(e),Sm(e),null===(s=t.client)||void 0===s||s.capture($f.DISMISSED,a),window.dispatchEvent(new CustomEvent("PHSurveyClosed",{detail:{surveyId:e.id}}))},Em=(e,t)=>{var i,n;if(!t)return void qf.error("[survey abandoned] event not captured, PostHog instance not found.");if(!(null===(i=t.client)||void 0===i?void 0:i.canCapture))return;const s=(e=>Wf("abandonedSurvey_",e))(e);try{if("true"===localStorage.getItem(s))return}catch(e){return}const r=Dm(e);if(r){try{localStorage.setItem(s,"true")}catch(e){}null===(n=t.client)||void 0===n||n.capture($f.ABANDONED,km("abandoned",e,r,t),{delivery:"unload"})}},Tm=e=>{const t=e.map(e=>e.id);return t.every(e=>!!e)?t:void 0},xm=(e,t)=>{var i,n,s;return(e=>e.questions.some(e=>{var t;return!!(null===(t=e.branching)||void 0===t?void 0:t.type)}))(e)?e.questions:t?null!==(i=((e,t)=>{if(!t||t.length!==e.questions.length)return null;const i=new Map(e.questions.map(e=>[e.id,e])),n=[];for(const e of t){const t=i.get(e);if(!t)return null;n.push(t)}return n})(e,t.questionOrder))&&void 0!==i?i:e.questions:e.appearance&&e.appearance.shuffleQuestions&&!e.enable_partial_responses?(n=e.questions,s=fc(e.questions),n.length===s.length&&n.every((e,t)=>e===s[t])?s.reverse():s):e.questions},Im=e=>dc(e)||$m(e),Rm=function(e){function t(e){var i,n;return this.getChildContext||(i=new Set,(n={})[t.__c]=this,this.getChildContext=function(){return n},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&i.forEach(function(e){e.__e=!0,D_(e)})},this.sub=function(e){i.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i&&i.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+w_++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed(){},isPopup:!0,onPreviewSubmit(){},onPreviewBack(){},surveySubmissionId:"",properties:void 0,surveyLanguage:null}),Pm=()=>Sf(Rm),Mm=({component:e,children:t,renderAsHtml:i,style:n})=>function(e,t,i){var n,s,r,o,a=x_({},e.props);for(r in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)"key"==r?n=t[r]:"ref"==r?s=t[r]:a[r]=void 0===t[r]&&null!=o?o[r]:t[r];return arguments.length>2&&(a.children=arguments.length>3?l_.call(arguments,2):i),P_(e.type,a,n||e.key,s||e.ref,null)}(e,i?{dangerouslySetInnerHTML:{__html:pm(t)},style:n}:{children:t,style:n});function Fm(e,t){var i,n,s;if(!(null===(i=e.conditions)||void 0===i?void 0:i.url))return!0;const r=null!==(n=lo(t))&&void 0!==n?n:"u">typeof window?window.location.href:void 0;if(!r)return!1;const o=[e.conditions.url],a=function(e){return null!=e?e:"icontains"}(null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType);return gc[a](o,[r])}const Am=e=>Wf("inProgressSurvey_",e),Lm={},Om=(e,t)=>{const i=Am(e);try{localStorage.setItem(i,JSON.stringify(t)),delete Lm[i]}catch(e){qf.error("Error setting in-progress survey state in localStorage",e),Lm[i]=t}},Dm=e=>{const t=Am(e),i=Lm[t];if(i)return i;try{const e=localStorage.getItem(t);if(e)return JSON.parse(e)}catch(e){qf.error("Error getting in-progress survey state from localStorage",e)}return null},$m=e=>{const t=Dm(e);return!Mt(null==t?void 0:t.surveySubmissionId)},Nm=e=>{const t=Am(e);delete Lm[t];try{localStorage.removeItem(t)}catch(e){qf.error("Error clearing in-progress survey state from localStorage",e)}};function Bm(e,t=!1){const i=`PostHogSurvey-${e.id}`;return t?`.${i}`:i}function qm(e,t=Mf.Right,i){if(e===Af.ExternalSurvey)return{};switch(t){case Mf.TopLeft:return{top:"0",left:"0",transform:"translate(30px, 30px)"};case Mf.TopRight:return{top:"0",right:"0",transform:"translate(-30px, 30px)"};case Mf.TopCenter:return{top:"0",left:"50%",transform:"translate(-50%, 30px)"};case Mf.MiddleLeft:return{top:"50%",left:"0",transform:"translate(30px, -50%)"};case Mf.MiddleRight:return{top:"50%",right:"0",transform:"translate(-30px, -50%)"};case Mf.MiddleCenter:return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case Mf.Left:return{left:"30px"};case Mf.Center:return{left:"50%",transform:"translateX(-50%)"};default:return{right:e===Af.Widget&&i===Pf.Tab?"60px":"30px"}}}const Hm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),Um=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),zm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),Wm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z"})}),jm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),Vm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:X_("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})}),Gm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:X_("path",{d:"M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z"})}),Qm=({fill:e="currentColor"}={})=>X_("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:e,xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"close-survey-title-adam",children:[X_("title",{id:"close-survey-title",className:"adam-testing",children:"Close survey"}),X_("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z",fill:e})]}),Km=X_("svg",{width:"80",height:"14",viewBox:"0 0 160 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[X_("g",{"clip-path":"url(#ph-survey-logo-clip)",children:[X_("path",{fill:"currentColor",d:"m50 23.34-.35-.05A4.5 4.5 0 0 1 47 21.97L35.56 10.1c-.3-.33-.86-.1-.86.35V27.5c0 .27.22.5.5.5h13.78c1.48 0 2.67-1.2 2.67-2.67v-.1a1.9 1.9 0 0 0-1.67-1.89zm-10.81.2a1.8 1.8 0 1 1 0-3.58 1.8 1.8 0 0 1 0 3.58"}),X_("path",{fill:"#0054ff",d:"M.87 19.13a.5.5 0 0 0-.87.34v5.94a2.6 2.6 0 0 0 2.59 2.58H7.8a.5.5 0 0 0 .37-.84zM.86 8.4c-.3-.32-.86-.1-.86.36v6.73q0 .2.13.34l8.81 9.68 1.8 2.06v-8.82zM4.59.82A2.67 2.67 0 0 0 0 2.68v1.93q0 .4.27.69l10.47 10.95v-9.1z"}),X_("path",{fill:"#ff5506",d:"M11.36 28h7.08a.5.5 0 0 0 .36-.85l-8.05-8.4v8.8l.23.28q.16.17.38.17m-.61-11.76 8.84 9.25 2.1 2.33q.1.11.27.14V18.7L10.75 7.15zm0-13.7v1.41a2 2 0 0 0 .55 1.28L21.96 16.2V7.65L15.32.8a2.67 2.67 0 0 0-4.57 1.71z"}),X_("path",{fill:"#ffb70f",d:"M22.06 28h7.76a.5.5 0 0 0 .36-.86l-8.22-8.45v9.27l.09.02zM31 25.49l1.13 1.14c.32.31.85.09.85-.35v-7.3l-.49-.51L21.96 7.64v8.55zM22.52 5.73l9.62 9.89c.3.32.86.1.86-.35V7.46L26.56.82a2.67 2.67 0 0 0-4.59 1.84v1.7c0 .51.2 1 .57 1.37z"})]}),X_("path",{fill:"currentColor",d:"M64.9 22.88c-.67 0-1.23-.56-1.23-1.24V5.24c0-.69.56-1.24 1.24-1.24h6.55c3.89 0 6.39 2.32 6.39 5.9 0 3.6-2.5 5.91-6.4 5.91h-3.53v5.83c0 .68-.56 1.24-1.24 1.24zm3.02-11.94c0 .68.55 1.23 1.23 1.23h1.88c1.6 0 2.58-.86 2.58-2.26s-.97-2.27-2.58-2.27h-1.88c-.68 0-1.23.55-1.23 1.23zM84.71 23.1c-4.18 0-7.14-2.97-7.14-7.02s2.96-7.01 7.14-7.01c4.14 0 7.14 2.97 7.14 7.01 0 4.05-3 7.01-7.14 7.01m-3.22-7.02c0 2.16 1.3 3.64 3.22 3.64 1.9 0 3.2-1.48 3.2-3.64s-1.3-3.64-3.2-3.64c-1.93 0-3.22 1.48-3.22 3.64m16.34 7.03a6.2 6.2 0 0 1-5.54-3.01c-.34-.57-.01-1.26.6-1.5l.77-.3c.7-.27 1.45.15 1.92.73a2.8 2.8 0 0 0 2.25 1.08c1.05 0 1.75-.51 1.75-1.27 0-2.13-7.17-.7-7.17-5.85 0-2.13 1.85-3.91 4.83-3.91 2.27 0 4.2.9 5.17 2.31.36.53.05 1.2-.54 1.44l-.85.35c-.68.29-1.45-.14-2-.63a2.5 2.5 0 0 0-1.64-.64c-.89 0-1.5.38-1.5.97 0 2.16 7.27.38 7.27 5.88 0 2.35-2.15 4.34-5.32 4.34m14.64-1.31c.04.57-.3 1.1-.86 1.2q-.6.1-1.27.11c-2.92 0-5.15-1.56-5.15-4.85v-5.66h-.91c-.69 0-1.24-.56-1.24-1.24v-.82c0-.68.55-1.23 1.24-1.23h.91v-2.7c0-.69.55-1.24 1.23-1.24h1.48c.68 0 1.24.55 1.24 1.23v2.7h2.04c.68 0 1.23.56 1.23 1.24v.82c0 .68-.55 1.24-1.23 1.24h-2.04v5.15c0 1.2.64 1.91 1.6 1.91.75 0 1.6.5 1.66 1.25zM125.5 5.23c0-.68.55-1.23 1.23-1.23h1.8c.68 0 1.23.55 1.23 1.23v16.41c0 .68-.55 1.24-1.23 1.24h-1.8c-.68 0-1.23-.56-1.23-1.24v-5.43c0-.68-.56-1.23-1.24-1.23h-5c-.67 0-1.23.55-1.23 1.23v5.43c0 .68-.55 1.24-1.23 1.24h-1.77c-.69 0-1.24-.56-1.24-1.24V5.24c0-.69.55-1.24 1.24-1.24h1.77c.68 0 1.23.55 1.23 1.23v4.87c0 .68.56 1.23 1.24 1.23h5c.67 0 1.23-.55 1.23-1.23zm12.87 17.87c-4.19 0-7.14-2.97-7.14-7.02s2.95-7.01 7.14-7.01c4.13 0 7.14 2.97 7.14 7.01 0 4.05-3 7.01-7.14 7.01m-3.22-7.02c0 2.16 1.29 3.64 3.22 3.64 1.9 0 3.2-1.48 3.2-3.64s-1.3-3.64-3.2-3.64c-1.93 0-3.22 1.48-3.22 3.64m17.17 6.37c-3.84 0-6.2-2.58-6.2-6.68s2.36-6.69 6.12-6.69c1.58 0 2.82.54 3.54 1.37 0-.64.52-1.15 1.16-1.15h1.5c.68 0 1.24.55 1.24 1.23V21.9c0 3.64-2.77 6.09-6.93 6.09-2.64 0-4.9-1.2-5.85-3.09-.31-.62.16-1.29.85-1.4l1.14-.17c.67-.11 1.29.4 1.78.85.5.46 1.26.7 2.08.7 1.85 0 3.06-1.04 3.06-2.55v-1.3c-.7.9-2.01 1.4-3.49 1.4m-2.36-6.68c0 2.02 1.18 3.31 3 3.31 1.86 0 3.04-1.29 3.04-3.31s-1.18-3.32-3.03-3.32c-1.83 0-3.01 1.3-3.01 3.32"}),X_("defs",{children:X_("clipPath",{id:"ph-survey-logo-clip",children:X_("path",{fill:"#fff",d:"M0 0h51.67v28H0z"})})})]});function Jm({urlParams:e}){const t=e?Object.entries(e).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&"):"";return X_("a",{href:"https://posthog.com/surveys"+(t?`?${t}`:""),target:"_blank",rel:"noopener",className:"footer-branding",children:["Survey by ",Km]})}function Ym({text:e,submitDisabled:t,appearance:i,onSubmit:n,link:s,onPreviewSubmit:r,skipSubmitButton:o,canGoBack:a,onBack:l}){const{isPreviewMode:c}=Sf(Rm),u=!!a&&!!l,d=!o&&X_("button",{className:"form-submit",disabled:t,"aria-label":"Submit survey",type:"button",onClick(){var e;s&&(null===(e=window)||void 0===e||e.open(s)),c?null==r||r():n()},children:e});return X_("div",{className:"bottom-section",children:[u?X_("div",{className:"form-buttons form-buttons-with-back",children:[X_("button",{className:"form-back",type:"button","aria-label":"Go to previous question",onClick:l,children:i.backButtonText||"Back"}),d]}):d,!i.whiteLabel&&X_(Jm,{urlParams:{utm_source:"survey-footer"}})]})}function Zm({question:e,forceDisableHtml:t,htmlFor:i}){return X_("div",{class:e.question||e.description?"question-header":"question-header question-header--empty",children:[X_(e.type===Lf.Open?"label":"h3",{className:"survey-question",htmlFor:i,children:e.question}),e.description&&Mm({component:R_("p",{className:"survey-question-description"}),children:e.description,renderAsHtml:!t&&"text"!==e.descriptionContentType})]})}function Xm({onClick:e}){const{isPreviewMode:t}=Sf(Rm);return X_("button",{className:"form-cancel",onClick:e,disabled:t,"aria-label":"Close survey",type:"button",children:Qm({fill:"black"})})}function ey({header:e,description:t,contentType:i,forceDisableHtml:n,appearance:s,onClose:r}){const{isPopup:o}=Sf(Rm);return mf(()=>{const e=e=>{"Enter"!==e.key&&"Escape"!==e.key||(e.preventDefault(),r())};return Kr(window,"keydown",e),()=>{window.removeEventListener("keydown",e)}},[r]),X_("div",{className:"thank-you-message",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==s.hideCancelButton&&X_(Xm,{onClick:()=>r()}),X_("h3",{className:"thank-you-message-header",children:e}),t&&Mm({component:R_("p",{className:"thank-you-message-body"}),children:t,renderAsHtml:!n&&"text"!==i}),o&&X_(Ym,{text:s.thankYouMessageCloseButtonText||"Close",submitDisabled:!1,appearance:s,onSubmit:()=>r()})]})}function ty({header:e,description:t,contentType:i,forceDisableHtml:n,appearance:s,onStart:r}){const{isPopup:o,onPreviewSubmit:a,onPopupSurveyDismissed:l}=Sf(Rm);return X_("div",{className:"intro-screen",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==s.hideCancelButton&&X_(Xm,{onClick:()=>l()}),e&&X_("h3",{className:"intro-screen-header",children:e}),t&&Mm({component:R_("p",{className:"intro-screen-body"}),children:t,renderAsHtml:!n&&"text"!==i}),X_(Ym,{text:s.introScreenButtonText||"Get started",submitDisabled:!1,appearance:s,onSubmit:r,onPreviewSubmit:()=>a(null)})]})}const iy=e=>kt(e)&&e.every(e=>It(e));function ny({question:e,forceDisableHtml:t,appearance:i,onSubmit:n,onPreviewSubmit:s,displayQuestionIndex:r,initialValue:o,canGoBack:a,onBack:l}){const{isPreviewMode:c}=Pm(),u=yf(null),[d,h]=vf(()=>It(o)?o:""),p=null==i?void 0:i.disableAutofocus;mf(()=>{p||setTimeout(()=>{var e;c||null===(e=u.current)||void 0===e||e.focus()},100)},[c,p]);const g=`surveyQuestion${r}`,_=bf(()=>function(e,t,i){const n=e.trim();if(!i&&""===n)return"This field is required";if(""===n)return!1;if(t&&t.length>0)for(const e of t)switch(e.type){case ht:var s;if(void 0!==e.value&&e.value>n.length)return null!==(s=e.errorMessage)&&void 0!==s?s:`Please enter at least ${e.value} characters`;break;case pt:var r;if(void 0!==e.value&&n.length>e.value)return null!==(r=e.errorMessage)&&void 0!==r?r:`Please enter no more than ${e.value} characters`}return!1}(d,e.validation,e.optional),[d,e.validation,e.optional]),f=Lr(e.validation,ht),v=Lr(e.validation,pt),m=bf(()=>function(e,t){const i=1===e?void 0:e;return i&&t?`Enter ${i}-${t} characters`:i?`Enter at least ${i} ${1===i?"character":"characters"}`:t?`Maximum ${t} ${1===t?"character":"characters"}`:void 0}(f,v),[f,v]),y=()=>{_||n(d.trim())},b=()=>{_||s(d.trim())};return X_(M_,{children:[X_("div",{className:"question-container",children:[X_(Zm,{question:e,forceDisableHtml:t,htmlFor:g}),X_("textarea",{ref:u,id:g,rows:4,placeholder:null==i?void 0:i.placeholder,minLength:f,maxLength:v,onInput(e){h(e.currentTarget.value),e.stopPropagation()},onKeyDown(e){e.stopPropagation(),"Enter"!==e.key||!e.metaKey&&!e.ctrlKey||_||(e.preventDefault(),c?b():y())},value:d}),m&&X_("div",{className:"validation-hint",children:m})]}),X_(Ym,{text:e.buttonText||"Submit",submitDisabled:!!_,appearance:i,onSubmit:y,onPreviewSubmit:b,canGoBack:a,onBack:l})]})}function sy({question:e,forceDisableHtml:t,appearance:i,onSubmit:n,onPreviewSubmit:s,canGoBack:r,onBack:o}){return X_(M_,{children:[X_("div",{className:"question-container",children:X_(Zm,{question:e,forceDisableHtml:t})}),X_(Ym,{text:e.buttonText||"Submit",submitDisabled:!1,link:e.link,appearance:i,onSubmit:()=>n("link clicked"),onPreviewSubmit:()=>s("link clicked"),canGoBack:r,onBack:o})]})}function ry({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:n,onSubmit:s,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){var c;const u=e.scale,d=10===e.scale?0:1,[h,p]=vf(()=>Ft(o)?o:kt(o)&&o.length>0&&Ft(parseInt(o[0]))?parseInt(o[0]):It(o)&&Ft(parseInt(o))?parseInt(o):null),g="emoji"===e.display&&2===e.scale,{isPreviewMode:_}=Pm(),f=e=>_?r(e):s(e);return X_(M_,{children:[X_("div",{className:"question-container",children:[X_(Zm,{question:e,forceDisableHtml:t}),X_("div",{className:"rating-section",children:[X_("div",{className:"rating-options",children:["emoji"===e.display&&X_("div",{className:"rating-options-emoji"+(g?" rating-options-emoji-2":""),children:null===(c=dy[e.scale])||void 0===c?void 0:c.map((t,n)=>X_("button",{"aria-label":`Rate ${n+1}`,className:`ratings-emoji question-${i}-rating-${n} ${n+1===h?"rating-active":""}`,value:n+1,type:"button",onClick(){const t=n+1;p(t),e.skipSubmitButton&&f(t)},children:t},n))}),"number"===e.display&&X_("div",{className:"rating-options-number",style:{gridTemplateColumns:`repeat(${u-d+1}, minmax(0, 1fr))`},children:hy(e.scale).map((t,s)=>X_(oy,{displayQuestionIndex:i,active:h===t,appearance:n,num:t,setActiveNumber(t){p(t),e.skipSubmitButton&&f(t)}},s))})]}),!g&&X_("div",{className:"rating-text",children:[X_("div",{children:e.lowerBoundLabel}),X_("div",{children:e.upperBoundLabel})]})]})]}),X_(Ym,{text:e.buttonText||(null==n?void 0:n.submitButtonText)||"Submit",submitDisabled:Pt(h)&&!e.optional,appearance:n,onSubmit:()=>s(h),onPreviewSubmit:()=>r(h),skipSubmitButton:e.skipSubmitButton,canGoBack:a,onBack:l})]})}function oy({num:e,active:t,displayQuestionIndex:i,setActiveNumber:n}){return X_("button",{"aria-label":`Rate ${e}`,className:`ratings-number question-${i}-rating-${e} ${t?"rating-active":""}`,type:"button",onClick(){n(e)},children:e})}function ay({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:n,onSubmit:s,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){const c=yf(null),u=bf(()=>(e=>{var t;if(!e.shuffleOptions)return e.choices;const i=[...e.choices],n=e.hasOpenChoice&&null!==(t=i.pop())&&void 0!==t?t:null,s=(r=i,(o=fc(i)).length>1&&r.every((e,t)=>e===o[t])?o.reverse():o);var r,o;return Pt(n)||s.push(n),s})(e),[e]),[d,h]=vf(()=>((e,t)=>It(e)||iy(e)?e:t===Lf.SingleChoice?null:[])(o,e.type)),[p,g]=vf(()=>((e,t)=>{if(It(e)&&!t.includes(e))return{isSelected:!0,inputValue:e};if(iy(e)){const i=e.find(e=>!t.includes(e));if(i)return{isSelected:!0,inputValue:i}}return{isSelected:!1,inputValue:""}})(o,u)),{isPreviewMode:_}=Pm(),f=e.type===Lf.SingleChoice,v=e.type===Lf.MultipleChoice,m=e.skipSubmitButton&&f&&!e.hasOpenChoice,y=(e,t)=>{if(t){const e=!p.isSelected;return g(t=>ct(ct({},t),{},{isSelected:e,inputValue:e?t.inputValue:""})),f&&h(""),void(e&&setTimeout(()=>{var e;return null===(e=c.current)||void 0===e?void 0:e.focus()},75))}if(f)return h(e),g(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),void(m&&(s(e),_&&r(e)));v&&kt(d)&&(d.includes(e)?h(d.filter(t=>t!==e)):h([...d,e]))},b=e=>{e.stopPropagation();const t=e.currentTarget.value;g(e=>ct(ct({},e),{},{inputValue:t})),f&&h(t)},S=e=>{e.stopPropagation(),"Enter"!==e.key||w()||(e.preventDefault(),k()),"Escape"===e.key&&(e.preventDefault(),g(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),f&&h(null))},w=()=>!(e.optional||!Pt(d)&&(!kt(d)||p.isSelected||0!==d.length)&&(!p.isSelected||""!==p.inputValue.trim())),k=()=>{p.isSelected&&v?kt(d)&&(_?r([...d,p.inputValue]):s([...d,p.inputValue])):_?r(d):s(d)};return X_(M_,{children:[X_("div",{className:"question-container",children:[X_(Zm,{question:e,forceDisableHtml:t}),X_("fieldset",{className:"multiple-choice-options limit-height",children:[X_("legend",{className:"sr-only",children:v?" Select all that apply":" Select one"}),u.map((t,n)=>{const s=!!e.hasOpenChoice&&n===e.choices.length-1,r=`surveyQuestion${i}Choice${n}`,o=`${r}Open`,a=s?p.isSelected:f?d===t:kt(d)&&d.includes(t);return X_("label",{className:s?"choice-option-open":"",children:[X_("div",{className:"response-choice",children:[X_("input",{type:f?"radio":"checkbox",name:r,checked:a,onChange:()=>y(t,s),id:r,"aria-controls":o}),X_("span",{children:s?`${t}:`:t})]}),s&&X_("input",{type:"text",ref:c,id:o,name:`question${i}Open`,value:p.inputValue,onKeyDown:S,onInput:b,onClick(e){p.isSelected||y(t,!0),e.stopPropagation()},"aria-label":`${t} - please specify`})]},n)})]})]}),X_(Ym,{text:e.buttonText||"Submit",submitDisabled:w(),appearance:n,onSubmit:k,onPreviewSubmit:k,skipSubmitButton:m,canGoBack:a,onBack:l})]})}const ly=[1,2,3,4,5],cy=[1,2,3,4,5,6,7],uy=[0,1,2,3,4,5,6,7,8,9,10],dy={2:[Vm,Gm],3:[zm,Um,Hm],5:[Wm,zm,Um,Hm,jm]};function hy(e){switch(e){case 5:default:return ly;case 7:return cy;case 10:return uy}}const py=Br("[Surveys]");function gy(e,t,i){var n;const s=e.questions[t],r=t+1;if(!(null===(n=s.branching)||void 0===n?void 0:n.type))return t===e.questions.length-1?Of.End:r;if(s.branching.type===Of.End)return Of.End;if(s.branching.type===Of.SpecificQuestion){if(Number.isInteger(s.branching.index))return s.branching.index}else if(s.branching.type===Of.ResponseBased){if(s.type===Lf.SingleChoice){var o;let e=s.choices.indexOf(`${i}`);if(-1===e&&s.hasOpenChoice&&(e=s.choices.length-1),null===(o=s.branching)||void 0===o||null===(o=o.responseValues)||void 0===o?void 0:o.hasOwnProperty(e)){const t=s.branching.responseValues[e];if(Number.isInteger(t))return t;if(t===Of.End)return Of.End}}else if(s.type===Lf.Rating){var a;if(s.optional&&Mt(i))return r===e.questions.length?Of.End:r;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");const t=function(e,t){if(2===t){if(1>e||e>2)throw new Error("The response must be in range 1-2");return 1===e?"positive":"negative"}if(3===t){if(1>e||e>3)throw new Error("The response must be in range 1-3");return 1===e?"negative":2===e?"neutral":"positive"}if(5===t){if(1>e||e>5)throw new Error("The response must be in range 1-5");return e>2?3===e?"neutral":"positive":"negative"}if(7===t){if(1>e||e>7)throw new Error("The response must be in range 1-7");return e>3?4===e?"neutral":"positive":"negative"}if(10===t){if(0>e||e>10)throw new Error("The response must be in range 0-10");return e>6?e>8?"promoters":"passives":"detractors"}throw new Error("The scale must be one of: 2, 3, 5, 7, 10")}(i,s.scale);if(null===(a=s.branching)||void 0===a||null===(a=a.responseValues)||void 0===a?void 0:a.hasOwnProperty(t)){const e=s.branching.responseValues[t];if(Number.isInteger(e))return e;if(e===Of.End)return Of.End}}return r}return py.warn("Falling back to next question index due to unexpected branching type"),r}const _y=Br("[SurveyTranslations]");function fy(e,t){const i=function(e){var t;return function({overrideLanguage:e,storedPersonProperties:t,locale:i},n){const s=rc(e);if(s)return null==n||n.info(`Using override display language: ${s}`),s;const r=function(e){return e&&"object"==typeof e&&"language"in e?rc(e.language):null}(t);if(r)return null==n||n.info(`Using person property language: ${r}`),r;const o=rc(i);return o?(null==n||n.info(`Using detected locale: ${o}`),o):(null==n||n.info("No user language detected"),null)}({overrideLanguage:e.config.overrideLanguage,storedPersonProperties:null===(t=e.client)||void 0===t?void 0:t.kv.get(S),locale:"u">typeof navigator?navigator.language||navigator.userLanguage:void 0},_y)}(t);if(!i)return _y.info("No user language detected"),{survey:e,language:null};const n=cc(e,i,_y);return{survey:n.survey,language:n.matchedKey}}const vy="ph:show_survey_widget",my="PHWidgetSurveyClickListener";function yy(e,t){try{const i=e.getBoundingClientRect(),n=window.innerHeight,s=window.innerWidth;let r=i.left+i.width/2-t/2;r+t>s-20&&(r=s-t-20),20>r&&(r=20);const o=n-i.bottom,a=250>o&&i.top>o;return{position:"fixed",top:a?"auto":`${i.bottom+12}px`,left:`${r}px`,right:"auto",bottom:a?n-i.top+12+"px":"auto",zIndex:fm.zIndex}}catch(e){return qf.warn("Failed to calculate trigger position:",e),null}}var by=class{constructor(e){var t,i;this._surveyTimeouts=new Map,this._widgetSelectorListeners=new Map,this._renderedTabWidgets=new Map,this._renderedTargets=new Map,this._prefillHandledSurveys=new Set,this._disposed=!1,this._currentLanguage=null,this._surveyIsRendered=!1,this._languageChangeListener=null,this._unsubscribeFeatureFlags=null,this._surveyPopupProps=null,this._loggedFeatureFlagsDisabledWarning=!1,this.handlePageUnload=()=>{var e;const t=null===(e=this._host.client)||void 0===e?void 0:e.kv.get(R);if(t)for(const e of t)$m(e)&&Em(e,this._host)},this.handlePopoverSurvey=(e,t,{resumeDelayFromActivation:i=!1}={})=>{var n,s,r,o,a,l,c;if(!(null===(n=this._host.client)||void 0===n?void 0:n.canCapture))return;const{survey:u,language:d}=this._translateSurveyForRendering(e);this._currentLanguage=d,this._surveyPopupProps=null,this._displayOptions=t;const h=this._applyDisplayOverrides(u,t);this._clearSurveyTimeout(h.id);const{properties:p,initialResponses:g}=null!=t?t:{},_=!(!g||0>=Object.keys(g).length)&&this._handleInitialResponses(h,g,p,d);if(_&&!(null===(s=h.appearance)||void 0===s?void 0:s.displayThankYouMessage))return;this._addSurveyToFocus(h);let f={};if((null===(r=h.appearance)||void 0===r?void 0:r.position)===Mf.NextToTrigger&&(null===(o=h.appearance)||void 0===o?void 0:o.widgetSelector)){var v;const e=document.querySelector(h.appearance.widgetSelector);e&&(f=yy(e,parseInt((null===(v=h.appearance)||void 0===v?void 0:v.maxWidth)||fm.maxWidth))||{})}const m=(null===(a=h.appearance)||void 0===a?void 0:a.surveyPopupDelaySeconds)||0,{shadow:y}=bm(h,this._host);this._renderedTargets.set(y,y.host);const b={posthog:this._host,survey:h,removeSurveyFromFocus:this._removeSurveyFromFocus,properties:p,style:f,isSurveyCompleted:_,skipShownEvent:null==t?void 0:t.skipShownEvent,surveyLanguage:d};if(this._surveyPopupProps=b,0>=m)return this._surveyIsRendered=!0,Y_(X_(Cy,ct({},b)),y);const S=()=>{this._surveyIsRendered=!0;const{survey:i,language:n}=this._translateSurveyForRendering(e);this._currentLanguage=n;const s=this._applyDisplayOverrides(i,t),r=ct(ct({},b),{},{survey:s,surveyLanguage:n});this._surveyPopupProps=r,Y_(X_(Cy,ct(ct({},r),{},{survey:ct(ct({},s),{},{appearance:ct(ct({},s.appearance),{},{surveyPopupDelaySeconds:0})})})),y)},w=()=>{var e;if(!(null===(e=this._host.client)||void 0===e?void 0:e.canCapture)||!this._shouldDisplaySurvey(h))return qf.info(`Survey ${h.id} no longer eligible when its display delay elapsed; not displaying`),this._removeSurveyFromFocus(h);S()},k=i?null===(l=this._host.surveys)||void 0===l||null===(l=l._surveyEventReceiver)||void 0===l||null===(c=l.getActivationTimestamp)||void 0===c?void 0:c.call(l,h.id):void 0,C=Ft(k)?Math.max(0,Date.now()-k):0,E=Math.max(0,1e3*m-C);if(0>=E)return w();const T=window.setTimeout(()=>{this._surveyTimeouts.delete(h.id),w()},E);this._surveyTimeouts.set(h.id,T)},this._handleWidget=e=>{var t;const{survey:i,language:n}=this._translateSurveyForRendering(e),{shadow:s,isNewlyCreated:r}=bm(i,this._host);this._renderedTargets.set(s,s.host),(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===Pf.Tab&&this._renderedTabWidgets.set(e.id,e),r&&Y_(X_(Ty,{posthog:this._host,survey:i,surveyLanguage:n},e.id),s)},this._detachWidgetSelectorListener=e=>{const t=this._widgetSelectorListeners.get(e);t&&(t.element.removeEventListener("click",t.listener),t.element.removeAttribute(my),this._widgetSelectorListeners.delete(e),qf.info(`Removed click listener for survey ${e}`))},this._removeWidgetSelectorListener=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._detachWidgetSelectorListener(e.id))},this._removeTabWidget=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._renderedTabWidgets.delete(e.id))},this._isWidgetSurveyOpen=e=>{try{var t;const i=document.querySelector(Bm(e,!0));return!!(null==i||null===(t=i.shadowRoot)||void 0===t?void 0:t.querySelector(".ph-survey"))}catch(e){return!1}},this._manageWidgetSelectorListener=(e,t)=>{const i=document.querySelector(t),n=this._widgetSelectorListeners.get(e.id);if(i){if(this._handleWidget(e),n){if(i===n.element)return;qf.info(`Selector element changed for survey ${e.id}. Re-attaching listener.`),this._detachWidgetSelectorListener(e.id)}if(!i.hasAttribute(my)){const t=t=>{var i,n;t.stopPropagation();const s=(null===(i=e.appearance)||void 0===i?void 0:i.position)===Mf.NextToTrigger?yy(t.currentTarget,parseInt((null===(n=e.appearance)||void 0===n?void 0:n.maxWidth)||fm.maxWidth)):{};window.dispatchEvent(new CustomEvent(vy,{detail:{surveyId:e.id,position:s}}))};Kr(i,"click",t),i.setAttribute(my,"true"),this._widgetSelectorListeners.set(e.id,{element:i,listener:t,survey:e}),qf.info(`Attached click listener for feedback button survey ${e.id}`)}}else n&&this._removeWidgetSelectorListener(e)},this.renderPopover=e=>{var t;if(!(null===(t=this._host.client)||void 0===t?void 0:t.canCapture))return;const{survey:i,language:n}=this._translateSurveyForRendering(e),{shadow:s}=bm(i,this._host);this._renderedTargets.set(s,s.host),Y_(X_(Cy,{posthog:this._host,survey:i,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:n}),s)},this.renderSurvey=(e,t,i)=>{var n;if(!(null===(n=this._host.client)||void 0===n?void 0:n.canCapture))return;const{survey:s,language:r}=this._translateSurveyForRendering(e);let o=!1;this._host.config.prefillFromUrl&&(o=this._handleUrlPrefill(s,r,i)),Y_(X_(Cy,{posthog:this._host,survey:s,removeSurveyFromFocus:this._removeSurveyFromFocus,isPopup:!1,properties:i,isSurveyCompleted:o,surveyLanguage:r}),t)},this.getActiveMatchingSurveys=(e,t=!1)=>{var i;null===(i=this._host.surveys)||void 0===i||i.getSurveys(t=>{e(t.filter(e=>this._shouldDisplaySurvey(e)))},t)},this.callSurveysAndEvaluateDisplayLogic=(e=!1)=>{this.getActiveMatchingSurveys(e=>{var t;const i=null===(t=this._host.client)||void 0===t?void 0:t.canCapture,n=e.filter(e=>i&&(e.type===Af.Popover||e.type===Af.Widget)),s=new Set(n.map(e=>e.id));for(const e of Array.from(this._surveyTimeouts.keys()))s.has(e)||this.cancelSurvey(e);const r=this._sortSurveysByAppearanceDelay(n),o=new Set,a=new Set;r.forEach(e=>{if(e.type===Af.Widget){var t,i,n,s;if((null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===Pf.Tab)return a.add(e.id),void this._handleWidget(e);(null===(i=e.appearance)||void 0===i?void 0:i.widgetType)===Pf.Selector&&(null===(n=e.appearance)||void 0===n?void 0:n.widgetSelector)&&(o.add(e.id),this._manageWidgetSelectorListener(e,null===(s=e.appearance)||void 0===s?void 0:s.widgetSelector))}Pt(this._surveyInFocus)&&e.type===Af.Popover&&this.handlePopoverSurvey(e,void 0,{resumeDelayFromActivation:!0})}),this._widgetSelectorListeners.forEach(({survey:e})=>{o.has(e.id)||this._removeWidgetSelectorListener(e)}),this._renderedTabWidgets.forEach((e,t)=>{a.has(t)||this._removeTabWidget(e)})},e)},this._addSurveyToFocus=e=>{Pt(this._surveyInFocus)||qf.error(`Survey ${this._surveyInFocus} already in focus. Cannot add survey ${e.id}.`),this._surveyInFocus=e.id},this._removeSurveyFromFocus=e=>{this._surveyInFocus!==e.id&&qf.error(`Survey ${e.id} is not in focus. Cannot remove survey ${e.id}.`),this._clearSurveyTimeout(e.id),this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0,this._removeSurveyFromDom(e)},this._host=e,this._surveyInFocus=null,this._languageChangeListener=()=>this._onLanguageChange(),Kr(window,"languagechange",this._languageChangeListener),this._unsubscribeFeatureFlags=null!==(t=null===(i=e.client)||void 0===i||null===(i=i.getExtension("featureFlagsCommon"))||void 0===i?void 0:i.onFeatureFlags(()=>this._onLanguageChange()))&&void 0!==t?t:null}_onLanguageChange(){var e;if(Pt(this._surveyInFocus))return;const t=null===(e=this._host.client)||void 0===e?void 0:e.kv.get(R),i=null==t?void 0:t.find(e=>e.id===this._surveyInFocus);if(!i)return;const{survey:n,language:s}=this._translateSurveyForRendering(i);if(s===this._currentLanguage)return;if(this._currentLanguage=s,!this._surveyIsRendered)return;const r=this._applyDisplayOverrides(n,this._displayOptions),{shadow:o}=bm(r,this._host);Y_(X_(Cy,ct(ct({},this._surveyPopupProps),{},{posthog:this._host,survey:r,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:s})),o)}_applyDisplayOverrides(e,t){return(null==t?void 0:t.position)||(null==t?void 0:t.selector)?ct(ct({},e),{},{appearance:ct(ct(ct({},e.appearance),t.position&&{position:t.position}),t.selector&&{widgetSelector:t.selector})}):e}_clearSurveyTimeout(e){const t=this._surveyTimeouts.get(e);t&&(clearTimeout(t),this._surveyTimeouts.delete(e))}cancelSurvey(e){this._surveyTimeouts.has(e)&&(qf.info(`Cancelled pending survey ${e}`),this._clearSurveyTimeout(e),this._surveyInFocus===e&&(this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0))}startAutomaticDisplay(){if(this._disposed||this._automaticDisplayDispose||!1===this._host.config.automaticDisplay)return;this._automaticDisplayDispose=()=>{};const e=function(e){let t;e.callSurveysAndEvaluateDisplayLogic(!0);const i=()=>{xt(t)&&(t=setInterval(()=>{e.callSurveysAndEvaluateDisplayLogic(!1)},1e3))},n=()=>{xt(t)||(clearInterval(t),t=void 0)};i();const s=()=>{document.hidden?n():(e.callSurveysAndEvaluateDisplayLogic(!1),i())};return Kr(document,"visibilitychange",s),()=>{n(),document.removeEventListener("visibilitychange",s)}}(this);this._disposed?e():this._automaticDisplayDispose=e}clearInMemoryInProgressSurveyState(){(()=>{for(const e of Object.keys(Lm))delete Lm[e]})()}dispose(){var e;this._disposed=!0,null===(e=this._automaticDisplayDispose)||void 0===e||e.call(this),this._automaticDisplayDispose=void 0,this._languageChangeListener&&(window.removeEventListener("languagechange",this._languageChangeListener),this._languageChangeListener=null),this._unsubscribeFeatureFlags&&(this._unsubscribeFeatureFlags(),this._unsubscribeFeatureFlags=null),this._surveyTimeouts.forEach((e,t)=>this._clearSurveyTimeout(t)),this._widgetSelectorListeners.forEach((e,t)=>this._detachWidgetSelectorListener(t)),this._renderedTargets.forEach((e,t)=>{Y_(null,t),null==e||e.remove()}),this._renderedTargets.clear(),this._renderedTabWidgets.clear(),this._surveyInFocus=null}_sortSurveysByAppearanceDelay(e){return e.sort((e,t)=>{var i,n;const s=$m(e),r=$m(t);if(s&&!r)return-1;if(!s&&r)return 1;const o=e.schedule===Df.Always,a=t.schedule===Df.Always;return o&&!a?1:!o&&a?-1:((null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds)||0)-((null===(n=t.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds)||0)})}_translateSurveyForRendering(e){return fy(e,this._host)}_handleUrlPrefill(e,t,i){if(this._prefillHandledSurveys.has(e.id))return!1;const{params:n}=function(){const e={};let t=!1;const i=window.location.search.replace(/^\?/,"");if(!i)return{params:e,autoSubmit:t};const n=i.split("&");for(const i of n){const n=i.indexOf("=");if(0>=n)continue;let s,r;try{s=decodeURIComponent(i.slice(0,n)),r=decodeURIComponent(i.slice(n+1))}catch(e){continue}if("auto_submit"===s&&"true"===r){t=!0;continue}const o=s.match(/^q(\d+)$/);if(o){const t=parseInt(o[1],10);e[t]||(e[t]=[]),e[t].push(r)}}return{params:e,autoSubmit:t}}();if(0===Object.keys(n).length)return!1;qf.info("[Survey Prefill] Detected URL prefill parameters");const s=this._processPrefillData(e,n,t);return!!s&&(this._autoSubmitPrefilledResponses(e,s,i,t),this._prefillHandledSurveys.add(e.id),s.isSurveyCompleted)}_autoSubmitPrefilledResponses(e,t,i,n){const{responses:s,submissionId:r,isSurveyCompleted:o,skippedResponses:a}=t;(Object.keys(a).length>0&&e.enable_partial_responses||o)&&wm({responses:o?s:a,survey:e,surveySubmissionId:r,posthog:this._host,isSurveyCompleted:o,properties:i,surveyLanguage:n})}_handleInitialResponses(e,t,i,n){const s={};for(const[e,i]of Object.entries(t))s[parseInt(e)]=kt(i)?i.map(String):[String(i)];qf.info("[Survey] Processing initial responses");const r=this._processPrefillData(e,s,n);return!!r&&(this._autoSubmitPrefilledResponses(e,r,i,n),r.isSurveyCompleted)}_processPrefillData(e,t,i){try{const n=function(e,t){const i={};return e.questions.forEach((e,n)=>{if(!t[n]||!e.id)return;const s=t[n],r=ec(e.id);try{switch(e.type){case Lf.SingleChoice:{if(!e.choices||0===e.choices.length)return void Nr.warn(`[Survey Prefill] Question ${n} has no choices`);const t=parseInt(s[0],10);if(isNaN(t)||0>t||t>=e.choices.length)return void Nr.warn(`[Survey Prefill] Invalid choice index for q${n}: ${s[0]}`);i[r]=e.choices[t];break}case Lf.MultipleChoice:{if(!e.choices||0===e.choices.length)return void Nr.warn(`[Survey Prefill] Question ${n} has no choices`);const t=s.map(e=>parseInt(e,10)).filter(t=>!isNaN(t)&&t>=0&&e.choices.length>t);if(0===t.length)return void Nr.warn(`[Survey Prefill] No valid choices for q${n}`);const o=[...new Set(t.map(t=>e.choices[t]))];t.length>o.length&&Nr.warn(`[Survey Prefill] Removed duplicate choices for q${n}`),i[r]=o;break}case Lf.Rating:{const t=parseInt(s[0],10),o=e.scale||10,a=10===o?0:1;if(isNaN(t)||a>t||t>o)return void Nr.warn(`[Survey Prefill] Invalid rating for q${n}: ${s[0]} (scale: ${a}-${o})`);i[r]=t;break}default:Nr.info(`[Survey Prefill] Question type ${e.type} does not support prefill`)}}catch(e){Nr.error(`[Survey Prefill] Error converting q${n}:`,e)}}),i}(e,t);if(0===Object.keys(n).length)return qf.warn("[Survey Prefill] No valid responses after conversion"),null;const s=Rl(),{startQuestionIndex:r,skippedResponses:o,skippedIndices:a}=function(e,t,i){let n=0;const s={},r=[],o=e.questions.length+1;let a=0;for(;e.questions.length>n&&o>a&&(a++,t.includes(n));){const t=e.questions[n];if(!t||!("skipSubmitButton"in t)||!t.skipSubmitButton)break;if(t.id){const e=ec(t.id);xt(i[e])||(s[e]=i[e])}r.push(n);const o=gy(e,n,t.id?i[ec(t.id)]:null);if(o===Of.End)return{startQuestionIndex:e.questions.length,skippedResponses:s,skippedIndices:r};n=o}return{startQuestionIndex:n,skippedResponses:s,skippedIndices:r}}(e,Object.keys(t).map(e=>parseInt(e,10)).filter(t=>{const i=e.questions[t];return(null==i?void 0:i.id)&&!xt(n[ec(i.id)])}),n),l=r>=e.questions.length;return Om(e,{surveySubmissionId:s,responses:n,lastQuestionIndex:r,questionOrder:Tm(e.questions),visitedIndices:a,surveyLanguage:i}),qf.info("[Survey Prefill] Stored prefilled responses in localStorage"),{responses:n,submissionId:s,startQuestionIndex:r,isSurveyCompleted:l,skippedResponses:o}}catch(e){return qf.error("[Survey Prefill] Error handling prefill:",e),null}}_isSurveyFeatureFlagEnabled(e,t){var i;if(!e)return!0;const n=null===(i=this._host.client)||void 0===i?void 0:i.getExtension(ef),s=!!(null==n?void 0:n.isFeatureEnabled(e,{send_event:!e.startsWith("survey-targeting-")}));let r=!0;t&&(r=(null==n?void 0:n.getFeatureFlag(e,{send_event:!1}))===t||"any"===t);const o=s&&r;return o||this._warnIfFeatureFlagsDisabled(e),o}_warnIfFeatureFlagsDisabled(e){this._loggedFeatureFlagsDisabledWarning||!1!==this._host.config.featureFlagEvaluation||(this._loggedFeatureFlagsDisabledWarning=!0,qf.warn(`Survey feature flag "${e}" evaluated to false because advanced_disable_feature_flags is set. PostHog creates an internal targeting flag for almost every survey, so no survey can display while flags are disabled. To keep surveys working, replace advanced_disable_feature_flags with advanced_only_evaluate_survey_feature_flags, which evaluates survey flags only.`))}_isSurveyConditionMatched(e){return!e.conditions||Fm(e,this._host)&&function(e){var t,i;return function(e,t){var i,n,s;if(!e||0===e.length)return!0;const r="u">typeof window?window:void 0,o="u">typeof globalThis?globalThis:r,a=null==o?void 0:o.navigator,l=null==a?void 0:a.userAgent;if(!l)return!1;const c=Ji(l,{userAgentDataPlatform:null==a||null===(i=a.userAgentData)||void 0===i?void 0:i.platform,maxTouchPoints:null==a?void 0:a.maxTouchPoints,screenWidth:null==r||null===(n=r.screen)||void 0===n?void 0:n.width,screenHeight:null==r||null===(s=r.screen)||void 0===s?void 0:s.height,devicePixelRatio:null==r?void 0:r.devicePixelRatio});return gc[null!=t?t:"icontains"](e,[c])}(null===(t=e.conditions)||void 0===t?void 0:t.deviceTypes,null===(i=e.conditions)||void 0===i?void 0:i.deviceTypesMatchType)}(e)&&function(e){var t,i;return!(null===(t=e.conditions)||void 0===t?void 0:t.selector)||!!(null===(i=document)||void 0===i?void 0:i.querySelector(e.conditions.selector))}(e)}_internalFlagCheckSatisfied(e){var t;return Im(e)?{satisfied:!0}:e.internal_targeting_flag_key&&function(e){var t;return"recurring"===e.schedule||(null!==(t=e.current_iteration)&&void 0!==t?t:0)>0}(e)&&!(null===(t=this._host.client)||void 0===t||null===(t=t.getExtension("featureFlagsCommon"))||void 0===t?void 0:t.hasLoadedFlags)?(this._warnIfFeatureFlagsDisabled(e.internal_targeting_flag_key),{satisfied:!1,reason:"Feature flags have not loaded yet; deferring internal targeting flag check"}):{satisfied:this._isSurveyFeatureFlagEnabled(e.internal_targeting_flag_key)}}checkSurveyEligibility(e){var t,i;const n={eligible:!0,reason:void 0};if(!Uf(e))return n.eligible=!1,n.reason=`Survey is not running. It was completed on ${e.end_date}`,n;if(!Gf.includes(e.type))return n.eligible=!1,n.reason=`Surveys of type ${e.type} are never eligible to be shown in the app`,n;const s=null===(t=e.conditions)||void 0===t?void 0:t.linkedFlagVariant;if(!this._isSurveyFeatureFlagEnabled(e.linked_flag_key,s))return n.eligible=!1,n.reason=s?`Survey linked feature flag is not enabled for variant ${s}`:"Survey linked feature flag is not enabled",n;if(!this._isSurveyFeatureFlagEnabled(e.targeting_flag_key))return n.eligible=!1,n.reason="Survey targeting feature flag is not enabled",n;const r=this._internalFlagCheckSatisfied(e);var o;return r.satisfied?(e=>{let t=null;try{t=localStorage.getItem("lastSeenSurveyDate")}catch(e){qf.error("localStorage error: "+e)}return function(e,t){if(!e||!t)return!0;const i="string"==typeof t?new Date(t):t,n=Math.abs((new Date).getTime()-i.getTime());return Math.ceil(n/864e5)>e}(e,t)})(null===(i=e.conditions)||void 0===i?void 0:i.seenSurveyWaitPeriodInDays)?((e=>{let t=null;try{t=localStorage.getItem(jf(e))}catch(e){qf.error("localStorage error: "+e)}return!!t&&!Im(e)})(e)&&(n.eligible=!1,n.reason="Survey has already been seen and it can't be activated again"),n):(n.eligible=!1,n.reason="Survey wait period has not passed",n):(n.eligible=!1,n.reason=null!==(o=r.reason)&&void 0!==o?o:"Survey internal targeting flag is not enabled and survey cannot activate repeatedly and survey is not in progress",n)}checkSurveyCaptureEligibility(){var e;return(null===(e=this._host.client)||void 0===e?void 0:e.canCapture)?{eligible:!0}:{eligible:!1,reason:Hf}}checkSurveyDisplayEligibility(e){const t=this.checkSurveyCaptureEligibility();return t.eligible?this.checkSurveyEligibility(e):t}checkSurveyRenderability(e){const t=this.checkSurveyDisplayEligibility(e);return t.eligible&&!this._hasActionOrEventTriggeredSurvey(e)?{eligible:!1,reason:"Survey event/action trigger has not been fired yet"}:t}_hasActionOrEventTriggeredSurvey(e){var t;if(!uc(e)&&!zf(e))return!0;const i=null===(t=this._host.surveys)||void 0===t||null===(t=t._surveyEventReceiver)||void 0===t?void 0:t.getSurveys();return!!(null==i?void 0:i.includes(e.id))}_checkFlags(e){var t;return!(null===(t=e.feature_flag_keys)||void 0===t?void 0:t.length)||e.feature_flag_keys.every(({key:e,value:t})=>!e||!t||this._isSurveyFeatureFlagEnabled(t))}_shouldDisplaySurvey(e){return this.checkSurveyEligibility(e).eligible&&this._isSurveyConditionMatched(e)&&this._hasActionOrEventTriggeredSurvey(e)&&this._checkFlags(e)}_removeSurveyFromDom(e){try{const t=document.querySelector(Bm(e,!0));(null==t?void 0:t.shadowRoot)&&(Y_(null,t.shadowRoot),this._renderedTargets.delete(t.shadowRoot)),null==t||t.remove()}catch(t){qf.warn(`Failed to remove survey ${e.id} from DOM:`,t)}}getTestAPI(){return{addSurveyToFocus:this._addSurveyToFocus,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyInFocus:this._surveyInFocus,surveyTimeouts:this._surveyTimeouts,handleWidget:this._handleWidget,handlePopoverSurvey:this.handlePopoverSurvey,manageWidgetSelectorListener:this._manageWidgetSelectorListener,sortSurveysByAppearanceDelay:this._sortSurveysByAppearanceDelay.bind(this),checkFlags:this._checkFlags.bind(this),isSurveyFeatureFlagEnabled:this._isSurveyFeatureFlagEnabled.bind(this),onLanguageChange:this._onLanguageChange.bind(this),currentLanguage:this._currentLanguage,surveyIsRendered:this._surveyIsRendered}}};function Sy({survey:e,removeSurveyFromFocus:t=()=>{},setSurveyVisible:i,isPreviewMode:n=!1,posthog:s}){mf(()=>{var r;if(n||!(null===(r=e.conditions)||void 0===r?void 0:r.url))return;const o=()=>{var n;const r=e.type===Af.Widget,o=Fm(e,s),a=(null===(n=e.appearance)||void 0===n?void 0:n.widgetType)===Pf.Tab&&r;if(!o)return qf.info(`Hiding survey ${e.id} because URL does not match`),i(!1),t(e);a&&(qf.info(`Showing survey ${e.id} because it is a feedback button tab and URL matches`),i(!0))};Kr(window,"popstate",o),Kr(window,"hashchange",o);const a=window.history.pushState,l=window.history.replaceState;return window.history.pushState=function(...e){a.apply(this,e),o()},window.history.replaceState=function(...e){l.apply(this,e),o()},()=>{window.removeEventListener("popstate",o),window.removeEventListener("hashchange",o),window.history.pushState=a,window.history.replaceState=l}},[n,e,t,i,s])}const wy=200;function ky(e=Ff.Right){switch(e){case Ff.Top:return{top:"0",left:"50%",transform:"translateX(-50%)"};case Ff.Left:return{top:"50%",left:"0",transform:"rotate(90deg) translateY(-100%)",transformOrigin:"left top"};case Ff.Bottom:return{bottom:"0",left:"50%",transform:"translateX(-50%)"};default:return{top:"50%",right:"0",transform:"rotate(-90deg) translateY(-100%)",transformOrigin:"right top"}}}function Cy({survey:e,forceDisableHtml:t,posthog:i,style:n={},previewPageIndex:s,removeSurveyFromFocus:r=()=>{},isPopup:o=!0,onPreviewSubmit:a=()=>{},onPreviewBack:l=()=>{},onPopupSurveyDismissed:c=()=>{},onCloseConfirmationMessage:u=()=>{},properties:d,isSurveyCompleted:h,skipShownEvent:p,surveyLanguage:g}){var _,f,v,m,y,b,S,w,k,C,E,T;const x=yf(null),I=Number.isInteger(s),{isPopupVisible:R,isSurveySent:P,hidePopupWithAnimation:M}=function(e,t,i,n,s,r,o,a,l){const[c,u]=vf(n||0===i||e.type===Af.ExternalSurvey),[d,h]=vf(!1),p=yf(!1),g=()=>{const t=()=>{r&&s(e),u(!1)};if(p.current)return;const i=null==o?void 0:o.current;i?(p.current=!0,i.style.transition=`opacity ${wy}ms ease-out`,i.style.opacity="0",setTimeout(()=>{p.current=!1,t()},250)):t()},_=t=>{t.detail.surveyId===e.id&&g()};return mf(()=>{if(!t)return void qf.error("usePopupVisibility hook called without a PostHog instance.");if(n)return;let s;const r=t=>{var i,n;if(t.detail.surveyId===e.id){if(!(null===(i=e.appearance)||void 0===i?void 0:i.displayThankYouMessage))return g();h(!0),(null===(n=e.appearance)||void 0===n?void 0:n.autoDisappear)&&(s&&clearTimeout(s),s=setTimeout(g,5e3))}},o=()=>{var i;if(Fm(e,t)){u(!0);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}window.dispatchEvent(new Event("PHSurveyShown")),a||null===(i=t.client)||void 0===i||i.capture($f.SHOWN,ct(ct({[Nf.SURVEY_NAME]:e.name,[Nf.SURVEY_ID]:e.id,[Nf.SURVEY_ITERATION]:e.current_iteration,[Nf.SURVEY_ITERATION_START_DATE]:e.current_iteration_start_date},l&&{[Nf.SURVEY_LANGUAGE]:l}),{},{sessionRecordingUrl:tf(t)}))}};Kr(window,"PHSurveyClosed",_),Kr(window,"PHSurveySent",r);const c=i>0?setTimeout(o,i):void 0;return xt(c)&&o(),()=>{xt(c)||clearTimeout(c),xt(s)||clearTimeout(s),window.removeEventListener("PHSurveyClosed",_),window.removeEventListener("PHSurveySent",r)}},[]),Sy({survey:e,removeSurveyFromFocus:s,setSurveyVisible:u,isPreviewMode:n,posthog:t}),{isPopupVisible:c,isSurveySent:d,setIsPopupVisible:u,hidePopupWithAnimation:g}}(e,i,(null===(_=e.appearance)||void 0===_?void 0:_.surveyPopupDelaySeconds)?1e3*e.appearance.surveyPopupDelaySeconds:0,I,r,o,x,p,g),F=P||s===e.questions.length||!0===h,[A,L]=vf(!1),O=bf(()=>!!Dm(e),[e]),D=!(!(null===(f=e.appearance)||void 0===f?void 0:f.introScreenHeader)&&!(null===(v=e.appearance)||void 0===v?void 0:v.introScreenDescription)),N=I?-1===s:!!(null===(m=e.appearance)||void 0===m?void 0:m.displayIntroScreen)&&D&&!A&&!O,B=bf(()=>{const t=Dm(e),n=(null==t?void 0:t.surveySubmissionId)||Rl()||"";return{isPreviewMode:I,previewPageIndex:s,onPopupSurveyDismissed(){g?Cm(e,i,I,g):Cm(e,i,I),c()},isPopup:o||!1,surveySubmissionId:n,onPreviewSubmit:a,onPreviewBack:l,posthog:i,properties:d,surveyLanguage:g}},[I,s,o,i,e,c,a,l,d,g]);return R?X_(Rm.Provider,{value:B,children:X_("div",{className:"ph-survey",style:ct(ct({},qm(e.type,null===(y=e.appearance)||void 0===y?void 0:y.position,null===(b=e.appearance)||void 0===b?void 0:b.widgetType)),n),ref:x,children:F?X_(ey,{header:(null===(S=e.appearance)||void 0===S?void 0:S.thankYouMessageHeader)||"Thank you!",description:(null===(w=e.appearance)||void 0===w?void 0:w.thankYouMessageDescription)||"",forceDisableHtml:!!t,contentType:null===(k=e.appearance)||void 0===k?void 0:k.thankYouMessageDescriptionContentType,appearance:e.appearance||fm,onClose(){M(),u()}}):N?X_(ty,{header:(null===(C=e.appearance)||void 0===C?void 0:C.introScreenHeader)||"",description:(null===(E=e.appearance)||void 0===E?void 0:E.introScreenDescription)||"",forceDisableHtml:!!t,contentType:null===(T=e.appearance)||void 0===T?void 0:T.introScreenDescriptionContentType,appearance:e.appearance||fm,onStart:()=>L(!0)}):X_(Ey,{survey:e,forceDisableHtml:!!t,posthog:i})})}):null}function Ey({survey:e,forceDisableHtml:t,posthog:i}){var n,s;const r=bf(()=>{const t=Dm(e);if(!t)return null;const i=Ft(t.lastQuestionIndex);return!i||i&&t.lastQuestionIndex>=0&&e.questions.length>t.lastQuestionIndex?t:(Nm(e),null)},[e]),[o,a]=vf(()=>((null==r?void 0:r.responses)&&qf.info("Survey is already in progress, filling in initial responses"),(null==r?void 0:r.responses)||{})),[l,c]=vf(!1),{previewPageIndex:u,onPopupSurveyDismissed:d,isPopup:h,onPreviewSubmit:p,onPreviewBack:g,surveySubmissionId:_,isPreviewMode:f,properties:v,surveyLanguage:m}=Sf(Rm),[y,b]=vf(()=>{const t=null==r?void 0:r.lastQuestionIndex,i=Ft(t)&&t>=0&&e.questions.length>t?t:0;return Ft(u)&&u>=0?u:i}),[S,w]=vf(()=>{var t;return(null!==(t=null==r?void 0:r.visitedIndices)&&void 0!==t?t:[]).filter(t=>t>=0&&e.questions.length>t)}),[k,C]=vf(()=>{var t;const i=Dm(e);return null!==(t=null==i?void 0:i.questionSnapshots)&&void 0!==t?t:{}}),E=bf(()=>Tm(xm(e,r)),[e.id,r]),T=bf(()=>{if(!E||new Set(E).size!==E.length)return xm(e,r);const t=new Map(e.questions.map(e=>[e.id,e])),i=E.map(e=>t.get(e)).filter(e=>!!e);return i.length===E.length?i:e.questions},[E,e.questions,e,r]);mf(()=>{!f||xt(u)||0>u||b(u)},[u,f]);const x=!!(null===(n=e.appearance)||void 0===n?void 0:n.allowGoBack)&&(f?(null!=u?u:0)>0:S.length>0),I=T.at(y);return I?X_("form",{className:"survey-form",name:"surveyForm",children:[h&&!0!==(null===(s=e.appearance)||void 0===s?void 0:s.hideCancelButton)&&X_(Xm,{onClick(){d()}}),X_("div",{className:"survey-box","data-question-index":y,children:[l&&X_("p",{role:"alert",children:"Your response could not be sent. Please try again later."}),xy({question:I,forceDisableHtml:t,displayQuestionIndex:y,appearance:e.appearance||fm,onSubmit:t=>(({res:t,displayQuestionIndex:n,questionId:s})=>{var r;if(!i)return void qf.error("onNextButtonClick called without a PostHog instance.");if(!(null===(r=i.client)||void 0===r?void 0:r.canCapture))return void c(!0);if(c(!1),!s)return void qf.error("onNextButtonClick called without a questionId.");const{responses:l,questionSnapshots:u}=function({responses:e,questionSnapshots:t={}},i,n,s){return{responses:ct(ct({},e),{},{[ec(i)]:n}),questionSnapshots:(null==s?void 0:s.id)?ct(ct({},t),{},{[s.id]:s.question}):t}}({responses:o,questionSnapshots:k},s,t,T[n]);a(l),C(u);const d=gy(e,n,t),h=d===Of.End,p=[...S,n];if(h||(w(p),b(d),Om(e,{surveySubmissionId:_,responses:l,lastQuestionIndex:d,questionOrder:Tm(T),visitedIndices:p,surveyLanguage:m,questionSnapshots:u})),e.enable_partial_responses||h){const t=new Set(p.map(e=>{var t;return null===(t=T[e])||void 0===t?void 0:t.id}).filter(e=>!!e).map(e=>ec(e))),n=Object.fromEntries(Object.entries(l).filter(([e])=>t.has(e)));wm({responses:n,survey:e,surveySubmissionId:_,isSurveyCompleted:h,posthog:i,properties:v,surveyLanguage:m,questionSnapshots:u})}})({res:t,displayQuestionIndex:y,questionId:I.id}),onPreviewSubmit:p,initialValue:I.id?o[ec(I.id)]:void 0,canGoBack:x,onBack(){if(f)return void g();if(0===S.length)return;const t=S[S.length-1],i=S.slice(0,-1);w(i),b(t),Om(e,{surveySubmissionId:_,responses:o,lastQuestionIndex:t,questionOrder:Tm(T),visitedIndices:i,surveyLanguage:m,questionSnapshots:k})}})]})]}):null}function Ty({survey:e,forceDisableHtml:t,posthog:i,readOnly:n,surveyLanguage:s}){var r,o,a,l,c,u,d,h;const[p,g]=vf(!0),[_,f]=vf(!1),[v,m]=vf({}),y=yf(void 0),b=()=>{var e;(_||!i||n||(null===(e=i.client)||void 0===e?void 0:e.canCapture))&&f(!_)};if(mf(()=>{var t,s,r;if(!i)return void qf.error("FeedbackWidget called without a PostHog instance.");if(n)return;"tab"===(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)&&m((r=null===(s=e.appearance)||void 0===s?void 0:s.position)&&r!==Mf.Right&&r!==Mf.NextToTrigger?{}:{top:"50%",bottom:"auto"});const o=t=>{var i;const n=t;(null===(i=n.detail)||void 0===i?void 0:i.surveyId)===e.id&&(qf.info(`Received show event for feedback button survey ${e.id}`),m(n.detail.position||{}),b())};return Kr(window,vy,o),()=>{xt(y.current)||(clearTimeout(y.current),y.current=void 0),window.removeEventListener(vy,o)}},[i,n,e.id,null===(r=e.appearance)||void 0===r?void 0:r.widgetType,null===(o=e.appearance)||void 0===o?void 0:o.position,null===(a=e.appearance)||void 0===a?void 0:a.widgetSelector,null===(l=e.appearance)||void 0===l?void 0:l.borderColor]),Sy({survey:e,setSurveyVisible:g,posthog:i}),!p)return null;const S=()=>{e.schedule!==Df.Always&&g(!1),xt(y.current)||clearTimeout(y.current),y.current=setTimeout(()=>{y.current=void 0,f(!1)},200)};return X_(M_,{children:["tab"===(null===(c=e.appearance)||void 0===c?void 0:c.widgetType)&&X_("button",{className:"ph-survey-widget-tab "+((null===(u=e.appearance)||void 0===u?void 0:u.tabPosition)===Ff.Top?"widget-tab-top":""),onClick:b,disabled:n,style:ky(null===(d=e.appearance)||void 0===d?void 0:d.tabPosition),children:(null===(h=e.appearance)||void 0===h?void 0:h.widgetLabel)||""}),_&&X_(Cy,{posthog:i,survey:e,forceDisableHtml:t,style:v,onPopupSurveyDismissed:S,onCloseConfirmationMessage:S,surveyLanguage:s})]})}const xy=({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:n,onSubmit:s,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l})=>{const c={forceDisableHtml:t,appearance:n,onPreviewSubmit(e){r(e)},onSubmit(e){s(e)},initialValue:o,displayQuestionIndex:i,canGoBack:a,onBack:l};switch(e.type){case Lf.Open:return R_(ny,ct(ct({},c),{},{question:e,key:e.id}));case Lf.Link:return R_(sy,ct(ct({},c),{},{question:e,key:e.id}));case Lf.Rating:return R_(ry,ct(ct({},c),{},{question:e,key:e.id}));case Lf.SingleChoice:case Lf.MultipleChoice:return R_(ay,ct(ct({},c),{},{question:e,key:e.id}));default:return qf.error(`Unsupported question type: ${e.type}`),null}},Iy={GZipJS:"gzip-js",Base64:"base64"};function Ry(e){let t=!0;return{dispose(){if(t){t=!1;const i=e();i&&Ct(i.then)&&i.then(void 0,()=>{})}}}}var Py=class{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(const i of this._events[e]||[])i(t);for(const i of this._events["*"]||[])i(e,t)}constructor(){this._events={}}};function My(e,t,i){if(Mt(e))return!1;switch(i){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var Fy=class{constructor(e){this._host=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Py,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?void 0:t.event)||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;xt(null===(e=this._host)||void 0===e?void 0:e.subscribeCapture)||(this._captureHookUnsubscribe=null===(t=this._host)||void 0===t?void 0:t.subscribeCapture((e,t)=>{this.on(e,t)}))}dispose(){var e,t,i;null===(e=this._captureHookUnsubscribe)||void 0===e||e.call(this),this._captureHookUnsubscribe=void 0,null===(t=this._host)||void 0===t||null===(i=t.setElementSelectors)||void 0===i||i.call(t,new Set,this),this._debugEventEmitter=new Py}register(e){var t,i;if(!xt(null===(t=this._host)||void 0===t?void 0:t.subscribeCapture)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null===(t=e.steps)||void 0===t||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null===(i=this._host)||void 0===i?void 0:i.setElementSelectors)){const e=new Set;this._actionRegistry.forEach(t=>{var i;null===(i=t.steps)||void 0===i||i.forEach(t=>{(null==t?void 0:t.selector)&&e.add(t.selector)})}),this._host.setElementSelectors(e,this)}}replace(e){this._actionRegistry.clear(),this._actionEvents.clear(),this.register(e)}on(e,t){null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&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(const 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?void 0:t.url){var i;let r=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!(null==e?void 0:e.properties)||!("$current_url"in e.properties))try{var n,s;r=null===(n=this._host)||void 0===n||null===(s=n.getActionUrl)||void 0===s?void 0:s.call(n)}catch(e){return!1}if(!r||"string"!=typeof r)return!1;if(!My(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?void 0:t.href))return!0;const n=this._getElementsList(e);if(n.length>0)return n.some(e=>My(e.href,t.href,t.href_matching||"exact"));const s=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!s&&My(function(e){const t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:""}(s),t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(!(null==t?void 0:t.text))return!0;const n=this._getElementsList(e);if(n.length>0)return n.some(e=>My(e.text,t.text,t.text_matching||"exact")||My(e.$el_text,t.text,t.text_matching||"exact"));const s=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!s&&(r=function(e){const t=[],i=/(?::|")text="(.*?)"/g;let n;for(;!Mt(n=i.exec(e));)t.includes(n[1])||t.push(n[1]);return t}(s),o=t.text,a=t.text_matching||"exact",r.some(e=>My(e,o,a)));var r,o,a}_checkStepSelector(e,t){var i,n;if(!(null==t?void 0:t.selector))return!0;const s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(null==s?void 0:s.includes(t.selector))return!0;const r=(null==e||null===(n=e.properties)||void 0===n?void 0:n.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch(e){}return!1}_getElementsList(e){var t;return null==(null==e||null===(t=e.properties)||void 0===t?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return!(null==t?void 0:t.properties)||0===t.properties.length||_c(t.properties.reduce((e,t)=>{const i=kt(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)}},Ay=class{constructor(e,t){this._onActivationChanged=t,this._pendingActivatedItems=[],this._host=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_subscribeSession(){var e,t;this._sessionIdUnsubscribe=null===(e=(t=this._host).subscribeSession)||void 0===e?void 0:e.call(t,e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&_c(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){const i=new Map;return e.forEach(e=>{var n;null===(n=e.conditions)||void 0===n||null===(n=n[t])||void 0===n||null===(n=n.values)||void 0===n||n.forEach(t=>{if(null==t?void 0:t.name){const n=i.get(t.name)||[];n.push(e.id),i.set(t.name,n)}})}),i}_getMatchingItems(e,t,i){const n=(i===Rf.Activation?this._eventToItems:this._cancelEventToItems).get(e);let s=[];return this._getItems(e=>{s=e.filter(e=>null==n?void 0:n.includes(e.id))}),s.filter(n=>{var s;const r=null===(s=n.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s?void 0:s.find(t=>t.name===e);return this._doesEventMatchFilter(r,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){xt(this._host.subscribeCapture)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){const i=e.filter(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length});var n;if(t&&this._actionToItems.clear(),0===i.length)return void(t&&(null===(n=this._actionMatcher)||void 0===n||n.replace([])));this._actionMatcher||(this._actionMatcher=new Fy(this._host),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));const s=[];i.forEach(e=>{var t;null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||t.values.forEach(t=>{if(s.push(t),t.name){var i;const n=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];n.includes(e.id)||n.push(e.id),this._actionToItems.set(t.name,n)}})}),t?this._actionMatcher.replace(s):this._actionMatcher.register(s)}_mergeItemMaps(e,t){t.forEach((t,i)=>{var n;const s=null!==(n=e.get(i))&&void 0!==n?n:[];t.forEach(e=>{s.includes(e)||s.push(e)}),e.set(i,s)})}_setupEventBasedItems(e,t){var i,n,s;const r=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),o=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.cancelEvents)&&(null===(i=e.conditions)||void 0===i||null===(i=i.cancelEvents)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),a=this._buildEventToItemMap(e,Rf.Activation),l=this._buildEventToItemMap(e,Rf.Cancellation);t?(this._eventToItems=a,this._cancelEventToItems=l):(this._mergeItemMaps(this._eventToItems,a),this._mergeItemMaps(this._cancelEventToItems,l)),(0!==r.length||0!==o.length||e.some(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length}))&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null===(n=(s=this._host).subscribeCapture)||void 0===n?void 0:n.call(s,(e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,n;const s=this._getLogger(),r=(null==t||null===(i=t.properties)||void 0===i?void 0:i.$survey_id)||(null==t||null===(n=t.properties)||void 0===n?void 0:n.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const i=this._activationOutcome(e,r,t);if("consume"===i)return s.info("event consumed activated item, removing it",{event:e,itemId:r}),void this._deactivateItems([r]);if("persist"===i)return s.info("shown item promoted to persisted activation",{event:e,itemId:r}),this._persistActivation(r),void this._clearActivationTimestamps([r])}if(this._cancelEventToItems.has(e)){const i=this._getMatchingItems(e,t,Rf.Cancellation);i.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:i.map(e=>e.id)}),this._deactivateItems(i.map(e=>e.id)),i.forEach(e=>this._cancelPendingItem(e.id)))}if(!this._eventToItems.has(e))return;s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});const o=this._getMatchingItems(e,t,Rf.Activation);this._activateItems(o.map(e=>e.id))}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){if(0===e.length)return;const t=!!this._host.getSessionId(),i=[];for(const n of e)t&&this._shouldPersistArmedActivation(n)?this._persistActivation(n)&&this._recordActivationTimestamp(n):i.push(n);i.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...i])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}),this._notifyActivationChanged()}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);const t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){const t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));const i=this._getRawPersistedActivatedIds(),n=i.filter(e=>!t.has(e));n.length!==i.length&&(this._setActivatedItems(n),0===n.length&&this._clearActivationSession()),this._clearActivationTimestamps(e),this._notifyActivationChanged()}_notifyActivationChanged(){try{var e;null===(e=this._onActivationChanged)||void 0===e||e.call(this)}catch(e){this._getLogger().error("Error while handling activated items change",e)}}_getRawActivationTimestamps(){const e=this._getActivationTimestampsKey();if(!e)return{};const t=this._host.getProperty(e);return t&&"object"==typeof t?t:{}}_recordActivationTimestamp(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps();this._writeActivationTimestamps(ct(ct({},t),{},{[e]:Date.now()}))}_clearActivationTimestamps(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps(),i={};let n=!1;for(const[s,r]of Object.entries(t))e.includes(s)?n=!0:i[s]=r;n&&(Tt(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(!this._getPersistedActivatedIds().includes(e))return;const t=this._getRawActivationTimestamps()[e];return Ft(t)?t:void 0}_getRawPersistedActivatedIds(){const e=this._getActivatedKey();return this._host.getProperty(e)||[]}_getPersistedActivatedIds(){const e=this._getRawPersistedActivatedIds();if(0===e.length)return[];const t=this._host.getProperty(this._getActivatedSessionKey()),i=this._host.getSessionId();return i&&t===i?e:[]}_stampActivationSession(){const e=this._host.getSessionId();e&&this._setActivatedSession(e)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){const t=this._host.getProperty(this._getActivatedSessionKey());if(t&&t!==e){const e=this._getRawPersistedActivatedIds(),t=this._getRawActivationTimestamps();e.length>0&&(this._setActivatedItems([]),e.filter(e=>Ft(t[e])).forEach(e=>this._cancelPendingItem(e))),this._clearActivationSession(),this._clearAllActivationTimestamps(),e.length>0&&this._notifyActivationChanged()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter(e=>!this._isItemPermanentlyIneligible(e))}dispose(){var e,t,i;null===(e=this._sessionIdUnsubscribe)||void 0===e||e.call(this),this._sessionIdUnsubscribe=void 0,null===(t=this._captureHookUnsubscribe)||void 0===t||t.call(this),this._captureHookUnsubscribe=void 0,null===(i=this._actionMatcher)||void 0===i||i.dispose(),this._actionMatcher=void 0}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps(),this._notifyActivationChanged()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}},Ly=class extends Ay{constructor(e,t,i,n){var s;super({subscribeCapture(t){const i=e.onEvent(e=>t(e.event,e));return()=>i.dispose()},subscribeSession(t){const i=e.onSession(t);return()=>i.dispose()},getSessionId(){var t;return null===(t=e.session)||void 0===t?void 0:t.sessionId},getProperty:t=>e.kv.get(t),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(s=null==i?void 0:i.setElementSelectors)&&void 0!==s?s:(t,i)=>{var n;return null===(n=e.getExtension("autocapture"))||void 0===n?void 0:n.setElementSelectors(t,i)}},n),this._client=e,this._surveys=t,this._subscribeSession()}_getActivatedKey(){return F}_getActivatedSessionKey(){return A}_getActivationTimestampsKey(){return L}_writeActivationTimestamps(e){this._client.kv.set({[L]:e})}_clearActivationTimestampsStore(){this._client.kv.remove(L)}_shouldPersistArmedActivation(e){var t;let i;this._getItems(t=>{i=t.find(t=>t.id===e)});const n=null==i||null===(t=i.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds;return Ft(n)&&n>0}_getShownEventName(){return $f.SHOWN}_getItems(e){this._surveys.getSurveys(e)}_cancelPendingItem(e){this._surveys.cancelPendingSurvey(e)}_getLogger(){return qf}_setActivatedItems(e){this._client.kv.set({[F]:e})}_setActivatedSession(e){this._client.kv.set({[A]:e})}_clearActivatedSession(){this._client.kv.remove(A)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t,i){var n;if(e===$f.SENT&&!1===(null==i||null===(n=i.properties)||void 0===n?void 0:n.$survey_completed))return"ignore";let s;return this._getItems(e=>{s=e.find(e=>e.id===t)}),!s||dc(s)?e===$f.SHOWN?"consume":"ignore":e===$f.SHOWN?"persist":e===$f.DISMISSED||e===$f.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}};const Oy=(e,t)=>(null==e?void 0:e.then)?e.then(t):t(e),Dy="SDK is not enabled or survey functionality is not yet loaded",$y="Disabled. Not loading surveys.";var Ny=class{constructor(e){this._configSource=e,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyInitializationFailed=!1,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._disposed=!1,this._renderTimeouts=new Set,this.onRemoteConfig=e=>{if(this._disposed)return;if(this._config.disableSurveys)return;if(!e.ok)return this._surveyInitializationFailed=!0,this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),qf.warn("Remote config unavailable. Not loading surveys.");const t=e.config.surveys;if(Mt(t))return qf.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=Lt(t)?t:t.length>0,qf.info(`flags response received, isSurveysEnabled: ${this._isSurveysEnabled}`),this.loadIfEnabled()},this._notifyActiveMatchingSurveyCallbacks=e=>{this._activeMatchingSurveyCallbacks.slice().forEach(t=>this._notifyActiveMatchingSurveyCallback(t,e))}}setup(e){if(!this._disposed)return this._initializingClient=e,Oy(e.kv.initialize(),()=>{if(this._initializingClient!==e||this._disposed)return;this._initializingClient=void 0,this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())})}dispose(){var e,t,i,n,s;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,null===(t=this._surveyEventReceiver)||void 0===t||t.dispose(),this._surveyEventReceiver=null,null===(i=this._surveyManager)||void 0===i||null===(n=i.dispose)||void 0===n||n.call(i),this._surveyManager=null,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks.forEach(e=>{e.active=!1}),this._activeMatchingSurveyCallbacks=[],null===(s=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===s||s.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0,this._getSurveysInFlightPromise=null,this._renderTimeouts.forEach(e=>clearTimeout(e)),this._renderTimeouts.clear())}get _config(){return this._configSource.get()}getRenderContext(){if(!this._client)return;const e=this;return{client:this._client,get config(){return e._config},surveys:e}}initialize(){this.loadIfEnabled()}reset(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.clearInMemoryInProgressSurveyState)||void 0===t||t.call(e);try{var i;null===(i=this._surveyEventReceiver)||void 0===i||i.reset(),localStorage.removeItem("lastSeenSurveyDate");const e=[];for(let t=0;t<localStorage.length;t++){const i=localStorage.key(t);((null==i?void 0:i.startsWith("seenSurvey_"))||(null==i?void 0:i.startsWith("inProgressSurvey_")))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}loadIfEnabled(){if(this._disposed||!this._client)return;const e=this._config;if(this._surveyManager)return;if(this._isInitializingSurveys)return void qf.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void qf.info($y);if(e.cookielessMode&&this._client.isOptedOut)return void qf.info("Not loading surveys in cookieless mode without consent.");const t=this._configSource.getExtensions();if(!t)return void this._handleSurveyLoadError("PostHog Extensions not found.");if(xt(this._isSurveysEnabled)&&!e.advancedEnableSurveys)return;const i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0,this._surveyInitializationFailed=!1;try{const e=t.generateSurveys;if(e)return this._completeSurveyInitialization(e,i),void(this._isInitializingSurveys=!1);const n=t.loadExternalDependency;if(!n)return this._handleSurveyLoadError(M),void(this._isInitializingSurveys=!1);n(e=>{try{if(this._disposed)return;const t=this._configSource.getExtensions();e||!(null==t?void 0:t.generateSurveys)?this._handleSurveyLoadError("Could not load surveys script",e):this._completeSurveyInitialization(t.generateSurveys,i)}finally{this._isInitializingSurveys=!1}})}catch(e){throw this._isInitializingSurveys=!1,this._handleSurveyLoadError("Error initializing surveys",e),e}}_completeSurveyInitialization(e,t){var i;if(this._disposed)return;this._surveyManager=e(t),this._surveyEventReceiver=this._createEventReceiver(this._client,this._notifyActiveMatchingSurveyCallbacks);const n=null===(i=this._client)||void 0===i?void 0:i.kv.get(R);n&&this._registerEventOrActionBasedSurveys(n),qf.info("Surveys loaded successfully"),this._startActiveMatchingSurveyConditions(),this._notifyActiveMatchingSurveyCallbacks(),this._notifySurveyCallbacks({isLoaded:!0})}_createEventReceiver(e,t){return new Ly(e,this,void 0,t)}_handleSurveyLoadError(e,t){this._surveyInitializationFailed=!0,qf.error(e,t),this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:e}),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=!1){if(this._disposed)return;const i=this._client;if(!i)return e([],{isLoaded:!1,error:Dy});if(this._config.disableSurveys)return qf.info($y),e([]);const n=i.kv.get(R);if(n&&!t)return e(n,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)return void this._getSurveysInFlightPromise.then(({surveys:t,context:i})=>{this._disposed||e(t,i)}).catch(e=>qf.error("Error in survey callback",e));const s=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this._config.requestTimeoutMs}).then(e=>{try{return this._handleSurveyResponse(i,e)}catch(e){return qf.error("Error processing surveys response",e),this._handleSurveyResponse(i,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(i,{statusCode:0,error:e}));this._getSurveysInFlightPromise=s;const r=()=>{this._getSurveysInFlightPromise===s&&(this._getSurveysInFlightPromise=null)};s.then(t=>{r(),this._disposed||(this._notifyActiveMatchingSurveyCallbacks(t.context),e(t.surveys,t.context))},r).catch(e=>qf.error("Error in survey callback",e))}_handleSurveyResponse(e,t){if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:Dy}};const i=t.statusCode;if(200!==i||!t.json){const e=`Surveys API could not be loaded, status: ${i}`;return 0!==i?qf.error(e):t.error||qf.warn(e),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this._lastSurveyRefreshFailedAt=null;const n=t.json.surveys||[];return e.kv.set({[R]:n,[P]:Date.now()}),this._registerEventOrActionBasedSurveys(n),{surveys:n,context:{isLoaded:!0}}}_registerEventOrActionBasedSurveys(e){const t=e.filter(e=>Uf(e)&&(uc(e)||zf(e)));this._registerSurveyTriggers(t)}_registerSurveyTriggers(e){var t;null===(t=this._surveyEventReceiver)||void 0===t||t.replace(e)}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e;const t=null===(e=this._client)||void 0===e?void 0:e.kv.get(P);return Ft(t)&&Date.now()-t>3e5}_isSurveyRefreshBackingOff(){return Ft(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;const n={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};Vf(n);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}_notifySurveyCallbacks(e){for(const t of this._surveyCallbacks){if(this._disposed)return;try{e.isLoaded?this.getSurveys(t):t([],e)}catch(e){qf.error("Error in survey callback",e)}}}getActiveMatchingSurveys(e,t=!1){if(!Mt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);qf.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t;if(this._disposed)return()=>{};const i={callback:e,active:!0,revision:0};this._activeMatchingSurveyCallbacks.push(i),this._startActiveMatchingSurveyConditions();const n=null===(t=this._client)||void 0===t?void 0:t.kv.get(R);return this._config.disableSurveys||!this._surveyManager&&this._surveyInitializationFailed&&!this._isInitializingSurveys||!n&&!Mt(this._lastSurveyRefreshFailedAt)&&!this._getSurveysInFlightPromise?this._notifyActiveMatchingSurveyCallback(i,{isLoaded:!1}):this._surveyManager&&this._notifyActiveMatchingSurveyCallback(i),()=>{var e;i.active=!1,this._activeMatchingSurveyCallbacks=this._activeMatchingSurveyCallbacks.filter(e=>e!==i),0===this._activeMatchingSurveyCallbacks.length&&(null===(e=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===e||e.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0)}}_startActiveMatchingSurveyConditions(){var e,t,i;this._surveyManager&&this._activeMatchingSurveyCallbacks.length>0&&(null!==(e=this._activeMatchingSurveyConditionsUnsubscribe)&&void 0!==e||(this._activeMatchingSurveyConditionsUnsubscribe=null===(t=(i=this._configSource).onMatchingConditionsChanged)||void 0===t?void 0:t.call(i,this._notifyActiveMatchingSurveyCallbacks)))}_notifyActiveMatchingSurveyCallback(e,t){if(this._disposed||!e.active)return;const i=++e.revision,n=n=>{if(!this._disposed&&e.active&&i===e.revision)try{const i=null!=t?t:{isLoaded:!0},s=JSON.stringify([n,i]);if(s===e.lastResult)return;e.lastResult=s,e.callback(n,i)}catch(e){qf.error("Error in active matching surveys callback",e)}};try{t&&!t.isLoaded?n([]):this.getActiveMatchingSurveys(n)}catch(e){qf.error("Error in active matching surveys callback",e)}}_getSurveyById(e){let t=null;return this.getSurveys(i=>{var n;t=null!==(n=i.find(t=>t.id===e))&&void 0!==n?n:null}),t}_checkSurveyEligibility(e){if(Mt(this._surveyManager))return{eligible:!1,reason:Dy};const t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){var t;if(!(null===(t=this._client)||void 0===t?void 0:t.canCapture))return{eligible:!1,reason:Hf};if(Mt(this._surveyManager))return{eligible:!1,reason:Dy};const i="string"==typeof e?this._getSurveyById(e):e;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Mt(this._surveyManager))return qf.warn("init was not called"),{visible:!1,disabledReason:Dy};const t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Mt(this._surveyManager)?(qf.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Dy})):new Promise(i=>{this.getSurveys(t=>{var n;const s=null!==(n=t.find(t=>t.id===e))&&void 0!==n?n:null;if(s){const e=this._checkSurveyRenderability(s);i({visible:e.eligible,disabledReason:e.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var n,s,r;if(!(null===(n=this._client)||void 0===n?void 0:n.canCapture))return;if(Mt(this._surveyManager))return void qf.warn("init was not called");const o="string"==typeof e?this._getSurveyById(e):e;if(!(null==o?void 0:o.id))return void qf.warn("Survey not found");if(!Gf.includes(o.type))return void qf.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const a=null===(s=typeof document>"u"?void 0:document)||void 0===s?void 0:s.querySelector(t);if(a){if(null===(r=o.appearance)||void 0===r?void 0:r.surveyPopupDelaySeconds){qf.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const e=setTimeout(()=>{var t,n,s;this._renderTimeouts.delete(e),!this._disposed&&(null===(t=this._client)||void 0===t?void 0:t.canCapture)&&(qf.info(`Rendering survey ${o.id} with delay of ${null===(n=o.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(o,a,i),qf.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this._renderTimeouts.add(e)}this._surveyManager.renderSurvey(o,a,i)}else qf.warn("Survey element not found")}displaySurvey(e,t){var i,n;if(!(null===(i=this._client)||void 0===i?void 0:i.canCapture))return;if(Mt(this._surveyManager))return void qf.warn("init was not called");const s=this._getSurveyById(e);if(!s)return void qf.warn("Survey not found");let r=s;if((null===(n=s.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds)&&t.ignoreDelay&&(r=ct(ct({},s),{},{appearance:ct(ct({},s.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==Bf.Popover&&t.initialResponses&&qf.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){const e=this._checkSurveyEligibility(s);if(!e.eligible)return void qf.warn("Survey is not eligible to be displayed: ",e.reason)}t.displayType!==Bf.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}cancelPendingSurvey(e){Mt(this._surveyManager)?qf.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e)}},By=class{constructor(e){this.disabled=!1===e;const t=Et(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;const n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(t-n.y)<this.thresholdPx&&this.timeoutMs>i-n.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}};const qy=()=>typeof window>"u"?void 0:window,Hy=()=>typeof document>"u"?void 0:document,Uy="$copy_autocapture",zy=["password","hidden","file","checkbox","button","submit","reset","image"],Wy=Br("[AutoCapture]");function jy(e,t){return t.length>e?t.slice(0,e)+"...":t}function Vy(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!uo(t));return t}function Gy(e,{e:t,maskAllElementAttributes:i,maskAllText:n,elementAttributeIgnoreList:s,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!uo(e))return{props:{}};const c=[e],u=new Set([e]);let d=e;for(;d.parentNode&&!ho(d,"body")&&1e3>c.length;){if(go(d.parentNode)){const e=d.parentNode.host;if(u.has(e))break;u.add(e),c.push(e),d=e;continue}if(!uo(d.parentNode))break;if(u.has(d.parentNode))break;u.add(d.parentNode),c.push(d.parentNode),d=d.parentNode}const h="click"===t.type&&"http://www.w3.org/2000/svg"===e.namespaceURI?c.findIndex(e=>ho(e,"button")||ho(e,"a")):-1;h>0&&(n=n||c.slice(0,h+1).some(e=>!Ho(e)||Uo(e)));const p=[],g={};let _,f=!1,v=!1;if(Hr(c,e=>{const t=Ho(e);if(ho(e,"a")&&!i&&!(null==s?void 0:s.includes("href"))){const i=e.getAttribute("href");f=!!(t&&i&&Jo(i))&&(o?cn(i):i)}ft(vo(e),"ph-no-capture")&&(v=!0),p.push(function(e,t,i,n,s=!1){const r=e.tagName.toLowerCase(),o={tag_name:r};So.indexOf(r)>-1&&!i&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?jy(1024,Yo(e)):jy(1024,yo(e)));const a=vo(e);t||(null==n?void 0:n.includes("class"))||0>=a.length||(o.classes=a.filter(function(e){return""!==e})),Hr(e.attributes,function(i){var r;if((!Uo(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&!(null==n?void 0:n.includes(i.name))&&!t&&Jo(i.value)&&(!It(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let e=i.value;"class"===i.name&&(e=_o(e).join(" ")),o["attr__"+i.name]=jy(1024,"href"===i.name&&s?cn(e):e)}});let l=1,c=1,u=e;for(;u=Vy(u);)l++,u.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o}(e,i,n,s,o)),Hr(function(e){if(!Ho(e))return{};const t={};return Hr(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),n=e.value;i&&n&&Jo(n)&&(t[i]=n)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(g,t)||(g[t]=e)})}),v)return{props:{},explicitNoCapture:v};if(h>0&&(e=c[h],p.splice(0,h)),n||(p[0].$el_text=ho(e,"a")||ho(e,"button")?Yo(e):yo(e)),f){var m,y;p[0].attr__href=f;const e=null===(m=Yr(f))||void 0===m?void 0:m.host,t=null===(y=qy())||void 0===y||null===(y=y.location)||void 0===y?void 0:y.host;e&&t&&e!==t&&(_=f)}return{props:Ur((S=t.type,{$event_type:S,$ce_version:1}),r?{}:{$elements:p},{$elements_chain:(b=p,kt(b)?function(e){return e.map(e=>{var t,i;let n="";if(e.tag_name&&(n+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)n+=`.${t.replace(/"/g,"")}`}const s=ct(ct(ct(ct({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return zr(s).sort(([e],[t])=>function(e,t){return t>e?-1:e>t?1:0}(e,t)).forEach(([e,t])=>r[Xo(e.toString())]=Xo(t.toString())),n+=":",n+=zr(r).map(([e,t])=>`${e}="${t}"`).join(""),n}).join(";")}(function(e){return e.map(e=>{var t,i;const n={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:ea(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return zr(e).filter(([e])=>0===e.indexOf("attr__")).forEach(([e,t])=>n.attributes[e]=t),n})}(b)):"")},(null===(a=p[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(l=p[0])||void 0===l?void 0:l.$el_text}:{},_&&"click"===t.type?{$external_click_url:_}:{},g),target:e};var b,S}const Qy="autocapture";var Ky=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!Ho(e))return!0;const i=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:Eo,n=new Set;let s=e;for(;s;){if(n.size>=1e3||n.has(s))return!0;n.add(s);const e=s,t=vo(e);if(ft(t,"ph-no-capture")||ft(t,"ph-sensitive")||Uo(e)||i.some(t=>wo(e,t)))return!0;const r=s.parentNode;s=go(r)?r.host:r&&uo(r)?r:null}return!1}_trackPointer(e){if(!this.isEnabled||"pointercancel"===e.type)return void this._clearPointer();if("pointerdown"===e.type){var t;this._clearPointer();const i=bo(e);return void(e.isPrimary&&0===e.button&&!e.ctrlKey&&i&&uo(i)&&(this._pointerDown={target:i,excluded:this._isExcludedPointerTarget(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null===(t=this._client)||void 0===t?void 0:t.distinctId}))}const i=this._pointerDown;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this._clearPointer():"pointerup"===e.type&&(i.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}_recoverClickTarget(e){var t;const i=this._pointerDown;this._clearPointer();const n=bo(e);if((null==i?void 0:i.released)&&i.target.isConnected&&i.distinctId===(null===(t=this._client)||void 0===t?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||"touch"===e.pointerType||"pen"===e.pointerType)&&0===e.button&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&n&&(ho(n,"html")||ho(n,"body"))){var s,r,o;if(i.excluded)return null;const e=null!==(s=this._refreshConfig().css_selector_ignorelist)&&void 0!==s?s:Eo;return[n,null===(r=Hy())||void 0===r?void 0:r.documentElement,null===(o=Hy())||void 0===o?void 0:o.body].some(t=>{if(!t)return!1;const i=vo(t);return ft(i,"ph-no-capture")||ft(i,"ph-sensitive")||!Ho(t)||Uo(t)||e.some(e=>wo(t,e))})?null:i.target}}constructor(e){this._configSource=e,this.name=Qy,this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementSelectorsByOwner=new Map,this._elementsChainAsString=!1,this._config={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this._disposed=!1,this._configSource.refresh(this._config),this.rageclicks=new By(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.startIfEnabled())}dispose(){var e;this._disposed||(this._disposed=!0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._elementSelectorsByOwner.clear(),this._elementSelectors=null,this._removeDomEventHandlers())}_refreshConfig(){return this._configSource.refresh(this._config),this._config}_compileUrlPatterns(){var e,t;return this._refreshConfig(),this._config.url_allowlist=null===(e=this._config.url_allowlist)||void 0===e?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null===(t=this._config.url_ignorelist)||void 0===t?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){const e=qy(),t=Hy();if(!this.isBrowserSupported())return void Wy.info("Disabling Automatic Event Collection because this browser is not supported");if(!e||!t)return;this._listenerWindow=e,this._listenerDocument=t;const i=this._domEventHandler=t=>{t=t||(null==e?void 0:e.event);try{if("blur"===t.type)return void this._clearPointer();if(0===t.type.indexOf("pointer"))return void this._trackPointer(t);const e="click"===t.type?this._recoverClickTarget(t):void 0;if(Pt(e))return;this._captureEvent(t,"$autocapture",e)}catch(e){Wy.error("Failed to capture event",e)}};if(Kr(e,"blur",i),Kr(t,"submit",i,{capture:!0}),Kr(t,"change",i,{capture:!0}),Kr(t,"click",i,{capture:!0}),Hr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{Kr(t,e,i,{capture:!0})}),this._refreshConfig().capture_copied_text){const i=this._copiedTextHandler=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t,Uy)}catch(e){Wy.error("Failed to capture clipboard event",e)}};Kr(t,"copy",i,{capture:!0}),Kr(t,"cut",i,{capture:!0}),Kr(t,"paste",i,{capture:!0})}}_removeDomEventHandlers(){const e=this._listenerWindow,t=this._listenerDocument;this._clearPointer(),this._domEventHandler&&(null==e||e.removeEventListener("blur",this._domEventHandler),Hr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==t||t.removeEventListener(e,this._domEventHandler,!0)}),null==t||t.removeEventListener("submit",this._domEventHandler,!0),null==t||t.removeEventListener("change",this._domEventHandler,!0),null==t||t.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==t||t.removeEventListener("copy",this._copiedTextHandler,!0),null==t||t.removeEventListener("cut",this._copiedTextHandler,!0),null==t||t.removeEventListener("paste",this._copiedTextHandler,!0),this._copiedTextHandler=void 0),this._listenerWindow=void 0,this._listenerDocument=void 0,this._initialized=!1}startIfEnabled(){this.isEnabled||this._clearPointer(),!this._disposed&&this._client&&this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(this._disposed)return;if(this._hasReceivedConfigResponse=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);const i=t.autocapture_opt_out;var n;Lt(i)&&(null===(n=this._client)||void 0===n||n.kv.set("$autocapture_disabled_server_side",i),this._isDisabledServerSide=i),this.startIfEnabled()}setElementSelectors(e,t=this){if(this._disposed)return;e.size?this._elementSelectorsByOwner.set(t,new Set(e)):this._elementSelectorsByOwner.delete(t);const i=new Set;this._elementSelectorsByOwner.forEach(e=>{e.forEach(e=>i.add(e))}),this._elementSelectors=i}getElementSelectors(e,t){var i;const n=[];return null===(i=this._elementSelectors)||void 0===i||i.forEach(i=>{var s;const r=null===(s=Hy())||void 0===s?void 0:s.querySelectorAll(i);null==r||r.forEach(s=>{e!==s&&t!==s||ft(n,i)||n.push(i)})}),n}get isEnabled(){var e,t;if(this._disposed)return!1;const i=null===(e=this._client)||void 0===e?void 0:e.kv.get(I),n=this._isDisabledServerSide,s=this._refreshConfig();if(!s.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;const r=s.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(Pt(n)&&!Lt(i)&&!r)return!1;const o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!s.enabled&&!o}_captureEvent(e,t="$autocapture",i){if(!this.isEnabled)return void this._clearPointer();let n=i||bo(e);po(n)&&(n=n.parentNode||null);const s=this._compileUrlPatterns();var r;"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&s.rageclick&&(null===(r=this.rageclicks)||void 0===r?void 0:r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime()))&&No(n,s.rageclick)&&this._captureEvent(e,"$rageclick",i);const o=t===Uy,a=o?ct(ct({},s),{},{dom_event_allowlist:void 0}):s;if(n&&function(e,t,i,n,s,r){var o;const a=typeof window>"u"?void 0:window;if(!a||Bo(e))return!1;if((null==i?void 0:i.url_allowlist)&&!fo(i.url_allowlist,r))return!1;if((null==i?void 0:i.url_ignorelist)&&fo(i.url_ignorelist,r))return!1;if(null==i?void 0:i.dom_event_allowlist){const e=i.dom_event_allowlist;if(e&&!e.some(e=>t.type===e))return!1}const{parentIsUsefulElement:l,targetElementList:c}=qo(e,n);if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(xt(i))return!0;for(const t of e)if(i.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,i))return!1;if(!ko(c,null==i?void 0:i.css_selector_allowlist))return!1;if(ko(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Eo))return!1;try{const i=a.getComputedStyle(e);if(i&&"pointer"===i.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}const u=e.tagName.toLowerCase();switch(u){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 l?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(So.indexOf(u)>-1||"true"===e.getAttribute("contenteditable"))}}(n,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:s.getCurrentUrl}})){var l;const{props:i,explicitNoCapture:r,target:o}=Gy(n,{e:e,maskAllElementAttributes:s.maskAllElementAttributes,maskAllText:s.maskAllText,elementAttributeIgnoreList:s.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:s.disableCaptureUrlHashes});if(r)return!1;const a=this.getElementSelectors(n,o);if(a&&a.length>0&&(i.$element_selectors=a),t===Uy){const t=e.type||"clipboard";if("paste"!==t){var c,u;const e=null===(c=qy())||void 0===c||null===(c=c.getSelection())||void 0===c?void 0:c.toString(),t=mo(e);if(!t)return!1;i.$selected_content=t,i.$clipboard_text_length=null!==(u=null==e?void 0:e.length)&&void 0!==u?u:0}i.$copy_type=t}if("$autocapture"===t&&"change"===e.type&&s.capture_value_css_selector_allowlist&&!s.maskAllText&&(ho(d=n,"input")?!ft(zy,d.type):ho(d,"textarea")||ho(d,"select")&&!d.multiple)&&function(e,t){var i;if(!Ho(e))return!1;const n=null!==(i=t.css_selector_ignorelist)&&void 0!==i?i:Eo,s=new Set;let r=e;for(ho(e,"select")&&(r=e.options[e.selectedIndex]||e);r;){const e=r,t=vo(e);if(s.size>=1e3||s.has(r)||ft(t,"ph-sensitive")||ft(t,"ph-no-capture")||n.some(t=>wo(e,t)))return!1;s.add(r);const i=r.assignedSlot||r.parentNode;r=go(i)?i.host:i&&uo(i)?i:null}return!0}(n,s)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){const e=s.capture_value_css_selector_allowlist;let t=!1;try{t=Ct(e)?!!e(n):kt(e)&&e.some(e=>wo(n,e))}catch(e){Wy.error("capture_value_css_selector_allowlist threw",e)}t&&(i.$input_value=n.value)}return null===(l=this._client)||void 0===l||l.capture(t,i),!0}var d}isBrowserSupported(){var e;return Ct(null===(e=Hy())||void 0===e?void 0:e.querySelectorAll)}};const Jy="featureFlags",Yy="logs",Zy=!!o||!!r,Xy=new WeakMap,eb="text/plain";let tb=0,ib=!1;const nb=(e,t)=>{const[i,n]=e.split("#"),[s,r]=i.split("?");if(!r)return e;const o=r.split("&").filter(e=>e.split("=")[0]!==t).join("&");return`${s}${o?`?${o}`:""}${n?`#${n}`:""}`},sb=(e,t,i=!0)=>{var n;const[s,r]=e.split("?"),o=ct({},t),a=null!==(n=null==r?void 0:r.split("&").map(e=>{var t;const[n,s]=e.split("="),r=i&&null!==(t=o[n])&&void 0!==t?t:s;return delete o[n],`${n}=${r}`}))&&void 0!==n?n:[],l=no(o);return l&&a.push(l),a.length>0?`${s}?${a.join("&")}`:s},rb=e=>{if(e._encodedBody)return e._encodedBody;const{data:t,compression:i}=e;if(!t)return;if(i===Iy.GZipJS){const e=ml(yl(io(t)),{mtime:0});return{contentType:eb,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(i===Iy.Base64){const e=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(io(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:io(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const n=io(t);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}},ob=e=>{const t=()=>"sendBeacon"===e.transport?{url:sb(e.url,{compression:Iy.Base64}),encodedBody:rb(ct(ct({},e),{},{compression:Iy.Base64,_encodedBody:void 0}))}:{url:nb(e.url,"compression"),encodedBody:rb(ct(ct({},e),{},{compression:void 0,_encodedBody:void 0}))};let i;try{i=rb(e)}catch(i){if(ds(e.compression,so(e.url,"compression")))return Nr.error("Failed to gzip request body, sending uncompressed payload",i),t();throw i}return i&&ds(e.compression,so(e.url,"compression"))&&!((n=i.body)instanceof ArrayBuffer?us(new Uint8Array(n)):ArrayBuffer.isView(n)&&us(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(ib=!0,t()):{url:e.url,encodedBody:i};var n},ab=e=>{try{return ob(e)}catch(i){var t;return Nr.error(i),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0,error:i}))}},lb=function(){var e=rt(function*(e){const t=yield vs(io(e.data),Yl.DEBUG,{rethrow:!0});if(!t)return e;const i=yield t.arrayBuffer();return ct(ct({},e),{},{_encodedBody:{contentType:eb,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),cb=e=>ln("AbortError","PostHog request timed out"+(e?` after ${e}ms`:"")),ub=/Failed to fetch|NetworkError|Load failed/i,db=e=>"TypeError"===(null==e?void 0:e.name)&&ub.test((null==e?void 0:e.message)||""),hb=e=>{try{const t=function(e,t=Date.now(),i=3e5){if("string"!=typeof e||!e)return;const n=e.trim(),s=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(",")).trim():n;if(/^\d+$/.test(s)){const e=1e3*Math.min(Number(s),i/1e3);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const r=/^\w{3} \w{3} /.test(s)?s+" GMT":s,o=Date.parse(r)-t;return Number.isFinite(o)&&o>0?Math.min(o,i):void 0}(e());return xt(t)?void 0:Math.min(t,3e4)}catch(e){return}},pb=e=>{const t=ab(e);if(!t)return;const i=new o;Xy.set(i,!0);const{url:n,encodedBody:s}=t;i.open(e.method||"GET",n,!0);const{contentType:r,body:a}=null!=s?s:{};Hr(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout);let l=!1;i.ontimeout=()=>{l=!0},i.onloadend=()=>{var t;if(l){var n;const t=cb(e.timeout);return Nr.warn(t),void(null===(n=e.callback)||void 0===n||n.call(e,{statusCode:0,error:t}))}const s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,s,hb(()=>i.getResponseHeader("Retry-After")))},i.send(a)},gb=e=>{const t=ab(e);if(!t)return;const{url:i,encodedBody:n}=t,{contentType:s,body:o,estimatedSize:l}=null!=n?n:{},c=new Headers;Hr(e.headers,function(e,t){c.append(t,e)}),s&&c.append("Content-Type",s);let u=null,d=!1;if(a){const t=new a;u={signal:t.signal,timeout:setTimeout(()=>{d=!0;try{t.abort(cb(e.timeout))}catch(e){p(e)}},e.timeout)}}let h=!1;const p=t=>{var i;h||(h=!0,d&&"AbortError"===(null==t?void 0:t.name)||db(t)?Nr.warn(t):Nr.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,error:t}))};let g=0;const _=()=>{tb-=g,g=0,u&&clearTimeout(u.timeout)};try{const t=ct({method:(null==e?void 0:e.method)||"GET",headers:c,referrerPolicy:"strict-origin",body:o,signal:null==u?void 0:u.signal},e.fetchOptions),n=null!=l?l:xt(o)?0:void 0;t.keepalive="POST"===t.method&&!e._keepaliveDisabled&&!1!==t.keepalive&&t.body===o&&!xt(n)&&n>=0&&52428.8>tb+n,t.keepalive&&(g=n,tb+=g),r(i,t).then(t=>t.text().then(i=>{var n;if(h)return;const s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){Nr.error(e)}h=!0,_(),null===(n=e.callback)||void 0===n||n.call(e,s,hb(()=>t.headers.get("Retry-After")))})).catch(e=>{_(),p(e)}).finally(_)}catch(e){_(),p(e)}},_b=e=>{try{var t;const{url:n,encodedBody:s}=ob(e),{contentType:o,body:a,estimatedSize:l}=null!=s?s:{};if(!a)return;const c=a instanceof Blob?a:new Blob([a],{type:o});if(i.sendBeacon(n,c))return;const u=kt(e.data)?e.data:null===(t=e.data)||void 0===t?void 0:t.batch;if(kt(u)&&u.length>1&&(null!=l?l:0)>16384){const t=Math.ceil(u.length/2),i=t=>kt(e.data)?t:ct(ct({},e.data),{},{batch:t});return _b(ct(ct({},e),{},{data:i(u.slice(0,t))})),void _b(ct(ct({},e),{},{data:i(u.slice(t))}))}Nr.warn(`Beacon of ~${null!=l?l:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?gb(ct(ct({},e),{},{_keepaliveDisabled:!0})):pb(e)}catch(e){Nr.warn("Beacon send failed",e)}},fb=(e,t,i,n)=>{const s="query"===n?"POST"===t?"sent_at":"_":void 0;return sb(i===Iy.GZipJS?nb(e,"compression"):e,ct(ct({},s?{[s]:Date.now().toString()}:{}),i===Iy.GZipJS?{}:{compression:i}))},vb=(()=>{const e=[];return r&&e.push({transport:"fetch",method:gb}),o&&e.push({transport:"XHR",method:pb}),(null==i?void 0:i.sendBeacon)&&e.push({transport:"sendBeacon",method:_b}),e})(),mb=()=>{var t;return(null==e||null===(t=e.performance)||void 0===t?void 0:t.now)?e.performance.now():Date.now()},yb=[50,75,100,150,200,300,400,500,750,1e3,1500,2e3,3e3,5e3,1e4];var bb=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);const i={};for(const n of e){const e=null==t?void 0:t.get_property(n);xt(e)||(i[n]=e)}return i}set(e,t){var i;null===(i=this._instance.persistence)||void 0===i||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null===(t=this._instance.persistence)||void 0===t||t.unregister(e)}},Sb=class{constructor(e){this.instance=e,this._logger=Nr,this.kv=new bb(e),this.onSession=e=>Ry(this.instance.onSessionId(t=>{try{e(t)}catch(e){this._logger.error("Browser extension session listener failed",e)}})),this.onEvent=e=>Ry(this.instance._addCaptureHook((t,i)=>{if(i)try{e({event:t,properties:i.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{const t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on("extensionsRemoteConfig",t);return this.instance._lastRemoteConfig&&t(this.instance._lastRemoteConfig),Ry(i)}}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){const e=this.instance.get_property(N);return"string"==typeof e?e:void 0}get library(){return{name:Yl.LIB_NAME,version:Yl.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,n,s;const r=null===(e=this.instance.sessionManager)||void 0===e?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(n=null==r?void 0:r.sessionStartTimestamp)&&void 0!==n?n:0,lastActivityTimestamp:null!==(s=null==r?void 0:r.lastActivityTimestamp)&&void 0!==s?s:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return Ct(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get isRateLimited(){var e;return!!(null===(e=this.instance.rateLimiter)||void 0===e?void 0:e.isClientRateLimited)}get projectToken(){return this.instance.config.token}getExtension(e){let t;switch(e){case Jy:case ef:t=this.instance.featureFlags;break;case Yy:t=this.instance.logs;break;case"surveys":t=this.instance.surveys;break;case Qy:t=this.instance.autocapture}return t}capture(e,t,i){if(!i)return this._notRateLimited(this.instance.capture(e,t));const n=ct({timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce},"unload"===i.delivery?{transport:"sendBeacon",send_instantly:!0}:{});return this._notRateLimited(this.instance.capture(e,t,n))}_notRateLimited(e){var t;return!xt(e)||!(null===(t=this.instance.rateLimiter)||void 0===t?void 0:t.lastEventRateLimited)}registerDynamicEventProperties(e){return Ry(this.instance._registerExtensionEventProperties(e))}sendRequest(e){var t=this;return rt(function*(e,i={}){var n;const s=null!==(n=i.target)&&void 0!==n?n:"api",r=i.query?sb(e,i.query):e,o=t.instance.requestRouter.endpointFor(s,r),a={method:i.method,url:o,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:"flags"===i.target&&"best-available"===i.compression?dt.Base64:void 0,timestampMode:i.sentAt};return"api"===s&&"/i/v1/logs"===e&&(a.batchKey="logs"),"sendBeacon"===i.transport?(t.instance._send_request(a),{statusCode:202}):new Promise(e=>{var i;if(a.callback=e,"flags"===s&&(null===(i=t.instance.config.metrics)||void 0===i?void 0:i.flags)){let i;a.onDispatch=()=>{i=mb()},a.callback=n=>{xt(i)||t._recordFlagsDuration(o,n,mb()-i),e(n)}}t.instance._send_request(a)})}).apply(this,arguments)}_recordFlagsDuration(e,t,i){try{var n,s,r;const o=t.statusCode||void 0,a={"server.address":(null!==(n=null===(s=Yr(e))||void 0===s?void 0:s.hostname)&&void 0!==n?n:e).replace(/^\[(.*)\]$/,"$1")};o&&(a["http.response.status_code"]=o);const l=((e,t)=>e?400>e?void 0:String(e):"AbortError"===(null==t?void 0:t.name)?"timeout":"_OTHER")(o,t.error);l&&(a["error.type"]=l);const c=Ec();c&&(a["client.timezone"]=c),null===(r=this.instance.metrics)||void 0===r||r.histogram("posthog.flags.request.duration",i,{unit:"ms",attributes:a,bounds:yb})}catch(e){Nr.error("Failed to record the /flags request duration",e)}}},wb=class{constructor(e){this._instance=e}get(){var e,t,i,n;const s=null===(e=this._instance)||void 0===e?void 0:e.config;return{disableSurveys:!!(null==s?void 0:s.disable_surveys),cookielessMode:!!(null==s?void 0:s.cookieless_mode),advancedEnableSurveys:!!(null==s?void 0:s.advanced_enable_surveys),requestTimeoutMs:null!==(t=null==s?void 0:s.surveys_request_timeout_ms)&&void 0!==t?t:1e4,prefillFromUrl:!!(null==s||null===(i=s.surveys)||void 0===i?void 0:i.prefillFromUrl),automaticDisplay:!(null==s?void 0:s.disable_surveys_automatic_display),featureFlagEvaluation:!(null==s?void 0:s.advanced_disable_feature_flags),overrideLanguage:null==s?void 0:s.override_display_language,prepareStylesheet:null==s?void 0:s.prepare_external_dependency_stylesheet,get_current_url:null==s?void 0:s.get_current_url,uiHost:null===(n=this._instance)||void 0===n||null===(n=n.requestRouter)||void 0===n?void 0:n.endpointFor("ui","")}}getExtensions(){const e=null==d?void 0:d.__PosthogExtensions__;if(!e||!this._instance)return;const t=this._instance,{generateSurveys:i,loadExternalDependency:n}=e;return{generateSurveys:i?e=>i(t,e):void 0,loadExternalDependency:n?e=>n(t,"surveys",e):void 0}}onMatchingConditionsChanged(t){var i,n;const s=null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook(e=>{"$pageview"!==e&&e!==$f.SHOWN&&e!==$f.DISMISSED&&e!==$f.SENT||t()}),r=()=>t();Kr(e,"PHSurveyShown",r);let o=!1;const a=null===(n=this._instance)||void 0===n?void 0:n.onFeatureFlags(()=>{o&&t()});return o=!0,()=>{o=!1,null==s||s(),null==a||a(),null==e||e.removeEventListener("PHSurveyShown",r)}}};const kb=new WeakMap,Cb=(e,t)=>{const i=function(e){var t;const i=new wb(e);if(!e)return{get config(){return i.get()}};if(null===(t=e.surveys)||void 0===t?void 0:t.getRenderContext)return e.surveys.getRenderContext();let n=kb.get(e);return n||(n={client:new Sb(e),get config(){return i.get()},surveys:e.surveys},kb.set(e,n)),n}(e);return i?function(e,t){if(typeof document>"u"||typeof window>"u")return;const i=new by(e);return!1===e.config.automaticDisplay?(qf.info("Surveys automatic display is disabled. Skipping call surveys and evaluate display logic."),i):!1===t?(qf.info("There are no surveys to load or Surveys is disabled in the project settings."),i):(i.startAutomaticDisplay(),i)}(i,t):void 0};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.generateSurveys=Cb,d.extendPostHogWithSurveys=Cb;const Eb=e=>{for(;null==e?void 0:e.__rrweb_original__;)e=e.__rrweb_original__;return e},Tb=1e4,xb=(e,t,i)=>i.remaining>0?t.length>i.remaining?(e.push(t.slice(0,i.remaining)),i.remaining=0,i.truncated=!0,!1):(e.push(t),i.remaining-=t.length,!0):(i.truncated=!0,!1),Ib=(e,t,i)=>{const n=JSON.stringify(e);if(i.remaining>=n.length)return xb(t,n,i);if(i.truncated=!0,2>i.remaining)return!1;let s=0,r=Math.min(e.length,i.remaining-2);for(;r>s;){const t=Math.ceil((s+r)/2);JSON.stringify(e.slice(0,t)).length>i.remaining?r=t-1:s=t}return xb(t,JSON.stringify(e.slice(0,s)),i)},Rb=e=>void 0!==e&&"function"!=typeof e&&"symbol"!=typeof e&&"bigint"!=typeof e,Pb=(e,t,i)=>{if(!i.truncated){if(i.keysRemaining-=1,i.sizeRemaining-=String(t).length+e.length,0>=i.keysRemaining||0>=i.sizeRemaining)return i.truncated=!0,void(i.result.attributes_truncated=!0);i.result[e]=t}},Mb=(e,t,i)=>{if(!i.truncated)if(Et(e)){if(i.seen.has(e))return void Pb(t||"circular","[Circular]",i);i.seen.add(e);try{for(const n in e)try{if(!{}.hasOwnProperty.call(e,n))continue;if(Mb(e[n],t?`${t}.${n}`:n,i),i.truncated)break}catch(e){continue}}catch(e){}}else Pb(t,e,i)},Fb=(e,t,i,n,s=!1,r)=>{if(!Rb(e))return!s||xb(t,"null",i);if(Pt(e)||(e=>{try{return Ft(e)||Lt(e)}catch(e){return!1}})(e))return xb(t,JSON.stringify(e),i);if("string"==typeof e)return Ib(e,t,i);if(!Et(e)&&!kt(e))return xb(t,JSON.stringify(e),i);if(n.has(e))return Ib("[Circular]",t,i);n.add(e);try{const r=e.toJSON;if(Ct(r))return Fb(r.call(e),t,i,n,s)}catch(e){}try{const n={}.toString.call(e);if("[object String]"===n)return Ib(String(e.valueOf()),t,i);if("[object Number]"===n||"[object Boolean]"===n)return xb(t,JSON.stringify(e.valueOf()),i)}catch(e){}if(e instanceof Error){const o={};try{for(const t in e)({}).hasOwnProperty.call(e,t)&&(o[t]=e[t])}catch(e){}try{o.name=e.name}catch(e){}try{o.message=e.message}catch(e){}try{o.stack=e.stack}catch(e){}return Fb(o,t,i,n,s,r)}if(kt(e)){if(!xb(t,"[",i))return!1;for(let s=0;e.length>s;s++){if(s>0&&!xb(t,",",i))return!1;let r;try{r=e[s]}catch(e){r=void 0}if(!Fb(r,t,i,n,!0))return!1}return xb(t,"]",i)}if(!xb(t,"{",i))return!1;let o=!0;try{for(const s in e){if(!{}.hasOwnProperty.call(e,s))continue;if(0>=i.remaining)return i.truncated=!0,!1;let a;try{a=e[s]}catch(e){continue}if(r)try{Mb(a,s,r)}catch(e){}if(!Rb(a))continue;const l=`${o?"":","}${JSON.stringify(s)}:`;if(l.length>=i.remaining)return i.truncated=!0,!1;const c=t.length,u=i.remaining,d=i.truncated;if(!xb(t,l,i))return!1;const h=t.length,p=Fb(a,t,i,n,!1),g=i.truncated;if(t.length!==h){if(o=!1,!p)return!1}else if(t.length=c,i.remaining=u,i.truncated=p?d:g,!p)return!1}}catch(e){}return xb(t,"}",i)},Ab=(e,t)=>{const i=[],n={remaining:t,truncated:!1},s=Et(e[0])?{result:{},keysRemaining:50,sizeRemaining:Tb,truncated:!1,seen:new WeakSet([e[0]])}:void 0;for(let t=0;e.length>t&&(0>=t||xb(i," ",n))&&Fb(e[t],i,n,new WeakSet,!1,0===t?s:void 0);t++);return{body:i.join("")+(n.truncated?"...":""),truncated:n.truncated,attributes:(null==s?void 0:s.result)||{}}},Lb={debug:"debug",log:"info",warn:"warn",error:"error",info:"info"},Ob=e=>"canCapture"in e,Db=e=>({console:d.console,hostname:d.location.host,getCapturingLogs(){let t;return t=Ob(e)?e.canCapture?e.getExtension(Yy):void 0:(Ct(e.is_capturing)?e.is_capturing():!e.has_opted_out_capturing())?e.logs:void 0,t?{captureConsoleLog:i=>((e,t,i)=>{if(Ob(e))return void t.captureConsoleLog(i);const n=(e=>{const t=/^1\.(\d+)\.(\d+)$/.exec(e);if(!t)return;const i=Number(t[1]),n=Number(t[2]);return 392>i||i>419?void 0:410===i?n>4?n>10?void 0:"de":"le":418===i?n>3?n>10?n>14?n>17?void 0:"vi":"ci":"ui":"he":419===i?n>2?void 0:"vi":410>i?"le":"he"})(e.version),s=n?t[n]:void 0;n?Ct(s)&&s.call(t,i):Ct(t.captureConsoleLog)&&t.captureConsoleLog(i)})(e,t,i),captureBufferedConsoleLog(e,i,n){var s;return null===(s=t.captureBufferedConsoleLog)||void 0===s?void 0:s.call(t,e,i,n)}}:void 0}});d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.logs={initializeLogs:e=>(e=>{const t=e.console;let i=e;const n=[],s={host:e.hostname};let r=!1;const o=()=>{i=void 0;for(const e of n)try{e()}catch(e){}};try{for(const e of Object.keys(Lb)){const o=n=>(...o)=>{let a=!1;try{if(o.length>0&&!r&&i){const t=i.getCapturingLogs();if(t){r=!0,a=!0;const{body:i,truncated:n,attributes:l}=Ab(o,Tb),c=ct(ct({},s),n?{body_truncated:"true"}:{}),u={level:Lb[e],body:i,attributes:ct(ct({"log.source":`console.${e}`},c),l)};t.captureConsoleLog(u)}}}catch(e){}finally{a&&(r=!1),n.apply(t,o)}},a=t[e];n.push(Mg(t,e,e=>{const t=o(e);return t.__rrweb_original__=Eb(a),t}))}}catch(e){throw o(),e}return o})(Db(e)),replayConsoleBuffer:(e,t)=>((e,t)=>{const i=e.getCapturingLogs();if(i)for(const s of t)try{var n;const{body:t,truncated:r,attributes:o}=Ab(s.args,Tb);null===(n=i.captureBufferedConsoleLog)||void 0===n||n.call(i,{level:Lb[s.level],body:t,attributes:ct(ct({"log.source":`console.${s.level}`,host:e.hostname},r?{body_truncated:"true"}:{}),o)},s.context,s.occurredAtMs)}catch(e){}})(Db(e),t)};const $b=e=>qt(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),Nb=Br("[Error tracking]"),Bb="webkit-masked-url:",qb=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Hb=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Bb],Ub=["__firefox__","__gCrWeb"];function zb(){return new bn([new Hn,new Yn,new zn,new Un,new Kn,new Qn,new jn,new Jn],function(e,...t){return(i,n=0)=>{const s=[],r=i.split("\n"),o=Math.min(r.length,n+1e3),a=[];for(let i=n;o>i;i++){const n=r[i];if(n.length>1024)continue;const o=An.test(n)?n.replace(An,"$1"):n;if(!o.match(/\S*Error: /)){for(const i of t){const t=i(o,e);if(t){s.push(t);const e=On(s);if(e){for(let t=a.length-1;t>=0;t--){const i=a[t];if(e.start>=i.start+i.length)break;a.pop()}a.push(e)}break}}if(Bn(s,a)>=50)break}}const l=[...a].sort((e,t)=>t.start-e.start),c=l[l.length-1];if(c){const e=$n(s,c);s.splice(c.start-e,e);for(const t of l)t.start-=e}for(const e of l)Dn(s,e);return a.some(e=>0===e.start&&s.length===e.length)&&function(e){const t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`);let i=0;for(let e=1;t.length>e;e++)qn(t,e,i)&&(i=e);e.push(...e.splice(0,i))}(s),function(e){if(!e.length)return[];const t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return ct(ct({},e),{},{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(s)}}("web:javascript",Rn,Fn))}const Wb=Br("[ExceptionAutocapture]"),jb=zb(),Vb=(e,t)=>{try{return e()}catch(e){return t}},Gb=(e,t)=>Vb(()=>e(t()),void 0),Qb=e=>Vb(()=>Ct(e)&&Ct(e.call),!1),Kb=(e,t)=>Vb(()=>{e[t].__POSTHOG_INSTRUMENTED__=!0},void 0),Jb=(e,t,i)=>{Vb(()=>{var i;null===(i=e[t])||void 0===i||delete i.__POSTHOG_INSTRUMENTED__},void 0),Vb(()=>{e[t]=i},void 0)},Yb=t=>{const i=e;i||Wb.info("window not available, cannot wrap onerror");const n=Vb(()=>i.onerror,void 0);return i.onerror=function(...e){var i;return Gb(t,()=>jb.buildFromUnknown((([e,t,i,n,s])=>{if(null!=s)return s;if(It(e)&&It(t)&&t.length>0&&"undefined"!=typeof ErrorEvent)try{return new ErrorEvent("error",{message:e,filename:t,lineno:i,colno:n})}catch(t){return e}return e})(e),{mechanism:{handled:!1}})),!!Qb(n)&&null!==(i=n(...e))&&void 0!==i&&i},Kb(i,"onerror"),()=>Jb(i,"onerror",n)},Zb=(t,i=!1)=>{const n=e;n||Wb.info("window not available, cannot wrap onUnhandledRejection");const s=Vb(()=>n.onunhandledrejection,void 0);return n.onunhandledrejection=function(e){var n;return Gb(t,()=>jb.buildFromUnknown(e,{mechanism:{handled:!1}})),Qb(s)?null!==(n=s(e))&&void 0!==n&&n:i},Kb(n,"onunhandledrejection"),()=>Jb(n,"onunhandledrejection",s)},Xb={wrapOnError:Yb,wrapUnhandledRejection:Zb,wrapConsoleError(e){const t=console;t||Wb.info("console not available, cannot wrap console.error");const i=Vb(()=>t.error,void 0);return t.error=function(...t){Vb(()=>t.length>1&&It(t[0])&&(/^\[PostHog\.js\](?: |$)/.test(t[0])||"rrweb logger error:"===t[0]),!1)||Gb(e,()=>{let e;e=1==t.length?t[0]:t.join(" ");const i=t.find(e=>e instanceof Error);return jb.buildFromUnknown(i||e,{mechanism:{handled:!0,type:"onconsole"},syntheticException:new Error("PostHog syntheticException"),skipFirstLines:2})}),Qb(i)&&i(...t)},Kb(t,"error"),()=>Jb(t,"error",i)}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.errorWrappingFunctions=Xb,d.posthogErrorWrappingFunctions=Xb;const eS=(e,t)=>{if(!Ct(null==e?void 0:e.capture))return;const i=null==t?void 0:t.autocaptureExceptions,n=!Pt(i)&&"object"==typeof i&&kt(i.errors_to_ignore)?i.errors_to_ignore.reduce((e,t)=>{try{e.push(new RegExp(t))}catch(e){Wb.error("Ignoring invalid legacy exception exclusion rule",t,e)}return e},[]):[],s=t=>{try{var i;null===(i=e.capture)||void 0===i||i.call(e,"$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",_noHeatmaps:!0})}catch(e){Wb.error("Failed to capture exception for a legacy client",e)}};Yb(e=>{n.some(t=>e.$exception_list.some(e=>t.test(e.value||"")))||s(e)}),Zb(s,!0)};d.extendPostHogWithExceptionAutoCapture=eS,d.extendPostHogWithExceptionAutocapture=eS;const tS="X-POSTHOG-SESSION-ID",iS="X-POSTHOG-WINDOW-ID",nS="X-POSTHOG-DISTINCT-ID",sS=[tS,iS,nS],rS=["attributionReporting","body","browsingTopics","cache","credentials","dispatcher","duplex","integrity","keepalive","method","mode","priority","redirect","referrer","referrerPolicy","signal","window"],oS=(e,t)=>({}.hasOwnProperty.call(e,t)),aS=e=>"object"==typeof e&&!Pt(e)||Ct(e),lS=e=>"undefined"!=typeof Request&&(e instanceof Request||"[object Request]"==={}.toString.call(e)),cS=t=>{try{var i;return lS(t)?t.url:new URL(t instanceof URL?t.toString():String(t),null==e||null===(i=e.location)||void 0===i?void 0:i.href).toString()}catch(e){return}},uS=(e,t,i,n,s)=>{let r;try{r=new URL(n).hostname}catch(e){return!1}if(!e)return!1;if(kt(e)&&!e.includes(r))return!1;let o=!1;if(i){const{sessionId:e,windowId:t}=i.checkAndGetSessionAndWindowId(!0);s.set(tS,e),s.set(iS,t),o=!0}const a=(e=>Ct(e)?e():e)(t);return a&&"$posthog_cookieless"!==a&&(s.set(nS,a),o=!0),o};d.__PosthogExtensions__=d.__PosthogExtensions__||{};const dS={_patchFetch:(t,i,n)=>Mg(e,"fetch",e=>function(s,r){const o=arguments.length>1?[s,r]:[s];let a=o;try{const e=cS(s);if(e)if(lS(s)){const e=new Request(s,r);uS(t,i,n,e.url,e.headers),a=[e]}else{const o=new Headers(aS(r)?r.headers:void 0);if(uS(t,i,n,e,o)){const e=((e,t)=>{if(xt(e)||Pt(e))return{headers:t};if(!aS(e))return;const i=e;if("undefined"==typeof Proxy||"undefined"==typeof Reflect){const e=Object.create(i);return Object.defineProperty(e,"headers",{configurable:!0,enumerable:!0,value:t,writable:!0}),e}return new Proxy({headers:t},{get:(e,t)=>oS(e,t)?Reflect.get(e,t):Reflect.get(i,t,i),has:(e,t)=>oS(e,t)||t in i,ownKeys(e){const t=new Set(Reflect.ownKeys(e));return Reflect.ownKeys(i).forEach(e=>t.add(e)),rS.forEach(e=>{e in i&&t.add(e)}),Array.from(t)},getOwnPropertyDescriptor(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);if(n)return n;if("string"==typeof t&&rS.includes(t)&&t in i)return{configurable:!0,enumerable:!0,get(){return Reflect.get(i,t,i)}};const s=Reflect.getOwnPropertyDescriptor(i,t);return s?ct(ct({},s),{},{configurable:!0}):void 0},getPrototypeOf:()=>Object.getPrototypeOf(i)})})(r,o);e&&(a=[s,e])}}}catch(e){a=o}return e.apply(this,a)}),_patchXHR:(t,i,n)=>Mg(e.XMLHttpRequest.prototype,"open",e=>function(s,r,o=!0,a,l){const c=this,u=new Headers,d=cS(r);d&&uS(t,i,n,d,u);const h=e.call(c,s,r,o,a,l);return sS.forEach(e=>{const t=u.get(e);if(t)try{c.setRequestHeader(e,t)}catch(e){}}),h})};d.__PosthogExtensions__.tracingHeadersPatchFns=dS,d.postHogTracingHeadersPatchFns=dS,"function"!=typeof[].at&&Object.defineProperty(Array.prototype,"at",{value(e){const t=this.length;let i=Math.trunc(e)||0;return 0>i&&(i+=t),0>i||i>=t?void 0:this[i]},writable:!0,enumerable:!1,configurable:!0}),"function"!=typeof[].findLast&&Object.defineProperty(Array.prototype,"findLast",{value(e,t){for(let i=this.length-1;i>=0;i--){const n=this[i];if(e.call(t,n,i,this))return n}},writable:!0,enumerable:!1,configurable:!0});var hS=class{constructor(){this.t=void 0,this.o=0,this.i=[]}l(e){var t;if(e.hadRecentInput)return;const i=this.i[0],n=this.i.at(-1);this.o&&i&&n&&1e3>e.startTime-n.startTime&&5e3>e.startTime-i.startTime?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const pS=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},gS=e=>{if("loading"===document.readyState)return"loading";const t=pS();if(t){if(t.domInteractive>e)return"loading";if(0===t.domContentLoadedEventStart||t.domContentLoadedEventStart>e)return"dom-interactive";if(0===t.domComplete||t.domComplete>e)return"dom-content-loaded"}return"complete"},_S=e=>{const t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},fS=e=>{let t="";try{for(;9!==(null==e?void 0:e.nodeType);){var i;const n=e,s=n.id?"#"+n.id:[_S(n),...Array.from(null!==(i=n.classList)&&void 0!==i?i:[]).sort()].join(".");if(t.length+s.length>99)return t||s;if(t=t?s+">"+t:s,n.id)break;e=n.parentNode}}catch(e){}return t},vS=new WeakMap;function mS(e,t){let i=vS.get(t);return i||(i=new WeakMap,vS.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}let yS=-1;const bS=()=>yS,SS=e=>{addEventListener("pageshow",t=>{t.persisted&&(yS=t.timeStamp,e(t))},!0)},wS=(e,t,i,n)=>{let s,r;return o=>{var a;t.value>=0&&(o||n)&&(r=t.value-(null!==(a=s)&&void 0!==a?a:0),(r||void 0===s)&&(s=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},kS=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},CS=()=>{var e,t;return null!==(e=null===(t=pS())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let ES=-1;const TS=new Set,xS=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,IS=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of TS)e();isFinite(ES)||(ES="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",IS,!0))}},RS=(e=!1)=>{if(e&&(ES=1/0),0>ES){var t;const e=CS(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;ES=null!=i?i:xS(),addEventListener("visibilitychange",IS,!0),addEventListener("prerenderingchange",IS,!0),SS(()=>{setTimeout(()=>{ES=xS()})})}return{get firstHiddenTime(){return ES},onHidden(e){TS.add(e)}}},PS=(e,t=-1,i,n=0,s,r,o)=>{const a=pS(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>bS()?a&&(document.prerendering||CS()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:n||l,navigationInteractionId:s,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},MS=(e,t,i={})=>{try{const n=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(n.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();n.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of n)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},FS=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},AS=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},LS=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var OS=class{constructor(){this.u=void 0}};const DS=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},$S=[1800,3e3],NS=(e,t={})=>{const i=FS(t);DS(()=>{const n=mS(t,OS),s=RS();let r,o=PS("FCP");const a=MS(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),s.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-CS(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=wS(e,o,$S,t.reportAllChanges),SS(i=>{o=PS("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,bS()),r=wS(e,o,$S,t.reportAllChanges),kS(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&MS(["soft-navigation"],i=>{i.forEach(i=>{n.u&&i.navigationId&&AS(n.u,i);const s=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=PS("FCP",s,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=wS(e,o,$S,t.reportAllChanges),r(!0)})},t)})},BS=[.1,.25],qS=e=>e.find(e=>{var t;return 1===(null===(t=e.node)||void 0===t?void 0:t.nodeType)})||e[0],HS=(e,t={})=>{const i=mS(t=Object.assign({},t),hS),n=new WeakMap;i.t=e=>{var i;if(null==e||null===(i=e.sources)||void 0===i?void 0:i.length){const i=qS(e.sources),o=null==i?void 0:i.node;if(o){var s,r;const e=null!==(s=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,o))&&void 0!==s?s:fS(o);n.set(i,e)}}},((e,t={})=>{const i=RS();NS(LS(()=>{let n,s=PS("CLS",0);const r=mS(t,hS),o=(i,o,a,l,c)=>{s=PS("CLS",0,i,o,a,l,c),r.o=0,n=wS(e,s,BS,t.reportAllChanges)},a=(e=!1)=>{r.o>s.value&&(s.value=r.o,s.entries=r.i),n(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.l(t):l(t);a()},u=["layout-shift"];FS(t)&&u.push("soft-navigation");const d=MS(u,c);d&&(n=wS(e,s,BS,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),n(!0)}),SS(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,bS()),kS(n)}),setTimeout(n))}))})(t=>{e((e=>{let t={};if(e.entries.length){var i;const s=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(null==s||null===(i=s.sources)||void 0===i?void 0:i.length){const e=qS(s.sources);e&&(t={largestShiftTarget:n.get(e),largestShiftTime:s.startTime,largestShiftValue:s.value,largestShiftSource:e,largestShiftEntry:s,loadState:gS(s.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},US=(e,t={})=>{const i=mS(t=Object.assign({},t),OS);FS(t)&&(i.u=new Map),NS(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:gS(bS())};if("soft-navigation"!==e.navigationType){if(e.entries.length){const i=pS(),n=e.entries.at(-1);if(i){const s=Math.max(0,i.responseStart-(i.activationStart||0));t={timeToFirstByte:s,firstByteToFCP:e.value-s,loadState:gS(e.entries[0].startTime),navigationEntry:i,fcpEntry:n}}}}else{var n;const s=null===(n=i.u)||void 0===n?void 0:n.get(e.navigationId);s&&(t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:"complete",navigationEntry:s})}return Object.assign(e,{attribution:t})})(t))},t)};let zS=0,WS=1/0,jS=0;const VS=e=>{for(const t of e)t.interactionId&&(WS=Math.min(WS,t.interactionId),jS=Math.max(jS,t.interactionId),zS=jS?(jS-WS)/7+1:0)};let GS;const QS=()=>{var e;return GS?zS:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var KS=class{constructor(){this.h=0,this.v=[],this.p=new Map,this.m=void 0,this.M=void 0}T(){return QS()-this.h}D(){this.h=QS(),this.v.length=0,this.p.clear()}S(e){const t=this.T(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{k:8,id:-1,entries:[]}}l(e){var t;if(null===(t=this.m)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let n=this.p.get(e.interactionId);if(n||10>this.v.length||e.duration>i.k){var s;if(n?e.duration>n.k?(n.entries=[e],n.k=e.duration):e.duration===n.k&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],k:e.duration},this.p.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.k-e.k),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.p.delete(t.id)}null===(s=this.M)||void 0===s||s.call(this,n)}}};const JS=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const s=LS(e);let r=-1;const o=()=>{n(r),s()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),s()},{timeout:t})}},YS=[200,500],ZS=(e,t={})=>{const i=mS(t=Object.assign({},t),KS);let n=[],s=[],r=0;const o=new WeakMap,a=new WeakMap;let l=!1;const c=()=>{l||(JS(u),l=!0)},u=()=>{const e=new Set(i.v.map(e=>o.get(e.entries[0]))),t=s.length-10;s=s.filter((i,n)=>n>=t||e.has(i));const a=new Set;for(const e of s){const t=d(e.startTime,e.processingEnd);for(const e of t)a.add(e)}n=n.filter(e=>e.startTime>r||a.has(e)),l=!1};i.m=e=>{const i=e.startTime+e.duration;let n;r=Math.max(r,e.processingEnd);for(let r=s.length-1;r>=0;r--){const o=s[r];if(8>=Math.abs(i-o.renderTime)){n=o,n.startTime=Math.min(e.startTime,n.startTime),n.processingStart=Math.min(e.processingStart,n.processingStart),n.processingEnd=Math.max(e.processingEnd,n.processingEnd),t.includeProcessedEventEntries&&n.entries.push(e);break}}n||(n={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:i,entries:t.includeProcessedEventEntries?[e]:[]},s.push(n)),e.interactionId&&o.set(e,n),c()},i.M=e=>{if(!a.get(e)){var i;const o=null===(i=e.entries.find(e=>e.target))||void 0===i?void 0:i.target;if(o){var n,s;const i=null!==(n=null===(s=t.generateTarget)||void 0===s?void 0:s.call(t,o))&&void 0!==n?n:fS(o);a.set(e,i)}else{var r;const t=null===(r=e.entries.find(e=>e.targetSelector))||void 0===r?void 0:r.targetSelector;t&&a.set(e,t)}}};const d=(e,t)=>{const i=[];for(const s of n)if(s.startTime+s.duration>=e){if(s.startTime>t)break;i.push(s)}return i};MS(["long-animation-frame"],e=>{n=n.concat(e),c()},t),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=RS();DS(()=>{var n;"interactionCount"in performance||GS||(GS=MS(["event"],VS,{durationThreshold:0}));let s,r=PS("INP");const o=mS(t,KS),a=(i,n,a,l,c)=>{o.D(),r=PS("INP",-1,i,n,a,l,c),s=wS(e,r,YS,t.reportAllChanges)},l=()=>{const e=o.S(r.navigationType);e&&e.k!==r.value&&(r.value=e.k,r.entries=e.entries,s())},c=e=>{l(),s(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{JS(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.l(t):c(t);l(),t&&s(!0)})},d=["event","first-input"];FS(t)&&d.push("soft-navigation");const h=MS(d,u,ct(ct({},t),{},{durationThreshold:null!==(n=t.durationThreshold)&&void 0!==n?n:40}));s=wS(e,r,YS,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),SS(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,bS())}))})})(t=>{e((e=>{if(0===e.entries.length){const t={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:e.value,loadState:gS(e.navigationStartTime||0)};return Object.assign(e,{attribution:t})}const t=e.entries[0],n=o.get(t),s=Math.max(n.processingStart,t.startTime),r=Math.max(t.startTime+t.duration,s),l=Math.min(n.processingEnd,r),c=n.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,l),h=i.p.get(t.interactionId),p={interactionTarget:a.get(h),interactionType:t.name.startsWith("key")?"keyboard":"pointer",interactionTime:t.startTime,nextPaintTime:r,processedEventEntries:c,longAnimationFrameEntries:u,inputDelay:s-t.startTime,processingDuration:l-s,presentationDelay:r-l,loadState:gS(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;const i=e.interactionTime,n=e.nextPaintTime;if(!(null===(t=e.longAnimationFrameEntries)||void 0===t?void 0:t.length)||!i||!n)return;const s=e.inputDelay,r=e.processingDuration;let o,a,l=0,c=0,u=0,d=0;for(const t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(const e of t.scripts){const t=e.startTime+e.duration;if(i>t)continue;const n=t-Math.max(i,e.startTime),u=e.duration?n/e.duration*e.forcedStyleAndLayoutDuration:0;l+=n-u,c+=u,n>d&&(a=i+s>e.startTime?"input-delay":i+s+r>e.startTime?"processing-duration":"presentation-delay",o=e,d=n)}}const h=e.longAnimationFrameEntries.at(-1),p=h?h.startTime+h.duration:0;p>=i+s+r&&(u=n-p),o&&a&&(e.longestScript={entry:o,subpart:a,intersectingDuration:d}),e.totalScriptDuration=l,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=u,e.totalUnattributedDuration=n-i-l-c-u})(p),Object.assign(e,{attribution:p})})(t))},t)};var XS=class{constructor(){this.m=void 0,this.u=void 0}l(e){var t;null===(t=this.m)||void 0===t||t.call(this,e)}};const $=[2500,4e3];let ew=50;const tw=[];MS(["resource"],e=>{for(const t of e)tw.push(t),tw.length>ew&&tw.shift()});const iw=(e,t={})=>{null!=(t=Object.assign({},t)).resourceBufferSize&&(ew=t.resourceBufferSize);const i=mS(t,XS),n=new WeakMap;FS(t)&&(i.u=new Map),i.m=e=>{const i=e.element;if(i){var s,r;const o=null!==(s=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,i))&&void 0!==s?s:fS(i);n.set(e,o)}else e.id&&n.set(e,`#${e.id}`)},((e,t={})=>{let i=!1;const n=FS(t);DS(()=>{let s,r=RS(),o=PS("LCP");const a=mS(t,XS),l=(n,a,l,c,u)=>{o=PS("LCP",-1,n,a,l,c,u),s=wS(e,o,$,t.reportAllChanges),i=!1,"soft-navigation"===n&&(r=RS(!0))},c=e=>{var t;a.u&&e.navigationId&&AS(a.u,e),i||s(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const n=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);n&&u([n])},u=e=>{t.reportAllChanges||n||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,n=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-CS(),0),a.l(t),n=[t];else if("interaction-contentful-paint"===t.entryType){var i;const s=t;if(!o.navigationId)continue;if("interactionId"in s&&s.interactionId!=o.navigationInteractionId)continue;l=(null===(i=s.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),s.largestContentfulPaint&&(a.l(s.largestContentfulPaint),n=[s.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=n,s())}},d=["largest-contentful-paint"];n&&d.push("interaction-contentful-paint","soft-navigation");const h=MS(d,u);if(h){s=wS(e,o,$,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;JS(()=>{if(!i){if(!n){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,s(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});SS(n=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,bS()),s=wS(e,o,$,t.reportAllChanges),kS(()=>{o.value=performance.now()-n.timeStamp,i=!0,s(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){var s,r,o;const a=e.entries.at(-1),l=a.url&&(tw.findLast(e=>e.name===a.url)||performance.getEntriesByType("resource").findLast(e=>e.name===a.url));let c;t.target=n.get(a),t.lcpEntry=a,a.url&&(t.url=a.url),l&&(t.lcpResourceEntry=l);let u=0,d=0;if("soft-navigation"!==e.navigationType?(c=pS(),u=null!==(s=null==c?void 0:c.activationStart)&&void 0!==s?s:0,d=null!==(r=null==c?void 0:c.responseStart)&&void 0!==r?r:0):(u=e.navigationStartTime||0,c=null===(o=i.u)||void 0===o?void 0:o.get(e.navigationId)),c){const i=Math.max(0,d-u),n=Math.max(i,l?(l.requestStart||l.startTime)-u:0),s=Math.min(e.value,Math.max(n,l?l.responseEnd-u:0));t=ct(ct({},t),{},{timeToFirstByte:i,resourceLoadDelay:n-i,resourceLoadDuration:s-n,elementRenderDelay:e.value-s,navigationEntry:c})}}return Object.assign(e,{attribution:t})})(t))},t)};let nw=-1;const sw=()=>nw,rw=e=>{addEventListener("pageshow",t=>{t.persisted&&(nw=t.timeStamp,e(t))},!0)},ow=(e,t,i,n)=>{let s,r;return o=>{var a;t.value>=0&&(o||n)&&(r=t.value-(null!==(a=s)&&void 0!==a?a:0),(r||void 0===s)&&(s=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},aw=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},lw=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},cw=()=>{var e,t;return null!==(e=null===(t=lw())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let uw=-1;const dw=new Set,hw=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,pw=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of dw)e();isFinite(uw)||(uw="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",pw,!0))}},gw=(e=!1)=>{if(e&&(uw=1/0),0>uw){var t;const e=cw(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;uw=null!=i?i:hw(),addEventListener("visibilitychange",pw,!0),addEventListener("prerenderingchange",pw,!0),rw(()=>{setTimeout(()=>{uw=hw()})})}return{get firstHiddenTime(){return uw},onHidden(e){dw.add(e)}}},_w=(e,t=-1,i,n=0,s,r,o)=>{const a=lw(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>sw()?a&&(document.prerendering||cw()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:n||l,navigationInteractionId:s,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},fw=new WeakMap;function vw(e,t){let i=fw.get(t);return i||(i=new WeakMap,fw.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}var mw=class{constructor(){this.t=void 0,this.i=0,this.o=[]}h(e){var t;if(e.hadRecentInput)return;const i=this.o[0],n=this.o.at(-1);this.i&&i&&n&&1e3>e.startTime-n.startTime&&5e3>e.startTime-i.startTime?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const yw=(e,t,i={})=>{try{const n=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(n.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();n.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of n)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},bw=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},Sw=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},ww=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var kw=class{constructor(){this.l=void 0}};const Cw=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},Ew=[1800,3e3],Tw=(e,t={})=>{const i=bw(t);Cw(()=>{const n=vw(t,kw),s=gw();let r,o=_w("FCP");const a=yw(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),s.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-cw(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=ow(e,o,Ew,t.reportAllChanges),rw(i=>{o=_w("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,sw()),r=ow(e,o,Ew,t.reportAllChanges),aw(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&yw(["soft-navigation"],i=>{i.forEach(i=>{n.l&&i.navigationId&&Sw(n.l,i);const s=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=_w("FCP",s,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=ow(e,o,Ew,t.reportAllChanges),r(!0)})},t)})},xw=[.1,.25],Iw=(e,t={})=>{const i=gw();Tw(ww(()=>{let n,s=_w("CLS",0);const r=vw(t,mw),o=(i,o,a,l,c)=>{s=_w("CLS",0,i,o,a,l,c),r.i=0,n=ow(e,s,xw,t.reportAllChanges)},a=(e=!1)=>{r.i>s.value&&(s.value=r.i,s.entries=r.o),n(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.h(t):l(t);a()},u=["layout-shift"];bw(t)&&u.push("soft-navigation");const d=yw(u,c);d&&(n=ow(e,s,xw,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),n(!0)}),rw(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,sw()),aw(n)}),setTimeout(n))}))};let Rw=0,Pw=1/0,Mw=0;const Fw=e=>{for(const t of e)t.interactionId&&(Pw=Math.min(Pw,t.interactionId),Mw=Math.max(Mw,t.interactionId),Rw=Mw?(Mw-Pw)/7+1:0)};let Aw;const Lw=()=>{var e;return Aw?Rw:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var Ow=class{constructor(){this.u=0,this.v=[],this.m=new Map,this.p=void 0,this.T=void 0}_(){return Lw()-this.u}M(){this.u=Lw(),this.v.length=0,this.m.clear()}L(e){const t=this._(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{P:8,id:-1,entries:[]}}h(e){var t;if(null===(t=this.p)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let n=this.m.get(e.interactionId);if(n||10>this.v.length||e.duration>i.P){var s;if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.m.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.P-e.P),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.m.delete(t.id)}null===(s=this.T)||void 0===s||s.call(this,n)}}};const Dw=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const s=ww(e);let r=-1;const o=()=>{n(r),s()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),s()},{timeout:t})}},$w=[200,500],Nw=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=gw();Cw(()=>{var n;"interactionCount"in performance||Aw||(Aw=yw(["event"],Fw,{durationThreshold:0}));let s,r=_w("INP");const o=vw(t,Ow),a=(i,n,a,l,c)=>{o.M(),r=_w("INP",-1,i,n,a,l,c),s=ow(e,r,$w,t.reportAllChanges)},l=()=>{const e=o.L(r.navigationType);e&&e.P!==r.value&&(r.value=e.P,r.entries=e.entries,s())},c=e=>{l(),s(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{Dw(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.h(t):c(t);l(),t&&s(!0)})},d=["event","first-input"];bw(t)&&d.push("soft-navigation");const h=yw(d,u,ct(ct({},t),{},{durationThreshold:null!==(n=t.durationThreshold)&&void 0!==n?n:40}));s=ow(e,r,$w,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),rw(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,sw())}))})};var Bw=class{constructor(){this.p=void 0,this.l=void 0}h(e){var t;null===(t=this.p)||void 0===t||t.call(this,e)}};const qw=[2500,4e3],Hw=(e,t={})=>{let i=!1;const n=bw(t);Cw(()=>{let s,r=gw(),o=_w("LCP");const a=vw(t,Bw),l=(n,a,l,c,u)=>{o=_w("LCP",-1,n,a,l,c,u),s=ow(e,o,qw,t.reportAllChanges),i=!1,"soft-navigation"===n&&(r=gw(!0))},c=e=>{var t;a.l&&e.navigationId&&Sw(a.l,e),i||s(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const n=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);n&&u([n])},u=e=>{t.reportAllChanges||n||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,n=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-cw(),0),a.h(t),n=[t];else if("interaction-contentful-paint"===t.entryType){var i;const s=t;if(!o.navigationId)continue;if("interactionId"in s&&s.interactionId!=o.navigationInteractionId)continue;l=(null===(i=s.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),s.largestContentfulPaint&&(a.h(s.largestContentfulPaint),n=[s.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=n,s())}},d=["largest-contentful-paint"];n&&d.push("interaction-contentful-paint","soft-navigation");const h=yw(d,u);if(h){s=ow(e,o,qw,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;Dw(()=>{if(!i){if(!n){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,s(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});rw(n=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,sw()),s=ow(e,o,qw,t.reportAllChanges),aw(()=>{o.value=performance.now()-n.timeStamp,i=!0,s(!0)})})}})},Uw={onLCP:iw,onCLS:HS,onFCP:US,onINP:ZS,withoutAttribution:{onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution-soft-navs"]=Uw,d.__PosthogExtensions__.postHogWebVitalsCallbacks=Uw,d.postHogWebVitalsCallbacks=Uw;const zw={onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-soft-navs"]=zw,d.__PosthogExtensions__.postHogWebVitalsCallbacks=zw,d.postHogWebVitalsCallbacks=zw,d.__PosthogExtensions__.loadWebVitalsCallbacks=()=>zw;const Ww={onLCP:iw,onCLS:HS,onFCP:US,onINP:ZS,withoutAttribution:{onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution"]=Ww,d.__PosthogExtensions__.postHogWebVitalsCallbacks=Ww,d.postHogWebVitalsCallbacks=Ww;const jw={onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals"]=jw,d.__PosthogExtensions__.postHogWebVitalsCallbacks=jw,d.postHogWebVitalsCallbacks=jw,d.__PosthogExtensions__.loadWebVitalsCallbacks=()=>jw;const Vw={};function Gw(e,t){const i=bo(e);return i?ct({node:i,originalEvent:e,timestamp:Date.now()},t):null}function Qw(e){return!!un(()=>uo(e))}function Kw(e,t){return Math.abs(e)<Math.abs(t)?0>t?"up":"down":0>e?"left":"right"}function Jw(e){return"swipe"===e.type?"$dead_swipe":"$dead_click"}const Yw="canvas,video,audio,embed,object";function Zw(e,t){return Ft(e)&&e>=t}function Xw(e,t=1e3){return e>=0&&t>e?e:void 0}function ek(e,t,i=1e3){return Ft(t)?Xw(e-t,i):void 0}var tk=class{_asRequiredConfig(e){var t,i,n,s,r,o,a,l;const c=this._defaultConfig((null==e?void 0:e.__onCapture)||this._captureDeadClick.bind(this));return{element_attribute_ignorelist:null!==(t=null==e?void 0:e.element_attribute_ignorelist)&&void 0!==t?t:c.element_attribute_ignorelist,scroll_threshold_ms:null!==(i=null==e?void 0:e.scroll_threshold_ms)&&void 0!==i?i:c.scroll_threshold_ms,selection_change_threshold_ms:null!==(n=null==e?void 0:e.selection_change_threshold_ms)&&void 0!==n?n:c.selection_change_threshold_ms,mutation_threshold_ms:null!==(s=null==e?void 0:e.mutation_threshold_ms)&&void 0!==s?s:c.mutation_threshold_ms,capture_clicks_with_modifier_keys:null!==(r=null==e?void 0:e.capture_clicks_with_modifier_keys)&&void 0!==r?r:c.capture_clicks_with_modifier_keys,capture_dead_swipes:null!==(o=null==e?void 0:e.capture_dead_swipes)&&void 0!==o?o:c.capture_dead_swipes,swipe_threshold_px:null!==(a=null==e?void 0:e.swipe_threshold_px)&&void 0!==a?a:c.swipe_threshold_px,max_dead_swipes_per_page_load:null!==(l=null==e?void 0:e.max_dead_swipes_per_page_load)&&void 0!==l?l:c.max_dead_swipes_per_page_load,css_selector_ignorelist:null==e?void 0:e.css_selector_ignorelist,__onCapture:c.__onCapture}}constructor(e,t){this.instance=e,this._observedRoots=new WeakSet,this._hadSelection=!1,this._clicks=[],this._deadSwipesCaptured=0,this._defaultConfig=e=>({element_attribute_ignorelist:[],scroll_threshold_ms:100,selection_change_threshold_ms:100,mutation_threshold_ms:2500,capture_clicks_with_modifier_keys:!1,capture_dead_swipes:!0,swipe_threshold_px:30,max_dead_swipes_per_page_load:10,__onCapture:e}),this._clearMouseSelection=()=>{clearTimeout(this._mouseSelectionTimer),this._mouseSelectionTimer=void 0,this._mouseSelection=void 0},this._onMouseDown=e=>{if(this._observeGesturePath(e),this._clearMouseSelection(),0===e.button){const t={path:e.composedPath(),trusted:e.isTrusted,selectionChanged:!1,selectionInitiallyRelated:!1},i=null==n?void 0:n.getSelection();t.selectionInitiallyRelated="Range"===(null==i?void 0:i.type)&&this._selectionTouchesGesture(i,t),this._mouseSelection=t}},this._onMouseOut=e=>{Pt(e.relatedTarget)&&this._clearMouseSelection()},this._onMouseUp=e=>{const t=this._mouseSelection,i=e;if(!t||0!==i.button||e.isTrusted!==t.trusted)return;const n=e.composedPath();for(const e of t.path)if(Qw(e)&&-1!==n.indexOf(e)){t.clickTarget=e;break}t.clickDetail=i.detail,this._mouseSelectionTimer=d.setTimeout(this._clearMouseSelection,0)},this._onClick=e=>{this._observeGesturePath(e);const t=e,i=Gw(t,{type:"click"}),n=this._mouseSelection;i&&n&&0===t.button&&t.detail>0&&t.detail===n.clickDetail&&e.isTrusted===n.trusted&&i.node===n.clickTarget&&(i.selectionChangedDuringGesture=n.selectionChanged&&this._config.selection_change_threshold_ms>0,this._clearMouseSelection()),Pt(i)||this._ignore(i)||this._queueCandidate(i),this._scheduleCheck()},this._onScroll=()=>{const e=Date.now();this._lastScroll=e,e%50==0&&this._clicks.forEach(t=>{xt(t.scrollDelayMs)&&(t.scrollDelayMs=e-t.timestamp)})},this._onSelectionChange=e=>{var t,i;const s=null==n?void 0:n.getSelection(),r=this._hadSelection;this._hadSelection="Range"===(null==s?void 0:s.type);const o=null==s?void 0:s.focusNode,a=o&&(uo(o)?o:o.parentElement),l=null==n?void 0:n.activeElement;let c=l;for(;null==c||null===(t=c.shadowRoot)||void 0===t?void 0:t.activeElement;)c=c.shadowRoot.activeElement;const u=$o(bo(e))||$o(null!=a?a:null)||$o(null!==(i=c)&&void 0!==i?i:null),d="Caret"===(null==s?void 0:s.type)&&c&&!c.shadowRoot&&o&&o!==l&&o.contains(null!=l?l:null);if(!(r||this._hadSelection||u||d))return;const h=Date.now();this._lastSelectionChanged=h;const p=this._mouseSelection;if(p&&(r||this._hadSelection||u)){const t=bo(e);let i;if($o(t))i=t;else if("Caret"===(null==s?void 0:s.type)){var g;$o(null!==(g=c)&&void 0!==g?g:null)||d?i=c:u&&(i=a)}const n=i?this._selectionIsInGesture(i,p):s&&(o||s.anchorNode)?this._selectionTouchesGesture(s,p):r&&!this._hadSelection&&p.selectionInitiallyRelated;p.selectionChanged=p.selectionChanged||n}this._clicks.forEach(e=>{const t=h-e.timestamp;0>t||!xt(e.selectionChangedDelayMs)&&t>=e.selectionChangedDelayMs||(e.selectionChangedDelayMs=t)})},this._onVisibilityChange=()=>{"hidden"===(null==n?void 0:n.visibilityState)&&this._clearMouseSelection();const e=Date.now();this._lastVisibilityChange=e,this._recordLivenessSignal("visibilityChangedDelayMs",e)},this._onFocusChange=()=>{const e=Date.now();this._lastFocusChange=e,this._recordLivenessSignal("focusChangedDelayMs",e)},this._onTouchStart=e=>{this._observeGesturePath(e);const t=e.touches,i=1===(null==t?void 0:t.length)?t[0]:void 0;this._touchStart=i?{x:i.clientX,y:i.clientY,timestamp:Date.now()}:void 0},this._onTouchCancel=()=>{this._touchStart=void 0},this._onTouchEnd=e=>{var t;const i=this._touchStart;if(this._touchStart=void 0,xt(i)||this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)return;const s=e,r=null===(t=s.changedTouches)||void 0===t?void 0:t[0];if(!r)return;const o=r.clientX-i.x,a=r.clientY-i.y,l=o*o+a*a,c=this._config.swipe_threshold_px;if(c*c>l)return;if([this._lastScroll,this._lastMutation,this._lastSelectionChanged].some(e=>Ft(e)&&e>=i.timestamp))return;var u,d;if(this._pageHasUnobservableSurfaces()&&(null!==(u=null==n||null===(d=n.elementsFromPoint)||void 0===d?void 0:d.call(n,i.x,i.y))&&void 0!==u?u:[]).some(e=>{var t;return null===(t=e.matches)||void 0===t?void 0:t.call(e,Yw)}))return;const h=Gw(s,{type:"swipe",swipeDirection:Kw(o,a),swipeDistancePx:Math.round(Math.sqrt(l))});Pt(h)||this._ignore(h)||this._queueCandidate(h),this._scheduleCheck()},this._config=this._asRequiredConfig(t),this._onCapture=this._config.__onCapture}start(e){this._startClickObserver(),this._startScrollObserver(),this._startSelectionChangedObserver(),this._startVisibilityChangeObserver(),this._startFocusChangeObserver(),this._startMutationObserver(e),this._config.capture_dead_swipes&&this._startSwipeObserver()}_startMutationObserver(t){if(!this._mutationObserver){const i=function(t){return function(t,i){const n=Vw[t];if(n)return n;let s=i[t];if((e=>Ct(e)&&-1!==e.toString().indexOf("[native code]"))(s)&&!(null==e?void 0:e.Zone))return Vw[t]=s.bind(i);const r=i.document;if(r&&Ct(r.createElement)){let e,n=!1;try{e=r.createElement("iframe"),e.hidden=!0,r.head.appendChild(e);const l=e.contentWindow;var o,a;l&&l[t]&&(s=l[t],"MutationObserver"===t&&function(e){return ft(e,"AppleWebKit")&&!ft(e,"Chrome")}(null!==(o=null===(a=i.navigator)||void 0===a?void 0:a.userAgent)&&void 0!==o?o:"")&&(e.classList.add("rr-block","ph-no-capture"),n=!0))}catch(e){Nr.warn(`Could not create sandbox iframe for ${t} check, bailing to assignableWindow.${t}: `,e)}finally{!n&&(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}}return s&&Ct(s)?Vw[t]=s.bind(i):s}("MutationObserver",t)}(d);this._mutationObserver=new i(e=>{this._onMutation(e)}),this._observeRoot(t)}}_observeRoot(e){e&&this._mutationObserver&&(this._observedRoots.has(e)||(this._mutationObserver.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this._observedRoots.add(e),this._observeShadowRoots(e)))}_observeShadowRoots(e,t){var i,n;uo(e)&&e.shadowRoot&&this._observeRoot(e.shadowRoot);const s=null!==(i=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"*"))&&void 0!==i?i:[];for(let e=0;s.length>e;e++)null==t||t.add(s[e]),this._observeRoot(s[e].shadowRoot)}_observeGesturePath(e){var t,i;const n=null!==(t=null===(i=e.composedPath)||void 0===i?void 0:i.call(e))&&void 0!==t?t:[];for(let e=0;n.length>e;e++){const t=n[e];Qw(t)&&this._observeRoot(t.shadowRoot)}}stop(){var e;null===(e=this._mutationObserver)||void 0===e||e.disconnect(),this._mutationObserver=void 0,this._observedRoots=new WeakSet,d.removeEventListener("click",this._onClick,{capture:!0}),d.removeEventListener("mousedown",this._onMouseDown,{capture:!0}),d.removeEventListener("mouseup",this._onMouseUp,{capture:!0}),d.removeEventListener("mouseout",this._onMouseOut,{capture:!0}),d.removeEventListener("dragstart",this._clearMouseSelection,{capture:!0}),d.removeEventListener("pointercancel",this._clearMouseSelection,{capture:!0}),d.removeEventListener("blur",this._clearMouseSelection),this._clearMouseSelection(),d.removeEventListener("scroll",this._onScroll,{capture:!0}),null==n||n.removeEventListener("selectionchange",this._onSelectionChange),d.removeEventListener("touchstart",this._onTouchStart,{capture:!0}),d.removeEventListener("touchend",this._onTouchEnd,{capture:!0}),d.removeEventListener("touchcancel",this._onTouchCancel,{capture:!0}),null==n||n.removeEventListener("visibilitychange",this._onVisibilityChange),d.removeEventListener("blur",this._onFocusChange),d.removeEventListener("focus",this._onFocusChange),this._touchStart=void 0}_onMutation(e){const t=new Set;for(const n of e)try{var i;if(!1===(null===(i=n.target)||void 0===i?void 0:i.isConnected))continue;this._lastMutation=Date.now();const e=n.addedNodes;for(let i=0;e.length>i;i++){const n=e[i];Qw(n)&&!t.has(n)&&this._observeShadowRoots(n,t)}}catch(e){}}_startClickObserver(){Kr(d,"click",this._onClick,{capture:!0}),Kr(d,"mousedown",this._onMouseDown,{capture:!0}),Kr(d,"mouseup",this._onMouseUp,{capture:!0}),Kr(d,"mouseout",this._onMouseOut,{capture:!0}),Kr(d,"dragstart",this._clearMouseSelection,{capture:!0}),Kr(d,"pointercancel",this._clearMouseSelection,{capture:!0}),Kr(d,"blur",this._clearMouseSelection)}_queueCandidate(e){e.selectionChangedDelayMs=ek(e.timestamp,this._lastSelectionChanged,this._config.selection_change_threshold_ms),e.visibilityChangedDelayMs=ek(e.timestamp,this._lastVisibilityChange),e.focusChangedDelayMs=ek(e.timestamp,this._lastFocusChange),this._clicks.push(e)}_scheduleCheck(){this._clicks.length&&xt(this._checkClickTimer)&&(this._checkClickTimer=d.setTimeout(()=>{this._checkClicks()},1e3))}_startScrollObserver(){Kr(d,"scroll",this._onScroll,{capture:!0})}_startSelectionChangedObserver(){var e;this._hadSelection="Range"===(null==n||null===(e=n.getSelection())||void 0===e?void 0:e.type),Kr(n,"selectionchange",this._onSelectionChange)}_selectionIsInGesture(e,t){const i=t.path[0];try{for(;e;){if(-1!==t.path.indexOf(e)||uo(i)&&i.contains(e))return!0;e=e.getRootNode().host}}catch(e){}return!1}_selectionTouchesGesture(e,t){const i=t.path[0],n=e.rangeCount>0?e.getRangeAt(0):void 0,s=!!n&&un(()=>n.startContainer.getRootNode()===i.getRootNode());if(n&&s&&uo(i)){var r;if(!n.collapsed)return n.intersectsNode(i);const e=uo(n.startContainer)&&null!==(r=n.startContainer.childNodes[n.startOffset])&&void 0!==r?r:n.startContainer;return this._selectionIsInGesture(e,t)}return this._selectionIsInGesture(e.focusNode,t)||this._selectionIsInGesture(e.anchorNode,t)}_startVisibilityChangeObserver(){Kr(n,"visibilitychange",this._onVisibilityChange)}_startFocusChangeObserver(){Kr(d,"blur",this._onFocusChange),Kr(d,"focus",this._onFocusChange)}_recordLivenessSignal(e,t){this._clicks.forEach(i=>{const n=Xw(t-i.timestamp);Ft(n)&&(xt(i[e])||i[e]>n)&&(i[e]=n)})}_startSwipeObserver(){Kr(d,"touchstart",this._onTouchStart,{capture:!0,passive:!0}),Kr(d,"touchend",this._onTouchEnd,{capture:!0,passive:!0}),Kr(d,"touchcancel",this._onTouchCancel,{capture:!0,passive:!0})}_pageHasUnobservableSurfaces(){const e=xt(this._surfacesCheckedAt)||Ft(this._lastMutation)&&this._lastMutation>this._surfacesCheckedAt;return(xt(this._hasUnobservableSurfaces)||e)&&(this._surfacesCheckedAt=Date.now(),this._hasUnobservableSurfaces=!!(null==n?void 0:n.querySelector(Yw))),!!this._hasUnobservableSurfaces}_ignore(e){return!e||("swipe"===e.type?this._ignoreCommon(e):this._ignoreClick(e))}_ignoreCommon(e){return!(!co(e.node)&&!this._clicks.some(t=>t.type===e.type&&t.node===e.node&&1e3>Math.abs(t.timestamp-e.timestamp))&&!ho(e.node,"html")&&uo(e.node)&&function(e,t){var i;if(!(typeof window>"u"?void 0:window)||Bo(e))return!1;const n=Lt(t)?Lo:null!==(i=null==t?void 0:t.css_selector_ignorelist)&&void 0!==i?i:Lo,{targetElementList:s}=qo(e,!1);return!ko(s,n)}(e.node,{css_selector_ignorelist:this._config.css_selector_ignorelist}))}_ignoreClick(e){return!(this._config.capture_clicks_with_modifier_keys||(t=e.originalEvent,!(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey)))||!!this._ignoreCommon(e)||function(e){if(!(typeof window>"u"?void 0:window)||Bo(e))return!1;const{targetElementList:t}=qo(e,!1);return t.some(e=>ho(e,"a"))}(e.node);var t}_checkClicks(){if(!this._clicks.length)return;clearTimeout(this._checkClickTimer),this._checkClickTimer=void 0;const e=this._clicks;this._clicks=[];for(const i of e){var t;i.mutationDelayMs=null!==(t=i.mutationDelayMs)&&void 0!==t?t:this._lastMutation&&this._lastMutation>=i.timestamp?this._lastMutation-i.timestamp:void 0,i.absoluteDelayMs=Date.now()-i.timestamp;const e=Zw(i.scrollDelayMs,this._config.scroll_threshold_ms),n=Zw(i.selectionChangedDelayMs,this._config.selection_change_threshold_ms),s=Zw(i.mutationDelayMs,this._config.mutation_threshold_ms),r=Zw(i.absoluteDelayMs,1.1*this._config.mutation_threshold_ms),o=Ft(i.scrollDelayMs)&&this._config.scroll_threshold_ms>i.scrollDelayMs,a=Ft(i.mutationDelayMs)&&this._config.mutation_threshold_ms>i.mutationDelayMs,l=i.selectionChangedDuringGesture||Ft(i.selectionChangedDelayMs)&&this._config.selection_change_threshold_ms>i.selectionChangedDelayMs,c=Ft(i.visibilityChangedDelayMs),u=Ft(i.focusChangedDelayMs);if(!(o||a||l||c||u))if(e||s||r||n){const t=Jw(i);if("$dead_swipe"===t){if(this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)continue;this._deadSwipesCaptured++}this._onCapture(i,{[`${t}_last_mutation_timestamp`]:this._lastMutation,[`${t}_event_timestamp`]:i.timestamp,[`${t}_scroll_timeout`]:e,[`${t}_mutation_timeout`]:s,[`${t}_absolute_timeout`]:r,[`${t}_selection_changed_timeout`]:n,[`${t}_visibility_changed_timeout`]:!1})}else this._config.mutation_threshold_ms>i.absoluteDelayMs&&this._clicks.push(i)}this._scheduleCheck()}_captureDeadClick(e,t){const i=Jw(e);this.instance.capture(i,ct(ct(ct({},t),Gy(e.node,{e:e.originalEvent,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:!1,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}).props),{},{[`${i}_scroll_delay_ms`]:e.scrollDelayMs,[`${i}_mutation_delay_ms`]:e.mutationDelayMs,[`${i}_absolute_delay_ms`]:e.absoluteDelayMs,[`${i}_selection_changed_delay_ms`]:e.selectionChangedDelayMs,[`${i}_visibility_changed_delay_ms`]:e.visibilityChangedDelayMs,[`${i}_focus_changed_delay_ms`]:e.focusChangedDelayMs,$dead_swipe_direction:e.swipeDirection,$dead_swipe_distance_px:e.swipeDistancePx}),{timestamp:new Date(e.timestamp)})}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.initDeadClicksAutocapture=(e,t)=>new tk(e,t);var ik=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}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(){const{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(){const e=this._storage._get(this._storageKey);return Wt(e)?1:ft(jt,e)?0:-1}get _storage(){const e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Dl:Ll,i=t._is_supported()?t:Ql;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;const t="localStorage"===e?Ll:Dl;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(Wt(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,d.doNotTrack,null==i?void 0:i.globalPrivacyControl].some(e=>Wt(e))}};const nk=Br("[Dead Clicks]"),sk=()=>!0,rk=e=>{var t;const i=!!(null===(t=e.instance.persistence)||void 0===t?void 0:t.get_property(Z)),n=e.instance.config.capture_dead_clicks;return Lt(n)?n:!!Et(n)||i};var ok=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Z]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"dead-clicks-autocapture",t=>{t?nk.error("failed to load script",t):e()})}_start(){var e;if(n){if(!this._lazyLoadedDeadClicksAutocapture&&(null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.initDeadClicksAutocapture)){const e=Et(this.instance.config.capture_dead_clicks)?ct({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=d.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this._lazyLoadedDeadClicksAutocapture.start(n),nk.info("starting...")}}else nk.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,nk.info("stopping..."))}};const ak=Br("[SegmentIntegration]");function lk(e,t,i=!0){const n=e.config.segment;if(!n)return t();const{analytics:s,filterProperties:r}=(e=>Ct(e.register))(o=n)?{analytics:o}:o;var o;!function(e,t,i,n){const s=t=>{const s=()=>t.anonymousId()||Rl();e.config.get_device_id=s,n&&t.id()&&(e.register({distinct_id:t.id(),$device_id:s()}),e.persistence.set_property(xe,Ye)),i(n?void 0:t.anonymousId()||void 0)},r=t.user();"then"in r&&Ct(r.then)?r.then(s):s(r)}(e,s,i=>{s.register(((e,t,{filterProperties:i}={})=>{"undefined"!=typeof Promise&&Promise.resolve||ak.warn("This browser does not have Promise support, and can not use the segment integration");const n=(n,s)=>{if(!s)return n;const r=!!t&&n.event.anonymousId===t&&!n.event.userId;r||n.event.userId||n.event.anonymousId===e.get_distinct_id()||(ak.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),n.event.userId&&n.event.userId!==e.get_distinct_id()&&(ak.info("UserId set, identifying with PostHog"),e.identify(n.event.userId));let o=e.calculateEventProperties(s,n.event.properties);if(!Mt(i)){const e=n.event.properties||{},t={};for(const i of Object.keys(o))St.call(e,i)||(t[i]=o[i]);const s=((e,t)=>{const i=kt(e)?e:[e];let n=ct({},t);for(const e of i)try{if(n=e(n),Mt(n))return null}catch(e){return ak.error("Error in Segment filterProperties:",e),null}return n})(i,t);if(Mt(s))return n;o=s}return n.event.properties=Object.assign({},o,n.event.properties),n};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return n(e,e.event.event)},page(e){return n(e,et)},identify(e){return n(e,it)},screen(e){return n(e,"$screen")}}})(e,i,{filterProperties:r})).then(()=>{t()},e=>{ak.error("Failed to register the Segment integration",e),t()})},i)}const ck="posthog-js";function uk(e,{organization:t,projectId:i,prefix:n,severityAllowList:s=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,d;if("*"!==s&&!s.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const p=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],g=p.map(e=>ct(ct({},e),{},{stacktrace:e.stacktrace?ct(ct({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>ct(ct({},e),{},{platform:"web:javascript"}))}):void 0})),_={$exception_message:(null===(l=p[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=p[0])||void 0===c?void 0:c.type,$exception_level:o.level,$exception_list:g,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=p[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=p[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var f;return t&&i&&(_.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&(null===(f=e.exceptions)||void 0===f||f.sendExceptionEvent(_)),o}}var dk=class{constructor(e,t,i,n,s,r){this.name=ck,this.setupOnce=function(o){o(uk(e,{organization:t,projectId:i,prefix:n,severityAllowList:s,sendExceptionsToPostHog:null==r||r}))}}},hk=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Nr.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?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null===(e=this._unsubscribeSessionId)||void 0===e||e.call(this),this._unsubscribeSessionId=void 0}doPageView(t,i){var n;const s=this._previousPageViewProperties(t,i);return this._currentPageview={pathname:null!==(n=null==e?void 0:e.location.pathname)&&void 0!==n?n:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){const i=this._currentPageview;if(!i)return{$pageview_id:t};let n={$pageview_id:t,$prev_pageview_id:i.pageViewId};const s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=s;if(!(xt(e)||xt(t)||xt(i)||xt(r)||xt(o)||xt(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);const s=e>1?Kt(t/e,0,1,Nr):1,l=e>1?Kt(i/e,0,1,Nr):1,c=r>1?Kt(o/r,0,1,Nr):1,u=r>1?Kt(a/r,0,1,Nr):1;n=Ur(n,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:s,$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:l,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:u})}}return i.pathname&&(n.$prev_pageview_pathname=i.pathname),i.timestamp&&(n.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),n}};const pk=["flags","surveys"],gk={[O]:{exposure:"hidden"},[q]:{exposure:"hidden"},[H]:{exposure:"hidden"},[V]:{exposure:"hidden"},[z]:{exposure:"hidden"},[j]:{exposure:"hidden"},[I]:{exposure:"event"},[G]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[Q]:{exposure:"event"},[K]:{exposure:"hidden"},[J]:{exposure:"event"},[Y]:{exposure:"event"},[Z]:{exposure:"event"},[X]:{exposure:"hidden"},[te]:{exposure:"event"},[ie]:{exposure:"hidden"},[ne]:{exposure:"hidden"},[ce]:{exposure:"hidden"},[ue]:{exposure:"event"},[se]:{exposure:"event",shouldSkipFromEventProperties:e=>Pt(e)},[de]:{exposure:"event"},[he]:{exposure:"event"},[pe]:{exposure:"event"},[ve]:{exposure:"event"},[me]:{exposure:"hidden"},[y]:{exposure:"hidden",storageGroup:"flags"},[p]:{exposure:"hidden",storageGroup:"flags"},[h]:{exposure:"hidden"},[g]:{exposure:"hidden",storageGroup:"flags"},[C]:{exposure:"hidden",storageGroup:"flags"},[v]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[m]:{exposure:"hidden",storageGroup:"flags"},[E]:{exposure:"hidden"},[T]:{exposure:"hidden"},[S]:{exposure:"hidden"},[b]:{exposure:"hidden"},[R]:{exposure:"hidden",storageGroup:"surveys"},[P]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[F]:{exposure:"event"},[A]:{exposure:"hidden"},[L]:{exposure:"hidden"},[be]:{exposure:"hidden"},[Se]:{exposure:"hidden"},[we]:{exposure:"hidden"},[ke]:{exposure:"event"},[Ce]:{exposure:"event"},[Ee]:{exposure:"event"},[Te]:{exposure:"event"},[w]:{exposure:"hidden"},[k]:{exposure:"hidden"},[ye]:{exposure:"event"},[_]:{exposure:"hidden"},[f]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[xe]:{exposure:"hidden"},[Ie]:{exposure:"hidden"},[Re]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[Me]:{exposure:"hidden"},[Fe]:{exposure:"hidden"},[Ae]:{exposure:"hidden"},[re]:{exposure:"event"},[oe]:{exposure:"event"},[ae]:{exposure:"event"},[le]:{exposure:"event"},[De]:{exposure:"event"},[$e]:{exposure:"event"},[Ne]:{exposure:"hidden"},[Be]:{exposure:"hidden"},[qe]:{exposure:"hidden"},[He]:{exposure:"hidden"},[Ue]:{exposure:"hidden"},[ze]:{exposure:"hidden"},[We]:{exposure:"hidden"},[je]:{exposure:"hidden"},[Ve]:{exposure:"hidden"},[Ke]:{exposure:"event"}},_k=[[ge,{exposure:"hidden"}],[_e,{exposure:"hidden"}],[fe,{exposure:"hidden"}]],fk=e=>{const t=gk[e];if(t)return t;for(const[t,i]of _k)if(0===e.indexOf(t))return i},vk={flags:f,surveys:P},mk=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],yk=e=>`${e}_cookie_identity_change_pending`,bk=e=>{let t="",i=0;for(const n of e){const e=encodeURIComponent(JSON.stringify(n).slice(1,-1)).length;if(i+e>1e3)break;t+=n,i+=e}return t},Sk="main",wk=[y,p,g,C,v,f,m,S],kk=e=>-1!==wk.indexOf(e),Ck=[z,j],Ek=e=>-1!==Ck.indexOf(e),Tk=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},xk=e=>{if(!e)return{};const t=JSON.parse(e);return Et(t)?t:{}},Ik=(e,t)=>{Hr(e,(i,n)=>{const s=fk(n);s&&"event"!==s.exposure||{}.hasOwnProperty.call(t,n)||delete e[n]})};var Rk=class{constructor(t,i,n=!0,s=!t.cookieless_mode){if(this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=t,this._ownsSplitStorage=n,this.props={},this._campaign_params_url=void 0,this._name=(e=>{let 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"})(t),this._disabled=t.disable_persistence||!!i,this._storage=this._buildStorage(t),this._splitStorage=this._resolveSplitStorage(t),this.load(s),this._markLoadedCrossTabFeatureFlagChangesPending(),t.debug&&Nr.info("Persistence loaded",t.persistence,ct({},this.props)),this.update_config(t,t,i),this.save(),e){const t=()=>this.flush();Kr(e,"beforeunload",t,{capture:!1}),Kr(e,"pagehide",t,{capture:!1}),this._onStorage=t=>{if(this._splitStorageEligible&&(!t.storageArea||t.storageArea===(null==e?void 0:e.localStorage))&&t.key)if(t.key!==this._name){if(this._splitStorage){const e=pk.find(e=>t.key===this._groupEntryName(e));e&&this._syncCrossTabFeatureFlagProperties(t.key,e)}}else this._syncCrossTabFeatureFlagProperties(t.key,Sk)},Kr(e,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!kk(e)||!0===i)return;if(!0===t)return void this._setCrossTabFeatureFlagChangesPending(e,!0);const n=new Set(i||[]);t.forEach(e=>n.add(e)),n.size&&this._setCrossTabFeatureFlagChangesPending(e,n)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&e&&(e.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i=!0){if(this._disabled)return!1;let n,s;try{if(s=Dl._get(e),Pt(s)){const e=this._slotWriteState(t);return e.storageValue=null,t!==Sk&&(e.persisted=!1),!1}n=xk(s)}catch(e){return!1}const r=t===Sk?n:Dl._parse(this._name);if(r&&this._hasCrossTabFeatureFlagIdentityMismatch(r))return!1;const o=this._mergeCrossTabFeatureFlagProperties(n,t,i);return t===Sk&&this._splitStorage&&!Tk(this._partitionProps().main,n)||this._rememberCrossTabStorageFingerprint(n,t,!0,s),o}_hasCrossTabFeatureFlagIdentityMismatch(e){const t=this.props[D],i=e[D];return!xt(t)&&!xt(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,n){const s=this._slotWriteState(t);s.storageValue=n,t!==Sk&&(s.persisted=i);try{s.fingerprint=this._entryFingerprint(e,t)}catch(e){s.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){let n=!1;return wk.forEach(i=>{var s;const r=null===(s=fk(i))||void 0===s?void 0:s.storageGroup;if(t===Sk&&this._splitStorage&&r||t!==Sk&&r!==t)return;const o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&Tk(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),n=!0)}),n&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),n}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;const e=Dl._get(this._name),t=this._slotWriteState(Sk);let i,n=!1,s=!1;if(e!==t.storageValue)if(Pt(e))t.storageValue=null;else{if(i=xk(e),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(i),this._crossTabFeatureFlagIdentityMismatch)return!1;s=this._mergeCrossTabFeatureFlagProperties(i,Sk,!1),!this._splitStorage||Tk(this._partitionProps().main,i)?this._rememberCrossTabStorageFingerprint(i,Sk,!0,e):t.storageValue=e,n=!0}return this._splitStorage&&pk.forEach(e=>{const t=Dl._get(this._groupEntryName(e)),r=this._slotWriteState(e),o=i||{},a=n&&wk.some(t=>{var i;return(null===(i=fk(t))||void 0===i?void 0:i.storageGroup)===e&&t in o});if(t===r.storageValue&&!a)return;if(Pt(t))return r.storageValue=null,r.persisted=!1,void(a&&(s=this._mergeCrossTabFeatureFlagProperties(o,e,!1)||s));const l=xk(t);s=this._mergeCrossTabFeatureFlagProperties(l,e,!1)||s,this._rememberCrossTabStorageFingerprint(l,e,!0,t)}),s}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);const i=fk(e);(null==i?void 0:i.volatile)||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||Sk).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){wk.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{const e=Dl._get(this._name),t=xk(e);this._slotWriteState(Sk).storageValue=e,wk.forEach(e=>{var i;const n=this._splitStorage?null===(i=fk(e))||void 0===i?void 0:i.storageGroup:void 0,s=n?Dl._get(this._groupEntryName(n)):null;if(n){const e=this._slotWriteState(n);e.storageValue=s,e.persisted=!Pt(s)}const r=n&&!Pt(s)?xk(s):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,r[e],this.props[e]):e in r&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){const n=new Set(kt(t)?t:[]),s=new Set(kt(this.props[e])?this.props[e]:[]);return i.forEach(e=>s.has(e)?n.add(e):n.delete(e)),Array.from(n)}const n=Et(t)?ct({},t):{},s=Et(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in s?n[e]=s[e]:delete n[e]}),n}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(!kk(e))return;const n=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0===n)return;let s=t;if(this._splitStorageEligible)try{var r;const t=this._splitStorage?null===(r=fk(e))||void 0===r?void 0:r.storageGroup:void 0,i=t?this._groupEntryName(t):this._name;s=xk(Dl._get(i))[e]}catch(e){}const o=new Set(n||[]);if("$active_feature_flags"===e){if(!xt(t)&&!kt(t)||!xt(s)&&!kt(s)||!kt(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const n=new Set(t||[]),r=new Set(s||[]),a=new Set(i);new Set([...n,...a]).forEach(e=>{n.has(e)!==a.has(e)&&o.add(e)}),o.forEach(e=>{r.has(e)===a.has(e)&&o.delete(e)})}else{if(!Et(i))return void(Tk(s,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));{if(!xt(t)&&!Et(t)||xt(t)&&Tt(i)&&xt(s))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const n=Et(t)?t:{},r=Et(s)?s:{};new Set([...Object.keys(n),...Object.keys(i)]).forEach(e=>{e in n==e in i&&Tk(n[e],i[e])||o.add(e)}),o.forEach(e=>{e in r==e in i&&Tk(r[e],i[e])&&o.delete(e)})}}o.size?this._setCrossTabFeatureFlagChangesPending(e,o):this._pendingCrossTabFeatureFlagChanges.delete(e)}_saveDebounceMs(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return Ft(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{const t=Ul(e,this._config.cookie_persisted_properties||[]),i=Wl(t,this._config.cookie_persisted_properties||[]),n=JSON.stringify(t)+"|"+JSON.stringify(i),s=Ll._get(this._name)||void 0;s&&Vl(this._name,s)===n&&(this._lastSeenCookiePropertiesFingerprint=n,this._lastSeenMainCookieValue=s)}catch(e){}else try{const e=Ll._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=e?Vl(this._name,e):void 0,this._lastSeenMainCookieValue=e}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t=!1){if(this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;let i;try{i=Ll._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;const n=Vl(this._name,i);let s;try{s=Hl(JSON.parse(i))}catch(e){return!1}if((Ll._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=n,this._lastSeenMainCookieValue=i;const r=jl(this._name,i),o=[...Nl,...r.properties],a={};if(Object.keys(s).forEach(e=>{const t=s[e];(xt(t)||Pt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete s[e])}),Tt(s))return!1;const l="distinct_id"in s||"anonymous"===s.$user_state||"identified"===s.$user_state,c=this.props,u=c[D],d=c[xe],h=Ur({},c);[...Nl,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in s)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){const t=h[e];(r.isValid||-1===Nl.indexOf(e)||!1!==t&&0!==t)&&delete h[e]}}),this.props=Ur(h,s),wk.forEach(e=>{const t=e in this.props;e in c===t&&Tk(c[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,c[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in s||"$user_state"in this.props||this._setProp(xe,Je);const m=this.props[D],k=this.props[xe];return!l||m===u&&k===d||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Jl._set(yk(this._name),!0),this._deleteProp(S),this._deleteProp(p),this._deleteProp(y),this._deleteProp(g),this._deleteProp(C),this._deleteProp(v),this._deleteProp(f),this._deleteProp(_),this._deleteProp(w),"anonymous"!==k||"identified"!==d&&"anonymous"!==s.$user_state&&(xt(u)||m===u)||(Ik(this.props,s),this._deleteProp(b)),"identified"===k?this.props.$user_id=m:delete this.props.$user_id,this._deleteProp(q)),!0}consumeCookieIdentityChange(){const e=yk(this._name),t=this._cookieIdentityChangePending||!!Jl._get(e);return this._cookieIdentityChangePending=!1,t&&Jl._remove(e),t}_beginCookieSyncSuppression(e=!1){return!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[Sk],this._writeNow(!0))}_endCookieSyncSuppression(e=!0){if(this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(t){-1===mk.indexOf(t.persistence.toLowerCase())&&(Nr.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");const i=((t=[],i=!1,n=()=>!1)=>{const s=[...Nl,...t];return ct(ct({},Dl),{},{_rawText(e){return[Ll._get(e),Ll._get(Bl(e)),Dl._get(e)].join("\0")},_parse(e){try{let r,o={};try{r=Ll._get(e)||void 0,o=r?Hl(JSON.parse(r)):{}}catch(e){}const a=JSON.parse(Dl._get(e)||"{}");let l;if(i){const i=jl(e,r),n=[...Nl,...i.properties],c={};Object.keys(o).forEach(e=>{const t=o[e];Pt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(c[e]=t)});const u="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state;if(Object.keys(c).length>0){var t;const e=a[D],r=null!==(t=a.$user_state)&&void 0!==t?t:Je;s.forEach(e=>{if(-1!==n.indexOf(e)&&!(e in o)&&(u||"distinct_id"!==e&&"$user_state"!==e)){const t=a[e];(i.isValid||-1===Nl.indexOf(e)||!1!==t&&0!==t)&&delete a[e]}}),!u||"$user_state"in o||"$user_state"in a||(a[xe]=Je),!u||("distinct_id"in c?c[D]:a[D])===e&&("$user_state"in c?c[xe]:a[xe])===r||($l.forEach(e=>delete a[e]),"identified"===c.$user_state&&"distinct_id"in c?a.$user_id=c[D]:delete a.$user_id,"identified"!==c.$user_state&&(delete a[ye],delete a[b]),delete a.__alias)}l=Ur(a,c)}else l=Ur(o,a);return n()||Dl._set(e,l),l}catch(e){}return null},_set(e,n,s,r,o,a){const l=Dl._set(e,n,void 0,void 0,a);try{const c=Ul(n,t);if(Object.keys(c).length){if(i){const i=Bl(e),u=Wl(c,t);if(Ll._set(i,u,s,r,o,a),Ll._get(i)!==JSON.stringify(u)){Ll._remove(i,r);const t=Ul(n);return Ll._set(e,t,s,r,o,a),l}}Ll._set(e,c,s,r,o,a)}}catch(e){Dl._error(e)}return l},_remove(t,i){try{null==e||e.localStorage.removeItem(t),Ll._remove(t,i),Ll._remove(Bl(t),i)}catch(e){Dl._error(e)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict,()=>!!this._disabled);let n,s=!1,r=!1;const o=t.persistence.toLowerCase();return"localstorage"===o&&Dl._is_supported()?(n=Dl,r=!0):"localstorage+cookie"===o&&i._is_supported()?(n=i,r=!0,s=!0):"sessionstorage"===o&&Jl._is_supported()?n=Jl:"memory"===o?n=Ql:"cookie"===o&&Ll._is_supported()?(n=Ll,s=!0):i._is_supported()?(n=i,r=!0,s=!0):Ll._is_supported()?(n=Ll,s=!0):n=Ql,this._splitStorageEligible=r,this._storesIdentityInCookie=s,n}_groupEntryName(e){return`${this._name}__${e}`}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){const e={};return Hr(this.props,(t,i)=>{const n=fk(i);if(!n||"event"===n.exposure){var s;if(null==n||null===(s=n.shouldSkipFromEventProperties)||void 0===s?void 0:s.call(n,t))return;e[i]=t}}),e}load(e=!1){if(this._disabled&&!e)return;const t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?Dl._parse(this._name):null;let n={};if(t)try{n=Hl(Ll._parse(this._name)),Hr(n,(e,t)=>{(xt(e)||Pt(e)||""===e)&&delete n[t]})}catch(e){}const s=this._storage._parse(this._name);if(s&&(this.props=Ur({},s)),this._splitStorage&&this._loadGroupEntries(),t&&s){var r,o;const e=null==i?void 0:i[D],t=null!==(r=null==i?void 0:i.$user_state)&&void 0!==r?r:Je,a=s[D],l=null!==(o=s.$user_state)&&void 0!==o?o:Je;if(a!==e||l!==t){this._cookieIdentityChangePending=!0,this._disabled||Jl._set(yk(this._name),!0);const i=Ur({},this.props);$l.forEach(e=>delete i[e]),"anonymous"!==l||"identified"!==t&&"anonymous"!==n.$user_state&&(xt(e)||a===e)||(Ik(i,n),delete i[b]),this.props=i;const s=new Set;$l.forEach(e=>{var t;const i=null===(t=fk(e))||void 0===t?void 0:t.storageGroup;i&&s.add(i)}),s.forEach(e=>{if(this._disabled)return;const t={};Hr(this.props,(i,n)=>{var s;(null===(s=fk(n))||void 0===s?void 0:s.storageGroup)===e&&(t[n]=i)}),Tt(t)?(Dl._remove(this._groupEntryName(e)),this._slotState[e]={}):Dl._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Jl._get(yk(this._name))&&(this._cookieIdentityChangePending=!0)}_loadGroupEntries(){for(const e of pk){const t=Dl._parse(this._groupEntryName(e));if(t&&!Tt(t)){const i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Ur(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null===(i=fk(t))||void 0===i?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){const i=vk[e];if(!i)return!1;const n=t[i],s=this.props[i];return Ft(n)&&Ft(s)&&s>n}refreshKey(e){this._refreshKeys([e])}_refreshKeys(e){if(this._disabled)return;let t,i=!1;const n=()=>(i||(t=this._storage._parse(this._name),i=!0),t);e.forEach(e=>{var t;if(this._metaIdentifierChangePending.has(e))return;const i=this._splitStorage?null===(t=fk(e))||void 0===t?void 0:t.storageGroup:void 0,s=i?Dl._parse(this._groupEntryName(i)):n();if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){const t=n();if(t&&e in t)return void this._setProp(e,t[e],!1)}this._deleteProp(e,!1)}})}refreshMetaIdentifiers(){if(this._disabled)return;const e=this._storageSnapshot();(xt(e)||e!==this._metaIdentifierStorageSnapshot)&&(this._refreshKeys(Ck),this._rememberMetaIdentifierStorageSnapshot(e))}_rememberMetaIdentifierStorageSnapshot(e=this._storageSnapshot()){this._metaIdentifierStorageSnapshot=0===this._metaIdentifierChangePending.size?e:void 0}_storageSnapshot(){const e=this._storage._rawText?this._storage._rawText(this._name):this._storage._get(this._name);return It(e)?e:void 0}save(){if(this._disabled)return;const e=this._saveDebounceMs();e>0?xt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}flush(){xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e=!1){if(this._disabled||this._cookieSyncSuppressed&&!e)return;e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||this.refreshMetaIdentifiers());const t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);const i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)return void(this._config.debug&&Nr.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));const n=this._writeEntry(this._storage,this._name,this.props,Sk);"written"===n&&this._rememberCurrentCookieProperties(this.props),"failed"!==n&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),"written"===n&&this._rememberMetaIdentifierStorageSnapshot(),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}_writeNowSplit(){const{main:e,groups:t}=this._partitionProps(),i=this._writeEntry(this._storage,this._name,e,Sk);"written"===i&&this._rememberCurrentCookieProperties(e),"failed"!==i&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),wk.forEach(e=>{var t;(null===(t=fk(e))||void 0===t?void 0:t.storageGroup)||this._pendingCrossTabFeatureFlagChanges.delete(e)})),"written"===i&&this._rememberMetaIdentifierStorageSnapshot();for(const e of pk){var n;const i=t[e];if(Tt(i)&&!(null===(n=this._slotState[e])||void 0===n?void 0:n.persisted)){wk.forEach(t=>{var i;(null===(i=fk(t))||void 0===i?void 0:i.storageGroup)===e&&this._pendingCrossTabFeatureFlagChanges.delete(t)});continue}const s=this._writeEntry(Dl,this._groupEntryName(e),i,e);"failed"!==s&&wk.forEach(t=>{const i=fk(t);(null==i?void 0:i.storageGroup)!==e||"written"!==s&&i.volatile||this._pendingCrossTabFeatureFlagChanges.delete(t)})}}_partitionProps(){const e={},t={flags:{},surveys:{}};return Hr(this.props,(i,n)=>{var s;const r=null===(s=fk(n))||void 0===s?void 0:s.storageGroup;r?t[r][n]=i:e[n]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===Sk)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;const i={};return Hr(e,(e,t)=>{var n;i[t]=(null===(n=fk(t))||void 0===n?void 0:n.volatile)?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,n){const s=this._slotWriteState(n);if(n!==Sk&&!s.dirty&&!xt(s.fingerprint))return"skipped";let r;try{if(r=this._entryFingerprint(i,n),r===s.fingerprint)return s.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(s.dirty=!1,n!==Sk&&(s.persisted=!0),xt(r)||(s.fingerprint=r),this._splitStorageEligible&&(s.storageValue=Dl._get(t)),"written"):(this._config.debug&&Nr.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this._markAllCrossTabFeatureFlagChangesPending(),xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!e&&this._ownsSplitStorage)for(const e of pk)Dl._remove(this._groupEntryName(e));e?delete this._slotState[Sk]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Et(e)){this.syncCookieProperties(),xt(t)&&(t="None"),this._expire_days=xt(i)?this._default_expiry:i;let n=!1;if(Hr(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),n=!0)}),n)return this.save(),!0}return!1}register(e,t){if(Et(e)){this.syncCookieProperties(),this._expire_days=xt(t)?this._default_expiry:t;let i=!1;if(Hr(e,(t,n)=>{e.hasOwnProperty(n)&&(this.props[n]!==t||Et(t)||kt(t))&&(this._setProp(n,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t="string"==typeof e?[e]:e;let i=!1;for(const e of t)e in this.props&&(this._deleteProp(e),i=!0);i&&this.save()}update_campaign_params(){const e=null==n?void 0:n.URL;if(e===this._campaign_params_url)return;const t=Pc(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!Tt(jr(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}update_search_keyword(){this.register(function(){const e=null==n?void 0:n.referrer;return e?Fc(e):{}}())}update_referrer_info(){var e;this.register_once({$referrer:Dc(),$referring_domain:(null==n?void 0:n.referrer)&&(null===(e=Yr(n.referrer))||void 0===e?void 0:e.host)||Oc},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=$c(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Fe]:this._storesIdentityInCookie?{r:bk(e.r),u:e.u?bk(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Hr([Me,Pe],t=>{const i=this.props[t];i&&Hr(i,function(t,i){e["$initial_"+mt(i)]=t})});const t=this.props[Fe];if(t){const i=function(e,t=!1){const i=Nc(e,t),n={};return Hr(i,function(e,t){n[`$initial_${mt(t)}`]=e}),n}(t,this._config.disable_capture_url_hashes);Ur(e,i)}return e}safe_merge(e){return Hr(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){const n=e.persistence!==t.persistence,s=!((e,t)=>{if(e.length!==t.length)return!1;const i=[...e].sort(),n=[...t].sort();return i.every((e,t)=>e===n[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=n||s,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this._disabled&&!a;a||this._syncCookieProperties(t,l),this._config=e,!a&&(n||s||o)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(ct(ct({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=r||o?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();const u=this._resolveSplitStorage(e),d=r||u!==this._splitStorage,h=!a&&(d||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(l);this._storageMigrationInProgress=d;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const e=this.props;this.clear(),this._storage=c,this._splitStorage=u,this.props=e,this.save()}else o&&(this._storage=c,a||(delete this._slotState[Sk],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){const e=this.props[Fe];if(!this._storesIdentityInCookie||!Et(e)||"string"!=typeof e.r)return;const t=bk(e.r),i="string"==typeof e.u?bk(e.u):e.u;t===e.r&&i===e.u||this._setProp(Fe,ct(ct({},e),{},{r:t,u:i}))}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){const i=this.props.__timers||{};i[e]=t,this._setProp(V,i),this.save()}remove_event_timer(e){const t=this.props.__timers||{},i=t[e];return xt(i)||(delete t[e],this._setProp(V,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i=!0){var n;const s=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||s===t||(this._localIdentityChangePending=!0),Ek(e)&&!Tk(s,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,s,t),(null===(n=fk(e))||void 0===n?void 0:n.volatile)||this._markGroupDirty(e))}_deleteProp(e,t=!0){delete this.props[e],t&&(kk(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),Ek(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t;const i=null===(t=fk(e))||void 0===t?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}};const Pk={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"},Mk={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"},Fk=Br("[RateLimiter]");var Ak=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Fk.info(`${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void Fk.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?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}get isClientRateLimited(){return 1>this._refilledBucket().tokens}clientRateLimitContext(e=!1){var t;const i=this._refilledBucket(),n=1>i.tokens;if(n||e||(i.tokens=Math.max(0,i.tokens-1)),n&&!e){const e=(Ft(i.dropped)?i.dropped:0)+1;i.dropped=e,!this.lastEventRateLimited&&this._captureWarning(e)&&(i.dropped=0)}return this.lastEventRateLimited=n,null===(t=this.instance.persistence)||void 0===t||t.set_property("$capture_rate_limit",i),{isRateLimited:n,remainingTokens:i.tokens}}_refilledBucket(){var e;const{captureEventsBurstLimit:t,captureEventsPerSecond:i}=this,n=(new Date).getTime(),s=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property(Re),r=s?ct({},s):{tokens:t,last:n};return r.tokens+=Math.max(0,n-r.last)/1e3*i,r.last=Math.max(r.last,n),r.tokens>t&&(r.tokens=t),r}_isPropertyAllowed(e){const t=this.instance.config.property_denylist;return!kt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&(null==s?void 0:s.pathname))return`${null!==(e=s.origin)&&void 0!==e?e:""}${s.pathname}`}_captureWarning(e){var t,i;const{captureEventsBurstLimit:n,captureEventsPerSecond:s}=this,r=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null===(t=(i=this.instance).get_session_id)||void 0===t?void 0:t.call(i):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${s} events per second and ${n} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}};const Lk=Br("[RemoteConfig]");var Ok=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null===(e=d._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config}_loadRemoteConfigJs(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.loadExternalDependency)?null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return Lk.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Lk.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return Lk.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){Lk.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||Lk.warn("Failed to fetch remote config from PostHog."):Lk.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){Lk.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null===(i=this._instance.featureFlags)||void 0===i||i.ensureFlagsLoaded()}catch(e){Lk.error("Error loading feature flags",e)}}};let Dk=!Zy&&-1===(null==c?void 0:c.indexOf("MSIE"))&&-1===(null==c?void 0:c.indexOf("Mozilla"));function $k(e,t,i){var n,s,r,o;i&&(t=ct(ct({},t),{},{callback:e=>i(e)})),e.__loaded?Dk?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(r=t.callback)||void 0===r||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=ct(ct({},e.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(n=e.compression)&&void 0!==n?n:t.compressionFallback:t.compression,(xt(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,null===(s=t.onDispatch)||void 0===s||s.call(t),((e,t)=>{var i,n,s;const r=ct(ct({},e),{},{callback:null!=t?t:t=>{var i;return null===(i=e.callback)||void 0===i?void 0:i.call(e,t)}});r.timeout=r.timeout||6e4;const o=null!==(i=r.transport)&&void 0!==i?i:"fetch";"sendBeacon"===o&&xt(r.compression)&&r.data&&(r.compression=Iy.Base64),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(e=>{var t,i;const n=(kt(e)?e:[e]).map(e=>ct(ct({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),s=n[0];return{api_key:null!==(t=null==s||null===(i=s.properties)||void 0===i?void 0:i.token)&&void 0!==t?t:null==s?void 0:s.token,batch:n,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((e,t=(new Date).toISOString())=>kt(e)?e.map(e=>ct(ct({},e),{},{sent_at:t})):ct(ct({},e),{},{sent_at:t}))(r.data))),r.url=fb(r.url,r.method,r.compression,r.timestampMode);const a=vb.filter(e=>!r.disableTransport||!e.transport||!r.disableTransport.includes(e.transport)),c=null!==(n=null===(s=function(e,t){for(let i=0;e.length>i;i++)if(t(e[i]))return e[i]}(a,e=>e.transport===o))||void 0===s?void 0:s.method)&&void 0!==n?n:a[0].method;if(!c)throw new Error("No available transport method");const u=e=>{try{c(e)}catch(e){var t;db(e)?Nr.warn(e):Nr.error(e),null===(t=r.callback)||void 0===t||t.call(r,{statusCode:0,error:e})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===Iy.GZipJS&&l&&"undefined"!=typeof Promise&&!ib?lb(r).then(e=>{u(e)}).catch(t=>{if(hs(t))return ib=!0,void u(ct(ct({},r),{},{compression:void 0,url:fb(e.url,e.method,void 0,e.timestampMode)}));ps(t)&&(ib=!0),u(r)}):u(r)})(t,(n,s)=>{var r,o,a;e.rateLimiter.checkForLimiting(n),400>n.statusCode||null===(r=(o=e.config).on_request_error)||void 0===r||r.call(o,n),i?i(n,s):null===(a=t.callback)||void 0===a||a.call(t,n)})):t.fireCallbackOnDrop&&(null===(o=t.callback)||void 0===o||o.call(t,{statusCode:0}))}var Nk=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Kt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Nr.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();const 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(ct(ct({},e),{},{callback:void 0}),"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flush()},this._flushTimeoutMs))}_flush(){if(this._queue.length>0){const e=this._formatQueue();for(const t in e)this._sendRequestSafely(e[t])}}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Nr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){const e={},t={};Hr(this._queue,i=>{var n;const s=i,r=((s?s.batchKey:null)||s.url)+(s.batchGroup?`:${s.batchGroup}`:"");xt(e[r])&&(e[r]=ct(ct({},s),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),t[r]=[]),null===(n=e[r].data)||void 0===n||n.push(s.data),s.callback&&t[r].push(s.callback)});for(const i in t){const n=t[i];n.length&&(e[i].callback=e=>{for(const t of n)t(e)})}return this._queue=[],e}};const Bk=["retriesPerformedSoFar"];var qk=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!xt(e)&&"onLine"in e.navigator){if(this._areWeOnline=e.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Kr(e,"online",this._onlineListener),Kr(e,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,t){let{retriesPerformedSoFar:i}=e,n=ys(e,Bk);At(i)&&(n.url=sb(n.url,{retry_count:i})),$k(this._instance,t?ct(ct({},n),{},{transport:t}):n,(e,t)=>{var s;if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=i?i:0))return void this._enqueue(ct({retriesPerformedSoFar:i},n),t);0===e.statusCode&&Nr.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!=i?i:0} retries.`)}null===(s=n.callback)||void 0===s||s.call(n,e)})}_enqueue(e,t){const i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;const n=Math.max(function(e){const t=3e3*Math.pow(2,e),i=t/2,n=Math.min(18e5,t),s=(Math.random()-.5)*(n-i);return Math.ceil(n+s)}(i),null!=t?t:0),s=Date.now()+n;this._queue.push({retryAt:s,requestOptions:e});let r=`Enqueued failed request for retry in ${n}`;navigator.onLine||(r+=" (Browser is offline)"),Nr.warn(r),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(){const e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,xt(e)||(this._onlineListener&&(e.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(e.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0));for(const{requestOptions:e}of this._queue)try{this._instance._send_request(ct(ct({},e),{},{callback:kt(e.data)?void 0:e.callback,transport:"sendBeacon"}))}catch(e){Nr.error(e)}this._queue=[]}},Hk=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,n;this._context||(this._context={});const s=this.scrollElement(),r=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=r+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(r),this._context.maxScrollY=Math.max(r,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!==(n=this._context.maxContentHeight)&&void 0!==n?n:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){const e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Kr(e,"scroll",this._updateScrollData,{capture:!0}),Kr(e,"scrollend",this._updateScrollData,{capture:!0}),Kr(e,"resize",this._updateScrollData)}scrollElement(){if(this._scrollRoot){const i=kt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(const n of i){var t;const i=null==e||null===(t=e.document)||void 0===t?void 0:t.querySelector(n);if(i)return i}return}var i;return null==e||null===(i=e.document)||void 0===i?void 0:i.documentElement}_scrollPosition(t){var i,n;const s="y"===t?"scrollTop":"scrollLeft";if(this._scrollRoot){const e=this.scrollElement();return e&&e[s]||0}return e?"y"===t?e.scrollY||e.pageYOffset||(null===(i=e.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollTop)||0:e.scrollX||e.pageXOffset||(null===(n=e.document)||void 0===n||null===(n=n.documentElement)||void 0===n?void 0:n.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}};const Uk=e=>$c(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);var zk=class{constructor(e,t,i,n){this._onSessionIdCallback=e=>{const t=this._getStored();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[Ie]:i})},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=n||Uk,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Ie]}getSetOnceProps(){var e;const t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?Nc(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(){const e={};return Hr(jr(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e[`$session_entry_${mt(i)}`]=t}),e}};const Wk=Br("[SessionId]"),jk=864e5;var Vk=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var n;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Py,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("always"===e.config.cookieless_mode)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._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Rl,this._windowIdGenerator=i||Rl;const s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Kt(this._config.session_idle_timeout_seconds||1800,60,36e3,Wk.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()){const e=Jl._parse(this._window_id_storage_key),t=Jl._parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:Jl._remove(this._window_id_storage_key),Jl._set(this._primary_window_exists_storage_key,!0)}(null===(n=this._config.bootstrap)||void 0===n?void 0:n.sessionID)&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return xt(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&&Jl._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Jl._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Jl._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){const t=this._lastPersistedActivityTimestamp;return!Pt(t)&&!Pt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){const n=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!n||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[ce]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return At(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(ce):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(Pt(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._lastPersistedActivityTimestamp)return;this._refreshSessionIdFromStorage();const[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[ce]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}_freshestActivityTimestamp(){const[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(){const e=this._persistence.props[ce];return kt(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t=!1){const i=((e,t=(new Date).getTime())=>{try{const i=(e=>{const t=e.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)})(e);return i>t+6e4?void Wk.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Wk.error("Invalid sessionID in bootstrap",e)}})(e);return!xt(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&e&&(e.removeEventListener(Xe,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Jl._remove(this._primary_window_exists_storage_key)},Kr(e,Xe,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if("always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const n=t||(new Date).getTime(),s=this._sessionId;if(i)this._lastCookieSyncTimestamp=n;else if(Pt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>n||n-this._lastCookieSyncTimestamp>=1e3){var r,o;null===(r=(o=this._persistence).syncCookieProperties)||void 0===r||r.call(o),this._lastCookieSyncTimestamp=n}let[,a,l]=this._getSessionId();const c=!xt(s)&&a!==s,u=this._freshestActivityTimestamp();let d=this._getWindowId();const h=this._pendingBootstrapSession,p=!!h&&(h.sessionStartTimestamp>n+6e4||n-h.sessionStartTimestamp>jk),g=h?p:At(l)&&Math.abs(n-l)>jk;let _=!1,f=c,v=!a||!!h;const m=a;let y=!v&&!e&&this._sessionHasBeenIdleTooLong(n,u);if(y&&(y=this._isSessionIdleAfterCrossTabRefresh(n),y||Wk.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this._getSessionId(),y||(v=!a||!!h)),v||y||g){f=!1;const e=h&&!p;a=e?h.sessionId:this._sessionIdGenerator(),d=this._windowIdGenerator(),Wk.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:v,activityTimeout:y,sessionPastMaximumLength:g}}),l=e?h.sessionStartTimestamp:n,this._pendingBootstrapSession=void 0,_=!0}else d||(d=this._windowIdGenerator(),_=!0),f=f||a!==m,f&&(Wk.info("adopted cross-tab session id",{sessionId:a,windowId:d}),_=!0);const b=At(u)&&e&&!g?u:n,S=At(l)?l:(new Date).getTime();this._setWindowId(d),this._setSessionId(a,b,S),e||this._resetIdleTimer();const w={noSessionId:v,activityTimeout:y,sessionPastMaximumLength:g,crossTabAdoption:f};return _&&this._sessionIdChangedHandlers.forEach(e=>e(a,d,w)),{sessionId:a,windowId:d,sessionStartTimestamp:S,changeReason:_?w:void 0,lastActivityTimestamp:u}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){const e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};const Gk=Object.freeze(["2026-08-30","2026-08-29","2026-06-25","2026-05-30","2026-01-30","2025-11-30","2025-05-24"]),Qk=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Qt(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if((null==i?void 0:i.brands)&&i.brands.some(e=>Qt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function Kk(){return Kk=rt(function*(){const e=null==i?void 0:i.userAgentData;if(null==e?void 0:e.getHighEntropyValues)try{const 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 Nr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}),Kk.apply(this,arguments)}const Jk="custom",Yk="i.posthog.com",Zk=/^\/static\//,Xk=["/s/","/e/","/i/"];var eC=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${Yk}`,".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":Jk),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(!Zk.test(e))return;const t=this.instance.config.asset_host;return"string"==typeof t&&t.trim().replace(/\/$/,"")||void 0}_urlKey(e){const t=Yr(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;let n=i;const s=this.instance.config.rewriteRequestPath;if(s){var r;const e=(null===(r=Yr(i))||void 0===r?void 0:r.href)||i;n=s(new URL(e)).toString()}if(s&&"api"===e&&Xk.some(e=>0===t.indexOf(e))){const e=this._urlKey(n);if(e){const t=this.apiHost;let i=this._ingestionEndpoints;(null==i?void 0:i.apiHost)===t&&i.rewriteRequestPath===s||(i={apiHost:t,rewriteRequestPath:s,urls:new Set},this._ingestionEndpoints=i),i.urls.add(e)}}return n}isIngestionEndpoint(e){const t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t=""){if(t&&(t="/"===t[0]?t:`/${t}`),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){const i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,`${i}${t}`)}if(this.region===Jk)return this._prepareEndpoint(e,t,this.apiHost+t);const i=Yk+t;switch(e){case"assets":return this._prepareEndpoint(e,t,`https://${this.region}-assets.${i}`);case"api":return this._prepareEndpoint(e,t,`https://${this.region}.${i}`)}}};const tC=Br("[PostHog ExternalIntegrations]"),iC={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var nC=class{constructor(e){this._instance=e}_loadScript(e,t){var i,n;null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,e,e=>{if(e)return tC.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e;for(const[s,r]of Object.entries(null!==(e=this._instance.config.integrations)&&void 0!==e?e:{})){var t,i,n;r&&!(null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t?void 0:t[s])&&this._loadScript(iC[s],()=>{var e;null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e||null===(e=e[s])||void 0===e||e.start(this._instance)}),!r&&(null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[s])&&(null===(n=d.__PosthogExtensions__)||void 0===n||null===(n=n.integrations)||void 0===n||null===(n=n[s])||void 0===n||n.stop())}}};const sC={};let rC=0;const oC=()=>{},aC='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',lC="Surveys module not available",cC="sanitize_properties is deprecated. Use before_send instead",uC="Invalid value for property_denylist config: ",dC=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],hC=["$feature_flag_called","$$heatmap","$snapshot"],pC=e=>"$"===e.charAt(0)&&!ft(hC,e),gC=/^[A-Za-z0-9_-]{1,400}$/,_C=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,fC=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,vC=["token","distinct_id",Oe],mC="posthog",yC=[...Gk].sort()[Gk.length-1],bC=e=>{const t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},SC=t=>{var i;return ct({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Qr(null==n?void 0:n.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:oC,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!0,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:s&&It(null==s?void 0:s.search)&&-1!==s.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==e||null===(i=e.location)||void 0===i?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(e){Nr.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:Ze,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:oC},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:xo,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:bC(e),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),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(t))},wC=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],kC=e=>{const t={};for(const[i,n]of wC)xt(e[i])||(t[n]=e[i]);const i=Ur({},t,e),n=e.__preview_external_dependency_versioned_paths;return xt(n)||(xt(e.strict_script_versioning)&&(i.strict_script_versioning=!!n),It(n)&&xt(e.asset_host)&&(i.asset_host=n)),kt(e.property_blacklist)&&(xt(e.property_denylist)?i.property_denylist=e.property_blacklist:kt(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Nr.error(uC+e.property_denylist)),i};var CC=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Nr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},EC=class t{_removeExtension(e){if(!e)return;const t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}_replaceExtension(e,t){var i;return this._removeExtension(e),this._extensions.push(t),null===(i=t.initialize)||void 0===i||i.call(t),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(this._hasWarnedAboutVolatileIdentity)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this._inCookielessMode())return;const e="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!e&&!this.config.disable_persistence)return;if(this._hasStableInitialDistinctId)return;let t,i,n;e?(t=`persistence is set to '${this.config.persistence}'`,i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",n="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",n="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${n}`)}_syncCookielessIdentity(){const e=this.persistence;if(!e||this._isConsentTransition)return;if(this._inCookielessMode())return void("on_reject"===this.config.cookieless_mode&&"$posthog_cookieless"!==this.get_distinct_id()&&(this._sync_opt_out_with_persistence(),this._enterCookielessMode()));if("$posthog_cookieless"!==this.get_distinct_id())return;this._is_persistence_disabled()||e.load(!0);const t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){const t=this.config.get_device_id(Rl());this.register({distinct_id:t,$device_id:t}),e.set_property(xe,Je)}this._sync_opt_out_with_persistence()}get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new CC,this._personProcessingSetOncePropertiesSent=!1,this.version=Yl.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Py,this._extensions=[],this._extensionEventPropertyProducers=[],this._replayDebugPropertiesPaused=!1,this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._isConsentTransition=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=SC(),this.SentryIntegration=dk,this.sentryIntegration=e=>function(e,t){const i=uk(e,t);return{name:ck,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 Hk(this),this.pageViewManager=new hk(this),this.rateLimiter=new Ak(this),this.requestRouter=new eC(this),this.consent=new ik(this),this.externalIntegrations=new nC(this);const i=null!==(e=t.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(e,t,i)=>{const n=It(e)?{[e]:t}:e;this.setPersonProperties(n),null==i||i({})},set_once:(e,t,i)=>{const n=It(e)?{[e]:t}:e;this.setPersonProperties(void 0,n),null==i||i({})}},this.on("eventCaptured",e=>Nr.info(`send "${null==e?void 0:e.event}"`,e))}init(e,i,n){if(n&&n!==mC){var s;const r=null!==(s=sC[n])&&void 0!==s?s:new t;return r._init(e,i,n),sC[n]=r,sC[mC][n]=r,r}return this._init(e,i,n)}_init(t,i={},n){var s,r,o;const a=It(t)?t.trim():"";if(!a)return Nr.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==(null===(l=this.config)||void 0===l?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=SC(i.defaults),i.debug=this._checkLocalStorageForDebug(i.debug),this._originalUserConfig=i,this._triggered_notifs=[],i.person_profiles?this._initialPersonProfilesConfig=i.person_profiles:i.process_person&&(this._initialPersonProfilesConfig=i.process_person);const c=SC(i.defaults),u=kC(i),d=Ur({},c,u,{name:n,token:a});Et(c.rageclick)&&Et(u.rageclick)&&(d.rageclick=Ur({},c.rageclick,u.rageclick)),Et(c.session_recording)&&Et(u.session_recording)&&(d.session_recording=Ur({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Nr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:Iy.GZipJS;const h=this._is_persistence_disabled(),p=!this._inCookielessMode();if(this.persistence=new Rk(this.config,h,!0,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Rk(ct(ct({},this.config),{},{persistence:"sessionStorage"}),h,!1,p),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!h&&Jl._is_supported()){const e=Jl._parse(this._sessionRegisteredPropertiesStorageKey);kt(e)&&e.forEach(e=>{It(e)&&this._sessionRegisteredPropKeys.add(e)})}else Jl._remove(this._sessionRegisteredPropertiesStorageKey);const g=ct({},this.persistence.props),_=ct({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Nk((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new qk(this),this.__request_queue=[];const f=this._inCookielessMode();f||(this.sessionManager=new Vk(this),this.sessionPropsManager=new zk(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{((null==i?void 0:i.activityTimeout)||(null==i?void 0:i.sessionPastMaximumLength)||(null==i?void 0:i.crossTabAdoption))&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Nr.info("Deferring extension initialization to improve startup performance"),this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._initExtensions(f)},0)):(Nr.info("Initializing extensions synchronously"),this._initExtensions(f)),Yl.DEBUG=Yl.DEBUG||this.config.debug,Yl.DEBUG&&Nr.info("Starting in debug mode",{this:this,config:i,thisC:ct({},this.config),p:g,s:_}),this.config.identity_distinct_id&&!(null===(s=i.bootstrap)||void 0===s?void 0:s.distinctID)&&(i.bootstrap=ct(ct({},i.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const v=null===(r=i.bootstrap)||void 0===r?void 0:r.distinctID;if(this._hasStableInitialDistinctId=!!v&&!Rt(v),null===(o=i.bootstrap)||void 0===o?void 0:o.distinctID){const e=i.bootstrap.distinctID,t=this.get_distinct_id(),n=this.persistence.get_property(xe);if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"anonymous"===n)this.identify(e);else if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"identified"===n)Nr.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{const t=this.config.get_device_id(Rl()),n=i.bootstrap.isIdentifiedID?t:e;this.persistence.set_property(xe,i.bootstrap.isIdentifiedID?Ye:Je),this.register({distinct_id:e,$device_id:n})}}if(f)this.register_once({distinct_id:Le,$device_id:null},"");else if(!this.get_distinct_id()){const e=this.config.get_device_id(Rl());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(xe,Je)}return Kr(e,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Kr(e,"pageshow",e=>{if(this._isPageUnloading=!1,!this._isShutdown){var t;if(e.persisted&&this.persistence){const e=this.persistence.get_property(D),t=this.persistence.get_property(xe);this.persistence.load(),this._processCookieIdentityChange()||e===this.persistence.get_property("distinct_id")&&t===this.persistence.get_property("$user_state")||this._processIdentityChange()}null===(t=this._retryQueue)||void 0===t||t.resume()}}),i.segment?lk(this,()=>this._loaded()):this._loaded(),Ct(this.config._onCapture)&&this.config._onCapture!==oC&&(Nr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Nr.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 Kk.apply(this,arguments)}().then(e=>{e&&this.register({[B]:e})}).catch(oC),this}_isSharedExtension(e){const t=e;return It(t.name)&&Ct(t.setup)}_enrollExtension(e,t){var i=this;this._isSharedExtension(e)?t.push(rt(function*(){try{yield e.setup(i._getBrowserClientAdapter())}catch(i){Nr.error(`Failed to set up extension "${e.name}"`,i);try{var t;yield null===(t=e.dispose)||void 0===t?void 0:t.call(e)}catch(t){Nr.error(`Failed to dispose extension "${e.name}"`,t)}}})):this._extensions.push(e)}_enrollFeatureFlags(){var e,i,n,s=this;const r=null!==(e=null===(i=this.config.__extensionClasses)||void 0===i?void 0:i.featureFlags)&&void 0!==e?e:null===(n=t.__defaultExtensionClasses)||void 0===n?void 0:n.featureFlags;var o,a,l;if(r)if(this.featureFlags&&this.featureFlags instanceof r||(null===(o=this._featureFlagsReloadingUnsubscribe)||void 0===o||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new r(this)),Ct(this.featureFlags.onReloading)&&Ct(this.featureFlags.setup)){if(!this._featureFlagsReloadingUnsubscribe){this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)});const e=this.featureFlags;rt(function*(){try{yield e.setup(s._getBrowserClientAdapter())}catch(t){Nr.error("Failed to set up feature flags",t);const i=s._featureFlagsReloadingUnsubscribe;s._featureFlagsReloadingUnsubscribe=void 0;try{null==i||i()}catch(e){Nr.error("Failed to unsubscribe feature flag reloading",e)}try{yield e.dispose()}catch(e){Nr.error("Failed to dispose feature flags",e)}}})()}}else null===(a=(l=this.featureFlags).initialize)||void 0===a||a.call(l)}_initExtensions(e){const i=performance.now(),n=ct(ct({},t.__defaultExtensionClasses),this.config.__extensionClasses),s=[];var r,o,a,l,c,u,d,h;n.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new n.exceptions(this)),n.historyAutocapture&&this._extensions.push(this.historyAutocapture=new n.historyAutocapture(this)),n.tracingHeaders&&this._extensions.push(this.tracingHeaders=new n.tracingHeaders(this)),n.siteApps&&this._extensions.push(this.siteApps=new n.siteApps(this)),n.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new n.sessionRecording(this)),this.config.disable_scroll_properties||s.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),n.autocapture&&this._enrollExtension(this.autocapture=new n.autocapture(this),s),n.surveys&&this._enrollExtension(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new n.surveys(this),s),n.logs&&this._enrollExtension(this.logs=null!==(a=this.logs)&&void 0!==a?a:new n.logs(this),s),n.metrics&&this._extensions.push(this.metrics=null!==(l=this.metrics)&&void 0!==l?l:new n.metrics(this)),n.conversations&&this._extensions.push(this.conversations=null!==(c=this.conversations)&&void 0!==c?c:new n.conversations(this)),n.productTours&&this._extensions.push(this.productTours=new n.productTours(this)),n.heatmaps&&this._extensions.push(this.heatmaps=new n.heatmaps(this)),n.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new n.webVitalsAutocapture(this)),n.exceptionObserver&&this._extensions.push(this.exceptionObserver=new n.exceptionObserver(this)),n.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new n.deadClicksAutocapture(this,rk)),n.toolbar&&this._extensions.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new n.toolbar(this)),n.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new n.experiments(this)),n.webMCP&&this._extensions.push(this.webMCP=null!==(h=this.webMCP)&&void 0!==h?h:new n.webMCP(this)),this._extensions.forEach(e=>{e.initialize&&s.push(()=>{var t;null===(t=e.initialize)||void 0===t||t.call(e)})}),s.push(()=>{if(this._pendingRemoteConfig){const e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}}),this._processInitTaskQueue(s,i)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void(this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._processInitTaskQueue(e,t)},0));const i=e.shift();if(i)try{i()}catch(e){Nr.error("Error initializing extension:",e)}}const i=Math.round(performance.now()-t);this.register_for_session({[De]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[$e]:i}),this.config.__preview_deferred_init_extensions&&Nr.info(`PostHog extensions initialized (${i}ms)`)}_onRemoteConfig(e){if(!n||!n.body)return Nr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var t;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=ft(i.supportedCompression,Iy.GZipJS)?Iy.GZipJS:ft(i.supportedCompression,Iy.Base64)?Iy.Base64:void 0),(null===(t=i.analytics)||void 0===t?void 0:t.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Ze}),this._internalEventEmitter.emit("extensionsRemoteConfig",e),this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}_loaded(){try{this.config.loaded(this)}catch(e){Nr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&(null==s?void 0:s.hostname)){const e=s.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 Ok(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.is_capturing()&&qr(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,n,s,r;this._isPageUnloading=!0,null===(e=this.surveys)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e),null===(i=this.metrics)||void 0===i||i.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(tt),null===(n=this.logs)||void 0===n||n.flushLogs("sendBeacon"),null===(s=this._requestQueue)||void 0===s||s.unload(),null===(r=this._retryQueue)||void 0===r||r.unload()):this._shouldCapturePageleave()&&this.capture(tt,null,{transport:"sendBeacon"})}_send_request(e){$k(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?ct(ct({},e),{},{transport:t}):e)}_execute_array(e){rC++;try{let t;const i=[],n=[],s=[];qr(e,e=>{if(e)if(t=e[0],kt(t))s.push(e);else if(Ct(e))try{e.call(this)}catch(t){Nr.error("Error executing queued PostHog call",e,t)}else kt(e)&&"alias"===t?i.push(e):kt(e)&&-1!==t.indexOf("capture")&&Ct(this[t])?s.push(e):n.push(e)});const r=function(e,t){qr(e,function(e){try{if(kt(e[0])){let i=t;Hr(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Nr.error("Error executing queued PostHog call",e,t)}})};r(i,this),r(n,this),r(s,this)}finally{rC--}}push(e){if(rC>0&&kt(e)&&It(e[0])){const i=t.prototype[e[0]];return void(Ct(i)&&i.apply(this,e.slice(1)))}this._execute_array([e])}get _facebookClickIdChannel(){return{property:U,persistenceKey:z,cookieName:"_fbc",pattern:_C,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[z]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(z)}}}get _facebookBrowserIdChannel(){return{property:W,persistenceKey:j,cookieName:"_fbp",pattern:fC,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[j]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(j)}}}_getPersistedMetaIdentifier(e){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(e.persistenceKey);return It(i)&&e.pattern.test(i)?{value:i,delivered:!1}:Et(i)&&It(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(!this.config.save_campaign_params||this._inCookielessMode())return;const t=wl(e.cookieName);return It(t)&&e.pattern.test(t)?t:void 0}_updateFacebookClickId(e,t,i,n){if(!this.persistence)return;const s=this._facebookClickIdChannel;this.persistence.refreshMetaIdentifiers();const r=this._getPersistedMetaIdentifier(s);if(n)return void s.unregister();if(i)return It(t)&&_C.test(t)?this._storeMetaIdentifier(s,t,r):void s.unregister();const o=It(e)&&gC.test(e)?e:void 0,a=this._readMetaCookie(s);return a&&((e,t,i)=>{const n=e.split(".");if(t)return n[3]===t;if(!i)return!0;const s=i.value.split(".");return n[3]===s[3]||Number(n[2])>Number(s[2])})(a,o,r)?this._storeMetaIdentifier(s,a,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this._storeMetaIdentifier(s,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}_updateFacebookBrowserId(e,t,i){if(!this.persistence)return;const n=this._facebookBrowserIdChannel;this.persistence.refreshMetaIdentifiers();const s=this._getPersistedMetaIdentifier(n);if(i)return void n.unregister();if(t)return It(e)&&fC.test(e)?this._storeMetaIdentifier(n,e,s):void n.unregister();const r=this._readMetaCookie(n);return r?this._storeMetaIdentifier(n,r,s):s?{value:s.value,pending:!s.delivered}:void 0}_markMetaIdentifierDelivered(e,t){if(!this.persistence)return;this.persistence.refreshMetaIdentifiers();const i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}capture(e,t,i){var n,s,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void Nr.uninitializedWarning("posthog.capture");if(!this.is_capturing())return void Nr.info(`Event "${e}" was not captured because capturing is disabled (opted out or consent pending).`);if(xt(e)||!It(e))return void Nr.error("No event name provided to posthog.capture");if(this._syncCookielessIdentity(),"$snapshot"===e&&this._inCookielessMode())return;const o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return void Nr.info(`Event "${e}" was not captured because the user agent looks like a bot. Set \`opt_out_useragent_filter: true\` to capture it.`);const a=(null==i?void 0:i.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==a?void 0:a.isRateLimited)return void Nr.critical("This capture call is ignored due to client rate limiting.");let l;(null==t?void 0:t.$current_url)&&!It(null==t?void 0:t.$current_url)&&(Nr.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==i?void 0:i._originatedFromCaptureException)||Nr.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&&(l=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();const c=new Date,u=(null==i?void 0:i.timestamp)||c,d=an(null==i?void 0:i.uuid,Rl);let h={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&o&&(h.event="$bot_pageview",h.properties.$browser_type="bot"),a&&(h.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const p="$feature_flag_called"===e&&!1===h.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==i?void 0:i.$set)&&!p&&(h.$set=null==i?void 0:i.$set);const g=Et(null==t?void 0:t.$set)?t.$set:void 0,_=kt(null==t?void 0:t.$unset)?t.$unset:[],f=(null==i?void 0:i.$unset)||[],v=e=>{var t;const n=!!(null==i?void 0:i.$set)&&e in i.$set;return{hasProvided:n||!!g&&e in g,provided:n?null==i||null===(t=i.$set)||void 0===t?void 0:t[e]:null==g?void 0:g[e],unset:-1!==_.indexOf(e)||-1!==f.indexOf(e)}},m=v(U),y=v(W),b=[{channel:this._facebookClickIdChannel,hasProvided:m.hasProvided,update:this._updateFacebookClickId(null==l?void 0:l.fbclid,m.provided,m.hasProvided,m.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:y.hasProvided,update:this._updateFacebookBrowserId(y.provided,y.hasProvided,y.unset)}];for(const{channel:e,hasProvided:t,update:i}of b)i&&!0===h.properties.$process_person_profile&&i.pending&&!t&&!p&&(h.$set=ct({[e.property]:i.value},h.$set));const S=null==i?void 0:i.$unset;S&&(h.$unset=S);const w=p?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==nt,e===it);if(w&&(h.$set_once=w),(null==i?void 0:i._noTruncate)||(k=this.config.properties_string_max_length,h=function(e,t){const i=new Set;return function e(n,s){if(n!==Object(n))return t?t(n):n;if(i.has(n))return;let r;if(i.add(n),kt(n))r=[],qr(n,t=>{r.push(e(t))});else{const t={};Hr(qt(n)?Vr(n):n,(n,s)=>{i.has(n)||(t[s]=e(n,s))}),r=t}return r}(e)}(h,e=>It(e)?e.slice(0,k):e)),h.timestamp=u,xt(null==i?void 0:i.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=c),p&&(h.properties=((e,t=[])=>{const i={},n=t=>{void 0!==e[t]&&(i[t]=e[t])};return ls.forEach(n),t.forEach(n),i})(h.properties,vC)),e===$f.DISMISSED||e===$f.SENT){const i=null==t?void 0:t[Nf.SURVEY_ID],n=null==t?void 0:t[Nf.SURVEY_ITERATION];Vf({id:i,current_iteration:n}),h.$set=ct(ct({},h.$set),{},{[sc({id:i,current_iteration:n},e===$f.SENT?"responded":"dismissed")]:!0})}else e===$f.SHOWN&&(h.$set=ct(ct({},h.$set),{},{[Nf.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var k;if(e===Pk.SHOWN){const e=null==t?void 0:t[Mk.TOUR_TYPE];e&&(h.$set=ct(ct({},h.$set),{},{[`${Mk.TOUR_LAST_SEEN_DATE}/${e}`]:(new Date).toISOString()}))}const C=ct(ct({},h.properties.$set),h.$set);if(Tt(C)||this.setPersonPropertiesForFlags(C),!Mt(this.config.before_send)){const e=this._runBeforeSend(h);if(!e)return;h=e,h.uuid=an(h.uuid,Rl)}this.sessionRecording&&!this._replayDebugPropertiesPaused&&pC(e)&&(this._replayDebugPropertiesPaused=!0,setTimeout(()=>this._replayDebugPropertiesPaused=!1,3e4));const E=b.filter(({channel:e,update:t})=>{var i,n,s;const r=null!==(i=null===(n=h.$set)||void 0===n?void 0:n[e.property])&&void 0!==i?i:Et(null===(s=h.properties)||void 0===s?void 0:s.$set)?h.properties.$set[e.property]:void 0;return(null==t?void 0:t.pending)&&r===t.value});this._internalEventEmitter.emit("eventCaptured",h);const T=null!==(n=null==i?void 0:i._url)&&void 0!==n?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),x="recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(T),I=ct(ct(ct({method:"POST",url:T,data:h,compression:"best-available",preferSyncCompression:null==i?void 0:i.send_instantly,timestampMode:x?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},x&&(null===(s=h.properties)||void 0===s?void 0:s.$session_id)?{batchGroup:h.properties.$session_id+(h.properties.$window_id?`-${h.properties.$window_id}`:"")}:{}),(null==i?void 0:i.transport)?{transport:i.transport}:{}),E.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(const{channel:e,update:t}of E)this._markMetaIdentifierDelivered(e,t.value)}}:{});if(!this.config.request_batching||i&&!(null==i?void 0:i._batchKey)||(null==i?void 0:i.send_instantly)){var R;let e;!I.transport&&!I.callback&&Tt(null!==(R=this.config.request_headers)&&void 0!==R?R:{})&&this._isPageUnloading&&(e="sendBeacon"),this._send_retriable_request(I,e)}else this._requestQueue.enqueue(I);return null===(r=this.featureFlags)||void 0===r||r.sendFlagCallsPendingCapture(),h}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null===(t=this._browserClientAdapter)||void 0===t?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new Sb(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);let t=!0;return()=>{if(!t)return;t=!1;const i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}_processCookieIdentityChange(e=!0){var t;return!!(null===(t=this.persistence)||void 0===t?void 0:t.consumeCookieIdentityChange())&&(this._processIdentityChange(e),!0)}_processIdentityChange(e=!0){var t,i,n;this._cachedPersonProperties=null,"anonymous"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))&&(null===(n=this.sessionPersistence)||void 0===n||n.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null===(i=this.featureFlags)||void 0===i||i.reset(),e&&this.reloadFeatureFlags()}calculateEventProperties(t,i,r,o,a){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return i;this._syncCookielessIdentity(),this.persistence.syncCookieProperties(),this._processCookieIdentityChange();const l=a?void 0:this.persistence.remove_event_timer(t);let u=ct({},i);if(u.token=this.config.token,u.$config_defaults="latest"===this.config.defaults?yC:this.config.defaults,this._inCookielessMode()&&(u[Oe]=!0),"$snapshot"===t){const e=ct(ct({},this.persistence.properties()),this.sessionPersistence.properties());return u.distinct_id=e.distinct_id,(!It(u.distinct_id)&&!Ft(u.distinct_id)||Rt(u.distinct_id))&&Nr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}const d=function(t,i,n,r=!1){var o,a,l,u;if(!c)return{};const d=t?[...Tc,...i||[]]:[],[h,p]=Qi(c),[g,_]=function(e){for(let t=0;Zi.length>t;t++){const[i,n,s]=Zi[t],r=e.match(i);if(r){const t=s&&e.match(s)||r;return[n,(null==t?void 0:t[1])||""]}}return["",""]}(c),f=function(){const e="u">typeof navigator?navigator:void 0;return(null==e?void 0:e.brave)?{brave:!0}:{}}(),v={};xt(n)||(v.detectGoogleSearchApp=n);const m={},y=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,b=null===(a=navigator)||void 0===a?void 0:a.maxTouchPoints,S=null==e||null===(l=e.screen)||void 0===l?void 0:l.width,w=null==e||null===(u=e.screen)||void 0===u?void 0:u.height,k=null==e?void 0:e.devicePixelRatio;xt(y)||(m.userAgentDataPlatform=y),xt(b)||(m.maxTouchPoints=b),xt(S)||(m.screenWidth=S),xt(w)||(m.screenHeight=w),xt(k)||(m.devicePixelRatio=k);const C=Ur(jr({$os:h,$os_version:p,$browser:Wi(c,navigator.vendor,f,v),$webview_app:g,$webview_app_version:_,$device:Ki(c),$device_type:Ji(c,m),$timezone:Ec(),$timezone_offset:Bc()}),{$current_url:ro(r?cn(null==s?void 0:s.href):null==s?void 0:s.href,d,Ic),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:c.length>1e3?c.substring(0,997)+"...":c,$browser_version:Vi(c,navigator.vendor,f,v),$browser_language:Ac(),$browser_language_prefix:Lc(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:Dr.LIB_NAME,$lib_version:Dr.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Dr.SDK_DIST_CHANNEL&&(C.$sdk_dist_channel=Dr.SDK_DIST_CHANNEL),C}(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){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(a,r.getTime(),!0);u.$session_id=e,u.$window_id=t}this.sessionPropsManager&&Ur(u,this.sessionPropsManager.getSessionProps());try{var h;if(this.sessionRecording){const e=this.sessionRecording.sdkDebugProperties,i=!this._replayDebugPropertiesPaused&&pC(t);for(const t in e)(i||ft(dC,t))&&(u[t]=e[t])}u.$sdk_debug_retry_queue_size=null===(h=this._retryQueue)||void 0===h?void 0:h.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}let p;if(this.requestRouter.region===Jk&&(u.$lib_custom_api_host=this.config.api_host),p="$pageview"!==t||a?"$pageleave"!==t||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),u=Ur(u,p),"$pageview"===t&&n&&(u.title=n.title),!xt(l)){const e=r.getTime()-l;u.$duration=parseFloat((e/1e3).toFixed(3))}c&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?"bot":"browser");const g=this.persistence.properties(),_=this.sessionPersistence.properties(),f=u.$groups,v=g.$groups;Et(f)&&!Tt(f)&&(u.$groups=ct(ct({},Et(v)?v:{}),f)),Hr(["$referrer","$referring_domain"],e=>{e in g&&delete _[e]});const m={};if(this._extensionEventPropertyProducers.length>0)for(const e of this._extensionEventPropertyProducers.slice())try{Ur(m,e())}catch(e){Nr.error("Failed to produce browser extension event properties",e)}u=Ur({},d,g,_,ct(ct({},m),u)),u.$is_identified=this._isIdentified(),kt(this.config.property_denylist)?Hr(this.config.property_denylist,function(e){delete u[e]}):Nr.error(uC+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(Nr.error(cC),u=y(u,t));const b=this._hasPersonProcessing();return u.$process_person_profile=b,b&&!a&&this._requirePersonProcessing("_calculate_event_properties"),u}_calculate_set_once_properties(e,t=!0,i=!1){var n;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;const s=this.persistence.get_initial_props(),r=null===(n=this.sessionPropsManager)||void 0===n?void 0:n.getSetOnceProps();let o=Ur({},s,r||{},e||{});const a=this.config.sanitize_properties;return a&&(Nr.error(cC),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),Tt(o)?void 0:o}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var n;null===(n=this.persistence)||void 0===n||n.register_once(e,t,i)}register_for_session(e){var t,i;null===(t=this.persistence)||void 0===t||t.syncCookieProperties(),this._processCookieIdentityChange(),null===(i=this.sessionPersistence)||void 0===i||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(!this._sessionRegisteredPropertiesStorageKey)return;if("memory"===this.config.persistence||(null===(e=this.sessionPersistence)||void 0===e?void 0:e._disabled)||!Jl._is_supported())return void Jl._remove(this._sessionRegisteredPropertiesStorageKey);const t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Jl._set(this._sessionRegisteredPropertiesStorageKey,t):Jl._remove(this._sessionRegisteredPropertiesStorageKey)}getFeatureFlag(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null===(t=this.featureFlags)||void 0===t?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,n;return null!==(i=null===(n=this.featureFlags)||void 0===n?void 0:n.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null===(e=this.featureFlags)||void 0===e||e.reloadFeatureFlags()}updateFlags(e,t,i){var n;null===(n=this.featureFlags)||void 0===n||n.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var n;null===(n=this.featureFlags)||void 0===n||n.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t=!1,i){var n;return null===(n=this.featureFlags)||void 0===n?void 0:n.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:lC}),()=>{})}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:lC})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:lC})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:lC}),()=>{})}renderSurvey(e,t){var i;null===(i=this.surveys)||void 0===i||i.renderSurvey(e,t)}displaySurvey(e,t=Qf){var i;null===(i=this.surveys)||void 0===i||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null===(t=this.surveys)||void 0===t||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null===(i=this.surveys)||void 0===i?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:lC}}canRenderSurveyAsync(e,t=!1){var i,n;return null!==(i=null===(n=this.surveys)||void 0===n?void 0:n.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:lC})}_validateIdentifyId(e){return!e||Rt(e)?(Nr.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Nr.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())||(Nr.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 Nr.uninitializedWarning("posthog.identify");if(Ft(e)&&(e=e.toString(),Nr.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))return;if(!this._requirePersonProcessing("posthog.identify"))return;this._syncCookielessIdentity();const n=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==n,r=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression();let a=!1;try{const n=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:n},""),e!==n&&e!==this.get_property("__alias")&&(this.unregister(q),this.register({distinct_id:e}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Je,c=e!==n,u=!c&&o;if(c&&o){var l;const s=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:n};this.persistence.set_property(xe,Ye),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",s,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=vc(e,t,i)),null===(l=this.featureFlags)||void 0===l||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:n)}else if(u){this.persistence.set_property(xe,Ye);const n=t||{},s=i||{};this.setPersonPropertiesForFlags({$set:n,$set_once:s},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:n,$set_once:s})&&(this._cachedPersonProperties=vc(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);c||s||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(w)):u&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}setPersonProperties(e,t){if(!e&&!t)return;if(!this._requirePersonProcessing("posthog.setPersonProperties"))return;const i=vc(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)):Nr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var t;const i=(kt(e)?e:[e]).filter(e=>It(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null===(t=this.featureFlags)||void 0===t||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var n;if(!e||!t)return void Nr.error("posthog.group requires a group type and group key");null===(n=this.persistence)||void 0===n||n.syncCookieProperties(),this._processCookieIdentityChange();const s=this.getGroups(),r=s[e]!==t;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ct(ct({},s),{},{[e]:t})}),(r||i)&&this._hasPersonProcessing()){const n={$group_type:e,$group_key:t};i&&(n.$group_set=i),this.capture(nt,n)}i&&this.setGroupPropertiesForFlags({[e]:i}),r&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;null===(t=this.featureFlags)||void 0===t||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var i;this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null===(i=this.featureFlags)||void 0===i||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null===(t=this.featureFlags)||void 0===t||t.resetGroupPropertiesForFlags(e)}reset(e){const t=Lt(e)?e:null==e?void 0:e.resetDeviceID,i=Lt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t=!1,i){var n,s,r,o,a,l;if(Nr.info("reset"),!this.__loaded)return Nr.uninitializedWarning("posthog.reset");const c=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null===(n=this._originalUserConfig)||void 0===n?void 0:n.bootstrap)||{},null===(s=this.featureFlags)||void 0===s||null===(r=s.updateConfig)||void 0===r||r.call(s,this.config,this._shouldDisableFlags());const u=this.get_property(N),d=this.get_property(B),h=this.get_property(ie);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const p=this.is_capturing();t||this.consent.reset(),t||!p||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const g=null===(a=this.persistence)||void 0===a||null===(l=a._beginCookieSyncSuppression)||void 0===l?void 0:l.call(a),_=this._isConsentTransition;this._isConsentTransition=_||t;let f=!1;try{var v,m,y,b,S,w,k,C,E,T,x,I,R;if(null===(v=this.persistence)||void 0===v||v.clear(),null===(m=this.sessionPersistence)||void 0===m||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),xt(h)||null===(T=this.persistence)||void 0===T||T.register({$session_recording_remote_config:h}),null===(y=this.surveys)||void 0===y||y.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(S=this.conversations)||void 0===S||S.reset(),null===(w=this.logs)||void 0===w||w.reset(),null===(k=this.metrics)||void 0===k||k.reset(),null===(C=this.persistence)||void 0===C||C.set_property("$user_state","anonymous"),null===(E=this.sessionManager)||void 0===E||E.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Le,$device_id:null},"");else{const t=this.config.get_device_id(Rl());this.register_once({distinct_id:t,$device_id:e?t:u},""),e||xt(d)||this.register({[B]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(i.distinctID&&!this._inCookielessMode()&&(null===(R=this.persistence)||void 0===R||R.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),null===(x=this.featureFlags)||void 0===x||x.initialize(),!Mt(c)&&!(null===(I=this.sessionManager)||void 0===I?void 0:I.setBootstrapSessionId(c,!0))){const e=ct({},i);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,f=!0}finally{var P,M;this._isConsentTransition=_,g&&(null===(P=this.persistence)||void 0===P||null===(M=P._endCookieSyncSuppression)||void 0===M||M.call(P,f))}var F;this._lastRemoteConfig&&(null===(F=this.conversations)||void 0===F||F.onRemoteConfig(this._lastRemoteConfig)),this.reloadFeatureFlags()}shutdown(e){var t=this;return rt(function*(){if(!t.__loaded)return void Nr.uninitializedWarning("posthog.shutdown");t._isShutdown=!0,clearTimeout(t._extensionInitTimeout),t._extensionInitTimeout=void 0;const e=t._featureFlagsReloadingUnsubscribe;t._featureFlagsReloadingUnsubscribe=void 0;for(const i of[()=>{var e;return null===(e=t.sessionRecording)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.flushLogs("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.flush("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.surveys)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.autocapture)||void 0===e?void 0:e.dispose()},()=>null==e?void 0:e(),()=>{var e;return null===(e=t._requestQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t._retryQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t.featureFlags)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.persistence)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.sessionPersistence)||void 0===e?void 0:e.destroy()}])try{const e=i();e&&Ct(e.then)&&e.then(void 0,e=>{Nr.error("Error during shutdown",e)})}catch(e){Nr.error("Error during shutdown",e)}})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null===(i=this.conversations)||void 0===i||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(e=this.conversations)||void 0===e||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?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let n=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if((null==e?void 0:e.withTimestamp)&&i){var s;const t=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return n;n+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return n}alias(e,t){return e===this.get_property("$people_distinct_id")?(Nr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(xt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(q,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Nr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const t=ct({},this.config);if(Et(e)){var i,n,s,r,o,a,l,c,u,d,h,p,g,_;Ur(this.config,kC(e));const b=this._is_persistence_disabled();if(this.persistence){const e="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;var f,v;if(e&&this.sessionPersistence!==this.persistence&&(null===(f=this.sessionPersistence)||void 0===f||f.remove(),null===(v=this.sessionPersistence)||void 0===v||v.destroy()),this.persistence.update_config(this.config,t,b),e)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new Rk(ct(ct({},this.config),{},{persistence:"sessionStorage"}),b,!1);else{var m;null===(m=this.sessionPersistence)||void 0===m||m.update_config(ct(ct({},this.config),{},{persistence:"sessionStorage"}),ct(ct({},t),{},{persistence:"sessionStorage"}),b)}}const S=this._checkLocalStorageForDebug(this.config.debug);var y;Lt(S)&&(this.config.debug=S),Lt(this.config.debug)&&(this.config.debug?(Yl.DEBUG=!0,Dl._is_supported()&&Dl._set("ph_debug",!0),Nr.info("set_config",{config:e,oldConfig:t,newConfig:ct({},this.config)})):(Yl.DEBUG=!1,Dl._is_supported()&&Dl._remove("ph_debug"))),null===(i=this.featureFlags)||void 0===i||null===(n=i.updateConfig)||void 0===n||n.call(i,this.config,this._shouldDisableFlags()),null===(s=this.exceptionObserver)||void 0===s||s.onConfigChange(),null===(r=this.exceptions)||void 0===r||r.onConfigChange(),null===(o=this.metrics)||void 0===o||o.onConfigChange(),null===(a=this.webMCP)||void 0===a||a.startIfEnabled(),null===(l=this.sessionRecording)||void 0===l||l.startIfEnabledOrStop(),null===(c=this.tracingHeaders)||void 0===c||c.startIfEnabledOrStop(),null===(u=this.autocapture)||void 0===u||u.startIfEnabled(),null===(d=this.heatmaps)||void 0===d||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null===(y=this.historyAutocapture)||void 0===y||y.startIfEnabledOrStop()),null===(h=this.exceptionObserver)||void 0===h||h.startIfEnabledOrStop(),null===(p=this.deadClicksAutocapture)||void 0===p||p.startIfEnabledOrStop(),null===(g=this.surveys)||void 0===g||g.loadIfEnabled(),this._sync_opt_out_with_persistence(),null===(_=this.externalIntegrations)||void 0===_||_.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&lk(this,oC,!1)}}_overrideSDKInfo(e,t){Yl.LIB_NAME=e,Yl.LIB_VERSION=t}startSessionRecording(e){const t=!0===e,i={sampling:t||!!(null==e?void 0:e.sampling),linked_flag:t||!!(null==e?void 0:e.linked_flag),url_trigger:t||!!(null==e?void 0:e.url_trigger),event_trigger:t||!!(null==e?void 0:e.event_trigger)};var n,s,r,o,a;Object.values(i).some(Boolean)&&(null===(n=this.sessionManager)||void 0===n||n.checkAndGetSessionAndWindowId(),i.sampling&&(null===(s=this.sessionRecording)||void 0===s||s.overrideSampling()),i.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),i.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),i.event_trigger&&(null===(a=this.sessionRecording)||void 0===a||a.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)||void 0===e?void 0:e.started)}captureException(e,t){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(ct(ct({},i),t))}catch(e){return}}addExceptionStep(e,t){var i;null===(i=this.exceptions)||void 0===i||i.addExceptionStep(e,t)}captureLog(e){var t;null===(t=this.logs)||void 0===t||t.captureLog(e)}get logger(){var e,i;return null!==(e=null===(i=this.logs)||void 0===i?void 0:i.logger)&&void 0!==e?e:t._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?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:mC;return t!==mC&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property("$user_state"))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&Tt(this.getGroups())&&!(null===(e=this.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.__alias)&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!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?(Nr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(Ae,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;const e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t;const i=this._is_persistence_disabled();var n,s,r;return this.is_capturing()||null===(n=this.logs)||void 0===n||n._onOptOut(),(null===(e=this.persistence)||void 0===e?void 0:e._disabled)!==i&&(null===(s=this.persistence)||void 0===s||s.set_disabled(i)),(null===(t=this.sessionPersistence)||void 0===t?void 0:t._disabled)!==i&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(i)),this._persistSessionRegisteredPropKeys(),i}opt_in_capturing(e){var i,n,s;if("always"===this.config.cookieless_mode)return void Nr.warn(aC);if(this._inCookielessMode()){var r,o,a,l,c,u;null===(r=this.sessionRecording)||void 0===r||r.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null===(o=this.sessionManager)||void 0===o||o.destroy(),null===(a=this.pageViewManager)||void 0===a||a.destroy(),this.sessionManager=new Vk(this),this.pageViewManager=new hk(this),this.persistence&&(this.sessionPropsManager=new zk(this,this.sessionManager,this.persistence));const e=null!==(l=null===(c=this.config.__extensionClasses)||void 0===c?void 0:c.sessionRecording)&&void 0!==l?l:null===(u=t.__defaultExtensionClasses)||void 0===u?void 0:u.sessionRecording;var d,h;e&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new e(this)),this._lastRemoteConfig&&(null===(d=this.sessionRecording)||void 0===d||null===(h=d.onRemoteConfig)||void 0===h||h.call(d,this._lastRemoteConfig)))}const p=1===this.consent.consent;var g,_,f;p&&this._syncCookielessIdentity(),this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(g=this.surveys)||void 0===g||g.loadIfEnabled(),null===(_=this.conversations)||void 0===_||_.loadIfEnabled()),p||!xt(null==e?void 0:e.captureEventName)&&!(null==e?void 0:e.captureEventName)||this.capture(null!==(f=null==e?void 0:e.captureEventName)&&void 0!==f?f:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),null===(n=this.persistence)||void 0===n||n.syncCookieProperties(),this._processCookieIdentityChange(),null===(s=this.featureFlags)||void 0===s||s.sendFlagCallsPendingCapture(),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){"always"!==this.config.cookieless_mode?(this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&this._enterCookielessMode()):Nr.warn(aC)}_enterCookielessMode(){var e,t;const i=this.sessionRecording;null==i||i.dispose({discardBufferedEvents:!0}),"$posthog_cookieless"!==this.get_distinct_id()&&this._reset(!0,!0),this.register({distinct_id:Le,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null===(e=this.sessionManager)||void 0===e||e.destroy(),null===(t=this.pageViewManager)||void 0===t||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return!this._isConsentTransition&&("always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?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 i?Qk(i,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){n&&("visible"===n.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(et,{title:n.title},{send_instantly:!0}),this._visibilityStateListener&&(n.removeEventListener(x,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Kr(n,x,this._visibilityStateListener)))}debug(t){!1===t?(null==e||e.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==e||e.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(){const e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Nr.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(e,t,i,n,s){const r=t in e&&!Mt(e[t]),o=i in e&&!Mt(e[i]);return r?e[t]:!!o&&(s&&s.warn(`Config field '${i}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Nr)}_runBeforeSend(e){var t;if(Mt(this.config.before_send))return e;const i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter($t),n=kt(this.config.before_send)?this.config.before_send:[this.config.before_send];let s=e;for(const t of n)try{if(s=t(s),Mt(s)){const t=`Event '${e.event}' was rejected in beforeSend function`;return Dt(e.event)?Nr.warn(`${t}. This can cause unexpected behavior.`):Nr.info(t),null}s.properties&&!Tt(s.properties)||Nr.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return Nr.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(const t of i)if(s.properties&&Mt(s.properties[t]))return Nr.warn(`Event '${e.event}' had its '${t}' 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?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){const t=Lt(e)&&!e,i=Dl._is_supported()&&"true"===Dl._get("ph_debug");return!t&&(!!i||e)}};EC.__defaultExtensionClasses={},EC._noopLogger=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Wr(e.prototype[t[i]])}(EC,["identify"]);const TC=["[data-ph-capture-value]"];var xC=class{constructor(e){this._instance=e}refresh(e){var t;const i=this._instance.config,n=Et(i.autocapture)?i.autocapture:void 0;e.enabled=!!i.autocapture,e.rageclick=i.rageclick,e.maskAllElementAttributes=i.mask_all_element_attributes,e.maskAllText=i.mask_all_text,e.disableCaptureUrlHashes=i.disable_capture_url_hashes,e.getCurrentUrl=i.get_current_url,e.remoteRequestsDisabled=this._instance._shouldDisableFlags(),e.url_allowlist=null==n?void 0:n.url_allowlist,e.url_ignorelist=null==n?void 0:n.url_ignorelist,e.dom_event_allowlist=null==n?void 0:n.dom_event_allowlist,e.element_allowlist=null==n?void 0:n.element_allowlist,e.css_selector_allowlist=null==n?void 0:n.css_selector_allowlist,e.css_selector_ignorelist=null==n?void 0:n.css_selector_ignorelist,e.element_attribute_ignorelist=null==n?void 0:n.element_attribute_ignorelist,e.capture_copied_text=null==n?void 0:n.capture_copied_text,e.capture_value_css_selector_allowlist=null!==(t=null==n?void 0:n.capture_value_css_selector_allowlist)&&void 0!==t?t:TC}};const IC=Br("[ExceptionAutocapture]"),RC=Br("[TracingHeaders]"),PC=Br("[Web Vitals]"),MC=9e5,FC=["CLS","FCP","INP","LCP"],AC=["INP","LCP"],LC=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],OC=Br("[SessionRecording]"),DC=[Ne,Be,qe,He,Ue,ze,We,je,Ve],$C=Br("[Heatmaps]");function NC(e){return Et(e)&&"clientX"in e&&"clientY"in e&&Ft(e.clientX)&&Ft(e.clientY)}const BC=Br("[Product Tours]"),qC=e=>{var t;return!e.config.disable_product_tours&&!!(null===(t=e.persistence)||void 0===t?void 0:t.get_property(X))},HC=["$set_once","$set"],UC=Br("[SiteApps]"),zC="Error while initializing PostHog app with config id ",WC=(()=>(null==e?void 0:e.location)?oo(e.location.hash,"__posthog")||oo(location.hash,"state"):null)(),jC="_postHogToolbarParams",VC=Br("[Toolbar]"),GC=Br("[FeatureFlags]"),QC=Br("[FeatureFlags]",{debugEnabled:!0}),KC="\" failed. Feature flags didn't load in time.",JC=[502,504],YC=["click","keydown","wheel","touchstart","pointerdown"],ZC="connection_error",XC=e=>{const t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},eE=e=>{const t={};for(const[i,n]of zr(e||{}))n&&(t[i]=n);return t},tE=(e,t)=>e.distinctId===t.distinctId&&e.sessionId===t.sessionId&&((e,t)=>{const i=Object.keys(e);return i.length===Object.keys(t).length&&i.every(i=>e[i]===t[i])})(e.groups,t.groups);var iE=class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=GC,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._reloadingHandlers=[],this._pendingReloads=new Set,this._activeReloads=new Set,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._requestGeneration=0,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._firingFeatureFlagsCallbacks=!1,this._flagCallsPendingCapture=new Map,this._sendingFlagCallsPendingCapture=!1,this._flagsLoadedFromRemote=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._hadUserInteraction=!1,this._onOnline=()=>{const e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t;const i=this._refreshIntervalMs,n=null!==(e=this._dueRefreshIntervalMs)&&void 0!==e?e:i;xt(i)||xt(n)||this._config.remoteRequestsDisabled||!this._document||"hidden"===this._document.visibilityState||Date.now()-(null!==(t=this._lastRefreshAt)&&void 0!==t?t:0)<n||(this._dueRefreshIntervalMs=this._hadUserInteraction||!this._config.idleRefreshBackoff?i:Math.min(2*n,36e5),this._hadUserInteraction=!1,this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onUserInteraction=()=>{this._hadUserInteraction&&this._dueRefreshIntervalMs===this._refreshIntervalMs||this._resumeConfiguredInterval()},this._onVisibilityChange=()=>{var e;"visible"===(null===(e=this._document)||void 0===e?void 0:e.visibilityState)&&this._resumeConfiguredInterval()},this._configSource=e}get _crossTabPersistence(){}_onConfigUpdated(){this._client&&this._syncAutomaticRefresh()}setup(e){try{this._window=typeof window>"u"?void 0:window,this._document=typeof document>"u"?void 0:document}catch(e){this._window=void 0,this._document=void 0}return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),Oy(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(e){var t;if(this._client===e)return this._window&&Kr(this._window,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=e.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null===(t=this._crossTabPersistence)||void 0===t?void 0:t.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_resumeConfiguredInterval(){this._hadUserInteraction=!0,this._dueRefreshIntervalMs=this._refreshIntervalMs,this._refreshIfDue()}_syncAutomaticRefresh(){var e;const t=this._config.refreshIntervalMs,i=!this._config.remoteRequestsDisabled&&this._document&&!xt(t)&&t>0?t:void 0;this._config.idleRefreshBackoff||(this._dueRefreshIntervalMs=i),i!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),xt(i)||(this._refreshIntervalMs=i,this._dueRefreshIntervalMs=i,this._scheduleNextRefresh(),(null===(e=this._document)||void 0===e?void 0:e.addEventListener)&&(Kr(this._document,x,this._onVisibilityChange),qr(YC,e=>{Kr(this._document,e,this._onUserInteraction,{capture:!0})}))))}_scheduleNextRefresh(){xt(this._refreshIntervalMs)||(xt(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){var e,t;xt(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null===(e=this._document)||void 0===e||null===(t=e.removeEventListener)||void 0===t||t.call(e,"visibilitychange",this._onVisibilityChange),qr(YC,e=>{var t,i;null===(t=this._document)||void 0===t||null===(i=t.removeEventListener)||void 0===i||i.call(t,e,this._onUserInteraction,{capture:!0})})),this._refreshIntervalMs=void 0,this._dueRefreshIntervalMs=void 0,this._hadUserInteraction=!1,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var e,t,i;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._client&&(this._clearDebouncer(),null===(e=this._dynamicProperties)||void 0===e||e.dispose(),this._dynamicProperties=void 0,null===(t=this._crossTabPersistenceUnsubscribe)||void 0===t||t.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null===(i=this._window)||void 0===i||i.removeEventListener("online",this._onOnline),this._client=void 0)}get _config(){return this._configSource.get()}_prop(e){var t;return this._bootstrapState&&e in this._bootstrapState?this._bootstrapState[e]:null===(t=this._client)||void 0===t?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!xt(null===(e=this._client)||void 0===e?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){if(!this._crossTabPersistence||!e.$enabled_feature_flags)return;const n=this._prop("$enabled_feature_flags")||{},s=e.$enabled_feature_flags||{},r=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,e])=>!(null==e?void 0:e.failed)).map(([e])=>e):[],a=!!t.errorsWhileComputingFlags&&!!t.flags,l=a?o:i&&!kt(r)?Object.keys(r||{}):Array.from(new Set([...Object.keys(n),...Object.keys(s)])),c=this._prop("$feature_flag_payloads")||{},u=e.$feature_flag_payloads||{},d=a||i?l:Array.from(new Set([...Object.keys(c),...Object.keys(u)])),h=!a&&!i,_=!!h||l,b=!!h||d,S={[p]:_,[y]:_,[C]:b};e.$feature_flag_details&&(S[g]=_);for(const t of[v,f,m])xt(e[t])||(S[t]=!0);this._crossTabPersistence.markCrossTabFeatureFlagChanges(S)}_remove(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){const e={};for(const t of[p,C,v,E]){const i=this._prop(t);xt(i)||(e[t]=i)}this._baseEventProperties=e;const t=ct({},e),i=this._prop(y);if(i)for(const[e,n]of Object.entries(i))t[`$feature/${e}`]=n;this._eventPropertiesWithFlagValues=t}_isCacheStale(){const e=this._config.cacheTtlMs;if(!e||0>=e)return!1;const t=this._prop(f);return"number"!=typeof t||Date.now()-t>e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,this._logger.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){const e=this._config.evaluationContexts;return(null==e?void 0:e.length)?e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}_getValidFlagKeys(){const e=this._config.flagKeys;if(!xt(e))return e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var e,t;const i=this._config,n=null!==(e=null===(t=i.bootstrap)||void 0===t?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(n).length){var s,r;const e=null!==(s=null===(r=i.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==s?s:{},t=Object.keys(n).filter(e=>!xt(n[e])).reduce((e,t)=>(e[t]=n[t],e),{}),o=Object.keys(e).filter(e=>t[e]).reduce((t,i)=>(t[i]=e[i],t),{});return this._receivedFeatureFlags({featureFlags:t,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(e,t,i){var n,s;const r=(null==i?void 0:i.merge)&&null!==(n=this._prop("$enabled_feature_flags"))&&void 0!==n?n:{},o=(null==i?void 0:i.merge)&&null!==(s=this._prop("$feature_flag_payloads"))&&void 0!==s?s:{},a=ct(ct({},r),e),l=ct(ct({},o),t),c={};for(const[e,t]of Object.entries(a))c[e]={key:e,enabled:os(t),variant:as(t),reason:void 0,metadata:xt(null==l?void 0:l[e])?void 0:{id:0,version:void 0,description:void 0,payload:l[e]}};this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this._prop(g),t=this._prop(E),i=this._prop(T);if(!i&&!t)return e||{};const n=Ur({},e||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(const e of s){var r,o;const s=n[e],a=null==t?void 0:t[e],l=xt(a)?null!==(r=null==s?void 0:s.enabled)&&void 0!==r&&r:!!a,c=xt(a)?null==s?void 0:s.variant:"string"==typeof a?a:void 0,u=null==i?void 0:i[e],d=ct(ct({},s),{},{enabled:l,variant:l?null!=c?c:null==s?void 0:s.variant:void 0});l!==(null==s?void 0:s.enabled)&&(d.original_enabled=null==s?void 0:s.enabled),c!==(null==s?void 0:s.variant)&&(d.original_variant=null==s?void 0:s.variant),u&&(d.metadata=ct(ct({},null==s?void 0:s.metadata),{},{payload:u,original_payload:null==s||null===(o=s.metadata)||void 0===o?void 0:o.payload})),n[e]=d}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:n}),this._override_warning=!0),n}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{const n=e[i];return{key:i,enabled:os(n),variant:as(n),payload:rs(t[i])}})}getFlagVariants(){const e=this._prop(y),t=this._prop(E);if(!t)return e||{};const i=Ur({},e||{}),n=Object.keys(t);for(let e=0;n.length>e;e++)i[n[e]]=t[n[e]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){const e=this._prop(C),t=this._prop(T);if(!t)return e||{};const i=Ur({},e||{}),n=Object.keys(t);for(let e=0;n.length>e;e++)i[n[e]]=t[n[e]];return this._override_warning||(this._logger.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.featureFlagsDisabled||this._hasStatusZeroCircuitBreakerTripped()||(this._firingFeatureFlagsCallbacks&&this._logger.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this._requestInFlight&&(this._additionalReloadRequested=!0),this._reloadDebouncer||(this._reloadingHandlers.slice().forEach(e=>{try{e()}catch(e){this._logger.error("Error while running feature flags reloading callback",e)}}),this._reloadDebouncer=setTimeout(()=>{this._callFlagsEndpoint()},5)))}reloadFeatureFlagsAsync(){return!this._client||this._reloadingDisabled||this._config.featureFlagsDisabled||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped()?Promise.resolve({status:"skipped"}):new Promise(e=>{this._pendingReloads.add(e),this.reloadFeatureFlags()})}_settleReloads(e,t){e.forEach(e=>e({status:t})),e.clear()}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}onReloading(e){return this._reloadingHandlers.push(e),()=>{this._reloadingHandlers=this._reloadingHandlers.filter(t=>t!==e)}}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}resetFlagCallReported(){this._remove(w),this._flagCallsPendingCapture=new Map}sendFlagCallsPendingCapture(){var e;if(0!==this._flagCallsPendingCapture.size&&!this._sendingFlagCallsPendingCapture&&(null===(e=this._client)||void 0===e?void 0:e.canCapture)&&!this._client.isRateLimited){this._sendingFlagCallsPendingCapture=!0;try{const e=this.getFlagVariants();for(const t of Array.from(this._flagCallsPendingCapture.keys())){const i=this._flagCallsPendingCapture.get(t);if(i){if(i.value!==String(e[t])||!tE(i.context,this._flagCallContext())){this._flagCallsPendingCapture.delete(t);continue}if(this.getFeatureFlagResult(t),this._flagCallsPendingCapture.has(t))break}}}finally{this._sendingFlagCallsPendingCapture=!1}}}_callFlagsEndpoint(e){var t;this._clearDebouncer();const i=this._client;if(!i||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped())return void this._settleReloads(this._pendingReloads,"skipped");if(this._requestInFlight)return void(this._additionalReloadRequested=!0);const n={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:ct(ct(ct({},i.initialPersonProperties),this._prop("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this._prop(b),timezone:Ec()};xt(i.deviceId)||(n.$device_id=i.deviceId),((null==e?void 0:e.disableFlags)||this._config.featureFlagsDisabled)&&(n.disable_flags=!0);const s=this._getValidEvaluationEnvironments();s.length&&(n.evaluation_contexts=s);const r=this._getValidFlagKeys();xt(r)||(n.flag_keys=r);const o=this._config.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this._requestGeneration,c=this._pendingReloads;this._pendingReloads=new Set,this._activeReloads=c,this._requestInFlight=!0;const u=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},d=e=>{var t,i;const s=null!==(t=e.json)&&void 0!==t?t:{},r=200!==e.statusCode;if(this._requestInFlight=!1,l!==this._requestGeneration)return void u();if(this._trackStatusZeroReachability(e.statusCode),r||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),n.disable_flags&&!this._additionalReloadRequested)return void this._settleReloads(c,"skipped");this._flagsLoadedFromRemote=!r;const a=[];e.error?a.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?ZC:"unknown_error"):200!==e.statusCode&&a.push(`api_error_${e.statusCode}`),s.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");const d=!!(null===(i=s.quotaLimited)||void 0===i?void 0:i.includes("feature_flags"));d&&a.push("quota_limited"),this._set({[_]:a}),d?this._logger.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."):n.disable_flags||this._receivedFeatureFlags(s,r,{partialResponse:o}),this._settleReloads(c,n.disable_flags?"skipped":a.length||!s.flags&&!s.featureFlags?"error":"loaded"),u()},h=e=>{this._requestInFlight=!1,l===this._requestGeneration?(this._set({[_]:[ZC]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),this._settleReloads(c,"error"),u()):u()};let p=null!==(t=this._config.requestMaxRetries)&&void 0!==t?t:1;const g=()=>p>0&&l===this._requestGeneration,f=()=>{if(l!==this._requestGeneration||!this._client||this._config.remoteRequestsDisabled)return this._requestInFlight=!1,this._settleReloads(c,"skipped"),void u();try{i.sendRequest(a,{target:"flags",method:"POST",body:n,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(e=>{if((e=>JC.includes(e.statusCode)||(e=>0===e.statusCode&&e.error instanceof Error&&"AbortError"===e.error.name)(e))(e)&&g())return p--,void setTimeout(f,500);d(e)}).catch(h)}catch(e){h(e)}};f()}_hasStatusZeroCircuitBreakerTripped(){return Xr(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=eo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var i;if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlag for key "'+e+KC);if(this._checkAndTriggerStaleRefresh())return;const n=this.getFeatureFlagResult(e,t);return null!==(i=null==n?void 0:n.variant)&&void 0!==i?i:null==n?void 0:n.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlagResult for key "'+e+KC);if(this._checkAndTriggerStaleRefresh())return;const i=this.getFlagVariants(),n=e in i,s=i[e],r=this.getFlagPayloads()[e],o=String(s),a=this._prop("$feature_flag_request_id")||void 0,l=this._prop("$feature_flag_evaluated_at")||void 0;let c,u=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var d;const e=null===(d=this._client)||void 0===d||null===(d=d.session)||void 0===d?void 0:d.sessionId,t=this._prop(k);e&&e!==t&&(u={},c=e)}if(!t.send_event&&"send_event"in t)c&&this._set({[w]:u,[k]:c});else{var h,p,g;const t=!(null===(h=this._client)||void 0===h?void 0:h.canCapture),i=!t&&!(null===(p=this._client)||void 0===p?void 0:p.isRateLimited);var _;if(i?this._flagCallsPendingCapture.delete(e):(t&&Object.keys(u).length>0&&(u={},this._set({[w]:u})),(null===(_=u[e])||void 0===_?void 0:_.includes(o))||this._holdFlagCall(e,o)),i&&!(null===(g=u[e])||void 0===g?void 0:g.includes(o))){var f,v,m,y,b,S,C,E,T,x,I,R,P;kt(u[e])?u[e].push(o):u[e]=[o],this._set(ct({[w]:u},c?{[k]:c}:{}));const t=this.getFeatureFlagDetails(e),i=[...null!==(f=this._prop("$feature_flag_errors"))&&void 0!==f?f:[]];xt(s)&&i.push("flag_missing");const n={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:null!==(v=null===(m=this._config.bootstrap)||void 0===m||null===(m=m.featureFlags)||void 0===m?void 0:m[e])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(y=null===(b=this._config.bootstrap)||void 0===b||null===(b=b.featureFlagPayloads)||void 0===b?void 0:b[e])&&void 0!==y?y:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};xt(null==t||null===(S=t.metadata)||void 0===S?void 0:S.has_experiment)||(n.$feature_flag_has_experiment=t.metadata.has_experiment),xt(null==t||null===(C=t.metadata)||void 0===C?void 0:C.version)||(n.$feature_flag_version=t.metadata.version);const d=null!==(E=null==t||null===(T=t.reason)||void 0===T?void 0:T.description)&&void 0!==E?E:null==t||null===(x=t.reason)||void 0===x?void 0:x.code;d&&(n.$feature_flag_reason=d),(null==t||null===(I=t.metadata)||void 0===I?void 0:I.id)&&(n.$feature_flag_id=t.metadata.id),xt(null==t?void 0:t.original_variant)&&xt(null==t?void 0:t.original_enabled)||(n.$feature_flag_original_response=xt(t.original_variant)?t.original_enabled:t.original_variant),(null==t||null===(R=t.metadata)||void 0===R?void 0:R.original_payload)&&(n.$feature_flag_original_payload=null==t||null===(P=t.metadata)||void 0===P?void 0:P.original_payload),i.length&&(n.$feature_flag_error=i.join(",")),this._captureFeatureFlagCalled(n)||(this._unmarkFlagCallReported(e,o),this._holdFlagCall(e,o))}else c&&this._set({[w]:u,[k]:c})}return n?{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:rs(r)}:void 0}_captureFeatureFlagCalled(e){try{var t;return!1!==(null===(t=this._client)||void 0===t?void 0:t.capture("$feature_flag_called",e))}catch(e){return this._logger.error("Failed to capture feature flag call",e),!0}}_holdFlagCall(e,t){this._flagCallsPendingCapture.set(e,{value:t,context:this._flagCallContext()})}_flagCallContext(){var e,t,i;return{distinctId:null===(e=this._client)||void 0===e?void 0:e.distinctId,groups:ct({},null===(t=this._client)||void 0===t?void 0:t.groups),sessionId:this._config.deduplicateCallsPerSession?null===(i=this._client)||void 0===i||null===(i=i.session)||void 0===i?void 0:i.sessionId:void 0}}_unmarkFlagCallReported(e,t){const i=this._prop("$flag_call_reported")||{},n=i[e];kt(n)&&n.includes(t)&&(i[e]=n.filter(e=>e!==t),this._set({[w]:i}))}getRemoteConfigPayload(e,t){this._getRemoteConfigPayload(e,t)}_getRemoteConfigPayload(e,t){var i=this;return rt(function*(){const n=i._client;if(!n)return;const s={distinct_id:n.distinctId,token:n.projectToken,person_properties:{$lib:n.library.name,$lib_version:n.library.version}},r=i._getValidEvaluationEnvironments();r.length&&(s.evaluation_contexts=r);const o=i._getValidFlagKeys();let a;xt(o)||(s.flag_keys=o);try{var l;const t=null===(l=(yield n.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||void 0===l?void 0:l.featureFlagPayloads;a=(null==t?void 0:t[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(a)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+KC),t.defaultValue;const i=this.getFeatureFlag(e,t);return xt(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this._receivedFeatureFlags(e,t,i)}_receivedFeatureFlags(e,t,i){if(!this._client)return;this._hasLoadedFlags=!0;const n=((e,t={},i={},n={},s,r=GC)=>{const o=((e,t)=>{const i=e.flags;if(i){const t=Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),n=Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!xt(null===(t=i[e].metadata)||void 0===t?void 0:t.payload)}).map(e=>{var t;return[e,null===(t=i[e].metadata)||void 0===t?void 0:t.payload]}));return ct(ct({},e),{},{featureFlags:t,featureFlagPayloads:n})}return e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e,r),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(!l)return;const u=e.requestId,d=e.evaluatedAt;if(kt(l)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const e={};if(l)for(let t=0;l.length>t;t++)e[l[t]]=!0;return{[p]:l,[y]:e,[m]:!1}}let h=l,_=c,b=a;if(null==s?void 0:s.partialResponse){const e=Object.keys(h),s=_||{};h=ct(ct({},t),h),_=ct(ct({},i),s),e.forEach(e=>{e in s||null==_||delete _[e]}),b=ct(ct({},n),b)}else if(e.errorsWhileComputingFlags)if(a){const e=new Set(Object.keys(a).filter(e=>{var t;return!(null===(t=a[e])||void 0===t?void 0:t.failed)}));h=ct(ct({},t),Object.fromEntries(Object.entries(h).filter(([t])=>e.has(t))));const s=Object.fromEntries(Object.entries(_||{}).filter(([t])=>e.has(t)));_=ct(ct({},i),s),e.forEach(e=>{e in s||null==_||delete _[e]}),b=ct(ct({},n),Object.fromEntries(Object.entries(b||{}).filter(([t])=>e.has(t))))}else h=ct(ct({},t),h),_=ct(ct({},i),_),b=ct(ct({},n),b);return ct(ct({[p]:Object.keys(eE(h)),[y]:h||{},[C]:_||{},[g]:b||{},[m]:!0===e.minimalFlagCalledEvents},u?{[v]:u}:{}),d?{[f]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(n)if(!1===(null==i?void 0:i.persist)){const e=!xt(this._client.kv.get(y));this._bootstrapState=n,e||this._set(n)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(n,e,!!(null==i?void 0:i.partialResponse)),this._set(n);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}override(e,t=!1){this._logger.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._overrideFeatureFlags(e)}_overrideFeatureFlags(e){if(this._client){if(!1===e)return this._remove([E,T]),this._fireFeatureFlagsCallbacks(),void QC.info("All overrides cleared");if(kt(e))return this._set({[E]:XC(e)}),this._fireFeatureFlagsCallbacks(),void QC.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t;const i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);const n={},s=i.flags,r=i.payloads;return s&&(n[E]=kt(s)?XC(s):s),r&&(n[T]=r),Object.keys(n).length&&this._set(n),!1===s&&!1===r?this._remove([E,T]):!1===s?this._remove(E):!1===r&&this._remove(T),this._fireFeatureFlagsCallbacks(),!1===s?QC.info("Flag overrides cleared"):s&&QC.info("Flag overrides set",{flags:s}),void(!1===r?QC.info("Payload overrides cleared"):r&&QC.info("Payload overrides set",{payloads:r}))}if(e&&"object"==typeof e)return this._set({[E]:e}),this._fireFeatureFlagsCallbacks(),void QC.info("Flag overrides set",{flags:e});this._logger.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this._logger.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var n;const s=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),r={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:r};s&&(o.$early_access_feature_name=s.name),i&&(o.$feature_enrollment_stage=i);const a=ct(ct({},this.getFlagVariants()),{},{[e]:t});null===(n=this._crossTabPersistence)||void 0===n||n.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(r)}),this._set({[p]:Object.keys(eE(a)),[y]:a,[S]:ct(ct({},this._prop("$stored_person_properties")||{}),r)}),this._fireFeatureFlagsCallbacks();try{var l;null===(l=this._client)||void 0===l||l.capture("$feature_enrollment_update",o)}catch(e){this._logger.error("Failed to capture early access feature enrollment",e)}}getEarlyAccessFeatures(e,t=!1,i){const n=this._prop(h);!n||t?this._getEarlyAccessFeatures(e,i):e(n)}_getEarlyAccessFeatures(e,t){var i=this;return rt(function*(){const n=i._client;if(!n)return;const s=t?`&${t.map(e=>`stage=${e}`).join("&")}`:"";let r;try{const e=yield n.sendRequest(`/api/early_access_features/?token=${n.projectToken}${s}`,{target:"api",method:"GET",sentAt:"query"});if(!e.json)return;r=e.json.earlyAccessFeatures,i._set({[h]:r})}catch(e){return void i._logger.error("Early access feature request failed",e)}try{e(r)}catch(e){i._logger.error("Early access feature callback failed",e)}})()}_prepareFeatureFlagsForCallbacks(){const 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){this._rebuildEventProperties();const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks(),n=this._firingFeatureFlagsCallbacks;this._firingFeatureFlagsCallbacks=!0,this.featureFlagEventHandlers.forEach(n=>{try{n(t,i,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}}),this._firingFeatureFlagsCallbacks=n}setPersonPropertiesForFlags(e,t=!0){this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t=!0){const i=this._prop("$stored_person_properties")||{},n=(null==e?void 0:e.$set)||((null==e?void 0:e.$set_once)?{}:e),s=null==e?void 0:e.$set_once,r={};if(s)for(const e in s)({}).hasOwnProperty.call(s,e)&&(e in i||(r[e]=s[e]));this._set({[S]:ct(ct(ct({},i),r),n)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const i=ct({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[S]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this._remove(S),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const i=this._prop("$stored_group_properties")||{},n=ct({},i);for(const t of Object.keys(e))n[t]=ct(ct({},i[t]),e[t]);this._set({[b]:n}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this._prop("$stored_group_properties")||{};this._set({[b]:ct(ct({},t),{},{[e]:{}})})}else this._remove(b)}reset(){this._requestGeneration++,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._additionalReloadRequested=!1,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._bootstrapState=void 0,this._hasLoadedFlags=!1,this._reloadingDisabled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0,this._flagCallsPendingCapture=new Map}};const nE=Br("[FeatureFlags]");var sE=class{constructor(e,t=!1){this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,n,s,r,o,a,l,c;return{bootstrap:{featureFlags:null!==(i=null===(n=e.bootstrap)||void 0===n?void 0:n.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(s=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==s?s:void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=e.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:xt(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(a=e.feature_flag_request_max_retries)&&void 0!==a?a:1),compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(c=e.evaluation_contexts)&&void 0!==c?c:e.evaluation_environments)&&void 0!==l?l:[],flagKeys:kt(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(nE.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),xt(e.flag_keys)||kt(e.flag_keys)||nE.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}},rE=class extends iE{constructor(e){const t=new sE(e.config,e._shouldDisableFlags());super(t),this.name=Jy,this._instance=e,this._mutableConfigSource=t}get _crossTabPersistence(){return this._instance.persistence}updateConfig(e,t){this._mutableConfigSource.update(e,t),this._onConfigUpdated()}};const oE="Refusing to render web experiment since the viewer is a likely bot",aE={ADD_ATTR:(e,t)=>"target"===e&&"a"===t||"form"===e&&/^(button|fieldset|input|output|select|textarea)$/.test(t),ADD_URI_SAFE_ATTR:["form"]};let lE;const cE={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>hc(t,e),not_regex:(e,t)=>!hc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},uE=Br("[Conversations]"),dE="Conversations not available yet.";function hE(e,t){var i,n,s,r,o,a,l;const c=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,u=null!==(n=null==e?void 0:e.maxBufferSize)&&void 0!==n?n:100,d=(null==t?void 0:t.consoleCapture)?void 0:null!==(s=null==e?void 0:e.maxLogsPerInterval)&&void 0!==s?s:1e3,h=xt(d)?Math.max(u,2048):Math.max(u,d),p=ct(ct({},function(){let e="",t="";try{var i;const n="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,s=null==n||null===(i=n.navigator)||void 0===i?void 0:i.userAgent;s&&([e,t]=Qi(s))}catch(e){}return function(e,t){const i=function(e){if(e)return{}.hasOwnProperty.call(hr,e)?hr[e]:e}(e);return ct(ct({},i?{"os.name":i}:{}),t?{"os.version":t}:{})}(e,t)}()),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==p?void 0:p["service.name"])&&void 0!==o?o:null==e?void 0:e.serviceName)&&void 0!==r?r:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(a=null==p?void 0:p["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==p?void 0:p["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:p,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:h,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const pE=["debug","log","warn","error","info"],gE="console",_E="__posthogHandledLogsRequestError",fE=(e,t)=>{const i=e instanceof Error?e:new Error(t);return i[_E]=!0,i},vE=e=>!!e&&"object"==typeof e&&!0===e[_E];var mE=class{get _coreLogger(){return ct(ct({},this._logger),{},{error:(...e)=>{e.some(vE)||this._logger.error(...e)}})}constructor(e,t){var i;this._configSource=e,this._getSdkContext=t,this.name="logs",this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=Br("[logs]"),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._setupStarted=!1,this._disposed=!1,this._consoleBuffer=[],this._consoleRecorderUnpatchers=[],this._isRecordingConsole=!1,this._isRecordingConsoleEntry=!1,this._listeningForReconnect=!1,this._onReconnect=()=>{var e,t;this._disposed||(this._consecutiveStatusZeroFailures=0,null===(e=this._core)||void 0===e||e.onReconnect(),null===(t=this._consoleCore)||void 0===t||t.onReconnect())},this._isLogsEnabled=!!(null===(i=e.get())||void 0===i?void 0:i.captureConsoleLogs)}get _isRequestReady(){return!0}_getConsoleLoader(){}_listenForReconnect(){if(!this._listeningForReconnect){try{this._window=typeof window>"u"?void 0:window}catch(e){this._window=void 0}this._window&&(Kr(this._window,"online",this._onReconnect),this._listeningForReconnect=!0)}}_buildCore(e,t,i,n){this._listenForReconnect();const s=hE(this._configSource.get(),i);return[new wr(this._createHost(e,t),s,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,n),s]}_getCore(){const e=this._configSource.get();var t;return this._core&&this._resolvedFrom===e||(null===(t=this._core)||void 0===t||t.reset(),this._resolvedFrom=e,[this._core,this._resolvedConfig]=this._buildCore(()=>this._queue,e=>{this._queue=e})),this._core}_getConsoleCore(){const e=this._configSource.get();var t;return this._consoleCore&&this._consoleResolvedFrom===e||(null===(t=this._consoleCore)||void 0===t||t.reset(),this._consoleResolvedFrom=e,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},gE)),this._consoleCore}setup(e){if(!this._disposed&&!this._setupStarted)return this._setupStarted=!0,this._client=e,this._logger=e.logger.createLogger("[logs]"),Oy(e.kv.initialize(),()=>{this._disposed||this._finishSetup(e)})}_finishSetup(e){var t;this._listenForReconnect(),(null===(t=this._configSource.get())||void 0===t?void 0:t.captureConsoleLogs)&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._configSource.remoteConfigWillArrive&&e.kv.get(this._configSource.captureHintKey))&&this._startConsoleRecorder();let i=!1;const n=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?n.dispose():(this._remoteConfigSubscription=n,i||this.loadIfEnabled())}dispose(){var e,t,i,n,s,r,o;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null===(t=this._window)||void 0===t||t.removeEventListener("online",this._onReconnect),null===(i=this._consoleLogsDispose)||void 0===i||i.call(this),this._consoleLogsDispose=void 0,null===(n=this._core)||void 0===n||n.clearQueue(),null===(s=this._consoleCore)||void 0===s||s.clearQueue(),null===(r=this._core)||void 0===r||r.reset(),null===(o=this._consoleCore)||void 0===o||o.reset())}onRemoteConfig(e){var t,i;if(this._disposed)return;const n=e.ok?null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs:void 0;Mt(n)?this._stopRecorderStartedByPersistedHint():(null===(i=this._client)||void 0===i||i.kv.set(this._configSource.captureHintKey,!!n),n?(this._isLogsEnabled=!0,this._isLoaded||this._startConsoleRecorder(),this.loadIfEnabled()):this._stopRecorderStartedByPersistedHint())}reset(){var e,t,i,n;this._stopConsoleRecorder(),null===(e=this._core)||void 0===e||e.clearQueue(),this._queue=[],null===(t=this._core)||void 0===t||t.reset(),null===(i=this._consoleCore)||void 0===i||i.clearQueue(),this._consoleQueue=[],null===(n=this._consoleCore)||void 0===n||n.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){!this._disposed&&this._client&&this._getCore().captureLog(e)}captureConsoleLog(e){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e)}captureBufferedConsoleLog(e,t,i){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e,{context:t,occurredAtMs:i})}_onOptOut(){var e;this._stopConsoleRecorder(),null===(e=this._consoleCore)||void 0===e||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e;if(this._isRecordingConsole||!(null===(e=this._window)||void 0===e?void 0:e.console))return;const t=hE(this._configSource.get()).maxBufferSize;let i=!0;this._consoleRecorderUnpatchers.push(()=>{i=!1});for(const e of pE){let n;try{n=Eb(this._window.console[e])}catch(e){continue}n&&this._consoleRecorderUnpatchers.push(Mg(this._window.console,e,s=>{const r=(...n)=>{try{i&&this._recordConsoleEntry(e,n,t)}catch(e){}return s.apply(this._window.console,n)};return r.__rrweb_original__=n,r}))}this._isRecordingConsole=!0,this._consoleRecorderTimeout=setTimeout(()=>{this._stopConsoleRecorder()},3e4)}_recordConsoleEntry(e,t,i){var n;if(this._isRecordingConsole&&!this._isRecordingConsoleEntry&&0!==t.length)if(null===(n=this._client)||void 0===n?void 0:n.canCapture){if(i>this._consoleBuffer.length){this._isRecordingConsoleEntry=!0;try{this._consoleBuffer.push({level:e,args:t,occurredAtMs:Date.now(),context:this._getSdkContext()})}finally{this._isRecordingConsoleEntry=!1}}}else this._stopConsoleRecorder()}_stopConsoleRecorder(){if(this._consoleBuffer=[],this._isRecordingConsole){this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0);for(const e of this._consoleRecorderUnpatchers)e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){const e=this._consoleBuffer;return this._stopConsoleRecorder(),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){this._client&&(e?this._flushViaTransport(e):(this._core&&this._core.flush().catch(e=>this._logFlushError(e)),this._consoleCore&&this._consoleCore.flush().catch(e=>this._logFlushError(e))))}flush(){var e=this;return rt(function*(){var t,i;const n=null===(t=e._core)||void 0===t?void 0:t.flush().catch(t=>e._logFlushError(t)),s=null===(i=e._consoleCore)||void 0===i?void 0:i.flush().catch(t=>e._logFlushError(t));yield n,yield s})()}_logFlushError(e){vE(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._disposed||!this._isLogsEnabled||this._isLoaded||this._isLoading)return;const e=this._getConsoleLoader();if(e){this._isLoading=!0;try{e((e,t)=>{if(this._isLoading=!1,!this._disposed&&this._isLogsEnabled)if(e||!t)this._logger.error("Could not load logs script",e),this._stopConsoleRecorder();else{const e=this._takeConsoleBuffer();this._consoleLogsDispose=t.initialize(this._client),this._isLoaded=!0,e.length>0&&t.replay(this._client,e)}})}catch(e){throw this._isLoading=!1,e}}else this._stopConsoleRecorder()}_createHost(e,t){const i=this._client;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:t=>t===ut.LogsQueue?e():void 0,setPersistedProperty(e,i){e===ut.LogsQueue&&t(null!=i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}_sendLogsBatch(e){return new Promise(t=>{if(Xr(this._consecutiveStatusZeroFailures,3))return void t({kind:"fatal",error:fE(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1;const n=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),n({kind:"retry-later",error:fE(void 0,"logs request timed out")})},9e4),r=this._isRequestReady;this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:e,compression:"best-available",timeoutMs:6e4}).then(e=>{var t;const i=e.statusCode;this._trackEndpointReachability(i,r),i>=200&&300>i?n({kind:"ok"}):413===i?n({kind:"too-large"}):0!==i&&408!==i&&429!==i&&500>i?n({kind:"fatal",error:new Error(`logs request failed with status ${i}`)}):0===i?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),n({kind:"retry-later",error:fE(e.error,"logs request failed before receiving an HTTP response")})):n({kind:"retry-later",error:null!==(t=e.error)&&void 0!==t?t:new Error(`logs request failed with status ${i}`)})},e=>{n({kind:"retry-later",error:e})})})}_trackEndpointReachability(e,t){(0!==e||t)&&(this._consecutiveStatusZeroFailures=eo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,this._client.library.name,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,gE,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,n,s){if(0===t.length)return;const r=t.map(e=>e.record);s([]);const o=mr(r,vr(i,this._client.library.name,this._client.library.version),n,this._client.library.version);this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:o,compression:"best-available",transport:e,timeoutMs:6e4}).catch(e=>this._logFlushError(e))}};const yE=Br("[NetworkMetrics]"),bE={"http:":80,"https:":443},SE=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),wE=(e,t)=>{var i;const n=String(t);return{method:String(e).toUpperCase(),url:(null===(i=Yr(n))||void 0===i?void 0:i.href)||n}},kE=(e,t,i,n,s,r,o=!1)=>{try{var a,l;const c=s();if(!c)return;const u=i||void 0,d=mb()-n,h=Yr(t.url);if(h&&"http:"!==h.protocol&&"https:"!==h.protocol)return;const p={url:(null==h?void 0:h.href)||t.url,method:t.method},g=Ct(c.name)?c.name(p):It(c.name)?c.name:"http.client.request.duration";if(!g)return;const _=o&&!u?void 0:((e,t)=>e?400>e?void 0:String(e):(null==t?void 0:t.name)||"_OTHER")(u,r),f=ct(ct(ct(ct(ct({},(e=>{const t=SE.has(e)?e:"_OTHER";return ct({"http.request.method":t},"_OTHER"===t&&e!==t?{"http.request.method_original":e}:{})})(p.method)),h?(e=>{return{"server.address":e.hostname.startsWith("[")&&e.hostname.endsWith("]")?e.hostname.slice(1,-1):e.hostname,"server.port":Number(e.port)||bE[e.protocol],"url.scheme":e.protocol.slice(0,-1),"url.template":(t=e.pathname,t.split("/").map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?":id":e).join("/"))};var t})(h):{}),u?{"http.response.status_code":u}:{}),_?{"error.type":_}:{}),null===(a=c.attributes)||void 0===a?void 0:a.call(c,p,{status:u,durationMs:d}));null===(l=e.metrics)||void 0===l||l.histogram(g,d,{unit:"ms",attributes:f})}catch(e){yE.error("Failed to record network metric",e)}},CE=()=>{},EE=(t,i)=>Ct(null==e?void 0:e.fetch)?Mg(e,"fetch",e=>function(...n){const s=mb(),r=e.apply(this,n);if(!i())return r;try{var o,a,l;const[e,c]=n,u=wE(null!==(o=null!==(a=null==c?void 0:c.method)&&void 0!==a?a:null==e?void 0:e.method)&&void 0!==o?o:"GET",null!==(l=null==e?void 0:e.url)&&void 0!==l?l:e);return r.then(e=>(kE(t,u,null==e?void 0:e.status,s,i,void 0,!0),e),e=>{throw kE(t,u,void 0,s,i,e),e})}catch(e){return yE.error("Failed to observe fetch",e),r}}):CE,TE=(t,i)=>{var n;const s=null==e||null===(n=e.XMLHttpRequest)||void 0===n?void 0:n.prototype;if(!s)return CE;const r=new WeakMap,o=Mg(s,"open",e=>function(...t){try{(()=>Xy.has(this))()||r.set(this,wE(t[0],t[1]))}catch(e){yE.error("Failed to observe XHR open",e)}return e.apply(this,t)}),a=Mg(s,"send",e=>function(...n){let s;try{const e=r.get(this);if(e&&i()){const n=mb();s=()=>{this.removeEventListener("loadend",s),kE(t,e,this.status,n,i)},Kr(this,"loadend",s)}}catch(e){yE.error("Failed to observe XHR send",e)}try{return e.apply(this,n)}catch(e){throw s&&this.removeEventListener("loadend",s),e}});return()=>{o(),a()}},xE=new WeakMap,IE=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),RE={maxStringLength:2048,truncationSuffix:"..."},PE={maxStringLength:2048,truncationSuffix:"..."};function ME(e){if(e)return!0===e?{intent:!0,model:!0}:{intent:!1!==e.intent,model:!1!==e.model}}function FE(e,t){return{}.hasOwnProperty.call(e,t)}function AE(e,t){const i=Object.create(e);return t&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:t}),i}function LE(e,t,i=!1){if(!It(e))return;const n=e.trim();return n?(i?tr(n,RE):n).slice(0,t):void 0}function OE(e){try{return Et(e)&&!0===e.isError}catch(e){return!1}}function DE(e){return tr(e||"Unknown error",PE).slice(0,2048)}function $E(e,t){try{return DE(t?function(e){try{if(!Et(e)||!kt(e.content))return;return e.content.filter(e=>Et(e)&&"text"===e.type&&It(e.text)).map(e=>e.text).join(" ").trim()||void 0}catch(e){return}}(e):Et(e)&&It(e.message)?e.message:It(e)?e:String(e))}catch(e){return"Unknown error"}}function NE(e,t,i){return t.errorResult?[{type:"Error",value:i,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:e.buildProperties(t.error,{handled:!0}).$exception_list.map(e=>ct(ct({},e),{},{value:DE(e.value)}))}function BE(e,t){if(t)return"Error";try{if(!Et(e))return"Error";let t=It(e.name)?e.name.trim():"";const i=e.constructor;return t&&"Error"!==t||!Ct(i)||"Error"===i.name||(t=i.name),(t||"Error").slice(0,256)}catch(e){return"Error"}}function qE(e,t){return{message:$E(e,t),type:BE(e,t)}}EC.__defaultExtensionClasses=ct({},((...e)=>Ur({},...e))({featureFlags:rE},{sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!!(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.isStarted)}get status(){var e,t;return"awaiting_config"===this._recordingStatus||"missing_config"===this._recordingStatus?this._recordingStatus:null!==(e=null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=ha,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var t,i;if(!(null==n?void 0:n.visibilityState)||"visible"===n.visibilityState)return!0;const s=null==e||null===(t=e.performance)||void 0===t||null===(i=t.getEntriesByType)||void 0===i?void 0:i.call(t,"visibility-state");return!(null==s?void 0:s.length)||s.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e,t;"visible"===(null==n?void 0:n.visibilityState)&&(this._documentWasEverVisible=!0,null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.setDocumentWasEverVisible)||void 0===t||t.call(e,!0))},!this._instance.sessionManager)throw OC.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this._config.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==n?void 0:n.addEventListener)&&Kr(n,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this._sessionRecordingDisposed=!0,null==n||null===(t=n.removeEventListener)||void 0===t||t.call(n,"visibilitychange",this._onVisibilityChange),e?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var t;const i=!!(null===(t=this._instance.get_property("$session_recording_remote_config"))||void 0===t?void 0:t.enabled),n=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return e&&i&&n&&!s}startIfEnabledOrStop(e){var t;if(this._sessionRecordingDisposed)return;if(this._isRecordingEnabled&&(null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.isStarted))return;const i=!xt(Object.assign)&&!xt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),OC.info("starting")):(this._recordingStatus=ha,this.stopRecording())}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=va),(null==d||null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.rrweb)||void 0===t?void 0:t.record)&&(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))this._onScriptLoaded(e);else{var n,s;const t=this._instance.sessionManager;null===(n=d.__PosthogExtensions__)||void 0===n||null===(s=n.loadExternalDependency)||void 0===s||s.call(n,this._instance,this._scriptName,i=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===t)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),OC.error("could not load recorder",i)):void this._onScriptLoaded(e);this._recordingStatus="disabled"})}}stopRecording(){var e,t;null===(e=this._persistFlagsOnSessionListener)||void 0===e||e.call(this),this._persistFlagsOnSessionListener=void 0,null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.stop()}_discardRecording(e=!1){var t,i;null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=void 0,null===(i=this._lazyLoadedSessionRecording)||void 0===i||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null===(e=this._persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._persistence)||void 0===t||t.unregister("$replay_sample_rate")}_validateSampleRate(e,t){if(Mt(e))return null;const i=Ft(e)?e:parseFloat(e);return"number"!=typeof(n=i)||!Number.isFinite(n)||0>n||n>1?(OC.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var n}_persistRemoteConfig(e){if(this._persistence){var t,i;const n=this._persistence,s=()=>{var t;const i=!1===e.sessionRecording?void 0:e.sessionRecording,s=this._validateSampleRate(null===(t=this._config.session_recording)||void 0===t?void 0:t.sampleRate,"session_recording.sampleRate"),r=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=s?s:r;Mt(o)&&this._resetSampling();const a=null==i?void 0:i.minimumDurationMilliseconds;n.register({[ie]:ct(ct({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:ct({capturePerformance:e.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:xt(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};s(),null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.onSessionId(s)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):("awaiting_config"===this._recordingStatus&&(this._recordingStatus="missing_config",this._instance.register_for_session({[Be]:!0}),OC.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.log)?this._lazyLoadedSessionRecording.log(e,t):OC.warn("log called before recorder was ready")}get _scriptName(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.get_property(ie);return(null==i||null===(t=i.scriptConfig)||void 0===t?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){const e=this._instance.get_property(ie);if(!e)return!1;let t;try{t="object"==typeof e?e:JSON.parse(e)}catch(e){return OC.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!Mt(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_onScriptLoaded(e){var t,i,n;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(!(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.initSessionRecording))return OC.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Ne]:!0});var s;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null===(s=d.__PosthogExtensions__)||void 0===s?void 0:s.initSessionRecording(this._instance,this._documentWasEverVisible),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if("missing_config"===this._recordingStatus||"awaiting_config"===this._recordingStatus)return;return this._recordingStatus="awaiting_config",OC.info("persisted remote config is stale, requesting fresh config before starting"),void new Ok(this._instance).load()}this._recordingStatus=va,null===(i=(n=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||void 0===i||i.call(n,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=ha}onRRwebEmit(e){var t,i;null===(t=this._lazyLoadedSessionRecording)||void 0===t||null===(i=t.onRRwebEmit)||void 0===i||i.call(t,e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_linked_flag:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_sampling:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null===(i=this._persistence)||void 0===i||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const e of DC){var i;const n=null===(i=this._instance.sessionPersistence)||void 0===i?void 0:i.get_property(e);xt(n)||(t[e]=n)}return ct(ct({},t),(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var i;return!!(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.flushBeforeIdentityReset)||void 0===t||t.call(e)}}},{autocapture:class extends Ky{constructor(e){super(new xC(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._isFlushingPageview=!1,this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(Nr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this._lastLocation=this._getCurrentLocation(),this.startIfEnabled()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,this._hashchangeListener&&this._hashchangeListener(),this._hashchangeListener=void 0,Nr.info("History API monitoring stopped")}monitorHistoryChanges(){e&&e.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(t){var i;if(!e||(null===(i=e.history[t])||void 0===i?void 0:i.__posthog_wrapped__))return;const n=this;Mg(e.history,t,i=>function(s,r,o){var a;n._isUrlChanging(o)&&n._flushPendingPageview(),i.call(this,s,r,o),n._capturePageview(t,!n._isFlushingPageview&&"popstate"!==(null==e||null===(a=e.event)||void 0===a?void 0:a.type))})}_getCurrentLocation(){const t=null==e?void 0:e.location;if(null==t?void 0:t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}_getCaptureOptions(){const e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:Et(e)?e:{}}_shouldCaptureHashChanges(e=this._getCaptureOptions()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){const t=this._getCaptureOptions(),i=this._lastLocation;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this._shouldCaptureHashChanges(t)&&e.hash!==i.hash))}_capturePageview(e,t=!1){try{t||this._flushPendingPageview();const i=this._getCurrentLocation();if(!i)return;if(this._hasLocationChanged(i)){const i=()=>this._instance.capture(et,{navigation_type:e});t?(this._pendingPageview=i,Promise.resolve().then(()=>this._flushPendingPageview())):i()}this._lastLocation=i}catch(t){Nr.error(`Error capturing ${e} pageview`,t)}}_isUrlChanging(t){var i,n;return!(Mt(t)||!e)&&(null===(i=Yr(String(t)))||void 0===i?void 0:i.href)!==(null===(n=e.location)||void 0===n?void 0:n.href)}_flushPendingPageview(){const e=this._pendingPageview;if(e){this._pendingPageview=void 0,this._isFlushingPageview=!0;try{e()}catch(e){Nr.error("Error capturing deferred pageview",e)}finally{this._isFlushingPageview=!1}this._lastLocation=this._getCurrentLocation()}}_setupPopstateListener(){if(this._popstateListener)return;const t=()=>{this._capturePageview("popstate")};Kr(e,"popstate",t),this._popstateListener=()=>{e&&e.removeEventListener("popstate",t)}}_setupHashchangeListener(){if(this._hashchangeListener)return;const t=()=>{this._capturePageview("hashchange")};Kr(e,"hashchange",t),this._hashchangeListener=()=>{e&&e.removeEventListener("hashchange",t)}}},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)||void 0===t?void 0:t.props[G]),this.rageclicks=new By(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return Et(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Mt(this._config.capture_heatmaps)?Mt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;$C.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[G]:i}),this._enabledServerSide=i,this.startIfEnabled()}getAndClearBuffer(){const e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){NC(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval="visible"===(null==n?void 0:n.visibilityState)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){e&&n&&(this._flushHandler=this._flush.bind(this),Kr(e,Xe,this._flushHandler),this._onClickHandler=t=>this._onClick(t||(null==e?void 0:e.event)),Kr(n,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=t=>this._onMouseMove(t||(null==e?void 0:e.event)),Kr(n,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new ok(this.instance,sk,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Kr(n,x,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var t;e&&n&&(this._flushHandler&&e.removeEventListener(Xe,this._flushHandler),this._onClickHandler&&n.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&n.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&n.removeEventListener(x,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null===(t=this._deadClicksCapture)||void 0===t||t.stop(),this._initialized=!1)}_getProperties(t,i){const n=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(t,i,n){let s=t;for(;s&&uo(s)&&!ho(s,"body");){if(s===n)return!1;let t;try{var r,o,a;t=null===(r=null!==(o=null===(a=s.ownerDocument)||void 0===a?void 0:a.defaultView)&&void 0!==o?o:e)||void 0===r?void 0:r.getComputedStyle(s).position}catch(e){return!1}if(ft(i,t))return!0;s=Co(s)}return!1}(bo(t),["fixed","sticky"],r);return{x:t.clientX+(o?0:s),y:t.clientY+(o?0:n),target_fixed:o,type:i}}_onClick(e,t="click"){var i;if(co(e.target)||!NC(e))return;const n=this._getProperties(e,t);(null===(i=this.rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&No(bo(e),this.instance.config.rageclick)&&this._capture(ct(ct({},n),{},{type:"rageclick"})),this._capture(n)}_onMouseMove(e){!co(e.target)&&NC(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(t){if(!e)return;const i=this._config.disable_capture_url_hashes?cn(e.location.href):e.location.href,n=this._config.custom_personal_data_properties,s=this._config.mask_personal_data_properties?[...Tc,...n||[]]:[],r=ro(i,s,Ic);this._buffer=this._buffer||{},this._buffer[r]||(this._buffer[r]=[]),this._buffer[r].push(t)}_flush(){this._buffer&&!Tt(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ok,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=(e=!1)=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",ct({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>ct(ct({},e),{},{[`$web_vitals_${t.name}_event`]:ct({},t),[`$web_vitals_${t.name}_value`]:t.value}),{})),e?{transport:"sendBeacon",send_instantly:!0}:void 0),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Mt(null==e?void 0:e.name)||Mt(null==e?void 0:e.value))return void PC.error("Invalid metric received",e);const i="string"==typeof e.navigationURL?e.navigationURL:void 0,n=this._maskedURL(i);if(xt(n))return;const s=Ft(e.navigationId)||"string"==typeof e.navigationId?`navigation:${e.navigationId}`:`url:${n}`;if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void PC.error("Ignoring metric with value >= "+this._maxAllowedValue,e);this._buffer.navigationKey!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),xt(this._buffer.navigationKey)&&(this._buffer.navigationKey=s,this._buffer.url=n),this._buffer.firstMetricTimestamp=xt(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;const r=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0),o=ct(ct(ct({},e),i?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete o.entries,Et(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){const t={};for(const i of LC){const n="url"===i&&"string"==typeof e.attribution[i]?this._maskedURL(e.attribution[i]):e.attribution[i];xt(n)||(t[i]=n)}o.attribution=t}else delete o.attribution;xt(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this._buffer.metrics.push(o),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()},this._startCapturing=()=>{if(this._initialized)return;let t,i,n,s,r=!1;const o=d.__PosthogExtensions__,a=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(null==a?void 0:a[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&xt(a)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!xt(l)){const e=l.withoutAttribution,o=this.attributionMetrics;r=!xt(e),t=o.indexOf("LCP")>-1?l.onLCP:(null==e?void 0:e.onLCP)||l.onLCP,i=o.indexOf("CLS")>-1?l.onCLS:(null==e?void 0:e.onCLS)||l.onCLS,n=o.indexOf("FCP")>-1?l.onFCP:(null==e?void 0:e.onFCP)||l.onFCP,s=o.indexOf("INP")>-1?l.onINP:(null==e?void 0:e.onINP)||l.onINP}if(!(t&&i&&n&&s))return void PC.error("web vitals callbacks not loaded - not starting");const c={reportSoftNavs:this.useSoftNavs},u=r&&this.attributionMetrics.indexOf("INP")>-1?ct(ct({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&t(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&n(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this),u);const h=null==e?void 0:e.document;Kr(h,x,()=>{"hidden"===(null==h?void 0:h.visibilityState)&&this._flushToCapture(!0)}),Kr(e,"pagehide",()=>this._flushToCapture(!0)),this._initialized=!0},this._enabledServerSide=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[Y]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const i=Et(this._perfConfig)?null===(e=this._perfConfig)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return Mt(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props.$web_vitals_allowed_metrics)||FC:i}get flushToCaptureTimeoutMs(){return(Et(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=Et(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return Lt(e)?e?FC:[]:kt(e)?e:AC}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=Et(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){const e=Et(this._perfConfig)&&Ft(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:MC;return e>0&&6e4>=e?MC:e}get isEnabled(){const e=null==s?void 0:s.protocol;if("http:"!==e&&"https:"!==e)return PC.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=Et(this._perfConfig)?this._perfConfig.web_vitals:Lt(this._perfConfig)?this._perfConfig:void 0;return Lt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(PC.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const i=Et(t.capturePerformance)&&!!t.capturePerformance.web_vitals,n=Et(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Y]:i}),this._instance.persistence.register({[te]:n})),this._enabledServerSide=i,this.startIfEnabled()}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t;const i=d.__PosthogExtensions__,n=this._callbackFlavor,s=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;(null==s?void 0:s[n])||"web-vitals"===n&&xt(s)&&(null==i?void 0:i.postHogWebVitalsCallbacks)?e():null==i||null===(t=i.loadExternalDependency)||void 0===t||t.call(i,this._instance,n,t=>{t?PC.error("failed to load script",t):e()})}_maskedURL(t){const i=t||(null==e?void 0:e.location.href);if(!i)return void PC.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?cn(i):i,s=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Tc,...s||[]]:[];return ro(n,r,Ic)}}},{exceptionObserver:class{constructor(t){var i;this._startCapturing=()=>{var t;if(!e||!this.isEnabled||!(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions))return;const i=d.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=d.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=d.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=i(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=n(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){IC.error("failed to start",e),this._stopCapturing()}},this._instance=t,this._remoteEnabled=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[Q]),this._rateLimiter=new Jt(ct(ct({},function(e={}){var t,i,n,s;return{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(n=null!==(s=e.exceptionRateLimiterBucketSize)&&void 0!==s?s:e.__exceptionRateLimiterBucketSize)&&void 0!==n?n:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,_logger:IC})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Et(e)?t=ct(ct({},t),e):(xt(e)?this._remoteEnabled:e)&&(t=ct(ct({},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?(IC.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"exception-autocapture",t=>{if(t)return IC.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null===(e=this._unwrapOnError)||void 0===e||e.call(this),this._unwrapOnError=void 0,null===(t=this._unwrapUnhandledRejection)||void 0===t||t.call(this),this._unwrapUnhandledRejection=void 0,null===(i=this._unwrapConsoleError)||void 0===i||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Q]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,n;const s=null!==(t=null==e||null===(i=e.$exception_list)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(s))return void IC.info("Skipping exception capture because of client rate limiting.",{exception:s});null===(n=this._instance.exceptions)||void 0===n||n.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=zb(),this._instance=e,this._suppressionRules=null!==(t=null===(i=this._instance.persistence)||void 0===i?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=is(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new ns(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=is(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,n;if(!e.ok)return;const s=e.config;if(!("errorTracking"in s))return;const r=null!==(t=null===(i=s.errorTracking)||void 0===i?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null===(n=s.errorTracking)||void 0===n?void 0:n.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[K]:this._suppressionRules,[J]:o})}get _captureExtensionExceptions(){var e;const t=!!this._instance.get_property(J),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 Nb.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:i,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};const t=[];return{sanitizedProperties:Object.keys(e).reduce((i,n)=>es.has(n)?(t.push(n),i):(i[n]=e[n],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t));n.length>0&&Nb.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(ct({[Zn]:e,[Xn]:(new Date).toISOString()},i))}catch(e){Nb.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Nb.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 Nb.info("Skipping exception capture because it was thrown by an extension");if(!this._captureExtensionExceptions&&this._isInjectedBrowserScriptException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by an injected browser script"),void Nb.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Nb.info("Skipping exception capture because it was thrown by the PostHog SDK")}const i=this._exceptionStepsConfig.enabled&&Mt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,n=function(){if("u">typeof process){var e;const t=null===(e=process.env.POSTHOG_RELEASE_ID)||void 0===e?void 0:e.trim();if(t)return t}const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();n&&(i.$release_id=n);try{const e=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return e&&this._exceptionStepsBuffer.clear(),e}catch(e){return $b(e)||Nb.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void($b(e)||Nb.error("Failed to process exception event. Ignoring this exception.",e))}}_addBufferedExceptionSteps(e){try{const t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:ct(ct({},e),{},{$exception_steps:t})}catch(t){return Nb.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Zn]:e,[Xn]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Et(e)?ct({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null===(t=this._instance.config.error_tracking)||void 0===t?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{const t=e.reduce((e,{type:t,value:i})=>(It(t)&&t.length>0&&e.$exception_types.push(t),It(i)&&i.length>0&&e.$exception_values.push(i),e),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{const i=e.values.map(e=>{const i=gc[e.operator],n=t[e.key];if(!i||!n)return!1;const s=kt(e.value)?e.value:[e.value];return s.length>0&&i(s,n)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return Nb.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){const t=e.flatMap(e=>{var t,i;return null!==(t=null===(i=e.stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(({filename:e})=>!!e&&Hb.some(t=>e.startsWith(t)));return 0!==i.length&&(!i.every(({filename:e})=>!!e&&e.startsWith(Bb))||e.some(({type:e,value:t})=>"NoResponse"===e||It(t)&&qb.some(({value:e,exact:i})=>i?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!(null==t?void 0:t.startsWith(Bb))))}_isInjectedBrowserScriptException(e){return e.some(({value:e})=>It(e)&&Ub.some(t=>e.includes(t)))}_isPostHogException(e){if(e.length>0){var t,i,n,s;const r=null!==(t=null===(i=e[0].stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[],o=r[r.length-1];return null!==(n=null==o||null===(s=o.filename)||void 0===s?void 0:s.includes("posthog.com/static"))&&void 0!==n&&n}return!1}_isExceptionList(e){return!Mt(e)&&kt(e)}}},{productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var i,n;if(this._persistence&&this._persistence.register({[X]:!!t.productTours}),!qC(this._instance))return!this._productTourManager&&Mt(null===(i=this._persistence)||void 0===i?void 0:i.props.ph_product_tours)||BC.info("product tours disabled; stopping and clearing cached tours"),null===(n=this._productTourManager)||void 0===n||n.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&qC(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"product-tours",t=>{t?BC.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&(null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.generateProductTours)&&(this._productTourManager=d.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(kt(this._cachedTours)&&!t)return void e(this._cachedTours,{isLoaded:!0});const i=this._persistence;if(i){const n=i.props[be];if(kt(n)&&!t)return this._cachedTours=n,void e(n,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:t=>{if(!qC(this._instance))return void e([],{isLoaded:!0});const n=t.statusCode;if(200!==n||!t.json){const i=`Product Tours API could not be loaded, status: ${n}`;return 0===n?t.error||BC.warn(i):BC.error(i),void e([],{isLoaded:!1,error:i})}const s=kt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=s,i&&i.register({[be]:s}),e(s,{isLoaded:!0})}})}getActiveProductTours(e){Mt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null===(t=this._productTourManager)||void 0===t||t.previewTour(e)})}dismissProductTour(){var e;null===(e=this._productTourManager)||void 0===e||e.dismissTour("user_clicked_skip")}nextStep(){var e;null===(e=this._productTourManager)||void 0===e||e.nextStep()}previousStep(){var e;null===(e=this._productTourManager)||void 0===e||e.previousStep()}clearCache(){var e;this._cachedTours=null,null===(e=this._persistence)||void 0===e||e.unregister("ph_product_tours")}resetTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.resetTour(e)}resetAllTours(){var e;null===(e=this._productTourManager)||void 0===e||e.resetAllTours()}cancelPendingTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.cancelPendingTour(e)}},featureFlags:rE},{siteApps:class{constructor(e){this._instance=e,this._siteAppElementPatchCount=0,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(!t)return;const 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=d._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,i,n,s,r,o,a;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[e,t]of Object.entries(u))l[e]={id:c[e],type:e,properties:t};const{$set_once:d,$set:h}=e;return{event:ct(ct({},ys(e,HC)),{},{properties:ct(ct(ct({},e.properties),h?{$set:ct(ct({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),h)}:{}),d?{$set_once:ct(ct({},null!==(n=null===(s=e.properties)||void 0===s?void 0:s.$set_once)&&void 0!==n?n:{}),d)}:{}),elements_chain:null!==(r=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_prepareElementForSiteApp(e){var t;const i=null===(t=e.tagName)||void 0===t?void 0:t.toLowerCase();if("style"===i&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(e)||(UC.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===i&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(e)||(UC.error("prepare_external_dependency_script returned null"),null)}return e}_patchSiteAppElementInsertionMethods(){var e,t,i,s,r,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const c=null==n?void 0:n.defaultView,u=null==c||null===(e=c.Node)||void 0===e?void 0:e.prototype;if(!c||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();const d=[],h=this,p=new WeakSet,g=(e,t,i)=>{if(!(null==e?void 0:e[t]))return;const n=e[t];e[t]=i(n),d.push(()=>{e[t]=n})},_=e=>{if(p.has(e))return e;const t=h._prepareElementForSiteApp(e);return t&&p.add(t),t},f=e=>e.map(e=>"string"==typeof e?e:_(e)).filter(e=>!Pt(e));return g(u,"appendChild",e=>function(t){const i=_(t);return i?e.call(this,i):t}),g(u,"insertBefore",e=>function(t,i){const n=_(t);return n?e.call(this,n,i):t}),g(u,"replaceChild",e=>function(t,i){const n=_(t);return n?e.call(this,n,i):i}),[null===(t=c.Element)||void 0===t?void 0:t.prototype,null===(i=c.Document)||void 0===i?void 0:i.prototype,null===(s=c.DocumentFragment)||void 0===s?void 0:s.prototype].forEach(e=>{g(e,"append",e=>function(...t){return e.apply(this,f(t))}),g(e,"prepend",e=>function(...t){return e.apply(this,f(t))})}),[null===(r=c.Element)||void 0===r?void 0:r.prototype,null===(o=c.CharacterData)||void 0===o?void 0:o.prototype,null===(a=c.DocumentType)||void 0===a?void 0:a.prototype].forEach(e=>{g(e,"before",e=>function(...t){return e.apply(this,f(t))}),g(e,"after",e=>function(...t){return e.apply(this,f(t))}),g(e,"replaceWith",e=>function(...t){const i=f(t);return t.length&&!i.length?void 0:e.apply(this,i)})}),g(null===(l=c.Element)||void 0===l?void 0:l.prototype,"insertAdjacentElement",e=>function(t,i){const n=_(i);return n?e.call(this,t,n):null}),this._restoreSiteAppElementPatches=()=>{d.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){let e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null===(t=this._restoreSiteAppElementPatches)||void 0===t||t.call(this)))}}_runWithPreparedSiteAppElements(e,t=!0){const i=this._patchSiteAppElementInsertionMethods();try{const n=e(i);return t&&i(),n}catch(e){throw i(),e}}setupSiteApp(e){const t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(UC.info(`Processing ${this._bufferedInvocations.length} events for site app with id ${e.id}`),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null===(i=this._stopBuffering)||void 0===i||i.call(this))};let n=!1;const s=s=>{t.errored=!s,t.loaded=!0,UC.info(`Site app with id ${e.id} ${s?"loaded":"errored"}`),n&&i()};try{const{processEvent:i}=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),s(e)}}),!1);i&&(t.processEvent=i),n=!0}catch(t){UC.error(zC+e.id,t),s(!1)}if(n&&t.loaded)try{i()}catch(i){UC.error(`Error while processing buffered events PostHog app with config id ${e.id}`,i),t.errored=!0}}_setupSiteApps(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}_onCapturedEvent(e){if(0===Object.keys(this.apps).length)return;const t=this.globalsForEvent(e);for(const i of Object.values(this.apps))try{this._runWithPreparedSiteAppElements(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})}catch(t){UC.error(`Error while processing event ${e.event} for site app ${i.id}`,t)}}onRemoteConfig(e){var t,i,n;if(null===(t=this.siteAppLoaders)||void 0===t?void 0:t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void UC.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this._stopBuffering)||void 0===i||i.call(this),!e.ok)return;const s=e.config;if(null===(n=s.siteApps)||void 0===n?void 0:n.length)if(this.isEnabled)for(const{id:e,url:t}of s.siteApps){var r,o;d[`__$$ph_site_app_${e}`]=this._instance,null===(r=d.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,t,t=>{if(t)return UC.error(zC+e,t)})}else UC.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},{surveys:class extends Ny{constructor(e){super(new wb(e))}},featureFlags:rE},{tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{const e=this._syncHostnamesForPatch();var t,i;e?(xt(this._restoreXHRPatch)&&(this._restoreXHRPatch=null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.tracingHeadersPatchFns)||void 0===t?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),xt(this._restoreFetchPatch)&&(this._restoreFetchPatch=null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.tracingHeadersPatchFns)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"tracing-headers",t=>{if(t)return RC.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(){const e=this._getConfiguredHostnames();return kt(e)?(kt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(kt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},{toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){d.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=d.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,i=void 0,s=void 0){var r,o;if(Jr(this.instance.config))return!1;if(!e||!n)return!1;t=null!==(r=t)&&void 0!==r?r:e.location,s=null!==(o=s)&&void 0!==o?o:e.history;try{if(!i){try{e.localStorage.setItem("test","test"),e.localStorage.removeItem("test")}catch(e){return!1}i=null==e?void 0:e.localStorage}const n=WC||oo(t.hash,"__posthog")||oo(t.hash,"state");let r;const o=n?un(()=>JSON.parse(atob(decodeURIComponent(n))))||un(()=>JSON.parse(decodeURIComponent(n))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?t.hash=o.desiredHash:s?s.replaceState(s.state,"",t.pathname+t.search):t.hash="")):(r=JSON.parse(i.getItem(jC)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){const t=d.ph_load_toolbar||d.ph_load_editor;!Mt(t)&&Ct(t)?t(e,this.instance):VC.warn("No toolbar load function found")}loadToolbar(t){const i=!!(null==n?void 0:n.getElementById("__POSTHOG_TOOLBAR__"));if(!e||i)return!1;const s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=ct(ct({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(e.localStorage.setItem(jC,JSON.stringify(ct(ct({},r),{},{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var o,a;this._setToolbarState(1),null===(o=d.__PosthogExtensions__)||void 0===o||null===(a=o.loadExternalDependency)||void 0===a||a.call(o,this.instance,"toolbar",e=>{if(e)return VC.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)}),Kr(e,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(r)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},{experiments:class t{get _config(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(e=!1)=>{this.getWebExperiments(e=>{t._logInfo("retrieved web experiments from the server"),this._flagToExperiments=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;this._flagToExperiments&&(t._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=this._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e));const n=this._instance.getFeatureFlag(e.feature_flag_key);It(n)&&e.variants[n]&&this._applyVariantForFlag(e,n)}else if(e.variants)for(const i in e.variants){const n=e.variants[i];t._matchesTestVariant(n,this._instance)&&this._applyTransforms(e.name,i,n.transforms)}})},e)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t._logInfo(oE);else if(!this._config.disable_web_experiments){if(Mt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t._logInfo("applying feature flags",e),e.forEach(e=>{var t;if(this._flagToExperiments&&(null===(t=this._flagToExperiments)||void 0===t?void 0:t.has(e))){var i;const t=this._instance.getFeatureFlag(e),n=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&(null==n?void 0:n.variants[t])&&this._applyVariantForFlag(n,t)}})}}previewWebExperiment(){const e=t.getWindowLocation();if(null==e?void 0:e.search){const i=so(null==e?void 0:e.search,"__experiment_id"),n=so(null==e?void 0:e.search,"__experiment_variant");i&&n&&(t._logInfo(`previewing web experiments ${i} && ${n}`),this.getWebExperiments(e=>{this._showPreviewWebExperiment(parseInt(i),n,e)},!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);const n=this._instance.get_property("$web_experiments");if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this._config.token}`),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,i,n){const s=n.filter(t=>t.id===e);s&&s.length>0&&(t._logInfo(`Previewing web experiment [${s[0].name}] with variant [${i}]`),this._applyTransforms(s[0].name,i,s[0].variants[i].transforms))}_applyVariantForFlag(e,i){const n=e.variants[i];t._matchUrlConditions(n,this._instance)?this._applyTransforms(e.name,i,n.transforms):t._logInfo(`skipping variant ${i} of experiment ${e.name} because this page does not match its url conditions`)}static _matchesTestVariant(e,i){return!Mt(e.conditions)&&t._matchUrlConditions(e,i)&&t._matchUTMConditions(e)}static _matchUrlConditions(e,i){var n;if(Mt(e.conditions)||Mt(null===(n=e.conditions)||void 0===n?void 0:n.url))return!0;const s=t.getWindowLocation();if(s){var r,o,a;const t=ao(i,s.href);return!(null===(r=e.conditions)||void 0===r?void 0:r.url)||cE[null!==(o=null===(a=e.conditions)||void 0===a?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](e.conditions.url,t)}return!1}static getWindowLocation(){return null==e?void 0:e.location}static _matchUTMConditions(e){var t;if(Mt(e.conditions)||Mt(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=Pc();if(i.utm_source){var n,s,r,o,a,l,c,u;const t=!(null===(n=e.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)||(null===(s=e.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)==i.utm_campaign,d=!(null===(r=e.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=e.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==i.utm_source,h=!(null===(a=e.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)||(null===(l=e.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)==i.utm_medium,p=!(null===(c=e.conditions)||void 0===c||null===(c=c.utm)||void 0===c?void 0:c.utm_term)||(null===(u=e.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==i.utm_term;return t&&h&&p&&d}return!1}static _logInfo(e,...t){Nr.info(`[WebExperiments] ${e}`,t)}static _logWarn(e,...t){Nr.warn(`[WebExperiments] ${e}`,t)}static _sanitizeLinkTargets(e){("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"template"===e.localName?e.content:e).querySelectorAll("a[target], template").forEach(e=>{var i;if("template"===e.localName)return void("http://www.w3.org/1999/xhtml"===e.namespaceURI&&t._sanitizeLinkTargets(e));if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||"_blank"!==(null===(i=e.getAttribute("target"))||void 0===i?void 0:i.toLowerCase()))return void e.removeAttribute("target");const n=(e.getAttribute("rel")||"").split(/\s+/).filter(e=>e&&!/^(opener|noopener)$/i.test(e));n.push("noopener"),e.setAttribute("rel",n.join(" "))})}_applyTransforms(e,i,n){this._is_bot()?t._logInfo(oE):"control"!==i?n.forEach(n=>{if(n.selector){var s;t._logInfo(`applying transform of variant ${i} for experiment ${e} `,n);const r=null===(s=document)||void 0===s?void 0:s.querySelectorAll(n.selector);if(!(null==r?void 0:r.length))return void t._logWarn(`no element on this page matches selector ${n.selector} of variant ${i} for experiment ${e}`);const o=new Map;null==r||r.forEach(e=>{if("script"===e.localName.toLowerCase())return;const i=e;if(n.html){var s;const a="http://www.w3.org/1998/Math/MathML"===e.namespaceURI&&"annotation-xml"===e.localName&&(null===(s=e.getAttribute("encoding"))||void 0===s?void 0:s.toLowerCase())||"",l=JSON.stringify([e.namespaceURI,e.localName,a]);let c=o.get(l);if(Mt(c)){var r;const i=null!==(r=lE)&&void 0!==r?r:lE=am(),s=e.ownerDocument.implementation.createHTMLDocument(""),u=s.createElementNS(e.namespaceURI,e.localName);a&&u.setAttribute("encoding",a);const d=s.createRange();d.selectNodeContents(u);const h="http://www.w3.org/2000/svg"===e.namespaceURI&&/^(foreignObject|desc|title)$/.test(e.localName)||/^(text\/html|application\/xhtml\+xml)$/.test(a)?"http://www.w3.org/1999/xhtml":e.namespaceURI,p=d.createContextualFragment(n.html);"http://www.w3.org/1998/Math/MathML"===e.namespaceURI&&/^(mi|mo|mn|ms|mtext)$/.test(e.localName)?(u.appendChild(p),i.sanitize(u,ct(ct({},aE),{},{NAMESPACE:h||void 0,IN_PLACE:!0}))):("http://www.w3.org/1999/xhtml"===u.namespaceURI&&"template"===u.localName?u.content:u).appendChild(i.sanitize(p,ct(ct({},aE),{},{NAMESPACE:h||void 0,RETURN_DOM_FRAGMENT:!0}))),t._sanitizeLinkTargets(u),c=u.innerHTML,o.set(l,c)}i.innerHTML=c}n.css&&i.setAttribute("style",n.css)})}}):t._logInfo("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?Qk(i,this._config.custom_blocked_useragents):void 0}},featureFlags:rE},{conversations:class{constructor(e){this._instance=e,this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._loadFailed=!1,this._resetGeneration=0,this._pendingPanelAction=null,this._theme=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations)return void(this._pendingPanelAction=null);if(this._remoteConfigSuccessful=e.ok,!e.ok)return;const t=e.config.conversations;Mt(t)?this._pendingPanelAction=null:(Lt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this._isConversationsEnabled||(this._pendingPanelAction=null),this.loadIfEnabled())}reset(){var e;null===(e=this._conversationsManager)||void 0===e||e.reset(),this._conversationsManager=null,this._resetGeneration++,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1,this._pendingPanelAction=null}loadIfEnabled(){if(this._conversationsManager)return;if(this._isInitializing)return;if(this._instance.config.disable_conversations)return;if(Jr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=null==d?void 0:d.__PosthogExtensions__;if(e&&!xt(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{const t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);const i=e.loadExternalDependency;if(!i)return void this._handleLoadError(M);const n=this._resetGeneration;i(this._instance,"conversations",t=>{if(n!==this._resetGeneration)return this._isInitializing=!1,void this.loadIfEnabled();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 uE.error("Conversations enabled but missing token in remote config.")}_completeInitialization(e){if(this._remoteConfig){try{this._conversationsManager=e(this._remoteConfig,this._instance),this._loadFailed=!1,uE.info("Conversations loaded successfully")}catch(e){return void this._handleLoadError("Error completing conversations initialization",e)}this._theme&&this._conversationsManager.setTheme(this._theme),this._applyPendingPanelAction()}else uE.error("Cannot complete initialization: remote config is null")}_applyPendingPanelAction(){const e=this._pendingPanelAction;this._pendingPanelAction=null,this._conversationsManager&&e&&("open"===e?this._conversationsManager.open():this._conversationsManager.close())}_handleLoadError(e,t){uE.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():uE.warn("Conversations not loaded yet.")}hide(){"open"===this._pendingPanelAction&&(this._pendingPanelAction=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.open()):this._pendingPanelAction="open"}close(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.close()):this._pendingPanelAction="close"}setTheme(e){var t,i;this._theme=ct(ct(ct({},this._theme),e),{},{dark:ct(ct({},null===(t=this._theme)||void 0===t?void 0:t.dark),null==e?void 0:e.dark)}),null===(i=this._conversationsManager)||void 0===i||i.setTheme(e)}isAvailable(){return!0===this._isConversationsEnabled&&!Pt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Jr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":xt(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?Mt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":(null==d?void 0:d.__PosthogExtensions__)?this._isInitializing?"initializing":this._loadFailed?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var n=this;return rt(function*(){return n._conversationsManager?n._conversationsManager.sendMessage(e,t,i):(uE.warn(dE),null)})()}getMessages(e,t){var i=this;return rt(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(uE.warn(dE),null)})()}markAsRead(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(uE.warn(dE),null)})()}getTickets(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(uE.warn(dE),null)})()}requestRestoreLink(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(uE.warn(dE),null)})()}restoreFromToken(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(uE.warn(dE),null)})()}restoreFromUrlToken(){var e=this;return rt(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(uE.warn(dE),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null===(e=this._conversationsManager)||void 0===e||e.setIdentity()}_onIdentityCleared(){var e;null===(e=this._conversationsManager)||void 0===e||e.clearIdentity()}}},{logs:class extends mE{constructor(e){super({get(){var t;return null==e||null===(t=e.config)||void 0===t?void 0:t.logs},captureHintKey:ee,get remoteConfigWillArrive(){var t,i;return!(null===(t=e._shouldDisableFlags)||void 0===t?void 0:t.call(e))||!!(null===(i=d._POSTHOG_REMOTE_CONFIG)||void 0===i||null===(i=i[e.config.token])||void 0===i?void 0:i.config)}},()=>function(e){var t;const i={};if(i.distinctId=e.get_distinct_id(),e.sessionManager){const{sessionId:t,windowId:n,sessionStartTimestamp:s,lastActivityTimestamp:r}=e.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=n,Mt(s)||(i.sessionStartTimestamp=s),Mt(r)||(i.lastActivityTimestamp=r)}if((null==d||null===(t=d.location)||void 0===t?void 0:t.href)&&(i.currentUrl=e.config.disable_capture_url_hashes?cn(d.location.href):d.location.href),e.featureFlags){const t=e.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}(e)),this._instance=e,this.name=Yy,this._listenForReconnect()}get _isRequestReady(){return this._instance.__loaded}_getConsoleLoader(){const e=Br("[logs]"),t=null==d?void 0:d.__PosthogExtensions__;if(!t)return void e.error("PostHog Extensions not found.");const i=t.loadExternalDependency;if(i)return e=>{i(this._instance,"logs",i=>{const n=t.logs;e(i,(null==n?void 0:n.initializeLogs)?{initialize:e=>n.initializeLogs(e),replay(e,t){var i;return null===(i=n.replayConsoleBuffer)||void 0===i?void 0:i.call(n,e,t)}}:void 0)})};e.error(M)}}},{metrics:class{constructor(e){this._instance=e,this._logger=Br("[metrics]"),this._disposed=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this._disposed)return;const t=!!(null===(e=this._instance.config.metrics)||void 0===e?void 0:e.network);t&&!this._stopNetworkMetrics?this._stopNetworkMetrics=(e=>{let t=!0;const i=()=>t?(e=>{var t;const i=null===(t=e.config.metrics)||void 0===t?void 0:t.network;return!0===i?{}:i||void 0})(e):void 0,n=EE(e,i),s=TE(e,i);return()=>{t=!1,n(),s()}})(this._instance):!t&&this._stopNetworkMetrics&&(this._stopNetworkMetrics(),this._stopNetworkMetrics=void 0)}_getCore(){var e;if(this._disposed)return;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.metrics;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,this._core=new Pr(this._createHost(),function(e){var t,i,n,s,r;const o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(n=null==o?void 0:o["deployment.environment"])&&void 0!==n?n:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(s=null==e?void 0:e.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(r=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(t),this._logger)),this._core}count(e,t=1,i){var n;null===(n=this._getCore())||void 0===n||n.count(e,t,i)}gauge(e,t,i){var n;null===(n=this._getCore())||void 0===n||n.gauge(e,t,i)}histogram(e,t,i){var n;null===(n=this._getCore())||void 0===n||n.histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){const t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch(e=>this._logger.error("PostHog metrics flush failed:",e))}reset(){var e;null===(e=this._core)||void 0===e||e.reset()}dispose(){var e,t;this._disposed=!0,null===(e=this._stopNetworkMetrics)||void 0===e||e.call(this),this._stopNetworkMetrics=void 0,null===(t=this._core)||void 0===t||t.reset()}_createHost(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>Yl.LIB_NAME,getLibraryVersion:()=>Yl.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{let n=!1;const s=e=>{n||(n=!0,clearTimeout(r),i(e))},r=setTimeout(()=>s({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(ct(ct({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){const t=e.statusCode;if(t>=200&&300>t)s({kind:"ok"});else if(413===t)s({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)s({kind:"fatal",error:new Error(`metrics request failed with status ${t}`)});else{var i;s({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`metrics request failed with status ${t}`)})}}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},{webMCP:class{constructor(e){this._instance=e,this._isPatched=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this._isPatched)return;const e=null==n?void 0:n.modelContext;if(!e||!Ct(e.registerTool))return;const t=xE.get(e);if(t)return t.instances.add(this._instance),void(this._isPatched=!0);const i={instances:new Set([this._instance])},s=e.registerTool,r=this;Mg(e,"registerTool",e=>{const t=e;return function(e,...n){let s=e;try{s=r._wrapTool(e,i)}catch(i){return t.call(this,e,...n)}return t.call(this,s,...n)}}),e.registerTool!==s&&(xE.set(e,i),this._isPatched=!0)}_wrapTool(e,t){if(!e||!Ct(e.execute))return e;const i=e.execute,n=this,{tool:s,injected:r}=function(e,t){const i={intent:!1,model:!1},n=e.inputSchema;if(!function(e){return!!xt(e)||Et(e)&&Object.keys(e).every(e=>IE.has(e)||e.startsWith("x-"))&&!0!==e.additionalProperties&&!Et(e.additionalProperties)&&(!e.type||"object"===e.type)&&(!e.properties||Et(e.properties))&&(!e.required||kt(e.required))}(n))return{tool:AE(e),injected:i};const s=(null==n?void 0:n.properties)||{},r=e=>FE(s,e)||kt(null==n?void 0:n.required)&&n.required.includes(e);if(i.intent=t.intent&&!r("context"),i.model=t.model&&!r("llm_model"),!i.intent&&!i.model)return{tool:AE(e),injected:i};const o=ct({},s),a=kt(null==n?void 0:n.required)?[...n.required]:[];return i.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},a.includes("context")||a.push("context")),i.model&&(o.llm_model={type:"string",description:'The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the site developer\'s analytics.'},a.includes("llm_model")||a.push("llm_model")),{tool:AE(e,ct(ct({},n),{},{type:(null==n?void 0:n.type)||"object",properties:o,required:a})),injected:i}}(e,function(e){const t={intent:!1,model:!1};for(const i of e.instances){const e=ME(i.config.capture_webmcp);t.intent||(t.intent=!0===(null==e?void 0:e.intent)),t.model||(t.model=!0===(null==e?void 0:e.model))}return t}(t));return Object.defineProperty(s,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const a=new Date,l=function(e,t){if(!Et(e))return{};try{const i=t.intent?LE(e.context,2048,!0):void 0,n=t.model?LE(e.llm_model,256):void 0;return ct(ct({},i&&"{}"!==i?{intent:i}:{}),n&&"unknown"!==n.toLowerCase()?{model:n}:{})}catch(e){return{}}}(o[0],r),c=function(e,t){const i=e[0];if(!Et(i))return e;try{const n=t.intent&&FE(i,"context"),s=t.model&&FE(i,"llm_model");if(!n&&!s)return e;const r=ct({},i);return n&&delete r.context,s&&delete r.llm_model,[r,...e.slice(1)]}catch(t){return e}}(o,r);let u;try{u=i.apply(this===s?e:this,c)}catch(e){throw n._captureToolCall(t,s,a,{error:e,errorResult:!1},l),e}if((d=u)&&"function"==typeof d.then)return Promise.resolve(u).then(e=>{const i=OE(e)?{error:e,errorResult:!0}:void 0;return n._captureToolCall(t,s,a,i,l),e},e=>{throw n._captureToolCall(t,s,a,{error:e,errorResult:!1},l),e});var d;const h=OE(u)?{error:u,errorResult:!0}:void 0;return n._captureToolCall(t,s,a,h,l),u}}),s}_captureToolCall(e,t,i,n,r){const o=Date.now()-i.getTime();let a;for(const c of e.instances){var l;const e=ME(c.config.capture_webmcp);if(e){n&&!a&&(a=qE(n.error,n.errorResult));try{c.capture("$mcp_tool_call",ct(ct(ct({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==s?void 0:s.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{}),e.intent&&r.intent?{$mcp_intent:r.intent,$mcp_intent_source:"context_parameter"}:{}),e.model&&r.model?{$mcp_llm_model:r.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:i})}catch(e){continue}if(n&&a&&c.exceptions&&(null===(l=c.exceptionObserver)||void 0===l?void 0:l.isEnabled))try{const e={$exception_list:NE(c.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==s?void 0:s.hostname};c.exceptionObserver.captureException(e)}catch(e){}}}}}}));const HE=function(){Yl.SDK_DIST_CHANNEL="npm";const t=sC[mC]=new EC;return function(){function t(){t.done||(t.done=!0,Dk=!1,Hr(sC,function(e){e._dom_loaded()}))}(null==n?void 0:n.addEventListener)?"complete"===n.readyState?t():Kr(n,"DOMContentLoaded",t,{capture:!1}):e&&Nr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();var UE=HE;exports.Compression=Iy,exports.DEFAULT_PRODUCT_TOUR_APPEARANCE={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},exports.DisplaySurveyType=Bf,exports.PostHog=EC,exports.ProductTourEventName=Pk,exports.ProductTourEventProperties=Mk,exports.SurveyEventName=$f,exports.SurveyEventProperties=Nf,exports.SurveyEventType=Rf,exports.SurveyPosition=Mf,exports.SurveyQuestionBranchingType=Of,exports.SurveyQuestionType=Lf,exports.SurveySchedule=Df,exports.SurveyTabPosition=Ff,exports.SurveyType=Af,exports.SurveyWidgetType=Pf,exports.default=UE,exports.posthog=HE,exports.severityLevels=["fatal","error","warning","log","info","debug"];
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="u">typeof window?window:void 0,t="u">typeof globalThis?globalThis:e,i=null==t?void 0:t.navigator,n=null==t?void 0:t.document,s=null==t?void 0:t.location,r=null==t?void 0:t.fetch,o=(null==t?void 0:t.XMLHttpRequest)&&"withCredentials"in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,a=null==t?void 0:t.AbortController,l=null==t?void 0:t.CompressionStream,c=null==i?void 0:i.userAgent,u="undefined"!=typeof globalThis?globalThis:e;u&&"undefined"==typeof self&&(u.self=u),u&&"undefined"==typeof File&&(u.File=function(){});const d=null!=e?e:{},h="$early_access_features",p="$active_feature_flags",g="$feature_flag_details",_="$feature_flag_errors",f="$feature_flag_evaluated_at",v="$feature_flag_request_id",m="$minimal_flag_called_events",y="$enabled_feature_flags",b="$stored_group_properties",S="$stored_person_properties",w="$flag_call_reported",k="$flag_call_reported_session_id",C="$feature_flag_payloads",E="$override_feature_flags",T="$override_feature_flag_payloads",x="visibilitychange",I="$autocapture_disabled_server_side",R="$surveys",P="$surveys_loaded_at",M="PostHog loadExternalDependency extension not found.",F="$surveys_activated",A="$surveys_activated_session",L="$surveys_activated_timestamps",O="$people_distinct_id",D="distinct_id",N="$device_id",B="$device_model",q="__alias",H="__cmpns",U="$fbc",z="$fbc_persistence",W="$fbp",j="$fbp_persistence",V="__timers",G="$heatmaps_enabled_server_side",Q="$exception_capture_enabled_server_side",K="$error_tracking_suppression_rules",J="$error_tracking_capture_extension_exceptions",Y="$web_vitals_enabled_server_side",Z="$dead_clicks_enabled_server_side",X="$product_tours_enabled_server_side",ee="$logs_capture_enabled_server_side",te="$web_vitals_allowed_metrics",ie="$session_recording_remote_config",ne="$session_recording_enabled_server_side",se="$replay_sample_rate",re="$replay_override_sampling",oe="$replay_override_linked_flag",ae="$replay_override_url_trigger",le="$replay_override_event_trigger",ce="$sesid",ue="$session_is_sampled",de="$session_past_minimum_duration",he="$session_recording_url_trigger_activated_session",pe="$session_recording_event_trigger_activated_session",ge="$posthog_sr_group_event_trigger_",_e="$posthog_sr_group_url_trigger_",fe="$posthog_sr_group_sampling_",ve="$debug_first_full_snapshot_timestamp",me="$sess_rec_flush_size",ye="$groups",be="ph_product_tours",Se="$product_tours_activated",we="$product_tours_activated_session",ke="$conversations_widget_session_id",Ce="$conversations_ticket_id",Ee="$conversations_widget_state",Te="$conversations_user_traits",xe="$user_state",Ie="$client_session_props",Re="$capture_rate_limit",Pe="$initial_campaign_params",Me="$initial_referrer_info",Fe="$initial_person_info",Ae="$epp",Le="$posthog_cookieless",Oe="$cookieless_mode",De="$sdk_debug_extensions_init_method",$e="$sdk_debug_extensions_init_time_ms",Ne="$sdk_debug_recording_script_not_loaded",Be="$sdk_debug_replay_stale_config",qe="$sdk_debug_replay_event_trigger_status",He="$sdk_debug_replay_linked_flag_trigger_status",Ue="$sdk_debug_replay_matched_recording_trigger_groups",ze="$sdk_debug_replay_pending_trigger_conditions",We="$sdk_debug_replay_remote_trigger_matching_config",je="$sdk_debug_replay_trigger_groups_count",Ve="$sdk_debug_replay_url_trigger_status",Ge="$sdk_debug_rrweb_attached",Qe="$sdk_debug_rrweb_start_attempted",Ke="$session_recording_start_reason",Je="anonymous",Ye="identified",Ze="identified_only",Xe="beforeunload",et="$pageview",tt="$pageleave",it="$identify",nt="$groupidentify";function st(e,t,i,n,s,r,o){try{var a=e[r](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(n,s)}function rt(e){return function(){var t=this,i=arguments;return new Promise(function(n,s){var r=e.apply(t,i);function o(e){st(r,n,s,o,a,"next",e)}function a(e){st(r,n,s,o,a,"throw",e)}o(void 0)})}}function ot(e){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ot(e)}function at(e,t,i){return(t=function(e){var t=function(e){if("object"!=ot(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=ot(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ot(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function lt(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function ct(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(i),!0).forEach(function(t){at(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):lt(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var ut=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_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.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),dt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});const ht="min_length",pt="max_length",gt=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],_t=["token"];function ft(e,t){return-1!==e.indexOf(t)}const vt=function(e){return e.trim()},mt=function(e){return e.replace(/^\$/,"")};function yt(e){var t;const i=[];return null!==(t=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}}))&&void 0!==t?t:"null"}const bt=Object.prototype,St=bt.hasOwnProperty,wt=bt.toString,kt=Array.isArray||function(e){return"[object Array]"===wt.call(e)},Ct=e=>"function"==typeof e,Et=e=>e===Object(e)&&!kt(e),Tt=e=>{if(Et(e)){for(const t in e)if(St.call(e,t))return!1;return!0}return!1},xt=e=>void 0===e,It=e=>"[object String]"==wt.call(e),Rt=e=>It(e)&&0===e.trim().length,Pt=e=>null===e,Mt=e=>xt(e)||Pt(e),Ft=e=>"[object Number]"==wt.call(e)&&e==e,At=e=>Ft(e)&&e>0,Lt=e=>"[object Boolean]"===wt.call(e),Ot=e=>e instanceof FormData,Dt=e=>ft(gt,e),$t=e=>ft(_t,e);function Nt(e){return null===e||"object"!=typeof e}function Bt(e,t){return{}.toString.call(e)===`[object ${t}]`}function qt(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Ut(e,Error)}}function Ht(e){return"u">typeof Event&&Ut(e,Event)}function Ut(e,t){try{return e instanceof t}catch(e){return!1}}const zt=[!0,"true",1,"1","yes"],Wt=e=>ft(zt,e),jt=[!1,"false",0,"0","no"],Vt=["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","pinterestbot","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","lightpanda","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"],Gt=new Map,Qt=function(e,t=[]){if(!e)return!1;const i=function(e,t){let i="";for(let e=0;t.length>e;e++){const n=t[e];i+=n.length+":"+n}return e.length+":"+e+"|"+t.length+":"+i}(e,t),n=Gt.get(i);if(void 0!==n)return n;const s=e.toLowerCase(),r=Vt.concat(t).some(e=>-1!==s.indexOf(e.toLowerCase()));return 256>Gt.size||Gt.clear(),Gt.set(i,r),r};function Kt(e,t,i,n,s){return t>i&&(n.warn("min cannot be greater than max."),t=i),Ft(e)?e>i?(n.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(n.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(n.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),Kt(null!=s?s:i,t,i,n))}var Jt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Kt(e.bucketSize,0,100,e._logger),this._refillRate=Kt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Kt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){const 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;const i=Date.now(),n=String(e);let s=this._buckets[n];return s?this._applyRefill(s,i):(s={tokens:this._bucketSize,lastAccess:i},this._buckets[n]=s),0===s.tokens||(s.tokens--,0===s.tokens&&(null===(t=this._onBucketRateLimited)||void 0===t||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}};const Yt="Mobile",Zt="Android",Xt="Tablet",ei="Android Tablet",ti="iPad",ii="Apple Watch",ni="Safari",si="BlackBerry",ri="Samsung Internet",oi="Chrome",ai="Chrome iOS",li="Internet Explorer",ci="Internet Explorer Mobile",ui="Opera",di="Microsoft Edge",hi="Firefox",pi="Firefox iOS",gi="Nintendo",_i="PlayStation",fi="Xbox",vi="Android Mobile",mi="Mobile Safari",yi="Windows",bi="Windows Phone",Si="Nokia",wi="Ouya",ki="Generic tablet",Ci="Konqueror",Ei="Oculus Browser",Ti="Vivaldi",xi="Yandex",Ii="Whale",Ri="DuckDuckGo",Pi="Pale Moon",Mi="Waterfox",Fi="Brave",Ai="Claude",Li="Codex",Oi="ChatGPT",Di="Google Search App",$i=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ni=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Bi=new RegExp(fi,"i"),qi=new RegExp("PlayStation \\w+","i"),Hi=new RegExp("Nintendo \\w+","i"),Ui=new RegExp("BlackBerry|PlayBook|BB10","i"),zi={"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"},Wi=function(e,t,i,n){t=t||"";const s=function(e){return(null==e?void 0:e.brave)?Fi:null}(i);return s||((null==n?void 0:n.detectGoogleSearchApp)&&ft(e,"GSA/")?Di:ft(e," OPR/")&&ft(e,"Mini")?"Opera Mini":ft(e," OPR/")?ui:Ui.test(e)?si:ft(e,"IEMobile")||ft(e,"WPDesktop")?ci:ft(e,"OculusBrowser")?Ei:ft(e,"SamsungBrowser")?ri:ft(e,"Edge")||ft(e,"Edg/")?di:ft(e,"Vivaldi/")?Ti:ft(e,"YaBrowser/")?xi:ft(e,"Whale/")?Ii:ft(e,"DuckDuckGo/")||ft(e,"Ddg/")?Ri:ft(e,"Claude/")?Ai:ft(e,"Codex/")?Li:ft(e,"ChatGPT/")?Oi:ft(e,"FBIOS")?"Facebook Mobile":ft(e,"UCWEB")||ft(e,"UCBrowser")?"UC Browser":ft(e,"CriOS")?ai:ft(e,"CrMo")||ft(e,oi)?oi:ft(e,Zt)&&ft(e,ni)?vi:ft(e,"FxiOS")?pi:ft(e.toLowerCase(),Ci.toLowerCase())?Ci:ft(e,"Brave/")?Fi:((e,t)=>t&&ft(t,"Apple")||function(e){return ft(e,ni)&&!ft(e,oi)&&!ft(e,Zt)}(e))(e,t)?ft(e,Yt)?mi:ni:ft(e,"PaleMoon/")?Pi:ft(e,"Waterfox/")?Mi:ft(e,hi)?hi:ft(e,"MSIE")||ft(e,"Trident/")?li:ft(e,"Gecko")?hi:"")},ji={[ci]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[di]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[oi]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[ai]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[ni]:[$i],[mi]:[$i],[ui]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[hi]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[pi]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[si]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),$i],[vi]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ri]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Ei]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[Ti]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[xi]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Ii]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Fi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Ai]:[Ni],[Li]:[Ni],[Oi]:[Ni],[Ri]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Pi]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Mi]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Di]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[li]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Vi=function(e,t,i,n){const s=Wi(e,t,i,n),r=ji[s];if(xt(r))return null;for(let t=0;r.length>t;t++){const i=e.match(r[t]);if(i)return parseFloat(i[i.length-2])}return null},Gi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[fi,e&&e[1]||""]],[new RegExp(gi,"i"),[gi,""]],[new RegExp(_i,"i"),[_i,""]],[Ui,[si,""]],[new RegExp(yi,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[bi,""];if(new RegExp(Yt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let e=zi[i[1]]||"";return/arm/i.test(t)&&(e="RT"),[yi,e]}return[yi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=xt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Zt,[e[2],e[3],e[4]||"0"].join(".")]:[Zt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const 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/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Qi=function(e){for(let t=0;Gi.length>t;t++){const[i,n]=Gi[t],s=i.exec(e),r=s&&(Ct(n)?n(s,e):n);if(r)return r}return["",""]},Ki=function(e){return Hi.test(e)?gi:qi.test(e)?_i:Bi.test(e)?fi:new RegExp(wi,"i").test(e)?wi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?bi:/iPad/.test(e)?ti:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ii:Ui.test(e)?si:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Si,"i").test(e)?Si:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Yt).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)?Zt:ei:new RegExp("(pda|Mobile)","i").test(e)?"Generic mobile":new RegExp(Xt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?ki:""},Ji=function(e,t){var i;const n=Ki(e);return n===ti||n===ei||"Kobo"===n||"Kindle Fire"===n||n===ki?Xt:n===gi||n===fi||n===_i||n===wi?"Console":n===ii?"Wearable":n?Yt:"Android"===(null==t?void 0:t.userAgentDataPlatform)&&(null!==(i=null==t?void 0:t.maxTouchPoints)&&void 0!==i?i:0)>0?600>Math.min(null!==(s=null==t?void 0:t.screenWidth)&&void 0!==s?s:0,null!==(r=null==t?void 0:t.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==t?void 0:t.devicePixelRatio)&&void 0!==o?o:1)?Yt:Xt:"Desktop";var s,r,o},Yi=/\bFBAV\/(\d+(?:\.\d+)*)/i,Zi=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Yi],[/\bFBAN\/EMA\b/i,"Facebook Lite",Yi],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Yi],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Xi="[Truncated]",en="[Unserializable]";function tn(e){let t="";for(let i=0;e.length>i;i++){const n=e.charCodeAt(i);if(55296>n||n>56319)t+=56320>n||n>57343?e[i]:"�";else{const n=e.charCodeAt(i+1);56320>n||n>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}function nn(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch(e){i=[]}for(const n of i){let i;try{i=t[n]}catch(e){i=en}Object.defineProperty(e,n,{value:i,enumerable:!0,writable:!0,configurable:!0})}return e}Date,Date;const sn=3e5;var rn=class{record(e){if("too-large"===e.kind)return;if("retry-later"!==e.kind)return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),i=Date.now(),n=Math.min(e.retryAfterMs,sn);if(!t)return this._installedAt=i,void(this._until=i+n);this._until=Math.max(this._until,Math.min(i+n,this._installedAt+sn))}remainingMs(){const e=Date.now();if(this._installedAt-5e3>e)return this.reset(),0;const t=Math.min(sn,Math.max(0,this._until-e));return 0===t&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this._until=0,this._installedAt=0}constructor(){this._until=0,this._installedAt=0}};const on=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function an(e,t){return"string"==typeof(i=e)&&on.test(i)?e:t();var i}function ln(e,t){const i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function cn(e){return e?e.split("#")[0]:e}function un(e){try{return e()}catch(e){return}}function dn(e,t){const i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function hn(e,t,i){return pn.apply(this,arguments)}function pn(){return(pn=rt(function*(e,t,i){let n;try{return yield Promise.race([e,new Promise((e,s)=>{n=dn(()=>{try{null==i||i(),e()}catch(e){s(e)}},t)})])}finally{clearTimeout(n)}})).apply(this,arguments)}let gn,_n,fn,vn;function mn(e){var t;const i=globalThis._posthogChunkIds,n=globalThis._debugIds;if(!i&&!n)return;const s=i?Object.keys(i):[],r=n?Object.keys(n):[];if(vn&&yn(i,s,_n)&&yn(n,r,fn))return vn;_n=i?ct({},i):void 0,fn=n?ct({},n):void 0,vn={},null!==(t=gn)&&void 0!==t||(gn={});const o=(t,i)=>{for(const s of t){const t=i[s];if(!t)continue;const r=null==gn?void 0:gn[s];if(r){vn[r]=t;continue}const o=e(s);for(let e=o.length-1;e>=0;e--){var n;const i=null===(n=o[e])||void 0===n?void 0:n.filename;if(i){vn[i]=t,gn[s]=i;break}}}};return n&&o(r,n),i&&o(s,i),vn}function yn(e,t,i){return e&&i?t.length===Object.keys(i).length&&t.every(t=>e[t]===i[t]):e===i}var bn=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){const i=t&&t.mechanism||{handled:!0,type:"generic"},n=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),r=this.parseStacktrace(n,s);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return rt(function*(){for(const i of e)i.stacktrace&&i.stacktrace.frames&&kt(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null===(t=e.syntheticException)||void 0===t?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i;let n,s;if(null!=e.cause&&(n=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack)try{s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch(e){}return ct(ct({},e),{},{cause:n,stack:s,errors:null===(i=e.errors)||void 0===i?void 0:i.map(e=>this.parseStacktrace(e,t))})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(const i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return rt(function*(){let i=e;for(const e of t.modifiers)i=yield e(i);return i})()}convertToExceptionList(e,t){const i=[],n=(e,s,r)=>{var o;const a=i.length,l=void 0===s?ct(ct({type:"string"==typeof t.type&&t.type.length>0?t.type:"generic"},"boolean"==typeof t.handled?{handled:t.handled}:void 0===t.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof t.synthetic?t.synthetic:e.synthetic,exception_id:a}):{type:"chained",source:r,synthetic:e.synthetic,exception_id:a,parent_id:s},c={type:e.type,value:e.value,mechanism:l};e.stack&&(c.stacktrace={type:"raw",frames:e.stack}),i.push(c),e.cause&&n(e.cause,a,"cause");for(const t of null!==(o=e.errors)&&void 0!==o?o:[])n(t,a,"member")};return n(e),i}buildParsingContext(e){var t;return{chunkIdMap:mn(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}getAggregateErrors(e){try{if(qt(e)){let i=Object.getPrototypeOf(e);for(let n=0;i&&100>n;n++){var t;const n=null===(t=Object.getOwnPropertyDescriptor(i,"constructor"))||void 0===t?void 0:t.value;if("function"==typeof n&&"AggregateError"===n.name){const t=e.errors;return kt(t)?t:void 0}i=Object.getPrototypeOf(i)}}}catch(e){}}buildCoercingContext(e,t,i=0){let n=0,s=0,r=!1;const o=new Set,a=[],l={},c=(e,t,i=0)=>{const c=u(t,i),d=c.apply;if(c.apply=t=>{a.push(e);try{return d(t)}finally{a.pop()}},i>4||i>0&&-1!==a.indexOf(e))return this.coerceFallback(c);const h="object"==typeof e&&null!==e||"function"==typeof e;if(0===i&&n>=50||h&&o.has(e))return;h&&o.add(e),0===i&&n++;const p=this.getAggregateErrors(e);let g,_;r||(r=!!p);try{if(g=this.applyCoercers(e,c),!g)throw l}catch(e){if(e===l)return void(0===i&&n--);if(!r)throw e;g=this.coerceFallback(c)}if(!p||n>=50)return g;try{_=p.length}catch(e){return g}if(!Number.isInteger(_)||0>_||_>4294967295)return g;const f=[];for(let e=0;50>n&&1e3>s&&_>e;e++){let i;s++;try{i=c.next(p[e])}catch(e){n++,i=this.coerceFallback(u(t+1))}i&&f.push(i)}return ct(ct({},g),{},{errors:f})},u=(i,n=0)=>ct(ct({},t),{},{syntheticException:0==i?t.syntheticException:void 0,mechanism:0==i?e:{},apply(e){const t=c(e,i,n+1);if(!t)throw l;return t},next:e=>c(e,i+1)}),d=u(i);return ct(ct({},d),{},{apply:e=>{var t;return null!==(t=c(e,i))&&void 0!==t?t:this.coerceFallback(d)}})}};const Sn=/^([a-z][a-z0-9.+-]+):/i,wn=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function kn(e){if(!e||"<anonymous>"===e)return!1;const t=Sn.exec(e);return!t||wn.includes(t[1].toLowerCase())}function Cn(e,t,i,n,s){const r={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:kn(t)};return xt(n)||(r.lineno=n),xt(s)||(r.colno=s),r}const En=(e,t)=>{const i=-1!==e.indexOf("safari-extension"),n=-1!==e.indexOf("safari-web-extension");return i||n?[-1!==e.indexOf("@")?e.split("@")[0]:"?",i?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Tn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,xn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,In=/\((\S*)(?::(\d+))(?::(\d+))\)/,Rn=(e,t)=>{const i=Tn.exec(e);if(i){const[,e,n,s]=i;return Cn(t,e,"?",+n,+s)}const n=xn.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){const e=In.exec(n[2]);e&&(n[2]=e[1],n[3]=e[2],n[4]=e[3])}const[e,i]=En(n[1]||"?",n[2]);return Cn(t,i,e,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},Pn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Mn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Fn=(e,t)=>{const i=Pn.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){const e=Mn.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="")}let e=i[3],n=i[1]||"?";return[n,e]=En(n,e),Cn(t,e,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},An=/\(error: (.*)\)/;function Ln(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function On(e){for(let t=1;10>=t;t++){const i=e.length-2*t;if(0>i)break;let n=!0;for(let s=0;t>s;s++)if(!Ln(e[i+s],e[i+t+s])){n=!1;break}if(n){for(let n=0;t>n;n++)e[i+n]=e[i+t+n];return e.length=i+t,{start:i,length:t}}}}function Dn(e,t){const i=t.start+t.length,n=Nn(e,t);n&&e.splice(i+n===e.length?i:t.start,n)}function $n(e,t){let i=t.start;for(;i>0&&Ln(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function Nn(e,t){const i=t.start+t.length;let n=i;for(;e.length>n&&Ln(e[n],e[n-t.length]);)n++;return n-i}function Bn(e,t){const i=t[0];let n=e.length-(i?$n(e,i):0);for(const i of t)n-=Nn(e,i);return n}function qn(e,t,i){for(let n=0;e.length>n;n++){const s=e[(t+n)%e.length],r=e[(i+n)%e.length];if(s!==r)return r>s}return!1}var Hn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const 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){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Bt(e,"DOMException")}isDOMError(e){return Bt(e,"DOMError")}},Un=class{match(e){return qt(e)}coerce(e,t){var i;const n=this.getStack(e),s=void 0===n?null===(i=t.syntheticException)||void 0===i?void 0:i.stack:void 0,r=!!s;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=n?n:s,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){try{const t=e.stacktrace;if("string"==typeof t&&t.length>0)return t;const i=e.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(e){return}}},zn=class{match(e){return!!Bt(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);const n=t.apply(e.message);return ct(ct({},n),{},{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:n.stack,synthetic:!0})}_hasUsableMessage(e){return It(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i;const n=e,s=null!==(t=n.lineno)&&void 0!==t?t:0,r=null!==(i=n.colno)&&void 0!==i?i:0;if(It(n.filename)&&0!==n.filename.length&&0!==s)return`Error\n at ${n.filename}:${s}:${r}`}};const Wn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var jn=class{match(e){return"string"==typeof e}coerce(e,t){var i;const[n,s]=this.getInfos(e);return{type:null!=n?n:"Error",value:null!=s?s:e,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e;const n=e.match(Wn);return n&&(t=n[1],i=n[2]),[t,i]}};const Vn=["fatal","error","warning","log","info","debug"];function Gn(e,t=40){const i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let e=i.length;e>0;e--){const n=i.slice(0,e).join(", ");if(t>=n.length)return e===i.length?n:n.length>t?`${n.slice(0,t)}...`:n}return""}var Qn=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,n;const s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null===(n=t.syntheticException)||void 0===n?void 0:n.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Ht(e))return e.constructor.name;const t="name"in e?e.name:void 0;return It(t)&&!Rt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){let 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;const t=this.getObjectClassName(e);return`${t&&"Object"!==t?`'${t}'`:"Object"} captured as exception with keys: ${Gn(e)}`}isSeverityLevel(e){return It(e)&&!Rt(e)&&Vn.indexOf(e)>=0}getStack(e){try{return It(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:It(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=e[t];if(qt(i))return i}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},Kn=class{match(e){return Ht(e)}coerce(e,t){var i;const n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Gn(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},Jn=class{match(e){return Nt(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?void 0:i.stack,synthetic:!0}}},Yn=class{match(e){return Bt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Ht(e))return!1;try{const t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i;const n=this.getUnhandledRejectionReason(e);return Nt(n)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}:t.apply(n)}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}};const Zn="$message",Xn="$timestamp",es=new Set([Zn,Xn]),ts={enabled:!0,max_bytes:32768};function is(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:ts.enabled,max_bytes:ss(e.max_bytes,ts.max_bytes)}:ct({},ts)}var ns=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=is(e)}setConfig(e){this._config=is(e),this._trimToMaxBytes()}add(e){const t=function(e){let t;try{t=yt(e)}catch(e){return}try{const e=JSON.parse(t);if(!Et(e))return;const i=e,n=i[Zn],s=i[Xn];if(!It(n)||0===n.trim().length)return;if(!It(s)&&!Ft(s))return;return{step:i,json:t}}catch(e){return}}(e);if(!t)return;const i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;const t=encodeURIComponent(e);let i=0;for(let e=0;t.length>e;e++)"%"===t[e]?(i+=1,e+=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;){const e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function ss(e,t){if(!Ft(e)||1/0===e||-1/0===e)return t;const i=Math.floor(e);return 0>i?t:i}const rs=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function os(e){return"string"==typeof e||e}function as(e){return"string"==typeof e?e:void 0}const ls=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],cs="NativeGzipValidationError",us=e=>e.length>=2&&31===e[0]&&139===e[1],ds=(e,t)=>e===dt.GZipJS||t===dt.GZipJS||"gzip"===t,hs=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),ps=e=>{if(!e||"object"!=typeof e)return!1;const t="name"in e?String(e.name):"";return hs(e)||t===cs};let gs;const _s=e=>{throw ln(cs,`Native gzip produced invalid output: ${e}`)},fs=function(){var e=rt(function*(e,t){18>e.size&&_s("too-short");const i=new Uint8Array(yield e.slice(0,10).arrayBuffer());us(i)&&8===i[2]||_s("invalid-header");const n=new DataView(yield e.slice(e.size-8).arrayBuffer());n.getUint32(0,!0)!==(e=>{const t=(()=>{if(gs)return gs;gs=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;gs[e]=t>>>0}return gs})();let i=4294967295;for(let n=0;e.length>n;n++)i=t[255&(i^e[n])]^i>>>8;return(4294967295^i)>>>0})(t)&&_s("invalid-crc");const s=t.length>>>0;n.getUint32(4,!0)!==s&&_s("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function vs(e){return ms.apply(this,arguments)}function ms(){return ms=rt(function*(e,t=!0,i){try{const t=(new TextEncoder).encode(e),i=new globalThis.CompressionStream("gzip"),s=i.writable.getWriter(),r=s.write(t).then(()=>s.close()).catch((n=rt(function*(e){try{yield s.abort(e)}catch(e){}throw e}),function(e){return n.apply(this,arguments)})),o=new Response(i.readable).blob(),[a]=yield Promise.all([o,r]);return yield fs(a,t),a}catch(e){if(null==i?void 0:i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}var n}),ms.apply(this,arguments)}function ys(e,t){if(null==e)return{};var i,n,s=function(e,t){if(null==e)return{};var i={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;i[n]=e[n]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;r.length>n;n++)t.includes(i=r[n])||{}.propertyIsEnumerable.call(e,i)&&(s[i]=e[i])}return s}const bs="[redacted]",Ss=/^[A-Za-z0-9+/\n\r]+=*$/,ws=/^[A-Za-z0-9_-]+={0,2}$/,ks=/[-_]/,Cs=/^data:[^,\s]*;base64,/i,Es=/^[A-Za-z0-9+/_-]+={0,2}$/,Ts=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,xs=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Is=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Rs=/[\s<>"]/,Ps=(()=>new RegExp(Is.source,"i"))(),Ms=/[a-z][a-z0-9+.-]{0,63}:\/\//i,Fs=(()=>new RegExp(`^${Ms.source}`,"i"))(),As=(()=>new RegExp(Ms.source,"gi"))(),Ls=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,Os=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,Ds=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,$s=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Ns=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,Bs=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,qs=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,Hs=/\b\d(?:[ ./-]?\d){12,}\b/g,Us=/\d+/g,zs=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Ws=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function js(e){return function(e){return xs.test(e)}(e)||Ls.test(e)||Os.test(e)}function Vs(e){return e.split("&",129).length>128}function Gs(e,t,i){return js(e)||t.includes(";")&&function(e){return e.split(";").some(e=>js(e.split("=",1)[0]))}(t)?bs:Ps.test(t)?i?Xs(t,{allowNestedUrls:!1,stripPunctuation:!0}):bs:t}function Qs(e,t){const i=new URLSearchParams;let n=!1,s=!1;for(const[r,o]of new URLSearchParams(e)){const e=er(r),a=er(o);n||(n=e!==r||a!==o);const l=Gs(e,a,t);n||(n=l!==a),s=js(e)||l!==a,i.append(e,l)}return{changed:n,lastFieldSensitive:s,serialized:i.toString()}}function Ks(e,t){if(!e.includes("="))return{value:Js(e,t),lastFieldSensitive:!1};const i=Qs(e,t);return{value:i.changed?i.serialized:e,lastFieldSensitive:i.lastFieldSensitive}}function Js(e,t){return t?Xs(e,{allowNestedUrls:!1,stripPunctuation:!0}):Ps.test(e)?bs:e}function Ys(e,t,i){return"#"===e?!t.fragment&&(t.fragment=!0):"?"===e&&(t.fragment?"="!==i&&!t.fragmentQuery&&(t.fragmentQuery=!0):!t.query&&(t.query=!0))}function Zs(e,t){var i;if(e.length>8192&&Fs.test(e))return bs;const{address:n,suffix:s}=t.stripPunctuation?function(e){let t=e.length;for(;t>0&&".,;:!?)]}'".includes(e[t-1]);)t--;return{address:e.slice(0,t),suffix:e.slice(t)}}(e):{address:e,suffix:""};let r;try{r=new URL(n)}catch(e){return bs+s}const o=r.search.slice(1),a=""!==r.hash,l=function(e){const t=e.slice(1),i=t.indexOf("?");return 0>i?{head:t,tail:null}:{head:t.slice(0,i),tail:t.slice(i+1)}}(r.hash);if(Vs(o)||Vs(l.head)||Vs(null!==(i=l.tail)&&void 0!==i?i:""))return bs+s;let c=!1;(r.username||r.password)&&(r.username=bs,r.password="",c=!0);const u=Qs(o,t.allowNestedUrls);u.changed&&(r.search=u.serialized,c=!0);const d=Ks(l.head,t.allowNestedUrls),h=null===l.tail?null:(p=l.tail,d.lastFieldSensitive?{value:""===p?"":bs,lastFieldSensitive:!0}:Ks(p,t.allowNestedUrls));var p;const g=null===h?d.value:`${d.value}?${h.value}`;g!==r.hash.slice(1)&&(r.hash=g,c=!0);const _=a?null!=h?h:d:u;return(c?er(r.toString()):n)+(_.lastFieldSensitive?"":s)}function Xs(e,t){return e.replace(Is,i=>function(e,t){const i=function(e){if(!e.includes("://"))return[];const t=[...e.matchAll(As)].map(e=>e.index),i=[],n={query:!1,fragment:!1,fragmentQuery:!1};let s=0,r=!1,o="";for(let a=0;e.length>a&&t.length>s;a++){t[s]===a&&(a>0&&"="!==o&&i.push(a),s++);const l=e[a];Ys(l,n,o)?(o=l,r=!0):r&&"=&".includes(l)&&(o=l)}return i}(e);if(0===i.length)return Zs(e,t);let n="",s=0;for(const r of i)n+=Zs(e.slice(s,r),ct(ct({},t),{},{stripPunctuation:!1})),s=r;return n+Zs(e.slice(s),t)}(i,ct(ct({},t),{},{stripPunctuation:t.stripPunctuation&&i.length!==e.length})))}function er(e){return e.replace(Ts,bs)}function tr(e,t){return function(e){return e.length>=10240&&(Ss.test(e)||function(e){const t=Cs.exec(e);if(!t)return!1;let i;try{i=decodeURIComponent(e.slice(t[0].length))}catch(e){return!1}return Es.test(i.replace(/[\r\n]/g,""))}(e)||ks.test(e)&&ws.test(e))}(e)?"[binary data redacted - not supported by PostHog MCP analytics]":function(e,t,i){const n=4*i.maxStringLength;if(e.length>n){const s=t(e.slice(0,function(e,t){let i=t;for(;i>0&&!Rs.test(e[i-1]);)i--;return i}(e,n)));if(s.length>=2*i.maxStringLength)return s+i.truncationSuffix}return t(e)}(e,e=>function(e){return Xs(e,{allowNestedUrls:!0,stripPunctuation:!0})}(function(e){let t=e.replace(Ds," ");return t=t.replace($s,bs),t=t.replace(Ns,bs),t=t.replace(Bs,`$1${bs}`),t=t.replace(Hs,nr),t=t.replace(qs,bs),t=t.replace(zs,`$1${bs}`),t=t.replace(Ws,`$1${bs}`),t}(er(e))),t)}function ir(e){let t=0,i=!1;for(let n=e.length-1;n>=0;n--){let s=e.charCodeAt(n)-48;if(0>s||s>9)return!1;i&&(s*=2,s>9&&(s-=9)),t+=s,i=!i}return t%10==0}function nr(e){const t=[];for(let i=Us.exec(e);null!==i;i=Us.exec(e))t.push({digits:i[0],start:i.index,end:i.index+i[0].length});let i="",n=0,s=0;for(;t.length>s;){let r="",o=-1;for(let e=s;t.length>e&&(r+=t[e].digits,19>=r.length);e++)r.length>=13&&ir(r)&&(o=e);0>o?s++:(i+=e.slice(n,t[s].start)+bs,n=t[o].end,s=o+1)}return i+e.slice(n)}const sr={}.propertyIsEnumerable;function rr(e,t){try{return lr(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function or(e,t,i,n){if(0>=i.remainingNodes)return{stringValue:Xi};if(i.remainingNodes--,Lt(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){const i=e.toString(),n=BigInt("9223372036854775808");return e>=n||-n>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}(e,t);if("number"==typeof e){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};const i=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:tn(e)};if("function"==typeof e)return{stringValue:"[Function]"};if("symbol"==typeof e)return{stringValue:String(e)};if("object"==typeof e&&null!==e){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(n>=20)return{stringValue:Xi};if(e instanceof Date){const t=e.getTime(),i=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:"string"==typeof i?tn(i):String(i)}}i.ancestors.add(e);try{try{const s=e.toJSON;if("function"==typeof s)return or(s.call(e),t,i,n+1)}catch(e){}return kt(e)?{arrayValue:{values:ar(e,t,i,n+1)}}:{kvlistValue:{values:lr(e,t,i,n+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:tn(String(e))}}function ar(e,t,i,n){const s=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&i.remainingNodes>0;o++)try{const r=o in e?e[o]:void 0;if(Mt(r))continue;s.push(or(r,t,i,n))}catch(e){s.push({stringValue:en})}return e.length>o&&s.push({stringValue:Xi}),s}function lr(e,t,i,n){const s=[];for(const r in e)if(sr.call(e,r)){if(!r){null==t||t.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(Pt(o)||xt(o))continue;s.push({key:tn(r),value:or(o,t,i,n)})}catch(e){s.push({key:tn(r),value:{stringValue:en}})}}return s}function cr(e,t,i){return ct(ct(ct(ct({},nn({},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":i})}const ur=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function dr(e,t){const i=nn({},e),n={};for(const e of ur)({}).hasOwnProperty.call(i,e)&&(n[e]=i[e],delete i[e]);return[...rr(i,t),...rr(n,t)]}const hr={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const pr={text:"INFO",number:9},gr={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:pr,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function _r(e){try{return tn(String(e))}catch(e){return en}}function fr(e,t,i,n){const s=e.level||"info",{text:r,number:o}=gr[s]||pr,a=function(e=Date.now()){return String(e)+"000000"}(Ft(n)?n:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),Mt(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),Mt(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=ct({},l),u=e.attributes;if(u){let e=[];try{e=Object.keys(u)}catch(t){e=[]}for(const t of e){let e;try{e=u[t]}catch(t){e=en}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:_r(e.body)},attributes:rr(c,i)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),xt(e.trace_flags)||(d.flags=e.trace_flags),d}function vr(e,t,i){return cr(e,t,i)}function mr(e,t,i,n){return{resourceLogs:[{resource:{attributes:dr(t)},scopeLogs:[{scope:{name:i,version:n},logRecords:e}]}]}}var yr=class{constructor(e){this._onFire=e,this._firesAt=0}get pending(){return!!this._timer}arm(e){this.clear(),this._firesAt=Date.now()+e,this._timer=dn(()=>{this._timer=void 0,this._onFire()},e)}armNoEarlierThan(e){this._timer&&Date.now()+e<=this._firesAt||this.arm(e)}clear(){this._timer&&(clearTimeout(this._timer),this._timer=void 0)}};function br(){return.75+.5*Math.random()}function Sr(e,t,i,n){const s=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,s);return Math.round((void 0===n?r:Math.min(r,Math.max(n,e)))*i)}var wr=class{constructor(e,t,i,n,s,r=()=>Promise.resolve(),o){var a;this._instance=e,this._config=t,this._logger=i,this._getContext=n,this._onReady=s,this._waitForStoragePersist=r,this._scopeName=o,this._flushTimer=new yr(()=>this._flushInBackground()),this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._retryAfter=new rn,this._consecutiveFlushFailures=0,this._flushJitter=1,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}clearQueue(){this._queueGeneration++,this._instance.setPersistedProperty(ut.LogsQueue,[])}reset(){this._flushTimer.clear(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.reset(),this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.isOpen()?this._hasQueuedRecords()&&this._armFlushTimer():this._flushInBackground()}captureLog(e,t){var i;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==e?void 0:e.body))return;const n=this._runBeforeSend(e);if(null===n)return;if(!n.body)return void this._logger.info("Log was rejected in beforeSend function");if(!this._checkRateLimit())return;const s={record:fr(n,null!==(i=null==t?void 0:t.context)&&void 0!==i?i:this._getContext(),this._logger,null==t?void 0:t.occurredAtMs)};this._onReady(()=>this._enqueue(s))}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let n=e;for(const e of i)try{const t=e(n);if(!t)return this._logger.info("Log was rejected in beforeSend function"),null;n=t}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return n}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;const 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 rt(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return rt(function*(){var t;e._flushTimer.clear();let i=null!==(t=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==t?t:[];if(0===i.length)return;const n=i.length;let s=0;for(;i.length>0&&n>s;){var r,o;const t=e._queueGeneration;e._evictedSinceAdvance=0;const n=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,n),l=mr(a.map(e=>e.record),e._buildResourceAttributes(),null!==(r=e._scopeName)&&void 0!==r?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(l);if(e._queueGeneration!==t)return;if("too-large"===c.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e._maxBatchRecordsPerPost}`);else{if(e._retryAfter.record(c),e._flushTimer.pending&&e._flushTimer.arm(Math.max(e._flushIntervalMs,e._retryAfter.remainingMs())),"retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.warn("Dropping a single log record 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(a.length),i=null!==(o=e._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==o?o:[],s+=a.length,"fatal"===c.kind)throw c.error}}})()}_persistQueueAdvance(e){var t=this;return rt(function*(){var i;const n=Math.max(0,e-t._evictedSinceAdvance),s=null!==(i=t._instance.getPersistedProperty(ut.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(ut.LogsQueue,s.slice(n)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return vr(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(this._instance.optedOut)return;const i=null!==(t=this._instance.getPersistedProperty(ut.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(ut.LogsQueue,i),this._maxBufferSize>i.length||this._retryAfter.isOpen()?this._armFlushTimer():this._flushInBackground()}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(Math.max(this._flushIntervalMs,this._retryAfter.remainingMs()))}_nextFlushDelay(){return Math.max(Sr(this._flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_hasQueuedRecords(){const e=this._instance.getPersistedProperty(ut.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return rt(function*(){t._flushTimer.clear();const i=t.flush().catch(()=>{});void 0!==e?yield hn(i,e):yield i})()}flushWithTimeout(e){var t=this;return rt(function*(){const i=t.flush();yield hn(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0,this._flushJitter=1},e=>{this._consecutiveFlushFailures++,this._flushJitter=br(),this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._flushTimer.armNoEarlierThan(this._nextFlushDelay())})}};const kr=/^[0-9a-f]+$/;function Cr(e,t,i){return"string"==typeof e&&e.length===t&&e!==i&&kr.test(e)}const Er=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;const Tr="00",xr=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ir(e){return String(e)+"000000"}function Rr(e,t,i,n){let s="";return n&&(s=Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(n[e])}`).join(",")),`${e}\0${t}\0${null!=i?i:""}\0${s}`}var Pr=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushTimer=new yr(()=>this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})),this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsByHistogram=new Map,this._boundsConflictWarned=new Set,this._boundsCapWarned=!1,this._retryAfter=new rn,this._consecutiveFlushFailures=0,this._flushJitter=1,this._generation=0}count(e,t=1,i){this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:kt(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var e=this;const t=this._flushPromise,i=function(){var i=rt(function*(){t&&(yield t.catch(()=>{})),yield e._doFlush()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this._flushPromise===i&&(this._flushPromise=null)});return this._flushPromise=i,i}drainWindow(){if(0===this._series.size)return null;const e=this._series;return this._startWindow(),this._buildPayload(e)}reset(){this._generation++,this._retryAfter.reset(),this._consecutiveFlushFailures=0,this._flushJitter=1,this._flushTimer.clear(),this._flushPromise=null,this._startWindow(),this._boundsByHistogram=new Map,this._boundsCapWarned=!1}_startWindow(){this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsConflictWarned=new Set}_capture(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this._runBeforeSend(e);if(null===t)return;if(!t.name||"string"!=typeof t.name)return void this._logger.warn("Dropping metric with empty name");if("number"!=typeof t.value||!Number.isFinite(t.value))return void this._logger.warn(`Dropping metric '${t.name}': value must be a finite number`);if("count"!==t.type&&"gauge"!==t.type&&"histogram"!==t.type)return void this._logger.warn(`Dropping metric '${t.name}': unknown type '${String(t.type)}'`);if("count"===t.type&&0>t.value)return void this._logger.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,n;try{i=t.attributes?ct({},t.attributes):void 0,n=Rr(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e)}let s,r=this._series.get(n);if(!r&&!this._admitNewSeries())return;if("histogram"===t.type&&(s=this._histogramBounds(t.name,t.unit,t.bounds),!s))return;r||(r={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now(),hist:s&&Fr(s)},this._series.set(n,r));const o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn(`Metric name '${t.name}' is already used as a ${o}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this._fold(r,t.value);const a=this._activeTraceContext();a&&(r.exemplar=ct(ct({},a),{},{value:t.value,timeMs:Date.now()})),this._armFlushTimer()}_activeTraceContext(){try{var e,t;const i=function(e){const t=function(e){if("string"!=typeof e)return;const t=Er.exec(e.trim());if(!t)return;const[,i,n,s,r,o]=t;return"ff"===i||"00"===i&&o||!function(e){return Cr(e,32,"00000000000000000000000000000000")}(n)||!function(e){return Cr(e,16,"0000000000000000")}(s)?void 0:{version:i,traceId:n,spanId:s,flags:r}}(e);return t&&{traceId:t.traceId,spanId:t.spanId,flags:(i=t.flags,1&parseInt(i,16)?"01":Tr)};var i}(null===(e=(t=this._instance).getActiveSpan)||void 0===e||null===(e=e.call(t))||void 0===e?void 0:e.traceparent());if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(e){}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}_histogramBounds(e,t,i){if(void 0!==i&&!function(e){if(!kt(e)||0===e.length)return!1;for(let t=0;e.length>t;t++)if(!Number.isFinite(e[t])||t>0&&e[t-1]>=e[t])return!1;return!0}(i))return void this._logger.warn(`Dropping histogram '${e}': bounds must be a non-empty array of finite, strictly increasing numbers`);const n=Rr("histogram",e,t,void 0),s=this._boundsByHistogram.get(n);if(s)return this._warnOnBoundsConflict(e,n,s,i),s;if(this._boundsByHistogram.size>=this._config.maxSeriesPerFlush){if(this._boundsCapWarned||(this._boundsCapWarned=!0,this._logger.warn(`Histogram bounds limit reached (${this._config.maxSeriesPerFlush} distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.`)),i&&!Mr(i,xr))return;return xr}const r=i?i.slice():xr;return this._boundsByHistogram.set(n,r),r}_warnOnBoundsConflict(e,t,i,n){Mr(i,null!=n?n:xr)||this._boundsConflictWarned.has(t)||(this._boundsConflictWarned.add(t),this._logger.warn(`Histogram '${e}' already uses the bounds [${i.join(", ")}]; samples that pass different bounds are recorded in those buckets.`))}_fold(e,t){switch(e.type){case"count":var i;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":{const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[function(e,t){for(let i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,i.bounds)]+=1;break}}}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=kt(t)?t:[t];let n=e;for(const e of i)try{const t=e(n);if(!t)return this._logger.info("Metric was rejected in beforeSend function"),null;n=t}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return n}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(this._nextFlushDelay())}_nextFlushDelay(){return Math.max(Sr(this._config.flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_doFlush(){var e=this;return rt(function*(){if(e._flushTimer.clear(),0===e._series.size)return;const t=e._series;e._startWindow();const i=e._generation,n=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(e._retryAfter.record(n),"retry-later"===n.kind?(e._consecutiveFlushFailures++,e._flushJitter=br()):(e._consecutiveFlushFailures=0,e._flushJitter=1),e._flushTimer.pending&&e._flushTimer.arm(e._nextFlushDelay()),n.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._flushTimer.armNoEarlierThan(e._nextFlushDelay());case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",n.error)}})()}_buildPayload(e){return t=this._buildMetrics(e),i=function(e,t,i){return cr(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),n=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:dr(i)},scopeMetrics:[{scope:{name:n,version:s},metrics:t}]}]};var t,i,n,s}_buildMetrics(e){const t=Ir(Date.now()),i=new Map;for(const o of e.values()){var n;const e=Rr(o.type,o.name,o.unit,void 0);let a=i.get(e);a||(a=ct({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(e,a));const l=rr(null!==(n=o.attributes)&&void 0!==n?n:{},this._logger),c=Ir(o.windowStartMs),u=Ar(o.exemplar);if("count"===o.type){var s;const e=ct({attributes:l,startTimeUnixNano:c,timeUnixNano:t,asDouble:null!==(s=o.total)&&void 0!==s?s:0},u);a.sum.dataPoints.push(e)}else if("gauge"===o.type){var r;const e=ct({attributes:l,timeUnixNano:t,asDouble:null!==(r=o.last)&&void 0!==r?r:0},u);a.gauge.dataPoints.push(e)}else{const e=o.hist,i=ct({attributes:l,startTimeUnixNano:c,timeUnixNano:t,count:e.count,sum:e.sum,min:e.min,max:e.max,bucketCounts:e.bucketCounts,explicitBounds:e.bounds},u);a.histogram.dataPoints.push(i)}}return Array.from(i.values())}_mergeWindowBack(e){for(const[s,r]of e){var t;const e=this._series.get(s);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,r.windowStartMs),e.exemplar=null!==(t=e.exemplar)&&void 0!==t?t:r.exemplar,e.type){case"count":var i,n;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+(null!==(n=r.total)&&void 0!==n?n:0);break;case"gauge":break;case"histogram":{const t=e.hist,i=r.hist;t.count+=i.count,t.sum+=i.sum,t.min=Math.min(t.min,i.min),t.max=Math.max(t.max,i.max);for(let e=0;t.bucketCounts.length>e;e++)t.bucketCounts[e]+=i.bucketCounts[e];break}}else this._admitNewSeries()&&this._series.set(s,r)}}};function Mr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let i=0;e.length>i;i++)if(e[i]!==t[i])return!1;return!0}function Fr(e){return{bounds:e,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(e.length+1).fill(0)}}function Ar(e){return e?{exemplars:[{filteredAttributes:[],timeUnixNano:Ir(e.timeMs),asDouble:e.value,traceId:e.traceId,spanId:e.spanId}]}:{}}function Lr(e,t){if(!e)return;const i=e.find(e=>e.type===t);return null==i?void 0:i.value}const Or="0.10.7",Dr={DEBUG:!1,LIB_VERSION:Or,LIB_NAME:"browser-common",JS_SDK_VERSION:Or},$r=(e,{debugEnabled:t}={})=>{const i={_log(i,...n){let s;try{s=typeof window>"u"?void 0:window}catch(e){return}s&&(Dr.DEBUG||s.POSTHOG_DEBUG||t)&&!xt(s.console)&&s.console&&("__rrweb_original__"in s.console[i]?s.console[i].__rrweb_original__:s.console[i])(e,...n)},debug(...e){i._log("debug",...e)},info(...e){i._log("log",...e)},warn(...e){i._log("warn",...e)},error(...e){i._log("error",...e)},critical(...t){console.error(e,...t)},uninitializedWarning(e){i.error(`You must initialize PostHog before calling ${e}`)},createLogger:(t,i)=>$r(`${e} ${t}`,i)};return i},Nr=$r("[PostHog.js]"),Br=(e,t)=>Nr.createLogger(e,t);function qr(e,t){kt(e)&&e.forEach(t)}function Hr(e,t){if(!Mt(e))if(kt(e))e.forEach(t);else if(Ot(e))e.forEach((e,i)=>t(e,i));else for(const i in e)St.call(e,i)&&t(e[i],i)}const Ur=function(e,...t){for(const i of t)for(const t in i)void 0!==i[t]&&(e[t]=i[t]);return e};function zr(e){const t=Object.keys(e);let i=t.length;const n=new Array(i);for(;i--;)n[i]=[t[i],e[t[i]]];return n}const Wr=function(e){return function(...t){try{return e.apply(this,t)}catch(e){Nr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Nr.critical(e)}}},jr=function(e){const t={};return Hr(e,function(e,i){(It(e)&&e.length>0||Ft(e))&&(t[i]=e)}),t};function Vr(e){const t=ct({},e);for(const i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}const Gr=["herokuapp.com","vercel.app","netlify.app"];function Qr(e){const t=null==e?void 0:e.hostname;if(!It(t))return!1;const i=t.split(".").slice(-2).join(".");for(const e of Gr)if(i===e)return!1;return!0}function Kr(e,t,i,n){const{capture:s=!1,passive:r=!0}=null!=n?n:{};null==e||e.addEventListener(t,i,{capture:s,passive:r})}function Jr(e){return"ph_toolbar_internal"===e.name}const Yr=e=>{const t=typeof document>"u"?void 0:document,i=null==t?void 0:t.createElement("a");return xt(i)?null:(i.href=e,i)},Zr=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(e){return!1}},Xr=(e,t)=>e>=t&&Zr(),eo=(e,t,i,n)=>{if(0===e){if(Zr()){const e=t+1;return e===i&&n(),e}return t}return 0},to=["localhost","127.0.0.1"],io=(e,t)=>{try{let i;return JSON.stringify(e,(e,t)=>{var n;return qt(t)?(null!==(n=i)&&void 0!==n||(i=new WeakMap),i.has(t)||i.set(t,Vr(t)),i.get(t)):"bigint"==typeof t?t.toString():t},t)}catch(t){return yt(e)}},no=function(e,t="&"){let i,n;const s=[];return Hr(e,function(e,t){xt(e)||xt(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),n=encodeURIComponent(t),s[s.length]=n+"="+i)}),s.join(t)},so=function(e,t){const i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let n;for(let e=0;i.length>e;e++){const s=i[e].split(/=(.*)/);if(s[0]===t){n=s;break}}if(!kt(n)||2>n.length)return"";{let e=n[1].replace(/\+/g," ");try{e=decodeURIComponent(e)}catch(t){Nr.error("Skipping decoding for malformed query param: "+e)}return e}},ro=function(e,t,i){if(!e||!t||!t.length)return e;const n=e.split(/#(.*)/),s=n[1],r=(n[0]||"").split(/\?(.*)/),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let e=0;l.length>e;e++){const n=l[e].split("?");let s=0;for(;n.length>s&&!t.includes(n[s].split("=")[0]);)s++;c.push(n.length>s?n.slice(0,s).concat(n[s].split("=")[0]+"="+i).join("?"):l[e])}let u=a;return null!=o&&(u+="?"+c.join("&")),null!=s&&(u+="#"+s),u},oo=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null};function ao(e,t){var i;const n=null==e||null===(i=e.config)||void 0===i?void 0:i.get_current_url;if(!Ct(n))return t;try{const e=n(t);return It(e)&&e?e:t}catch(e){return Nr.error("Error in get_current_url, falling back to window.location.href",e),t}}function lo(e){var t;const i=typeof window>"u"?void 0:window,n=null==i||null===(t=i.location)||void 0===t?void 0:t.href;return xt(n)?void 0:ao(e,n)}function co(e){var t;return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!!(null===(t=e.closest)||void 0===t?void 0:t.call(e,".toolbar-global-fade-container")))}function uo(e){return!!e&&1===e.nodeType}function ho(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function po(e){return!!e&&3===e.nodeType}function go(e){return!!e&&11===e.nodeType&&uo(e.host)}function _o(e){return e?vt(e).split(/\s+/):[]}function fo(e,t){const i=lo(t);return!!(i&&e&&e.some(e=>i.match(e)))}function vo(e){let 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 _o(t)}function mo(e){return Mt(e)?null:vt(e).split(/(\s+)/).filter(e=>Jo(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function yo(e){let t="";return Ho(e)&&!Uo(e)&&e.childNodes&&e.childNodes.length&&Hr(e.childNodes,function(e){var i;po(e)&&e.textContent&&(t+=null!==(i=mo(e.textContent))&&void 0!==i?i:"")}),vt(t)}function bo(e){var t;return xt(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}const So=["a","button","form","input","select","textarea","label"];function wo(e,t){const i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}function ko(e,t){if(xt(t))return!0;for(const i of e)if(t.some(e=>wo(i,e)))return!0;return!1}function Co(e){const t=e.parentNode;return!(!t||!uo(t))&&t}const Eo=[".ph-no-autocapture","[data-ph-no-autocapture]"],To=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],xo=(()=>[...To,"+","-","−","–"])(),Io=(()=>xo.length+10)(),Ro=["button","a","input","select","textarea","label"],Po=["button","link","tab","menuitem","option"],Mo=(e,t)=>/[a-z0-9]/i.test(t)?ft(xo,t)?new RegExp(`\\b${t}\\b`).test(e):e.includes(t):e===t,Fo=e=>ft(Ro,e.tagName.toLowerCase())||ft(Po,(e.getAttribute("role")||"").toLowerCase());function Ao(e){let t="",i="";const n=e=>{uo(e)&&Ho(e)&&!Uo(e)&&(t+=` ${yo(e)}`,i=i||e.getAttribute("aria-label")||"",Hr(e.childNodes,n))};n(e),t=vt(t.replace(/\s+/g," "));const s=(Jo(t)?t:"").toLowerCase(),r=e.getAttribute("aria-label")||(s?"":i);return{safeText:s,ariaLabel:vt(r).toLowerCase()}}const Lo=[".ph-no-deadclick",".ph-no-capture"],Oo=[".ph-no-rageclick",".ph-no-capture"],Do=["","text","search","email","password","url","tel","number"];function $o(e){return!(!e||!uo(e))&&(!!ho(e,"textarea")||(ho(e,"input")?ft(Do,(e.getAttribute("type")||"").toLowerCase()):function(e){var t;if(e.isContentEditable)return!0;const i=null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return"true"===i||""===i}(e)))}function No(e,t){if(!(typeof window>"u"?void 0:window)||Bo(e))return!1;let i,n,s;var r,o;if(Lt(t)?(i=!!t&&Oo,n=void 0,s=!1):(i=null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:Oo,n=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&&$o(e))return!1;const{targetElementList:a}=qo(e,!1);return!(n&&function(e,{safeText:t,ariaLabel:i}){let n;if(!0===e)n=To;else{if(!kt(e))return!1;if(e.length>Io)return Nr.error(`[PostHog] content_ignorelist array cannot exceed ${Io} items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map(e=>e.toLowerCase())}return n.some(e=>Mo(t,e)||Mo(i,e))}(n,function(e,t){for(const e of t)if(Fo(e))return Ao(e);for(const e of t){try{var i;if("pointer"!==(null===(i=window)||void 0===i?void 0:i.getComputedStyle(e).getPropertyValue("cursor")))break}catch(e){break}const t=Ao(e);if(t.safeText||t.ariaLabel)return t}return Ao(e)}(e,a))||ko(a,i))}const Bo=e=>!e||ho(e,"html")||!uo(e),qo=(e,t)=>{const i=typeof window>"u"?void 0:window;if(!i||Bo(e))return{parentIsUsefulElement:!1,targetElementList:[]};let n=!1;const s=[e];let r=e;for(;r.parentNode&&!ho(r,"body");){if(go(r.parentNode)){s.push(r.parentNode.host),r=r.parentNode.host;continue}const e=Co(r);if(!e)break;if(t||So.indexOf(e.tagName.toLowerCase())>-1)n=!0;else try{const t=i.getComputedStyle(e);t&&"pointer"===t.getPropertyValue("cursor")&&(n=!0)}catch(e){}s.push(e),r=e}return{parentIsUsefulElement:n,targetElementList:s}};function Ho(e){const t=new Set;let i=0;for(let n=e;n.parentNode&&!ho(n,"body");n=n.parentNode){if(i++>=1e3||t.has(n))return!1;t.add(n);const e=vo(n);if(ft(e,"ph-sensitive")||ft(e,"ph-no-capture"))return!1}if(ft(vo(e),"ph-include"))return!0;const n=e.type||"";if(It(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}const 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 Uo(e){return!!(ho(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ho(e,"select")||ho(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const zo=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Wo=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,jo=[16,15,14,13],Vo=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Go=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Qo=/[0-9A-Za-z_]/;function Ko(e){let t=0,i=!1;for(let n=e.length-1;n>=0;n--){let s=e.charCodeAt(n)-48;i&&(s*=2,s>9&&(s-=9)),t+=s,i=!i}return t%10==0}function Jo(e,t=!0){if(Mt(e))return!1;if(It(e)){if(e=vt(e),t?zo.test((e||"").replace(/[- ]/g,"")):function(e){let t;for(Wo.lastIndex=0;t=Wo.exec(e);){const e=t[2];if(!e)continue;const i=e.replace(/[- ]/g,"");for(let e=0;i.length>e;e++)for(const t of jo){const n=e+t;if(i.length>=n){const t=i.slice(e,n);if(zo.test(t)&&Ko(t))return!0}}}return!1}(e))return!1;if(t?Vo.test(e):function(e){let t;for(Go.lastIndex=0;t=Go.exec(e);){const e=t[1],i=t[3];if(!(e&&i&&Qo.test(e)&&Qo.test(i)))return!0}return!1}(e))return!1}return!0}function Yo(e){let t=yo(e);return t=`${t} ${Zo(e)}`.trim(),Jo(t)?t:""}function Zo(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Hr(e.childNodes,function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=yo(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${Zo(e)}`.trim())}catch(e){Nr.error("[AutoCapture]",e)}}),t}function Xo(e){return e.replace(/"|\\"/g,'\\"')}function ea(e){const t=e.attr__class;if(t)return kt(t)?t:_o(t)}const ta=1e6;function ia(e){var t;return Math.min(ta,null!==(t=e.payloadSizeLimitBytes)&&void 0!==t?t:ta)}const na={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:ta,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","google-analytics.com","analytics.google.com","nr-data.net","datadoghq.com","datadoghq.eu","ddog-gov.com","segment.io","rudderstack.com","amplitude.com","mixpanel.com","hotjar.com","hotjar.io","fullstory.com"],streamNetworkBody:!1},sa=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],ra=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],oa=["auth","token","secret","session","api-key","apikey","api_key","credential","password","passwd","cookie","csrf","xsrf"],aa=e=>{Mt(e)||Hr(Object.keys(e),t=>{(e=>{const t=e.toLowerCase();return sa.includes(t)||oa.some(e=>t.includes(e))})(t)&&(e[t]="redacted")})},la=["/s/","/e/","/i/"];function ca(e,t,i,n){if(Mt(e))return e;let s=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return It(s)&&(s=parseInt(s)),s>i?`[SessionRecording] ${n} body too large to record (${s} bytes)`:e}function ua(e,t){if(Mt(e))return e;let i=e;return Jo(i,!1)||(i="[SessionRecording] "+t+" body redacted"),Hr(ra,e=>{(null==i?void 0:i.length)&&-1!==(null==i?void 0:i.indexOf(e))&&(i="[SessionRecording] "+t+" body redacted as might contain: "+e)}),i}const da=new WeakSet,ha="disabled",pa="sampled",ga="active",_a="buffering",fa="paused",va="lazy_loading",ma="rrweb_error",ya="trigger_activated",ba="trigger_pending",Sa="trigger_disabled";function wa(e,t,i,n,s,r){return 0===t?Sa:(null==e?void 0:e.get_property(i?n+i:s))===r?ya:ba}function ka(e,t,i){return t.some(t=>{var n;return"regex"===t.matching&&(null!==(n=null==i?void 0:i.get(t.url))&&void 0!==n?n:new RegExp(t.url)).test(e)})}function Ca(e){return e.includes("trigger_activated")?ya:e.includes("trigger_pending")?ba:Sa}function Ea(e){const t=new Set(e);switch(t.delete(Sa),t.size){case 0:return Sa;case 1:return Array.from(t)[0];default:return ba}}var Ta=class{constructor(e){this._matchers=e}triggerStatus(e){return Ca(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return Ca(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},xa=class{constructor(e){this._matchers=e}triggerStatus(e){return Ea(this._matchers.map(t=>t.triggerStatus(e)))}triggerStatusNoSideEffects(e){return Ea(this._matchers.map(t=>t.triggerStatusNoSideEffects(e)))}stop(){this._matchers.forEach(e=>e.stop())}},Ia=class{triggerStatus(){return this.triggerStatusNoSideEffects()}triggerStatusNoSideEffects(){return ya}stop(){}};const Ra=e=>"sessionRecording"in e;var Pa=class{constructor(e,t){this._instance=e,this._urlTriggers=[],this._urlBlocklist=[],this._compiledTriggerRegexes=new Map,this._compiledBlocklistRegexes=new Map,this._lastCheckedUrl="",this.urlBlocked=!1,this._groupId=t}onConfig(e){var t,i;this._urlTriggers=(Ra(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.urlTriggers:[]:null==e?void 0:e.urlTriggers)||[],this._urlBlocklist=(Ra(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.urlBlocklist:[]:null==e?void 0:e.urlBlocklist)||[],this._compileRegexCache()}_compileRegexCache(){this._compiledTriggerRegexes.clear(),this._compiledBlocklistRegexes.clear();for(const e of this._urlTriggers)if("regex"===e.matching&&!this._compiledTriggerRegexes.has(e.url))try{this._compiledTriggerRegexes.set(e.url,new RegExp(e.url))}catch(t){Nr.error("Invalid URL trigger regex pattern:",e.url,t)}for(const e of this._urlBlocklist)if("regex"===e.matching&&!this._compiledBlocklistRegexes.has(e.url))try{this._compiledBlocklistRegexes.set(e.url,new RegExp(e.url))}catch(t){Nr.error("Invalid URL blocklist regex pattern:",e.url,t)}}onRemoteConfig(e){this.onConfig(e)}_urlTriggerStatus(e){return wa(this._instance,this._urlTriggers.length,this._groupId,_e,he,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[Ve]:t}),t}triggerStatusNoSideEffects(e){return this._urlTriggerStatus(e)}isCurrentUrlBlocked(){const e=lo(this._instance);if(!e)return!1;try{return ka(e,this._urlBlocklist,this._compiledBlocklistRegexes)}catch(e){return!0}}checkUrlBlocklist(e,t){const i=lo(this._instance);if(!i)return;if(i===this._lastCheckedUrl)return;this._lastCheckedUrl=i;const n=this.urlBlocked,s=ka(i,this._urlBlocklist,this._compiledBlocklistRegexes);n&&s||(s&&!n?e():!s&&n&&t())}checkUrlTriggerConditions(e,t,i,n){const s=lo(this._instance);if(!s)return;if(s===this._lastCheckedUrl)return;this._lastCheckedUrl=s;const r=this.urlBlocked,o=ka(s,this._urlBlocklist,this._compiledBlocklistRegexes);o&&!r?e():!o&&r&&t();const a=this._urlTriggerStatus(n)===ya,l=ka(s,this._urlTriggers,this._compiledTriggerRegexes);!a&&l&&i("url",s)}stop(){this._lastCheckedUrl=""}},Ma=class{constructor(e){this._instance=e,this.linkedFlag=null,this.linkedFlagSeen=!1,this._flagListenerCleanup=()=>{}}triggerStatus(){const e=this.triggerStatusNoSideEffects();return this._instance.register_for_session({[He]:e}),e}triggerStatusNoSideEffects(){let e=ba;return Mt(this.linkedFlag)&&(e=Sa),this.linkedFlagSeen&&(e=ya),e}onConfig(e,t){var i;if(this.linkedFlag=(Ra(e)?Et(e.sessionRecording)?null===(i=e.sessionRecording)||void 0===i?void 0:i.linkedFlag:null:null==e?void 0:e.linkedFlag)||null,!Mt(this.linkedFlag)&&!this.linkedFlagSeen){const e=It(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,i=It(this.linkedFlag)?null:this.linkedFlag.variant;this._flagListenerCleanup=this._instance.onFeatureFlags((n,s)=>{let r=!1;if(Et(s)&&e in s){const t=s[e];r=Lt(t)?!0===t:i?t===i:!!t}const o=r&&!this.linkedFlagSeen;this.linkedFlagSeen=r,o&&t(e,i)})}}onRemoteConfig(e,t){this.onConfig(e,t)}stop(){this._flagListenerCleanup()}},Fa=class{constructor(e,t){this._instance=e,this._eventTriggers=[],this._groupId=t}onConfig(e){var t;this._eventTriggers=(Ra(e)?Et(e.sessionRecording)?null===(t=e.sessionRecording)||void 0===t?void 0:t.eventTriggers:[]:null==e?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}_eventTriggerStatus(e){return wa(this._instance,this._eventTriggers.length,this._groupId,ge,pe,e)}triggerStatus(e){const t=this.triggerStatusNoSideEffects(e);return this._instance.register_for_session({[qe]:t}),t}triggerStatusNoSideEffects(e){return this._eventTriggerStatus(e)}checkEventTriggerConditions(e,t,i){if(0===this._eventTriggers.length)return;const n=this._eventTriggerStatus(i)===ya,s=this._eventTriggers.includes(e);!n&&s&&t("event",e)}stop(){}},Aa=class{constructor(e,t,i){if(this._instance=e,this.group=t,this._urlTriggerMatching=new Pa(e,t.id),this._eventTriggerMatching=new Fa(e,t.id),this._linkedFlagMatching=new Ma(e),t.conditions.events&&t.conditions.events.length>0||t.conditions.urls&&t.conditions.urls.length>0||t.conditions.flag){const e=(t.conditions.events||[]).map(e=>e.name),n={urlTriggers:t.conditions.urls||[],eventTriggers:e,linkedFlag:t.conditions.flag||null,urlBlocklist:[]};this._urlTriggerMatching.onConfig(n),this._eventTriggerMatching.onConfig(n),this._linkedFlagMatching.onConfig(n,i);const s=[this._eventTriggerMatching,this._urlTriggerMatching,this._linkedFlagMatching];this._combinedMatching="any"===t.conditions.matchType?new Ta(s):new xa(s)}else this._combinedMatching=new Ia}triggerStatus(e){return this._combinedMatching.triggerStatus(e)}triggerStatusNoSideEffects(e){return this._combinedMatching.triggerStatusNoSideEffects(e)}getPendingTriggerConditions(e){return"trigger_pending"!==this.triggerStatusNoSideEffects(e)?[]:[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===ba).map(({label:e})=>e)}checkEventTriggerConditions(e,t,i){this._eventTriggerMatching.checkEventTriggerConditions(e,t,i)}checkUrlTriggerConditions(e,t,i,n){this._urlTriggerMatching.checkUrlTriggerConditions(e,t,i,n)}activateTrigger(e,t){var i;const n="url"===e?_e+this.group.id:ge+this.group.id;null===(i=this._instance.persistence)||void 0===i||i.register({[n]:t})}stop(){this._urlTriggerMatching.stop(),this._eventTriggerMatching.stop(),this._linkedFlagMatching.stop()}};function La(e){if(e.rrwebError)return ma;if(!e.receivedFlags)return _a;if(!e.isRecordingEnabled)return ha;if(e.urlTriggerMatching.urlBlocked)return fa;const t=!0===e.isSampled,i=new Ta([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId);return t?pa:"trigger_activated"===i?ga:"trigger_pending"===i?_a:!1===e.isSampled?ha:ga}function Oa(e){if(e.rrwebError)return ma;if(!e.receivedFlags)return _a;if(!e.isRecordingEnabled)return ha;if(e.urlTriggerMatching.urlBlocked)return fa;const t=new xa([e.eventTriggerMatching,e.urlTriggerMatching,e.linkedFlagMatching]).triggerStatus(e.sessionId),i=t!==Sa,n=Lt(e.isSampled);return i&&"trigger_pending"===t?_a:i&&"trigger_disabled"===t||n&&!e.isSampled?ha:!0===e.isSampled?pa:ga}function Da(){const e=[];return function(t,i){if(Et(i)||kt(i)){for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(i)?"[Circular]":(e.push(i),i)}return i}}function $a(e){try{const t=JSON.stringify(e,Da());return t?new Blob([t]).size:0}catch(e){return-1}}function Na(e){if(Pt(e))return 4;if(xt(e))return 0;switch(typeof e){case"string":return e.length+2;case"number":return String(e).length;case"boolean":return e?4:5;case"object":{if(kt(e)){let t=2;for(let i=0;e.length>i;i++){i>0&&(t+=1);const n=e[i];t+=xt(n)||Pt(n)?4:Na(n)}return t}const t=e;let i=2,n=!0;for(const e in t){if(!{}.hasOwnProperty.call(t,e))continue;const s=t[e];xt(s)||(n||(i+=1),n=!1,i+=e.length+3+Na(s))}return i}default:return 0}}function Ba(e,t=6606028.8){if(e.size>=t&&e.data.length>1){const t=Math.floor(e.data.length/2),i=e.sizes.slice(0,t),n=e.sizes.slice(t);return[Ba({size:i.reduce((e,t)=>e+t,0),data:e.data.slice(0,t),sizes:i,sessionId:e.sessionId,windowId:e.windowId}),Ba({size:n.reduce((e,t)=>e+t,0),data:e.data.slice(t),sizes:n,sessionId:e.sessionId,windowId:e.windowId})].flatMap(e=>e)}return[e]}var qa=Uint8Array,Ha=Uint16Array,Ua=Uint32Array,za=new qa([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]),Wa=new qa([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]),ja=new qa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Va=function(e,t){for(var i=new Ha(31),n=0;31>n;++n)i[n]=t+=1<<e[n-1];var s=new Ua(i[30]);for(n=1;30>n;++n)for(var r=i[n];i[n+1]>r;++r)s[r]=r-i[n]<<5|n;return[i,s]},Ga=Va(za,2),Qa=Ga[1];Ga[0][28]=258,Qa[258]=28;for(var Ka=Va(Wa,0)[1],Ja=new Ha(32768),Ya=0;32768>Ya;++Ya){var Za=(43690&Ya)>>>1|(21845&Ya)<<1;Ja[Ya]=((65280&(Za=(61680&(Za=(52428&Za)>>>2|(13107&Za)<<2))>>>4|(3855&Za)<<4))>>>8|(255&Za)<<8)>>>1}var Xa=function(e,t,i){for(var n=e.length,s=0,r=new Ha(t);n>s;++s)++r[e[s]-1];var o,a=new Ha(t);for(s=0;t>s;++s)a[s]=a[s-1]+r[s-1]<<1;if(i){o=new Ha(1<<t);var l=15-t;for(s=0;n>s;++s)if(e[s])for(var c=s<<4|e[s],u=t-e[s],d=a[e[s]-1]++<<u,h=d|(1<<u)-1;h>=d;++d)o[Ja[d]>>>l]=c}else for(o=new Ha(n),s=0;n>s;++s)o[s]=Ja[a[e[s]-1]++]>>>15-e[s];return o},el=new qa(288);for(Ya=0;144>Ya;++Ya)el[Ya]=8;for(Ya=144;256>Ya;++Ya)el[Ya]=9;for(Ya=256;280>Ya;++Ya)el[Ya]=7;for(Ya=280;288>Ya;++Ya)el[Ya]=8;var tl=new qa(32);for(Ya=0;32>Ya;++Ya)tl[Ya]=5;var il=Xa(el,9,0),nl=Xa(tl,5,0),sl=function(e){return(e/8|0)+(7&e&&1)},rl=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof Ha?Ha:e instanceof Ua?Ua:qa)(i-t);return n.set(e.subarray(t,i)),n},ol=function(e,t,i){var n=t/8|0;e[n]|=i<<=7&t,e[n+1]|=i>>>8},al=function(e,t,i){var n=t/8|0;e[n]|=i<<=7&t,e[n+1]|=i>>>8,e[n+2]|=i>>>16},ll=function(e,t){for(var i=[],n=0;e.length>n;++n)e[n]&&i.push({s:n,f:e[n]});var s=i.length,r=i.slice();if(!s)return[new qa(0),0];if(1==s){var o=new qa(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],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=i[i[d].f>i[c].f?c++:d++],l=i[c!=u&&i[d].f>i[c].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(n=1;s>n;++n)r[n].s>h&&(h=r[n].s);var p=new Ha(h+1),g=cl(i[u-1],p,0);if(g>t){n=0;var _=0,f=g-t,v=1<<f;for(r.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});s>n;++n){var m=r[n].s;if(t>=p[m])break;_+=v-(1<<g-p[m]),p[m]=t}for(_>>>=f;_>0;){var y=r[n].s;t>p[y]?_-=1<<t-p[y]++-1:++n}for(;n>=0&&_;--n){var b=r[n].s;p[b]==t&&(--p[b],++_)}g=t}return[new qa(p),g]},cl=function(e,t,i){return-1==e.s?Math.max(cl(e.l,t,i+1),cl(e.r,t,i+1)):t[e.s]=i},ul=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Ha(++t),n=0,s=e[0],r=1,o=function(e){i[n++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++r;else{if(!s&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(s),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(s);r=1,s=e[a]}return[i.subarray(0,n),t]},dl=function(e,t){for(var i=0,n=0;t.length>n;++n)i+=e[n]*t[n];return i},hl=function(e,t,i){var n=i.length,s=sl(t+2);e[s]=255&n,e[s+1]=n>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var r=0;n>r;++r)e[s+r+4]=i[r];return 8*(s+4+n)},pl=function(e,t,i,n,s,r,o,a,l,c,u){ol(t,u++,i),++s[256];for(var d=ll(s,15),h=d[0],p=d[1],g=ll(r,15),_=g[0],f=g[1],v=ul(h),m=v[0],y=v[1],b=ul(_),S=b[0],w=b[1],k=new Ha(19),C=0;m.length>C;++C)k[31&m[C]]++;for(C=0;S.length>C;++C)k[31&S[C]]++;for(var E=ll(k,7),T=E[0],x=E[1],I=19;I>4&&!T[ja[I-1]];--I);var R,P,M,F,A=c+5<<3,L=dl(s,el)+dl(r,tl)+o,O=dl(s,h)+dl(r,_)+o+14+3*I+dl(k,T)+(2*k[16]+3*k[17]+7*k[18]);if(L>=A&&O>=A)return hl(t,u,e.subarray(l,l+c));if(ol(t,u,1+(L>O)),u+=2,L>O){R=Xa(h,p,0),P=h,M=Xa(_,f,0),F=_;var D=Xa(T,x,0);for(ol(t,u,y-257),ol(t,u+5,w-1),ol(t,u+10,I-4),u+=14,C=0;I>C;++C)ol(t,u+3*C,T[ja[C]]);u+=3*I;for(var N=[m,S],B=0;2>B;++B){var q=N[B];for(C=0;q.length>C;++C)ol(t,u,D[H=31&q[C]]),u+=T[H],H>15&&(ol(t,u,q[C]>>>5&127),u+=q[C]>>>12)}}else R=il,P=el,M=nl,F=tl;for(C=0;a>C;++C)if(n[C]>255){var H;al(t,u,R[257+(H=n[C]>>>18&31)]),u+=P[H+257],H>7&&(ol(t,u,n[C]>>>23&31),u+=za[H]);var U=31&n[C];al(t,u,M[U]),u+=F[U],U>3&&(al(t,u,n[C]>>>5&8191),u+=Wa[U])}else al(t,u,R[n[C]]),u+=P[n[C]];return al(t,u,R[256]),u+P[256]},gl=new Ua([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),_l=new qa(0),fl=function(){for(var e=new Ua(256),t=0;256>t;++t){for(var i=t,n=9;--n;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),vl=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ml(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,n=0;t.length>n;++n)i=fl[255&i^t[n]]^i>>>8;e=i},d(){return 4294967295^e}}}(),n=e.length;i.p(e);var s,r,o,a,l,c=(s=e,r=t,o=function(e){return 10+(e.filename&&e.filename.length+1||0)}(t),a=8,function(e,t,i,n,s,r){var o=e.length,a=new qa(n+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(n,a.length-s),c=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?c=hl(l,c,e.subarray(u,d)):(l[u]=r,c=hl(l,c,e.subarray(u,o)))}else{for(var h=gl[t-1],p=h>>>13,g=8191&h,_=(1<<i)-1,f=new Ha(32768),v=new Ha(_+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&_},S=new Ua(25e3),w=new Ha(288),k=new Ha(32),C=0,E=0,T=(u=0,0),x=0,I=0;o>u;++u){var R=b(u),P=32767&u,M=v[R];if(f[P]=M,v[R]=P,u>=x){var F=o-u;if((C>7e3||T>24576)&&F>423){c=pl(e,l,0,S,w,k,E,T,I,u-I,c),T=C=E=0,I=u;for(var A=0;286>A;++A)w[A]=0;for(A=0;30>A;++A)k[A]=0}var L=2,O=0,D=g,N=P-M&32767;if(F>2&&R==b(u-N))for(var B=Math.min(p,F)-1,q=Math.min(32767,u),H=Math.min(258,F);q>=N&&--D&&P!=M;){if(e[u+L]==e[u+L-N]){for(var U=0;H>U&&e[u+U]==e[u+U-N];++U);if(U>L){if(L=U,O=N,U>B)break;var z=Math.min(N,U-2),W=0;for(A=0;z>A;++A){var j=u-N+A+32768&32767,V=j-f[j]+32768&32767;V>W&&(W=V,M=j)}}}N+=(P=M)-(M=f[P])+32768&32767}if(O){S[T++]=268435456|Qa[L]<<18|Ka[O];var G=31&Qa[L],Q=31&Ka[O];E+=za[G]+Wa[Q],++w[257+G],++k[Q],x=u+L,++C}else S[T++]=e[u],++w[e[u]]}}c=pl(e,l,r,S,w,k,E,T,I,u-I,c),r||(c=hl(l,c,_l))}return rl(a,0,n+sl(c)+s)}(s,null==r.level?6:r.level,null==r.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(s.length)))):12+r.mem,o,a,!l)),u=c.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&&vl(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var n=0;i.length>=n;++n)e[n+10]=i.charCodeAt(n)}}(c,t),vl(c,u-8,i.d()),vl(c,u-4,n),c}function yl(e,t){var i=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var n=new qa(e.length+(e.length>>>1)),s=0,r=function(e){n[s++]=e},o=0;i>o;++o){if(s+5>n.length){var a=new qa(s+8+(i-o<<1));a.set(n),n=a}var l=e.charCodeAt(o);128>l||t?r(l):2048>l?(r(192|l>>>6),r(128|63&l)):l>55295&&57344>l?(r(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),r(128|l>>>12&63),r(128|l>>>6&63),r(128|63&l)):(r(224|l>>>12),r(128|l>>>6&63),r(128|63&l))}return rl(n,0,s)}function bl(e,t){var i="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var n=0;e.length>n;){var s=e[n++];128>s||t?i+=String.fromCharCode(s):224>s?i+=String.fromCharCode((31&s)<<6|63&e[n++]):240>s?i+=String.fromCharCode((15&s)<<12|(63&e[n++])<<6|63&e[n++]):(s=((15&s)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,i+=String.fromCharCode(55296|s>>10,56320|1023&s))}return i}var Sl=class{constructor(e,t={}){var i,n,s,r;this._rrweb=e,this._options=t,this._loggedTracker={},this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0,this._refillByteBudget=()=>{const e=Date.now(),t=e-this._lastByteRefill;t>0?(this._byteTokens=Math.min(this._bytesBucketSize,this._byteTokens+t/1e3*this._bytesRefillRate),this._lastByteRefill=e):this._lastByteRefill=e},this._onNodeRateLimited=e=>{if(!this._loggedTracker[e]){var t,i;this._loggedTracker[e]=!0;const n=this._getNode(e);null===(t=(i=this._options).onBlockedNode)||void 0===t||t.call(i,e,n)}},this._getNodeOrRelevantParent=e=>{const t=this._getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){const e=t.closest("svg");if(e)return[this._rrweb.mirror.getId(e),e]}return[e,t]},this._getNode=e=>this._rrweb.mirror.getNode(e),this._numberOfChanges=e=>{var t,i,n,s,r,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(n=null===(s=e.attributes)||void 0===s?void 0:s.length)&&void 0!==n?n:0)+(null!==(r=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==r?r:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)},this.throttleMutations=e=>{if(3!==e.type||0!==e.data.source)return e;const t=e.data,i=this._numberOfChanges(t);if(t.attributes){const e=t.attributes.length;t.attributes=t.attributes.filter(e=>{const[t]=this._getNodeOrRelevantParent(e.id);return!this._rateLimiter.consumeRateLimit(t)&&e});const i=e-t.attributes.length;var n,s;i>0&&(null===(n=(s=this._options).onDroppedAttributeMutations)||void 0===n||n.call(s,i))}const r=this._numberOfChanges(t);if(0===r&&i!==r)return;if(this._byteBudgetDisabled)return e;this._refillByteBudget();const o=Na(e);var a,l;return o>this._byteTokens?(null===(a=(l=this._options).onDroppedOversizedMutation)||void 0===a||a.call(l,o),void this._scheduleResync()):(this._byteTokens-=o,e)},this._scheduleResync=()=>{if(this._resyncTimer)return;const e=Math.max(0,this._resyncIntervalMs-(Date.now()-this._lastResyncAt));this._resyncTimer=setTimeout(()=>{var e,t;this._resyncTimer=void 0,this._lastResyncAt=Date.now(),null===(e=(t=this._options).requestFullSnapshot)||void 0===e||e.call(t)},e)},this._rateLimiter=new Jt({bucketSize:null!==(i=this._options.bucketSize)&&void 0!==i?i:100,refillRate:null!==(n=this._options.refillRate)&&void 0!==n?n:10,refillInterval:1e3,_onBucketRateLimited:this._onNodeRateLimited,_logger:Nr}),this._bytesBucketSize=null!==(s=this._options.bytesBucketSize)&&void 0!==s?s:0,this._bytesRefillRate=null!==(r=this._options.bytesRefillRate)&&void 0!==r?r:25600,this._byteBudgetDisabled=!Number.isFinite(this._bytesBucketSize)||0>=this._bytesBucketSize,this._byteTokens=this._bytesBucketSize;const o=this._options.resyncIntervalMs;this._resyncIntervalMs=Ft(o)&&Number.isFinite(o)&&o>0?o:3e5}reset(){this._loggedTracker={},this._resyncTimer&&(clearTimeout(this._resyncTimer),this._resyncTimer=void 0),this._lastResyncAt=Date.now()}stop(){this._rateLimiter.stop(),this.reset(),this._byteTokens=this._bytesBucketSize,this._lastByteRefill=Date.now(),this._lastResyncAt=-1/0}};const wl=e=>{if(n){try{const t=e+"=",i=n.cookie.split(";").filter(e=>e.length);for(let e=0;i.length>e;e++){let n=i[e];for(;" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(t))return decodeURIComponent(n.substring(t.length,n.length))}}catch(e){}return null}};var kl=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,n,s){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(n)||!Number.isInteger(s)||0>t||0>i||0>n||0>s||t>0xffffffffffff||i>4095||n>1073741823||s>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|i>>>8,r[7]=i,r[8]=128|n>>>24,r[9]=n>>>16,r[10]=n>>>8,r[11]=n,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new e(r)}toString(){let e="";for(let 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 e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;16>t;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},Cl=class{generate(){const e=this.generateOrAbort();if(!xt(e))return e;{this._timestamp=0;const e=this.generateOrAbort();if(xt(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){const e=(()=>{const e=Date.now();return Ft(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();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 kl.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new xl}};const El=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};let Tl;var xl=class{nextUint32(){var e;return this._buffer.length>this._cursor||((null!==(e=Tl)&&void 0!==e?e:Tl="u">typeof window&&!xt(window.crypto)&&crypto.getRandomValues?e=>{try{return crypto.getRandomValues(e)}catch(t){return El(e)}}:El)(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}};let Il;const Rl=()=>Pl().toString(),Pl=()=>(Il||(Il=new Cl)).generate();let Ml="";const Fl=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Al=null;const Ll={_is_supported(){if(!Pt(Al))return Al;if(Al=!1,n)try{const e=`__ph_cookie_support_${Rl()}`;Ll._set(e,"xyz"),Al='"xyz"'===wl(e),Ll._remove(e)}catch(e){Al=!1}return Al},_error(e){Nr.error("cookieStore error: "+e)},_get:wl,_parse(e){let t;try{t=JSON.parse(Ll._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(!n)return!1;try{let o="",a="";const l=function(e,t){if(t){let t=function(e,t=n){if(Ml)return Ml;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let s=Math.min(i.length,8);const r="dmn_chk_"+Rl();for(;!Ml&&s--;){const e=i.slice(s).join("."),n=r+"=1;domain=."+e+";path=/";t.cookie=n+";max-age=3",t.cookie.includes(r)&&(t.cookie=n+";max-age=0",Ml=e)}return Ml}(e);if(!t){const i=(e=>{const t=e.match(Fl);return t?t[0]:""})(e);i!==t&&Nr.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}(n.location.hostname,s);if(i){const e=new Date;e.setTime(e.getTime()+864e5*i),o="; expires="+e.toUTCString()}r&&(a="; secure");const c=e+"="+encodeURIComponent(JSON.stringify(t))+o+"; SameSite=Lax; path=/"+l+a;return c.length>3686.4&&Nr.warn("cookieStore warning: large cookie, len="+c.length),n.cookie=c,!0}catch(e){return!1}},_remove(e,t){if((null==n?void 0:n.cookie)&&(!t||!Pt(wl(e))))try{Ll._set(e,"",-1,t)}catch(e){return}}};let Ol=null;const Dl={_is_supported(){if(!Pt(Ol))return Ol;let t=!0;if(xt(e))t=!1;else try{const e="__mplssupport__";Dl._set(e,"xyz"),'"xyz"'!==Dl._get(e)&&(t=!1),Dl._remove(e)}catch(e){t=!1}return t||Nr.error("localStorage unsupported; falling back to cookie store"),Ol=t,t},_error(e){Nr.error("localStorage error: "+e)},_get(t){try{return null==e?void 0:e.localStorage.getItem(t)}catch(e){Dl._error(e)}return null},_parse(e){try{return JSON.parse(Dl._get(e))||{}}catch(e){}return null},_set(t,i){try{return null==e||e.localStorage.setItem(t,JSON.stringify(i)),!0}catch(e){Dl._error(e)}return!1},_remove(t){try{null==e||e.localStorage.removeItem(t)}catch(e){Dl._error(e)}}},$l=[S,p,y,g,C,v,f,_,w],Nl=[N,D,ce,ue,Ae,Fe,z,xe],Bl=e=>e+"_cpm",ql=["__proto__","constructor","prototype"],Hl=e=>{if(!Et(e))return{};const t={};return Object.keys(e).forEach(i=>{-1===ql.indexOf(i)&&(t[i]=e[i])}),t},Ul=(e,t=[])=>{const i={};return[...Nl,...t].forEach(t=>{const n=e[t];xt(n)||Pt(n)||""===n||(i[t]=n)}),i},zl=e=>{let t=5381,i=2166136261;for(let n=0;e.length>n;n++){const s=e.charCodeAt(n);t=33*t^s,i=Math.imul(i^s,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},Wl=(e,t)=>({p:t,f:zl(JSON.stringify(e))}),jl=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const i=Ll._parse(Bl(e)),n=(null==i?void 0:i.f)===zl(t)&&kt(i.p);return{properties:n?i.p:[],isValid:n}}catch(e){return{properties:[],isValid:!1}}},Vl=(e,t)=>t+"|"+(Ll._get(Bl(e))||""),Gl={},Ql={_is_supported:()=>!0,_error(e){Nr.error("memoryStorage error: "+e)},_get:e=>e in Gl?Gl[e]:null,_parse:e=>e in Gl?Gl[e]:null,_set:(e,t)=>(Gl[e]=t,!0),_remove(e){delete Gl[e]}};let Kl=null;const Jl={_is_supported(){if(!Pt(Kl))return Kl;if(Kl=!0,xt(e))Kl=!1;else try{const e="__support__";Jl._set(e,"xyz"),'"xyz"'!==Jl._get(e)&&(Kl=!1),Jl._remove(e)}catch(e){Kl=!1}return Kl},_error(e){Nr.error("sessionStorage error: ",e)},_get(t){try{return null==e?void 0:e.sessionStorage.getItem(t)}catch(e){Jl._error(e)}return null},_parse(e){try{return JSON.parse(Jl._get(e))||null}catch(e){}return null},_set(t,i){try{return null==e||e.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(e){Jl._error(e)}return!1},_remove(t){try{null==e||e.sessionStorage.removeItem(t)}catch(e){Jl._error(e)}}};Dr.DEBUG=!1,Dr.LIB_VERSION="1.447.3",Dr.LIB_NAME="web";var Yl=Dr,Zl=class{constructor(e){if(!e.persistence)throw new Error("it is not valid to not have persistence and be this far into setting up the application");this._getProperty=e.get_property.bind(e),this._setProperty=e.persistence.set_property.bind(e.persistence)}trackSize(e,t){this._setProperty(me,{sessionId:e,size:this.currentTrackedSize(e)+t})}currentTrackedSize(e){const t=this._getProperty(me);return Et(i=t)&&It(i.sessionId)&&Ft(i.size)&&t.sessionId===e?t.size:0;var i}};function Xl(e,t){return function(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<Kt(100*t,0,100,Nr)}function ec(e){return`$survey_response_${e}`}function tc(e,t){if(!t)return null;const i=e[ec(t)];return kt(i)?[...i]:i}function ic({event:e,survey:t,responses:i={},submissionId:n,completed:s,surveyLanguage:r,questionSnapshots:o}){return ct(ct(ct(ct({},!xt(n)&&{$survey_submission_id:n}),"sent"===e?!xt(s)&&{$survey_completed:s}:{$survey_partially_completed:nc(i)}),r&&{$survey_language:r}),function(e={},t,i){const n={};return t.questions.forEach(t=>{if(xt(t.originalQuestionIndex))return;const i=0===(s=t.originalQuestionIndex)?"$survey_response":`$survey_response_${s}`;var s;const r=tc(e,t.id);xt(r)||(n[i]=r)}),ct(ct({$survey_questions:t.questions.map(t=>{var n,s;return{id:t.id,question:null!==(n=null==i?void 0:i[null!==(s=t.id)&&void 0!==s?s:""])&&void 0!==n?n:t.question,response:tc(e,t.id)}})},e),n)}(i,t,o))}function nc(e={}){return Object.values(e).some(e=>!Mt(e))}function sc(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function rc(e){return"string"==typeof e&&e.trim()?e.trim():null}function oc(e){return e.toLowerCase()}function ac(e,t,i){if(!e||!t)return null;const n=oc(t),s=Object.keys(e).find(e=>oc(e)===n);if(s)return null==i||i.debug(`Found exact translation match: ${s}`),s;if(n.includes("-")){const s=n.split("-")[0],r=Object.keys(e).find(e=>oc(e)===s);if(r)return null==i||i.debug(`Found base language translation match: ${r} (from ${t})`),r}return null}const lc=["thankYouMessageHeader","thankYouMessageDescription","thankYouMessageCloseButtonText","introScreenHeader","introScreenDescription","introScreenButtonText","submitButtonText","backButtonText"];function cc(e,t,i){var n;const s=ac(e.translations,t,i),r=ct({},e);let o=!1;if(s){var a;const t=null===(a=e.translations)||void 0===a?void 0:a[s];if(t)if(null==i||i.info(`Applying survey-level translation for language: ${s}`),xt(t.name)||(r.name=t.name,o=!0),r.appearance){const e=ct({},r.appearance);for(const i of lc){const n=t[i];xt(n)||(e[i]=n,o=!0)}r.appearance=e}else(function(e){return lc.some(t=>!xt(e[t]))})(t)&&(o=!0)}const l=e.questions.map(e=>function(e,t,i){var n;const s=ac(e.translations,t,i);if(!s)return{question:e,matchedKey:null,hasChanges:!1};const r=null===(n=e.translations)||void 0===n?void 0:n[s];if(!r)return{question:e,matchedKey:null,hasChanges:!1};const o=ct({},e);let a=!1;return xt(r.question)||(o.question=r.question,a=!0),xt(r.description)||(o.description=r.description,a=!0),xt(r.buttonText)||(o.buttonText=r.buttonText,a=!0),"link"in o&&!xt(r.link)&&(o.link=r.link,a=!0),"lowerBoundLabel"in o&&!xt(r.lowerBoundLabel)&&(o.lowerBoundLabel=r.lowerBoundLabel,a=!0),"upperBoundLabel"in o&&!xt(r.upperBoundLabel)&&(o.upperBoundLabel=r.upperBoundLabel,a=!0),"choices"in o&&function(e){return kt(e.choices)}(r)&&(o.choices=r.choices,a=!0),{question:a?o:e,matchedKey:a?s:null,hasChanges:a}}(e,t,i)),c=l.map(e=>e.question),u=l.some(e=>e.hasChanges);let d=null;return s||(d=(null===(n=l.find(e=>e.matchedKey))||void 0===n?void 0:n.matchedKey)||null),u&&(r.questions=c,o=!0,null==i||i.info(`Applied question-level translations for language: ${t}`)),{survey:r,matchedKey:o?s||d:null}}function uc(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}function dc(e){var t;return uc(e)&&!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t?void 0:t.repeatedActivation)||"always"===e.schedule}const hc=(e,t)=>{if(!(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}},pc=e=>e.toLowerCase(),gc={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=>hc(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!hc(t,e))),icontains:(e,t)=>t.map(pc).some(t=>e.map(pc).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(pc).every(t=>e.map(pc).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function _c(e,t){return!e||Object.entries(e).every(([e,i])=>{const n=null==t?void 0:t[e];if(null==n)return!1;const s=gc[i.operator];return!!s&&s(i.values.map(String),[String(n)])})}const fc=e=>{const t=[...e];for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}return t};function vc(e,t,i){return io({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}const mc=new Set(["is_not","not_icontains","not_regex"]);function yc(e,t,i){return!e||0===e.length||e.every(e=>{const n="person"===e.type?i:t,s=null==n?void 0:n[e.key],r=e.operator||"exact";if(xt(s)||Pt(s))return mc.has(r);const o=gc[r];return!!o&&!xt(e.value)&&!Pt(e.value)&&o(kt(e.value)?e.value.map(String):[String(e.value)],kt(s)?s.map(String):[String(s)])})}const bc=Br("[SessionRecording]");function Sc(e,t){return t?e:"!"+e}function wc(e,t){return e===t||e!=="!"+t&&null}var kc=class{constructor(e,t,i,n,s,r,o){this._instance=e,this._urlTriggerMatching=t,this._eventTriggerMatching=i,this._linkedFlagMatching=n,this._reportStarted=s,this._tryTakeFullSnapshot=r,this._onTriggerActivated=o,this._sampleRate=null,this._recordingStatusFunction=Oa}onRemoteConfig(e){this._sampleRate=Ft(e.sampleRate)?e.sampleRate:null,"any"===e.triggerMatchType?(this._triggerStatusMatcher=new Ta([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=La):(this._triggerStatusMatcher=new xa([this._eventTriggerMatching,this._urlTriggerMatching]),this._recordingStatusFunction=Oa),this._instance.register_for_session({[We]:e.triggerMatchType}),this._urlTriggerMatching.onConfig(e),this._eventTriggerMatching.onConfig(e),this._linkedFlagMatching.onConfig(e,(e,t)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:t}),this._onTriggerActivated()})}getStatus(e){return this._recordingStatusFunction({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId})}getMinimumDuration(e){const t=this._instance.get_property("$session_recording_remote_config"),i=null==t?void 0:t.minimumDurationMilliseconds;return Ft(i)?i:null}checkUrlTriggers(e,t,i,n){this._urlTriggerMatching.checkUrlTriggerConditions(t,i,n,e)}setupEventTriggerListeners(e,t,i){if(0!==this._eventTriggerMatching._eventTriggers.length&&Mt(this._removeEventTriggerCaptureHook))return this._removeEventTriggerCaptureHook=e(e=>{try{this._eventTriggerMatching.checkEventTriggerConditions(e.event,i,t)}catch(e){bc.error("Could not activate event trigger",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){var t;const i=this._sampleRate;var n,s;if(!Ft(i))return null===(n=this._instance.persistence)||void 0===n||n.unregister("$session_is_sampled"),void(null===(s=this._instance.persistence)||void 0===s||s.unregister("$replay_sample_rate"));const r=this._instance.get_property(ue),o=this._instance.get_property(se),a=wc(r,e),l=Ft(o)&&o!==i,c=xt(o)&&r===e,u=l||c||!Lt(a),d=u?Xl(e,i):a;u&&(d?this._reportStarted("sampled"):bc.warn(`Sample rate (${i}) has determined that this sessionId (${e}) will not be sent to the server.`)),null===(t=this._instance.persistence)||void 0===t||t.register({$session_is_sampled:Sc(e,d),$replay_sample_rate:Pt(o)&&r===e?null:i})}ensureSamplingDecision(e){if(!Ft(this._sampleRate))return;const t=this._instance.get_property(ue);Lt(wc(t,e))||this.makeSamplingDecisions(e)}onFlushComplete(){}clearConditionalRecordingPersistence(){var e,t,i,n,s;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_recording_event_trigger_activated_session"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$session_recording_url_trigger_activated_session"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_is_sampled"),null===(n=this._instance.persistence)||void 0===n||n.unregister("$replay_sample_rate"),null===(s=this._instance.persistence)||void 0===s||s.unregister("$session_past_minimum_duration")}updateActiveTriggers(e){}hasPendingTriggers(e){var t;return(null===(t=this._triggerStatusMatcher)||void 0===t?void 0:t.triggerStatus(e))===ba}getPendingTriggerConditions(e){return[{label:"URL condition not matched",status:this._urlTriggerMatching.triggerStatusNoSideEffects(e)},{label:"event condition not matched",status:this._eventTriggerMatching.triggerStatusNoSideEffects(e)},{label:"linked flag condition not matched",status:this._linkedFlagMatching.triggerStatusNoSideEffects()}].filter(({status:e})=>e===ba).map(({label:e})=>e)}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._eventTriggerMatching.stop(),this._urlTriggerMatching.stop(),this._linkedFlagMatching.stop()}},Cc=class{constructor(e,t,i,n,s){this._instance=e,this._urlTriggerMatching=t,this._reportStarted=i,this._tryAddCustomEvent=n,this._onTriggerActivated=s,this._triggerGroupMatchers=[],this._triggerGroupSamplingResults=new Map,this._hasCompletedInitialFlush=!1}onRemoteConfig(e){e.triggerGroups&&0!==e.triggerGroups.length?(this._setupTriggerGroups(e.triggerGroups),this._instance.register_for_session({[We]:"v2_trigger_groups",[je]:e.triggerGroups.length}),this._urlTriggerMatching.onConfig(e)):bc.warn("[V2Strategy] No trigger groups configured")}getStatus(e){return function(e){if(e.rrwebError)return ma;if(!e.receivedFlags)return _a;if(!e.isRecordingEnabled)return ha;if(e.urlTriggerMatching.urlBlocked)return fa;const t=e.triggerGroupMatchers,i=e.triggerGroupSamplingResults;if(0===t.length)return ha;let n=!1,s=!1;for(const r of t){const t=r.triggerStatus(e.sessionId);if("trigger_activated"===t){const e=r.group.id,t=i.get(e);xt(t)?Nr.warn("[V2 Triggers] Group activated but no sampling decision found",{groupId:e}):!0===t&&(s=!0)}else"trigger_pending"===t&&(n=!0)}return s?pa:n?_a:ha}({receivedFlags:!0,isRecordingEnabled:!0,isSampled:e.isSampled,rrwebError:e.rrwebError,urlTriggerMatching:e.urlTriggerMatching,eventTriggerMatching:e.eventTriggerMatching,linkedFlagMatching:e.linkedFlagMatching,sessionId:e.sessionId,triggerGroupMatchers:this._triggerGroupMatchers,triggerGroupSamplingResults:this._triggerGroupSamplingResults,minimumDuration:this.getMinimumDuration(e.sessionId)})}getMinimumDuration(e){let t=null;for(const i of this._triggerGroupMatchers)if("trigger_activated"===i.triggerStatus(e)){const e=i.group.minDurationMs;Ft(e)&&(Pt(t)||t>e)&&(t=e)}return t}checkUrlTriggers(e,t,i,n){this._urlTriggerMatching.checkUrlBlocklist(t,i);for(const n of this._triggerGroupMatchers)n.checkUrlTriggerConditions(t,i,t=>{this._checkGroupLevelProperties(n,void 0)&&(n.activateTrigger(t,e),this.updateActiveTriggers(e),this._onTriggerActivated(t))},e)}setupEventTriggerListeners(e,t,i){return this._removeEventTriggerCaptureHook=e(e=>{var i;if(this._hasCompletedInitialFlush)return bc.info("[SessionRecorder] Stopping trigger checks - initial buffer flushed"),null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),void(this._removeEventTriggerCaptureHook=void 0);try{for(const i of this._triggerGroupMatchers)i.checkEventTriggerConditions(e.event,n=>{if(!this._checkGroupLevelProperties(i,e.properties))return;const s=(i.group.conditions.events||[]).filter(t=>t.name===e.event),r=this._instance.get_property(S);s.some(t=>!t.properties||0===t.properties.length||yc(t.properties,e.properties,r))&&(i.activateTrigger(n,t),this.updateActiveTriggers(t),this._onTriggerActivated(n))},t)}catch(e){bc.error("Could not activate event trigger for trigger groups",e)}}),this._removeEventTriggerCaptureHook}makeSamplingDecisions(e){for(const i of this._triggerGroupMatchers){var t;const n=i.group,s=n.id,r=n.sampleRate,o=fe+s,a=this._instance.get_property(o);let l=null,c=!1,u=!1,d=!1;if(Et(a)){const t=a.sessionId,i=a.sampleRate,n=a.sampled;c="string"==typeof t&&t!==e,u=Ft(i)&&i!==r,l=t===e&&Ft(i)&&i===r&&Lt(n)?n:null}else l=a===e||null,c="string"==typeof a&&a!==e,d=a===e;const h=c||u||d||!Lt(l),p=h?Xl(e+s,r):l;h&&this._tryAddCustomEvent("triggerGroupSamplingDecisionMade",{group_id:s,group_name:n.name,sampleRate:r,isSampled:p}),this._triggerGroupSamplingResults.set(s,p),null===(t=this._instance.persistence)||void 0===t||t.register({[o]:{sessionId:e,sampleRate:r,sampled:p}})}this.updateActiveTriggers(e)}ensureSamplingDecision(e){}onFlushComplete(){this._hasCompletedInitialFlush=!0}clearConditionalRecordingPersistence(){var e,t,i;null===(e=this._instance.persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._instance.persistence)||void 0===t||t.unregister("$replay_sample_rate"),null===(i=this._instance.persistence)||void 0===i||i.unregister("$session_past_minimum_duration");for(const e of this._triggerGroupMatchers){var n,s,r;const t=e.group.id;null===(n=this._instance.persistence)||void 0===n||n.unregister("$posthog_sr_group_event_trigger_"+t),null===(s=this._instance.persistence)||void 0===s||s.unregister("$posthog_sr_group_url_trigger_"+t),null===(r=this._instance.persistence)||void 0===r||r.unregister("$posthog_sr_group_sampling_"+t)}}updateActiveTriggers(e){const t=[];for(const i of this._triggerGroupMatchers){const n=i.group,s=n.id,r="trigger_activated"===i.triggerStatus(e),o=!0===this._triggerGroupSamplingResults.get(s);r&&t.push({id:s,name:n.name,matched:!0,sampled:o})}this._instance.register_for_session({[Ue]:t})}hasPendingTriggers(e){for(const t of this._triggerGroupMatchers)if("trigger_pending"===t.triggerStatus(e))return!0;return!1}getPendingTriggerConditions(e){return this._triggerGroupMatchers.flatMap(t=>"trigger_pending"!==t.triggerStatusNoSideEffects(e)?[]:t.getPendingTriggerConditions(e).map(e=>`trigger group "${t.group.name}": ${e}`))}stop(){var e;null===(e=this._removeEventTriggerCaptureHook)||void 0===e||e.call(this),this._removeEventTriggerCaptureHook=void 0,this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear(),this._urlTriggerMatching.stop()}_checkGroupLevelProperties(e,t){const i=e.group.conditions.properties;return!i||0===i.length||yc(i,t,this._instance.get_property(S))}_setupTriggerGroups(e){this._triggerGroupMatchers.forEach(e=>e.stop()),this._triggerGroupMatchers=[],this._triggerGroupSamplingResults.clear();for(const t of e){const e=new Aa(this._instance,t,(e,i)=>{this._reportStarted("linked_flag_matched",{flag:e,variant:i,group_id:t.id,group_name:t.name}),this._onTriggerActivated()});this._triggerGroupMatchers.push(e)}}};function Ec(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}const Tc=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],xc=(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Tc])(),Ic="<masked>",Rc=["li_fat_id"];function Pc(e,t,i){if(!n)return{};const s=t?[...Tc,...i||[]]:[],r=Mc(ro(n.URL,s,Ic),e),o=function(){const e={};return Hr(Rc,function(t){const i=wl(t);e[t]=i||null}),e}();return Ur(o,r)}function Mc(e,t){const i=xc.concat(t||[]),n={};return Hr(i,function(t){const i=so(e,t);n[t]=i||null}),n}function Fc(e){const t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!Pt(t)){s.$search_engine=t;const e=n?so(n.referrer,i):"";e.length&&(s.ph_keyword=e)}return s}function Ac(){return navigator.language||navigator.userLanguage}function Lc(){const e=Ac();return"string"==typeof e?e.split("-")[0]:void 0}const Oc="$direct";function Dc(){return(null==n?void 0:n.referrer)||Oc}function $c(e,t,i=!1){const n=e?[...Tc,...t||[]]:[],r=i?cn(null==s?void 0:s.href):null==s?void 0:s.href,o=null==r?void 0:r.substring(0,1e3);return{r:Dc().substring(0,1e3),u:o?ro(o,n,Ic):void 0}}function Nc(e,t=!1){var i;const{r:n,u:s}=e,r=t?cn(s):s,o={$referrer:n,$referring_domain:null==n?void 0:n==Oc?Oc:null===(i=Yr(n))||void 0===i?void 0:i.host};if(r){o.$current_url=r;const e=Yr(r);o.$host=null==e?void 0:e.host,o.$pathname=null==e?void 0:e.pathname;const t=Mc(r);Ur(o,t)}if(n){const e=Fc(n);Ur(o,e)}return o}function Bc(){try{return(new Date).getTimezoneOffset()}catch(e){return}}const qc=1e5,Hc=/^[A-Za-z0-9]*[A-Za-z][A-Za-z0-9]*$/,Uc=[],zc=()=>!1,Wc="@type @id actionStatus availability bestRating contentRating encodingFormat eventAttendanceMode eventStatus highPrice inLanguage isAccessibleForFree isFamilyFriendly itemCondition itemListOrder lowPrice maximumAttendeeCapacity nonprofitStatus numberOfItems offerCount position price priceCurrency priceValidUntil publicAccess ratingCount ratingValue reviewCount smokingAllowed worstRating".split(" "),jc="Action BorrowAction ReadAction SearchAction SeekToAction SolveMathAction WatchAction".split(" "),Vc="AutoDealer Bakery BarOrPub CafeOrCoffeeShop CollegeOrUniversity Corporation DaySpa Dentist EducationalOrganization Electrician FoodEstablishment GovernmentOrganization HealthClub Hotel LegalService Library LibrarySystem LocalBusiness Locksmith LodgingBusiness MedicalBusiness NGO OnlineStore Organization PerformingGroup Pharmacy Physician Plumber RealEstateAgent Restaurant School SportsOrganization Store".split(" "),Gc="Accommodation AdministrativeArea Country Place State".split(" "),Qc={AggregateOffer:{offers:["Offer"]},Brand:{name:!0},BreadcrumbList:{itemListElement:["ListItem"]},CreativeWork:{genre:!0,dateCreated:!0,dateModified:!0,datePublished:!0,expires:!0,learningResourceType:!0,educationalLevel:!0,educationalUse:!0,interactivityType:!0,aggregateRating:["AggregateRating"],potentialAction:jc,publisher:Vc},Event:{startDate:!0,endDate:!0,previousStartDate:!0,aggregateRating:["AggregateRating"],offers:["AggregateOffer","Offer"]},ItemList:{itemListElement:["ListItem"]},ListItem:{item:Uc},Offer:{seller:Vc},Organization:{name:!0,legalName:!0,foundingDate:!0,dissolutionDate:!0,aggregateRating:["AggregateRating"],brand:["Brand"]},Place:{aggregateRating:["AggregateRating"]},Product:{name:!0,sku:!0,mpn:!0,gtin:!0,gtin8:!0,gtin12:!0,gtin13:!0,gtin14:!0,productID:!0,productGroupID:!0,asin:!0,model:!0,category:!0,color:!0,material:!0,pattern:!0,size:!0,productionDate:!0,releaseDate:!0,brand:["Brand","Organization"],manufacturer:Vc,offers:["Offer","AggregateOffer"],aggregateRating:["AggregateRating"]},Service:{name:!0,serviceType:!0,category:!0,provider:Vc,areaServed:Gc,offers:["AggregateOffer","Offer"],aggregateRating:["AggregateRating"]},OfferCatalog:{name:!0,itemListElement:Uc}},Kc=[["3DModel AboutPage Answer Article AudioObject Blog BlogPosting Book Clip CollectionPage Comment ContactPage Course CreativeWorkSeason CreativeWorkSeries DataCatalog DataDownload DataFeed Dataset DiscussionForumPosting Episode FAQPage Game HowTo HowToDirection HowToSection HowToStep HowToTip ImageObject LearningResource MediaObject Message MobileApplication Movie MusicPlaylist MusicRecording NewsArticle Photograph PodcastEpisode PodcastSeries ProfilePage QAPage Question Quiz Recipe Review ScholarlyArticle SearchResultsPage SiteNavigationElement SocialMediaPosting SoftwareApplication TVEpisode TVSeries TechArticle VacationRental VideoGame VideoObject WebApplication WebPage WebPageElement WebSite".split(" "),Qc.CreativeWork],["BroadcastEvent BusinessEvent EducationEvent Festival MusicEvent SportsEvent TheaterEvent".split(" "),Qc.Event],[Vc,Qc.Organization],[Gc,Qc.Place],["Car IndividualProduct ProductGroup ProductModel".split(" "),Qc.Product]];function Jc(e,t){return St.call(e,t)?e[t]:void 0}function Yc(e){const t=typeof e;return Pt(e)||"string"===t||"number"===t||"boolean"===t}function Zc(e,t){return t&&function(e){return It(e)&&/^(https?:\/\/|\/|\.\.?\/)/i.test(e.trim())}(e)?t(e.trim())||void 0:e}function Xc(e,t){return kt(e)&&e.every(Yc)?e.map(e=>Zc(e,t)).filter(e=>!xt(e)):Yc(e)?Zc(e,t):void 0}function eu(e,t){if("string"!=typeof e)return;const i=e.trim(),n=i.indexOf("#"),s=0>n?i:i.slice(n+1);if(!(!s||0>n&&(/^[a-z][a-z\d+.-]*:/i.test(i)||i.includes("/")||i.includes("?"))))try{return t(s)?s:void 0}catch(e){return}}function tu(e){if(St.call(Qc,e))return Qc[e];for(const[t,i]of Kc)if(t.includes(e))return i}function iu(e,t,i){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0})}function nu(e,t,i,n){if(kt(e)){const s=e.map(e=>nu(e,t,i,n)).filter(e=>!xt(e));return s.length?s:void 0}return su(e,t,i,n)||void 0}function su(e,t,i,n){if(!Et(e)||!function(e){return e.remainingNodes?(e.remainingNodes--,!0):(e.exceeded=!0,!1)}(i))return null;const s=Jc(e,"@type"),r=function(e){const t=new Set,i="string"==typeof e?[e]:kt(e)?e:[],n=[];for(const e of i){if("string"!=typeof e)continue;const i=e.replace(/^https?:\/\/schema\.org\//,"");if(100>=i.length&&Hc.test(i)&&!t.has(i)&&(t.add(i),n.push(i),20===n.length))break}return n}(s),o=r.filter(e=>!!tu(e)&&(!n||!n.length||n.includes(e))),a={};for(const n of Wc){const o="@type"===n?r.length?"string"==typeof s?r[0]:r:void 0:"@id"===n?eu(Jc(e,n),t):Xc(Jc(e,n),i.maskUrl);xt(o)||iu(a,n,o)}for(const n of o){const s=tu(n);for(const n of Object.keys(s)){const r=Jc(e,n),o=s[n];if(!0===o){const e=Xc(r,i.maskUrl);xt(e)||iu(a,n,e)}else{const e=nu(r,t,i,o);xt(e)||iu(a,n,e)}}}const l=nu(Jc(e,"@graph"),t,i);return xt(l)||iu(a,"@graph",l),Object.keys(a).length?a:null}function ru(e,t,i){if(!Et(e))return null;const n=Jc(e,"@context");if("string"!=typeof n||!/^https?:\/\/schema\.org\/?$/.test(n))return null;const s=su(e,t,i);return s?ct({"@context":"https://schema.org"},s):null}function ou(e){var t;return"SCRIPT"===e.nodeName&&"application/ld+json"===(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.trim().toLowerCase())}function au(e,t,i){if("string"==typeof t?e.classList.contains(t):t&&Array.from(e.classList).some(e=>(t.lastIndex=0,t.test(e))))return!0;try{return!!i&&e.matches(i)}catch(e){return!1}}function lu(e,t,i){for(let n=e;n;){if(au(n,t,i))return!0;const e=n.parentNode;n=n.parentElement||(e&&e.nodeType===e.DOCUMENT_FRAGMENT_NODE?e.host:null)}return!1}function cu(e){return ou(e)?[e]:e.nodeType!==e.ELEMENT_NODE?[]:Array.from(e.querySelectorAll("script")).filter(ou)}function uu(e){return Et(e)?e.network_timing:e}const du=Br("[SessionRecording]"),hu=[1,2,3,4,5,6,7,12],pu=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function gu(){var e;return null==d||null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.rrweb}function _u(){var e;return null===(e=gu())||void 0===e?void 0:e.record}function fu(e){try{return JSON.stringify(e)}catch(t){if(t instanceof RangeError)throw t;return JSON.stringify(e,Da())}}function vu(e){return bl(ml(yl(fu(e))),!0)}function mu(e){return yu.apply(this,arguments)}function yu(){return(yu=rt(function*(e){const t=yield vs(fu(e),Yl.DEBUG,{rethrow:!0});return bl(new Uint8Array(yield t.arrayBuffer()),!0)})).apply(this,arguments)}let bu,Su;const wu="undefined"!=typeof globalThis&&"CompressionStream"in globalThis&&"TextEncoder"in globalThis&&"Response"in globalThis&&"function"==typeof Response.prototype.blob;let ku=!1;function Cu(e){var t;return kt(e)&&0===e.length?(bu=null!==(t=bu)&&void 0!==t?t:vu([]),bu):vu(e)}function Eu(e){return Tu.apply(this,arguments)}function Tu(){return(Tu=rt(function*(e){var t;return kt(e)&&0===e.length?bu||(Su=null!==(t=Su)&&void 0!==t?t:mu([]).then(e=>(bu=e,e)).catch(e=>{throw bu=void 0,Su=void 0,e}),Su):mu(e)})).apply(this,arguments)}function xu(e){return wu&&!ku&&function(e){return 2===e.type||3===e.type&&(0===e.data.source||8===e.data.source)}(e)}function Iu(e){return{event:e,size:Na(e)}}function Ru(e,t){return ct(ct({},e),{},{data:t,cv:"2024-10"})}function Pu(e,t){return ct(ct({},e),{},{cv:"2024-10",data:ct(ct({},e.data),t)})}function Mu(e){try{if(2===e.type)return Iu(Ru(e,vu(e.data)));if(3===e.type&&0===e.data.source)return Iu(Pu(e,{texts:Cu(e.data.texts),attributes:Cu(e.data.attributes),removes:Cu(e.data.removes),adds:Cu(e.data.adds)}));if(3===e.type&&8===e.data.source)return Iu(Pu(e,{adds:e.data.adds?vu(e.data.adds):void 0,removes:e.data.removes?vu(e.data.removes):void 0}))}catch(e){du.warn("could not compress event - will use uncompressed event",e)}return{event:e,size:$a(e)}}function Fu(){return Fu=rt(function*(e){try{if(2===e.type)return Iu(Ru(e,yield mu(e.data)));if(3===e.type&&0===e.data.source){const[t,i,n,s]=yield Promise.all([Eu(e.data.texts),Eu(e.data.attributes),Eu(e.data.removes),Eu(e.data.adds)]);return Iu(Pu(e,{texts:t,attributes:i,removes:n,adds:s}))}if(3===e.type&&8===e.data.source){const[t,i]=yield Promise.all([e.data.adds?mu(e.data.adds):void 0,e.data.removes?mu(e.data.removes):void 0]);return Iu(Pu(e,{adds:t,removes:i}))}}catch(t){return ps(t)&&(ku=!0),du.warn("could not compress event asynchronously - trying synchronous compression",t),Mu(e)}return{event:e,size:$a(e)}}),Fu.apply(this,arguments)}function Au(e,t){return 5===e.type&&e.data.tag===t}function Lu(e){return Au(e,"sessionIdle")}function Ou(e){return Au(e,"$session_ending")}function Du(e){return Au(e,"$session_starting")}var $u=class{get sessionId(){return this._sessionId}get _sessionManager(){if(!this._instance.sessionManager)throw new Error("[SessionRecording] must be started with a valid sessionManager.");return this._instance.sessionManager}get _sessionIdleThresholdMilliseconds(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get _isSampled(){return wc(this._instance.get_property(ue),this.sessionId)}get _sampleRate(){var e;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.sampleRate;return Ft(t)?t:null}get _minimumDuration(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getMinimumDuration(this.sessionId))&&void 0!==e?e:null}constructor(e,t){this._instance=e,this._endpoint="/s/",this._forceAllowLocalhostNetworkCapture=!1,this._stopRrweb=void 0,this._jsonLdCaptureReady=!1,this._lastActivityTimestamp=Date.now(),this._isActivatingTrigger=!1,this._queuedRRWebEvents=[],this._isIdle="unknown",this._eventsDroppedWhileIdle=0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,this._unstringifiableEventsDropped=0,this._holdFlushUntilInteraction=!1,this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed=!1,this._suppressNextFreshStartHold=!1,this._rrwebError=!1,this._rrwebStartAttempted=!1,this._snapshotCostErrorLogged=!1,this._hasWarnedClientMaskingOverride=!1,this._hasWarnedExclusiveAttributeMasking=!1,this._maskRegionsFnFailed=!1,this._hasLoggedRecorderCallbackError=!1,this._lastFullSnapshotSessionId=void 0,this._fullSnapshotHealAttemptedFor=void 0,this._pendingBufferRestored=!1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueueGeneration=0,this._isStoppingAfterCompression=!1,this._removePageViewCaptureHook=void 0,this._removeEventTriggerCaptureHook=void 0,this._onSessionIdListener=void 0,this._onSessionIdleResetForcedListener=void 0,this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback=(e,t,i)=>{var n,s,r,o;if(!i)return;if(e===this._sessionId&&t===this._windowId)return;const a=!i.noSessionId&&(i.activityTimeout||i.sessionPastMaximumLength),l=this._sessionId,c=this._windowId;var u;if(a&&this._tryAddCustomEvent("$session_ending",{currentSessionId:l,currentWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp,flushed_size:null===(u=this._flushedSizeTracker)||void 0===u?void 0:u.currentTrackedSize(l)}),null===(n=this._instance.persistence)||void 0===n||n.unregister("$debug_first_full_snapshot_timestamp"),null===(s=gu())||void 0===s||null===(r=s.resetMaxDepthState)||void 0===r||r.call(s),this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),this._clearConditionalRecordingPersistence(),!(!1===this._isIdle&&this.isStarted||this._sessionId===e&&this._windowId===t)){const t=this._sessionId!==e&&!1!==this._isIdle;this._isIdle="unknown",this._restartForSessionIdChange(t)}a&&this._tryAddCustomEvent("$session_starting",{previousSessionId:l,previousWindowId:c,nextSessionId:e,nextWindowId:t,changeReason:i,lastActivityTimestamp:this._lastActivityTimestamp}),null===(o=this._strategy)||void 0===o||o.makeSamplingDecisions(e)},this._isRestartingForSessionIdChange=!1,this._hasPassedMinimumDuration=()=>{var e;return(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[de])===this._sessionId},this._getBufferDuration=()=>{var e,t;if(0===this._buffer.data.length)return null;const i=null===(e=this._buffer.data[0])||void 0===e?void 0:e.timestamp,n=null===(t=this._buffer.data[this._buffer.data.length-1])||void 0===t?void 0:t.timestamp;return Ft(i)&&Ft(n)?n-i:null},this._isBelowMinimumDuration=()=>{var e,t;const i=this._minimumDuration;if(!Ft(i))return!1;if(null===(e=null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.strictMinimumDuration)||void 0===e||!e){const e=this._sessionDuration;return Ft(e)&&e>=0&&i>e}if(this._hasPassedMinimumDuration())return!1;const n=this._getBufferDuration();return!!Pt(n)||i>n||(null===(s=this._instance.persistence)||void 0===s||s.register({$session_past_minimum_duration:this._sessionId}),!1);var s},this._onBeforeUnload=()=>{"buffering"!==this.status?(this._holdFlushUntilInteraction&&this._heldEpochShipsOnUnload&&this._documentWasEverVisible&&(this._setFlushHold(void 0),this._heldBufferOverflowed&&(this._heldBufferOverflowed=!1,this._tryTakeFullSnapshot())),this._drainCompressionQueueSync(),this._flushBuffer(!0)):this._clearBuffer()},this._onPageHide=()=>{this._onBeforeUnload()},this._onOffline=()=>{this._tryAddCustomEvent("browser offline",{})},this._onOnline=()=>{this._tryAddCustomEvent("browser online",{})},this._onVisibilityChange=()=>{(null==n?void 0:n.visibilityState)&&("visible"===n.visibilityState&&(this._documentWasEverVisible=!0),this._tryAddCustomEvent("window "+n.visibilityState,{}))},this._documentWasEverVisible=null==t||t;const{sessionId:i,windowId:s,sessionStartTimestamp:r}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=i,this._windowId=s,this._sessionStartTimestamp=r,this._linkedFlagMatching=new Ma(this._instance),this._urlTriggerMatching=new Pa(this._instance),this._eventTriggerMatching=new Fa(this._instance),this._buffer=this._clearBuffer(),this._pendingBufferStorageKey="ph_replay_pending_buffer_"+JSON.stringify([this._instance.config.persistence_name||this._instance.config.token,this._instance.config.token]),this._sessionManager.sessionTimeoutMs>this._sessionIdleThresholdMilliseconds||du.warn(`session_idle_threshold_ms (${this._sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this._sessionManager.sessionTimeoutMs}). Session will never be detected as idle`),this._flushedSizeTracker=new Zl(this._instance)}setDocumentWasEverVisible(e){e&&(this._documentWasEverVisible=!0)}get _masking(){var e,t,i,n,s,r,o,a,l;const c=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking,u={maskAllInputs:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.maskAllInputs,maskTextSelector:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.maskTextSelector,blockSelector:null===(n=this._instance.config.session_recording)||void 0===n?void 0:n.blockSelector,maskAllElementAttributes:null===(s=this._instance.config.session_recording)||void 0===s?void 0:s.maskAllElementAttributes},d=null!==(r=null==u?void 0:u.maskAllInputs)&&void 0!==r?r:null==c?void 0:c.maskAllInputs,h=null!==(o=null==u?void 0:u.maskTextSelector)&&void 0!==o?o:null==c?void 0:c.maskTextSelector,p=null!==(a=null==u?void 0:u.blockSelector)&&void 0!==a?a:null==c?void 0:c.blockSelector,g=null!==(l=null==u?void 0:u.maskAllElementAttributes)&&void 0!==l?l:null==c?void 0:c.maskAllElementAttributes;return xt(d)&&xt(h)&&xt(p)&&xt(g)?void 0:{maskAllInputs:null==d||d,maskTextSelector:h,blockSelector:p,maskAllElementAttributes:g}}_warnIfClientMaskingShadowsServer(){var e;if(this._hasWarnedClientMaskingOverride)return;const t=null===(e=this._remoteConfig)||void 0===e?void 0:e.masking;if(Mt(t))return;const i=this._instance.config.session_recording,n=["maskAllInputs","maskTextSelector","blockSelector","maskAllElementAttributes"].filter(e=>{const n=null==i?void 0:i[e],s=t[e];return!xt(n)&&n!==s});0!==n.length&&(this._hasWarnedClientMaskingOverride=!0,du.warn('Session recording masking is configured both in `posthog.init` and in your project settings, and they differ. The `session_recording` options in `posthog.init` take precedence, so the project ("Privacy and masking") setting is ignored for: '+n.join(", ")+". Remove these masking options from `posthog.init` to use the project setting instead. See https://posthog.com/docs/session-replay/privacy",{client:{maskAllInputs:null==i?void 0:i.maskAllInputs,maskTextSelector:null==i?void 0:i.maskTextSelector,blockSelector:null==i?void 0:i.blockSelector,maskAllElementAttributes:null==i?void 0:i.maskAllElementAttributes},project:t}))}get _canvasResolutionScale(){var e;return Kt(null===(e=this._instance.config.session_recording.canvasCapture)||void 0===e?void 0:e.resolutionScale,.1,1,Br("canvas recording resolution scale"),1)}get _canvasRecording(){var e,t,i,n,s,r,o;const a=this._instance.config.session_recording.captureCanvas,l=null===(e=this._remoteConfig)||void 0===e?void 0:e.canvasRecording,c=null!==(t=null!==(i=null==a?void 0:a.recordCanvas)&&void 0!==i?i:null==l?void 0:l.enabled)&&void 0!==t&&t,u=null!==(n=null!==(s=null==a?void 0:a.canvasFps)&&void 0!==s?s:null==l?void 0:l.fps)&&void 0!==n?n:4;let d=null!==(r=null!==(o=null==a?void 0:a.canvasQuality)&&void 0!==o?o:null==l?void 0:l.quality)&&void 0!==r?r:.4;if("string"==typeof d){const e=parseFloat(d);d=isNaN(e)?.4:e}return{enabled:c,fps:Kt(u,0,12,Br("canvas recording fps"),4),quality:Kt(d,0,1,Br("canvas recording quality"),.4)}}get _isConsoleLogCaptureEnabled(){var e;const t=!!(null===(e=this._remoteConfig)||void 0===e?void 0:e.consoleLogRecordingEnabled),i=this._instance.config.enable_recording_console_log;return null!=i?i:t}get _networkPayloadCapture(){var e,t,i;const n=null===(e=this._remoteConfig)||void 0===e?void 0:e.networkPayloadCapture,s={recordHeaders:null===(t=this._instance.config.session_recording)||void 0===t?void 0:t.recordHeaders,recordBody:null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.recordBody},r=!1!==s.recordHeaders&&(s.recordHeaders||(null==n?void 0:n.recordHeaders)),o=!1!==s.recordBody&&(s.recordBody||(null==n?void 0:n.recordBody)),a=uu(this._instance.config.capture_performance),l=uu(null==n?void 0:n.capturePerformance),c=!!(Lt(a)?a:l);return r||o||c?{recordHeaders:r,recordBody:o,recordPerformance:c}:void 0}_gatherRRWebPlugins(){var e,t;const i=[],n=null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.rrwebPlugins)||void 0===e?void 0:e.getRecordConsolePlugin;n&&this._isConsoleLogCaptureEnabled&&i.push(n());const r=null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.rrwebPlugins)||void 0===t?void 0:t.getRecordNetworkPlugin;if(this._networkPayloadCapture&&Ct(r))if(!to.includes(s.hostname)||this._forceAllowLocalhostNetworkCapture){const e=Ct(this._instance.requestRouter.isIngestionEndpoint)?this._instance.requestRouter.isIngestionEndpoint.bind(this._instance.requestRouter):void 0;i.push(r(ct(ct({},((e,t,i)=>{const n={payloadSizeLimitBytes:na.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...na.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...na.payloadHostDenyList]},s=!1!==e.session_recording.recordHeaders&&t.recordHeaders,r=!1!==e.session_recording.recordBody&&t.recordBody,o=!1!==e.capture_performance&&t.recordPerformance,a=(e=>{const t=ia(e);return e=>((null==e?void 0:e.requestBody)&&(e.requestBody=ca(e.requestBody,e.requestHeaders,t,"Request")),(null==e?void 0:e.responseBody)&&(e.responseBody=ca(e.responseBody,e.responseHeaders,t,"Response")),e)})(n),l=t=>{return a(((e,t,i)=>{var n;if(null==i?void 0:i(e.name))return;const s=Yr(e.name);let r=0===t.indexOf("http")?null===(n=Yr(t))||void 0===n?void 0:n.pathname:t;"/"===r&&(r="");const o=null==s?void 0:s.pathname.replace(r||"","");return s&&o&&la.some(e=>0===o.indexOf(e))?void 0:e})((aa((n=t).requestHeaders),aa(n.responseHeaders),n),e.api_host,i));var n},c=Ct(e.session_recording.maskNetworkRequestFn);return c&&Ct(e.session_recording.maskCapturedNetworkRequestFn)?Nr.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."):c&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{const i=e.session_recording.maskNetworkRequestFn({url:t.name});if(i||!t.isInitial)return ct(ct({},t),{},{name:null==i?void 0:i.url})}),n.maskRequestFn=Ct(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,n;const s=l(t);if(!s)return;const r=s.isInitial?{name:"",entryType:s.entryType,startTime:s.startTime,duration:s.duration,endTime:s.endTime,timeOrigin:s.timeOrigin,timestamp:s.timestamp,isInitial:!0}:void 0,o=null===(i=(n=e.session_recording).maskCapturedNetworkRequestFn)||void 0===i?void 0:i.call(n,s);return Mt(o)&&r?(da.add(r),r):null!=o?o:void 0}:e=>function(e){if(!xt(e))return e.requestBody=ua(e.requestBody,"Request"),e.responseBody=ua(e.responseBody,"Response"),e}(l(e)),ct(ct(ct({},na),n),{},{recordHeaders:s,recordBody:r,recordPerformance:o,recordInitialRequests:o,streamNetworkBody:!0===e.session_recording.streamNetworkBody})})(this._instance.config,this._networkPayloadCapture,e)),{},{captureFetchSynchronously:!0===this._instance.config.__preview_replay_sync_fetch})))}else du.info("NetworkCapture not started because we are on localhost.");return i}_stripUrlHash(e){return this._instance.config.disable_capture_url_hashes?cn(e):e}_maskReplayUrl(e,t=!1){const i=t?cn(e):this._stripUrlHash(e),n=this._instance.config.mask_personal_data_properties?[...Tc,...this._instance.config.custom_personal_data_properties||[]]:[];return this._maskUrl(ro(i,n,Ic))}_maskUrl(e){const t=this._instance.config.session_recording;if(t.maskCapturedNetworkRequestFn){var i;const n=t.maskCapturedNetworkRequestFn({name:e});return null!==(i=null==n?void 0:n.name)&&void 0!==i?i:null==n?void 0:n.url}if(t.maskNetworkRequestFn){const i=t.maskNetworkRequestFn({url:e});return null==i?void 0:i.url}return e}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return 10>this._queuedRRWebEvents.length?this._queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt+1,rrwebMethod:e.rrwebMethod}):du.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(pu(()=>_u().addCustomEvent(e,t)))}_canCaptureJsonLd(){var e;return this._jsonLdCaptureReady&&!0===(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)&&!this._urlTriggerMatching.urlBlocked&&!0!==this._isIdle}_tryAddJsonLdEvent(e){if(!this._canCaptureJsonLd())return!1;try{const t=_u();return!!t&&(t.addCustomEvent("$json_ld",e),this._canCaptureJsonLd())}catch(e){return!1}}_scheduleJsonLdScan(e=!1){Promise.resolve().then(()=>{var t;return null===(t=this._jsonLdCapture)||void 0===t?void 0:t.scan(e)})}_pageViewFallBack(){try{if(this._instance.config.capture_pageview||!e)return;const t=new URL(e.location.href),i=this._maskReplayUrl(t.origin+t.pathname+t.search);this._lastHref!==i&&(this._lastHref=i,this._tryAddCustomEvent("$url_changed",{href:i}))}catch(e){}}_processQueuedEvents(){if(this._queuedRRWebEvents.length){const e=[...this._queuedRRWebEvents];this._queuedRRWebEvents=[],e.forEach(e=>{Date.now()-e.enqueuedAt>2e3||this._tryRRWebMethod(e)})}}_tryTakeFullSnapshot(){return this._tryRRWebMethod(pu(()=>_u().takeFullSnapshot()))}get _fullSnapshotIntervalMillis(){var e,t,i;if((null===(e=this._strategy)||void 0===e?void 0:e.hasPendingTriggers(this.sessionId))&&!["sampled","active"].includes(this.status)){var n;const e=null===(n=this._instance.config.session_recording)||void 0===n?void 0:n.trigger_pending_buffer_interval_millis;return Ft(e)&&Number.isFinite(e)&&e>=1e3&&36e5>=e?e:6e4}return null!==(t=null===(i=this._instance.config.session_recording)||void 0===i?void 0:i.full_snapshot_interval_millis)&&void 0!==t?t:3e5}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0===this._isIdle)return;const e=this._fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},e))}_onTriggerActivated(e){"event"===e&&this._releaseHoldAndFlush(),!this._urlTriggerMatching.urlBlocked&&["sampled","active"].includes(this.status)&&this._scheduleFullSnapshot()}_pauseRecording(){var e;this._urlTriggerMatching.urlBlocked||(this._urlTriggerMatching.urlBlocked=!0,null===(e=this._jsonLdCapture)||void 0===e||e.scan(),clearInterval(this._fullSnapshotTimer),du.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){var e;this._urlTriggerMatching.urlBlocked&&(null===(e=this._jsonLdCapture)||void 0===e||e.scan(),this._urlTriggerMatching.urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),du.info("recording resumed"))}_activateTrigger(e,t){var i;if("event"===e&&this._releaseHoldAndFlush(),!this._isActivatingTrigger&&(null===(i=this._strategy)||void 0===i?void 0:i.hasPendingTriggers(this.sessionId))){this._isActivatingTrigger=!0;try{var n,s;const i="url"===e?he:pe;null===(n=this._instance.persistence)||void 0===n||n.register({[i]:this.sessionId}),null===(s=this._strategy)||void 0===s||s.updateActiveTriggers(this.sessionId),this._onTriggerActivated(),this._flushBuffer(),this._reportStarted(e+"_trigger_matched",{["url"===e?"matchedUrl":"matchedEvent"]:t})}finally{this._isActivatingTrigger=!1}}}get isStarted(){return!!this._stopRrweb}get _remoteConfig(){const e=this._instance.get_property(ie);if(!e)return;let t;try{t=Et(e)?e:JSON.parse(e)}catch(e){return void du.warn("persisted remote config for session recording is invalid and will be ignored",e)}if(!this.isStarted&&!this._isRestartingForSessionIdChange){var i;const n=null!==(i=t.cache_timestamp)&&void 0!==i?i:Date.now();if(Date.now()-n>36e5)return void du.info("persisted remote config for session recording is stale and will be ignored",{cacheTimestamp:n,persistedConfig:e})}return t}_checkOverride(e,t,i){this._instance.get_property(e)&&(t(),i())}start(t){var i,s;const r=this._remoteConfig;if(!r)return void du.info("remote config must be stored in persistence before recording can start");if(!this.isStarted){const e=!1!==this._isIdle&&!this._suppressNextFreshStartHold;this._setFlushHold(e?"no_interaction_since_recording_started":void 0),this._suppressNextFreshStartHold=!1,this._heldEpochShipsOnUnload=e,this._heldBufferOverflowed=!1}this._isStoppingAfterCompression&&(this._invalidateCompressionQueue(),this._clearBuffer());const{sessionId:o,windowId:a,sessionStartTimestamp:l}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=o,this._windowId=a,this._sessionStartTimestamp=l,this._restorePendingBuffer(),null===(i=this._instance.persistence)||void 0===i||i.unregister("$debug_first_full_snapshot_timestamp"),(null==r?void 0:r.endpoint)&&(this._endpoint=null==r?void 0:r.endpoint),this._strategy=2===(null==r?void 0:r.version)&&(null==r?void 0:r.triggerGroups)&&r.triggerGroups.length>0?new Cc(this._instance,this._urlTriggerMatching,this._reportStarted.bind(this),this._tryAddCustomEvent.bind(this),this._onTriggerActivated.bind(this)):new kc(this._instance,this._urlTriggerMatching,this._eventTriggerMatching,this._linkedFlagMatching,this._reportStarted.bind(this),this._tryTakeFullSnapshot.bind(this),this._onTriggerActivated.bind(this)),this._strategy.onRemoteConfig(r),null===(s=this._removeEventTriggerCaptureHook)||void 0===s||s.call(this),this._removeEventTriggerCaptureHook=this._strategy.setupEventTriggerListeners(this._instance.on.bind(this._instance,"eventCaptured"),this.sessionId,(e,t)=>this._activateTrigger(e,t)),this._checkOverride(re,()=>{this.overrideSampling()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(re)}),this._checkOverride(oe,()=>{this.overrideLinkedFlag()},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(oe)}),this._checkOverride(le,()=>{this.overrideTrigger("event")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(le)}),this._checkOverride(ae,()=>{this.overrideTrigger("url")},()=>{var e;return null===(e=this._instance.persistence)||void 0===e?void 0:e.unregister(ae)}),this._strategy.makeSamplingDecisions(this.sessionId),this._startRecorder(),this._rrwebError||(Kr(e,"beforeunload",this._onBeforeUnload),Kr(e,"pagehide",this._onPageHide),Kr(e,"offline",this._onOffline),Kr(e,"online",this._onOnline),Kr(n,"visibilitychange",this._onVisibilityChange),!this._onSessionIdListener&&Ct(this._sessionManager.onSessionId)&&(this._onSessionIdListener=this._sessionManager.onSessionId(this._onSessionIdCallback)),!this._onSessionIdleResetForcedListener&&Ct(this._sessionManager.on)?this._onSessionIdleResetForcedListener=this._sessionManager.on("forcedIdleReset",()=>{this._clearConditionalRecordingPersistence(),this._isIdle="unknown",this.stop(),this._forceIdleSessionIdListener=this._sessionManager.onSessionId((e,t,i)=>{var n;null===(n=this._forceIdleSessionIdListener)||void 0===n||n.call(this),this._forceIdleSessionIdListener=void 0,this._onSessionIdCallback(e,t,i)})}):Ct(this._sessionManager.on)||du.warn("bundled core has no SessionIdManager.on (requires posthog-js >= 1.268.6); recording will start but skip forced-idle-reset handling"),Mt(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this._instance.on("eventCaptured",e=>{try{if("$pageview"===e.event){const t=(null==e?void 0:e.properties.$current_url)?this._maskReplayUrl(e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){du.error("Could not add $pageview to rrweb session",e)}})),"active"===this.status&&this._reportStarted(t||"recording_initialized"))}_teardown(){var t,i,s,r,o,a;null==e||e.removeEventListener("beforeunload",this._onBeforeUnload),null==e||e.removeEventListener("pagehide",this._onPageHide),null==e||e.removeEventListener("offline",this._onOffline),null==e||e.removeEventListener("online",this._onOnline),null==n||n.removeEventListener("visibilitychange",this._onVisibilityChange),clearInterval(this._fullSnapshotTimer),this._clearFlushBufferTimer(),null===(t=this._removePageViewCaptureHook)||void 0===t||t.call(this),this._removePageViewCaptureHook=void 0,null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),this._removeEventTriggerCaptureHook=void 0,null===(s=this._onSessionIdListener)||void 0===s||s.call(this),this._onSessionIdListener=void 0,null===(r=this._onSessionIdleResetForcedListener)||void 0===r||r.call(this),this._onSessionIdleResetForcedListener=void 0,null===(o=this._forceIdleSessionIdListener)||void 0===o||o.call(this),this._forceIdleSessionIdListener=void 0,null===(a=this._strategy)||void 0===a||a.stop(),this._stopRecordingProducers(),this._invalidateCompressionQueue()}_invalidateCompressionQueue(){this._compressionQueueGeneration+=1,this._pendingCompressionEvents=[],this._queuedCompressionEvents=0,this._compressionQueue=void 0,this._isStoppingAfterCompression=!1}_stopRecordingProducers(){var e,t;null===(e=this._mutationThrottler)||void 0===e||e.stop(),this._queuedRRWebEvents=[],null===(t=this._jsonLdCapture)||void 0===t||t.stop(),this._jsonLdCapture=void 0,this._jsonLdCaptureReady=!1;try{var i;null===(i=this._stopRrweb)||void 0===i||i.call(this)}catch(e){du.warn("could not stop rrweb",e)}this._stopRrweb=void 0}_stopAfterCompressionQueueDrains(){if(!this._compressionQueue||0===this._queuedCompressionEvents)return!1;if(this._isStoppingAfterCompression)return!0;this._isStoppingAfterCompression=!0,this._flushHoldReason=void 0;const e=this._compressionQueueGeneration;return this._clearFlushBufferTimer(),this._stopRecordingProducers(),this._compressionQueue.catch(()=>{}).then(()=>{e===this._compressionQueueGeneration&&(this._isStoppingAfterCompression=!1,this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),du.info("stopped"))}).catch(()=>{this._isStoppingAfterCompression=!1,this._releaseHoldAfterStop(),this._teardown(),du.info("stopped")}),!0}stop(){if(this._stopRecordingProducers(),this._isRestartingForSessionIdChange)this._drainCompressionQueueSync();else if(this._stopAfterCompressionQueueDrains())return;this._flushBuffer(),this._clearBuffer(),this._releaseHoldAfterStop(),this._teardown(),du.info("stopped")}_releaseHoldAfterStop(){this._setFlushHold(void 0,{preserveLogDedup:this._isRestartingForSessionIdChange}),this._heldEpochShipsOnUnload=!1}flushBeforeIdentityReset(){(this.isStarted||this._isStoppingAfterCompression)&&(this._drainCompressionQueueSync(),this._flushBuffer())}_restartForSessionIdChange(e){this._isRestartingForSessionIdChange=!0,this._lastActivityTimestamp=Date.now();try{var t,i;this.stop(),this._lastSeenSnapshotCost=void 0,this._unstringifiableEventsDropped=0,this._throttledMutationsDropped=0,this._oversizedMutationsDropped=0,this._oversizedMutationBytesDropped=0,null===(t=gu())||void 0===t||null===(i=t.resetSnapshotCostState)||void 0===i||i.call(t),this.start("session_id_changed")}finally{this._isRestartingForSessionIdChange=!1}this._setFlushHold(e?"no_interaction_since_session_rotated":void 0),this._heldEpochShipsOnUnload=!1}_setFlushHold(e,{preserveLogDedup:t=!1}={}){if(this._holdFlushUntilInteraction=!xt(e),this._flushHoldReason=e,xt(e))return void(t||(this._lastLoggedFlushHold=void 0));if(this._isRestartingForSessionIdChange)return;const i=`${this.sessionId}:${e}`;i!==this._lastLoggedFlushHold&&(this._lastLoggedFlushHold=i,du.info(`holding buffer: ${e}. nothing is uploaded until the user interacts with the page`))}_releaseHoldAndFlush(){this.isStarted||(this._suppressNextFreshStartHold=!0),this._holdFlushUntilInteraction&&(this._setFlushHold(void 0),this._heldEpochShipsOnUnload=!1,this._heldBufferOverflowed&&(this._heldBufferOverflowed=!1,this._tryTakeFullSnapshot()),this._scheduleFlushBuffer())}discard({discardProducerEvents:e=!1}={}){this._holdFlushUntilInteraction=!0,e&&(this._clearBuffer(),this._stopRecordingProducers()),this._clearBuffer(),this._teardown(),this._clearBuffer(),this._releaseHoldAfterStop(),du.info("discarded")}_captureProcessedEvent(e,t,i,n,s){if(-1===i)return this._unstringifiableEventsDropped+=1,void du.warn("could not stringify event - dropping it to keep the rest of the recording");const r={$snapshot_bytes:i,$snapshot_data:t,$session_id:n,$window_id:s};"disabled"!==this.status?(this._ensureFullSnapshotForSession(e,n),this._captureSnapshotBuffered(r)):this._clearBuffer()}_safeTrackFullSnapshotCost(){try{this._trackFullSnapshotCost()}catch(e){this._snapshotCostErrorLogged||(this._snapshotCostErrorLogged=!0,du.error("could not track full snapshot cost",e))}}_trackFullSnapshotCost(){var e,t;const i=null===(e=gu())||void 0===e||null===(t=e.getLastSnapshotCost)||void 0===t?void 0:t.call(e);i&&i!==this._lastSeenSnapshotCost&&(this._lastSeenSnapshotCost=i,500>i.durationMs||du.warn("full snapshot was slow, the page may have been unresponsive while it ran",{durationMs:Math.round(i.durationMs),stylesheetMs:Math.round(i.stylesheetMs),nodeCount:i.nodeCount,cssRuleCount:i.cssRuleCount,nonDeferrableCssRuleCount:i.nonDeferrableCssRuleCount,deferredStylesheetCount:i.deferredStylesheetCount}))}_ensureFullSnapshotForSession(e,t){2!==e.type?3===e.type&&(xt(this._lastFullSnapshotSessionId)||this._lastFullSnapshotSessionId===t||this._fullSnapshotHealAttemptedFor===t||(this._fullSnapshotHealAttemptedFor=t,du.info("incremental snapshot for a session with no full snapshot - requesting one",{sessionId:t}),this._tryTakeFullSnapshot())):this._lastFullSnapshotSessionId=t}_finishQueuedCompressionEvent(e){e.counted&&e.generation===this._compressionQueueGeneration&&(this._queuedCompressionEvents=Math.max(0,this._queuedCompressionEvents-1)),e.counted=!1,this._pendingCompressionEvents=this._pendingCompressionEvents.filter(t=>t!==e)}_captureQueuedCompressionEvent(e,t,i){e.processed||e.generation!==this._compressionQueueGeneration||(e.processed=!0,this._captureProcessedEvent(e.event,t,i,e.targetSessionId,e.targetWindowId))}_processQueuedCompressionEventSync(e){try{let t,i=e.event;if(e.compressionEnabled)try{({event:i,size:t}=Mu(e.event))}catch(e){du.warn("could not process queued compression event - will use uncompressed event",e)}xt(t)&&(t=$a(e.event));try{this._captureQueuedCompressionEvent(e,i,t)}catch(e){du.warn("could not capture queued compression event",e)}}finally{this._finishQueuedCompressionEvent(e)}}_drainCompressionQueueSync(){[...this._pendingCompressionEvents].forEach(e=>{try{this._processQueuedCompressionEventSync(e)}catch(e){du.warn("could not drain queued compression event",e)}})}_enqueueCompression(e,t,i,n){var s=this;const r={event:e,compressionEnabled:t,targetSessionId:i,targetWindowId:n,generation:this._compressionQueueGeneration,processed:!1,counted:!0};this._pendingCompressionEvents.push(r),this._queuedCompressionEvents+=1;const o=(a=rt(function*(){try{if(r.processed)return;let i,n;try{const s=t?xu(e)?yield function(e){return Fu.apply(this,arguments)}(e):Mu(e):{event:e,size:$a(e)};i=s.event,n=s.size}catch(t){du.warn("could not process queued compression event - will use uncompressed event",t),i=e,n=$a(e)}s._captureQueuedCompressionEvent(r,i,n)}finally{s._finishQueuedCompressionEvent(r)}}),function(){return a.apply(this,arguments)});var a;this._compressionQueue=this._compressionQueue?this._compressionQueue.catch(()=>{}).then(o):o()}onRRwebEmit(t){var i,n,s,r,o,a,l,c,u,d,h;if(!this._instance.sessionManager)return;if(this._processQueuedEvents(),!t||!Et(t))return;if(4===t.type){const e=this._maskReplayUrl(t.data.href);if(this._lastHref=e,!e)return;t.data.href=e}else this._pageViewFallBack();if(null===(i=this._strategy)||void 0===i||i.checkUrlTriggers(this.sessionId,()=>this._pauseRecording(),()=>this._resumeRecording(),(e,t)=>this._activateTrigger(e,t)),this._urlTriggerMatching.urlBlocked&&!function(e){return 5===e.type&&"recording paused"===e.data.tag}(t))return;2===t.type&&(this._safeTrackFullSnapshotCost(),Promise.resolve().then(()=>this._safeTrackFullSnapshotCost()),this._scheduleFullSnapshot(),null===(d=this._mutationThrottler)||void 0===d||d.reset(),null===(h=this._instance.persistence)||void 0===h||h.register_once({$debug_first_full_snapshot_timestamp:t.timestamp},void 0));const p=2===t.type&&(null===(n=this._strategy)||void 0===n?void 0:n.hasPendingTriggers(this.sessionId));p&&this._clearBufferBeforeMostRecentMeta();const g=this._mutationThrottler?this._mutationThrottler.throttleMutations(t):t;if(!g)return void(!0===this._isIdle&&this._eventsDroppedWhileIdle++);const _=function(e){const t=e;if(t&&Et(t)&&6===t.type&&Et(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));const i=[];for(let e=0;t.data.payload.payload.length>e;e++)i.push(t.data.payload.payload[e]&&t.data.payload.payload[e].length>2e3?t.data.payload.payload[e].slice(0,2e3)+"...[truncated]":t.data.payload.payload[e]);return t.data.payload.payload=i,e}return e}(g),f=function(e){return Ou(e)?e.data.payload:null}(_),v=function(e){return Du(e)?e.data.payload:null}(_),m=function(e){return Lu(e)?e.data.payload:null}(_);f||v?(null==f?void 0:f.lastActivityTimestamp)&&(_.timestamp=f.lastActivityTimestamp):(null==m?void 0:m.sessionId)||this._updateWindowAndSessionIds(_);const y=null!==(s=null!==(r=null!==(o=null==f?void 0:f.currentSessionId)&&void 0!==o?o:null==v?void 0:v.nextSessionId)&&void 0!==r?r:null==m?void 0:m.sessionId)&&void 0!==s?s:this._sessionId,b=null!==(a=null!==(l=null!==(c=null==f?void 0:f.currentWindowId)&&void 0!==c?c:null==v?void 0:v.nextWindowId)&&void 0!==l?l:null==m?void 0:m.windowId)&&void 0!==a?a:this._windowId;if(!0===this._isIdle&&!function(e){return Lu(e)||Ou(e)||Du(e)}(_))return void(function(e){return 2===e.type||4===e.type||3===e.type&&9!==e.data.source}(_)&&this._eventsDroppedWhileIdle++);2===_.type&&(this._eventsDroppedWhileIdle=0),m&&(_.timestamp=m.lastActivityTimestamp+m.threshold);const S=this._jsonLdCaptureReady;this._jsonLdCaptureReady=!0,p?this._scheduleJsonLdScan(!0):S||this._scheduleJsonLdScan();const w=null===(u=this._instance.config.session_recording.compress_events)||void 0===u||u;if(5===_.type&&"$json_ld"===_.data.tag){let t;try{t=e?this._maskReplayUrl(e.location.href):void 0}catch(e){}_.data.href=t}if(this._queuedCompressionEvents>0||w&&xu(_))return void this._enqueueCompression(_,w,y,b);const{event:k,size:C}=w?Mu(_):{event:_,size:$a(_)};this._captureProcessedEvent(_,k,C,y,b)}get status(){return this._strategy?this._strategy.getStatus({instance:this._instance,sessionId:this.sessionId,isSampled:this._isSampled,rrwebError:this._rrwebError,urlTriggerMatching:this._urlTriggerMatching,eventTriggerMatching:this._eventTriggerMatching,linkedFlagMatching:this._linkedFlagMatching,remoteConfig:this._remoteConfig}):ha}log(e,t="log"){var i;null===(i=this._instance.sessionRecording)||void 0===i||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}overrideLinkedFlag(){this._linkedFlagMatching.linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this._instance.persistence)||void 0===e||e.register({$session_is_sampled:this.sessionId,$replay_sample_rate:null}),this._tryTakeFullSnapshot(),this._releaseHoldAndFlush(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e),this._releaseHoldAndFlush()}_currentMaskedHostname(){try{var t;const i=null==e||null===(t=e.location)||void 0===t?void 0:t.href;if(!i)return;const n=this._maskReplayUrl(i);if(!n)return;return new URL(n).hostname||void 0}catch(e){return}}_clearFlushBufferTimer(){this._flushBufferTimer&&(clearTimeout(this._flushBufferTimer),this._flushBufferTimer=void 0)}_scheduleFlushBuffer(){this._flushBufferTimer||(this._flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_wouldOpenRecordingWithMarkersOnly(){return this._lastFullSnapshotSessionId!==this._buffer.sessionId&&0!==this._buffer.data.length&&this._buffer.data.every(e=>5===(null==e?void 0:e.type)&&!Ou(e)&&!Du(e))}_describePendingTriggerConditions(){var e,t;return null!==(e=null===(t=this._strategy)||void 0===t?void 0:t.getPendingTriggerConditions(this.sessionId))&&void 0!==e?e:[]}_maybeLogBufferingReason(e){if("buffering"!==e)return xt(this._lastLoggedBufferingReason)||this._instance.register_for_session({[ze]:[]}),void(this._lastLoggedBufferingReason=void 0);const t=this._describePendingTriggerConditions();if(0===t.length)return xt(this._lastLoggedBufferingReason)||this._instance.register_for_session({[ze]:[]}),void(this._lastLoggedBufferingReason=void 0);const i=t.join(", "),n=`${this.sessionId}:${i}`;n!==this._lastLoggedBufferingReason&&(this._lastLoggedBufferingReason=n,this._instance.register_for_session({[ze]:t}),du.info(`buffering: ${i}`))}_canParkPendingBuffer(){var e;return"memory"!==this._instance.config.persistence&&!0!==(null===(e=this._instance.persistence)||void 0===e?void 0:e._disabled)&&Jl._is_supported()}_parkBufferForNextPage(){0!==this._buffer.data.length&&this._buffer.size!==this._lastParkedBufferSize&&943718.4>=this._buffer.size&&this._canParkPendingBuffer()&&(this._lastParkedBufferSize=this._buffer.size,Jl._set(this._pendingBufferStorageKey,this._buffer))}_restorePendingBuffer(){if(this._pendingBufferRestored||!this._canParkPendingBuffer())return;this._pendingBufferRestored=!0;const e=Jl._parse(this._pendingBufferStorageKey);Jl._remove(this._pendingBufferStorageKey),Et(e)&&kt(e.data)&&0!==e.data.length&&kt(e.sizes)&&e.sizes.length===e.data.length&&Ft(e.size)&&e.sessionId===this._sessionId&&e.windowId===this._windowId&&(this._buffer.data.length>0||(this._buffer=e))}_flushBuffer(e=!1){var t;if(this._clearFlushBufferTimer(),this._holdFlushUntilInteraction)return this._buffer;if(this._wouldOpenRecordingWithMarkersOnly())return this._buffer.size>943718.4?this._clearBuffer():(e&&this._parkBufferForNextPage(),this._buffer);const i=this._buffer;null===(t=this._strategy)||void 0===t||t.ensureSamplingDecision(this.sessionId);const n=this._isBelowMinimumDuration(),s=this.status;if(this._maybeLogBufferingReason(s),"buffering"===s||"paused"===s||"disabled"===s||n)return!e||"active"!==s&&"sampled"!==s||this._parkBufferForNextPage(),this._scheduleFlushBuffer(),this._buffer;if(this._buffer!==i)return this._buffer;if(i.data.length>0){var r;const e=this._currentMaskedHostname();Ba(i).forEach(t=>{try{var i;null===(i=this._flushedSizeTracker)||void 0===i||i.trackSize(t.sessionId,t.size),this._captureSnapshot(ct(ct(ct(ct({$snapshot_bytes:t.size,$snapshot_data:t.data,$session_id:t.sessionId,$window_id:t.windowId,$lib:Yl.LIB_NAME,$lib_version:Yl.LIB_VERSION,$snapshot_host:e},this._throttledMutationsDropped>0?{$sdk_debug_replay_throttled_mutations_dropped:this._throttledMutationsDropped}:{}),this._oversizedMutationsDropped>0?{$sdk_debug_replay_oversized_mutations_dropped:this._oversizedMutationsDropped}:{}),this._oversizedMutationBytesDropped>0?{$sdk_debug_replay_oversized_mutation_bytes_dropped:this._oversizedMutationBytesDropped}:{}),this._unstringifiableEventsDropped>0?{$sdk_debug_replay_unstringifiable_events_dropped:this._unstringifiableEventsDropped}:{}))}catch(e){du.warn("could not capture snapshot chunk - skipping it",e)}}),xt(this._lastParkedBufferSize)||(Jl._remove(this._pendingBufferStorageKey),this._lastParkedBufferSize=void 0),null===(r=this._strategy)||void 0===r||r.onFlushComplete()}return this._clearBuffer()}_captureSnapshotBuffered(e){var t;const i=2+((null===(t=this._buffer)||void 0===t?void 0:t.data.length)||0),n=e.$session_id,s=this._buffer.sessionId!==n;if(s||!0!==this._isIdle&&!this._holdFlushUntilInteraction&&this._buffer.size+e.$snapshot_bytes+i>943718.4){const t=this._sessionId;if(this._buffer=this._flushBuffer(),this._sessionId!==t)return;s&&this._buffer.data.length>0&&(this._buffer=this._clearBuffer()),this._buffer.sessionId=n,this._buffer.windowId=e.$window_id}this._holdFlushUntilInteraction&&(this._heldBufferOverflowed||this._buffer.size+e.$snapshot_bytes+i>943718.4)?this._heldBufferOverflowed=!0:(this._buffer.size+=e.$snapshot_bytes,this._buffer.data.push(e.$snapshot_data),this._buffer.sizes.push(e.$snapshot_bytes),!0===this._isIdle||this._holdFlushUntilInteraction||this._scheduleFlushBuffer())}_captureSnapshot(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}get _sessionDuration(){var e,t;const i=null===(e=this._buffer)||void 0===e?void 0:e.data[(null===(t=this._buffer)||void 0===t?void 0:t.data.length)-1];return i?i.timestamp-this._sessionStartTimestamp:null}_clearBufferBeforeMostRecentMeta(){if(!this._buffer||0===this._buffer.data.length)return this._clearBuffer();let e=-1;for(let t=this._buffer.data.length-1;t>=0;t--)if(4===this._buffer.data[t].type){e=t;break}return 0>e?this._clearBuffer():(this._buffer.data=this._buffer.data.slice(e),this._buffer.sizes=this._buffer.sizes.slice(e),this._buffer.size=this._buffer.sizes.reduce((e,t)=>e+t,0),this._buffer)}_clearBuffer(){return this._buffer={size:0,data:[],sizes:[],sessionId:this._sessionId,windowId:this._windowId},this._buffer}_reportStarted(e,t){this._instance.register_for_session({[Ke]:e}),du.info(e.replace("_"," "),t),"session_id_changed"!==e&&this._tryAddCustomEvent("$recording_started",ct({reason:e},t))}_isInteractiveEvent(e){var t;return 3===e.type&&-1!==hu.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){const t=this._isInteractiveEvent(e);t||!0===this._isIdle||e.timestamp-this._lastActivityTimestamp>this._sessionIdleThresholdMilliseconds&&(this._isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this._sessionIdleThresholdMilliseconds,bufferLength:this._buffer.data.length,bufferSize:this._buffer.size,sessionId:this._sessionId,windowId:this._windowId}),this._flushBuffer());const{windowId:i,sessionId:n}=this._sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp);let s=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this._isIdle)){const t="unknown"===this._isIdle;this._isIdle=!1,t||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),s=!0)}const r=this._sessionId!==n,o=this._windowId!==i;if(this._windowId=i,this._sessionId=n,r||o){const e=r&&!1!==this._isIdle;e&&(this._isIdle="unknown"),this._restartForSessionIdChange(e)}else if(t&&this._releaseHoldAndFlush(),s){var a;const e=["sampled","active"].includes(this.status)||(null===(a=this._strategy)||void 0===a?void 0:a.hasPendingTriggers(this.sessionId));this._eventsDroppedWhileIdle>0&&e&&this._tryTakeFullSnapshot(),this._scheduleJsonLdScan(),this._scheduleFullSnapshot()}}_clearConditionalRecordingPersistence(){var e;null===(e=this._strategy)||void 0===e||e.clearConditionalRecordingPersistence()}get sdkDebugProperties(){var e;return{$recording_status:this.status,$sdk_debug_replay_flush_hold_reason:this._flushHoldReason,$sdk_debug_replay_internal_buffer_length:this._buffer.data.length,$sdk_debug_replay_internal_buffer_size:this._buffer.size,$sdk_debug_session_start:this._sessionStartTimestamp,$sdk_debug_replay_flushed_size:null===(e=this._flushedSizeTracker)||void 0===e?void 0:e.currentTrackedSize(this.sessionId),$sdk_debug_replay_rrweb_error:this._rrwebError,[Ge]:this._rrwebAttached,[Qe]:this._rrwebStartAttempted}}get _rrwebAttached(){var e,t,i;return!!this._stopRrweb&&(null===(e=null===(t=_u())||void 0===t||null===(i=t.isRecording)||void 0===i?void 0:i.call(t))||void 0===e||e)}_startRecorder(){var t;if(this._stopRrweb)return;this._rrwebStartAttempted=!0;const i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,maskAllElementAttributes:!1,maskAttributeFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,inlineStylesheetBudgetRules:1e4,recordCrossOriginIframes:!1,sampling:void 0,attributeFilter:void 0},s=this._instance.config.session_recording;for(const[e,t]of Object.entries(s||{}))if(e in i)if("maskInputOptions"===e)i.maskInputOptions=ct({password:!0},t);else if("sampling"===e){const e=null!=t?t:{},n={};xt(e.mousemove)||(n.mousemove=e.mousemove),xt(e.mouseInteraction)||(n.mouseInteraction=e.mouseInteraction),i.sampling=n}else i[e]=t;var r,o,a,l;!0===(null==s?void 0:s.captureJsonLd)&&!0!==i.slimDOMOptions&&"all"!==i.slimDOMOptions&&(i.slimDOMOptions=ct(ct({},i.slimDOMOptions),{},{script:!0})),this._canvasRecording&&this._canvasRecording.enabled&&(i.recordCanvas=!0,i.sampling=ct(ct({},i.sampling),{},{canvas:this._canvasRecording.fps}),i.dataURLOptions={type:"image/webp",quality:this._canvasRecording.quality},i.canvasResolutionScale=this._canvasResolutionScale,i.canvasMasking={configured:()=>{var e;return Ct(null===(e=this._instance.config.session_recording)||void 0===e||null===(e=e.canvasCapture)||void 0===e?void 0:e.maskRegionsFn)},regionsFn:e=>{var t;const i=null===(t=this._instance.config.session_recording)||void 0===t||null===(t=t.canvasCapture)||void 0===t?void 0:t.maskRegionsFn;if(Ct(i))try{var n;return null!==(n=i(e))&&void 0!==n?n:null}catch(e){return this._maskRegionsFnFailed||(this._maskRegionsFnFailed=!0,du.warn("canvasCapture.maskRegionsFn threw, canvas frames will be skipped",e)),null}}}),this._masking&&(i.maskAllInputs=null===(r=this._masking.maskAllInputs)||void 0===r||r,i.maskTextSelector=null!==(o=this._masking.maskTextSelector)&&void 0!==o?o:void 0,i.blockSelector=null!==(a=this._masking.blockSelector)&&void 0!==a?a:void 0,i.maskAllElementAttributes=null!==(l=this._masking.maskAllElementAttributes)&&void 0!==l&&l),i.maskAllElementAttributes&&i.maskAttributeFn&&(i.maskAttributeFn=void 0,this._hasWarnedExclusiveAttributeMasking||(this._hasWarnedExclusiveAttributeMasking=!0,du.warn('`maskAllElementAttributes` and `maskAttributeFn` are mutually exclusive, and `maskAttributeFn` is being ignored. Remove one of the two. Note that `maskAllElementAttributes` can also come from your project\'s "Privacy and masking" settings. See https://posthog.com/docs/session-replay/privacy'))),this._warnIfClientMaskingShadowsServer();const c=_u();if(!c)return void du.error("_startRecorder was called but rrwebRecord is not available. This indicates something has gone wrong.");this._mutationThrottler=null!==(t=this._mutationThrottler)&&void 0!==t?t:new Sl(c,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(e,t)=>{const i=`Too many mutations on node '${e}'. Rate limiting. This could be due to SVG animations or something similar`;du.info(i,{node:t}),this.log("[SessionRecording] "+i,"warn")},onDroppedAttributeMutations:e=>this._throttledMutationsDropped+=e,bytesRefillRate:this._instance.config.session_recording.__mutationBytesRefillRate,bytesBucketSize:this._instance.config.session_recording.__mutationBytesBucketSize,resyncIntervalMs:this._fullSnapshotIntervalMillis,onDroppedOversizedMutation:e=>{0===this._oversizedMutationsDropped&&this.log("[SessionRecording] Dropped an oversized DOM mutation to keep the recording playable. The recording will resync with a full snapshot.","warn"),this._oversizedMutationsDropped+=1,this._oversizedMutationBytesDropped+=e},requestFullSnapshot:()=>this._tryTakeFullSnapshot()});const u=this._gatherRRWebPlugins();if(this._stopRrweb=c(ct(ct({emit:e=>{this.onRRwebEmit(e)},plugins:u,errorHandler:(e,t)=>"rrweb"===t&&(this._hasLoggedRecorderCallbackError||(this._hasLoggedRecorderCallbackError=!0,du.error("rrweb internal error - recording will continue but may be incomplete",e)),!0)},i),{},{recordAfter:"DOMContentLoaded"})),!this._stopRrweb)return this._rrwebError=!0,void du.error("rrweb failed to start - Loss of recording data is possible. Check the browser console for rrweb errors.");this._rrwebError=!1,!0===(null==s?void 0:s.captureJsonLd)&&n&&(null==e?void 0:e.MutationObserver)&&!this._jsonLdCapture&&(this._jsonLdCapture=function(e,t,i){const n=new WeakMap,s=i.getCaptureState||(()=>!0);let r=qc;const o=function(e,t){const i=t.attributeFilter;return t.maskAllElementAttributes||t.maskAttributeFn||(null==i?void 0:i.length)&&!i.includes("id")?zc:i=>{const n=e.getElementById(i);return!!n&&"SCRIPT"!==n.nodeName&&(!t.isRecordedElement||t.isRecordedElement(n))&&!lu(n,t.blockClass,t.blockSelector)}}(e,i),a=t=>{try{const a=s();if(!r||!1===a||!t.isConnected||t.ownerDocument!==e||function(e,t){return lu(e,t.blockClass,t.blockSelector)||lu(e,t.maskTextClass,t.maskTextSelector)}(t,i))return;const l=function(e,t=zc,i){if(!e||e.length>qc)return null;try{const n=JSON.parse(e),s={maskUrl:i,remainingNodes:2048,exceeded:!1},r=kt(n)?n.map(e=>ru(e,t,s)):ru(n,t,s);if(s.exceeded||Pt(r)||kt(r)&&(!r.length||r.some(Pt)))return null;const o=JSON.stringify(r);return o.length>2e4?null:[r,o]}catch(e){return null}}(t.text,o,i.maskUrl);if(!l)return void n.delete(t);const[c,u]=l;if(Pt(a))return void n.set(t,u);if(n.get(t)!==u){if(u.length>r)return void(r=0);i.emit(c)&&(n.set(t,u),r-=u.length)}}catch(e){return}};try{const i=new t(e=>{try{if(!r||!1===s())return;const t=e=>{for(const t of cu(e))a(t)};for(const i of e)if("childList"===i.type)ou(i.target)&&a(i.target),i.addedNodes.forEach(t);else if("characterData"===i.type){const e=i.target.parentNode;e&&ou(e)&&a(e)}else"attributes"===i.type&&ou(i.target)&&a(i.target)}catch(e){return}});return i.observe(e,{attributes:!0,attributeFilter:["type"],characterData:!0,childList:!0,subtree:!0}),{scan(t=!1){r&&!1!==s()&&cu(e.documentElement).forEach(e=>{t&&n.delete(e),a(e)})},stop(){return i.disconnect()}}}catch(e){return{scan(){},stop(){}}}}(n,e.MutationObserver,{maskUrl:e=>this._maskReplayUrl(e),attributeFilter:i.attributeFilter,blockClass:i.blockClass,blockSelector:i.blockSelector,isRecordedElement:e=>c.mirror.getId(e)>0,maskAllElementAttributes:i.maskAllElementAttributes,maskAttributeFn:i.maskAttributeFn,maskTextClass:i.maskTextClass,maskTextSelector:i.maskTextSelector,getCaptureState:()=>{var e;return!0!==(null===(e=this._instance.config.session_recording)||void 0===e?void 0:e.captureJsonLd)||this._urlTriggerMatching.urlBlocked||this._urlTriggerMatching.isCurrentUrlBlocked()?null:this._canCaptureJsonLd()},emit:e=>this._tryAddJsonLdEvent(e)}),this._urlTriggerMatching.isCurrentUrlBlocked()&&this._jsonLdCapture.scan()),this._lastActivityTimestamp=Date.now(),this._isIdle=Lt(this._isIdle)?this._isIdle:"unknown",this.tryAddCustomEvent("$remote_config_received",this._remoteConfig),this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:i,activePlugins:u.map(e=>null==e?void 0:e.name)}),this._tryAddCustomEvent("$posthog_config",{config:this._instance.config})}tryAddCustomEvent(e,t){return this._tryAddCustomEvent(e,t)}};const Nu=["type"];var Bu=function(e){return e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e}({}),qu=function(e){return e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e}({}),Hu=function(e){return e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e}({}),Uu=function(e){return e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e}({}),zu=function(e){return e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e}({}),Wu=function(e){return e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e}({}),ju=function(e){return e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e}({});function Vu(e,t){return-1!==e.indexOf(t)}Date,Date;var Gu={Node:["childNodes","parentNode","parentElement","textContent","previousSibling","nextSibling","lastChild"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot"],MutationObserver:[]},Qu={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:["querySelector","querySelectorAll"],MutationObserver:["constructor"]},Ku={};function Ju(e){if(Ku[e])return Ku[e];const t=function(e){var t,i;const n=null===(t=globalThis)||void 0===t||null===(t=t.Zone)||void 0===t||null===(i=t.__symbol__)||void 0===i?void 0:i.call(t,e);return n&&globalThis[n]?globalThis[n]:void 0}(e)||globalThis[e],i=t.prototype,n=e in Gu?Gu[e]:void 0,s=Boolean(n&&n.every(e=>{var t;return Boolean(null===(t=Object.getOwnPropertyDescriptor(i,e))||void 0===t||null===(t=t.get)||void 0===t?void 0:t.toString().includes("[native code]"))})),r=e in Qu?Qu[e]:void 0,o=Boolean(r&&r.every(e=>{var t;return"function"==typeof i[e]&&(null===(t=i[e])||void 0===t?void 0:t.toString().includes("[native code]"))}));if(s&&o)return Ku[e]=t.prototype,t.prototype;const a=document.createElement("iframe");a.style.display="none";let l=!1;try{document.body.appendChild(a);const n=a.contentWindow;if(!n)return t.prototype;const s=n[e].prototype;return s?(function(e){return Vu(e,"AppleWebKit")&&!Vu(e,"Chrome")}(navigator.userAgent)&&(a.classList.add("rr-block","ph-no-capture"),a.setAttribute("__rrwebUntaintedPrototype",e),l=!0),Ku[e]=s):i}catch(e){return i}finally{!l&&a.parentNode&&document.body.removeChild(a)}}var Yu=Object.create(null);function Zu(e,t,i){var n;const s=Yu[e],r=s[i];if(r)return r.call(t);const o=Ju(e),a=null===(n=Object.getOwnPropertyDescriptor(o,i))||void 0===n?void 0:n.get;return a?(s[i]=a,a.call(t)):t[i]}Yu.Node=Object.create(null),Yu.ShadowRoot=Object.create(null),Yu.MutationObserver=Object.create(null),Yu.Element=Object.create(null);var Xu,ed={};function td(e,t,i){const n=`${e}.${String(i)}`;if(ed[n])return ed[n].bind(t);const s=Ju(e)[i];return"function"!=typeof s?t[i]:(ed[n]=s,s.bind(t))}function id(){return Ju("MutationObserver").constructor}function nd(e,t,i){try{if(!(t in e))return()=>{};const n=e[t],s={next:n},r=i(function(...e){return s.next.apply(this,e)});return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:n},__rrweb_layer__:{enumerable:!1,value:s}})),e[t]=r,()=>{if(e[t]===r)return void(e[t]=s.next);const i=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let n=e[t],o=i(n);for(;o;){if(o.next===r)return void(o.next=s.next);n=o.next,o=i(n)}}}catch(e){return()=>{}}}var sd={childNodes:e=>Zu("Node",e,"childNodes"),parentNode:e=>Zu("Node",e,"parentNode"),parentElement:e=>Zu("Node",e,"parentElement"),textContent:e=>Zu("Node",e,"textContent"),previousSibling:e=>Zu("Node",e,"previousSibling"),nextSibling:e=>Zu("Node",e,"nextSibling"),lastChild:e=>Zu("Node",e,"lastChild"),isConnected(e){if(void 0===Xu){var t;const e=null===(t=Object.getOwnPropertyDescriptor(Ju("Node"),"isConnected"))||void 0===t?void 0:t.get;Xu=(null==e?void 0:e.toString().includes("[native code]"))?e:null}return null==Xu?void 0:Xu.call(e)},contains:(e,t)=>td("Node",e,"contains")(t),getRootNode:e=>td("Node",e,"getRootNode")(),host:e=>e&&"host"in e?Zu("ShadowRoot",e,"host"):null,styleSheets:e=>e.styleSheets,shadowRoot:e=>e&&"shadowRoot"in e?Zu("Element",e,"shadowRoot"):null,querySelector:(e,t)=>td("Element",e,"querySelector")(t),querySelectorAll:(e,t)=>td("Element",e,"querySelectorAll")(t),mutationObserver:id,patch:nd};function rd(){try{if("undefined"!=typeof performance&&performance.now)return performance.now()}catch(e){}return Date.now()}var od=0;function ad(){od+=1}function ld(){return od}function cd(e,t){return(t!==od||e>6e4)&&!0}var ud=0,dd=0,hd=0,pd={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gd=null,_d=null,fd=[],vd=0,md=0,yd={slowestBatchMs:0},bd={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0};function Sd(e){(ud+=1)>1||(pd={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},fd=[],vd=0,_d=(e=>e&&e>0?e:null)(e),dd=rd(),hd=od)}function wd(){return 0===ud?gd||{durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0}:(ud-=1)>0?pd:(pd.durationMs=rd()-dd,pd.deferredStylesheetCount=vd,bd.deferredCount+=vd,_d=null,cd(pd.durationMs,hd)?pd:gd=pd)}function kd(e,t,i){let n=e.length;if(i>=32)return n;for(let s=0;e.length>s;s++){const r=e[s];try{const e=r.cssRules;if(e&&e.length)n+=kd(e,t,i+1);else if(t&&r.styleSheet){const e=r.styleSheet;if(!t.has(e)){t.add(e);const s=e.rules||e.cssRules;s&&(n+=kd(s,t,i+1))}}}catch(e){}}return n}function Cd(e){if(0===ud)return;const t=kd(e,null,0);pd.cssRuleCount+=t,md>0&&(pd.nonDeferrableCssRuleCount+=t)}function Ed(e){md+=1;try{return e()}finally{md-=1}}function Td(e){ud>0&&(pd.stylesheetMs+=e)}function xd(e){if(0===ud||null===_d)return!1;const t=pd.cssRuleCount-pd.nonDeferrableCssRuleCount;return t>=_d||t+function(e){try{const t=e&&(e.rules||e.cssRules);if(!t)return 0;const i=new WeakSet;return i.add(e),kd(t,i,0)}catch(e){return 0}}(e)>_d}function Id(){const e=fd;return fd=[],e}function Rd(){bd.failedCount+=1}function Pd(e){e>0&&(bd.abandonedCount+=e)}function Md(e){return Md="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Md(e)}function Fd(e,t,i){return(t=function(e){var t=function(e){if("object"!=Md(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=Md(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Md(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ad(e){return e.nodeType===e.ELEMENT_NODE}function Ld(e){const t=e&&"host"in e&&"mode"in e&&sd.host(e)||null;return Boolean(t&&"shadowRoot"in t&&sd.shadowRoot(t)===e)}function Od(e){return"[object ShadowRoot]"==={}.toString.call(e)}function Dd(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),e}function $d(e){const{cssText:t}=e;if(3>t.split('"').length)return t;const i=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?i.push("layer"):e.layerName&&i.push(`layer(${e.layerName})`),e.supportsText&&i.push(`supports(${e.supportsText})`),e.media.length&&i.push(e.media.mediaText),i.join(" ")+";"}var Nd=0;function Bd(e){const t=0===Nd,i=t?rd():0;Nd+=1;try{const t=e.rules||e.cssRules;if(!t)return null;Cd(t);let i=e.href;return!i&&e.ownerNode&&(i=e.ownerNode.baseURI),Dd(Array.from(t,e=>qd(e,i)).join(""))}catch(e){return null}finally{Nd-=1,t&&Td(rd()-i)}}function qd(e,t){if(Ud(e)){let t;try{t=Bd(e.styleSheet)||$d(e)}catch(i){t=e.cssText}try{var i;if(t&&(null===(i=e.styleSheet)||void 0===i?void 0:i.href))return sh(t,e.styleSheet.href)}catch(e){}return t}{let i=e.cssText;return zd(e)&&e.selectorText.includes(":")&&(i=Hd(i)),t?sh(i,t):i}}function Hd(e){return e.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")}function Ud(e){return"styleSheet"in e}function zd(e){return"selectorText"in e}var Wd=/^-?[A-Za-z_][\w-]*$/,jd=/^-?[A-Za-z_][\w-]*(\.-?[A-Za-z_][\w-]*)*$/;function Vd(e){const t=[];let i=!1,n=null;const s=new Map;function r(e){const s=t.pop();if("group"===s.kind){if(null===e){for(;t.length>0&&"group"===t[t.length-1].kind;)t.pop();return void r(null)}const i=t[t.length-1];return i.parts.push(e),void(i.index+=1)}if(!s.importRule)return i=!0,void(n=e);o(t[t.length-1],s.importRule,e)}function o(e,t,i){try{let s;try{s=i||$d(t)}catch(e){s=t.cssText}try{var n;s&&(null===(n=t.styleSheet)||void 0===n?void 0:n.href)&&(s=sh(s,t.styleSheet.href))}catch(e){}s&&e.parts.push(s),e.index+=1}catch(e){r(null)}}function a(e){const i=e.rules[e.index];if("sheet"===e.kind&&Ud(i)){const n=s.get(i);return null===n?(e.parts.push(i.cssText),void(e.index+=1)):n?void t.push({kind:"sheet",sheet:n.sheet,rules:n.rules,sheetHref:n.sheetHref,index:0,parts:[],importRule:i}):void o(e,i,null)}if(function(e,i){try{const n=function(e){const t=e;if(!t.cssRules||0===t.cssRules.length)return null;if(t.media&&"string"==typeof t.media.mediaText)return`@media ${t.media.mediaText} {`;if(zd(e)){if("number"==typeof t.type&&1!==t.type)return null;const i=t.style?t.style.cssText:"";return`${e.selectorText} {${i?" "+i:""}`}if("containerName"in t)return"string"!=typeof t.containerQuery||t.containerName&&!Wd.test(t.containerName)?null:`@container ${t.containerName?`${t.containerName} `:""}${t.containerQuery} {`;if("string"==typeof t.conditionText){let n="";try{var i;n=(null===(i=e.constructor)||void 0===i?void 0:i.name)||""}catch(e){return null}return""===n||"Object"===n||"CSSSupportsRule"===n?`@supports ${t.conditionText} {`:null}return"string"==typeof t.name?"keyText"in t.cssRules[0]?Wd.test(t.name)?`@keyframes ${t.name} {`:null:""===t.name?"@layer {":jd.test(t.name)?`@layer ${t.name} {`:null:null}(e);if(null===n)return!1;const s=i.sheetHref;return t.push({kind:"group",rules:Array.from(e.cssRules),sheetHref:s,index:0,parts:[],prelude:s?sh(n,s):n,fixColons:"sheet"===i.kind&&zd(e)&&e.selectorText.includes(":")}),!0}catch(e){return!1}}(i,e))return;let n=i.cssText;"sheet"===e.kind&&zd(i)&&i.selectorText.includes(":")&&(n=Hd(n)),e.parts.push(e.sheetHref?sh(n,e.sheetHref):n),e.index+=1}return function(e){try{const i=e.rules||e.cssRules;if(!i)return!1;Cd(i);let n=e.href;!n&&e.ownerNode&&(n=e.ownerNode.baseURI);const r=Array.from(i);return t.push({kind:"sheet",sheet:e,rules:r,sheetHref:n,index:0,parts:[],importRule:null}),function(e,t){const i=[{sheet:t,rules:e,index:0}];for(;i.length>0;){const e=i[i.length-1];if(e.index>=e.rules.length){i.pop();continue}const t=e.rules[e.index];if(e.index+=1,!Ud(t)||s.has(t))continue;let n=null;try{n=t.styleSheet}catch(e){s.set(t,null);continue}if(n&&!i.some(e=>e.sheet===n))try{const e=n.rules||n.cssRules;if(!e)continue;Cd(e);let r=n.href;!r&&n.ownerNode&&(r=n.ownerNode.baseURI);const o=Array.from(e);s.set(t,{sheet:n,rules:o,sheetHref:r}),i.push({sheet:n,rules:o,index:0})}catch(e){}}}(r,e),!0}catch(e){return!1}}(e)||(i=!0),{advance(e){if(i)return!0;const s=rd();let o=e>0?e:1;try{for(;!i&&o>0;){const e=t[t.length-1];if(e.index>=e.rules.length){let t=null;try{if("group"===e.kind){const i=e.prelude+e.parts.join("")+"}";t=e.fixColons?Hd(i):i}else t=Dd(e.parts.join(""))}catch(e){}r(t);continue}o-=1;try{a(e)}catch(e){r(null)}}}catch(e){i=!0,n=null}finally{Td(rd()-s)}return i},text:()=>i?n:null,remainingRules(){if(i)return 0;let e=0;for(const i of t)e+=i.rules.length-i.index;return e}}}var Gd=class{constructor(){Fd(this,"idNodeMap",new Map),Fd(this,"nodeMetaMap",new WeakMap)}getId(e){var t,i;return e&&null!==(t=null===(i=this.getMeta(e))||void 0===i?void 0:i.id)&&void 0!==t?t:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);if(this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e)),Ad(e)){const t=sd.shadowRoot(e);t&&this.removeNodeFromMap(t),"IFRAME"===e.nodeName&&e.contentDocument&&this.removeNodeFromMap(e.contentDocument)}}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){this.idNodeMap.set(t.id,e),this.nodeMetaMap.set(e,t)}replace(e,t){const i=this.getNode(e);if(i){const e=this.nodeMetaMap.get(i);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}};function Qd({element:e,maskInputOptions:t,tagName:i,type:n,value:s,maskInputFn:r}){let o=s||"";const a=n&&Kd(n);return(t[i.toLowerCase()]||a&&t[a])&&(o=r?r(o,e):"*".repeat(o.length)),o}function Kd(e){return e.toLowerCase()}var Jd=new Set(["rr_width","rr_height","rr_left","rr_top","rr_position","rr_transform","rr_display","rr_scrollleft","rr_scrolltop","rr_mediastate","rr_open_mode"]);function Yd({element:e,name:t,value:i,maskAllElementAttributes:n,maskAttributeFn:s,isGenerated:r=!1}){return i?n?r&&Jd.has(Kd(t))?i:"*".repeat(i.length):s?s(t,i,e):i:i}var Zd="__rrweb_original__";function Xd(e){try{const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Kd(t):null}catch(e){return null}}var eh=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,th=/^(?:[a-z+]+:)?\/\//i,ih=/^www\..*/i,nh=/^(data:)([^,]*),(.*)/i;function sh(e,t){return(e||"").replace(eh,(e,i,n,s,r,o)=>{const a=n||r||o,l=i||s||"";if(!a)return e;if(th.test(a)||ih.test(a))return`url(${l}${a}${l})`;if(nh.test(a))return`url(${l}${a}${l})`;if("/"===a[0])return`url(${l}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${l})`;const c=a.split("#")[0],u=a.substring(c.length),d=t.split("#")[0].split("/"),h=c.split("/");d.pop();for(const e of h)"."!==e&&(".."===e?d.pop():d.push(e));return`url(${l}${d.join("/")}${u}${l})`})}var rh,oh,ah=new Map,lh=1,ch=new RegExp("[^a-z0-9-_:]");function uh(){return lh++}var dh=!1,hh=/^[^ \t\n\r\u000c]+/,ph=/^[, \t\n\r\u000c]+/,gh=new WeakMap;function _h(e,t){return t&&""!==t.trim()?fh(e,t):t}function fh(e,t){let i=gh.get(e);if(i||(i=e.createElement("a"),gh.set(e,i)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return i.setAttribute("href",t),i.href}function vh(e,t){return(null==t?void 0:t.maxBase64ImageLength)?function(e,t){return t&&e.length>t?"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==":e}(e,t.maxBase64ImageLength):e}function mh(e,t,i,n,s,r){if(!n)return n;if("src"===i||"href"===i&&("use"!==t||"#"!==n[0])){const i=_h(e,n);if(i.startsWith("data:")){if("img"===t&&s){let e=i;return((null==r?void 0:r.type)||void 0!==(null==r?void 0:r.quality))&&(e=function(e,t,i,n){if(1e5>t.length)return t;if(!e.complete||0===e.naturalWidth)return t;if(e.naturalWidth>4096||e.naturalHeight>4096)return t;const s=ah.get(t);if(s&&s.type===i&&s.quality===n)return s.result;try{const s=document.createElement("canvas");s.width=e.naturalWidth,s.height=e.naturalHeight;const r=s.getContext("2d");if(!r)return t;r.drawImage(e,0,0);const o=s.toDataURL(i||"image/webp",null!=n?n:.4),a=t.length>o.length?o:t;if(ah.size>=10){const e=ah.keys().next().value;void 0!==e&&ah.delete(e)}return ah.set(t,{type:i,quality:n,result:a}),a}catch(e){return t}}(s,i,r.type,r.quality)),vh(e,r)}if("image"===t)return vh(i,r)}return i}if("xlink:href"===i&&"#"!==n[0]){const i=_h(e,n);return"image"===t&&i.startsWith("data:")?vh(i,r):i}return"background"!==i||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===i?function(e,t){if(""===t.trim())return t;let i=0;function n(e){let n;const s=e.exec(t.substring(i));return s?(n=s[0],i+=n.length,n):""}const s=[];for(;n(ph),t.length>i;){let r=n(hh);if(","===r.slice(-1))r=_h(e,r.substring(0,r.length-1)),s.push(r);else{let n="";r=_h(e,r);let o=!1;for(;;){const e=t.charAt(i);if(""===e){s.push((r+n).trim());break}if(o)")"===e&&(o=!1);else{if(","===e){i+=1,s.push((r+n).trim());break}"("===e&&(o=!0)}n+=e,i+=1}}}return s.join(", ")}(e,n):"style"===i?sh(n,fh(e)):"object"===t&&"data"===i?_h(e,n):n:_h(e,n)}function yh(e,t,i){return("video"===e||"audio"===e)&&"autoplay"===Kd(t)}function bh(e){return"string"==typeof e&&Kd(e).split(/\s+/).includes("stylesheet")}function Sh(e,t,i){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!i&&Sh(sd.parentNode(e),t,i);for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;return!!i&&Sh(sd.parentNode(e),t,i)}function wh(e,t,i,n){let s;if(Ad(e)){if(s=e,!sd.childNodes(s).length)return!1}else{if(null===sd.parentElement(e))return!1;s=sd.parentElement(e)}try{if("string"==typeof t){if(n){if(s.closest(`.${t}`))return!0}else if(s.classList.contains(t))return!0}else if(Sh(s,t,n))return!0;if(i)if(n){if(s.closest(i))return!0}else if(s.matches(i))return!0}catch(e){}return!1}function kh(e,t,i){const n=e.removeEventListener;"function"==typeof n&&n.call(e,t,i)}var Ch=new Map;function Eh(e={}){Ch.forEach((t,i)=>{e.keepChangedLinks&&t.changedLinkBaseline||(t.controller.abort(),Ch.delete(i))})}function Th(e){try{return e.sheet}catch(e){return null}}function xh(e,t,i,n,s){const r=new AbortController,o=()=>{var t;(null===(t=Ch.get(e))||void 0===t?void 0:t.controller)===r&&Ch.delete(e),r.abort()};let a=!1;const l=()=>{if(!a){a=!0;try{t()}finally{o()}}};e.addEventListener("load",l,{signal:r.signal,once:!0}),e.addEventListener("error",o,{signal:r.signal,once:!0});const c=Date.now()+6e4;let u;const d=t=>{const s=n.length>t?n[t]:Math.max(n[n.length-1],1e3);u=setTimeout(()=>{e.isConnected?i()?l():Date.now()<c?d(t+1):o():o()},s)};r.signal.addEventListener("abort",()=>clearTimeout(u),{once:!0}),d(0),Ch.set(e,{controller:r,changedLinkBaseline:s})}var Ih=[100,200,400,800,1600,3200,6400,12800,25600];function Rh(e,t){return Array.from(e.styleSheets).find(e=>e.href===t)}function Ph(e){return null==e?"":e.toLowerCase()}var Mh=!1,Fh=!1;function Ah(e,t){const{doc:i,mirror:n,blockClass:s,blockSelector:r,maskTextClass:o,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p=!1,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f={},inlineImages:v=!1,recordCanvas:m=!1,canvasMaskingConfigured:y,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w=5e3,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E=5e3,keepIframeSrcFn:T=()=>!1,newlyAddedElement:x=!1,depth:I=0,maxDepth:R=50}=t;let{needsMask:P}=t,{preserveWhiteSpace:M=!0}=t;if(I>=R)return Fh=!0,Mh||(Mh=!0,console.warn(`[rrweb-snapshot] DOM tree depth exceeded max depth of ${R}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`)),null;P||(P=wh(e,o,a,void 0===P)),ud>0&&(pd.nodeCount+=1);const F=function(e,t){const{doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:o,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:u,maskAllElementAttributes:d=!1,maskAttributeFn:h,dataURLOptions:p={},inlineImages:g,recordCanvas:_,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const i=t.getId(e);return 1===i?void 0:i}(i,n);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:ju.Document,childNodes:[],compatMode:e.compatMode}:{type:ju.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:ju.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:i,blockClass:n,blockSelector:s,inlineStylesheet:r,maskInputOptions:o={},maskInputFn:a,maskAllElementAttributes:l=!1,maskAttributeFn:c,dataURLOptions:u={},inlineImages:d,recordCanvas:h,canvasMaskingConfigured:p,keepIframeSrcFn:g,newlyAddedElement:_=!1,rootId:f}=t,v=function(e,t,i){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let i=e.classList.length;i--;)if(t.test(e.classList[i]))return!0;if(i)return e.matches(i)}catch(e){}return!1}(e,n,s),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=Kd(e.tagName);return ch.test(t)?"div":t}(e),y=new Set;let b={};const S=e.attributes.length;for(let t=0;S>t;t++){const n=e.attributes[t];yh(m,n.name)||(b[n.name]=mh(i,m,Kd(n.name),n.value,e,u))}if("link"===m&&"string"==typeof b.href){var w;const t=null===(w=Th(e))||void 0===w?void 0:w.href;t&&(b.href=t)}if("link"===m&&r&&!v&&bh(b.rel)){let t=e.sheet;if(!t){const n=function(e){return e.href}(e);n&&(t=Rh(i,n),!t&&n.includes(".css"))&&(t=Rh(i,window.location.origin+"/"+n.replace(window.location.href,"")))}let n=null;t&&(xd(t)?ud>0&&(fd.push(e),vd+=1):n=Bd(t)),n&&(delete b.rel,delete b.href,b._cssText=n)}var k;if("style"===m&&e.sheet&&!(e.innerText||sd.textContent(e)||"").trim().length){const t=Ed(()=>Bd(e.sheet));t&&(b._cssText=t)}if("input"===m||"textarea"===m||"select"===m){const t=e.value,i=e.checked;"radio"!==b.type&&"checkbox"!==b.type&&"submit"!==b.type&&"button"!==b.type&&t?b.value=Qd({element:e,type:Xd(e),tagName:m,value:t,maskInputOptions:o,maskInputFn:a}):i&&(b.checked=i)}if("option"===m&&(e.selected&&!o.select?b.selected=!0:delete b.selected),"dialog"===m&&e.open){try{b.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal"}catch(e){b.rr_open_mode="modal",b.ph_rr_could_not_detect_modal=!0}y.add("rr_open_mode")}if("canvas"===m&&h&&!(null==p?void 0:p()))try{if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let i=0;e.width>i;i+=50)for(let n=0;e.height>n;n+=50){const s=t.getImageData,r=Zd in s?s[Zd]:s;let o;try{o=r.call(t,i,n,Math.min(50,e.width-i),Math.min(50,e.height-n))}catch(e){return!1}if(new Uint32Array(o.data.buffer).some(e=>0!==e))return!1}return!0})(e)||(b.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){const t=e.toDataURL(u.type,u.quality),n=i.createElement("canvas");n.width=e.width,n.height=e.height,t!==n.toDataURL(u.type,u.quality)&&(b.rr_dataURL=t)}}catch(e){"SecurityError"===(null==(k=e)?void 0:k.name)?dh||(dh=!0,console.warn("Cannot read canvas pixels, so this canvas is left out of the recording. A cross-origin image or video drawn into it taints it.",k)):console.warn("Cannot read canvas pixels, so this canvas is left out of the recording.",k)}let C,E=!1;if("img"===m&&d){rh||(rh=i.createElement("canvas"),oh=rh.getContext("2d"));const t=e,n=t.currentSrc||t.getAttribute("src")||"<unknown-src>",s=t.crossOrigin,r=(t,i)=>E?Yd({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c}):i,o=()=>{kh(t,"load",o);try{rh.width=t.naturalWidth,rh.height=t.naturalHeight,oh.drawImage(t,0,0);const e=rh.toDataURL(u.type,u.quality);b.rr_dataURL=r("rr_dataURL",e)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o));console.warn(`Cannot inline img src=${n}! Error: ${e}`)}"anonymous"===t.crossOrigin&&(s?b.crossOrigin=r("crossOrigin",s):t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}if("audio"===m||"video"===m){const t=b;t.rr_mediaState=e.paused?"paused":"played",y.add("rr_mediaState"),t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}if(_||(e.scrollLeft&&(b.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(b.rr_scrollTop=e.scrollTop)),v){var T,x,I;const{width:t,height:n,left:s,top:r}=e.getBoundingClientRect(),o=null===(T=i.defaultView)||void 0===T?void 0:T.getComputedStyle(e);b={class:b.class,rr_width:`${t}px`,rr_height:`${n}px`,rr_left:`${Math.floor(s+((null===(x=i.defaultView)||void 0===x?void 0:x.scrollX)||0))}px`,rr_top:`${Math.floor(r+((null===(I=i.defaultView)||void 0===I?void 0:I.scrollY)||0))}px`},y.add("rr_width"),y.add("rr_height"),y.add("rr_left"),y.add("rr_top"),o&&(b.rr_position=o.position||"static",y.add("rr_position"),o.transform&&"none"!==o.transform&&(b.rr_transform=o.transform,y.add("rr_transform")),o.display&&o.display.startsWith("inline")&&(b.rr_display=o.display,y.add("rr_display")))}if("iframe"!==m||g(b.src)||(e.contentDocument||(b.rr_src=b.src),delete b.src),l||c)for(const[t,i]of Object.entries(b))"string"!=typeof i&&null!==i||(b[t]=Yd({element:e,name:t,value:i,maskAllElementAttributes:l,maskAttributeFn:c,isGenerated:y.has(t)}));E=!0;try{customElements.get(m)&&(C=!0)}catch(e){}return{type:ju.Element,tagName:m,attributes:b,childNodes:[],isSVG:(R=e,Boolean("svg"===R.tagName||R.ownerSVGElement)||void 0),needBlock:v,rootId:f,isCustom:C};var R}(e,{doc:i,blockClass:s,blockSelector:r,inlineStylesheet:a,maskInputOptions:l,maskInputFn:u,maskAllElementAttributes:d,maskAttributeFn:h,dataURLOptions:p,inlineImages:g,recordCanvas:_,canvasMaskingConfigured:f,keepIframeSrcFn:v,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:case e.CDATA_SECTION_NODE:return function(e,t){const{needsMask:i,maskTextFn:n,rootId:s}=t,r=sd.parentNode(e),o=r&&r.tagName;let a=sd.textContent(e);const l="STYLE"===o||void 0,c="string"==typeof o&&"SCRIPT"===o.toUpperCase();if(l&&a){try{var u;if(e.nextSibling||e.previousSibling);else if(xd(r.sheet));else if(null===(u=r.sheet)||void 0===u?void 0:u.cssRules){const e=Bd(r.sheet);e&&!/(?:^|[\s;{}])-?[a-zA-Z][\w-]*\s*:\s*;/.test(e)&&(a=e)}}catch(t){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${t}`,e)}a=sh(a,fh(t.doc))}return c&&(a="SCRIPT_PLACEHOLDER"),!l&&!c&&a&&i&&(a=n?n(a,sd.parentElement(e)):a.replace(/[\S]/g,"*")),{type:ju.Text,textContent:a||"",isStyle:l,rootId:s}}(e,{doc:i,needsMask:o,maskTextFn:c,rootId:y});case e.COMMENT_NODE:return{type:ju.Comment,textContent:sd.textContent(e)||"",rootId:y};default:return!1}}(e,{doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:P,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,keepIframeSrcFn:T,newlyAddedElement:x});if(!F)return console.warn(e,"not serialized"),null;let A;A=n.hasNode(e)?n.getId(e):function(e,t){if(t.comment&&e.type===ju.Comment)return!0;if(e.type===ju.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===function(e){var t;let i;try{i=new URL(e,window.location.href)}catch(e){return null}const n=i.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!==(t=null==n?void 0:n[1])&&void 0!==t?t:null}(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Ph(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Ph(e.attributes.name)||["icon","apple-touch-icon","shortcut icon"].includes(Ph(e.attributes.rel)))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Ph(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Ph(e.attributes.property).match(/^(og|twitter|fb):/)||Ph(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Ph(e.attributes.name)))return!0;if(t.headMetaRobots&&["robots","googlebot","bingbot"].includes(Ph(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&(["author","generator","framework","publisher","progid"].includes(Ph(e.attributes.name))||Ph(e.attributes.property).match(/^article:/)||Ph(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&["google-site-verification","yandex-verification","csrf-token","p:domain_verify","verify-v1","verification","shopify-checkout-api-token"].includes(Ph(e.attributes.name)))return!0}}return!1}(F,_)||!M&&F.type===ju.Text&&!F.isStyle&&!F.textContent.replace(/^\s+|\s+$/gm,"").length?-2:uh();const L=Object.assign(F,{id:A});if(n.add(e,L),-2===A)return null;b&&b(e);let O=!l;if(L.type===ju.Element){O=O&&!L.needBlock,delete L.needBlock;const t=sd.shadowRoot(e);t&&Od(t)&&(L.isShadowHost=!0)}if((L.type===ju.Document||L.type===ju.Element)&&O){_.headWhitespace&&L.type===ju.Element&&"head"===L.tagName&&(M=!1);const t={doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:P,maskTextClass:o,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:T,depth:I+1,maxDepth:R};if(L.type===ju.Element&&"textarea"===L.tagName&&void 0!==L.attributes.value);else for(const i of Array.from(sd.childNodes(e))){const e=Ah(i,t);e&&L.childNodes.push(e)}let x=null;if(Ad(e)&&(x=sd.shadowRoot(e)))for(const e of Array.from(sd.childNodes(x))){const i=Ah(e,t);i&&(Od(x)&&(i.isShadow=!0),L.childNodes.push(i))}}const D=sd.parentNode(e);if(D&&Ld(D)&&Od(D)&&(L.isShadow=!0),L.type===ju.Element&&"iframe"===L.tagName){const t=function(e,t,i){const n=()=>{},s=e.contentWindow;if(!s)return n;let r;try{r=s.document.readyState}catch(e){return n}const o=()=>t();if("complete"!==r){let n=!1,s=null;const r=()=>{n||(n=!0,null!==s&&(clearTimeout(s),s=null),kh(e,"load",a),e.addEventListener("load",o),t())},a=()=>r();return s=setTimeout(r,i),e.addEventListener("load",a),()=>{null!==s&&(clearTimeout(s),s=null),n?kh(e,"load",o):(n=!0,kh(e,"load",a))}}const a="about:blank";let l;try{l=s.location.href}catch(e){return n}if(l!==a||e.src===a||""===e.src){const i=setTimeout(t,0);return e.addEventListener("load",o),()=>{clearTimeout(i),kh(e,"load",o)}}return e.addEventListener("load",o),()=>{kh(e,"load",o)}}(e,()=>{const t=e.contentDocument;if(t&&S){const i=Ah(t,{doc:t,mirror:n,blockClass:s,blockSelector:r,needsMask:P,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onIframeListenerRegistered:k,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:T,depth:I+1,maxDepth:R});i&&S(e,i)}},w);null==k||k(e,t)}var N,B,q;return L.type===ju.Element&&"link"===L.tagName&&bh(L.attributes.rel)&&(B=()=>{if(C){const t=n.getMeta(e),l=Ah(e,{doc:i,mirror:n,blockClass:s,blockSelector:r,needsMask:P,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,maskAllElementAttributes:p,maskAttributeFn:g,slimDOMOptions:_,dataURLOptions:f,inlineImages:v,recordCanvas:m,canvasMaskingConfigured:y,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:S,iframeLoadTimeout:w,onStylesheetLoad:C,stylesheetLoadTimeout:E,keepIframeSrcFn:T,depth:I,maxDepth:R});l&&C(e,l,t)}},q=E,Ch.has(N=e)||Th(N)||xh(N,B,()=>Boolean(Th(N)),[q])),L}function Lh(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:!1===e?{}:e}var Oh=class e{constructor(...e){Fd(this,"parentElement",null),Fd(this,"parentNode",null),Fd(this,"ownerDocument",void 0),Fd(this,"firstChild",null),Fd(this,"lastChild",null),Fd(this,"previousSibling",null),Fd(this,"nextSibling",null),Fd(this,"ELEMENT_NODE",1),Fd(this,"TEXT_NODE",3),Fd(this,"nodeType",void 0),Fd(this,"nodeName",void 0),Fd(this,"RRNodeType",void 0)}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};function Dh(e,t,i=document){const n={capture:!0,passive:!0};return i.addEventListener(e,t,n),()=>$h(i,e,t,n)}function $h(e,t,i,n){Nh(()=>{const s=e.removeEventListener;"function"==typeof s&&(void 0!==n?s.call(e,t,i,n):s.call(e,t,i))})}function Nh(e){try{e()}catch(e){if(!(e instanceof DOMException&&"SecurityError"===e.name))throw e}}function Bh(e){e.forEach(e=>{if("function"==typeof e)try{e()}catch(e){}})}var qh="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",Hh={map:{},getId(){return console.warn(qh),-1},getNode(){return console.warn(qh),null},removeNodeFromMap(){console.warn(qh)},has(){return console.warn(qh),!1},reset(){console.warn(qh)}};function Uh(e,t,i={}){let n=null,s=0;return function(...r){const o=Date.now();s||!1!==i.leading||(s=o);const a=t-(o-s),l=this;0>=a||a>t?(n&&(clearTimeout(n),n=null),s=o,e.apply(l,r)):n||!1===i.trailing||(n=setTimeout(()=>{s=!1===i.leading?0:Date.now(),n=null,e.apply(l,r)},a))}}function zh(e,t,i,n,s=window){const r=s.Object.getOwnPropertyDescriptor(e,t),o=()=>zh(e,t,r||{},!0);if(n)return s.Object.defineProperty(e,t,i),o;const a=function(e){let t="function"==typeof e.setTimeout?e.setTimeout:void 0;try{var i,n;const s=null===(i=e.Zone)||void 0===i||null===(n=i.__symbol__)||void 0===n?void 0:n.call(i,"setTimeout"),r=s?e[s]:void 0;"function"==typeof r&&(t=r)}catch(e){}if(!t)return()=>{};const s=t;return t=>{try{s.call(e,t,0)}catch(e){}}}(s);return s.Object.defineProperty(e,t,{set(e){if(a(()=>{try{i.set.call(this,e)}catch(e){}}),r&&r.set){if(r.get)try{r.get.call(this)}catch(e){return}r.set.call(this,e)}}}),o}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Hh=new Proxy(Hh,{get(e,t,i){return"map"===t&&console.warn(qh),Reflect.get(e,t,i)}}));var Wh=Date.now;function jh(e){var t,i,n,s;const r=e.document;return{left:r.scrollingElement?r.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:r.documentElement.scrollLeft||(null==r?void 0:r.body)&&(null===(t=sd.parentElement(r.body))||void 0===t?void 0:t.scrollLeft)||(null==r||null===(i=r.body)||void 0===i?void 0:i.scrollLeft)||0,top:r.scrollingElement?r.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==r?void 0:r.documentElement.scrollTop)||(null==r?void 0:r.body)&&(null===(n=sd.parentElement(r.body))||void 0===n?void 0:n.scrollTop)||(null==r||null===(s=r.body)||void 0===s?void 0:s.scrollTop)||0}}function Vh(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Gh(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Qh(e){return e?e.nodeType===e.ELEMENT_NODE?e:sd.parentElement(e):null}function Kh(e,t,i,n){if(!e)return!1;const s=Qh(e);if(!s)return!1;try{if("string"==typeof t){if(s.classList.contains(t))return!0;if(n&&null!==s.closest("."+t))return!0}else if(Sh(s,t,n))return!0}catch(e){}if(i){if(s.matches(i))return!0;if(n&&null!==s.closest(i))return!0}return!1}function Jh(e,t,i){const n=t&&"string"!=typeof t&&(t.global||t.sticky)?new RegExp(t):null;for(;e;){if(n&&(n.lastIndex=0),Kh(e,n||t,i,!0))return!0;const s="getRootNode"in e?sd.getRootNode(e):null;e=(null==s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE?sd.host(s):null}return!1}function Yh(e,t,i){return!("TITLE"!==e.tagName||!i.headTitleMutations)||-2===t.getId(e)}function Zh(e,t){if(Ld(e))return!1;const i=t.getId(e);if(!t.has(i))return!0;const n=sd.parentNode(e);return(!n||n.nodeType!==e.DOCUMENT_NODE)&&(!n||Zh(n,t))}function Xh(e){return Boolean(e.changedTouches)}function ep(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function tp(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function ip(e){return!!e&&(e instanceof Oh&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(sd.shadowRoot(e)))}/[1-9][0-9]{12}/.test(Date.now().toString())||(Wh=()=>(new Date).getTime());var np=class{constructor(){Fd(this,"id",1),Fd(this,"styleIDMap",new WeakMap),Fd(this,"idStyleMap",new Map)}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let i;return i=void 0===t?this.id++:t,this.styleIDMap.set(e,i),this.idStyleMap.set(i,e),i}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}};function sp(e){var t;let i=null;return"getRootNode"in e&&(null===(t=sd.getRootNode(e))||void 0===t?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&sd.host(sd.getRootNode(e))&&(i=sd.host(sd.getRootNode(e))),i}function rp(e){const t=e.ownerDocument;if(!t)return!1;if(sd.contains(t,e))return!0;const i=sd.isConnected(e);return"boolean"==typeof i?i:function(e){const t=e.ownerDocument;if(!t)return!1;const i=function(e){let t,i=e;for(;t=sp(i);)i=t;return i}(e);return sd.contains(t,i)}(e)}var op,ap=(e,t)=>`${e}@${t}`,lp=class{constructor(){Fd(this,"frozen",!1),Fd(this,"locked",!1),Fd(this,"takePendingRecords",void 0),Fd(this,"texts",[]),Fd(this,"attributes",[]),Fd(this,"attributeMap",new WeakMap),Fd(this,"generatedAttributes",new WeakMap),Fd(this,"removes",[]),Fd(this,"mapRemoves",new Set),Fd(this,"movedMap",{}),Fd(this,"addedSet",new Set),Fd(this,"movedSet",new Set),Fd(this,"droppedSet",new Set),Fd(this,"removesSubTreeCache",new Set),Fd(this,"mutationCb",void 0),Fd(this,"blockClass",void 0),Fd(this,"blockSelector",void 0),Fd(this,"maskTextClass",void 0),Fd(this,"maskTextSelector",void 0),Fd(this,"inlineStylesheet",void 0),Fd(this,"maskInputOptions",void 0),Fd(this,"maskTextFn",void 0),Fd(this,"maskInputFn",void 0),Fd(this,"maskAllElementAttributes",void 0),Fd(this,"maskAttributeFn",void 0),Fd(this,"keepIframeSrcFn",void 0),Fd(this,"recordCanvas",void 0),Fd(this,"canvasMaskingConfigured",void 0),Fd(this,"inlineImages",void 0),Fd(this,"slimDOMOptions",void 0),Fd(this,"dataURLOptions",void 0),Fd(this,"doc",void 0),Fd(this,"mirror",void 0),Fd(this,"iframeManager",void 0),Fd(this,"stylesheetManager",void 0),Fd(this,"shadowDomManager",void 0),Fd(this,"canvasManager",void 0),Fd(this,"processedNodeManager",void 0),Fd(this,"unattachedDoc",void 0),Fd(this,"canvasManagerReleased",!1),Fd(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),Fd(this,"emit",()=>{if(this.frozen||this.locked)return;const e=rd(),t=ld();try{this.processBufferedMutations()}finally{i=rd()-e,n=t,ud>0||cd(i,null!=n?n:od)||i>yd.slowestBatchMs&&(yd.slowestBatchMs=i)}var i,n}),Fd(this,"processBufferedMutations",()=>{const e=[],t=new Set,i=e=>{let t=e,i=-2;for(;-2===i;)t=t&&sd.nextSibling(t),i=t&&this.mirror.getId(t);return i};let n;const s=s=>{var r;const o=sd.parentNode(s);if(!o||!rp(s)||"TEXTAREA"===o.tagName)return!0;if(this.isBlockedAtEmission(o))return!0;const a=Ld(o)?this.mirror.getId(sp(s)):this.mirror.getId(o),l=i(s);if(-1===a||-1===l)return!1;null!==(r=n)&&void 0!==r||(n=this.buildSerializationOptions());const c=Ah(s,n);return c&&(e.push({parentId:a,nextId:l,node:c}),t.add(c.id)),!0};for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e);for(const e of this.movedSet)up(this.removesSubTreeCache,e)&&!this.movedSet.has(sd.parentNode(e))||this.addedSet.add(e);for(const e of Array.from(this.addedSet)){const t=dp(this.droppedSet,e),i=up(this.removesSubTreeCache,e),n=this.movedSet.has(e)||dp(this.movedSet,e);!t&&!i||n||(this.droppedSet.add(e),this.addedSet.delete(e))}const r=new Set;let o=null;const a=this.addedSet.values();let l=a.next();for(;this.addedSet.size;){let e=null;if(null!==o)for(e=sd.previousSibling(o);e&&-2===this.mirror.getId(e);)e=sd.previousSibling(e);if(e&&this.addedSet.has(e))o=e;else{for(this.addedSet.has(l.value)||(l=a.next()),o=l.value;;){const e=sd.parentNode(o),t=e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE?sd.host(e):e;if(!t||!this.addedSet.has(t))break;o=t}const e=sd.parentNode(o);if(e&&this.addedSet.has(sd.lastChild(e)))o=sd.lastChild(e);else if(e)for(;;){let e=sd.nextSibling(o);for(;e&&-2===this.mirror.getId(e);)e=sd.nextSibling(e);if(!e||!this.addedSet.has(e))break;o=e}}this.addedSet.delete(o);const t=sd.parentNode(o),i=t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?sd.host(t):t;i&&r.has(i)?r.add(o):s(o)||r.add(o)}r.size>0&&console.warn(`[rrweb] dropped ${r.size} node(s) with unresolved parent at emit`);const c={texts:this.texts.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const t=e.node,i=sd.parentNode(t);return i&&"TEXTAREA"===i.tagName&&this.genTextAreaValueMutation(i),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.filter(e=>!this.isBlockedAtEmission(e.node)).map(e=>{const{attributes:t}=e;if(!this.maskAllElementAttributes&&!this.maskAttributeFn&&"string"==typeof t.style){const i=JSON.stringify(e.styleDiff),n=JSON.stringify(e._unchangedStyles);t.style.length>i.length&&(i+n).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}if(this.maskAllElementAttributes||this.maskAttributeFn)for(const[n,s]of Object.entries(t))if("string"==typeof s||null===s){var i;t[n]=Yd({element:e.node,name:n,value:s,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,isGenerated:null===(i=this.generatedAttributes.get(e.node))||void 0===i?void 0:i.has(n)})}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e},u=[];if(this.inlineStylesheet)for(const{id:e,attributes:t}of c.attributes){if(!("rel"in t)&&!("href"in t))continue;const i=this.mirror.getNode(e);i&&"link"===Kd(i.nodeName)&&bh(i.getAttribute("rel"))&&i.getAttribute("href")&&!i.disabled&&u.push(i)}if(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.generatedAttributes=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},c.texts.length||c.attributes.length||c.removes.length||c.adds.length){this.mutationCb(c);for(const e of u)this.stylesheetManager.inlineLinkStylesheetAfterChange(e,{currentId:()=>this.mirror.getId(e),reserializeWithoutCss:()=>({previous:this.mirror.getMeta(e),current:Ah(e,ct(ct({},this.buildSerializationOptions()),{},{inlineStylesheet:!1}))}),lastSerialization:()=>this.mirror.getMeta(e),readdAsMove:()=>this.recordReinsertion(e)})}}),Fd(this,"bufferBelongsToIframe",e=>this.doc===e.contentDocument),Fd(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const i=Array.from(sd.childNodes(e),e=>sd.textContent(e)||"").join("");t.attributes.value=Qd({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Xd(e),value:i,maskInputFn:this.maskInputFn})}),Fd(this,"processMutation",e=>{if(!Yh(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=sd.textContent(e.target);Kh(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:wh(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,Qh(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{var t;const n=e.target,s=Kd(n.tagName),r=e.attributeName,o=null!==(t=e.attributeNamespace)&&void 0!==t?t:null;let a=function(e,t,i){if(!i)return t;const n=e.getAttributeNodeNS(i,t);if(n)return n.name;if("http://www.w3.org/1999/xlink"===i)return`xlink:${t}`;if("http://www.w3.org/XML/1998/namespace"===i)return`xml:${t}`;if("http://www.w3.org/2000/xmlns/"===i)return"xmlns"===t?t:`xmlns:${t}`;const s=e.lookupPrefix(i);return s?`${s}:${t}`:t}(n,r,o),l=o?n.getAttributeNS(o,r):e.target.getAttribute(r);if("value"===a){const e=n,t=Xd(e);l=Qd({element:e,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:t,value:l,maskInputFn:this.maskInputFn})}if(Kh(e.target,this.blockClass,this.blockSelector,!1)||l===e.oldValue)return;let c=this.attributeMap.get(e.target);const u="iframe"===s&&"src"===a;if(u&&!this.keepIframeSrcFn(l)&&n.contentDocument)return;if("type"===a&&"input"===s&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!yh(s,a)){var i;c||(c={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(c),this.attributeMap.set(e.target,c));const t=mh(this.doc,s,Kd(a),l,n,this.dataURLOptions);if(u&&!this.keepIframeSrcFn(l)&&(a="rr_src"),c.attributes[a]=t,null===(i=this.generatedAttributes.get(e.target))||void 0===i||i.delete(a),"style"===a){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const t=this.unattachedDoc.createElement("span"),i=n.style;e.oldValue&&(t.style.cssText=e.oldValue);for(const e of Array.from(i)){const n=i.getPropertyValue(e),s=i.getPropertyPriority(e);n!==t.style.getPropertyValue(e)||s!==t.style.getPropertyPriority(e)?c.styleDiff[e]=""===s?n:[n,s]:c._unchangedStyles[e]=[n,s]}for(const e of Array.from(t.style))""===i.getPropertyValue(e)&&(c.styleDiff[e]=!1)}else if("open"===a&&"dialog"===s){c.attributes.rr_open_mode=n.matches("dialog:modal")?"modal":"non-modal";let t=this.generatedAttributes.get(e.target);t||(t=new Set,this.generatedAttributes.set(e.target,t)),t.add("rr_open_mode")}}break}case"childList":if(e.removedNodes.forEach(e=>{rp(e)||this.shadowDomManager.removeShadowRootsIn(e)}),Kh(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const i=this.mirror.getId(t),n=Ld(e.target)?this.mirror.getId(sd.host(e.target)):this.mirror.getId(e.target);Kh(e.target,this.blockClass,this.blockSelector,!1)||Yh(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(cp(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===i||Zh(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[ap(i,n)]?cp(this.movedSet,t):(this.removes.push({parentId:n,id:i,isShadow:!(!Ld(e.target)||!Od(e.target))||void 0}),function(e,t){const i=[e];for(;i.length;){const e=i.pop();t.has(e)||(t.add(e),sd.childNodes(e).forEach(e=>i.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.add(t))})}}),Fd(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)){if(this.addedSet.has(e))return this.addedSet.delete(e),void this.addedSet.add(e);if(!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(Yh(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let i=null;t&&this.mirror.hasNode(t)&&(i=this.mirror.getId(t)),i&&-1!==i&&(this.movedMap[ap(this.mirror.getId(e),i)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);if(!Kh(e,this.blockClass,this.blockSelector,!1)){if(e.nodeType===e.TEXT_NODE)return;const t=sd.childNodes(e);for(let e=0,i=t.length;i>e;e++){const i=t[e];i&&this.genAdds(i)}if(ip(e)){const t=sd.childNodes(sd.shadowRoot(e));for(let i=0,n=t.length;n>i;i++){const n=t[i];n&&(this.processedNodeManager.add(n,this),this.genAdds(n,e))}}}}}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","maskAllElementAttributes","maskAttributeFn","keepIframeSrcFn","recordCanvas","canvasMaskingConfigured","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]}),this.canvasManager.acquire()}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}readPendingRecordsFrom(e){this.takePendingRecords=()=>e.takeRecords()}reset(){this.releaseCanvasManager()}releaseCanvasManager(){this.canvasManagerReleased||(this.canvasManagerReleased=!0,this.canvasManager.reset())}bufferDoc(){return this.doc}destroy(){for(const e of this.mapRemoves)this.mapRemoves.delete(e),this.mirror.removeNodeFromMap(e)}isBlockedAtEmission(e){return Jh(e,this.blockClass,this.blockSelector)}recordReinsertion(e){var t;const i=sd.parentNode(e);if(!i)return;null===(t=this.takePendingRecords)||void 0===t||t.call(this).forEach(this.processMutation);const n=(e,t)=>({type:"childList",target:i,removedNodes:e,addedNodes:t,oldValue:null,attributeName:null});this.processMutation(n([e],[])),this.processMutation(n([],[e])),this.emit()}buildSerializationOptions(){return{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,canvasMaskingConfigured:this.canvasMaskingConfigured,inlineImages:this.inlineImages,onSerialize:e=>{ep(e,this.mirror)&&this.iframeManager.addIframe(e),tp(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ip(e)&&!Kh(e,this.blockClass,this.blockSelector,!0)&&this.shadowDomManager.addShadowRoot(sd.shadowRoot(e),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onIframeListenerRegistered:(e,t)=>{this.iframeManager.registerLoadListenerDisposer(e,t)},onStylesheetLoad:(e,t,i)=>{this.stylesheetManager.attachLinkElement(e,t,i)}}}};function cp(e,t){const i=[t];for(;i.length;){const t=i.pop();if(e.delete(t),t.nodeType===t.TEXT_NODE)continue;const n=sd.childNodes(t);for(let e=0,t=n.length;t>e;e++){const t=n[e];t&&i.push(t)}}}function up(e,t,i){return 0!==e.size&&function(e,t){const i=sd.parentNode(t);return!!i&&e.has(i)}(e,t)}function dp(e,t){if(0===e.size)return!1;let i=sd.parentNode(t);for(;i;){if(e.has(i))return!0;i=sd.parentNode(i)}return!1}function hp(e){op=e}function pp(){op=void 0}var gp=(e,t="rrweb")=>op?(...i)=>{try{return e(...i)}catch(e){if(op&&!0===op(e,t))return;throw e}}:e,_p=[];function fp(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function vp(e,t){const i=new lp;let n;i.init(e);try{n=new(id())(gp(i.processMutations.bind(i)));const s={attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};return e.attributeFilter&&e.attributeFilter.length>0&&(s.attributeFilter=e.attributeFilter),n.observe(t,s),i.readPendingRecordsFrom(n),_p.push(i),{observer:n,buffer:i}}catch(e){try{null==n||n.disconnect(),i.destroy(),i.reset()}catch(e){}throw e}}function mp({scrollCb:e,doc:t,mirror:i,blockClass:n,blockSelector:s,sampling:r}){const o=new Map,a=r=>{const a=fp(r);if(!a||Kh(a,n,s,!0))return;const l=i.getId(a);let c,u;if(a===t&&t.defaultView){const e=jh(t.defaultView);c=e.left,u=e.top}else c=a.scrollLeft,u=a.scrollTop;const d=`${c},${u}`;o.get(l)!==d&&(o.set(l,d),e({id:l,x:c,y:u}))},l=[Dh("scroll",gp(Uh(gp(e=>a(e)),r.scroll||100)),t)];return"onscrollend"in t&&l.push(Dh("scrollend",gp(a),t)),()=>l.forEach(e=>e())}function yp(e,t){for(let i=_p.length-1;i>=0;i--){const n=_p[i];if(!n)continue;let s=n.bufferBelongsToIframe(e);!s&&t&&t.has(n.bufferDoc())&&(s=!0),s&&(n.reset(),_p.splice(i,1))}}var bp=["INPUT","TEXTAREA","SELECT"],Sp=new WeakMap;function wp(e){return function e(t,i){if(xp("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||xp("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||xp("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||xp("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);return i.unshift(n),e(t.parentRule,i)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);i.unshift(e)}return i}(e,[])}function kp(e,t,i){let n,s;return e?(e.ownerNode?n=t.getId(e.ownerNode):s=i.getId(e),{styleId:s,id:n}):{}}function Cp({mirror:e,stylesheetManager:t},i){var n,s;let r=null;r=e.getId("#document"===i.nodeName?i:sd.host(i));const o="#document"===i.nodeName?null===(n=i.defaultView)||void 0===n?void 0:n.Document:null===(s=i.ownerDocument)||void 0===s||null===(s=s.defaultView)||void 0===s?void 0:s.ShadowRoot,a=(null==o?void 0:o.prototype)?Object.getOwnPropertyDescriptor(null==o?void 0:o.prototype,"adoptedStyleSheets"):void 0;return null!==r&&-1!==r&&o&&a?(Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var e;return null===(e=a.get)||void 0===e?void 0:e.call(this)},set(e){let i;try{var n;i=null===(n=a.set)||void 0===n?void 0:n.call(this,e)}catch(e){if(e&&"object"==typeof e&&"NotAllowedError"===e.name)return;throw e}if(null!==r&&-1!==r)try{t.adoptStyleSheets(e,r)}catch(e){}return i}}),gp(()=>{Object.defineProperty(i,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})})):()=>{}}var Ep=new Set;function Tp(e,t={}){const i=e.doc.defaultView;if(!i)return()=>{};let n,s;!function(e,t){const{mutationCb:i,mousemoveCb:n,mouseInteractionCb:s,scrollCb:r,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p,customElementCb:g}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),i(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),n(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),s(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),r(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),o(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),g(...e)}}(e,t);const r=[],o=gp(()=>{try{if(s)try{s.destroy(),s.reset()}finally{const e=_p.indexOf(s);-1!==e&&_p.splice(e,1)}e.shadowDomManager.resetForDoc(e.doc),null==n||n.disconnect()}finally{Bh(r)}}),a=(e,t)=>{const i=gp(()=>{try{return t()}catch(t){throw Ep.add(e),t}})();"function"==typeof i&&r.push(i)};try{if(e.recordDOM&&a("mutation",()=>{const t=vp(e,e.doc);n=t.observer,s=t.buffer}),a("move",()=>function({mousemoveCb:e,sampling:t,doc:i,mirror:n}){if(!1===t.mousemove)return()=>{};const s="number"==typeof t.mousemove?t.mousemove:50,r="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let o,a=[];const l=Uh(gp(t=>{const i=Date.now()-o;e(a.map(e=>(e.timeOffset-=i,e)),t),a=[],o=null}),r),c=gp(Uh(gp(e=>{const t=fp(e),{clientX:i,clientY:s}=Xh(e)?e.changedTouches[0]:e;o||(o=Wh()),a.push({x:i,y:s,id:n.getId(t),timeOffset:Wh()-o}),l("drag"===e.type?qu.Drag:"touchmove"===e.type?qu.TouchMove:qu.MouseMove)}),s,{trailing:!1})),u=[Dh("mousemove",c,i),Dh("touchmove",c,i),Dh("drag",c,i)];return gp(()=>{u.forEach(e=>e())})}(e)),a("mouseInteraction",()=>function({mouseInteractionCb:e,doc:t,mirror:i,blockClass:n,blockSelector:s,sampling:r}){if(!1===r.mouseInteraction)return()=>{};const o=!0===r.mouseInteraction||void 0===r.mouseInteraction?{}:r.mouseInteraction,a=[];let l=null;return Object.keys(Hu).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==o[e]).forEach(r=>{let o=Kd(r);const c=(t=>r=>{const o=fp(r);if(Kh(o,n,s,!0))return;let a=null,c=t;if("pointerType"in r){switch(r.pointerType){case"mouse":a=Uu.Mouse;break;case"touch":a=Uu.Touch;break;case"pen":a=Uu.Pen}a===Uu.Touch&&(Hu[t]===Hu.MouseDown?c="TouchStart":Hu[t]===Hu.MouseUp&&(c="TouchEnd"))}else Xh(r)&&(a=Uu.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Uu.Touch||c.startsWith("Mouse")&&a===Uu.Mouse)&&(a=null)):Hu[t]===Hu.Click&&(a=l,l=null);const u=Xh(r)?r.changedTouches[0]:r;if(!u)return;const d=i.getId(o),{clientX:h,clientY:p}=u;gp(e)(ct({type:Hu[c],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(r);if(window.PointerEvent)switch(Hu[r]){case Hu.MouseDown:case Hu.MouseUp:o=o.replace("mouse","pointer");break;case Hu.TouchStart:case Hu.TouchEnd:return}a.push(Dh(o,c,t))}),gp(()=>{a.forEach(e=>e())})}(e)),a("scroll",()=>mp(e)),a("viewportResize",()=>function({viewportResizeCb:e},{win:t}){let i=-1,n=-1;return Dh("resize",gp(Uh(gp(()=>{const t=Vh(),s=Gh();i===t&&n===s||(e({width:Number(s),height:Number(t)}),i=t,n=s)}),200)),t)}(e,{win:i})),a("input",()=>function({inputCb:e,doc:t,mirror:i,blockClass:n,blockSelector:s,ignoreClass:r,ignoreSelector:o,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:u}){function d(e){let i=fp(e);const c=e.isTrusted,d=t.defaultView;if(i&&d&&!(i instanceof d.HTMLElement))return;const p=i&&i.tagName;if(i&&"OPTION"===p&&(i=sd.parentElement(i)),!i||!p||0>bp.indexOf(p)||Kh(i,n,s,!0))return;if(i.classList.contains(r)||o&&i.matches(o))return;let g=i.value,_=!1;const f=Xd(i)||"";"radio"===f||"checkbox"===f?_=i.checked:(a[p.toLowerCase()]||a[f])&&(g=Qd({element:i,maskInputOptions:a,tagName:p,type:f,value:g,maskInputFn:l})),h(i,u?{text:g,isChecked:_,userTriggered:c}:{text:g,isChecked:_});const v=i.name;"radio"===f&&v&&_&&t.querySelectorAll(`input[type="radio"][name="${v}"]`).forEach(e=>{if(e!==i){const t=e.value;h(e,u?{text:t,isChecked:!_,userTriggered:!1}:{text:t,isChecked:!_})}})}function h(t,n){const s=Sp.get(t);if(!s||s.text!==n.text||s.isChecked!==n.isChecked){Sp.set(t,n);const s=i.getId(t);gp(e)(ct(ct({},n),{},{id:s}))}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>Dh(e,gp(d),t)),g=t.defaultView;if(!g)return()=>{p.forEach(e=>e())};const _=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value");return _&&_.set&&p.push(...[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]].map(e=>zh(e[0],e[1],{set(){gp(d)({target:this,isTrusted:!1})}},!1,g))),gp(()=>{Bh(p)})}(e)),a("mediaInteraction",()=>function({mediaInteractionCb:e,blockClass:t,blockSelector:i,mirror:n,sampling:s,doc:r}){const o=gp(r=>Uh(gp(s=>{const o=fp(s);if(!o||Kh(o,t,i,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:u,loop:d}=o;e({type:r,id:n.getId(o),currentTime:a,volume:l,muted:c,playbackRate:u,loop:d})}),s.media||500)),a=[Dh("play",o(Wu.Play),r),Dh("pause",o(Wu.Pause),r),Dh("seeked",o(Wu.Seeked),r),Dh("volumechange",o(Wu.VolumeChange),r),Dh("ratechange",o(Wu.RateChange),r)];return gp(()=>{a.forEach(e=>e())})}(e)),e.recordDOM){const t=function(e){const t=new Map,i=new Set;let n=!0;const s=e=>{if(n)try{e()}catch(e){}},r=e=>{var i;const n=t.get(e);if(n){for(;null===(i=n[0])||void 0===i?void 0:i.ready;){const e=n.shift();(null==e?void 0:e.emit)&&s(e.emit)}0===n.length&&t.delete(e)}};return{queueMutation(e,i){if(!e)return void s(i);const n=t.get(e);n?(n.push({emit:i,ready:!0}),r(e)):s(i)},queuePendingMutation(o,a,l){if(!n)return()=>{};let c=t.get(o);c||(c=[],t.set(o,c));const u={emit:a,ready:!1};c.push(u);let d,h=!1,p=!1;const g=()=>{h||p||(h=!0,void 0!==d&&i.delete(d),u.ready=!0,u.emit=void 0,r(o))};try{d=e.setTimeout(g,5e3),h||p?e.clearTimeout(d):i.add(d)}catch(e){g()}return t=>{!p&&n&&(p=!0,void 0!==d&&(e.clearTimeout(d),i.delete(d)),h?t&&s(l):(u.ready=!0,t||(u.emit=void 0),r(o)))}},reset(){n=!1,i.forEach(t=>e.clearTimeout(t)),i.clear(),t.clear()}}}(i);r.push(t.reset),a("styleSheet",()=>function({styleSheetRuleCb:e,mirror:t,stylesheetManager:i},{win:n,mutationQueue:s}){if(!n.CSSStyleSheet||!n.CSSStyleSheet.prototype)return()=>{};const r=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=new Proxy(r,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=kp(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&s.queueMutation(r,()=>e({id:c,styleId:u,adds:[{rule:a,index:l}]})),l},"host")}),n.CSSStyleSheet.prototype.addRule=function(e,t,i=this.cssRules.length){return n.CSSStyleSheet.prototype.insertRule.apply(this,[`${e} { ${t} }`,i])};const o=n.CSSStyleSheet.prototype.deleteRule;let a,l;n.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=kp(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&s.queueMutation(r,()=>e({id:c,styleId:u,removes:[{index:a}]})),l},"host")}),n.CSSStyleSheet.prototype.removeRule=function(e){return n.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},n.CSSStyleSheet.prototype.replace&&(a=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);try{const n=null==l?void 0:l.then;if(r.ownerNode||!l||"function"!=typeof n)return l;i.onCssomSheetMutation(r);const{id:o,styleId:c}=kp(r,t,i.styleMirror);if(!(o&&-1!==o||c&&-1!==c))return l;const u=s.queuePendingMutation(r,()=>e({id:o,styleId:c,replace:a}),()=>{const t=Bd(r);null!==t&&e({id:o,styleId:c,replace:t})});try{n.call(l,()=>u(!0),()=>u(!1))}catch(e){u(!1)}}catch(e){}return l},"host")})),n.CSSStyleSheet.prototype.replaceSync&&(l=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r);const{id:c,styleId:u}=kp(r,t,i.styleMirror);return(c&&-1!==c||u&&-1!==u)&&s.queueMutation(r,()=>e({id:c,styleId:u,replaceSync:a})),l},"host")}));const c={};Ip("CSSGroupingRule")?c.CSSGroupingRule=n.CSSGroupingRule:(Ip("CSSMediaRule")&&(c.CSSMediaRule=n.CSSMediaRule),Ip("CSSConditionRule")&&(c.CSSConditionRule=n.CSSConditionRule),Ip("CSSSupportsRule")&&(c.CSSSupportsRule=n.CSSSupportsRule));const u={};return Object.entries(c).forEach(([n,r])=>{u[n]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=new Proxy(u[n].insertRule,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=kp(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...wp(r),l];s.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,adds:[{rule:a,index:t}]}))}return l},"host")}),r.prototype.deleteRule=new Proxy(u[n].deleteRule,{apply:gp((n,r,o)=>{const[a]=o,l=n.apply(r,o);i.onCssomSheetMutation(r.parentStyleSheet);const{id:c,styleId:u}=kp(r.parentStyleSheet,t,i.styleMirror);if(r.parentStyleSheet&&(c&&-1!==c||u&&-1!==u)){const t=[...wp(r),a];s.queueMutation(r.parentStyleSheet,()=>e({id:c,styleId:u,removes:[{index:t}]}))}return l},"host")})}),gp(()=>{n.CSSStyleSheet.prototype.insertRule=r,n.CSSStyleSheet.prototype.deleteRule=o,a&&(n.CSSStyleSheet.prototype.replace=a),l&&(n.CSSStyleSheet.prototype.replaceSync=l),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule})})}(e,{win:i,mutationQueue:t})),a("adoptedStyleSheet",()=>Cp(e,e.doc)),a("styleDeclaration",()=>function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:i,stylesheetManager:n},{win:s,mutationQueue:r}){const o=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:gp((s,o,a)=>{var l;const[c,u,d]=a,h=s.apply(o,a);if(i.has(c))return h;const p=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;n.onCssomSheetMutation(p);const{id:g,styleId:_}=kp(p,t,n.styleMirror);if(g&&-1!==g||_&&-1!==_){const t=wp(o.parentRule);r.queueMutation(p,()=>e({id:g,styleId:_,set:{property:c,value:u,priority:d},index:t}))}return h},"host")});const a=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:gp((s,o,a)=>{var l;const[c]=a,u=s.apply(o,a);if(i.has(c))return u;const d=null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet;n.onCssomSheetMutation(d);const{id:h,styleId:p}=kp(d,t,n.styleMirror);if(h&&-1!==h||p&&-1!==p){const t=wp(o.parentRule);r.queueMutation(d,()=>e({id:h,styleId:p,remove:{property:c},index:t}))}return u},"host")}),gp(()=>{s.CSSStyleDeclaration.prototype.setProperty=o,s.CSSStyleDeclaration.prototype.removeProperty=a})}(e,{win:i,mutationQueue:t})),e.collectFonts&&a("font",()=>function({fontCb:e,doc:t}){const i=t.defaultView;if(!i)return()=>{};const n=[],s=new WeakMap,r=i.FontFace;i.FontFace=function(e,t,i){const n=new r(e,t,i);return s.set(n,{family:e,buffer:"string"!=typeof t,descriptors:i,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),n};const o=nd(t.fonts,"add",function(t){return function(i){return setTimeout(gp(()=>{const t=s.get(i);t&&(e(t),s.delete(i))}),0),t.apply(this,[i])}});return n.push(()=>{i.FontFace=r}),n.push(o),gp(()=>{n.forEach(e=>e())})}(e))}a("selection",()=>function(e){const{doc:t,mirror:i,blockClass:n,blockSelector:s,selectionCb:r}=e;let o=!0;const a=gp(()=>{const e=t.getSelection();if(!e||o&&(null==e?void 0:e.isCollapsed))return;o=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;l>t;t++){const{startContainer:r,startOffset:o,endContainer:l,endOffset:c}=e.getRangeAt(t);Kh(r,n,s,!0)||Kh(l,n,s,!0)||a.push({start:i.getId(r),startOffset:o,end:i.getId(l),endOffset:c})}r({ranges:a})});return a(),Dh("selectionchange",a)}(e)),a("customElement",()=>function({doc:e,customElementCb:t}){const i=e.defaultView;return i&&i.customElements?nd(i.customElements,"define",function(e){return function(i,n,s){try{t({define:{name:i}})}catch(e){console.warn(`Custom element callback failed for ${i}`)}return e.apply(this,[i,n,s])}}):()=>{}}(e));for(const t of e.plugins)a(`plugin:${t.name}`,()=>t.observer(t.callback,i,t.options))}catch(e){try{o()}catch(e){}throw e}return o}function xp(e){return void 0!==window[e]}function Ip(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function Rp(e){const t=window;if("function"==typeof t.requestIdleCallback){const i=t.requestIdleCallback(e,{timeout:2e3});return{cancel(){var e;return null===(e=t.cancelIdleCallback)||void 0===e?void 0:e.call(t,i)}}}const i=setTimeout(e,250);return{cancel:()=>clearTimeout(i)}}var Pp=class{constructor(e){Fd(this,"generateIdFn",void 0),Fd(this,"iframeRemoteIdToLocalIdMap",new WeakMap),Fd(this,"iframeLocalIdToRemoteIdMap",new WeakMap),this.generateIdFn=e}getId(e,t,i,n){if(0>t)return t;const s=i||this.getRemoteIdToLocalIdMap(e),r=n||this.getLocalIdToRemoteIdMap(e);let o=s.get(t);return void 0===o&&(o=this.generateIdFn(),s.set(t,o),r.set(o,t)),o}getIds(e,t){const i=this.getRemoteIdToLocalIdMap(e),n=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getId(e,t,i,n))}getRemoteId(e,t,i){var n;return"number"!=typeof t||0>t?t:null!==(n=(i||this.getLocalIdToRemoteIdMap(e)).get(t))&&void 0!==n?n:-1}getRemoteIds(e,t){const i=this.getLocalIdToRemoteIdMap(e);return t.map(t=>this.getRemoteId(e,t,i))}reset(e){if(!e)return this.iframeRemoteIdToLocalIdMap=new WeakMap,void(this.iframeLocalIdToRemoteIdMap=new WeakMap);this.iframeRemoteIdToLocalIdMap.delete(e),this.iframeLocalIdToRemoteIdMap.delete(e)}getRemoteIdToLocalIdMap(e){let t=this.iframeRemoteIdToLocalIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToLocalIdMap.set(e,t)),t}getLocalIdToRemoteIdMap(e){let t=this.iframeLocalIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeLocalIdToRemoteIdMap.set(e,t)),t}},Mp=class{constructor(e){Fd(this,"iframes",new WeakMap),Fd(this,"crossOriginIframeMap",new WeakMap),Fd(this,"crossOriginIframeMirror",new Pp(uh)),Fd(this,"crossOriginIframeStyleMirror",void 0),Fd(this,"crossOriginIframeRootIdMap",new WeakMap),Fd(this,"mirror",void 0),Fd(this,"mutationCb",void 0),Fd(this,"wrappedEmit",void 0),Fd(this,"loadListener",void 0),Fd(this,"pageHideListener",void 0),Fd(this,"stylesheetManager",void 0),Fd(this,"recordCrossOriginIframes",void 0),Fd(this,"messageHandler",void 0),Fd(this,"nestedIframeListeners",new Map),Fd(this,"attachedWindows",new WeakMap),Fd(this,"attachedDocuments",new WeakMap),Fd(this,"attachedIframes",new Map),Fd(this,"loadListenerDisposers",new WeakMap),Fd(this,"iframeElementsById",new Map),Fd(this,"pageHideHandlers",new WeakMap),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Pp(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.messageHandler=this.handleMessage.bind(this),this.recordCrossOriginIframes&&window.addEventListener("message",this.messageHandler)}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}registerLoadListenerDisposer(e,t){let i=this.loadListenerDisposers.get(e);i||(i=new Set,this.loadListenerDisposers.set(e,i)),i.add(t);const n=this.mirror.getId(e);-1!==n&&this.iframeElementsById.set(n,e)}getIframeElementById(e){var t,i,n;return null!==(t=null!==(i=null===(n=this.attachedIframes.get(e))||void 0===n?void 0:n.element)&&void 0!==i?i:this.iframeElementsById.get(e))&&void 0!==t?t:null}forgetIframeId(e){this.attachedIframes.delete(e),this.iframeElementsById.delete(e)}disposeLoadListeners(e){const t=this.loadListenerDisposers.get(e);t&&(t.forEach(e=>Nh(e)),this.loadListenerDisposers.delete(e))}removePageHideListener(e){const t=this.pageHideHandlers.get(e);t&&(t.forEach(({win:e,handler:t})=>{$h(e,"pagehide",t)}),this.pageHideHandlers.delete(e))}addLoadListener(e){this.loadListener=e}addPageHideListener(e){this.pageHideListener=e}removeLoadListener(){this.loadListener=void 0}trackIframeContent(e,t){const i=this.mirror.getId(e);return this.attachedIframes.set(i,{element:e,content:t}),i}attachIframe(e,t){var i;const n=this.trackIframeContent(e,t);if(e.contentDocument){let t=this.attachedDocuments.get(e);t||(t=new Set,this.attachedDocuments.set(e,t)),t.add(e.contentDocument)}this.mutationCb({adds:[{parentId:n,nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0});const s=e.contentWindow;if(this.recordCrossOriginIframes&&s&&!this.nestedIframeListeners.has(s)){const t=this.handleMessage.bind(this);Nh(()=>{s.addEventListener("message",t),this.nestedIframeListeners.set(s,t);let i=this.attachedWindows.get(e);i||(i=new Set,this.attachedWindows.set(e,i)),i.add(s)})}Nh(()=>{const t=e.contentWindow;if(!t)return;let i=this.pageHideHandlers.get(e);if(i)for(const e of i)if(e.win===t)return;const n=()=>{var t;null===(t=this.pageHideListener)||void 0===t||t.call(this,e),e.contentDocument&&this.mirror.removeNodeFromMap(e.contentDocument)};t.addEventListener("pagehide",n),i||(i=new Set,this.pageHideHandlers.set(e,i)),i.add({win:t,handler:n})}),null===(i=this.loadListener)||void 0===i||i.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const i=this.crossOriginIframeMap.get(e.source);if(!i)return;const n=this.transformCrossOriginEvent(i,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}transformCrossOriginEvent(e,t){switch(t.type){case Bu.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const i=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,i),this.patchRootIdOnNode(t.data.node,i),this.trackIframeContent(e,t.data.node),{timestamp:t.timestamp,type:Bu.IncrementalSnapshot,data:{source:qu.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Bu.Meta:case Bu.Load:case Bu.DomContentLoaded:return!1;case Bu.Plugin:return t;case Bu.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Bu.IncrementalSnapshot:switch(t.data.source){case qu.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const i=this.crossOriginIframeRootIdMap.get(e);i&&this.patchRootIdOnNode(t.node,i)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case qu.Drag:case qu.TouchMove:case qu.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case qu.ViewportResize:return!1;case qu.MediaInteraction:case qu.MouseInteraction:case qu.Scroll:case qu.CanvasMutation:case qu.Input:return this.replaceIds(t.data,e,["id"]),t;case qu.StyleSheetRule:case qu.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case qu.Font:return t;case qu.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case qu.AdoptedStyleSheet:var i;return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(i=t.data.styles)||void 0===i||i.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,i,n){for(const s of n)(Array.isArray(t[s])||"number"==typeof t[s])&&(t[s]=Array.isArray(t[s])?e.getIds(i,t[s]):e.getId(i,t[s]));return t}replaceIds(e,t,i){return this.replace(this.crossOriginIframeMirror,e,t,i)}replaceStyleIds(e,t,i){return this.replace(this.crossOriginIframeStyleMirror,e,t,i)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===ju.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}removeIframeById(e){const t=this.attachedIframes.get(e),i=(null==t?void 0:t.element)||this.iframeElementsById.get(e)||this.mirror.getNode(e);if(this.iframeElementsById.delete(e),i){const e=i.contentWindow,t=this.attachedWindows.get(i);t&&(t.forEach(e=>{const t=this.nestedIframeListeners.get(e);t&&($h(e,"message",t),this.nestedIframeListeners.delete(e)),this.crossOriginIframeMap.delete(e)}),this.attachedWindows.delete(i)),e&&this.nestedIframeListeners.has(e)&&($h(e,"message",this.nestedIframeListeners.get(e)),this.nestedIframeListeners.delete(e)),e&&this.crossOriginIframeMap.delete(e),this.iframes.delete(i),this.disposeLoadListeners(i),this.removePageHideListener(i);const n=this.attachedDocuments.get(i);n&&(n.forEach(e=>{Nh(()=>this.mirror.removeNodeFromMap(e))}),Nh(()=>yp(i,n)),this.attachedDocuments.delete(i))}t&&this.attachedIframes.delete(e)}cleanupDetachedIframes(){if(0===this.attachedIframes.size)return;const e=[];this.attachedIframes.forEach((t,i)=>{this.mirror.has(i)||e.push(i)}),e.forEach(e=>this.removeIframeById(e))}reattachIframes(){this.attachedIframes.forEach(({content:e},t)=>{this.mirror.has(t)?this.mutationCb({adds:[{parentId:t,nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}):this.attachedIframes.delete(t)})}destroy(){this.recordCrossOriginIframes&&$h(window,"message",this.messageHandler),this.nestedIframeListeners.forEach((e,t)=>{$h(t,"message",e)}),this.nestedIframeListeners.clear();const e=new Set;this.iframeElementsById.forEach(t=>e.add(t)),this.attachedIframes.forEach(({element:t})=>e.add(t)),e.forEach(e=>{this.disposeLoadListeners(e),this.removePageHideListener(e)}),this.crossOriginIframeMirror.reset(),this.crossOriginIframeStyleMirror.reset(),this.attachedIframes.clear(),this.crossOriginIframeMap=new WeakMap,this.iframes=new WeakMap,this.crossOriginIframeRootIdMap=new WeakMap,this.loadListenerDisposers=new WeakMap,this.pageHideHandlers=new WeakMap,this.attachedDocuments=new WeakMap,this.attachedWindows=new WeakMap,this.iframeElementsById=new Map}},Fp=class{constructor(e){Fd(this,"shadowDoms",new Map),Fd(this,"mutationCb",void 0),Fd(this,"scrollCb",void 0),Fd(this,"bypassOptions",void 0),Fd(this,"mirror",void 0),Fd(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){var i,n;if(!Od(e))return;if(this.shadowDoms.has(e))return;const s=null!==(i=null===(n=sd.host(e))||void 0===n?void 0:n.ownerDocument)&&void 0!==i?i:t,r={doc:s,handlers:[]};this.shadowDoms.set(e,r);const{observer:o,buffer:a}=vp(ct(ct({},this.bypassOptions),{},{doc:s,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);r.handlers.push(()=>{o.disconnect(),a.destroy(),a.releaseCanvasManager();const e=_p.indexOf(a);-1!==e&&_p.splice(e,1)}),r.handlers.push(mp(ct(ct({},this.bypassOptions),{},{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(()=>{this.shadowDoms.get(e)===r&&(e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(sd.host(e))),r.handlers.push(Cp({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)))},0)}removeShadowRootsIn(e){if(0===this.shadowDoms.size)return;const t=sd.shadowRoot(e);t&&(this.shadowDoms.has(t)&&this.removeShadowRoot(t),this.removeShadowRootsIn(t)),sd.childNodes(e).forEach(e=>this.removeShadowRootsIn(e))}removeShadowRoot(e){const t=this.shadowDoms.get(e);this.shadowDoms.delete(e),null==t||t.handlers.forEach(Ap)}observeAttachShadow(e){Nh(()=>{const t=e.contentWindow,i=e.contentDocument;t&&i&&this.patchAttachShadow(t.Element,i)})}patchAttachShadow(e,t){const i=this;this.restoreHandlers.push({doc:t,handler:nd(e.prototype,"attachShadow",function(e){return function(n){const s=e.call(this,n),r=sd.shadowRoot(this);return r&&rp(this)&&i.addShadowRoot(r,t),s}})})}reset(){this.restoreHandlers.forEach(({handler:e})=>Ap(e)),this.restoreHandlers=[];const e=this.shadowDoms;this.shadowDoms=new Map,e.forEach(({handlers:e})=>e.forEach(Ap))}resetForDoc(e){const t=[];for(const i of this.restoreHandlers)i.doc===e?Ap(i.handler):t.push(i);this.restoreHandlers=t,this.shadowDoms.forEach((t,i)=>{t.doc===e&&this.removeShadowRoot(i)})}};function Ap(e){try{e()}catch(e){}}var Lp="skip-frame";function Op(e){if("object"!=typeof e||null===e)return!1;const{x:t,y:i,width:n,height:s}=e;return Number.isFinite(t)&&Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(s)&&n>=0&&s>=0}for(var Dp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$p="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Np=0;64>Np;Np++)$p[Dp.charCodeAt(Np)]=Np;var Bp=function(e){var t,i=new Uint8Array(e),n=i.length,s="";for(t=0;n>t;t+=3)s+=Dp[i[t]>>2],s+=Dp[(3&i[t])<<4|i[t+1]>>4],s+=Dp[(15&i[t+1])<<2|i[t+2]>>6],s+=Dp[63&i[t+2]];return n%3==2?s=s.substring(0,s.length-1)+"=":n%3==1&&(s=s.substring(0,s.length-2)+"=="),s},qp=!1,Hp=new Map,Up=(e,t,i)=>{if(!e||!jp(e,t)&&"object"!=typeof e)return;const n=function(e,t){let i=Hp.get(e);return i||(i=new Map,Hp.set(e,i)),i.has(t)||i.set(t,[]),i.get(t)}(i,e.constructor.name);let s=n.indexOf(e);return-1===s&&(s=n.length,n.push(e)),s};function zp(e,t,i,n){if(e instanceof Array)return e.map(e=>zp(e,t,i,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:Bp(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[zp(e.buffer,t,i,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:i}=e;return{rr_type:t,src:i}}if(e instanceof HTMLCanvasElement){const t="HTMLImageElement";let i;try{i=e.toDataURL(n.type,n.quality)}catch(e){throw function(e){"SecurityError"===(null==e?void 0:e.name)?qp||(qp=!0,console.warn("[replay] canvas capture: skipping a canvas draw because its pixels cannot be read. A cross-origin image or video drawn into it taints it.",e)):console.warn("[replay] canvas capture: skipping a canvas draw because its pixels cannot be read.",e)}(e),e}return{rr_type:t,src:i}}return e instanceof ImageData?{rr_type:e.constructor.name,args:[zp(e.data,t,i,n),e.width,e.height]}:jp(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:Up(e,t,i)}:e}var Wp=(e,t,i,n)=>e.map(e=>zp(e,t,i,n)),jp=(e,t)=>{const i=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(i.find(i=>e instanceof t[i]))},Vp=["webgl","webgl2"];function Gp(e){return"nodeType"in e}function Qp(e,t,i,n){const s=[];try{if(n){const n=function(e,t,i){const n=e.GPUCanvasContext;if((null==n?void 0:n.prototype)&&"function"==typeof n.prototype.configure)return nd(n.prototype,"configure",function(n){return function(s){const r=function(e){const{canvas:t}=e;return t&&"object"==typeof t?t:null}(this);if(!r||Gp(r)&&Kh(r,t,i,!0))return n.call(this,s);Gp(r)&&!("__context"in r)&&(r.__context="webgpu");const o=function(e){const t=e.GPUTextureUsage;return t?t.COPY_SRC|t.RENDER_ATTACHMENT:null}(e);return n.call(this,null!==o&&s?ct(ct({},s),{},{usage:"number"==typeof s.usage?s.usage|o:o}):s)}})}(e,t,i);n&&s.push(n)}const r=nd(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(s,...r){const o=function(e){return"experimental-webgl"===e?"webgl":e}(s);if(!Kh(this,t,i,!0)&&("__context"in this||(this.__context=o),n&&Vp.includes(o)))if(r[0]&&"object"==typeof r[0]){const e=r[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else r.splice(0,1,{preserveDrawingBuffer:!0});return e.apply(this,[s,...r])}});s.push(r)}catch(e){console.warn("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{s.forEach(e=>e())}}function Kp(e,t,i,n,s,r,o){const a=[],l=Object.getOwnPropertyNames(e);for(const c of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const l=nd(e,c,function(e){return function(...a){const l=e.apply(this,a);if(Up(l,r,this),this.canvas&&"tagName"in this.canvas&&!Kh(this.canvas,n,s,!0)){let e;try{e=Wp(a,r,this,o)}catch(e){}e&&i(this.canvas,{type:t,property:c,args:e})}return l}});a.push(l)}catch(r){const o=zh(e,c,{set(e){this.canvas&&"tagName"in this.canvas&&!Kh(this.canvas,n,s,!0)&&i(this.canvas,{type:t,property:c,args:[e],setter:!0})}});a.push(o)}return a}var Jp='(function() {\n\t//#region ../../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/base64-arraybuffer/1.0.2/f63fa6b5c318cf1c9f6bdd1d4292ad2f15f76f2ec78475025a2d44070e896fe9/node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js\n\tvar chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n\tvar lookup = typeof Uint8Array === "undefined" ? [] : /* @__PURE__ */ new Uint8Array(256);\n\tfor (var i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i;\n\tvar encode = function(arraybuffer) {\n\t\tvar bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";\n\t\tfor (i = 0; i < len; i += 3) {\n\t\t\tbase64 += chars[bytes[i] >> 2];\n\t\t\tbase64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];\n\t\t\tbase64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];\n\t\t\tbase64 += chars[bytes[i + 2] & 63];\n\t\t}\n\t\tif (len % 3 === 2) base64 = base64.substring(0, base64.length - 1) + "=";\n\t\telse if (len % 3 === 1) base64 = base64.substring(0, base64.length - 2) + "==";\n\t\treturn base64;\n\t};\n\t//#endregion\n\t//#region ../rrweb/src/record/workers/image-bitmap-data-url-worker.ts\n\tconst lastFingerprintMap = /* @__PURE__ */ new Map();\n\tconst transparentFingerprintMap = /* @__PURE__ */ new Map();\n\tconst lastSentAtMap = /* @__PURE__ */ new Map();\n\tconst PROVIDER_KEYFRAME_INTERVAL_MS = 3e4;\n\tfunction hashPixels(data) {\n\t\tconst view = new Uint32Array(data.buffer, data.byteOffset, data.byteLength >>> 2);\n\t\tlet primaryHash = 2166136261;\n\t\tlet secondaryHash = 2654435769;\n\t\tfor (let i = 0; i < view.length; i++) {\n\t\t\tprimaryHash ^= view[i];\n\t\t\tprimaryHash = Math.imul(primaryHash, 16777619);\n\t\t\tsecondaryHash ^= view[i];\n\t\t\tsecondaryHash = Math.imul(secondaryHash, 2246822507);\n\t\t}\n\t\treturn `${(primaryHash >>> 0).toString(16)}:${(secondaryHash >>> 0).toString(16)}`;\n\t}\n\tfunction frameFingerprint(width, height, data) {\n\t\treturn `${width}x${height}:${hashPixels(data)}`;\n\t}\n\tfunction transparentFingerprint(width, height) {\n\t\tconst pixelCount = width * height;\n\t\tlet hash = transparentFingerprintMap.get(pixelCount);\n\t\tif (hash === void 0) {\n\t\t\thash = hashPixels(new Uint8ClampedArray(pixelCount * 4));\n\t\t\ttransparentFingerprintMap.set(pixelCount, hash);\n\t\t}\n\t\treturn `${width}x${height}:${hash}`;\n\t}\n\tconst worker = self;\n\tlet reusableCanvas = null;\n\tlet reusableCtx = null;\n\tworker.onmessage = async function(e) {\n\t\tif ("resetFrameDedup" in e.data) {\n\t\t\tlastFingerprintMap.clear();\n\t\t\treturn;\n\t\t}\n\t\tif ("OffscreenCanvas" in globalThis) {\n\t\t\tconst { id, bitmap, width, height, displayWidth, displayHeight, dataURLOptions, maskRegions } = e.data;\n\t\t\ttry {\n\t\t\t\tif (!reusableCanvas || reusableCanvas.width !== width || reusableCanvas.height !== height) {\n\t\t\t\t\treusableCanvas = new OffscreenCanvas(width, height);\n\t\t\t\t\treusableCtx = reusableCanvas.getContext("2d", { willReadFrequently: true });\n\t\t\t\t}\n\t\t\t\tconst ctx = reusableCtx;\n\t\t\t\tctx.clearRect(0, 0, width, height);\n\t\t\t\tctx.drawImage(bitmap, 0, 0);\n\t\t\t\tbitmap.close();\n\t\t\t\tif (maskRegions) {\n\t\t\t\t\tctx.fillStyle = "black";\n\t\t\t\t\tfor (const region of maskRegions) ctx.fillRect(region.x, region.y, region.width, region.height);\n\t\t\t\t}\n\t\t\t\tconst fingerprint = frameFingerprint(width, height, ctx.getImageData(0, 0, width, height).data);\n\t\t\t\tif (fingerprint === (lastFingerprintMap.get(id) ?? transparentFingerprint(width, height))) {\n\t\t\t\t\tconst lastSentAt = lastSentAtMap.get(id);\n\t\t\t\t\tif (!(maskRegions !== void 0 && lastSentAt !== void 0 && Date.now() - lastSentAt >= PROVIDER_KEYFRAME_INTERVAL_MS)) return worker.postMessage({ id });\n\t\t\t\t}\n\t\t\t\tconst blob = await reusableCanvas.convertToBlob(dataURLOptions);\n\t\t\t\tconst arrayBuffer = await blob.arrayBuffer();\n\t\t\t\tworker.postMessage({\n\t\t\t\t\tid,\n\t\t\t\t\ttype: blob.type,\n\t\t\t\t\tbase64: encode(arrayBuffer),\n\t\t\t\t\tdisplayWidth,\n\t\t\t\t\tdisplayHeight\n\t\t\t\t});\n\t\t\t\tlastFingerprintMap.set(id, fingerprint);\n\t\t\t\tlastSentAtMap.set(id, Date.now());\n\t\t\t} catch {\n\t\t\t\tworker.postMessage({ id });\n\t\t\t}\n\t\t} else {\n\t\t\te.data.bitmap.close();\n\t\t\treturn worker.postMessage({ id: e.data.id });\n\t\t}\n\t};\n\t//#endregion\n})();\n',Yp="undefined"!=typeof self&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Jp],{type:"text/javascript;charset=utf-8"});function Zp(e){let t;try{if(t=Yp&&(self.URL||self.webkitURL).createObjectURL(Yp),!t)throw"";const i=new Worker(t,{name:null==e?void 0:e.name});return i.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),i}catch(t){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Jp),{name:null==e?void 0:e.name})}}var Xp="A page CSP that omits blob: from worker-src or script-src blocks it";function eg(e,...t){console.warn(`[replay] canvas capture: ${e}`,...t)}var tg=class{onFullSnapshot(){var e;null===(e=this.resetFrameDedup)||void 0===e||e.call(this)}acquire(){this.refCount+=1}reset(){this.refCount>0&&(this.refCount-=1),this.refCount>0||this.teardown()}teardown(){this.torndown||(this.torndown=!0,this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers(),null!==this.rafIdTimestamp&&(cancelAnimationFrame(this.rafIdTimestamp),this.rafIdTimestamp=null),null!==this.rafIdFlush&&(cancelAnimationFrame(this.rafIdFlush),this.rafIdFlush=null))}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){Fd(this,"pendingCanvasMutations",new Map),Fd(this,"rafStamps",{latestId:0,invokeId:null}),Fd(this,"mirror",void 0),Fd(this,"mutationCb",void 0),Fd(this,"resetObservers",void 0),Fd(this,"frozen",!1),Fd(this,"locked",!1),Fd(this,"rafIdTimestamp",null),Fd(this,"rafIdFlush",null),Fd(this,"refCount",0),Fd(this,"torndown",!1),Fd(this,"resetFrameDedup",null),Fd(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:i,blockClass:n,blockSelector:s,recordCanvas:r,dataURLOptions:o,resolutionScale:a,canvasMasking:l}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,r&&"all"===t&&this.initCanvasMutationObserver(i,n,s,o),r&&"number"==typeof t&&this.initCanvasFPSObserver(t,i,n,s,{dataURLOptions:o,resolutionScale:a,canvasMasking:l})}initCanvasFPSObserver(e,t,i,n,s){var r=this;if(!("OffscreenCanvas"in t))return void eg("disabled because this browser does not support OffscreenCanvas");const o="number"==typeof s.resolutionScale&&Number.isFinite(s.resolutionScale)?Math.min(1,Math.max(.1,s.resolutionScale)):1,a=Qp(t,i,n,!0),l=new Map;let c;try{c=new Zp}catch(e){return eg(`disabled because the encode worker did not start. ${Xp}`,e),void a()}let u=!1;c.onerror=e=>{var t;u=!0,eg(`stopped because the encode worker failed. ${Xp}`,e),cancelAnimationFrame(g),null===(t=c.terminate)||void 0===t||t.call(c),this.resetFrameDedup=null},this.resetFrameDedup=()=>{c.postMessage({resetFrameDedup:!0})},c.onmessage=e=>{const{id:t}=e.data;if(l.set(t,!1),!("base64"in e.data))return;const{base64:i,type:n,displayWidth:s,displayHeight:r}=e.data;this.mutationCb({id:t,type:zu["2D"],commands:[{property:"clearRect",args:[0,0,s,r]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:i}],type:n}]},0,0,s,r]}],displayWidth:s,displayHeight:r})};let d=!1,h=!1;const p=1e3/e;let g,_=0;const f=e=>{var a;u||(_&&p>e-_||(_=e,(()=>{const e=[],s=t=>{try{t.querySelectorAll("canvas").forEach(t=>{Kh(t,i,n,!0)||e.push(t)}),t.querySelectorAll("*").forEach(e=>{e.shadowRoot&&s(e.shadowRoot)})}catch(e){}};return s(t.document),e})().forEach((a=rt(function*(e){const t=r.mirror.getId(e);if(-1!==t&&!l.get(t)&&0!==e.width&&0!==e.height){l.set(t,!0);try{if(["webgl","webgl2"].includes(e.__context)){var i,n;const s=e.getContext(e.__context);if(null==s||null===(i=s.isContextLost)||void 0===i?void 0:i.call(s))return void l.set(t,!1);!1===(null==s||null===(n=s.getContextAttributes())||void 0===n?void 0:n.preserveDrawingBuffer)&&s.clear(s.COLOR_BUFFER_BIT)}const r=e.clientWidth||e.width,a=e.clientHeight||e.height,u=Math.max(1,Math.round(r*o)),h=Math.max(1,Math.round(a*o)),p=function(e,t,i,n,s,r){if(!e||"function"!=typeof e.regionsFn)return;let o;try{o=e.regionsFn(t)}catch(e){return Lp}if(void 0===o)return;if(!Array.isArray(o)||!o.every(Op))return Lp;const a=i/s,l=n/r;return o.filter(e=>e.width>0&&e.height>0).map(e=>{const t=Math.floor(e.x*a),i=Math.floor(e.y*l);return{x:t,y:i,width:Math.ceil((e.x+e.width)*a)-t,height:Math.ceil((e.y+e.height)*l)-i}})}(s.canvasMasking,e,u,h,r,a);if("skip-frame"===p)return d||(d=!0,eg("dropped a frame because the mask provider did not return valid regions. A provider that always fails records no canvas frames at all")),void l.set(t,!1);const g=yield createImageBitmap(e,1>o?{resizeWidth:u,resizeHeight:h,resizeQuality:"medium"}:{resizeWidth:u,resizeHeight:h});c.postMessage({id:t,bitmap:g,width:u,height:h,displayWidth:r,displayHeight:a,dataURLOptions:s.dataURLOptions,maskRegions:p},[g])}catch(e){h||(h=!0,eg("dropped a frame because the snapshot failed. A canvas that fails every frame records no canvas frames at all",e)),l.set(t,!1)}}}),function(e){return a.apply(this,arguments)}))),g=requestAnimationFrame(f))};g=requestAnimationFrame(f),this.resetObservers=()=>{var e;a(),cancelAnimationFrame(g),null===(e=c.terminate)||void 0===e||e.call(c),this.resetFrameDedup=null}}initCanvasMutationObserver(e,t,i,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const s=Qp(e,t,i,!1),r=function(e,t,i,n,s){const r=[],o=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const a of o)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[a])continue;const o=nd(t.CanvasRenderingContext2D.prototype,a,function(r){return function(...o){return Kh(this.canvas,i,n,!0)||setTimeout(()=>{let i;try{i=Wp(o,t,this,s)}catch(e){return}e(this.canvas,{type:zu["2D"],property:a,args:i})},0),r.apply(this,o)}});r.push(o)}catch(s){const o=zh(t.CanvasRenderingContext2D.prototype,a,{set(t){Kh(this.canvas,i,n,!0)||e(this.canvas,{type:zu["2D"],property:a,args:[t],setter:!0})}});r.push(o)}return()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,n),o=function(e,t,i,n,s){const r=[];return void 0!==t.WebGLRenderingContext&&r.push(...Kp(t.WebGLRenderingContext.prototype,zu.WebGL,e,i,n,t,s)),void 0!==t.WebGL2RenderingContext&&r.push(...Kp(t.WebGL2RenderingContext.prototype,zu.WebGL2,e,i,n,t,s)),()=>{r.forEach(e=>e())}}(this.processMutation.bind(this),e,t,i,n);this.resetObservers=()=>{s(),r(),o()}}startPendingCanvasMutationFlusher(){this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,this.rafIdTimestamp=requestAnimationFrame(e)};this.rafIdTimestamp=requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const i=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,i)}),this.rafIdFlush=requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const i=this.pendingCanvasMutations.get(e);if(!i||-1===t)return;const n=i.map(e=>ys(e,Nu)),{type:s}=i[0];this.mutationCb({id:t,type:s,commands:n}),this.pendingCanvasMutations.delete(e)}};function ig(e){var t,i,n;const s={};for(const n of Object.keys(null!==(t=null===(i=e.previous)||void 0===i?void 0:i.attributes)&&void 0!==t?t:{}))s[n]=null;return Object.assign(s,null===(n=e.current)||void 0===n?void 0:n.attributes),delete s.rel,delete s.href,s}var ng,sg,rg,og=class{constructor(e){var t,i,n;Fd(this,"trackedLinkElements",new WeakSet),Fd(this,"pendingDeferredSheets",new Set),Fd(this,"stopped",!1),Fd(this,"changedLinkJobs",new Map),Fd(this,"linksInlinedSinceSnapshot",new WeakSet),Fd(this,"mutationCb",void 0),Fd(this,"adoptedStyleSheetCb",void 0),Fd(this,"maskAllElementAttributes",void 0),Fd(this,"maskAttributeFn",void 0),Fd(this,"blockClass",void 0),Fd(this,"blockSelector",void 0),Fd(this,"styleMirror",new np),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb,this.maskAllElementAttributes=null!==(t=e.maskAllElementAttributes)&&void 0!==t&&t,this.maskAttributeFn=e.maskAttributeFn,this.blockClass=null!==(i=e.blockClass)&&void 0!==i?i:"rr-block",this.blockSelector=null!==(n=e.blockSelector)&&void 0!==n?n:null}isLinkBlocked(e){return Jh(e,this.blockClass,this.blockSelector)}attachLinkElement(e,t,i=null){this.stopped||!("_cssText"in t.attributes)||this.isLinkBlocked(e)||(this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:ig({previous:i,current:t})}]}),this.linksInlinedSinceSnapshot.add(e)),this.trackLinkElement(e)}beginDeferredLinkInlining(e,t,i={}){var n;const s=null!==(n=i.emitCssText)&&void 0!==n?n:i=>this.emitCssTextMutation(e,t,i);if(-1===t||!e.isConnected)return null;let r=null,o=null;try{o=e.sheet,o&&(r=Vd(o))}catch(e){}var a;if(!r||!o)return Rd(),null===(a=i.onUninlinable)||void 0===a||a.call(i),null;const l=r;let c=!1;const u={sheet:o,invalidate(){c=!0}};this.pendingDeferredSheets.add(u);let d=!1;return{advance:t=>{if(d)return!0;const n=rd(),r=ld();let a=!0;try{if(c)return d=!0,i.onInvalidatedBySheetMutation?i.onInvalidatedBySheetMutation():Rd(),!0;if(!l.advance(t))return a=!1,!1;d=!0;const n=l.text();if(!e.isConnected)return!0;let r=null;try{r=e.sheet}catch(e){}return r!==o?(Rd(),!0):n?(this.isLinkBlocked(e)||s(n),!0):(Rd(),null===(h=i.onUninlinable)||void 0===h||h.call(i),!0);var h}finally{a&&this.pendingDeferredSheets.delete(u),cd(p=rd()-n,null!=(g=r)?g:od)||(bd.totalMs+=p,p>bd.slowestSliceMs&&(bd.slowestSliceMs=p))}var p,g},remainingRules:()=>l.remainingRules(),discard:()=>{this.pendingDeferredSheets.delete(u)}}}onCssomSheetMutation(e){if(e&&0!==this.pendingDeferredSheets.size)for(const t of this.pendingDeferredSheets)t.sheet===e&&(this.pendingDeferredSheets.delete(t),t.invalidate())}inlineLinkStylesheetAfterChange(e,t){this.stopped||-1===t.currentId()||function(e,t){const i=Th(e),n=Ch.get(e);if(n)return void(n.changedLinkBaseline&&(n.changedLinkBaseline.sheetAtLatestChange=i));const s={sheetAtLatestChange:i},r=()=>{const t=Th(e);return Boolean(t&&(t!==s.sheetAtLatestChange||t.href===e.href))};r()?t():xh(e,t,r,Ih,s)}(e,()=>this.inlineChangedLinkStylesheet(e,t,3))}inlineChangedLinkStylesheet(e,t,i){var n;const s=t.currentId();if(this.stopped||!e.isConnected||-1===s||this.isLinkBlocked(e))return;null===(n=this.changedLinkJobs.get(e))||void 0===n||n.drop();let r=!1;const o=this.beginDeferredLinkInlining(e,s,{emitCssText:i=>this.emitCssTextMutation(e,s,i,ig(t.reserializeWithoutCss())),onInvalidatedBySheetMutation(){r=!0},onUninlinable:()=>this.readdAsPlainLink(e,t)});if(!o)return;let a=null;const l=()=>{o.discard(),null==a||a.cancel(),a=null,this.changedLinkJobs.get(e)===c&&this.changedLinkJobs.delete(e)},c={remainingRules:()=>o.remainingRules(),runSlice:()=>{try{return this.stopped||this.changedLinkJobs.get(e)!==c||-1===t.currentId()||this.isLinkBlocked(e)?(l(),!0):!!o.advance(200)&&(l(),!r||(i>0?this.inlineChangedLinkStylesheet(e,t,i-1):Rd(),!0))}catch(e){return l(),!0}},drop:l};this.changedLinkJobs.set(e,c);const u=e=>{a=null;let t,i=0;do{t=c.runSlice(),i+=1}while(!t&&(e?!e.didTimeout&&e.timeRemaining()>5:10>i));t||(a=Rp(u))};a=Rp(u)}flushChangedLinkInlining(e){let t=0;for(const i of this.changedLinkJobs.values()){let n=!1;for(;!n;){if(Math.floor(i.remainingRules()/200)+1>e-t){i.drop(),Pd(1);break}n=i.runSlice(),t+=1}}return t}inlineDeferredLinkElement(e,t){var i;null===(i=this.beginDeferredLinkInlining(e,t))||void 0===i||i.advance(1/0)}emitCssTextMutation(e,t,i,n={}){this.stopped||(this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t,attributes:ct(ct({},n),{},{_cssText:Yd({element:e,name:"_cssText",value:i,maskAllElementAttributes:this.maskAllElementAttributes,maskAttributeFn:this.maskAttributeFn})})}]}),this.linksInlinedSinceSnapshot.add(e))}readdAsPlainLink(e,t){try{var i,n;if(this.stopped||!e.isConnected||this.isLinkBlocked(e))return;if(!this.linksInlinedSinceSnapshot.has(e)&&!("_cssText"in(null!==(i=null===(n=t.lastSerialization())||void 0===n?void 0:n.attributes)&&void 0!==i?i:{})))return;this.linksInlinedSinceSnapshot.delete(e),t.readdAsMove()}catch(e){}}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const i={id:t,styleIds:[]},n=[];for(const t of e){let e;if(this.styleMirror.has(t))e=this.styleMirror.getId(t);else{const i=this.styleMirror.add(t);e=i;const s=rd();try{Ed(()=>{try{const e=t.rules||t.cssRules;e&&Cd(e)}catch(e){}n.push({styleId:i,rules:Array.from(t.rules||CSSRule,(e,i)=>({rule:qd(e,t.href),index:i}))})})}finally{Td(rd()-s)}}i.styleIds.push(e)}n.length>0&&(i.styles=n),this.adoptedStyleSheetCb(i)}stop(){this.stopped=!0,this.dropChangedLinkJobs(),Eh()}dropChangedLinkJobs(){Array.from(this.changedLinkJobs.values()).forEach(e=>e.drop())}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet,this.pendingDeferredSheets.clear(),this.dropChangedLinkJobs(),this.linksInlinedSinceSnapshot=new WeakSet,Eh({keepChangedLinks:!0})}trackStylesheetInLinkElement(e){}},ag=class{constructor(){Fd(this,"nodeMap",new WeakMap),Fd(this,"active",!1)}inOtherBuffer(e,t){const i=this.nodeMap.get(e);return i&&Array.from(i).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},lg=!1;try{if(2!==Array.from([1],e=>2*e)[0]){var cg;const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null===(cg=e.contentWindow)||void 0===cg?void 0:cg.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}var ug=new Gd,dg=new Set([qu.Mutation,qu.MediaInteraction,qu.StyleSheetRule,qu.CanvasMutation,qu.Font,qu.Log,qu.StyleDeclaration,qu.AdoptedStyleSheet]);function hg(e={}){let t,i=!1,n=!1;const{emit:s,checkoutEveryNms:r,checkoutEveryNth:o,blockClass:a="rr-block",blockSelector:l=null,ignoreClass:c="rr-ignore",ignoreSelector:u=null,maskTextClass:d="rr-mask",maskTextSelector:h=null,inlineStylesheet:p=!0,inlineStylesheetBudgetRules:g,maskAllInputs:_,maskInputOptions:f,slimDOMOptions:v,maskInputFn:m,maskTextFn:y,maskAllElementAttributes:b=!1,maskAttributeFn:S,hooks:w,packFn:k,sampling:C={},dataURLOptions:E={},canvasResolutionScale:T,canvasMasking:x,mousemoveWait:I,recordDOM:R=!0,recordCanvas:P=!1,recordCrossOriginIframes:M=!1,recordAfter:F=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:A=!1,collectFonts:L=!1,inlineImages:O=!1,plugins:D,keepIframeSrcFn:N=()=>!1,ignoreCSSAttributes:B=new Set([]),attributeFilter:q,errorHandler:H}=e;hp(H);const U=ct({type:"image/webp",quality:.4,maxBase64ImageLength:1048576},E),z=!M||window.parent===window;let W=!1;if(!z)try{window.parent.document&&(W=!1)}catch(e){W=!0}if(z&&!s)throw new Error("emit function is required");if(!z&&!W)return()=>{};void 0!==I&&void 0===C.mousemove&&(C.mousemove=I),ug.reset(),Eh();const j=!0===_?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0,hidden:!0}:void 0!==f?f:{password:!0},V=Lh(void 0!==v&&v);let G;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=[].forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=[].forEach)}();let Q=0;const K=new Map;let J,Y;const Z=e=>{for(const t of D||[])t.eventProcessor&&(e=t.eventProcessor(e));return k&&!W&&(e=k(e)),e};ng=(e,t)=>{var i;const n=e;if(n.timestamp=Wh(),!(null===(i=_p[0])||void 0===i?void 0:i.isFrozen())||n.type===Bu.FullSnapshot||n.type===Bu.IncrementalSnapshot&&dg.has(n.data.source)||_p.forEach(e=>e.unfreeze()),z)null==s||s(Z(n),t);else if(W){const e={type:"rrweb",event:Z(n),origin:window.location.origin,isCheckout:t};window.parent.postMessage(e,"*")}if(n.type===Bu.FullSnapshot)G=n,Q=0;else if(n.type===Bu.IncrementalSnapshot){if(n.data.source===qu.Mutation&&n.data.isAttachIframe)return;Q++,(o&&Q>=o||r&&n.timestamp-G.timestamp>r)&&sg(!0)}};const X=e=>{if(e.removes&&e.removes.length>0){const t=e.adds.length>0?new Set(e.adds.map(e=>e.node.id)):null,i=new Set;if(e.adds.length>0)for(const t of e.adds){const e=ug.getNode(t.node.id);e&&"IFRAME"===e.nodeName&&i.add(e)}e.removes.forEach(({id:e})=>{if(t&&t.has(e))return;const n=re.getIframeElementById(e);n&&i.has(n)?re.forgetIframeId(e):(null==J||J(e),re.removeIframeById(e))}),null==Y||Y(),re.cleanupDetachedIframes()}ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Mutation},e)})},ee=e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Scroll},e)}),te=e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.CanvasMutation},e)}),ie=new og({mutationCb:X,adoptedStyleSheetCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.AdoptedStyleSheet},e)}),maskAllElementAttributes:b,maskAttributeFn:S,blockClass:a,blockSelector:l});let ne=!1;const se=()=>{if(!ne){ne=!0;try{var e;const i=null!==(e=null==t?void 0:t.flush())&&void 0!==e?e:0;ie.flushChangedLinkInlining(50-i)}finally{ne=!1}}},re=new Mp({mirror:ug,mutationCb:X,stylesheetManager:ie,recordCrossOriginIframes:M,wrappedEmit:ng});for(const e of D||[])e.getMirror&&e.getMirror({nodeMirror:ug,crossOriginIframeMirror:re.crossOriginIframeMirror,crossOriginIframeStyleMirror:re.crossOriginIframeStyleMirror});const oe=new ag,ae=null==x?void 0:x.configured;rg=new tg({recordCanvas:P,mutationCb:te,win:window,blockClass:a,blockSelector:l,mirror:ug,sampling:C.canvas,dataURLOptions:U,resolutionScale:T,canvasMasking:x});const le=new Fp({mutationCb:X,scrollCb:ee,bypassOptions:{blockClass:a,blockSelector:l,maskTextClass:d,maskTextSelector:h,inlineStylesheet:p,maskInputOptions:j,dataURLOptions:U,maskTextFn:y,maskInputFn:m,maskAllElementAttributes:b,maskAttributeFn:S,recordCanvas:P,canvasMaskingConfigured:ae,inlineImages:O,sampling:C,slimDOMOptions:V,iframeManager:re,stylesheetManager:ie,canvasManager:rg,keepIframeSrcFn:N,processedNodeManager:oe,attributeFilter:q},mirror:ug});sg=(e=!1)=>{if(R){Sd(g);try{if(ng({type:Bu.Meta,data:{href:window.location.href,width:Gh(),height:Vh()}},e),i)return;null==t||t.cancel(),t=void 0,ie.reset(),le.init(),_p.forEach(e=>e.lock());let n=null,s=[];try{n=function(e,t){const{mirror:i=new Gd,blockClass:n="rr-block",blockSelector:s=null,maskTextClass:r="rr-mask",maskTextSelector:o=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,canvasMaskingConfigured:u,maskAllInputs:d=!1,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:g=!1,maskAttributeFn:_,slimDOM:f=!1,dataURLOptions:v,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E=()=>!1,maxDepth:T,inlineStylesheetBudgetRules:x}=t||{},I=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0,hidden:!0}:!1===d?{password:!0}:d,R=Lh(f);Sd(x);try{return Ah(e,{doc:e,mirror:i,blockClass:n,blockSelector:s,maskTextClass:r,maskTextSelector:o,skipChild:!1,inlineStylesheet:a,maskInputOptions:I,maskTextFn:h,maskInputFn:p,maskAllElementAttributes:g,maskAttributeFn:_,slimDOMOptions:R,dataURLOptions:v,inlineImages:l,recordCanvas:c,canvasMaskingConfigured:u,preserveWhiteSpace:m,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:S,onIframeListenerRegistered:w,onStylesheetLoad:k,stylesheetLoadTimeout:C,keepIframeSrcFn:E,newlyAddedElement:!1,maxDepth:T})}finally{wd()}}(document,{mirror:ug,blockClass:a,blockSelector:l,maskTextClass:d,maskTextSelector:h,inlineStylesheet:p,maskAllInputs:j,inlineStylesheetBudgetRules:g,maskTextFn:y,maskInputFn:m,maskAllElementAttributes:b,maskAttributeFn:S,slimDOM:V,dataURLOptions:U,recordCanvas:P,canvasMaskingConfigured:ae,inlineImages:O,onSerialize(e){ep(e,ug)&&re.addIframe(e),tp(e,ug)&&ie.trackLinkElement(e),ip(e)&&le.addShadowRoot(sd.shadowRoot(e),document)},onIframeLoad(e,t){re.attachIframe(e,t),le.observeAttachShadow(e)},onIframeListenerRegistered(e,t){re.registerLoadListenerDisposer(e,t)},onStylesheetLoad(e,t,i){ie.attachLinkElement(e,t,i)},keepIframeSrcFn:N})}finally{s=Id()}if(i)return;if(!n)return console.warn("Failed to snapshot the document");if(ng({type:Bu.FullSnapshot,data:{node:n,initialOffset:jh(window)}},e),i)return;if(_p.forEach(e=>e.unlock()),rg.onFullSnapshot(),s.length){const e=function(e,t,i){let n=!1,s=null,r=0,o=null;const a=()=>null!==o||e.length>r,l=()=>{const i=e[r];e[r]=null,r+=1,i&&Nh(()=>{o=t.beginDeferredLinkInlining(i,ug.getId(i))})},c=()=>{if(!o)return;const e=o;let t=!0;Nh(()=>{t=e.advance(200)}),t&&(o=null)},u=()=>{o||l(),c()},d=e=>{if(s=null,n)return;let t=0;do{try{u()}catch(e){null==o||o.discard(),o=null,Pd(1)}t+=1}while(!n&&a()&&(e?!e.didTimeout&&e.timeRemaining()>5:10>t));n||(a()?s=Rp(d):i())};return s=Rp(d),{cancel(){n=!0,null==o||o.discard(),o=null,null==s||s.cancel(),s=null},flush(){if(n)return 0;n=!0,null==s||s.cancel(),s=null;let t=0,u=0;for(;a()&&50>t;){o||l();const e=o;if(e)if(Math.floor(e.remainingRules()/200)+1>50-t)e.discard(),o=null,u+=1;else{try{c()}catch(e){null==o||o.discard(),o=null,u+=1}t+=1}}if(a()||u>0){let t=u+(null!==o?1:0);for(let i=r;e.length>i;i++)null!==e[i]&&(t+=1);Pd(t),null==o||o.discard(),o=null}return i(),t}}}(s,ie,()=>{t===e&&(t=void 0)});t=e}M&&re.reattachIframes(),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&ie.adoptStyleSheets(document.adoptedStyleSheets,ug.getId(document))}finally{wd()}}};try{const e=[];e.push(Dh("pagehide",()=>{try{se()}catch(e){}t=void 0},window));for(const t of["visibilitychange","freeze","resume"])e.push(Dh(t,ad,document));J=t=>{const i=K.get(t);i&&(i.forEach(t=>{Nh(t);const i=e.indexOf(t);-1!==i&&e.splice(i,1)}),K.delete(t))},Y=()=>{for(const[e]of K){const t=ug.getNode(e);if(t)try{t.contentDocument&&t.contentDocument.defaultView||null==J||J(e)}catch(t){null==J||J(e)}else null==J||J(e)}};const s=e=>{var t;return gp(Tp)({mutationCb:X,mousemoveCb:(e,t)=>ng({type:Bu.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.MouseInteraction},e)}),scrollCb:ee,viewportResizeCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.ViewportResize},e)}),inputCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Input},e)}),mediaInteractionCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.MediaInteraction},e)}),styleSheetRuleCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.StyleSheetRule},e)}),styleDeclarationCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.StyleDeclaration},e)}),canvasMutationCb:te,fontCb:e=>ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Font},e)}),selectionCb(e){ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.Selection},e)})},customElementCb(e){ng({type:Bu.IncrementalSnapshot,data:ct({source:qu.CustomElement},e)})},blockClass:a,ignoreClass:c,ignoreSelector:u,maskTextClass:d,maskTextSelector:h,maskInputOptions:j,inlineStylesheet:p,sampling:C,recordDOM:R,recordCanvas:P,canvasMaskingConfigured:ae,inlineImages:O,userTriggeredOnInput:A,collectFonts:L,doc:e,maskInputFn:m,maskTextFn:y,maskAllElementAttributes:b,maskAttributeFn:S,keepIframeSrcFn:N,blockSelector:l,slimDOMOptions:V,dataURLOptions:U,mirror:ug,iframeManager:re,stylesheetManager:ie,shadowDomManager:le,processedNodeManager:oe,canvasManager:rg,ignoreCSSAttributes:B,attributeFilter:q,plugins:(null==D||null===(t=D.filter(e=>e.observer))||void 0===t?void 0:t.map(e=>({name:e.name,observer:e.observer,options:e.options,callback:t=>ng({type:Bu.Plugin,data:{plugin:e.name,payload:t}})})))||[]},w)},r=new WeakMap,o=new WeakMap;re.addLoadListener(t=>{try{const i=t.contentDocument,n=ug.getId(t);if(!i)return;const a=o.get(t);if(a){o.delete(t),Nh(a);const i=e.indexOf(a);-1!==i&&e.splice(i,1)}const l=r.get(i);if(-1!==n&&l){if(l())return;null==J||J(n)}const c=s(i);if("function"==typeof c){let s=!1;const a=Dh("rrweb-check-iframe-observers",()=>{s=!0},i);-1!==n&&r.set(i,()=>{s=!1;const e=i.createEvent("Event");return e.initEvent("rrweb-check-iframe-observers",!1,!1),i.dispatchEvent(e),s});const l=()=>{r.delete(i),a(),c()};if(e.push(l),-1!==n){let e=K.get(n);e||(e=new Set,K.set(n,e)),e.add(l)}else o.set(t,l)}}catch(e){console.warn(e)}}),re.addPageHideListener(e=>{const t=ug.getId(e);null==J||J(t),yp(e)});let g=-1;const _=e=>ng({type:Bu.Custom,data:{tag:"rrweb/fullscreen",payload:e}}),f=()=>{var e,t,i,n;const s=document,r=null!==(e=null!==(t=null!==(i=null!==(n=s.fullscreenElement)&&void 0!==n?n:s.webkitFullscreenElement)&&void 0!==i?i:s.mozFullScreenElement)&&void 0!==t?t:s.msFullscreenElement)&&void 0!==e?e:null,o=r?ug.getId(r):-1;o!==g&&(-1!==g&&_({id:g,enter:!1}),g=o,-1!==o&&_({id:o,enter:!0}))},v=()=>{if(i||n)return;if(n=!0,sg(),i)return;const t=s(document);i?"function"==typeof t&&Bh([t]):("function"==typeof t&&e.push(t),e.push(Dh("fullscreenchange",f)),e.push(Dh("webkitfullscreenchange",f)),e.push(Dh("mozfullscreenchange",f)),e.push(Dh("MSFullscreenChange",f)),lg=!0)};return["interactive","complete"].includes(document.readyState)?v():(e.push(Dh("DOMContentLoaded",()=>{ng({type:Bu.DomContentLoaded,data:{}}),"DOMContentLoaded"===F&&setTimeout(v,0)})),e.push(Dh("load",()=>{ng({type:Bu.Load,data:{}}),"load"===F&&v()},window))),()=>{i=!0;try{se()}catch(e){}t=void 0,ie.stop(),Bh(e),oe.destroy(),re.removeLoadListener(),re.destroy(),K.clear(),le.reset(),ug.reset(),lg=!1,pp()}}catch(e){console.warn(e)}}hg.addCustomEvent=(e,t)=>{if(!lg)throw new Error("please add custom event after start recording");ng({type:Bu.Custom,data:{tag:e,payload:t}})},hg.freezePage=()=>{_p.forEach(e=>e.freeze())},hg.takeFullSnapshot=e=>{if(!lg)throw new Error("please take full snapshot after start recording");sg(e)},hg.isRecording=()=>lg,hg.mirror=ug,Date,Date;var pg=Object.create(null);function gg(e){return gg="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gg(e)}function _g(e,t,i){return(t=function(e){var t=function(e){if("object"!=gg(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=gg(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gg(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}pg.Node=Object.create(null),pg.ShadowRoot=Object.create(null),pg.MutationObserver=Object.create(null),pg.Element=Object.create(null);var fg=class{constructor(e){_g(this,"fileName",void 0),_g(this,"functionName",void 0),_g(this,"lineNumber",void 0),_g(this,"columnNumber",void 0),this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}toString(){const e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?`${this.functionName} (${this.fileName}:${e}:${t})`:`${this.fileName}:${e}:${t}`}},vg=/(^|@)\S+:\d+/,mg=/^\s*at .*(\S+:\d+|\(native\))/m,yg=/^(eval@)?(\[native code])?$/,bg={parse(e){return e?void 0!==e.stacktrace||void 0!==e["opera#sourceloc"]?this.parseOpera(e):e.stack&&e.stack.match(mg)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):[]:[]},extractLocation(e){if(-1===e.indexOf(":"))return[e];const t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error(`Cannot parse given url: ${e}`);return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE(e){return e.stack.split("\n").filter(function(e){return!!e.match(mg)},this).map(function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let t=e.replace(/^\s+/,"").replace(/\(eval code/g,"(");const i=t.match(/ (\((.+):(\d+):(\d+)\)$)/);t=i?t.replace(i[0],""):t;const n=t.split(/\s+/).slice(1),s=this.extractLocation(i?i[1]:n.pop());return new fg({functionName:n.join(" ")||void 0,fileName:["eval","<anonymous>"].indexOf(s[0])>-1?void 0:s[0],lineNumber:s[1],columnNumber:s[2]})},this)},parseFFOrSafari(e){return e.stack.split("\n").filter(function(e){return!e.match(yg)},this).map(function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new fg({functionName:e});{const t=/((.*".+"[^@]*)?[^@]*)(?:@)/,i=e.match(t),n=i&&i[1]?i[1]:void 0,s=this.extractLocation(e.replace(t,""));return new fg({functionName:n,fileName:s[0],lineNumber:s[1],columnNumber:s[2]})}},this)},parseOpera(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9(e){const t=/Line (\d+).*script (?:in )?(\S+)/i,i=e.message.split("\n"),n=[];for(let e=2,s=i.length;s>e;e+=2){const s=t.exec(i[e]);s&&n.push(new fg({fileName:s[2],lineNumber:parseFloat(s[1])}))}return n},parseOpera10(e){const t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,i=e.stacktrace.split("\n"),n=[];for(let e=0,s=i.length;s>e;e+=2){const s=t.exec(i[e]);s&&n.push(new fg({functionName:s[3]||void 0,fileName:s[2],lineNumber:parseFloat(s[1])}))}return n},parseOpera11(e){return e.stack.split("\n").filter(function(e){return!!e.match(vg)&&!e.match(/^Error created at/)},this).map(function(e){const t=e.split("@"),i=this.extractLocation(t.pop());return new fg({functionName:(t.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,fileName:i[0],lineNumber:i[1],columnNumber:i[2]})},this)}};function Sg(e){if(!e||!e.outerHTML)return"";let t="";for(;e.parentElement;){let i=e.localName;if(!i)break;i=i.toLowerCase();const n=e.parentElement,s=[];if(n.children&&n.children.length>0)for(let e=0;n.children.length>e;e++){const t=n.children[e];t.localName&&t.localName.toLowerCase&&t.localName.toLowerCase()===i&&s.push(t)}s.length>1&&(i+=`:eq(${s.indexOf(e)})`),t=i+(t?">"+t:""),e=n}return t}function wg(e){return Array.isArray(e)}function kg(e){return"object"==typeof e&&null!==e&&!wg(e)}function Cg(e,t){if(0===t)return!0;const i=Object.keys(e);for(const n of i)if(kg(e[n])&&Cg(e[n],t-1))return!0;return!1}function Eg(e,t){const i={numOfKeysLimit:50,depthOfLimit:4};Object.assign(i,t);const n=[],s=[];return JSON.stringify(e,function(e,t){if(n.length>0){const i=n.indexOf(this);~i?n.splice(i+1):n.push(this),~i?s.splice(i,1/0,e):s.push(e),~n.indexOf(t)&&(t=n[0]===t?"[Circular ~]":"[Circular ~."+s.slice(0,n.indexOf(t)).join(".")+"]")}else n.push(t);if(null===t)return t;if(void 0===t)return"undefined";if(kg(r=t)&&Object.keys(r).length>i.numOfKeysLimit||"function"==typeof r||kg(r)&&Cg(r,i.depthOfLimit))return function(e){let t=e.toString();return i.stringLengthLimit&&t.length>i.stringLengthLimit&&(t=`${t.slice(0,i.stringLengthLimit)}...`),t}(t);var r;if("bigint"==typeof t)return t.toString()+"n";if(t instanceof Event){const e={};for(const i in t){const n=t[i];e[i]=wg(n)?Sg(n.length?n[0]:null):n}return e}return t instanceof Node?t instanceof HTMLElement?t?t.outerHTML:"":t.nodeName:t instanceof Error?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t})}var Tg={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function xg(e,t,i){const n=i?Object.assign({},Tg,i):Tg,s=n.logger;if(!s)return()=>{};let r;r="string"==typeof s?t[s]:s;let o=0,a=!1,l=!0;const c=[];if(n.level.includes("error")){const i=t=>{const i=t.message;e({level:"error",trace:bg.parse(t.error).map(e=>e.toString()),payload:[Eg(i,n.stringifyOptions)]})};t.addEventListener("error",i),c.push(()=>{t.removeEventListener("error",i)});const s=t=>{let i,s;t.reason instanceof Error?(i=t.reason,s=[Eg(`Uncaught (in promise) ${i.name}: ${i.message}`,n.stringifyOptions)]):(i=new Error,s=[Eg("Uncaught (in promise)",n.stringifyOptions),Eg(t.reason,n.stringifyOptions)]),e({level:"error",trace:bg.parse(i).map(e=>e.toString()),payload:s})};t.addEventListener("unhandledrejection",s),c.push(()=>{t.removeEventListener("unhandledrejection",s)})}for(const e of n.level)c.push(u(r,e));return()=>{l=!1,c.forEach(e=>e())};function u(t,i){return t[i]?function(s,r){try{if(!(r in s))return()=>{};const c=s[r],u={next:c},d=(s=>(...r)=>{if(s.apply(t,r),l&&!("assert"===i&&r[0]||a)){a=!0;try{const t=bg.parse(new Error).map(e=>e.toString()).splice(1),s=("assert"===i?r.slice(1):r).map(e=>Eg(e,n.stringifyOptions));o++,n.lengthThreshold>o?e({level:i,trace:t,payload:s}):o===n.lengthThreshold&&e({level:"warn",trace:[],payload:[Eg("The number of log records reached the threshold.")]})}catch(e){s.apply(t,["rrweb logger error:",e,...r])}finally{a=!1}}})(function(...e){return u.next.apply(this,e)});return"function"==typeof d&&(d.prototype=d.prototype||{},Object.defineProperties(d,{__rrweb_original__:{enumerable:!1,value:c},__rrweb_layer__:{enumerable:!1,value:u}})),s[r]=d,()=>{if(s[r]===d)return void(s[r]=u.next);const e=e=>{var t;return"function"==typeof e?null!==(t=e.__rrweb_layer__)&&void 0!==t?t:e.__posthog_layer__:void 0};let t=s[r],i=e(t);for(;i;){if(i.next===d)return void(i.next=u.next);t=i.next,i=e(t)}}}catch(e){return()=>{}}}(t,i):()=>{}}}var Ig=e=>({name:"rrweb/console@1",observer:xg,options:e});const Rg=()=>{},Pg=e=>{var t;if(Ct(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Mg(e,t,i){try{if(!(t in e))return Rg;const n={next:e[t]},s=i(function(...e){return n.next.apply(this,e)});return Ct(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:n}})),e[t]=s,()=>{if(e[t]===s)return void(e[t]=n.next);let i=e[t],r=Pg(i);for(;r;){if(r.next===s)return void(r.next=n.next);i=r.next,r=Pg(i)}}}catch(e){return Rg}}function Fg(e,t){var i;const n=function(e){try{return"string"==typeof e?new URL(e).hostname:"url"in e?new URL(e.url).hostname:e.hostname}catch(e){return null}}(e),s={hostname:n,isHostDenied:!1};if(!(null===(i=t.payloadHostDenyList)||void 0===i?void 0:i.length)||!(null==n?void 0:n.trim().length))return s;for(const e of t.payloadHostDenyList)if(n.endsWith(e))return{hostname:n,isHostDenied:!0};return s}const Ag=Br("[Recorder]"),Lg=e=>"navigation"===e.entryType,Og=e=>"resource"===e.entryType,Dg=()=>{};function $g(e,t){var i;return Lg(t)&&"complete"===(null===(i=e.document)||void 0===i?void 0:i.readyState)&&t.loadEventEnd>0}function Ng(e,t){return t.recordInitialRequests?e.performance.getEntries().filter(i=>$g(e,i)||Og(i)&&t.initiatorTypes.includes(i.initiatorType)):t.performanceEntryTypeToObserve.includes("navigation")?function(e){var t;return"complete"!==(null===(t=e.document)||void 0===t?void 0:t.readyState)?[]:e.performance.getEntriesByType("navigation").filter(t=>$g(e,t))}(e):[]}function Bg(e,t){return!!t&&(Lt(t)||t[e])}function qg(e){if("undefined"==typeof Request)return!1;if(e instanceof Request)return!0;try{return"[object Request]"==={}.toString.call(e)}catch(e){return!1}}const Hg=["image/","video/","audio/","font/","application/octet-stream","application/pdf","application/zip","application/wasm"];function Ug({type:e,recordBody:t,headers:i,url:n}){function s(e){const t=Object.keys(i).find(e=>"content-type"===e.toLowerCase()),n=t&&i[t];return e.some(e=>null==n?void 0:n.toLowerCase().includes(e))}if(!t)return!1;if(function e(t){try{return"string"==typeof t?t.startsWith("blob:"):t instanceof URL?"blob:"===t.protocol:!!qg(t)&&e(t.url)}catch(e){return!1}}(n))return!1;if(s(Hg))return!1;if(Lt(t))return!0;if(kt(t))return s(t);const r=t[e];return Lt(r)?r:s(r)}function zg(e,t,i,n,s){return Wg.apply(this,arguments)}function Wg(){return Wg=rt(function*(e,t,i,n,s,r=0){if(r>10)return Ag.warn("Failed to get performance entry for request",{url:i,initiatorType:t}),null;const o=function(e,t){for(let i=e.length-1;i>=0;i-=1)if(t(e[i]))return e[i]}(e.performance.getEntriesByName(i),e=>Og(e)&&e.initiatorType===t&&(xt(n)||e.startTime>=n)&&(xt(s)||s>=e.startTime));return o||(yield new Promise(e=>setTimeout(e,50*r)),zg(e,t,i,n,s,r+1))}),Wg.apply(this,arguments)}function jg({body:e,options:t,url:i}){if(Mt(e))return null;const{hostname:n,isHostDenied:s}=Fg(i,t);if(s)return n+" is in deny list";if(It(e))return e;if((e=>"u">typeof Document&&e instanceof Document)(e))return e.textContent;if(Ot(e))return no(e);if(Et(e))try{return JSON.stringify(e)}catch(e){return"[SessionReplay] Failed to stringify response object"}return"[SessionReplay] Cannot read body of type "+toString.call(e)}const Vg=e=>!Pt(e)&&("navigation"===e.entryType||"resource"===e.entryType);function Gg(e,{entry:t,method:i,status:n,networkRequest:s,isInitial:r,start:o,end:a,url:l,initiatorType:c}){o=t?t.startTime:o,a=t?t.responseEnd:a;const u=Math.floor(Date.now()-e.performance.now()),d=Math.floor(u+(o||0)),h=[ct(ct({},t?JSON.parse(JSON.stringify(t.toJSON())):{name:l}),{},{startTime:xt(o)?void 0:Math.round(o),endTime:xt(a)?void 0:Math.round(a),timeOrigin:u,timestamp:d,method:i,initiatorType:c||(t?t.initiatorType:void 0),status:n,requestHeaders:s.requestHeaders,requestBody:s.requestBody,responseHeaders:s.responseHeaders,responseBody:s.responseBody,isInitial:r})];if(Vg(t))for(const e of t.serverTiming||[])h.push({timeOrigin:u,timestamp:d,startTime:Math.round(t.startTime),name:e.name,duration:e.duration,entryType:"serverTiming"});return h}const Qg=["video/","audio/"];function Kg(e){return Et(e)&&Ct(e.getReader)&&Ct(e.tee)}const Jg="[SessionReplay] Timeout while trying to read body",Yg="[SessionReplay] Failed to read body";function Zg(e){return`${Yg}: ${e}`}function Xg(e){return`[SessionReplay] Body too large to record (> ${e} bytes)`}function e_(e,t){if(!t.streamNetworkBody)return function(e){return new Promise(t=>{const i=setTimeout(()=>t(Jg),500);try{e.clone().text().then(e=>t(e),e=>t(Zg(e))).finally(()=>clearTimeout(i))}catch(e){clearTimeout(i),t(Yg)}})}(e);const i=ia(t);return function(e,t){try{var i,n;const s=null===(i=e.headers)||void 0===i||null===(n=i.get)||void 0===n?void 0:n.call(i,"content-length");if(!s)return!1;const r=parseInt(s,10);return Number.isFinite(r)&&r>t}catch(e){return!1}}(e,i)?Promise.resolve(Xg(i)):function(e,t){return new Promise(i=>{let n,s=!1;function r(){try{null==n||n.cancel().catch(()=>{})}catch(e){}}function o(e){s||(s=!0,clearTimeout(a),r(),i(e))}const a=setTimeout(()=>o(Jg),500);let l;try{l=e.clone()}catch(e){return void o(Yg)}const c=l.body;if(!Kg(c)||"undefined"==typeof TextDecoder){try{l.text().then(e=>o(e),e=>o(Zg(e)))}catch(e){o(Yg)}return}try{n=c.getReader()}catch(e){return void o(Yg)}const u=[];let d=0;!function e(){n.read().then(({done:i,value:n})=>{if(s)r();else if(i)o((new TextDecoder).decode(function(e,t){const i=new Uint8Array(t);let n=0;for(const t of e)i.set(t,n),n+=t.byteLength;return i}(u,d)));else{if(n){if(d+n.byteLength>t)return void o(Xg(t));d+=n.byteLength,u.push(n)}e()}},e=>o(Zg(e)))}()})}(e,i)}function t_(e){return i_.apply(this,arguments)}function i_(){return i_=rt(function*({r:e,options:t,url:i}){const{hostname:n,isHostDenied:s}=Fg(i,t);return s?Promise.resolve(n+" is in deny list"):e_(e,t)}),i_.apply(this,arguments)}function n_(e){return s_.apply(this,arguments)}function s_(){return s_=rt(function*({r:e,options:t,url:i}){const n=function({r:e,options:t,url:i}){var n;if("chunked"===e.headers.get("Transfer-Encoding"))return"Chunked Transfer-Encoding is not supported";const s=null===(n=e.headers.get("Content-Type"))||void 0===n?void 0:n.toLowerCase(),r=Qg.some(e=>null==s?void 0:s.startsWith(e));if(s&&r)return`Content-Type ${s} is not supported`;const{hostname:o,isHostDenied:a}=Fg(i,t);return a?o+" is in deny list":null}({r:e,options:t,url:i});return Pt(n)?e_(e,t):Promise.resolve(n)}),s_.apply(this,arguments)}let r_=null;function o_(e,t,i){if(!("performance"in t))return()=>{};if(r_)return Ag.warn("Network observer already initialised, doing nothing"),()=>{};const n=i?Object.assign({},na,i):na;let s=!0,r=!1;const o=t=>{if(!s)return;const i=[];let o=!1;t.requests.forEach(e=>{const t="serverTiming"===e.entryType;if(t&&o)return;let s;try{s=n.maskRequestFn(e)}catch(e){return r||(r=!0,Ag.warn("Network capture masking callback failed; dropping the record. Further masking failures will not be logged for this observer.")),void(t||(o=!0))}t||(o=!s||(e=>!!e&&da.has(e))(s)),s&&i.push(s)}),i.length>0&&e(ct(ct({},t),{},{requests:i}))},a=function(e,t,i){try{e({requests:Ng(t,i).flatMap(e=>Gg(t,{entry:e,method:void 0,status:void 0,networkRequest:{},isInitial:!0})),isInitial:!0})}catch(e){Ag.error("Failed to capture initial performance entries for network capture",e)}const n=t.PerformanceObserver,s=null==n?void 0:n.supportedEntryTypes;if(!n||!kt(s))return;const r=s.filter(e=>i.performanceEntryTypeToObserve.includes(e));if(!r.length)return;const o=new n(n=>{e({requests:n.getEntries().filter(e=>Lg(e)||Og(e)&&i.initiatorTypes.includes(e.initiatorType)&&(e=>!i.recordBody&&!i.recordHeaders||"xmlhttprequest"!==e.initiatorType&&"fetch"!==e.initiatorType)(e)).flatMap(e=>Gg(t,{entry:e,method:void 0,status:void 0,networkRequest:{}}))})});return o.observe({entryTypes:r}),()=>{o.disconnect()}}(o,t,n),l=n.recordHeaders||n.recordBody;if(!a&&!l)return s=!1,Dg;let c=()=>{},u=()=>{};return l&&(c=function(e,t,i){if(!i.initiatorTypes.includes("xmlhttprequest"))return()=>{};const n=Bg("request",i.recordHeaders),s=Bg("response",i.recordHeaders),r=Mg(t.XMLHttpRequest.prototype,"open",r=>function(o,a,l=!0,c,u){const d=this;try{const r=new Request(a),l={};let c,u;const h={},p=d.setRequestHeader.bind(d);d.setRequestHeader=(e,t)=>(h[e]=t,p(e,t)),n&&(l.requestHeaders=h);const g=d.send.bind(d);d.send=e=>(Ug({type:"request",headers:h,url:a,recordBody:i.recordBody})&&(l.requestBody=jg({body:e,options:i,url:a})),c=t.performance.now(),g(e));const _=()=>{d.removeEventListener("readystatechange",f),d.removeEventListener("error",_),d.removeEventListener("abort",_),d.removeEventListener("timeout",_)},f=()=>{if(d.readyState!==d.DONE)return;_(),u=t.performance.now();const n={};d.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),i=t.shift(),s=t.join(": ");i&&(n[i]=s)}),s&&(l.responseHeaders=n),Ug({type:"response",headers:n,url:a,recordBody:i.recordBody})&&(l.responseBody=jg({body:d.response,options:i,url:a})),zg(t,"xmlhttprequest",r.url,c,u).then(i=>{e({requests:Gg(t,{entry:i,method:o,status:null==d?void 0:d.status,networkRequest:l,start:c,end:u,url:a.toString(),initiatorType:"xmlhttprequest"})})}).catch(()=>{})};d.addEventListener("readystatechange",f),d.addEventListener("error",_),d.addEventListener("abort",_),d.addEventListener("timeout",_)}catch(e){Ag.error("Failed to instrument XHR for network capture",e)}r.call(d,o,a.toString(),l,c,u)});return()=>{r()}}(o,t,n),u=!0===n.captureFetchSynchronously?function(e,t,i){if(!i.initiatorTypes.includes("fetch"))return()=>{};const n=Bg("request",i.recordHeaders),s=Bg("response",i.recordHeaders),r=Mg(t,"fetch",r=>function(o,a){let l;try{l=new Request(o,a)}catch(e){Ag.error("Failed to instrument fetch for network capture",e);try{return Promise.resolve(r(o,a))}catch(e){return new Promise((t,i)=>i(e))}}const c={};let u,d;const h=rt(function*(){try{const e={};l.headers.forEach((t,i)=>{e[i]=t}),n&&(c.requestHeaders=e),!Kg(null==a?void 0:a.body)&&Ug({type:"request",headers:e,url:o,recordBody:i.recordBody})&&(c.requestBody=yield t_({r:l,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch request for network capture",e)}})(),p=(g=rt(function*(e){try{const t={};e.headers.forEach((e,i)=>{t[i]=e}),s&&(c.responseHeaders=t),Ug({type:"response",headers:t,url:o,recordBody:i.recordBody})&&(c.responseBody=yield n_({r:e,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch response for network capture",e)}}),function(e){return g.apply(this,arguments)});var g;try{u=t.performance.now()}catch(e){}let _;try{_=qg(o)?r(l):r(o,a)}catch(e){_=new Promise((t,i)=>i(e))}const f=Promise.resolve(_).then(e=>{try{d=t.performance.now()}catch(e){}return{status:"fulfilled",response:e}},e=>({status:"rejected",error:e}));return rt(function*(){let i;try{yield h;const e=yield f;if("rejected"===e.status)throw e.error;return i=e.response,yield p(i),i}finally{(n=i,zg(t,"fetch",l.url,u,d).then(i=>{e({requests:Gg(t,{entry:i,method:l.method,status:null==n?void 0:n.status,networkRequest:c,start:u,end:d,url:l.url,initiatorType:"fetch"})})})).catch(()=>{})}var n})()});return()=>{r()}}(o,t,n):function(e,t,i){if(!i.initiatorTypes.includes("fetch"))return()=>{};const n=Bg("request",i.recordHeaders),s=Bg("response",i.recordHeaders),r=Mg(t,"fetch",r=>function(){var o=rt(function*(o,a){let l,c;try{l=new Request(o,a)}catch(e){return Ag.error("Failed to instrument fetch for network capture",e),r(o,a)}const u={};let d,h;try{try{const e={};l.headers.forEach((t,i)=>{e[i]=t}),n&&(u.requestHeaders=e),!Kg(null==a?void 0:a.body)&&Ug({type:"request",headers:e,url:o,recordBody:i.recordBody})&&(u.requestBody=yield t_({r:l,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch request for network capture",e)}d=t.performance.now(),c=qg(o)?yield r(l):yield r(o,a),h=t.performance.now();try{const e={};c.headers.forEach((t,i)=>{e[i]=t}),s&&(u.responseHeaders=e),Ug({type:"response",headers:e,url:o,recordBody:i.recordBody})&&(u.responseBody=yield n_({r:c,options:i,url:o}))}catch(e){Ag.error("Failed to record fetch response for network capture",e)}return c}finally{zg(t,"fetch",l.url,d,h).then(i=>{e({requests:Gg(t,{entry:i,method:l.method,status:null==c?void 0:c.status,networkRequest:u,start:d,end:h,url:l.url,initiatorType:"fetch"})})}).catch(()=>{})}});return function(e,t){return o.apply(this,arguments)}}());return()=>{r()}}(o,t,n)),r_=()=>{s=!1,null==a||a(),c(),u(),r_=null},r_}const a_=e=>({name:"rrweb/network@1",observer:o_,options:e});var l_,c_,u_,d_,h_,p_,g_,__,f_,v_,m_,y_,b_,S_,w_;d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.rrwebPlugins={getRecordConsolePlugin:Ig,getRecordNetworkPlugin:a_},d.__PosthogExtensions__.rrweb={record:hg,version:"v2",wasMaxDepthReached:()=>Fh,resetMaxDepthState(){Fh=!1,Mh=!1},getLastSnapshotCost:()=>gd,getMutationCost:()=>ct({},yd),getObserverInitFailures:()=>Ep.size?Array.from(Ep):void 0,resetSnapshotCostState(){ud=0,dd=0,hd=0,od=0,pd={durationMs:0,stylesheetMs:0,nodeCount:0,cssRuleCount:0,nonDeferrableCssRuleCount:0,deferredStylesheetCount:0},gd=null,_d=null,fd=[],vd=0,md=0,yd={slowestBatchMs:0},bd={deferredCount:0,failedCount:0,abandonedCount:0,totalMs:0,slowestSliceMs:0}}},d.rrweb={record:hg,version:"v2"},d.rrwebConsoleRecord={getRecordConsolePlugin:Ig},d.getRecordNetworkPlugin=a_,d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.initSessionRecording=(e,t)=>new $u(e,t);var k_={},C_=[],E_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,T_=Array.isArray;function x_(e,t){for(var i in t)e[i]=t[i];return e}function I_(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function R_(e,t,i){var n,s,r,o={};for(r in t)"key"==r?n=t[r]:"ref"==r?s=t[r]:o[r]=t[r];if(arguments.length>2&&(o.children=arguments.length>3?l_.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(r in e.defaultProps)void 0===o[r]&&(o[r]=e.defaultProps[r]);return P_(e,o,n,s,null)}function P_(e,t,i,n,s){var r={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==s?++u_:s,__i:-1,__u:0};return null==s&&null!=c_.vnode&&c_.vnode(r),r}function M_(e){return e.children}function F_(e,t){this.props=e,this.context=t}function A_(e,t){if(null==t)return e.__?A_(e.__,e.__i+1):null;for(var i;e.__k.length>t;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?A_(e):null}function L_(e){if(e.__P&&e.__d){var t=e.__v,i=t.__e,n=[],s=[],r=x_({},t);r.__v=t.__v+1,c_.vnode&&c_.vnode(r),W_(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[i]:null,n,null==i?A_(t):i,!!(32&t.__u),s),r.__v=t.__v,r.__.__k[r.__i]=r,V_(n,r,s),t.__e=t.__=null,r.__e!=i&&O_(r)}}function O_(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),O_(e)}function D_(e){(!e.__d&&(e.__d=!0)&&d_.push(e)&&!$_.__r++||h_!=c_.debounceRendering)&&((h_=c_.debounceRendering)||p_)($_)}function $_(){try{for(var e,t=1;d_.length;)d_.length>t&&d_.sort(g_),e=d_.shift(),t=d_.length,L_(e)}finally{d_.length=$_.__r=0}}function N_(e,t,i,n,s,r,o,a,l,c,u){var d,h,p,g,_,f,v,m=n&&n.__k||C_,y=t.length;for(l=function(e,t,i,n,s){var r,o,a,l,c,u=i.length,d=u,h=0;for(e.__k=new Array(s),r=0;s>r;r++)null!=(o=t[r])&&"boolean"!=typeof o&&"function"!=typeof o?("string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?o=e.__k[r]=P_(null,o,null,null,null):T_(o)?o=e.__k[r]=P_(M_,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?o=e.__k[r]=P_(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[r]=o,l=r+h,o.__=e,o.__b=e.__b+1,a=null,-1!=(c=o.__i=q_(o,i,l,d))&&(d--,(a=i[c])&&(a.__u|=2)),null==a||null==a.__v?(-1==c&&(s>u?h--:u>s&&h++),"function"!=typeof o.type&&(o.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,o.__u|=4))):e.__k[r]=null;if(d)for(r=0;u>r;r++)null!=(a=i[r])&&!(2&a.__u)&&(a.__e==n&&(n=A_(a)),K_(a,a));return n}(i,t,m,l,y),d=0;y>d;d++)null!=(p=i.__k[d])&&(h=-1!=p.__i&&m[p.__i]||k_,p.__i=d,f=W_(e,p,h,s,r,o,a,l,c,u),g=p.__e,p.ref&&h.ref!=p.ref&&(h.ref&&Q_(h.ref,null,p),u.push(p.ref,p.__c||g,p)),null==_&&null!=g&&(_=g),(v=!!(4&p.__u))||h.__k===p.__k?(l=B_(p,l,e,v),v&&h.__e&&(h.__e=null)):"function"==typeof p.type&&void 0!==f?l=f:g&&(l=g.nextSibling),p.__u&=-7);return i.__e=_,l}function B_(e,t,i,n){var s,r;if("function"==typeof e.type){for(s=e.__k,r=0;s&&s.length>r;r++)s[r]&&(s[r].__=e,t=B_(s[r],t,i,n));return t}e.__e!=t&&(n&&(t&&e.type&&!t.parentNode&&(t=A_(e)),i.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function q_(e,t,i,n){var s,r,o,a=e.key,l=e.type,c=t[i],u=null!=c&&!(2&c.__u);if(null===c&&null==a||u&&a==c.key&&l==c.type)return i;if(n>(u?1:0))for(s=i-1,r=i+1;s>=0||t.length>r;)if(null!=(c=t[o=0>s?r++:s--])&&!(2&c.__u)&&a==c.key&&l==c.type)return o;return-1}function H_(e,t,i){"-"==t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||E_.test(t)?i:i+"px"}function U_(e,t,i,n,s){var r,o;e:if("style"==t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof n&&(e.style.cssText=n=""),n)for(t in n)i&&t in i||H_(e.style,t,"");if(i)for(t in i)n&&i[t]==n[t]||H_(e.style,t,i[t])}else if("o"==t[0]&&"n"==t[1])r=t!=(t=t.replace(m_,"$1")),o=t.toLowerCase(),t=o in e||"onFocusOut"==t||"onFocusIn"==t?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=i,i?n?i[v_]=n[v_]:(i[v_]=y_,e.addEventListener(t,r?S_:b_,r)):e.removeEventListener(t,r?S_:b_,r);else{if("http://www.w3.org/2000/svg"==s)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==i?"":i))}}function z_(e){return function(t){if(this.l){var i=this.l[t.type+e];if(null==t[f_])t[f_]=y_++;else if(i[v_]>t[f_])return;return i(c_.event?c_.event(t):t)}}}function W_(e,t,i,n,s,r,o,a,l,c){var u,d,h,p,g,_,f,v,m,y,$,b,S,w,k,C,E=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),r=[a=t.__e=i.__e]),(u=c_.__b)&&u(t);e:if("function"==typeof E){d=o.length;try{if(m=t.props,y=E.prototype&&E.prototype.render,$=(u=E.contextType)&&n[u.__c],b=u?$?$.props.value:u.__:n,i.__c?v=(h=t.__c=i.__c).__=h.__E:(y?t.__c=h=new E(m,b):(t.__c=h=new F_(m,b),h.constructor=E,h.render=J_),$&&$.sub(h),h.state||(h.state={}),h.__n=n,p=h.__d=!0,h.__h=[],h._sb=[]),y&&null==h.__s&&(h.__s=h.state),y&&null!=E.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=x_({},h.__s)),x_(h.__s,E.getDerivedStateFromProps(m,h.__s))),g=h.props,_=h.state,h.__v=t,p)y&&null==E.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),y&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(y&&null==E.getDerivedStateFromProps&&m!==g&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,b),t.__v==i.__v||!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,b)){t.__v!=i.__v&&(h.props=m,h.state=h.__s,h.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.some(function(e){e&&(e.__=t)}),C_.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h);break e}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,b),y&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(g,_,f)})}if(h.context=b,h.props=m,h.__P=e,h.__e=!1,S=c_.__r,w=0,y)h.state=h.__s,h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),C_.push.apply(h.__h,h._sb),h._sb=[];else do{h.__d=!1,S&&S(t),u=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&25>++w);h.state=h.__s,null!=h.getChildContext&&(n=x_(x_({},n),h.getChildContext())),y&&!p&&null!=h.getSnapshotBeforeUpdate&&(f=h.getSnapshotBeforeUpdate(g,_)),k=null!=u&&u.type===M_&&null==u.key?G_(u.props.children):u,a=N_(e,T_(k)?k:[k],t,i,n,s,r,o,a,l,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),v&&(h.__E=h.__=null)}catch(e){if(o.length=d,t.__v=null,l||null!=r)if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;null!=r&&(r[r.indexOf(a)]=null),t.__e=a}else{if(null!=r)for(C=r.length;C--;)I_(r[C]);j_(t)}else t.__e=i.__e,!t.__k&&i.__k&&(t.__k=i.__k),e.then||j_(t);c_.__e(e,t,i)}}else null==r&&t.__v==i.__v?(t.__k=i.__k,t.__e=i.__e):a=t.__e=function(e,t,i,n,s,r,o,a,l){var c,u,d,h,p,g,_,f=i.props||k_,v=t.props,m=t.type;if("svg"==m?s="http://www.w3.org/2000/svg":"math"==m?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),null!=r)for(c=0;r.length>c;c++)if((p=r[c])&&"setAttribute"in p==!!m&&(m?p.localName==m:3==p.nodeType)){e=p,r[c]=null;break}if(null==e){if(null==m)return document.createTextNode(v);e=document.createElementNS(s,m,v.is&&v),a&&(c_.__m&&c_.__m(t,r),a=!1),r=null}if(null==m)f===v||a&&e.data==v||(e.data=v);else{if(r="textarea"==m&&null!=v.defaultValue?null:r&&l_.call(e.childNodes),!a&&null!=r)for(f={},c=0;e.attributes.length>c;c++)f[(p=e.attributes[c]).name]=p.value;for(c in f)p=f[c],"dangerouslySetInnerHTML"==c?d=p:"children"==c||c in v||"value"==c&&"defaultValue"in v||"checked"==c&&"defaultChecked"in v||U_(e,c,null,p,s);for(c in v)p=v[c],"children"==c?h=p:"dangerouslySetInnerHTML"==c?u=p:"value"==c?g=p:"checked"==c?_=p:a&&"function"!=typeof p||f[c]===p||U_(e,c,p,f[c],s);if(u)a||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),N_("template"==t.type?e.content:e,T_(h)?h:[h],t,i,n,"foreignObject"==m?"http://www.w3.org/1999/xhtml":s,r,o,r?r[0]:i.__k&&A_(i,0),a,l),null!=r)for(c=r.length;c--;)I_(r[c]);a&&"textarea"!=m||(c="value","progress"==m&&null==g?e.removeAttribute("value"):null!=g&&(g!==e[c]||"progress"==m&&!g||"option"==m&&g!=f[c])&&U_(e,c,g,f[c],s),c="checked",null!=_&&_!=e[c]&&U_(e,c,_,f[c],s))}return e}(i.__e,t,i,n,s,r,o,l,c);return(u=c_.diffed)&&u(t),128&t.__u?void 0:a}function j_(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(j_))}function V_(e,t,i){for(var n=0;i.length>n;n++)Q_(i[n],i[++n],i[++n]);c_.__c&&c_.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){c_.__e(e,t.__v)}})}function G_(e){return"object"!=typeof e||null==e||e.__b>0?e:T_(e)?e.map(G_):void 0!==e.constructor?null:x_({},e)}function Q_(e,t,i){try{if("function"==typeof e){var n="function"==typeof e.__u;n&&e.__u(),n&&null==t||(e.__u=e(t))}else e.current=t}catch(e){c_.__e(e,i)}}function K_(e,t,i){var n,s;if(c_.unmount&&c_.unmount(e),(n=e.ref)&&(n.current&&n.current!=e.__e||Q_(n,null,t)),null!=(n=e.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(e){c_.__e(e,t)}n.base=n.__P=n.__n=null}if(n=e.__k)for(s=0;n.length>s;s++)n[s]&&K_(n[s],t,i||"function"!=typeof e.type);i||I_(e.__e),e.__c=e.__=e.__e=void 0}function J_(e,t,i){return this.constructor(e,i)}function Y_(e,t,i){var n,s,r,o;t==document&&(t=document.documentElement),c_.__&&c_.__(e,t),s=(n="function"==typeof i)?null:i&&i.__k||t.__k,r=[],o=[],W_(t,e=(!n&&i||t).__k=R_(M_,null,[e]),s||k_,k_,t.namespaceURI,!n&&i?[i]:s?null:t.firstChild?l_.call(t.childNodes):null,r,!n&&i?i:s?s.__e:t.firstChild,n,o),V_(r,e,o),e.props.children=null}l_=C_.slice,c_={__e(e,t,i,n){for(var s,r,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((r=s.constructor)&&null!=r.getDerivedStateFromError&&(s.setState(r.getDerivedStateFromError(e)),o=s.__d),null!=s.componentDidCatch&&(s.componentDidCatch(e,n||{}),o=s.__d),o)return s.__E=s}catch(t){e=t}throw e}},u_=0,F_.prototype.setState=function(e,t){var i=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=x_({},this.state);"function"==typeof e&&(e=e(x_({},i),this.props)),e&&x_(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),D_(this))},F_.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),D_(this))},F_.prototype.render=M_,d_=[],p_="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,g_=function(e,t){return e.__v.__b-t.__v.__b},$_.__r=0,__=Math.random().toString(8),f_="__d"+__,v_="__a"+__,m_=/(PointerCapture)$|Capture$/i,y_=0,b_=z_(!1),S_=z_(!0),w_=0;var Z_=0;function X_(e,t,i,n,s,r){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)"ref"==a?o=t[a]:l[a]=t[a];var c={type:e,props:l,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Z_,__i:-1,__u:0,__source:s,__self:r};if("function"==typeof e&&(o=e.defaultProps))for(a in o)void 0===l[a]&&(l[a]=o[a]);return c_.vnode&&c_.vnode(c),c}const ef="featureFlagsCommon";function tf({client:e,config:t}){var i;if(!e||!t.uiHost)return;const n=null===(i=e.session)||void 0===i?void 0:i.sessionId;return n?`${t.uiHost}/project/${e.projectToken}/replay/${n}`:void 0}var nf,sf,rf,of,af=0,lf=[],cf=c_,uf=cf.__b,df=cf.__r,hf=cf.diffed,pf=cf.__c,gf=cf.unmount,_f=cf.__;function ff(e,t){cf.__h&&cf.__h(sf,e,af||t),af=0;var i=sf.__H||(sf.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({}),i.__[e]}function vf(e){return af=1,function(e,t){var i=ff(nf++,2);if(i.t=e,!i.__c&&(i.__=[If(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=sf,!sf.__f)){var n=function(e,t,n){if(!i.__c.__H)return!0;var r=!1,o=i.__c.props!==e;if(i.__c.__H.__.some(function(e){if(e.__N){r=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),s){var a=s.call(this,e,t,n);return r?a||o:a}return!r||o};sf.__f=!0;var s=sf.shouldComponentUpdate,r=sf.componentWillUpdate;sf.componentWillUpdate=function(e,t,i){if(this.__e){var o=s;s=void 0,n(e,t,i),s=o}r&&r.call(this,e,t,i)},sf.shouldComponentUpdate=n}return i.__N||i.__}(If,e)}function mf(e,t){var i=ff(nf++,3);!cf.__s&&xf(i.__H,t)&&(i.__=e,i.u=t,sf.__H.__h.push(i))}function yf(e){return af=5,bf(function(){return{current:e}},[])}function bf(e,t){var i=ff(nf++,7);return xf(i.__H,t)&&(i.__=e(),i.__H=t,i.__h=e),i.__}function Sf(e){var t=sf.context[e.__c],i=ff(nf++,9);return i.c=e,t?(null==i.__&&(i.__=!0,t.sub(sf)),t.props.value):e.__}function wf(){for(var e;e=lf.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ef),t.__h.some(Tf),t.__h=[]}catch(i){t.__h=[],cf.__e(i,e.__v)}}}cf.__b=function(e){sf=null,uf&&uf(e)},cf.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),_f&&_f(e,t)},cf.__r=function(e){df&&df(e),nf=0;var t=(sf=e.__c).__H;t&&(rf===sf?(t.__h=[],sf.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.length&&wf(),nf=0)),rf=sf},cf.diffed=function(e){hf&&hf(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==lf.push(t)&&of===cf.requestAnimationFrame||((of=cf.requestAnimationFrame)||Cf)(wf)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),rf=sf=null},cf.__c=function(e,t){t.some(function(e){try{e.__h.some(Ef),e.__h=e.__h.filter(function(e){return!e.__||Tf(e)})}catch(i){t.some(function(e){e.__h&&(e.__h=[])}),t=[],cf.__e(i,e.__v)}}),pf&&pf(e,t)},cf.unmount=function(e){gf&&gf(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.some(function(e){try{Ef(e)}catch(e){t=e}}),i.__H=void 0,t&&cf.__e(t,i.__v))};var kf="function"==typeof requestAnimationFrame;function Cf(e){var t,i=function(){clearTimeout(n),kf&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(i,35);kf&&(t=requestAnimationFrame(i))}function Ef(e){var t=sf,i=e.__c;"function"==typeof i&&(e.__c=void 0,i()),sf=t}function Tf(e){var t=sf;e.__c=e.__(),sf=t}function xf(e,t){return!e||e.length!==t.length||t.some(function(t,i){return t!==e[i]})}function If(e,t){return"function"==typeof t?t(e):t}const Rf={Activation:"events",Cancellation:"cancelEvents"},Pf={Button:"button",Tab:"tab",Selector:"selector"},Mf={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"},Ff={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Af={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Lf={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},Of={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Df={Once:"once",Recurring:"recurring",Always:"always"},$f={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Nf={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"},Bf={Popover:"popover",Inline:"inline"},qf=Br("[Surveys]"),Hf="PostHog is not capturing, so a survey response cannot be recorded";function Uf(e){return!(!e.start_date||e.end_date)}function zf(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}const Wf=(e,t)=>`${e}${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`,jf=e=>Wf("seenSurvey_",e),Vf=e=>{try{const t=jf(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){qf.error("Failed to persist survey seen state",e)}},Gf=[Af.Popover,Af.Widget,Af.API],Qf={ignoreConditions:!1,ignoreDelay:!1,displayType:Bf.Popover};function Kf(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);t>i;i++)n[i]=e[i];return n}function Jf(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,s,r,o,a=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t);else for(;!(l=(n=r.call(i)).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(c)throw s}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Kf(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Kf(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const Yf=Object.entries,Zf=Object.setPrototypeOf,Xf=Object.isFrozen,ev=Object.getPrototypeOf,tv=Object.getOwnPropertyDescriptor;let iv=Object.freeze,nv=Object.seal,sv=Object.create,rv="undefined"!=typeof Reflect&&Reflect,ov=rv.apply,av=rv.construct;iv||(iv=function(e){return e}),nv||(nv=function(e){return e}),ov||(ov=function(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),s=2;i>s;s++)n[s-2]=arguments[s];return e.apply(t,n)}),av||(av=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;t>n;n++)i[n-1]=arguments[n];return new e(...i)});const lv=Rv([].forEach),cv=Rv([].lastIndexOf),uv=Rv([].pop),dv=Rv([].push),hv=Rv([].splice),pv=Array.isArray,gv=Rv("".toLowerCase),_v=Rv("".toString),fv=Rv("".match),vv=Rv("".replace),mv=Rv("".indexOf),yv=Rv("".trim),bv=Rv((0).toString),Sv=Rv(Boolean.prototype.toString),wv="undefined"==typeof BigInt?null:Rv(BigInt.prototype.toString),kv="undefined"==typeof Symbol?null:Rv(Symbol.prototype.toString),Cv=Rv({}.hasOwnProperty),Ev=Rv({}.toString),Tv=Rv(/t/.test),xv=(Iv=TypeError,function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return av(Iv,t)});var Iv;function Rv(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var i=arguments.length,n=new Array(i>1?i-1:0),s=1;i>s;s++)n[s-1]=arguments[s];return ov(e,t,n)}}function Pv(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:gv;if(Zf&&Zf(e,null),!pv(t))return e;let n=t.length;for(;n--;){let s=t[n];if("string"==typeof s){const e=i(s);e!==s&&(Xf(t)||(t[n]=e),s=e)}e[s]=!0}return e}function Mv(e){for(let t=0;e.length>t;t++)Cv(e,t)||(e[t]=null);return e}function Fv(e){const t=sv(null);for(const n of Yf(e)){var i=Jf(n,2);const s=i[0],r=i[1];Cv(e,s)&&(t[s]=pv(r)?Mv(r):r&&"object"==typeof r&&r.constructor===Object?Fv(r):r)}return t}function Av(e,t){for(;null!==e;){const i=tv(e,t);if(i){if(i.get)return Rv(i.get);if("function"==typeof i.value)return Rv(i.value)}e=ev(e)}return function(){return null}}const Lv=iv(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Ov=iv(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Dv=iv(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$v=iv(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Nv=iv(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Bv=iv(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qv=iv(["#text"]),Hv=iv(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Uv=iv(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),zv=iv(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wv=iv(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),jv=nv(/{{[\w\W]*|^[\w\W]*}}/g),Vv=nv(/<%[\w\W]*|^[\w\W]*%>/g),Gv=nv(/\${[\w\W]*/g),Qv=nv(/^data-[\-\w.\u00B7-\uFFFF]+$/),Kv=nv(/^aria-[\-\w]+$/),Jv=nv(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Yv=nv(/^(?:\w+script|data):/i),Zv=nv(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xv=nv(/^html$/i),em=nv(/^[a-z][.\w]*(-[.\w]+)+$/i),tm=nv(/<[/\w!]/g),im=nv(/<[/\w]/g),nm=nv(/<\/no(script|embed|frames)/i),sm=nv(/\/>/i),rm=function(){return"undefined"==typeof window?null:window},om=function(e,t,i,n){return Cv(e,t)&&pv(e[t])?Pv(n.base?Fv(n.base):{},e[t],n.transform):i};var am=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rm();const i=t=>e(t);if(i.version="3.4.13",i.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return i.isSupported=!1,i;let n=t.document;const s=n,r=s.currentScript,o=t.HTMLTemplateElement,a=t.Node,l=t.NodeFilter,c=t.DOMParser,u=t.trustedTypes,d=t.Element.prototype,h=Av(d,"cloneNode"),p=Av(d,"remove"),g=Av(d,"nextSibling"),_=Av(d,"childNodes"),f=Av(d,"parentNode"),v=Av(d,"shadowRoot"),m=Av(d,"attributes"),y=a&&a.prototype?Av(a.prototype,"nodeType"):null,b=a&&a.prototype?Av(a.prototype,"nodeName"):null,S=a&&a.prototype?Av(a.prototype,"ownerDocument"):null;if("function"==typeof o){const e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let w,k,C="",E=!1,T=0;const x=function(){if(T>0)throw xv('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},I=function(e){x(),T++;try{return w.createHTML(e)}finally{T--}},R=n.implementation,P=n.createNodeIterator,M=n.createDocumentFragment,F=n.getElementsByTagName,A=s.importNode;let L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof Yf&&"function"==typeof f&&R&&void 0!==R.createHTMLDocument;const O=jv,D=Vv,N=Gv,B=Qv,q=Kv,H=Yv,U=Zv,z=em;let W=Jv,j=null;const V=Pv({},[...Lv,...Ov,...Dv,...Nv,...qv]);let G=null;const Q=Pv({},[...Hv,...Uv,...zv,...Wv]);let K=Object.seal(sv(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),J=null,Y=null;const Z=Object.seal(sv(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let X=!0,ee=!0,te=!1,ie=!0,ne=!1,se=!0,re=!1,oe=!1,ae=null,le=null,ce=!1,ue=!1,de=!1,he=!1,pe=!0,ge=!1;const _e="user-content-";let fe=!0,ve=!1,me={},ye=null;const be=Pv({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Se=null;const we=Pv({},["audio","video","img","source","image","track"]);let ke=null;const Ce=Pv({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ee="http://www.w3.org/1998/Math/MathML",Te="http://www.w3.org/2000/svg",xe="http://www.w3.org/1999/xhtml";let Ie=xe,Re=!1,Pe=null;const Me=Pv({},[Ee,Te,xe],_v),Fe=iv(["mi","mo","mn","ms","mtext"]);let Ae=Pv({},Fe);const Le=iv(["annotation-xml"]);let Oe=Pv({},Le);const De=Pv({},["title","style","font","a","script"]);let $e=null;const Ne=["application/xhtml+xml","text/html"];let Be=null,qe=null;const He=n.createElement("form"),Ue=function(e){return e instanceof RegExp||e instanceof Function},ze=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(qe&&qe===e)return;e&&"object"==typeof e||(e={}),e=Fv(e),$e=-1===Ne.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Be="application/xhtml+xml"===$e?_v:gv,j=om(e,"ALLOWED_TAGS",V,{transform:Be}),G=om(e,"ALLOWED_ATTR",Q,{transform:Be}),Pe=om(e,"ALLOWED_NAMESPACES",Me,{transform:_v}),ke=om(e,"ADD_URI_SAFE_ATTR",Ce,{transform:Be,base:Ce}),Se=om(e,"ADD_DATA_URI_TAGS",we,{transform:Be,base:we}),ye=om(e,"FORBID_CONTENTS",be,{transform:Be}),J=om(e,"FORBID_TAGS",Fv({}),{transform:Be}),Y=om(e,"FORBID_ATTR",Fv({}),{transform:Be}),me=!!Cv(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?Fv(e.USE_PROFILES):e.USE_PROFILES),X=!1!==e.ALLOW_ARIA_ATTR,ee=!1!==e.ALLOW_DATA_ATTR,te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ie=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ne=e.SAFE_FOR_TEMPLATES||!1,se=!1!==e.SAFE_FOR_XML,re=e.WHOLE_DOCUMENT||!1,ue=e.RETURN_DOM||!1,de=e.RETURN_DOM_FRAGMENT||!1,he=e.RETURN_TRUSTED_TYPE||!1,ce=e.FORCE_BODY||!1,pe=!1!==e.SANITIZE_DOM,ge=e.SANITIZE_NAMED_PROPS||!1,fe=!1!==e.KEEP_CONTENT,ve=e.IN_PLACE||!1,W=function(e){try{return Tv(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Jv,Ie="string"==typeof e.NAMESPACE?e.NAMESPACE:xe,Ae=Cv(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?Fv(e.MATHML_TEXT_INTEGRATION_POINTS):Pv({},Fe),Oe=Cv(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?Fv(e.HTML_INTEGRATION_POINTS):Pv({},Le);const t=Cv(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?Fv(e.CUSTOM_ELEMENT_HANDLING):sv(null);if(K=sv(null),Cv(t,"tagNameCheck")&&Ue(t.tagNameCheck)&&(K.tagNameCheck=t.tagNameCheck),Cv(t,"attributeNameCheck")&&Ue(t.attributeNameCheck)&&(K.attributeNameCheck=t.attributeNameCheck),Cv(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(K.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),nv(K),ne&&(ee=!1),de&&(ue=!0),me&&(j=Pv({},qv),G=sv(null),!0===me.html&&(Pv(j,Lv),Pv(G,Hv)),!0===me.svg&&(Pv(j,Ov),Pv(G,Uv),Pv(G,Wv)),!0===me.svgFilters&&(Pv(j,Dv),Pv(G,Uv),Pv(G,Wv)),!0===me.mathMl&&(Pv(j,Nv),Pv(G,zv),Pv(G,Wv))),Z.tagCheck=null,Z.attributeCheck=null,Cv(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?Z.tagCheck=e.ADD_TAGS:pv(e.ADD_TAGS)&&(j===V&&(j=Fv(j)),Pv(j,e.ADD_TAGS,Be))),Cv(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?Z.attributeCheck=e.ADD_ATTR:pv(e.ADD_ATTR)&&(G===Q&&(G=Fv(G)),Pv(G,e.ADD_ATTR,Be))),Cv(e,"ADD_URI_SAFE_ATTR")&&pv(e.ADD_URI_SAFE_ATTR)&&Pv(ke,e.ADD_URI_SAFE_ATTR,Be),Cv(e,"FORBID_CONTENTS")&&pv(e.FORBID_CONTENTS)&&(ye===be&&(ye=Fv(ye)),Pv(ye,e.FORBID_CONTENTS,Be)),Cv(e,"ADD_FORBID_CONTENTS")&&pv(e.ADD_FORBID_CONTENTS)&&(ye===be&&(ye=Fv(ye)),Pv(ye,e.ADD_FORBID_CONTENTS,Be)),fe&&(j["#text"]=!0),re&&Pv(j,["html","head","body"]),j.table&&(Pv(j,["tbody"]),delete J.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw xv('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw xv('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=w;w=e.TRUSTED_TYPES_POLICY;try{C=I("")}catch(e){throw w=t,e}}else null===e.TRUSTED_TYPES_POLICY?(w=void 0,C=""):(void 0===w&&(E||(k=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let i=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const s="dompurify"+(i?"#"+i:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(u,r),E=!0),w=k),w&&"string"==typeof C&&(C=I("")));iv&&iv(e),qe=e},We=Pv({},[...Ov,...Dv,...$v]),je=Pv({},[...Nv,...Bv]),Ve=function(e){dv(i.removed,{element:e});try{f(e).removeChild(e)}catch(t){if(p(e),!f(e))throw xv("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ge=function(e){Je(e);const t=_(e);if(t){const e=[];lv(t,t=>{dv(e,t)}),lv(e,e=>{try{p(e)}catch(e){}})}const i=m(e);if(i)for(let t=i.length-1;t>=0;--t){const n=i[t],s=n&&n.name;if("string"==typeof s)try{e.removeAttribute(s)}catch(e){}}},Qe=function(e,t){try{dv(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){dv(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ue||de)try{Ve(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ke=function(e){const t=m(e);if(t)for(let i=t.length-1;i>=0;--i){const n=t[i],s=n&&n.name;if("string"==typeof s&&!G[Be(s)])try{e.removeAttribute(s)}catch(e){}}},Je=function(e){const t=[e];for(;t.length>0;){const e=t.pop();1===(y?y(e):e.nodeType)&&Ke(e);const i=_(e);if(i)for(let e=i.length-1;e>=0;--e)t.push(i[e])}},Ye=function(e){let t=null,i=null;if(ce)e="<remove></remove>"+e;else{const t=fv(e,/^[\r\n\t ]+/);i=t&&t[0]}"application/xhtml+xml"===$e&&Ie===xe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=w?I(e):e;if(Ie===xe)try{t=(new c).parseFromString(s,$e)}catch(e){}if(!t||!t.documentElement){t=R.createDocument(Ie,"template",null);try{t.documentElement.innerHTML=Re?C:s}catch(e){}}const r=t.body||t.documentElement;return e&&i&&r.insertBefore(n.createTextNode(i),r.childNodes[0]||null),Ie===xe?F.call(t,re?"html":"body")[0]:re?t.documentElement:r},Ze=function(e){const t=S?S(e):e.ownerDocument;return P.call(t||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Xe=function(e){return e=vv(e,O," "),e=vv(e,D," "),vv(e,N," ")},et=function(e){var t;e.normalize();const i=S?S(e):e.ownerDocument,n=P.call(i||e,e,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let s=n.nextNode();for(;s;)s.data=Xe(s.data),s=n.nextNode();const r=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");r&&lv(r,e=>{it(e.content)&&et(e.content)})},tt=function(e){const t=b?b(e):null;return"string"==typeof t&&"form"===Be(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==m(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==y(e)||e.childNodes!==_(e))},it=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return 11===y(e)}catch(e){return!1}},nt=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return"number"==typeof y(e)}catch(e){return!1}};function st(e,t,n){0!==e.length&&lv(e,e=>{e.call(i,t,n,qe)})}const rt=function(e,t,i,n){return 0===e.length?t:t===i||t===n?Fv(t):t},ot=function(e,t){if(st(L.beforeSanitizeElements,e,null),e!==t&&null===f(e))return ve&&Je(e),!0;if(tt(e))return Ve(e),!0;const n=Be(b?b(e):e.nodeName);if(j=rt(L.uponSanitizeElement,j,V,ae),st(L.uponSanitizeElement,e,{tagName:n,allowedTags:j}),e!==t&&null===f(e))return ve&&Je(e),!0;if(function(e,t){return!!(se&&e.hasChildNodes()&&!nt(e.firstElementChild)&&Tv(tm,e.textContent)&&Tv(tm,e.innerHTML))||!(!se||e.namespaceURI!==xe||"style"!==t||!nt(e.firstElementChild))||7===e.nodeType||!(!se||8!==e.nodeType||!Tv(im,e.data))}(e,n))return Ve(e),!0;if(J[n]||!(Z.tagCheck instanceof Function&&Z.tagCheck(n))&&!j[n]){const i=function(e,t,i){if(!J[t]&&ct(t)){if(K.tagNameCheck instanceof RegExp&&Tv(K.tagNameCheck,t))return!1;if(K.tagNameCheck instanceof Function&&K.tagNameCheck(t))return!1}if(fe&&!ye[t]){const t=f(e),n=_(e);if(n&&t)for(let s=n.length-1;s>=0;--s){const r=e===i?h(n[s],!0):n[s];t.insertBefore(r,g(e))}}return Ve(e),!0}(e,n,t);return!1===i&&st(L.afterSanitizeElements,e,null),i}if(1===(y?y(e):e.nodeType)&&!function(e){let t=f(e);t&&t.tagName||(t={namespaceURI:Ie,tagName:"template"});const i=gv(e.tagName),n=gv(t.tagName);return!!Pe[e.namespaceURI]&&(e.namespaceURI===Te?function(e,t,i){return t.namespaceURI===xe?"svg"===e:t.namespaceURI===Ee?"svg"===e&&("annotation-xml"===i||Ae[i]):Boolean(We[e])}(i,t,n):e.namespaceURI===Ee?function(e,t,i){return t.namespaceURI===xe?"math"===e:t.namespaceURI===Te?"math"===e&&Oe[i]:Boolean(je[e])}(i,t,n):e.namespaceURI===xe?function(e,t,i){return!(t.namespaceURI===Te&&!Oe[i])&&!(t.namespaceURI===Ee&&!Ae[i])&&!je[e]&&(De[e]||!We[e])}(i,t,n):!("application/xhtml+xml"!==$e||!Pe[e.namespaceURI]))}(e))return Ve(e),!0;if(("noscript"===n||"noembed"===n||"noframes"===n)&&Tv(nm,e.innerHTML))return Ve(e),!0;if(ne&&3===e.nodeType){const t=Xe(e.textContent);e.textContent!==t&&(dv(i.removed,{element:e.cloneNode()}),e.textContent=t)}return st(L.afterSanitizeElements,e,null),!1},at=function(e,t,i){if(Y[t])return!1;if(se&&"patchsrc"===t)return!1;if(se&&"for"===t&&"label"!==e&&"output"!==e)return!1;if(pe&&("id"===t||"name"===t)&&(i in n||i in He))return!1;const s=G[t]||Z.attributeCheck instanceof Function&&Z.attributeCheck(t,e);if(ee&&Tv(B,t));else if(X&&Tv(q,t));else if(s){if(ke[t]);else if(Tv(W,vv(i,U,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==mv(i,"data:")||!Se[e])if(te&&!Tv(H,vv(i,U,"")));else if(i)return!1}else if(!(ct(e)&&(K.tagNameCheck instanceof RegExp&&Tv(K.tagNameCheck,e)||K.tagNameCheck instanceof Function&&K.tagNameCheck(e))&&(K.attributeNameCheck instanceof RegExp&&Tv(K.attributeNameCheck,t)||K.attributeNameCheck instanceof Function&&K.attributeNameCheck(t,e))||"is"===t&&K.allowCustomizedBuiltInElements&&(K.tagNameCheck instanceof RegExp&&Tv(K.tagNameCheck,i)||K.tagNameCheck instanceof Function&&K.tagNameCheck(i))))return!1;return!0},lt=Pv({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ct=function(e){return!lt[gv(e)]&&Tv(z,e)},ut=function(e,t,i,n){if(w&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!i)switch(u.getAttributeType(e,t)){case"TrustedHTML":return I(n);case"TrustedScriptURL":return function(e){x(),T++;try{return w.createScriptURL(e)}finally{T--}}(n)}return n},dt=function(e,t,n,s){try{n?e.setAttributeNS(n,t,s):e.setAttribute(t,s),tt(e)?Ve(e):uv(i.removed)}catch(i){Qe(t,e)}},ht=function(e){st(L.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||tt(e))return;G=rt(L.uponSanitizeAttribute,G,Q,le);const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let n=t.length;const s=Be(e.nodeName);for(;n--;){const r=t[n],o=r.name,a=r.namespaceURI,l=r.value,c=Be(o),u=l;let d="value"===o?u:yv(u);i.attrName=c,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,st(L.uponSanitizeAttribute,e,i),d=i.attrValue,!ge||"id"!==c&&"name"!==c||0===mv(d,_e)||(Qe(o,e),d=_e+d),se&&Tv(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)||"attributename"===c&&fv(d,"href")?Qe(o,e):i.forceKeepAttr||(!i.keepAttr||!ie&&Tv(sm,d)?Qe(o,e):(ne&&(d=Xe(d)),at(s,c,d)?(d=ut(s,c,a,d),d!==u&&dt(e,o,a,d)):Qe(o,e)))}st(L.afterSanitizeAttributes,e,null)},pt=function(e){let t=null;const i=Ze(e);for(st(L.beforeSanitizeShadowDOM,e,null);t=i.nextNode();)if(st(L.uponSanitizeShadowNode,t,null),ot(t,e),ht(t),it(t.content)&&pt(t.content),1===(y?y(t):t.nodeType)){const e=v(t);it(e)&&(gt(e),pt(e))}st(L.afterSanitizeShadowDOM,e,null)},gt=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){pt(e.shadow);continue}const i=e.node,n=1===(y?y(i):i.nodeType),s=_(i);if(s)for(let e=s.length-1;e>=0;--e)t.push({node:s[e],shadow:null});if(n){const e=b?b(i):null;if("string"==typeof e&&"template"===Be(e)){const e=i.content;it(e)&&t.push({node:e,shadow:null})}}if(n){const e=v(i);it(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,o=null,a=null;if(Re=!e,Re&&(e="\x3c!--\x3e"),"string"!=typeof e&&!nt(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return bv(e);case"boolean":return Sv(e);case"bigint":return wv?wv(e):"0";case"symbol":return kv?kv(e):"Symbol()";case"undefined":default:return Ev(e);case"function":case"object":{if(null===e)return Ev(e);const t=e,i=Av(t,"toString");if("function"==typeof i){const e=i(t);return"string"==typeof e?e:Ev(e)}return Ev(e)}}}(e)))throw xv("dirty is not a string, aborting");if(!i.isSupported)return e;oe?(j=ae,G=le):ze(t),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(j=Fv(j)),L.uponSanitizeAttribute.length>0&&(G=Fv(G)),i.removed=[];const l=ve&&"string"!=typeof e&&nt(e);if(l){!function(e){if(!se)return;const t=[e];for(;t.length>0;){const e=t.pop(),i=y?y(e):e.nodeType;if(7===i||8===i&&Tv(im,e.data)){try{p(e)}catch(e){}continue}if(1===i){const t=e,i=Be(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute("patchsrc")&&t.removeAttribute("patchsrc"),t.hasAttribute&&t.hasAttribute("for")&&"label"!==i&&"output"!==i&&t.removeAttribute("for")}catch(e){}}const n=_(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}}(e);const t=b?b(e):e.nodeName;if("string"==typeof t){const i=Be(t);if(!j[i]||J[i])throw Ge(e),xv("root node is forbidden and cannot be sanitized in-place")}if(tt(e))throw Ge(e),xv("root node is clobbered and cannot be sanitized in-place");try{gt(e)}catch(t){throw Ge(e),t}}else if(nt(e))n=Ye("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r),gt(r);else{if(!ue&&!ne&&!re&&-1===e.indexOf("<"))return w&&he?I(e):e;if(n=Ye(e),!n)return ue?null:he?C:""}n&&ce&&Ve(n.firstChild);const c=l?e:n;try{const e=Ze(c);for(;o=e.nextNode();)ot(o,c),ht(o),it(o.content)&&pt(o.content)}catch(t){throw l&&(Ge(e),lv(i.removed,e=>{e.element&&Je(e.element)})),t}if(l)return lv(i.removed,e=>{e.element&&Je(e.element)}),ne&&et(e),e;if(ue){if(ne&&et(n),de)for(a=M.call(n.ownerDocument);n.firstChild;)a.appendChild(n.firstChild);else a=n;return(G.shadowroot||G.shadowrootmode)&&(a=A.call(s,a,!0)),a}let u=re?n.outerHTML:n.innerHTML;return re&&j["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Tv(Xv,n.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+u),ne&&(u=Xe(u)),w&&he?I(u):u},i.setConfig=function(){ze(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,ae=j,le=G},i.clearConfig=function(){qe=null,oe=!1,ae=null,le=null,w=k,C=""},i.isValidAttribute=function(e,t,i){qe||ze({});const n=Be(e),s=Be(t);return at(n,s,i)},i.addHook=function(e,t){"function"==typeof t&&Cv(L,e)&&dv(L[e],t)},i.removeHook=function(e,t){if(Cv(L,e)){if(void 0!==t){const i=cv(L[e],t);return-1===i?void 0:hv(L[e],i,1)[0]}return uv(L[e])}},i.removeHooks=function(e){Cv(L,e)&&(L[e]=[])},i.removeAllHooks=function(){L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();const lm=["a","abbr","acronym","area","article","aside","b","bdi","bdo","blockquote","br","caption","center","cite","code","col","colgroup","data","dd","del","details","dfn","div","dl","dt","em","figcaption","figure","footer","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","img","ins","kbd","li","map","mark","nav","ol","p","pre","q","rp","rt","rtc","ruby","s","samp","small","span","strike","strong","sub","summary","sup","table","tbody","td","th","thead","time","tr","tt","u","ul","var","wbr"],cm=["style","lang","title","width","height"],um=["abbr","align","axis","bgcolor","char","charoff","colspan","headers","height","nowrap","rowspan","scope","valign","width"],dm={a:["href","hreflang","target","rel"],bdo:["dir"],blockquote:["cite"],col:["align","char","charoff","span"],colgroup:["align","char","charoff","span"],del:["cite","datetime"],hr:["align","size","width"],img:["align","alt","height","src","width"],ins:["cite","datetime"],ol:["start","type"],q:["cite"],table:["align","bgcolor","border","cellpadding","cellspacing","frame","rules","summary","width"],tbody:["align","char","charoff","valign"],td:um,tfoot:["align","char","charoff","valign"],th:um,thead:["align","char","charoff","valign"],tr:["align","bgcolor","char","charoff","valign"]};let hm;function pm(e){var t;const i=(null!==(t=hm)&&void 0!==t?t:hm=am()).sanitize(e,{ALLOWED_TAGS:lm,ALLOWED_ATTR:[],ALLOW_ARIA_ATTR:!1,ALLOW_DATA_ATTR:!1,ALLOWED_NAMESPACES:["http://www.w3.org/1999/xhtml"],ADD_ATTR:(e,t)=>-1!==cm.indexOf(e)||{}.hasOwnProperty.call(dm,t)&&-1!==(dm[t]||[]).indexOf(e),RETURN_DOM_FRAGMENT:!0}),n=i.querySelectorAll("a");for(let e=0;n.length>e;e++)n.item(e).relList.add("noopener");const s=document.createElement("div");return s.appendChild(i),s.innerHTML}const gm=Br("[Stylesheet Loader]"),_m="#020617",fm={fontFamily:"inherit",backgroundColor:"#eeeded",submitButtonColor:"black",submitButtonTextColor:"white",ratingButtonColor:"white",ratingButtonActiveColor:"black",borderColor:"#c9c6c6",whiteLabel:!1,displayThankYouMessage:!0,thankYouMessageHeader:"Thank you for your feedback!",position:Mf.Right,widgetType:Pf.Tab,widgetLabel:"Feedback",widgetColor:"black",zIndex:String(2147483645),disabledButtonOpacity:"0.6",maxWidth:"300px",textSubtleColor:"#939393",boxPadding:"20px 24px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",borderRadius:"10px",shuffleQuestions:!1,outlineColor:"rgba(59, 130, 246, 0.8)",inputBackground:"white",inputTextColor:_m,scrollbarThumbColor:"var(--ph-survey-border-color)",scrollbarTrackColor:"var(--ph-survey-background-color)"},vm=[Mf.Center,Mf.Left,Mf.Right];function mm(e){if(e.startsWith("#")){let t=e.replace(/^#/,"");return/^[0-9A-Fa-f]{3}$/.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),/^[0-9A-Fa-f]{6}$/.test(t)?`rgb(${parseInt(t.slice(0,2),16)},${parseInt(t.slice(2,4),16)},${parseInt(t.slice(4,6),16)})`:"rgb(255, 255, 255)"}return"rgb(255, 255, 255)"}function ym(e=fm.backgroundColor){let t;"#"===e[0]&&(t=mm(e)),e.startsWith("rgb")&&(t=e);const i={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}[e.toLowerCase()];if(i&&(t=mm(i)),!t)return _m;const n=t.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);if(n){const e=parseInt(n[1]),t=parseInt(n[2]),i=parseInt(n[3]);return Math.sqrt(e*e*.299+t*t*.587+i*i*.114)>127.5?_m:"white"}return _m}const bm=(e,t,i)=>{const n=Bm(e),s=document.querySelector(`.${n}`);if(s&&s.shadowRoot)return{shadow:s.shadowRoot,isNewlyCreated:!1};const r=document.createElement("div");((e,t,i)=>{const n=ct(ct({},fm),i),s=e.style,r=!vm.includes(n.position)||t===Af.Widget&&(null==i?void 0:i.widgetType)===Pf.Tab;s.setProperty("--ph-survey-font-family",function(e){if("inherit"===e)return"inherit";const t='BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';return e?`${e}, ${t}`:`-apple-system, ${t}`}(n.fontFamily)),s.setProperty("--ph-survey-box-padding",n.boxPadding),s.setProperty("--ph-survey-max-width",n.maxWidth),s.setProperty("--ph-survey-z-index",n.zIndex),s.setProperty("--ph-survey-border-color",n.borderColor),r?(s.setProperty("--ph-survey-border-radius",n.borderRadius),s.setProperty("--ph-survey-border-bottom","1.5px solid var(--ph-survey-border-color)")):(s.setProperty("--ph-survey-border-bottom","none"),s.setProperty("--ph-survey-border-radius",`${n.borderRadius} ${n.borderRadius} 0 0`)),s.setProperty("--ph-survey-background-color",n.backgroundColor),s.setProperty("--ph-survey-box-shadow",n.boxShadow),s.setProperty("--ph-survey-disabled-button-opacity",n.disabledButtonOpacity),s.setProperty("--ph-survey-submit-button-color",n.submitButtonColor),s.setProperty("--ph-survey-submit-button-text-color",(null==i?void 0:i.submitButtonTextColor)||ym(n.submitButtonColor)),s.setProperty("--ph-survey-rating-bg-color",n.ratingButtonColor),s.setProperty("--ph-survey-rating-active-bg-color",n.ratingButtonActiveColor),s.setProperty("--ph-survey-rating-active-text-color",ym(n.ratingButtonActiveColor)),s.setProperty("--ph-survey-text-primary-color",(null==i?void 0:i.textColor)||ym(n.backgroundColor)),s.setProperty("--ph-survey-text-subtle-color",n.textSubtleColor),s.setProperty("--ph-widget-color",n.widgetColor),s.setProperty("--ph-widget-text-color",ym(n.widgetColor)),s.setProperty("--ph-widget-z-index",n.zIndex);const o=(null==i?void 0:i.inputBackground)||(null==i?void 0:i.inputBackgroundColor);let a=o||n.inputBackground;o||"white"!==n.backgroundColor||(a="#f8f8f8"),s.setProperty("--ph-survey-input-background",a);const l=(null==i?void 0:i.inputTextColor)||ym(a);s.setProperty("--ph-survey-input-text-color",l),s.setProperty("--ph-survey-rating-text-color",l),s.setProperty("--ph-survey-scrollbar-thumb-color",n.scrollbarThumbColor),s.setProperty("--ph-survey-scrollbar-track-color",n.scrollbarTrackColor),s.setProperty("--ph-survey-outline-color",n.outlineColor)})(r,e.type,e.appearance),r.className=n;const o=r.attachShadow({mode:"open"}),a=function(e){const t=((e,t,i)=>{let n=e.createElement("style");n.innerText=t;const s=(e=>{var t;return Ct(e)?e:null==e||null===(t=e.config)||void 0===t?void 0:t.prepare_external_dependency_stylesheet})(i);return s&&(n=s(n)),n||(gm.error("prepare_external_dependency_stylesheet returned null"),null)})(document,':host{--ph-survey-font-family:-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--ph-survey-box-padding:20px 24px;--ph-survey-max-width:300px;--ph-survey-z-index:calc(2147480000 + 3645);--ph-survey-border-color:#dcdcdc;--ph-survey-border-bottom:1.5px solid var(--ph-survey-border-color);--ph-survey-border-radius:10px;--ph-survey-background-color:#eeeded;--ph-survey-box-shadow:0 4px 12px #00000026;--ph-survey-submit-button-color:black;--ph-survey-submit-button-text-color:white;--ph-survey-rating-bg-color:white;--ph-survey-rating-text-color:#020617;--ph-survey-rating-active-bg-color:black;--ph-survey-rating-active-text-color:white;--ph-survey-text-primary-color:#020617;--ph-survey-text-subtle-color:#939393;--ph-widget-color:#e0a045;--ph-widget-text-color:white;--ph-survey-scrollbar-thumb-color:var(--ph-survey-border-color);--ph-survey-scrollbar-track-color:var(--ph-survey-background-color);--ph-survey-outline-color:#3b82f6cc;--ph-survey-input-background:white;--ph-survey-input-text-color:#020617;--ph-survey-disabled-button-opacity:.6}.ph-survey{min-width:300px;width:var(--ph-survey-max-width);max-width:85%;z-index:var(--ph-survey-z-index);height:fit-content;margin:0;position:fixed;bottom:0}.ph-survey h3,.ph-survey p{margin:0}.ph-survey *{box-sizing:border-box;font-family:var(--ph-survey-font-family);color:var(--ph-survey-text-primary-color)}.ph-survey textarea,.ph-survey input[type=text],.ph-survey .multiple-choice-options label{color:var(--ph-survey-input-text-color);background:var(--ph-survey-input-background);border:1.5px solid var(--ph-survey-border-color);border-radius:4px;padding:10px;transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey textarea,.ph-survey input[type=text]{transition:border-color .2s ease-out,box-shadow .2s ease-out,transform .15s ease-out}.ph-survey input{margin:0}.ph-survey textarea:focus,.ph-survey textarea:focus-visible,.ph-survey input[type=text]:focus,.ph-survey input[type=text]:focus-visible,.ph-survey .form-submit:focus,.ph-survey .form-submit:focus-visible,.ph-survey input[type=checkbox]:focus,.ph-survey input[type=radio]:focus,.ph-survey input[type=checkbox]:focus-visible,.ph-survey input[type=radio]:focus-visible{outline:1.5px solid var(--ph-survey-outline-color);border-color:var(--ph-survey-rating-active-bg-color);outline-offset:2px}.ph-survey textarea:focus:not(:focus-visible),.ph-survey input[type=text]:focus:not(:focus-visible),.ph-survey button:focus:not(:focus-visible),.ph-survey input[type=checkbox]:focus:not(:focus-visible),.ph-survey input[type=radio]:focus:not(:focus-visible){outline:none}.ph-survey textarea:hover:not(:focus),.ph-survey input[type=text]:hover:not(:focus){border-color:var(--ph-survey-rating-active-bg-color)}@media (max-width:768px){.ph-survey textarea,.ph-survey input[type=text]{font-size:1rem}}.ph-survey .multiple-choice-options label,.ph-survey .rating-options-number,.ph-survey .form-cancel,.ph-survey input[type=checkbox],.ph-survey input[type=radio]{border:1.5px solid var(--ph-survey-border-color)}.ph-survey label,.ph-survey input[type=checkbox],.ph-survey input[type=radio],.ph-survey .ratings-emoji,.ph-survey .ratings-number,.ph-survey .footer-branding,.ph-survey .form-cancel,.ph-survey .form-submit{transition:all .2s ease-out}@media (prefers-reduced-motion:no-preference){.ph-survey button:active,.ph-survey input[type=checkbox]:active,.ph-survey input[type=radio]:active,.ph-survey label:active{transition-duration:.1s}}.ph-survey-widget-tab{background:var(--ph-widget-color);color:var(--ph-widget-text-color);text-align:center;cursor:pointer;z-index:var(--ph-survey-z-index);border:none;border-radius:3px 3px 0 0;padding:10px 12px;transition:padding .2s ease-out;position:fixed}.ph-survey-widget-tab:hover:not(.widget-tab-top){padding-bottom:16px}.ph-survey-widget-tab.widget-tab-top{border-radius:0 0 3px 3px}.ph-survey-widget-tab.widget-tab-top:hover{padding-top:16px}@keyframes ph-survey-fade-in{0%{opacity:0}to{opacity:1}}.survey-box{flex-direction:column;gap:16px;display:flex}.bottom-section{flex-direction:column;gap:8px;display:flex}.thank-you-message-header~.bottom-section,.intro-screen-header~.bottom-section{padding-top:16px}.question-container,.thank-you-message,.intro-screen{flex-direction:column;gap:8px;display:flex}.survey-question{font-size:14px;font-weight:500}.survey-question-description{opacity:.8;padding-top:4px;font-size:13px}.survey-question-description,.thank-you-message-body,.intro-screen-body{word-wrap:break-word;overflow-wrap:break-word}:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) img,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) video,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) iframe,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) embed,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) object,:is(.survey-question-description,.thank-you-message-body,.intro-screen-body) svg{max-width:100%;height:auto}.question-textarea-wrapper{flex-direction:column;display:flex}.survey-form{animation:.3s ease-out forwards ph-survey-fade-in}.survey-form,.thank-you-message,.intro-screen{text-align:left;width:100%;z-index:var(--ph-survey-z-index);border:1.5px solid var(--ph-survey-border-color);border-bottom:var(--ph-survey-border-bottom);background:var(--ph-survey-background-color);border-radius:var(--ph-survey-border-radius);box-shadow:var(--ph-survey-box-shadow);padding:var(--ph-survey-box-padding);margin:0;position:relative}.survey-form textarea,.survey-form input[type=text]{min-width:100%}.survey-form textarea:focus,.survey-form textarea:focus-visible{box-shadow:0 4px 12px #00000014}.survey-form textarea:focus:not(:focus-visible){box-shadow:none}.survey-box .question-header--empty~.multiple-choice-options,.survey-box .question-header--empty~textarea{margin-top:0}.multiple-choice-options{border:none;flex-direction:column;gap:8px;margin:0;padding:1px 0;font-size:14px;display:flex}.multiple-choice-options label,.multiple-choice-options .response-choice{color:inherit;align-items:center;gap:8px;display:flex}.multiple-choice-options label{cursor:pointer;font-size:13px}.multiple-choice-options label:hover:not(:has(input:checked)){border-color:var(--ph-survey-text-subtle-color);box-shadow:0 2px 8px #00000014}.multiple-choice-options label:has(input:checked){border-color:var(--ph-survey-rating-active-bg-color);box-shadow:0 1px 4px #0000000d}.multiple-choice-options label.choice-option-open{flex-wrap:wrap}.multiple-choice-options label span{color:inherit}.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--ph-survey-input-background);cursor:pointer;z-index:1;border-radius:3px;flex-shrink:0;width:1rem;height:1rem;transition:all .2s cubic-bezier(.4,0,.2,1),transform .15s ease-out;position:relative}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):focus{transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):hover{border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1.05)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):active{transform:scale(.95)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked{background:var(--ph-survey-rating-active-bg-color);border-color:var(--ph-survey-rating-active-bg-color);transform:scale(1)}:is(.multiple-choice-options input[type=checkbox],.multiple-choice-options input[type=radio]):checked:hover{transform:scale(1.05)}.multiple-choice-options input[type=checkbox]:checked:after{border:solid var(--ph-survey-rating-active-text-color);border-width:0 2px 2px 0;width:4px;height:8px;animation:.2s ease-out .1s forwards ph-survey-checkmark-reveal;left:4px;transform:rotate(45deg)scale(0)}.multiple-choice-options input[type=radio]:checked:after{background:var(--ph-survey-rating-active-text-color);border-radius:50%;width:6px;height:6px;animation:.15s ease-out 50ms forwards ph-survey-radio-reveal;top:5px;left:5px;transform:scale(0)}.multiple-choice-options input[type=checkbox]:checked:after,.multiple-choice-options input[type=radio]:checked:after{content:"";box-sizing:content-box;position:absolute}.multiple-choice-options input[type=radio]{border-radius:50%}.multiple-choice-options input[type=radio]:checked{border:none}:is(.multiple-choice-options input[type=checkbox]:checked,.multiple-choice-options input[type=radio]:checked)~*{font-weight:700}.multiple-choice-options .choice-option-open input[type=text]::placeholder{color:var(--ph-survey-text-subtle-color);font-weight:400}.rating-options-emoji{justify-content:space-between;display:flex}.rating-options-emoji-2{justify-content:space-around}.ratings-emoji{opacity:.5;background-color:#0000;border:none;padding:0;font-size:16px}.ratings-emoji:hover{cursor:pointer;opacity:1;transform:scale(1.15)}.ratings-emoji.rating-active{opacity:1}.ratings-emoji svg{fill:var(--ph-survey-text-primary-color);transition:fill .2s ease-out}.rating-options-number{border-radius:6px;grid-auto-columns:1fr;grid-auto-flow:column;display:grid;overflow:hidden}.rating-options-number .ratings-number{border-right:1px solid var(--ph-survey-border-color);text-align:center;cursor:pointer;color:var(--ph-survey-rating-text-color);border-top:none;border-bottom:none;border-left:none;font-weight:700}.rating-options-number .ratings-number:last-of-type{border-right:0}.rating-options-number .ratings-number.rating-active{background:var(--ph-survey-rating-active-bg-color);color:var(--ph-survey-rating-active-text-color)}.ratings-number{background-color:var(--ph-survey-rating-bg-color);border:none;padding:8px 0}.ratings-number .rating-active{background-color:var(--ph-survey-rating-active-bg-color)}.ratings-number{cursor:pointer}@media (hover:hover) and (pointer:fine){.ratings-number:hover:not(.rating-active){background-color:color-mix(in srgb, var(--ph-survey-rating-active-bg-color) 14%, var(--ph-survey-rating-bg-color))}}.rating-text{opacity:.7;flex-direction:row;justify-content:space-between;font-size:11px;display:flex}.form-buttons{flex-direction:row;gap:8px;width:100%;display:flex}.form-buttons-with-back>.form-submit{flex:auto;min-width:0}.form-submit{text-align:center;cursor:pointer;user-select:none;background:var(--ph-survey-submit-button-color);color:var(--ph-survey-submit-button-text-color);border:none;border-radius:6px;min-width:100%;padding:12px;font-weight:700;box-shadow:0 2px #0000000b}.form-submit:not([disabled]):hover{transform:scale(1.02);box-shadow:0 4px 8px #0000001a}.form-submit:not([disabled]):active{transform:scale(.98);box-shadow:0 1px 2px #0000000d}.form-submit[disabled]{opacity:var(--ph-survey-disabled-button-opacity);cursor:not-allowed}.form-back{text-align:center;cursor:pointer;user-select:none;color:var(--ph-survey-text-primary-color);border:1.5px solid var(--ph-survey-border-color);background:0 0;border-radius:6px;flex:none;padding:12px 16px;font-weight:600}.form-back:hover{transform:scale(1.02)}.form-back:active{transform:scale(.98)}.validation-hint{opacity:.7;margin-top:4px;font-size:12px}.form-cancel{cursor:pointer;background:#fff;border-radius:100%;padding:12px;line-height:0;position:absolute;top:0;right:0;transform:translate(50%,-50%)}.form-cancel:hover{opacity:.7;transform:translate(50%,-50%)scale(1.1)}.footer-branding{opacity:.6;justify-content:center;align-items:center;gap:4px;font-size:11px;font-weight:500;text-decoration:none;display:flex}.footer-branding:hover{opacity:1}.footer-branding a{text-decoration:none}.thank-you-message{text-align:center}.thank-you-message-header{margin:10px 0 0}.thank-you-message-body{opacity:.8;font-size:14px}.intro-screen{text-align:center;animation:.3s ease-out forwards ph-survey-fade-in}.intro-screen-header{margin:10px 0 0}.intro-screen-body{opacity:.8;font-size:14px}.limit-height{scrollbar-width:thin;scrollbar-color:var(--ph-survey-scrollbar-thumb-color) var(--ph-survey-scrollbar-track-color);max-height:256px;overflow:hidden auto}.limit-height::-webkit-scrollbar{width:8px}.limit-height::-webkit-scrollbar-track{background:var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb{background-color:var(--ph-survey-scrollbar-thumb-color);border:2px solid var(--ph-survey-scrollbar-track-color);border-radius:4px}.limit-height::-webkit-scrollbar-thumb:hover{background-color:var(--ph-survey-text-subtle-color)}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (prefers-reduced-motion:reduce){.ph-survey *{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@keyframes ph-survey-checkmark-reveal{0%{opacity:0;transform:rotate(45deg)scale(0)}50%{opacity:1;transform:rotate(45deg)scale(1.2)}to{opacity:1;transform:rotate(45deg)scale(1)}}@keyframes ph-survey-radio-reveal{0%{opacity:0;transform:scale(0)}50%{opacity:1;transform:scale(1.3)}to{opacity:1;transform:scale(1)}}',null==e?void 0:e.config.prepareStylesheet);return null==t||t.setAttribute("data-ph-survey-style","true"),t}(t);if(a){const e=o.querySelector("style");e&&o.removeChild(e),o.appendChild(a)}return(i||document.body).appendChild(r),{shadow:o,isNewlyCreated:!0}},Sm=e=>{try{const t=jf(e);localStorage.getItem(t)||localStorage.setItem(t,"true")}catch(e){qf.error("Failed to persist survey seen state",e)}},wm=({responses:e,survey:t,surveySubmissionId:i,posthog:n,isSurveyCompleted:s,properties:r,surveyLanguage:o,questionSnapshots:a})=>{var l,c,u;n?(null===(l=n.client)||void 0===l?void 0:l.canCapture)&&(Sm(t),s&&Nm(t),null===(c=n.client)||void 0===c||c.capture($f.SENT,ct(ct(ct({[Nf.SURVEY_NAME]:t.name,[Nf.SURVEY_ID]:t.id,[Nf.SURVEY_ITERATION]:t.current_iteration,[Nf.SURVEY_ITERATION_START_DATE]:t.current_iteration_start_date,sessionRecordingUrl:tf(n)},ic(ct(ct({event:"sent",survey:t,responses:e,submissionId:i,completed:s},!xt(o)&&{surveyLanguage:o}),!xt(a)&&{questionSnapshots:a}))),r),{},{$set:{[sc(t,"responded")]:!0}})),s&&(window.dispatchEvent(new CustomEvent("PHSurveySent",{detail:{surveyId:t.id}})),null===(u=n.client)||void 0===u||null===(u=u.getExtension("featureFlagsCommon"))||void 0===u||u.reloadFeatureFlags())):qf.error("[survey sent] event not captured, PostHog instance not found.")},km=(e,t,i,n)=>ct({[Nf.SURVEY_NAME]:t.name,[Nf.SURVEY_ID]:t.id,[Nf.SURVEY_ITERATION]:t.current_iteration,[Nf.SURVEY_ITERATION_START_DATE]:t.current_iteration_start_date,sessionRecordingUrl:tf(n)},ic(ct(ct(ct(ct({event:e,survey:t},!xt(null==i?void 0:i.responses)&&{responses:i.responses}),!xt(null==i?void 0:i.surveySubmissionId)&&{submissionId:i.surveySubmissionId}),!xt(null==i?void 0:i.surveyLanguage)&&{surveyLanguage:i.surveyLanguage}),!xt(null==i?void 0:i.questionSnapshots)&&{questionSnapshots:i.questionSnapshots}))),Cm=(e,t,i,n)=>{var s;if(!t)return void qf.error("[survey dismissed] event not captured, PostHog instance not found.");if(i)return;const r=Dm(e),o=r?r.surveyLanguage:n,a=ct(ct(ct({},km("dismissed",e,r,t)),o&&{[Nf.SURVEY_LANGUAGE]:o}),{},{$set:{[sc(e,"dismissed")]:!0}});Nm(e),Sm(e),null===(s=t.client)||void 0===s||s.capture($f.DISMISSED,a),window.dispatchEvent(new CustomEvent("PHSurveyClosed",{detail:{surveyId:e.id}}))},Em=(e,t)=>{var i,n;if(!t)return void qf.error("[survey abandoned] event not captured, PostHog instance not found.");if(!(null===(i=t.client)||void 0===i?void 0:i.canCapture))return;const s=(e=>Wf("abandonedSurvey_",e))(e);try{if("true"===localStorage.getItem(s))return}catch(e){return}const r=Dm(e);if(r){try{localStorage.setItem(s,"true")}catch(e){}null===(n=t.client)||void 0===n||n.capture($f.ABANDONED,km("abandoned",e,r,t),{delivery:"unload"})}},Tm=e=>{const t=e.map(e=>e.id);return t.every(e=>!!e)?t:void 0},xm=(e,t)=>{var i,n,s;return(e=>e.questions.some(e=>{var t;return!!(null===(t=e.branching)||void 0===t?void 0:t.type)}))(e)?e.questions:t?null!==(i=((e,t)=>{if(!t||t.length!==e.questions.length)return null;const i=new Map(e.questions.map(e=>[e.id,e])),n=[];for(const e of t){const t=i.get(e);if(!t)return null;n.push(t)}return n})(e,t.questionOrder))&&void 0!==i?i:e.questions:e.appearance&&e.appearance.shuffleQuestions&&!e.enable_partial_responses?(n=e.questions,s=fc(e.questions),n.length===s.length&&n.every((e,t)=>e===s[t])?s.reverse():s):e.questions},Im=e=>dc(e)||$m(e),Rm=function(e){function t(e){var i,n;return this.getChildContext||(i=new Set,(n={})[t.__c]=this,this.getChildContext=function(){return n},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&i.forEach(function(e){e.__e=!0,D_(e)})},this.sub=function(e){i.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i&&i.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+w_++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed(){},isPopup:!0,onPreviewSubmit(){},onPreviewBack(){},surveySubmissionId:"",properties:void 0,surveyLanguage:null}),Pm=()=>Sf(Rm),Mm=({component:e,children:t,renderAsHtml:i,style:n})=>function(e,t,i){var n,s,r,o,a=x_({},e.props);for(r in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)"key"==r?n=t[r]:"ref"==r?s=t[r]:a[r]=void 0===t[r]&&null!=o?o[r]:t[r];return arguments.length>2&&(a.children=arguments.length>3?l_.call(arguments,2):i),P_(e.type,a,n||e.key,s||e.ref,null)}(e,i?{dangerouslySetInnerHTML:{__html:pm(t)},style:n}:{children:t,style:n});function Fm(e,t){var i,n,s;if(!(null===(i=e.conditions)||void 0===i?void 0:i.url))return!0;const r=null!==(n=lo(t))&&void 0!==n?n:"u">typeof window?window.location.href:void 0;if(!r)return!1;const o=[e.conditions.url],a=function(e){return null!=e?e:"icontains"}(null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType);return gc[a](o,[r])}const Am=e=>Wf("inProgressSurvey_",e),Lm={},Om=(e,t)=>{const i=Am(e);try{localStorage.setItem(i,JSON.stringify(t)),delete Lm[i]}catch(e){qf.error("Error setting in-progress survey state in localStorage",e),Lm[i]=t}},Dm=e=>{const t=Am(e),i=Lm[t];if(i)return i;try{const e=localStorage.getItem(t);if(e)return JSON.parse(e)}catch(e){qf.error("Error getting in-progress survey state from localStorage",e)}return null},$m=e=>{const t=Dm(e);return!Mt(null==t?void 0:t.surveySubmissionId)},Nm=e=>{const t=Am(e);delete Lm[t];try{localStorage.removeItem(t)}catch(e){qf.error("Error clearing in-progress survey state from localStorage",e)}};function Bm(e,t=!1){const i=`PostHogSurvey-${e.id}`;return t?`.${i}`:i}function qm(e,t=Mf.Right,i){if(e===Af.ExternalSurvey)return{};switch(t){case Mf.TopLeft:return{top:"0",left:"0",transform:"translate(30px, 30px)"};case Mf.TopRight:return{top:"0",right:"0",transform:"translate(-30px, 30px)"};case Mf.TopCenter:return{top:"0",left:"50%",transform:"translate(-50%, 30px)"};case Mf.MiddleLeft:return{top:"50%",left:"0",transform:"translate(30px, -50%)"};case Mf.MiddleRight:return{top:"50%",right:"0",transform:"translate(-30px, -50%)"};case Mf.MiddleCenter:return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case Mf.Left:return{left:"30px"};case Mf.Center:return{left:"50%",transform:"translateX(-50%)"};default:return{right:e===Af.Widget&&i===Pf.Tab?"60px":"30px"}}}const Hm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),Um=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),zm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),Wm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z"})}),jm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 -960 960 960",width:"48",children:X_("path",{d:"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"})}),Vm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:X_("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66-.23-.45-.52-.86-.88-1.22L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})}),Gm=X_("svg",{className:"emoji-svg",xmlns:"http://www.w3.org/2000/svg",height:"48",viewBox:"0 0 24 24",width:"48",children:X_("path",{d:"M22 4h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2V4zM2.17 11.12c-.11.25-.17.52-.17.8V13c0 1.1.9 2 2 2h5.5l-.92 4.65c-.05.22-.02.46.08.66.23.45.52.86.88 1.22L10 22l6.41-6.41c.38-.38.59-.89.59-1.42V6.34C17 5.05 15.95 4 14.66 4H6.55c-.7 0-1.36.37-1.72.97l-2.66 6.15z"})}),Qm=({fill:e="currentColor"}={})=>X_("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:e,xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"close-survey-title-adam",children:[X_("title",{id:"close-survey-title",className:"adam-testing",children:"Close survey"}),X_("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z",fill:e})]}),Km=X_("svg",{width:"80",height:"14",viewBox:"0 0 160 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[X_("g",{"clip-path":"url(#ph-survey-logo-clip)",children:[X_("path",{fill:"currentColor",d:"m50 23.34-.35-.05A4.5 4.5 0 0 1 47 21.97L35.56 10.1c-.3-.33-.86-.1-.86.35V27.5c0 .27.22.5.5.5h13.78c1.48 0 2.67-1.2 2.67-2.67v-.1a1.9 1.9 0 0 0-1.67-1.89zm-10.81.2a1.8 1.8 0 1 1 0-3.58 1.8 1.8 0 0 1 0 3.58"}),X_("path",{fill:"#0054ff",d:"M.87 19.13a.5.5 0 0 0-.87.34v5.94a2.6 2.6 0 0 0 2.59 2.58H7.8a.5.5 0 0 0 .37-.84zM.86 8.4c-.3-.32-.86-.1-.86.36v6.73q0 .2.13.34l8.81 9.68 1.8 2.06v-8.82zM4.59.82A2.67 2.67 0 0 0 0 2.68v1.93q0 .4.27.69l10.47 10.95v-9.1z"}),X_("path",{fill:"#ff5506",d:"M11.36 28h7.08a.5.5 0 0 0 .36-.85l-8.05-8.4v8.8l.23.28q.16.17.38.17m-.61-11.76 8.84 9.25 2.1 2.33q.1.11.27.14V18.7L10.75 7.15zm0-13.7v1.41a2 2 0 0 0 .55 1.28L21.96 16.2V7.65L15.32.8a2.67 2.67 0 0 0-4.57 1.71z"}),X_("path",{fill:"#ffb70f",d:"M22.06 28h7.76a.5.5 0 0 0 .36-.86l-8.22-8.45v9.27l.09.02zM31 25.49l1.13 1.14c.32.31.85.09.85-.35v-7.3l-.49-.51L21.96 7.64v8.55zM22.52 5.73l9.62 9.89c.3.32.86.1.86-.35V7.46L26.56.82a2.67 2.67 0 0 0-4.59 1.84v1.7c0 .51.2 1 .57 1.37z"})]}),X_("path",{fill:"currentColor",d:"M64.9 22.88c-.67 0-1.23-.56-1.23-1.24V5.24c0-.69.56-1.24 1.24-1.24h6.55c3.89 0 6.39 2.32 6.39 5.9 0 3.6-2.5 5.91-6.4 5.91h-3.53v5.83c0 .68-.56 1.24-1.24 1.24zm3.02-11.94c0 .68.55 1.23 1.23 1.23h1.88c1.6 0 2.58-.86 2.58-2.26s-.97-2.27-2.58-2.27h-1.88c-.68 0-1.23.55-1.23 1.23zM84.71 23.1c-4.18 0-7.14-2.97-7.14-7.02s2.96-7.01 7.14-7.01c4.14 0 7.14 2.97 7.14 7.01 0 4.05-3 7.01-7.14 7.01m-3.22-7.02c0 2.16 1.3 3.64 3.22 3.64 1.9 0 3.2-1.48 3.2-3.64s-1.3-3.64-3.2-3.64c-1.93 0-3.22 1.48-3.22 3.64m16.34 7.03a6.2 6.2 0 0 1-5.54-3.01c-.34-.57-.01-1.26.6-1.5l.77-.3c.7-.27 1.45.15 1.92.73a2.8 2.8 0 0 0 2.25 1.08c1.05 0 1.75-.51 1.75-1.27 0-2.13-7.17-.7-7.17-5.85 0-2.13 1.85-3.91 4.83-3.91 2.27 0 4.2.9 5.17 2.31.36.53.05 1.2-.54 1.44l-.85.35c-.68.29-1.45-.14-2-.63a2.5 2.5 0 0 0-1.64-.64c-.89 0-1.5.38-1.5.97 0 2.16 7.27.38 7.27 5.88 0 2.35-2.15 4.34-5.32 4.34m14.64-1.31c.04.57-.3 1.1-.86 1.2q-.6.1-1.27.11c-2.92 0-5.15-1.56-5.15-4.85v-5.66h-.91c-.69 0-1.24-.56-1.24-1.24v-.82c0-.68.55-1.23 1.24-1.23h.91v-2.7c0-.69.55-1.24 1.23-1.24h1.48c.68 0 1.24.55 1.24 1.23v2.7h2.04c.68 0 1.23.56 1.23 1.24v.82c0 .68-.55 1.24-1.23 1.24h-2.04v5.15c0 1.2.64 1.91 1.6 1.91.75 0 1.6.5 1.66 1.25zM125.5 5.23c0-.68.55-1.23 1.23-1.23h1.8c.68 0 1.23.55 1.23 1.23v16.41c0 .68-.55 1.24-1.23 1.24h-1.8c-.68 0-1.23-.56-1.23-1.24v-5.43c0-.68-.56-1.23-1.24-1.23h-5c-.67 0-1.23.55-1.23 1.23v5.43c0 .68-.55 1.24-1.23 1.24h-1.77c-.69 0-1.24-.56-1.24-1.24V5.24c0-.69.55-1.24 1.24-1.24h1.77c.68 0 1.23.55 1.23 1.23v4.87c0 .68.56 1.23 1.24 1.23h5c.67 0 1.23-.55 1.23-1.23zm12.87 17.87c-4.19 0-7.14-2.97-7.14-7.02s2.95-7.01 7.14-7.01c4.13 0 7.14 2.97 7.14 7.01 0 4.05-3 7.01-7.14 7.01m-3.22-7.02c0 2.16 1.29 3.64 3.22 3.64 1.9 0 3.2-1.48 3.2-3.64s-1.3-3.64-3.2-3.64c-1.93 0-3.22 1.48-3.22 3.64m17.17 6.37c-3.84 0-6.2-2.58-6.2-6.68s2.36-6.69 6.12-6.69c1.58 0 2.82.54 3.54 1.37 0-.64.52-1.15 1.16-1.15h1.5c.68 0 1.24.55 1.24 1.23V21.9c0 3.64-2.77 6.09-6.93 6.09-2.64 0-4.9-1.2-5.85-3.09-.31-.62.16-1.29.85-1.4l1.14-.17c.67-.11 1.29.4 1.78.85.5.46 1.26.7 2.08.7 1.85 0 3.06-1.04 3.06-2.55v-1.3c-.7.9-2.01 1.4-3.49 1.4m-2.36-6.68c0 2.02 1.18 3.31 3 3.31 1.86 0 3.04-1.29 3.04-3.31s-1.18-3.32-3.03-3.32c-1.83 0-3.01 1.3-3.01 3.32"}),X_("defs",{children:X_("clipPath",{id:"ph-survey-logo-clip",children:X_("path",{fill:"#fff",d:"M0 0h51.67v28H0z"})})})]});function Jm({urlParams:e}){const t=e?Object.entries(e).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&"):"";return X_("a",{href:"https://posthog.com/surveys"+(t?`?${t}`:""),target:"_blank",rel:"noopener",className:"footer-branding",children:["Survey by ",Km]})}function Ym({text:e,submitDisabled:t,appearance:i,onSubmit:n,link:s,onPreviewSubmit:r,skipSubmitButton:o,canGoBack:a,onBack:l}){const{isPreviewMode:c}=Sf(Rm),u=!!a&&!!l,d=!o&&X_("button",{className:"form-submit",disabled:t,"aria-label":"Submit survey",type:"button",onClick(){var e;s&&(null===(e=window)||void 0===e||e.open(s)),c?null==r||r():n()},children:e});return X_("div",{className:"bottom-section",children:[u?X_("div",{className:"form-buttons form-buttons-with-back",children:[X_("button",{className:"form-back",type:"button","aria-label":"Go to previous question",onClick:l,children:i.backButtonText||"Back"}),d]}):d,!i.whiteLabel&&X_(Jm,{urlParams:{utm_source:"survey-footer"}})]})}function Zm({question:e,forceDisableHtml:t,htmlFor:i}){return X_("div",{class:e.question||e.description?"question-header":"question-header question-header--empty",children:[X_(e.type===Lf.Open?"label":"h3",{className:"survey-question",htmlFor:i,children:e.question}),e.description&&Mm({component:R_("p",{className:"survey-question-description"}),children:e.description,renderAsHtml:!t&&"text"!==e.descriptionContentType})]})}function Xm({onClick:e}){const{isPreviewMode:t}=Sf(Rm);return X_("button",{className:"form-cancel",onClick:e,disabled:t,"aria-label":"Close survey",type:"button",children:Qm({fill:"black"})})}function ey({header:e,description:t,contentType:i,forceDisableHtml:n,appearance:s,onClose:r}){const{isPopup:o}=Sf(Rm);return mf(()=>{const e=e=>{"Enter"!==e.key&&"Escape"!==e.key||(e.preventDefault(),r())};return Kr(window,"keydown",e),()=>{window.removeEventListener("keydown",e)}},[r]),X_("div",{className:"thank-you-message",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==s.hideCancelButton&&X_(Xm,{onClick:()=>r()}),X_("h3",{className:"thank-you-message-header",children:e}),t&&Mm({component:R_("p",{className:"thank-you-message-body"}),children:t,renderAsHtml:!n&&"text"!==i}),o&&X_(Ym,{text:s.thankYouMessageCloseButtonText||"Close",submitDisabled:!1,appearance:s,onSubmit:()=>r()})]})}function ty({header:e,description:t,contentType:i,forceDisableHtml:n,appearance:s,onStart:r}){const{isPopup:o,onPreviewSubmit:a,onPopupSurveyDismissed:l}=Sf(Rm);return X_("div",{className:"intro-screen",role:"status",tabIndex:0,"aria-atomic":"true",children:[o&&!0!==s.hideCancelButton&&X_(Xm,{onClick:()=>l()}),e&&X_("h3",{className:"intro-screen-header",children:e}),t&&Mm({component:R_("p",{className:"intro-screen-body"}),children:t,renderAsHtml:!n&&"text"!==i}),X_(Ym,{text:s.introScreenButtonText||"Get started",submitDisabled:!1,appearance:s,onSubmit:r,onPreviewSubmit:()=>a(null)})]})}const iy=e=>kt(e)&&e.every(e=>It(e));function ny({question:e,forceDisableHtml:t,appearance:i,onSubmit:n,onPreviewSubmit:s,displayQuestionIndex:r,initialValue:o,canGoBack:a,onBack:l}){const{isPreviewMode:c}=Pm(),u=yf(null),[d,h]=vf(()=>It(o)?o:""),p=null==i?void 0:i.disableAutofocus;mf(()=>{p||setTimeout(()=>{var e;c||null===(e=u.current)||void 0===e||e.focus()},100)},[c,p]);const g=`surveyQuestion${r}`,_=bf(()=>function(e,t,i){const n=e.trim();if(!i&&""===n)return"This field is required";if(""===n)return!1;if(t&&t.length>0)for(const e of t)switch(e.type){case ht:var s;if(void 0!==e.value&&e.value>n.length)return null!==(s=e.errorMessage)&&void 0!==s?s:`Please enter at least ${e.value} characters`;break;case pt:var r;if(void 0!==e.value&&n.length>e.value)return null!==(r=e.errorMessage)&&void 0!==r?r:`Please enter no more than ${e.value} characters`}return!1}(d,e.validation,e.optional),[d,e.validation,e.optional]),f=Lr(e.validation,ht),v=Lr(e.validation,pt),m=bf(()=>function(e,t){const i=1===e?void 0:e;return i&&t?`Enter ${i}-${t} characters`:i?`Enter at least ${i} ${1===i?"character":"characters"}`:t?`Maximum ${t} ${1===t?"character":"characters"}`:void 0}(f,v),[f,v]),y=()=>{_||n(d.trim())},b=()=>{_||s(d.trim())};return X_(M_,{children:[X_("div",{className:"question-container",children:[X_(Zm,{question:e,forceDisableHtml:t,htmlFor:g}),X_("textarea",{ref:u,id:g,rows:4,placeholder:null==i?void 0:i.placeholder,minLength:f,maxLength:v,onInput(e){h(e.currentTarget.value),e.stopPropagation()},onKeyDown(e){e.stopPropagation(),"Enter"!==e.key||!e.metaKey&&!e.ctrlKey||_||(e.preventDefault(),c?b():y())},value:d}),m&&X_("div",{className:"validation-hint",children:m})]}),X_(Ym,{text:e.buttonText||"Submit",submitDisabled:!!_,appearance:i,onSubmit:y,onPreviewSubmit:b,canGoBack:a,onBack:l})]})}function sy({question:e,forceDisableHtml:t,appearance:i,onSubmit:n,onPreviewSubmit:s,canGoBack:r,onBack:o}){return X_(M_,{children:[X_("div",{className:"question-container",children:X_(Zm,{question:e,forceDisableHtml:t})}),X_(Ym,{text:e.buttonText||"Submit",submitDisabled:!1,link:e.link,appearance:i,onSubmit:()=>n("link clicked"),onPreviewSubmit:()=>s("link clicked"),canGoBack:r,onBack:o})]})}function ry({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:n,onSubmit:s,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){var c;const u=e.scale,d=10===e.scale?0:1,[h,p]=vf(()=>Ft(o)?o:kt(o)&&o.length>0&&Ft(parseInt(o[0]))?parseInt(o[0]):It(o)&&Ft(parseInt(o))?parseInt(o):null),g="emoji"===e.display&&2===e.scale,{isPreviewMode:_}=Pm(),f=e=>_?r(e):s(e);return X_(M_,{children:[X_("div",{className:"question-container",children:[X_(Zm,{question:e,forceDisableHtml:t}),X_("div",{className:"rating-section",children:[X_("div",{className:"rating-options",children:["emoji"===e.display&&X_("div",{className:"rating-options-emoji"+(g?" rating-options-emoji-2":""),children:null===(c=dy[e.scale])||void 0===c?void 0:c.map((t,n)=>X_("button",{"aria-label":`Rate ${n+1}`,className:`ratings-emoji question-${i}-rating-${n} ${n+1===h?"rating-active":""}`,value:n+1,type:"button",onClick(){const t=n+1;p(t),e.skipSubmitButton&&f(t)},children:t},n))}),"number"===e.display&&X_("div",{className:"rating-options-number",style:{gridTemplateColumns:`repeat(${u-d+1}, minmax(0, 1fr))`},children:hy(e.scale).map((t,s)=>X_(oy,{displayQuestionIndex:i,active:h===t,appearance:n,num:t,setActiveNumber(t){p(t),e.skipSubmitButton&&f(t)}},s))})]}),!g&&X_("div",{className:"rating-text",children:[X_("div",{children:e.lowerBoundLabel}),X_("div",{children:e.upperBoundLabel})]})]})]}),X_(Ym,{text:e.buttonText||(null==n?void 0:n.submitButtonText)||"Submit",submitDisabled:Pt(h)&&!e.optional,appearance:n,onSubmit:()=>s(h),onPreviewSubmit:()=>r(h),skipSubmitButton:e.skipSubmitButton,canGoBack:a,onBack:l})]})}function oy({num:e,active:t,displayQuestionIndex:i,setActiveNumber:n}){return X_("button",{"aria-label":`Rate ${e}`,className:`ratings-number question-${i}-rating-${e} ${t?"rating-active":""}`,type:"button",onClick(){n(e)},children:e})}function ay({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:n,onSubmit:s,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l}){const c=yf(null),u=bf(()=>(e=>{var t;if(!e.shuffleOptions)return e.choices;const i=[...e.choices],n=e.hasOpenChoice&&null!==(t=i.pop())&&void 0!==t?t:null,s=(r=i,(o=fc(i)).length>1&&r.every((e,t)=>e===o[t])?o.reverse():o);var r,o;return Pt(n)||s.push(n),s})(e),[e]),[d,h]=vf(()=>((e,t)=>It(e)||iy(e)?e:t===Lf.SingleChoice?null:[])(o,e.type)),[p,g]=vf(()=>((e,t)=>{if(It(e)&&!t.includes(e))return{isSelected:!0,inputValue:e};if(iy(e)){const i=e.find(e=>!t.includes(e));if(i)return{isSelected:!0,inputValue:i}}return{isSelected:!1,inputValue:""}})(o,u)),{isPreviewMode:_}=Pm(),f=e.type===Lf.SingleChoice,v=e.type===Lf.MultipleChoice,m=e.skipSubmitButton&&f&&!e.hasOpenChoice,y=(e,t)=>{if(t){const e=!p.isSelected;return g(t=>ct(ct({},t),{},{isSelected:e,inputValue:e?t.inputValue:""})),f&&h(""),void(e&&setTimeout(()=>{var e;return null===(e=c.current)||void 0===e?void 0:e.focus()},75))}if(f)return h(e),g(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),void(m&&(s(e),_&&r(e)));v&&kt(d)&&(d.includes(e)?h(d.filter(t=>t!==e)):h([...d,e]))},b=e=>{e.stopPropagation();const t=e.currentTarget.value;g(e=>ct(ct({},e),{},{inputValue:t})),f&&h(t)},S=e=>{e.stopPropagation(),"Enter"!==e.key||w()||(e.preventDefault(),k()),"Escape"===e.key&&(e.preventDefault(),g(e=>ct(ct({},e),{},{isSelected:!1,inputValue:""})),f&&h(null))},w=()=>!(e.optional||!Pt(d)&&(!kt(d)||p.isSelected||0!==d.length)&&(!p.isSelected||""!==p.inputValue.trim())),k=()=>{p.isSelected&&v?kt(d)&&(_?r([...d,p.inputValue]):s([...d,p.inputValue])):_?r(d):s(d)};return X_(M_,{children:[X_("div",{className:"question-container",children:[X_(Zm,{question:e,forceDisableHtml:t}),X_("fieldset",{className:"multiple-choice-options limit-height",children:[X_("legend",{className:"sr-only",children:v?" Select all that apply":" Select one"}),u.map((t,n)=>{const s=!!e.hasOpenChoice&&n===e.choices.length-1,r=`surveyQuestion${i}Choice${n}`,o=`${r}Open`,a=s?p.isSelected:f?d===t:kt(d)&&d.includes(t);return X_("label",{className:s?"choice-option-open":"",children:[X_("div",{className:"response-choice",children:[X_("input",{type:f?"radio":"checkbox",name:r,checked:a,onChange:()=>y(t,s),id:r,"aria-controls":o}),X_("span",{children:s?`${t}:`:t})]}),s&&X_("input",{type:"text",ref:c,id:o,name:`question${i}Open`,value:p.inputValue,onKeyDown:S,onInput:b,onClick(e){p.isSelected||y(t,!0),e.stopPropagation()},"aria-label":`${t} - please specify`})]},n)})]})]}),X_(Ym,{text:e.buttonText||"Submit",submitDisabled:w(),appearance:n,onSubmit:k,onPreviewSubmit:k,skipSubmitButton:m,canGoBack:a,onBack:l})]})}const ly=[1,2,3,4,5],cy=[1,2,3,4,5,6,7],uy=[0,1,2,3,4,5,6,7,8,9,10],dy={2:[Vm,Gm],3:[zm,Um,Hm],5:[Wm,zm,Um,Hm,jm]};function hy(e){switch(e){case 5:default:return ly;case 7:return cy;case 10:return uy}}const py=Br("[Surveys]");function gy(e,t,i){var n;const s=e.questions[t],r=t+1;if(!(null===(n=s.branching)||void 0===n?void 0:n.type))return t===e.questions.length-1?Of.End:r;if(s.branching.type===Of.End)return Of.End;if(s.branching.type===Of.SpecificQuestion){if(Number.isInteger(s.branching.index))return s.branching.index}else if(s.branching.type===Of.ResponseBased){if(s.type===Lf.SingleChoice){var o;let e=s.choices.indexOf(`${i}`);if(-1===e&&s.hasOpenChoice&&(e=s.choices.length-1),null===(o=s.branching)||void 0===o||null===(o=o.responseValues)||void 0===o?void 0:o.hasOwnProperty(e)){const t=s.branching.responseValues[e];if(Number.isInteger(t))return t;if(t===Of.End)return Of.End}}else if(s.type===Lf.Rating){var a;if(s.optional&&Mt(i))return r===e.questions.length?Of.End:r;if("number"!=typeof i||!Number.isInteger(i))throw new Error("The response type must be an integer");const t=function(e,t){if(2===t){if(1>e||e>2)throw new Error("The response must be in range 1-2");return 1===e?"positive":"negative"}if(3===t){if(1>e||e>3)throw new Error("The response must be in range 1-3");return 1===e?"negative":2===e?"neutral":"positive"}if(5===t){if(1>e||e>5)throw new Error("The response must be in range 1-5");return e>2?3===e?"neutral":"positive":"negative"}if(7===t){if(1>e||e>7)throw new Error("The response must be in range 1-7");return e>3?4===e?"neutral":"positive":"negative"}if(10===t){if(0>e||e>10)throw new Error("The response must be in range 0-10");return e>6?e>8?"promoters":"passives":"detractors"}throw new Error("The scale must be one of: 2, 3, 5, 7, 10")}(i,s.scale);if(null===(a=s.branching)||void 0===a||null===(a=a.responseValues)||void 0===a?void 0:a.hasOwnProperty(t)){const e=s.branching.responseValues[t];if(Number.isInteger(e))return e;if(e===Of.End)return Of.End}}return r}return py.warn("Falling back to next question index due to unexpected branching type"),r}const _y=Br("[SurveyTranslations]");function fy(e,t){const i=function(e){var t;return function({overrideLanguage:e,storedPersonProperties:t,locale:i},n){const s=rc(e);if(s)return null==n||n.info(`Using override display language: ${s}`),s;const r=function(e){return e&&"object"==typeof e&&"language"in e?rc(e.language):null}(t);if(r)return null==n||n.info(`Using person property language: ${r}`),r;const o=rc(i);return o?(null==n||n.info(`Using detected locale: ${o}`),o):(null==n||n.info("No user language detected"),null)}({overrideLanguage:e.config.overrideLanguage,storedPersonProperties:null===(t=e.client)||void 0===t?void 0:t.kv.get(S),locale:"u">typeof navigator?navigator.language||navigator.userLanguage:void 0},_y)}(t);if(!i)return _y.info("No user language detected"),{survey:e,language:null};const n=cc(e,i,_y);return{survey:n.survey,language:n.matchedKey}}const vy="ph:show_survey_widget",my="PHWidgetSurveyClickListener";function yy(e,t){try{const i=e.getBoundingClientRect(),n=window.innerHeight,s=window.innerWidth;let r=i.left+i.width/2-t/2;r+t>s-20&&(r=s-t-20),20>r&&(r=20);const o=n-i.bottom,a=250>o&&i.top>o;return{position:"fixed",top:a?"auto":`${i.bottom+12}px`,left:`${r}px`,right:"auto",bottom:a?n-i.top+12+"px":"auto",zIndex:fm.zIndex}}catch(e){return qf.warn("Failed to calculate trigger position:",e),null}}var by=class{constructor(e){var t,i;this._surveyTimeouts=new Map,this._widgetSelectorListeners=new Map,this._renderedTabWidgets=new Map,this._renderedTargets=new Map,this._prefillHandledSurveys=new Set,this._disposed=!1,this._currentLanguage=null,this._surveyIsRendered=!1,this._languageChangeListener=null,this._unsubscribeFeatureFlags=null,this._surveyPopupProps=null,this._loggedFeatureFlagsDisabledWarning=!1,this.handlePageUnload=()=>{var e;const t=null===(e=this._host.client)||void 0===e?void 0:e.kv.get(R);if(t)for(const e of t)$m(e)&&Em(e,this._host)},this.handlePopoverSurvey=(e,t,{resumeDelayFromActivation:i=!1}={})=>{var n,s,r,o,a,l,c;if(!(null===(n=this._host.client)||void 0===n?void 0:n.canCapture))return;const{survey:u,language:d}=this._translateSurveyForRendering(e);this._currentLanguage=d,this._surveyPopupProps=null,this._displayOptions=t;const h=this._applyDisplayOverrides(u,t);this._clearSurveyTimeout(h.id);const{properties:p,initialResponses:g}=null!=t?t:{},_=!(!g||0>=Object.keys(g).length)&&this._handleInitialResponses(h,g,p,d);if(_&&!(null===(s=h.appearance)||void 0===s?void 0:s.displayThankYouMessage))return;this._addSurveyToFocus(h);let f={};if((null===(r=h.appearance)||void 0===r?void 0:r.position)===Mf.NextToTrigger&&(null===(o=h.appearance)||void 0===o?void 0:o.widgetSelector)){var v;const e=document.querySelector(h.appearance.widgetSelector);e&&(f=yy(e,parseInt((null===(v=h.appearance)||void 0===v?void 0:v.maxWidth)||fm.maxWidth))||{})}const m=(null===(a=h.appearance)||void 0===a?void 0:a.surveyPopupDelaySeconds)||0,{shadow:y}=bm(h,this._host);this._renderedTargets.set(y,y.host);const b={posthog:this._host,survey:h,removeSurveyFromFocus:this._removeSurveyFromFocus,properties:p,style:f,isSurveyCompleted:_,skipShownEvent:null==t?void 0:t.skipShownEvent,surveyLanguage:d};if(this._surveyPopupProps=b,0>=m)return this._surveyIsRendered=!0,Y_(X_(Cy,ct({},b)),y);const S=()=>{this._surveyIsRendered=!0;const{survey:i,language:n}=this._translateSurveyForRendering(e);this._currentLanguage=n;const s=this._applyDisplayOverrides(i,t),r=ct(ct({},b),{},{survey:s,surveyLanguage:n});this._surveyPopupProps=r,Y_(X_(Cy,ct(ct({},r),{},{survey:ct(ct({},s),{},{appearance:ct(ct({},s.appearance),{},{surveyPopupDelaySeconds:0})})})),y)},w=()=>{var e;if(!(null===(e=this._host.client)||void 0===e?void 0:e.canCapture)||!this._shouldDisplaySurvey(h))return qf.info(`Survey ${h.id} no longer eligible when its display delay elapsed; not displaying`),this._removeSurveyFromFocus(h);S()},k=i?null===(l=this._host.surveys)||void 0===l||null===(l=l._surveyEventReceiver)||void 0===l||null===(c=l.getActivationTimestamp)||void 0===c?void 0:c.call(l,h.id):void 0,C=Ft(k)?Math.max(0,Date.now()-k):0,E=Math.max(0,1e3*m-C);if(0>=E)return w();const T=window.setTimeout(()=>{this._surveyTimeouts.delete(h.id),w()},E);this._surveyTimeouts.set(h.id,T)},this._handleWidget=e=>{var t;const{survey:i,language:n}=this._translateSurveyForRendering(e),{shadow:s,isNewlyCreated:r}=bm(i,this._host);this._renderedTargets.set(s,s.host),(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===Pf.Tab&&this._renderedTabWidgets.set(e.id,e),r&&Y_(X_(Ty,{posthog:this._host,survey:i,surveyLanguage:n},e.id),s)},this._detachWidgetSelectorListener=e=>{const t=this._widgetSelectorListeners.get(e);t&&(t.element.removeEventListener("click",t.listener),t.element.removeAttribute(my),this._widgetSelectorListeners.delete(e),qf.info(`Removed click listener for survey ${e}`))},this._removeWidgetSelectorListener=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._detachWidgetSelectorListener(e.id))},this._removeTabWidget=e=>{this._isWidgetSurveyOpen(e)||(this._removeSurveyFromDom(e),this._renderedTabWidgets.delete(e.id))},this._isWidgetSurveyOpen=e=>{try{var t;const i=document.querySelector(Bm(e,!0));return!!(null==i||null===(t=i.shadowRoot)||void 0===t?void 0:t.querySelector(".ph-survey"))}catch(e){return!1}},this._manageWidgetSelectorListener=(e,t)=>{const i=document.querySelector(t),n=this._widgetSelectorListeners.get(e.id);if(i){if(this._handleWidget(e),n){if(i===n.element)return;qf.info(`Selector element changed for survey ${e.id}. Re-attaching listener.`),this._detachWidgetSelectorListener(e.id)}if(!i.hasAttribute(my)){const t=t=>{var i,n;t.stopPropagation();const s=(null===(i=e.appearance)||void 0===i?void 0:i.position)===Mf.NextToTrigger?yy(t.currentTarget,parseInt((null===(n=e.appearance)||void 0===n?void 0:n.maxWidth)||fm.maxWidth)):{};window.dispatchEvent(new CustomEvent(vy,{detail:{surveyId:e.id,position:s}}))};Kr(i,"click",t),i.setAttribute(my,"true"),this._widgetSelectorListeners.set(e.id,{element:i,listener:t,survey:e}),qf.info(`Attached click listener for feedback button survey ${e.id}`)}}else n&&this._removeWidgetSelectorListener(e)},this.renderPopover=e=>{var t;if(!(null===(t=this._host.client)||void 0===t?void 0:t.canCapture))return;const{survey:i,language:n}=this._translateSurveyForRendering(e),{shadow:s}=bm(i,this._host);this._renderedTargets.set(s,s.host),Y_(X_(Cy,{posthog:this._host,survey:i,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:n}),s)},this.renderSurvey=(e,t,i)=>{var n;if(!(null===(n=this._host.client)||void 0===n?void 0:n.canCapture))return;const{survey:s,language:r}=this._translateSurveyForRendering(e);let o=!1;this._host.config.prefillFromUrl&&(o=this._handleUrlPrefill(s,r,i)),Y_(X_(Cy,{posthog:this._host,survey:s,removeSurveyFromFocus:this._removeSurveyFromFocus,isPopup:!1,properties:i,isSurveyCompleted:o,surveyLanguage:r}),t)},this.getActiveMatchingSurveys=(e,t=!1)=>{var i;null===(i=this._host.surveys)||void 0===i||i.getSurveys(t=>{e(t.filter(e=>this._shouldDisplaySurvey(e)))},t)},this.callSurveysAndEvaluateDisplayLogic=(e=!1)=>{this.getActiveMatchingSurveys(e=>{var t;const i=null===(t=this._host.client)||void 0===t?void 0:t.canCapture,n=e.filter(e=>i&&(e.type===Af.Popover||e.type===Af.Widget)),s=new Set(n.map(e=>e.id));for(const e of Array.from(this._surveyTimeouts.keys()))s.has(e)||this.cancelSurvey(e);const r=this._sortSurveysByAppearanceDelay(n),o=new Set,a=new Set;r.forEach(e=>{if(e.type===Af.Widget){var t,i,n,s;if((null===(t=e.appearance)||void 0===t?void 0:t.widgetType)===Pf.Tab)return a.add(e.id),void this._handleWidget(e);(null===(i=e.appearance)||void 0===i?void 0:i.widgetType)===Pf.Selector&&(null===(n=e.appearance)||void 0===n?void 0:n.widgetSelector)&&(o.add(e.id),this._manageWidgetSelectorListener(e,null===(s=e.appearance)||void 0===s?void 0:s.widgetSelector))}Pt(this._surveyInFocus)&&e.type===Af.Popover&&this.handlePopoverSurvey(e,void 0,{resumeDelayFromActivation:!0})}),this._widgetSelectorListeners.forEach(({survey:e})=>{o.has(e.id)||this._removeWidgetSelectorListener(e)}),this._renderedTabWidgets.forEach((e,t)=>{a.has(t)||this._removeTabWidget(e)})},e)},this._addSurveyToFocus=e=>{Pt(this._surveyInFocus)||qf.error(`Survey ${this._surveyInFocus} already in focus. Cannot add survey ${e.id}.`),this._surveyInFocus=e.id},this._removeSurveyFromFocus=e=>{this._surveyInFocus!==e.id&&qf.error(`Survey ${e.id} is not in focus. Cannot remove survey ${e.id}.`),this._clearSurveyTimeout(e.id),this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0,this._removeSurveyFromDom(e)},this._host=e,this._surveyInFocus=null,this._languageChangeListener=()=>this._onLanguageChange(),Kr(window,"languagechange",this._languageChangeListener),this._unsubscribeFeatureFlags=null!==(t=null===(i=e.client)||void 0===i||null===(i=i.getExtension("featureFlagsCommon"))||void 0===i?void 0:i.onFeatureFlags(()=>this._onLanguageChange()))&&void 0!==t?t:null}_onLanguageChange(){var e;if(Pt(this._surveyInFocus))return;const t=null===(e=this._host.client)||void 0===e?void 0:e.kv.get(R),i=null==t?void 0:t.find(e=>e.id===this._surveyInFocus);if(!i)return;const{survey:n,language:s}=this._translateSurveyForRendering(i);if(s===this._currentLanguage)return;if(this._currentLanguage=s,!this._surveyIsRendered)return;const r=this._applyDisplayOverrides(n,this._displayOptions),{shadow:o}=bm(r,this._host);Y_(X_(Cy,ct(ct({},this._surveyPopupProps),{},{posthog:this._host,survey:r,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyLanguage:s})),o)}_applyDisplayOverrides(e,t){return(null==t?void 0:t.position)||(null==t?void 0:t.selector)?ct(ct({},e),{},{appearance:ct(ct(ct({},e.appearance),t.position&&{position:t.position}),t.selector&&{widgetSelector:t.selector})}):e}_clearSurveyTimeout(e){const t=this._surveyTimeouts.get(e);t&&(clearTimeout(t),this._surveyTimeouts.delete(e))}cancelSurvey(e){this._surveyTimeouts.has(e)&&(qf.info(`Cancelled pending survey ${e}`),this._clearSurveyTimeout(e),this._surveyInFocus===e&&(this._surveyInFocus=null,this._currentLanguage=null,this._surveyIsRendered=!1,this._surveyPopupProps=null,this._displayOptions=void 0))}startAutomaticDisplay(){if(this._disposed||this._automaticDisplayDispose||!1===this._host.config.automaticDisplay)return;this._automaticDisplayDispose=()=>{};const e=function(e){let t;e.callSurveysAndEvaluateDisplayLogic(!0);const i=()=>{xt(t)&&(t=setInterval(()=>{e.callSurveysAndEvaluateDisplayLogic(!1)},1e3))},n=()=>{xt(t)||(clearInterval(t),t=void 0)};i();const s=()=>{document.hidden?n():(e.callSurveysAndEvaluateDisplayLogic(!1),i())};return Kr(document,"visibilitychange",s),()=>{n(),document.removeEventListener("visibilitychange",s)}}(this);this._disposed?e():this._automaticDisplayDispose=e}clearInMemoryInProgressSurveyState(){(()=>{for(const e of Object.keys(Lm))delete Lm[e]})()}dispose(){var e;this._disposed=!0,null===(e=this._automaticDisplayDispose)||void 0===e||e.call(this),this._automaticDisplayDispose=void 0,this._languageChangeListener&&(window.removeEventListener("languagechange",this._languageChangeListener),this._languageChangeListener=null),this._unsubscribeFeatureFlags&&(this._unsubscribeFeatureFlags(),this._unsubscribeFeatureFlags=null),this._surveyTimeouts.forEach((e,t)=>this._clearSurveyTimeout(t)),this._widgetSelectorListeners.forEach((e,t)=>this._detachWidgetSelectorListener(t)),this._renderedTargets.forEach((e,t)=>{Y_(null,t),null==e||e.remove()}),this._renderedTargets.clear(),this._renderedTabWidgets.clear(),this._surveyInFocus=null}_sortSurveysByAppearanceDelay(e){return e.sort((e,t)=>{var i,n;const s=$m(e),r=$m(t);if(s&&!r)return-1;if(!s&&r)return 1;const o=e.schedule===Df.Always,a=t.schedule===Df.Always;return o&&!a?1:!o&&a?-1:((null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds)||0)-((null===(n=t.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds)||0)})}_translateSurveyForRendering(e){return fy(e,this._host)}_handleUrlPrefill(e,t,i){if(this._prefillHandledSurveys.has(e.id))return!1;const{params:n}=function(){const e={};let t=!1;const i=window.location.search.replace(/^\?/,"");if(!i)return{params:e,autoSubmit:t};const n=i.split("&");for(const i of n){const n=i.indexOf("=");if(0>=n)continue;let s,r;try{s=decodeURIComponent(i.slice(0,n)),r=decodeURIComponent(i.slice(n+1))}catch(e){continue}if("auto_submit"===s&&"true"===r){t=!0;continue}const o=s.match(/^q(\d+)$/);if(o){const t=parseInt(o[1],10);e[t]||(e[t]=[]),e[t].push(r)}}return{params:e,autoSubmit:t}}();if(0===Object.keys(n).length)return!1;qf.info("[Survey Prefill] Detected URL prefill parameters");const s=this._processPrefillData(e,n,t);return!!s&&(this._autoSubmitPrefilledResponses(e,s,i,t),this._prefillHandledSurveys.add(e.id),s.isSurveyCompleted)}_autoSubmitPrefilledResponses(e,t,i,n){const{responses:s,submissionId:r,isSurveyCompleted:o,skippedResponses:a}=t;(Object.keys(a).length>0&&e.enable_partial_responses||o)&&wm({responses:o?s:a,survey:e,surveySubmissionId:r,posthog:this._host,isSurveyCompleted:o,properties:i,surveyLanguage:n})}_handleInitialResponses(e,t,i,n){const s={};for(const[e,i]of Object.entries(t))s[parseInt(e)]=kt(i)?i.map(String):[String(i)];qf.info("[Survey] Processing initial responses");const r=this._processPrefillData(e,s,n);return!!r&&(this._autoSubmitPrefilledResponses(e,r,i,n),r.isSurveyCompleted)}_processPrefillData(e,t,i){try{const n=function(e,t){const i={};return e.questions.forEach((e,n)=>{if(!t[n]||!e.id)return;const s=t[n],r=ec(e.id);try{switch(e.type){case Lf.SingleChoice:{if(!e.choices||0===e.choices.length)return void Nr.warn(`[Survey Prefill] Question ${n} has no choices`);const t=parseInt(s[0],10);if(isNaN(t)||0>t||t>=e.choices.length)return void Nr.warn(`[Survey Prefill] Invalid choice index for q${n}: ${s[0]}`);i[r]=e.choices[t];break}case Lf.MultipleChoice:{if(!e.choices||0===e.choices.length)return void Nr.warn(`[Survey Prefill] Question ${n} has no choices`);const t=s.map(e=>parseInt(e,10)).filter(t=>!isNaN(t)&&t>=0&&e.choices.length>t);if(0===t.length)return void Nr.warn(`[Survey Prefill] No valid choices for q${n}`);const o=[...new Set(t.map(t=>e.choices[t]))];t.length>o.length&&Nr.warn(`[Survey Prefill] Removed duplicate choices for q${n}`),i[r]=o;break}case Lf.Rating:{const t=parseInt(s[0],10),o=e.scale||10,a=10===o?0:1;if(isNaN(t)||a>t||t>o)return void Nr.warn(`[Survey Prefill] Invalid rating for q${n}: ${s[0]} (scale: ${a}-${o})`);i[r]=t;break}default:Nr.info(`[Survey Prefill] Question type ${e.type} does not support prefill`)}}catch(e){Nr.error(`[Survey Prefill] Error converting q${n}:`,e)}}),i}(e,t);if(0===Object.keys(n).length)return qf.warn("[Survey Prefill] No valid responses after conversion"),null;const s=Rl(),{startQuestionIndex:r,skippedResponses:o,skippedIndices:a}=function(e,t,i){let n=0;const s={},r=[],o=e.questions.length+1;let a=0;for(;e.questions.length>n&&o>a&&(a++,t.includes(n));){const t=e.questions[n];if(!t||!("skipSubmitButton"in t)||!t.skipSubmitButton)break;if(t.id){const e=ec(t.id);xt(i[e])||(s[e]=i[e])}r.push(n);const o=gy(e,n,t.id?i[ec(t.id)]:null);if(o===Of.End)return{startQuestionIndex:e.questions.length,skippedResponses:s,skippedIndices:r};n=o}return{startQuestionIndex:n,skippedResponses:s,skippedIndices:r}}(e,Object.keys(t).map(e=>parseInt(e,10)).filter(t=>{const i=e.questions[t];return(null==i?void 0:i.id)&&!xt(n[ec(i.id)])}),n),l=r>=e.questions.length;return Om(e,{surveySubmissionId:s,responses:n,lastQuestionIndex:r,questionOrder:Tm(e.questions),visitedIndices:a,surveyLanguage:i}),qf.info("[Survey Prefill] Stored prefilled responses in localStorage"),{responses:n,submissionId:s,startQuestionIndex:r,isSurveyCompleted:l,skippedResponses:o}}catch(e){return qf.error("[Survey Prefill] Error handling prefill:",e),null}}_isSurveyFeatureFlagEnabled(e,t){var i;if(!e)return!0;const n=null===(i=this._host.client)||void 0===i?void 0:i.getExtension(ef),s=!!(null==n?void 0:n.isFeatureEnabled(e,{send_event:!e.startsWith("survey-targeting-")}));let r=!0;t&&(r=(null==n?void 0:n.getFeatureFlag(e,{send_event:!1}))===t||"any"===t);const o=s&&r;return o||this._warnIfFeatureFlagsDisabled(e),o}_warnIfFeatureFlagsDisabled(e){this._loggedFeatureFlagsDisabledWarning||!1!==this._host.config.featureFlagEvaluation||(this._loggedFeatureFlagsDisabledWarning=!0,qf.warn(`Survey feature flag "${e}" evaluated to false because advanced_disable_feature_flags is set. PostHog creates an internal targeting flag for almost every survey, so no survey can display while flags are disabled. To keep surveys working, replace advanced_disable_feature_flags with advanced_only_evaluate_survey_feature_flags, which evaluates survey flags only.`))}_isSurveyConditionMatched(e){return!e.conditions||Fm(e,this._host)&&function(e){var t,i;return function(e,t){var i,n,s;if(!e||0===e.length)return!0;const r="u">typeof window?window:void 0,o="u">typeof globalThis?globalThis:r,a=null==o?void 0:o.navigator,l=null==a?void 0:a.userAgent;if(!l)return!1;const c=Ji(l,{userAgentDataPlatform:null==a||null===(i=a.userAgentData)||void 0===i?void 0:i.platform,maxTouchPoints:null==a?void 0:a.maxTouchPoints,screenWidth:null==r||null===(n=r.screen)||void 0===n?void 0:n.width,screenHeight:null==r||null===(s=r.screen)||void 0===s?void 0:s.height,devicePixelRatio:null==r?void 0:r.devicePixelRatio});return gc[null!=t?t:"icontains"](e,[c])}(null===(t=e.conditions)||void 0===t?void 0:t.deviceTypes,null===(i=e.conditions)||void 0===i?void 0:i.deviceTypesMatchType)}(e)&&function(e){var t,i;return!(null===(t=e.conditions)||void 0===t?void 0:t.selector)||!!(null===(i=document)||void 0===i?void 0:i.querySelector(e.conditions.selector))}(e)}_internalFlagCheckSatisfied(e){var t;return Im(e)?{satisfied:!0}:e.internal_targeting_flag_key&&function(e){var t;return"recurring"===e.schedule||(null!==(t=e.current_iteration)&&void 0!==t?t:0)>0}(e)&&!(null===(t=this._host.client)||void 0===t||null===(t=t.getExtension("featureFlagsCommon"))||void 0===t?void 0:t.hasLoadedFlags)?(this._warnIfFeatureFlagsDisabled(e.internal_targeting_flag_key),{satisfied:!1,reason:"Feature flags have not loaded yet; deferring internal targeting flag check"}):{satisfied:this._isSurveyFeatureFlagEnabled(e.internal_targeting_flag_key)}}checkSurveyEligibility(e){var t,i;const n={eligible:!0,reason:void 0};if(!Uf(e))return n.eligible=!1,n.reason=`Survey is not running. It was completed on ${e.end_date}`,n;if(!Gf.includes(e.type))return n.eligible=!1,n.reason=`Surveys of type ${e.type} are never eligible to be shown in the app`,n;const s=null===(t=e.conditions)||void 0===t?void 0:t.linkedFlagVariant;if(!this._isSurveyFeatureFlagEnabled(e.linked_flag_key,s))return n.eligible=!1,n.reason=s?`Survey linked feature flag is not enabled for variant ${s}`:"Survey linked feature flag is not enabled",n;if(!this._isSurveyFeatureFlagEnabled(e.targeting_flag_key))return n.eligible=!1,n.reason="Survey targeting feature flag is not enabled",n;const r=this._internalFlagCheckSatisfied(e);var o;return r.satisfied?(e=>{let t=null;try{t=localStorage.getItem("lastSeenSurveyDate")}catch(e){qf.error("localStorage error: "+e)}return function(e,t){if(!e||!t)return!0;const i="string"==typeof t?new Date(t):t,n=Math.abs((new Date).getTime()-i.getTime());return Math.ceil(n/864e5)>e}(e,t)})(null===(i=e.conditions)||void 0===i?void 0:i.seenSurveyWaitPeriodInDays)?((e=>{let t=null;try{t=localStorage.getItem(jf(e))}catch(e){qf.error("localStorage error: "+e)}return!!t&&!Im(e)})(e)&&(n.eligible=!1,n.reason="Survey has already been seen and it can't be activated again"),n):(n.eligible=!1,n.reason="Survey wait period has not passed",n):(n.eligible=!1,n.reason=null!==(o=r.reason)&&void 0!==o?o:"Survey internal targeting flag is not enabled and survey cannot activate repeatedly and survey is not in progress",n)}checkSurveyCaptureEligibility(){var e;return(null===(e=this._host.client)||void 0===e?void 0:e.canCapture)?{eligible:!0}:{eligible:!1,reason:Hf}}checkSurveyDisplayEligibility(e){const t=this.checkSurveyCaptureEligibility();return t.eligible?this.checkSurveyEligibility(e):t}checkSurveyRenderability(e){const t=this.checkSurveyDisplayEligibility(e);return t.eligible&&!this._hasActionOrEventTriggeredSurvey(e)?{eligible:!1,reason:"Survey event/action trigger has not been fired yet"}:t}_hasActionOrEventTriggeredSurvey(e){var t;if(!uc(e)&&!zf(e))return!0;const i=null===(t=this._host.surveys)||void 0===t||null===(t=t._surveyEventReceiver)||void 0===t?void 0:t.getSurveys();return!!(null==i?void 0:i.includes(e.id))}_checkFlags(e){var t;return!(null===(t=e.feature_flag_keys)||void 0===t?void 0:t.length)||e.feature_flag_keys.every(({key:e,value:t})=>!e||!t||this._isSurveyFeatureFlagEnabled(t))}_shouldDisplaySurvey(e){return this.checkSurveyEligibility(e).eligible&&this._isSurveyConditionMatched(e)&&this._hasActionOrEventTriggeredSurvey(e)&&this._checkFlags(e)}_removeSurveyFromDom(e){try{const t=document.querySelector(Bm(e,!0));(null==t?void 0:t.shadowRoot)&&(Y_(null,t.shadowRoot),this._renderedTargets.delete(t.shadowRoot)),null==t||t.remove()}catch(t){qf.warn(`Failed to remove survey ${e.id} from DOM:`,t)}}getTestAPI(){return{addSurveyToFocus:this._addSurveyToFocus,removeSurveyFromFocus:this._removeSurveyFromFocus,surveyInFocus:this._surveyInFocus,surveyTimeouts:this._surveyTimeouts,handleWidget:this._handleWidget,handlePopoverSurvey:this.handlePopoverSurvey,manageWidgetSelectorListener:this._manageWidgetSelectorListener,sortSurveysByAppearanceDelay:this._sortSurveysByAppearanceDelay.bind(this),checkFlags:this._checkFlags.bind(this),isSurveyFeatureFlagEnabled:this._isSurveyFeatureFlagEnabled.bind(this),onLanguageChange:this._onLanguageChange.bind(this),currentLanguage:this._currentLanguage,surveyIsRendered:this._surveyIsRendered}}};function Sy({survey:e,removeSurveyFromFocus:t=()=>{},setSurveyVisible:i,isPreviewMode:n=!1,posthog:s}){mf(()=>{var r;if(n||!(null===(r=e.conditions)||void 0===r?void 0:r.url))return;const o=()=>{var n;const r=e.type===Af.Widget,o=Fm(e,s),a=(null===(n=e.appearance)||void 0===n?void 0:n.widgetType)===Pf.Tab&&r;if(!o)return qf.info(`Hiding survey ${e.id} because URL does not match`),i(!1),t(e);a&&(qf.info(`Showing survey ${e.id} because it is a feedback button tab and URL matches`),i(!0))};Kr(window,"popstate",o),Kr(window,"hashchange",o);const a=window.history.pushState,l=window.history.replaceState;return window.history.pushState=function(...e){a.apply(this,e),o()},window.history.replaceState=function(...e){l.apply(this,e),o()},()=>{window.removeEventListener("popstate",o),window.removeEventListener("hashchange",o),window.history.pushState=a,window.history.replaceState=l}},[n,e,t,i,s])}const wy=200;function ky(e=Ff.Right){switch(e){case Ff.Top:return{top:"0",left:"50%",transform:"translateX(-50%)"};case Ff.Left:return{top:"50%",left:"0",transform:"rotate(90deg) translateY(-100%)",transformOrigin:"left top"};case Ff.Bottom:return{bottom:"0",left:"50%",transform:"translateX(-50%)"};default:return{top:"50%",right:"0",transform:"rotate(-90deg) translateY(-100%)",transformOrigin:"right top"}}}function Cy({survey:e,forceDisableHtml:t,posthog:i,style:n={},previewPageIndex:s,removeSurveyFromFocus:r=()=>{},isPopup:o=!0,onPreviewSubmit:a=()=>{},onPreviewBack:l=()=>{},onPopupSurveyDismissed:c=()=>{},onCloseConfirmationMessage:u=()=>{},properties:d,isSurveyCompleted:h,skipShownEvent:p,surveyLanguage:g}){var _,f,v,m,y,b,S,w,k,C,E,T;const x=yf(null),I=Number.isInteger(s),{isPopupVisible:R,isSurveySent:P,hidePopupWithAnimation:M}=function(e,t,i,n,s,r,o,a,l){const[c,u]=vf(n||0===i||e.type===Af.ExternalSurvey),[d,h]=vf(!1),p=yf(!1),g=()=>{const t=()=>{r&&s(e),u(!1)};if(p.current)return;const i=null==o?void 0:o.current;i?(p.current=!0,i.style.transition=`opacity ${wy}ms ease-out`,i.style.opacity="0",setTimeout(()=>{p.current=!1,t()},250)):t()},_=t=>{t.detail.surveyId===e.id&&g()};return mf(()=>{if(!t)return void qf.error("usePopupVisibility hook called without a PostHog instance.");if(n)return;let s;const r=t=>{var i,n;if(t.detail.surveyId===e.id){if(!(null===(i=e.appearance)||void 0===i?void 0:i.displayThankYouMessage))return g();h(!0),(null===(n=e.appearance)||void 0===n?void 0:n.autoDisappear)&&(s&&clearTimeout(s),s=setTimeout(g,5e3))}},o=()=>{var i;if(Fm(e,t)){u(!0);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}window.dispatchEvent(new Event("PHSurveyShown")),a||null===(i=t.client)||void 0===i||i.capture($f.SHOWN,ct(ct({[Nf.SURVEY_NAME]:e.name,[Nf.SURVEY_ID]:e.id,[Nf.SURVEY_ITERATION]:e.current_iteration,[Nf.SURVEY_ITERATION_START_DATE]:e.current_iteration_start_date},l&&{[Nf.SURVEY_LANGUAGE]:l}),{},{sessionRecordingUrl:tf(t)}))}};Kr(window,"PHSurveyClosed",_),Kr(window,"PHSurveySent",r);const c=i>0?setTimeout(o,i):void 0;return xt(c)&&o(),()=>{xt(c)||clearTimeout(c),xt(s)||clearTimeout(s),window.removeEventListener("PHSurveyClosed",_),window.removeEventListener("PHSurveySent",r)}},[]),Sy({survey:e,removeSurveyFromFocus:s,setSurveyVisible:u,isPreviewMode:n,posthog:t}),{isPopupVisible:c,isSurveySent:d,setIsPopupVisible:u,hidePopupWithAnimation:g}}(e,i,(null===(_=e.appearance)||void 0===_?void 0:_.surveyPopupDelaySeconds)?1e3*e.appearance.surveyPopupDelaySeconds:0,I,r,o,x,p,g),F=P||s===e.questions.length||!0===h,[A,L]=vf(!1),O=bf(()=>!!Dm(e),[e]),D=!(!(null===(f=e.appearance)||void 0===f?void 0:f.introScreenHeader)&&!(null===(v=e.appearance)||void 0===v?void 0:v.introScreenDescription)),N=I?-1===s:!!(null===(m=e.appearance)||void 0===m?void 0:m.displayIntroScreen)&&D&&!A&&!O,B=bf(()=>{const t=Dm(e),n=(null==t?void 0:t.surveySubmissionId)||Rl()||"";return{isPreviewMode:I,previewPageIndex:s,onPopupSurveyDismissed(){g?Cm(e,i,I,g):Cm(e,i,I),c()},isPopup:o||!1,surveySubmissionId:n,onPreviewSubmit:a,onPreviewBack:l,posthog:i,properties:d,surveyLanguage:g}},[I,s,o,i,e,c,a,l,d,g]);return R?X_(Rm.Provider,{value:B,children:X_("div",{className:"ph-survey",style:ct(ct({},qm(e.type,null===(y=e.appearance)||void 0===y?void 0:y.position,null===(b=e.appearance)||void 0===b?void 0:b.widgetType)),n),ref:x,children:F?X_(ey,{header:(null===(S=e.appearance)||void 0===S?void 0:S.thankYouMessageHeader)||"Thank you!",description:(null===(w=e.appearance)||void 0===w?void 0:w.thankYouMessageDescription)||"",forceDisableHtml:!!t,contentType:null===(k=e.appearance)||void 0===k?void 0:k.thankYouMessageDescriptionContentType,appearance:e.appearance||fm,onClose(){M(),u()}}):N?X_(ty,{header:(null===(C=e.appearance)||void 0===C?void 0:C.introScreenHeader)||"",description:(null===(E=e.appearance)||void 0===E?void 0:E.introScreenDescription)||"",forceDisableHtml:!!t,contentType:null===(T=e.appearance)||void 0===T?void 0:T.introScreenDescriptionContentType,appearance:e.appearance||fm,onStart:()=>L(!0)}):X_(Ey,{survey:e,forceDisableHtml:!!t,posthog:i})})}):null}function Ey({survey:e,forceDisableHtml:t,posthog:i}){var n,s;const r=bf(()=>{const t=Dm(e);if(!t)return null;const i=Ft(t.lastQuestionIndex);return!i||i&&t.lastQuestionIndex>=0&&e.questions.length>t.lastQuestionIndex?t:(Nm(e),null)},[e]),[o,a]=vf(()=>((null==r?void 0:r.responses)&&qf.info("Survey is already in progress, filling in initial responses"),(null==r?void 0:r.responses)||{})),[l,c]=vf(!1),{previewPageIndex:u,onPopupSurveyDismissed:d,isPopup:h,onPreviewSubmit:p,onPreviewBack:g,surveySubmissionId:_,isPreviewMode:f,properties:v,surveyLanguage:m}=Sf(Rm),[y,b]=vf(()=>{const t=null==r?void 0:r.lastQuestionIndex,i=Ft(t)&&t>=0&&e.questions.length>t?t:0;return Ft(u)&&u>=0?u:i}),[S,w]=vf(()=>{var t;return(null!==(t=null==r?void 0:r.visitedIndices)&&void 0!==t?t:[]).filter(t=>t>=0&&e.questions.length>t)}),[k,C]=vf(()=>{var t;const i=Dm(e);return null!==(t=null==i?void 0:i.questionSnapshots)&&void 0!==t?t:{}}),E=bf(()=>Tm(xm(e,r)),[e.id,r]),T=bf(()=>{if(!E||new Set(E).size!==E.length)return xm(e,r);const t=new Map(e.questions.map(e=>[e.id,e])),i=E.map(e=>t.get(e)).filter(e=>!!e);return i.length===E.length?i:e.questions},[E,e.questions,e,r]);mf(()=>{!f||xt(u)||0>u||b(u)},[u,f]);const x=!!(null===(n=e.appearance)||void 0===n?void 0:n.allowGoBack)&&(f?(null!=u?u:0)>0:S.length>0),I=T.at(y);return I?X_("form",{className:"survey-form",name:"surveyForm",children:[h&&!0!==(null===(s=e.appearance)||void 0===s?void 0:s.hideCancelButton)&&X_(Xm,{onClick(){d()}}),X_("div",{className:"survey-box","data-question-index":y,children:[l&&X_("p",{role:"alert",children:"Your response could not be sent. Please try again later."}),xy({question:I,forceDisableHtml:t,displayQuestionIndex:y,appearance:e.appearance||fm,onSubmit:t=>(({res:t,displayQuestionIndex:n,questionId:s})=>{var r;if(!i)return void qf.error("onNextButtonClick called without a PostHog instance.");if(!(null===(r=i.client)||void 0===r?void 0:r.canCapture))return void c(!0);if(c(!1),!s)return void qf.error("onNextButtonClick called without a questionId.");const{responses:l,questionSnapshots:u}=function({responses:e,questionSnapshots:t={}},i,n,s){return{responses:ct(ct({},e),{},{[ec(i)]:n}),questionSnapshots:(null==s?void 0:s.id)?ct(ct({},t),{},{[s.id]:s.question}):t}}({responses:o,questionSnapshots:k},s,t,T[n]);a(l),C(u);const d=gy(e,n,t),h=d===Of.End,p=[...S,n];if(h||(w(p),b(d),Om(e,{surveySubmissionId:_,responses:l,lastQuestionIndex:d,questionOrder:Tm(T),visitedIndices:p,surveyLanguage:m,questionSnapshots:u})),e.enable_partial_responses||h){const t=new Set(p.map(e=>{var t;return null===(t=T[e])||void 0===t?void 0:t.id}).filter(e=>!!e).map(e=>ec(e))),n=Object.fromEntries(Object.entries(l).filter(([e])=>t.has(e)));wm({responses:n,survey:e,surveySubmissionId:_,isSurveyCompleted:h,posthog:i,properties:v,surveyLanguage:m,questionSnapshots:u})}})({res:t,displayQuestionIndex:y,questionId:I.id}),onPreviewSubmit:p,initialValue:I.id?o[ec(I.id)]:void 0,canGoBack:x,onBack(){if(f)return void g();if(0===S.length)return;const t=S[S.length-1],i=S.slice(0,-1);w(i),b(t),Om(e,{surveySubmissionId:_,responses:o,lastQuestionIndex:t,questionOrder:Tm(T),visitedIndices:i,surveyLanguage:m,questionSnapshots:k})}})]})]}):null}function Ty({survey:e,forceDisableHtml:t,posthog:i,readOnly:n,surveyLanguage:s}){var r,o,a,l,c,u,d,h;const[p,g]=vf(!0),[_,f]=vf(!1),[v,m]=vf({}),y=yf(void 0),b=()=>{var e;(_||!i||n||(null===(e=i.client)||void 0===e?void 0:e.canCapture))&&f(!_)};if(mf(()=>{var t,s,r;if(!i)return void qf.error("FeedbackWidget called without a PostHog instance.");if(n)return;"tab"===(null===(t=e.appearance)||void 0===t?void 0:t.widgetType)&&m((r=null===(s=e.appearance)||void 0===s?void 0:s.position)&&r!==Mf.Right&&r!==Mf.NextToTrigger?{}:{top:"50%",bottom:"auto"});const o=t=>{var i;const n=t;(null===(i=n.detail)||void 0===i?void 0:i.surveyId)===e.id&&(qf.info(`Received show event for feedback button survey ${e.id}`),m(n.detail.position||{}),b())};return Kr(window,vy,o),()=>{xt(y.current)||(clearTimeout(y.current),y.current=void 0),window.removeEventListener(vy,o)}},[i,n,e.id,null===(r=e.appearance)||void 0===r?void 0:r.widgetType,null===(o=e.appearance)||void 0===o?void 0:o.position,null===(a=e.appearance)||void 0===a?void 0:a.widgetSelector,null===(l=e.appearance)||void 0===l?void 0:l.borderColor]),Sy({survey:e,setSurveyVisible:g,posthog:i}),!p)return null;const S=()=>{e.schedule!==Df.Always&&g(!1),xt(y.current)||clearTimeout(y.current),y.current=setTimeout(()=>{y.current=void 0,f(!1)},200)};return X_(M_,{children:["tab"===(null===(c=e.appearance)||void 0===c?void 0:c.widgetType)&&X_("button",{className:"ph-survey-widget-tab "+((null===(u=e.appearance)||void 0===u?void 0:u.tabPosition)===Ff.Top?"widget-tab-top":""),onClick:b,disabled:n,style:ky(null===(d=e.appearance)||void 0===d?void 0:d.tabPosition),children:(null===(h=e.appearance)||void 0===h?void 0:h.widgetLabel)||""}),_&&X_(Cy,{posthog:i,survey:e,forceDisableHtml:t,style:v,onPopupSurveyDismissed:S,onCloseConfirmationMessage:S,surveyLanguage:s})]})}const xy=({question:e,forceDisableHtml:t,displayQuestionIndex:i,appearance:n,onSubmit:s,onPreviewSubmit:r,initialValue:o,canGoBack:a,onBack:l})=>{const c={forceDisableHtml:t,appearance:n,onPreviewSubmit(e){r(e)},onSubmit(e){s(e)},initialValue:o,displayQuestionIndex:i,canGoBack:a,onBack:l};switch(e.type){case Lf.Open:return R_(ny,ct(ct({},c),{},{question:e,key:e.id}));case Lf.Link:return R_(sy,ct(ct({},c),{},{question:e,key:e.id}));case Lf.Rating:return R_(ry,ct(ct({},c),{},{question:e,key:e.id}));case Lf.SingleChoice:case Lf.MultipleChoice:return R_(ay,ct(ct({},c),{},{question:e,key:e.id}));default:return qf.error(`Unsupported question type: ${e.type}`),null}},Iy={GZipJS:"gzip-js",Base64:"base64"};function Ry(e){let t=!0;return{dispose(){if(t){t=!1;const i=e();i&&Ct(i.then)&&i.then(void 0,()=>{})}}}}var Py=class{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(const i of this._events[e]||[])i(t);for(const i of this._events["*"]||[])i(e,t)}constructor(){this._events={}}};function My(e,t,i){if(Mt(e))return!1;switch(i){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var Fy=class{constructor(e){this._host=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Py,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?void 0:t.event)||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;xt(null===(e=this._host)||void 0===e?void 0:e.subscribeCapture)||(this._captureHookUnsubscribe=null===(t=this._host)||void 0===t?void 0:t.subscribeCapture((e,t)=>{this.on(e,t)}))}dispose(){var e,t,i;null===(e=this._captureHookUnsubscribe)||void 0===e||e.call(this),this._captureHookUnsubscribe=void 0,null===(t=this._host)||void 0===t||null===(i=t.setElementSelectors)||void 0===i||i.call(t,new Set,this),this._debugEventEmitter=new Py}register(e){var t,i;if(!xt(null===(t=this._host)||void 0===t?void 0:t.subscribeCapture)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null===(t=e.steps)||void 0===t||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null===(i=this._host)||void 0===i?void 0:i.setElementSelectors)){const e=new Set;this._actionRegistry.forEach(t=>{var i;null===(i=t.steps)||void 0===i||i.forEach(t=>{(null==t?void 0:t.selector)&&e.add(t.selector)})}),this._host.setElementSelectors(e,this)}}replace(e){this._actionRegistry.clear(),this._actionEvents.clear(),this.register(e)}on(e,t){null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&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(const 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?void 0:t.url){var i;let r=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!(null==e?void 0:e.properties)||!("$current_url"in e.properties))try{var n,s;r=null===(n=this._host)||void 0===n||null===(s=n.getActionUrl)||void 0===s?void 0:s.call(n)}catch(e){return!1}if(!r||"string"!=typeof r)return!1;if(!My(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?void 0:t.href))return!0;const n=this._getElementsList(e);if(n.length>0)return n.some(e=>My(e.href,t.href,t.href_matching||"exact"));const s=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!s&&My(function(e){const t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:""}(s),t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(!(null==t?void 0:t.text))return!0;const n=this._getElementsList(e);if(n.length>0)return n.some(e=>My(e.text,t.text,t.text_matching||"exact")||My(e.$el_text,t.text,t.text_matching||"exact"));const s=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!s&&(r=function(e){const t=[],i=/(?::|")text="(.*?)"/g;let n;for(;!Mt(n=i.exec(e));)t.includes(n[1])||t.push(n[1]);return t}(s),o=t.text,a=t.text_matching||"exact",r.some(e=>My(e,o,a)));var r,o,a}_checkStepSelector(e,t){var i,n;if(!(null==t?void 0:t.selector))return!0;const s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(null==s?void 0:s.includes(t.selector))return!0;const r=(null==e||null===(n=e.properties)||void 0===n?void 0:n.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch(e){}return!1}_getElementsList(e){var t;return null==(null==e||null===(t=e.properties)||void 0===t?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return!(null==t?void 0:t.properties)||0===t.properties.length||_c(t.properties.reduce((e,t)=>{const i=kt(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)}},Ay=class{constructor(e,t){this._onActivationChanged=t,this._pendingActivatedItems=[],this._host=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_subscribeSession(){var e,t;this._sessionIdUnsubscribe=null===(e=(t=this._host).subscribeSession)||void 0===e?void 0:e.call(t,e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&_c(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){const i=new Map;return e.forEach(e=>{var n;null===(n=e.conditions)||void 0===n||null===(n=n[t])||void 0===n||null===(n=n.values)||void 0===n||n.forEach(t=>{if(null==t?void 0:t.name){const n=i.get(t.name)||[];n.push(e.id),i.set(t.name,n)}})}),i}_getMatchingItems(e,t,i){const n=(i===Rf.Activation?this._eventToItems:this._cancelEventToItems).get(e);let s=[];return this._getItems(e=>{s=e.filter(e=>null==n?void 0:n.includes(e.id))}),s.filter(n=>{var s;const r=null===(s=n.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s?void 0:s.find(t=>t.name===e);return this._doesEventMatchFilter(r,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){xt(this._host.subscribeCapture)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){const i=e.filter(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length});var n;if(t&&this._actionToItems.clear(),0===i.length)return void(t&&(null===(n=this._actionMatcher)||void 0===n||n.replace([])));this._actionMatcher||(this._actionMatcher=new Fy(this._host),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));const s=[];i.forEach(e=>{var t;null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||t.values.forEach(t=>{if(s.push(t),t.name){var i;const n=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];n.includes(e.id)||n.push(e.id),this._actionToItems.set(t.name,n)}})}),t?this._actionMatcher.replace(s):this._actionMatcher.register(s)}_mergeItemMaps(e,t){t.forEach((t,i)=>{var n;const s=null!==(n=e.get(i))&&void 0!==n?n:[];t.forEach(e=>{s.includes(e)||s.push(e)}),e.set(i,s)})}_setupEventBasedItems(e,t){var i,n,s;const r=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),o=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.cancelEvents)&&(null===(i=e.conditions)||void 0===i||null===(i=i.cancelEvents)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),a=this._buildEventToItemMap(e,Rf.Activation),l=this._buildEventToItemMap(e,Rf.Cancellation);t?(this._eventToItems=a,this._cancelEventToItems=l):(this._mergeItemMaps(this._eventToItems,a),this._mergeItemMaps(this._cancelEventToItems,l)),(0!==r.length||0!==o.length||e.some(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length}))&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null===(n=(s=this._host).subscribeCapture)||void 0===n?void 0:n.call(s,(e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,n;const s=this._getLogger(),r=(null==t||null===(i=t.properties)||void 0===i?void 0:i.$survey_id)||(null==t||null===(n=t.properties)||void 0===n?void 0:n.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const i=this._activationOutcome(e,r,t);if("consume"===i)return s.info("event consumed activated item, removing it",{event:e,itemId:r}),void this._deactivateItems([r]);if("persist"===i)return s.info("shown item promoted to persisted activation",{event:e,itemId:r}),this._persistActivation(r),void this._clearActivationTimestamps([r])}if(this._cancelEventToItems.has(e)){const i=this._getMatchingItems(e,t,Rf.Cancellation);i.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:i.map(e=>e.id)}),this._deactivateItems(i.map(e=>e.id)),i.forEach(e=>this._cancelPendingItem(e.id)))}if(!this._eventToItems.has(e))return;s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});const o=this._getMatchingItems(e,t,Rf.Activation);this._activateItems(o.map(e=>e.id))}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){if(0===e.length)return;const t=!!this._host.getSessionId(),i=[];for(const n of e)t&&this._shouldPersistArmedActivation(n)?this._persistActivation(n)&&this._recordActivationTimestamp(n):i.push(n);i.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...i])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}),this._notifyActivationChanged()}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);const t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){const t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));const i=this._getRawPersistedActivatedIds(),n=i.filter(e=>!t.has(e));n.length!==i.length&&(this._setActivatedItems(n),0===n.length&&this._clearActivationSession()),this._clearActivationTimestamps(e),this._notifyActivationChanged()}_notifyActivationChanged(){try{var e;null===(e=this._onActivationChanged)||void 0===e||e.call(this)}catch(e){this._getLogger().error("Error while handling activated items change",e)}}_getRawActivationTimestamps(){const e=this._getActivationTimestampsKey();if(!e)return{};const t=this._host.getProperty(e);return t&&"object"==typeof t?t:{}}_recordActivationTimestamp(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps();this._writeActivationTimestamps(ct(ct({},t),{},{[e]:Date.now()}))}_clearActivationTimestamps(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps(),i={};let n=!1;for(const[s,r]of Object.entries(t))e.includes(s)?n=!0:i[s]=r;n&&(Tt(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(!this._getPersistedActivatedIds().includes(e))return;const t=this._getRawActivationTimestamps()[e];return Ft(t)?t:void 0}_getRawPersistedActivatedIds(){const e=this._getActivatedKey();return this._host.getProperty(e)||[]}_getPersistedActivatedIds(){const e=this._getRawPersistedActivatedIds();if(0===e.length)return[];const t=this._host.getProperty(this._getActivatedSessionKey()),i=this._host.getSessionId();return i&&t===i?e:[]}_stampActivationSession(){const e=this._host.getSessionId();e&&this._setActivatedSession(e)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){const t=this._host.getProperty(this._getActivatedSessionKey());if(t&&t!==e){const e=this._getRawPersistedActivatedIds(),t=this._getRawActivationTimestamps();e.length>0&&(this._setActivatedItems([]),e.filter(e=>Ft(t[e])).forEach(e=>this._cancelPendingItem(e))),this._clearActivationSession(),this._clearAllActivationTimestamps(),e.length>0&&this._notifyActivationChanged()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter(e=>!this._isItemPermanentlyIneligible(e))}dispose(){var e,t,i;null===(e=this._sessionIdUnsubscribe)||void 0===e||e.call(this),this._sessionIdUnsubscribe=void 0,null===(t=this._captureHookUnsubscribe)||void 0===t||t.call(this),this._captureHookUnsubscribe=void 0,null===(i=this._actionMatcher)||void 0===i||i.dispose(),this._actionMatcher=void 0}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps(),this._notifyActivationChanged()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}},Ly=class extends Ay{constructor(e,t,i,n){var s;super({subscribeCapture(t){const i=e.onEvent(e=>t(e.event,e));return()=>i.dispose()},subscribeSession(t){const i=e.onSession(t);return()=>i.dispose()},getSessionId(){var t;return null===(t=e.session)||void 0===t?void 0:t.sessionId},getProperty:t=>e.kv.get(t),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(s=null==i?void 0:i.setElementSelectors)&&void 0!==s?s:(t,i)=>{var n;return null===(n=e.getExtension("autocapture"))||void 0===n?void 0:n.setElementSelectors(t,i)}},n),this._client=e,this._surveys=t,this._subscribeSession()}_getActivatedKey(){return F}_getActivatedSessionKey(){return A}_getActivationTimestampsKey(){return L}_writeActivationTimestamps(e){this._client.kv.set({[L]:e})}_clearActivationTimestampsStore(){this._client.kv.remove(L)}_shouldPersistArmedActivation(e){var t;let i;this._getItems(t=>{i=t.find(t=>t.id===e)});const n=null==i||null===(t=i.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds;return Ft(n)&&n>0}_getShownEventName(){return $f.SHOWN}_getItems(e){this._surveys.getSurveys(e)}_cancelPendingItem(e){this._surveys.cancelPendingSurvey(e)}_getLogger(){return qf}_setActivatedItems(e){this._client.kv.set({[F]:e})}_setActivatedSession(e){this._client.kv.set({[A]:e})}_clearActivatedSession(){this._client.kv.remove(A)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t,i){var n;if(e===$f.SENT&&!1===(null==i||null===(n=i.properties)||void 0===n?void 0:n.$survey_completed))return"ignore";let s;return this._getItems(e=>{s=e.find(e=>e.id===t)}),!s||dc(s)?e===$f.SHOWN?"consume":"ignore":e===$f.SHOWN?"persist":e===$f.DISMISSED||e===$f.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}};const Oy=(e,t)=>(null==e?void 0:e.then)?e.then(t):t(e),Dy="SDK is not enabled or survey functionality is not yet loaded",$y="Disabled. Not loading surveys.";var Ny=class{constructor(e){this._configSource=e,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyInitializationFailed=!1,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._disposed=!1,this._renderTimeouts=new Set,this.onRemoteConfig=e=>{if(this._disposed)return;if(this._config.disableSurveys)return;if(!e.ok)return this._surveyInitializationFailed=!0,this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),qf.warn("Remote config unavailable. Not loading surveys.");const t=e.config.surveys;if(Mt(t))return qf.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=Lt(t)?t:t.length>0,qf.info(`flags response received, isSurveysEnabled: ${this._isSurveysEnabled}`),this.loadIfEnabled()},this._notifyActiveMatchingSurveyCallbacks=e=>{this._activeMatchingSurveyCallbacks.slice().forEach(t=>this._notifyActiveMatchingSurveyCallback(t,e))}}setup(e){if(!this._disposed)return this._initializingClient=e,Oy(e.kv.initialize(),()=>{if(this._initializingClient!==e||this._disposed)return;this._initializingClient=void 0,this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())})}dispose(){var e,t,i,n,s;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,null===(t=this._surveyEventReceiver)||void 0===t||t.dispose(),this._surveyEventReceiver=null,null===(i=this._surveyManager)||void 0===i||null===(n=i.dispose)||void 0===n||n.call(i),this._surveyManager=null,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks.forEach(e=>{e.active=!1}),this._activeMatchingSurveyCallbacks=[],null===(s=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===s||s.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0,this._getSurveysInFlightPromise=null,this._renderTimeouts.forEach(e=>clearTimeout(e)),this._renderTimeouts.clear())}get _config(){return this._configSource.get()}getRenderContext(){if(!this._client)return;const e=this;return{client:this._client,get config(){return e._config},surveys:e}}initialize(){this.loadIfEnabled()}reset(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.clearInMemoryInProgressSurveyState)||void 0===t||t.call(e);try{var i;null===(i=this._surveyEventReceiver)||void 0===i||i.reset(),localStorage.removeItem("lastSeenSurveyDate");const e=[];for(let t=0;t<localStorage.length;t++){const i=localStorage.key(t);((null==i?void 0:i.startsWith("seenSurvey_"))||(null==i?void 0:i.startsWith("inProgressSurvey_")))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}loadIfEnabled(){if(this._disposed||!this._client)return;const e=this._config;if(this._surveyManager)return;if(this._isInitializingSurveys)return void qf.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void qf.info($y);if(e.cookielessMode&&this._client.isOptedOut)return void qf.info("Not loading surveys in cookieless mode without consent.");const t=this._configSource.getExtensions();if(!t)return void this._handleSurveyLoadError("PostHog Extensions not found.");if(xt(this._isSurveysEnabled)&&!e.advancedEnableSurveys)return;const i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0,this._surveyInitializationFailed=!1;try{const e=t.generateSurveys;if(e)return this._completeSurveyInitialization(e,i),void(this._isInitializingSurveys=!1);const n=t.loadExternalDependency;if(!n)return this._handleSurveyLoadError(M),void(this._isInitializingSurveys=!1);n(e=>{try{if(this._disposed)return;const t=this._configSource.getExtensions();e||!(null==t?void 0:t.generateSurveys)?this._handleSurveyLoadError("Could not load surveys script",e):this._completeSurveyInitialization(t.generateSurveys,i)}finally{this._isInitializingSurveys=!1}})}catch(e){throw this._isInitializingSurveys=!1,this._handleSurveyLoadError("Error initializing surveys",e),e}}_completeSurveyInitialization(e,t){var i;if(this._disposed)return;this._surveyManager=e(t),this._surveyEventReceiver=this._createEventReceiver(this._client,this._notifyActiveMatchingSurveyCallbacks);const n=null===(i=this._client)||void 0===i?void 0:i.kv.get(R);n&&this._registerEventOrActionBasedSurveys(n),qf.info("Surveys loaded successfully"),this._startActiveMatchingSurveyConditions(),this._notifyActiveMatchingSurveyCallbacks(),this._notifySurveyCallbacks({isLoaded:!0})}_createEventReceiver(e,t){return new Ly(e,this,void 0,t)}_handleSurveyLoadError(e,t){this._surveyInitializationFailed=!0,qf.error(e,t),this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:e}),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=!1){if(this._disposed)return;const i=this._client;if(!i)return e([],{isLoaded:!1,error:Dy});if(this._config.disableSurveys)return qf.info($y),e([]);const n=i.kv.get(R);if(n&&!t)return e(n,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)return void this._getSurveysInFlightPromise.then(({surveys:t,context:i})=>{this._disposed||e(t,i)}).catch(e=>qf.error("Error in survey callback",e));const s=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this._config.requestTimeoutMs}).then(e=>{try{return this._handleSurveyResponse(i,e)}catch(e){return qf.error("Error processing surveys response",e),this._handleSurveyResponse(i,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(i,{statusCode:0,error:e}));this._getSurveysInFlightPromise=s;const r=()=>{this._getSurveysInFlightPromise===s&&(this._getSurveysInFlightPromise=null)};s.then(t=>{r(),this._disposed||(this._notifyActiveMatchingSurveyCallbacks(t.context),e(t.surveys,t.context))},r).catch(e=>qf.error("Error in survey callback",e))}_handleSurveyResponse(e,t){if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:Dy}};const i=t.statusCode;if(200!==i||!t.json){const e=`Surveys API could not be loaded, status: ${i}`;return 0!==i?qf.error(e):t.error||qf.warn(e),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this._lastSurveyRefreshFailedAt=null;const n=t.json.surveys||[];return e.kv.set({[R]:n,[P]:Date.now()}),this._registerEventOrActionBasedSurveys(n),{surveys:n,context:{isLoaded:!0}}}_registerEventOrActionBasedSurveys(e){const t=e.filter(e=>Uf(e)&&(uc(e)||zf(e)));this._registerSurveyTriggers(t)}_registerSurveyTriggers(e){var t;null===(t=this._surveyEventReceiver)||void 0===t||t.replace(e)}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e;const t=null===(e=this._client)||void 0===e?void 0:e.kv.get(P);return Ft(t)&&Date.now()-t>3e5}_isSurveyRefreshBackingOff(){return Ft(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;const n={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};Vf(n);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}_notifySurveyCallbacks(e){for(const t of this._surveyCallbacks){if(this._disposed)return;try{e.isLoaded?this.getSurveys(t):t([],e)}catch(e){qf.error("Error in survey callback",e)}}}getActiveMatchingSurveys(e,t=!1){if(!Mt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);qf.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t;if(this._disposed)return()=>{};const i={callback:e,active:!0,revision:0};this._activeMatchingSurveyCallbacks.push(i),this._startActiveMatchingSurveyConditions();const n=null===(t=this._client)||void 0===t?void 0:t.kv.get(R);return this._config.disableSurveys||!this._surveyManager&&this._surveyInitializationFailed&&!this._isInitializingSurveys||!n&&!Mt(this._lastSurveyRefreshFailedAt)&&!this._getSurveysInFlightPromise?this._notifyActiveMatchingSurveyCallback(i,{isLoaded:!1}):this._surveyManager&&this._notifyActiveMatchingSurveyCallback(i),()=>{var e;i.active=!1,this._activeMatchingSurveyCallbacks=this._activeMatchingSurveyCallbacks.filter(e=>e!==i),0===this._activeMatchingSurveyCallbacks.length&&(null===(e=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===e||e.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0)}}_startActiveMatchingSurveyConditions(){var e,t,i;this._surveyManager&&this._activeMatchingSurveyCallbacks.length>0&&(null!==(e=this._activeMatchingSurveyConditionsUnsubscribe)&&void 0!==e||(this._activeMatchingSurveyConditionsUnsubscribe=null===(t=(i=this._configSource).onMatchingConditionsChanged)||void 0===t?void 0:t.call(i,this._notifyActiveMatchingSurveyCallbacks)))}_notifyActiveMatchingSurveyCallback(e,t){if(this._disposed||!e.active)return;const i=++e.revision,n=n=>{if(!this._disposed&&e.active&&i===e.revision)try{const i=null!=t?t:{isLoaded:!0},s=JSON.stringify([n,i]);if(s===e.lastResult)return;e.lastResult=s,e.callback(n,i)}catch(e){qf.error("Error in active matching surveys callback",e)}};try{t&&!t.isLoaded?n([]):this.getActiveMatchingSurveys(n)}catch(e){qf.error("Error in active matching surveys callback",e)}}_getSurveyById(e){let t=null;return this.getSurveys(i=>{var n;t=null!==(n=i.find(t=>t.id===e))&&void 0!==n?n:null}),t}_checkSurveyEligibility(e){if(Mt(this._surveyManager))return{eligible:!1,reason:Dy};const t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){var t;if(!(null===(t=this._client)||void 0===t?void 0:t.canCapture))return{eligible:!1,reason:Hf};if(Mt(this._surveyManager))return{eligible:!1,reason:Dy};const i="string"==typeof e?this._getSurveyById(e):e;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Mt(this._surveyManager))return qf.warn("init was not called"),{visible:!1,disabledReason:Dy};const t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Mt(this._surveyManager)?(qf.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Dy})):new Promise(i=>{this.getSurveys(t=>{var n;const s=null!==(n=t.find(t=>t.id===e))&&void 0!==n?n:null;if(s){const e=this._checkSurveyRenderability(s);i({visible:e.eligible,disabledReason:e.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var n,s,r;if(!(null===(n=this._client)||void 0===n?void 0:n.canCapture))return;if(Mt(this._surveyManager))return void qf.warn("init was not called");const o="string"==typeof e?this._getSurveyById(e):e;if(!(null==o?void 0:o.id))return void qf.warn("Survey not found");if(!Gf.includes(o.type))return void qf.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const a=null===(s=typeof document>"u"?void 0:document)||void 0===s?void 0:s.querySelector(t);if(a){if(null===(r=o.appearance)||void 0===r?void 0:r.surveyPopupDelaySeconds){qf.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const e=setTimeout(()=>{var t,n,s;this._renderTimeouts.delete(e),!this._disposed&&(null===(t=this._client)||void 0===t?void 0:t.canCapture)&&(qf.info(`Rendering survey ${o.id} with delay of ${null===(n=o.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(o,a,i),qf.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this._renderTimeouts.add(e)}this._surveyManager.renderSurvey(o,a,i)}else qf.warn("Survey element not found")}displaySurvey(e,t){var i,n;if(!(null===(i=this._client)||void 0===i?void 0:i.canCapture))return;if(Mt(this._surveyManager))return void qf.warn("init was not called");const s=this._getSurveyById(e);if(!s)return void qf.warn("Survey not found");let r=s;if((null===(n=s.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds)&&t.ignoreDelay&&(r=ct(ct({},s),{},{appearance:ct(ct({},s.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==Bf.Popover&&t.initialResponses&&qf.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){const e=this._checkSurveyEligibility(s);if(!e.eligible)return void qf.warn("Survey is not eligible to be displayed: ",e.reason)}t.displayType!==Bf.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}cancelPendingSurvey(e){Mt(this._surveyManager)?qf.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e)}},By=class{constructor(e){this.disabled=!1===e;const t=Et(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;const n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(t-n.y)<this.thresholdPx&&this.timeoutMs>i-n.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}};const qy=()=>typeof window>"u"?void 0:window,Hy=()=>typeof document>"u"?void 0:document,Uy="$copy_autocapture",zy=["password","hidden","file","checkbox","button","submit","reset","image"],Wy=Br("[AutoCapture]");function jy(e,t){return t.length>e?t.slice(0,e)+"...":t}function Vy(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!uo(t));return t}function Gy(e,{e:t,maskAllElementAttributes:i,maskAllText:n,elementAttributeIgnoreList:s,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!uo(e))return{props:{}};const c=[e],u=new Set([e]);let d=e;for(;d.parentNode&&!ho(d,"body")&&1e3>c.length;){if(go(d.parentNode)){const e=d.parentNode.host;if(u.has(e))break;u.add(e),c.push(e),d=e;continue}if(!uo(d.parentNode))break;if(u.has(d.parentNode))break;u.add(d.parentNode),c.push(d.parentNode),d=d.parentNode}const h="click"===t.type&&"http://www.w3.org/2000/svg"===e.namespaceURI?c.findIndex(e=>ho(e,"button")||ho(e,"a")):-1;h>0&&(n=n||c.slice(0,h+1).some(e=>!Ho(e)||Uo(e)));const p=[],g={};let _,f=!1,v=!1;if(Hr(c,e=>{const t=Ho(e);if(ho(e,"a")&&!i&&!(null==s?void 0:s.includes("href"))){const i=e.getAttribute("href");f=!!(t&&i&&Jo(i))&&(o?cn(i):i)}ft(vo(e),"ph-no-capture")&&(v=!0),p.push(function(e,t,i,n,s=!1){const r=e.tagName.toLowerCase(),o={tag_name:r};So.indexOf(r)>-1&&!i&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?jy(1024,Yo(e)):jy(1024,yo(e)));const a=vo(e);t||(null==n?void 0:n.includes("class"))||0>=a.length||(o.classes=a.filter(function(e){return""!==e})),Hr(e.attributes,function(i){var r;if((!Uo(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&!(null==n?void 0:n.includes(i.name))&&!t&&Jo(i.value)&&(!It(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let e=i.value;"class"===i.name&&(e=_o(e).join(" ")),o["attr__"+i.name]=jy(1024,"href"===i.name&&s?cn(e):e)}});let l=1,c=1,u=e;for(;u=Vy(u);)l++,u.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o}(e,i,n,s,o)),Hr(function(e){if(!Ho(e))return{};const t={};return Hr(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),n=e.value;i&&n&&Jo(n)&&(t[i]=n)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(g,t)||(g[t]=e)})}),v)return{props:{},explicitNoCapture:v};if(h>0&&(e=c[h],p.splice(0,h)),n||(p[0].$el_text=ho(e,"a")||ho(e,"button")?Yo(e):yo(e)),f){var m,y;p[0].attr__href=f;const e=null===(m=Yr(f))||void 0===m?void 0:m.host,t=null===(y=qy())||void 0===y||null===(y=y.location)||void 0===y?void 0:y.host;e&&t&&e!==t&&(_=f)}return{props:Ur((S=t.type,{$event_type:S,$ce_version:1}),r?{}:{$elements:p},{$elements_chain:(b=p,kt(b)?function(e){return e.map(e=>{var t,i;let n="";if(e.tag_name&&(n+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)n+=`.${t.replace(/"/g,"")}`}const s=ct(ct(ct(ct({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return zr(s).sort(([e],[t])=>function(e,t){return t>e?-1:e>t?1:0}(e,t)).forEach(([e,t])=>r[Xo(e.toString())]=Xo(t.toString())),n+=":",n+=zr(r).map(([e,t])=>`${e}="${t}"`).join(""),n}).join(";")}(function(e){return e.map(e=>{var t,i;const n={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:ea(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return zr(e).filter(([e])=>0===e.indexOf("attr__")).forEach(([e,t])=>n.attributes[e]=t),n})}(b)):"")},(null===(a=p[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(l=p[0])||void 0===l?void 0:l.$el_text}:{},_&&"click"===t.type?{$external_click_url:_}:{},g),target:e};var b,S}const Qy="autocapture";var Ky=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!Ho(e))return!0;const i=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:Eo,n=new Set;let s=e;for(;s;){if(n.size>=1e3||n.has(s))return!0;n.add(s);const e=s,t=vo(e);if(ft(t,"ph-no-capture")||ft(t,"ph-sensitive")||Uo(e)||i.some(t=>wo(e,t)))return!0;const r=s.parentNode;s=go(r)?r.host:r&&uo(r)?r:null}return!1}_trackPointer(e){if(!this.isEnabled||"pointercancel"===e.type)return void this._clearPointer();if("pointerdown"===e.type){var t;this._clearPointer();const i=bo(e);return void(e.isPrimary&&0===e.button&&!e.ctrlKey&&i&&uo(i)&&(this._pointerDown={target:i,excluded:this._isExcludedPointerTarget(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null===(t=this._client)||void 0===t?void 0:t.distinctId}))}const i=this._pointerDown;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this._clearPointer():"pointerup"===e.type&&(i.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}_recoverClickTarget(e){var t;const i=this._pointerDown;this._clearPointer();const n=bo(e);if((null==i?void 0:i.released)&&i.target.isConnected&&i.distinctId===(null===(t=this._client)||void 0===t?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||"touch"===e.pointerType||"pen"===e.pointerType)&&0===e.button&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&n&&(ho(n,"html")||ho(n,"body"))){var s,r,o;if(i.excluded)return null;const e=null!==(s=this._refreshConfig().css_selector_ignorelist)&&void 0!==s?s:Eo;return[n,null===(r=Hy())||void 0===r?void 0:r.documentElement,null===(o=Hy())||void 0===o?void 0:o.body].some(t=>{if(!t)return!1;const i=vo(t);return ft(i,"ph-no-capture")||ft(i,"ph-sensitive")||!Ho(t)||Uo(t)||e.some(e=>wo(t,e))})?null:i.target}}constructor(e){this._configSource=e,this.name=Qy,this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementSelectorsByOwner=new Map,this._elementsChainAsString=!1,this._config={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this._disposed=!1,this._configSource.refresh(this._config),this.rageclicks=new By(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.startIfEnabled())}dispose(){var e;this._disposed||(this._disposed=!0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._elementSelectorsByOwner.clear(),this._elementSelectors=null,this._removeDomEventHandlers())}_refreshConfig(){return this._configSource.refresh(this._config),this._config}_compileUrlPatterns(){var e,t;return this._refreshConfig(),this._config.url_allowlist=null===(e=this._config.url_allowlist)||void 0===e?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null===(t=this._config.url_ignorelist)||void 0===t?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){const e=qy(),t=Hy();if(!this.isBrowserSupported())return void Wy.info("Disabling Automatic Event Collection because this browser is not supported");if(!e||!t)return;this._listenerWindow=e,this._listenerDocument=t;const i=this._domEventHandler=t=>{t=t||(null==e?void 0:e.event);try{if("blur"===t.type)return void this._clearPointer();if(0===t.type.indexOf("pointer"))return void this._trackPointer(t);const e="click"===t.type?this._recoverClickTarget(t):void 0;if(Pt(e))return;this._captureEvent(t,"$autocapture",e)}catch(e){Wy.error("Failed to capture event",e)}};if(Kr(e,"blur",i),Kr(t,"submit",i,{capture:!0}),Kr(t,"change",i,{capture:!0}),Kr(t,"click",i,{capture:!0}),Hr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{Kr(t,e,i,{capture:!0})}),this._refreshConfig().capture_copied_text){const i=this._copiedTextHandler=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t,Uy)}catch(e){Wy.error("Failed to capture clipboard event",e)}};Kr(t,"copy",i,{capture:!0}),Kr(t,"cut",i,{capture:!0}),Kr(t,"paste",i,{capture:!0})}}_removeDomEventHandlers(){const e=this._listenerWindow,t=this._listenerDocument;this._clearPointer(),this._domEventHandler&&(null==e||e.removeEventListener("blur",this._domEventHandler),Hr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==t||t.removeEventListener(e,this._domEventHandler,!0)}),null==t||t.removeEventListener("submit",this._domEventHandler,!0),null==t||t.removeEventListener("change",this._domEventHandler,!0),null==t||t.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==t||t.removeEventListener("copy",this._copiedTextHandler,!0),null==t||t.removeEventListener("cut",this._copiedTextHandler,!0),null==t||t.removeEventListener("paste",this._copiedTextHandler,!0),this._copiedTextHandler=void 0),this._listenerWindow=void 0,this._listenerDocument=void 0,this._initialized=!1}startIfEnabled(){this.isEnabled||this._clearPointer(),!this._disposed&&this._client&&this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(this._disposed)return;if(this._hasReceivedConfigResponse=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);const i=t.autocapture_opt_out;var n;Lt(i)&&(null===(n=this._client)||void 0===n||n.kv.set("$autocapture_disabled_server_side",i),this._isDisabledServerSide=i),this.startIfEnabled()}setElementSelectors(e,t=this){if(this._disposed)return;e.size?this._elementSelectorsByOwner.set(t,new Set(e)):this._elementSelectorsByOwner.delete(t);const i=new Set;this._elementSelectorsByOwner.forEach(e=>{e.forEach(e=>i.add(e))}),this._elementSelectors=i}getElementSelectors(e,t){var i;const n=[];return null===(i=this._elementSelectors)||void 0===i||i.forEach(i=>{var s;const r=null===(s=Hy())||void 0===s?void 0:s.querySelectorAll(i);null==r||r.forEach(s=>{e!==s&&t!==s||ft(n,i)||n.push(i)})}),n}get isEnabled(){var e,t;if(this._disposed)return!1;const i=null===(e=this._client)||void 0===e?void 0:e.kv.get(I),n=this._isDisabledServerSide,s=this._refreshConfig();if(!s.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;const r=s.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(Pt(n)&&!Lt(i)&&!r)return!1;const o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!s.enabled&&!o}_captureEvent(e,t="$autocapture",i){if(!this.isEnabled)return void this._clearPointer();let n=i||bo(e);po(n)&&(n=n.parentNode||null);const s=this._compileUrlPatterns();var r;"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&s.rageclick&&(null===(r=this.rageclicks)||void 0===r?void 0:r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime()))&&No(n,s.rageclick)&&this._captureEvent(e,"$rageclick",i);const o=t===Uy,a=o?ct(ct({},s),{},{dom_event_allowlist:void 0}):s;if(n&&function(e,t,i,n,s,r){var o;const a=typeof window>"u"?void 0:window;if(!a||Bo(e))return!1;if((null==i?void 0:i.url_allowlist)&&!fo(i.url_allowlist,r))return!1;if((null==i?void 0:i.url_ignorelist)&&fo(i.url_ignorelist,r))return!1;if(null==i?void 0:i.dom_event_allowlist){const e=i.dom_event_allowlist;if(e&&!e.some(e=>t.type===e))return!1}const{parentIsUsefulElement:l,targetElementList:c}=qo(e,n);if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(xt(i))return!0;for(const t of e)if(i.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,i))return!1;if(!ko(c,null==i?void 0:i.css_selector_allowlist))return!1;if(ko(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Eo))return!1;try{const i=a.getComputedStyle(e);if(i&&"pointer"===i.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}const u=e.tagName.toLowerCase();switch(u){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 l?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(So.indexOf(u)>-1||"true"===e.getAttribute("contenteditable"))}}(n,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:s.getCurrentUrl}})){var l;const{props:i,explicitNoCapture:r,target:o}=Gy(n,{e:e,maskAllElementAttributes:s.maskAllElementAttributes,maskAllText:s.maskAllText,elementAttributeIgnoreList:s.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:s.disableCaptureUrlHashes});if(r)return!1;const a=this.getElementSelectors(n,o);if(a&&a.length>0&&(i.$element_selectors=a),t===Uy){const t=e.type||"clipboard";if("paste"!==t){var c,u;const e=null===(c=qy())||void 0===c||null===(c=c.getSelection())||void 0===c?void 0:c.toString(),t=mo(e);if(!t)return!1;i.$selected_content=t,i.$clipboard_text_length=null!==(u=null==e?void 0:e.length)&&void 0!==u?u:0}i.$copy_type=t}if("$autocapture"===t&&"change"===e.type&&s.capture_value_css_selector_allowlist&&!s.maskAllText&&(ho(d=n,"input")?!ft(zy,d.type):ho(d,"textarea")||ho(d,"select")&&!d.multiple)&&function(e,t){var i;if(!Ho(e))return!1;const n=null!==(i=t.css_selector_ignorelist)&&void 0!==i?i:Eo,s=new Set;let r=e;for(ho(e,"select")&&(r=e.options[e.selectedIndex]||e);r;){const e=r,t=vo(e);if(s.size>=1e3||s.has(r)||ft(t,"ph-sensitive")||ft(t,"ph-no-capture")||n.some(t=>wo(e,t)))return!1;s.add(r);const i=r.assignedSlot||r.parentNode;r=go(i)?i.host:i&&uo(i)?i:null}return!0}(n,s)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){const e=s.capture_value_css_selector_allowlist;let t=!1;try{t=Ct(e)?!!e(n):kt(e)&&e.some(e=>wo(n,e))}catch(e){Wy.error("capture_value_css_selector_allowlist threw",e)}t&&(i.$input_value=n.value)}return null===(l=this._client)||void 0===l||l.capture(t,i),!0}var d}isBrowserSupported(){var e;return Ct(null===(e=Hy())||void 0===e?void 0:e.querySelectorAll)}};const Jy="featureFlags",Yy="logs",Zy=!!o||!!r,Xy=new WeakMap,eb="text/plain";let tb=0,ib=!1;const nb=(e,t)=>{const[i,n]=e.split("#"),[s,r]=i.split("?");if(!r)return e;const o=r.split("&").filter(e=>e.split("=")[0]!==t).join("&");return`${s}${o?`?${o}`:""}${n?`#${n}`:""}`},sb=(e,t,i=!0)=>{var n;const[s,r]=e.split("?"),o=ct({},t),a=null!==(n=null==r?void 0:r.split("&").map(e=>{var t;const[n,s]=e.split("="),r=i&&null!==(t=o[n])&&void 0!==t?t:s;return delete o[n],`${n}=${r}`}))&&void 0!==n?n:[],l=no(o);return l&&a.push(l),a.length>0?`${s}?${a.join("&")}`:s},rb=e=>{if(e._encodedBody)return e._encodedBody;const{data:t,compression:i}=e;if(!t)return;if(i===Iy.GZipJS){const e=ml(yl(io(t)),{mtime:0});return{contentType:eb,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(i===Iy.Base64){const e=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(io(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:io(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const n=io(t);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}},ob=e=>{const t=()=>"sendBeacon"===e.transport?{url:sb(e.url,{compression:Iy.Base64}),encodedBody:rb(ct(ct({},e),{},{compression:Iy.Base64,_encodedBody:void 0}))}:{url:nb(e.url,"compression"),encodedBody:rb(ct(ct({},e),{},{compression:void 0,_encodedBody:void 0}))};let i;try{i=rb(e)}catch(i){if(ds(e.compression,so(e.url,"compression")))return Nr.error("Failed to gzip request body, sending uncompressed payload",i),t();throw i}return i&&ds(e.compression,so(e.url,"compression"))&&!((n=i.body)instanceof ArrayBuffer?us(new Uint8Array(n)):ArrayBuffer.isView(n)&&us(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(ib=!0,t()):{url:e.url,encodedBody:i};var n},ab=e=>{try{return ob(e)}catch(i){var t;return Nr.error(i),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0,error:i}))}},lb=function(){var e=rt(function*(e){const t=yield vs(io(e.data),Yl.DEBUG,{rethrow:!0});if(!t)return e;const i=yield t.arrayBuffer();return ct(ct({},e),{},{_encodedBody:{contentType:eb,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}}(),cb=e=>ln("AbortError","PostHog request timed out"+(e?` after ${e}ms`:"")),ub=/Failed to fetch|NetworkError|Load failed/i,db=e=>"TypeError"===(null==e?void 0:e.name)&&ub.test((null==e?void 0:e.message)||""),hb=e=>{try{const t=function(e,t=Date.now(),i=3e5){if("string"!=typeof e||!e)return;const n=e.trim(),s=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(",")).trim():n;if(/^\d+$/.test(s)){const e=1e3*Math.min(Number(s),i/1e3);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s))return;const r=/^\w{3} \w{3} /.test(s)?s+" GMT":s,o=Date.parse(r)-t;return Number.isFinite(o)&&o>0?Math.min(o,i):void 0}(e());return xt(t)?void 0:Math.min(t,3e4)}catch(e){return}},pb=e=>{const t=ab(e);if(!t)return;const i=new o;Xy.set(i,!0);const{url:n,encodedBody:s}=t;i.open(e.method||"GET",n,!0);const{contentType:r,body:a}=null!=s?s:{};Hr(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout);let l=!1;i.ontimeout=()=>{l=!0},i.onloadend=()=>{var t;if(l){var n;const t=cb(e.timeout);return Nr.warn(t),void(null===(n=e.callback)||void 0===n||n.call(e,{statusCode:0,error:t}))}const s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,s,hb(()=>i.getResponseHeader("Retry-After")))},i.send(a)},gb=e=>{const t=ab(e);if(!t)return;const{url:i,encodedBody:n}=t,{contentType:s,body:o,estimatedSize:l}=null!=n?n:{},c=new Headers;Hr(e.headers,function(e,t){c.append(t,e)}),s&&c.append("Content-Type",s);let u=null,d=!1;if(a){const t=new a;u={signal:t.signal,timeout:setTimeout(()=>{d=!0;try{t.abort(cb(e.timeout))}catch(e){p(e)}},e.timeout)}}let h=!1;const p=t=>{var i;h||(h=!0,d&&"AbortError"===(null==t?void 0:t.name)||db(t)?Nr.warn(t):Nr.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,error:t}))};let g=0;const _=()=>{tb-=g,g=0,u&&clearTimeout(u.timeout)};try{const t=ct({method:(null==e?void 0:e.method)||"GET",headers:c,referrerPolicy:"strict-origin",body:o,signal:null==u?void 0:u.signal},e.fetchOptions),n=null!=l?l:xt(o)?0:void 0;t.keepalive="POST"===t.method&&!e._keepaliveDisabled&&!1!==t.keepalive&&t.body===o&&!xt(n)&&n>=0&&52428.8>tb+n,t.keepalive&&(g=n,tb+=g),r(i,t).then(t=>t.text().then(i=>{var n;if(h)return;const s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){Nr.error(e)}h=!0,_(),null===(n=e.callback)||void 0===n||n.call(e,s,hb(()=>t.headers.get("Retry-After")))})).catch(e=>{_(),p(e)}).finally(_)}catch(e){_(),p(e)}},_b=e=>{try{var t;const{url:n,encodedBody:s}=ob(e),{contentType:o,body:a,estimatedSize:l}=null!=s?s:{};if(!a)return;const c=a instanceof Blob?a:new Blob([a],{type:o});if(i.sendBeacon(n,c))return;const u=kt(e.data)?e.data:null===(t=e.data)||void 0===t?void 0:t.batch;if(kt(u)&&u.length>1&&(null!=l?l:0)>16384){const t=Math.ceil(u.length/2),i=t=>kt(e.data)?t:ct(ct({},e.data),{},{batch:t});return _b(ct(ct({},e),{},{data:i(u.slice(0,t))})),void _b(ct(ct({},e),{},{data:i(u.slice(t))}))}Nr.warn(`Beacon of ~${null!=l?l:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?gb(ct(ct({},e),{},{_keepaliveDisabled:!0})):pb(e)}catch(e){Nr.warn("Beacon send failed",e)}},fb=(e,t,i,n)=>{const s="query"===n?"POST"===t?"sent_at":"_":void 0;return sb(i===Iy.GZipJS?nb(e,"compression"):e,ct(ct({},s?{[s]:Date.now().toString()}:{}),i===Iy.GZipJS?{}:{compression:i}))},vb=(()=>{const e=[];return r&&e.push({transport:"fetch",method:gb}),o&&e.push({transport:"XHR",method:pb}),(null==i?void 0:i.sendBeacon)&&e.push({transport:"sendBeacon",method:_b}),e})(),mb=()=>{var t;return(null==e||null===(t=e.performance)||void 0===t?void 0:t.now)?e.performance.now():Date.now()},yb=[50,75,100,150,200,300,400,500,750,1e3,1500,2e3,3e3,5e3,1e4];var bb=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);const i={};for(const n of e){const e=null==t?void 0:t.get_property(n);xt(e)||(i[n]=e)}return i}set(e,t){var i;null===(i=this._instance.persistence)||void 0===i||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null===(t=this._instance.persistence)||void 0===t||t.unregister(e)}},Sb=class{constructor(e){this.instance=e,this._logger=Nr,this.kv=new bb(e),this.onSession=e=>Ry(this.instance.onSessionId(t=>{try{e(t)}catch(e){this._logger.error("Browser extension session listener failed",e)}})),this.onEvent=e=>Ry(this.instance._addCaptureHook((t,i)=>{if(i)try{e({event:t,properties:i.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{const t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on("extensionsRemoteConfig",t);return this.instance._lastRemoteConfig&&t(this.instance._lastRemoteConfig),Ry(i)}}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){const e=this.instance.get_property(N);return"string"==typeof e?e:void 0}get library(){return{name:Yl.LIB_NAME,version:Yl.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,n,s;const r=null===(e=this.instance.sessionManager)||void 0===e?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(n=null==r?void 0:r.sessionStartTimestamp)&&void 0!==n?n:0,lastActivityTimestamp:null!==(s=null==r?void 0:r.lastActivityTimestamp)&&void 0!==s?s:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return Ct(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get isRateLimited(){var e;return!!(null===(e=this.instance.rateLimiter)||void 0===e?void 0:e.isClientRateLimited)}get projectToken(){return this.instance.config.token}getExtension(e){let t;switch(e){case Jy:case ef:t=this.instance.featureFlags;break;case Yy:t=this.instance.logs;break;case"surveys":t=this.instance.surveys;break;case Qy:t=this.instance.autocapture}return t}capture(e,t,i){if(!i)return this._notRateLimited(this.instance.capture(e,t));const n=ct({timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce},"unload"===i.delivery?{transport:"sendBeacon",send_instantly:!0}:{});return this._notRateLimited(this.instance.capture(e,t,n))}_notRateLimited(e){var t;return!xt(e)||!(null===(t=this.instance.rateLimiter)||void 0===t?void 0:t.lastEventRateLimited)}registerDynamicEventProperties(e){return Ry(this.instance._registerExtensionEventProperties(e))}sendRequest(e){var t=this;return rt(function*(e,i={}){var n;const s=null!==(n=i.target)&&void 0!==n?n:"api",r=i.query?sb(e,i.query):e,o=t.instance.requestRouter.endpointFor(s,r),a={method:i.method,url:o,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:"flags"===i.target&&"best-available"===i.compression?dt.Base64:void 0,timestampMode:i.sentAt};return"api"===s&&"/i/v1/logs"===e&&(a.batchKey="logs"),"sendBeacon"===i.transport?(t.instance._send_request(a),{statusCode:202}):new Promise(e=>{var i;if(a.callback=e,"flags"===s&&(null===(i=t.instance.config.metrics)||void 0===i?void 0:i.flags)){let i;a.onDispatch=()=>{i=mb()},a.callback=n=>{xt(i)||t._recordFlagsDuration(o,n,mb()-i),e(n)}}t.instance._send_request(a)})}).apply(this,arguments)}_recordFlagsDuration(e,t,i){try{var n,s,r;const o=t.statusCode||void 0,a={"server.address":(null!==(n=null===(s=Yr(e))||void 0===s?void 0:s.hostname)&&void 0!==n?n:e).replace(/^\[(.*)\]$/,"$1")};o&&(a["http.response.status_code"]=o);const l=((e,t)=>e?400>e?void 0:String(e):"AbortError"===(null==t?void 0:t.name)?"timeout":"_OTHER")(o,t.error);l&&(a["error.type"]=l);const c=Ec();c&&(a["client.timezone"]=c),null===(r=this.instance.metrics)||void 0===r||r.histogram("posthog.flags.request.duration",i,{unit:"ms",attributes:a,bounds:yb})}catch(e){Nr.error("Failed to record the /flags request duration",e)}}},wb=class{constructor(e){this._instance=e}get(){var e,t,i,n;const s=null===(e=this._instance)||void 0===e?void 0:e.config;return{disableSurveys:!!(null==s?void 0:s.disable_surveys),cookielessMode:!!(null==s?void 0:s.cookieless_mode),advancedEnableSurveys:!!(null==s?void 0:s.advanced_enable_surveys),requestTimeoutMs:null!==(t=null==s?void 0:s.surveys_request_timeout_ms)&&void 0!==t?t:1e4,prefillFromUrl:!!(null==s||null===(i=s.surveys)||void 0===i?void 0:i.prefillFromUrl),automaticDisplay:!(null==s?void 0:s.disable_surveys_automatic_display),featureFlagEvaluation:!(null==s?void 0:s.advanced_disable_feature_flags),overrideLanguage:null==s?void 0:s.override_display_language,prepareStylesheet:null==s?void 0:s.prepare_external_dependency_stylesheet,get_current_url:null==s?void 0:s.get_current_url,uiHost:null===(n=this._instance)||void 0===n||null===(n=n.requestRouter)||void 0===n?void 0:n.endpointFor("ui","")}}getExtensions(){const e=null==d?void 0:d.__PosthogExtensions__;if(!e||!this._instance)return;const t=this._instance,{generateSurveys:i,loadExternalDependency:n}=e;return{generateSurveys:i?e=>i(t,e):void 0,loadExternalDependency:n?e=>n(t,"surveys",e):void 0}}onMatchingConditionsChanged(t){var i,n;const s=null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook(e=>{"$pageview"!==e&&e!==$f.SHOWN&&e!==$f.DISMISSED&&e!==$f.SENT||t()}),r=()=>t();Kr(e,"PHSurveyShown",r);let o=!1;const a=null===(n=this._instance)||void 0===n?void 0:n.onFeatureFlags(()=>{o&&t()});return o=!0,()=>{o=!1,null==s||s(),null==a||a(),null==e||e.removeEventListener("PHSurveyShown",r)}}};const kb=new WeakMap,Cb=(e,t)=>{const i=function(e){var t;const i=new wb(e);if(!e)return{get config(){return i.get()}};if(null===(t=e.surveys)||void 0===t?void 0:t.getRenderContext)return e.surveys.getRenderContext();let n=kb.get(e);return n||(n={client:new Sb(e),get config(){return i.get()},surveys:e.surveys},kb.set(e,n)),n}(e);return i?function(e,t){if(typeof document>"u"||typeof window>"u")return;const i=new by(e);return!1===e.config.automaticDisplay?(qf.info("Surveys automatic display is disabled. Skipping call surveys and evaluate display logic."),i):!1===t?(qf.info("There are no surveys to load or Surveys is disabled in the project settings."),i):(i.startAutomaticDisplay(),i)}(i,t):void 0};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.generateSurveys=Cb,d.extendPostHogWithSurveys=Cb;const Eb=e=>{for(;null==e?void 0:e.__rrweb_original__;)e=e.__rrweb_original__;return e},Tb=1e4,xb=(e,t,i)=>i.remaining>0?t.length>i.remaining?(e.push(t.slice(0,i.remaining)),i.remaining=0,i.truncated=!0,!1):(e.push(t),i.remaining-=t.length,!0):(i.truncated=!0,!1),Ib=(e,t,i)=>{const n=JSON.stringify(e);if(i.remaining>=n.length)return xb(t,n,i);if(i.truncated=!0,2>i.remaining)return!1;let s=0,r=Math.min(e.length,i.remaining-2);for(;r>s;){const t=Math.ceil((s+r)/2);JSON.stringify(e.slice(0,t)).length>i.remaining?r=t-1:s=t}return xb(t,JSON.stringify(e.slice(0,s)),i)},Rb=e=>void 0!==e&&"function"!=typeof e&&"symbol"!=typeof e&&"bigint"!=typeof e,Pb=(e,t,i)=>{if(!i.truncated){if(i.keysRemaining-=1,i.sizeRemaining-=String(t).length+e.length,0>=i.keysRemaining||0>=i.sizeRemaining)return i.truncated=!0,void(i.result.attributes_truncated=!0);i.result[e]=t}},Mb=(e,t,i)=>{if(!i.truncated)if(Et(e)){if(i.seen.has(e))return void Pb(t||"circular","[Circular]",i);i.seen.add(e);try{for(const n in e)try{if(!{}.hasOwnProperty.call(e,n))continue;if(Mb(e[n],t?`${t}.${n}`:n,i),i.truncated)break}catch(e){continue}}catch(e){}}else Pb(t,e,i)},Fb=(e,t,i,n,s=!1,r)=>{if(!Rb(e))return!s||xb(t,"null",i);if(Pt(e)||(e=>{try{return Ft(e)||Lt(e)}catch(e){return!1}})(e))return xb(t,JSON.stringify(e),i);if("string"==typeof e)return Ib(e,t,i);if(!Et(e)&&!kt(e))return xb(t,JSON.stringify(e),i);if(n.has(e))return Ib("[Circular]",t,i);n.add(e);try{const r=e.toJSON;if(Ct(r))return Fb(r.call(e),t,i,n,s)}catch(e){}try{const n={}.toString.call(e);if("[object String]"===n)return Ib(String(e.valueOf()),t,i);if("[object Number]"===n||"[object Boolean]"===n)return xb(t,JSON.stringify(e.valueOf()),i)}catch(e){}if(e instanceof Error){const o={};try{for(const t in e)({}).hasOwnProperty.call(e,t)&&(o[t]=e[t])}catch(e){}try{o.name=e.name}catch(e){}try{o.message=e.message}catch(e){}try{o.stack=e.stack}catch(e){}return Fb(o,t,i,n,s,r)}if(kt(e)){if(!xb(t,"[",i))return!1;for(let s=0;e.length>s;s++){if(s>0&&!xb(t,",",i))return!1;let r;try{r=e[s]}catch(e){r=void 0}if(!Fb(r,t,i,n,!0))return!1}return xb(t,"]",i)}if(!xb(t,"{",i))return!1;let o=!0;try{for(const s in e){if(!{}.hasOwnProperty.call(e,s))continue;if(0>=i.remaining)return i.truncated=!0,!1;let a;try{a=e[s]}catch(e){continue}if(r)try{Mb(a,s,r)}catch(e){}if(!Rb(a))continue;const l=`${o?"":","}${JSON.stringify(s)}:`;if(l.length>=i.remaining)return i.truncated=!0,!1;const c=t.length,u=i.remaining,d=i.truncated;if(!xb(t,l,i))return!1;const h=t.length,p=Fb(a,t,i,n,!1),g=i.truncated;if(t.length!==h){if(o=!1,!p)return!1}else if(t.length=c,i.remaining=u,i.truncated=p?d:g,!p)return!1}}catch(e){}return xb(t,"}",i)},Ab=(e,t)=>{const i=[],n={remaining:t,truncated:!1},s=Et(e[0])?{result:{},keysRemaining:50,sizeRemaining:Tb,truncated:!1,seen:new WeakSet([e[0]])}:void 0;for(let t=0;e.length>t&&(0>=t||xb(i," ",n))&&Fb(e[t],i,n,new WeakSet,!1,0===t?s:void 0);t++);return{body:i.join("")+(n.truncated?"...":""),truncated:n.truncated,attributes:(null==s?void 0:s.result)||{}}},Lb={debug:"debug",log:"info",warn:"warn",error:"error",info:"info"},Ob=e=>"canCapture"in e,Db=e=>({console:d.console,hostname:d.location.host,getCapturingLogs(){let t;return t=Ob(e)?e.canCapture?e.getExtension(Yy):void 0:(Ct(e.is_capturing)?e.is_capturing():!e.has_opted_out_capturing())?e.logs:void 0,t?{captureConsoleLog:i=>((e,t,i)=>{if(Ob(e))return void t.captureConsoleLog(i);const n=(e=>{const t=/^1\.(\d+)\.(\d+)$/.exec(e);if(!t)return;const i=Number(t[1]),n=Number(t[2]);return 392>i||i>419?void 0:410===i?n>4?n>10?void 0:"de":"le":418===i?n>3?n>10?n>14?n>17?void 0:"vi":"ci":"ui":"he":419===i?n>2?void 0:"vi":410>i?"le":"he"})(e.version),s=n?t[n]:void 0;n?Ct(s)&&s.call(t,i):Ct(t.captureConsoleLog)&&t.captureConsoleLog(i)})(e,t,i),captureBufferedConsoleLog(e,i,n){var s;return null===(s=t.captureBufferedConsoleLog)||void 0===s?void 0:s.call(t,e,i,n)}}:void 0}});d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.logs={initializeLogs:e=>(e=>{const t=e.console;let i=e;const n=[],s={host:e.hostname};let r=!1;const o=()=>{i=void 0;for(const e of n)try{e()}catch(e){}};try{for(const e of Object.keys(Lb)){const o=n=>(...o)=>{let a=!1;try{if(o.length>0&&!r&&i){const t=i.getCapturingLogs();if(t){r=!0,a=!0;const{body:i,truncated:n,attributes:l}=Ab(o,Tb),c=ct(ct({},s),n?{body_truncated:"true"}:{}),u={level:Lb[e],body:i,attributes:ct(ct({"log.source":`console.${e}`},c),l)};t.captureConsoleLog(u)}}}catch(e){}finally{a&&(r=!1),n.apply(t,o)}},a=t[e];n.push(Mg(t,e,e=>{const t=o(e);return t.__rrweb_original__=Eb(a),t}))}}catch(e){throw o(),e}return o})(Db(e)),replayConsoleBuffer:(e,t)=>((e,t)=>{const i=e.getCapturingLogs();if(i)for(const s of t)try{var n;const{body:t,truncated:r,attributes:o}=Ab(s.args,Tb);null===(n=i.captureBufferedConsoleLog)||void 0===n||n.call(i,{level:Lb[s.level],body:t,attributes:ct(ct({"log.source":`console.${s.level}`,host:e.hostname},r?{body_truncated:"true"}:{}),o)},s.context,s.occurredAtMs)}catch(e){}})(Db(e),t)};const $b=e=>qt(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),Nb=Br("[Error tracking]"),Bb="webkit-masked-url:",qb=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Hb=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Bb],Ub=["__firefox__","__gCrWeb"];function zb(){return new bn([new Hn,new Yn,new zn,new Un,new Kn,new Qn,new jn,new Jn],function(e,...t){return(i,n=0)=>{const s=[],r=i.split("\n"),o=Math.min(r.length,n+1e3),a=[];for(let i=n;o>i;i++){const n=r[i];if(n.length>1024)continue;const o=An.test(n)?n.replace(An,"$1"):n;if(!o.match(/\S*Error: /)){for(const i of t){const t=i(o,e);if(t){s.push(t);const e=On(s);if(e){for(let t=a.length-1;t>=0;t--){const i=a[t];if(e.start>=i.start+i.length)break;a.pop()}a.push(e)}break}}if(Bn(s,a)>=50)break}}const l=[...a].sort((e,t)=>t.start-e.start),c=l[l.length-1];if(c){const e=$n(s,c);s.splice(c.start-e,e);for(const t of l)t.start-=e}for(const e of l)Dn(s,e);return a.some(e=>0===e.start&&s.length===e.length)&&function(e){const t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`);let i=0;for(let e=1;t.length>e;e++)qn(t,e,i)&&(i=e);e.push(...e.splice(0,i))}(s),function(e){if(!e.length)return[];const t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return ct(ct({},e),{},{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(s)}}("web:javascript",Rn,Fn))}const Wb=Br("[ExceptionAutocapture]"),jb=zb(),Vb=(e,t)=>{try{return e()}catch(e){return t}},Gb=(e,t)=>Vb(()=>e(t()),void 0),Qb=e=>Vb(()=>Ct(e)&&Ct(e.call),!1),Kb=(e,t)=>Vb(()=>{e[t].__POSTHOG_INSTRUMENTED__=!0},void 0),Jb=(e,t,i)=>{Vb(()=>{var i;null===(i=e[t])||void 0===i||delete i.__POSTHOG_INSTRUMENTED__},void 0),Vb(()=>{e[t]=i},void 0)},Yb=t=>{const i=e;i||Wb.info("window not available, cannot wrap onerror");const n=Vb(()=>i.onerror,void 0);return i.onerror=function(...e){var i;return Gb(t,()=>jb.buildFromUnknown((([e,t,i,n,s])=>{if(null!=s)return s;if(It(e)&&It(t)&&t.length>0&&"undefined"!=typeof ErrorEvent)try{return new ErrorEvent("error",{message:e,filename:t,lineno:i,colno:n})}catch(t){return e}return e})(e),{mechanism:{handled:!1}})),!!Qb(n)&&null!==(i=n(...e))&&void 0!==i&&i},Kb(i,"onerror"),()=>Jb(i,"onerror",n)},Zb=(t,i=!1)=>{const n=e;n||Wb.info("window not available, cannot wrap onUnhandledRejection");const s=Vb(()=>n.onunhandledrejection,void 0);return n.onunhandledrejection=function(e){var n;return Gb(t,()=>jb.buildFromUnknown(e,{mechanism:{handled:!1}})),Qb(s)?null!==(n=s(e))&&void 0!==n&&n:i},Kb(n,"onunhandledrejection"),()=>Jb(n,"onunhandledrejection",s)},Xb={wrapOnError:Yb,wrapUnhandledRejection:Zb,wrapConsoleError(e){const t=console;t||Wb.info("console not available, cannot wrap console.error");const i=Vb(()=>t.error,void 0);return t.error=function(...t){Vb(()=>t.length>1&&It(t[0])&&(/^\[PostHog\.js\](?: |$)/.test(t[0])||"rrweb logger error:"===t[0]),!1)||Gb(e,()=>{let e;e=1==t.length?t[0]:t.join(" ");const i=t.find(e=>e instanceof Error);return jb.buildFromUnknown(i||e,{mechanism:{handled:!0,type:"onconsole"},syntheticException:new Error("PostHog syntheticException"),skipFirstLines:2})}),Qb(i)&&i(...t)},Kb(t,"error"),()=>Jb(t,"error",i)}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.errorWrappingFunctions=Xb,d.posthogErrorWrappingFunctions=Xb;const eS=(e,t)=>{if(!Ct(null==e?void 0:e.capture))return;const i=null==t?void 0:t.autocaptureExceptions,n=!Pt(i)&&"object"==typeof i&&kt(i.errors_to_ignore)?i.errors_to_ignore.reduce((e,t)=>{try{e.push(new RegExp(t))}catch(e){Wb.error("Ignoring invalid legacy exception exclusion rule",t,e)}return e},[]):[],s=t=>{try{var i;null===(i=e.capture)||void 0===i||i.call(e,"$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",_noHeatmaps:!0})}catch(e){Wb.error("Failed to capture exception for a legacy client",e)}};Yb(e=>{n.some(t=>e.$exception_list.some(e=>t.test(e.value||"")))||s(e)}),Zb(s,!0)};d.extendPostHogWithExceptionAutoCapture=eS,d.extendPostHogWithExceptionAutocapture=eS;const tS="X-POSTHOG-SESSION-ID",iS="X-POSTHOG-WINDOW-ID",nS="X-POSTHOG-DISTINCT-ID",sS=[tS,iS,nS],rS=["attributionReporting","body","browsingTopics","cache","credentials","dispatcher","duplex","integrity","keepalive","method","mode","priority","redirect","referrer","referrerPolicy","signal","window"],oS=(e,t)=>({}.hasOwnProperty.call(e,t)),aS=e=>"object"==typeof e&&!Pt(e)||Ct(e),lS=e=>"undefined"!=typeof Request&&(e instanceof Request||"[object Request]"==={}.toString.call(e)),cS=t=>{try{var i;return lS(t)?t.url:new URL(t instanceof URL?t.toString():String(t),null==e||null===(i=e.location)||void 0===i?void 0:i.href).toString()}catch(e){return}},uS=(e,t,i,n,s)=>{let r;try{r=new URL(n).hostname}catch(e){return!1}if(!e)return!1;if(kt(e)&&!e.includes(r))return!1;let o=!1;if(i){const{sessionId:e,windowId:t}=i.checkAndGetSessionAndWindowId(!0);s.set(tS,e),s.set(iS,t),o=!0}const a=(e=>Ct(e)?e():e)(t);return a&&"$posthog_cookieless"!==a&&(s.set(nS,a),o=!0),o};d.__PosthogExtensions__=d.__PosthogExtensions__||{};const dS={_patchFetch:(t,i,n)=>Mg(e,"fetch",e=>function(s,r){const o=arguments.length>1?[s,r]:[s];let a=o;try{const e=cS(s);if(e)if(lS(s)){const e=new Request(s,r);uS(t,i,n,e.url,e.headers),a=[e]}else{const o=new Headers(aS(r)?r.headers:void 0);if(uS(t,i,n,e,o)){const e=((e,t)=>{if(xt(e)||Pt(e))return{headers:t};if(!aS(e))return;const i=e;if("undefined"==typeof Proxy||"undefined"==typeof Reflect){const e=Object.create(i);return Object.defineProperty(e,"headers",{configurable:!0,enumerable:!0,value:t,writable:!0}),e}return new Proxy({headers:t},{get:(e,t)=>oS(e,t)?Reflect.get(e,t):Reflect.get(i,t,i),has:(e,t)=>oS(e,t)||t in i,ownKeys(e){const t=new Set(Reflect.ownKeys(e));return Reflect.ownKeys(i).forEach(e=>t.add(e)),rS.forEach(e=>{e in i&&t.add(e)}),Array.from(t)},getOwnPropertyDescriptor(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);if(n)return n;if("string"==typeof t&&rS.includes(t)&&t in i)return{configurable:!0,enumerable:!0,get(){return Reflect.get(i,t,i)}};const s=Reflect.getOwnPropertyDescriptor(i,t);return s?ct(ct({},s),{},{configurable:!0}):void 0},getPrototypeOf:()=>Object.getPrototypeOf(i)})})(r,o);e&&(a=[s,e])}}}catch(e){a=o}return e.apply(this,a)}),_patchXHR:(t,i,n)=>Mg(e.XMLHttpRequest.prototype,"open",e=>function(s,r,o=!0,a,l){const c=this,u=new Headers,d=cS(r);d&&uS(t,i,n,d,u);const h=e.call(c,s,r,o,a,l);return sS.forEach(e=>{const t=u.get(e);if(t)try{c.setRequestHeader(e,t)}catch(e){}}),h})};d.__PosthogExtensions__.tracingHeadersPatchFns=dS,d.postHogTracingHeadersPatchFns=dS,"function"!=typeof[].at&&Object.defineProperty(Array.prototype,"at",{value(e){const t=this.length;let i=Math.trunc(e)||0;return 0>i&&(i+=t),0>i||i>=t?void 0:this[i]},writable:!0,enumerable:!1,configurable:!0}),"function"!=typeof[].findLast&&Object.defineProperty(Array.prototype,"findLast",{value(e,t){for(let i=this.length-1;i>=0;i--){const n=this[i];if(e.call(t,n,i,this))return n}},writable:!0,enumerable:!1,configurable:!0});var hS=class{constructor(){this.t=void 0,this.o=0,this.i=[]}l(e){var t;if(e.hadRecentInput)return;const i=this.i[0],n=this.i.at(-1);this.o&&i&&n&&1e3>e.startTime-n.startTime&&5e3>e.startTime-i.startTime?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const pS=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},gS=e=>{if("loading"===document.readyState)return"loading";const t=pS();if(t){if(t.domInteractive>e)return"loading";if(0===t.domContentLoadedEventStart||t.domContentLoadedEventStart>e)return"dom-interactive";if(0===t.domComplete||t.domComplete>e)return"dom-content-loaded"}return"complete"},_S=e=>{const t=e.nodeName;return 1===e.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},fS=e=>{let t="";try{for(;9!==(null==e?void 0:e.nodeType);){var i;const n=e,s=n.id?"#"+n.id:[_S(n),...Array.from(null!==(i=n.classList)&&void 0!==i?i:[]).sort()].join(".");if(t.length+s.length>99)return t||s;if(t=t?s+">"+t:s,n.id)break;e=n.parentNode}}catch(e){}return t},vS=new WeakMap;function mS(e,t){let i=vS.get(t);return i||(i=new WeakMap,vS.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}let yS=-1;const bS=()=>yS,SS=e=>{addEventListener("pageshow",t=>{t.persisted&&(yS=t.timeStamp,e(t))},!0)},wS=(e,t,i,n)=>{let s,r;return o=>{var a;t.value>=0&&(o||n)&&(r=t.value-(null!==(a=s)&&void 0!==a?a:0),(r||void 0===s)&&(s=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},kS=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},CS=()=>{var e,t;return null!==(e=null===(t=pS())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let ES=-1;const TS=new Set,xS=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,IS=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of TS)e();isFinite(ES)||(ES="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",IS,!0))}},RS=(e=!1)=>{if(e&&(ES=1/0),0>ES){var t;const e=CS(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;ES=null!=i?i:xS(),addEventListener("visibilitychange",IS,!0),addEventListener("prerenderingchange",IS,!0),SS(()=>{setTimeout(()=>{ES=xS()})})}return{get firstHiddenTime(){return ES},onHidden(e){TS.add(e)}}},PS=(e,t=-1,i,n=0,s,r,o)=>{const a=pS(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>bS()?a&&(document.prerendering||CS()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:n||l,navigationInteractionId:s,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},MS=(e,t,i={})=>{try{const n=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(n.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();n.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of n)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},FS=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},AS=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},LS=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var OS=class{constructor(){this.u=void 0}};const DS=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},$S=[1800,3e3],NS=(e,t={})=>{const i=FS(t);DS(()=>{const n=mS(t,OS),s=RS();let r,o=PS("FCP");const a=MS(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),s.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-CS(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=wS(e,o,$S,t.reportAllChanges),SS(i=>{o=PS("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,bS()),r=wS(e,o,$S,t.reportAllChanges),kS(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&MS(["soft-navigation"],i=>{i.forEach(i=>{n.u&&i.navigationId&&AS(n.u,i);const s=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=PS("FCP",s,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=wS(e,o,$S,t.reportAllChanges),r(!0)})},t)})},BS=[.1,.25],qS=e=>e.find(e=>{var t;return 1===(null===(t=e.node)||void 0===t?void 0:t.nodeType)})||e[0],HS=(e,t={})=>{const i=mS(t=Object.assign({},t),hS),n=new WeakMap;i.t=e=>{var i;if(null==e||null===(i=e.sources)||void 0===i?void 0:i.length){const i=qS(e.sources),o=null==i?void 0:i.node;if(o){var s,r;const e=null!==(s=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,o))&&void 0!==s?s:fS(o);n.set(i,e)}}},((e,t={})=>{const i=RS();NS(LS(()=>{let n,s=PS("CLS",0);const r=mS(t,hS),o=(i,o,a,l,c)=>{s=PS("CLS",0,i,o,a,l,c),r.o=0,n=wS(e,s,BS,t.reportAllChanges)},a=(e=!1)=>{r.o>s.value&&(s.value=r.o,s.entries=r.i),n(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.l(t):l(t);a()},u=["layout-shift"];FS(t)&&u.push("soft-navigation");const d=MS(u,c);d&&(n=wS(e,s,BS,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),n(!0)}),SS(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,bS()),kS(n)}),setTimeout(n))}))})(t=>{e((e=>{let t={};if(e.entries.length){var i;const s=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(null==s||null===(i=s.sources)||void 0===i?void 0:i.length){const e=qS(s.sources);e&&(t={largestShiftTarget:n.get(e),largestShiftTime:s.startTime,largestShiftValue:s.value,largestShiftSource:e,largestShiftEntry:s,loadState:gS(s.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},US=(e,t={})=>{const i=mS(t=Object.assign({},t),OS);FS(t)&&(i.u=new Map),NS(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:gS(bS())};if("soft-navigation"!==e.navigationType){if(e.entries.length){const i=pS(),n=e.entries.at(-1);if(i){const s=Math.max(0,i.responseStart-(i.activationStart||0));t={timeToFirstByte:s,firstByteToFCP:e.value-s,loadState:gS(e.entries[0].startTime),navigationEntry:i,fcpEntry:n}}}}else{var n;const s=null===(n=i.u)||void 0===n?void 0:n.get(e.navigationId);s&&(t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:"complete",navigationEntry:s})}return Object.assign(e,{attribution:t})})(t))},t)};let zS=0,WS=1/0,jS=0;const VS=e=>{for(const t of e)t.interactionId&&(WS=Math.min(WS,t.interactionId),jS=Math.max(jS,t.interactionId),zS=jS?(jS-WS)/7+1:0)};let GS;const QS=()=>{var e;return GS?zS:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var KS=class{constructor(){this.h=0,this.v=[],this.p=new Map,this.m=void 0,this.M=void 0}T(){return QS()-this.h}D(){this.h=QS(),this.v.length=0,this.p.clear()}S(e){const t=this.T(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{k:8,id:-1,entries:[]}}l(e){var t;if(null===(t=this.m)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let n=this.p.get(e.interactionId);if(n||10>this.v.length||e.duration>i.k){var s;if(n?e.duration>n.k?(n.entries=[e],n.k=e.duration):e.duration===n.k&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],k:e.duration},this.p.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.k-e.k),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.p.delete(t.id)}null===(s=this.M)||void 0===s||s.call(this,n)}}};const JS=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const s=LS(e);let r=-1;const o=()=>{n(r),s()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),s()},{timeout:t})}},YS=[200,500],ZS=(e,t={})=>{const i=mS(t=Object.assign({},t),KS);let n=[],s=[],r=0;const o=new WeakMap,a=new WeakMap;let l=!1;const c=()=>{l||(JS(u),l=!0)},u=()=>{const e=new Set(i.v.map(e=>o.get(e.entries[0]))),t=s.length-10;s=s.filter((i,n)=>n>=t||e.has(i));const a=new Set;for(const e of s){const t=d(e.startTime,e.processingEnd);for(const e of t)a.add(e)}n=n.filter(e=>e.startTime>r||a.has(e)),l=!1};i.m=e=>{const i=e.startTime+e.duration;let n;r=Math.max(r,e.processingEnd);for(let r=s.length-1;r>=0;r--){const o=s[r];if(8>=Math.abs(i-o.renderTime)){n=o,n.startTime=Math.min(e.startTime,n.startTime),n.processingStart=Math.min(e.processingStart,n.processingStart),n.processingEnd=Math.max(e.processingEnd,n.processingEnd),t.includeProcessedEventEntries&&n.entries.push(e);break}}n||(n={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:i,entries:t.includeProcessedEventEntries?[e]:[]},s.push(n)),e.interactionId&&o.set(e,n),c()},i.M=e=>{if(!a.get(e)){var i;const o=null===(i=e.entries.find(e=>e.target))||void 0===i?void 0:i.target;if(o){var n,s;const i=null!==(n=null===(s=t.generateTarget)||void 0===s?void 0:s.call(t,o))&&void 0!==n?n:fS(o);a.set(e,i)}else{var r;const t=null===(r=e.entries.find(e=>e.targetSelector))||void 0===r?void 0:r.targetSelector;t&&a.set(e,t)}}};const d=(e,t)=>{const i=[];for(const s of n)if(s.startTime+s.duration>=e){if(s.startTime>t)break;i.push(s)}return i};MS(["long-animation-frame"],e=>{n=n.concat(e),c()},t),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=RS();DS(()=>{var n;"interactionCount"in performance||GS||(GS=MS(["event"],VS,{durationThreshold:0}));let s,r=PS("INP");const o=mS(t,KS),a=(i,n,a,l,c)=>{o.D(),r=PS("INP",-1,i,n,a,l,c),s=wS(e,r,YS,t.reportAllChanges)},l=()=>{const e=o.S(r.navigationType);e&&e.k!==r.value&&(r.value=e.k,r.entries=e.entries,s())},c=e=>{l(),s(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{JS(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.l(t):c(t);l(),t&&s(!0)})},d=["event","first-input"];FS(t)&&d.push("soft-navigation");const h=MS(d,u,ct(ct({},t),{},{durationThreshold:null!==(n=t.durationThreshold)&&void 0!==n?n:40}));s=wS(e,r,YS,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),SS(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,bS())}))})})(t=>{e((e=>{if(0===e.entries.length){const t={processedEventEntries:[],longAnimationFrameEntries:[],inputDelay:0,processingDuration:0,presentationDelay:e.value,loadState:gS(e.navigationStartTime||0)};return Object.assign(e,{attribution:t})}const t=e.entries[0],n=o.get(t),s=Math.max(n.processingStart,t.startTime),r=Math.max(t.startTime+t.duration,s),l=Math.min(n.processingEnd,r),c=n.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,l),h=i.p.get(t.interactionId),p={interactionTarget:a.get(h),interactionType:t.name.startsWith("key")?"keyboard":"pointer",interactionTime:t.startTime,nextPaintTime:r,processedEventEntries:c,longAnimationFrameEntries:u,inputDelay:s-t.startTime,processingDuration:l-s,presentationDelay:r-l,loadState:gS(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;const i=e.interactionTime,n=e.nextPaintTime;if(!(null===(t=e.longAnimationFrameEntries)||void 0===t?void 0:t.length)||!i||!n)return;const s=e.inputDelay,r=e.processingDuration;let o,a,l=0,c=0,u=0,d=0;for(const t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(const e of t.scripts){const t=e.startTime+e.duration;if(i>t)continue;const n=t-Math.max(i,e.startTime),u=e.duration?n/e.duration*e.forcedStyleAndLayoutDuration:0;l+=n-u,c+=u,n>d&&(a=i+s>e.startTime?"input-delay":i+s+r>e.startTime?"processing-duration":"presentation-delay",o=e,d=n)}}const h=e.longAnimationFrameEntries.at(-1),p=h?h.startTime+h.duration:0;p>=i+s+r&&(u=n-p),o&&a&&(e.longestScript={entry:o,subpart:a,intersectingDuration:d}),e.totalScriptDuration=l,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=u,e.totalUnattributedDuration=n-i-l-c-u})(p),Object.assign(e,{attribution:p})})(t))},t)};var XS=class{constructor(){this.m=void 0,this.u=void 0}l(e){var t;null===(t=this.m)||void 0===t||t.call(this,e)}};const $=[2500,4e3];let ew=50;const tw=[];MS(["resource"],e=>{for(const t of e)tw.push(t),tw.length>ew&&tw.shift()});const iw=(e,t={})=>{null!=(t=Object.assign({},t)).resourceBufferSize&&(ew=t.resourceBufferSize);const i=mS(t,XS),n=new WeakMap;FS(t)&&(i.u=new Map),i.m=e=>{const i=e.element;if(i){var s,r;const o=null!==(s=null===(r=t.generateTarget)||void 0===r?void 0:r.call(t,i))&&void 0!==s?s:fS(i);n.set(e,o)}else e.id&&n.set(e,`#${e.id}`)},((e,t={})=>{let i=!1;const n=FS(t);DS(()=>{let s,r=RS(),o=PS("LCP");const a=mS(t,XS),l=(n,a,l,c,u)=>{o=PS("LCP",-1,n,a,l,c,u),s=wS(e,o,$,t.reportAllChanges),i=!1,"soft-navigation"===n&&(r=RS(!0))},c=e=>{var t;a.u&&e.navigationId&&AS(a.u,e),i||s(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const n=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);n&&u([n])},u=e=>{t.reportAllChanges||n||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,n=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-CS(),0),a.l(t),n=[t];else if("interaction-contentful-paint"===t.entryType){var i;const s=t;if(!o.navigationId)continue;if("interactionId"in s&&s.interactionId!=o.navigationInteractionId)continue;l=(null===(i=s.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),s.largestContentfulPaint&&(a.l(s.largestContentfulPaint),n=[s.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=n,s())}},d=["largest-contentful-paint"];n&&d.push("interaction-contentful-paint","soft-navigation");const h=MS(d,u);if(h){s=wS(e,o,$,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;JS(()=>{if(!i){if(!n){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,s(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});SS(n=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,bS()),s=wS(e,o,$,t.reportAllChanges),kS(()=>{o.value=performance.now()-n.timeStamp,i=!0,s(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){var s,r,o;const a=e.entries.at(-1),l=a.url&&(tw.findLast(e=>e.name===a.url)||performance.getEntriesByType("resource").findLast(e=>e.name===a.url));let c;t.target=n.get(a),t.lcpEntry=a,a.url&&(t.url=a.url),l&&(t.lcpResourceEntry=l);let u=0,d=0;if("soft-navigation"!==e.navigationType?(c=pS(),u=null!==(s=null==c?void 0:c.activationStart)&&void 0!==s?s:0,d=null!==(r=null==c?void 0:c.responseStart)&&void 0!==r?r:0):(u=e.navigationStartTime||0,c=null===(o=i.u)||void 0===o?void 0:o.get(e.navigationId)),c){const i=Math.max(0,d-u),n=Math.max(i,l?(l.requestStart||l.startTime)-u:0),s=Math.min(e.value,Math.max(n,l?l.responseEnd-u:0));t=ct(ct({},t),{},{timeToFirstByte:i,resourceLoadDelay:n-i,resourceLoadDuration:s-n,elementRenderDelay:e.value-s,navigationEntry:c})}}return Object.assign(e,{attribution:t})})(t))},t)};let nw=-1;const sw=()=>nw,rw=e=>{addEventListener("pageshow",t=>{t.persisted&&(nw=t.timeStamp,e(t))},!0)},ow=(e,t,i,n)=>{let s,r;return o=>{var a;t.value>=0&&(o||n)&&(r=t.value-(null!==(a=s)&&void 0!==a?a:0),(r||void 0===s)&&(s=t.value,t.delta=r,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,i),e(t)))}},aw=e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))},lw=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},cw=()=>{var e,t;return null!==(e=null===(t=lw())||void 0===t?void 0:t.activationStart)&&void 0!==e?e:0};let uw=-1;const dw=new Set,hw=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,pw=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of dw)e();isFinite(uw)||(uw="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",pw,!0))}},gw=(e=!1)=>{if(e&&(uw=1/0),0>uw){var t;const e=cw(),i=document.prerendering||null===(t=globalThis.performance.getEntriesByType("visibility-state").find(t=>"hidden"===t.name&&t.startTime>=e))||void 0===t?void 0:t.startTime;uw=null!=i?i:hw(),addEventListener("visibilitychange",pw,!0),addEventListener("prerenderingchange",pw,!0),rw(()=>{setTimeout(()=>{uw=hw()})})}return{get firstHiddenTime(){return uw},onHidden(e){dw.add(e)}}},_w=(e,t=-1,i,n=0,s,r,o)=>{const a=lw(),l=(null==a?void 0:a.navigationId)||0;let c="navigate";return i?c=i:0>sw()?a&&(document.prerendering||cw()>0?c="prerender":document.wasDiscarded?c="restore":a.type&&(c=a.type.replace(/_/g,"-"))):c="back-forward-cache",{name:e,value:t,rating:"good",delta:0,entries:[],id:`v6-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:c,navigationId:n||l,navigationInteractionId:s,navigationURL:r||(null==a?void 0:a.name),navigationStartTime:o||0}},fw=new WeakMap;function vw(e,t){let i=fw.get(t);return i||(i=new WeakMap,fw.set(t,i)),i.get(e)||i.set(e,new t),i.get(e)}var mw=class{constructor(){this.t=void 0,this.i=0,this.o=[]}h(e){var t;if(e.hadRecentInput)return;const i=this.o[0],n=this.o.at(-1);this.i&&i&&n&&1e3>e.startTime-n.startTime&&5e3>e.startTime-i.startTime?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),null===(t=this.t)||void 0===t||t.call(this,e)}};const yw=(e,t,i={})=>{try{const n=e.filter(e=>PerformanceObserver.supportedEntryTypes.includes(e));if(n.length>0){const e=new PerformanceObserver(e=>{queueMicrotask(()=>{const i=e.getEntries();n.length>1&&i.sort((e,t)=>e.startTime+e.duration-(t.startTime+t.duration)),t(i)})});for(const t of n)e.observe(ct({type:t,buffered:!0},i));return e}}catch(e){}},bw=e=>{var t,i;return(null===(t=globalThis.PerformanceObserver)||void 0===t||null===(t=t.supportedEntryTypes)||void 0===t?void 0:t.includes("soft-navigation"))&&"function"==typeof(null===(i=globalThis.PerformanceSoftNavigation)||void 0===i||null===(i=i.prototype)||void 0===i?void 0:i.getLargestInteractionContentfulPaint)&&e&&e.reportSoftNavs},Sw=(e,t)=>{if(e.set(t.navigationId,t),e.size>2){const t=e.keys().next().value;void 0!==t&&e.delete(t)}},ww=e=>{let t=!1;return()=>{t||(e(),t=!0)}};var kw=class{constructor(){this.l=void 0}};const Cw=e=>{document.prerendering?addEventListener("prerenderingchange",e,!0):e()},Ew=[1800,3e3],Tw=(e,t={})=>{const i=bw(t);Cw(()=>{const n=vw(t,kw),s=gw();let r,o=_w("FCP");const a=yw(["paint"],e=>{for(const t of e)"first-contentful-paint"===t.name&&(a.disconnect(),s.firstHiddenTime>t.startTime&&(o.value=Math.max(t.startTime-cw(),0),o.entries.push(t),o.navigationId=t.navigationId||o.navigationId,r(!0)))});a&&(r=ow(e,o,Ew,t.reportAllChanges),rw(i=>{o=_w("FCP",-1,"back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,sw()),r=ow(e,o,Ew,t.reportAllChanges),aw(()=>{o.value=performance.now()-i.timeStamp,r(!0)})})),i&&yw(["soft-navigation"],i=>{i.forEach(i=>{n.l&&i.navigationId&&Sw(n.l,i);const s=Math.max((i.presentationTime||i.paintTime||0)-i.startTime,0);o=_w("FCP",s,"soft-navigation",i.navigationId,i.interactionId,i.name,i.startTime),r=ow(e,o,Ew,t.reportAllChanges),r(!0)})},t)})},xw=[.1,.25],Iw=(e,t={})=>{const i=gw();Tw(ww(()=>{let n,s=_w("CLS",0);const r=vw(t,mw),o=(i,o,a,l,c)=>{s=_w("CLS",0,i,o,a,l,c),r.i=0,n=ow(e,s,xw,t.reportAllChanges)},a=(e=!1)=>{r.i>s.value&&(s.value=r.i,s.entries=r.o),n(e)},l=e=>{a(!0),o("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},c=e=>{for(const t of e)"soft-navigation"!==t.entryType?r.h(t):l(t);a()},u=["layout-shift"];bw(t)&&u.push("soft-navigation");const d=yw(u,c);d&&(n=ow(e,s,xw,t.reportAllChanges),i.onHidden(()=>{c(d.takeRecords()),n(!0)}),rw(()=>{o("back-forward-cache",s.navigationId,s.navigationInteractionId,s.navigationURL,sw()),aw(n)}),setTimeout(n))}))};let Rw=0,Pw=1/0,Mw=0;const Fw=e=>{for(const t of e)t.interactionId&&(Pw=Math.min(Pw,t.interactionId),Mw=Math.max(Mw,t.interactionId),Rw=Mw?(Mw-Pw)/7+1:0)};let Aw;const Lw=()=>{var e;return Aw?Rw:null!==(e=performance.interactionCount)&&void 0!==e?e:0};var Ow=class{constructor(){this.u=0,this.v=[],this.m=new Map,this.p=void 0,this.T=void 0}_(){return Lw()-this.u}M(){this.u=Lw(),this.v.length=0,this.m.clear()}L(e){const t=this._(),i=Math.min(this.v.length-1,Math.floor(t/50));return!t||-1!==i||"soft-navigation"!==e&&"back-forward-cache"!==e?this.v[i]:{P:8,id:-1,entries:[]}}h(e){var t;if(null===(t=this.p)||void 0===t||t.call(this,e),!e.interactionId)return;const i=this.v.at(-1);let n=this.m.get(e.interactionId);if(n||10>this.v.length||e.duration>i.P){var s;if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.m.set(n.id,n),this.v.push(n)),this.v.sort((e,t)=>t.P-e.P),this.v.length>10){const e=this.v.splice(10);for(const t of e)this.m.delete(t.id)}null===(s=this.T)||void 0===s||s.call(this,n)}}};const Dw=e=>{const t="requestIdleCallback"in globalThis?1e3:0,i=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)e();else{const s=ww(e);let r=-1;const o=()=>{n(r),s()};addEventListener("visibilitychange",o,{once:!0,capture:!0}),r=i(()=>{removeEventListener("visibilitychange",o,{capture:!0}),s()},{timeout:t})}},$w=[200,500],Nw=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const i=gw();Cw(()=>{var n;"interactionCount"in performance||Aw||(Aw=yw(["event"],Fw,{durationThreshold:0}));let s,r=_w("INP");const o=vw(t,Ow),a=(i,n,a,l,c)=>{o.M(),r=_w("INP",-1,i,n,a,l,c),s=ow(e,r,$w,t.reportAllChanges)},l=()=>{const e=o.L(r.navigationType);e&&e.P!==r.value&&(r.value=e.P,r.entries=e.entries,s())},c=e=>{l(),s(!0),a("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime)},u=(e,t=!1)=>{Dw(()=>{for(const t of e)"soft-navigation"!==t.entryType?o.h(t):c(t);l(),t&&s(!0)})},d=["event","first-input"];bw(t)&&d.push("soft-navigation");const h=yw(d,u,ct(ct({},t),{},{durationThreshold:null!==(n=t.durationThreshold)&&void 0!==n?n:40}));s=ow(e,r,$w,t.reportAllChanges),h&&(i.onHidden(()=>{u(h.takeRecords(),!0)}),rw(()=>{a("back-forward-cache",r.navigationId,r.navigationInteractionId,r.navigationURL,sw())}))})};var Bw=class{constructor(){this.p=void 0,this.l=void 0}h(e){var t;null===(t=this.p)||void 0===t||t.call(this,e)}};const qw=[2500,4e3],Hw=(e,t={})=>{let i=!1;const n=bw(t);Cw(()=>{let s,r=gw(),o=_w("LCP");const a=vw(t,Bw),l=(n,a,l,c,u)=>{o=_w("LCP",-1,n,a,l,c,u),s=ow(e,o,qw,t.reportAllChanges),i=!1,"soft-navigation"===n&&(r=gw(!0))},c=e=>{var t;a.l&&e.navigationId&&Sw(a.l,e),i||s(!0),l("soft-navigation",e.navigationId,e.interactionId,e.name,e.startTime);const n=null===(t=e.getLargestInteractionContentfulPaint)||void 0===t?void 0:t.call(e);n&&u([n])},u=e=>{t.reportAllChanges||n||(e=e.slice(-1));for(const t of e){if(!t)continue;if("soft-navigation"===t.entryType){c(t);continue}let e=0,n=[],l=t.startTime;if("largest-contentful-paint"===t.entryType)e=Math.max(t.startTime-cw(),0),a.h(t),n=[t];else if("interaction-contentful-paint"===t.entryType){var i;const s=t;if(!o.navigationId)continue;if("interactionId"in s&&s.interactionId!=o.navigationInteractionId)continue;l=(null===(i=s.largestContentfulPaint)||void 0===i?void 0:i.renderTime)||0,e=Math.max(l-t.startTime,0),s.largestContentfulPaint&&(a.h(s.largestContentfulPaint),n=[s.largestContentfulPaint])}r.firstHiddenTime>l&&(o.value=e,o.entries=n,s())}},d=["largest-contentful-paint"];n&&d.push("interaction-contentful-paint","soft-navigation");const h=yw(d,u);if(h){s=ow(e,o,qw,t.reportAllChanges);const r=["keydown","click","visibilitychange"],a=e=>{if(e.isTrusted&&!i){const e=o.id;Dw(()=>{if(!i){if(!n){h.disconnect();for(const e of r)removeEventListener(e,a,{capture:!0})}e===o.id&&(i=!0,s(!0))}})}};for(const e of r)addEventListener(e,a,{capture:!0});rw(n=>{l("back-forward-cache",o.navigationId,o.navigationInteractionId,o.navigationURL,sw()),s=ow(e,o,qw,t.reportAllChanges),aw(()=>{o.value=performance.now()-n.timeStamp,i=!0,s(!0)})})}})},Uw={onLCP:iw,onCLS:HS,onFCP:US,onINP:ZS,withoutAttribution:{onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution-soft-navs"]=Uw,d.__PosthogExtensions__.postHogWebVitalsCallbacks=Uw,d.postHogWebVitalsCallbacks=Uw;const zw={onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-soft-navs"]=zw,d.__PosthogExtensions__.postHogWebVitalsCallbacks=zw,d.postHogWebVitalsCallbacks=zw,d.__PosthogExtensions__.loadWebVitalsCallbacks=()=>zw;const Ww={onLCP:iw,onCLS:HS,onFCP:US,onINP:ZS,withoutAttribution:{onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals-with-attribution"]=Ww,d.__PosthogExtensions__.postHogWebVitalsCallbacks=Ww,d.postHogWebVitalsCallbacks=Ww;const jw={onLCP:Hw,onCLS:Iw,onFCP:Tw,onINP:Nw};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor=d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor||{},d.__PosthogExtensions__.postHogWebVitalsCallbacksByFlavor["web-vitals"]=jw,d.__PosthogExtensions__.postHogWebVitalsCallbacks=jw,d.postHogWebVitalsCallbacks=jw,d.__PosthogExtensions__.loadWebVitalsCallbacks=()=>jw;const Vw={};function Gw(e,t){const i=bo(e);return i?ct({node:i,originalEvent:e,timestamp:Date.now()},t):null}function Qw(e){return!!un(()=>uo(e))}function Kw(e,t){return Math.abs(e)<Math.abs(t)?0>t?"up":"down":0>e?"left":"right"}function Jw(e){return"swipe"===e.type?"$dead_swipe":"$dead_click"}const Yw="canvas,video,audio,embed,object";function Zw(e,t){return Ft(e)&&e>=t}function Xw(e,t=1e3){return e>=0&&t>e?e:void 0}function ek(e,t,i=1e3){return Ft(t)?Xw(e-t,i):void 0}var tk=class{_asRequiredConfig(e){var t,i,n,s,r,o,a,l;const c=this._defaultConfig((null==e?void 0:e.__onCapture)||this._captureDeadClick.bind(this));return{element_attribute_ignorelist:null!==(t=null==e?void 0:e.element_attribute_ignorelist)&&void 0!==t?t:c.element_attribute_ignorelist,scroll_threshold_ms:null!==(i=null==e?void 0:e.scroll_threshold_ms)&&void 0!==i?i:c.scroll_threshold_ms,selection_change_threshold_ms:null!==(n=null==e?void 0:e.selection_change_threshold_ms)&&void 0!==n?n:c.selection_change_threshold_ms,mutation_threshold_ms:null!==(s=null==e?void 0:e.mutation_threshold_ms)&&void 0!==s?s:c.mutation_threshold_ms,capture_clicks_with_modifier_keys:null!==(r=null==e?void 0:e.capture_clicks_with_modifier_keys)&&void 0!==r?r:c.capture_clicks_with_modifier_keys,capture_dead_swipes:null!==(o=null==e?void 0:e.capture_dead_swipes)&&void 0!==o?o:c.capture_dead_swipes,swipe_threshold_px:null!==(a=null==e?void 0:e.swipe_threshold_px)&&void 0!==a?a:c.swipe_threshold_px,max_dead_swipes_per_page_load:null!==(l=null==e?void 0:e.max_dead_swipes_per_page_load)&&void 0!==l?l:c.max_dead_swipes_per_page_load,css_selector_ignorelist:null==e?void 0:e.css_selector_ignorelist,__onCapture:c.__onCapture}}constructor(e,t){this.instance=e,this._observedRoots=new WeakSet,this._hadSelection=!1,this._clicks=[],this._deadSwipesCaptured=0,this._defaultConfig=e=>({element_attribute_ignorelist:[],scroll_threshold_ms:100,selection_change_threshold_ms:100,mutation_threshold_ms:2500,capture_clicks_with_modifier_keys:!1,capture_dead_swipes:!0,swipe_threshold_px:30,max_dead_swipes_per_page_load:10,__onCapture:e}),this._clearMouseSelection=()=>{clearTimeout(this._mouseSelectionTimer),this._mouseSelectionTimer=void 0,this._mouseSelection=void 0},this._onMouseDown=e=>{if(this._observeGesturePath(e),this._clearMouseSelection(),0===e.button){const t={path:e.composedPath(),trusted:e.isTrusted,selectionChanged:!1,selectionInitiallyRelated:!1},i=null==n?void 0:n.getSelection();t.selectionInitiallyRelated="Range"===(null==i?void 0:i.type)&&this._selectionTouchesGesture(i,t),this._mouseSelection=t}},this._onMouseOut=e=>{Pt(e.relatedTarget)&&this._clearMouseSelection()},this._onMouseUp=e=>{const t=this._mouseSelection,i=e;if(!t||0!==i.button||e.isTrusted!==t.trusted)return;const n=e.composedPath();for(const e of t.path)if(Qw(e)&&-1!==n.indexOf(e)){t.clickTarget=e;break}t.clickDetail=i.detail,this._mouseSelectionTimer=d.setTimeout(this._clearMouseSelection,0)},this._onClick=e=>{this._observeGesturePath(e);const t=e,i=Gw(t,{type:"click"}),n=this._mouseSelection;i&&n&&0===t.button&&t.detail>0&&t.detail===n.clickDetail&&e.isTrusted===n.trusted&&i.node===n.clickTarget&&(i.selectionChangedDuringGesture=n.selectionChanged&&this._config.selection_change_threshold_ms>0,this._clearMouseSelection()),Pt(i)||this._ignore(i)||this._queueCandidate(i),this._scheduleCheck()},this._onScroll=()=>{const e=Date.now();this._lastScroll=e,e%50==0&&this._clicks.forEach(t=>{xt(t.scrollDelayMs)&&(t.scrollDelayMs=e-t.timestamp)})},this._onSelectionChange=e=>{var t,i;const s=null==n?void 0:n.getSelection(),r=this._hadSelection;this._hadSelection="Range"===(null==s?void 0:s.type);const o=null==s?void 0:s.focusNode,a=o&&(uo(o)?o:o.parentElement),l=null==n?void 0:n.activeElement;let c=l;for(;null==c||null===(t=c.shadowRoot)||void 0===t?void 0:t.activeElement;)c=c.shadowRoot.activeElement;const u=$o(bo(e))||$o(null!=a?a:null)||$o(null!==(i=c)&&void 0!==i?i:null),d="Caret"===(null==s?void 0:s.type)&&c&&!c.shadowRoot&&o&&o!==l&&o.contains(null!=l?l:null);if(!(r||this._hadSelection||u||d))return;const h=Date.now();this._lastSelectionChanged=h;const p=this._mouseSelection;if(p&&(r||this._hadSelection||u)){const t=bo(e);let i;if($o(t))i=t;else if("Caret"===(null==s?void 0:s.type)){var g;$o(null!==(g=c)&&void 0!==g?g:null)||d?i=c:u&&(i=a)}const n=i?this._selectionIsInGesture(i,p):s&&(o||s.anchorNode)?this._selectionTouchesGesture(s,p):r&&!this._hadSelection&&p.selectionInitiallyRelated;p.selectionChanged=p.selectionChanged||n}this._clicks.forEach(e=>{const t=h-e.timestamp;0>t||!xt(e.selectionChangedDelayMs)&&t>=e.selectionChangedDelayMs||(e.selectionChangedDelayMs=t)})},this._onVisibilityChange=()=>{"hidden"===(null==n?void 0:n.visibilityState)&&this._clearMouseSelection();const e=Date.now();this._lastVisibilityChange=e,this._recordLivenessSignal("visibilityChangedDelayMs",e)},this._onFocusChange=()=>{const e=Date.now();this._lastFocusChange=e,this._recordLivenessSignal("focusChangedDelayMs",e)},this._onTouchStart=e=>{this._observeGesturePath(e);const t=e.touches,i=1===(null==t?void 0:t.length)?t[0]:void 0;this._touchStart=i?{x:i.clientX,y:i.clientY,timestamp:Date.now()}:void 0},this._onTouchCancel=()=>{this._touchStart=void 0},this._onTouchEnd=e=>{var t;const i=this._touchStart;if(this._touchStart=void 0,xt(i)||this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)return;const s=e,r=null===(t=s.changedTouches)||void 0===t?void 0:t[0];if(!r)return;const o=r.clientX-i.x,a=r.clientY-i.y,l=o*o+a*a,c=this._config.swipe_threshold_px;if(c*c>l)return;if([this._lastScroll,this._lastMutation,this._lastSelectionChanged].some(e=>Ft(e)&&e>=i.timestamp))return;var u,d;if(this._pageHasUnobservableSurfaces()&&(null!==(u=null==n||null===(d=n.elementsFromPoint)||void 0===d?void 0:d.call(n,i.x,i.y))&&void 0!==u?u:[]).some(e=>{var t;return null===(t=e.matches)||void 0===t?void 0:t.call(e,Yw)}))return;const h=Gw(s,{type:"swipe",swipeDirection:Kw(o,a),swipeDistancePx:Math.round(Math.sqrt(l))});Pt(h)||this._ignore(h)||this._queueCandidate(h),this._scheduleCheck()},this._config=this._asRequiredConfig(t),this._onCapture=this._config.__onCapture}start(e){this._startClickObserver(),this._startScrollObserver(),this._startSelectionChangedObserver(),this._startVisibilityChangeObserver(),this._startFocusChangeObserver(),this._startMutationObserver(e),this._config.capture_dead_swipes&&this._startSwipeObserver()}_startMutationObserver(t){if(!this._mutationObserver){const i=function(t){return function(t,i){const n=Vw[t];if(n)return n;let s=i[t];if((e=>Ct(e)&&-1!==e.toString().indexOf("[native code]"))(s)&&!(null==e?void 0:e.Zone))return Vw[t]=s.bind(i);const r=i.document;if(r&&Ct(r.createElement)){let e,n=!1;try{e=r.createElement("iframe"),e.hidden=!0,r.head.appendChild(e);const l=e.contentWindow;var o,a;l&&l[t]&&(s=l[t],"MutationObserver"===t&&function(e){return ft(e,"AppleWebKit")&&!ft(e,"Chrome")}(null!==(o=null===(a=i.navigator)||void 0===a?void 0:a.userAgent)&&void 0!==o?o:"")&&(e.classList.add("rr-block","ph-no-capture"),n=!0))}catch(e){Nr.warn(`Could not create sandbox iframe for ${t} check, bailing to assignableWindow.${t}: `,e)}finally{!n&&(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}}return s&&Ct(s)?Vw[t]=s.bind(i):s}("MutationObserver",t)}(d);this._mutationObserver=new i(e=>{this._onMutation(e)}),this._observeRoot(t)}}_observeRoot(e){e&&this._mutationObserver&&(this._observedRoots.has(e)||(this._mutationObserver.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),this._observedRoots.add(e),this._observeShadowRoots(e)))}_observeShadowRoots(e,t){var i,n;uo(e)&&e.shadowRoot&&this._observeRoot(e.shadowRoot);const s=null!==(i=null===(n=e.querySelectorAll)||void 0===n?void 0:n.call(e,"*"))&&void 0!==i?i:[];for(let e=0;s.length>e;e++)null==t||t.add(s[e]),this._observeRoot(s[e].shadowRoot)}_observeGesturePath(e){var t,i;const n=null!==(t=null===(i=e.composedPath)||void 0===i?void 0:i.call(e))&&void 0!==t?t:[];for(let e=0;n.length>e;e++){const t=n[e];Qw(t)&&this._observeRoot(t.shadowRoot)}}stop(){var e;null===(e=this._mutationObserver)||void 0===e||e.disconnect(),this._mutationObserver=void 0,this._observedRoots=new WeakSet,d.removeEventListener("click",this._onClick,{capture:!0}),d.removeEventListener("mousedown",this._onMouseDown,{capture:!0}),d.removeEventListener("mouseup",this._onMouseUp,{capture:!0}),d.removeEventListener("mouseout",this._onMouseOut,{capture:!0}),d.removeEventListener("dragstart",this._clearMouseSelection,{capture:!0}),d.removeEventListener("pointercancel",this._clearMouseSelection,{capture:!0}),d.removeEventListener("blur",this._clearMouseSelection),this._clearMouseSelection(),d.removeEventListener("scroll",this._onScroll,{capture:!0}),null==n||n.removeEventListener("selectionchange",this._onSelectionChange),d.removeEventListener("touchstart",this._onTouchStart,{capture:!0}),d.removeEventListener("touchend",this._onTouchEnd,{capture:!0}),d.removeEventListener("touchcancel",this._onTouchCancel,{capture:!0}),null==n||n.removeEventListener("visibilitychange",this._onVisibilityChange),d.removeEventListener("blur",this._onFocusChange),d.removeEventListener("focus",this._onFocusChange),this._touchStart=void 0}_onMutation(e){const t=new Set;for(const n of e)try{var i;if(!1===(null===(i=n.target)||void 0===i?void 0:i.isConnected))continue;this._lastMutation=Date.now();const e=n.addedNodes;for(let i=0;e.length>i;i++){const n=e[i];Qw(n)&&!t.has(n)&&this._observeShadowRoots(n,t)}}catch(e){}}_startClickObserver(){Kr(d,"click",this._onClick,{capture:!0}),Kr(d,"mousedown",this._onMouseDown,{capture:!0}),Kr(d,"mouseup",this._onMouseUp,{capture:!0}),Kr(d,"mouseout",this._onMouseOut,{capture:!0}),Kr(d,"dragstart",this._clearMouseSelection,{capture:!0}),Kr(d,"pointercancel",this._clearMouseSelection,{capture:!0}),Kr(d,"blur",this._clearMouseSelection)}_queueCandidate(e){e.selectionChangedDelayMs=ek(e.timestamp,this._lastSelectionChanged,this._config.selection_change_threshold_ms),e.visibilityChangedDelayMs=ek(e.timestamp,this._lastVisibilityChange),e.focusChangedDelayMs=ek(e.timestamp,this._lastFocusChange),this._clicks.push(e)}_scheduleCheck(){this._clicks.length&&xt(this._checkClickTimer)&&(this._checkClickTimer=d.setTimeout(()=>{this._checkClicks()},1e3))}_startScrollObserver(){Kr(d,"scroll",this._onScroll,{capture:!0})}_startSelectionChangedObserver(){var e;this._hadSelection="Range"===(null==n||null===(e=n.getSelection())||void 0===e?void 0:e.type),Kr(n,"selectionchange",this._onSelectionChange)}_selectionIsInGesture(e,t){const i=t.path[0];try{for(;e;){if(-1!==t.path.indexOf(e)||uo(i)&&i.contains(e))return!0;e=e.getRootNode().host}}catch(e){}return!1}_selectionTouchesGesture(e,t){const i=t.path[0],n=e.rangeCount>0?e.getRangeAt(0):void 0,s=!!n&&un(()=>n.startContainer.getRootNode()===i.getRootNode());if(n&&s&&uo(i)){var r;if(!n.collapsed)return n.intersectsNode(i);const e=uo(n.startContainer)&&null!==(r=n.startContainer.childNodes[n.startOffset])&&void 0!==r?r:n.startContainer;return this._selectionIsInGesture(e,t)}return this._selectionIsInGesture(e.focusNode,t)||this._selectionIsInGesture(e.anchorNode,t)}_startVisibilityChangeObserver(){Kr(n,"visibilitychange",this._onVisibilityChange)}_startFocusChangeObserver(){Kr(d,"blur",this._onFocusChange),Kr(d,"focus",this._onFocusChange)}_recordLivenessSignal(e,t){this._clicks.forEach(i=>{const n=Xw(t-i.timestamp);Ft(n)&&(xt(i[e])||i[e]>n)&&(i[e]=n)})}_startSwipeObserver(){Kr(d,"touchstart",this._onTouchStart,{capture:!0,passive:!0}),Kr(d,"touchend",this._onTouchEnd,{capture:!0,passive:!0}),Kr(d,"touchcancel",this._onTouchCancel,{capture:!0,passive:!0})}_pageHasUnobservableSurfaces(){const e=xt(this._surfacesCheckedAt)||Ft(this._lastMutation)&&this._lastMutation>this._surfacesCheckedAt;return(xt(this._hasUnobservableSurfaces)||e)&&(this._surfacesCheckedAt=Date.now(),this._hasUnobservableSurfaces=!!(null==n?void 0:n.querySelector(Yw))),!!this._hasUnobservableSurfaces}_ignore(e){return!e||("swipe"===e.type?this._ignoreCommon(e):this._ignoreClick(e))}_ignoreCommon(e){return!(!co(e.node)&&!this._clicks.some(t=>t.type===e.type&&t.node===e.node&&1e3>Math.abs(t.timestamp-e.timestamp))&&!ho(e.node,"html")&&uo(e.node)&&function(e,t){var i;if(!(typeof window>"u"?void 0:window)||Bo(e))return!1;const n=Lt(t)?Lo:null!==(i=null==t?void 0:t.css_selector_ignorelist)&&void 0!==i?i:Lo,{targetElementList:s}=qo(e,!1);return!ko(s,n)}(e.node,{css_selector_ignorelist:this._config.css_selector_ignorelist}))}_ignoreClick(e){return!(this._config.capture_clicks_with_modifier_keys||(t=e.originalEvent,!(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey)))||!!this._ignoreCommon(e)||function(e){if(!(typeof window>"u"?void 0:window)||Bo(e))return!1;const{targetElementList:t}=qo(e,!1);return t.some(e=>ho(e,"a"))}(e.node);var t}_checkClicks(){if(!this._clicks.length)return;clearTimeout(this._checkClickTimer),this._checkClickTimer=void 0;const e=this._clicks;this._clicks=[];for(const i of e){var t;i.mutationDelayMs=null!==(t=i.mutationDelayMs)&&void 0!==t?t:this._lastMutation&&this._lastMutation>=i.timestamp?this._lastMutation-i.timestamp:void 0,i.absoluteDelayMs=Date.now()-i.timestamp;const e=Zw(i.scrollDelayMs,this._config.scroll_threshold_ms),n=Zw(i.selectionChangedDelayMs,this._config.selection_change_threshold_ms),s=Zw(i.mutationDelayMs,this._config.mutation_threshold_ms),r=Zw(i.absoluteDelayMs,1.1*this._config.mutation_threshold_ms),o=Ft(i.scrollDelayMs)&&this._config.scroll_threshold_ms>i.scrollDelayMs,a=Ft(i.mutationDelayMs)&&this._config.mutation_threshold_ms>i.mutationDelayMs,l=i.selectionChangedDuringGesture||Ft(i.selectionChangedDelayMs)&&this._config.selection_change_threshold_ms>i.selectionChangedDelayMs,c=Ft(i.visibilityChangedDelayMs),u=Ft(i.focusChangedDelayMs);if(!(o||a||l||c||u))if(e||s||r||n){const t=Jw(i);if("$dead_swipe"===t){if(this._deadSwipesCaptured>=this._config.max_dead_swipes_per_page_load)continue;this._deadSwipesCaptured++}this._onCapture(i,{[`${t}_last_mutation_timestamp`]:this._lastMutation,[`${t}_event_timestamp`]:i.timestamp,[`${t}_scroll_timeout`]:e,[`${t}_mutation_timeout`]:s,[`${t}_absolute_timeout`]:r,[`${t}_selection_changed_timeout`]:n,[`${t}_visibility_changed_timeout`]:!1})}else this._config.mutation_threshold_ms>i.absoluteDelayMs&&this._clicks.push(i)}this._scheduleCheck()}_captureDeadClick(e,t){const i=Jw(e);this.instance.capture(i,ct(ct(ct({},t),Gy(e.node,{e:e.originalEvent,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:!1,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}).props),{},{[`${i}_scroll_delay_ms`]:e.scrollDelayMs,[`${i}_mutation_delay_ms`]:e.mutationDelayMs,[`${i}_absolute_delay_ms`]:e.absoluteDelayMs,[`${i}_selection_changed_delay_ms`]:e.selectionChangedDelayMs,[`${i}_visibility_changed_delay_ms`]:e.visibilityChangedDelayMs,[`${i}_focus_changed_delay_ms`]:e.focusChangedDelayMs,$dead_swipe_direction:e.swipeDirection,$dead_swipe_distance_px:e.swipeDistancePx}),{timestamp:new Date(e.timestamp)})}};d.__PosthogExtensions__=d.__PosthogExtensions__||{},d.__PosthogExtensions__.initDeadClicksAutocapture=(e,t)=>new tk(e,t);var ik=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}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(){const{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(){const e=this._storage._get(this._storageKey);return Wt(e)?1:ft(jt,e)?0:-1}get _storage(){const e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Dl:Ll,i=t._is_supported()?t:Ql;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;const t="localStorage"===e?Ll:Dl;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(Wt(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,d.doNotTrack,null==i?void 0:i.globalPrivacyControl].some(e=>Wt(e))}};const nk=Br("[Dead Clicks]"),sk=()=>!0,rk=e=>{var t;const i=!!(null===(t=e.instance.persistence)||void 0===t?void 0:t.get_property(Z)),n=e.instance.config.capture_dead_clicks;return Lt(n)?n:!!Et(n)||i};var ok=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Z]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this.instance,"dead-clicks-autocapture",t=>{t?nk.error("failed to load script",t):e()})}_start(){var e;if(n){if(!this._lazyLoadedDeadClicksAutocapture&&(null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.initDeadClicksAutocapture)){const e=Et(this.instance.config.capture_dead_clicks)?ct({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=d.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this._lazyLoadedDeadClicksAutocapture.start(n),nk.info("starting...")}}else nk.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,nk.info("stopping..."))}};const ak=Br("[SegmentIntegration]");function lk(e,t,i=!0){const n=e.config.segment;if(!n)return t();const{analytics:s,filterProperties:r}=(e=>Ct(e.register))(o=n)?{analytics:o}:o;var o;!function(e,t,i,n){const s=t=>{const s=()=>t.anonymousId()||Rl();e.config.get_device_id=s,n&&t.id()&&(e.register({distinct_id:t.id(),$device_id:s()}),e.persistence.set_property(xe,Ye)),i(n?void 0:t.anonymousId()||void 0)},r=t.user();"then"in r&&Ct(r.then)?r.then(s):s(r)}(e,s,i=>{s.register(((e,t,{filterProperties:i}={})=>{"undefined"!=typeof Promise&&Promise.resolve||ak.warn("This browser does not have Promise support, and can not use the segment integration");const n=(n,s)=>{if(!s)return n;const r=!!t&&n.event.anonymousId===t&&!n.event.userId;r||n.event.userId||n.event.anonymousId===e.get_distinct_id()||(ak.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),n.event.userId&&n.event.userId!==e.get_distinct_id()&&(ak.info("UserId set, identifying with PostHog"),e.identify(n.event.userId));let o=e.calculateEventProperties(s,n.event.properties);if(!Mt(i)){const e=n.event.properties||{},t={};for(const i of Object.keys(o))St.call(e,i)||(t[i]=o[i]);const s=((e,t)=>{const i=kt(e)?e:[e];let n=ct({},t);for(const e of i)try{if(n=e(n),Mt(n))return null}catch(e){return ak.error("Error in Segment filterProperties:",e),null}return n})(i,t);if(Mt(s))return n;o=s}return n.event.properties=Object.assign({},o,n.event.properties),n};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return n(e,e.event.event)},page(e){return n(e,et)},identify(e){return n(e,it)},screen(e){return n(e,"$screen")}}})(e,i,{filterProperties:r})).then(()=>{t()},e=>{ak.error("Failed to register the Segment integration",e),t()})},i)}const ck="posthog-js";function uk(e,{organization:t,projectId:i,prefix:n,severityAllowList:s=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,d;if("*"!==s&&!s.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const p=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],g=p.map(e=>ct(ct({},e),{},{stacktrace:e.stacktrace?ct(ct({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>ct(ct({},e),{},{platform:"web:javascript"}))}):void 0})),_={$exception_message:(null===(l=p[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=p[0])||void 0===c?void 0:c.type,$exception_level:o.level,$exception_list:g,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=p[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=p[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var f;return t&&i&&(_.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&(null===(f=e.exceptions)||void 0===f||f.sendExceptionEvent(_)),o}}var dk=class{constructor(e,t,i,n,s,r){this.name=ck,this.setupOnce=function(o){o(uk(e,{organization:t,projectId:i,prefix:n,severityAllowList:s,sendExceptionsToPostHog:null==r||r}))}}},hk=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Nr.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?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null===(e=this._unsubscribeSessionId)||void 0===e||e.call(this),this._unsubscribeSessionId=void 0}doPageView(t,i){var n;const s=this._previousPageViewProperties(t,i);return this._currentPageview={pathname:null!==(n=null==e?void 0:e.location.pathname)&&void 0!==n?n:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){const i=this._currentPageview;if(!i)return{$pageview_id:t};let n={$pageview_id:t,$prev_pageview_id:i.pageViewId};const s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=s;if(!(xt(e)||xt(t)||xt(i)||xt(r)||xt(o)||xt(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);const s=e>1?Kt(t/e,0,1,Nr):1,l=e>1?Kt(i/e,0,1,Nr):1,c=r>1?Kt(o/r,0,1,Nr):1,u=r>1?Kt(a/r,0,1,Nr):1;n=Ur(n,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:s,$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:l,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:u})}}return i.pathname&&(n.$prev_pageview_pathname=i.pathname),i.timestamp&&(n.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),n}};const pk=["flags","surveys"],gk={[O]:{exposure:"hidden"},[q]:{exposure:"hidden"},[H]:{exposure:"hidden"},[V]:{exposure:"hidden"},[z]:{exposure:"hidden"},[j]:{exposure:"hidden"},[I]:{exposure:"event"},[G]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[Q]:{exposure:"event"},[K]:{exposure:"hidden"},[J]:{exposure:"event"},[Y]:{exposure:"event"},[Z]:{exposure:"event"},[X]:{exposure:"hidden"},[te]:{exposure:"event"},[ie]:{exposure:"hidden"},[ne]:{exposure:"hidden"},[ce]:{exposure:"hidden"},[ue]:{exposure:"event"},[se]:{exposure:"event",shouldSkipFromEventProperties:e=>Pt(e)},[de]:{exposure:"event"},[he]:{exposure:"event"},[pe]:{exposure:"event"},[ve]:{exposure:"event"},[me]:{exposure:"hidden"},[y]:{exposure:"hidden",storageGroup:"flags"},[p]:{exposure:"hidden",storageGroup:"flags"},[h]:{exposure:"hidden"},[g]:{exposure:"hidden",storageGroup:"flags"},[C]:{exposure:"hidden",storageGroup:"flags"},[v]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[m]:{exposure:"hidden",storageGroup:"flags"},[E]:{exposure:"hidden"},[T]:{exposure:"hidden"},[S]:{exposure:"hidden"},[b]:{exposure:"hidden"},[R]:{exposure:"hidden",storageGroup:"surveys"},[P]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[F]:{exposure:"event"},[A]:{exposure:"hidden"},[L]:{exposure:"hidden"},[be]:{exposure:"hidden"},[Se]:{exposure:"hidden"},[we]:{exposure:"hidden"},[ke]:{exposure:"event"},[Ce]:{exposure:"event"},[Ee]:{exposure:"event"},[Te]:{exposure:"event"},[w]:{exposure:"hidden"},[k]:{exposure:"hidden"},[ye]:{exposure:"event"},[_]:{exposure:"hidden"},[f]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[xe]:{exposure:"hidden"},[Ie]:{exposure:"hidden"},[Re]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[Me]:{exposure:"hidden"},[Fe]:{exposure:"hidden"},[Ae]:{exposure:"hidden"},[re]:{exposure:"event"},[oe]:{exposure:"event"},[ae]:{exposure:"event"},[le]:{exposure:"event"},[De]:{exposure:"event"},[$e]:{exposure:"event"},[Ne]:{exposure:"hidden"},[Be]:{exposure:"hidden"},[qe]:{exposure:"hidden"},[He]:{exposure:"hidden"},[Ue]:{exposure:"hidden"},[ze]:{exposure:"hidden"},[We]:{exposure:"hidden"},[je]:{exposure:"hidden"},[Ve]:{exposure:"hidden"},[Ke]:{exposure:"event"}},_k=[[ge,{exposure:"hidden"}],[_e,{exposure:"hidden"}],[fe,{exposure:"hidden"}]],fk=e=>{const t=gk[e];if(t)return t;for(const[t,i]of _k)if(0===e.indexOf(t))return i},vk={flags:f,surveys:P},mk=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],yk=e=>`${e}_cookie_identity_change_pending`,bk=e=>{let t="",i=0;for(const n of e){const e=encodeURIComponent(JSON.stringify(n).slice(1,-1)).length;if(i+e>1e3)break;t+=n,i+=e}return t},Sk="main",wk=[y,p,g,C,v,f,m,S],kk=e=>-1!==wk.indexOf(e),Ck=[z,j],Ek=e=>-1!==Ck.indexOf(e),Tk=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},xk=e=>{if(!e)return{};const t=JSON.parse(e);return Et(t)?t:{}},Ik=(e,t)=>{Hr(e,(i,n)=>{const s=fk(n);s&&"event"!==s.exposure||{}.hasOwnProperty.call(t,n)||delete e[n]})};var Rk=class{constructor(t,i,n=!0,s=!t.cookieless_mode){if(this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=t,this._ownsSplitStorage=n,this.props={},this._campaign_params_url=void 0,this._name=(e=>{let 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"})(t),this._disabled=t.disable_persistence||!!i,this._storage=this._buildStorage(t),this._splitStorage=this._resolveSplitStorage(t),this.load(s),this._markLoadedCrossTabFeatureFlagChangesPending(),t.debug&&Nr.info("Persistence loaded",t.persistence,ct({},this.props)),this.update_config(t,t,i),this.save(),e){const t=()=>this.flush();Kr(e,"beforeunload",t,{capture:!1}),Kr(e,"pagehide",t,{capture:!1}),this._onStorage=t=>{if(this._splitStorageEligible&&(!t.storageArea||t.storageArea===(null==e?void 0:e.localStorage))&&t.key)if(t.key!==this._name){if(this._splitStorage){const e=pk.find(e=>t.key===this._groupEntryName(e));e&&this._syncCrossTabFeatureFlagProperties(t.key,e)}}else this._syncCrossTabFeatureFlagProperties(t.key,Sk)},Kr(e,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!kk(e)||!0===i)return;if(!0===t)return void this._setCrossTabFeatureFlagChangesPending(e,!0);const n=new Set(i||[]);t.forEach(e=>n.add(e)),n.size&&this._setCrossTabFeatureFlagChangesPending(e,n)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&e&&(e.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i=!0){if(this._disabled)return!1;let n,s;try{if(s=Dl._get(e),Pt(s)){const e=this._slotWriteState(t);return e.storageValue=null,t!==Sk&&(e.persisted=!1),!1}n=xk(s)}catch(e){return!1}const r=t===Sk?n:Dl._parse(this._name);if(r&&this._hasCrossTabFeatureFlagIdentityMismatch(r))return!1;const o=this._mergeCrossTabFeatureFlagProperties(n,t,i);return t===Sk&&this._splitStorage&&!Tk(this._partitionProps().main,n)||this._rememberCrossTabStorageFingerprint(n,t,!0,s),o}_hasCrossTabFeatureFlagIdentityMismatch(e){const t=this.props[D],i=e[D];return!xt(t)&&!xt(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,n){const s=this._slotWriteState(t);s.storageValue=n,t!==Sk&&(s.persisted=i);try{s.fingerprint=this._entryFingerprint(e,t)}catch(e){s.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){let n=!1;return wk.forEach(i=>{var s;const r=null===(s=fk(i))||void 0===s?void 0:s.storageGroup;if(t===Sk&&this._splitStorage&&r||t!==Sk&&r!==t)return;const o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&Tk(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),n=!0)}),n&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),n}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;const e=Dl._get(this._name),t=this._slotWriteState(Sk);let i,n=!1,s=!1;if(e!==t.storageValue)if(Pt(e))t.storageValue=null;else{if(i=xk(e),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(i),this._crossTabFeatureFlagIdentityMismatch)return!1;s=this._mergeCrossTabFeatureFlagProperties(i,Sk,!1),!this._splitStorage||Tk(this._partitionProps().main,i)?this._rememberCrossTabStorageFingerprint(i,Sk,!0,e):t.storageValue=e,n=!0}return this._splitStorage&&pk.forEach(e=>{const t=Dl._get(this._groupEntryName(e)),r=this._slotWriteState(e),o=i||{},a=n&&wk.some(t=>{var i;return(null===(i=fk(t))||void 0===i?void 0:i.storageGroup)===e&&t in o});if(t===r.storageValue&&!a)return;if(Pt(t))return r.storageValue=null,r.persisted=!1,void(a&&(s=this._mergeCrossTabFeatureFlagProperties(o,e,!1)||s));const l=xk(t);s=this._mergeCrossTabFeatureFlagProperties(l,e,!1)||s,this._rememberCrossTabStorageFingerprint(l,e,!0,t)}),s}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);const i=fk(e);(null==i?void 0:i.volatile)||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||Sk).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){wk.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{const e=Dl._get(this._name),t=xk(e);this._slotWriteState(Sk).storageValue=e,wk.forEach(e=>{var i;const n=this._splitStorage?null===(i=fk(e))||void 0===i?void 0:i.storageGroup:void 0,s=n?Dl._get(this._groupEntryName(n)):null;if(n){const e=this._slotWriteState(n);e.storageValue=s,e.persisted=!Pt(s)}const r=n&&!Pt(s)?xk(s):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,r[e],this.props[e]):e in r&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){const n=new Set(kt(t)?t:[]),s=new Set(kt(this.props[e])?this.props[e]:[]);return i.forEach(e=>s.has(e)?n.add(e):n.delete(e)),Array.from(n)}const n=Et(t)?ct({},t):{},s=Et(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in s?n[e]=s[e]:delete n[e]}),n}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(!kk(e))return;const n=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0===n)return;let s=t;if(this._splitStorageEligible)try{var r;const t=this._splitStorage?null===(r=fk(e))||void 0===r?void 0:r.storageGroup:void 0,i=t?this._groupEntryName(t):this._name;s=xk(Dl._get(i))[e]}catch(e){}const o=new Set(n||[]);if("$active_feature_flags"===e){if(!xt(t)&&!kt(t)||!xt(s)&&!kt(s)||!kt(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const n=new Set(t||[]),r=new Set(s||[]),a=new Set(i);new Set([...n,...a]).forEach(e=>{n.has(e)!==a.has(e)&&o.add(e)}),o.forEach(e=>{r.has(e)===a.has(e)&&o.delete(e)})}else{if(!Et(i))return void(Tk(s,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));{if(!xt(t)&&!Et(t)||xt(t)&&Tt(i)&&xt(s))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const n=Et(t)?t:{},r=Et(s)?s:{};new Set([...Object.keys(n),...Object.keys(i)]).forEach(e=>{e in n==e in i&&Tk(n[e],i[e])||o.add(e)}),o.forEach(e=>{e in r==e in i&&Tk(r[e],i[e])&&o.delete(e)})}}o.size?this._setCrossTabFeatureFlagChangesPending(e,o):this._pendingCrossTabFeatureFlagChanges.delete(e)}_saveDebounceMs(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return Ft(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{const t=Ul(e,this._config.cookie_persisted_properties||[]),i=Wl(t,this._config.cookie_persisted_properties||[]),n=JSON.stringify(t)+"|"+JSON.stringify(i),s=Ll._get(this._name)||void 0;s&&Vl(this._name,s)===n&&(this._lastSeenCookiePropertiesFingerprint=n,this._lastSeenMainCookieValue=s)}catch(e){}else try{const e=Ll._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=e?Vl(this._name,e):void 0,this._lastSeenMainCookieValue=e}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t=!1){if(this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;let i;try{i=Ll._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;const n=Vl(this._name,i);let s;try{s=Hl(JSON.parse(i))}catch(e){return!1}if((Ll._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=n,this._lastSeenMainCookieValue=i;const r=jl(this._name,i),o=[...Nl,...r.properties],a={};if(Object.keys(s).forEach(e=>{const t=s[e];(xt(t)||Pt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete s[e])}),Tt(s))return!1;const l="distinct_id"in s||"anonymous"===s.$user_state||"identified"===s.$user_state,c=this.props,u=c[D],d=c[xe],h=Ur({},c);[...Nl,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in s)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){const t=h[e];(r.isValid||-1===Nl.indexOf(e)||!1!==t&&0!==t)&&delete h[e]}}),this.props=Ur(h,s),wk.forEach(e=>{const t=e in this.props;e in c===t&&Tk(c[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,c[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in s||"$user_state"in this.props||this._setProp(xe,Je);const m=this.props[D],k=this.props[xe];return!l||m===u&&k===d||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Jl._set(yk(this._name),!0),this._deleteProp(S),this._deleteProp(p),this._deleteProp(y),this._deleteProp(g),this._deleteProp(C),this._deleteProp(v),this._deleteProp(f),this._deleteProp(_),this._deleteProp(w),"anonymous"!==k||"identified"!==d&&"anonymous"!==s.$user_state&&(xt(u)||m===u)||(Ik(this.props,s),this._deleteProp(b)),"identified"===k?this.props.$user_id=m:delete this.props.$user_id,this._deleteProp(q)),!0}consumeCookieIdentityChange(){const e=yk(this._name),t=this._cookieIdentityChangePending||!!Jl._get(e);return this._cookieIdentityChangePending=!1,t&&Jl._remove(e),t}_beginCookieSyncSuppression(e=!1){return!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[Sk],this._writeNow(!0))}_endCookieSyncSuppression(e=!0){if(this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(t){-1===mk.indexOf(t.persistence.toLowerCase())&&(Nr.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");const i=((t=[],i=!1,n=()=>!1)=>{const s=[...Nl,...t];return ct(ct({},Dl),{},{_rawText(e){return[Ll._get(e),Ll._get(Bl(e)),Dl._get(e)].join("\0")},_parse(e){try{let r,o={};try{r=Ll._get(e)||void 0,o=r?Hl(JSON.parse(r)):{}}catch(e){}const a=JSON.parse(Dl._get(e)||"{}");let l;if(i){const i=jl(e,r),n=[...Nl,...i.properties],c={};Object.keys(o).forEach(e=>{const t=o[e];Pt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(c[e]=t)});const u="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state;if(Object.keys(c).length>0){var t;const e=a[D],r=null!==(t=a.$user_state)&&void 0!==t?t:Je;s.forEach(e=>{if(-1!==n.indexOf(e)&&!(e in o)&&(u||"distinct_id"!==e&&"$user_state"!==e)){const t=a[e];(i.isValid||-1===Nl.indexOf(e)||!1!==t&&0!==t)&&delete a[e]}}),!u||"$user_state"in o||"$user_state"in a||(a[xe]=Je),!u||("distinct_id"in c?c[D]:a[D])===e&&("$user_state"in c?c[xe]:a[xe])===r||($l.forEach(e=>delete a[e]),"identified"===c.$user_state&&"distinct_id"in c?a.$user_id=c[D]:delete a.$user_id,"identified"!==c.$user_state&&(delete a[ye],delete a[b]),delete a.__alias)}l=Ur(a,c)}else l=Ur(o,a);return n()||Dl._set(e,l),l}catch(e){}return null},_set(e,n,s,r,o,a){const l=Dl._set(e,n,void 0,void 0,a);try{const c=Ul(n,t);if(Object.keys(c).length){if(i){const i=Bl(e),u=Wl(c,t);if(Ll._set(i,u,s,r,o,a),Ll._get(i)!==JSON.stringify(u)){Ll._remove(i,r);const t=Ul(n);return Ll._set(e,t,s,r,o,a),l}}Ll._set(e,c,s,r,o,a)}}catch(e){Dl._error(e)}return l},_remove(t,i){try{null==e||e.localStorage.removeItem(t),Ll._remove(t,i),Ll._remove(Bl(t),i)}catch(e){Dl._error(e)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict,()=>!!this._disabled);let n,s=!1,r=!1;const o=t.persistence.toLowerCase();return"localstorage"===o&&Dl._is_supported()?(n=Dl,r=!0):"localstorage+cookie"===o&&i._is_supported()?(n=i,r=!0,s=!0):"sessionstorage"===o&&Jl._is_supported()?n=Jl:"memory"===o?n=Ql:"cookie"===o&&Ll._is_supported()?(n=Ll,s=!0):i._is_supported()?(n=i,r=!0,s=!0):Ll._is_supported()?(n=Ll,s=!0):n=Ql,this._splitStorageEligible=r,this._storesIdentityInCookie=s,n}_groupEntryName(e){return`${this._name}__${e}`}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){const e={};return Hr(this.props,(t,i)=>{const n=fk(i);if(!n||"event"===n.exposure){var s;if(null==n||null===(s=n.shouldSkipFromEventProperties)||void 0===s?void 0:s.call(n,t))return;e[i]=t}}),e}load(e=!1){if(this._disabled&&!e)return;const t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?Dl._parse(this._name):null;let n={};if(t)try{n=Hl(Ll._parse(this._name)),Hr(n,(e,t)=>{(xt(e)||Pt(e)||""===e)&&delete n[t]})}catch(e){}const s=this._storage._parse(this._name);if(s&&(this.props=Ur({},s)),this._splitStorage&&this._loadGroupEntries(),t&&s){var r,o;const e=null==i?void 0:i[D],t=null!==(r=null==i?void 0:i.$user_state)&&void 0!==r?r:Je,a=s[D],l=null!==(o=s.$user_state)&&void 0!==o?o:Je;if(a!==e||l!==t){this._cookieIdentityChangePending=!0,this._disabled||Jl._set(yk(this._name),!0);const i=Ur({},this.props);$l.forEach(e=>delete i[e]),"anonymous"!==l||"identified"!==t&&"anonymous"!==n.$user_state&&(xt(e)||a===e)||(Ik(i,n),delete i[b]),this.props=i;const s=new Set;$l.forEach(e=>{var t;const i=null===(t=fk(e))||void 0===t?void 0:t.storageGroup;i&&s.add(i)}),s.forEach(e=>{if(this._disabled)return;const t={};Hr(this.props,(i,n)=>{var s;(null===(s=fk(n))||void 0===s?void 0:s.storageGroup)===e&&(t[n]=i)}),Tt(t)?(Dl._remove(this._groupEntryName(e)),this._slotState[e]={}):Dl._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Jl._get(yk(this._name))&&(this._cookieIdentityChangePending=!0)}_loadGroupEntries(){for(const e of pk){const t=Dl._parse(this._groupEntryName(e));if(t&&!Tt(t)){const i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Ur(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null===(i=fk(t))||void 0===i?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){const i=vk[e];if(!i)return!1;const n=t[i],s=this.props[i];return Ft(n)&&Ft(s)&&s>n}refreshKey(e){this._refreshKeys([e])}_refreshKeys(e){if(this._disabled)return;let t,i=!1;const n=()=>(i||(t=this._storage._parse(this._name),i=!0),t);e.forEach(e=>{var t;if(this._metaIdentifierChangePending.has(e))return;const i=this._splitStorage?null===(t=fk(e))||void 0===t?void 0:t.storageGroup:void 0,s=i?Dl._parse(this._groupEntryName(i)):n();if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){const t=n();if(t&&e in t)return void this._setProp(e,t[e],!1)}this._deleteProp(e,!1)}})}refreshMetaIdentifiers(){if(this._disabled)return;const e=this._storageSnapshot();(xt(e)||e!==this._metaIdentifierStorageSnapshot)&&(this._refreshKeys(Ck),this._rememberMetaIdentifierStorageSnapshot(e))}_rememberMetaIdentifierStorageSnapshot(e=this._storageSnapshot()){this._metaIdentifierStorageSnapshot=0===this._metaIdentifierChangePending.size?e:void 0}_storageSnapshot(){const e=this._storage._rawText?this._storage._rawText(this._name):this._storage._get(this._name);return It(e)?e:void 0}save(){if(this._disabled)return;const e=this._saveDebounceMs();e>0?xt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}flush(){xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e=!1){if(this._disabled||this._cookieSyncSuppressed&&!e)return;e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||this.refreshMetaIdentifiers());const t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);const i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)return void(this._config.debug&&Nr.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));const n=this._writeEntry(this._storage,this._name,this.props,Sk);"written"===n&&this._rememberCurrentCookieProperties(this.props),"failed"!==n&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),"written"===n&&this._rememberMetaIdentifierStorageSnapshot(),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}_writeNowSplit(){const{main:e,groups:t}=this._partitionProps(),i=this._writeEntry(this._storage,this._name,e,Sk);"written"===i&&this._rememberCurrentCookieProperties(e),"failed"!==i&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),wk.forEach(e=>{var t;(null===(t=fk(e))||void 0===t?void 0:t.storageGroup)||this._pendingCrossTabFeatureFlagChanges.delete(e)})),"written"===i&&this._rememberMetaIdentifierStorageSnapshot();for(const e of pk){var n;const i=t[e];if(Tt(i)&&!(null===(n=this._slotState[e])||void 0===n?void 0:n.persisted)){wk.forEach(t=>{var i;(null===(i=fk(t))||void 0===i?void 0:i.storageGroup)===e&&this._pendingCrossTabFeatureFlagChanges.delete(t)});continue}const s=this._writeEntry(Dl,this._groupEntryName(e),i,e);"failed"!==s&&wk.forEach(t=>{const i=fk(t);(null==i?void 0:i.storageGroup)!==e||"written"!==s&&i.volatile||this._pendingCrossTabFeatureFlagChanges.delete(t)})}}_partitionProps(){const e={},t={flags:{},surveys:{}};return Hr(this.props,(i,n)=>{var s;const r=null===(s=fk(n))||void 0===s?void 0:s.storageGroup;r?t[r][n]=i:e[n]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===Sk)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;const i={};return Hr(e,(e,t)=>{var n;i[t]=(null===(n=fk(t))||void 0===n?void 0:n.volatile)?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,n){const s=this._slotWriteState(n);if(n!==Sk&&!s.dirty&&!xt(s.fingerprint))return"skipped";let r;try{if(r=this._entryFingerprint(i,n),r===s.fingerprint)return s.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(s.dirty=!1,n!==Sk&&(s.persisted=!0),xt(r)||(s.fingerprint=r),this._splitStorageEligible&&(s.storageValue=Dl._get(t)),"written"):(this._config.debug&&Nr.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this._markAllCrossTabFeatureFlagChangesPending(),xt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!e&&this._ownsSplitStorage)for(const e of pk)Dl._remove(this._groupEntryName(e));e?delete this._slotState[Sk]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Et(e)){this.syncCookieProperties(),xt(t)&&(t="None"),this._expire_days=xt(i)?this._default_expiry:i;let n=!1;if(Hr(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),n=!0)}),n)return this.save(),!0}return!1}register(e,t){if(Et(e)){this.syncCookieProperties(),this._expire_days=xt(t)?this._default_expiry:t;let i=!1;if(Hr(e,(t,n)=>{e.hasOwnProperty(n)&&(this.props[n]!==t||Et(t)||kt(t))&&(this._setProp(n,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t="string"==typeof e?[e]:e;let i=!1;for(const e of t)e in this.props&&(this._deleteProp(e),i=!0);i&&this.save()}update_campaign_params(){const e=null==n?void 0:n.URL;if(e===this._campaign_params_url)return;const t=Pc(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!Tt(jr(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}update_search_keyword(){this.register(function(){const e=null==n?void 0:n.referrer;return e?Fc(e):{}}())}update_referrer_info(){var e;this.register_once({$referrer:Dc(),$referring_domain:(null==n?void 0:n.referrer)&&(null===(e=Yr(n.referrer))||void 0===e?void 0:e.host)||Oc},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=$c(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Fe]:this._storesIdentityInCookie?{r:bk(e.r),u:e.u?bk(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Hr([Me,Pe],t=>{const i=this.props[t];i&&Hr(i,function(t,i){e["$initial_"+mt(i)]=t})});const t=this.props[Fe];if(t){const i=function(e,t=!1){const i=Nc(e,t),n={};return Hr(i,function(e,t){n[`$initial_${mt(t)}`]=e}),n}(t,this._config.disable_capture_url_hashes);Ur(e,i)}return e}safe_merge(e){return Hr(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){const n=e.persistence!==t.persistence,s=!((e,t)=>{if(e.length!==t.length)return!1;const i=[...e].sort(),n=[...t].sort();return i.every((e,t)=>e===n[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=n||s,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this._disabled&&!a;a||this._syncCookieProperties(t,l),this._config=e,!a&&(n||s||o)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(ct(ct({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=r||o?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();const u=this._resolveSplitStorage(e),d=r||u!==this._splitStorage,h=!a&&(d||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(l);this._storageMigrationInProgress=d;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const e=this.props;this.clear(),this._storage=c,this._splitStorage=u,this.props=e,this.save()}else o&&(this._storage=c,a||(delete this._slotState[Sk],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){const e=this.props[Fe];if(!this._storesIdentityInCookie||!Et(e)||"string"!=typeof e.r)return;const t=bk(e.r),i="string"==typeof e.u?bk(e.u):e.u;t===e.r&&i===e.u||this._setProp(Fe,ct(ct({},e),{},{r:t,u:i}))}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){const i=this.props.__timers||{};i[e]=t,this._setProp(V,i),this.save()}remove_event_timer(e){const t=this.props.__timers||{},i=t[e];return xt(i)||(delete t[e],this._setProp(V,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i=!0){var n;const s=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||s===t||(this._localIdentityChangePending=!0),Ek(e)&&!Tk(s,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,s,t),(null===(n=fk(e))||void 0===n?void 0:n.volatile)||this._markGroupDirty(e))}_deleteProp(e,t=!0){delete this.props[e],t&&(kk(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),Ek(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t;const i=null===(t=fk(e))||void 0===t?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}};const Pk={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"},Mk={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"},Fk=Br("[RateLimiter]");var Ak=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Fk.info(`${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void Fk.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?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}get isClientRateLimited(){return 1>this._refilledBucket().tokens}clientRateLimitContext(e=!1){var t;const i=this._refilledBucket(),n=1>i.tokens;if(n||e||(i.tokens=Math.max(0,i.tokens-1)),n&&!e){const e=(Ft(i.dropped)?i.dropped:0)+1;i.dropped=e,!this.lastEventRateLimited&&this._captureWarning(e)&&(i.dropped=0)}return this.lastEventRateLimited=n,null===(t=this.instance.persistence)||void 0===t||t.set_property("$capture_rate_limit",i),{isRateLimited:n,remainingTokens:i.tokens}}_refilledBucket(){var e;const{captureEventsBurstLimit:t,captureEventsPerSecond:i}=this,n=(new Date).getTime(),s=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property(Re),r=s?ct({},s):{tokens:t,last:n};return r.tokens+=Math.max(0,n-r.last)/1e3*i,r.last=Math.max(r.last,n),r.tokens>t&&(r.tokens=t),r}_isPropertyAllowed(e){const t=this.instance.config.property_denylist;return!kt(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&(null==s?void 0:s.pathname))return`${null!==(e=s.origin)&&void 0!==e?e:""}${s.pathname}`}_captureWarning(e){var t,i;const{captureEventsBurstLimit:n,captureEventsPerSecond:s}=this,r=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null===(t=(i=this.instance).get_session_id)||void 0===t?void 0:t.call(i):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${a}. Config is set to ${s} events per second and ${n} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}};const Lk=Br("[RemoteConfig]");var Ok=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null===(e=d._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config}_loadRemoteConfigJs(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.loadExternalDependency)?null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return Lk.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Lk.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return Lk.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){Lk.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||Lk.warn("Failed to fetch remote config from PostHog."):Lk.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){Lk.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null===(i=this._instance.featureFlags)||void 0===i||i.ensureFlagsLoaded()}catch(e){Lk.error("Error loading feature flags",e)}}};let Dk=!Zy&&-1===(null==c?void 0:c.indexOf("MSIE"))&&-1===(null==c?void 0:c.indexOf("Mozilla"));function $k(e,t,i){var n,s,r,o;i&&(t=ct(ct({},t),{},{callback:e=>i(e)})),e.__loaded?Dk?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(r=t.callback)||void 0===r||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=ct(ct({},e.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(n=e.compression)&&void 0!==n?n:t.compressionFallback:t.compression,(xt(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,null===(s=t.onDispatch)||void 0===s||s.call(t),((e,t)=>{var i,n,s;const r=ct(ct({},e),{},{callback:null!=t?t:t=>{var i;return null===(i=e.callback)||void 0===i?void 0:i.call(e,t)}});r.timeout=r.timeout||6e4;const o=null!==(i=r.transport)&&void 0!==i?i:"fetch";"sendBeacon"===o&&xt(r.compression)&&r.data&&(r.compression=Iy.Base64),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(e=>{var t,i;const n=(kt(e)?e:[e]).map(e=>ct(ct({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),s=n[0];return{api_key:null!==(t=null==s||null===(i=s.properties)||void 0===i?void 0:i.token)&&void 0!==t?t:null==s?void 0:s.token,batch:n,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((e,t=(new Date).toISOString())=>kt(e)?e.map(e=>ct(ct({},e),{},{sent_at:t})):ct(ct({},e),{},{sent_at:t}))(r.data))),r.url=fb(r.url,r.method,r.compression,r.timestampMode);const a=vb.filter(e=>!r.disableTransport||!e.transport||!r.disableTransport.includes(e.transport)),c=null!==(n=null===(s=function(e,t){for(let i=0;e.length>i;i++)if(t(e[i]))return e[i]}(a,e=>e.transport===o))||void 0===s?void 0:s.method)&&void 0!==n?n:a[0].method;if(!c)throw new Error("No available transport method");const u=e=>{try{c(e)}catch(e){var t;db(e)?Nr.warn(e):Nr.error(e),null===(t=r.callback)||void 0===t||t.call(r,{statusCode:0,error:e})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===Iy.GZipJS&&l&&"undefined"!=typeof Promise&&!ib?lb(r).then(e=>{u(e)}).catch(t=>{if(hs(t))return ib=!0,void u(ct(ct({},r),{},{compression:void 0,url:fb(e.url,e.method,void 0,e.timestampMode)}));ps(t)&&(ib=!0),u(r)}):u(r)})(t,(n,s)=>{var r,o,a;e.rateLimiter.checkForLimiting(n),400>n.statusCode||null===(r=(o=e.config).on_request_error)||void 0===r||r.call(o,n),i?i(n,s):null===(a=t.callback)||void 0===a||a.call(t,n)})):t.fireCallbackOnDrop&&(null===(o=t.callback)||void 0===o||o.call(t,{statusCode:0}))}var Nk=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Kt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Nr.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();const 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(ct(ct({},e),{},{callback:void 0}),"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flush()},this._flushTimeoutMs))}_flush(){if(this._queue.length>0){const e=this._formatQueue();for(const t in e)this._sendRequestSafely(e[t])}}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Nr.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){const e={},t={};Hr(this._queue,i=>{var n;const s=i,r=((s?s.batchKey:null)||s.url)+(s.batchGroup?`:${s.batchGroup}`:"");xt(e[r])&&(e[r]=ct(ct({},s),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),t[r]=[]),null===(n=e[r].data)||void 0===n||n.push(s.data),s.callback&&t[r].push(s.callback)});for(const i in t){const n=t[i];n.length&&(e[i].callback=e=>{for(const t of n)t(e)})}return this._queue=[],e}};const Bk=["retriesPerformedSoFar"];var qk=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!xt(e)&&"onLine"in e.navigator){if(this._areWeOnline=e.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Kr(e,"online",this._onlineListener),Kr(e,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,t){let{retriesPerformedSoFar:i}=e,n=ys(e,Bk);At(i)&&(n.url=sb(n.url,{retry_count:i})),$k(this._instance,t?ct(ct({},n),{},{transport:t}):n,(e,t)=>{var s;if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=i?i:0))return void this._enqueue(ct({retriesPerformedSoFar:i},n),t);0===e.statusCode&&Nr.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!=i?i:0} retries.`)}null===(s=n.callback)||void 0===s||s.call(n,e)})}_enqueue(e,t){const i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;const n=Math.max(function(e){const t=3e3*Math.pow(2,e),i=t/2,n=Math.min(18e5,t),s=(Math.random()-.5)*(n-i);return Math.ceil(n+s)}(i),null!=t?t:0),s=Date.now()+n;this._queue.push({retryAt:s,requestOptions:e});let r=`Enqueued failed request for retry in ${n}`;navigator.onLine||(r+=" (Browser is offline)"),Nr.warn(r),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(){const e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,xt(e)||(this._onlineListener&&(e.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(e.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0));for(const{requestOptions:e}of this._queue)try{this._instance._send_request(ct(ct({},e),{},{callback:kt(e.data)?void 0:e.callback,transport:"sendBeacon"}))}catch(e){Nr.error(e)}this._queue=[]}},Hk=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,n;this._context||(this._context={});const s=this.scrollElement(),r=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=r+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(r),this._context.maxScrollY=Math.max(r,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!==(n=this._context.maxContentHeight)&&void 0!==n?n:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){const e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Kr(e,"scroll",this._updateScrollData,{capture:!0}),Kr(e,"scrollend",this._updateScrollData,{capture:!0}),Kr(e,"resize",this._updateScrollData)}scrollElement(){if(this._scrollRoot){const i=kt(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(const n of i){var t;const i=null==e||null===(t=e.document)||void 0===t?void 0:t.querySelector(n);if(i)return i}return}var i;return null==e||null===(i=e.document)||void 0===i?void 0:i.documentElement}_scrollPosition(t){var i,n;const s="y"===t?"scrollTop":"scrollLeft";if(this._scrollRoot){const e=this.scrollElement();return e&&e[s]||0}return e?"y"===t?e.scrollY||e.pageYOffset||(null===(i=e.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollTop)||0:e.scrollX||e.pageXOffset||(null===(n=e.document)||void 0===n||null===(n=n.documentElement)||void 0===n?void 0:n.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}};const Uk=e=>$c(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);var zk=class{constructor(e,t,i,n){this._onSessionIdCallback=e=>{const t=this._getStored();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[Ie]:i})},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=n||Uk,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Ie]}getSetOnceProps(){var e;const t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?Nc(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(){const e={};return Hr(jr(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e[`$session_entry_${mt(i)}`]=t}),e}};const Wk=Br("[SessionId]"),jk=864e5;var Vk=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var n;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Py,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("always"===e.config.cookieless_mode)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._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Rl,this._windowIdGenerator=i||Rl;const s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Kt(this._config.session_idle_timeout_seconds||1800,60,36e3,Wk.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()){const e=Jl._parse(this._window_id_storage_key),t=Jl._parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:Jl._remove(this._window_id_storage_key),Jl._set(this._primary_window_exists_storage_key,!0)}(null===(n=this._config.bootstrap)||void 0===n?void 0:n.sessionID)&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return xt(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&&Jl._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Jl._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Jl._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){const t=this._lastPersistedActivityTimestamp;return!Pt(t)&&!Pt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){const n=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!n||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[ce]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return At(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(ce):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(Pt(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._lastPersistedActivityTimestamp)return;this._refreshSessionIdFromStorage();const[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[ce]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}_freshestActivityTimestamp(){const[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(){const e=this._persistence.props[ce];return kt(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t=!1){const i=((e,t=(new Date).getTime())=>{try{const i=(e=>{const t=e.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)})(e);return i>t+6e4?void Wk.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Wk.error("Invalid sessionID in bootstrap",e)}})(e);return!xt(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&e&&(e.removeEventListener(Xe,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Jl._remove(this._primary_window_exists_storage_key)},Kr(e,Xe,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if("always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const n=t||(new Date).getTime(),s=this._sessionId;if(i)this._lastCookieSyncTimestamp=n;else if(Pt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>n||n-this._lastCookieSyncTimestamp>=1e3){var r,o;null===(r=(o=this._persistence).syncCookieProperties)||void 0===r||r.call(o),this._lastCookieSyncTimestamp=n}let[,a,l]=this._getSessionId();const c=!xt(s)&&a!==s,u=this._freshestActivityTimestamp();let d=this._getWindowId();const h=this._pendingBootstrapSession,p=!!h&&(h.sessionStartTimestamp>n+6e4||n-h.sessionStartTimestamp>jk),g=h?p:At(l)&&Math.abs(n-l)>jk;let _=!1,f=c,v=!a||!!h;const m=a;let y=!v&&!e&&this._sessionHasBeenIdleTooLong(n,u);if(y&&(y=this._isSessionIdleAfterCrossTabRefresh(n),y||Wk.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this._getSessionId(),y||(v=!a||!!h)),v||y||g){f=!1;const e=h&&!p;a=e?h.sessionId:this._sessionIdGenerator(),d=this._windowIdGenerator(),Wk.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:v,activityTimeout:y,sessionPastMaximumLength:g}}),l=e?h.sessionStartTimestamp:n,this._pendingBootstrapSession=void 0,_=!0}else d||(d=this._windowIdGenerator(),_=!0),f=f||a!==m,f&&(Wk.info("adopted cross-tab session id",{sessionId:a,windowId:d}),_=!0);const b=At(u)&&e&&!g?u:n,S=At(l)?l:(new Date).getTime();this._setWindowId(d),this._setSessionId(a,b,S),e||this._resetIdleTimer();const w={noSessionId:v,activityTimeout:y,sessionPastMaximumLength:g,crossTabAdoption:f};return _&&this._sessionIdChangedHandlers.forEach(e=>e(a,d,w)),{sessionId:a,windowId:d,sessionStartTimestamp:S,changeReason:_?w:void 0,lastActivityTimestamp:u}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){const e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};const Gk=Object.freeze(["2026-08-30","2026-08-29","2026-06-25","2026-05-30","2026-01-30","2025-11-30","2025-05-24"]),Qk=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Qt(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if((null==i?void 0:i.brands)&&i.brands.some(e=>Qt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function Kk(){return Kk=rt(function*(){const e=null==i?void 0:i.userAgentData;if(null==e?void 0:e.getHighEntropyValues)try{const 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 Nr.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}}),Kk.apply(this,arguments)}const Jk="custom",Yk="i.posthog.com",Zk=/^\/static\//,Xk=["/s/","/e/","/i/"];var eC=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${Yk}`,".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":Jk),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(!Zk.test(e))return;const t=this.instance.config.asset_host;return"string"==typeof t&&t.trim().replace(/\/$/,"")||void 0}_urlKey(e){const t=Yr(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;let n=i;const s=this.instance.config.rewriteRequestPath;if(s){var r;const e=(null===(r=Yr(i))||void 0===r?void 0:r.href)||i;n=s(new URL(e)).toString()}if(s&&"api"===e&&Xk.some(e=>0===t.indexOf(e))){const e=this._urlKey(n);if(e){const t=this.apiHost;let i=this._ingestionEndpoints;(null==i?void 0:i.apiHost)===t&&i.rewriteRequestPath===s||(i={apiHost:t,rewriteRequestPath:s,urls:new Set},this._ingestionEndpoints=i),i.urls.add(e)}}return n}isIngestionEndpoint(e){const t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t=""){if(t&&(t="/"===t[0]?t:`/${t}`),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){const i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,`${i}${t}`)}if(this.region===Jk)return this._prepareEndpoint(e,t,this.apiHost+t);const i=Yk+t;switch(e){case"assets":return this._prepareEndpoint(e,t,`https://${this.region}-assets.${i}`);case"api":return this._prepareEndpoint(e,t,`https://${this.region}.${i}`)}}};const tC=Br("[PostHog ExternalIntegrations]"),iC={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var nC=class{constructor(e){this._instance=e}_loadScript(e,t){var i,n;null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,e,e=>{if(e)return tC.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e;for(const[s,r]of Object.entries(null!==(e=this._instance.config.integrations)&&void 0!==e?e:{})){var t,i,n;r&&!(null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t?void 0:t[s])&&this._loadScript(iC[s],()=>{var e;null===(e=d.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e||null===(e=e[s])||void 0===e||e.start(this._instance)}),!r&&(null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[s])&&(null===(n=d.__PosthogExtensions__)||void 0===n||null===(n=n.integrations)||void 0===n||null===(n=n[s])||void 0===n||n.stop())}}};const sC={};let rC=0;const oC=()=>{},aC='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',lC="Surveys module not available",cC="sanitize_properties is deprecated. Use before_send instead",uC="Invalid value for property_denylist config: ",dC=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],hC=["$feature_flag_called","$$heatmap","$snapshot"],pC=e=>"$"===e.charAt(0)&&!ft(hC,e),gC=/^[A-Za-z0-9_-]{1,400}$/,_C=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,fC=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,vC=["token","distinct_id",Oe],mC="posthog",yC=[...Gk].sort()[Gk.length-1],bC=e=>{const t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},SC=t=>{var i;return ct({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Qr(null==n?void 0:n.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:oC,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!0,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:s&&It(null==s?void 0:s.search)&&-1!==s.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==e||null===(i=e.location)||void 0===i?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(e){Nr.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:Ze,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:oC},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:xo,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:bC(e),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),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(t))},wC=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],kC=e=>{const t={};for(const[i,n]of wC)xt(e[i])||(t[n]=e[i]);const i=Ur({},t,e),n=e.__preview_external_dependency_versioned_paths;return xt(n)||(xt(e.strict_script_versioning)&&(i.strict_script_versioning=!!n),It(n)&&xt(e.asset_host)&&(i.asset_host=n)),kt(e.property_blacklist)&&(xt(e.property_denylist)?i.property_denylist=e.property_blacklist:kt(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Nr.error(uC+e.property_denylist)),i};var CC=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Nr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},EC=class t{_removeExtension(e){if(!e)return;const t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}_replaceExtension(e,t){var i;return this._removeExtension(e),this._extensions.push(t),null===(i=t.initialize)||void 0===i||i.call(t),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(this._hasWarnedAboutVolatileIdentity)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this._inCookielessMode())return;const e="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!e&&!this.config.disable_persistence)return;if(this._hasStableInitialDistinctId)return;let t,i,n;e?(t=`persistence is set to '${this.config.persistence}'`,i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",n="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",n="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${n}`)}_syncCookielessIdentity(){const e=this.persistence;if(!e||this._isConsentTransition)return;if(this._inCookielessMode())return void("on_reject"===this.config.cookieless_mode&&"$posthog_cookieless"!==this.get_distinct_id()&&(this._sync_opt_out_with_persistence(),this._enterCookielessMode()));if("$posthog_cookieless"!==this.get_distinct_id())return;this._is_persistence_disabled()||e.load(!0);const t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){const t=this.config.get_device_id(Rl());this.register({distinct_id:t,$device_id:t}),e.set_property(xe,Je)}this._sync_opt_out_with_persistence()}get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new CC,this._personProcessingSetOncePropertiesSent=!1,this.version=Yl.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Py,this._extensions=[],this._extensionEventPropertyProducers=[],this._replayDebugPropertiesPaused=!1,this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._isConsentTransition=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=SC(),this.SentryIntegration=dk,this.sentryIntegration=e=>function(e,t){const i=uk(e,t);return{name:ck,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 Hk(this),this.pageViewManager=new hk(this),this.rateLimiter=new Ak(this),this.requestRouter=new eC(this),this.consent=new ik(this),this.externalIntegrations=new nC(this);const i=null!==(e=t.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(e,t,i)=>{const n=It(e)?{[e]:t}:e;this.setPersonProperties(n),null==i||i({})},set_once:(e,t,i)=>{const n=It(e)?{[e]:t}:e;this.setPersonProperties(void 0,n),null==i||i({})}},this.on("eventCaptured",e=>Nr.info(`send "${null==e?void 0:e.event}"`,e))}init(e,i,n){if(n&&n!==mC){var s;const r=null!==(s=sC[n])&&void 0!==s?s:new t;return r._init(e,i,n),sC[n]=r,sC[mC][n]=r,r}return this._init(e,i,n)}_init(t,i={},n){var s,r,o;const a=It(t)?t.trim():"";if(!a)return Nr.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==(null===(l=this.config)||void 0===l?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=SC(i.defaults),i.debug=this._checkLocalStorageForDebug(i.debug),this._originalUserConfig=i,this._triggered_notifs=[],i.person_profiles?this._initialPersonProfilesConfig=i.person_profiles:i.process_person&&(this._initialPersonProfilesConfig=i.process_person);const c=SC(i.defaults),u=kC(i),d=Ur({},c,u,{name:n,token:a});Et(c.rageclick)&&Et(u.rageclick)&&(d.rageclick=Ur({},c.rageclick,u.rageclick)),Et(c.session_recording)&&Et(u.session_recording)&&(d.session_recording=Ur({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Nr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:Iy.GZipJS;const h=this._is_persistence_disabled(),p=!this._inCookielessMode();if(this.persistence=new Rk(this.config,h,!0,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Rk(ct(ct({},this.config),{},{persistence:"sessionStorage"}),h,!1,p),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!h&&Jl._is_supported()){const e=Jl._parse(this._sessionRegisteredPropertiesStorageKey);kt(e)&&e.forEach(e=>{It(e)&&this._sessionRegisteredPropKeys.add(e)})}else Jl._remove(this._sessionRegisteredPropertiesStorageKey);const g=ct({},this.persistence.props),_=ct({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Nk((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new qk(this),this.__request_queue=[];const f=this._inCookielessMode();f||(this.sessionManager=new Vk(this),this.sessionPropsManager=new zk(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{((null==i?void 0:i.activityTimeout)||(null==i?void 0:i.sessionPastMaximumLength)||(null==i?void 0:i.crossTabAdoption))&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Nr.info("Deferring extension initialization to improve startup performance"),this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._initExtensions(f)},0)):(Nr.info("Initializing extensions synchronously"),this._initExtensions(f)),Yl.DEBUG=Yl.DEBUG||this.config.debug,Yl.DEBUG&&Nr.info("Starting in debug mode",{this:this,config:i,thisC:ct({},this.config),p:g,s:_}),this.config.identity_distinct_id&&!(null===(s=i.bootstrap)||void 0===s?void 0:s.distinctID)&&(i.bootstrap=ct(ct({},i.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const v=null===(r=i.bootstrap)||void 0===r?void 0:r.distinctID;if(this._hasStableInitialDistinctId=!!v&&!Rt(v),null===(o=i.bootstrap)||void 0===o?void 0:o.distinctID){const e=i.bootstrap.distinctID,t=this.get_distinct_id(),n=this.persistence.get_property(xe);if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"anonymous"===n)this.identify(e);else if(i.bootstrap.isIdentifiedID&&null!=t&&t!==e&&"identified"===n)Nr.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{const t=this.config.get_device_id(Rl()),n=i.bootstrap.isIdentifiedID?t:e;this.persistence.set_property(xe,i.bootstrap.isIdentifiedID?Ye:Je),this.register({distinct_id:e,$device_id:n})}}if(f)this.register_once({distinct_id:Le,$device_id:null},"");else if(!this.get_distinct_id()){const e=this.config.get_device_id(Rl());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(xe,Je)}return Kr(e,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Kr(e,"pageshow",e=>{if(this._isPageUnloading=!1,!this._isShutdown){var t;if(e.persisted&&this.persistence){const e=this.persistence.get_property(D),t=this.persistence.get_property(xe);this.persistence.load(),this._processCookieIdentityChange()||e===this.persistence.get_property("distinct_id")&&t===this.persistence.get_property("$user_state")||this._processIdentityChange()}null===(t=this._retryQueue)||void 0===t||t.resume()}}),i.segment?lk(this,()=>this._loaded()):this._loaded(),Ct(this.config._onCapture)&&this.config._onCapture!==oC&&(Nr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Nr.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 Kk.apply(this,arguments)}().then(e=>{e&&this.register({[B]:e})}).catch(oC),this}_isSharedExtension(e){const t=e;return It(t.name)&&Ct(t.setup)}_enrollExtension(e,t){var i=this;this._isSharedExtension(e)?t.push(rt(function*(){try{yield e.setup(i._getBrowserClientAdapter())}catch(i){Nr.error(`Failed to set up extension "${e.name}"`,i);try{var t;yield null===(t=e.dispose)||void 0===t?void 0:t.call(e)}catch(t){Nr.error(`Failed to dispose extension "${e.name}"`,t)}}})):this._extensions.push(e)}_enrollFeatureFlags(){var e,i,n,s=this;const r=null!==(e=null===(i=this.config.__extensionClasses)||void 0===i?void 0:i.featureFlags)&&void 0!==e?e:null===(n=t.__defaultExtensionClasses)||void 0===n?void 0:n.featureFlags;var o,a,l;if(r)if(this.featureFlags&&this.featureFlags instanceof r||(null===(o=this._featureFlagsReloadingUnsubscribe)||void 0===o||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new r(this)),Ct(this.featureFlags.onReloading)&&Ct(this.featureFlags.setup)){if(!this._featureFlagsReloadingUnsubscribe){this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)});const e=this.featureFlags;rt(function*(){try{yield e.setup(s._getBrowserClientAdapter())}catch(t){Nr.error("Failed to set up feature flags",t);const i=s._featureFlagsReloadingUnsubscribe;s._featureFlagsReloadingUnsubscribe=void 0;try{null==i||i()}catch(e){Nr.error("Failed to unsubscribe feature flag reloading",e)}try{yield e.dispose()}catch(e){Nr.error("Failed to dispose feature flags",e)}}})()}}else null===(a=(l=this.featureFlags).initialize)||void 0===a||a.call(l)}_initExtensions(e){const i=performance.now(),n=ct(ct({},t.__defaultExtensionClasses),this.config.__extensionClasses),s=[];var r,o,a,l,c,u,d,h;n.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new n.exceptions(this)),n.historyAutocapture&&this._extensions.push(this.historyAutocapture=new n.historyAutocapture(this)),n.tracingHeaders&&this._extensions.push(this.tracingHeaders=new n.tracingHeaders(this)),n.siteApps&&this._extensions.push(this.siteApps=new n.siteApps(this)),n.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new n.sessionRecording(this)),this.config.disable_scroll_properties||s.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),n.autocapture&&this._enrollExtension(this.autocapture=new n.autocapture(this),s),n.surveys&&this._enrollExtension(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new n.surveys(this),s),n.logs&&this._enrollExtension(this.logs=null!==(a=this.logs)&&void 0!==a?a:new n.logs(this),s),n.metrics&&this._extensions.push(this.metrics=null!==(l=this.metrics)&&void 0!==l?l:new n.metrics(this)),n.conversations&&this._extensions.push(this.conversations=null!==(c=this.conversations)&&void 0!==c?c:new n.conversations(this)),n.productTours&&this._extensions.push(this.productTours=new n.productTours(this)),n.heatmaps&&this._extensions.push(this.heatmaps=new n.heatmaps(this)),n.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new n.webVitalsAutocapture(this)),n.exceptionObserver&&this._extensions.push(this.exceptionObserver=new n.exceptionObserver(this)),n.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new n.deadClicksAutocapture(this,rk)),n.toolbar&&this._extensions.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new n.toolbar(this)),n.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new n.experiments(this)),n.webMCP&&this._extensions.push(this.webMCP=null!==(h=this.webMCP)&&void 0!==h?h:new n.webMCP(this)),this._extensions.forEach(e=>{e.initialize&&s.push(()=>{var t;null===(t=e.initialize)||void 0===t||t.call(e)})}),s.push(()=>{if(this._pendingRemoteConfig){const e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}}),this._processInitTaskQueue(s,i)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void(this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._processInitTaskQueue(e,t)},0));const i=e.shift();if(i)try{i()}catch(e){Nr.error("Error initializing extension:",e)}}const i=Math.round(performance.now()-t);this.register_for_session({[De]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[$e]:i}),this.config.__preview_deferred_init_extensions&&Nr.info(`PostHog extensions initialized (${i}ms)`)}_onRemoteConfig(e){if(!n||!n.body)return Nr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var t;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=ft(i.supportedCompression,Iy.GZipJS)?Iy.GZipJS:ft(i.supportedCompression,Iy.Base64)?Iy.Base64:void 0),(null===(t=i.analytics)||void 0===t?void 0:t.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Ze}),this._internalEventEmitter.emit("extensionsRemoteConfig",e),this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}_loaded(){try{this.config.loaded(this)}catch(e){Nr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&(null==s?void 0:s.hostname)){const e=s.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 Ok(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.is_capturing()&&qr(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,n,s,r;this._isPageUnloading=!0,null===(e=this.surveys)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e),null===(i=this.metrics)||void 0===i||i.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(tt),null===(n=this.logs)||void 0===n||n.flushLogs("sendBeacon"),null===(s=this._requestQueue)||void 0===s||s.unload(),null===(r=this._retryQueue)||void 0===r||r.unload()):this._shouldCapturePageleave()&&this.capture(tt,null,{transport:"sendBeacon"})}_send_request(e){$k(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?ct(ct({},e),{},{transport:t}):e)}_execute_array(e){rC++;try{let t;const i=[],n=[],s=[];qr(e,e=>{if(e)if(t=e[0],kt(t))s.push(e);else if(Ct(e))try{e.call(this)}catch(t){Nr.error("Error executing queued PostHog call",e,t)}else kt(e)&&"alias"===t?i.push(e):kt(e)&&-1!==t.indexOf("capture")&&Ct(this[t])?s.push(e):n.push(e)});const r=function(e,t){qr(e,function(e){try{if(kt(e[0])){let i=t;Hr(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Nr.error("Error executing queued PostHog call",e,t)}})};r(i,this),r(n,this),r(s,this)}finally{rC--}}push(e){if(rC>0&&kt(e)&&It(e[0])){const i=t.prototype[e[0]];return void(Ct(i)&&i.apply(this,e.slice(1)))}this._execute_array([e])}get _facebookClickIdChannel(){return{property:U,persistenceKey:z,cookieName:"_fbc",pattern:_C,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[z]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(z)}}}get _facebookBrowserIdChannel(){return{property:W,persistenceKey:j,cookieName:"_fbp",pattern:fC,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[j]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(j)}}}_getPersistedMetaIdentifier(e){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(e.persistenceKey);return It(i)&&e.pattern.test(i)?{value:i,delivered:!1}:Et(i)&&It(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(!this.config.save_campaign_params||this._inCookielessMode())return;const t=wl(e.cookieName);return It(t)&&e.pattern.test(t)?t:void 0}_updateFacebookClickId(e,t,i,n){if(!this.persistence)return;const s=this._facebookClickIdChannel;this.persistence.refreshMetaIdentifiers();const r=this._getPersistedMetaIdentifier(s);if(n)return void s.unregister();if(i)return It(t)&&_C.test(t)?this._storeMetaIdentifier(s,t,r):void s.unregister();const o=It(e)&&gC.test(e)?e:void 0,a=this._readMetaCookie(s);return a&&((e,t,i)=>{const n=e.split(".");if(t)return n[3]===t;if(!i)return!0;const s=i.value.split(".");return n[3]===s[3]||Number(n[2])>Number(s[2])})(a,o,r)?this._storeMetaIdentifier(s,a,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this._storeMetaIdentifier(s,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}_updateFacebookBrowserId(e,t,i){if(!this.persistence)return;const n=this._facebookBrowserIdChannel;this.persistence.refreshMetaIdentifiers();const s=this._getPersistedMetaIdentifier(n);if(i)return void n.unregister();if(t)return It(e)&&fC.test(e)?this._storeMetaIdentifier(n,e,s):void n.unregister();const r=this._readMetaCookie(n);return r?this._storeMetaIdentifier(n,r,s):s?{value:s.value,pending:!s.delivered}:void 0}_markMetaIdentifierDelivered(e,t){if(!this.persistence)return;this.persistence.refreshMetaIdentifiers();const i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}capture(e,t,i){var n,s,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void Nr.uninitializedWarning("posthog.capture");if(!this.is_capturing())return void Nr.info(`Event "${e}" was not captured because capturing is disabled (opted out or consent pending).`);if(xt(e)||!It(e))return void Nr.error("No event name provided to posthog.capture");if(this._syncCookielessIdentity(),"$snapshot"===e&&this._inCookielessMode())return;const o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return void Nr.info(`Event "${e}" was not captured because the user agent looks like a bot. Set \`opt_out_useragent_filter: true\` to capture it.`);const a=(null==i?void 0:i.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==a?void 0:a.isRateLimited)return void Nr.critical("This capture call is ignored due to client rate limiting.");let l;(null==t?void 0:t.$current_url)&&!It(null==t?void 0:t.$current_url)&&(Nr.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==i?void 0:i._originatedFromCaptureException)||Nr.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&&(l=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();const c=new Date,u=(null==i?void 0:i.timestamp)||c,d=an(null==i?void 0:i.uuid,Rl);let h={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&o&&(h.event="$bot_pageview",h.properties.$browser_type="bot"),a&&(h.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const p="$feature_flag_called"===e&&!1===h.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==i?void 0:i.$set)&&!p&&(h.$set=null==i?void 0:i.$set);const g=Et(null==t?void 0:t.$set)?t.$set:void 0,_=kt(null==t?void 0:t.$unset)?t.$unset:[],f=(null==i?void 0:i.$unset)||[],v=e=>{var t;const n=!!(null==i?void 0:i.$set)&&e in i.$set;return{hasProvided:n||!!g&&e in g,provided:n?null==i||null===(t=i.$set)||void 0===t?void 0:t[e]:null==g?void 0:g[e],unset:-1!==_.indexOf(e)||-1!==f.indexOf(e)}},m=v(U),y=v(W),b=[{channel:this._facebookClickIdChannel,hasProvided:m.hasProvided,update:this._updateFacebookClickId(null==l?void 0:l.fbclid,m.provided,m.hasProvided,m.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:y.hasProvided,update:this._updateFacebookBrowserId(y.provided,y.hasProvided,y.unset)}];for(const{channel:e,hasProvided:t,update:i}of b)i&&!0===h.properties.$process_person_profile&&i.pending&&!t&&!p&&(h.$set=ct({[e.property]:i.value},h.$set));const S=null==i?void 0:i.$unset;S&&(h.$unset=S);const w=p?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==nt,e===it);if(w&&(h.$set_once=w),(null==i?void 0:i._noTruncate)||(k=this.config.properties_string_max_length,h=function(e,t){const i=new Set;return function e(n,s){if(n!==Object(n))return t?t(n):n;if(i.has(n))return;let r;if(i.add(n),kt(n))r=[],qr(n,t=>{r.push(e(t))});else{const t={};Hr(qt(n)?Vr(n):n,(n,s)=>{i.has(n)||(t[s]=e(n,s))}),r=t}return r}(e)}(h,e=>It(e)?e.slice(0,k):e)),h.timestamp=u,xt(null==i?void 0:i.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=c),p&&(h.properties=((e,t=[])=>{const i={},n=t=>{void 0!==e[t]&&(i[t]=e[t])};return ls.forEach(n),t.forEach(n),i})(h.properties,vC)),e===$f.DISMISSED||e===$f.SENT){const i=null==t?void 0:t[Nf.SURVEY_ID],n=null==t?void 0:t[Nf.SURVEY_ITERATION];Vf({id:i,current_iteration:n}),h.$set=ct(ct({},h.$set),{},{[sc({id:i,current_iteration:n},e===$f.SENT?"responded":"dismissed")]:!0})}else e===$f.SHOWN&&(h.$set=ct(ct({},h.$set),{},{[Nf.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var k;if(e===Pk.SHOWN){const e=null==t?void 0:t[Mk.TOUR_TYPE];e&&(h.$set=ct(ct({},h.$set),{},{[`${Mk.TOUR_LAST_SEEN_DATE}/${e}`]:(new Date).toISOString()}))}const C=ct(ct({},h.properties.$set),h.$set);if(Tt(C)||this.setPersonPropertiesForFlags(C),!Mt(this.config.before_send)){const e=this._runBeforeSend(h);if(!e)return;h=e,h.uuid=an(h.uuid,Rl)}this.sessionRecording&&!this._replayDebugPropertiesPaused&&pC(e)&&(this._replayDebugPropertiesPaused=!0,setTimeout(()=>this._replayDebugPropertiesPaused=!1,3e4));const E=b.filter(({channel:e,update:t})=>{var i,n,s;const r=null!==(i=null===(n=h.$set)||void 0===n?void 0:n[e.property])&&void 0!==i?i:Et(null===(s=h.properties)||void 0===s?void 0:s.$set)?h.properties.$set[e.property]:void 0;return(null==t?void 0:t.pending)&&r===t.value});this._internalEventEmitter.emit("eventCaptured",h);const T=null!==(n=null==i?void 0:i._url)&&void 0!==n?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),x="recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(T),I=ct(ct(ct({method:"POST",url:T,data:h,compression:"best-available",preferSyncCompression:null==i?void 0:i.send_instantly,timestampMode:x?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},x&&(null===(s=h.properties)||void 0===s?void 0:s.$session_id)?{batchGroup:h.properties.$session_id+(h.properties.$window_id?`-${h.properties.$window_id}`:"")}:{}),(null==i?void 0:i.transport)?{transport:i.transport}:{}),E.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(const{channel:e,update:t}of E)this._markMetaIdentifierDelivered(e,t.value)}}:{});if(!this.config.request_batching||i&&!(null==i?void 0:i._batchKey)||(null==i?void 0:i.send_instantly)){var R;let e;!I.transport&&!I.callback&&Tt(null!==(R=this.config.request_headers)&&void 0!==R?R:{})&&this._isPageUnloading&&(e="sendBeacon"),this._send_retriable_request(I,e)}else this._requestQueue.enqueue(I);return null===(r=this.featureFlags)||void 0===r||r.sendFlagCallsPendingCapture(),h}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null===(t=this._browserClientAdapter)||void 0===t?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new Sb(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);let t=!0;return()=>{if(!t)return;t=!1;const i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}_processCookieIdentityChange(e=!0){var t;return!!(null===(t=this.persistence)||void 0===t?void 0:t.consumeCookieIdentityChange())&&(this._processIdentityChange(e),!0)}_processIdentityChange(e=!0){var t,i,n;this._cachedPersonProperties=null,"anonymous"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))&&(null===(n=this.sessionPersistence)||void 0===n||n.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null===(i=this.featureFlags)||void 0===i||i.reset(),e&&this.reloadFeatureFlags()}calculateEventProperties(t,i,r,o,a){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return i;this._syncCookielessIdentity(),this.persistence.syncCookieProperties(),this._processCookieIdentityChange();const l=a?void 0:this.persistence.remove_event_timer(t);let u=ct({},i);if(u.token=this.config.token,u.$config_defaults="latest"===this.config.defaults?yC:this.config.defaults,this._inCookielessMode()&&(u[Oe]=!0),"$snapshot"===t){const e=ct(ct({},this.persistence.properties()),this.sessionPersistence.properties());return u.distinct_id=e.distinct_id,(!It(u.distinct_id)&&!Ft(u.distinct_id)||Rt(u.distinct_id))&&Nr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}const d=function(t,i,n,r=!1){var o,a,l,u;if(!c)return{};const d=t?[...Tc,...i||[]]:[],[h,p]=Qi(c),[g,_]=function(e){for(let t=0;Zi.length>t;t++){const[i,n,s]=Zi[t],r=e.match(i);if(r){const t=s&&e.match(s)||r;return[n,(null==t?void 0:t[1])||""]}}return["",""]}(c),f=function(){const e="u">typeof navigator?navigator:void 0;return(null==e?void 0:e.brave)?{brave:!0}:{}}(),v={};xt(n)||(v.detectGoogleSearchApp=n);const m={},y=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,b=null===(a=navigator)||void 0===a?void 0:a.maxTouchPoints,S=null==e||null===(l=e.screen)||void 0===l?void 0:l.width,w=null==e||null===(u=e.screen)||void 0===u?void 0:u.height,k=null==e?void 0:e.devicePixelRatio;xt(y)||(m.userAgentDataPlatform=y),xt(b)||(m.maxTouchPoints=b),xt(S)||(m.screenWidth=S),xt(w)||(m.screenHeight=w),xt(k)||(m.devicePixelRatio=k);const C=Ur(jr({$os:h,$os_version:p,$browser:Wi(c,navigator.vendor,f,v),$webview_app:g,$webview_app_version:_,$device:Ki(c),$device_type:Ji(c,m),$timezone:Ec(),$timezone_offset:Bc()}),{$current_url:ro(r?cn(null==s?void 0:s.href):null==s?void 0:s.href,d,Ic),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:c.length>1e3?c.substring(0,997)+"...":c,$browser_version:Vi(c,navigator.vendor,f,v),$browser_language:Ac(),$browser_language_prefix:Lc(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:Dr.LIB_NAME,$lib_version:Dr.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Dr.SDK_DIST_CHANNEL&&(C.$sdk_dist_channel=Dr.SDK_DIST_CHANNEL),C}(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){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(a,r.getTime(),!0);u.$session_id=e,u.$window_id=t}this.sessionPropsManager&&Ur(u,this.sessionPropsManager.getSessionProps());try{var h;if(this.sessionRecording){const e=this.sessionRecording.sdkDebugProperties,i=!this._replayDebugPropertiesPaused&&pC(t);for(const t in e)(i||ft(dC,t))&&(u[t]=e[t])}u.$sdk_debug_retry_queue_size=null===(h=this._retryQueue)||void 0===h?void 0:h.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}let p;if(this.requestRouter.region===Jk&&(u.$lib_custom_api_host=this.config.api_host),p="$pageview"!==t||a?"$pageleave"!==t||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),u=Ur(u,p),"$pageview"===t&&n&&(u.title=n.title),!xt(l)){const e=r.getTime()-l;u.$duration=parseFloat((e/1e3).toFixed(3))}c&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?"bot":"browser");const g=this.persistence.properties(),_=this.sessionPersistence.properties(),f=u.$groups,v=g.$groups;Et(f)&&!Tt(f)&&(u.$groups=ct(ct({},Et(v)?v:{}),f)),Hr(["$referrer","$referring_domain"],e=>{e in g&&delete _[e]});const m={};if(this._extensionEventPropertyProducers.length>0)for(const e of this._extensionEventPropertyProducers.slice())try{Ur(m,e())}catch(e){Nr.error("Failed to produce browser extension event properties",e)}u=Ur({},d,g,_,ct(ct({},m),u)),u.$is_identified=this._isIdentified(),kt(this.config.property_denylist)?Hr(this.config.property_denylist,function(e){delete u[e]}):Nr.error(uC+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(Nr.error(cC),u=y(u,t));const b=this._hasPersonProcessing();return u.$process_person_profile=b,b&&!a&&this._requirePersonProcessing("_calculate_event_properties"),u}_calculate_set_once_properties(e,t=!0,i=!1){var n;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;const s=this.persistence.get_initial_props(),r=null===(n=this.sessionPropsManager)||void 0===n?void 0:n.getSetOnceProps();let o=Ur({},s,r||{},e||{});const a=this.config.sanitize_properties;return a&&(Nr.error(cC),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),Tt(o)?void 0:o}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var n;null===(n=this.persistence)||void 0===n||n.register_once(e,t,i)}register_for_session(e){var t,i;null===(t=this.persistence)||void 0===t||t.syncCookieProperties(),this._processCookieIdentityChange(),null===(i=this.sessionPersistence)||void 0===i||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(!this._sessionRegisteredPropertiesStorageKey)return;if("memory"===this.config.persistence||(null===(e=this.sessionPersistence)||void 0===e?void 0:e._disabled)||!Jl._is_supported())return void Jl._remove(this._sessionRegisteredPropertiesStorageKey);const t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Jl._set(this._sessionRegisteredPropertiesStorageKey,t):Jl._remove(this._sessionRegisteredPropertiesStorageKey)}getFeatureFlag(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null===(t=this.featureFlags)||void 0===t?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,n;return null!==(i=null===(n=this.featureFlags)||void 0===n?void 0:n.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null===(e=this.featureFlags)||void 0===e||e.reloadFeatureFlags()}updateFlags(e,t,i){var n;null===(n=this.featureFlags)||void 0===n||n.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var n;null===(n=this.featureFlags)||void 0===n||n.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t=!1,i){var n;return null===(n=this.featureFlags)||void 0===n?void 0:n.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:lC}),()=>{})}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:lC})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:lC})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:lC}),()=>{})}renderSurvey(e,t){var i;null===(i=this.surveys)||void 0===i||i.renderSurvey(e,t)}displaySurvey(e,t=Qf){var i;null===(i=this.surveys)||void 0===i||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null===(t=this.surveys)||void 0===t||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null===(i=this.surveys)||void 0===i?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:lC}}canRenderSurveyAsync(e,t=!1){var i,n;return null!==(i=null===(n=this.surveys)||void 0===n?void 0:n.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:lC})}_validateIdentifyId(e){return!e||Rt(e)?(Nr.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Nr.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())||(Nr.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 Nr.uninitializedWarning("posthog.identify");if(Ft(e)&&(e=e.toString(),Nr.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))return;if(!this._requirePersonProcessing("posthog.identify"))return;this._syncCookielessIdentity();const n=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==n,r=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression();let a=!1;try{const n=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:n},""),e!==n&&e!==this.get_property("__alias")&&(this.unregister(q),this.register({distinct_id:e}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Je,c=e!==n,u=!c&&o;if(c&&o){var l;const s=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:n};this.persistence.set_property(xe,Ye),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",s,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=vc(e,t,i)),null===(l=this.featureFlags)||void 0===l||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:n)}else if(u){this.persistence.set_property(xe,Ye);const n=t||{},s=i||{};this.setPersonPropertiesForFlags({$set:n,$set_once:s},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:n,$set_once:s})&&(this._cachedPersonProperties=vc(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);c||s||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(w)):u&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}setPersonProperties(e,t){if(!e&&!t)return;if(!this._requirePersonProcessing("posthog.setPersonProperties"))return;const i=vc(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)):Nr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var t;const i=(kt(e)?e:[e]).filter(e=>It(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null===(t=this.featureFlags)||void 0===t||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var n;if(!e||!t)return void Nr.error("posthog.group requires a group type and group key");null===(n=this.persistence)||void 0===n||n.syncCookieProperties(),this._processCookieIdentityChange();const s=this.getGroups(),r=s[e]!==t;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ct(ct({},s),{},{[e]:t})}),(r||i)&&this._hasPersonProcessing()){const n={$group_type:e,$group_key:t};i&&(n.$group_set=i),this.capture(nt,n)}i&&this.setGroupPropertiesForFlags({[e]:i}),r&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;null===(t=this.featureFlags)||void 0===t||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var i;this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null===(i=this.featureFlags)||void 0===i||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null===(t=this.featureFlags)||void 0===t||t.resetGroupPropertiesForFlags(e)}reset(e){const t=Lt(e)?e:null==e?void 0:e.resetDeviceID,i=Lt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t=!1,i){var n,s,r,o,a,l;if(Nr.info("reset"),!this.__loaded)return Nr.uninitializedWarning("posthog.reset");const c=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null===(n=this._originalUserConfig)||void 0===n?void 0:n.bootstrap)||{},null===(s=this.featureFlags)||void 0===s||null===(r=s.updateConfig)||void 0===r||r.call(s,this.config,this._shouldDisableFlags());const u=this.get_property(N),d=this.get_property(B),h=this.get_property(ie);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const p=this.is_capturing();t||this.consent.reset(),t||!p||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const g=null===(a=this.persistence)||void 0===a||null===(l=a._beginCookieSyncSuppression)||void 0===l?void 0:l.call(a),_=this._isConsentTransition;this._isConsentTransition=_||t;let f=!1;try{var v,m,y,b,S,w,k,C,E,T,x,I,R;if(null===(v=this.persistence)||void 0===v||v.clear(),null===(m=this.sessionPersistence)||void 0===m||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),xt(h)||null===(T=this.persistence)||void 0===T||T.register({$session_recording_remote_config:h}),null===(y=this.surveys)||void 0===y||y.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(S=this.conversations)||void 0===S||S.reset(),null===(w=this.logs)||void 0===w||w.reset(),null===(k=this.metrics)||void 0===k||k.reset(),null===(C=this.persistence)||void 0===C||C.set_property("$user_state","anonymous"),null===(E=this.sessionManager)||void 0===E||E.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Le,$device_id:null},"");else{const t=this.config.get_device_id(Rl());this.register_once({distinct_id:t,$device_id:e?t:u},""),e||xt(d)||this.register({[B]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(i.distinctID&&!this._inCookielessMode()&&(null===(R=this.persistence)||void 0===R||R.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),null===(x=this.featureFlags)||void 0===x||x.initialize(),!Mt(c)&&!(null===(I=this.sessionManager)||void 0===I?void 0:I.setBootstrapSessionId(c,!0))){const e=ct({},i);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,f=!0}finally{var P,M;this._isConsentTransition=_,g&&(null===(P=this.persistence)||void 0===P||null===(M=P._endCookieSyncSuppression)||void 0===M||M.call(P,f))}var F;this._lastRemoteConfig&&(null===(F=this.conversations)||void 0===F||F.onRemoteConfig(this._lastRemoteConfig)),this.reloadFeatureFlags()}shutdown(e){var t=this;return rt(function*(){if(!t.__loaded)return void Nr.uninitializedWarning("posthog.shutdown");t._isShutdown=!0,clearTimeout(t._extensionInitTimeout),t._extensionInitTimeout=void 0;const e=t._featureFlagsReloadingUnsubscribe;t._featureFlagsReloadingUnsubscribe=void 0;for(const i of[()=>{var e;return null===(e=t.sessionRecording)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.flushLogs("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.flush("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.surveys)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.autocapture)||void 0===e?void 0:e.dispose()},()=>null==e?void 0:e(),()=>{var e;return null===(e=t._requestQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t._retryQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t.featureFlags)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.persistence)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.sessionPersistence)||void 0===e?void 0:e.destroy()}])try{const e=i();e&&Ct(e.then)&&e.then(void 0,e=>{Nr.error("Error during shutdown",e)})}catch(e){Nr.error("Error during shutdown",e)}})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null===(i=this.conversations)||void 0===i||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(e=this.conversations)||void 0===e||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?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let n=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if((null==e?void 0:e.withTimestamp)&&i){var s;const t=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return n;n+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return n}alias(e,t){return e===this.get_property("$people_distinct_id")?(Nr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(xt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(q,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Nr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const t=ct({},this.config);if(Et(e)){var i,n,s,r,o,a,l,c,u,d,h,p,g,_;Ur(this.config,kC(e));const b=this._is_persistence_disabled();if(this.persistence){const e="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;var f,v;if(e&&this.sessionPersistence!==this.persistence&&(null===(f=this.sessionPersistence)||void 0===f||f.remove(),null===(v=this.sessionPersistence)||void 0===v||v.destroy()),this.persistence.update_config(this.config,t,b),e)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new Rk(ct(ct({},this.config),{},{persistence:"sessionStorage"}),b,!1);else{var m;null===(m=this.sessionPersistence)||void 0===m||m.update_config(ct(ct({},this.config),{},{persistence:"sessionStorage"}),ct(ct({},t),{},{persistence:"sessionStorage"}),b)}}const S=this._checkLocalStorageForDebug(this.config.debug);var y;Lt(S)&&(this.config.debug=S),Lt(this.config.debug)&&(this.config.debug?(Yl.DEBUG=!0,Dl._is_supported()&&Dl._set("ph_debug",!0),Nr.info("set_config",{config:e,oldConfig:t,newConfig:ct({},this.config)})):(Yl.DEBUG=!1,Dl._is_supported()&&Dl._remove("ph_debug"))),null===(i=this.featureFlags)||void 0===i||null===(n=i.updateConfig)||void 0===n||n.call(i,this.config,this._shouldDisableFlags()),null===(s=this.exceptionObserver)||void 0===s||s.onConfigChange(),null===(r=this.exceptions)||void 0===r||r.onConfigChange(),null===(o=this.metrics)||void 0===o||o.onConfigChange(),null===(a=this.webMCP)||void 0===a||a.startIfEnabled(),null===(l=this.sessionRecording)||void 0===l||l.startIfEnabledOrStop(),null===(c=this.tracingHeaders)||void 0===c||c.startIfEnabledOrStop(),null===(u=this.autocapture)||void 0===u||u.startIfEnabled(),null===(d=this.heatmaps)||void 0===d||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null===(y=this.historyAutocapture)||void 0===y||y.startIfEnabledOrStop()),null===(h=this.exceptionObserver)||void 0===h||h.startIfEnabledOrStop(),null===(p=this.deadClicksAutocapture)||void 0===p||p.startIfEnabledOrStop(),null===(g=this.surveys)||void 0===g||g.loadIfEnabled(),this._sync_opt_out_with_persistence(),null===(_=this.externalIntegrations)||void 0===_||_.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&lk(this,oC,!1)}}_overrideSDKInfo(e,t){Yl.LIB_NAME=e,Yl.LIB_VERSION=t}startSessionRecording(e){const t=!0===e,i={sampling:t||!!(null==e?void 0:e.sampling),linked_flag:t||!!(null==e?void 0:e.linked_flag),url_trigger:t||!!(null==e?void 0:e.url_trigger),event_trigger:t||!!(null==e?void 0:e.event_trigger)};var n,s,r,o,a;Object.values(i).some(Boolean)&&(null===(n=this.sessionManager)||void 0===n||n.checkAndGetSessionAndWindowId(),i.sampling&&(null===(s=this.sessionRecording)||void 0===s||s.overrideSampling()),i.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),i.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),i.event_trigger&&(null===(a=this.sessionRecording)||void 0===a||a.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)||void 0===e?void 0:e.started)}captureException(e,t){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(ct(ct({},i),t))}catch(e){return}}addExceptionStep(e,t){var i;null===(i=this.exceptions)||void 0===i||i.addExceptionStep(e,t)}captureLog(e){var t;null===(t=this.logs)||void 0===t||t.captureLog(e)}get logger(){var e,i;return null!==(e=null===(i=this.logs)||void 0===i?void 0:i.logger)&&void 0!==e?e:t._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?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:mC;return t!==mC&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property("$user_state"))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&Tt(this.getGroups())&&!(null===(e=this.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.__alias)&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!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?(Nr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(Ae,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;const e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t;const i=this._is_persistence_disabled();var n,s,r;return this.is_capturing()||null===(n=this.logs)||void 0===n||n._onOptOut(),(null===(e=this.persistence)||void 0===e?void 0:e._disabled)!==i&&(null===(s=this.persistence)||void 0===s||s.set_disabled(i)),(null===(t=this.sessionPersistence)||void 0===t?void 0:t._disabled)!==i&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(i)),this._persistSessionRegisteredPropKeys(),i}opt_in_capturing(e){var i,n,s;if("always"===this.config.cookieless_mode)return void Nr.warn(aC);if(this._inCookielessMode()){var r,o,a,l,c,u;null===(r=this.sessionRecording)||void 0===r||r.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null===(o=this.sessionManager)||void 0===o||o.destroy(),null===(a=this.pageViewManager)||void 0===a||a.destroy(),this.sessionManager=new Vk(this),this.pageViewManager=new hk(this),this.persistence&&(this.sessionPropsManager=new zk(this,this.sessionManager,this.persistence));const e=null!==(l=null===(c=this.config.__extensionClasses)||void 0===c?void 0:c.sessionRecording)&&void 0!==l?l:null===(u=t.__defaultExtensionClasses)||void 0===u?void 0:u.sessionRecording;var d,h;e&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new e(this)),this._lastRemoteConfig&&(null===(d=this.sessionRecording)||void 0===d||null===(h=d.onRemoteConfig)||void 0===h||h.call(d,this._lastRemoteConfig)))}const p=1===this.consent.consent;var g,_,f;p&&this._syncCookielessIdentity(),this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(g=this.surveys)||void 0===g||g.loadIfEnabled(),null===(_=this.conversations)||void 0===_||_.loadIfEnabled()),p||!xt(null==e?void 0:e.captureEventName)&&!(null==e?void 0:e.captureEventName)||this.capture(null!==(f=null==e?void 0:e.captureEventName)&&void 0!==f?f:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),null===(n=this.persistence)||void 0===n||n.syncCookieProperties(),this._processCookieIdentityChange(),null===(s=this.featureFlags)||void 0===s||s.sendFlagCallsPendingCapture(),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){"always"!==this.config.cookieless_mode?(this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&this._enterCookielessMode()):Nr.warn(aC)}_enterCookielessMode(){var e,t;const i=this.sessionRecording;null==i||i.dispose({discardBufferedEvents:!0}),"$posthog_cookieless"!==this.get_distinct_id()&&this._reset(!0,!0),this.register({distinct_id:Le,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null===(e=this.sessionManager)||void 0===e||e.destroy(),null===(t=this.pageViewManager)||void 0===t||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return!this._isConsentTransition&&("always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?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 i?Qk(i,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){n&&("visible"===n.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(et,{title:n.title},{send_instantly:!0}),this._visibilityStateListener&&(n.removeEventListener(x,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Kr(n,x,this._visibilityStateListener)))}debug(t){!1===t?(null==e||e.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==e||e.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(){const e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Nr.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(e,t,i,n,s){const r=t in e&&!Mt(e[t]),o=i in e&&!Mt(e[i]);return r?e[t]:!!o&&(s&&s.warn(`Config field '${i}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Nr)}_runBeforeSend(e){var t;if(Mt(this.config.before_send))return e;const i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter($t),n=kt(this.config.before_send)?this.config.before_send:[this.config.before_send];let s=e;for(const t of n)try{if(s=t(s),Mt(s)){const t=`Event '${e.event}' was rejected in beforeSend function`;return Dt(e.event)?Nr.warn(`${t}. This can cause unexpected behavior.`):Nr.info(t),null}s.properties&&!Tt(s.properties)||Nr.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return Nr.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(const t of i)if(s.properties&&Mt(s.properties[t]))return Nr.warn(`Event '${e.event}' had its '${t}' 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?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){const t=Lt(e)&&!e,i=Dl._is_supported()&&"true"===Dl._get("ph_debug");return!t&&(!!i||e)}};EC.__defaultExtensionClasses={},EC._noopLogger=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Wr(e.prototype[t[i]])}(EC,["identify"]);const TC=["[data-ph-capture-value]"];var xC=class{constructor(e){this._instance=e}refresh(e){var t;const i=this._instance.config,n=Et(i.autocapture)?i.autocapture:void 0;e.enabled=!!i.autocapture,e.rageclick=i.rageclick,e.maskAllElementAttributes=i.mask_all_element_attributes,e.maskAllText=i.mask_all_text,e.disableCaptureUrlHashes=i.disable_capture_url_hashes,e.getCurrentUrl=i.get_current_url,e.remoteRequestsDisabled=this._instance._shouldDisableFlags(),e.url_allowlist=null==n?void 0:n.url_allowlist,e.url_ignorelist=null==n?void 0:n.url_ignorelist,e.dom_event_allowlist=null==n?void 0:n.dom_event_allowlist,e.element_allowlist=null==n?void 0:n.element_allowlist,e.css_selector_allowlist=null==n?void 0:n.css_selector_allowlist,e.css_selector_ignorelist=null==n?void 0:n.css_selector_ignorelist,e.element_attribute_ignorelist=null==n?void 0:n.element_attribute_ignorelist,e.capture_copied_text=null==n?void 0:n.capture_copied_text,e.capture_value_css_selector_allowlist=null!==(t=null==n?void 0:n.capture_value_css_selector_allowlist)&&void 0!==t?t:TC}};const IC=Br("[ExceptionAutocapture]"),RC=Br("[TracingHeaders]"),PC=Br("[Web Vitals]"),MC=9e5,FC=["CLS","FCP","INP","LCP"],AC=["INP","LCP"],LC=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],OC=Br("[SessionRecording]"),DC=[Ne,Be,qe,He,Ue,ze,We,je,Ve],$C=Br("[Heatmaps]");function NC(e){return Et(e)&&"clientX"in e&&"clientY"in e&&Ft(e.clientX)&&Ft(e.clientY)}const BC=Br("[Product Tours]"),qC=e=>{var t;return!e.config.disable_product_tours&&!!(null===(t=e.persistence)||void 0===t?void 0:t.get_property(X))},HC=["$set_once","$set"],UC=Br("[SiteApps]"),zC="Error while initializing PostHog app with config id ",WC=(()=>(null==e?void 0:e.location)?oo(e.location.hash,"__posthog")||oo(location.hash,"state"):null)(),jC="_postHogToolbarParams",VC=Br("[Toolbar]"),GC=Br("[FeatureFlags]"),QC=Br("[FeatureFlags]",{debugEnabled:!0}),KC="\" failed. Feature flags didn't load in time.",JC=[502,504],YC=["click","keydown","wheel","touchstart","pointerdown"],ZC="connection_error",XC=e=>{const t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},eE=e=>{const t={};for(const[i,n]of zr(e||{}))n&&(t[i]=n);return t},tE=(e,t)=>e.distinctId===t.distinctId&&e.sessionId===t.sessionId&&((e,t)=>{const i=Object.keys(e);return i.length===Object.keys(t).length&&i.every(i=>e[i]===t[i])})(e.groups,t.groups);var iE=class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=GC,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._reloadingHandlers=[],this._pendingReloads=new Set,this._activeReloads=new Set,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._requestGeneration=0,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._firingFeatureFlagsCallbacks=!1,this._flagCallsPendingCapture=new Map,this._sendingFlagCallsPendingCapture=!1,this._flagsLoadedFromRemote=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._hadUserInteraction=!1,this._onOnline=()=>{const e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t;const i=this._refreshIntervalMs,n=null!==(e=this._dueRefreshIntervalMs)&&void 0!==e?e:i;xt(i)||xt(n)||this._config.remoteRequestsDisabled||!this._document||"hidden"===this._document.visibilityState||Date.now()-(null!==(t=this._lastRefreshAt)&&void 0!==t?t:0)<n||(this._dueRefreshIntervalMs=this._hadUserInteraction||!this._config.idleRefreshBackoff?i:Math.min(2*n,36e5),this._hadUserInteraction=!1,this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onUserInteraction=()=>{this._hadUserInteraction&&this._dueRefreshIntervalMs===this._refreshIntervalMs||this._resumeConfiguredInterval()},this._onVisibilityChange=()=>{var e;"visible"===(null===(e=this._document)||void 0===e?void 0:e.visibilityState)&&this._resumeConfiguredInterval()},this._configSource=e}get _crossTabPersistence(){}_onConfigUpdated(){this._client&&this._syncAutomaticRefresh()}setup(e){try{this._window=typeof window>"u"?void 0:window,this._document=typeof document>"u"?void 0:document}catch(e){this._window=void 0,this._document=void 0}return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),Oy(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(e){var t;if(this._client===e)return this._window&&Kr(this._window,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=e.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null===(t=this._crossTabPersistence)||void 0===t?void 0:t.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_resumeConfiguredInterval(){this._hadUserInteraction=!0,this._dueRefreshIntervalMs=this._refreshIntervalMs,this._refreshIfDue()}_syncAutomaticRefresh(){var e;const t=this._config.refreshIntervalMs,i=!this._config.remoteRequestsDisabled&&this._document&&!xt(t)&&t>0?t:void 0;this._config.idleRefreshBackoff||(this._dueRefreshIntervalMs=i),i!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),xt(i)||(this._refreshIntervalMs=i,this._dueRefreshIntervalMs=i,this._scheduleNextRefresh(),(null===(e=this._document)||void 0===e?void 0:e.addEventListener)&&(Kr(this._document,x,this._onVisibilityChange),qr(YC,e=>{Kr(this._document,e,this._onUserInteraction,{capture:!0})}))))}_scheduleNextRefresh(){xt(this._refreshIntervalMs)||(xt(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){var e,t;xt(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null===(e=this._document)||void 0===e||null===(t=e.removeEventListener)||void 0===t||t.call(e,"visibilitychange",this._onVisibilityChange),qr(YC,e=>{var t,i;null===(t=this._document)||void 0===t||null===(i=t.removeEventListener)||void 0===i||i.call(t,e,this._onUserInteraction,{capture:!0})})),this._refreshIntervalMs=void 0,this._dueRefreshIntervalMs=void 0,this._hadUserInteraction=!1,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var e,t,i;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._client&&(this._clearDebouncer(),null===(e=this._dynamicProperties)||void 0===e||e.dispose(),this._dynamicProperties=void 0,null===(t=this._crossTabPersistenceUnsubscribe)||void 0===t||t.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null===(i=this._window)||void 0===i||i.removeEventListener("online",this._onOnline),this._client=void 0)}get _config(){return this._configSource.get()}_prop(e){var t;return this._bootstrapState&&e in this._bootstrapState?this._bootstrapState[e]:null===(t=this._client)||void 0===t?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!xt(null===(e=this._client)||void 0===e?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){if(!this._crossTabPersistence||!e.$enabled_feature_flags)return;const n=this._prop("$enabled_feature_flags")||{},s=e.$enabled_feature_flags||{},r=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,e])=>!(null==e?void 0:e.failed)).map(([e])=>e):[],a=!!t.errorsWhileComputingFlags&&!!t.flags,l=a?o:i&&!kt(r)?Object.keys(r||{}):Array.from(new Set([...Object.keys(n),...Object.keys(s)])),c=this._prop("$feature_flag_payloads")||{},u=e.$feature_flag_payloads||{},d=a||i?l:Array.from(new Set([...Object.keys(c),...Object.keys(u)])),h=!a&&!i,_=!!h||l,b=!!h||d,S={[p]:_,[y]:_,[C]:b};e.$feature_flag_details&&(S[g]=_);for(const t of[v,f,m])xt(e[t])||(S[t]=!0);this._crossTabPersistence.markCrossTabFeatureFlagChanges(S)}_remove(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){const e={};for(const t of[p,C,v,E]){const i=this._prop(t);xt(i)||(e[t]=i)}this._baseEventProperties=e;const t=ct({},e),i=this._prop(y);if(i)for(const[e,n]of Object.entries(i))t[`$feature/${e}`]=n;this._eventPropertiesWithFlagValues=t}_isCacheStale(){const e=this._config.cacheTtlMs;if(!e||0>=e)return!1;const t=this._prop(f);return"number"!=typeof t||Date.now()-t>e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,this._logger.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){const e=this._config.evaluationContexts;return(null==e?void 0:e.length)?e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}_getValidFlagKeys(){const e=this._config.flagKeys;if(!xt(e))return e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var e,t;const i=this._config,n=null!==(e=null===(t=i.bootstrap)||void 0===t?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(n).length){var s,r;const e=null!==(s=null===(r=i.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==s?s:{},t=Object.keys(n).filter(e=>!xt(n[e])).reduce((e,t)=>(e[t]=n[t],e),{}),o=Object.keys(e).filter(e=>t[e]).reduce((t,i)=>(t[i]=e[i],t),{});return this._receivedFeatureFlags({featureFlags:t,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(e,t,i){var n,s;const r=(null==i?void 0:i.merge)&&null!==(n=this._prop("$enabled_feature_flags"))&&void 0!==n?n:{},o=(null==i?void 0:i.merge)&&null!==(s=this._prop("$feature_flag_payloads"))&&void 0!==s?s:{},a=ct(ct({},r),e),l=ct(ct({},o),t),c={};for(const[e,t]of Object.entries(a))c[e]={key:e,enabled:os(t),variant:as(t),reason:void 0,metadata:xt(null==l?void 0:l[e])?void 0:{id:0,version:void 0,description:void 0,payload:l[e]}};this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this._prop(g),t=this._prop(E),i=this._prop(T);if(!i&&!t)return e||{};const n=Ur({},e||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(const e of s){var r,o;const s=n[e],a=null==t?void 0:t[e],l=xt(a)?null!==(r=null==s?void 0:s.enabled)&&void 0!==r&&r:!!a,c=xt(a)?null==s?void 0:s.variant:"string"==typeof a?a:void 0,u=null==i?void 0:i[e],d=ct(ct({},s),{},{enabled:l,variant:l?null!=c?c:null==s?void 0:s.variant:void 0});l!==(null==s?void 0:s.enabled)&&(d.original_enabled=null==s?void 0:s.enabled),c!==(null==s?void 0:s.variant)&&(d.original_variant=null==s?void 0:s.variant),u&&(d.metadata=ct(ct({},null==s?void 0:s.metadata),{},{payload:u,original_payload:null==s||null===(o=s.metadata)||void 0===o?void 0:o.payload})),n[e]=d}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:n}),this._override_warning=!0),n}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{const n=e[i];return{key:i,enabled:os(n),variant:as(n),payload:rs(t[i])}})}getFlagVariants(){const e=this._prop(y),t=this._prop(E);if(!t)return e||{};const i=Ur({},e||{}),n=Object.keys(t);for(let e=0;n.length>e;e++)i[n[e]]=t[n[e]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){const e=this._prop(C),t=this._prop(T);if(!t)return e||{};const i=Ur({},e||{}),n=Object.keys(t);for(let e=0;n.length>e;e++)i[n[e]]=t[n[e]];return this._override_warning||(this._logger.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.featureFlagsDisabled||this._hasStatusZeroCircuitBreakerTripped()||(this._firingFeatureFlagsCallbacks&&this._logger.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this._requestInFlight&&(this._additionalReloadRequested=!0),this._reloadDebouncer||(this._reloadingHandlers.slice().forEach(e=>{try{e()}catch(e){this._logger.error("Error while running feature flags reloading callback",e)}}),this._reloadDebouncer=setTimeout(()=>{this._callFlagsEndpoint()},5)))}reloadFeatureFlagsAsync(){return!this._client||this._reloadingDisabled||this._config.featureFlagsDisabled||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped()?Promise.resolve({status:"skipped"}):new Promise(e=>{this._pendingReloads.add(e),this.reloadFeatureFlags()})}_settleReloads(e,t){e.forEach(e=>e({status:t})),e.clear()}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}onReloading(e){return this._reloadingHandlers.push(e),()=>{this._reloadingHandlers=this._reloadingHandlers.filter(t=>t!==e)}}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}resetFlagCallReported(){this._remove(w),this._flagCallsPendingCapture=new Map}sendFlagCallsPendingCapture(){var e;if(0!==this._flagCallsPendingCapture.size&&!this._sendingFlagCallsPendingCapture&&(null===(e=this._client)||void 0===e?void 0:e.canCapture)&&!this._client.isRateLimited){this._sendingFlagCallsPendingCapture=!0;try{const e=this.getFlagVariants();for(const t of Array.from(this._flagCallsPendingCapture.keys())){const i=this._flagCallsPendingCapture.get(t);if(i){if(i.value!==String(e[t])||!tE(i.context,this._flagCallContext())){this._flagCallsPendingCapture.delete(t);continue}if(this.getFeatureFlagResult(t),this._flagCallsPendingCapture.has(t))break}}}finally{this._sendingFlagCallsPendingCapture=!1}}}_callFlagsEndpoint(e){var t;this._clearDebouncer();const i=this._client;if(!i||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped())return void this._settleReloads(this._pendingReloads,"skipped");if(this._requestInFlight)return void(this._additionalReloadRequested=!0);const n={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:ct(ct(ct({},i.initialPersonProperties),this._prop("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this._prop(b),timezone:Ec()};xt(i.deviceId)||(n.$device_id=i.deviceId),((null==e?void 0:e.disableFlags)||this._config.featureFlagsDisabled)&&(n.disable_flags=!0);const s=this._getValidEvaluationEnvironments();s.length&&(n.evaluation_contexts=s);const r=this._getValidFlagKeys();xt(r)||(n.flag_keys=r);const o=this._config.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this._requestGeneration,c=this._pendingReloads;this._pendingReloads=new Set,this._activeReloads=c,this._requestInFlight=!0;const u=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},d=e=>{var t,i;const s=null!==(t=e.json)&&void 0!==t?t:{},r=200!==e.statusCode;if(this._requestInFlight=!1,l!==this._requestGeneration)return void u();if(this._trackStatusZeroReachability(e.statusCode),r||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),n.disable_flags&&!this._additionalReloadRequested)return void this._settleReloads(c,"skipped");this._flagsLoadedFromRemote=!r;const a=[];e.error?a.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?ZC:"unknown_error"):200!==e.statusCode&&a.push(`api_error_${e.statusCode}`),s.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");const d=!!(null===(i=s.quotaLimited)||void 0===i?void 0:i.includes("feature_flags"));d&&a.push("quota_limited"),this._set({[_]:a}),d?this._logger.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."):n.disable_flags||this._receivedFeatureFlags(s,r,{partialResponse:o}),this._settleReloads(c,n.disable_flags?"skipped":a.length||!s.flags&&!s.featureFlags?"error":"loaded"),u()},h=e=>{this._requestInFlight=!1,l===this._requestGeneration?(this._set({[_]:[ZC]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),this._settleReloads(c,"error"),u()):u()};let p=null!==(t=this._config.requestMaxRetries)&&void 0!==t?t:1;const g=()=>p>0&&l===this._requestGeneration,f=()=>{if(l!==this._requestGeneration||!this._client||this._config.remoteRequestsDisabled)return this._requestInFlight=!1,this._settleReloads(c,"skipped"),void u();try{i.sendRequest(a,{target:"flags",method:"POST",body:n,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(e=>{if((e=>JC.includes(e.statusCode)||(e=>0===e.statusCode&&e.error instanceof Error&&"AbortError"===e.error.name)(e))(e)&&g())return p--,void setTimeout(f,500);d(e)}).catch(h)}catch(e){h(e)}};f()}_hasStatusZeroCircuitBreakerTripped(){return Xr(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=eo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var i;if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlag for key "'+e+KC);if(this._checkAndTriggerStaleRefresh())return;const n=this.getFeatureFlagResult(e,t);return null!==(i=null==n?void 0:n.variant)&&void 0!==i?i:null==n?void 0:n.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlagResult for key "'+e+KC);if(this._checkAndTriggerStaleRefresh())return;const i=this.getFlagVariants(),n=e in i,s=i[e],r=this.getFlagPayloads()[e],o=String(s),a=this._prop("$feature_flag_request_id")||void 0,l=this._prop("$feature_flag_evaluated_at")||void 0;let c,u=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var d;const e=null===(d=this._client)||void 0===d||null===(d=d.session)||void 0===d?void 0:d.sessionId,t=this._prop(k);e&&e!==t&&(u={},c=e)}if(!t.send_event&&"send_event"in t)c&&this._set({[w]:u,[k]:c});else{var h,p,g;const t=!(null===(h=this._client)||void 0===h?void 0:h.canCapture),i=!t&&!(null===(p=this._client)||void 0===p?void 0:p.isRateLimited);var _;if(i?this._flagCallsPendingCapture.delete(e):(t&&Object.keys(u).length>0&&(u={},this._set({[w]:u})),(null===(_=u[e])||void 0===_?void 0:_.includes(o))||this._holdFlagCall(e,o)),i&&!(null===(g=u[e])||void 0===g?void 0:g.includes(o))){var f,v,m,y,b,S,C,E,T,x,I,R,P;kt(u[e])?u[e].push(o):u[e]=[o],this._set(ct({[w]:u},c?{[k]:c}:{}));const t=this.getFeatureFlagDetails(e),i=[...null!==(f=this._prop("$feature_flag_errors"))&&void 0!==f?f:[]];xt(s)&&i.push("flag_missing");const n={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:null!==(v=null===(m=this._config.bootstrap)||void 0===m||null===(m=m.featureFlags)||void 0===m?void 0:m[e])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(y=null===(b=this._config.bootstrap)||void 0===b||null===(b=b.featureFlagPayloads)||void 0===b?void 0:b[e])&&void 0!==y?y:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};xt(null==t||null===(S=t.metadata)||void 0===S?void 0:S.has_experiment)||(n.$feature_flag_has_experiment=t.metadata.has_experiment),xt(null==t||null===(C=t.metadata)||void 0===C?void 0:C.version)||(n.$feature_flag_version=t.metadata.version);const d=null!==(E=null==t||null===(T=t.reason)||void 0===T?void 0:T.description)&&void 0!==E?E:null==t||null===(x=t.reason)||void 0===x?void 0:x.code;d&&(n.$feature_flag_reason=d),(null==t||null===(I=t.metadata)||void 0===I?void 0:I.id)&&(n.$feature_flag_id=t.metadata.id),xt(null==t?void 0:t.original_variant)&&xt(null==t?void 0:t.original_enabled)||(n.$feature_flag_original_response=xt(t.original_variant)?t.original_enabled:t.original_variant),(null==t||null===(R=t.metadata)||void 0===R?void 0:R.original_payload)&&(n.$feature_flag_original_payload=null==t||null===(P=t.metadata)||void 0===P?void 0:P.original_payload),i.length&&(n.$feature_flag_error=i.join(",")),this._captureFeatureFlagCalled(n)||(this._unmarkFlagCallReported(e,o),this._holdFlagCall(e,o))}else c&&this._set({[w]:u,[k]:c})}return n?{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:rs(r)}:void 0}_captureFeatureFlagCalled(e){try{var t;return!1!==(null===(t=this._client)||void 0===t?void 0:t.capture("$feature_flag_called",e))}catch(e){return this._logger.error("Failed to capture feature flag call",e),!0}}_holdFlagCall(e,t){this._flagCallsPendingCapture.set(e,{value:t,context:this._flagCallContext()})}_flagCallContext(){var e,t,i;return{distinctId:null===(e=this._client)||void 0===e?void 0:e.distinctId,groups:ct({},null===(t=this._client)||void 0===t?void 0:t.groups),sessionId:this._config.deduplicateCallsPerSession?null===(i=this._client)||void 0===i||null===(i=i.session)||void 0===i?void 0:i.sessionId:void 0}}_unmarkFlagCallReported(e,t){const i=this._prop("$flag_call_reported")||{},n=i[e];kt(n)&&n.includes(t)&&(i[e]=n.filter(e=>e!==t),this._set({[w]:i}))}getRemoteConfigPayload(e,t){this._getRemoteConfigPayload(e,t)}_getRemoteConfigPayload(e,t){var i=this;return rt(function*(){const n=i._client;if(!n)return;const s={distinct_id:n.distinctId,token:n.projectToken,person_properties:{$lib:n.library.name,$lib_version:n.library.version}},r=i._getValidEvaluationEnvironments();r.length&&(s.evaluation_contexts=r);const o=i._getValidFlagKeys();let a;xt(o)||(s.flag_keys=o);try{var l;const t=null===(l=(yield n.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||void 0===l?void 0:l.featureFlagPayloads;a=(null==t?void 0:t[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(a)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+KC),t.defaultValue;const i=this.getFeatureFlag(e,t);return xt(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this._receivedFeatureFlags(e,t,i)}_receivedFeatureFlags(e,t,i){if(!this._client)return;this._hasLoadedFlags=!0;const n=((e,t={},i={},n={},s,r=GC)=>{const o=((e,t)=>{const i=e.flags;if(i){const t=Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),n=Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!xt(null===(t=i[e].metadata)||void 0===t?void 0:t.payload)}).map(e=>{var t;return[e,null===(t=i[e].metadata)||void 0===t?void 0:t.payload]}));return ct(ct({},e),{},{featureFlags:t,featureFlagPayloads:n})}return e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e,r),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(!l)return;const u=e.requestId,d=e.evaluatedAt;if(kt(l)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const e={};if(l)for(let t=0;l.length>t;t++)e[l[t]]=!0;return{[p]:l,[y]:e,[m]:!1}}let h=l,_=c,b=a;if(null==s?void 0:s.partialResponse){const e=Object.keys(h),s=_||{};h=ct(ct({},t),h),_=ct(ct({},i),s),e.forEach(e=>{e in s||null==_||delete _[e]}),b=ct(ct({},n),b)}else if(e.errorsWhileComputingFlags)if(a){const e=new Set(Object.keys(a).filter(e=>{var t;return!(null===(t=a[e])||void 0===t?void 0:t.failed)}));h=ct(ct({},t),Object.fromEntries(Object.entries(h).filter(([t])=>e.has(t))));const s=Object.fromEntries(Object.entries(_||{}).filter(([t])=>e.has(t)));_=ct(ct({},i),s),e.forEach(e=>{e in s||null==_||delete _[e]}),b=ct(ct({},n),Object.fromEntries(Object.entries(b||{}).filter(([t])=>e.has(t))))}else h=ct(ct({},t),h),_=ct(ct({},i),_),b=ct(ct({},n),b);return ct(ct({[p]:Object.keys(eE(h)),[y]:h||{},[C]:_||{},[g]:b||{},[m]:!0===e.minimalFlagCalledEvents},u?{[v]:u}:{}),d?{[f]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(n)if(!1===(null==i?void 0:i.persist)){const e=!xt(this._client.kv.get(y));this._bootstrapState=n,e||this._set(n)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(n,e,!!(null==i?void 0:i.partialResponse)),this._set(n);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}override(e,t=!1){this._logger.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._overrideFeatureFlags(e)}_overrideFeatureFlags(e){if(this._client){if(!1===e)return this._remove([E,T]),this._fireFeatureFlagsCallbacks(),void QC.info("All overrides cleared");if(kt(e))return this._set({[E]:XC(e)}),this._fireFeatureFlagsCallbacks(),void QC.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t;const i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);const n={},s=i.flags,r=i.payloads;return s&&(n[E]=kt(s)?XC(s):s),r&&(n[T]=r),Object.keys(n).length&&this._set(n),!1===s&&!1===r?this._remove([E,T]):!1===s?this._remove(E):!1===r&&this._remove(T),this._fireFeatureFlagsCallbacks(),!1===s?QC.info("Flag overrides cleared"):s&&QC.info("Flag overrides set",{flags:s}),void(!1===r?QC.info("Payload overrides cleared"):r&&QC.info("Payload overrides set",{payloads:r}))}if(e&&"object"==typeof e)return this._set({[E]:e}),this._fireFeatureFlagsCallbacks(),void QC.info("Flag overrides set",{flags:e});this._logger.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this._logger.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var n;const s=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),r={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:r};s&&(o.$early_access_feature_name=s.name),i&&(o.$feature_enrollment_stage=i);const a=ct(ct({},this.getFlagVariants()),{},{[e]:t});null===(n=this._crossTabPersistence)||void 0===n||n.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(r)}),this._set({[p]:Object.keys(eE(a)),[y]:a,[S]:ct(ct({},this._prop("$stored_person_properties")||{}),r)}),this._fireFeatureFlagsCallbacks();try{var l;null===(l=this._client)||void 0===l||l.capture("$feature_enrollment_update",o)}catch(e){this._logger.error("Failed to capture early access feature enrollment",e)}}getEarlyAccessFeatures(e,t=!1,i){const n=this._prop(h);!n||t?this._getEarlyAccessFeatures(e,i):e(n)}_getEarlyAccessFeatures(e,t){var i=this;return rt(function*(){const n=i._client;if(!n)return;const s=t?`&${t.map(e=>`stage=${e}`).join("&")}`:"";let r;try{const e=yield n.sendRequest(`/api/early_access_features/?token=${n.projectToken}${s}`,{target:"api",method:"GET",sentAt:"query"});if(!e.json)return;r=e.json.earlyAccessFeatures,i._set({[h]:r})}catch(e){return void i._logger.error("Early access feature request failed",e)}try{e(r)}catch(e){i._logger.error("Early access feature callback failed",e)}})()}_prepareFeatureFlagsForCallbacks(){const 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){this._rebuildEventProperties();const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks(),n=this._firingFeatureFlagsCallbacks;this._firingFeatureFlagsCallbacks=!0,this.featureFlagEventHandlers.forEach(n=>{try{n(t,i,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}}),this._firingFeatureFlagsCallbacks=n}setPersonPropertiesForFlags(e,t=!0){this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t=!0){const i=this._prop("$stored_person_properties")||{},n=(null==e?void 0:e.$set)||((null==e?void 0:e.$set_once)?{}:e),s=null==e?void 0:e.$set_once,r={};if(s)for(const e in s)({}).hasOwnProperty.call(s,e)&&(e in i||(r[e]=s[e]));this._set({[S]:ct(ct(ct({},i),r),n)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const i=ct({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[S]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this._remove(S),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const i=this._prop("$stored_group_properties")||{},n=ct({},i);for(const t of Object.keys(e))n[t]=ct(ct({},i[t]),e[t]);this._set({[b]:n}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this._prop("$stored_group_properties")||{};this._set({[b]:ct(ct({},t),{},{[e]:{}})})}else this._remove(b)}reset(){this._requestGeneration++,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._additionalReloadRequested=!1,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._bootstrapState=void 0,this._hasLoadedFlags=!1,this._reloadingDisabled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0,this._flagCallsPendingCapture=new Map}};const nE=Br("[FeatureFlags]");var sE=class{constructor(e,t=!1){this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,n,s,r,o,a,l,c;return{bootstrap:{featureFlags:null!==(i=null===(n=e.bootstrap)||void 0===n?void 0:n.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(s=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==s?s:void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=e.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:xt(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(a=e.feature_flag_request_max_retries)&&void 0!==a?a:1),compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(c=e.evaluation_contexts)&&void 0!==c?c:e.evaluation_environments)&&void 0!==l?l:[],flagKeys:kt(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(nE.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),xt(e.flag_keys)||kt(e.flag_keys)||nE.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}},rE=class extends iE{constructor(e){const t=new sE(e.config,e._shouldDisableFlags());super(t),this.name=Jy,this._instance=e,this._mutableConfigSource=t}get _crossTabPersistence(){return this._instance.persistence}updateConfig(e,t){this._mutableConfigSource.update(e,t),this._onConfigUpdated()}};const oE="Refusing to render web experiment since the viewer is a likely bot",aE={ADD_ATTR:(e,t)=>"target"===e&&"a"===t||"form"===e&&/^(button|fieldset|input|output|select|textarea)$/.test(t),ADD_URI_SAFE_ATTR:["form"]};let lE;const cE={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>hc(t,e),not_regex:(e,t)=>!hc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},uE=Br("[Conversations]"),dE="Conversations not available yet.";function hE(e,t){var i,n,s,r,o,a,l;const c=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,u=null!==(n=null==e?void 0:e.maxBufferSize)&&void 0!==n?n:100,d=(null==t?void 0:t.consoleCapture)?void 0:null!==(s=null==e?void 0:e.maxLogsPerInterval)&&void 0!==s?s:1e3,h=xt(d)?Math.max(u,2048):Math.max(u,d),p=ct(ct({},function(){let e="",t="";try{var i;const n="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,s=null==n||null===(i=n.navigator)||void 0===i?void 0:i.userAgent;s&&([e,t]=Qi(s))}catch(e){}return function(e,t){const i=function(e){if(e)return{}.hasOwnProperty.call(hr,e)?hr[e]:e}(e);return ct(ct({},i?{"os.name":i}:{}),t?{"os.version":t}:{})}(e,t)}()),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==p?void 0:p["service.name"])&&void 0!==o?o:null==e?void 0:e.serviceName)&&void 0!==r?r:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(a=null==p?void 0:p["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==p?void 0:p["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:p,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:h,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const pE=["debug","log","warn","error","info"],gE="console",_E="__posthogHandledLogsRequestError",fE=(e,t)=>{const i=e instanceof Error?e:new Error(t);return i[_E]=!0,i},vE=e=>!!e&&"object"==typeof e&&!0===e[_E];var mE=class{get _coreLogger(){return ct(ct({},this._logger),{},{error:(...e)=>{e.some(vE)||this._logger.error(...e)}})}constructor(e,t){var i;this._configSource=e,this._getSdkContext=t,this.name="logs",this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=Br("[logs]"),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._setupStarted=!1,this._disposed=!1,this._consoleBuffer=[],this._consoleRecorderUnpatchers=[],this._isRecordingConsole=!1,this._isRecordingConsoleEntry=!1,this._listeningForReconnect=!1,this._onReconnect=()=>{var e,t;this._disposed||(this._consecutiveStatusZeroFailures=0,null===(e=this._core)||void 0===e||e.onReconnect(),null===(t=this._consoleCore)||void 0===t||t.onReconnect())},this._isLogsEnabled=!!(null===(i=e.get())||void 0===i?void 0:i.captureConsoleLogs)}get _isRequestReady(){return!0}_getConsoleLoader(){}_listenForReconnect(){if(!this._listeningForReconnect){try{this._window=typeof window>"u"?void 0:window}catch(e){this._window=void 0}this._window&&(Kr(this._window,"online",this._onReconnect),this._listeningForReconnect=!0)}}_buildCore(e,t,i,n){this._listenForReconnect();const s=hE(this._configSource.get(),i);return[new wr(this._createHost(e,t),s,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,n),s]}_getCore(){const e=this._configSource.get();var t;return this._core&&this._resolvedFrom===e||(null===(t=this._core)||void 0===t||t.reset(),this._resolvedFrom=e,[this._core,this._resolvedConfig]=this._buildCore(()=>this._queue,e=>{this._queue=e})),this._core}_getConsoleCore(){const e=this._configSource.get();var t;return this._consoleCore&&this._consoleResolvedFrom===e||(null===(t=this._consoleCore)||void 0===t||t.reset(),this._consoleResolvedFrom=e,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},gE)),this._consoleCore}setup(e){if(!this._disposed&&!this._setupStarted)return this._setupStarted=!0,this._client=e,this._logger=e.logger.createLogger("[logs]"),Oy(e.kv.initialize(),()=>{this._disposed||this._finishSetup(e)})}_finishSetup(e){var t;this._listenForReconnect(),(null===(t=this._configSource.get())||void 0===t?void 0:t.captureConsoleLogs)&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._configSource.remoteConfigWillArrive&&e.kv.get(this._configSource.captureHintKey))&&this._startConsoleRecorder();let i=!1;const n=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?n.dispose():(this._remoteConfigSubscription=n,i||this.loadIfEnabled())}dispose(){var e,t,i,n,s,r,o;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null===(t=this._window)||void 0===t||t.removeEventListener("online",this._onReconnect),null===(i=this._consoleLogsDispose)||void 0===i||i.call(this),this._consoleLogsDispose=void 0,null===(n=this._core)||void 0===n||n.clearQueue(),null===(s=this._consoleCore)||void 0===s||s.clearQueue(),null===(r=this._core)||void 0===r||r.reset(),null===(o=this._consoleCore)||void 0===o||o.reset())}onRemoteConfig(e){var t,i;if(this._disposed)return;const n=e.ok?null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs:void 0;Mt(n)?this._stopRecorderStartedByPersistedHint():(null===(i=this._client)||void 0===i||i.kv.set(this._configSource.captureHintKey,!!n),n?(this._isLogsEnabled=!0,this._isLoaded||this._startConsoleRecorder(),this.loadIfEnabled()):this._stopRecorderStartedByPersistedHint())}reset(){var e,t,i,n;this._stopConsoleRecorder(),null===(e=this._core)||void 0===e||e.clearQueue(),this._queue=[],null===(t=this._core)||void 0===t||t.reset(),null===(i=this._consoleCore)||void 0===i||i.clearQueue(),this._consoleQueue=[],null===(n=this._consoleCore)||void 0===n||n.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){!this._disposed&&this._client&&this._getCore().captureLog(e)}captureConsoleLog(e){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e)}captureBufferedConsoleLog(e,t,i){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e,{context:t,occurredAtMs:i})}_onOptOut(){var e;this._stopConsoleRecorder(),null===(e=this._consoleCore)||void 0===e||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e;if(this._isRecordingConsole||!(null===(e=this._window)||void 0===e?void 0:e.console))return;const t=hE(this._configSource.get()).maxBufferSize;let i=!0;this._consoleRecorderUnpatchers.push(()=>{i=!1});for(const e of pE){let n;try{n=Eb(this._window.console[e])}catch(e){continue}n&&this._consoleRecorderUnpatchers.push(Mg(this._window.console,e,s=>{const r=(...n)=>{try{i&&this._recordConsoleEntry(e,n,t)}catch(e){}return s.apply(this._window.console,n)};return r.__rrweb_original__=n,r}))}this._isRecordingConsole=!0,this._consoleRecorderTimeout=setTimeout(()=>{this._stopConsoleRecorder()},3e4)}_recordConsoleEntry(e,t,i){var n;if(this._isRecordingConsole&&!this._isRecordingConsoleEntry&&0!==t.length)if(null===(n=this._client)||void 0===n?void 0:n.canCapture){if(i>this._consoleBuffer.length){this._isRecordingConsoleEntry=!0;try{this._consoleBuffer.push({level:e,args:t,occurredAtMs:Date.now(),context:this._getSdkContext()})}finally{this._isRecordingConsoleEntry=!1}}}else this._stopConsoleRecorder()}_stopConsoleRecorder(){if(this._consoleBuffer=[],this._isRecordingConsole){this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0);for(const e of this._consoleRecorderUnpatchers)e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){const e=this._consoleBuffer;return this._stopConsoleRecorder(),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){this._client&&(e?this._flushViaTransport(e):(this._core&&this._core.flush().catch(e=>this._logFlushError(e)),this._consoleCore&&this._consoleCore.flush().catch(e=>this._logFlushError(e))))}flush(){var e=this;return rt(function*(){var t,i;const n=null===(t=e._core)||void 0===t?void 0:t.flush().catch(t=>e._logFlushError(t)),s=null===(i=e._consoleCore)||void 0===i?void 0:i.flush().catch(t=>e._logFlushError(t));yield n,yield s})()}_logFlushError(e){vE(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._disposed||!this._isLogsEnabled||this._isLoaded||this._isLoading)return;const e=this._getConsoleLoader();if(e){this._isLoading=!0;try{e((e,t)=>{if(this._isLoading=!1,!this._disposed&&this._isLogsEnabled)if(e||!t)this._logger.error("Could not load logs script",e),this._stopConsoleRecorder();else{const e=this._takeConsoleBuffer();this._consoleLogsDispose=t.initialize(this._client),this._isLoaded=!0,e.length>0&&t.replay(this._client,e)}})}catch(e){throw this._isLoading=!1,e}}else this._stopConsoleRecorder()}_createHost(e,t){const i=this._client;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:t=>t===ut.LogsQueue?e():void 0,setPersistedProperty(e,i){e===ut.LogsQueue&&t(null!=i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}_sendLogsBatch(e){return new Promise(t=>{if(Xr(this._consecutiveStatusZeroFailures,3))return void t({kind:"fatal",error:fE(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1;const n=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),n({kind:"retry-later",error:fE(void 0,"logs request timed out")})},9e4),r=this._isRequestReady;this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:e,compression:"best-available",timeoutMs:6e4}).then(e=>{var t;const i=e.statusCode;this._trackEndpointReachability(i,r),i>=200&&300>i?n({kind:"ok"}):413===i?n({kind:"too-large"}):0!==i&&408!==i&&429!==i&&500>i?n({kind:"fatal",error:new Error(`logs request failed with status ${i}`)}):0===i?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),n({kind:"retry-later",error:fE(e.error,"logs request failed before receiving an HTTP response")})):n({kind:"retry-later",error:null!==(t=e.error)&&void 0!==t?t:new Error(`logs request failed with status ${i}`)})},e=>{n({kind:"retry-later",error:e})})})}_trackEndpointReachability(e,t){(0!==e||t)&&(this._consecutiveStatusZeroFailures=eo(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,this._client.library.name,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,gE,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,n,s){if(0===t.length)return;const r=t.map(e=>e.record);s([]);const o=mr(r,vr(i,this._client.library.name,this._client.library.version),n,this._client.library.version);this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:o,compression:"best-available",transport:e,timeoutMs:6e4}).catch(e=>this._logFlushError(e))}};const yE=Br("[NetworkMetrics]"),bE={"http:":80,"https:":443},SE=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),wE=(e,t)=>{var i;const n=String(t);return{method:String(e).toUpperCase(),url:(null===(i=Yr(n))||void 0===i?void 0:i.href)||n}},kE=(e,t,i,n,s,r,o=!1)=>{try{var a,l;const c=s();if(!c)return;const u=i||void 0,d=mb()-n,h=Yr(t.url);if(h&&"http:"!==h.protocol&&"https:"!==h.protocol)return;const p={url:(null==h?void 0:h.href)||t.url,method:t.method},g=Ct(c.name)?c.name(p):It(c.name)?c.name:"http.client.request.duration";if(!g)return;const _=o&&!u?void 0:((e,t)=>e?400>e?void 0:String(e):(null==t?void 0:t.name)||"_OTHER")(u,r),f=ct(ct(ct(ct(ct({},(e=>{const t=SE.has(e)?e:"_OTHER";return ct({"http.request.method":t},"_OTHER"===t&&e!==t?{"http.request.method_original":e}:{})})(p.method)),h?(e=>{return{"server.address":e.hostname.startsWith("[")&&e.hostname.endsWith("]")?e.hostname.slice(1,-1):e.hostname,"server.port":Number(e.port)||bE[e.protocol],"url.scheme":e.protocol.slice(0,-1),"url.template":(t=e.pathname,t.split("/").map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?":id":e).join("/"))};var t})(h):{}),u?{"http.response.status_code":u}:{}),_?{"error.type":_}:{}),null===(a=c.attributes)||void 0===a?void 0:a.call(c,p,{status:u,durationMs:d}));null===(l=e.metrics)||void 0===l||l.histogram(g,d,{unit:"ms",attributes:f})}catch(e){yE.error("Failed to record network metric",e)}},CE=()=>{},EE=(t,i)=>Ct(null==e?void 0:e.fetch)?Mg(e,"fetch",e=>function(...n){const s=mb(),r=e.apply(this,n);if(!i())return r;try{var o,a,l;const[e,c]=n,u=wE(null!==(o=null!==(a=null==c?void 0:c.method)&&void 0!==a?a:null==e?void 0:e.method)&&void 0!==o?o:"GET",null!==(l=null==e?void 0:e.url)&&void 0!==l?l:e);return r.then(e=>(kE(t,u,null==e?void 0:e.status,s,i,void 0,!0),e),e=>{throw kE(t,u,void 0,s,i,e),e})}catch(e){return yE.error("Failed to observe fetch",e),r}}):CE,TE=(t,i)=>{var n;const s=null==e||null===(n=e.XMLHttpRequest)||void 0===n?void 0:n.prototype;if(!s)return CE;const r=new WeakMap,o=Mg(s,"open",e=>function(...t){try{(()=>Xy.has(this))()||r.set(this,wE(t[0],t[1]))}catch(e){yE.error("Failed to observe XHR open",e)}return e.apply(this,t)}),a=Mg(s,"send",e=>function(...n){let s;try{const e=r.get(this);if(e&&i()){const n=mb();s=()=>{this.removeEventListener("loadend",s),kE(t,e,this.status,n,i)},Kr(this,"loadend",s)}}catch(e){yE.error("Failed to observe XHR send",e)}try{return e.apply(this,n)}catch(e){throw s&&this.removeEventListener("loadend",s),e}});return()=>{o(),a()}},xE=new WeakMap,IE=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),RE={maxStringLength:2048,truncationSuffix:"..."},PE={maxStringLength:2048,truncationSuffix:"..."};function ME(e){if(e)return!0===e?{intent:!0,model:!0}:{intent:!1!==e.intent,model:!1!==e.model}}function FE(e,t){return{}.hasOwnProperty.call(e,t)}function AE(e,t){const i=Object.create(e);return t&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:t}),i}function LE(e,t,i=!1){if(!It(e))return;const n=e.trim();return n?(i?tr(n,RE):n).slice(0,t):void 0}function OE(e){try{return Et(e)&&!0===e.isError}catch(e){return!1}}function DE(e){return tr(e||"Unknown error",PE).slice(0,2048)}function $E(e,t){try{return DE(t?function(e){try{if(!Et(e)||!kt(e.content))return;return e.content.filter(e=>Et(e)&&"text"===e.type&&It(e.text)).map(e=>e.text).join(" ").trim()||void 0}catch(e){return}}(e):Et(e)&&It(e.message)?e.message:It(e)?e:String(e))}catch(e){return"Unknown error"}}function NE(e,t,i){return t.errorResult?[{type:"Error",value:i,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:e.buildProperties(t.error,{handled:!0}).$exception_list.map(e=>ct(ct({},e),{},{value:DE(e.value)}))}function BE(e,t){if(t)return"Error";try{if(!Et(e))return"Error";let t=It(e.name)?e.name.trim():"";const i=e.constructor;return t&&"Error"!==t||!Ct(i)||"Error"===i.name||(t=i.name),(t||"Error").slice(0,256)}catch(e){return"Error"}}function qE(e,t){return{message:$E(e,t),type:BE(e,t)}}EC.__defaultExtensionClasses=ct({},((...e)=>Ur({},...e))({featureFlags:rE},{sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!!(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.isStarted)}get status(){var e,t;return"awaiting_config"===this._recordingStatus||"missing_config"===this._recordingStatus?this._recordingStatus:null!==(e=null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=ha,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var t,i;if(!(null==n?void 0:n.visibilityState)||"visible"===n.visibilityState)return!0;const s=null==e||null===(t=e.performance)||void 0===t||null===(i=t.getEntriesByType)||void 0===i?void 0:i.call(t,"visibility-state");return!(null==s?void 0:s.length)||s.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e,t;"visible"===(null==n?void 0:n.visibilityState)&&(this._documentWasEverVisible=!0,null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.setDocumentWasEverVisible)||void 0===t||t.call(e,!0))},!this._instance.sessionManager)throw OC.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this._config.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==n?void 0:n.addEventListener)&&Kr(n,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this._sessionRecordingDisposed=!0,null==n||null===(t=n.removeEventListener)||void 0===t||t.call(n,"visibilitychange",this._onVisibilityChange),e?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var t;const i=!!(null===(t=this._instance.get_property("$session_recording_remote_config"))||void 0===t?void 0:t.enabled),n=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return e&&i&&n&&!s}startIfEnabledOrStop(e){var t;if(this._sessionRecordingDisposed)return;if(this._isRecordingEnabled&&(null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.isStarted))return;const i=!xt(Object.assign)&&!xt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),OC.info("starting")):(this._recordingStatus=ha,this.stopRecording())}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=va),(null==d||null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.rrweb)||void 0===t?void 0:t.record)&&(null===(i=d.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))this._onScriptLoaded(e);else{var n,s;const t=this._instance.sessionManager;null===(n=d.__PosthogExtensions__)||void 0===n||null===(s=n.loadExternalDependency)||void 0===s||s.call(n,this._instance,this._scriptName,i=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===t)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),OC.error("could not load recorder",i)):void this._onScriptLoaded(e);this._recordingStatus="disabled"})}}stopRecording(){var e,t;null===(e=this._persistFlagsOnSessionListener)||void 0===e||e.call(this),this._persistFlagsOnSessionListener=void 0,null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.stop()}_discardRecording(e=!1){var t,i;null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=void 0,null===(i=this._lazyLoadedSessionRecording)||void 0===i||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null===(e=this._persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._persistence)||void 0===t||t.unregister("$replay_sample_rate")}_validateSampleRate(e,t){if(Mt(e))return null;const i=Ft(e)?e:parseFloat(e);return"number"!=typeof(n=i)||!Number.isFinite(n)||0>n||n>1?(OC.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var n}_persistRemoteConfig(e){if(this._persistence){var t,i;const n=this._persistence,s=()=>{var t;const i=!1===e.sessionRecording?void 0:e.sessionRecording,s=this._validateSampleRate(null===(t=this._config.session_recording)||void 0===t?void 0:t.sampleRate,"session_recording.sampleRate"),r=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=s?s:r;Mt(o)&&this._resetSampling();const a=null==i?void 0:i.minimumDurationMilliseconds;n.register({[ie]:ct(ct({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:ct({capturePerformance:e.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:xt(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};s(),null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.onSessionId(s)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):("awaiting_config"===this._recordingStatus&&(this._recordingStatus="missing_config",this._instance.register_for_session({[Be]:!0}),OC.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.log)?this._lazyLoadedSessionRecording.log(e,t):OC.warn("log called before recorder was ready")}get _scriptName(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.get_property(ie);return(null==i||null===(t=i.scriptConfig)||void 0===t?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){const e=this._instance.get_property(ie);if(!e)return!1;let t;try{t="object"==typeof e?e:JSON.parse(e)}catch(e){return OC.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!Mt(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_onScriptLoaded(e){var t,i,n;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(!(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.initSessionRecording))return OC.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Ne]:!0});var s;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null===(s=d.__PosthogExtensions__)||void 0===s?void 0:s.initSessionRecording(this._instance,this._documentWasEverVisible),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if("missing_config"===this._recordingStatus||"awaiting_config"===this._recordingStatus)return;return this._recordingStatus="awaiting_config",OC.info("persisted remote config is stale, requesting fresh config before starting"),void new Ok(this._instance).load()}this._recordingStatus=va,null===(i=(n=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||void 0===i||i.call(n,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=ha}onRRwebEmit(e){var t,i;null===(t=this._lazyLoadedSessionRecording)||void 0===t||null===(i=t.onRRwebEmit)||void 0===i||i.call(t,e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_linked_flag:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_sampling:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null===(i=this._persistence)||void 0===i||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const e of DC){var i;const n=null===(i=this._instance.sessionPersistence)||void 0===i?void 0:i.get_property(e);xt(n)||(t[e]=n)}return ct(ct({},t),(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var i;return!!(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.flushBeforeIdentityReset)||void 0===t||t.call(e)}}},{autocapture:class extends Ky{constructor(e){super(new xC(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._isFlushingPageview=!1,this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(Nr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this._lastLocation=this._getCurrentLocation(),this.startIfEnabled()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,this._hashchangeListener&&this._hashchangeListener(),this._hashchangeListener=void 0,Nr.info("History API monitoring stopped")}monitorHistoryChanges(){e&&e.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(t){var i;if(!e||(null===(i=e.history[t])||void 0===i?void 0:i.__posthog_wrapped__))return;const n=this;Mg(e.history,t,i=>function(s,r,o){var a;n._isUrlChanging(o)&&n._flushPendingPageview(),i.call(this,s,r,o),n._capturePageview(t,!n._isFlushingPageview&&"popstate"!==(null==e||null===(a=e.event)||void 0===a?void 0:a.type))})}_getCurrentLocation(){const t=null==e?void 0:e.location;if(null==t?void 0:t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}_getCaptureOptions(){const e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:Et(e)?e:{}}_shouldCaptureHashChanges(e=this._getCaptureOptions()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){const t=this._getCaptureOptions(),i=this._lastLocation;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this._shouldCaptureHashChanges(t)&&e.hash!==i.hash))}_capturePageview(e,t=!1){try{t||this._flushPendingPageview();const i=this._getCurrentLocation();if(!i)return;if(this._hasLocationChanged(i)){const i=()=>this._instance.capture(et,{navigation_type:e});t?(this._pendingPageview=i,Promise.resolve().then(()=>this._flushPendingPageview())):i()}this._lastLocation=i}catch(t){Nr.error(`Error capturing ${e} pageview`,t)}}_isUrlChanging(t){var i,n;return!(Mt(t)||!e)&&(null===(i=Yr(String(t)))||void 0===i?void 0:i.href)!==(null===(n=e.location)||void 0===n?void 0:n.href)}_flushPendingPageview(){const e=this._pendingPageview;if(e){this._pendingPageview=void 0,this._isFlushingPageview=!0;try{e()}catch(e){Nr.error("Error capturing deferred pageview",e)}finally{this._isFlushingPageview=!1}this._lastLocation=this._getCurrentLocation()}}_setupPopstateListener(){if(this._popstateListener)return;const t=()=>{this._capturePageview("popstate")};Kr(e,"popstate",t),this._popstateListener=()=>{e&&e.removeEventListener("popstate",t)}}_setupHashchangeListener(){if(this._hashchangeListener)return;const t=()=>{this._capturePageview("hashchange")};Kr(e,"hashchange",t),this._hashchangeListener=()=>{e&&e.removeEventListener("hashchange",t)}}},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)||void 0===t?void 0:t.props[G]),this.rageclicks=new By(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return Et(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Mt(this._config.capture_heatmaps)?Mt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;$C.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[G]:i}),this._enabledServerSide=i,this.startIfEnabled()}getAndClearBuffer(){const e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){NC(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval="visible"===(null==n?void 0:n.visibilityState)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){e&&n&&(this._flushHandler=this._flush.bind(this),Kr(e,Xe,this._flushHandler),this._onClickHandler=t=>this._onClick(t||(null==e?void 0:e.event)),Kr(n,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=t=>this._onMouseMove(t||(null==e?void 0:e.event)),Kr(n,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new ok(this.instance,sk,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Kr(n,x,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var t;e&&n&&(this._flushHandler&&e.removeEventListener(Xe,this._flushHandler),this._onClickHandler&&n.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&n.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&n.removeEventListener(x,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null===(t=this._deadClicksCapture)||void 0===t||t.stop(),this._initialized=!1)}_getProperties(t,i){const n=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(t,i,n){let s=t;for(;s&&uo(s)&&!ho(s,"body");){if(s===n)return!1;let t;try{var r,o,a;t=null===(r=null!==(o=null===(a=s.ownerDocument)||void 0===a?void 0:a.defaultView)&&void 0!==o?o:e)||void 0===r?void 0:r.getComputedStyle(s).position}catch(e){return!1}if(ft(i,t))return!0;s=Co(s)}return!1}(bo(t),["fixed","sticky"],r);return{x:t.clientX+(o?0:s),y:t.clientY+(o?0:n),target_fixed:o,type:i}}_onClick(e,t="click"){var i;if(co(e.target)||!NC(e))return;const n=this._getProperties(e,t);(null===(i=this.rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&No(bo(e),this.instance.config.rageclick)&&this._capture(ct(ct({},n),{},{type:"rageclick"})),this._capture(n)}_onMouseMove(e){!co(e.target)&&NC(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(t){if(!e)return;const i=this._config.disable_capture_url_hashes?cn(e.location.href):e.location.href,n=this._config.custom_personal_data_properties,s=this._config.mask_personal_data_properties?[...Tc,...n||[]]:[],r=ro(i,s,Ic);this._buffer=this._buffer||{},this._buffer[r]||(this._buffer[r]=[]),this._buffer[r].push(t)}_flush(){this._buffer&&!Tt(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ok,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=(e=!1)=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",ct({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>ct(ct({},e),{},{[`$web_vitals_${t.name}_event`]:ct({},t),[`$web_vitals_${t.name}_value`]:t.value}),{})),e?{transport:"sendBeacon",send_instantly:!0}:void 0),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Mt(null==e?void 0:e.name)||Mt(null==e?void 0:e.value))return void PC.error("Invalid metric received",e);const i="string"==typeof e.navigationURL?e.navigationURL:void 0,n=this._maskedURL(i);if(xt(n))return;const s=Ft(e.navigationId)||"string"==typeof e.navigationId?`navigation:${e.navigationId}`:`url:${n}`;if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void PC.error("Ignoring metric with value >= "+this._maxAllowedValue,e);this._buffer.navigationKey!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),xt(this._buffer.navigationKey)&&(this._buffer.navigationKey=s,this._buffer.url=n),this._buffer.firstMetricTimestamp=xt(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;const r=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0),o=ct(ct(ct({},e),i?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete o.entries,Et(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){const t={};for(const i of LC){const n="url"===i&&"string"==typeof e.attribution[i]?this._maskedURL(e.attribution[i]):e.attribution[i];xt(n)||(t[i]=n)}o.attribution=t}else delete o.attribution;xt(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this._buffer.metrics.push(o),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()},this._startCapturing=()=>{if(this._initialized)return;let t,i,n,s,r=!1;const o=d.__PosthogExtensions__,a=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(null==a?void 0:a[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&xt(a)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!xt(l)){const e=l.withoutAttribution,o=this.attributionMetrics;r=!xt(e),t=o.indexOf("LCP")>-1?l.onLCP:(null==e?void 0:e.onLCP)||l.onLCP,i=o.indexOf("CLS")>-1?l.onCLS:(null==e?void 0:e.onCLS)||l.onCLS,n=o.indexOf("FCP")>-1?l.onFCP:(null==e?void 0:e.onFCP)||l.onFCP,s=o.indexOf("INP")>-1?l.onINP:(null==e?void 0:e.onINP)||l.onINP}if(!(t&&i&&n&&s))return void PC.error("web vitals callbacks not loaded - not starting");const c={reportSoftNavs:this.useSoftNavs},u=r&&this.attributionMetrics.indexOf("INP")>-1?ct(ct({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&t(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&n(this._addToBuffer.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this),u);const h=null==e?void 0:e.document;Kr(h,x,()=>{"hidden"===(null==h?void 0:h.visibilityState)&&this._flushToCapture(!0)}),Kr(e,"pagehide",()=>this._flushToCapture(!0)),this._initialized=!0},this._enabledServerSide=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[Y]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const i=Et(this._perfConfig)?null===(e=this._perfConfig)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return Mt(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props.$web_vitals_allowed_metrics)||FC:i}get flushToCaptureTimeoutMs(){return(Et(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=Et(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return Lt(e)?e?FC:[]:kt(e)?e:AC}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=Et(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){const e=Et(this._perfConfig)&&Ft(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:MC;return e>0&&6e4>=e?MC:e}get isEnabled(){const e=null==s?void 0:s.protocol;if("http:"!==e&&"https:"!==e)return PC.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=Et(this._perfConfig)?this._perfConfig.web_vitals:Lt(this._perfConfig)?this._perfConfig:void 0;return Lt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(PC.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const i=Et(t.capturePerformance)&&!!t.capturePerformance.web_vitals,n=Et(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Y]:i}),this._instance.persistence.register({[te]:n})),this._enabledServerSide=i,this.startIfEnabled()}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t;const i=d.__PosthogExtensions__,n=this._callbackFlavor,s=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;(null==s?void 0:s[n])||"web-vitals"===n&&xt(s)&&(null==i?void 0:i.postHogWebVitalsCallbacks)?e():null==i||null===(t=i.loadExternalDependency)||void 0===t||t.call(i,this._instance,n,t=>{t?PC.error("failed to load script",t):e()})}_maskedURL(t){const i=t||(null==e?void 0:e.location.href);if(!i)return void PC.error("Could not determine current URL");const n=this._instance.config.disable_capture_url_hashes?cn(i):i,s=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Tc,...s||[]]:[];return ro(n,r,Ic)}}},{exceptionObserver:class{constructor(t){var i;this._startCapturing=()=>{var t;if(!e||!this.isEnabled||!(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions))return;const i=d.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=d.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=d.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=i(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=n(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){IC.error("failed to start",e),this._stopCapturing()}},this._instance=t,this._remoteEnabled=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[Q]),this._rateLimiter=new Jt(ct(ct({},function(e={}){var t,i,n,s;return{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(n=null!==(s=e.exceptionRateLimiterBucketSize)&&void 0!==s?s:e.__exceptionRateLimiterBucketSize)&&void 0!==n?n:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,_logger:IC})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Et(e)?t=ct(ct({},t),e):(xt(e)?this._remoteEnabled:e)&&(t=ct(ct({},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?(IC.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"exception-autocapture",t=>{if(t)return IC.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null===(e=this._unwrapOnError)||void 0===e||e.call(this),this._unwrapOnError=void 0,null===(t=this._unwrapUnhandledRejection)||void 0===t||t.call(this),this._unwrapUnhandledRejection=void 0,null===(i=this._unwrapConsoleError)||void 0===i||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Q]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,n;const s=null!==(t=null==e||null===(i=e.$exception_list)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(s))return void IC.info("Skipping exception capture because of client rate limiting.",{exception:s});null===(n=this._instance.exceptions)||void 0===n||n.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=zb(),this._instance=e,this._suppressionRules=null!==(t=null===(i=this._instance.persistence)||void 0===i?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=is(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new ns(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=is(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,n;if(!e.ok)return;const s=e.config;if(!("errorTracking"in s))return;const r=null!==(t=null===(i=s.errorTracking)||void 0===i?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null===(n=s.errorTracking)||void 0===n?void 0:n.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[K]:this._suppressionRules,[J]:o})}get _captureExtensionExceptions(){var e;const t=!!this._instance.get_property(J),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 Nb.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:i,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};const t=[];return{sanitizedProperties:Object.keys(e).reduce((i,n)=>es.has(n)?(t.push(n),i):(i[n]=e[n],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t));n.length>0&&Nb.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(ct({[Zn]:e,[Xn]:(new Date).toISOString()},i))}catch(e){Nb.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Nb.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 Nb.info("Skipping exception capture because it was thrown by an extension");if(!this._captureExtensionExceptions&&this._isInjectedBrowserScriptException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by an injected browser script"),void Nb.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Nb.info("Skipping exception capture because it was thrown by the PostHog SDK")}const i=this._exceptionStepsConfig.enabled&&Mt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,n=function(){if("u">typeof process){var e;const t=null===(e=process.env.POSTHOG_RELEASE_ID)||void 0===e?void 0:e.trim();if(t)return t}const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();n&&(i.$release_id=n);try{const e=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return e&&this._exceptionStepsBuffer.clear(),e}catch(e){return $b(e)||Nb.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void($b(e)||Nb.error("Failed to process exception event. Ignoring this exception.",e))}}_addBufferedExceptionSteps(e){try{const t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:ct(ct({},e),{},{$exception_steps:t})}catch(t){return Nb.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Zn]:e,[Xn]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Et(e)?ct({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null===(t=this._instance.config.error_tracking)||void 0===t?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{const t=e.reduce((e,{type:t,value:i})=>(It(t)&&t.length>0&&e.$exception_types.push(t),It(i)&&i.length>0&&e.$exception_values.push(i),e),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{const i=e.values.map(e=>{const i=gc[e.operator],n=t[e.key];if(!i||!n)return!1;const s=kt(e.value)?e.value:[e.value];return s.length>0&&i(s,n)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return Nb.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){const t=e.flatMap(e=>{var t,i;return null!==(t=null===(i=e.stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(({filename:e})=>!!e&&Hb.some(t=>e.startsWith(t)));return 0!==i.length&&(!i.every(({filename:e})=>!!e&&e.startsWith(Bb))||e.some(({type:e,value:t})=>"NoResponse"===e||It(t)&&qb.some(({value:e,exact:i})=>i?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!(null==t?void 0:t.startsWith(Bb))))}_isInjectedBrowserScriptException(e){return e.some(({value:e})=>It(e)&&Ub.some(t=>e.includes(t)))}_isPostHogException(e){if(e.length>0){var t,i,n,s;const r=null!==(t=null===(i=e[0].stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[],o=r[r.length-1];return null!==(n=null==o||null===(s=o.filename)||void 0===s?void 0:s.includes("posthog.com/static"))&&void 0!==n&&n}return!1}_isExceptionList(e){return!Mt(e)&&kt(e)}}},{productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var i,n;if(this._persistence&&this._persistence.register({[X]:!!t.productTours}),!qC(this._instance))return!this._productTourManager&&Mt(null===(i=this._persistence)||void 0===i?void 0:i.props.ph_product_tours)||BC.info("product tours disabled; stopping and clearing cached tours"),null===(n=this._productTourManager)||void 0===n||n.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&qC(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"product-tours",t=>{t?BC.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&(null===(e=d.__PosthogExtensions__)||void 0===e?void 0:e.generateProductTours)&&(this._productTourManager=d.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(kt(this._cachedTours)&&!t)return void e(this._cachedTours,{isLoaded:!0});const i=this._persistence;if(i){const n=i.props[be];if(kt(n)&&!t)return this._cachedTours=n,void e(n,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:t=>{if(!qC(this._instance))return void e([],{isLoaded:!0});const n=t.statusCode;if(200!==n||!t.json){const i=`Product Tours API could not be loaded, status: ${n}`;return 0===n?t.error||BC.warn(i):BC.error(i),void e([],{isLoaded:!1,error:i})}const s=kt(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=s,i&&i.register({[be]:s}),e(s,{isLoaded:!0})}})}getActiveProductTours(e){Mt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null===(t=this._productTourManager)||void 0===t||t.previewTour(e)})}dismissProductTour(){var e;null===(e=this._productTourManager)||void 0===e||e.dismissTour("user_clicked_skip")}nextStep(){var e;null===(e=this._productTourManager)||void 0===e||e.nextStep()}previousStep(){var e;null===(e=this._productTourManager)||void 0===e||e.previousStep()}clearCache(){var e;this._cachedTours=null,null===(e=this._persistence)||void 0===e||e.unregister("ph_product_tours")}resetTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.resetTour(e)}resetAllTours(){var e;null===(e=this._productTourManager)||void 0===e||e.resetAllTours()}cancelPendingTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.cancelPendingTour(e)}},featureFlags:rE},{siteApps:class{constructor(e){this._instance=e,this._siteAppElementPatchCount=0,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(!t)return;const 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=d._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,i,n,s,r,o,a;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[e,t]of Object.entries(u))l[e]={id:c[e],type:e,properties:t};const{$set_once:d,$set:h}=e;return{event:ct(ct({},ys(e,HC)),{},{properties:ct(ct(ct({},e.properties),h?{$set:ct(ct({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),h)}:{}),d?{$set_once:ct(ct({},null!==(n=null===(s=e.properties)||void 0===s?void 0:s.$set_once)&&void 0!==n?n:{}),d)}:{}),elements_chain:null!==(r=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_prepareElementForSiteApp(e){var t;const i=null===(t=e.tagName)||void 0===t?void 0:t.toLowerCase();if("style"===i&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(e)||(UC.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===i&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(e)||(UC.error("prepare_external_dependency_script returned null"),null)}return e}_patchSiteAppElementInsertionMethods(){var e,t,i,s,r,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const c=null==n?void 0:n.defaultView,u=null==c||null===(e=c.Node)||void 0===e?void 0:e.prototype;if(!c||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();const d=[],h=this,p=new WeakSet,g=(e,t,i)=>{if(!(null==e?void 0:e[t]))return;const n=e[t];e[t]=i(n),d.push(()=>{e[t]=n})},_=e=>{if(p.has(e))return e;const t=h._prepareElementForSiteApp(e);return t&&p.add(t),t},f=e=>e.map(e=>"string"==typeof e?e:_(e)).filter(e=>!Pt(e));return g(u,"appendChild",e=>function(t){const i=_(t);return i?e.call(this,i):t}),g(u,"insertBefore",e=>function(t,i){const n=_(t);return n?e.call(this,n,i):t}),g(u,"replaceChild",e=>function(t,i){const n=_(t);return n?e.call(this,n,i):i}),[null===(t=c.Element)||void 0===t?void 0:t.prototype,null===(i=c.Document)||void 0===i?void 0:i.prototype,null===(s=c.DocumentFragment)||void 0===s?void 0:s.prototype].forEach(e=>{g(e,"append",e=>function(...t){return e.apply(this,f(t))}),g(e,"prepend",e=>function(...t){return e.apply(this,f(t))})}),[null===(r=c.Element)||void 0===r?void 0:r.prototype,null===(o=c.CharacterData)||void 0===o?void 0:o.prototype,null===(a=c.DocumentType)||void 0===a?void 0:a.prototype].forEach(e=>{g(e,"before",e=>function(...t){return e.apply(this,f(t))}),g(e,"after",e=>function(...t){return e.apply(this,f(t))}),g(e,"replaceWith",e=>function(...t){const i=f(t);return t.length&&!i.length?void 0:e.apply(this,i)})}),g(null===(l=c.Element)||void 0===l?void 0:l.prototype,"insertAdjacentElement",e=>function(t,i){const n=_(i);return n?e.call(this,t,n):null}),this._restoreSiteAppElementPatches=()=>{d.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){let e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null===(t=this._restoreSiteAppElementPatches)||void 0===t||t.call(this)))}}_runWithPreparedSiteAppElements(e,t=!0){const i=this._patchSiteAppElementInsertionMethods();try{const n=e(i);return t&&i(),n}catch(e){throw i(),e}}setupSiteApp(e){const t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(UC.info(`Processing ${this._bufferedInvocations.length} events for site app with id ${e.id}`),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null===(i=this._stopBuffering)||void 0===i||i.call(this))};let n=!1;const s=s=>{t.errored=!s,t.loaded=!0,UC.info(`Site app with id ${e.id} ${s?"loaded":"errored"}`),n&&i()};try{const{processEvent:i}=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),s(e)}}),!1);i&&(t.processEvent=i),n=!0}catch(t){UC.error(zC+e.id,t),s(!1)}if(n&&t.loaded)try{i()}catch(i){UC.error(`Error while processing buffered events PostHog app with config id ${e.id}`,i),t.errored=!0}}_setupSiteApps(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}_onCapturedEvent(e){if(0===Object.keys(this.apps).length)return;const t=this.globalsForEvent(e);for(const i of Object.values(this.apps))try{this._runWithPreparedSiteAppElements(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})}catch(t){UC.error(`Error while processing event ${e.event} for site app ${i.id}`,t)}}onRemoteConfig(e){var t,i,n;if(null===(t=this.siteAppLoaders)||void 0===t?void 0:t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void UC.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this._stopBuffering)||void 0===i||i.call(this),!e.ok)return;const s=e.config;if(null===(n=s.siteApps)||void 0===n?void 0:n.length)if(this.isEnabled)for(const{id:e,url:t}of s.siteApps){var r,o;d[`__$$ph_site_app_${e}`]=this._instance,null===(r=d.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,t,t=>{if(t)return UC.error(zC+e,t)})}else UC.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},{surveys:class extends Ny{constructor(e){super(new wb(e))}},featureFlags:rE},{tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{const e=this._syncHostnamesForPatch();var t,i;e?(xt(this._restoreXHRPatch)&&(this._restoreXHRPatch=null===(t=d.__PosthogExtensions__)||void 0===t||null===(t=t.tracingHeadersPatchFns)||void 0===t?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),xt(this._restoreFetchPatch)&&(this._restoreFetchPatch=null===(i=d.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i,n;(null===(t=d.__PosthogExtensions__)||void 0===t?void 0:t.tracingHeadersPatchFns)?e():null===(i=d.__PosthogExtensions__)||void 0===i||null===(n=i.loadExternalDependency)||void 0===n||n.call(i,this._instance,"tracing-headers",t=>{if(t)return RC.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(){const e=this._getConfiguredHostnames();return kt(e)?(kt(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(kt(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},{toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){d.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=d.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,i=void 0,s=void 0){var r,o;if(Jr(this.instance.config))return!1;if(!e||!n)return!1;t=null!==(r=t)&&void 0!==r?r:e.location,s=null!==(o=s)&&void 0!==o?o:e.history;try{if(!i){try{e.localStorage.setItem("test","test"),e.localStorage.removeItem("test")}catch(e){return!1}i=null==e?void 0:e.localStorage}const n=WC||oo(t.hash,"__posthog")||oo(t.hash,"state");let r;const o=n?un(()=>JSON.parse(atob(decodeURIComponent(n))))||un(()=>JSON.parse(decodeURIComponent(n))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?t.hash=o.desiredHash:s?s.replaceState(s.state,"",t.pathname+t.search):t.hash="")):(r=JSON.parse(i.getItem(jC)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){const t=d.ph_load_toolbar||d.ph_load_editor;!Mt(t)&&Ct(t)?t(e,this.instance):VC.warn("No toolbar load function found")}loadToolbar(t){const i=!!(null==n?void 0:n.getElementById("__POSTHOG_TOOLBAR__"));if(!e||i)return!1;const s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=ct(ct({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(e.localStorage.setItem(jC,JSON.stringify(ct(ct({},r),{},{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var o,a;this._setToolbarState(1),null===(o=d.__PosthogExtensions__)||void 0===o||null===(a=o.loadExternalDependency)||void 0===a||a.call(o,this.instance,"toolbar",e=>{if(e)return VC.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)}),Kr(e,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(r)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},{experiments:class t{get _config(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(e=!1)=>{this.getWebExperiments(e=>{t._logInfo("retrieved web experiments from the server"),this._flagToExperiments=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;this._flagToExperiments&&(t._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=this._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e));const n=this._instance.getFeatureFlag(e.feature_flag_key);It(n)&&e.variants[n]&&this._applyVariantForFlag(e,n)}else if(e.variants)for(const i in e.variants){const n=e.variants[i];t._matchesTestVariant(n,this._instance)&&this._applyTransforms(e.name,i,n.transforms)}})},e)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t._logInfo(oE);else if(!this._config.disable_web_experiments){if(Mt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t._logInfo("applying feature flags",e),e.forEach(e=>{var t;if(this._flagToExperiments&&(null===(t=this._flagToExperiments)||void 0===t?void 0:t.has(e))){var i;const t=this._instance.getFeatureFlag(e),n=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&(null==n?void 0:n.variants[t])&&this._applyVariantForFlag(n,t)}})}}previewWebExperiment(){const e=t.getWindowLocation();if(null==e?void 0:e.search){const i=so(null==e?void 0:e.search,"__experiment_id"),n=so(null==e?void 0:e.search,"__experiment_variant");i&&n&&(t._logInfo(`previewing web experiments ${i} && ${n}`),this.getWebExperiments(e=>{this._showPreviewWebExperiment(parseInt(i),n,e)},!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);const n=this._instance.get_property("$web_experiments");if(n&&!t)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this._config.token}`),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,i,n){const s=n.filter(t=>t.id===e);s&&s.length>0&&(t._logInfo(`Previewing web experiment [${s[0].name}] with variant [${i}]`),this._applyTransforms(s[0].name,i,s[0].variants[i].transforms))}_applyVariantForFlag(e,i){const n=e.variants[i];t._matchUrlConditions(n,this._instance)?this._applyTransforms(e.name,i,n.transforms):t._logInfo(`skipping variant ${i} of experiment ${e.name} because this page does not match its url conditions`)}static _matchesTestVariant(e,i){return!Mt(e.conditions)&&t._matchUrlConditions(e,i)&&t._matchUTMConditions(e)}static _matchUrlConditions(e,i){var n;if(Mt(e.conditions)||Mt(null===(n=e.conditions)||void 0===n?void 0:n.url))return!0;const s=t.getWindowLocation();if(s){var r,o,a;const t=ao(i,s.href);return!(null===(r=e.conditions)||void 0===r?void 0:r.url)||cE[null!==(o=null===(a=e.conditions)||void 0===a?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](e.conditions.url,t)}return!1}static getWindowLocation(){return null==e?void 0:e.location}static _matchUTMConditions(e){var t;if(Mt(e.conditions)||Mt(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=Pc();if(i.utm_source){var n,s,r,o,a,l,c,u;const t=!(null===(n=e.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)||(null===(s=e.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)==i.utm_campaign,d=!(null===(r=e.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=e.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==i.utm_source,h=!(null===(a=e.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)||(null===(l=e.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)==i.utm_medium,p=!(null===(c=e.conditions)||void 0===c||null===(c=c.utm)||void 0===c?void 0:c.utm_term)||(null===(u=e.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==i.utm_term;return t&&h&&p&&d}return!1}static _logInfo(e,...t){Nr.info(`[WebExperiments] ${e}`,t)}static _logWarn(e,...t){Nr.warn(`[WebExperiments] ${e}`,t)}static _sanitizeLinkTargets(e){("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"template"===e.localName?e.content:e).querySelectorAll("a[target], template").forEach(e=>{var i;if("template"===e.localName)return void("http://www.w3.org/1999/xhtml"===e.namespaceURI&&t._sanitizeLinkTargets(e));if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||"_blank"!==(null===(i=e.getAttribute("target"))||void 0===i?void 0:i.toLowerCase()))return void e.removeAttribute("target");const n=(e.getAttribute("rel")||"").split(/\s+/).filter(e=>e&&!/^(opener|noopener)$/i.test(e));n.push("noopener"),e.setAttribute("rel",n.join(" "))})}_applyTransforms(e,i,n){this._is_bot()?t._logInfo(oE):"control"!==i?n.forEach(n=>{if(n.selector){var s;t._logInfo(`applying transform of variant ${i} for experiment ${e} `,n);const r=null===(s=document)||void 0===s?void 0:s.querySelectorAll(n.selector);if(!(null==r?void 0:r.length))return void t._logWarn(`no element on this page matches selector ${n.selector} of variant ${i} for experiment ${e}`);const o=new Map;null==r||r.forEach(e=>{if("script"===e.localName.toLowerCase())return;const i=e;if(n.html){var s;const a="http://www.w3.org/1998/Math/MathML"===e.namespaceURI&&"annotation-xml"===e.localName&&(null===(s=e.getAttribute("encoding"))||void 0===s?void 0:s.toLowerCase())||"",l=JSON.stringify([e.namespaceURI,e.localName,a]);let c=o.get(l);if(Mt(c)){var r;const i=null!==(r=lE)&&void 0!==r?r:lE=am(),s=e.ownerDocument.implementation.createHTMLDocument(""),u=s.createElementNS(e.namespaceURI,e.localName);a&&u.setAttribute("encoding",a);const d=s.createRange();d.selectNodeContents(u);const h="http://www.w3.org/2000/svg"===e.namespaceURI&&/^(foreignObject|desc|title)$/.test(e.localName)||/^(text\/html|application\/xhtml\+xml)$/.test(a)?"http://www.w3.org/1999/xhtml":e.namespaceURI,p=d.createContextualFragment(n.html);"http://www.w3.org/1998/Math/MathML"===e.namespaceURI&&/^(mi|mo|mn|ms|mtext)$/.test(e.localName)?(u.appendChild(p),i.sanitize(u,ct(ct({},aE),{},{NAMESPACE:h||void 0,IN_PLACE:!0}))):("http://www.w3.org/1999/xhtml"===u.namespaceURI&&"template"===u.localName?u.content:u).appendChild(i.sanitize(p,ct(ct({},aE),{},{NAMESPACE:h||void 0,RETURN_DOM_FRAGMENT:!0}))),t._sanitizeLinkTargets(u),c=u.innerHTML,o.set(l,c)}i.innerHTML=c}n.css&&i.setAttribute("style",n.css)})}}):t._logInfo("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?Qk(i,this._config.custom_blocked_useragents):void 0}},featureFlags:rE},{conversations:class{constructor(e){this._instance=e,this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._loadFailed=!1,this._resetGeneration=0,this._pendingPanelAction=null,this._theme=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations)return void(this._pendingPanelAction=null);if(this._remoteConfigSuccessful=e.ok,!e.ok)return;const t=e.config.conversations;Mt(t)?this._pendingPanelAction=null:(Lt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this._isConversationsEnabled||(this._pendingPanelAction=null),this.loadIfEnabled())}reset(){var e;null===(e=this._conversationsManager)||void 0===e||e.reset(),this._conversationsManager=null,this._resetGeneration++,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1,this._pendingPanelAction=null}loadIfEnabled(){if(this._conversationsManager)return;if(this._isInitializing)return;if(this._instance.config.disable_conversations)return;if(Jr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=null==d?void 0:d.__PosthogExtensions__;if(e&&!xt(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{const t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);const i=e.loadExternalDependency;if(!i)return void this._handleLoadError(M);const n=this._resetGeneration;i(this._instance,"conversations",t=>{if(n!==this._resetGeneration)return this._isInitializing=!1,void this.loadIfEnabled();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 uE.error("Conversations enabled but missing token in remote config.")}_completeInitialization(e){if(this._remoteConfig){try{this._conversationsManager=e(this._remoteConfig,this._instance),this._loadFailed=!1,uE.info("Conversations loaded successfully")}catch(e){return void this._handleLoadError("Error completing conversations initialization",e)}this._theme&&this._conversationsManager.setTheme(this._theme),this._applyPendingPanelAction()}else uE.error("Cannot complete initialization: remote config is null")}_applyPendingPanelAction(){const e=this._pendingPanelAction;this._pendingPanelAction=null,this._conversationsManager&&e&&("open"===e?this._conversationsManager.open():this._conversationsManager.close())}_handleLoadError(e,t){uE.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():uE.warn("Conversations not loaded yet.")}hide(){"open"===this._pendingPanelAction&&(this._pendingPanelAction=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.open()):this._pendingPanelAction="open"}close(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.close()):this._pendingPanelAction="close"}setTheme(e){var t,i;this._theme=ct(ct(ct({},this._theme),e),{},{dark:ct(ct({},null===(t=this._theme)||void 0===t?void 0:t.dark),null==e?void 0:e.dark)}),null===(i=this._conversationsManager)||void 0===i||i.setTheme(e)}isAvailable(){return!0===this._isConversationsEnabled&&!Pt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Jr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":xt(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?Mt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":(null==d?void 0:d.__PosthogExtensions__)?this._isInitializing?"initializing":this._loadFailed?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var n=this;return rt(function*(){return n._conversationsManager?n._conversationsManager.sendMessage(e,t,i):(uE.warn(dE),null)})()}getMessages(e,t){var i=this;return rt(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(uE.warn(dE),null)})()}markAsRead(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(uE.warn(dE),null)})()}getTickets(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(uE.warn(dE),null)})()}requestRestoreLink(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(uE.warn(dE),null)})()}restoreFromToken(e){var t=this;return rt(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(uE.warn(dE),null)})()}restoreFromUrlToken(){var e=this;return rt(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(uE.warn(dE),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null===(e=this._conversationsManager)||void 0===e||e.setIdentity()}_onIdentityCleared(){var e;null===(e=this._conversationsManager)||void 0===e||e.clearIdentity()}}},{logs:class extends mE{constructor(e){super({get(){var t;return null==e||null===(t=e.config)||void 0===t?void 0:t.logs},captureHintKey:ee,get remoteConfigWillArrive(){var t,i;return!(null===(t=e._shouldDisableFlags)||void 0===t?void 0:t.call(e))||!!(null===(i=d._POSTHOG_REMOTE_CONFIG)||void 0===i||null===(i=i[e.config.token])||void 0===i?void 0:i.config)}},()=>function(e){var t;const i={};if(i.distinctId=e.get_distinct_id(),e.sessionManager){const{sessionId:t,windowId:n,sessionStartTimestamp:s,lastActivityTimestamp:r}=e.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=n,Mt(s)||(i.sessionStartTimestamp=s),Mt(r)||(i.lastActivityTimestamp=r)}if((null==d||null===(t=d.location)||void 0===t?void 0:t.href)&&(i.currentUrl=e.config.disable_capture_url_hashes?cn(d.location.href):d.location.href),e.featureFlags){const t=e.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}(e)),this._instance=e,this.name=Yy,this._listenForReconnect()}get _isRequestReady(){return this._instance.__loaded}_getConsoleLoader(){const e=Br("[logs]"),t=null==d?void 0:d.__PosthogExtensions__;if(!t)return void e.error("PostHog Extensions not found.");const i=t.loadExternalDependency;if(i)return e=>{i(this._instance,"logs",i=>{const n=t.logs;e(i,(null==n?void 0:n.initializeLogs)?{initialize:e=>n.initializeLogs(e),replay(e,t){var i;return null===(i=n.replayConsoleBuffer)||void 0===i?void 0:i.call(n,e,t)}}:void 0)})};e.error(M)}}},{metrics:class{constructor(e){this._instance=e,this._logger=Br("[metrics]"),this._disposed=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this._disposed)return;const t=!!(null===(e=this._instance.config.metrics)||void 0===e?void 0:e.network);t&&!this._stopNetworkMetrics?this._stopNetworkMetrics=(e=>{let t=!0;const i=()=>t?(e=>{var t;const i=null===(t=e.config.metrics)||void 0===t?void 0:t.network;return!0===i?{}:i||void 0})(e):void 0,n=EE(e,i),s=TE(e,i);return()=>{t=!1,n(),s()}})(this._instance):!t&&this._stopNetworkMetrics&&(this._stopNetworkMetrics(),this._stopNetworkMetrics=void 0)}_getCore(){var e;if(this._disposed)return;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.metrics;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,this._core=new Pr(this._createHost(),function(e){var t,i,n,s,r;const o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(n=null==o?void 0:o["deployment.environment"])&&void 0!==n?n:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(s=null==e?void 0:e.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(r=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(t),this._logger)),this._core}count(e,t=1,i){var n;null===(n=this._getCore())||void 0===n||n.count(e,t,i)}gauge(e,t,i){var n;null===(n=this._getCore())||void 0===n||n.gauge(e,t,i)}histogram(e,t,i){var n;null===(n=this._getCore())||void 0===n||n.histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){const t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch(e=>this._logger.error("PostHog metrics flush failed:",e))}reset(){var e;null===(e=this._core)||void 0===e||e.reset()}dispose(){var e,t;this._disposed=!0,null===(e=this._stopNetworkMetrics)||void 0===e||e.call(this),this._stopNetworkMetrics=void 0,null===(t=this._core)||void 0===t||t.reset()}_createHost(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>Yl.LIB_NAME,getLibraryVersion:()=>Yl.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{let n=!1;const s=e=>{n||(n=!0,clearTimeout(r),i(e))},r=setTimeout(()=>s({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(ct(ct({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){const t=e.statusCode;if(t>=200&&300>t)s({kind:"ok"});else if(413===t)s({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)s({kind:"fatal",error:new Error(`metrics request failed with status ${t}`)});else{var i;s({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`metrics request failed with status ${t}`)})}}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},{webMCP:class{constructor(e){this._instance=e,this._isPatched=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this._isPatched)return;const e=null==n?void 0:n.modelContext;if(!e||!Ct(e.registerTool))return;const t=xE.get(e);if(t)return t.instances.add(this._instance),void(this._isPatched=!0);const i={instances:new Set([this._instance])},s=e.registerTool,r=this;Mg(e,"registerTool",e=>{const t=e;return function(e,...n){let s=e;try{s=r._wrapTool(e,i)}catch(i){return t.call(this,e,...n)}return t.call(this,s,...n)}}),e.registerTool!==s&&(xE.set(e,i),this._isPatched=!0)}_wrapTool(e,t){if(!e||!Ct(e.execute))return e;const i=e.execute,n=this,{tool:s,injected:r}=function(e,t){const i={intent:!1,model:!1},n=e.inputSchema;if(!function(e){return!!xt(e)||Et(e)&&Object.keys(e).every(e=>IE.has(e)||e.startsWith("x-"))&&!0!==e.additionalProperties&&!Et(e.additionalProperties)&&(!e.type||"object"===e.type)&&(!e.properties||Et(e.properties))&&(!e.required||kt(e.required))}(n))return{tool:AE(e),injected:i};const s=(null==n?void 0:n.properties)||{},r=e=>FE(s,e)||kt(null==n?void 0:n.required)&&n.required.includes(e);if(i.intent=t.intent&&!r("context"),i.model=t.model&&!r("llm_model"),!i.intent&&!i.model)return{tool:AE(e),injected:i};const o=ct({},s),a=kt(null==n?void 0:n.required)?[...n.required]:[];return i.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},a.includes("context")||a.push("context")),i.model&&(o.llm_model={type:"string",description:'The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the site developer\'s analytics.'},a.includes("llm_model")||a.push("llm_model")),{tool:AE(e,ct(ct({},n),{},{type:(null==n?void 0:n.type)||"object",properties:o,required:a})),injected:i}}(e,function(e){const t={intent:!1,model:!1};for(const i of e.instances){const e=ME(i.config.capture_webmcp);t.intent||(t.intent=!0===(null==e?void 0:e.intent)),t.model||(t.model=!0===(null==e?void 0:e.model))}return t}(t));return Object.defineProperty(s,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const a=new Date,l=function(e,t){if(!Et(e))return{};try{const i=t.intent?LE(e.context,2048,!0):void 0,n=t.model?LE(e.llm_model,256):void 0;return ct(ct({},i&&"{}"!==i?{intent:i}:{}),n&&"unknown"!==n.toLowerCase()?{model:n}:{})}catch(e){return{}}}(o[0],r),c=function(e,t){const i=e[0];if(!Et(i))return e;try{const n=t.intent&&FE(i,"context"),s=t.model&&FE(i,"llm_model");if(!n&&!s)return e;const r=ct({},i);return n&&delete r.context,s&&delete r.llm_model,[r,...e.slice(1)]}catch(t){return e}}(o,r);let u;try{u=i.apply(this===s?e:this,c)}catch(e){throw n._captureToolCall(t,s,a,{error:e,errorResult:!1},l),e}if((d=u)&&"function"==typeof d.then)return Promise.resolve(u).then(e=>{const i=OE(e)?{error:e,errorResult:!0}:void 0;return n._captureToolCall(t,s,a,i,l),e},e=>{throw n._captureToolCall(t,s,a,{error:e,errorResult:!1},l),e});var d;const h=OE(u)?{error:u,errorResult:!0}:void 0;return n._captureToolCall(t,s,a,h,l),u}}),s}_captureToolCall(e,t,i,n,r){const o=Date.now()-i.getTime();let a;for(const c of e.instances){var l;const e=ME(c.config.capture_webmcp);if(e){n&&!a&&(a=qE(n.error,n.errorResult));try{c.capture("$mcp_tool_call",ct(ct(ct({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==s?void 0:s.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{}),e.intent&&r.intent?{$mcp_intent:r.intent,$mcp_intent_source:"context_parameter"}:{}),e.model&&r.model?{$mcp_llm_model:r.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:i})}catch(e){continue}if(n&&a&&c.exceptions&&(null===(l=c.exceptionObserver)||void 0===l?void 0:l.isEnabled))try{const e={$exception_list:NE(c.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==s?void 0:s.hostname};c.exceptionObserver.captureException(e)}catch(e){}}}}}}));const HE=function(){Yl.SDK_DIST_CHANNEL="npm";const t=sC[mC]=new EC;return function(){function t(){t.done||(t.done=!0,Dk=!1,Hr(sC,function(e){e._dom_loaded()}))}(null==n?void 0:n.addEventListener)?"complete"===n.readyState?t():Kr(n,"DOMContentLoaded",t,{capture:!1}):e&&Nr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();var UE=HE;exports.Compression=Iy,exports.DEFAULT_PRODUCT_TOUR_APPEARANCE={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},exports.DisplaySurveyType=Bf,exports.PostHog=EC,exports.ProductTourEventName=Pk,exports.ProductTourEventProperties=Mk,exports.SurveyEventName=$f,exports.SurveyEventProperties=Nf,exports.SurveyEventType=Rf,exports.SurveyPosition=Mf,exports.SurveyQuestionBranchingType=Of,exports.SurveyQuestionType=Lf,exports.SurveySchedule=Df,exports.SurveyTabPosition=Ff,exports.SurveyType=Af,exports.SurveyWidgetType=Pf,exports.default=UE,exports.posthog=HE,exports.severityLevels=["fatal","error","warning","log","info","debug"];