posthog-js 1.421.2 → 1.422.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) 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.es5.js.map +1 -1
  5. package/dist/array.full.js +1 -1
  6. package/dist/array.full.js.map +1 -1
  7. package/dist/array.full.no-external.js +1 -1
  8. package/dist/array.full.no-external.js.map +1 -1
  9. package/dist/array.js +1 -1
  10. package/dist/array.js.map +1 -1
  11. package/dist/array.no-external.js +1 -1
  12. package/dist/array.no-external.js.map +1 -1
  13. package/dist/conversations.js +1 -1
  14. package/dist/customizations.full.js +1 -1
  15. package/dist/customizations.js +1 -1
  16. package/dist/dead-clicks-autocapture.js +1 -1
  17. package/dist/default-extensions.js +1 -1
  18. package/dist/default-extensions.js.map +1 -1
  19. package/dist/exception-autocapture.js +1 -1
  20. package/dist/extension-bundles.js +1 -1
  21. package/dist/extension-bundles.js.map +1 -1
  22. package/dist/lazy-recorder.js +1 -1
  23. package/dist/lazy-recorder.js.map +1 -1
  24. package/dist/main.js +1 -1
  25. package/dist/main.js.map +1 -1
  26. package/dist/module.full.js +1 -1
  27. package/dist/module.full.js.map +1 -1
  28. package/dist/module.full.no-external.js +1 -1
  29. package/dist/module.full.no-external.js.map +1 -1
  30. package/dist/module.js +1 -1
  31. package/dist/module.js.map +1 -1
  32. package/dist/module.no-external.js +1 -1
  33. package/dist/module.no-external.js.map +1 -1
  34. package/dist/module.slim.js +1 -1
  35. package/dist/module.slim.js.map +1 -1
  36. package/dist/module.slim.no-external.js +1 -1
  37. package/dist/module.slim.no-external.js.map +1 -1
  38. package/dist/posthog-recorder.js +1 -1
  39. package/dist/posthog-recorder.js.map +1 -1
  40. package/dist/product-tours.js +1 -1
  41. package/dist/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +1 -0
  42. package/dist/src/extensions/replay/external/mutation-throttler.d.ts +1 -0
  43. package/dist/surveys-preview.js +1 -1
  44. package/dist/surveys.js +1 -1
  45. package/lib/package.json +1 -1
  46. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +1 -0
  47. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +9 -0
  48. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
  49. package/lib/src/extensions/replay/external/mutation-throttler.d.ts +1 -0
  50. package/lib/src/extensions/replay/external/mutation-throttler.js +9 -0
  51. package/lib/src/extensions/replay/external/mutation-throttler.js.map +1 -1
  52. package/package.json +7 -7
package/dist/module.js CHANGED
@@ -1,2 +1,2 @@
1
- var t="undefined"!=typeof window?window:void 0,i="undefined"!=typeof globalThis?globalThis:t,e=null==i?void 0:i.navigator,r=null==i?void 0:i.document,s=null==i?void 0:i.location,n=null==i?void 0:i.fetch,o=null!=i&&i.XMLHttpRequest&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,a=null==i?void 0:i.AbortController,l=null==i?void 0:i.CompressionStream,h=null==e?void 0:e.userAgent;function u(){return!(!t||!1===t.navigator.onLine)}var d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});var v=null!=t?t:{},c={DEBUG:!1,LIB_VERSION:"0.6.0",LIB_NAME:"browser-common"};function f(t,i,e,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void e(t)}a.done?i(l):Promise.resolve(l).then(r,s)}function p(t){return function(){var i=this,e=arguments;return new Promise((function(r,s){var n=t.apply(i,e);function o(t){f(n,r,s,o,a,"next",t)}function a(t){f(n,r,s,o,a,"throw",t)}o(void 0)}))}}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var i=1;arguments.length>i;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},_.apply(null,arguments)}function g(t,i){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==i.indexOf(r))continue;e[r]=t[r]}return e}var m=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function y(t){return"string"==typeof t||t}function b(t){return"string"==typeof t?t:void 0}var w=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],x=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),E=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),S=["$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"],k=["token"],T=20,P=1e3,R=1e4,C="[Circular]",O="[Truncated]",I="[Unserializable]",A="[Function]";function F(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}var M=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],D=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return M.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function N(t,i){return-1!==t.indexOf(i)}var L=function(t){return t.trim()},U=function(t){return t.replace(/^\$/,"")};function j(t){var i,e=[];return null!==(i=JSON.stringify(t,(function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}})))&&void 0!==i?i:"null"}var B=Object.prototype,z=B.hasOwnProperty,q=B.toString,H=Array.isArray||function(t){return"[object Array]"===q.call(t)},V=t=>"function"==typeof t,W=t=>t===Object(t)&&!H(t),G=t=>{if(W(t)){for(var i in t)if(z.call(t,i))return!1;return!0}return!1},K=t=>void 0===t,J=t=>"[object String]"==q.call(t),Y=t=>J(t)&&0===t.trim().length,Q=t=>null===t,X=t=>K(t)||Q(t),Z=t=>"[object Number]"==q.call(t)&&t==t,tt=t=>Z(t)&&t>0,it=t=>"[object Boolean]"===q.call(t),et=t=>t instanceof FormData,rt=t=>N(S,t),st=t=>N(k,t);function nt(t){return null===t||"object"!=typeof t}function ot(t,i){return{}.toString.call(t)==="[object "+i+"]"}function at(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return ht(t,Error)}}function lt(t){return"undefined"!=typeof Event&&ht(t,Event)}function ht(t,i){try{return t instanceof i}catch(t){return!1}}var ut=[!0,"true",1,"1","yes"],dt=t=>N(ut,t),vt=[!1,"false",0,"0","no"];function ct(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),Z(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),ct(s||e,i,e,r))}class ft{constructor(t){this.k={},this.S=t.S,this.C=ct(t.bucketSize,0,100,t.I),this.R=ct(t.refillRate,0,this.C,t.I),this.A=ct(t.refillInterval,0,864e5,t.I)}O(t,i){var e=Math.floor((i-t.lastAccess)/this.A);e>0&&(t.tokens=Math.min(t.tokens+e*this.R,this.C),t.lastAccess=t.lastAccess+e*this.A)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.k[r];return s?this.O(s,e):this.k[r]=s={tokens:this.C,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.S)||i.call(this,t)),0===s.tokens)}stop(){this.k={}}}var pt="Mobile",_t="iOS",gt="Android",mt="Tablet",yt=gt+" "+mt,bt="iPad",wt="Apple",xt=wt+" Watch",Et="Safari",St="BlackBerry",kt="Samsung",Tt=kt+"Browser",$t=kt+" Internet",Pt="Chrome",Rt=Pt+" OS",Ct=Pt+" "+_t,Ot="Internet Explorer",It=Ot+" "+pt,At="Opera",Ft=At+" Mini",Mt="Edge",Dt="Microsoft "+Mt,Nt="Firefox",Lt=Nt+" "+_t,Ut="Nintendo",jt="PlayStation",Bt="Xbox",zt=gt+" "+pt,qt=pt+" "+Et,Ht="Windows",Vt=Ht+" Phone",Wt="Nokia",Gt="Ouya",Kt="Generic",Jt=Kt+" "+pt.toLowerCase(),Yt=Kt+" "+mt.toLowerCase(),Qt="Konqueror",Xt="Oculus Browser",Zt="Vivaldi",ti="Yandex",ii="Whale",ei="DuckDuckGo",ri="Pale Moon",si="Waterfox",ni="Brave",oi="Google Search App",ai="(\\d+(\\.\\d+)?)",li=new RegExp("Version/"+ai),hi=new RegExp(Bt,"i"),ui=new RegExp(jt+" \\w+","i"),di=new RegExp(Ut+" \\w+","i"),vi=new RegExp(St+"|PlayBook|BB10","i"),ci={"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"},fi=function(t,i,e,r){i=i||"";var s=function(t){return null!=t&&t.brave?ni:null}(e);return s||(null!=r&&r.detectGoogleSearchApp&&N(t,"GSA/")?oi:N(t," OPR/")&&N(t,"Mini")?Ft:N(t," OPR/")?At:vi.test(t)?St:N(t,"IE"+pt)||N(t,"WPDesktop")?It:N(t,"OculusBrowser")?Xt:N(t,Tt)?$t:N(t,Mt)||N(t,"Edg/")?Dt:N(t,Zt+"/")?Zt:N(t,"YaBrowser/")?ti:N(t,ii+"/")?ii:N(t,ei+"/")||N(t,"Ddg/")?ei:N(t,"FBIOS")?"Facebook "+pt:N(t,"UCWEB")||N(t,"UCBrowser")?"UC Browser":N(t,"CriOS")?Ct:N(t,"CrMo")||N(t,Pt)?Pt:N(t,gt)&&N(t,Et)?zt:N(t,"FxiOS")?Lt:N(t.toLowerCase(),Qt.toLowerCase())?Qt:N(t,ni+"/")?ni:((t,i)=>i&&N(i,wt)||function(t){return N(t,Et)&&!N(t,Pt)&&!N(t,gt)}(t))(t,i)?N(t,pt)?qt:Et:N(t,"PaleMoon/")?ri:N(t,si+"/")?si:N(t,Nt)?Nt:N(t,"MSIE")||N(t,"Trident/")?Ot:N(t,"Gecko")?Nt:"")},pi={[It]:[new RegExp("rv:"+ai)],[Dt]:[new RegExp(Mt+"?\\/"+ai)],[Pt]:[new RegExp("("+Pt+"|CrMo)\\/"+ai)],[Ct]:[new RegExp("CriOS\\/"+ai)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ai)],[Et]:[li],[qt]:[li],[At]:[new RegExp("(Opera|OPR)\\/"+ai)],[Nt]:[new RegExp(Nt+"\\/"+ai)],[Lt]:[new RegExp("FxiOS\\/"+ai)],[Qt]:[new RegExp("Konqueror[:/]?"+ai,"i")],[St]:[new RegExp(St+" "+ai),li],[zt]:[new RegExp("android\\s"+ai,"i")],[$t]:[new RegExp(Tt+"\\/"+ai)],[Xt]:[new RegExp("OculusBrowser\\/"+ai)],[Zt]:[new RegExp(Zt+"\\/"+ai)],[ti]:[new RegExp("YaBrowser\\/"+ai)],[ii]:[new RegExp(ii+"\\/"+ai)],[ni]:[new RegExp(ni+"\\/"+ai)],[ei]:[new RegExp("(DuckDuckGo|Ddg)\\/"+ai)],[ri]:[new RegExp("PaleMoon\\/"+ai)],[si]:[new RegExp(si+"\\/"+ai)],[oi]:[new RegExp("GSA\\/"+ai)],[Ot]:[new RegExp("(rv:|MSIE )"+ai)],Mozilla:[new RegExp("rv:"+ai)]},_i=function(t,i,e,r){var s=fi(t,i,e,r),n=pi[s];if(K(n))return null;for(var o=0;n.length>o;o++){var a=t.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},gi=[[new RegExp(Bt+"; "+Bt+" (.*?)[);]","i"),t=>[Bt,t&&t[1]||""]],[new RegExp(Ut,"i"),[Ut,""]],[new RegExp(jt,"i"),[jt,""]],[vi,[St,""]],[new RegExp(Ht,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[Vt,""];if(new RegExp(pt).test(i)&&!/IEMobile\b/.test(i))return[Ht+" "+pt,""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=ci[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[Ht,r]}return[Ht,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[_t,[t[3],t[4],t[5]||"0"].join(".")]:[_t,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=K(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("("+gt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+gt+")","i"),t=>t&&t[2]?[gt,[t[2],t[3],t[4]||"0"].join(".")]:[gt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Rt,""]],[/Linux|debian/i,["Linux",""]]],mi=function(t){return di.test(t)?Ut:ui.test(t)?jt:hi.test(t)?Bt:new RegExp(Gt,"i").test(t)?Gt:new RegExp("("+Vt+"|WPDesktop)","i").test(t)?Vt:/iPad/.test(t)?bt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?xt:vi.test(t)?St:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Wt,"i").test(t)?Wt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(pt).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?gt:yt:new RegExp("(pda|"+pt+")","i").test(t)?Jt:new RegExp(mt,"i").test(t)&&!new RegExp(mt+" pc","i").test(t)?Yt:""},yi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function bi(t,i){return"string"==typeof(e=t)&&yi.test(e)?t:i();var e}function wi(t,i){var e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function xi(t){return t?t.split("#")[0]:t}function Ei(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function Si(t,i,e){return ki.apply(this,arguments)}function ki(){return(ki=p((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=Ei((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Ti,$i="NativeGzipValidationError",Pi=t=>t.length>=2&&31===t[0]&&139===t[1],Ri=(t,i)=>t===E.GZipJS||i===E.GZipJS||"gzip"===i,Ci=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),Oi=t=>{throw wi($i,"Native gzip produced invalid output: "+t)},Ii=function(){var t=p((function*(t,i){18>t.size&&Oi("too-short");var e=new Uint8Array(yield t.slice(0,10).arrayBuffer());Pi(e)&&8===e[2]||Oi("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var i=(()=>{if(Ti)return Ti;Ti=[];for(var t=0;256>t;t++){for(var i=t,e=0;8>e;e++)i=1&i?3988292384^i>>>1:i>>>1;Ti[t]=i>>>0}return Ti})(),e=4294967295,r=0;t.length>r;r++)e=i[255&(e^t[r])]^e>>>8;return(4294967295^e)>>>0})(i)&&Oi("invalid-crc");var s=i.length>>>0;r.getUint32(4,!0)!==s&&Oi("invalid-size")}));return function(i,e){return t.apply(this,arguments)}}();function Ai(){return Ai=p((function*(t,i,e){void 0===i&&(i=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),n=s.writable.getWriter(),o=n.write(r).then((()=>n.close())).catch(function(){var t=p((function*(t){try{yield n.abort(t)}catch(t){}throw t}));return function(i){return t.apply(this,arguments)}}()),a=new Response(s.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield Ii(l,r),l}catch(t){if(null!=e&&e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}})),Ai.apply(this,arguments)}var Fi={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Mi=Fi.info,Di=0x8000000000000000,Ni={}.propertyIsEnumerable;function Li(t,i){try{return Bi(t,i,{ancestors:new WeakSet,remainingNodes:R},0)}catch(t){return[]}}function Ui(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:O};if(e.remainingNodes--,it(t))return{boolValue:t};if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if("undefined"==typeof BigInt)return{stringValue:String(t)};var s=BigInt(t).toString();return t>=Di||-Di>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:F(t)};if("function"==typeof t)return{stringValue:A};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:C};if(r>=T)return{stringValue:O};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof o?F(o):String(o)}}e.ancestors.add(t);try{try{var a=t.toJSON;if("function"==typeof a)return Ui(a.call(t),i,e,r+1)}catch(t){}return H(t)?{arrayValue:{values:ji(t,i,e,r+1)}}:{kvlistValue:{values:Bi(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:F(String(t))}}function ji(t,i,e,r){for(var s=[],n=Math.min(t.length,P),o=0;n>o&&e.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(X(a))continue;s.push(Ui(a,i,e,r))}catch(t){s.push({stringValue:I})}return t.length>o&&s.push({stringValue:O}),s}function Bi(t,i,e,r){var s=[];for(var n in t)if(Ni.call(t,n)){if(s.length>=P||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(Q(o)||K(o))continue;s.push({key:F(n),value:Ui(o,i,e,r)})}catch(t){s.push({key:F(n),value:{stringValue:I}})}}return s}function zi(t){try{return F(String(t))}catch(t){return I}}function qi(t,i,e,r){var s,n=Fi[t.level||"info"]||Mi,o=n.text,a=n.number,l=(void 0===(s=Z(r)?r:void 0)&&(s=Date.now()),String(s)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),X(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),X(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var u=_({},h),d=t.attributes;if(d){var v=[];try{v=Object.keys(d)}catch(t){v=[]}for(var c of v){var f=void 0;try{f=d[c]}catch(t){f=I}Object.defineProperty(u,c,{value:f,enumerable:!0,writable:!0,configurable:!0})}}var p={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:a,severityText:o,body:{stringValue:zi(t.body)},attributes:Li(u,e)};return t.trace_id&&(p.traceId=t.trace_id),t.span_id&&(p.spanId=t.span_id),K(t.trace_flags)||(p.flags=t.trace_flags),p}function Hi(t,i,e){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}function Vi(t,i,e,r){return{resourceLogs:[{resource:{attributes:Li(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let Wi=class{constructor(t,i,e,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Wi=i,this.I=e,this.hn=r,this.dn=s,this.vn=n,this.cn=o,this.fn=null,this.pn=0,this.gn=0,this.mn=0,this.yn=0,this.bn=0,this._n=!1,this.wn=i.maxBufferSize,this.kn=Math.max(null!==(a=i.maxQueueSize)&&void 0!==a?a:i.maxBufferSize,i.maxBufferSize),this.Sn=i.flushIntervalMs,this.xn=i.maxBatchRecordsPerPost,this.Cn=i.rateCapWindowMs,this.Tn=i.maxLogsPerInterval}clearQueue(){this.gn++,this._instance.setPersistedProperty(x.LogsQueue,[])}reset(){this.Mn(),this.yn=0,this.bn=0,this._n=!1,this.mn=0,this.xn=this.Wi.maxBatchRecordsPerPost}onReconnect(){this.mn=0,this.En()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.In(t);if(null!==r)if(r.body){if(this.Rn()){var s={record:qi(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.hn(),this.I,null==i?void 0:i.occurredAtMs)};this.dn((()=>this.Pn(s)))}}else this.I.info("Log was rejected in beforeSend function")}}In(t){var i=this.Wi.beforeSend;if(!i)return t;var e=H(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for log:",t),null}return r}Rn(){if(void 0===this.Tn)return!0;var t=Date.now(),i=t-this.yn;return this.Cn>i&&i>=0||(this.yn=t,this.bn=0,this._n=!1),this.Tn>this.bn?(this.bn++,!0):(this._n||(this.I.warn("captureLog dropping logs: exceeded "+this.Tn+" logs per "+this.Cn+"ms"),this._n=!0),!1)}flush(){var t=this;return p((function*(){if(!t._instance.isDisabled)return t.fn||(t.fn=t.An().finally((()=>{t.fn=null}))),t.fn}))()}An(){var t=this;return p((function*(){var i;t.Mn();var e=null!==(i=t._instance.getPersistedProperty(x.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,o,a=t.gn;t.pn=0;var l=Math.min(e.length,t.xn),h=e.slice(0,l),u=Vi(h.map((t=>t.record)),t.Fn(),null!==(n=t.cn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.On(u);if(t.gn!==a)return;if("too-large"===d.kind&&h.length>1)t.xn=Math.max(1,Math.floor(h.length/2)),t.I.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.xn);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.Wi.maxBatchRecordsPerPost>t.xn&&(t.xn=Math.min(t.Wi.maxBatchRecordsPerPost,t.xn+1)),yield t.Ln(h.length),e=null!==(o=t._instance.getPersistedProperty(x.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===d.kind)throw d.error}}}))()}Ln(t){var i=this;return p((function*(){var e,r=Math.max(0,t-i.pn),s=null!==(e=i._instance.getPersistedProperty(x.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(x.LogsQueue,s.slice(r)),yield i.vn()}))()}Fn(){return Hi(this.Wi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Pn(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(x.LogsQueue))&&void 0!==i?i:[];this.kn>e.length||(e.shift(),this.pn++,this.I.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(x.LogsQueue,e),this.wn>e.length?this.Dn():this.En()}}Dn(t){void 0===t&&(t=this.Sn),this.$n||(this.$n=Ei((()=>{this.$n=void 0,this.En()}),t))}Nn(){var t=Math.min(Math.max(0,this.mn-1),6);return this.Sn*Math.pow(2,t)}qn(){var t=this._instance.getPersistedProperty(x.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return p((function*(){i.Mn();var e=i.flush().catch((()=>{}));void 0!==t?yield Si(e,t):yield e}))()}flushWithTimeout(t){var i=this;return p((function*(){var e=i.flush();yield Si(e,t,(()=>{e.catch((()=>{}))}))}))()}En(){this.flush().then((()=>{this.mn=0}),(t=>{this.mn++,this.I.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.qn()&&this.Dn(this.Nn())}))}Mn(){this.$n&&(clearTimeout(this.$n),this.$n=void 0)}};var Gi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ki(t){return String(t)+"000000"}function Ji(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}let Yi=class{constructor(t,i,e){this._instance=t,this.Wi=i,this.I=e,this.jn=new Map,this.fn=null,this.Bn=!1,this.Hn=new Map,this.Un=new Set,this.zn=0}count(t,i,e){void 0===i&&(i=1),this.Wn({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Wn({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Wn({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,i=this.fn,e=function(){var e=p((function*(){i&&(yield i.catch((()=>{}))),yield t.Vn()}));return function(){return e.apply(this,arguments)}}(),r=e().finally((()=>{this.fn===r&&(this.fn=null)}));return this.fn=r,r}drainWindow(){if(0===this.jn.size)return null;var t=this.jn;return this.jn=new Map,this.Bn=!1,this.Hn=new Map,this.Un=new Set,this.Gn(t)}reset(){this.zn++,this.Mn(),this.jn=new Map,this.fn=null,this.Bn=!1,this.Hn=new Map,this.Un=new Set}Wn(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.In(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.I.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var e,r;try{e=i.attributes?_({},i.attributes):void 0,r=Ji(i.type,i.name,i.unit,e)}catch(t){return void this.I.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s=this.jn.get(r);if(!s){if(!this.Zn())return;s={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.jn.set(r,s)}var n=this.Hn.get(i.name);void 0===n?this.Hn.set(i.name,i.type):n===i.type||this.Un.has(i.name)||(this.Un.add(i.name),this.I.warn("Metric name '"+i.name+"' is already used as a "+n+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Qn(s,i.value),this.Dn()}else this.I.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}Zn(){return this.Wi.maxSeriesPerFlush>this.jn.size||(this.Bn||(this.Bn=!0,this.I.warn("Metric series cap reached ("+this.Wi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Qn(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Gi.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=i,r.min=Math.min(r.min,i),r.max=Math.max(r.max,i),r.bucketCounts[function(t,i){for(var e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Gi)]+=1}}In(t){var i=this.Wi.beforeSend;if(!i)return t;var e=H(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for metric:",t),null}return r}Dn(){this.$n||(this.$n=Ei((()=>{this.$n=void 0,this.flush().catch((t=>{this.I.error("Metrics flush failed:",t)}))}),this.Wi.flushIntervalMs))}Mn(){this.$n&&(clearTimeout(this.$n),this.$n=void 0)}Vn(){var t=this;return p((function*(){if(0!==t.jn.size){var i=t.jn;t.jn=new Map,t.Bn=!1,t.Hn=new Map,t.Un=new Set;var e=t.zn,r=yield t._instance.Jn(t.Gn(i));if(e===t.zn)switch(r.kind){case"ok":return;case"retry-later":return t.Kn(i),void t.Dn();case"too-large":return void t.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.I.error("Failed to send metrics batch:",r.error)}}}))()}Gn(t){return i=this.Yn(t),e=function(t,i,e){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}(this.Wi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Li(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Yn(t){var i=Ki(Date.now()),e=new Map;for(var r of t.values()){var s,n=Ji(r.type,r.name,r.unit,void 0),o=e.get(n);o||(o=_({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},e.set(n,o));var a=Li(null!==(s=r.attributes)&&void 0!==s?s:{},this.I),l=Ki(r.windowStartMs);if("count"===r.type){var h,u={attributes:a,startTimeUnixNano:l,timeUnixNano:i,asDouble:null!==(h=r.total)&&void 0!==h?h:0};o.sum.dataPoints.push(u)}else if("gauge"===r.type){var d,v={attributes:a,timeUnixNano:i,asDouble:null!==(d=r.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(v)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:i,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:Gi})}return Array.from(e.values())}Kn(t){var i,e;for(var r of t){var s=r[0],n=r[1],o=this.jn.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(i=o.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Zn()&&this.jn.set(s,n)}}};var Qi,Xi,Zi;function te(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return Zi&&e.length===Xi||(Xi=e.length,Zi=e.reduce(((e,r)=>{Qi||(Qi={});var s=Qi[r];if(s)e[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,h=i[r];if(l&&h){e[l]=h,Qi[r]=[l,h];break}}return e}),{})),Zi}}class ie{constructor(t,i,e){void 0===e&&(e=[]),this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i){void 0===i&&(i={});var e=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(e,i,0).apply(t),s=this.buildParsingContext(i),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,e),$exception_level:"error"}}modifyFrames(t){var i=this;return p((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&H(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t}))()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e,r;return null!=t.cause&&(e=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(r=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),_({},t,{cause:e,stack:r})}applyChunkIds(t,i){return t.map((t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t)))}applyCoercers(t,i){for(var e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return p((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,i){var e,r,s,n={type:t.type,value:t.value,mechanism:{type:null!==(e=i.type)&&void 0!==e?e:"generic",handled:null===(r=i.handled)||void 0===r||r,synthetic:null!==(s=t.synthetic)&&void 0!==s&&s}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,_({},i,{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:te(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,e){void 0===e&&(e=0);var r=(e,r)=>{if(4>=r){var s=this.buildCoercingContext(t,i,r);return this.applyCoercers(e,s)}};return _({},i,{syntheticException:0==e?i.syntheticException:void 0,mechanism:t,apply:t=>r(t,e),next:t=>r(t,e+1)})}}var ee="?";function re(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?ee:e,in_app:!(null!=i&&i.startsWith("webkit-masked-url://"))&&"<anonymous>"!==i};return K(r)||(n.lineno=r),K(s)||(n.colno=s),n}var se=(t,i)=>{var e=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return e||r?[-1!==t.indexOf("@")?t.split("@")[0]:ee,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},ne=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,oe=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ae=/\((\S*)(?::(\d+))(?::(\d+))\)/,le=(t,i)=>{var e=ne.exec(t);if(e)return re(i,e[1],ee,+e[2],+e[3]);var r=oe.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ae.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=se(r[1]||ee,r[2]);return re(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},he=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ue=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,de=(t,i)=>{var e=he.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=ue.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}var s=e[3],n=e[1]||ee,o=se(n,s);return re(i,s=o[1],n=o[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ve=/\(error: (.*)\)/;class ce{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=J(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?i+": "+t.message:i}isDOMException(t){return ot(t,"DOMException")}isDOMError(t){return ot(t,"DOMError")}}class fe{match(t){return at(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}}class pe{constructor(){}match(t){return!!ot(t,"ErrorEvent")&&(null!=t.error||this.wi(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);var r=i.apply(t.message);return _({},r,{stack:null!==(e=this.ki(t))&&void 0!==e?e:r.stack,synthetic:!0})}wi(t){return J(t.message)&&t.message.length>0}ki(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(J(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var _e=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ge{match(t){return"string"==typeof t}coerce(t,i){var e,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}getInfos(t){var i="Error",e=t,r=t.match(_e);return r&&(i=r[1],e=r[2]),[i,e]}}var me=["fatal","error","warning","log","info","debug"];function ye(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}class be{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,r,s=this.getErrorPropertyFromObject(t);return s?i.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null==(r=i.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(lt(t))return t.constructor.name;var i="name"in t?t.name:void 0;return J(i)&&!Y(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var i="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(i+=" with message: '"+t.message+"'"),i}if("message"in t&&"string"==typeof t.message)return t.message;var e=this.getObjectClassName(t);return(e&&"Object"!==e?"'"+e+"'":"Object")+" captured as exception with keys: "+ye(t)}isSeverityLevel(t){return J(t)&&!Y(t)&&me.indexOf(t)>=0}getStack(t){try{return J(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:J(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(at(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}}class we{match(t){return lt(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ye(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class xe{match(t){return nt(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class Ee{match(t){return ot(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!lt(t))return!1;try{var i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e,r=this.getUnhandledRejectionReason(t);return nt(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var Se="$message",ke="$timestamp",Te=new Set([Se,ke]),$e={enabled:!0,max_bytes:32768};function Pe(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:$e.enabled,max_bytes:Ce(t.max_bytes,$e.max_bytes)}:_({},$e)}class Re{constructor(t){this.Xn=[],this.ts=0,this.Wi=Pe(t)}setConfig(t){this.Wi=Pe(t),this.es()}add(t){var i=function(t){var i;try{i=j(t)}catch(t){return}try{var e=JSON.parse(i);if(!W(e))return;var r=e,s=r[Se],n=r[ke];if(!J(s)||0===s.trim().length)return;if(!J(n)&&!Z(n))return;return{step:r,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.Wi.max_bytes||(this.Xn.push({step:i.step,bytes:e}),this.ts+=e,this.es())}}getAttachable(){return this.Xn.map((t=>t.step))}clear(){this.Xn=[],this.ts=0}size(){return this.Xn.length}es(){for(;this.ts>this.Wi.max_bytes&&this.Xn.length>0;){var t=this.Xn.shift();t&&(this.ts-=t.bytes)}}}function Ce(t,i){if(!Z(t)||t===1/0||t===-1/0)return i;var e=Math.floor(t);return 0>e?i:e}var Oe=function(i,e){var r=(void 0===e?{}:e).debugEnabled,s={P(e){if(t&&(c.DEBUG||t.POSTHOG_DEBUG||r)&&!K(t.console)&&t.console){for(var s=("__rrweb_original__"in t.console[e]?t.console[e].__rrweb_original__:t.console[e]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];s(i,...o)}},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("error",...i)},critical(){for(var t=arguments.length,e=new Array(t),r=0;t>r;r++)e[r]=arguments[r];console.error(i,...e)},uninitializedWarning(t){s.error("You must initialize PostHog before calling "+t)},createLogger:(t,e)=>Oe(i+" "+t,e)};return s},Ie=Oe("[PostHog.js]"),Ae=Ie.createLogger,Fe=Ae("[ExternalScriptsLoader]"),Me=t=>{var i=null==r?void 0:r.querySelectorAll("script");if(i)for(var e=0;i.length>e;e++)if(i[e].src===t||i[e].getAttribute("src")===t)return i[e]},De=(t,i,e)=>{if(t.config.disable_external_dependency_loading)return Fe.warn(i+" was requested but loading of external scripts is disabled."),e("Loading of external scripts is disabled");var s=Me(i);if(s){if(s.__posthog_loading_callback_fired)return e();var n=s.__posthog_loading_error;return n?e(n):(s.addEventListener("load",(t=>{s.__posthog_loading_callback_fired=!0,e(void 0,t)})),void s.addEventListener("error",(t=>{s.__posthog_loading_error=t,e(t)})))}var o=()=>{if(!r)return e("document not found");if(Me(i))return De(t,i,e);var s=r.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=i,s.onload=t=>{s.__posthog_loading_callback_fired=!0,e(void 0,t)},s.onerror=t=>{s.__posthog_loading_error=t,e(t)},t.config.prepare_external_dependency_script&&(s=t.config.prepare_external_dependency_script(s)),!s)return e("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)r.head.appendChild(s);else{var n,o=r.querySelectorAll("body > script");o.length>0?null==(n=o[0].parentNode)||n.insertBefore(s,o[0]):r.body.appendChild(s)}};null!=r&&r.body?o():null==r||r.addEventListener("DOMContentLoaded",o)},Ne={},Le=(t,i)=>{var e="/static/"+i+".js?v="+t.version;if("toolbar"===i){var r=3e5;e=e+"&t="+Math.floor(Date.now()/r)*r}return t.requestRouter.endpointFor("assets",e)};v.__PosthogExtensions__=v.__PosthogExtensions__||{},v.__PosthogExtensions__.loadExternalDependency=(t,i,e)=>{if("remote-config"!==i){var r=t.config.strict_script_versioning;if(r){var s=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+i+".js"),n=Ne[s];if("fallback"===r&&n){if(Me(n))return void De(t,n,e);delete Ne[s]}De(t,s,"fallback"===r?(r,n)=>{if(r)if("string"==typeof r)e(r);else{var o,a=Le(t,i);Ne[s]=a;var l=Me(s);null==l||null==(o=l.parentNode)||o.removeChild(l),De(t,a,e)}else e(void 0,n)}:e)}else De(t,Le(t,i),e)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");De(t,o,e)}},v.__PosthogExtensions__.loadSiteApp=(t,i,e)=>{var r=t.requestRouter.endpointFor("api",i);De(t,r,e)};c.DEBUG=!1,c.LIB_VERSION="1.421.2",c.LIB_NAME="web";var Ue="$people_distinct_id",je="distinct_id",Be="$device_id",ze="$device_model",qe="__alias",He="__timers",Ve="$autocapture_disabled_server_side",We="$heatmaps_enabled_server_side",Ge="$exception_capture_enabled_server_side",Ke="$error_tracking_suppression_rules",Je="$error_tracking_capture_extension_exceptions",Ye="$web_vitals_enabled_server_side",Qe="$dead_clicks_enabled_server_side",Xe="$product_tours_enabled_server_side",Ze="$logs_capture_enabled_server_side",tr="$web_vitals_allowed_metrics",ir="$session_recording_remote_config",er="$replay_sample_rate",rr="$replay_override_sampling",sr="$replay_override_linked_flag",nr="$replay_override_url_trigger",or="$replay_override_event_trigger",ar="$sesid",lr="$session_is_sampled",hr="$enabled_feature_flags",ur="$active_feature_flags",dr="$early_access_features",vr="$feature_flag_details",cr="$feature_flag_payloads",fr="$feature_flag_request_id",pr="$minimal_flag_called_events",_r="$override_feature_flags",gr="$override_feature_flag_payloads",mr="$stored_person_properties",yr="$stored_group_properties",br="$groups",wr="$surveys",xr="$surveys_loaded_at",Er="$surveys_activated",Sr="$surveys_activated_session",kr="$surveys_activated_timestamps",Tr="ph_product_tours",$r="$flag_call_reported",Pr="$flag_call_reported_session_id",Rr="$feature_flag_errors",Cr="$feature_flag_evaluated_at",Or="$user_state",Ir="$client_session_props",Ar="$capture_rate_limit",Fr="$initial_campaign_params",Mr="$initial_referrer_info",Dr="$initial_person_info",Nr="$epp",Lr="$posthog_cookieless",Ur="$cookieless_mode",jr="$sdk_debug_extensions_init_method",Br="$sdk_debug_extensions_init_time_ms",zr="$sdk_debug_recording_script_not_loaded",qr="PostHog loadExternalDependency extension not found.",Hr="on_reject",Vr="always",Wr="anonymous",Gr="identified",Kr="identified_only",Jr="visibilitychange",Yr="beforeunload",Qr="$pageview",Xr="$pageleave",Zr="$identify",ts="$groupidentify";function is(t,i){H(t)&&t.forEach(i)}function es(t,i){if(!X(t))if(H(t))t.forEach(i);else if(et(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)z.call(t,e)&&i(t[e],e)}var rs=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];for(var s of e)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function ss(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var ns=function(t){try{return t()}catch(t){return}},os=function(t){return function(){try{for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,e)}catch(t){Ie.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ie.critical(t)}}},as=function(t){var i={};return es(t,(function(t,e){(J(t)&&t.length>0||Z(t))&&(i[e]=t)})),i};var ls=["herokuapp.com","vercel.app","netlify.app"];function hs(t){var i=null==t?void 0:t.hostname;if(!J(i))return!1;var e=i.split(".").slice(-2).join(".");for(var r of ls)if(e===r)return!1;return!0}function us(t,i,e,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===o||o})}function ds(t){return"ph_toolbar_internal"===t.name}var vs=t=>{if(r){try{for(var i=t+"=",e=r.cookie.split(";").filter((t=>t.length)),s=0;e.length>s;s++){for(var n=e[s];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(i))return decodeURIComponent(n.substring(i.length,n.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Z(t)&&isFinite(t)&&Math.floor(t)===t});class cs{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,e,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(r)||0>t||0>i||0>e||0>r||t>0xffffffffffff||i>4095||e>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|i>>>8,s[7]=i,s[8]=128|e>>>24,s[9]=e>>>16,s[10]=e>>>8,s[11]=e,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new cs(s)}toString(){for(var t="",i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new cs(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var i=0;16>i;i++){var e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}}class fs{generate(){var t=this.generateOrAbort();if(!K(t))return t;this.Dr=0;var i=this.generateOrAbort();if(K(i))throw new Error("Could not generate UUID after timestamp reset");return i}generateOrAbort(){var t=Date.now();if(t>this.Dr)this.Dr=t,this.Fr();else{if(this.Dr>=t+1e4)return;this.Nr++,this.Nr>4398046511103&&(this.Dr++,this.Fr())}return cs.fromFieldsV7(this.Dr,Math.trunc(this.Nr/Math.pow(2,30)),this.Nr&Math.pow(2,30)-1,this.qr.nextUint32())}Fr(){this.Nr=1024*this.qr.nextUint32()+(1023&this.qr.nextUint32())}constructor(){this.Dr=0,this.Nr=0,this.qr=new gs}}var ps,_s=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!K(t.crypto)&&crypto.getRandomValues&&(_s=t=>crypto.getRandomValues(t));class gs{nextUint32(){return this.yt.length>this.jr||(_s(this.yt),this.jr=0),this.yt[this.jr++]}constructor(){this.yt=new Uint32Array(8),this.jr=1/0}}var ms=()=>ys().toString(),ys=()=>(ps||(ps=new fs)).generate(),bs="",ws=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var xs={Br:()=>!!r,Wr(t){Ie.error("cookieStore error: "+t)},Ur:vs,zr(t){var i;try{i=JSON.parse(xs.Ur(t))||{}}catch(t){}return i},Hr(t,i,e,s,n){if(!r)return!1;try{var o="",a="",l=function(t,i){if(i){var e=function(t,i){if(void 0===i&&(i=r),bs)return bs;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var e=t.split("."),s=Math.min(e.length,8),n="dmn_chk_"+ms();!bs&&s--;){var o=e.slice(s).join("."),a=n+"=1;domain=."+o+";path=/";i.cookie=a+";max-age=3",i.cookie.includes(n)&&(i.cookie=a+";max-age=0",bs=o)}return bs}(t);if(!e){var s=(t=>{var i=t.match(ws);return i?i[0]:""})(t);s!==e&&Ie.info("Warning: cookie subdomain discovery mismatch",s,e),e=s}return e?"; domain=."+e:""}return""}(r.location.hostname,s);if(e){var h=new Date;h.setTime(h.getTime()+864e5*e),o="; expires="+h.toUTCString()}n&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(i))+o+"; SameSite=Lax; path=/"+l+a;return u.length>3686.4&&Ie.warn("cookieStore warning: large cookie, len="+u.length),r.cookie=u,!0}catch(t){return!1}},$r(t,i){if(null!=r&&r.cookie)try{xs.Hr(t,"",-1,i)}catch(t){return}}},Es=null,Ss={Br(){if(!Q(Es))return Es;var i=!0;if(K(t))i=!1;else try{var e="__mplssupport__";Ss.Hr(e,"xyz"),'"xyz"'!==Ss.Ur(e)&&(i=!1),Ss.$r(e)}catch(t){i=!1}return i||Ie.error("localStorage unsupported; falling back to cookie store"),Es=i,i},Wr(t){Ie.error("localStorage error: "+t)},Ur(i){try{return null==t?void 0:t.localStorage.getItem(i)}catch(t){Ss.Wr(t)}return null},zr(t){try{return JSON.parse(Ss.Ur(t))||{}}catch(t){}return null},Hr(i,e){try{return null==t||t.localStorage.setItem(i,JSON.stringify(e)),!0}catch(t){Ss.Wr(t)}return!1},$r(i){try{null==t||t.localStorage.removeItem(i)}catch(t){Ss.Wr(t)}}},ks=[mr,ur,hr,vr,cr,fr,Cr,Rr,$r],Ts=[Be,je,ar,lr,Nr,Dr,Or],$s=t=>t+"_cpm",Ps=["__proto__","constructor","prototype"],Rs=t=>{if(!W(t))return{};var i={};return Object.keys(t).forEach((e=>{-1===Ps.indexOf(e)&&(i[e]=t[e])})),i},Cs=function(t,i){void 0===i&&(i=[]);var e={};return[...Ts,...i].forEach((i=>{var r=t[i];K(r)||Q(r)||""===r||(e[i]=r)})),e},Os=t=>{for(var i=5381,e=2166136261,r=0;t.length>r;r++){var s=t.charCodeAt(r);i=33*i^s,e=Math.imul(e^s,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},Is=(t,i)=>({p:i,f:Os(JSON.stringify(t))}),As=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{var e=xs.zr($s(t)),r=(null==e?void 0:e.f)===Os(i)&&H(e.p);return{properties:r?e.p:[],isValid:r}}catch(t){return{properties:[],isValid:!1}}},Fs=(t,i)=>i+"|"+(xs.Ur($s(t))||""),Ms={},Ds={Br:()=>!0,Wr(t){Ie.error("memoryStorage error: "+t)},Ur:t=>Ms[t]||null,zr:t=>Ms[t]||null,Hr:(t,i)=>(Ms[t]=i,!0),$r(t){delete Ms[t]}},Ns=null,Ls={Br(){if(!Q(Ns))return Ns;if(Ns=!0,K(t))Ns=!1;else try{var i="__support__";Ls.Hr(i,"xyz"),'"xyz"'!==Ls.Ur(i)&&(Ns=!1),Ls.$r(i)}catch(t){Ns=!1}return Ns},Wr(t){Ie.error("sessionStorage error: ",t)},Ur(i){try{return null==t?void 0:t.sessionStorage.getItem(i)}catch(t){Ls.Wr(t)}return null},zr(t){try{return JSON.parse(Ls.Ur(t))||null}catch(t){}return null},Hr(i,e){try{return null==t||t.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch(t){Ls.Wr(t)}return!1},$r(i){try{null==t||t.sessionStorage.removeItem(i)}catch(t){Ls.Wr(t)}}};class Us{constructor(t){this._instance=t}get Wi(){return this._instance.config}get consent(){return this.ws()?0:this.ks}isOptedOut(){return this.Wi.cookieless_mode===Vr||this.isRejected()||-1===this.consent&&this.Wi.cookieless_mode===Hr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Wi.opt_out_capturing_by_default}optInOut(t){this.Ss.Hr(this.xs,t?1:0,this.Wi.cookie_expiration,this.Wi.cross_subdomain_cookie,this.Wi.secure_cookie)}reset(){this.Ss.$r(this.xs,this.Wi.cross_subdomain_cookie)}get xs(){var t=this._instance.config,i=t.token,e=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(e?e+i:"__ph_opt_in_out_"+i)}get ks(){var t=this.Ss.Ur(this.xs);return dt(t)?1:N(vt,t)?0:-1}get Ss(){var t=this.Wi.opt_out_capturing_persistence_type,i="localStorage"===t?Ss:xs;if(!this.Cs||this.Cs!==i){this.Cs=i;var e="localStorage"===t?xs:Ss;e.Ur(this.xs)&&(this.Cs.Ur(this.xs)||this.optInOut(dt(e.Ur(this.xs))),e.$r(this.xs,this.Wi.cross_subdomain_cookie))}return this.Cs}ws(){return!!this.Wi.respect_dnt&&[null==e?void 0:e.doNotTrack,null==e?void 0:e.msDoNotTrack,v.doNotTrack].some((t=>dt(t)))}}function js(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!V(r))return i;try{var s=r(i);return J(s)&&s?s:i}catch(t){return Ie.error("Error in get_current_url, falling back to window.location.href",t),i}}var Bs="__POSTHOG_TOOLBAR__",zs=1,qs=3,Hs=11;function Vs(t){return t instanceof Element&&(t.id===Bs||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Ws(t){return!!t&&t.nodeType===zs}function Gs(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Ks(t){return!!t&&t.nodeType===qs}function Js(t){return!!t&&t.nodeType===Hs&&Ws(t.host)}var Ys=1e3;function Qs(t){return t?L(t).split(/\s+/):[]}function Xs(i,e){var r=function(i){var e,r=null==t||null==(e=t.location)?void 0:e.href;return K(r)?void 0:js(i,r)}(e);return!!(r&&i&&i.some((t=>r.match(t))))}function Zs(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return Qs(i)}function tn(t){return X(t)?null:L(t).split(/(\s+)/).filter((t=>kn(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function en(t){var i="";return _n(t)&&!gn(t)&&t.childNodes&&t.childNodes.length&&es(t.childNodes,(function(t){var e;Ks(t)&&t.textContent&&(i+=null!==(e=tn(t.textContent))&&void 0!==e?e:"")})),L(i)}function rn(t){var i;return K(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var sn=["a","button","form","input","select","textarea","label"];function nn(t,i){if(K(i))return!0;var e,r=function(t){if(i.some((i=>function(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}(t,i))))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function on(t){var i=t.parentNode;return!(!i||!Ws(i))&&i}var an=[".ph-no-autocapture","[data-ph-no-autocapture]"],ln=["next","previous","prev",">","<"],hn=[...ln,"+","-","−","–"],un=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,dn=[".ph-no-rageclick",".ph-no-capture"],vn=["","text","search","email","password","url","tel","number"];function cn(i,e){if(!t||fn(i))return!1;var r,s,n,o,a;if(it(e)?(r=!!e&&dn,s=void 0,n=!1):(r=null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:dn,s=null==e?void 0:e.content_ignorelist,n=null!==(a=null==e?void 0:e.ignore_text_selection)&&void 0!==a&&a),!1===r)return!1;if(n&&function(t){return!(!t||!Ws(t))&&(!!Gs(t,"textarea")||(Gs(t,"input")?N(vn,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var i=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===i||""===i}(t)))}(i))return!1;var l=pn(i,!1).targetElementList;return!function(t,i){if(!1===t||K(t))return!1;var e;if(!0===t)e=ln;else{if(!H(t))return!1;if(t.length>10)return Ie.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map((t=>t.toLowerCase()))}return i.some((t=>{var i=t.safeText,r=t.ariaLabel;return e.some((t=>un(i,t)||un(r,t)))}))}(s,l.map((t=>{var i;return{safeText:en(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!nn(l,r)}var fn=t=>!t||Gs(t,"html")||!Ws(t),pn=(i,e)=>{if(!t||fn(i))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,s=[i],n=i;n.parentNode&&!Gs(n,"body");)if(Js(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=on(n);if(!o)break;if(e||sn.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var a=t.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(r=!0)}catch(t){}s.push(o),n=o}return{parentIsUsefulElement:r,targetElementList:s}};function _n(t){for(var i=new Set,e=0,r=t;r.parentNode&&!Gs(r,"body");r=r.parentNode){if(e++>=Ys||i.has(r))return!1;i.add(r);var s=Zs(r);if(N(s,"ph-sensitive")||N(s,"ph-no-capture"))return!1}if(N(Zs(t),"ph-include"))return!0;var n=t.type||"";if(J(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!J(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function gn(t){return!!(Gs(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Gs(t,"select")||Gs(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var mn=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}))$"),yn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,bn=[16,15,14,13],wn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),xn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),En=/[0-9A-Za-z_]/;function Sn(t){for(var i=0,e=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;e&&(s*=2)>9&&(s-=9),i+=s,e=!e}return i%10==0}function kn(t,i){if(void 0===i&&(i=!0),X(t))return!1;if(J(t)){t=L(t);var e=i?mn.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(yn.lastIndex=0;i=yn.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of bn){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(mn.test(a)&&Sn(a))return!0}}}return!1}(t);if(e)return!1;var r=i?wn.test(t):function(t){var i;for(xn.lastIndex=0;i=xn.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&En.test(e)&&En.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function Tn(t){var i=en(t);return kn(i=(i+" "+$n(t)).trim())?i:""}function $n(t){var i="";return t&&t.childNodes&&t.childNodes.length&&es(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=en(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+$n(t)).trim())}catch(t){Ie.error("[AutoCapture]",t)}})),i}function Pn(t){return t.replace(/"|\\"/g,'\\"')}function Rn(t){var i=t.attr__class;if(i)return H(i)?i:Qs(i)}var Cn=Ae("[Dead Clicks]"),On=()=>!0,In=t=>{var i,e=!(null==(i=t.instance.persistence)||!i.get_property(Qe)),r=t.instance.config.capture_dead_clicks;return it(r)?r:!!W(r)||e};class An{get lazyLoadedDeadClicksAutocapture(){return this.Ts}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[Qe]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ms((()=>{this.Es()})):this.stop()}Ms(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?Cn.error("failed to load script",i):t()}))}Es(){var t;if(r){if(!this.Ts&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=W(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Ts=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ts.start(r),Cn.info("starting...")}}else Cn.error("`document` not found. Cannot start.")}stop(){this.Ts&&(this.Ts.stop(),this.Ts=void 0,Cn.info("stopping..."))}}var Fn=Ae("[SegmentIntegration]");var Mn="posthog-js";function Dn(t,i){var e=void 0===i?{}:i,r=e.organization,s=e.projectId,n=e.prefix,o=e.severityAllowList,a=void 0===o?["error"]:o,l=e.sendExceptionsToPostHog,h=void 0===l||l;return i=>{var e,o,l,u,d;if("*"!==a&&!a.includes(i.level)||!t.__loaded)return i;i.tags||(i.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());i.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(i.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var c,f=(null==(e=i.exception)?void 0:e.values)||[],p=f.map((t=>_({},t,{stacktrace:t.stacktrace?_({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>_({},t,{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null==(o=f[0])?void 0:o.value)||i.message,$exception_type:null==(l=f[0])?void 0:l.type,$exception_level:i.level,$exception_list:p,$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:(null==(u=f[0])?void 0:u.value)||i.message,$sentry_exception_type:null==(d=f[0])?void 0:d.type,$sentry_tags:i.tags};return r&&s&&(g.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+i.event_id),h&&(null==(c=t.exceptions)||c.sendExceptionEvent(g)),i}}class Nn{constructor(t,i,e,r,s,n){this.name=Mn,this.setupOnce=function(o){o(Dn(t,{organization:i,projectId:e,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Ln{constructor(t){this.Is=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(Ie.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Rs=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Ps()}Ps(){var t;this.As=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.Is)}destroy(){var t;null==(t=this.As)||t.call(this),this.As=void 0}doPageView(i,e){var r,s=this.Fs(i,e);return this.Rs={pathname:null!==(r=null==t?void 0:t.location.pathname)&&void 0!==r?r:"",pageViewId:e,timestamp:i},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var i;return this.Fs(t,null==(i=this.Rs)?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.Rs)?void 0:t.pageViewId}}Fs(t,i){var e=this.Rs;if(!e)return{$pageview_id:i};var r={$pageview_id:i,$prev_pageview_id:e.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,h=s.lastContentY,u=s.maxContentY;if(!(K(n)||K(o)||K(a)||K(l)||K(h)||K(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),h=Math.ceil(h),u=Math.ceil(u);var d=n>1?ct(o/n,0,1,Ie):1,v=n>1?ct(a/n,0,1,Ie):1,c=l>1?ct(h/l,0,1,Ie):1,f=l>1?ct(u/l,0,1,Ie):1;r=rs(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:h,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:f})}}return e.pathname&&(r.$prev_pageview_pathname=e.pathname),e.timestamp&&(r.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),r}}var Un=["flags","surveys"],jn={[Ue]:{exposure:"hidden"},[qe]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[He]:{exposure:"hidden"},[Ve]:{exposure:"event"},[We]:{exposure:"hidden"},[Ze]:{exposure:"hidden"},[Ge]:{exposure:"event"},[Ke]:{exposure:"hidden"},[Je]:{exposure:"event"},[Ye]:{exposure:"event"},[Qe]:{exposure:"event"},[Xe]:{exposure:"hidden"},[tr]:{exposure:"event"},[ir]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[ar]:{exposure:"hidden"},[lr]:{exposure:"event"},[er]:{exposure:"event",shouldSkipFromEventProperties:t=>Q(t)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[hr]:{exposure:"hidden",storageGroup:"flags"},[ur]:{exposure:"hidden",storageGroup:"flags"},[dr]:{exposure:"hidden"},[vr]:{exposure:"hidden",storageGroup:"flags"},[cr]:{exposure:"hidden",storageGroup:"flags"},[fr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[pr]:{exposure:"hidden",storageGroup:"flags"},[_r]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[mr]:{exposure:"hidden"},[yr]:{exposure:"hidden"},[wr]:{exposure:"hidden",storageGroup:"surveys"},[xr]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Er]:{exposure:"event"},[Sr]:{exposure:"hidden"},[kr]:{exposure:"hidden"},[Tr]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[$r]:{exposure:"hidden"},[Pr]:{exposure:"hidden"},[br]:{exposure:"event"},[Rr]:{exposure:"hidden"},[Cr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Or]:{exposure:"hidden"},[Ir]:{exposure:"hidden"},[Ar]:{exposure:"hidden"},[Fr]:{exposure:"hidden"},[Mr]:{exposure:"hidden"},[Dr]:{exposure:"hidden"},[Nr]:{exposure:"hidden"},[rr]:{exposure:"event"},[sr]:{exposure:"event"},[nr]:{exposure:"event"},[or]:{exposure:"event"},[jr]:{exposure:"event"},[Br]:{exposure:"event"},[zr]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_pending_trigger_conditions:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},Bn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],zn=t=>{var i=jn[t];if(i)return i;for(var e of Bn){var r=e[1];if(0===t.indexOf(e[0]))return r}},qn=(t,i)=>{try{return JSON.stringify(t,((t,i)=>"bigint"==typeof i?i.toString():i),i)}catch(i){return j(t)}},Hn=t=>{var i=null==r?void 0:r.createElement("a");return K(i)?null:(i.href=t,i)},Vn=function(t,i){for(var e,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===i){e=n;break}}if(!H(e)||2>e.length)return"";var o=e[1];try{o=decodeURIComponent(o)}catch(t){Ie.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Wn=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),h=[],u=0;l.length>u;u++){var d=l[u].split("=");H(d)&&(i.includes(d[0])?h.push(d[0]+"="+e):h.push(l[u]))}var v=a;return null!=o&&(v+="?"+h.join("&")),null!=s&&(v+="#"+s),v},Gn=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Kn=(t,i)=>t>=i&&u(),Jn=(t,i,e,r)=>{if(0===t){if(u()){var s=i+1;return s===e&&r(),s}return i}return 0},Yn="https?://(.*)",Qn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Xn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qn],Zn="<masked>",to=["li_fat_id"];function io(t,i,e){if(!r)return{};var s,n=i?[...Qn,...e||[]]:[],o=eo(Wn(r.URL,n,Zn),t),a=(s={},es(to,(function(t){var i=vs(t);s[t]=i||null})),s);return rs(a,o)}function eo(t,i){var e=Xn.concat(i||[]),r={};return es(e,(function(i){var e=Vn(t,i);r[i]=e||null})),r}function ro(t){var i=function(t){return t?0===t.search(Yn+"google.([^/?]*)")?"google":0===t.search(Yn+"bing.com")?"bing":0===t.search(Yn+"yahoo.com")?"yahoo":0===t.search(Yn+"duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",s={};if(!Q(i)){s.$search_engine=i;var n=r?Vn(r.referrer,e):"";n.length&&(s.ph_keyword=n)}return s}function so(){return navigator.language||navigator.userLanguage}var no="$direct";function oo(){return(null==r?void 0:r.referrer)||no}function ao(t,i,e){void 0===e&&(e=!1);var r=t?[...Qn,...i||[]]:[],n=e?xi(null==s?void 0:s.href):null==s?void 0:s.href,o=null==n?void 0:n.substring(0,1e3);return{r:oo().substring(0,1e3),u:o?Wn(o,r,Zn):void 0}}function lo(t,i){var e;void 0===i&&(i=!1);var r=t.r,s=t.u,n=i?xi(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==no?no:null==(e=Hn(r))?void 0:e.host};if(n){o.$current_url=n;var a=Hn(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=eo(n);rs(o,l)}if(r){var h=ro(r);rs(o,h)}return o}function ho(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function uo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var vo={flags:Cr,surveys:xr},co=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],fo=t=>t+"_cookie_identity_change_pending",po="main",_o=(t,i)=>{es(t,((e,r)=>{var s=zn(r);s&&"event"!==s.exposure||{}.hasOwnProperty.call(i,r)||delete t[r]}))};class go{constructor(i,e,r){if(void 0===r&&(r=!0),this.Os={},this.Ls=!1,this.Ds=!1,this.$s=!1,this.Ns=!1,this.Wi=i,this.qs=r,this.props={},this.js=void 0,this.Bs=(t=>{var i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(i),this.Ss=this.Hs(i),this.Ds=this.Us(i),this.load(),i.debug&&Ie.info("Persistence loaded",i.persistence,_({},this.props)),this.update_config(i,i,e),this.save(),t){var s=()=>this.flush();us(t,"beforeunload",s,{capture:!1}),us(t,"pagehide",s,{capture:!1})}}zs(){var t,i=null==(t=this.Wi)?void 0:t.persistence_save_debounce_ms;return Z(i)&&i>0?i:0}Ws(t){if(this.Wi.cookieWinsOnConflict&&"localstorage+cookie"===this.Wi.persistence.toLowerCase())if(t)try{var i=Cs(t,this.Wi.cookie_persisted_properties||[]),e=Is(i,this.Wi.cookie_persisted_properties||[]),r=JSON.stringify(i)+"|"+JSON.stringify(e),s=xs.Ur(this.Bs)||void 0;s&&Fs(this.Bs,s)===r&&(this.Vs=r,this.Gs=s)}catch(t){}else try{var n=xs.Ur(this.Bs)||void 0;this.Vs=n?Fs(this.Bs,n):void 0,this.Gs=n}catch(t){}}syncCookieProperties(){return this.Zs(this.Wi)}Zs(t,i){if(void 0===i&&(i=!1),this.Qs&&!i||this.Ns||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;var e;try{e=xs.Ur(this.Bs)||void 0}catch(t){}if(!e||e===this.Gs)return!1;var r,s=Fs(this.Bs,e);try{r=Rs(JSON.parse(e))}catch(t){return!1}if((xs.Ur(this.Bs)||void 0)!==e)return!1;this.Vs=s,this.Gs=e;var n=As(this.Bs,e),o=[...Ts,...n.properties],a={};if(Object.keys(r).forEach((t=>{var i=r[t];(K(i)||Q(i)||""===i||t===Or&&i!==Wr&&i!==Gr)&&(a[t]=!0,delete r[t])})),G(r))return!1;var l=je in r||r[Or]===Wr||r[Or]===Gr,h=this.props[je],u=this.props[Or],d=rs({},this.props);[...Ts,...t.cookie_persisted_properties||[]].forEach((t=>{if(-1!==o.indexOf(t)&&!(t in r)&&!a[t]&&(l||t!==je&&t!==Or)){var i=d[t];!n.isValid&&-1!==Ts.indexOf(t)&&(!1===i||0===i)||delete d[t]}})),this.props=rs(d,r),!l||Or in r||Or in this.props||this.Js(Or,Wr);var v=this.props[je],c=this.props[Or];return!l||v===h&&c===u||(this.$s=!0,Ls.Hr(fo(this.Bs),!0),this.Ks(mr),this.Ks(ur),this.Ks(hr),this.Ks(vr),this.Ks(cr),this.Ks(fr),this.Ks(Cr),this.Ks(Rr),this.Ks($r),c===Wr&&(u===Gr||r[Or]===Wr||!K(h)&&v!==h)&&(_o(this.props,r),this.Ks(yr)),c===Gr?this.props.$user_id=v:delete this.props.$user_id,this.Ks(qe)),!0}consumeCookieIdentityChange(){var t=fo(this.Bs),i=this.$s||!!Ls.Ur(t);return this.$s=!1,i&&Ls.$r(t),i}Ys(t){return void 0===t&&(t=!1),!(this.Ns||this.Qs&&!t||!this.Wi.cookieWinsOnConflict||"localstorage+cookie"!==this.Wi.persistence.toLowerCase()||(this.Ns=!0,0))}Xs(){this.Ns&&(K(this.ta)||(clearTimeout(this.ta),this.ta=void 0),delete this.Os[po],this.ea(!0))}ia(t){if(void 0===t&&(t=!0),this.Ns)try{t?this.Xs():K(this.ta)||(clearTimeout(this.ta),this.ta=void 0)}finally{this.Ns=!1}}isDisabled(){return!!this.Qs}Hs(i){-1===co.indexOf(i.persistence.toLowerCase())&&(Ie.critical("Unknown persistence type "+i.persistence+"; falling back to localStorage+cookie"),i.persistence="localStorage+cookie");var e,r=function(i,e){void 0===i&&(i=[]),void 0===e&&(e=!1);var r=[...Ts,...i];return _({},Ss,{zr(t){try{var i,s={};try{i=xs.Ur(t)||void 0,s=i?Rs(JSON.parse(i)):{}}catch(t){}var n,o=JSON.parse(Ss.Ur(t)||"{}");if(e){var a=As(t,i),l=[...Ts,...a.properties],h={};Object.keys(s).forEach((t=>{var i=s[t];Q(i)||""===i||t===Or&&i!==Wr&&i!==Gr||(h[t]=i)}));var u=je in h||h[Or]===Wr||h[Or]===Gr;if(Object.keys(h).length>0){var d,v=o[je],c=null!==(d=o[Or])&&void 0!==d?d:Wr;r.forEach((t=>{if(-1!==l.indexOf(t)&&!(t in s)&&(u||t!==je&&t!==Or)){var i=o[t];!a.isValid&&-1!==Ts.indexOf(t)&&(!1===i||0===i)||delete o[t]}})),!u||Or in s||Or in o||(o[Or]=Wr),!u||(je in h?h[je]:o[je])===v&&(Or in h?h[Or]:o[Or])===c||(ks.forEach((t=>delete o[t])),h[Or]===Gr&&je in h?o.$user_id=h[je]:delete o.$user_id,h[Or]!==Gr&&(delete o[br],delete o[yr]),delete o.__alias)}n=rs(o,h)}else n=rs(s,o);return Ss.Hr(t,n),n}catch(t){}return null},Hr(t,r,s,n,o,a){var l=Ss.Hr(t,r,void 0,void 0,a);try{var h=Cs(r,i);if(Object.keys(h).length){if(e){var u=$s(t),d=Is(h,i);if(xs.Hr(u,d,s,n,o,a),xs.Ur(u)!==JSON.stringify(d)){xs.$r(u,n);var v=Cs(r);return xs.Hr(t,v,s,n,o,a),l}}xs.Hr(t,h,s,n,o,a)}}catch(t){Ss.Wr(t)}return l},$r(i,e){try{null==t||t.localStorage.removeItem(i),xs.$r(i,e),xs.$r($s(i),e)}catch(t){Ss.Wr(t)}}})}(i.cookie_persisted_properties||[],i.cookieWinsOnConflict),s=!1,n=i.persistence.toLowerCase();return"localstorage"===n&&Ss.Br()?(e=Ss,s=!0):"localstorage+cookie"===n&&r.Br()?(e=r,s=!0):"sessionstorage"===n&&Ls.Br()?e=Ls:"memory"===n?e=Ds:"cookie"===n?e=xs:r.Br()?(e=r,s=!0):e=xs,this.Ls=s,e}ra(t){return this.Bs+"__"+t}Us(t){return this.Ls&&!!t.split_storage}properties(){var t={};return es(this.props,((i,e)=>{var r=zn(e);if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(i))return;t[e]=i}})),t}load(t){if(void 0===t&&(t=!1),!this.Qs||t){var i=this.Wi.cookieWinsOnConflict&&"localstorage+cookie"===this.Wi.persistence.toLowerCase(),e=i?Ss.zr(this.Bs):null,r={};if(i)try{es(r=Rs(xs.zr(this.Bs)),((t,i)=>{(K(t)||Q(t)||""===t)&&delete r[i]}))}catch(t){}var s=this.Ss.zr(this.Bs);if(s&&(this.props=rs({},s)),this.Ds&&this.na(),i&&s){var n,o,a=null==e?void 0:e[je],l=null!==(n=null==e?void 0:e[Or])&&void 0!==n?n:Wr,h=s[je],u=null!==(o=s[Or])&&void 0!==o?o:Wr;if(h!==a||u!==l){this.$s=!0,Ls.Hr(fo(this.Bs),!0);var d=rs({},this.props);ks.forEach((t=>delete d[t])),u===Wr&&(l===Gr||r[Or]===Wr||!K(a)&&h!==a)&&(_o(d,r),delete d[yr]),this.props=d;var v=new Set;ks.forEach((t=>{var i,e=null==(i=zn(t))?void 0:i.storageGroup;e&&v.add(e)})),v.forEach((t=>{var i={};es(this.props,((e,r)=>{var s;(null==(s=zn(r))?void 0:s.storageGroup)===t&&(i[r]=e)})),G(i)?(Ss.$r(this.ra(t)),this.Os[t]={}):Ss.Hr(this.ra(t),i)&&(this.Os[t]={persisted:!0,fingerprint:this.sa(i,t)})}))}}Ls.Ur(fo(this.Bs))&&(this.$s=!0)}}na(){for(var t of Un){var i=Ss.zr(this.ra(t));if(i&&!G(i)){var e=this.aa(t);e.persisted=!0,this.oa(t)||(e.fingerprint=this.sa(i,t)),this.la(t,i)||rs(this.props,i)}}}oa(t){return Object.keys(this.props).some((i=>{var e;return(null==(e=zn(i))?void 0:e.storageGroup)===t}))}la(t,i){var e=vo[t];if(!e)return!1;var r=i[e],s=this.props[e];return Z(r)&&Z(s)&&s>r}refreshKey(t){var i;if(!this.Qs){var e=this.Ds?null==(i=zn(t))?void 0:i.storageGroup:void 0,r=e?Ss.zr(this.ra(e)):this.Ss.zr(this.Bs);if(r&&t in r)this.Js(t,r[t]);else{if(e){var s=this.Ss.zr(this.Bs);if(s&&t in s)return void this.Js(t,s[t])}this.Ks(t)}}}save(){if(!this.Qs){var t=this.zs();t>0?K(this.ta)&&(this.ta=setTimeout((()=>{this.ta=void 0,this.ea()}),t)):this.ea()}}flush(){K(this.ta)||(clearTimeout(this.ta),this.ta=void 0,this.ea())}ea(t){void 0===t&&(t=!1),this.Qs||this.Ns&&!t||(t||this.syncCookieProperties(),this.Ds?this.ua():this.ha(this.Ss,this.Bs,this.props,po)&&this.Ws(this.props))}ua(){var t=this.da(),i=t.main,e=t.groups;for(var r of(this.ha(this.Ss,this.Bs,i,po)&&this.Ws(i),Un)){var s,n=e[r];(!G(n)||null!=(s=this.Os[r])&&s.persisted)&&this.ha(Ss,this.ra(r),n,r)}}da(){var t={},i={flags:{},surveys:{}};return es(this.props,((e,r)=>{var s,n=null==(s=zn(r))?void 0:s.storageGroup;n?i[n][r]=e:t[r]=e})),{main:t,groups:i}}sa(t,i){if(i===po)return JSON.stringify(t)+"|"+this.va+"|"+this.ca+"|"+this.fa;var e={};return es(t,((t,i)=>{var r;e[i]=null!=(r=zn(i))&&r.volatile?"__volatile__":t})),JSON.stringify(e)}ha(t,i,e,r){var s,n=this.aa(r);if(r!==po&&!n.dirty&&!K(n.fingerprint))return!1;try{if((s=this.sa(e,r))===n.fingerprint)return n.dirty=!1,!1}catch(t){s=void 0}return t.Hr(i,e,this.va,this.ca,this.fa,this.Wi.debug)?(n.dirty=!1,r!==po&&(n.persisted=!0),K(s)||(n.fingerprint=s),!0):(this.Wi.debug&&Ie.warn('failed to persist storage entry "'+i+'"; will retry on next save'),!1)}remove(t){var i=(void 0===t?{}:t).keepGroupEntries,e=void 0!==i&&i;if(K(this.ta)||(clearTimeout(this.ta),this.ta=void 0),this.Ss.$r(this.Bs,!1),this.Ss.$r(this.Bs,!0),!e&&this.qs)for(var r of Un)Ss.$r(this.ra(r));e?delete this.Os[po]:this.Os={},this.Vs=void 0,this.Gs=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(W(t)){this.syncCookieProperties(),K(i)&&(i="None"),this.va=K(e)?this.pa:e;var r=!1;if(es(t,((t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.Js(e,t),r=!0)})),r)return this.save(),!0}return!1}register(t,i){if(W(t)){this.syncCookieProperties(),this.va=K(i)?this.pa:i;var e=!1;if(es(t,((i,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==i||W(i)||H(i))&&(this.Js(r,i),e=!0)})),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var i="string"==typeof t?[t]:t,e=!1;for(var r of i)r in this.props&&(this.Ks(r),e=!0);e&&this.save()}update_campaign_params(){var t=null==r?void 0:r.URL;if(t!==this.js){var i=io(this.Wi.custom_campaign_params,this.Wi.mask_personal_data_properties,this.Wi.custom_personal_data_properties);G(as(i))||this.register(i),this.js=t}}update_search_keyword(){var t;this.register((t=null==r?void 0:r.referrer)?ro(t):{})}update_referrer_info(){var t;this.register_once({$referrer:oo(),$referring_domain:null!=r&&r.referrer&&(null==(t=Hn(r.referrer))?void 0:t.host)||no},void 0)}set_initial_person_info(){this.props[Fr]||this.props[Mr]||this.register_once({[Dr]:ao(this.Wi.mask_personal_data_properties,this.Wi.custom_personal_data_properties,this.Wi.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};es([Mr,Fr],(i=>{var e=this.props[i];e&&es(e,(function(i,e){t["$initial_"+U(e)]=i}))}));var i=this.props[Dr];if(i){var e=function(t,i){void 0===i&&(i=!1);var e=lo(t,i),r={};return es(e,(function(t,i){r["$initial_"+U(i)]=t})),r}(i,this.Wi.disable_capture_url_hashes);rs(t,e)}return t}safe_merge(t){return es(this.props,(function(i,e){e in t||(t[e]=i)})),t}update_config(t,i,e){var r=t.persistence!==i.persistence,s=!((t,i)=>{if(t.length!==i.length)return!1;var e=[...t].sort(),r=[...i].sort();return e.every(((t,i)=>t===r[i]))})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),n=r||s,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,a=t.disable_persistence||!!e,l=!!this.Qs&&!a;a||this.Zs(i,l),this.Wi=t,!a&&(r||s||o)&&(this.Vs=void 0,this.Gs=void 0,this.Zs(_({},t,{cookie_persisted_properties:i.cookie_persisted_properties}),l));var h=n||o?this.Hs(t):this.Ss,u=this.Us(t),d=n||u!==this.Ds,v=!a&&(d||t.cross_subdomain_cookie!==this.ca||t.secure_cookie!==this.fa)&&this.Ys(l);try{if(this.pa=this.va=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){var c=this.props;this.clear(),this.Ss=h,this.Ds=u,this.props=c,this.save()}else o&&(this.Ss=h,a||(delete this.Os[po],this.ea()))}finally{v&&this.ia()}}set_disabled(t){this.Qs=t,this.Qs?this.remove():this.save()}set_cross_subdomain(t){t!==this.ca&&(this.ca=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.fa&&(this.fa=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){var e=this.props[He]||{};e[t]=i,this.Js(He,e),this.save()}remove_event_timer(t){var i=this.props[He]||{},e=i[t];return K(e)||(delete i[t],this.Js(He,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.Js(t,i),this.save()}Js(t,i){var e;this.props[t]=i,null!=(e=zn(t))&&e.volatile||this.ga(t)}Ks(t){delete this.props[t],this.ga(t)}ga(t){var i,e=null==(i=zn(t))?void 0:i.storageGroup;e&&(this.aa(e).dirty=!0)}aa(t){return this.Os[t]||(this.Os[t]={})}}function mo(t){var i=!0;return{dispose(){if(i){i=!1;var e=t();e&&V(e.then)&&e.then(void 0,(()=>{}))}}}}var yo={GZipJS:"gzip-js",Base64:"base64"},bo={Activation:"events",Cancellation:"cancelEvents"},wo={Button:"button",Tab:"tab",Selector:"selector"},xo={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"},Eo={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},So={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ko={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},To={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},$o={Once:"once",Recurring:"recurring",Always:"always"},Po={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Ro={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"},Co={Popover:"popover",Inline:"inline"},Oo={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},Io={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"},Ao={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"},Fo=Ae("[RateLimiter]");class Mo{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((t=>{Fo.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4}))}catch(t){return void Fo.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var i,e,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(i=null==(e=this.instance.persistence)?void 0:e.get_property(Ar))&&void 0!==i?i:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var h=(Z(a.dropped)?a.dropped:0)+1;a.dropped=h,!this.lastEventRateLimited&&this.ma(h)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(Ar,a),{isRateLimited:l,remainingTokens:a.tokens}}ya(t){var i=this.instance.config.property_denylist;return!H(i)||!i.includes(t)}ba(){var t;if(this.ya("$current_url")&&this.ya("$pathname")&&null!=s&&s.pathname)return""+(null!==(t=s.origin)&&void 0!==t?t:"")+s.pathname}ma(t){var i,e,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.ba(),o=this.ya("$session_id")?null==(i=(e=this.instance).get_session_id)?void 0:i.call(e):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}}var Do=Ae("[RemoteConfig]");class No{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}_a(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}wa(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Do.info("Using preloaded remote config",this.remoteConfig),void this.ka(this.remoteConfig);if(this._instance.Sa())return void Do.warn("Remote config is disabled. Falling back to local config.");this._a((t=>{if(!t)return Do.info("No config found after loading remote JS config. Falling back to JSON."),void this.wa((t=>{this.ka(t.json,t)}));this.ka(t)}))}catch(t){Do.error("Error loading remote config",t),this.ka()}}ka(t,i){!t&&i&&(0===i.statusCode?i.error||Do.warn("Failed to fetch remote config from PostHog."):Do.error("Failed to fetch remote config from PostHog."));try{this._instance.ka(t?{ok:!0,config:t}:{ok:!1})}catch(t){Do.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded()}catch(t){Do.error("Error loading feature flags",t)}}}var Lo=["fatal","error","warning","log","info","debug"],Uo=Uint8Array,jo=Uint16Array,Bo=Uint32Array,zo=new Uo([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]),qo=new Uo([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]),Ho=new Uo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vo=function(t,i){for(var e=new jo(31),r=0;31>r;++r)e[r]=i+=1<<t[r-1];var s=new Bo(e[30]);for(r=1;30>r;++r)for(var n=e[r];e[r+1]>n;++n)s[n]=n-e[r]<<5|r;return[e,s]},Wo=Vo(zo,2),Go=Wo[1];Wo[0][28]=258,Go[258]=28;for(var Ko=Vo(qo,0)[1],Jo=new jo(32768),Yo=0;32768>Yo;++Yo){var Qo=(43690&Yo)>>>1|(21845&Yo)<<1;Jo[Yo]=((65280&(Qo=(61680&(Qo=(52428&Qo)>>>2|(13107&Qo)<<2))>>>4|(3855&Qo)<<4))>>>8|(255&Qo)<<8)>>>1}var Xo=function(t,i,e){for(var r=t.length,s=0,n=new jo(i);r>s;++s)++n[t[s]-1];var o,a=new jo(i);for(s=0;i>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(e){o=new jo(1<<i);var l=15-i;for(s=0;r>s;++s)if(t[s])for(var h=s<<4|t[s],u=i-t[s],d=a[t[s]-1]++<<u,v=d|(1<<u)-1;v>=d;++d)o[Jo[d]>>>l]=h}else for(o=new jo(r),s=0;r>s;++s)o[s]=Jo[a[t[s]-1]++]>>>15-t[s];return o},Zo=new Uo(288);for(Yo=0;144>Yo;++Yo)Zo[Yo]=8;for(Yo=144;256>Yo;++Yo)Zo[Yo]=9;for(Yo=256;280>Yo;++Yo)Zo[Yo]=7;for(Yo=280;288>Yo;++Yo)Zo[Yo]=8;var ta=new Uo(32);for(Yo=0;32>Yo;++Yo)ta[Yo]=5;var ia=Xo(Zo,9,0),ea=Xo(ta,5,0),ra=function(t){return(t/8>>0)+(7&t&&1)},sa=function(t,i,e){(null==e||e>t.length)&&(e=t.length);var r=new(t instanceof jo?jo:t instanceof Bo?Bo:Uo)(e-i);return r.set(t.subarray(i,e)),r},na=function(t,i,e){var r=i/8>>0;t[r]|=e<<=7&i,t[r+1]|=e>>>8},oa=function(t,i,e){var r=i/8>>0;t[r]|=e<<=7&i,t[r+1]|=e>>>8,t[r+2]|=e>>>16},aa=function(t,i){for(var e=[],r=0;t.length>r;++r)t[r]&&e.push({s:r,f:t[r]});var s=e.length,n=e.slice();if(!s)return[new Uo(0),0];if(1==s){var o=new Uo(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort((function(t,i){return t.f-i.f})),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,u=1,d=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=e[e[d].f>e[h].f?h++:d++],l=e[h!=u&&e[d].f>e[h].f?h++:d++],e[u++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new jo(v+1),f=la(e[u-1],c,0);if(f>i){r=0;var p=0,_=f-i,g=1<<_;for(n.sort((function(t,i){return c[i.s]-c[t.s]||t.f-i.f}));s>r;++r){var m=n[r].s;if(i>=c[m])break;p+=g-(1<<f-c[m]),c[m]=i}for(p>>>=_;p>0;){var y=n[r].s;i>c[y]?p-=1<<i-c[y]++-1:++r}for(;r>=0&&p;--r){var b=n[r].s;c[b]==i&&(--c[b],++p)}f=i}return[new Uo(c),f]},la=function(t,i,e){return-1==t.s?Math.max(la(t.l,i,e+1),la(t.r,i,e+1)):i[t.s]=e},ha=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new jo(++i),r=0,s=t[0],n=1,o=function(t){e[r++]=t},a=1;i>=a;++a)if(t[a]==s&&a!=i)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[e.subarray(0,r),i]},ua=function(t,i){for(var e=0,r=0;i.length>r;++r)e+=t[r]*i[r];return e},da=function(t,i,e){var r=e.length,s=ra(i+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=e[n];return 8*(s+4+r)},va=function(t,i,e,r,s,n,o,a,l,h,u){na(i,u++,e),++s[256];for(var d=aa(s,15),v=d[0],c=d[1],f=aa(n,15),p=f[0],_=f[1],g=ha(v),m=g[0],y=g[1],b=ha(p),w=b[0],x=b[1],E=new jo(19),S=0;m.length>S;++S)E[31&m[S]]++;for(S=0;w.length>S;++S)E[31&w[S]]++;for(var k=aa(E,7),T=k[0],P=k[1],R=19;R>4&&!T[Ho[R-1]];--R);var C,O,I,A,F=h+5<<3,M=ua(s,Zo)+ua(n,ta)+o,D=ua(s,v)+ua(n,p)+o+14+3*R+ua(E,T)+(2*E[16]+3*E[17]+7*E[18]);if(M>=F&&D>=F)return da(i,u,t.subarray(l,l+h));if(na(i,u,1+(M>D)),u+=2,M>D){C=Xo(v,c,0),O=v,I=Xo(p,_,0),A=p;var N=Xo(T,P,0);for(na(i,u,y-257),na(i,u+5,x-1),na(i,u+10,R-4),u+=14,S=0;R>S;++S)na(i,u+3*S,T[Ho[S]]);u+=3*R;for(var L=[m,w],U=0;2>U;++U){var j=L[U];for(S=0;j.length>S;++S)na(i,u,N[B=31&j[S]]),u+=T[B],B>15&&(na(i,u,j[S]>>>5&127),u+=j[S]>>>12)}}else C=ia,O=Zo,I=ea,A=ta;for(S=0;a>S;++S)if(r[S]>255){var B;oa(i,u,C[257+(B=r[S]>>>18&31)]),u+=O[B+257],B>7&&(na(i,u,r[S]>>>23&31),u+=zo[B]);var z=31&r[S];oa(i,u,I[z]),u+=A[z],z>3&&(oa(i,u,r[S]>>>5&8191),u+=qo[z])}else oa(i,u,C[r[S]]),u+=O[r[S]];return oa(i,u,C[256]),u+O[256]},ca=new Bo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fa=function(){for(var t=new Bo(256),i=0;256>i;++i){for(var e=i,r=9;--r;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),pa=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function _a(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,r=0;i.length>r;++r)e=fa[255&e^i[r]]^e>>>8;t=e},d(){return 4294967295^t}}}(),r=t.length;e.p(t);var s,n,o,a,l,h=(a=10+((s=i).filename&&s.filename.length+1||0),l=8,function(t,i,e,r,s,n){var o=t.length,a=new Uo(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),h=0;if(!i||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?h=da(l,h,t.subarray(u,d)):(l[u]=!0,h=da(l,h,t.subarray(u,o)))}else{for(var v=ca[i-1],c=v>>>13,f=8191&v,p=(1<<e)-1,_=new jo(32768),g=new jo(p+1),m=Math.ceil(e/3),y=2*m,b=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<y)&p},w=new Bo(25e3),x=new jo(288),E=new jo(32),S=0,k=0,T=(u=0,0),P=0,R=0;o>u;++u){var C=b(u),O=32767&u,I=g[C];if(_[O]=I,g[C]=O,u>=P){var A=o-u;if((S>7e3||T>24576)&&A>423){h=va(t,l,0,w,x,E,k,T,R,u-R,h),T=S=k=0,R=u;for(var F=0;286>F;++F)x[F]=0;for(F=0;30>F;++F)E[F]=0}var M=2,D=0,N=f,L=O-I&32767;if(A>2&&C==b(u-L))for(var U=Math.min(c,A)-1,j=Math.min(32767,u),B=Math.min(258,A);j>=L&&--N&&O!=I;){if(t[u+M]==t[u+M-L]){for(var z=0;B>z&&t[u+z]==t[u+z-L];++z);if(z>M){if(M=z,D=L,z>U)break;var q=Math.min(L,z-2),H=0;for(F=0;q>F;++F){var V=u-L+F+32768&32767,W=V-_[V]+32768&32767;W>H&&(H=W,I=V)}}}L+=(O=I)-(I=_[O])+32768&32767}if(D){w[T++]=268435456|Go[M]<<18|Ko[D];var G=31&Go[M],K=31&Ko[D];k+=zo[G]+qo[K],++x[257+G],++E[K],P=u+M,++S}else w[T++]=t[u],++x[t[u]]}}h=va(t,l,!0,w,x,E,k,T,R,u-R,h)}return sa(a,0,r+ra(h)+s)}(n=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),u=h.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&pa(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var r=0;e.length>=r;++r)t[r+10]=e.charCodeAt(r)}}(h,i),pa(h,u-8,e.d()),pa(h,u-4,r),h}var ga=!!o||!!n,ma="text/plain",ya=!1,ba=(t,i)=>{var e=t.split("#"),r=e[1],s=e[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter((t=>t.split("=")[0]!==i)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},wa=function(t,i,e){var r;void 0===e&&(e=!0);var s=t.split("?"),n=s[0],o=s[1],a=_({},i),l=null!==(r=null==o?void 0:o.split("&").map((t=>{var i,r=t.split("="),s=r[0],n=e&&null!==(i=a[s])&&void 0!==i?i:r[1];return delete a[s],s+"="+n})))&&void 0!==r?r:[],h=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return es(t,(function(t,i){K(t)||K(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)})),s.join(i)}(a);return h&&l.push(h),l.length>0?n+"?"+l.join("&"):n},xa=t=>{if(t.xa)return t.xa;var i=t.data,e=t.compression;if(i){if(e===yo.GZipJS){var r=_a(function(t,i){var e=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var r=new Uo(t.length+(t.length>>>1)),s=0,n=function(t){r[s++]=t},o=0;e>o;++o){if(s+5>r.length){var a=new Uo(s+8+(e-o<<1));a.set(r),r=a}var l=t.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return sa(r,0,s)}(qn(i)),{mtime:0});return{contentType:ma,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(e===yo.Base64){var s=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,i)=>String.fromCharCode(parseInt(i,16))))):t}(qn(i)),n=(t=>"data="+encodeURIComponent("string"==typeof t?t:qn(t)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=qn(i);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Ea=t=>{var i,e,r=()=>"sendBeacon"===t.transport?{url:wa(t.url,{compression:yo.Base64}),encodedBody:xa(_({},t,{compression:yo.Base64,xa:void 0}))}:{url:ba(t.url,"compression"),encodedBody:xa(_({},t,{compression:void 0,xa:void 0}))};try{i=xa(t)}catch(i){if(Ri(t.compression,Vn(t.url,"compression")))return Ie.error("Failed to gzip request body, sending uncompressed payload",i),r();throw i}return i&&Ri(t.compression,Vn(t.url,"compression"))&&!((e=i.body)instanceof ArrayBuffer?Pi(new Uint8Array(e)):ArrayBuffer.isView(e)&&Pi(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)))?(ya=!0,r()):{url:t.url,encodedBody:i}},Sa=t=>{try{return Ea(t)}catch(i){return Ie.error(i),void(null==t.callback||t.callback({statusCode:0,error:i}))}},ka=function(){var t=p((function*(t){var i=qn(t.data),e=yield function(t,i,e){return Ai.apply(this,arguments)}(i,c.DEBUG,{rethrow:!0});if(!e)return t;var r=yield e.arrayBuffer();return _({},t,{xa:{contentType:ma,body:r,estimatedSize:r.byteLength}})}));return function(i){return t.apply(this,arguments)}}(),Ta=/Failed to fetch|NetworkError|Load failed/i,$a=t=>"TypeError"===(null==t?void 0:t.name)&&Ta.test((null==t?void 0:t.message)||""),Pa=t=>{var i=Sa(t);if(i){var e=i.url,r=i.encodedBody,s=null!=r?r:{},o=s.contentType,l=s.body,h=s.estimatedSize,u=new Headers;es(t.headers,(function(t,i){u.append(i,t)})),o&&u.append("Content-Type",o);var d=null,v=!1;if(a){var c=new a;d={signal:c.signal,timeout:setTimeout((()=>{var i;v=!0,c.abort(wi("AbortError","PostHog request timed out"+((i=t.timeout)?" after "+i+"ms":"")))}),t.timeout)}}var f=i=>{v&&"AbortError"===(null==i?void 0:i.name)||$a(i)?Ie.warn(i):Ie.error(i),null==t.callback||t.callback({statusCode:0,error:i})};try{var p;n(e,_({method:(null==t?void 0:t.method)||"GET",headers:u,keepalive:"POST"===t.method&&!t.Ca&&52428.8>(h||0),body:l,signal:null==(p=d)?void 0:p.signal},t.fetchOptions)).then((i=>i.text().then((e=>{var r={statusCode:i.status,text:e};if(200===i.status)try{r.json=JSON.parse(e)}catch(t){Ie.error(t)}null==t.callback||t.callback(r)})))).catch(f).finally((()=>d?clearTimeout(d.timeout):null))}catch(t){d&&clearTimeout(d.timeout),f(t)}}},Ra=t=>{try{var i,r=Ea(t),s=r.url,n=r.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var h=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(e.sendBeacon(s,h))return;var u=H(t.data)?t.data:null==(i=t.data)?void 0:i.batch;if(H(u)&&u.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(u.length/2),v=i=>H(t.data)?i:_({},t.data,{batch:i});return Ra(_({},t,{data:v(u.slice(0,d))})),void Ra(_({},t,{data:v(u.slice(d))}))}Ie.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),Pa(_({},t,{Ca:!0}))}catch(t){Ie.warn("Beacon send failed",t)}},Ca=(t,i,e,r)=>{var s="query"===r?"POST"===i?"sent_at":"_":void 0;return wa(e===yo.GZipJS?ba(t,"compression"):t,_({},s?{[s]:Date.now().toString()}:{},e===yo.GZipJS?{}:{compression:e}))},Oa=[];n&&Oa.push({transport:"fetch",method:Pa}),o&&Oa.push({transport:"XHR",method(t){var i=Sa(t);if(i){var e=new o,r=i.encodedBody;e.open(t.method||"GET",i.url,!0);var s=null!=r?r:{},n=s.contentType,a=s.body;es(t.headers,(function(t,i){e.setRequestHeader(i,t)})),n&&e.setRequestHeader("Content-Type",n),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i={statusCode:e.status,text:e.responseText};if(200===e.status)try{i.json=JSON.parse(e.responseText)}catch(t){}null==t.callback||t.callback(i)}},e.send(a)}}}),null!=e&&e.sendBeacon&&Oa.push({transport:"sendBeacon",method:Ra});var Ia=3e3;class Aa{constructor(t,i){this.Ta=!0,this.Ma=[],this.Ea=ct((null==i?void 0:i.flush_interval_ms)||Ia,250,5e3,Ie.createLogger("flush interval"),Ia),this.Ia=t}enqueue(t){this.Ma.push(t),this.Ra||this.Pa()}unload(){this.Aa();var t=this.Ma.length>0?this.Fa():{},i=Object.values(t);[...i.filter((t=>0===t.url.indexOf("/e"))),...i.filter((t=>0!==t.url.indexOf("/e")))].map((t=>{this.Oa(_({},t,{transport:"sendBeacon"}))}))}enable(){this.Ta=!1,this.Pa()}Pa(){var t=this;this.Ta||(this.Ra=setTimeout((()=>{if(this.Aa(),this.Ma.length>0){var i=this.Fa(),e=function(){var e=i[r],s=(new Date).getTime();e.data&&H(e.data)&&es(e.data,(t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp})),t.Oa(e)};for(var r in i)e()}}),this.Ea))}Oa(t){try{this.Ia(t)}catch(t){Ie.error(t)}}Aa(){clearTimeout(this.Ra),this.Ra=void 0}Fa(){var t={};return es(this.Ma,(i=>{var e,r=i,s=(r?r.batchKey:null)||r.url;K(t[s])&&(t[s]=_({},r,{data:[]})),null==(e=t[s].data)||e.push(r.data)})),this.Ma=[],t}}var Fa=["retriesPerformedSoFar"];class Ma{constructor(i){this.La=!1,this.Da=3e3,this.Ma=[],this._instance=i,this.Ma=[],this.$a=!0,!K(t)&&"onLine"in t.navigator&&(this.$a=t.navigator.onLine,this.Na=()=>{this.$a=!0,this.qa()},this.ja=()=>{this.$a=!1},us(t,"online",this.Na),us(t,"offline",this.ja))}get length(){return this.Ma.length}retriableRequest(t){var i=t.retriesPerformedSoFar,e=g(t,Fa);tt(i)&&(e.url=wa(e.url,{retry_count:i})),this._instance._send_request(_({},e,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=i?i:0))return void this.Pn(_({retriesPerformedSoFar:i},e));0===t.statusCode&&Ie.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==e.callback||e.callback(t)}}))}Pn(t){var i=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=i+1;var e=function(t){var i=3e3*Math.pow(2,t),e=i/2,r=Math.min(18e5,i),s=Math.random()-.5;return Math.ceil(r+s*(r-e))}(i),r=Date.now()+e;this.Ma.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+e;navigator.onLine||(s+=" (Browser is offline)"),Ie.warn(s),this.La||(this.La=!0,this.Ba())}Ba(){if(this.Ha&&clearTimeout(this.Ha),0===this.Ma.length)return this.La=!1,void(this.Ha=void 0);this.Ha=setTimeout((()=>{this.$a&&this.Ma.length>0&&this.qa(),this.Ba()}),this.Da)}qa(){var t=Date.now(),i=[],e=this.Ma.filter((e=>t>e.retryAt||(i.push(e),!1)));if(this.Ma=i,e.length>0)for(var r of e)this.retriableRequest(r.requestOptions)}unload(){for(var i of(this.Ha&&(clearTimeout(this.Ha),this.Ha=void 0),this.La=!1,K(t)||(this.Na&&(t.removeEventListener("online",this.Na),this.Na=void 0),this.ja&&(t.removeEventListener("offline",this.ja),this.ja=void 0)),this.Ma)){var e=i.requestOptions;try{this._instance._send_request(_({},e,{transport:"sendBeacon"}))}catch(t){Ie.error(t)}}this.Ma=[]}}class Da{constructor(t){this.Ua=()=>{var t,i,e,r;this.za||(this.za={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.za.lastScrollY=Math.ceil(n),this.za.maxScrollY=Math.max(n,null!==(t=this.za.maxScrollY)&&void 0!==t?t:0),this.za.maxScrollHeight=Math.max(o,null!==(i=this.za.maxScrollHeight)&&void 0!==i?i:0),this.za.lastContentY=a,this.za.maxContentY=Math.max(a,null!==(e=this.za.maxContentY)&&void 0!==e?e:0),this.za.maxContentHeight=Math.max(l,null!==(r=this.za.maxContentHeight)&&void 0!==r?r:0)},this._instance=t}get Wa(){return this._instance.config.scroll_root_selector}getContext(){return this.za}resetContext(){var t=this.za;return setTimeout(this.Ua,0),t}startMeasuringScrollPosition(){us(t,"scroll",this.Ua,{capture:!0}),us(t,"scrollend",this.Ua,{capture:!0}),us(t,"resize",this.Ua)}scrollElement(){if(!this.Wa)return null==t?void 0:t.document.documentElement;var i=H(this.Wa)?this.Wa:[this.Wa];for(var e of i){var r=null==t?void 0:t.document.querySelector(e);if(r)return r}}Va(i){var e="y"===i?"scrollTop":"scrollLeft";if(this.Wa){var r=this.scrollElement();return r&&r[e]||0}return t?"y"===i?t.scrollY||t.pageYOffset||t.document.documentElement.scrollTop||0:t.scrollX||t.pageXOffset||t.document.documentElement.scrollLeft||0:0}scrollY(){return this.Va("y")}scrollX(){return this.Va("x")}}var Na=t=>ao(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);class La{constructor(t,i,e,r){this.st=t=>{var i=this.Ga();if(!i||i.sessionId!==t){var e={sessionId:t,props:this.Za(this._instance)};this.Qa.register({[Ir]:e})}},this._instance=t,this.Ja=i,this.Qa=e,this.Za=r||Na,this.Ja.onSessionId(this.st)}Ga(){return this.Qa.props[Ir]}getSetOnceProps(){var t,i=null==(t=this.Ga())?void 0:t.props;return i?"r"in i?lo(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var t={};return es(as(this.getSetOnceProps()),((i,e)=>{"$current_url"===e&&(e="url"),t["$session_entry_"+U(e)]=i})),t}}class Ua{on(t,i){return this.Ka[t]||(this.Ka[t]=[]),this.Ka[t].push(i),()=>{this.Ka[t]=this.Ka[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.Ka[t]||[])e(i);for(var r of this.Ka["*"]||[])r(t,i)}constructor(){this.Ka={}}}var ja=Ae("[SessionId]"),Ba=864e5;class za{on(t,i){return this.Ya.on(t,i)}constructor(t,i,e){var r;if(this.Xa=null,this.eo=null,this.io=[],this.ro=void 0,this.no=!1,this.Ya=new Ua,this.so=(t,i)=>!(!tt(t)||!tt(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===Vr)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Wi=t.config,this.Qa=t.persistence,this.ut=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.ao=void 0,this._sessionActivityTimestamp=null,this.oo=i||ms,this.lo=e||ms;var s=this.Wi.persistence_name||this.Wi.token;if(this._sessionTimeoutMs=1e3*ct(this.Wi.session_idle_timeout_seconds||1800,60,36e3,ja.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.uo(),this.ho="ph_"+s+"_window_id",this.do="ph_"+s+"_primary_window_exists",this.vo()){var n=Ls.zr(this.ho),o=Ls.zr(this.do);n&&!o?this.ut=n:Ls.$r(this.ho),Ls.Hr(this.do,!0)}null!=(r=this.Wi.bootstrap)&&r.sessionID&&this.setBootstrapSessionId(this.Wi.bootstrap.sessionID),this.co()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return K(this.io)&&(this.io=[]),this.io.push(t),this._e&&t(this._e,this.ut),()=>{this.io=this.io.filter((i=>i!==t))}}vo(){return"memory"!==this.Wi.persistence&&!this.Qa.Qs&&Ls.Br()}fo(t){t!==this.ut&&(this.ut=t,this.vo()&&Ls.Hr(this.ho,t))}po(){return this.ut?this.ut:this.vo()?Ls.zr(this.ho):null}mo(t){var i=this.Xa;return!Q(i)&&!Q(t)&&5e3>Math.abs(t-i)}yo(t,i,e){var r=i!==this._sessionActivityTimestamp,s=!(t!==this._e||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this._e=t,s&&!r||s&&this.mo(i)||(this.Xa=i,this.Qa.register({[ar]:[i,t,e]}))}bo(){var t,i=null==(t=this.Wi)?void 0:t.persistence_save_debounce_ms;return tt(i)&&i>0}_o(){this.bo()?this.Qa.refreshKey(ar):(this.Qa.flush(),this.Qa.load())}wo(){var t;if(!Q(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Xa){this._o();var i=this.ko();i[1]===this._e&&i[2]===this._sessionStartTimestamp&&(this.Xa=this._sessionActivityTimestamp,this.Qa.register({[ar]:[this._sessionActivityTimestamp,null!==(t=this._e)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Qa.flush())}}So(){var t=this.ko()[0],i=tt(t)?t:0,e=tt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}xo(t){return this._o(),this.so(t,this.So())}ko(){var t=this.Qa.props[ar];return H(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Xa=null,this.ao=void 0,clearTimeout(this.Co),this.Co=void 0,this.yo(null,null,null)}setBootstrapSessionId(t,i){void 0===i&&(i=!1);var e=function(t,i){void 0===i&&(i=(new Date).getTime());try{var e=(t=>{var i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void ja.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void ja.error("Invalid sessionID in bootstrap",t)}}(t);return!K(e)&&(i?this.ao={sessionId:t,sessionStartTimestamp:e}:this.yo(t,(new Date).getTime(),e),!0)}destroy(){this.no=!0,this.wo(),clearTimeout(this.Co),this.Co=void 0,this.ro&&t&&(t.removeEventListener(Yr,this.ro,{capture:!1}),this.ro=void 0),this.io=[]}co(){this.ro=()=>{this.wo(),this.vo()&&Ls.$r(this.do)},us(t,Yr,this.ro,{capture:!1})}checkAndGetSessionAndWindowId(t,i,e){if(void 0===t&&(t=!1),void 0===i&&(i=null),void 0===e&&(e=!1),this.Wi.cookieless_mode===Vr)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=i||(new Date).getTime(),s=this._e;if(e)this.eo=r;else if(Q(this.eo)||this.eo>r||r-this.eo>=1e3){var n,o;null==(n=(o=this.Qa).syncCookieProperties)||n.call(o),this.eo=r}var a=this.ko(),l=a[1],h=a[2],u=!K(s)&&l!==s,d=this.So(),v=this.po(),c=this.ao,f=!!c&&(c.sessionStartTimestamp>r+6e4||r-c.sessionStartTimestamp>Ba),p=c?f:tt(h)&&Math.abs(r-h)>Ba,_=!1,g=u,m=!l||!!c,y=l,b=!m&&!t&&this.so(r,d);if(b){(b=this.xo(r))||ja.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this.ko();l=w[1],h=w[2]}if(m||b||p){g=!1;var x=c&&!f;l=x?c.sessionId:this.oo(),v=this.lo(),ja.info("new session ID assigned",{sessionId:l,windowId:v,bootstrapped:!!x,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p}}),h=x?c.sessionStartTimestamp:r,this.ao=void 0,_=!0}else v||(v=this.lo(),_=!0),(g=g||l!==y)&&(ja.info("adopted cross-tab session id",{sessionId:l,windowId:v}),_=!0);var E=tt(d)&&t&&!p?d:r,S=tt(h)?h:(new Date).getTime();this.fo(v),this.yo(l,E,S),t||this.uo();var k={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p,crossTabAdoption:g};return _&&this.io.forEach((t=>t(l,v,k))),{sessionId:l,windowId:v,sessionStartTimestamp:S,changeReason:_?k:void 0,lastActivityTimestamp:d}}uo(){this.no||(clearTimeout(this.Co),this.Co=setTimeout((()=>{if(!this.no)if(this.xo((new Date).getTime())){var t=this._e;this.resetSessionId(),this.Ya.emit("forcedIdleReset",{idleSessionId:t})}else this.uo()}),1.1*this.sessionTimeoutMs))}}var qa=function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&D(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>D(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver};function Ha(){return(Ha=p((function*(){var t=null==e?void 0:e.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var i=yield t.getHighEntropyValues(["model"]),r=null==i?void 0:i.model;return J(r)&&r.length>0?r:void 0}catch(t){return void Ie.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}}))).apply(this,arguments)}function Va(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var Wa=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Ga=t=>t.toLowerCase(),Ka={exact:(t,i)=>i.some((i=>t.some((t=>i===t)))),is_not:(t,i)=>i.every((i=>t.every((t=>i!==t)))),regex:(t,i)=>i.some((i=>t.some((t=>Wa(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!Wa(i,t))))),icontains:(t,i)=>i.map(Ga).some((i=>t.map(Ga).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(Ga).every((i=>t.map(Ga).every((t=>!i.includes(t))))),gt:(t,i)=>i.some((i=>{var e=parseFloat(i);return!isNaN(e)&&t.some((t=>e>parseFloat(t)))})),lt:(t,i)=>i.some((i=>{var e=parseFloat(i);return!isNaN(e)&&t.some((t=>e<parseFloat(t)))}))};function Ja(t,i){return!t||Object.entries(t).every((t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(null==r)return!1;var s=Ka[e.operator];return!!s&&s(e.values,[String(r)])}))}function Ya(t,i,e){return qn({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}var Qa="custom",Xa="i.posthog.com",Za=/^\/static\//,tl=["/s/","/e/","/i/"];class il{constructor(t){this.To={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,i=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace("."+Xa,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.To[this.apiHost]||(this.To[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":Qa),this.To[this.apiHost]}Mo(t){if(Za.test(t)){var i=this.instance.config.asset_host;if("string"==typeof i)return i.trim().replace(/\/$/,"")||void 0}}Eo(t){var i=Hn(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}Io(t,i,e){if("ui"===t)return e;var r=e,s=this.instance.config.rewriteRequestPath;if(s){var n,o=(null==(n=Hn(e))?void 0:n.href)||e;r=s(new URL(o)).toString()}if(s&&"api"===t&&tl.some((t=>0===i.indexOf(t)))){var a=this.Eo(r);if(a){var l,h=this.apiHost,u=this.Ro;(null==(l=u)?void 0:l.apiHost)===h&&u.rewriteRequestPath===s||(u={apiHost:h,rewriteRequestPath:s,urls:new Set},this.Ro=u),u.urls.add(a)}}return r}isIngestionEndpoint(t){var i=this.Ro,e=this.Eo(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i){if(void 0===i&&(i=""),i&&(i="/"===i[0]?i:"/"+i),"ui"===t)return this.Io(t,i,this.uiHost+i);if("flags"===t)return this.Io(t,i,this.flagsApiHost+i);if("assets"===t){var e=this.Mo(i);if(e)return this.Io(t,i,""+e+i)}if(this.region===Qa)return this.Io(t,i,this.apiHost+i);var r=Xa+i;switch(t){case"assets":return this.Io(t,i,"https://"+this.region+"-assets."+r);case"api":return this.Io(t,i,"https://"+this.region+"."+r)}}}var el=Ae("[Surveys]"),rl="seenSurvey_",sl=t=>{try{var i=(t=>((t,i)=>""+rl+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(i))(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){el.error("Failed to persist survey seen state",t)}},nl=[So.Popover,So.Widget,So.API],ol={ignoreConditions:!1,ignoreDelay:!1,displayType:Co.Popover},al=Ae("[PostHog ExternalIntegrations]"),ll={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class hl{constructor(t){this._instance=t}Ms(t,i){var e;null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,t,(t=>{if(t)return al.error("failed to load script",t);i()}))}startIfEnabledOrStop(){var t=this,i=function(){var i,r,s,n=e[0],o=e[1];!o||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[n]||t.Ms(ll[n],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[n])||i.start(t._instance)})),!o&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=v.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var e of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;i()}}}class ul{constructor(t,i){this.I=t,this.vs=i,this.Po=new Map,this.ls=!1}add(t){var i=this;return p((function*(){if(i.ls)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.Po.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');i.Po.set(t.name,t);try{var e=t.setup(i.vs);e&&(yield e)}catch(e){var r=i.Po.get(t.name)===t;r&&i.Po.delete(t.name),i.I.error('Failed to set up browser extension "'+t.name+'"',e),r&&i.Ao(t)}}))()}getExtension(t){return this.Po.get(t)}dispose(){if(!this.ls){this.ls=!0;var t=Array.from(this.Po.values()).reverse();for(var i of(this.Po.clear(),t))this.Ao(i)}}Ao(t){try{var i=null==t.dispose?void 0:t.dispose();i&&V(i.then)&&i.then(void 0,(i=>{this.I.error('Failed to dispose browser extension "'+t.name+'"',i)}))}catch(i){this.I.error('Failed to dispose browser extension "'+t.name+'"',i)}}}class dl{constructor(t){this._instance=t}initialize(){}get(t){var i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);var e={};for(var r of t){var s=null==i?void 0:i.get_property(r);K(s)||(e[r]=s)}return e}set(t,i){var e;null==(e=this._instance.persistence)||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null==(i=this._instance.persistence)||i.unregister(t)}}var vl="extensionsRemoteConfig";class cl{constructor(t){this.ls=!1,this.instance=t,this.I=Ie,this.Fo=t.Oo,this.kv=new dl(t),this.onEvent=t=>mo(this.instance.on("eventCaptured",(i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.I.error("Browser extension event listener failed",t)}}))),this.onRemoteConfig=t=>{if(this.ls)return mo((()=>{}));var i=i=>{try{t(i)}catch(t){this.I.error("Browser extension remote config listener failed",t)}},e=this.instance.Lo.on(vl,i);return this.Fo&&i(this.Fo),mo(e)},this.Do=new ul(Ie.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property(Be))&&void 0!==t?t:this.distinctId}get deviceId(){var t=this.instance.get_property(Be);return"string"==typeof t?t:void 0}get library(){return{name:c.LIB_NAME,version:c.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null==(i=this.instance.persistence)?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==s?void 0:s.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==s?void 0:s.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.Do.add(t)}getExtension(t){return this.Do.getExtension(t)}capture(t,i,e){var r=this;return p((function*(){e?r.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):r.instance.capture(t,i)}))()}registerDynamicEventProperties(t){return mo(this.instance.$o(t))}handleRemoteConfig(t){this.ls||(this.Fo=t,this.instance.Lo.emit(vl,t))}sendRequest(t,i){var e=this;return p((function*(){var r;void 0===i&&(i={});var s=e.instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",t),n={method:i.method,url:i.query?wa(s,i.query):s,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?E.Base64:void 0,timestampMode:i.sentAt};return"sendBeacon"===i.transport?(e.instance._send_request(n),{statusCode:202}):new Promise((t=>{n.callback=t,e.instance._send_request(n)}))}))()}dispose(){this.ls||(this.ls=!0,this.Do.dispose())}}var fl={},pl=0,_l=()=>{},gl='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ml="Surveys module not available",yl="sanitize_properties is deprecated. Use before_send instead",bl="Invalid value for property_denylist config: ",wl=["token","distinct_id",Ur],xl="posthog",El=!ga&&-1===(null==h?void 0:h.indexOf("MSIE"))&&-1===(null==h?void 0:h.indexOf("Mozilla")),Sl=t=>{var i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},kl=i=>{var e;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:hs(null==r?void 0:r.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:_l,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=i?i:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:s&&J(null==s?void 0:s.search)&&-1!==s.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==t||null==(e=t.location)?void 0:e.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){Ie.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Kr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Ia},error_tracking:{},_onCapture:_l},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:hn,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:Sl(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(i))},Tl=[["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"]],$l=t=>{var i={};for(var e of Tl){var r=e[0],s=e[1];K(t[r])||(i[s]=t[r])}var n=rs({},i,t),o=t.__preview_external_dependency_versioned_paths;return K(o)||(K(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),J(o)&&K(t.asset_host)&&(n.asset_host=o)),H(t.property_blacklist)&&(K(t.property_denylist)?n.property_denylist=t.property_blacklist:H(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:Ie.error(bl+t.property_denylist)),n};class Pl{constructor(){this.__forceAllowLocalhost=!1}get No(){return this.__forceAllowLocalhost}set No(t){Ie.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Rl{qo(t,i){if(t){var e=this.Po.indexOf(t);-1!==e&&this.Po.splice(e,1)}return this.Po.push(i),null==i.initialize||i.initialize(),i}jo(){return this.config.cookieless_mode===Vr||this.config.cookieless_mode===Hr&&this.consent.isRejected()}Bo(){if(!this.jo()&&this.get_distinct_id()===Lr){var t=this.persistence;if(t){this.Ho()||t.load(!0);var i=this.get_distinct_id();if(!i||i===Lr){var e=this.config.get_device_id(ms());this.register({distinct_id:e,$device_id:e}),t.set_property(Or,Wr)}this.Uo()}}}get decideEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.webPerformance=new Pl,this.zo=!1,this.version=c.LIB_VERSION,this.Wo=new Set,this.Vo="",this.Lo=new Ua,this.Po=[],this.Go=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=kl(),this.SentryIntegration=Nn,this.sentryIntegration=t=>function(t,i){var e=Dn(t,i);return{name:Mn,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Zo=!1,this.Qo=null,this.Jo=null,this.Ko=null,this.scrollManager=new Da(this),this.pageViewManager=new Ln(this),this.rateLimiter=new Mo(this),this.requestRouter=new il(this),this.consent=new Us(this),this.externalIntegrations=new hl(this);var i=null!==(t=Rl.__defaultExtensionClasses)&&void 0!==t?t:{};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:(t,i,e)=>{var r=J(t)?{[t]:i}:t;this.setPersonProperties(r),null==e||e({})},set_once:(t,i,e)=>{var r=J(t)?{[t]:i}:t;this.setPersonProperties(void 0,r),null==e||e({})}},this.on("eventCaptured",(t=>Ie.info('send "'+(null==t?void 0:t.event)+'"',t)))}init(t,i,e){if(e&&e!==xl){var r,s=null!==(r=fl[e])&&void 0!==r?r:new Rl;return s._init(t,i,e),fl[e]=s,fl[xl][e]=s,s}return this._init(t,i,e)}_init(i,e,r){var s,n;void 0===e&&(e={});var o,a=J(i)?i.trim():"";if(!a)return Ie.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return a!==(null==(o=this.config)?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=kl(e.defaults),e.debug=this.Yo(e.debug),this.Xo=e,this.tl=[],e.person_profiles?this.Jo=e.person_profiles:e.process_person&&(this.Jo=e.process_person);var l=kl(e.defaults),h=$l(e),u=rs({},l,h,{name:r,token:a});W(l.rageclick)&&W(h.rageclick)&&(u.rageclick=rs({},l.rageclick,h.rageclick)),W(l.session_recording)&&W(h.session_recording)&&(u.session_recording=rs({},l.session_recording,h.session_recording)),this.set_config(u),this.config.on_xhr_error&&Ie.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=e.disable_compression?void 0:yo.GZipJS;var d=this.Ho();if(this.persistence=new go(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new go(_({},this.config,{persistence:"sessionStorage"}),d,!1),this.Vo="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!d&&Ls.Br()){var v=Ls.zr(this.Vo);H(v)&&v.forEach((t=>{J(t)&&this.Wo.add(t)}))}else Ls.$r(this.Vo);var f=_({},this.persistence.props),p=_({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.el=new Aa((t=>this.il(t)),this.config.request_queue_config),this.rl=new Ma(this),this.__request_queue=[];var g=this.jo();if(g||(this.sessionManager=new za(this),this.sessionPropsManager=new La(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((t,i,e)=>{(null!=e&&e.activityTimeout||null!=e&&e.sessionPastMaximumLength||null!=e&&e.crossTabAdoption)&&this.nl()}))),this.sl(),this.config.__preview_deferred_init_extensions?(Ie.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.al(g)}),0)):(Ie.info("Initializing extensions synchronously"),this.al(g)),c.DEBUG=c.DEBUG||this.config.debug,c.DEBUG&&Ie.info("Starting in debug mode",{this:this,config:e,thisC:_({},this.config),p:f,s:p}),!this.config.identity_distinct_id||null!=(s=e.bootstrap)&&s.distinctID||(e.bootstrap=_({},e.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(n=e.bootstrap)?void 0:n.distinctID)){var m=e.bootstrap.distinctID,y=this.get_distinct_id(),b=this.persistence.get_property(Or);if(e.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Wr)this.identify(m);else if(e.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Gr)Ie.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var w=this.config.get_device_id(ms()),x=e.bootstrap.isIdentifiedID?w:m;this.persistence.set_property(Or,e.bootstrap.isIdentifiedID?Gr:Wr),this.register({distinct_id:m,$device_id:x})}}if(g)this.register_once({distinct_id:Lr,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(ms());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(Or,Wr)}return us(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),e.segment?function(t,i){var e=t.config.segment;if(!e)return i();!function(t,i){var e=t.config.segment;if(!e)return i();var r=e=>{var r=()=>e.anonymousId()||ms();t.config.get_device_id=r,e.id()&&(t.register({distinct_id:e.id(),$device_id:r()}),t.persistence.set_property(Or,Gr)),i()},s=e.user();"then"in s&&V(s.then)?s.then(r):r(s)}(t,(()=>{e.register((t=>{"undefined"!=typeof Promise&&Promise.resolve||Fn.warn("This browser does not have Promise support, and can not use the segment integration");var i=(i,e)=>{if(!e)return i;i.event.userId||i.event.anonymousId===t.get_distinct_id()||(Fn.info("No userId set, resetting PostHog"),t.reset()),i.event.userId&&i.event.userId!==t.get_distinct_id()&&(Fn.info("UserId set, identifying with PostHog"),t.identify(i.event.userId));var r=t.calculateEventProperties(e,i.event.properties);return i.event.properties=Object.assign({},r,i.event.properties),i};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:t=>i(t,t.event.event),page:t=>i(t,Qr),identify:t=>i(t,Zr),screen:t=>i(t,"$screen")}})(t)).then((()=>{i()}))}))}(this,(()=>this.ol())):this.ol(),V(this.config._onCapture)&&this.config._onCapture!==_l&&(Ie.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(t=>this.config._onCapture(t.event,t)))),this.config.ip&&Ie.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 Ha.apply(this,arguments)}().then((t=>{t&&this.register({[ze]:t})})).catch(_l),this}ll(t){var i=t;return J(i.name)&&V(i.setup)}ul(t,i){this.ll(t)?i.push((()=>{this.hl().add(t).catch((()=>null==t.dispose?void 0:t.dispose())).catch((i=>{Ie.error('Failed to dispose browser extension "'+t.name+'"',i)}))})):this.Po.push(t)}sl(){var t,i,e,r,s,n,o=null!==(t=null==(i=this.config.__extensionClasses)?void 0:i.featureFlags)&&void 0!==t?t:null==(e=Rl.__defaultExtensionClasses)?void 0:e.featureFlags;o&&(this.featureFlags&&this.featureFlags instanceof o||(null==(r=this.dl)||r.call(this),this.dl=void 0,this.featureFlags=new o(this)),V(this.featureFlags.onReloading)&&V(this.featureFlags.setup)?this.dl||(this.dl=this.featureFlags.onReloading((()=>{this.Lo.emit("featureFlagsReloading",!0)})),this.hl().add(this.featureFlags)):null==(s=(n=this.featureFlags).initialize)||s.call(n))}al(t){var i,e,r,s,n,o,a,l=performance.now(),h=_({},Rl.__defaultExtensionClasses,this.config.__extensionClasses),u=[];h.exceptions&&this.Po.push(this.exceptions=null!==(i=this.exceptions)&&void 0!==i?i:new h.exceptions(this)),h.historyAutocapture&&this.Po.push(this.historyAutocapture=new h.historyAutocapture(this)),h.tracingHeaders&&this.Po.push(this.tracingHeaders=new h.tracingHeaders(this)),h.siteApps&&this.Po.push(this.siteApps=new h.siteApps(this)),h.sessionRecording&&!t&&this.Po.push(this.sessionRecording=new h.sessionRecording(this)),this.config.disable_scroll_properties||u.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),h.autocapture&&this.ul(this.autocapture=new h.autocapture(this),u),h.surveys&&this.ul(this.surveys=null!==(e=this.surveys)&&void 0!==e?e:new h.surveys(this),u),h.logs&&this.ul(this.logs=null!==(r=this.logs)&&void 0!==r?r:new h.logs(this),u),h.metrics&&this.Po.push(this.metrics=null!==(s=this.metrics)&&void 0!==s?s:new h.metrics(this)),h.conversations&&this.Po.push(this.conversations=null!==(n=this.conversations)&&void 0!==n?n:new h.conversations(this)),h.productTours&&this.Po.push(this.productTours=new h.productTours(this)),h.heatmaps&&this.Po.push(this.heatmaps=new h.heatmaps(this)),h.webVitalsAutocapture&&this.Po.push(this.webVitalsAutocapture=new h.webVitalsAutocapture(this)),h.exceptionObserver&&this.Po.push(this.exceptionObserver=new h.exceptionObserver(this)),h.deadClicksAutocapture&&this.Po.push(this.deadClicksAutocapture=new h.deadClicksAutocapture(this,In)),h.toolbar&&this.Po.push(this.toolbar=null!==(o=this.toolbar)&&void 0!==o?o:new h.toolbar(this)),h.experiments&&this.Po.push(this.experiments=null!==(a=this.experiments)&&void 0!==a?a:new h.experiments(this)),this.Po.forEach((t=>{t.initialize&&u.push((()=>{null==t.initialize||t.initialize()}))})),u.push((()=>{if(this.vl){var t=this.vl;this.vl=void 0,this.Po.forEach((i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t)))}})),this.cl(u,l)}cl(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout((()=>{this.cl(t,i)}),0);var e=t.shift();if(e)try{e()}catch(t){Ie.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-i);this.register_for_session({[jr]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Br]:r}),this.config.__preview_deferred_init_extensions&&Ie.info("PostHog extensions initialized ("+r+"ms)")}ka(t){var i;if(!r||!r.body)return Ie.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.ka(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.vl=t),this.Oo=t,this.compression=void 0,t.ok){var e,s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=N(s.supportedCompression,yo.GZipJS)?yo.GZipJS:N(s.supportedCompression,yo.Base64)?yo.Base64:void 0),null!=(e=s.analytics)&&e.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.Jo?this.Jo:Kr}),null==(i=this.fl)||i.handleRemoteConfig(t),this.Po.forEach((i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t)))}ol(){try{this.config.loaded(this)}catch(t){Ie.critical("`loaded` function failed",t)}if(this.pl(),this.config.internal_or_test_user_hostname&&null!=s&&s.hostname){var t=s.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.jo())&&this.gl()}),1),this.ml=new No(this),this.ml.load()}pl(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.el)||t.enable())}_dom_loaded(){this.is_capturing()&&is(this.__request_queue,(t=>this.il(t))),this.__request_queue=[],this.pl()}_handle_unload(){var t,i,e,r,s;null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(i=this.metrics)||i.flush("sendBeacon"),this.config.request_batching?(this.yl()&&this.capture(Xr),null==(e=this.logs)||e.flushLogs("sendBeacon"),null==(r=this.el)||r.unload(),null==(s=this.rl)||s.unload()):this.yl()&&this.capture(Xr,null,{transport:"sendBeacon"})}_send_request(t){var i;this.__loaded?El?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=_({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?null!==(i=this.compression)&&void 0!==i?i:t.compressionFallback:t.compression,(K(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var i,e,r,s=_({},t);s.timeout=s.timeout||6e4;var n,o,a,h,u,d=null!==(i=s.transport)&&void 0!==i?i:"fetch";"sendBeacon"===d&&K(s.compression)&&s.data&&(s.compression=yo.Base64),"POST"===s.method&&s.data&&("capture-body"===s.timestampMode?s.data={api_key:null!==(o=null==(u=(h=(H(n=s.data)?n:[n]).map((t=>_({},t,t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{}))))[0])||null==(a=u.properties)?void 0:a.token)&&void 0!==o?o:null==u?void 0:u.token,batch:h,sent_at:(new Date).toISOString()}:"body"===s.timestampMode&&(s.data=function(t,i){return void 0===i&&(i=(new Date).toISOString()),H(t)?t.map((t=>_({},t,{sent_at:i}))):_({},t,{sent_at:i})}(s.data))),s.url=Ca(s.url,s.method,s.compression,s.timestampMode);var v=Oa.filter((t=>!s.disableTransport||!t.transport||!s.disableTransport.includes(t.transport))),c=null!==(e=null==(r=function(t,i){for(var e=0;t.length>e;e++)if(t[e].transport===d)return t[e]}(v))?void 0:r.method)&&void 0!==e?e:v[0].method;if(!c)throw new Error("No available transport method");var f=t=>{try{c(t)}catch(t){$a(t)?Ie.warn(t):Ie.error(t),null==s.callback||s.callback({statusCode:0,error:t})}};"sendBeacon"!==d&&s.data&&s.compression===yo.GZipJS&&l&&"undefined"!=typeof Promise&&!ya?ka(s).then((t=>{f(t)})).catch((i=>{if(Ci(i))return ya=!0,void f(_({},s,{compression:void 0,url:Ca(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var i="name"in t?String(t.name):"";return Ci(t)||i===$i})(i)&&(ya=!0),f(s)})):c(s)})(_({},t,{callback:i=>{var e,r;this.rateLimiter.checkForLimiting(i),400>i.statusCode||null==(e=(r=this.config).on_request_error)||e.call(r,i),null==t.callback||t.callback(i)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}il(t){this.rl?this.rl.retriableRequest(t):this._send_request(t)}_execute_array(t){pl++;try{var i,e=[],r=[],s=[];is(t,(t=>{if(t)if(H(i=t[0]))s.push(t);else if(V(t))try{t.call(this)}catch(i){Ie.error("Error executing queued PostHog call",t,i)}else H(t)&&"alias"===i?e.push(t):H(t)&&-1!==i.indexOf("capture")&&V(this[i])?s.push(t):r.push(t)}));var n=function(t,i){is(t,(function(t){try{if(H(t[0])){var e=i;es(t,(function(t){e=e[t[0]].apply(e,t.slice(1))}))}else i[t[0]].apply(i,t.slice(1))}catch(i){Ie.error("Error executing queued PostHog call",t,i)}}))};n(e,this),n(r,this),n(s,this)}finally{pl--}}push(t){if(pl>0&&H(t)&&J(t[0])){var i=Rl.prototype[t[0]];V(i)&&i.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,i,e){var r,s,n,o,a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.el){if(this.is_capturing())if(!K(t)&&J(t)){this.Bo();var l=!this.config.opt_out_useragent_filter&&this._is_bot();if(!l||this.config.__preview_capture_bot_pageviews){var h=null!=e&&e.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==h||!h.isRateLimited){null!=i&&i.$current_url&&!J(null==i?void 0:i.$current_url)&&(Ie.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||null!=e&&e.bl||Ie.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var u=new Date,d=(null==e?void 0:e.timestamp)||u,v=bi(null==e?void 0:e.uuid,ms),c={uuid:v,event:t,properties:this.calculateEventProperties(t,i||{},d,v)};t===Qr&&this.config.__preview_capture_bot_pageviews&&l&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),h&&(c.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens);var f="$feature_flag_called"===t&&!1===c.properties.$feature_flag_has_experiment&&!0===this.get_property(pr);(null==e?void 0:e.$set)&&!f&&(c.$set=null==e?void 0:e.$set);var p=null==e?void 0:e.$unset;p&&(c.$unset=p);var g,m,y,b=f?void 0:this._l(null==e?void 0:e.$set_once,t!==ts,t===Zr);if(b&&(c.$set_once=b),null!=e&&e._noTruncate||(s=this.config.properties_string_max_length,n=c,o=t=>J(t)?t.slice(0,s):t,a=new Set,c=function t(i,e){if(i!==Object(i))return o?o(i):i;if(!a.has(i)){var r;if(a.add(i),H(i))r=[],is(i,(i=>{r.push(t(i))}));else{var s={};es(i,((i,e)=>{a.has(i)||(s[e]=t(i,e))})),r=s}return r}}(n)),c.timestamp=d,K(null==e?void 0:e.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=u),f&&(c.properties=function(t,i){void 0===i&&(i=[]);var e={},r=i=>{void 0!==t[i]&&(e[i]=t[i])};return w.forEach(r),i.forEach(r),e}(c.properties,wl)),t===Po.DISMISSED||t===Po.SENT){var x=null==i?void 0:i[Ro.SURVEY_ID],E=null==i?void 0:i[Ro.SURVEY_ITERATION];sl({id:x,current_iteration:E}),c.$set=_({},c.$set,{[(g={id:x,current_iteration:E},m=t===Po.SENT?"responded":"dismissed",y="$survey_"+m+"/"+g.id,g.current_iteration&&g.current_iteration>0&&(y="$survey_"+m+"/"+g.id+"/"+g.current_iteration),y)]:!0})}else t===Po.SHOWN&&(c.$set=_({},c.$set,{[Ro.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(t===Io.SHOWN){var S=null==i?void 0:i[Ao.TOUR_TYPE];S&&(c.$set=_({},c.$set,{[Ao.TOUR_LAST_SEEN_DATE+"/"+S]:(new Date).toISOString()}))}var k=_({},c.properties.$set,c.$set);if(G(k)||this.setPersonPropertiesForFlags(k),!X(this.config.before_send)){var T=this.In(c);if(!T)return;(c=T).uuid=bi(c.uuid,ms)}this.Lo.emit("eventCaptured",c);var P=null!==(r=null==e?void 0:e._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),R={method:"POST",url:P,data:c,compression:"best-available",timestampMode:"recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(P)?"body":"capture-body",batchKey:null==e?void 0:e._batchKey,transport:null==e?void 0:e.transport};return!this.config.request_batching||e&&(null==e||!e._batchKey)||null!=e&&e.send_instantly?this.il(R):this.el.enqueue(R),c}Ie.critical("This capture call is ignored due to client rate limiting.")}}else Ie.error("No event name provided to posthog.capture")}else Ie.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(i=>t(i.event,i)))}getExtension(t){var i;return null==(i=this.fl)?void 0:i.getExtension(t)}hl(){var t;return null!==(t=this.fl)&&void 0!==t?t:this.fl=new cl(this)}$o(t){this.Go.push(t);var i=!0;return()=>{if(i){i=!1;var e=this.Go.indexOf(t);-1!==e&&this.Go.splice(e,1)}}}wl(t){var i,e,r;return void 0===t&&(t=!0),!(null==(i=this.persistence)||!i.consumeCookieIdentityChange())&&(this.Ko=null,this.persistence.get_property(Or)===Wr&&(null==(r=this.sessionPersistence)||r.clear(),this.Wo.clear(),this.kl()),null==(e=this.featureFlags)||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(i,e,n,o,a){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return e;this.persistence.syncCookieProperties(),this.wl();var l=a?void 0:this.persistence.remove_event_timer(i),u=_({},e);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this.jo()&&(u[Ur]=!0),"$snapshot"===i){var d=_({},this.persistence.properties(),this.sessionPersistence.properties());return u.distinct_id=d.distinct_id,(!J(u.distinct_id)&&!Z(u.distinct_id)||Y(u.distinct_id))&&Ie.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}var v,f=function(i,e,r,n){var o,a,l,u;if(void 0===n&&(n=!1),!h)return{};var d,v=i?[...Qn,...e||[]]:[],f=function(t){for(var i=0;gi.length>i;i++){var e=gi[i],r=e[1],s=e[0].exec(t),n=s&&(V(r)?r(s,t):r);if(n)return n}return["",""]}(h),p=f[0],_=f[1],g=null!=(d="undefined"!=typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};K(r)||(m.detectGoogleSearchApp=r);var y={},b=null==(o=navigator)||null==(o=o.userAgentData)?void 0:o.platform,w=null==(a=navigator)?void 0:a.maxTouchPoints,x=null==t||null==(l=t.screen)?void 0:l.width,E=null==t||null==(u=t.screen)?void 0:u.height,S=null==t?void 0:t.devicePixelRatio;K(b)||(y.userAgentDataPlatform=b),K(w)||(y.maxTouchPoints=w),K(x)||(y.screenWidth=x),K(E)||(y.screenHeight=E),K(S)||(y.devicePixelRatio=S);var k,T,P,R,C,O,I,A,F=rs(as({$os:p,$os_version:_,$browser:fi(h,navigator.vendor,g,m),$device:mi(h),$device_type:(T=h,P=y,A=mi(T),A===bt||A===yt||"Kobo"===A||"Kindle Fire"===A||A===Yt?mt:A===Ut||A===Bt||A===jt||A===Gt?"Console":A===xt?"Wearable":A?pt:"Android"===(null==P?void 0:P.userAgentDataPlatform)&&(null!==(R=null==P?void 0:P.maxTouchPoints)&&void 0!==R?R:0)>0?600>Math.min(null!==(C=null==P?void 0:P.screenWidth)&&void 0!==C?C:0,null!==(O=null==P?void 0:P.screenHeight)&&void 0!==O?O:0)/(null!==(I=null==P?void 0:P.devicePixelRatio)&&void 0!==I?I:1)?pt:mt:"Desktop"),$timezone:ho(),$timezone_offset:uo()}),{$current_url:Wn(n?xi(null==s?void 0:s.href):null==s?void 0:s.href,v,Zn),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:h.length>1e3?h.substring(0,997)+"...":h,$browser_version:_i(h,navigator.vendor,g,m),$browser_language:so(),$browser_language_prefix:(k=so(),"string"==typeof k?k.split("-")[0]:void 0),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return c.SDK_DIST_CHANNEL&&(F.$sdk_dist_channel=c.SDK_DIST_CHANNEL),F}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var p=this.sessionManager.checkAndGetSessionAndWindowId(a,n.getTime(),!0),g=p.windowId;u.$session_id=p.sessionId,u.$window_id=g}this.sessionPropsManager&&rs(u,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&rs(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=null==(m=this.rl)?void 0:m.length}catch(t){u.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===Qa&&(u.$lib_custom_api_host=this.config.api_host),v=i!==Qr||a?i!==Xr||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,o),u=rs(u,v),i===Qr&&r&&(u.title=r.title),!K(l)){var y=n.getTime()-l;u.$duration=parseFloat((y/1e3).toFixed(3))}h&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?"bot":"browser");var b=this.persistence.properties(),w=this.sessionPersistence.properties();es(["$referrer","$referring_domain"],(t=>{t in b&&delete w[t]}));var x={};if(this.Go.length>0)for(var E of this.Go.slice())try{rs(x,E())}catch(t){Ie.error("Failed to produce browser extension event properties",t)}(u=rs({},f,b,w,_({},x,u))).$is_identified=this._isIdentified(),H(this.config.property_denylist)?es(this.config.property_denylist,(function(t){delete u[t]})):Ie.error(bl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(Ie.error(yl),u=S(u,i));var k=this.Sl();return u.$process_person_profile=k,k&&!a&&this.xl("_calculate_event_properties"),u}_l(t,i,e){var r;if(void 0===i&&(i=!0),void 0===e&&(e=!1),!this.persistence||!this.Sl())return t;if(this.zo&&!e)return t;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=rs({},s,n||{},t||{}),a=this.config.sanitize_properties;return a&&(Ie.error(yl),o=a(o,"$set_once")),i&&(this.zo=!0),G(o)?void 0:o}register(t,i){var e;null==(e=this.persistence)||e.register(t,i)}register_once(t,i,e){var r;null==(r=this.persistence)||r.register_once(t,i,e)}register_for_session(t){var i,e;null==(i=this.persistence)||i.syncCookieProperties(),this.wl(),null==(e=this.sessionPersistence)||e.register(t),Object.keys(t).forEach((t=>this.Wo.add(t))),this.kl()}unregister(t){var i;null==(i=this.persistence)||i.unregister(t)}unregister_for_session(t){var i;null==(i=this.sessionPersistence)||i.unregister(t),this.Wo.delete(t),this.kl()}Cl(t,i){this.register({[t]:i})}nl(){this.Wo.forEach((t=>{var i;null==(i=this.sessionPersistence)||i.unregister(t)})),this.Wo.clear(),this.kl()}kl(){var t;if(this.Vo)if("memory"===this.config.persistence||null!=(t=this.sessionPersistence)&&t.Qs||!Ls.Br())Ls.$r(this.Vo);else{var i=[];this.Wo.forEach((t=>i.push(t))),i.length>0?Ls.Hr(this.Vo,i):Ls.$r(this.Vo)}}getFeatureFlag(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,r;return null!==(e=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,i,e){var r;null==(r=this.featureFlags)||r.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i,e){var r;return void 0===i&&(i=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.Lo.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:ml}),()=>{})}onSessionId(t){var i,e;return null!==(i=null==(e=this.sessionManager)?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:ml})}getActiveMatchingSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:ml})}renderSurvey(t,i){var e;null==(e=this.surveys)||e.renderSurvey(t,i)}displaySurvey(t,i){var e;void 0===i&&(i=ol),null==(e=this.surveys)||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null==(i=this.surveys)||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null==(e=this.surveys)?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:ml}}canRenderSurveyAsync(t,i){var e,r;return void 0===i&&(i=!1),null!==(e=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:ml})}Tl(t){return!t||Y(t)?(Ie.critical("Unique user id has not been set in posthog.identify"),!1):t===Lr?(Ie.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Ie.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return Ie.uninitializedWarning("posthog.identify");if(Z(t)&&(t=t.toString(),Ie.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Tl(t)&&this.xl("posthog.identify")){this.Bo();var r=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,n=this.wl(!1),o=this.persistence.Ys(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:t}),this.get_property(Be)||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),t!==l&&t!==this.get_property(qe)&&(this.unregister(qe),this.register({distinct_id:t}));var h,u=(this.persistence.get_property(Or)||Wr)===Wr,d=t!==l,v=!d&&u;if(d&&u)this.persistence.set_property(Or,Gr),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Xs(),this.capture(Zr,{distinct_id:t,$anon_distinct_id:l},{$set:i||{},$set_once:e||{}}),this.Ko=Ya(t,i,e),null==(h=this.featureFlags)||h.setAnonymousDistinctId(l);else if(v){this.persistence.set_property(Or,Gr);var c=i||{},f=e||{};this.setPersonPropertiesForFlags({$set:c,$set_once:f},!1),this.config.cookieWinsOnConflict&&this.persistence.Xs(),this.capture("$set",{$set:c,$set_once:f}),this.Ko=Ya(t,i,e)}else(i||e)&&this.setPersonProperties(i,e);d||s||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister($r)):v&&(i||e)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.ia(a)}}}setPersonProperties(t,i){if((t||i)&&this.xl("posthog.setPersonProperties")){var e=Ya(this.get_distinct_id(),t,i);this.Ko!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}}),this.Ko=e):Ie.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var i,e=(H(t)?t:[t]).filter((t=>J(t)&&t.length>0));0!==e.length&&this.xl("posthog.unsetPersonProperties")&&(null==(i=this.featureFlags)||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.Ko=null)}group(t,i,e){var r;if(t&&i){null==(r=this.persistence)||r.syncCookieProperties(),this.wl();var s=this.getGroups(),n=s[t]!==i;if(n&&this.resetGroupPropertiesForFlags(t),this.register({$groups:_({},s,{[t]:i})}),n||e){var o={$group_type:t,$group_key:i};e&&(o.$group_set=e),this.capture(ts,o)}e&&this.setGroupPropertiesForFlags({[t]:e}),n&&!e&&this.reloadFeatureFlags()}else Ie.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),null==(e=this.featureFlags)||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),this.xl("posthog.setGroupPropertiesForFlags")&&(null==(e=this.featureFlags)||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null==(i=this.featureFlags)||i.resetGroupPropertiesForFlags(t)}reset(t){var i=it(t)?t:null==t?void 0:t.resetDeviceID,e=it(t)||null==t?void 0:t.bootstrap;this.Ml(i,!1,e)}Ml(t,i,e){var r,s,n;if(void 0===i&&(i=!1),Ie.info("reset"),!this.__loaded)return Ie.uninitializedWarning("posthog.reset");var o=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null==(r=this.Xo)?void 0:r.bootstrap)||{},null==(s=this.featureFlags)||null==s.updateConfig||s.updateConfig(this.config,this.Sa());var a=this.get_property(Be),l=this.get_property(ze),h=this.get_property(ir),u=this.is_capturing();this.consent.reset(),i||!u||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.");var d=null==(n=this.persistence)||null==n.Ys?void 0:n.Ys(),v=!1;try{var c,f,p,g,m,y,b,w,x,E,S,k,T;if(null==(c=this.persistence)||c.clear(),null==(f=this.sessionPersistence)||f.clear(),this.Wo.clear(),this.kl(),K(h)||null==(E=this.persistence)||E.register({[ir]:h}),null==(p=this.surveys)||p.reset(),null==(g=this.featureFlags)||g.reset(),null==(m=this.conversations)||m.reset(),null==(y=this.logs)||y.reset(),null==(b=this.metrics)||b.reset(),null==(w=this.persistence)||w.set_property(Or,Wr),null==(x=this.sessionManager)||x.resetSessionId(),this.Ko=null,this.config.cookieless_mode===Vr)this.register_once({distinct_id:Lr,$device_id:null},"");else{var P=this.config.get_device_id(ms());this.register_once({distinct_id:P,$device_id:t?P:a},""),t||K(l)||this.register({[ze]:l})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(void 0===e.distinctID||this.jo()||(null==(T=this.persistence)||T.set_property(Or,e.isIdentifiedID?Gr:Wr),this.register({distinct_id:e.distinctID})),null==(S=this.featureFlags)||S.initialize(),!(K(o)||null!=(k=this.sessionManager)&&k.setBootstrapSessionId(o,!0))){var R=_({},e);delete R.sessionID,this.config.bootstrap=R}delete this.config.identity_distinct_id,delete this.config.identity_hash,v=!0}finally{var C;d&&(null==(C=this.persistence)||null==C.ia||C.ia(v))}this.reloadFeatureFlags()}shutdown(t){var i=this;return p((function*(){var t,e,r,s,n;if(i.__loaded){i.hl().dispose(),null==(t=i.sessionRecording)||t.dispose(),null==(e=i.logs)||e.flushLogs("sendBeacon"),null==(r=i.metrics)||r.flush("sendBeacon"),null==(s=i.el)||s.unload(),null==(n=i.rl)||n.unload();try{var o;null==(o=i.featureFlags)||o.destroy()}catch(t){Ie.error("Error while destroying feature flags",t)}}else Ie.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,i){var e;this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null==(e=this.conversations)||e.El()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(t=this.conversations)||t.Il()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var i=this.sessionManager.checkAndGetSessionAndWindowId(!0),e=i.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i.sessionId);if(null!=t&&t.withTimestamp&&e){var s,n=null!==(s=t.timestampLookBack)&&void 0!==s?s:10;if(!e)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-e)/1e3)-n,0)}return r}alias(t,i){return t===this.get_property(Ue)?(Ie.critical("Attempting to create alias for existing People user - aborting."),-2):this.xl("posthog.alias")?(K(i)&&(i=this.get_distinct_id()),t!==i?(this.Cl(qe,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(Ie.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var i=_({},this.config);if(W(t)){var e,r,s,n,o,a,l,h,u,d,v,f;rs(this.config,$l(t));var p=this.Ho();null==(e=this.persistence)||e.update_config(this.config,i,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new go(_({},this.config,{persistence:"sessionStorage"}),p,!1);var g,m=this.Yo(this.config.debug);it(m)&&(this.config.debug=m),it(this.config.debug)&&(this.config.debug?(c.DEBUG=!0,Ss.Br()&&Ss.Hr("ph_debug",!0),Ie.info("set_config",{config:t,oldConfig:i,newConfig:_({},this.config)})):(c.DEBUG=!1,Ss.Br()&&Ss.$r("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this.Sa()),null==(s=this.exceptionObserver)||s.onConfigChange(),null==(n=this.exceptions)||n.onConfigChange(),null==(o=this.sessionRecording)||o.startIfEnabledOrStop(),null==(a=this.tracingHeaders)||a.startIfEnabledOrStop(),null==(l=this.autocapture)||l.startIfEnabled(),null==(h=this.heatmaps)||h.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null==(g=this.historyAutocapture)||g.startIfEnabledOrStop()),null==(u=this.exceptionObserver)||u.startIfEnabledOrStop(),null==(d=this.deadClicksAutocapture)||d.startIfEnabledOrStop(),null==(v=this.surveys)||v.loadIfEnabled(),this.Uo(),null==(f=this.externalIntegrations)||f.startIfEnabledOrStop()}}_overrideSDKInfo(t,i){c.LIB_NAME=t,c.LIB_VERSION=i}startSessionRecording(t){var i,e,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(i=this.sessionManager)||i.checkAndGetSessionAndWindowId(),a.sampling&&(null==(e=this.sessionRecording)||e.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,i){if(this.exceptions){var e=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:e});return this.exceptions.sendExceptionEvent(_({},r,i))}}addExceptionStep(t,i){var e;null==(e=this.exceptions)||e.addExceptionStep(t,i)}captureLog(t){var i;null==(i=this.logs)||i.captureLog(t)}get logger(){var t,i;return null!==(t=null==(i=this.logs)?void 0:i.logger)&&void 0!==t?t:Rl.Rl}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null==(e=this.toolbar)?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null==(i=this.persistence)?void 0:i.props[t]}getSessionProperty(t){var i;return null==(i=this.sessionPersistence)?void 0:i.props[t]}toString(){var t,i=null!==(t=this.config.name)&&void 0!==t?t:xl;return i!==xl&&(i=xl+"."+i),i}_isIdentified(){var t,i;return(null==(t=this.persistence)?void 0:t.get_property(Or))===Gr||(null==(i=this.sessionPersistence)?void 0:i.get_property(Or))===Gr}Sl(){var t,i;return!("never"===this.config.person_profiles||this.config.person_profiles===Kr&&!this._isIdentified()&&G(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t[qe])&&(null==(i=this.persistence)||null==(i=i.props)||!i[Nr]))}yl(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.Sl()||this.xl("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.xl("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}xl(t){return"never"===this.config.person_profiles?(Ie.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Cl(Nr,!0),!0)}Ho(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Hr)}Uo(){var t,i,e,r,s,n=this.Ho();return this.is_capturing()||null==(e=this.logs)||e.Pl(),(null==(t=this.persistence)?void 0:t.Qs)!==n&&(null==(r=this.persistence)||r.set_disabled(n)),(null==(i=this.sessionPersistence)?void 0:i.Qs)!==n&&(null==(s=this.sessionPersistence)||s.set_disabled(n)),n&&(this.Wo.clear(),this.kl()),n}opt_in_capturing(t){var i;if(this.config.cookieless_mode!==Vr){if(this.jo()){var e,r,s,n,o;this.Ml(!0,!0),null==(e=this.sessionManager)||e.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new za(this),this.pageViewManager=new Ln(this),this.persistence&&(this.sessionPropsManager=new La(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=Rl.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this.qo(this.sessionRecording,new l(this)),this.Oo&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this.Oo)))}var h,u;this.consent.optInOut(!0),this.Uo(),this.pl(),null==(i=this.sessionRecording)||i.startIfEnabledOrStop(),this.config.cookieless_mode==Hr&&(null==(h=this.surveys)||h.loadIfEnabled()),(K(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(u=null==t?void 0:t.captureEventName)&&void 0!==u?u:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.gl()}else Ie.warn(gl)}opt_out_capturing(){var t,i,e;this.config.cookieless_mode!==Vr?(this.config.cookieless_mode===Hr&&this.consent.isOptedIn()&&this.Ml(!0,!0),this.consent.optInOut(!1),this.Uo(),this.config.cookieless_mode===Hr&&(this.register({distinct_id:Lr,$device_id:null}),null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,null==(i=this.sessionManager)||i.destroy(),null==(e=this.pageViewManager)||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.gl(),this.pl())):Ie.warn(gl)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Vr||(this.config.cookieless_mode===Hr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Uo()}_is_bot(){return e?qa(e,this.config.custom_blocked_useragents):void 0}gl(){r&&("visible"===r.visibilityState?this.Zo||(this.Zo=!0,this.capture(Qr,{title:r.title},{send_instantly:!0}),this.Qo&&(r.removeEventListener(Jr,this.Qo),this.Qo=null)):this.Qo||(this.Qo=this.gl.bind(this),us(r,Jr,this.Qo)))}debug(i){!1===i?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Sa(){var t=this.Xo||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ie.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(t,i,e,r,s){var n=i in t&&!X(t[i]),o=e in t&&!X(t[e]);return n?t[i]:!!o&&(s&&s.warn("Config field '"+e+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,Ie)}In(t){var i;if(X(this.config.before_send))return t;var e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(st),r=H(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r)try{if(s=n(s),X(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return rt(t.event)?Ie.warn(o+". This can cause unexpected behavior."):Ie.info(o),null}s.properties&&!G(s.properties)||Ie.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(i){return Ie.error("Error in beforeSend function for event '"+t.event+"':",i),null}for(var a of e)if(s.properties&&X(s.properties[a]))return Ie.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.Rs)?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Yo(t){var i=it(t)&&!t,e=Ss.Br()&&"true"===Ss.Ur("ph_debug");return!i&&(!!e||t)}}Rl.__defaultExtensionClasses={},Rl.Rl=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(var e=0;i.length>e;e++)t.prototype[i[e]]=os(t.prototype[i[e]])}(Rl,["identify"]);class Cl{constructor(t){this.disabled=!1===t;var i=W(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}}var Ol="$copy_autocapture",Il=Ae("[AutoCapture]");function Al(t,i){return i.length>t?i.slice(0,t)+"...":i}function Fl(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Ws(i));return i}function Ml(i,e){var r,s,n=e.e,o=e.maskAllElementAttributes,a=e.maskAllText,l=e.elementAttributeIgnoreList,h=e.elementsChainAsString,u=e.disableCaptureUrlHashes;if(!Ws(i))return{props:{}};for(var d=[i],v=new Set([i]),c=i;c.parentNode&&!Gs(c,"body")&&Ys>d.length;)if(Js(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!Ws(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p,g,m=[],y={},b=!1,w=!1;if(es(d,(t=>{var i=_n(t);if(Gs(t,"a")){var e=t.getAttribute("href");b=!!(i&&e&&kn(e))&&(u?xi(e):e)}N(Zs(t),"ph-no-capture")&&(w=!0),m.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};sn.indexOf(n)>-1&&!e&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Al(1024,Tn(t)):Al(1024,en(t)));var a=Zs(t);a.length>0&&(o.classes=a.filter((function(t){return""!==t}))),es(t.attributes,(function(e){var n;if((!gn(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&kn(e.value)&&(!J(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=e.value;"class"===e.name&&(a=Qs(a).join(" ")),o["attr__"+e.name]=Al(1024,"href"===e.name&&s?xi(a):a)}}));for(var l=1,h=1,u=t;u=Fl(u);)l++,u.tagName===t.tagName&&h++;return o.nth_child=l,o.nth_of_type=h,o}(t,o,a,l,u));var r=function(t){if(!_n(t))return{};var i={};return es(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&kn(r)&&(i[e]=r)}})),i}(t);rs(y,r)})),w)return{props:{},explicitNoCapture:w};if(a||(m[0].$el_text=Gs(i,"a")||Gs(i,"button")?Tn(i):en(i)),b){var x,E;m[0].attr__href=b;var S=null==(x=Hn(b))?void 0:x.host,k=null==t||null==(E=t.location)?void 0:E.host;S&&k&&S!==k&&(p=b)}return{props:rs({$event_type:n.type,$ce_version:1},h?{}:{$elements:m},{$elements_chain:(g=m,function(t){return t.map((t=>{var i,e,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var n=_({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return ss(n).sort(((t,i)=>t[0].localeCompare(i[0]))).forEach((t=>{var i=t[1];return o[Pn(t[0].toString())]=Pn(i.toString())})),(r+=":")+ss(o).map((t=>t[0]+'="'+t[1]+'"')).join("")})).join(";")}(function(t){return t.map((t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:Rn(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return ss(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=m[0])&&r.$el_text?{$el_text:null==(s=m[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},y)}}class Dl{constructor(t){this.name="autocapture",this.rs=!1,this.ns=null,this.ss=!1,this.os=!1,this.Wi={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.ls=!1,this.us=t,this.us.refresh(this.Wi),this.rageclicks=new Cl(this.Wi.rageclick),this.hs=null}setup(t){this.ds(),this.vs=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.ls?i.dispose():(this.cs=i,this.startIfEnabled())}dispose(){var t;this.ls||(this.ls=!0,this.vs=void 0,null==(t=this.cs)||t.dispose(),this.cs=void 0,this.fs())}ps(){return this.us.refresh(this.Wi),this.Wi}ds(){var t,i;return this.ps(),this.Wi.url_allowlist=null==(t=this.Wi.url_allowlist)?void 0:t.map((t=>new RegExp(t))),this.Wi.url_ignorelist=null==(i=this.Wi.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),this.Wi}gs(){if(this.isBrowserSupported()){if(t&&r){var i=this.ys=i=>{i=i||(null==t?void 0:t.event);try{this.bs(i)}catch(t){Il.error("Failed to capture event",t)}};if(us(r,"submit",i,{capture:!0}),us(r,"change",i,{capture:!0}),us(r,"click",i,{capture:!0}),this.ps().capture_copied_text){var e=this._s=i=>{i=i||(null==t?void 0:t.event);try{this.bs(i,Ol)}catch(t){Il.error("Failed to capture clipboard event",t)}};us(r,"copy",e,{capture:!0}),us(r,"cut",e,{capture:!0}),us(r,"paste",e,{capture:!0})}}}else Il.info("Disabling Automatic Event Collection because this browser is not supported")}fs(){this.ys&&(null==r||r.removeEventListener("submit",this.ys,!0),null==r||r.removeEventListener("change",this.ys,!0),null==r||r.removeEventListener("click",this.ys,!0),this.ys=void 0),this._s&&(null==r||r.removeEventListener("copy",this._s,!0),null==r||r.removeEventListener("cut",this._s,!0),null==r||r.removeEventListener("paste",this._s,!0),this._s=void 0),this.rs=!1}startIfEnabled(){!this.ls&&this.vs&&this.isEnabled&&!this.rs&&(this.gs(),this.rs=!0)}onRemoteConfig(t){if(!this.ls)if(this.ss=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.os=i.elementsChainAsString);var e,r=i.autocapture_opt_out;it(r)&&(null==(e=this.vs)||e.kv.set(Ve,r),this.ns=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.hs=t}getElementSelectors(t){var i,e=[];return null==(i=this.hs)||i.forEach((i=>{var s=null==r?void 0:r.querySelectorAll(i);null==s||s.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i;if(this.ls)return!1;var e=null==(t=this.vs)?void 0:t.kv.get(Ve),r=this.ns,s=this.ps(),n=s.remoteRequestsDisabled&&!this.ss;if(Q(r)&&!it(e)&&!n)return!1;var o=null!==(i=this.ns)&&void 0!==i?i:!!e;return!!s.enabled&&!o}bs(i,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var r=rn(i);Ks(r)&&(r=r.parentNode||null);var s,n=this.ds();"$autocapture"===e&&"click"===i.type&&i instanceof MouseEvent&&n.rageclick&&null!=(s=this.rageclicks)&&s.isRageClick(i.clientX,i.clientY,i.timeStamp||(new Date).getTime())&&cn(r,n.rageclick)&&this.bs(i,"$rageclick");var o=e===Ol,a=o?_({},n,{dom_event_allowlist:void 0}):n;if(r&&function(i,e,r,s,n,o){var a;if(!t||fn(i))return!1;if(null!=r&&r.url_allowlist&&!Xs(r.url_allowlist,o))return!1;if(null!=r&&r.url_ignorelist&&Xs(r.url_ignorelist,o))return!1;if(null!=r&&r.dom_event_allowlist){var l=r.dom_event_allowlist;if(l&&!l.some((t=>e.type===t)))return!1}var h=pn(i,s),u=h.parentIsUsefulElement,d=h.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(K(e))return!0;var r,s=function(t){if(e.some((i=>t.tagName.toLowerCase()===i)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(d,r))return!1;if(!nn(d,null==r?void 0:r.css_selector_allowlist))return!1;if(nn(d,null!==(a=null==r?void 0:r.css_selector_ignorelist)&&void 0!==a?a:an))return!1;try{var v=t.getComputedStyle(i);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var c=i.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return u?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(sn.indexOf(c)>-1||"true"===i.getAttribute("contenteditable"))}}(r,i,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l,h=Ml(r,{e:i,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.os,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),u=h.props;if(h.explicitNoCapture)return!1;var d=this.getElementSelectors(r);if(d&&d.length>0&&(u.$element_selectors=d),e===Ol){var v=i.type||"clipboard";if("paste"!==v){var c,f,p=null==t||null==(c=t.getSelection())?void 0:c.toString(),g=tn(p);if(!g)return!1;u.$selected_content=g,u.$clipboard_text_length=null!==(f=null==p?void 0:p.length)&&void 0!==f?f:0}u.$copy_type=v}return null==(l=this.vs)||l.capture(e,u).catch((t=>Il.error("Failed to capture event",t))),!0}}}isBrowserSupported(){return V(null==r?void 0:r.querySelectorAll)}}class Nl{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=W(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.Sa(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}}var Ll=Ae("[ExceptionAutocapture]"),Ul=()=>{},jl=t=>{var i;if(V(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function Bl(t,i,e){try{if(!(i in t))return Ul;var r={next:t[i]},s=e((function(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];return r.next.apply(this,i)}));return V(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[i]=s,()=>{if(t[i]!==s)for(var e=t[i],n=jl(e);n;){if(n.next===s)return void(n.next=r.next);n=jl(e=n.next)}else t[i]=r.next}}catch(t){return Ul}}var zl=Ae("[TracingHeaders]"),ql=Ae("[Web Vitals]"),Hl=9e5,Vl=["CLS","FCP","INP","LCP"],Wl=["INP","LCP"],Gl=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Kl="disabled",Jl="lazy_loading",Yl="awaiting_config",Ql="missing_config";Ae("[SessionRecording]"),Ae("[SessionRecording]");var Xl="[SessionRecording]",Zl=Ae(Xl),th=Ae("[Heatmaps]");function ih(t){return W(t)&&"clientX"in t&&"clientY"in t&&Z(t.clientX)&&Z(t.clientY)}var eh=Ae("[Product Tours]"),rh=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(Xe))},sh=["$set_once","$set"],nh=Ae("[SiteApps]"),oh="Error while initializing PostHog app with config id ",ah=(t,i)=>null!=t&&t.then?t.then(i):i(t),lh="SDK is not enabled or survey functionality is not yet loaded",hh="Disabled. Not loading surveys.";class uh{constructor(t,i){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Al=!1,this.Fl=[],this.Ol=null,this.Ll=null,this.ls=!1,this.Dl=new Set,this.onRemoteConfig=t=>{if(!this.ls&&!this.Wi.disableSurveys){if(!t.ok)return el.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(X(i))return el.warn("Flags not loaded yet. Not loading surveys.");this.$l=it(i)?i:i.length>0,el.info("flags response received, isSurveysEnabled: "+this.$l),this.loadIfEnabled()}},this.us=t,this.Nl=i}setup(t){if(!this.ls)return this.ql=t,ah(t.kv.initialize(),(()=>{if(this.ql===t&&!this.ls){this.ql=void 0,this.vs=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.ls?i.dispose():(this.cs=i,this.loadIfEnabled())}}))}dispose(){var t,i,e;this.ls||(this.ls=!0,this.ql=void 0,this.vs=void 0,null==(t=this.cs)||t.dispose(),this.cs=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Fl=[],this.Ol=null,this.Dl.forEach((t=>clearTimeout(t))),this.Dl.clear())}get Wi(){return this.us.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith(rl)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this.ls&&this.vs){var t=this.Wi;if(!this._surveyManager)if(this.Al)el.info("Already initializing surveys, skipping...");else if(t.disableSurveys)el.info(hh);else if(t.cookielessMode&&this.us.isOptedOut())el.info("Not loading surveys in cookieless mode without consent.");else{var i=this.us.getExtensions();if(i){if(!K(this.$l)||t.advancedEnableSurveys){var e=this.$l||t.advancedEnableSurveys;this.Al=!0;try{var r=i.generateSurveys;if(r)return this.jl(r,e),void(this.Al=!1);var s=i.loadExternalDependency;if(!s)return this.Bl(qr),void(this.Al=!1);s((t=>{try{if(this.ls)return;var i=this.us.getExtensions();t||null==i||!i.generateSurveys?this.Bl("Could not load surveys script",t):this.jl(i.generateSurveys,e)}finally{this.Al=!1}}))}catch(t){throw this.Al=!1,this.Bl("Error initializing surveys",t),t}}}else el.error("PostHog Extensions not found.")}}}jl(t,i){this.ls||(this._surveyManager=t(i),this._surveyEventReceiver=this.us.createEventReceiver(),el.info("Surveys loaded successfully"),this.Hl({isLoaded:!0}))}Bl(t,i){el.error(t,i),this.Hl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Fl.push(t),this._surveyManager&&this.Hl({isLoaded:!0}),()=>{this.Fl=this.Fl.filter((i=>i!==t))}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.vs)&&void 0!==e?e:this.Nl;if(r&&!this.ls){if(this.Wi.disableSurveys)return el.info(hh),t([]);var s=r.kv.get(wr);if(s&&!i)return t(s,{isLoaded:!0}),void(this.Ul()&&this.getSurveys((()=>{}),!0));if(this.Ol)this.Ol.then((i=>{this.ls||t(i.surveys,i.context)})).catch((t=>el.error("Error in survey callback",t)));else{var n=this.zl("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.Wi.requestTimeoutMs}).then((t=>{try{return this.Wl(r,t)}catch(t){return el.error("Error processing surveys response",t),this.Wl(r,{statusCode:0,error:t})}}),(t=>this.Wl(r,{statusCode:0,error:t})));this.Ol=n;var o=()=>{this.Ol===n&&(this.Ol=null)};n.then((i=>{o(),this.ls||t(i.surveys,i.context)}),o).catch((t=>el.error("Error in survey callback",t)))}}}zl(t,i){var e=this.vs;return e?e.sendRequest(t,i):new Promise((t=>t({statusCode:0,error:new Error(lh)})))}Wl(t,i){if(this.ls)return{surveys:[],context:{isLoaded:!1,error:lh}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?el.error(r):i.error||el.warn(r),this.Ll=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Ll=null;var s,n=i.json.surveys||[],o=n.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Va(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t))));return o.length>0&&(null==(s=this._surveyEventReceiver)||s.register(o)),t.kv.set({[wr]:n,[xr]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}Ul(){return this.Vl()&&!this.Ol&&!this.Gl()}Vl(){var t,i,e=null==(t=null!==(i=this.vs)&&void 0!==i?i:this.Nl)?void 0:t.kv.get(xr);return Z(e)&&Date.now()-e>3e5}Gl(){return Z(this.Ll)&&3e5>Date.now()-this.Ll}markSurveyAsSeen(t,i){var e,r={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};sl(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}Hl(t){for(var i of this.Fl)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){el.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!X(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);el.warn("init was not called")}Zl(t){var i=null;return this.getSurveys((e=>{var r;i=null!==(r=e.find((i=>i.id===t)))&&void 0!==r?r:null})),i}Ql(t){if(X(this._surveyManager))return{eligible:!1,reason:lh};var i="string"==typeof t?this.Zl(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Jl(t){if(X(this._surveyManager))return{eligible:!1,reason:lh};var i="string"==typeof t?this.Zl(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(X(this._surveyManager))return el.warn("init was not called"),{visible:!1,disabledReason:lh};var i=this.Jl(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return X(this._surveyManager)?(el.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:lh})):new Promise((e=>{this.getSurveys((i=>{var r,s=null!==(r=i.find((i=>i.id===t)))&&void 0!==r?r:null;if(s){var n=this.Jl(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var s;if(X(this._surveyManager))el.warn("init was not called");else{var n="string"==typeof t?this.Zl(t):t;if(null!=n&&n.id)if(nl.includes(n.type)){var o=null==r?void 0:r.querySelector(i);if(o)if(null!=(s=n.appearance)&&s.surveyPopupDelaySeconds){el.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout((()=>{var t,i;this.Dl.delete(a),this.ls||(el.info("Rendering survey "+n.id+" with delay of "+(null==(t=n.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(n,o,e),el.info("Survey "+n.id+" rendered"))}),1e3*n.appearance.surveyPopupDelaySeconds);this.Dl.add(a)}else this._surveyManager.renderSurvey(n,o,e);else el.warn("Survey element not found")}else el.warn("Surveys of type "+n.type+" cannot be rendered in the app");else el.warn("Survey not found")}}displaySurvey(t,i){var e;if(X(this._surveyManager))el.warn("init was not called");else{var r=this.Zl(t);if(r){var s=r;if(null!=(e=r.appearance)&&e.surveyPopupDelaySeconds&&i.ignoreDelay&&(s=_({},r,{appearance:_({},r.appearance,{surveyPopupDelaySeconds:0})})),i.displayType!==Co.Popover&&i.initialResponses&&el.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var n=this.Ql(r);if(!n.eligible)return void el.warn("Survey is not eligible to be displayed: ",n.reason)}i.displayType!==Co.Inline?this._surveyManager.handlePopoverSurvey(s,i):this.renderSurvey(s,i.selector,i.properties)}else el.warn("Survey not found")}}cancelPendingSurvey(t){X(this._surveyManager)?el.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}function dh(t,i,e){if(X(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}class vh{constructor(t){this.Kl=new Set,this.Yl=new Set,this.Xl=new Ua,this.tu=(t,i)=>this.eu(t,i)&&this.iu(t,i)&&this.ru(t,i)&&this.nu(t,i),this.eu=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t}init(){var t,i;K(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.su=null==(i=this._instance)?void 0:i._addCaptureHook(((t,i)=>{this.on(t,i)})))}dispose(){var t;null==(t=this.su)||t.call(this),this.su=void 0,this.Xl=new Ua}register(t){var i,e;if(!K(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i;this.Kl.add(t),null==(i=t.steps)||i.forEach((t=>{this.Yl.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Kl.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&r.add(t.selector)}))})),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Kl.clear(),this.Yl.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Yl.has(t)||this.Yl.has(i.event))&&this.Kl.forEach((t=>{this.au(i,t)&&this.Xl.emit("actionCaptured",t.name)}))}ou(t){this.onAction("actionCaptured",(i=>t(i)))}au(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.tu(t,e))return!0;return!1}onAction(t,i){return this.Xl.on(t,i)}iu(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!dh(r,i.url,i.url_matching||"contains"))return!1}return!0}ru(t,i){return!!this.lu(t,i)&&!!this.uu(t,i)&&!!this.hu(t,i)}lu(t,i){var e;if(null==i||!i.href)return!0;var r=this.du(t);if(r.length>0)return r.some((t=>dh(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&dh((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}uu(t,i){var e;if(null==i||!i.text)return!0;var r=this.du(t);if(r.length>0)return r.some((t=>dh(t.text,i.text,i.text_matching||"exact")||dh(t.$el_text,i.text,i.text_matching||"exact")));var s,n,o,a=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!a&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!X(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(a),n=i.text,o=i.text_matching||"exact",s.some((t=>dh(t,n,o))))}hu(t,i){var e,r;if(null==i||!i.selector)return!0;var s=null==t||null==(e=t.properties)?void 0:e.$element_selectors;if(null!=s&&s.includes(i.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&n)try{return new RegExp(i.selector_regex).test(n)}catch(t){return!1}return!1}du(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}nu(t,i){return null==i||!i.properties||0===i.properties.length||Ja(i.properties.reduce(((t,i)=>{var e=H(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class ch{constructor(t){var i;this.vu=[],this._instance=t,this.cu=new Map,this.fu=new Map,this.pu=new Map,this.gu=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId((t=>this.mu(t)))}yu(t){return!1}bu(){return null}_u(t){}wu(){}ku(t,i){return!!t&&Ja(t.propertyFilters,null==i?void 0:i.properties)}Su(t,i){var e=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach((i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}}))})),e}xu(t,i,e){var r=(e===bo.Activation?this.cu:this.fu).get(t),s=[];return this.Cu((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find((i=>i.name===t));return this.ku(n,i)}))}register(t){this.Tu(t,!1)}replace(t){this.Tu(t,!0)}Tu(t,i){var e;K(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Mu(t,i),this.Eu(t,i))}Eu(t,i){var e=t.filter((t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length}));if(i&&this.pu.clear(),0!==e.length){this.Iu||(this.Iu=new vh(this._instance),this.Iu.init(),this.Iu.ou((t=>this.onAction(t))));var r=[];e.forEach((t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach((i=>{if(r.push(i),i.name){var e,s=null!==(e=this.pu.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.pu.set(i.name,s)}}))})),i?this.Iu.replace(r):this.Iu.register(r)}else{var s;i&&(null==(s=this.Iu)||s.replace([]))}}Ru(t,i){i.forEach(((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach((t=>{s.includes(t)||s.push(t)})),t.set(e,s)}))}Mu(t,i){var e,r,s=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0})),n=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0})),o=this.Su(t,bo.Activation),a=this.Su(t,bo.Cancellation);i?(this.cu=o,this.fu=a):(this.Ru(this.cu,o),this.Ru(this.fu,a)),(0!==s.length||0!==n.length)&&(null!==(e=this.su)&&void 0!==e||(this.su=null==(r=this._instance)?void 0:r._addCaptureHook(((t,i)=>{this.onEvent(t,i)}))))}onEvent(t,i){var e,r,s=this.Pu(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.Au(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Fu([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Ou(n),void this.Lu([n])}if(this.fu.has(t)){var a=this.xu(t,i,bo.Cancellation);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map((t=>t.id))}),this.Fu(a.map((t=>t.id))),a.forEach((t=>this.Du(t.id))))}if(this.cu.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.cu.get(t)});var l=this.xu(t,i,bo.Activation);this.$u(l.map((t=>t.id)))}}onAction(t){this.pu.has(t)&&this.$u(this.pu.get(t)||[])}$u(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.yu(s)?this.Ou(s)&&this.Nu(s):r.push(s);r.length>0&&(this.vu=[...new Set([...this.vu,...r])]),this.Pu().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Ou(t){this.vu=this.vu.filter((i=>i!==t));var i=this.qu();return!i.includes(t)&&(this.ju([...i,t]),this.Bu(),!0)}Fu(t){var i=new Set(t);this.vu=this.vu.filter((t=>!i.has(t)));var e=this.Hu(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.ju(r),0===r.length&&this.Uu()),this.Lu(t)}zu(){var t,i=this.bu();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}Nu(t){if(this.bu()){var i=this.zu();this._u(_({},i,{[t]:Date.now()}))}}Lu(t){if(this.bu()){var i=this.zu(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],o=s[1];t.includes(n)?r=!0:e[n]=o}r&&(G(e)?this.wu():this._u(e))}}Wu(){this.bu()&&this.wu()}getActivationTimestamp(t){if(this.qu().includes(t)){var i=this.zu()[t];return Z(i)?i:void 0}}Hu(){var t,i=this.Vu();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}qu(){var t,i,e=this.Hu();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Gu()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Bu(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Zu(i)}Uu(){this.Qu()}mu(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Gu()];if(e&&e!==t){var r=this.Hu(),s=this.zu();r.length>0&&(this.ju([]),r.filter((t=>Z(s[t]))).forEach((t=>this.Du(t)))),this.Uu(),this.Wu()}}getActivatedIds(){return[...new Set([...this.qu(),...this.vu])].filter((t=>!this.Ju(t)))}dispose(){var t,i,e;null==(t=this.gu)||t.call(this),this.gu=void 0,null==(i=this.su)||i.call(this),this.su=void 0,null==(e=this.Iu)||e.dispose(),this.Iu=void 0}reset(){this.vu=[],this.Hu().length>0&&this.ju([]),this.Uu(),this.Wu()}getEventToItemsMap(){return this.cu}Ku(){return this.Iu}}class fh extends ch{constructor(t){super(t)}Vu(){return Er}Gu(){return Sr}bu(){return kr}_u(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[kr]:t})}wu(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(kr)}yu(t){var i,e;this.Cu((i=>{e=i.find((i=>i.id===t))}));var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return Z(r)&&r>0}Yu(){return Po.SHOWN}Cu(t){var i;null==(i=this._instance)||i.getSurveys(t)}Du(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Pu(){return el}ju(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Er]:t})}Zu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Sr]:t})}Qu(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Sr)}Ju(){return!1}Au(t,i){var e;this.Cu((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return Va(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===Po.SHOWN?"consume":"ignore":t===Po.SHOWN?"persist":t===Po.DISMISSED||t===Po.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class ph{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);K(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach((t=>this._instance.unregister(t))):this._instance.unregister(t)}}class _h{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=null==v?void 0:v.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new fh(this._instance)}}var gh=null!=t&&t.location?Gn(t.location.hash,"__posthog")||Gn(location.hash,"state"):null,mh="_postHogToolbarParams",yh=Ae("[Toolbar]"),bh=Ae("[FeatureFlags]");class wh{constructor(t,i){void 0===i&&(i=!1),this.Xu=!1,this.update(t,i)}update(t,i){this.th=((t,i)=>{var e,r,s,n,o;return{bootstrap:{featureFlags:null==(e=t.bootstrap)?void 0:e.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(s=t.remote_config_refresh_interval_ms)&&void 0!==s?s:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(o=t.evaluation_contexts)&&void 0!==o?o:t.evaluation_environments)&&void 0!==n?n:[],flagKeys:H(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Xu||(bh.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Xu=!0),K(t.flag_keys)||H(t.flag_keys)||bh.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.th}}var xh=Ae("[FeatureFlags]"),Eh=Ae("[FeatureFlags]",{debugEnabled:!0}),Sh="\" failed. Feature flags didn't load in time.",kh="connection_error",Th=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},$h=t=>{var i={};for(var e of ss(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},Ph=Ae("[Error tracking]"),Rh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],Ch=["__firefox__","__gCrWeb"],Oh="Refusing to render web experiment since the viewer is a likely bot",Ih={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Wa(i,t),not_regex:(t,i)=>!Wa(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class Ah{get Wi(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{Ah.eh("retrieved web experiments from the server"),i.ih=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.ih&&(Ah.eh("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.ih)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);J(r)&&t.variants[r]&&i.rh(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Ah.nh(n,i._instance)&&i.rh(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Ah.eh(Oh);else if(!this.Wi.disable_web_experiments){if(X(this.ih))return this.ih=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ah.eh("applying feature flags",t),t.forEach((t=>{var i;if(this.ih&&null!=(i=this.ih)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ih)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.rh(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Ah.getWindowLocation();if(null!=t&&t.search){var i=Vn(null==t?void 0:t.search,"__experiment_id"),e=Vn(null==t?void 0:t.search,"__experiment_variant");i&&e&&(Ah.eh("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.sh(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.Wi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Wi.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Wi.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}sh(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(Ah.eh("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.rh(r[0].name,i,r[0].variants[i].transforms))}static nh(t,i){return!X(t.conditions)&&Ah.ah(t,i)&&Ah.oh(t)}static ah(t,i){var e;if(X(t.conditions)||X(null==(e=t.conditions)?void 0:e.url))return!0;var r=Ah.getWindowLocation();if(r){var s,n,o,a=js(i,r.href);return null==(s=t.conditions)||!s.url||Ih[null!==(n=null==(o=t.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,a)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static oh(t){var i;if(X(t.conditions)||X(null==(i=t.conditions)?void 0:i.utm))return!0;var e=io();if(e.utm_source){var r,s,n,o,a,l,h,u,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==e.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==e.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(h=t.conditions)||null==(h=h.utm)||!h.utm_term||(null==(u=t.conditions)||null==(u=u.utm)?void 0:u.utm_term)==e.utm_term;return d&&c&&f&&v}return!1}static eh(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];Ie.info("[WebExperiments] "+t,e)}rh(t,i,e){this._is_bot()?Ah.eh(Oh):"control"!==i?e.forEach((e=>{if(e.selector){var r;Ah.eh("applying transform of variant "+i+" for experiment "+t+" ",e);var s=null==(r=document)?void 0:r.querySelectorAll(e.selector);null==s||s.forEach((t=>{var i=t;e.html&&(i.innerHTML=e.html),e.css&&i.setAttribute("style",e.css)}))}})):Ah.eh("Control variants leave the page unmodified.")}_is_bot(){return e&&this._instance?qa(e,this.Wi.custom_blocked_useragents):void 0}}var Fh=Ae("[Conversations]"),Mh="Conversations not available yet.";function Dh(t,i){var e,r,s,n,o,a,l,h=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,d=null!=i&&i.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,v=K(d)?Math.max(u,2048):Math.max(u,d),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==c?void 0:c["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==n?n:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(a=null==c?void 0:c["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:u,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Nh=["debug","log","warn","error","info"],Lh="console",Uh="__posthogHandledLogsRequestError",jh=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Uh]=!0,e},Bh=t=>!!t&&"object"==typeof t&&!0===t[Uh],zh={featureFlags:class{constructor(t){this.name="featureFlags",this.lh=!1,this.featureFlagEventHandlers=[],this.I=xh,this.uh={},this.hh={},this.dh=[],this.fh=!1,this.ph=!1,this.gh=0,this.mh=!1,this.yh=!1,this.bh=!1,this._h=!1,this.wh=0,this.It=()=>{var t=this.kh();this.wh=0,t&&this.reloadFeatureFlags()},this.Sh=()=>{var t,i=this.xh;K(i)||this.Wi.remoteRequestsDisabled||!r||"hidden"===r.visibilityState||Date.now()-(null!==(t=this.Ch)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Th())},this.Et=()=>{"visible"===(null==r?void 0:r.visibilityState)&&this.Sh()},"get"in t?this.us=t:(this.Mh=new wh(t.config,t.Sa()),this.us=this.Mh)}updateConfig(t,i){var e;null==(e=this.Mh)||e.update(t,i),this.vs&&this.Eh()}setup(t){return this.ql=t,this.I=t.logger.createLogger("[FeatureFlags]"),ah(t.kv.initialize(),(()=>{this.ql===t&&(this.ql=void 0,this.vs=t,this.Ih(t))}))}Ih(i){if(this.vs===i)return t&&us(t,"online",this.It),this.Eh(),this.Rh=i.registerDynamicEventProperties((()=>this.Ph()?this.uh:this.hh)),this.Ah(),this.initialize()}Eh(){var t=this.Wi.refreshIntervalMs,i=!this.Wi.remoteRequestsDisabled&&r&&!K(t)&&t>0?t:void 0;i!==this.xh&&(this.Fh(),K(i)||(this.xh=i,this.Th(),null!=r&&r.addEventListener&&us(r,Jr,this.Et)))}Th(){K(this.xh)||(K(this.Oh)||clearInterval(this.Oh),this.Ch=Date.now(),this.Oh=setInterval(this.Sh,this.xh))}Fh(){K(this.Oh)||(clearInterval(this.Oh),this.Oh=void 0,null==r||null==r.removeEventListener||r.removeEventListener(Jr,this.Et)),this.xh=void 0,this.Ch=void 0}destroy(){this.Lh()}dispose(){this.Lh()}Lh(){var i;this.Fh(),this.gh++,this.yh=!1,this.ql=void 0,this.vs&&(this.Dh(),null==(i=this.Rh)||i.dispose(),this.Rh=void 0,this.dh=[],null==t||t.removeEventListener("online",this.It),this.vs=void 0)}get Wi(){return this.us.get()}$h(t){var i;return null==(i=this.vs)?void 0:i.kv.get(t)}Hr(t){this.Nh((()=>{var i;return null==(i=this.vs)?void 0:i.kv.set(t)}))}$r(t){this.Nh((()=>{var i;return null==(i=this.vs)?void 0:i.kv.remove(t)}))}Nh(t){try{t()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}Ah(){var t={};for(var i of[ur,cr,fr,_r]){var e=this.$h(i);K(e)||(t[i]=e)}this.uh=t;var r=_({},t),s=this.$h(hr);if(s)for(var n of Object.entries(s))r["$feature/"+n[0]]=n[1];this.hh=r}Ph(){var t=this.Wi.cacheTtlMs;if(!t||0>=t)return!1;var i=this.$h(Cr);return"number"!=typeof i||Date.now()-i>t}qh(){return!!this.Ph()&&(this._h||this.ph||(this._h=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}jh(){var t=this.Wi.evaluationContexts;return null!=t&&t.length?t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Bh(){var t=this.Wi.flagKeys;if(!K(t))return t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),i}))}initialize(){var t,i,e=this.Wi,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((t=>!!r[t])).reduce(((t,i)=>(t[i]=r[i]||!1,t)),{}),l=Object.keys(o).filter((t=>a[t])).reduce(((t,i)=>(t[i]=o[i],t)),{});return this.Hh({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,i,e){var r,s,n=null!=e&&e.merge&&null!==(r=this.$h(hr))&&void 0!==r?r:{},o=null!=e&&e.merge&&null!==(s=this.$h(cr))&&void 0!==s?s:{},a=_({},n,t),l=_({},o,i),h={};for(var u of Object.entries(a)){var d=u[0],v=u[1];h[d]={key:d,enabled:y(v),variant:b(v),reason:void 0,metadata:K(null==l?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.Hh({flags:h})}get hasLoadedFlags(){return this.fh}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.$h(vr),i=this.$h(_r),e=this.$h(gr);if(!e&&!i)return t||{};var r=rs({},t||{}),s=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(var n of s){var o,a,l=r[n],h=null==i?void 0:i[n],u=K(h)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!h,d=K(h)?null==l?void 0:l.variant:"string"==typeof h?h:void 0,v=null==e?void 0:e[n],c=_({},l,{enabled:u,variant:u?null!=d?d:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=_({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=c}return this.lh||(this.I.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:r}),this.lh=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map((e=>{var r=t[e];return{key:e,enabled:y(r),variant:b(r),payload:m(i[e])}}))}getFlagVariants(){var t=this.$h(hr),i=this.$h(_r);if(!i)return t||{};for(var e=rs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.lh||(this.I.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.lh=!0),e}getFlagPayloads(){var t=this.$h(cr),i=this.$h(gr);if(!i)return t||{};for(var e=rs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.lh||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.lh=!0),e}reloadFeatureFlags(){this.mh||this.Wi.featureFlagsDisabled||this.kh()||this.Uh||(this.dh.slice().forEach((t=>{try{t()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}})),this.Uh=setTimeout((()=>{this.zh()}),5))}Dh(){clearTimeout(this.Uh),this.Uh=void 0}onReloading(t){return this.dh.push(t),()=>{this.dh=this.dh.filter((i=>i!==t))}}ensureFlagsLoaded(){this.fh||this.ph||this.Uh||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.mh=t}resetFlagCallReported(){this.$r($r)}zh(t){this.Dh();var i=this.vs;if(i&&!this.Wi.remoteRequestsDisabled&&!this.kh())if(this.ph)this.yh=!0;else{var e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:_({},i.initialPersonProperties,this.$h(mr)||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.$h(yr),timezone:ho()};K(i.deviceId)||(e.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.Wi.featureFlagsDisabled)&&(e.disable_flags=!0);var r=this.jh();r.length&&(e.evaluation_contexts=r);var s=this.Bh();K(s)||(e.flag_keys=s);var n=this.Wi.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.gh;this.ph=!0;var l=()=>{this.yh&&(this.yh=!1,this.zh())},h=t=>{this.ph=!1,a===this.gh?(this.Hr({[Rr]:[kh]}),this.I.error("Feature flag request failed",t),l()):l()};try{i.sendRequest(o,{target:"flags",method:"POST",body:e,compression:this.Wi.compression,sentAt:"body",timeoutMs:this.Wi.requestTimeoutMs}).then((t=>{var i,r,s=null!==(i=t.json)&&void 0!==i?i:{},o=200!==t.statusCode;if(this.ph=!1,a===this.gh){if(this.Wh(t.statusCode),o||this.yh||(this.$anon_distinct_id=void 0),!e.disable_flags||this.yh){this.bh=!o;var h=[];t.error?h.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?kh:"unknown_error"):200!==t.statusCode&&h.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");var u=!(null==(r=s.quotaLimited)||!r.includes("feature_flags"));u&&h.push("quota_limited"),this.Hr({[Rr]:h}),u?this.I.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."):e.disable_flags||this.Hh(s,o,{partialResponse:n}),l()}}else l()})).catch(h)}catch(t){h(t)}}}kh(){return Kn(this.wh,3)}Wh(t){this.wh=Jn(t,this.wh,3,(()=>this.I.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this.bh)if(this.fh||this.getFlags()&&this.getFlags().length>0){if(!this.qh()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+t+Sh)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.bh)if(this.fh||this.getFlags()&&this.getFlags().length>0){if(!this.qh()){var e,r=this.getFlagVariants(),s=t in r,n=r[t],o=this.getFlagPayloads()[t],a=String(n),l=this.$h(fr)||void 0,h=this.$h(Cr)||void 0,u=this.$h($r)||{};if(this.Wi.deduplicateCallsPerSession){var d,v=null==(d=this.vs)?void 0:d.session.sessionId,c=this.$h(Pr);v&&v!==c&&(u={},e=v)}if(i.send_event||!("send_event"in i))if(t in u&&u[t].includes(a))e&&this.Hr({[$r]:u,[Pr]:e});else{var f,p,g,y,b,w,x,E,S,k,T,P;H(u[t])?u[t].push(a):u[t]=[a],this.Hr(_({[$r]:u},e?{[Pr]:e}:{}));var R=this.getFeatureFlagDetails(t),C=[...null!==(f=this.$h(Rr))&&void 0!==f?f:[]];K(n)&&C.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:null!==(p=null==(g=this.Wi.bootstrap)||null==(g=g.featureFlags)?void 0:g[t])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(y=null==(b=this.Wi.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.bh};K(null==R||null==(w=R.metadata)?void 0:w.has_experiment)||(O.$feature_flag_has_experiment=R.metadata.has_experiment),K(null==R||null==(x=R.metadata)?void 0:x.version)||(O.$feature_flag_version=R.metadata.version);var I,A=null!==(E=null==R||null==(S=R.reason)?void 0:S.description)&&void 0!==E?E:null==R||null==(k=R.reason)?void 0:k.code;A&&(O.$feature_flag_reason=A),null!=R&&null!=(T=R.metadata)&&T.id&&(O.$feature_flag_id=R.metadata.id),K(null==R?void 0:R.original_variant)&&K(null==R?void 0:R.original_enabled)||(O.$feature_flag_original_response=K(R.original_variant)?R.original_enabled:R.original_variant),null!=R&&null!=(P=R.metadata)&&P.original_payload&&(O.$feature_flag_original_payload=null==R||null==(I=R.metadata)?void 0:I.original_payload),C.length&&(O.$feature_flag_error=C.join(",")),this.Vh(O)}else e&&this.Hr({[$r]:u,[Pr]:e});if(s)return{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:m(o)}}}else this.I.warn('getFeatureFlagResult for key "'+t+Sh)}Vh(t){try{var i;null==(i=this.vs)||i.capture("$feature_flag_called",t).catch((t=>{this.I.error("Failed to capture feature flag call",t)}))}catch(t){this.I.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Gh(t,i)}Gh(t,i){var e=this;return p((function*(){var r=e.vs;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e.jh();n.length&&(s.evaluation_contexts=n);var o,a=e.Bh();K(a)||(s.flag_keys=a);try{var l,h=null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.Wi.compression,sentAt:"body",timeoutMs:e.Wi.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;o=(null==h?void 0:h[t])||void 0}catch(t){return void e.I.error("Remote config feature flag request failed",t)}try{i(o)}catch(t){e.I.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.bh)return i.defaultValue;if(!(this.fh||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+t+Sh),i.defaultValue;var e=this.getFeatureFlag(t,i);return K(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((i=>i!==t))}receivedFeatureFlags(t,i,e){this.Hh(t,i,e)}Hh(t,i,e){if(this.vs){this.fh=!0;var r=function(t,i,e,r,s,n){void 0===i&&(i={}),void 0===e&&(e={}),void 0===r&&(r={}),void 0===n&&(n=xh);var o=((t,i)=>{var e=t.flags;return e?_({},t,{featureFlags:Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),featureFlagPayloads:Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,n),a=o.flags,l=o.featureFlags,h=o.featureFlagPayloads;if(l){var u=t.requestId,d=t.evaluatedAt;if(H(l)){n.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var v={};if(l)for(var c=0;l.length>c;c++)v[l[c]]=!0;return{[ur]:l,[hr]:v,[pr]:!1}}var f=l,p=h,g=a;if(null!=s&&s.partialResponse)f=_({},i,f),p=_({},e,p),g=_({},r,g);else if(t.errorsWhileComputingFlags)if(a){var m=new Set(Object.keys(a).filter((t=>{var i;return!(null!=(i=a[t])&&i.failed)})));f=_({},i,Object.fromEntries(Object.entries(f).filter((t=>m.has(t[0]))))),p=_({},e,Object.fromEntries(Object.entries(p||{}).filter((t=>m.has(t[0]))))),g=_({},r,Object.fromEntries(Object.entries(g||{}).filter((t=>m.has(t[0])))))}else f=_({},i,f),p=_({},e,p),g=_({},r,g);return _({[ur]:Object.keys($h(f)),[hr]:f||{},[cr]:p||{},[vr]:g||{},[pr]:!0===t.minimalFlagCalledEvents},u?{[fr]:u}:{},d?{[Cr]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.I);r&&this.Hr(r),i||(this._h=!1),this.Zh(i)}}override(t,i){void 0===i&&(i=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Qh(t)}Qh(t){if(this.vs){if(!1===t)return this.$r([_r,gr]),this.Zh(),void Eh.info("All overrides cleared");if(H(t))return this.Hr({[_r]:Th(t)}),this.Zh(),void Eh.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.lh=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[_r]=H(s)?Th(s):s),n&&(r[gr]=n),Object.keys(r).length&&this.Hr(r),!1===s&&!1===n?this.$r([_r,gr]):!1===s?this.$r(_r):!1===n&&this.$r(gr),this.Zh(),!1===s?Eh.info("Flag overrides cleared"):s&&Eh.info("Flag overrides set",{flags:s}),void(!1===n?Eh.info("Payload overrides cleared"):n&&Eh.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Hr({[_r]:t}),this.Zh(),void Eh.info("Flag overrides set",{flags:t});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.fh){var i=this.Jh(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.I.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var r=(this.$h(dr)||[]).find((i=>i.flagKey===t)),s={["$feature_enrollment/"+t]:i},n={$feature_flag:t,$feature_enrollment:i,$set:s};r&&(n.$early_access_feature_name=r.name),e&&(n.$feature_enrollment_stage=e);var o=_({},this.getFlagVariants(),{[t]:i});this.Hr({[ur]:Object.keys($h(o)),[hr]:o,[mr]:_({},this.$h(mr)||{},s)}),this.Zh();try{var a;null==(a=this.vs)||a.capture("$feature_enrollment_update",n).catch((t=>{this.I.error("Failed to capture early access feature enrollment",t)}))}catch(t){this.I.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.$h(dr);!r||i?this.Kh(t,e):t(r)}Kh(t,i){var e=this;return p((function*(){var r=e.vs;if(r){var s,n=i?"&"+i.map((t=>"stage="+t)).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;e.Hr({[dr]:s=o.json.earlyAccessFeatures})}catch(t){return void e.I.error("Early access feature request failed",t)}try{t(s)}catch(t){e.I.error("Early access feature callback failed",t)}}}))()}Jh(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter((t=>i[t])),flagVariants:Object.keys(i).filter((t=>i[t])).reduce(((t,e)=>(t[e]=i[e],t)),{})}}Zh(t){this.Ah();var i=this.Jh(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.I.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Yh(t,i)}Yh(t,i){void 0===i&&(i=!0);var e=this.$h(mr)||{},r=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,n={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in e||(n[o]=s[o]));this.Hr({[mr]:_({},e,n,r)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=_({},this.$h(mr)||{});t.forEach((t=>{delete e[t]})),this.Hr({[mr]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.$r(mr),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=this.$h(yr)||{},r=_({},e);for(var s of Object.keys(t))r[s]=_({},e[s],t[s]);this.Hr({[yr]:r}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.$h(yr)||{};this.Hr({[yr]:_({},i,{[t]:{}})})}else this.$r(yr)}reset(){this.gh++,this.yh=!1,this.uh={},this.hh={},this.fh=!1,this.mh=!1,this.bh=!1,this.$anon_distinct_id=void 0,this.Dh(),this.lh=!1,this.wh=0}}},qh={sessionRecording:class{get Wi(){return this._instance.config}get Qa(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Xh)||!t.isStarted)}get status(){var t,i;return this.td===Yl||this.td===Ql?this.td:null!==(t=null==(i=this.Xh)?void 0:i.status)&&void 0!==t?t:this.td}constructor(i){if(this._forceAllowLocalhostNetworkCapture=!1,this.td=Kl,this.ed=void 0,this.rd=!1,this._t=(()=>{var i;if(null==r||!r.visibilityState||"visible"===r.visibilityState)return!0;var e=null==t||null==(i=t.performance)||null==i.getEntriesByType?void 0:i.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some((t=>"visible"===t.name))})(),this.Et=()=>{var t;"visible"===(null==r?void 0:r.visibilityState)&&(this._t=!0,null==(t=this.Xh)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=i,!this._instance.sessionManager)throw Zl.error("started without valid sessionManager"),new Error(Xl+" started without valid sessionManager. This is a bug.");if(this.Wi.cookieless_mode===Vr)throw new Error(Xl+' cannot be used with cookieless_mode="always"');null!=r&&r.addEventListener&&us(r,"visibilitychange",this.Et)}initialize(){this.startIfEnabledOrStop()}dispose(){this.rd=!0,null==r||null==r.removeEventListener||r.removeEventListener("visibilitychange",this.Et),this.stopRecording()}get nd(){var i,e=!(null==(i=this._instance.get_property(ir))||!i.enabled),r=!this.Wi.disable_session_recording,s=this.Wi.disable_session_recording||this._instance.consent.isOptedOut();return t&&e&&r&&!s}startIfEnabledOrStop(t){var i;if(!(this.rd||this.nd&&null!=(i=this.Xh)&&i.isStarted)){var e=!K(Object.assign)&&!K(Array.from);this.nd&&e?(this.sd(t),Zl.info("starting")):(this.td=Kl,this.stopRecording())}}sd(t){var i,e,r;this.nd&&(this.td!==Yl&&this.td!==Ql&&(this.td=Jl),null!=v&&null!=(i=v.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=v.__PosthogExtensions__)&&e.initSessionRecording?this.ad(t):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.od,(i=>{if(i)return this._instance.register_for_session({[zr]:!0}),Zl.error("could not load recorder",i);this.ad(t)})))}stopRecording(){var t,i;null==(t=this.ed)||t.call(this),this.ed=void 0,null==(i=this.Xh)||i.stop()}ld(){var t,i;null==(t=this.ed)||t.call(this),this.ed=void 0,null==(i=this.Xh)||i.discard()}ud(){var t,i;null==(t=this.Qa)||t.unregister(lr),null==(i=this.Qa)||i.unregister(er)}hd(t,i){if(X(t))return null;var e,r=Z(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Zl.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}dd(t){if(this.Qa){var i,e,r=this.Qa,s=()=>{var i,e=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.hd(null==(i=this.Wi.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),n=this.hd(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=s?s:n;X(o)&&this.ud();var a=null==e?void 0:e.minimumDurationMilliseconds;r.register({[ir]:_({cache_timestamp:Date.now(),enabled:!!e},e,{networkPayloadCapture:_({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:K(a)?null:a,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};s(),null==(i=this.ed)||i.call(this),this.ed=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(s)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.dd(i),void this.ld()):(this.dd(i),void this.startIfEnabledOrStop()):(this.td===Yl&&(this.td=Ql,Zl.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.Xh)&&e.log?this.Xh.log(t,i):Zl.warn("log called before recorder was ready")}get od(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(ir);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}vd(){var t,i=this._instance.get_property(ir);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return Zl.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!X(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}ad(t){var i,e,r;if(!this.rd){if(null==(i=v.__PosthogExtensions__)||!i.initSessionRecording)return Zl.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[zr]:!0});var s;if(this.Xh||(this.Xh=null==(s=v.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this._t),this.Xh._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.vd()){if(this.td===Ql||this.td===Yl)return;return this.td=Yl,Zl.info("persisted remote config is stale, requesting fresh config before starting"),void new No(this._instance).load()}this.td=Jl,null==(e=(r=this.Xh).setDocumentWasEverVisible)||e.call(r,this._t),this.Xh.start(t)}}onRRwebEmit(t){var i;null==(i=this.Xh)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Xh||null==(i=this.Qa)||i.register({[sr]:!0}),null==(t=this.Xh)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.Xh||null==(i=this.Qa)||i.register({[rr]:!0}),null==(t=this.Xh)||t.overrideSampling()}overrideTrigger(t){var i,e;this.Xh||null==(e=this.Qa)||e.register({["url"===t?nr:or]:!0}),null==(i=this.Xh)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Xh)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Xh)||!e.tryAddCustomEvent(t,i))}}},Hh={autocapture:class extends Dl{constructor(t){super(new Nl(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.fd=this.pd()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.gd();return!!(t.path||t.search||this.md(t))}startIfEnabled(){this.isEnabled&&(Ie.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.fd=this.pd(),this.startIfEnabled()}stop(){this.yd&&this.yd(),this.yd=void 0,this.bd&&this.bd(),this.bd=void 0,Ie.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this._d("pushState"),this._d("replaceState"),this.wd(),this.md()&&this.kd())}_d(i){var e;if(t&&(null==(e=t.history[i])||!e.__posthog_wrapped__)){var r=this;Bl(t.history,i,(t=>function(e,s,n){t.call(this,e,s,n),r.Sd(i)}))}}pd(){var i=null==t?void 0:t.location;if(null!=i&&i.pathname)return{pathname:i.pathname,search:i.search,hash:i.hash}}gd(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:W(t)?t:{}}md(t){return void 0===t&&(t=this.gd()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}xd(t){var i=this.gd(),e=this.fd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.md(i)&&t.hash!==e.hash))}Sd(t){try{var i=this.pd();if(!i)return;this.xd(i)&&this._instance.capture(Qr,{navigation_type:t}),this.fd=i}catch(i){Ie.error("Error capturing "+t+" pageview",i)}}wd(){if(!this.yd){var i=()=>{this.Sd("popstate")};us(t,"popstate",i),this.yd=()=>{t&&t.removeEventListener("popstate",i)}}}kd(){if(!this.bd){var i=()=>{this.Sd("hashchange")};us(t,"hashchange",i),this.bd=()=>{t&&t.removeEventListener("hashchange",i)}}}},heatmaps:class{get Wi(){return this.instance.config}constructor(t){var i;this.Cd=!1,this.rs=!1,this.Td=null,this.instance=t,this.Cd=!(null==(i=this.instance.persistence)||!i.props[We]),this.rageclicks=new Cl(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return W(this.Wi.capture_heatmaps)&&this.Wi.capture_heatmaps.flush_interval_milliseconds&&(t=this.Wi.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return X(this.Wi.capture_heatmaps)?X(this.Wi.enable_heatmaps)?this.Cd:this.Wi.enable_heatmaps:!1!==this.Wi.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.rs)return;th.info("starting..."),this.Md(),this.Et()}else{var t;clearInterval(null!==(t=this.Td)&&void 0!==t?t:void 0),this.Ed(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[We]:e}),this.Cd=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.yt;return this.yt=void 0,t}Id(t){ih(t.originalEvent)&&this.Ii(t.originalEvent,"deadclick")}Et(){this.Td&&clearInterval(this.Td),this.Td="visible"===(null==r?void 0:r.visibilityState)?setInterval(this.qa.bind(this),this.flushIntervalMilliseconds):null}Md(){t&&r&&(this.Rd=this.qa.bind(this),us(t,Yr,this.Rd),this.Pd=i=>this.Ii(i||(null==t?void 0:t.event)),us(r,"click",this.Pd,{capture:!0}),this.Ad=i=>this.Fd(i||(null==t?void 0:t.event)),us(r,"mousemove",this.Ad,{capture:!0}),this.Od=new An(this.instance,On,this.Id.bind(this)),this.Od.startIfEnabledOrStop(),this.Ld=this.Et.bind(this),us(r,Jr,this.Ld),this.rs=!0)}Ed(){var i;t&&r&&(this.Rd&&t.removeEventListener(Yr,this.Rd),this.Pd&&r.removeEventListener("click",this.Pd,{capture:!0}),this.Ad&&r.removeEventListener("mousemove",this.Ad,{capture:!0}),this.Ld&&r.removeEventListener(Jr,this.Ld),clearTimeout(this.Dd),null==(i=this.Od)||i.stop(),this.rs=!1)}$d(i,e){var r=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(i,e,r){for(var s=i;s&&Ws(s)&&!Gs(s,"body");){if(s===r)return!1;var n=void 0;try{var o,a,l;n=null==(o=null!==(a=null==(l=s.ownerDocument)?void 0:l.defaultView)&&void 0!==a?a:t)?void 0:o.getComputedStyle(s).position}catch(t){return!1}if(N(e,n))return!0;s=on(s)}return!1}(rn(i),["fixed","sticky"],n);return{x:i.clientX+(o?0:s),y:i.clientY+(o?0:r),target_fixed:o,type:e}}Ii(t,i){var e;if(void 0===i&&(i="click"),!Vs(t.target)&&ih(t)){var r=this.$d(t,i);null!=(e=this.rageclicks)&&e.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&cn(rn(t),this.instance.config.rageclick)&&this.Wn(_({},r,{type:"rageclick"})),this.Wn(r)}}Fd(t){!Vs(t.target)&&ih(t)&&(clearTimeout(this.Dd),this.Dd=setTimeout((()=>{this.Wn(this.$d(t,"mousemove"))}),500))}Wn(i){if(t){var e=this.Wi.disable_capture_url_hashes?xi(t.location.href):t.location.href,r=this.Wi.custom_personal_data_properties,s=this.Wi.mask_personal_data_properties?[...Qn,...r||[]]:[],n=Wn(e,s,Zn);this.yt=this.yt||{},this.yt[n]||(this.yt[n]=[]),this.yt[n].push(i)}}qa(){this.yt&&!G(this.yt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:An,webVitalsAutocapture:class{constructor(t){var i;this.Cd=!1,this.rs=!1,this.yt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Nd=()=>{clearTimeout(this.qd),this.qd=void 0,0!==this.yt.metrics.length&&(this._instance.capture("$web_vitals",_({$current_url:this.yt.url},this.yt.metrics.reduce(((t,i)=>_({},t,{["$web_vitals_"+i.name+"_event"]:_({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.yt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.jd=t=>{var i;if(this.yt=this.yt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},X(null==t?void 0:t.name)||X(null==t?void 0:t.value))ql.error("Invalid metric received",t);else{var e="string"==typeof t.navigationURL?t.navigationURL:void 0,r=this.Bd(e);if(!K(r)){var s=Z(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+r;if(!this.Hd||this.Hd>t.value){this.yt.navigationKey!==s&&(this.Nd(),this.qd=setTimeout(this.Nd,this.flushToCaptureTimeoutMs)),K(this.yt.navigationKey)&&(this.yt.navigationKey=s,this.yt.url=r),this.yt.firstMetricTimestamp=K(this.yt.firstMetricTimestamp)?Date.now():this.yt.firstMetricTimestamp;var n=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=_({},t,e?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});if(delete o.entries,W(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var a={};for(var l of Gl){var h="url"===l&&"string"==typeof t.attribution[l]?this.Bd(t.attribution[l]):t.attribution[l];K(h)||(a[l]=h)}o.attribution=a}else delete o.attribution;K(n)||(o.$session_id=n.sessionId,o.$window_id=n.windowId),this.yt.metrics.push(o),this.yt.metrics.length===this.allowedMetrics.length&&this.Nd()}else ql.error("Ignoring metric with value >= "+this.Hd,t)}}},this.Ud=()=>{if(!this.rs){var t,i,e,r,s=!1,n=v.__PosthogExtensions__,o=null==n?void 0:n.postHogWebVitalsCallbacksByFlavor,a=(null==o?void 0:o[this.zd])||("web-vitals"===this.zd&&K(o)?null==n?void 0:n.postHogWebVitalsCallbacks:void 0);if(!K(a)){var l=a.withoutAttribution,h=this.attributionMetrics;s=!K(l),t=h.indexOf("LCP")>-1?a.onLCP:(null==l?void 0:l.onLCP)||a.onLCP,i=h.indexOf("CLS")>-1?a.onCLS:(null==l?void 0:l.onCLS)||a.onCLS,e=h.indexOf("FCP")>-1?a.onFCP:(null==l?void 0:l.onFCP)||a.onFCP,r=h.indexOf("INP")>-1?a.onINP:(null==l?void 0:l.onINP)||a.onINP}if(t&&i&&e&&r){var u={reportSoftNavs:this.useSoftNavs},d=s&&this.attributionMetrics.indexOf("INP")>-1?_({},u,{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&t(this.jd.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&i(this.jd.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&e(this.jd.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&r(this.jd.bind(this),d),this.rs=!0}else ql.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Cd=!(null==(i=this._instance.persistence)||!i.props[Ye]),this.startIfEnabled()}get Wd(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=W(this.Wd)?null==(t=this.Wd)?void 0:t.web_vitals_allowed_metrics:void 0;return X(e)?(null==(i=this._instance.persistence)?void 0:i.props[tr])||Vl:e}get flushToCaptureTimeoutMs(){return(W(this.Wd)?this.Wd.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=W(this.Wd)?this.Wd.web_vitals_attribution:void 0;return it(t)?t?Vl:[]:H(t)?t:Wl}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t=W(this.Wd)?this.Wd.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Hd(){var t=W(this.Wd)&&Z(this.Wd.__web_vitals_max_value)?this.Wd.__web_vitals_max_value:Hl;return t>0&&6e4>=t?Hl:t}get isEnabled(){var t=null==s?void 0:s.protocol;if("http:"!==t&&"https:"!==t)return ql.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=W(this.Wd)?this.Wd.web_vitals:it(this.Wd)?this.Wd:void 0;return it(i)?i:this.Cd}startIfEnabled(){this.isEnabled&&!this.rs&&(ql.info("enabled, starting..."),this.Ms(this.Ud))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=W(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=W(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ye]:e}),this._instance.persistence.register({[tr]:r})),this.Cd=e,this.startIfEnabled()}}}get zd(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ms(t){var i=v.__PosthogExtensions__,e=this.zd,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&K(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?ql.error("failed to load script",i):t()}))}Bd(i){var e=i||(null==t?void 0:t.location.href);if(e){var r=this._instance.config.disable_capture_url_hashes?xi(e):e,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Qn,...s||[]]:[];return Wn(r,n,Zn)}ql.error("Could not determine current URL")}}},Vh={exceptionObserver:class{constructor(i){var e;this.Ud=()=>{var i;if(t&&this.isEnabled&&null!=(i=v.__PosthogExtensions__)&&i.errorWrappingFunctions){var e=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Vd&&this.Wi.capture_unhandled_errors&&(this.Vd=e(this.captureException.bind(this))),!this.Gd&&this.Wi.capture_unhandled_rejections&&(this.Gd=r(this.captureException.bind(this))),!this.Zd&&this.Wi.capture_console_errors&&(this.Zd=s(this.captureException.bind(this)))}catch(t){Ll.error("failed to start",t),this.Qd()}}},this._instance=i,this.Jd=!(null==(e=this._instance.persistence)||!e.props[Ge]),this.oe=new ft(_({},function(t){var i,e,r,s;return void 0===t&&(t={}),{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,I:Ll})),this.Wi=this.Kd(),this.startIfEnabledOrStop()}Kd(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return W(t)?i=_({},i,t):(K(t)?this.Jd:t)&&(i=_({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Wi.capture_console_errors||this.Wi.capture_unhandled_errors||this.Wi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ll.info("enabled"),this.Qd(),this.Ms(this.Ud)):this.Qd()}Ms(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Ll.error("failed to load script",i);t()}))}Qd(){var t,i,e;null==(t=this.Vd)||t.call(this),this.Vd=void 0,null==(i=this.Gd)||i.call(this),this.Gd=void 0,null==(e=this.Zd)||e.call(this),this.Zd=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Jd=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ge]:this.Jd}),this.Wi=this.Kd(),this.startIfEnabledOrStop())}}onConfigChange(){this.Wi=this.Kd()}captureException(t){var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";this.oe.consumeRateLimit(s)?Ll.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var i,e;this.Yd=[],this.Xd=new ie([new ce,new Ee,new pe,new fe,new we,new be,new ge,new xe],function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];return function(i,r){void 0===r&&(r=0);for(var s=[],n=i.split("\n"),o=r;n.length>o;o++){var a=n[o];if(1024>=a.length){var l=ve.test(a)?a.replace(ve,"$1"):a;if(!l.match(/\S*Error: /)){for(var h of e){var u=h(l,t);if(u){s.push(u);break}}if(s.length>=50)break}}}return function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map((t=>{return _({},t,{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||ee});var e}))}(s)}}("web:javascript",le,de)),this._instance=t,this.Yd=null!==(i=null==(e=this._instance.persistence)?void 0:e.get_property(Ke))&&void 0!==i?i:[],this.tv=Pe(this.ev()),this.iv=new Re(this.tv)}onConfigChange(){this.tv=Pe(this.ev()),this.iv.setConfig(this.tv)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Yd=n,this._instance.persistence&&this._instance.persistence.register({[Ke]:this.Yd,[Je]:o})}}}get rv(){var t,i=!!this._instance.get_property(Je),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.Xd.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.tv.enabled)try{if(!J(t)||0===t.trim().length)return void Ph.warn("Ignoring exception step because message must be a non-empty string");var e=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce(((e,r)=>Te.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.nv(i)),r=e.sanitizedProperties,s=e.droppedKeys;s.length>0&&Ph.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.iv.add(_({[Se]:t,[ke]:(new Date).toISOString()},r))}catch(t){Ph.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.sv(i)){if(this.av(i))return this.ov("Exception dropped: matched a suppression rule"),void Ph.info("Skipping exception capture because a suppression rule matched");if(!this.rv&&this.lv(i))return this.ov("Exception dropped: thrown by a browser extension"),void Ph.info("Skipping exception capture because it was thrown by an extension");if(!this.rv&&this.uv(i))return this.ov("Exception dropped: thrown by an injected browser script"),void Ph.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.hv(i))return this.ov("Exception dropped: thrown by the PostHog SDK"),void Ph.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.tv.enabled&&X(t.$exception_steps)?this.dv(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",bl:!0});return s&&this.iv.clear(),s}catch(t){return Ph.error("Failed to capture exception event. Dropping this exception.",t),void this.iv.clear()}}catch(t){return void Ph.error("Failed to process exception event. Ignoring this exception.",t)}var n}dv(t){try{var i=this.iv.getAttachable();return 0===i.length?t:_({},t,{$exception_steps:i})}catch(i){return Ph.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}ov(t){this.tv.enabled&&this.iv.add({[Se]:t,[ke]:(new Date).toISOString()})}nv(t){return W(t)?_({},t):{}}ev(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}av(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return J(e)&&e.length>0&&t.$exception_types.push(e),J(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Yd.some((t=>{var e=t.values.map((t=>{var e=Ka[t.operator],r=i[t.key];if(!e||!r)return!1;var s=H(t.value)?t.value:[t.value];return s.length>0&&e(s,r)}));return"OR"===t.type?e.some(Boolean):e.every(Boolean)}))}catch(t){return Ph.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}lv(t){return t.flatMap((t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]})).some((t=>{var i=t.filename;return!!i&&Rh.some((t=>i.startsWith(t)))}))}uv(t){return t.some((t=>{var i=t.value;return J(i)&&Ch.some((t=>i.includes(t)))}))}hv(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}sv(t){return!X(t)&&H(t)}}},Wh=_({productTours:class{get Qa(){return this._instance.persistence}constructor(t){this.vv=null,this.fv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.Qa&&this.Qa.register({[Xe]:!!i.productTours}),!rh(this._instance))return!this.vv&&X(null==(e=this.Qa)?void 0:e.props[Tr])||eh.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.vv)||r.stop(),this.vv=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.vv&&rh(this._instance)&&this.Ms((()=>this.pv()))}Ms(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?eh.error("Could not load product tours script",i):t()}))}pv(){var t;!this.vv&&null!=(t=v.__PosthogExtensions__)&&t.generateProductTours&&(this.vv=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!H(this.fv)||i){var e=this.Qa;if(e){var r=e.props[Tr];if(H(r)&&!i)return this.fv=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(rh(this._instance)){var r=i.statusCode;if(200!==r||!i.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?i.error||eh.warn(s):eh.error(s),void t([],{isLoaded:!1,error:s})}var n=H(i.json.product_tours)?i.json.product_tours:[];this.fv=n,e&&e.register({[Tr]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.fv,{isLoaded:!0})}getActiveProductTours(t){X(this.vv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.vv.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.vv)||i.showTourById(t)}previewTour(t){this.vv?this.vv.previewTour(t):this.Ms((()=>{var i;this.pv(),null==(i=this.vv)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.vv)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.vv)||t.nextStep()}previousStep(){var t;null==(t=this.vv)||t.previousStep()}clearCache(){var t;this.fv=null,null==(t=this.Qa)||t.unregister(Tr)}resetTour(t){var i;null==(i=this.vv)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.vv)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.vv)||i.cancelPendingTour(t)}}},zh),Gh={siteApps:class{constructor(t){this.gv=0,this._instance=t,this.mv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yv(t,i){if(i){var e=this.globalsForEvent(i);this.mv.push(e),this.mv.length>1e3&&(this.mv=this.mv.slice(10))}}get siteAppLoaders(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.yv.bind(this));this.bv=()=>{t(),this.mv=[],this.bv=void 0}}}globalsForEvent(t){var i,e,r,s,n,o,a;if(!t)throw new Error("Event payload is required");var l={},h=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(u)){var v=d[0];l[v]={id:h[v],type:v,properties:d[1]}}var c=t.$set_once,f=t.$set;return{event:_({},g(t,sh),{properties:_({},t.properties,f?{$set:_({},null!==(i=null==(e=t.properties)?void 0:e.$set)&&void 0!==i?i:{},f)}:{},c?{$set_once:_({},null!==(r=null==(s=t.properties)?void 0:s.$set_once)&&void 0!==r?r:{},c)}:{}),elements_chain:null!==(n=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=t.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_v(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(nh.error("prepare_external_dependency_stylesheet returned null"),null):"script"===e&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(nh.error("prepare_external_dependency_script returned null"),null):t}wv(){var t,i,e,s,n,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var h=null==r?void 0:r.defaultView,u=null==h||null==(t=h.Node)?void 0:t.prototype;if(!h||!u)return()=>{};if(this.gv++,this.Sv)return this.xv();var d=[],v=this,c=new WeakSet,f=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),d.push((()=>{t[i]=r}))}},p=t=>{if(c.has(t))return t;var i=v._v(t);return i&&c.add(i),i},_=t=>t.map((t=>"string"==typeof t?t:p(t))).filter((t=>!Q(t)));return f(u,"appendChild",(t=>function(i){var e=p(i);return e?t.call(this,e):i})),f(u,"insertBefore",(t=>function(i,e){var r=p(i);return r?t.call(this,r,e):i})),f(u,"replaceChild",(t=>function(i,e){var r=p(i);return r?t.call(this,r,e):e})),[null==(i=h.Element)?void 0:i.prototype,null==(e=h.Document)?void 0:e.prototype,null==(s=h.DocumentFragment)?void 0:s.prototype].forEach((t=>{f(t,"append",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))})),f(t,"prepend",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))}))})),[null==(n=h.Element)?void 0:n.prototype,null==(o=h.CharacterData)?void 0:o.prototype,null==(a=h.DocumentType)?void 0:a.prototype].forEach((t=>{f(t,"before",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))})),f(t,"after",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))})),f(t,"replaceWith",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=_(e);return e.length&&!s.length?void 0:t.apply(this,s)}))})),f(null==(l=h.Element)?void 0:l.prototype,"insertAdjacentElement",(t=>function(i,e){var r=p(e);return r?t.call(this,i,r):null})),this.Sv=()=>{d.forEach((t=>t())),this.Sv=void 0},this.xv()}xv(){var t=!1;return()=>{var i;t||(t=!0,this.gv--,0===this.gv&&(null==(i=this.Sv)||i.call(this)))}}Cv(t,i){void 0===i&&(i=!0);var e=this.wv();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.mv.length&&(nh.info("Processing "+this.mv.length+" events for site app with id "+t.id),this.mv.forEach((t=>this.Cv((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this.bv)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,nh.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Cv((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){nh.error(oh+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){nh.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}Tv(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}Mv(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Cv((()=>null==r.processEvent?void 0:r.processEvent(e)))}catch(i){nh.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.Tv(),void this._instance.on("eventCaptured",(t=>this.Mv(t)))):void nh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.bv)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,i=a.id,e=a.url;v["__$$ph_site_app_"+i]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return nh.error(oh+i,t)}))};for(var a of n.siteApps)o()}else nh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Kh={tracingHeaders:class{constructor(t){this.Ev=void 0,this.Iv=void 0,this.Rv=void 0,this.Ud=()=>{var t,i,e=this.Pv();e?(K(this.Ev)&&(this.Ev=null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),K(this.Iv)&&(this.Iv=null==(i=v.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Qd()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Ms(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return zl.error("failed to load script",i);t()}))}Av(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Pv(){var t=this.Av();return H(t)?(H(this.Rv)?this.Rv.splice(0,this.Rv.length,...t):this.Rv=[...t],t.length>0?this.Rv:void 0):(H(this.Rv)&&this.Rv.splice(0),this.Rv=t||void 0,this.Rv)}Qd(){var t,i;null==(t=this.Ev)||t.call(this),null==(i=this.Iv)||i.call(this),this.Ev=void 0,this.Iv=void 0}startIfEnabledOrStop(){this.Pv()?this.Ms(this.Ud):this.Qd()}}},Jh=_({surveys:class extends uh{constructor(t){var i;super(new _h(t),{get projectToken(){return i.config.token},kv:new ph(i=t)}),this._instance=t}zl(t,i){var e=i.query?wa(t,i.query):t;return new Promise((t=>{var r;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})}))}}},zh),Yh={toolbar:class{constructor(t){this.instance=t}Fv(t){v.ph_toolbar_state=t}Ov(){var t;return null!==(t=v.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i,e,s){if(void 0===i&&(i=void 0),void 0===e&&(e=void 0),void 0===s&&(s=void 0),ds(this.instance.config))return!1;if(!t||!r)return!1;i=null!=i?i:t.location,s=null!=s?s:t.history;try{if(!e){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}e=null==t?void 0:t.localStorage}var n,o=gh||Gn(i.hash,"__posthog")||Gn(i.hash,"state"),a=o?ns((()=>JSON.parse(atob(decodeURIComponent(o)))))||ns((()=>JSON.parse(decodeURIComponent(o)))):null;return a&&"ph_authorize"===a.action?((n=a).source="url",n&&Object.keys(n).length>0&&(a.desiredHash?i.hash=a.desiredHash:s?s.replaceState(s.state,"",i.pathname+i.search):i.hash="")):((n=JSON.parse(e.getItem(mh)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}Lv(t){var i=v.ph_load_toolbar||v.ph_load_editor;!X(i)&&V(i)?i(t,this.instance):yh.warn("No toolbar load function found")}loadToolbar(i){var e=!(null==r||!r.getElementById(Bs));if(!t||e)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=_({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(t.localStorage.setItem(mh,JSON.stringify(_({},n,{source:void 0}))),2===this.Ov())this.Lv(n);else if(0===this.Ov()){var o;this.Fv(1),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return yh.error("[Toolbar] Failed to load",t),void this.Fv(0);this.Fv(2),this.Lv(n)})),us(t,"turbolinks:load",(()=>{this.Fv(0),this.loadToolbar(n)}))}return!0}Dv(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},Qh=_({experiments:Ah},zh),Xh={conversations:class{constructor(t){this.$v=void 0,this._conversationsManager=null,this.Nv=!1,this.Me=null,this.qv=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.jv=t.ok,t.ok)){var i=t.config.conversations;X(i)||(it(i)?this.$v=i:(this.$v=i.enabled,this.Me=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.$v=void 0,this.Me=null,this.jv=void 0,this.qv=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Nv||this._instance.config.disable_conversations||ds(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==v?void 0:v.__PosthogExtensions__;if(t&&!K(this.$v)&&this.$v)if(this.Me&&this.Me.token){this.Nv=!0;try{var i=t.initConversations;if(i)return this.Bv(i),void(this.Nv=!1);var e=t.loadExternalDependency;if(!e)return void this.Hv(qr);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.Hv("Could not load conversations script",i):this.Bv(t.initConversations),this.Nv=!1}))}catch(t){this.Hv("Error initializing conversations",t),this.Nv=!1}}else Fh.error("Conversations enabled but missing token in remote config.")}}Bv(t){if(this.Me)try{this._conversationsManager=t(this.Me,this._instance),this.qv=!1,Fh.info("Conversations loaded successfully")}catch(t){this.Hv("Error completing conversations initialization",t)}else Fh.error("Cannot complete initialization: remote config is null")}Hv(t,i){Fh.error(t,i),this._conversationsManager=null,this.Nv=!1,this.qv=!0}show(){this._conversationsManager?this._conversationsManager.show():Fh.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.$v&&!Q(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":ds(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.jv?"remote_config_failed":K(this.$v)?this.jv?"disabled_in_project":"remote_config_pending":this.$v?X(this.Me)||!this.Me.token?"missing_token":null!=v&&v.__PosthogExtensions__?this.Nv?"initializing":this.qv?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var r=this;return p((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,i,e):(Fh.warn(Mh),null)}))()}getMessages(t,i){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Fh.warn(Mh),null)}))()}markAsRead(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Fh.warn(Mh),null)}))()}getTickets(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Fh.warn(Mh),null)}))()}requestRestoreLink(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Fh.warn(Mh),null)}))()}restoreFromToken(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Fh.warn(Mh),null)}))()}restoreFromUrlToken(){var t=this;return p((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Fh.warn(Mh),null)}))()}getCurrentTicketId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}El(){var t;null==(t=this._conversationsManager)||t.setIdentity()}Il(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},Zh={logs:class{constructor(i){var e,r=this;this.name="logs",this.Uv=!1,this.zv=!1,this.Wv=!1,this.I=Ae("[logs]"),this.Vv=_({},this.I,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(Bh)||r.I.error(...i)}}),this.Ma=[],this.Gv=[],this.wh=0,this.ls=!1,this.Zv=[],this.Qv=[],this.Jv=!1,this.Kv=!1,this.Yv=()=>{var t,i;this.ls||(this.wh=0,null==(t=this.Xv)||t.onReconnect(),null==(i=this.tc)||i.onReconnect())},this._instance=i,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.Uv=!0),t&&us(t,"online",this.Yv)}ec(t,i,e,r){var s,n=Dh(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new Wi(this.ic(t,i),n,this.Vv,(()=>this.rc()),(t=>t()),void 0,r),n]}nc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Xv||this.sc!==i){var e;null==(e=this.Xv)||e.reset(),this.sc=i;var r=this.ec((()=>this.Ma),(t=>{this.Ma=t}));this.Xv=r[0],this.ac=r[1]}return this.Xv}oc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.tc||this.lc!==i){var e;null==(e=this.tc)||e.reset(),this.lc=i;var r=this.ec((()=>this.Gv),(t=>{this.Gv=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Lh);this.tc=r[0],this.uc=r[1]}return this.tc}setup(t){var i;if(!this.ls){this.vs=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.Uv=!0),(this.Uv||this.hc()&&this.dc())&&this.vc();var e=!1,r=t.onRemoteConfig((t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)}));this.ls?r.dispose():(this.cs=r,e||this.loadIfEnabled())}}dispose(){var i,e,r,s;this.ls||(this.ls=!0,this.cc(),null==(i=this.cs)||i.dispose(),this.cs=void 0,this.vs=void 0,this.Wv=!1,null==t||t.removeEventListener("online",this.Yv),null==(e=this.fc)||e.call(this),this.fc=void 0,null==(r=this.Xv)||r.reset(),null==(s=this.tc)||s.reset())}onRemoteConfig(t){var i,e;if(!this.ls){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;X(r)?this.gc():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[Ze]:!!r}),r?(this.Uv=!0,this.zv||this.vc(),this.loadIfEnabled()):this.gc())}}reset(){var t,i,e,r;this.cc(),null==(t=this.Xv)||t.clearQueue(),this.Ma=[],null==(i=this.Xv)||i.reset(),null==(e=this.tc)||e.clearQueue(),this.Gv=[],null==(r=this.tc)||r.reset(),this.wh=0}captureLog(t){this.ls||this.nc().captureLog(t)}captureConsoleLog(t){this.ls||this.oc().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.ls||this.oc().captureLog(t,{context:i,occurredAtMs:e})}dc(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[Ze])}hc(){var t,i;return null==(t=this._instance)||null==t.Sa||!t.Sa()||!(null==(i=v._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}Pl(){var t;this.cc(),null==(t=this.tc)||t.clearQueue(),this.Gv=[]}gc(){this.Uv||this.cc()}vc(){var t,i=this;if(!this.Jv&&null!=v&&v.console){var e=Dh(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(v.console[t])}catch(t){return 0}if(!r)return 0;i.Qv.push(Bl(v.console,t,(s=>{var n=function(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];try{i.mc(t,n,e)}catch(t){}return s.apply(v.console,n)};return n.__rrweb_original__=r,n})))};for(var s of Nh)r(s);this.Jv=!0,this.yc=setTimeout((()=>{this.cc()}),3e4)}}mc(t,i,e){var r;if(this.Jv&&!this.Kv&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Zv.length){this.Kv=!0;try{this.Zv.push({level:t,args:i,occurredAtMs:Date.now(),context:this.rc()})}finally{this.Kv=!1}}}else this.cc()}cc(){if(this.Zv=[],this.Jv){for(var t of(this.Jv=!1,this.yc&&(clearTimeout(this.yc),this.yc=void 0),this.Qv))t();this.Qv=[]}}bc(){var t=this.Zv;return this.cc(),t}get logger(){return this._c||(this._c={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this._c}flushLogs(t){t?this.wc(t):(this.Xv&&this.Xv.flush().catch((t=>this.kc(t))),this.tc&&this.tc.flush().catch((t=>this.kc(t))))}kc(t){Bh(t)||this.I.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.ls&&this.Uv&&!this.zv&&!this.Wv){var t=null==v?void 0:v.__PosthogExtensions__;if(!t)return this.I.error("PostHog Extensions not found."),void this.cc();var i=t.loadExternalDependency;if(!i)return this.I.error(qr),void this.cc();this.Wv=!0;try{i(this._instance,"logs",(i=>{if(this.Wv=!1,!this.ls&&this.Uv){var e=t.logs;if(i||null==e||!e.initializeLogs)this.I.error("Could not load logs script",i),this.cc();else{var r,s,n=this.bc();this.fc=e.initializeLogs(null!==(r=this.vs)&&void 0!==r?r:this._instance),this.zv=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.vs)&&void 0!==s?s:this._instance,n))}}}))}catch(t){throw this.Wv=!1,t}}}ic(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===x.LogsQueue?t():void 0,setPersistedProperty(t,e){var r;t===x.LogsQueue&&i(null!==(r=e)&&void 0!==r?r:[])},On:t=>this.On(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}On(t){return new Promise((i=>{if(Kn(this.wh,3))i({kind:"fatal",error:jh(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout((()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:jh(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Sc(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.xc(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:jh(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}}))}xc(t){(0!==t||this._instance.__loaded)&&(this.wh=Jn(t,this.wh,3,(()=>this.I.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."))))}wc(t){this.Ma.length>0&&this.Cc(t,this.Ma,this.ac,c.LIB_NAME,(t=>{this.Ma=t})),this.Gv.length>0&&this.Cc(t,this.Gv,this.uc,Lh,(t=>{this.Gv=t}))}Cc(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var o=Vi(n,Hi(e,c.LIB_NAME,c.LIB_VERSION),r,c.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Sc(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Sc(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}rc(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,X(s)||(i.sessionStartTimestamp=s),X(n)||(i.lastActivityTimestamp=n)}if(null!=v&&null!=(t=v.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?xi(v.location.href):v.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}}},tu={metrics:class{constructor(t){this.I=Ae("[metrics]"),this._instance=t}initialize(){}nc(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Xv&&this.sc===e||(null==(i=this.Xv)||i.reset(),this.sc=e,this.Xv=new Yi(this.ic(),function(t){var i,e,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(e),this.I)),this.Xv}count(t,i,e){void 0===i&&(i=1),this.nc().count(t,i,e)}gauge(t,i,e){this.nc().gauge(t,i,e)}histogram(t,i,e){this.nc().histogram(t,i,e)}flush(t){if(!this.Xv)return Promise.resolve();if(t){var i=this.Xv.drainWindow();return i&&this.Jn(i,t),Promise.resolve()}return this.Xv.flush().catch((t=>this.I.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Xv)||t.reset()}ic(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Jn:t=>i.Jn(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Jn(t,i){return new Promise((e=>{var r=!1,s=t=>{r||(r=!0,clearTimeout(n),e(t))},n=setTimeout((()=>s({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(_({method:"POST",url:this.Tc(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var i=t.statusCode;if(i>=200&&300>i)s({kind:"ok"});else if(413===i)s({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)s({kind:"fatal",error:new Error("metrics request failed with status "+i)});else{var e;s({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("metrics request failed with status "+i)})}}}))}))}Tc(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},iu=_({},zh,qh,Hh,Vh,Wh,Gh,Jh,Kh,Yh,Qh,Xh,Zh,tu);Rl.__defaultExtensionClasses=_({},iu);var eu=function(){c.SDK_DIST_CHANNEL="npm";var i=fl[xl]=new Rl;return function(){function i(){i.done||(i.done=!0,El=!1,es(fl,(function(t){t._dom_loaded()})))}null!=r&&r.addEventListener?"complete"===r.readyState?i():us(r,"DOMContentLoaded",i,{capture:!1}):t&&Ie.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),i}();export{yo as Compression,Oo as DEFAULT_PRODUCT_TOUR_APPEARANCE,Co as DisplaySurveyType,Rl as PostHog,Io as ProductTourEventName,Ao as ProductTourEventProperties,Po as SurveyEventName,Ro as SurveyEventProperties,bo as SurveyEventType,xo as SurveyPosition,To as SurveyQuestionBranchingType,ko as SurveyQuestionType,$o as SurveySchedule,Eo as SurveyTabPosition,So as SurveyType,wo as SurveyWidgetType,eu as default,eu as posthog,Lo as severityLevels};
1
+ var t="undefined"!=typeof window?window:void 0,i="undefined"!=typeof globalThis?globalThis:t,e=null==i?void 0:i.navigator,r=null==i?void 0:i.document,s=null==i?void 0:i.location,n=null==i?void 0:i.fetch,o=null!=i&&i.XMLHttpRequest&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,a=null==i?void 0:i.AbortController,l=null==i?void 0:i.CompressionStream,h=null==e?void 0:e.userAgent;function u(){return!(!t||!1===t.navigator.onLine)}var d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});var v=null!=t?t:{},c={DEBUG:!1,LIB_VERSION:"0.6.1",LIB_NAME:"browser-common"};function f(t,i,e,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void e(t)}a.done?i(l):Promise.resolve(l).then(r,s)}function p(t){return function(){var i=this,e=arguments;return new Promise((function(r,s){var n=t.apply(i,e);function o(t){f(n,r,s,o,a,"next",t)}function a(t){f(n,r,s,o,a,"throw",t)}o(void 0)}))}}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var i=1;arguments.length>i;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},_.apply(null,arguments)}function g(t,i){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==i.indexOf(r))continue;e[r]=t[r]}return e}var m=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function y(t){return"string"==typeof t||t}function b(t){return"string"==typeof t?t:void 0}var w=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],x=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),E=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),S=["$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"],k=["token"],T=20,P=1e3,R=1e4,C="[Circular]",O="[Truncated]",I="[Unserializable]",A="[Function]";function F(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}var M=["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","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],D=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return M.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function N(t,i){return-1!==t.indexOf(i)}var L=function(t){return t.trim()},U=function(t){return t.replace(/^\$/,"")};function j(t){var i,e=[];return null!==(i=JSON.stringify(t,(function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}})))&&void 0!==i?i:"null"}var B=Object.prototype,z=B.hasOwnProperty,q=B.toString,H=Array.isArray||function(t){return"[object Array]"===q.call(t)},V=t=>"function"==typeof t,W=t=>t===Object(t)&&!H(t),G=t=>{if(W(t)){for(var i in t)if(z.call(t,i))return!1;return!0}return!1},K=t=>void 0===t,J=t=>"[object String]"==q.call(t),Y=t=>J(t)&&0===t.trim().length,Q=t=>null===t,X=t=>K(t)||Q(t),Z=t=>"[object Number]"==q.call(t)&&t==t,tt=t=>Z(t)&&t>0,it=t=>"[object Boolean]"===q.call(t),et=t=>t instanceof FormData,rt=t=>N(S,t),st=t=>N(k,t);function nt(t){return null===t||"object"!=typeof t}function ot(t,i){return{}.toString.call(t)==="[object "+i+"]"}function at(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return ht(t,Error)}}function lt(t){return"undefined"!=typeof Event&&ht(t,Event)}function ht(t,i){try{return t instanceof i}catch(t){return!1}}var ut=[!0,"true",1,"1","yes"],dt=t=>N(ut,t),vt=[!1,"false",0,"0","no"];function ct(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),Z(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),ct(s||e,i,e,r))}class ft{constructor(t){this.k={},this.S=t.S,this.C=ct(t.bucketSize,0,100,t.I),this.A=ct(t.refillRate,0,this.C,t.I),this.R=ct(t.refillInterval,0,864e5,t.I)}O(t,i){var e=Math.floor((i-t.lastAccess)/this.R);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.C),t.lastAccess=t.lastAccess+e*this.R)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.k[r];return s?this.O(s,e):this.k[r]=s={tokens:this.C,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.S)||i.call(this,t)),0===s.tokens)}stop(){this.k={}}}var pt="Mobile",_t="iOS",gt="Android",mt="Tablet",yt=gt+" "+mt,bt="iPad",wt="Apple",xt=wt+" Watch",Et="Safari",St="BlackBerry",kt="Samsung",Tt=kt+"Browser",$t=kt+" Internet",Pt="Chrome",Rt=Pt+" OS",Ct=Pt+" "+_t,Ot="Internet Explorer",It=Ot+" "+pt,At="Opera",Ft=At+" Mini",Mt="Edge",Dt="Microsoft "+Mt,Nt="Firefox",Lt=Nt+" "+_t,Ut="Nintendo",jt="PlayStation",Bt="Xbox",zt=gt+" "+pt,qt=pt+" "+Et,Ht="Windows",Vt=Ht+" Phone",Wt="Nokia",Gt="Ouya",Kt="Generic",Jt=Kt+" "+pt.toLowerCase(),Yt=Kt+" "+mt.toLowerCase(),Qt="Konqueror",Xt="Oculus Browser",Zt="Vivaldi",ti="Yandex",ii="Whale",ei="DuckDuckGo",ri="Pale Moon",si="Waterfox",ni="Brave",oi="Google Search App",ai="(\\d+(\\.\\d+)?)",li=new RegExp("Version/"+ai),hi=new RegExp(Bt,"i"),ui=new RegExp(jt+" \\w+","i"),di=new RegExp(Ut+" \\w+","i"),vi=new RegExp(St+"|PlayBook|BB10","i"),ci={"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"},fi=function(t,i,e,r){i=i||"";var s=function(t){return null!=t&&t.brave?ni:null}(e);return s||(null!=r&&r.detectGoogleSearchApp&&N(t,"GSA/")?oi:N(t," OPR/")&&N(t,"Mini")?Ft:N(t," OPR/")?At:vi.test(t)?St:N(t,"IE"+pt)||N(t,"WPDesktop")?It:N(t,"OculusBrowser")?Xt:N(t,Tt)?$t:N(t,Mt)||N(t,"Edg/")?Dt:N(t,Zt+"/")?Zt:N(t,"YaBrowser/")?ti:N(t,ii+"/")?ii:N(t,ei+"/")||N(t,"Ddg/")?ei:N(t,"FBIOS")?"Facebook "+pt:N(t,"UCWEB")||N(t,"UCBrowser")?"UC Browser":N(t,"CriOS")?Ct:N(t,"CrMo")||N(t,Pt)?Pt:N(t,gt)&&N(t,Et)?zt:N(t,"FxiOS")?Lt:N(t.toLowerCase(),Qt.toLowerCase())?Qt:N(t,ni+"/")?ni:((t,i)=>i&&N(i,wt)||function(t){return N(t,Et)&&!N(t,Pt)&&!N(t,gt)}(t))(t,i)?N(t,pt)?qt:Et:N(t,"PaleMoon/")?ri:N(t,si+"/")?si:N(t,Nt)?Nt:N(t,"MSIE")||N(t,"Trident/")?Ot:N(t,"Gecko")?Nt:"")},pi={[It]:[new RegExp("rv:"+ai)],[Dt]:[new RegExp(Mt+"?\\/"+ai)],[Pt]:[new RegExp("("+Pt+"|CrMo)\\/"+ai)],[Ct]:[new RegExp("CriOS\\/"+ai)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ai)],[Et]:[li],[qt]:[li],[At]:[new RegExp("(Opera|OPR)\\/"+ai)],[Nt]:[new RegExp(Nt+"\\/"+ai)],[Lt]:[new RegExp("FxiOS\\/"+ai)],[Qt]:[new RegExp("Konqueror[:/]?"+ai,"i")],[St]:[new RegExp(St+" "+ai),li],[zt]:[new RegExp("android\\s"+ai,"i")],[$t]:[new RegExp(Tt+"\\/"+ai)],[Xt]:[new RegExp("OculusBrowser\\/"+ai)],[Zt]:[new RegExp(Zt+"\\/"+ai)],[ti]:[new RegExp("YaBrowser\\/"+ai)],[ii]:[new RegExp(ii+"\\/"+ai)],[ni]:[new RegExp(ni+"\\/"+ai)],[ei]:[new RegExp("(DuckDuckGo|Ddg)\\/"+ai)],[ri]:[new RegExp("PaleMoon\\/"+ai)],[si]:[new RegExp(si+"\\/"+ai)],[oi]:[new RegExp("GSA\\/"+ai)],[Ot]:[new RegExp("(rv:|MSIE )"+ai)],Mozilla:[new RegExp("rv:"+ai)]},_i=function(t,i,e,r){var s=fi(t,i,e,r),n=pi[s];if(K(n))return null;for(var o=0;n.length>o;o++){var a=t.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},gi=[[new RegExp(Bt+"; "+Bt+" (.*?)[);]","i"),t=>[Bt,t&&t[1]||""]],[new RegExp(Ut,"i"),[Ut,""]],[new RegExp(jt,"i"),[jt,""]],[vi,[St,""]],[new RegExp(Ht,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[Vt,""];if(new RegExp(pt).test(i)&&!/IEMobile\b/.test(i))return[Ht+" "+pt,""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=ci[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[Ht,r]}return[Ht,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[_t,[t[3],t[4],t[5]||"0"].join(".")]:[_t,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=K(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("("+gt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+gt+")","i"),t=>t&&t[2]?[gt,[t[2],t[3],t[4]||"0"].join(".")]:[gt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Rt,""]],[/Linux|debian/i,["Linux",""]]],mi=function(t){return di.test(t)?Ut:ui.test(t)?jt:hi.test(t)?Bt:new RegExp(Gt,"i").test(t)?Gt:new RegExp("("+Vt+"|WPDesktop)","i").test(t)?Vt:/iPad/.test(t)?bt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?xt:vi.test(t)?St:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Wt,"i").test(t)?Wt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(pt).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?gt:yt:new RegExp("(pda|"+pt+")","i").test(t)?Jt:new RegExp(mt,"i").test(t)&&!new RegExp(mt+" pc","i").test(t)?Yt:""},yi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function bi(t,i){return"string"==typeof(e=t)&&yi.test(e)?t:i();var e}function wi(t,i){var e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function xi(t){return t?t.split("#")[0]:t}function Ei(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function Si(t,i,e){return ki.apply(this,arguments)}function ki(){return(ki=p((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=Ei((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Ti,$i="NativeGzipValidationError",Pi=t=>t.length>=2&&31===t[0]&&139===t[1],Ri=(t,i)=>t===E.GZipJS||i===E.GZipJS||"gzip"===i,Ci=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),Oi=t=>{throw wi($i,"Native gzip produced invalid output: "+t)},Ii=function(){var t=p((function*(t,i){18>t.size&&Oi("too-short");var e=new Uint8Array(yield t.slice(0,10).arrayBuffer());Pi(e)&&8===e[2]||Oi("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var i=(()=>{if(Ti)return Ti;Ti=[];for(var t=0;256>t;t++){for(var i=t,e=0;8>e;e++)i=1&i?3988292384^i>>>1:i>>>1;Ti[t]=i>>>0}return Ti})(),e=4294967295,r=0;t.length>r;r++)e=i[255&(e^t[r])]^e>>>8;return(4294967295^e)>>>0})(i)&&Oi("invalid-crc");var s=i.length>>>0;r.getUint32(4,!0)!==s&&Oi("invalid-size")}));return function(i,e){return t.apply(this,arguments)}}();function Ai(){return Ai=p((function*(t,i,e){void 0===i&&(i=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),n=s.writable.getWriter(),o=n.write(r).then((()=>n.close())).catch(function(){var t=p((function*(t){try{yield n.abort(t)}catch(t){}throw t}));return function(i){return t.apply(this,arguments)}}()),a=new Response(s.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield Ii(l,r),l}catch(t){if(null!=e&&e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}})),Ai.apply(this,arguments)}var Fi={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Mi=Fi.info,Di=0x8000000000000000,Ni={}.propertyIsEnumerable;function Li(t,i){try{return Bi(t,i,{ancestors:new WeakSet,remainingNodes:R},0)}catch(t){return[]}}function Ui(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:O};if(e.remainingNodes--,it(t))return{boolValue:t};if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if("undefined"==typeof BigInt)return{stringValue:String(t)};var s=BigInt(t).toString();return t>=Di||-Di>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:F(t)};if("function"==typeof t)return{stringValue:A};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:C};if(r>=T)return{stringValue:O};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof o?F(o):String(o)}}e.ancestors.add(t);try{try{var a=t.toJSON;if("function"==typeof a)return Ui(a.call(t),i,e,r+1)}catch(t){}return H(t)?{arrayValue:{values:ji(t,i,e,r+1)}}:{kvlistValue:{values:Bi(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:F(String(t))}}function ji(t,i,e,r){for(var s=[],n=Math.min(t.length,P),o=0;n>o&&e.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(X(a))continue;s.push(Ui(a,i,e,r))}catch(t){s.push({stringValue:I})}return t.length>o&&s.push({stringValue:O}),s}function Bi(t,i,e,r){var s=[];for(var n in t)if(Ni.call(t,n)){if(s.length>=P||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(Q(o)||K(o))continue;s.push({key:F(n),value:Ui(o,i,e,r)})}catch(t){s.push({key:F(n),value:{stringValue:I}})}}return s}function zi(t){try{return F(String(t))}catch(t){return I}}function qi(t,i,e,r){var s,n=Fi[t.level||"info"]||Mi,o=n.text,a=n.number,l=(void 0===(s=Z(r)?r:void 0)&&(s=Date.now()),String(s)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),X(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),X(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var u=_({},h),d=t.attributes;if(d){var v=[];try{v=Object.keys(d)}catch(t){v=[]}for(var c of v){var f=void 0;try{f=d[c]}catch(t){f=I}Object.defineProperty(u,c,{value:f,enumerable:!0,writable:!0,configurable:!0})}}var p={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:a,severityText:o,body:{stringValue:zi(t.body)},attributes:Li(u,e)};return t.trace_id&&(p.traceId=t.trace_id),t.span_id&&(p.spanId=t.span_id),K(t.trace_flags)||(p.flags=t.trace_flags),p}function Hi(t,i,e){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}function Vi(t,i,e,r){return{resourceLogs:[{resource:{attributes:Li(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let Wi=class{constructor(t,i,e,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.zi=i,this.I=e,this.hn=r,this.dn=s,this.vn=n,this.fn=o,this.pn=null,this.gn=0,this.mn=0,this.yn=0,this.bn=0,this._n=0,this.wn=!1,this.kn=i.maxBufferSize,this.Sn=Math.max(null!==(a=i.maxQueueSize)&&void 0!==a?a:i.maxBufferSize,i.maxBufferSize),this.xn=i.flushIntervalMs,this.Cn=i.maxBatchRecordsPerPost,this.Tn=i.rateCapWindowMs,this.Mn=i.maxLogsPerInterval}clearQueue(){this.mn++,this._instance.setPersistedProperty(x.LogsQueue,[])}reset(){this.En(),this.bn=0,this._n=0,this.wn=!1,this.yn=0,this.Cn=this.zi.maxBatchRecordsPerPost}onReconnect(){this.yn=0,this.In()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Rn(t);if(null!==r)if(r.body){if(this.Pn()){var s={record:qi(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.hn(),this.I,null==i?void 0:i.occurredAtMs)};this.dn((()=>this.An(s)))}}else this.I.info("Log was rejected in beforeSend function")}}Rn(t){var i=this.zi.beforeSend;if(!i)return t;var e=H(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for log:",t),null}return r}Pn(){if(void 0===this.Mn)return!0;var t=Date.now(),i=t-this.bn;return this.Tn>i&&i>=0||(this.bn=t,this._n=0,this.wn=!1),this.Mn>this._n?(this._n++,!0):(this.wn||(this.I.warn("captureLog dropping logs: exceeded "+this.Mn+" logs per "+this.Tn+"ms"),this.wn=!0),!1)}flush(){var t=this;return p((function*(){if(!t._instance.isDisabled)return t.pn||(t.pn=t.Fn().finally((()=>{t.pn=null}))),t.pn}))()}Fn(){var t=this;return p((function*(){var i;t.En();var e=null!==(i=t._instance.getPersistedProperty(x.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,o,a=t.mn;t.gn=0;var l=Math.min(e.length,t.Cn),h=e.slice(0,l),u=Vi(h.map((t=>t.record)),t.On(),null!==(n=t.fn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.Ln(u);if(t.mn!==a)return;if("too-large"===d.kind&&h.length>1)t.Cn=Math.max(1,Math.floor(h.length/2)),t.I.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.Cn);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.zi.maxBatchRecordsPerPost>t.Cn&&(t.Cn=Math.min(t.zi.maxBatchRecordsPerPost,t.Cn+1)),yield t.Dn(h.length),e=null!==(o=t._instance.getPersistedProperty(x.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===d.kind)throw d.error}}}))()}Dn(t){var i=this;return p((function*(){var e,r=Math.max(0,t-i.gn),s=null!==(e=i._instance.getPersistedProperty(x.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(x.LogsQueue,s.slice(r)),yield i.vn()}))()}On(){return Hi(this.zi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}An(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(x.LogsQueue))&&void 0!==i?i:[];this.Sn>e.length||(e.shift(),this.gn++,this.I.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(x.LogsQueue,e),this.kn>e.length?this.$n():this.In()}}$n(t){void 0===t&&(t=this.xn),this.Nn||(this.Nn=Ei((()=>{this.Nn=void 0,this.In()}),t))}qn(){var t=Math.min(Math.max(0,this.yn-1),6);return this.xn*Math.pow(2,t)}jn(){var t=this._instance.getPersistedProperty(x.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return p((function*(){i.En();var e=i.flush().catch((()=>{}));void 0!==t?yield Si(e,t):yield e}))()}flushWithTimeout(t){var i=this;return p((function*(){var e=i.flush();yield Si(e,t,(()=>{e.catch((()=>{}))}))}))()}In(){this.flush().then((()=>{this.yn=0}),(t=>{this.yn++,this.I.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.jn()&&this.$n(this.qn())}))}En(){this.Nn&&(clearTimeout(this.Nn),this.Nn=void 0)}};var Gi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ki(t){return String(t)+"000000"}function Ji(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}let Yi=class{constructor(t,i,e){this._instance=t,this.zi=i,this.I=e,this.Bn=new Map,this.pn=null,this.Hn=!1,this.Un=new Map,this.zn=new Set,this.Wn=0}count(t,i,e){void 0===i&&(i=1),this.Vn({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Vn({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Vn({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,i=this.pn,e=function(){var e=p((function*(){i&&(yield i.catch((()=>{}))),yield t.Gn()}));return function(){return e.apply(this,arguments)}}(),r=e().finally((()=>{this.pn===r&&(this.pn=null)}));return this.pn=r,r}drainWindow(){if(0===this.Bn.size)return null;var t=this.Bn;return this.Bn=new Map,this.Hn=!1,this.Un=new Map,this.zn=new Set,this.Zn(t)}reset(){this.Wn++,this.En(),this.Bn=new Map,this.pn=null,this.Hn=!1,this.Un=new Map,this.zn=new Set}Vn(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Rn(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.I.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var e,r;try{e=i.attributes?_({},i.attributes):void 0,r=Ji(i.type,i.name,i.unit,e)}catch(t){return void this.I.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s=this.Bn.get(r);if(!s){if(!this.Qn())return;s={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.Bn.set(r,s)}var n=this.Un.get(i.name);void 0===n?this.Un.set(i.name,i.type):n===i.type||this.zn.has(i.name)||(this.zn.add(i.name),this.I.warn("Metric name '"+i.name+"' is already used as a "+n+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Jn(s,i.value),this.$n()}else this.I.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}Qn(){return this.zi.maxSeriesPerFlush>this.Bn.size||(this.Hn||(this.Hn=!0,this.I.warn("Metric series cap reached ("+this.zi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Jn(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Gi.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=i,r.min=Math.min(r.min,i),r.max=Math.max(r.max,i),r.bucketCounts[function(t,i){for(var e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Gi)]+=1}}Rn(t){var i=this.zi.beforeSend;if(!i)return t;var e=H(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for metric:",t),null}return r}$n(){this.Nn||(this.Nn=Ei((()=>{this.Nn=void 0,this.flush().catch((t=>{this.I.error("Metrics flush failed:",t)}))}),this.zi.flushIntervalMs))}En(){this.Nn&&(clearTimeout(this.Nn),this.Nn=void 0)}Gn(){var t=this;return p((function*(){if(0!==t.Bn.size){var i=t.Bn;t.Bn=new Map,t.Hn=!1,t.Un=new Map,t.zn=new Set;var e=t.Wn,r=yield t._instance.Kn(t.Zn(i));if(e===t.Wn)switch(r.kind){case"ok":return;case"retry-later":return t.Yn(i),void t.$n();case"too-large":return void t.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.I.error("Failed to send metrics batch:",r.error)}}}))()}Zn(t){return i=this.Xn(t),e=function(t,i,e){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}(this.zi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Li(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Xn(t){var i=Ki(Date.now()),e=new Map;for(var r of t.values()){var s,n=Ji(r.type,r.name,r.unit,void 0),o=e.get(n);o||(o=_({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},e.set(n,o));var a=Li(null!==(s=r.attributes)&&void 0!==s?s:{},this.I),l=Ki(r.windowStartMs);if("count"===r.type){var h,u={attributes:a,startTimeUnixNano:l,timeUnixNano:i,asDouble:null!==(h=r.total)&&void 0!==h?h:0};o.sum.dataPoints.push(u)}else if("gauge"===r.type){var d,v={attributes:a,timeUnixNano:i,asDouble:null!==(d=r.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(v)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:i,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:Gi})}return Array.from(e.values())}Yn(t){var i,e;for(var r of t){var s=r[0],n=r[1],o=this.Bn.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(i=o.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Qn()&&this.Bn.set(s,n)}}};var Qi,Xi,Zi;function te(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return Zi&&e.length===Xi||(Xi=e.length,Zi=e.reduce(((e,r)=>{Qi||(Qi={});var s=Qi[r];if(s)e[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,h=i[r];if(l&&h){e[l]=h,Qi[r]=[l,h];break}}return e}),{})),Zi}}class ie{constructor(t,i,e){void 0===e&&(e=[]),this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i){void 0===i&&(i={});var e=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(e,i,0).apply(t),s=this.buildParsingContext(i),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,e),$exception_level:"error"}}modifyFrames(t){var i=this;return p((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&H(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t}))()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e,r;return null!=t.cause&&(e=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(r=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),_({},t,{cause:e,stack:r})}applyChunkIds(t,i){return t.map((t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t)))}applyCoercers(t,i){for(var e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return p((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,i){var e,r,s,n={type:t.type,value:t.value,mechanism:{type:null!==(e=i.type)&&void 0!==e?e:"generic",handled:null===(r=i.handled)||void 0===r||r,synthetic:null!==(s=t.synthetic)&&void 0!==s&&s}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,_({},i,{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:te(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,e){void 0===e&&(e=0);var r=(e,r)=>{if(4>=r){var s=this.buildCoercingContext(t,i,r);return this.applyCoercers(e,s)}};return _({},i,{syntheticException:0==e?i.syntheticException:void 0,mechanism:t,apply:t=>r(t,e),next:t=>r(t,e+1)})}}var ee="?";function re(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?ee:e,in_app:!(null!=i&&i.startsWith("webkit-masked-url://"))&&"<anonymous>"!==i};return K(r)||(n.lineno=r),K(s)||(n.colno=s),n}var se=(t,i)=>{var e=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return e||r?[-1!==t.indexOf("@")?t.split("@")[0]:ee,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},ne=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,oe=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ae=/\((\S*)(?::(\d+))(?::(\d+))\)/,le=(t,i)=>{var e=ne.exec(t);if(e)return re(i,e[1],ee,+e[2],+e[3]);var r=oe.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ae.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=se(r[1]||ee,r[2]);return re(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},he=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ue=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,de=(t,i)=>{var e=he.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=ue.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}var s=e[3],n=e[1]||ee,o=se(n,s);return re(i,s=o[1],n=o[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ve=/\(error: (.*)\)/;class ce{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=J(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?i+": "+t.message:i}isDOMException(t){return ot(t,"DOMException")}isDOMError(t){return ot(t,"DOMError")}}class fe{match(t){return at(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}}class pe{constructor(){}match(t){return!!ot(t,"ErrorEvent")&&(null!=t.error||this.ki(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);var r=i.apply(t.message);return _({},r,{stack:null!==(e=this.Si(t))&&void 0!==e?e:r.stack,synthetic:!0})}ki(t){return J(t.message)&&t.message.length>0}Si(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(J(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var _e=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ge{match(t){return"string"==typeof t}coerce(t,i){var e,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}getInfos(t){var i="Error",e=t,r=t.match(_e);return r&&(i=r[1],e=r[2]),[i,e]}}var me=["fatal","error","warning","log","info","debug"];function ye(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}class be{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,r,s=this.getErrorPropertyFromObject(t);return s?i.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null==(r=i.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(lt(t))return t.constructor.name;var i="name"in t?t.name:void 0;return J(i)&&!Y(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var i="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(i+=" with message: '"+t.message+"'"),i}if("message"in t&&"string"==typeof t.message)return t.message;var e=this.getObjectClassName(t);return(e&&"Object"!==e?"'"+e+"'":"Object")+" captured as exception with keys: "+ye(t)}isSeverityLevel(t){return J(t)&&!Y(t)&&me.indexOf(t)>=0}getStack(t){try{return J(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:J(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(at(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}}class we{match(t){return lt(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ye(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class xe{match(t){return nt(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class Ee{match(t){return ot(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!lt(t))return!1;try{var i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e,r=this.getUnhandledRejectionReason(t);return nt(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var Se="$message",ke="$timestamp",Te=new Set([Se,ke]),$e={enabled:!0,max_bytes:32768};function Pe(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:$e.enabled,max_bytes:Ce(t.max_bytes,$e.max_bytes)}:_({},$e)}class Re{constructor(t){this.ts=[],this.es=0,this.zi=Pe(t)}setConfig(t){this.zi=Pe(t),this.rs()}add(t){var i=function(t){var i;try{i=j(t)}catch(t){return}try{var e=JSON.parse(i);if(!W(e))return;var r=e,s=r[Se],n=r[ke];if(!J(s)||0===s.trim().length)return;if(!J(n)&&!Z(n))return;return{step:r,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.zi.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.rs())}}getAttachable(){return this.ts.map((t=>t.step))}clear(){this.ts=[],this.es=0}size(){return this.ts.length}rs(){for(;this.es>this.zi.max_bytes&&this.ts.length>0;){var t=this.ts.shift();t&&(this.es-=t.bytes)}}}function Ce(t,i){if(!Z(t)||t===1/0||t===-1/0)return i;var e=Math.floor(t);return 0>e?i:e}var Oe=function(i,e){var r=(void 0===e?{}:e).debugEnabled,s={P(e){if(t&&(c.DEBUG||t.POSTHOG_DEBUG||r)&&!K(t.console)&&t.console){for(var s=("__rrweb_original__"in t.console[e]?t.console[e].__rrweb_original__:t.console[e]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];s(i,...o)}},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];s.P("error",...i)},critical(){for(var t=arguments.length,e=new Array(t),r=0;t>r;r++)e[r]=arguments[r];console.error(i,...e)},uninitializedWarning(t){s.error("You must initialize PostHog before calling "+t)},createLogger:(t,e)=>Oe(i+" "+t,e)};return s},Ie=Oe("[PostHog.js]"),Ae=Ie.createLogger,Fe=Ae("[ExternalScriptsLoader]"),Me=t=>{var i=null==r?void 0:r.querySelectorAll("script");if(i)for(var e=0;i.length>e;e++)if(i[e].src===t||i[e].getAttribute("src")===t)return i[e]},De=(t,i,e)=>{if(t.config.disable_external_dependency_loading)return Fe.warn(i+" was requested but loading of external scripts is disabled."),e("Loading of external scripts is disabled");var s=Me(i);if(s){if(s.__posthog_loading_callback_fired)return e();var n=s.__posthog_loading_error;return n?e(n):(s.addEventListener("load",(t=>{s.__posthog_loading_callback_fired=!0,e(void 0,t)})),void s.addEventListener("error",(t=>{s.__posthog_loading_error=t,e(t)})))}var o=()=>{if(!r)return e("document not found");if(Me(i))return De(t,i,e);var s=r.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=i,s.onload=t=>{s.__posthog_loading_callback_fired=!0,e(void 0,t)},s.onerror=t=>{s.__posthog_loading_error=t,e(t)},t.config.prepare_external_dependency_script&&(s=t.config.prepare_external_dependency_script(s)),!s)return e("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)r.head.appendChild(s);else{var n,o=r.querySelectorAll("body > script");o.length>0?null==(n=o[0].parentNode)||n.insertBefore(s,o[0]):r.body.appendChild(s)}};null!=r&&r.body?o():null==r||r.addEventListener("DOMContentLoaded",o)},Ne={},Le=(t,i)=>{var e="/static/"+i+".js?v="+t.version;if("toolbar"===i){var r=3e5;e=e+"&t="+Math.floor(Date.now()/r)*r}return t.requestRouter.endpointFor("assets",e)};v.__PosthogExtensions__=v.__PosthogExtensions__||{},v.__PosthogExtensions__.loadExternalDependency=(t,i,e)=>{if("remote-config"!==i){var r=t.config.strict_script_versioning;if(r){var s=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+i+".js"),n=Ne[s];if("fallback"===r&&n){if(Me(n))return void De(t,n,e);delete Ne[s]}De(t,s,"fallback"===r?(r,n)=>{if(r)if("string"==typeof r)e(r);else{var o,a=Le(t,i);Ne[s]=a;var l=Me(s);null==l||null==(o=l.parentNode)||o.removeChild(l),De(t,a,e)}else e(void 0,n)}:e)}else De(t,Le(t,i),e)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");De(t,o,e)}},v.__PosthogExtensions__.loadSiteApp=(t,i,e)=>{var r=t.requestRouter.endpointFor("api",i);De(t,r,e)};c.DEBUG=!1,c.LIB_VERSION="1.422.1",c.LIB_NAME="web";var Ue="$people_distinct_id",je="distinct_id",Be="$device_id",ze="$device_model",qe="__alias",He="__timers",Ve="$autocapture_disabled_server_side",We="$heatmaps_enabled_server_side",Ge="$exception_capture_enabled_server_side",Ke="$error_tracking_suppression_rules",Je="$error_tracking_capture_extension_exceptions",Ye="$web_vitals_enabled_server_side",Qe="$dead_clicks_enabled_server_side",Xe="$product_tours_enabled_server_side",Ze="$logs_capture_enabled_server_side",tr="$web_vitals_allowed_metrics",ir="$session_recording_remote_config",er="$replay_sample_rate",rr="$replay_override_sampling",sr="$replay_override_linked_flag",nr="$replay_override_url_trigger",or="$replay_override_event_trigger",ar="$sesid",lr="$session_is_sampled",hr="$enabled_feature_flags",ur="$active_feature_flags",dr="$early_access_features",vr="$feature_flag_details",cr="$feature_flag_payloads",fr="$feature_flag_request_id",pr="$minimal_flag_called_events",_r="$override_feature_flags",gr="$override_feature_flag_payloads",mr="$stored_person_properties",yr="$stored_group_properties",br="$groups",wr="$surveys",xr="$surveys_loaded_at",Er="$surveys_activated",Sr="$surveys_activated_session",kr="$surveys_activated_timestamps",Tr="ph_product_tours",$r="$flag_call_reported",Pr="$flag_call_reported_session_id",Rr="$feature_flag_errors",Cr="$feature_flag_evaluated_at",Or="$user_state",Ir="$client_session_props",Ar="$capture_rate_limit",Fr="$initial_campaign_params",Mr="$initial_referrer_info",Dr="$initial_person_info",Nr="$epp",Lr="$posthog_cookieless",Ur="$cookieless_mode",jr="$sdk_debug_extensions_init_method",Br="$sdk_debug_extensions_init_time_ms",zr="$sdk_debug_recording_script_not_loaded",qr="PostHog loadExternalDependency extension not found.",Hr="on_reject",Vr="always",Wr="anonymous",Gr="identified",Kr="identified_only",Jr="visibilitychange",Yr="beforeunload",Qr="$pageview",Xr="$pageleave",Zr="$identify",ts="$groupidentify";function is(t,i){H(t)&&t.forEach(i)}function es(t,i){if(!X(t))if(H(t))t.forEach(i);else if(et(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)z.call(t,e)&&i(t[e],e)}var rs=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];for(var s of e)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function ss(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var ns=function(t){try{return t()}catch(t){return}},os=function(t){return function(){try{for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,e)}catch(t){Ie.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ie.critical(t)}}},as=function(t){var i={};return es(t,(function(t,e){(J(t)&&t.length>0||Z(t))&&(i[e]=t)})),i};var ls=["herokuapp.com","vercel.app","netlify.app"];function hs(t){var i=null==t?void 0:t.hostname;if(!J(i))return!1;var e=i.split(".").slice(-2).join(".");for(var r of ls)if(e===r)return!1;return!0}function us(t,i,e,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===o||o})}function ds(t){return"ph_toolbar_internal"===t.name}var vs=t=>{if(r){try{for(var i=t+"=",e=r.cookie.split(";").filter((t=>t.length)),s=0;e.length>s;s++){for(var n=e[s];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(i))return decodeURIComponent(n.substring(i.length,n.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Z(t)&&isFinite(t)&&Math.floor(t)===t});class cs{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,e,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(r)||0>t||0>i||0>e||0>r||t>0xffffffffffff||i>4095||e>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|i>>>8,s[7]=i,s[8]=128|e>>>24,s[9]=e>>>16,s[10]=e>>>8,s[11]=e,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new cs(s)}toString(){for(var t="",i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new cs(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var i=0;16>i;i++){var e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}}class fs{generate(){var t=this.generateOrAbort();if(!K(t))return t;this.Fr=0;var i=this.generateOrAbort();if(K(i))throw new Error("Could not generate UUID after timestamp reset");return i}generateOrAbort(){var t=Date.now();if(t>this.Fr)this.Fr=t,this.Nr();else{if(this.Fr>=t+1e4)return;this.qr++,this.qr>4398046511103&&(this.Fr++,this.Nr())}return cs.fromFieldsV7(this.Fr,Math.trunc(this.qr/Math.pow(2,30)),this.qr&Math.pow(2,30)-1,this.jr.nextUint32())}Nr(){this.qr=1024*this.jr.nextUint32()+(1023&this.jr.nextUint32())}constructor(){this.Fr=0,this.qr=0,this.jr=new gs}}var ps,_s=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!K(t.crypto)&&crypto.getRandomValues&&(_s=t=>crypto.getRandomValues(t));class gs{nextUint32(){return this.bt.length>this.Br||(_s(this.bt),this.Br=0),this.bt[this.Br++]}constructor(){this.bt=new Uint32Array(8),this.Br=1/0}}var ms=()=>ys().toString(),ys=()=>(ps||(ps=new fs)).generate(),bs="",ws=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var xs={Hr:()=>!!r,zr(t){Ie.error("cookieStore error: "+t)},$r:vs,Vr(t){var i;try{i=JSON.parse(xs.$r(t))||{}}catch(t){}return i},Ur(t,i,e,s,n){if(!r)return!1;try{var o="",a="",l=function(t,i){if(i){var e=function(t,i){if(void 0===i&&(i=r),bs)return bs;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var e=t.split("."),s=Math.min(e.length,8),n="dmn_chk_"+ms();!bs&&s--;){var o=e.slice(s).join("."),a=n+"=1;domain=."+o+";path=/";i.cookie=a+";max-age=3",i.cookie.includes(n)&&(i.cookie=a+";max-age=0",bs=o)}return bs}(t);if(!e){var s=(t=>{var i=t.match(ws);return i?i[0]:""})(t);s!==e&&Ie.info("Warning: cookie subdomain discovery mismatch",s,e),e=s}return e?"; domain=."+e:""}return""}(r.location.hostname,s);if(e){var h=new Date;h.setTime(h.getTime()+864e5*e),o="; expires="+h.toUTCString()}n&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(i))+o+"; SameSite=Lax; path=/"+l+a;return u.length>3686.4&&Ie.warn("cookieStore warning: large cookie, len="+u.length),r.cookie=u,!0}catch(t){return!1}},Wr(t,i){if(null!=r&&r.cookie)try{xs.Ur(t,"",-1,i)}catch(t){return}}},Es=null,Ss={Hr(){if(!Q(Es))return Es;var i=!0;if(K(t))i=!1;else try{var e="__mplssupport__";Ss.Ur(e,"xyz"),'"xyz"'!==Ss.$r(e)&&(i=!1),Ss.Wr(e)}catch(t){i=!1}return i||Ie.error("localStorage unsupported; falling back to cookie store"),Es=i,i},zr(t){Ie.error("localStorage error: "+t)},$r(i){try{return null==t?void 0:t.localStorage.getItem(i)}catch(t){Ss.zr(t)}return null},Vr(t){try{return JSON.parse(Ss.$r(t))||{}}catch(t){}return null},Ur(i,e){try{return null==t||t.localStorage.setItem(i,JSON.stringify(e)),!0}catch(t){Ss.zr(t)}return!1},Wr(i){try{null==t||t.localStorage.removeItem(i)}catch(t){Ss.zr(t)}}},ks=[mr,ur,hr,vr,cr,fr,Cr,Rr,$r],Ts=[Be,je,ar,lr,Nr,Dr,Or],$s=t=>t+"_cpm",Ps=["__proto__","constructor","prototype"],Rs=t=>{if(!W(t))return{};var i={};return Object.keys(t).forEach((e=>{-1===Ps.indexOf(e)&&(i[e]=t[e])})),i},Cs=function(t,i){void 0===i&&(i=[]);var e={};return[...Ts,...i].forEach((i=>{var r=t[i];K(r)||Q(r)||""===r||(e[i]=r)})),e},Os=t=>{for(var i=5381,e=2166136261,r=0;t.length>r;r++){var s=t.charCodeAt(r);i=33*i^s,e=Math.imul(e^s,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},Is=(t,i)=>({p:i,f:Os(JSON.stringify(t))}),As=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{var e=xs.Vr($s(t)),r=(null==e?void 0:e.f)===Os(i)&&H(e.p);return{properties:r?e.p:[],isValid:r}}catch(t){return{properties:[],isValid:!1}}},Fs=(t,i)=>i+"|"+(xs.$r($s(t))||""),Ms={},Ds={Hr:()=>!0,zr(t){Ie.error("memoryStorage error: "+t)},$r:t=>Ms[t]||null,Vr:t=>Ms[t]||null,Ur:(t,i)=>(Ms[t]=i,!0),Wr(t){delete Ms[t]}},Ns=null,Ls={Hr(){if(!Q(Ns))return Ns;if(Ns=!0,K(t))Ns=!1;else try{var i="__support__";Ls.Ur(i,"xyz"),'"xyz"'!==Ls.$r(i)&&(Ns=!1),Ls.Wr(i)}catch(t){Ns=!1}return Ns},zr(t){Ie.error("sessionStorage error: ",t)},$r(i){try{return null==t?void 0:t.sessionStorage.getItem(i)}catch(t){Ls.zr(t)}return null},Vr(t){try{return JSON.parse(Ls.$r(t))||null}catch(t){}return null},Ur(i,e){try{return null==t||t.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch(t){Ls.zr(t)}return!1},Wr(i){try{null==t||t.sessionStorage.removeItem(i)}catch(t){Ls.zr(t)}}};class Us{constructor(t){this._instance=t}get zi(){return this._instance.config}get consent(){return this.ks()?0:this.Ss}isOptedOut(){return this.zi.cookieless_mode===Vr||this.isRejected()||-1===this.consent&&this.zi.cookieless_mode===Hr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.zi.opt_out_capturing_by_default}optInOut(t){this.xs.Ur(this.Cs,t?1:0,this.zi.cookie_expiration,this.zi.cross_subdomain_cookie,this.zi.secure_cookie)}reset(){this.xs.Wr(this.Cs,this.zi.cross_subdomain_cookie)}get Cs(){var t=this._instance.config,i=t.token,e=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(e?e+i:"__ph_opt_in_out_"+i)}get Ss(){var t=this.xs.$r(this.Cs);return dt(t)?1:N(vt,t)?0:-1}get xs(){var t=this.zi.opt_out_capturing_persistence_type,i="localStorage"===t?Ss:xs;if(!this.Ts||this.Ts!==i){this.Ts=i;var e="localStorage"===t?xs:Ss;e.$r(this.Cs)&&(this.Ts.$r(this.Cs)||this.optInOut(dt(e.$r(this.Cs))),e.Wr(this.Cs,this.zi.cross_subdomain_cookie))}return this.Ts}ks(){return!!this.zi.respect_dnt&&[null==e?void 0:e.doNotTrack,null==e?void 0:e.msDoNotTrack,v.doNotTrack].some((t=>dt(t)))}}function js(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!V(r))return i;try{var s=r(i);return J(s)&&s?s:i}catch(t){return Ie.error("Error in get_current_url, falling back to window.location.href",t),i}}var Bs="__POSTHOG_TOOLBAR__",zs=1,qs=3,Hs=11;function Vs(t){return t instanceof Element&&(t.id===Bs||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Ws(t){return!!t&&t.nodeType===zs}function Gs(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Ks(t){return!!t&&t.nodeType===qs}function Js(t){return!!t&&t.nodeType===Hs&&Ws(t.host)}var Ys=1e3;function Qs(t){return t?L(t).split(/\s+/):[]}function Xs(i,e){var r=function(i){var e,r=null==t||null==(e=t.location)?void 0:e.href;return K(r)?void 0:js(i,r)}(e);return!!(r&&i&&i.some((t=>r.match(t))))}function Zs(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return Qs(i)}function tn(t){return X(t)?null:L(t).split(/(\s+)/).filter((t=>kn(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function en(t){var i="";return _n(t)&&!gn(t)&&t.childNodes&&t.childNodes.length&&es(t.childNodes,(function(t){var e;Ks(t)&&t.textContent&&(i+=null!==(e=tn(t.textContent))&&void 0!==e?e:"")})),L(i)}function rn(t){var i;return K(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var sn=["a","button","form","input","select","textarea","label"];function nn(t,i){if(K(i))return!0;var e,r=function(t){if(i.some((i=>function(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}(t,i))))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function on(t){var i=t.parentNode;return!(!i||!Ws(i))&&i}var an=[".ph-no-autocapture","[data-ph-no-autocapture]"],ln=["next","previous","prev",">","<"],hn=[...ln,"+","-","−","–"],un=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,dn=[".ph-no-rageclick",".ph-no-capture"],vn=["","text","search","email","password","url","tel","number"];function cn(i,e){if(!t||fn(i))return!1;var r,s,n,o,a;if(it(e)?(r=!!e&&dn,s=void 0,n=!1):(r=null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:dn,s=null==e?void 0:e.content_ignorelist,n=null!==(a=null==e?void 0:e.ignore_text_selection)&&void 0!==a&&a),!1===r)return!1;if(n&&function(t){return!(!t||!Ws(t))&&(!!Gs(t,"textarea")||(Gs(t,"input")?N(vn,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var i=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===i||""===i}(t)))}(i))return!1;var l=pn(i,!1).targetElementList;return!function(t,i){if(!1===t||K(t))return!1;var e;if(!0===t)e=ln;else{if(!H(t))return!1;if(t.length>10)return Ie.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map((t=>t.toLowerCase()))}return i.some((t=>{var i=t.safeText,r=t.ariaLabel;return e.some((t=>un(i,t)||un(r,t)))}))}(s,l.map((t=>{var i;return{safeText:en(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!nn(l,r)}var fn=t=>!t||Gs(t,"html")||!Ws(t),pn=(i,e)=>{if(!t||fn(i))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,s=[i],n=i;n.parentNode&&!Gs(n,"body");)if(Js(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=on(n);if(!o)break;if(e||sn.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var a=t.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(r=!0)}catch(t){}s.push(o),n=o}return{parentIsUsefulElement:r,targetElementList:s}};function _n(t){for(var i=new Set,e=0,r=t;r.parentNode&&!Gs(r,"body");r=r.parentNode){if(e++>=Ys||i.has(r))return!1;i.add(r);var s=Zs(r);if(N(s,"ph-sensitive")||N(s,"ph-no-capture"))return!1}if(N(Zs(t),"ph-include"))return!0;var n=t.type||"";if(J(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!J(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function gn(t){return!!(Gs(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Gs(t,"select")||Gs(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var mn=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}))$"),yn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,bn=[16,15,14,13],wn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),xn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),En=/[0-9A-Za-z_]/;function Sn(t){for(var i=0,e=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;e&&(s*=2)>9&&(s-=9),i+=s,e=!e}return i%10==0}function kn(t,i){if(void 0===i&&(i=!0),X(t))return!1;if(J(t)){t=L(t);var e=i?mn.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(yn.lastIndex=0;i=yn.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of bn){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(mn.test(a)&&Sn(a))return!0}}}return!1}(t);if(e)return!1;var r=i?wn.test(t):function(t){var i;for(xn.lastIndex=0;i=xn.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&En.test(e)&&En.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function Tn(t){var i=en(t);return kn(i=(i+" "+$n(t)).trim())?i:""}function $n(t){var i="";return t&&t.childNodes&&t.childNodes.length&&es(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=en(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+$n(t)).trim())}catch(t){Ie.error("[AutoCapture]",t)}})),i}function Pn(t){return t.replace(/"|\\"/g,'\\"')}function Rn(t){var i=t.attr__class;if(i)return H(i)?i:Qs(i)}var Cn=Ae("[Dead Clicks]"),On=()=>!0,In=t=>{var i,e=!(null==(i=t.instance.persistence)||!i.get_property(Qe)),r=t.instance.config.capture_dead_clicks;return it(r)?r:!!W(r)||e};class An{get lazyLoadedDeadClicksAutocapture(){return this.Ms}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[Qe]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Es((()=>{this.Is()})):this.stop()}Es(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?Cn.error("failed to load script",i):t()}))}Is(){var t;if(r){if(!this.Ms&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=W(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Ms=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ms.start(r),Cn.info("starting...")}}else Cn.error("`document` not found. Cannot start.")}stop(){this.Ms&&(this.Ms.stop(),this.Ms=void 0,Cn.info("stopping..."))}}var Fn=Ae("[SegmentIntegration]");var Mn="posthog-js";function Dn(t,i){var e=void 0===i?{}:i,r=e.organization,s=e.projectId,n=e.prefix,o=e.severityAllowList,a=void 0===o?["error"]:o,l=e.sendExceptionsToPostHog,h=void 0===l||l;return i=>{var e,o,l,u,d;if("*"!==a&&!a.includes(i.level)||!t.__loaded)return i;i.tags||(i.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());i.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(i.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var c,f=(null==(e=i.exception)?void 0:e.values)||[],p=f.map((t=>_({},t,{stacktrace:t.stacktrace?_({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>_({},t,{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null==(o=f[0])?void 0:o.value)||i.message,$exception_type:null==(l=f[0])?void 0:l.type,$exception_level:i.level,$exception_list:p,$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:(null==(u=f[0])?void 0:u.value)||i.message,$sentry_exception_type:null==(d=f[0])?void 0:d.type,$sentry_tags:i.tags};return r&&s&&(g.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+i.event_id),h&&(null==(c=t.exceptions)||c.sendExceptionEvent(g)),i}}class Nn{constructor(t,i,e,r,s,n){this.name=Mn,this.setupOnce=function(o){o(Dn(t,{organization:i,projectId:e,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Ln{constructor(t){this.Rs=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(Ie.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Ps=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.As()}As(){var t;this.Fs=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.Rs)}destroy(){var t;null==(t=this.Fs)||t.call(this),this.Fs=void 0}doPageView(i,e){var r,s=this.Os(i,e);return this.Ps={pathname:null!==(r=null==t?void 0:t.location.pathname)&&void 0!==r?r:"",pageViewId:e,timestamp:i},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var i;return this.Os(t,null==(i=this.Ps)?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.Ps)?void 0:t.pageViewId}}Os(t,i){var e=this.Ps;if(!e)return{$pageview_id:i};var r={$pageview_id:i,$prev_pageview_id:e.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,h=s.lastContentY,u=s.maxContentY;if(!(K(n)||K(o)||K(a)||K(l)||K(h)||K(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),h=Math.ceil(h),u=Math.ceil(u);var d=n>1?ct(o/n,0,1,Ie):1,v=n>1?ct(a/n,0,1,Ie):1,c=l>1?ct(h/l,0,1,Ie):1,f=l>1?ct(u/l,0,1,Ie):1;r=rs(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:h,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:f})}}return e.pathname&&(r.$prev_pageview_pathname=e.pathname),e.timestamp&&(r.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),r}}var Un=["flags","surveys"],jn={[Ue]:{exposure:"hidden"},[qe]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[He]:{exposure:"hidden"},[Ve]:{exposure:"event"},[We]:{exposure:"hidden"},[Ze]:{exposure:"hidden"},[Ge]:{exposure:"event"},[Ke]:{exposure:"hidden"},[Je]:{exposure:"event"},[Ye]:{exposure:"event"},[Qe]:{exposure:"event"},[Xe]:{exposure:"hidden"},[tr]:{exposure:"event"},[ir]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[ar]:{exposure:"hidden"},[lr]:{exposure:"event"},[er]:{exposure:"event",shouldSkipFromEventProperties:t=>Q(t)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[hr]:{exposure:"hidden",storageGroup:"flags"},[ur]:{exposure:"hidden",storageGroup:"flags"},[dr]:{exposure:"hidden"},[vr]:{exposure:"hidden",storageGroup:"flags"},[cr]:{exposure:"hidden",storageGroup:"flags"},[fr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[pr]:{exposure:"hidden",storageGroup:"flags"},[_r]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[mr]:{exposure:"hidden"},[yr]:{exposure:"hidden"},[wr]:{exposure:"hidden",storageGroup:"surveys"},[xr]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Er]:{exposure:"event"},[Sr]:{exposure:"hidden"},[kr]:{exposure:"hidden"},[Tr]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[$r]:{exposure:"hidden"},[Pr]:{exposure:"hidden"},[br]:{exposure:"event"},[Rr]:{exposure:"hidden"},[Cr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Or]:{exposure:"hidden"},[Ir]:{exposure:"hidden"},[Ar]:{exposure:"hidden"},[Fr]:{exposure:"hidden"},[Mr]:{exposure:"hidden"},[Dr]:{exposure:"hidden"},[Nr]:{exposure:"hidden"},[rr]:{exposure:"event"},[sr]:{exposure:"event"},[nr]:{exposure:"event"},[or]:{exposure:"event"},[jr]:{exposure:"event"},[Br]:{exposure:"event"},[zr]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_pending_trigger_conditions:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},Bn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],zn=t=>{var i=jn[t];if(i)return i;for(var e of Bn){var r=e[1];if(0===t.indexOf(e[0]))return r}},qn=(t,i)=>{try{return JSON.stringify(t,((t,i)=>"bigint"==typeof i?i.toString():i),i)}catch(i){return j(t)}},Hn=t=>{var i=null==r?void 0:r.createElement("a");return K(i)?null:(i.href=t,i)},Vn=function(t,i){for(var e,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===i){e=n;break}}if(!H(e)||2>e.length)return"";var o=e[1];try{o=decodeURIComponent(o)}catch(t){Ie.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Wn=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),h=[],u=0;l.length>u;u++){var d=l[u].split("=");H(d)&&(i.includes(d[0])?h.push(d[0]+"="+e):h.push(l[u]))}var v=a;return null!=o&&(v+="?"+h.join("&")),null!=s&&(v+="#"+s),v},Gn=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Kn=(t,i)=>t>=i&&u(),Jn=(t,i,e,r)=>{if(0===t){if(u()){var s=i+1;return s===e&&r(),s}return i}return 0},Yn="https?://(.*)",Qn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Xn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qn],Zn="<masked>",to=["li_fat_id"];function io(t,i,e){if(!r)return{};var s,n=i?[...Qn,...e||[]]:[],o=eo(Wn(r.URL,n,Zn),t),a=(s={},es(to,(function(t){var i=vs(t);s[t]=i||null})),s);return rs(a,o)}function eo(t,i){var e=Xn.concat(i||[]),r={};return es(e,(function(i){var e=Vn(t,i);r[i]=e||null})),r}function ro(t){var i=function(t){return t?0===t.search(Yn+"google.([^/?]*)")?"google":0===t.search(Yn+"bing.com")?"bing":0===t.search(Yn+"yahoo.com")?"yahoo":0===t.search(Yn+"duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",s={};if(!Q(i)){s.$search_engine=i;var n=r?Vn(r.referrer,e):"";n.length&&(s.ph_keyword=n)}return s}function so(){return navigator.language||navigator.userLanguage}var no="$direct";function oo(){return(null==r?void 0:r.referrer)||no}function ao(t,i,e){void 0===e&&(e=!1);var r=t?[...Qn,...i||[]]:[],n=e?xi(null==s?void 0:s.href):null==s?void 0:s.href,o=null==n?void 0:n.substring(0,1e3);return{r:oo().substring(0,1e3),u:o?Wn(o,r,Zn):void 0}}function lo(t,i){var e;void 0===i&&(i=!1);var r=t.r,s=t.u,n=i?xi(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==no?no:null==(e=Hn(r))?void 0:e.host};if(n){o.$current_url=n;var a=Hn(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=eo(n);rs(o,l)}if(r){var h=ro(r);rs(o,h)}return o}function ho(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function uo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var vo={flags:Cr,surveys:xr},co=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],fo=t=>t+"_cookie_identity_change_pending",po="main",_o=(t,i)=>{es(t,((e,r)=>{var s=zn(r);s&&"event"!==s.exposure||{}.hasOwnProperty.call(i,r)||delete t[r]}))};class go{constructor(i,e,r){if(void 0===r&&(r=!0),this.Ls={},this.Ds=!1,this.$s=!1,this.Ns=!1,this.qs=!1,this.zi=i,this.js=r,this.props={},this.Bs=void 0,this.Hs=(t=>{var i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(i),this.xs=this.Us(i),this.$s=this.zs(i),this.load(),i.debug&&Ie.info("Persistence loaded",i.persistence,_({},this.props)),this.update_config(i,i,e),this.save(),t){var s=()=>this.flush();us(t,"beforeunload",s,{capture:!1}),us(t,"pagehide",s,{capture:!1})}}Ws(){var t,i=null==(t=this.zi)?void 0:t.persistence_save_debounce_ms;return Z(i)&&i>0?i:0}Vs(t){if(this.zi.cookieWinsOnConflict&&"localstorage+cookie"===this.zi.persistence.toLowerCase())if(t)try{var i=Cs(t,this.zi.cookie_persisted_properties||[]),e=Is(i,this.zi.cookie_persisted_properties||[]),r=JSON.stringify(i)+"|"+JSON.stringify(e),s=xs.$r(this.Hs)||void 0;s&&Fs(this.Hs,s)===r&&(this.Gs=r,this.Zs=s)}catch(t){}else try{var n=xs.$r(this.Hs)||void 0;this.Gs=n?Fs(this.Hs,n):void 0,this.Zs=n}catch(t){}}syncCookieProperties(){return this.Qs(this.zi)}Qs(t,i){if(void 0===i&&(i=!1),this.Js&&!i||this.qs||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;var e;try{e=xs.$r(this.Hs)||void 0}catch(t){}if(!e||e===this.Zs)return!1;var r,s=Fs(this.Hs,e);try{r=Rs(JSON.parse(e))}catch(t){return!1}if((xs.$r(this.Hs)||void 0)!==e)return!1;this.Gs=s,this.Zs=e;var n=As(this.Hs,e),o=[...Ts,...n.properties],a={};if(Object.keys(r).forEach((t=>{var i=r[t];(K(i)||Q(i)||""===i||t===Or&&i!==Wr&&i!==Gr)&&(a[t]=!0,delete r[t])})),G(r))return!1;var l=je in r||r[Or]===Wr||r[Or]===Gr,h=this.props[je],u=this.props[Or],d=rs({},this.props);[...Ts,...t.cookie_persisted_properties||[]].forEach((t=>{if(-1!==o.indexOf(t)&&!(t in r)&&!a[t]&&(l||t!==je&&t!==Or)){var i=d[t];!n.isValid&&-1!==Ts.indexOf(t)&&(!1===i||0===i)||delete d[t]}})),this.props=rs(d,r),!l||Or in r||Or in this.props||this.Ks(Or,Wr);var v=this.props[je],c=this.props[Or];return!l||v===h&&c===u||(this.Ns=!0,Ls.Ur(fo(this.Hs),!0),this.Ys(mr),this.Ys(ur),this.Ys(hr),this.Ys(vr),this.Ys(cr),this.Ys(fr),this.Ys(Cr),this.Ys(Rr),this.Ys($r),c===Wr&&(u===Gr||r[Or]===Wr||!K(h)&&v!==h)&&(_o(this.props,r),this.Ys(yr)),c===Gr?this.props.$user_id=v:delete this.props.$user_id,this.Ys(qe)),!0}consumeCookieIdentityChange(){var t=fo(this.Hs),i=this.Ns||!!Ls.$r(t);return this.Ns=!1,i&&Ls.Wr(t),i}Xs(t){return void 0===t&&(t=!1),!(this.qs||this.Js&&!t||!this.zi.cookieWinsOnConflict||"localstorage+cookie"!==this.zi.persistence.toLowerCase()||(this.qs=!0,0))}ta(){this.qs&&(K(this.ea)||(clearTimeout(this.ea),this.ea=void 0),delete this.Ls[po],this.ia(!0))}ra(t){if(void 0===t&&(t=!0),this.qs)try{t?this.ta():K(this.ea)||(clearTimeout(this.ea),this.ea=void 0)}finally{this.qs=!1}}isDisabled(){return!!this.Js}Us(i){-1===co.indexOf(i.persistence.toLowerCase())&&(Ie.critical("Unknown persistence type "+i.persistence+"; falling back to localStorage+cookie"),i.persistence="localStorage+cookie");var e,r=function(i,e){void 0===i&&(i=[]),void 0===e&&(e=!1);var r=[...Ts,...i];return _({},Ss,{Vr(t){try{var i,s={};try{i=xs.$r(t)||void 0,s=i?Rs(JSON.parse(i)):{}}catch(t){}var n,o=JSON.parse(Ss.$r(t)||"{}");if(e){var a=As(t,i),l=[...Ts,...a.properties],h={};Object.keys(s).forEach((t=>{var i=s[t];Q(i)||""===i||t===Or&&i!==Wr&&i!==Gr||(h[t]=i)}));var u=je in h||h[Or]===Wr||h[Or]===Gr;if(Object.keys(h).length>0){var d,v=o[je],c=null!==(d=o[Or])&&void 0!==d?d:Wr;r.forEach((t=>{if(-1!==l.indexOf(t)&&!(t in s)&&(u||t!==je&&t!==Or)){var i=o[t];!a.isValid&&-1!==Ts.indexOf(t)&&(!1===i||0===i)||delete o[t]}})),!u||Or in s||Or in o||(o[Or]=Wr),!u||(je in h?h[je]:o[je])===v&&(Or in h?h[Or]:o[Or])===c||(ks.forEach((t=>delete o[t])),h[Or]===Gr&&je in h?o.$user_id=h[je]:delete o.$user_id,h[Or]!==Gr&&(delete o[br],delete o[yr]),delete o.__alias)}n=rs(o,h)}else n=rs(s,o);return Ss.Ur(t,n),n}catch(t){}return null},Ur(t,r,s,n,o,a){var l=Ss.Ur(t,r,void 0,void 0,a);try{var h=Cs(r,i);if(Object.keys(h).length){if(e){var u=$s(t),d=Is(h,i);if(xs.Ur(u,d,s,n,o,a),xs.$r(u)!==JSON.stringify(d)){xs.Wr(u,n);var v=Cs(r);return xs.Ur(t,v,s,n,o,a),l}}xs.Ur(t,h,s,n,o,a)}}catch(t){Ss.zr(t)}return l},Wr(i,e){try{null==t||t.localStorage.removeItem(i),xs.Wr(i,e),xs.Wr($s(i),e)}catch(t){Ss.zr(t)}}})}(i.cookie_persisted_properties||[],i.cookieWinsOnConflict),s=!1,n=i.persistence.toLowerCase();return"localstorage"===n&&Ss.Hr()?(e=Ss,s=!0):"localstorage+cookie"===n&&r.Hr()?(e=r,s=!0):"sessionstorage"===n&&Ls.Hr()?e=Ls:"memory"===n?e=Ds:"cookie"===n?e=xs:r.Hr()?(e=r,s=!0):e=xs,this.Ds=s,e}na(t){return this.Hs+"__"+t}zs(t){return this.Ds&&!!t.split_storage}properties(){var t={};return es(this.props,((i,e)=>{var r=zn(e);if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(i))return;t[e]=i}})),t}load(t){if(void 0===t&&(t=!1),!this.Js||t){var i=this.zi.cookieWinsOnConflict&&"localstorage+cookie"===this.zi.persistence.toLowerCase(),e=i?Ss.Vr(this.Hs):null,r={};if(i)try{es(r=Rs(xs.Vr(this.Hs)),((t,i)=>{(K(t)||Q(t)||""===t)&&delete r[i]}))}catch(t){}var s=this.xs.Vr(this.Hs);if(s&&(this.props=rs({},s)),this.$s&&this.sa(),i&&s){var n,o,a=null==e?void 0:e[je],l=null!==(n=null==e?void 0:e[Or])&&void 0!==n?n:Wr,h=s[je],u=null!==(o=s[Or])&&void 0!==o?o:Wr;if(h!==a||u!==l){this.Ns=!0,Ls.Ur(fo(this.Hs),!0);var d=rs({},this.props);ks.forEach((t=>delete d[t])),u===Wr&&(l===Gr||r[Or]===Wr||!K(a)&&h!==a)&&(_o(d,r),delete d[yr]),this.props=d;var v=new Set;ks.forEach((t=>{var i,e=null==(i=zn(t))?void 0:i.storageGroup;e&&v.add(e)})),v.forEach((t=>{var i={};es(this.props,((e,r)=>{var s;(null==(s=zn(r))?void 0:s.storageGroup)===t&&(i[r]=e)})),G(i)?(Ss.Wr(this.na(t)),this.Ls[t]={}):Ss.Ur(this.na(t),i)&&(this.Ls[t]={persisted:!0,fingerprint:this.aa(i,t)})}))}}Ls.$r(fo(this.Hs))&&(this.Ns=!0)}}sa(){for(var t of Un){var i=Ss.Vr(this.na(t));if(i&&!G(i)){var e=this.oa(t);e.persisted=!0,this.la(t)||(e.fingerprint=this.aa(i,t)),this.ua(t,i)||rs(this.props,i)}}}la(t){return Object.keys(this.props).some((i=>{var e;return(null==(e=zn(i))?void 0:e.storageGroup)===t}))}ua(t,i){var e=vo[t];if(!e)return!1;var r=i[e],s=this.props[e];return Z(r)&&Z(s)&&s>r}refreshKey(t){var i;if(!this.Js){var e=this.$s?null==(i=zn(t))?void 0:i.storageGroup:void 0,r=e?Ss.Vr(this.na(e)):this.xs.Vr(this.Hs);if(r&&t in r)this.Ks(t,r[t]);else{if(e){var s=this.xs.Vr(this.Hs);if(s&&t in s)return void this.Ks(t,s[t])}this.Ys(t)}}}save(){if(!this.Js){var t=this.Ws();t>0?K(this.ea)&&(this.ea=setTimeout((()=>{this.ea=void 0,this.ia()}),t)):this.ia()}}flush(){K(this.ea)||(clearTimeout(this.ea),this.ea=void 0,this.ia())}ia(t){void 0===t&&(t=!1),this.Js||this.qs&&!t||(t||this.syncCookieProperties(),this.$s?this.ha():this.da(this.xs,this.Hs,this.props,po)&&this.Vs(this.props))}ha(){var t=this.va(),i=t.main,e=t.groups;for(var r of(this.da(this.xs,this.Hs,i,po)&&this.Vs(i),Un)){var s,n=e[r];(!G(n)||null!=(s=this.Ls[r])&&s.persisted)&&this.da(Ss,this.na(r),n,r)}}va(){var t={},i={flags:{},surveys:{}};return es(this.props,((e,r)=>{var s,n=null==(s=zn(r))?void 0:s.storageGroup;n?i[n][r]=e:t[r]=e})),{main:t,groups:i}}aa(t,i){if(i===po)return JSON.stringify(t)+"|"+this.ca+"|"+this.fa+"|"+this.pa;var e={};return es(t,((t,i)=>{var r;e[i]=null!=(r=zn(i))&&r.volatile?"__volatile__":t})),JSON.stringify(e)}da(t,i,e,r){var s,n=this.oa(r);if(r!==po&&!n.dirty&&!K(n.fingerprint))return!1;try{if((s=this.aa(e,r))===n.fingerprint)return n.dirty=!1,!1}catch(t){s=void 0}return t.Ur(i,e,this.ca,this.fa,this.pa,this.zi.debug)?(n.dirty=!1,r!==po&&(n.persisted=!0),K(s)||(n.fingerprint=s),!0):(this.zi.debug&&Ie.warn('failed to persist storage entry "'+i+'"; will retry on next save'),!1)}remove(t){var i=(void 0===t?{}:t).keepGroupEntries,e=void 0!==i&&i;if(K(this.ea)||(clearTimeout(this.ea),this.ea=void 0),this.xs.Wr(this.Hs,!1),this.xs.Wr(this.Hs,!0),!e&&this.js)for(var r of Un)Ss.Wr(this.na(r));e?delete this.Ls[po]:this.Ls={},this.Gs=void 0,this.Zs=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(W(t)){this.syncCookieProperties(),K(i)&&(i="None"),this.ca=K(e)?this.ga:e;var r=!1;if(es(t,((t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.Ks(e,t),r=!0)})),r)return this.save(),!0}return!1}register(t,i){if(W(t)){this.syncCookieProperties(),this.ca=K(i)?this.ga:i;var e=!1;if(es(t,((i,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==i||W(i)||H(i))&&(this.Ks(r,i),e=!0)})),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var i="string"==typeof t?[t]:t,e=!1;for(var r of i)r in this.props&&(this.Ys(r),e=!0);e&&this.save()}update_campaign_params(){var t=null==r?void 0:r.URL;if(t!==this.Bs){var i=io(this.zi.custom_campaign_params,this.zi.mask_personal_data_properties,this.zi.custom_personal_data_properties);G(as(i))||this.register(i),this.Bs=t}}update_search_keyword(){var t;this.register((t=null==r?void 0:r.referrer)?ro(t):{})}update_referrer_info(){var t;this.register_once({$referrer:oo(),$referring_domain:null!=r&&r.referrer&&(null==(t=Hn(r.referrer))?void 0:t.host)||no},void 0)}set_initial_person_info(){this.props[Fr]||this.props[Mr]||this.register_once({[Dr]:ao(this.zi.mask_personal_data_properties,this.zi.custom_personal_data_properties,this.zi.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};es([Mr,Fr],(i=>{var e=this.props[i];e&&es(e,(function(i,e){t["$initial_"+U(e)]=i}))}));var i=this.props[Dr];if(i){var e=function(t,i){void 0===i&&(i=!1);var e=lo(t,i),r={};return es(e,(function(t,i){r["$initial_"+U(i)]=t})),r}(i,this.zi.disable_capture_url_hashes);rs(t,e)}return t}safe_merge(t){return es(this.props,(function(i,e){e in t||(t[e]=i)})),t}update_config(t,i,e){var r=t.persistence!==i.persistence,s=!((t,i)=>{if(t.length!==i.length)return!1;var e=[...t].sort(),r=[...i].sort();return e.every(((t,i)=>t===r[i]))})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),n=r||s,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,a=t.disable_persistence||!!e,l=!!this.Js&&!a;a||this.Qs(i,l),this.zi=t,!a&&(r||s||o)&&(this.Gs=void 0,this.Zs=void 0,this.Qs(_({},t,{cookie_persisted_properties:i.cookie_persisted_properties}),l));var h=n||o?this.Us(t):this.xs,u=this.zs(t),d=n||u!==this.$s,v=!a&&(d||t.cross_subdomain_cookie!==this.fa||t.secure_cookie!==this.pa)&&this.Xs(l);try{if(this.ga=this.ca=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){var c=this.props;this.clear(),this.xs=h,this.$s=u,this.props=c,this.save()}else o&&(this.xs=h,a||(delete this.Ls[po],this.ia()))}finally{v&&this.ra()}}set_disabled(t){this.Js=t,this.Js?this.remove():this.save()}set_cross_subdomain(t){t!==this.fa&&(this.fa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.pa&&(this.pa=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){var e=this.props[He]||{};e[t]=i,this.Ks(He,e),this.save()}remove_event_timer(t){var i=this.props[He]||{},e=i[t];return K(e)||(delete i[t],this.Ks(He,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.Ks(t,i),this.save()}Ks(t,i){var e;this.props[t]=i,null!=(e=zn(t))&&e.volatile||this.ma(t)}Ys(t){delete this.props[t],this.ma(t)}ma(t){var i,e=null==(i=zn(t))?void 0:i.storageGroup;e&&(this.oa(e).dirty=!0)}oa(t){return this.Ls[t]||(this.Ls[t]={})}}function mo(t){var i=!0;return{dispose(){if(i){i=!1;var e=t();e&&V(e.then)&&e.then(void 0,(()=>{}))}}}}var yo={GZipJS:"gzip-js",Base64:"base64"},bo={Activation:"events",Cancellation:"cancelEvents"},wo={Button:"button",Tab:"tab",Selector:"selector"},xo={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"},Eo={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},So={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ko={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},To={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},$o={Once:"once",Recurring:"recurring",Always:"always"},Po={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Ro={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"},Co={Popover:"popover",Inline:"inline"},Oo={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},Io={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"},Ao={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"},Fo=Ae("[RateLimiter]");class Mo{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((t=>{Fo.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4}))}catch(t){return void Fo.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var i,e,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(i=null==(e=this.instance.persistence)?void 0:e.get_property(Ar))&&void 0!==i?i:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var h=(Z(a.dropped)?a.dropped:0)+1;a.dropped=h,!this.lastEventRateLimited&&this.ya(h)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(Ar,a),{isRateLimited:l,remainingTokens:a.tokens}}ba(t){var i=this.instance.config.property_denylist;return!H(i)||!i.includes(t)}_a(){var t;if(this.ba("$current_url")&&this.ba("$pathname")&&null!=s&&s.pathname)return""+(null!==(t=s.origin)&&void 0!==t?t:"")+s.pathname}ya(t){var i,e,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this._a(),o=this.ba("$session_id")?null==(i=(e=this.instance).get_session_id)?void 0:i.call(e):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}}var Do=Ae("[RemoteConfig]");class No{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}wa(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}ka(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Do.info("Using preloaded remote config",this.remoteConfig),void this.Sa(this.remoteConfig);if(this._instance.xa())return void Do.warn("Remote config is disabled. Falling back to local config.");this.wa((t=>{if(!t)return Do.info("No config found after loading remote JS config. Falling back to JSON."),void this.ka((t=>{this.Sa(t.json,t)}));this.Sa(t)}))}catch(t){Do.error("Error loading remote config",t),this.Sa()}}Sa(t,i){!t&&i&&(0===i.statusCode?i.error||Do.warn("Failed to fetch remote config from PostHog."):Do.error("Failed to fetch remote config from PostHog."));try{this._instance.Sa(t?{ok:!0,config:t}:{ok:!1})}catch(t){Do.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded()}catch(t){Do.error("Error loading feature flags",t)}}}var Lo=["fatal","error","warning","log","info","debug"],Uo=Uint8Array,jo=Uint16Array,Bo=Uint32Array,zo=new Uo([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]),qo=new Uo([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]),Ho=new Uo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vo=function(t,i){for(var e=new jo(31),r=0;31>r;++r)e[r]=i+=1<<t[r-1];var s=new Bo(e[30]);for(r=1;30>r;++r)for(var n=e[r];e[r+1]>n;++n)s[n]=n-e[r]<<5|r;return[e,s]},Wo=Vo(zo,2),Go=Wo[1];Wo[0][28]=258,Go[258]=28;for(var Ko=Vo(qo,0)[1],Jo=new jo(32768),Yo=0;32768>Yo;++Yo){var Qo=(43690&Yo)>>>1|(21845&Yo)<<1;Jo[Yo]=((65280&(Qo=(61680&(Qo=(52428&Qo)>>>2|(13107&Qo)<<2))>>>4|(3855&Qo)<<4))>>>8|(255&Qo)<<8)>>>1}var Xo=function(t,i,e){for(var r=t.length,s=0,n=new jo(i);r>s;++s)++n[t[s]-1];var o,a=new jo(i);for(s=0;i>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(e){o=new jo(1<<i);var l=15-i;for(s=0;r>s;++s)if(t[s])for(var h=s<<4|t[s],u=i-t[s],d=a[t[s]-1]++<<u,v=d|(1<<u)-1;v>=d;++d)o[Jo[d]>>>l]=h}else for(o=new jo(r),s=0;r>s;++s)o[s]=Jo[a[t[s]-1]++]>>>15-t[s];return o},Zo=new Uo(288);for(Yo=0;144>Yo;++Yo)Zo[Yo]=8;for(Yo=144;256>Yo;++Yo)Zo[Yo]=9;for(Yo=256;280>Yo;++Yo)Zo[Yo]=7;for(Yo=280;288>Yo;++Yo)Zo[Yo]=8;var ta=new Uo(32);for(Yo=0;32>Yo;++Yo)ta[Yo]=5;var ia=Xo(Zo,9,0),ea=Xo(ta,5,0),ra=function(t){return(t/8>>0)+(7&t&&1)},sa=function(t,i,e){(null==e||e>t.length)&&(e=t.length);var r=new(t instanceof jo?jo:t instanceof Bo?Bo:Uo)(e-i);return r.set(t.subarray(i,e)),r},na=function(t,i,e){var r=i/8>>0;t[r]|=e<<=7&i,t[r+1]|=e>>>8},oa=function(t,i,e){var r=i/8>>0;t[r]|=e<<=7&i,t[r+1]|=e>>>8,t[r+2]|=e>>>16},aa=function(t,i){for(var e=[],r=0;t.length>r;++r)t[r]&&e.push({s:r,f:t[r]});var s=e.length,n=e.slice();if(!s)return[new Uo(0),0];if(1==s){var o=new Uo(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort((function(t,i){return t.f-i.f})),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,u=1,d=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=e[e[d].f>e[h].f?h++:d++],l=e[h!=u&&e[d].f>e[h].f?h++:d++],e[u++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new jo(v+1),f=la(e[u-1],c,0);if(f>i){r=0;var p=0,_=f-i,g=1<<_;for(n.sort((function(t,i){return c[i.s]-c[t.s]||t.f-i.f}));s>r;++r){var m=n[r].s;if(i>=c[m])break;p+=g-(1<<f-c[m]),c[m]=i}for(p>>>=_;p>0;){var y=n[r].s;i>c[y]?p-=1<<i-c[y]++-1:++r}for(;r>=0&&p;--r){var b=n[r].s;c[b]==i&&(--c[b],++p)}f=i}return[new Uo(c),f]},la=function(t,i,e){return-1==t.s?Math.max(la(t.l,i,e+1),la(t.r,i,e+1)):i[t.s]=e},ha=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new jo(++i),r=0,s=t[0],n=1,o=function(t){e[r++]=t},a=1;i>=a;++a)if(t[a]==s&&a!=i)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[e.subarray(0,r),i]},ua=function(t,i){for(var e=0,r=0;i.length>r;++r)e+=t[r]*i[r];return e},da=function(t,i,e){var r=e.length,s=ra(i+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=e[n];return 8*(s+4+r)},va=function(t,i,e,r,s,n,o,a,l,h,u){na(i,u++,e),++s[256];for(var d=aa(s,15),v=d[0],c=d[1],f=aa(n,15),p=f[0],_=f[1],g=ha(v),m=g[0],y=g[1],b=ha(p),w=b[0],x=b[1],E=new jo(19),S=0;m.length>S;++S)E[31&m[S]]++;for(S=0;w.length>S;++S)E[31&w[S]]++;for(var k=aa(E,7),T=k[0],P=k[1],R=19;R>4&&!T[Ho[R-1]];--R);var C,O,I,A,F=h+5<<3,M=ua(s,Zo)+ua(n,ta)+o,D=ua(s,v)+ua(n,p)+o+14+3*R+ua(E,T)+(2*E[16]+3*E[17]+7*E[18]);if(M>=F&&D>=F)return da(i,u,t.subarray(l,l+h));if(na(i,u,1+(M>D)),u+=2,M>D){C=Xo(v,c,0),O=v,I=Xo(p,_,0),A=p;var N=Xo(T,P,0);for(na(i,u,y-257),na(i,u+5,x-1),na(i,u+10,R-4),u+=14,S=0;R>S;++S)na(i,u+3*S,T[Ho[S]]);u+=3*R;for(var L=[m,w],U=0;2>U;++U){var j=L[U];for(S=0;j.length>S;++S)na(i,u,N[B=31&j[S]]),u+=T[B],B>15&&(na(i,u,j[S]>>>5&127),u+=j[S]>>>12)}}else C=ia,O=Zo,I=ea,A=ta;for(S=0;a>S;++S)if(r[S]>255){var B;oa(i,u,C[257+(B=r[S]>>>18&31)]),u+=O[B+257],B>7&&(na(i,u,r[S]>>>23&31),u+=zo[B]);var z=31&r[S];oa(i,u,I[z]),u+=A[z],z>3&&(oa(i,u,r[S]>>>5&8191),u+=qo[z])}else oa(i,u,C[r[S]]),u+=O[r[S]];return oa(i,u,C[256]),u+O[256]},ca=new Bo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fa=function(){for(var t=new Bo(256),i=0;256>i;++i){for(var e=i,r=9;--r;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),pa=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function _a(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,r=0;i.length>r;++r)e=fa[255&e^i[r]]^e>>>8;t=e},d(){return 4294967295^t}}}(),r=t.length;e.p(t);var s,n,o,a,l,h=(a=10+((s=i).filename&&s.filename.length+1||0),l=8,function(t,i,e,r,s,n){var o=t.length,a=new Uo(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),h=0;if(!i||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?h=da(l,h,t.subarray(u,d)):(l[u]=!0,h=da(l,h,t.subarray(u,o)))}else{for(var v=ca[i-1],c=v>>>13,f=8191&v,p=(1<<e)-1,_=new jo(32768),g=new jo(p+1),m=Math.ceil(e/3),y=2*m,b=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<y)&p},w=new Bo(25e3),x=new jo(288),E=new jo(32),S=0,k=0,T=(u=0,0),P=0,R=0;o>u;++u){var C=b(u),O=32767&u,I=g[C];if(_[O]=I,g[C]=O,u>=P){var A=o-u;if((S>7e3||T>24576)&&A>423){h=va(t,l,0,w,x,E,k,T,R,u-R,h),T=S=k=0,R=u;for(var F=0;286>F;++F)x[F]=0;for(F=0;30>F;++F)E[F]=0}var M=2,D=0,N=f,L=O-I&32767;if(A>2&&C==b(u-L))for(var U=Math.min(c,A)-1,j=Math.min(32767,u),B=Math.min(258,A);j>=L&&--N&&O!=I;){if(t[u+M]==t[u+M-L]){for(var z=0;B>z&&t[u+z]==t[u+z-L];++z);if(z>M){if(M=z,D=L,z>U)break;var q=Math.min(L,z-2),H=0;for(F=0;q>F;++F){var V=u-L+F+32768&32767,W=V-_[V]+32768&32767;W>H&&(H=W,I=V)}}}L+=(O=I)-(I=_[O])+32768&32767}if(D){w[T++]=268435456|Go[M]<<18|Ko[D];var G=31&Go[M],K=31&Ko[D];k+=zo[G]+qo[K],++x[257+G],++E[K],P=u+M,++S}else w[T++]=t[u],++x[t[u]]}}h=va(t,l,!0,w,x,E,k,T,R,u-R,h)}return sa(a,0,r+ra(h)+s)}(n=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),u=h.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&pa(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var r=0;e.length>=r;++r)t[r+10]=e.charCodeAt(r)}}(h,i),pa(h,u-8,e.d()),pa(h,u-4,r),h}var ga=!!o||!!n,ma="text/plain",ya=!1,ba=(t,i)=>{var e=t.split("#"),r=e[1],s=e[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter((t=>t.split("=")[0]!==i)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},wa=function(t,i,e){var r;void 0===e&&(e=!0);var s=t.split("?"),n=s[0],o=s[1],a=_({},i),l=null!==(r=null==o?void 0:o.split("&").map((t=>{var i,r=t.split("="),s=r[0],n=e&&null!==(i=a[s])&&void 0!==i?i:r[1];return delete a[s],s+"="+n})))&&void 0!==r?r:[],h=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return es(t,(function(t,i){K(t)||K(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)})),s.join(i)}(a);return h&&l.push(h),l.length>0?n+"?"+l.join("&"):n},xa=t=>{if(t.Ca)return t.Ca;var i=t.data,e=t.compression;if(i){if(e===yo.GZipJS){var r=_a(function(t,i){var e=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var r=new Uo(t.length+(t.length>>>1)),s=0,n=function(t){r[s++]=t},o=0;e>o;++o){if(s+5>r.length){var a=new Uo(s+8+(e-o<<1));a.set(r),r=a}var l=t.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return sa(r,0,s)}(qn(i)),{mtime:0});return{contentType:ma,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(e===yo.Base64){var s=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,i)=>String.fromCharCode(parseInt(i,16))))):t}(qn(i)),n=(t=>"data="+encodeURIComponent("string"==typeof t?t:qn(t)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=qn(i);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Ea=t=>{var i,e,r=()=>"sendBeacon"===t.transport?{url:wa(t.url,{compression:yo.Base64}),encodedBody:xa(_({},t,{compression:yo.Base64,Ca:void 0}))}:{url:ba(t.url,"compression"),encodedBody:xa(_({},t,{compression:void 0,Ca:void 0}))};try{i=xa(t)}catch(i){if(Ri(t.compression,Vn(t.url,"compression")))return Ie.error("Failed to gzip request body, sending uncompressed payload",i),r();throw i}return i&&Ri(t.compression,Vn(t.url,"compression"))&&!((e=i.body)instanceof ArrayBuffer?Pi(new Uint8Array(e)):ArrayBuffer.isView(e)&&Pi(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)))?(ya=!0,r()):{url:t.url,encodedBody:i}},Sa=t=>{try{return Ea(t)}catch(i){return Ie.error(i),void(null==t.callback||t.callback({statusCode:0,error:i}))}},ka=function(){var t=p((function*(t){var i=qn(t.data),e=yield function(t,i,e){return Ai.apply(this,arguments)}(i,c.DEBUG,{rethrow:!0});if(!e)return t;var r=yield e.arrayBuffer();return _({},t,{Ca:{contentType:ma,body:r,estimatedSize:r.byteLength}})}));return function(i){return t.apply(this,arguments)}}(),Ta=/Failed to fetch|NetworkError|Load failed/i,$a=t=>"TypeError"===(null==t?void 0:t.name)&&Ta.test((null==t?void 0:t.message)||""),Pa=t=>{var i=Sa(t);if(i){var e=i.url,r=i.encodedBody,s=null!=r?r:{},o=s.contentType,l=s.body,h=s.estimatedSize,u=new Headers;es(t.headers,(function(t,i){u.append(i,t)})),o&&u.append("Content-Type",o);var d=null,v=!1;if(a){var c=new a;d={signal:c.signal,timeout:setTimeout((()=>{var i;v=!0,c.abort(wi("AbortError","PostHog request timed out"+((i=t.timeout)?" after "+i+"ms":"")))}),t.timeout)}}var f=i=>{v&&"AbortError"===(null==i?void 0:i.name)||$a(i)?Ie.warn(i):Ie.error(i),null==t.callback||t.callback({statusCode:0,error:i})};try{var p;n(e,_({method:(null==t?void 0:t.method)||"GET",headers:u,keepalive:"POST"===t.method&&!t.Ta&&52428.8>(h||0),body:l,signal:null==(p=d)?void 0:p.signal},t.fetchOptions)).then((i=>i.text().then((e=>{var r={statusCode:i.status,text:e};if(200===i.status)try{r.json=JSON.parse(e)}catch(t){Ie.error(t)}null==t.callback||t.callback(r)})))).catch(f).finally((()=>d?clearTimeout(d.timeout):null))}catch(t){d&&clearTimeout(d.timeout),f(t)}}},Ra=t=>{try{var i,r=Ea(t),s=r.url,n=r.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var h=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(e.sendBeacon(s,h))return;var u=H(t.data)?t.data:null==(i=t.data)?void 0:i.batch;if(H(u)&&u.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(u.length/2),v=i=>H(t.data)?i:_({},t.data,{batch:i});return Ra(_({},t,{data:v(u.slice(0,d))})),void Ra(_({},t,{data:v(u.slice(d))}))}Ie.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),Pa(_({},t,{Ta:!0}))}catch(t){Ie.warn("Beacon send failed",t)}},Ca=(t,i,e,r)=>{var s="query"===r?"POST"===i?"sent_at":"_":void 0;return wa(e===yo.GZipJS?ba(t,"compression"):t,_({},s?{[s]:Date.now().toString()}:{},e===yo.GZipJS?{}:{compression:e}))},Oa=[];n&&Oa.push({transport:"fetch",method:Pa}),o&&Oa.push({transport:"XHR",method(t){var i=Sa(t);if(i){var e=new o,r=i.encodedBody;e.open(t.method||"GET",i.url,!0);var s=null!=r?r:{},n=s.contentType,a=s.body;es(t.headers,(function(t,i){e.setRequestHeader(i,t)})),n&&e.setRequestHeader("Content-Type",n),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i={statusCode:e.status,text:e.responseText};if(200===e.status)try{i.json=JSON.parse(e.responseText)}catch(t){}null==t.callback||t.callback(i)}},e.send(a)}}}),null!=e&&e.sendBeacon&&Oa.push({transport:"sendBeacon",method:Ra});var Ia=3e3;class Aa{constructor(t,i){this.Ma=!0,this.Ea=[],this.Ia=ct((null==i?void 0:i.flush_interval_ms)||Ia,250,5e3,Ie.createLogger("flush interval"),Ia),this.Ra=t}enqueue(t){this.Ea.push(t),this.Pa||this.Aa()}unload(){this.Fa();var t=this.Ea.length>0?this.Oa():{},i=Object.values(t);[...i.filter((t=>0===t.url.indexOf("/e"))),...i.filter((t=>0!==t.url.indexOf("/e")))].map((t=>{this.La(_({},t,{transport:"sendBeacon"}))}))}enable(){this.Ma=!1,this.Aa()}Aa(){var t=this;this.Ma||(this.Pa=setTimeout((()=>{if(this.Fa(),this.Ea.length>0){var i=this.Oa(),e=function(){var e=i[r],s=(new Date).getTime();e.data&&H(e.data)&&es(e.data,(t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp})),t.La(e)};for(var r in i)e()}}),this.Ia))}La(t){try{this.Ra(t)}catch(t){Ie.error(t)}}Fa(){clearTimeout(this.Pa),this.Pa=void 0}Oa(){var t={};return es(this.Ea,(i=>{var e,r=i,s=(r?r.batchKey:null)||r.url;K(t[s])&&(t[s]=_({},r,{data:[]})),null==(e=t[s].data)||e.push(r.data)})),this.Ea=[],t}}var Fa=["retriesPerformedSoFar"];class Ma{constructor(i){this.Da=!1,this.$a=3e3,this.Ea=[],this._instance=i,this.Ea=[],this.Na=!0,!K(t)&&"onLine"in t.navigator&&(this.Na=t.navigator.onLine,this.qa=()=>{this.Na=!0,this.ja()},this.Ba=()=>{this.Na=!1},us(t,"online",this.qa),us(t,"offline",this.Ba))}get length(){return this.Ea.length}retriableRequest(t){var i=t.retriesPerformedSoFar,e=g(t,Fa);tt(i)&&(e.url=wa(e.url,{retry_count:i})),this._instance._send_request(_({},e,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=i?i:0))return void this.An(_({retriesPerformedSoFar:i},e));0===t.statusCode&&Ie.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==e.callback||e.callback(t)}}))}An(t){var i=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=i+1;var e=function(t){var i=3e3*Math.pow(2,t),e=i/2,r=Math.min(18e5,i),s=Math.random()-.5;return Math.ceil(r+s*(r-e))}(i),r=Date.now()+e;this.Ea.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+e;navigator.onLine||(s+=" (Browser is offline)"),Ie.warn(s),this.Da||(this.Da=!0,this.Ha())}Ha(){if(this.Ua&&clearTimeout(this.Ua),0===this.Ea.length)return this.Da=!1,void(this.Ua=void 0);this.Ua=setTimeout((()=>{this.Na&&this.Ea.length>0&&this.ja(),this.Ha()}),this.$a)}ja(){var t=Date.now(),i=[],e=this.Ea.filter((e=>t>e.retryAt||(i.push(e),!1)));if(this.Ea=i,e.length>0)for(var r of e)this.retriableRequest(r.requestOptions)}unload(){for(var i of(this.Ua&&(clearTimeout(this.Ua),this.Ua=void 0),this.Da=!1,K(t)||(this.qa&&(t.removeEventListener("online",this.qa),this.qa=void 0),this.Ba&&(t.removeEventListener("offline",this.Ba),this.Ba=void 0)),this.Ea)){var e=i.requestOptions;try{this._instance._send_request(_({},e,{transport:"sendBeacon"}))}catch(t){Ie.error(t)}}this.Ea=[]}}class Da{constructor(t){this.za=()=>{var t,i,e,r;this.Wa||(this.Wa={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.Wa.lastScrollY=Math.ceil(n),this.Wa.maxScrollY=Math.max(n,null!==(t=this.Wa.maxScrollY)&&void 0!==t?t:0),this.Wa.maxScrollHeight=Math.max(o,null!==(i=this.Wa.maxScrollHeight)&&void 0!==i?i:0),this.Wa.lastContentY=a,this.Wa.maxContentY=Math.max(a,null!==(e=this.Wa.maxContentY)&&void 0!==e?e:0),this.Wa.maxContentHeight=Math.max(l,null!==(r=this.Wa.maxContentHeight)&&void 0!==r?r:0)},this._instance=t}get Va(){return this._instance.config.scroll_root_selector}getContext(){return this.Wa}resetContext(){var t=this.Wa;return setTimeout(this.za,0),t}startMeasuringScrollPosition(){us(t,"scroll",this.za,{capture:!0}),us(t,"scrollend",this.za,{capture:!0}),us(t,"resize",this.za)}scrollElement(){if(!this.Va)return null==t?void 0:t.document.documentElement;var i=H(this.Va)?this.Va:[this.Va];for(var e of i){var r=null==t?void 0:t.document.querySelector(e);if(r)return r}}Ga(i){var e="y"===i?"scrollTop":"scrollLeft";if(this.Va){var r=this.scrollElement();return r&&r[e]||0}return t?"y"===i?t.scrollY||t.pageYOffset||t.document.documentElement.scrollTop||0:t.scrollX||t.pageXOffset||t.document.documentElement.scrollLeft||0:0}scrollY(){return this.Ga("y")}scrollX(){return this.Ga("x")}}var Na=t=>ao(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);class La{constructor(t,i,e,r){this.ut=t=>{var i=this.Za();if(!i||i.sessionId!==t){var e={sessionId:t,props:this.Qa(this._instance)};this.Ja.register({[Ir]:e})}},this._instance=t,this.Ka=i,this.Ja=e,this.Qa=r||Na,this.Ka.onSessionId(this.ut)}Za(){return this.Ja.props[Ir]}getSetOnceProps(){var t,i=null==(t=this.Za())?void 0:t.props;return i?"r"in i?lo(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var t={};return es(as(this.getSetOnceProps()),((i,e)=>{"$current_url"===e&&(e="url"),t["$session_entry_"+U(e)]=i})),t}}class Ua{on(t,i){return this.Ya[t]||(this.Ya[t]=[]),this.Ya[t].push(i),()=>{this.Ya[t]=this.Ya[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.Ya[t]||[])e(i);for(var r of this.Ya["*"]||[])r(t,i)}constructor(){this.Ya={}}}var ja=Ae("[SessionId]"),Ba=864e5;class za{on(t,i){return this.Xa.on(t,i)}constructor(t,i,e){var r;if(this.eo=null,this.io=null,this.ro=[],this.no=void 0,this.so=!1,this.Xa=new Ua,this.ao=(t,i)=>!(!tt(t)||!tt(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===Vr)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.zi=t.config,this.Ja=t.persistence,this.ct=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.oo=void 0,this._sessionActivityTimestamp=null,this.lo=i||ms,this.uo=e||ms;var s=this.zi.persistence_name||this.zi.token;if(this._sessionTimeoutMs=1e3*ct(this.zi.session_idle_timeout_seconds||1800,60,36e3,ja.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ho(),this.do="ph_"+s+"_window_id",this.vo="ph_"+s+"_primary_window_exists",this.co()){var n=Ls.Vr(this.do),o=Ls.Vr(this.vo);n&&!o?this.ct=n:Ls.Wr(this.do),Ls.Ur(this.vo,!0)}null!=(r=this.zi.bootstrap)&&r.sessionID&&this.setBootstrapSessionId(this.zi.bootstrap.sessionID),this.fo()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return K(this.ro)&&(this.ro=[]),this.ro.push(t),this._e&&t(this._e,this.ct),()=>{this.ro=this.ro.filter((i=>i!==t))}}co(){return"memory"!==this.zi.persistence&&!this.Ja.Js&&Ls.Hr()}po(t){t!==this.ct&&(this.ct=t,this.co()&&Ls.Ur(this.do,t))}mo(){return this.ct?this.ct:this.co()?Ls.Vr(this.do):null}yo(t){var i=this.eo;return!Q(i)&&!Q(t)&&5e3>Math.abs(t-i)}bo(t,i,e){var r=i!==this._sessionActivityTimestamp,s=!(t!==this._e||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this._e=t,s&&!r||s&&this.yo(i)||(this.eo=i,this.Ja.register({[ar]:[i,t,e]}))}_o(){var t,i=null==(t=this.zi)?void 0:t.persistence_save_debounce_ms;return tt(i)&&i>0}wo(){this._o()?this.Ja.refreshKey(ar):(this.Ja.flush(),this.Ja.load())}ko(){var t;if(!Q(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.eo){this.wo();var i=this.So();i[1]===this._e&&i[2]===this._sessionStartTimestamp&&(this.eo=this._sessionActivityTimestamp,this.Ja.register({[ar]:[this._sessionActivityTimestamp,null!==(t=this._e)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Ja.flush())}}xo(){var t=this.So()[0],i=tt(t)?t:0,e=tt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}Co(t){return this.wo(),this.ao(t,this.xo())}So(){var t=this.Ja.props[ar];return H(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.eo=null,this.oo=void 0,clearTimeout(this.To),this.To=void 0,this.bo(null,null,null)}setBootstrapSessionId(t,i){void 0===i&&(i=!1);var e=function(t,i){void 0===i&&(i=(new Date).getTime());try{var e=(t=>{var i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void ja.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void ja.error("Invalid sessionID in bootstrap",t)}}(t);return!K(e)&&(i?this.oo={sessionId:t,sessionStartTimestamp:e}:this.bo(t,(new Date).getTime(),e),!0)}destroy(){this.so=!0,this.ko(),clearTimeout(this.To),this.To=void 0,this.no&&t&&(t.removeEventListener(Yr,this.no,{capture:!1}),this.no=void 0),this.ro=[]}fo(){this.no=()=>{this.ko(),this.co()&&Ls.Wr(this.vo)},us(t,Yr,this.no,{capture:!1})}checkAndGetSessionAndWindowId(t,i,e){if(void 0===t&&(t=!1),void 0===i&&(i=null),void 0===e&&(e=!1),this.zi.cookieless_mode===Vr)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=i||(new Date).getTime(),s=this._e;if(e)this.io=r;else if(Q(this.io)||this.io>r||r-this.io>=1e3){var n,o;null==(n=(o=this.Ja).syncCookieProperties)||n.call(o),this.io=r}var a=this.So(),l=a[1],h=a[2],u=!K(s)&&l!==s,d=this.xo(),v=this.mo(),c=this.oo,f=!!c&&(c.sessionStartTimestamp>r+6e4||r-c.sessionStartTimestamp>Ba),p=c?f:tt(h)&&Math.abs(r-h)>Ba,_=!1,g=u,m=!l||!!c,y=l,b=!m&&!t&&this.ao(r,d);if(b){(b=this.Co(r))||ja.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this.So();l=w[1],h=w[2]}if(m||b||p){g=!1;var x=c&&!f;l=x?c.sessionId:this.lo(),v=this.uo(),ja.info("new session ID assigned",{sessionId:l,windowId:v,bootstrapped:!!x,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p}}),h=x?c.sessionStartTimestamp:r,this.oo=void 0,_=!0}else v||(v=this.uo(),_=!0),(g=g||l!==y)&&(ja.info("adopted cross-tab session id",{sessionId:l,windowId:v}),_=!0);var E=tt(d)&&t&&!p?d:r,S=tt(h)?h:(new Date).getTime();this.po(v),this.bo(l,E,S),t||this.ho();var k={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:p,crossTabAdoption:g};return _&&this.ro.forEach((t=>t(l,v,k))),{sessionId:l,windowId:v,sessionStartTimestamp:S,changeReason:_?k:void 0,lastActivityTimestamp:d}}ho(){this.so||(clearTimeout(this.To),this.To=setTimeout((()=>{if(!this.so)if(this.Co((new Date).getTime())){var t=this._e;this.resetSessionId(),this.Xa.emit("forcedIdleReset",{idleSessionId:t})}else this.ho()}),1.1*this.sessionTimeoutMs))}}var qa=function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&D(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>D(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver};function Ha(){return(Ha=p((function*(){var t=null==e?void 0:e.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var i=yield t.getHighEntropyValues(["model"]),r=null==i?void 0:i.model;return J(r)&&r.length>0?r:void 0}catch(t){return void Ie.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}}))).apply(this,arguments)}function Va(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var Wa=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Ga=t=>t.toLowerCase(),Ka={exact:(t,i)=>i.some((i=>t.some((t=>i===t)))),is_not:(t,i)=>i.every((i=>t.every((t=>i!==t)))),regex:(t,i)=>i.some((i=>t.some((t=>Wa(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!Wa(i,t))))),icontains:(t,i)=>i.map(Ga).some((i=>t.map(Ga).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(Ga).every((i=>t.map(Ga).every((t=>!i.includes(t))))),gt:(t,i)=>i.some((i=>{var e=parseFloat(i);return!isNaN(e)&&t.some((t=>e>parseFloat(t)))})),lt:(t,i)=>i.some((i=>{var e=parseFloat(i);return!isNaN(e)&&t.some((t=>e<parseFloat(t)))}))};function Ja(t,i){return!t||Object.entries(t).every((t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(null==r)return!1;var s=Ka[e.operator];return!!s&&s(e.values,[String(r)])}))}function Ya(t,i,e){return qn({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}var Qa="custom",Xa="i.posthog.com",Za=/^\/static\//,tl=["/s/","/e/","/i/"];class il{constructor(t){this.Mo={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,i=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace("."+Xa,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.Mo[this.apiHost]||(this.Mo[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":Qa),this.Mo[this.apiHost]}Eo(t){if(Za.test(t)){var i=this.instance.config.asset_host;if("string"==typeof i)return i.trim().replace(/\/$/,"")||void 0}}Io(t){var i=Hn(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}Ro(t,i,e){if("ui"===t)return e;var r=e,s=this.instance.config.rewriteRequestPath;if(s){var n,o=(null==(n=Hn(e))?void 0:n.href)||e;r=s(new URL(o)).toString()}if(s&&"api"===t&&tl.some((t=>0===i.indexOf(t)))){var a=this.Io(r);if(a){var l,h=this.apiHost,u=this.Po;(null==(l=u)?void 0:l.apiHost)===h&&u.rewriteRequestPath===s||(u={apiHost:h,rewriteRequestPath:s,urls:new Set},this.Po=u),u.urls.add(a)}}return r}isIngestionEndpoint(t){var i=this.Po,e=this.Io(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i){if(void 0===i&&(i=""),i&&(i="/"===i[0]?i:"/"+i),"ui"===t)return this.Ro(t,i,this.uiHost+i);if("flags"===t)return this.Ro(t,i,this.flagsApiHost+i);if("assets"===t){var e=this.Eo(i);if(e)return this.Ro(t,i,""+e+i)}if(this.region===Qa)return this.Ro(t,i,this.apiHost+i);var r=Xa+i;switch(t){case"assets":return this.Ro(t,i,"https://"+this.region+"-assets."+r);case"api":return this.Ro(t,i,"https://"+this.region+"."+r)}}}var el=Ae("[Surveys]"),rl="seenSurvey_",sl=t=>{try{var i=(t=>((t,i)=>""+rl+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(i))(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){el.error("Failed to persist survey seen state",t)}},nl=[So.Popover,So.Widget,So.API],ol={ignoreConditions:!1,ignoreDelay:!1,displayType:Co.Popover},al=Ae("[PostHog ExternalIntegrations]"),ll={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class hl{constructor(t){this._instance=t}Es(t,i){var e;null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,t,(t=>{if(t)return al.error("failed to load script",t);i()}))}startIfEnabledOrStop(){var t=this,i=function(){var i,r,s,n=e[0],o=e[1];!o||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[n]||t.Es(ll[n],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[n])||i.start(t._instance)})),!o&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=v.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var e of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;i()}}}class ul{constructor(t,i){this.I=t,this.cs=i,this.Ao=new Map,this.us=!1}add(t){var i=this;return p((function*(){if(i.us)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.Ao.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');i.Ao.set(t.name,t);try{var e=t.setup(i.cs);e&&(yield e)}catch(e){var r=i.Ao.get(t.name)===t;r&&i.Ao.delete(t.name),i.I.error('Failed to set up browser extension "'+t.name+'"',e),r&&i.Fo(t)}}))()}getExtension(t){return this.Ao.get(t)}dispose(){if(!this.us){this.us=!0;var t=Array.from(this.Ao.values()).reverse();for(var i of(this.Ao.clear(),t))this.Fo(i)}}Fo(t){try{var i=null==t.dispose?void 0:t.dispose();i&&V(i.then)&&i.then(void 0,(i=>{this.I.error('Failed to dispose browser extension "'+t.name+'"',i)}))}catch(i){this.I.error('Failed to dispose browser extension "'+t.name+'"',i)}}}class dl{constructor(t){this._instance=t}initialize(){}get(t){var i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);var e={};for(var r of t){var s=null==i?void 0:i.get_property(r);K(s)||(e[r]=s)}return e}set(t,i){var e;null==(e=this._instance.persistence)||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null==(i=this._instance.persistence)||i.unregister(t)}}var vl="extensionsRemoteConfig";class cl{constructor(t){this.us=!1,this.instance=t,this.I=Ie,this.Oo=t.Lo,this.kv=new dl(t),this.onEvent=t=>mo(this.instance.on("eventCaptured",(i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.I.error("Browser extension event listener failed",t)}}))),this.onRemoteConfig=t=>{if(this.us)return mo((()=>{}));var i=i=>{try{t(i)}catch(t){this.I.error("Browser extension remote config listener failed",t)}},e=this.instance.Do.on(vl,i);return this.Oo&&i(this.Oo),mo(e)},this.$o=new ul(Ie.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property(Be))&&void 0!==t?t:this.distinctId}get deviceId(){var t=this.instance.get_property(Be);return"string"==typeof t?t:void 0}get library(){return{name:c.LIB_NAME,version:c.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null==(i=this.instance.persistence)?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==s?void 0:s.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==s?void 0:s.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.$o.add(t)}getExtension(t){return this.$o.getExtension(t)}capture(t,i,e){var r=this;return p((function*(){e?r.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):r.instance.capture(t,i)}))()}registerDynamicEventProperties(t){return mo(this.instance.No(t))}handleRemoteConfig(t){this.us||(this.Oo=t,this.instance.Do.emit(vl,t))}sendRequest(t,i){var e=this;return p((function*(){var r;void 0===i&&(i={});var s=e.instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",t),n={method:i.method,url:i.query?wa(s,i.query):s,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?E.Base64:void 0,timestampMode:i.sentAt};return"sendBeacon"===i.transport?(e.instance._send_request(n),{statusCode:202}):new Promise((t=>{n.callback=t,e.instance._send_request(n)}))}))()}dispose(){this.us||(this.us=!0,this.$o.dispose())}}var fl={},pl=0,_l=()=>{},gl='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ml="Surveys module not available",yl="sanitize_properties is deprecated. Use before_send instead",bl="Invalid value for property_denylist config: ",wl=["token","distinct_id",Ur],xl="posthog",El=!ga&&-1===(null==h?void 0:h.indexOf("MSIE"))&&-1===(null==h?void 0:h.indexOf("Mozilla")),Sl=t=>{var i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},kl=i=>{var e;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:hs(null==r?void 0:r.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:_l,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=i?i:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:s&&J(null==s?void 0:s.search)&&-1!==s.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==t||null==(e=t.location)?void 0:e.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){Ie.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Kr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Ia},error_tracking:{},_onCapture:_l},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:hn,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:Sl(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(i))},Tl=[["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"]],$l=t=>{var i={};for(var e of Tl){var r=e[0],s=e[1];K(t[r])||(i[s]=t[r])}var n=rs({},i,t),o=t.__preview_external_dependency_versioned_paths;return K(o)||(K(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),J(o)&&K(t.asset_host)&&(n.asset_host=o)),H(t.property_blacklist)&&(K(t.property_denylist)?n.property_denylist=t.property_blacklist:H(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:Ie.error(bl+t.property_denylist)),n};class Pl{constructor(){this.__forceAllowLocalhost=!1}get qo(){return this.__forceAllowLocalhost}set qo(t){Ie.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Rl{jo(t,i){if(t){var e=this.Ao.indexOf(t);-1!==e&&this.Ao.splice(e,1)}return this.Ao.push(i),null==i.initialize||i.initialize(),i}Bo(){return this.config.cookieless_mode===Vr||this.config.cookieless_mode===Hr&&this.consent.isRejected()}Ho(){if(!this.Bo()&&this.get_distinct_id()===Lr){var t=this.persistence;if(t){this.Uo()||t.load(!0);var i=this.get_distinct_id();if(!i||i===Lr){var e=this.config.get_device_id(ms());this.register({distinct_id:e,$device_id:e}),t.set_property(Or,Wr)}this.zo()}}}get decideEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.webPerformance=new Pl,this.Wo=!1,this.version=c.LIB_VERSION,this.Vo=new Set,this.Go="",this.Do=new Ua,this.Ao=[],this.Zo=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=kl(),this.SentryIntegration=Nn,this.sentryIntegration=t=>function(t,i){var e=Dn(t,i);return{name:Mn,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Qo=!1,this.Jo=null,this.Ko=null,this.Yo=null,this.scrollManager=new Da(this),this.pageViewManager=new Ln(this),this.rateLimiter=new Mo(this),this.requestRouter=new il(this),this.consent=new Us(this),this.externalIntegrations=new hl(this);var i=null!==(t=Rl.__defaultExtensionClasses)&&void 0!==t?t:{};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:(t,i,e)=>{var r=J(t)?{[t]:i}:t;this.setPersonProperties(r),null==e||e({})},set_once:(t,i,e)=>{var r=J(t)?{[t]:i}:t;this.setPersonProperties(void 0,r),null==e||e({})}},this.on("eventCaptured",(t=>Ie.info('send "'+(null==t?void 0:t.event)+'"',t)))}init(t,i,e){if(e&&e!==xl){var r,s=null!==(r=fl[e])&&void 0!==r?r:new Rl;return s._init(t,i,e),fl[e]=s,fl[xl][e]=s,s}return this._init(t,i,e)}_init(i,e,r){var s,n;void 0===e&&(e={});var o,a=J(i)?i.trim():"";if(!a)return Ie.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return a!==(null==(o=this.config)?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=kl(e.defaults),e.debug=this.Xo(e.debug),this.tl=e,this.el=[],e.person_profiles?this.Ko=e.person_profiles:e.process_person&&(this.Ko=e.process_person);var l=kl(e.defaults),h=$l(e),u=rs({},l,h,{name:r,token:a});W(l.rageclick)&&W(h.rageclick)&&(u.rageclick=rs({},l.rageclick,h.rageclick)),W(l.session_recording)&&W(h.session_recording)&&(u.session_recording=rs({},l.session_recording,h.session_recording)),this.set_config(u),this.config.on_xhr_error&&Ie.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=e.disable_compression?void 0:yo.GZipJS;var d=this.Uo();if(this.persistence=new go(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new go(_({},this.config,{persistence:"sessionStorage"}),d,!1),this.Go="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!d&&Ls.Hr()){var v=Ls.Vr(this.Go);H(v)&&v.forEach((t=>{J(t)&&this.Vo.add(t)}))}else Ls.Wr(this.Go);var f=_({},this.persistence.props),p=_({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.il=new Aa((t=>this.rl(t)),this.config.request_queue_config),this.nl=new Ma(this),this.__request_queue=[];var g=this.Bo();if(g||(this.sessionManager=new za(this),this.sessionPropsManager=new La(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((t,i,e)=>{(null!=e&&e.activityTimeout||null!=e&&e.sessionPastMaximumLength||null!=e&&e.crossTabAdoption)&&this.sl()}))),this.al(),this.config.__preview_deferred_init_extensions?(Ie.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.ol(g)}),0)):(Ie.info("Initializing extensions synchronously"),this.ol(g)),c.DEBUG=c.DEBUG||this.config.debug,c.DEBUG&&Ie.info("Starting in debug mode",{this:this,config:e,thisC:_({},this.config),p:f,s:p}),!this.config.identity_distinct_id||null!=(s=e.bootstrap)&&s.distinctID||(e.bootstrap=_({},e.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(n=e.bootstrap)?void 0:n.distinctID)){var m=e.bootstrap.distinctID,y=this.get_distinct_id(),b=this.persistence.get_property(Or);if(e.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Wr)this.identify(m);else if(e.bootstrap.isIdentifiedID&&null!=y&&y!==m&&b===Gr)Ie.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var w=this.config.get_device_id(ms()),x=e.bootstrap.isIdentifiedID?w:m;this.persistence.set_property(Or,e.bootstrap.isIdentifiedID?Gr:Wr),this.register({distinct_id:m,$device_id:x})}}if(g)this.register_once({distinct_id:Lr,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(ms());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(Or,Wr)}return us(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),e.segment?function(t,i){var e=t.config.segment;if(!e)return i();!function(t,i){var e=t.config.segment;if(!e)return i();var r=e=>{var r=()=>e.anonymousId()||ms();t.config.get_device_id=r,e.id()&&(t.register({distinct_id:e.id(),$device_id:r()}),t.persistence.set_property(Or,Gr)),i()},s=e.user();"then"in s&&V(s.then)?s.then(r):r(s)}(t,(()=>{e.register((t=>{"undefined"!=typeof Promise&&Promise.resolve||Fn.warn("This browser does not have Promise support, and can not use the segment integration");var i=(i,e)=>{if(!e)return i;i.event.userId||i.event.anonymousId===t.get_distinct_id()||(Fn.info("No userId set, resetting PostHog"),t.reset()),i.event.userId&&i.event.userId!==t.get_distinct_id()&&(Fn.info("UserId set, identifying with PostHog"),t.identify(i.event.userId));var r=t.calculateEventProperties(e,i.event.properties);return i.event.properties=Object.assign({},r,i.event.properties),i};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:t=>i(t,t.event.event),page:t=>i(t,Qr),identify:t=>i(t,Zr),screen:t=>i(t,"$screen")}})(t)).then((()=>{i()}))}))}(this,(()=>this.ll())):this.ll(),V(this.config._onCapture)&&this.config._onCapture!==_l&&(Ie.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(t=>this.config._onCapture(t.event,t)))),this.config.ip&&Ie.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 Ha.apply(this,arguments)}().then((t=>{t&&this.register({[ze]:t})})).catch(_l),this}ul(t){var i=t;return J(i.name)&&V(i.setup)}hl(t,i){this.ul(t)?i.push((()=>{this.dl().add(t).catch((()=>null==t.dispose?void 0:t.dispose())).catch((i=>{Ie.error('Failed to dispose browser extension "'+t.name+'"',i)}))})):this.Ao.push(t)}al(){var t,i,e,r,s,n,o=null!==(t=null==(i=this.config.__extensionClasses)?void 0:i.featureFlags)&&void 0!==t?t:null==(e=Rl.__defaultExtensionClasses)?void 0:e.featureFlags;o&&(this.featureFlags&&this.featureFlags instanceof o||(null==(r=this.vl)||r.call(this),this.vl=void 0,this.featureFlags=new o(this)),V(this.featureFlags.onReloading)&&V(this.featureFlags.setup)?this.vl||(this.vl=this.featureFlags.onReloading((()=>{this.Do.emit("featureFlagsReloading",!0)})),this.dl().add(this.featureFlags)):null==(s=(n=this.featureFlags).initialize)||s.call(n))}ol(t){var i,e,r,s,n,o,a,l=performance.now(),h=_({},Rl.__defaultExtensionClasses,this.config.__extensionClasses),u=[];h.exceptions&&this.Ao.push(this.exceptions=null!==(i=this.exceptions)&&void 0!==i?i:new h.exceptions(this)),h.historyAutocapture&&this.Ao.push(this.historyAutocapture=new h.historyAutocapture(this)),h.tracingHeaders&&this.Ao.push(this.tracingHeaders=new h.tracingHeaders(this)),h.siteApps&&this.Ao.push(this.siteApps=new h.siteApps(this)),h.sessionRecording&&!t&&this.Ao.push(this.sessionRecording=new h.sessionRecording(this)),this.config.disable_scroll_properties||u.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),h.autocapture&&this.hl(this.autocapture=new h.autocapture(this),u),h.surveys&&this.hl(this.surveys=null!==(e=this.surveys)&&void 0!==e?e:new h.surveys(this),u),h.logs&&this.hl(this.logs=null!==(r=this.logs)&&void 0!==r?r:new h.logs(this),u),h.metrics&&this.Ao.push(this.metrics=null!==(s=this.metrics)&&void 0!==s?s:new h.metrics(this)),h.conversations&&this.Ao.push(this.conversations=null!==(n=this.conversations)&&void 0!==n?n:new h.conversations(this)),h.productTours&&this.Ao.push(this.productTours=new h.productTours(this)),h.heatmaps&&this.Ao.push(this.heatmaps=new h.heatmaps(this)),h.webVitalsAutocapture&&this.Ao.push(this.webVitalsAutocapture=new h.webVitalsAutocapture(this)),h.exceptionObserver&&this.Ao.push(this.exceptionObserver=new h.exceptionObserver(this)),h.deadClicksAutocapture&&this.Ao.push(this.deadClicksAutocapture=new h.deadClicksAutocapture(this,In)),h.toolbar&&this.Ao.push(this.toolbar=null!==(o=this.toolbar)&&void 0!==o?o:new h.toolbar(this)),h.experiments&&this.Ao.push(this.experiments=null!==(a=this.experiments)&&void 0!==a?a:new h.experiments(this)),this.Ao.forEach((t=>{t.initialize&&u.push((()=>{null==t.initialize||t.initialize()}))})),u.push((()=>{if(this.cl){var t=this.cl;this.cl=void 0,this.Ao.forEach((i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t)))}})),this.fl(u,l)}fl(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout((()=>{this.fl(t,i)}),0);var e=t.shift();if(e)try{e()}catch(t){Ie.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-i);this.register_for_session({[jr]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Br]:r}),this.config.__preview_deferred_init_extensions&&Ie.info("PostHog extensions initialized ("+r+"ms)")}Sa(t){var i;if(!r||!r.body)return Ie.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Sa(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.cl=t),this.Lo=t,this.compression=void 0,t.ok){var e,s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=N(s.supportedCompression,yo.GZipJS)?yo.GZipJS:N(s.supportedCompression,yo.Base64)?yo.Base64:void 0),null!=(e=s.analytics)&&e.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.Ko?this.Ko:Kr}),null==(i=this.pl)||i.handleRemoteConfig(t),this.Ao.forEach((i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t)))}ll(){try{this.config.loaded(this)}catch(t){Ie.critical("`loaded` function failed",t)}if(this.gl(),this.config.internal_or_test_user_hostname&&null!=s&&s.hostname){var t=s.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Bo())&&this.ml()}),1),this.yl=new No(this),this.yl.load()}gl(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.il)||t.enable())}_dom_loaded(){this.is_capturing()&&is(this.__request_queue,(t=>this.rl(t))),this.__request_queue=[],this.gl()}_handle_unload(){var t,i,e,r,s;null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(i=this.metrics)||i.flush("sendBeacon"),this.config.request_batching?(this.bl()&&this.capture(Xr),null==(e=this.logs)||e.flushLogs("sendBeacon"),null==(r=this.il)||r.unload(),null==(s=this.nl)||s.unload()):this.bl()&&this.capture(Xr,null,{transport:"sendBeacon"})}_send_request(t){var i;this.__loaded?El?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=_({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?null!==(i=this.compression)&&void 0!==i?i:t.compressionFallback:t.compression,(K(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var i,e,r,s=_({},t);s.timeout=s.timeout||6e4;var n,o,a,h,u,d=null!==(i=s.transport)&&void 0!==i?i:"fetch";"sendBeacon"===d&&K(s.compression)&&s.data&&(s.compression=yo.Base64),"POST"===s.method&&s.data&&("capture-body"===s.timestampMode?s.data={api_key:null!==(o=null==(u=(h=(H(n=s.data)?n:[n]).map((t=>_({},t,t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{}))))[0])||null==(a=u.properties)?void 0:a.token)&&void 0!==o?o:null==u?void 0:u.token,batch:h,sent_at:(new Date).toISOString()}:"body"===s.timestampMode&&(s.data=function(t,i){return void 0===i&&(i=(new Date).toISOString()),H(t)?t.map((t=>_({},t,{sent_at:i}))):_({},t,{sent_at:i})}(s.data))),s.url=Ca(s.url,s.method,s.compression,s.timestampMode);var v=Oa.filter((t=>!s.disableTransport||!t.transport||!s.disableTransport.includes(t.transport))),c=null!==(e=null==(r=function(t,i){for(var e=0;t.length>e;e++)if(t[e].transport===d)return t[e]}(v))?void 0:r.method)&&void 0!==e?e:v[0].method;if(!c)throw new Error("No available transport method");var f=t=>{try{c(t)}catch(t){$a(t)?Ie.warn(t):Ie.error(t),null==s.callback||s.callback({statusCode:0,error:t})}};"sendBeacon"!==d&&s.data&&s.compression===yo.GZipJS&&l&&"undefined"!=typeof Promise&&!ya?ka(s).then((t=>{f(t)})).catch((i=>{if(Ci(i))return ya=!0,void f(_({},s,{compression:void 0,url:Ca(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var i="name"in t?String(t.name):"";return Ci(t)||i===$i})(i)&&(ya=!0),f(s)})):c(s)})(_({},t,{callback:i=>{var e,r;this.rateLimiter.checkForLimiting(i),400>i.statusCode||null==(e=(r=this.config).on_request_error)||e.call(r,i),null==t.callback||t.callback(i)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}rl(t){this.nl?this.nl.retriableRequest(t):this._send_request(t)}_execute_array(t){pl++;try{var i,e=[],r=[],s=[];is(t,(t=>{if(t)if(H(i=t[0]))s.push(t);else if(V(t))try{t.call(this)}catch(i){Ie.error("Error executing queued PostHog call",t,i)}else H(t)&&"alias"===i?e.push(t):H(t)&&-1!==i.indexOf("capture")&&V(this[i])?s.push(t):r.push(t)}));var n=function(t,i){is(t,(function(t){try{if(H(t[0])){var e=i;es(t,(function(t){e=e[t[0]].apply(e,t.slice(1))}))}else i[t[0]].apply(i,t.slice(1))}catch(i){Ie.error("Error executing queued PostHog call",t,i)}}))};n(e,this),n(r,this),n(s,this)}finally{pl--}}push(t){if(pl>0&&H(t)&&J(t[0])){var i=Rl.prototype[t[0]];V(i)&&i.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,i,e){var r,s,n,o,a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.il){if(this.is_capturing())if(!K(t)&&J(t)){this.Ho();var l=!this.config.opt_out_useragent_filter&&this._is_bot();if(!l||this.config.__preview_capture_bot_pageviews){var h=null!=e&&e.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==h||!h.isRateLimited){null!=i&&i.$current_url&&!J(null==i?void 0:i.$current_url)&&(Ie.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||null!=e&&e._l||Ie.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var u=new Date,d=(null==e?void 0:e.timestamp)||u,v=bi(null==e?void 0:e.uuid,ms),c={uuid:v,event:t,properties:this.calculateEventProperties(t,i||{},d,v)};t===Qr&&this.config.__preview_capture_bot_pageviews&&l&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),h&&(c.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens);var f="$feature_flag_called"===t&&!1===c.properties.$feature_flag_has_experiment&&!0===this.get_property(pr);(null==e?void 0:e.$set)&&!f&&(c.$set=null==e?void 0:e.$set);var p=null==e?void 0:e.$unset;p&&(c.$unset=p);var g,m,y,b=f?void 0:this.wl(null==e?void 0:e.$set_once,t!==ts,t===Zr);if(b&&(c.$set_once=b),null!=e&&e._noTruncate||(s=this.config.properties_string_max_length,n=c,o=t=>J(t)?t.slice(0,s):t,a=new Set,c=function t(i,e){if(i!==Object(i))return o?o(i):i;if(!a.has(i)){var r;if(a.add(i),H(i))r=[],is(i,(i=>{r.push(t(i))}));else{var s={};es(i,((i,e)=>{a.has(i)||(s[e]=t(i,e))})),r=s}return r}}(n)),c.timestamp=d,K(null==e?void 0:e.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=u),f&&(c.properties=function(t,i){void 0===i&&(i=[]);var e={},r=i=>{void 0!==t[i]&&(e[i]=t[i])};return w.forEach(r),i.forEach(r),e}(c.properties,wl)),t===Po.DISMISSED||t===Po.SENT){var x=null==i?void 0:i[Ro.SURVEY_ID],E=null==i?void 0:i[Ro.SURVEY_ITERATION];sl({id:x,current_iteration:E}),c.$set=_({},c.$set,{[(g={id:x,current_iteration:E},m=t===Po.SENT?"responded":"dismissed",y="$survey_"+m+"/"+g.id,g.current_iteration&&g.current_iteration>0&&(y="$survey_"+m+"/"+g.id+"/"+g.current_iteration),y)]:!0})}else t===Po.SHOWN&&(c.$set=_({},c.$set,{[Ro.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(t===Io.SHOWN){var S=null==i?void 0:i[Ao.TOUR_TYPE];S&&(c.$set=_({},c.$set,{[Ao.TOUR_LAST_SEEN_DATE+"/"+S]:(new Date).toISOString()}))}var k=_({},c.properties.$set,c.$set);if(G(k)||this.setPersonPropertiesForFlags(k),!X(this.config.before_send)){var T=this.Rn(c);if(!T)return;(c=T).uuid=bi(c.uuid,ms)}this.Do.emit("eventCaptured",c);var P=null!==(r=null==e?void 0:e._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),R={method:"POST",url:P,data:c,compression:"best-available",timestampMode:"recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(P)?"body":"capture-body",batchKey:null==e?void 0:e._batchKey,transport:null==e?void 0:e.transport};return!this.config.request_batching||e&&(null==e||!e._batchKey)||null!=e&&e.send_instantly?this.rl(R):this.il.enqueue(R),c}Ie.critical("This capture call is ignored due to client rate limiting.")}}else Ie.error("No event name provided to posthog.capture")}else Ie.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(i=>t(i.event,i)))}getExtension(t){var i;return null==(i=this.pl)?void 0:i.getExtension(t)}dl(){var t;return null!==(t=this.pl)&&void 0!==t?t:this.pl=new cl(this)}No(t){this.Zo.push(t);var i=!0;return()=>{if(i){i=!1;var e=this.Zo.indexOf(t);-1!==e&&this.Zo.splice(e,1)}}}kl(t){var i,e,r;return void 0===t&&(t=!0),!(null==(i=this.persistence)||!i.consumeCookieIdentityChange())&&(this.Yo=null,this.persistence.get_property(Or)===Wr&&(null==(r=this.sessionPersistence)||r.clear(),this.Vo.clear(),this.Sl()),null==(e=this.featureFlags)||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(i,e,n,o,a){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return e;this.persistence.syncCookieProperties(),this.kl();var l=a?void 0:this.persistence.remove_event_timer(i),u=_({},e);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this.Bo()&&(u[Ur]=!0),"$snapshot"===i){var d=_({},this.persistence.properties(),this.sessionPersistence.properties());return u.distinct_id=d.distinct_id,(!J(u.distinct_id)&&!Z(u.distinct_id)||Y(u.distinct_id))&&Ie.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}var v,f=function(i,e,r,n){var o,a,l,u;if(void 0===n&&(n=!1),!h)return{};var d,v=i?[...Qn,...e||[]]:[],f=function(t){for(var i=0;gi.length>i;i++){var e=gi[i],r=e[1],s=e[0].exec(t),n=s&&(V(r)?r(s,t):r);if(n)return n}return["",""]}(h),p=f[0],_=f[1],g=null!=(d="undefined"!=typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};K(r)||(m.detectGoogleSearchApp=r);var y={},b=null==(o=navigator)||null==(o=o.userAgentData)?void 0:o.platform,w=null==(a=navigator)?void 0:a.maxTouchPoints,x=null==t||null==(l=t.screen)?void 0:l.width,E=null==t||null==(u=t.screen)?void 0:u.height,S=null==t?void 0:t.devicePixelRatio;K(b)||(y.userAgentDataPlatform=b),K(w)||(y.maxTouchPoints=w),K(x)||(y.screenWidth=x),K(E)||(y.screenHeight=E),K(S)||(y.devicePixelRatio=S);var k,T,P,R,C,O,I,A,F=rs(as({$os:p,$os_version:_,$browser:fi(h,navigator.vendor,g,m),$device:mi(h),$device_type:(T=h,P=y,A=mi(T),A===bt||A===yt||"Kobo"===A||"Kindle Fire"===A||A===Yt?mt:A===Ut||A===Bt||A===jt||A===Gt?"Console":A===xt?"Wearable":A?pt:"Android"===(null==P?void 0:P.userAgentDataPlatform)&&(null!==(R=null==P?void 0:P.maxTouchPoints)&&void 0!==R?R:0)>0?600>Math.min(null!==(C=null==P?void 0:P.screenWidth)&&void 0!==C?C:0,null!==(O=null==P?void 0:P.screenHeight)&&void 0!==O?O:0)/(null!==(I=null==P?void 0:P.devicePixelRatio)&&void 0!==I?I:1)?pt:mt:"Desktop"),$timezone:ho(),$timezone_offset:uo()}),{$current_url:Wn(n?xi(null==s?void 0:s.href):null==s?void 0:s.href,v,Zn),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:h.length>1e3?h.substring(0,997)+"...":h,$browser_version:_i(h,navigator.vendor,g,m),$browser_language:so(),$browser_language_prefix:(k=so(),"string"==typeof k?k.split("-")[0]:void 0),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return c.SDK_DIST_CHANNEL&&(F.$sdk_dist_channel=c.SDK_DIST_CHANNEL),F}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var p=this.sessionManager.checkAndGetSessionAndWindowId(a,n.getTime(),!0),g=p.windowId;u.$session_id=p.sessionId,u.$window_id=g}this.sessionPropsManager&&rs(u,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&rs(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=null==(m=this.nl)?void 0:m.length}catch(t){u.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===Qa&&(u.$lib_custom_api_host=this.config.api_host),v=i!==Qr||a?i!==Xr||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,o),u=rs(u,v),i===Qr&&r&&(u.title=r.title),!K(l)){var y=n.getTime()-l;u.$duration=parseFloat((y/1e3).toFixed(3))}h&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?"bot":"browser");var b=this.persistence.properties(),w=this.sessionPersistence.properties();es(["$referrer","$referring_domain"],(t=>{t in b&&delete w[t]}));var x={};if(this.Zo.length>0)for(var E of this.Zo.slice())try{rs(x,E())}catch(t){Ie.error("Failed to produce browser extension event properties",t)}(u=rs({},f,b,w,_({},x,u))).$is_identified=this._isIdentified(),H(this.config.property_denylist)?es(this.config.property_denylist,(function(t){delete u[t]})):Ie.error(bl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(Ie.error(yl),u=S(u,i));var k=this.xl();return u.$process_person_profile=k,k&&!a&&this.Cl("_calculate_event_properties"),u}wl(t,i,e){var r;if(void 0===i&&(i=!0),void 0===e&&(e=!1),!this.persistence||!this.xl())return t;if(this.Wo&&!e)return t;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=rs({},s,n||{},t||{}),a=this.config.sanitize_properties;return a&&(Ie.error(yl),o=a(o,"$set_once")),i&&(this.Wo=!0),G(o)?void 0:o}register(t,i){var e;null==(e=this.persistence)||e.register(t,i)}register_once(t,i,e){var r;null==(r=this.persistence)||r.register_once(t,i,e)}register_for_session(t){var i,e;null==(i=this.persistence)||i.syncCookieProperties(),this.kl(),null==(e=this.sessionPersistence)||e.register(t),Object.keys(t).forEach((t=>this.Vo.add(t))),this.Sl()}unregister(t){var i;null==(i=this.persistence)||i.unregister(t)}unregister_for_session(t){var i;null==(i=this.sessionPersistence)||i.unregister(t),this.Vo.delete(t),this.Sl()}Tl(t,i){this.register({[t]:i})}sl(){this.Vo.forEach((t=>{var i;null==(i=this.sessionPersistence)||i.unregister(t)})),this.Vo.clear(),this.Sl()}Sl(){var t;if(this.Go)if("memory"===this.config.persistence||null!=(t=this.sessionPersistence)&&t.Js||!Ls.Hr())Ls.Wr(this.Go);else{var i=[];this.Vo.forEach((t=>i.push(t))),i.length>0?Ls.Ur(this.Go,i):Ls.Wr(this.Go)}}getFeatureFlag(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,r;return null!==(e=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,i,e){var r;null==(r=this.featureFlags)||r.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i,e){var r;return void 0===i&&(i=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.Do.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:ml}),()=>{})}onSessionId(t){var i,e;return null!==(i=null==(e=this.sessionManager)?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:ml})}getActiveMatchingSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:ml})}renderSurvey(t,i){var e;null==(e=this.surveys)||e.renderSurvey(t,i)}displaySurvey(t,i){var e;void 0===i&&(i=ol),null==(e=this.surveys)||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null==(i=this.surveys)||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null==(e=this.surveys)?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:ml}}canRenderSurveyAsync(t,i){var e,r;return void 0===i&&(i=!1),null!==(e=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:ml})}Ml(t){return!t||Y(t)?(Ie.critical("Unique user id has not been set in posthog.identify"),!1):t===Lr?(Ie.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(Ie.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return Ie.uninitializedWarning("posthog.identify");if(Z(t)&&(t=t.toString(),Ie.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Ml(t)&&this.Cl("posthog.identify")){this.Ho();var r=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,n=this.kl(!1),o=this.persistence.Xs(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:t}),this.get_property(Be)||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),t!==l&&t!==this.get_property(qe)&&(this.unregister(qe),this.register({distinct_id:t}));var h,u=(this.persistence.get_property(Or)||Wr)===Wr,d=t!==l,v=!d&&u;if(d&&u)this.persistence.set_property(Or,Gr),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.ta(),this.capture(Zr,{distinct_id:t,$anon_distinct_id:l},{$set:i||{},$set_once:e||{}}),this.Yo=Ya(t,i,e),null==(h=this.featureFlags)||h.setAnonymousDistinctId(l);else if(v){this.persistence.set_property(Or,Gr);var c=i||{},f=e||{};this.setPersonPropertiesForFlags({$set:c,$set_once:f},!1),this.config.cookieWinsOnConflict&&this.persistence.ta(),this.capture("$set",{$set:c,$set_once:f}),this.Yo=Ya(t,i,e)}else(i||e)&&this.setPersonProperties(i,e);d||s||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister($r)):v&&(i||e)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.ra(a)}}}setPersonProperties(t,i){if((t||i)&&this.Cl("posthog.setPersonProperties")){var e=Ya(this.get_distinct_id(),t,i);this.Yo!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}}),this.Yo=e):Ie.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var i,e=(H(t)?t:[t]).filter((t=>J(t)&&t.length>0));0!==e.length&&this.Cl("posthog.unsetPersonProperties")&&(null==(i=this.featureFlags)||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.Yo=null)}group(t,i,e){var r;if(t&&i){null==(r=this.persistence)||r.syncCookieProperties(),this.kl();var s=this.getGroups(),n=s[t]!==i;if(n&&this.resetGroupPropertiesForFlags(t),this.register({$groups:_({},s,{[t]:i})}),n||e){var o={$group_type:t,$group_key:i};e&&(o.$group_set=e),this.capture(ts,o)}e&&this.setGroupPropertiesForFlags({[t]:e}),n&&!e&&this.reloadFeatureFlags()}else Ie.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),null==(e=this.featureFlags)||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),this.Cl("posthog.setGroupPropertiesForFlags")&&(null==(e=this.featureFlags)||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null==(i=this.featureFlags)||i.resetGroupPropertiesForFlags(t)}reset(t){var i=it(t)?t:null==t?void 0:t.resetDeviceID,e=it(t)||null==t?void 0:t.bootstrap;this.El(i,!1,e)}El(t,i,e){var r,s,n;if(void 0===i&&(i=!1),Ie.info("reset"),!this.__loaded)return Ie.uninitializedWarning("posthog.reset");var o=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null==(r=this.tl)?void 0:r.bootstrap)||{},null==(s=this.featureFlags)||null==s.updateConfig||s.updateConfig(this.config,this.xa());var a=this.get_property(Be),l=this.get_property(ze),h=this.get_property(ir),u=this.is_capturing();this.consent.reset(),i||!u||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.");var d=null==(n=this.persistence)||null==n.Xs?void 0:n.Xs(),v=!1;try{var c,f,p,g,m,y,b,w,x,E,S,k,T;if(null==(c=this.persistence)||c.clear(),null==(f=this.sessionPersistence)||f.clear(),this.Vo.clear(),this.Sl(),K(h)||null==(E=this.persistence)||E.register({[ir]:h}),null==(p=this.surveys)||p.reset(),null==(g=this.featureFlags)||g.reset(),null==(m=this.conversations)||m.reset(),null==(y=this.logs)||y.reset(),null==(b=this.metrics)||b.reset(),null==(w=this.persistence)||w.set_property(Or,Wr),null==(x=this.sessionManager)||x.resetSessionId(),this.Yo=null,this.config.cookieless_mode===Vr)this.register_once({distinct_id:Lr,$device_id:null},"");else{var P=this.config.get_device_id(ms());this.register_once({distinct_id:P,$device_id:t?P:a},""),t||K(l)||this.register({[ze]:l})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(void 0===e.distinctID||this.Bo()||(null==(T=this.persistence)||T.set_property(Or,e.isIdentifiedID?Gr:Wr),this.register({distinct_id:e.distinctID})),null==(S=this.featureFlags)||S.initialize(),!(K(o)||null!=(k=this.sessionManager)&&k.setBootstrapSessionId(o,!0))){var R=_({},e);delete R.sessionID,this.config.bootstrap=R}delete this.config.identity_distinct_id,delete this.config.identity_hash,v=!0}finally{var C;d&&(null==(C=this.persistence)||null==C.ra||C.ra(v))}this.reloadFeatureFlags()}shutdown(t){var i=this;return p((function*(){var t,e,r,s,n;if(i.__loaded){i.dl().dispose(),null==(t=i.sessionRecording)||t.dispose(),null==(e=i.logs)||e.flushLogs("sendBeacon"),null==(r=i.metrics)||r.flush("sendBeacon"),null==(s=i.il)||s.unload(),null==(n=i.nl)||n.unload();try{var o;null==(o=i.featureFlags)||o.destroy()}catch(t){Ie.error("Error while destroying feature flags",t)}}else Ie.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,i){var e;this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null==(e=this.conversations)||e.Il()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(t=this.conversations)||t.Rl()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var i=this.sessionManager.checkAndGetSessionAndWindowId(!0),e=i.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i.sessionId);if(null!=t&&t.withTimestamp&&e){var s,n=null!==(s=t.timestampLookBack)&&void 0!==s?s:10;if(!e)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-e)/1e3)-n,0)}return r}alias(t,i){return t===this.get_property(Ue)?(Ie.critical("Attempting to create alias for existing People user - aborting."),-2):this.Cl("posthog.alias")?(K(i)&&(i=this.get_distinct_id()),t!==i?(this.Tl(qe,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(Ie.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var i=_({},this.config);if(W(t)){var e,r,s,n,o,a,l,h,u,d,v,f;rs(this.config,$l(t));var p=this.Uo();null==(e=this.persistence)||e.update_config(this.config,i,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new go(_({},this.config,{persistence:"sessionStorage"}),p,!1);var g,m=this.Xo(this.config.debug);it(m)&&(this.config.debug=m),it(this.config.debug)&&(this.config.debug?(c.DEBUG=!0,Ss.Hr()&&Ss.Ur("ph_debug",!0),Ie.info("set_config",{config:t,oldConfig:i,newConfig:_({},this.config)})):(c.DEBUG=!1,Ss.Hr()&&Ss.Wr("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this.xa()),null==(s=this.exceptionObserver)||s.onConfigChange(),null==(n=this.exceptions)||n.onConfigChange(),null==(o=this.sessionRecording)||o.startIfEnabledOrStop(),null==(a=this.tracingHeaders)||a.startIfEnabledOrStop(),null==(l=this.autocapture)||l.startIfEnabled(),null==(h=this.heatmaps)||h.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null==(g=this.historyAutocapture)||g.startIfEnabledOrStop()),null==(u=this.exceptionObserver)||u.startIfEnabledOrStop(),null==(d=this.deadClicksAutocapture)||d.startIfEnabledOrStop(),null==(v=this.surveys)||v.loadIfEnabled(),this.zo(),null==(f=this.externalIntegrations)||f.startIfEnabledOrStop()}}_overrideSDKInfo(t,i){c.LIB_NAME=t,c.LIB_VERSION=i}startSessionRecording(t){var i,e,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(i=this.sessionManager)||i.checkAndGetSessionAndWindowId(),a.sampling&&(null==(e=this.sessionRecording)||e.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,i){if(this.exceptions){var e=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:e});return this.exceptions.sendExceptionEvent(_({},r,i))}}addExceptionStep(t,i){var e;null==(e=this.exceptions)||e.addExceptionStep(t,i)}captureLog(t){var i;null==(i=this.logs)||i.captureLog(t)}get logger(){var t,i;return null!==(t=null==(i=this.logs)?void 0:i.logger)&&void 0!==t?t:Rl.Pl}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null==(e=this.toolbar)?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null==(i=this.persistence)?void 0:i.props[t]}getSessionProperty(t){var i;return null==(i=this.sessionPersistence)?void 0:i.props[t]}toString(){var t,i=null!==(t=this.config.name)&&void 0!==t?t:xl;return i!==xl&&(i=xl+"."+i),i}_isIdentified(){var t,i;return(null==(t=this.persistence)?void 0:t.get_property(Or))===Gr||(null==(i=this.sessionPersistence)?void 0:i.get_property(Or))===Gr}xl(){var t,i;return!("never"===this.config.person_profiles||this.config.person_profiles===Kr&&!this._isIdentified()&&G(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t[qe])&&(null==(i=this.persistence)||null==(i=i.props)||!i[Nr]))}bl(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.xl()||this.Cl("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Cl("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Cl(t){return"never"===this.config.person_profiles?(Ie.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Tl(Nr,!0),!0)}Uo(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Hr)}zo(){var t,i,e,r,s,n=this.Uo();return this.is_capturing()||null==(e=this.logs)||e.Al(),(null==(t=this.persistence)?void 0:t.Js)!==n&&(null==(r=this.persistence)||r.set_disabled(n)),(null==(i=this.sessionPersistence)?void 0:i.Js)!==n&&(null==(s=this.sessionPersistence)||s.set_disabled(n)),n&&(this.Vo.clear(),this.Sl()),n}opt_in_capturing(t){var i;if(this.config.cookieless_mode!==Vr){if(this.Bo()){var e,r,s,n,o;this.El(!0,!0),null==(e=this.sessionManager)||e.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new za(this),this.pageViewManager=new Ln(this),this.persistence&&(this.sessionPropsManager=new La(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=Rl.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this.jo(this.sessionRecording,new l(this)),this.Lo&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this.Lo)))}var h,u;this.consent.optInOut(!0),this.zo(),this.gl(),null==(i=this.sessionRecording)||i.startIfEnabledOrStop(),this.config.cookieless_mode==Hr&&(null==(h=this.surveys)||h.loadIfEnabled()),(K(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(u=null==t?void 0:t.captureEventName)&&void 0!==u?u:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.ml()}else Ie.warn(gl)}opt_out_capturing(){var t,i,e;this.config.cookieless_mode!==Vr?(this.config.cookieless_mode===Hr&&this.consent.isOptedIn()&&this.El(!0,!0),this.consent.optInOut(!1),this.zo(),this.config.cookieless_mode===Hr&&(this.register({distinct_id:Lr,$device_id:null}),null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,null==(i=this.sessionManager)||i.destroy(),null==(e=this.pageViewManager)||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.ml(),this.gl())):Ie.warn(gl)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Vr||(this.config.cookieless_mode===Hr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.zo()}_is_bot(){return e?qa(e,this.config.custom_blocked_useragents):void 0}ml(){r&&("visible"===r.visibilityState?this.Qo||(this.Qo=!0,this.capture(Qr,{title:r.title},{send_instantly:!0}),this.Jo&&(r.removeEventListener(Jr,this.Jo),this.Jo=null)):this.Jo||(this.Jo=this.ml.bind(this),us(r,Jr,this.Jo)))}debug(i){!1===i?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}xa(){var t=this.tl||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ie.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(t,i,e,r,s){var n=i in t&&!X(t[i]),o=e in t&&!X(t[e]);return n?t[i]:!!o&&(s&&s.warn("Config field '"+e+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,Ie)}Rn(t){var i;if(X(this.config.before_send))return t;var e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(st),r=H(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r)try{if(s=n(s),X(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return rt(t.event)?Ie.warn(o+". This can cause unexpected behavior."):Ie.info(o),null}s.properties&&!G(s.properties)||Ie.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(i){return Ie.error("Error in beforeSend function for event '"+t.event+"':",i),null}for(var a of e)if(s.properties&&X(s.properties[a]))return Ie.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.Ps)?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Xo(t){var i=it(t)&&!t,e=Ss.Hr()&&"true"===Ss.$r("ph_debug");return!i&&(!!e||t)}}Rl.__defaultExtensionClasses={},Rl.Pl=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(var e=0;i.length>e;e++)t.prototype[i[e]]=os(t.prototype[i[e]])}(Rl,["identify"]);class Cl{constructor(t){this.disabled=!1===t;var i=W(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}}var Ol="$copy_autocapture",Il=Ae("[AutoCapture]");function Al(t,i){return i.length>t?i.slice(0,t)+"...":i}function Fl(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Ws(i));return i}function Ml(i,e){var r,s,n=e.e,o=e.maskAllElementAttributes,a=e.maskAllText,l=e.elementAttributeIgnoreList,h=e.elementsChainAsString,u=e.disableCaptureUrlHashes;if(!Ws(i))return{props:{}};for(var d=[i],v=new Set([i]),c=i;c.parentNode&&!Gs(c,"body")&&Ys>d.length;)if(Js(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!Ws(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p,g,m=[],y={},b=!1,w=!1;if(es(d,(t=>{var i=_n(t);if(Gs(t,"a")){var e=t.getAttribute("href");b=!!(i&&e&&kn(e))&&(u?xi(e):e)}N(Zs(t),"ph-no-capture")&&(w=!0),m.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};sn.indexOf(n)>-1&&!e&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Al(1024,Tn(t)):Al(1024,en(t)));var a=Zs(t);a.length>0&&(o.classes=a.filter((function(t){return""!==t}))),es(t.attributes,(function(e){var n;if((!gn(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&kn(e.value)&&(!J(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=e.value;"class"===e.name&&(a=Qs(a).join(" ")),o["attr__"+e.name]=Al(1024,"href"===e.name&&s?xi(a):a)}}));for(var l=1,h=1,u=t;u=Fl(u);)l++,u.tagName===t.tagName&&h++;return o.nth_child=l,o.nth_of_type=h,o}(t,o,a,l,u));var r=function(t){if(!_n(t))return{};var i={};return es(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&kn(r)&&(i[e]=r)}})),i}(t);rs(y,r)})),w)return{props:{},explicitNoCapture:w};if(a||(m[0].$el_text=Gs(i,"a")||Gs(i,"button")?Tn(i):en(i)),b){var x,E;m[0].attr__href=b;var S=null==(x=Hn(b))?void 0:x.host,k=null==t||null==(E=t.location)?void 0:E.host;S&&k&&S!==k&&(p=b)}return{props:rs({$event_type:n.type,$ce_version:1},h?{}:{$elements:m},{$elements_chain:(g=m,function(t){return t.map((t=>{var i,e,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var n=_({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return ss(n).sort(((t,i)=>t[0].localeCompare(i[0]))).forEach((t=>{var i=t[1];return o[Pn(t[0].toString())]=Pn(i.toString())})),(r+=":")+ss(o).map((t=>t[0]+'="'+t[1]+'"')).join("")})).join(";")}(function(t){return t.map((t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:Rn(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return ss(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=m[0])&&r.$el_text?{$el_text:null==(s=m[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},y)}}class Dl{constructor(t){this.name="autocapture",this.ns=!1,this.ss=null,this.os=!1,this.ls=!1,this.zi={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.us=!1,this.hs=t,this.hs.refresh(this.zi),this.rageclicks=new Cl(this.zi.rageclick),this.ds=null}setup(t){this.vs(),this.cs=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.us?i.dispose():(this.fs=i,this.startIfEnabled())}dispose(){var t;this.us||(this.us=!0,this.cs=void 0,null==(t=this.fs)||t.dispose(),this.fs=void 0,this.ps())}gs(){return this.hs.refresh(this.zi),this.zi}vs(){var t,i;return this.gs(),this.zi.url_allowlist=null==(t=this.zi.url_allowlist)?void 0:t.map((t=>new RegExp(t))),this.zi.url_ignorelist=null==(i=this.zi.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),this.zi}ys(){if(this.isBrowserSupported()){if(t&&r){var i=this.bs=i=>{i=i||(null==t?void 0:t.event);try{this._s(i)}catch(t){Il.error("Failed to capture event",t)}};if(us(r,"submit",i,{capture:!0}),us(r,"change",i,{capture:!0}),us(r,"click",i,{capture:!0}),this.gs().capture_copied_text){var e=this.ws=i=>{i=i||(null==t?void 0:t.event);try{this._s(i,Ol)}catch(t){Il.error("Failed to capture clipboard event",t)}};us(r,"copy",e,{capture:!0}),us(r,"cut",e,{capture:!0}),us(r,"paste",e,{capture:!0})}}}else Il.info("Disabling Automatic Event Collection because this browser is not supported")}ps(){this.bs&&(null==r||r.removeEventListener("submit",this.bs,!0),null==r||r.removeEventListener("change",this.bs,!0),null==r||r.removeEventListener("click",this.bs,!0),this.bs=void 0),this.ws&&(null==r||r.removeEventListener("copy",this.ws,!0),null==r||r.removeEventListener("cut",this.ws,!0),null==r||r.removeEventListener("paste",this.ws,!0),this.ws=void 0),this.ns=!1}startIfEnabled(){!this.us&&this.cs&&this.isEnabled&&!this.ns&&(this.ys(),this.ns=!0)}onRemoteConfig(t){if(!this.us)if(this.os=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.ls=i.elementsChainAsString);var e,r=i.autocapture_opt_out;it(r)&&(null==(e=this.cs)||e.kv.set(Ve,r),this.ss=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.ds=t}getElementSelectors(t){var i,e=[];return null==(i=this.ds)||i.forEach((i=>{var s=null==r?void 0:r.querySelectorAll(i);null==s||s.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i;if(this.us)return!1;var e=null==(t=this.cs)?void 0:t.kv.get(Ve),r=this.ss,s=this.gs(),n=s.remoteRequestsDisabled&&!this.os;if(Q(r)&&!it(e)&&!n)return!1;var o=null!==(i=this.ss)&&void 0!==i?i:!!e;return!!s.enabled&&!o}_s(i,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var r=rn(i);Ks(r)&&(r=r.parentNode||null);var s,n=this.vs();"$autocapture"===e&&"click"===i.type&&i instanceof MouseEvent&&n.rageclick&&null!=(s=this.rageclicks)&&s.isRageClick(i.clientX,i.clientY,i.timeStamp||(new Date).getTime())&&cn(r,n.rageclick)&&this._s(i,"$rageclick");var o=e===Ol,a=o?_({},n,{dom_event_allowlist:void 0}):n;if(r&&function(i,e,r,s,n,o){var a;if(!t||fn(i))return!1;if(null!=r&&r.url_allowlist&&!Xs(r.url_allowlist,o))return!1;if(null!=r&&r.url_ignorelist&&Xs(r.url_ignorelist,o))return!1;if(null!=r&&r.dom_event_allowlist){var l=r.dom_event_allowlist;if(l&&!l.some((t=>e.type===t)))return!1}var h=pn(i,s),u=h.parentIsUsefulElement,d=h.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(K(e))return!0;var r,s=function(t){if(e.some((i=>t.tagName.toLowerCase()===i)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(d,r))return!1;if(!nn(d,null==r?void 0:r.css_selector_allowlist))return!1;if(nn(d,null!==(a=null==r?void 0:r.css_selector_ignorelist)&&void 0!==a?a:an))return!1;try{var v=t.getComputedStyle(i);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var c=i.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return u?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(sn.indexOf(c)>-1||"true"===i.getAttribute("contenteditable"))}}(r,i,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l,h=Ml(r,{e:i,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.ls,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),u=h.props;if(h.explicitNoCapture)return!1;var d=this.getElementSelectors(r);if(d&&d.length>0&&(u.$element_selectors=d),e===Ol){var v=i.type||"clipboard";if("paste"!==v){var c,f,p=null==t||null==(c=t.getSelection())?void 0:c.toString(),g=tn(p);if(!g)return!1;u.$selected_content=g,u.$clipboard_text_length=null!==(f=null==p?void 0:p.length)&&void 0!==f?f:0}u.$copy_type=v}return null==(l=this.cs)||l.capture(e,u).catch((t=>Il.error("Failed to capture event",t))),!0}}}isBrowserSupported(){return V(null==r?void 0:r.querySelectorAll)}}class Nl{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=W(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.xa(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}}var Ll=Ae("[ExceptionAutocapture]"),Ul=()=>{},jl=t=>{var i;if(V(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function Bl(t,i,e){try{if(!(i in t))return Ul;var r={next:t[i]},s=e((function(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];return r.next.apply(this,i)}));return V(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[i]=s,()=>{if(t[i]!==s)for(var e=t[i],n=jl(e);n;){if(n.next===s)return void(n.next=r.next);n=jl(e=n.next)}else t[i]=r.next}}catch(t){return Ul}}var zl=Ae("[TracingHeaders]"),ql=Ae("[Web Vitals]"),Hl=9e5,Vl=["CLS","FCP","INP","LCP"],Wl=["INP","LCP"],Gl=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Kl="disabled",Jl="lazy_loading",Yl="awaiting_config",Ql="missing_config";Ae("[SessionRecording]"),Ae("[SessionRecording]");var Xl="[SessionRecording]",Zl=Ae(Xl),th=Ae("[Heatmaps]");function ih(t){return W(t)&&"clientX"in t&&"clientY"in t&&Z(t.clientX)&&Z(t.clientY)}var eh=Ae("[Product Tours]"),rh=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(Xe))},sh=["$set_once","$set"],nh=Ae("[SiteApps]"),oh="Error while initializing PostHog app with config id ",ah=(t,i)=>null!=t&&t.then?t.then(i):i(t),lh="SDK is not enabled or survey functionality is not yet loaded",hh="Disabled. Not loading surveys.";class uh{constructor(t,i){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Fl=!1,this.Ol=[],this.Ll=null,this.Dl=null,this.us=!1,this.$l=new Set,this.onRemoteConfig=t=>{if(!this.us&&!this.zi.disableSurveys){if(!t.ok)return el.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(X(i))return el.warn("Flags not loaded yet. Not loading surveys.");this.Nl=it(i)?i:i.length>0,el.info("flags response received, isSurveysEnabled: "+this.Nl),this.loadIfEnabled()}},this.hs=t,this.ql=i}setup(t){if(!this.us)return this.jl=t,ah(t.kv.initialize(),(()=>{if(this.jl===t&&!this.us){this.jl=void 0,this.cs=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.us?i.dispose():(this.fs=i,this.loadIfEnabled())}}))}dispose(){var t,i,e;this.us||(this.us=!0,this.jl=void 0,this.cs=void 0,null==(t=this.fs)||t.dispose(),this.fs=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Ol=[],this.Ll=null,this.$l.forEach((t=>clearTimeout(t))),this.$l.clear())}get zi(){return this.hs.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith(rl)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this.us&&this.cs){var t=this.zi;if(!this._surveyManager)if(this.Fl)el.info("Already initializing surveys, skipping...");else if(t.disableSurveys)el.info(hh);else if(t.cookielessMode&&this.hs.isOptedOut())el.info("Not loading surveys in cookieless mode without consent.");else{var i=this.hs.getExtensions();if(i){if(!K(this.Nl)||t.advancedEnableSurveys){var e=this.Nl||t.advancedEnableSurveys;this.Fl=!0;try{var r=i.generateSurveys;if(r)return this.Bl(r,e),void(this.Fl=!1);var s=i.loadExternalDependency;if(!s)return this.Hl(qr),void(this.Fl=!1);s((t=>{try{if(this.us)return;var i=this.hs.getExtensions();t||null==i||!i.generateSurveys?this.Hl("Could not load surveys script",t):this.Bl(i.generateSurveys,e)}finally{this.Fl=!1}}))}catch(t){throw this.Fl=!1,this.Hl("Error initializing surveys",t),t}}}else el.error("PostHog Extensions not found.")}}}Bl(t,i){this.us||(this._surveyManager=t(i),this._surveyEventReceiver=this.hs.createEventReceiver(),el.info("Surveys loaded successfully"),this.Ul({isLoaded:!0}))}Hl(t,i){el.error(t,i),this.Ul({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ol.push(t),this._surveyManager&&this.Ul({isLoaded:!0}),()=>{this.Ol=this.Ol.filter((i=>i!==t))}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.cs)&&void 0!==e?e:this.ql;if(r&&!this.us){if(this.zi.disableSurveys)return el.info(hh),t([]);var s=r.kv.get(wr);if(s&&!i)return t(s,{isLoaded:!0}),void(this.zl()&&this.getSurveys((()=>{}),!0));if(this.Ll)this.Ll.then((i=>{this.us||t(i.surveys,i.context)})).catch((t=>el.error("Error in survey callback",t)));else{var n=this.Wl("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.zi.requestTimeoutMs}).then((t=>{try{return this.Vl(r,t)}catch(t){return el.error("Error processing surveys response",t),this.Vl(r,{statusCode:0,error:t})}}),(t=>this.Vl(r,{statusCode:0,error:t})));this.Ll=n;var o=()=>{this.Ll===n&&(this.Ll=null)};n.then((i=>{o(),this.us||t(i.surveys,i.context)}),o).catch((t=>el.error("Error in survey callback",t)))}}}Wl(t,i){var e=this.cs;return e?e.sendRequest(t,i):new Promise((t=>t({statusCode:0,error:new Error(lh)})))}Vl(t,i){if(this.us)return{surveys:[],context:{isLoaded:!1,error:lh}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?el.error(r):i.error||el.warn(r),this.Dl=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Dl=null;var s,n=i.json.surveys||[],o=n.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Va(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t))));return o.length>0&&(null==(s=this._surveyEventReceiver)||s.register(o)),t.kv.set({[wr]:n,[xr]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}zl(){return this.Gl()&&!this.Ll&&!this.Zl()}Gl(){var t,i,e=null==(t=null!==(i=this.cs)&&void 0!==i?i:this.ql)?void 0:t.kv.get(xr);return Z(e)&&Date.now()-e>3e5}Zl(){return Z(this.Dl)&&3e5>Date.now()-this.Dl}markSurveyAsSeen(t,i){var e,r={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};sl(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}Ul(t){for(var i of this.Ol)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){el.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!X(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);el.warn("init was not called")}Ql(t){var i=null;return this.getSurveys((e=>{var r;i=null!==(r=e.find((i=>i.id===t)))&&void 0!==r?r:null})),i}Jl(t){if(X(this._surveyManager))return{eligible:!1,reason:lh};var i="string"==typeof t?this.Ql(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Kl(t){if(X(this._surveyManager))return{eligible:!1,reason:lh};var i="string"==typeof t?this.Ql(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(X(this._surveyManager))return el.warn("init was not called"),{visible:!1,disabledReason:lh};var i=this.Kl(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return X(this._surveyManager)?(el.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:lh})):new Promise((e=>{this.getSurveys((i=>{var r,s=null!==(r=i.find((i=>i.id===t)))&&void 0!==r?r:null;if(s){var n=this.Kl(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var s;if(X(this._surveyManager))el.warn("init was not called");else{var n="string"==typeof t?this.Ql(t):t;if(null!=n&&n.id)if(nl.includes(n.type)){var o=null==r?void 0:r.querySelector(i);if(o)if(null!=(s=n.appearance)&&s.surveyPopupDelaySeconds){el.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout((()=>{var t,i;this.$l.delete(a),this.us||(el.info("Rendering survey "+n.id+" with delay of "+(null==(t=n.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(n,o,e),el.info("Survey "+n.id+" rendered"))}),1e3*n.appearance.surveyPopupDelaySeconds);this.$l.add(a)}else this._surveyManager.renderSurvey(n,o,e);else el.warn("Survey element not found")}else el.warn("Surveys of type "+n.type+" cannot be rendered in the app");else el.warn("Survey not found")}}displaySurvey(t,i){var e;if(X(this._surveyManager))el.warn("init was not called");else{var r=this.Ql(t);if(r){var s=r;if(null!=(e=r.appearance)&&e.surveyPopupDelaySeconds&&i.ignoreDelay&&(s=_({},r,{appearance:_({},r.appearance,{surveyPopupDelaySeconds:0})})),i.displayType!==Co.Popover&&i.initialResponses&&el.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var n=this.Jl(r);if(!n.eligible)return void el.warn("Survey is not eligible to be displayed: ",n.reason)}i.displayType!==Co.Inline?this._surveyManager.handlePopoverSurvey(s,i):this.renderSurvey(s,i.selector,i.properties)}else el.warn("Survey not found")}}cancelPendingSurvey(t){X(this._surveyManager)?el.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}function dh(t,i,e){if(X(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}class vh{constructor(t){this.Yl=new Set,this.Xl=new Set,this.tu=new Ua,this.eu=(t,i)=>this.iu(t,i)&&this.ru(t,i)&&this.nu(t,i)&&this.su(t,i),this.iu=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t}init(){var t,i;K(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.au=null==(i=this._instance)?void 0:i._addCaptureHook(((t,i)=>{this.on(t,i)})))}dispose(){var t;null==(t=this.au)||t.call(this),this.au=void 0,this.tu=new Ua}register(t){var i,e;if(!K(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i;this.Yl.add(t),null==(i=t.steps)||i.forEach((t=>{this.Xl.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Yl.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&r.add(t.selector)}))})),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Yl.clear(),this.Xl.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Xl.has(t)||this.Xl.has(i.event))&&this.Yl.forEach((t=>{this.ou(i,t)&&this.tu.emit("actionCaptured",t.name)}))}lu(t){this.onAction("actionCaptured",(i=>t(i)))}ou(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.eu(t,e))return!0;return!1}onAction(t,i){return this.tu.on(t,i)}ru(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!dh(r,i.url,i.url_matching||"contains"))return!1}return!0}nu(t,i){return!!this.uu(t,i)&&!!this.hu(t,i)&&!!this.du(t,i)}uu(t,i){var e;if(null==i||!i.href)return!0;var r=this.vu(t);if(r.length>0)return r.some((t=>dh(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&dh((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}hu(t,i){var e;if(null==i||!i.text)return!0;var r=this.vu(t);if(r.length>0)return r.some((t=>dh(t.text,i.text,i.text_matching||"exact")||dh(t.$el_text,i.text,i.text_matching||"exact")));var s,n,o,a=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!a&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!X(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(a),n=i.text,o=i.text_matching||"exact",s.some((t=>dh(t,n,o))))}du(t,i){var e,r;if(null==i||!i.selector)return!0;var s=null==t||null==(e=t.properties)?void 0:e.$element_selectors;if(null!=s&&s.includes(i.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&n)try{return new RegExp(i.selector_regex).test(n)}catch(t){return!1}return!1}vu(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}su(t,i){return null==i||!i.properties||0===i.properties.length||Ja(i.properties.reduce(((t,i)=>{var e=H(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class ch{constructor(t){var i;this.cu=[],this._instance=t,this.fu=new Map,this.pu=new Map,this.gu=new Map,this.mu=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId((t=>this.yu(t)))}bu(t){return!1}_u(){return null}wu(t){}ku(){}Su(t,i){return!!t&&Ja(t.propertyFilters,null==i?void 0:i.properties)}xu(t,i){var e=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach((i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}}))})),e}Cu(t,i,e){var r=(e===bo.Activation?this.fu:this.pu).get(t),s=[];return this.Tu((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find((i=>i.name===t));return this.Su(n,i)}))}register(t){this.Mu(t,!1)}replace(t){this.Mu(t,!0)}Mu(t,i){var e;K(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Eu(t,i),this.Iu(t,i))}Iu(t,i){var e=t.filter((t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length}));if(i&&this.gu.clear(),0!==e.length){this.Ru||(this.Ru=new vh(this._instance),this.Ru.init(),this.Ru.lu((t=>this.onAction(t))));var r=[];e.forEach((t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach((i=>{if(r.push(i),i.name){var e,s=null!==(e=this.gu.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.gu.set(i.name,s)}}))})),i?this.Ru.replace(r):this.Ru.register(r)}else{var s;i&&(null==(s=this.Ru)||s.replace([]))}}Pu(t,i){i.forEach(((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach((t=>{s.includes(t)||s.push(t)})),t.set(e,s)}))}Eu(t,i){var e,r,s=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0})),n=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0})),o=this.xu(t,bo.Activation),a=this.xu(t,bo.Cancellation);i?(this.fu=o,this.pu=a):(this.Pu(this.fu,o),this.Pu(this.pu,a)),(0!==s.length||0!==n.length)&&(null!==(e=this.au)&&void 0!==e||(this.au=null==(r=this._instance)?void 0:r._addCaptureHook(((t,i)=>{this.onEvent(t,i)}))))}onEvent(t,i){var e,r,s=this.Au(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.Fu(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Ou([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Lu(n),void this.Du([n])}if(this.pu.has(t)){var a=this.Cu(t,i,bo.Cancellation);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map((t=>t.id))}),this.Ou(a.map((t=>t.id))),a.forEach((t=>this.$u(t.id))))}if(this.fu.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.fu.get(t)});var l=this.Cu(t,i,bo.Activation);this.Nu(l.map((t=>t.id)))}}onAction(t){this.gu.has(t)&&this.Nu(this.gu.get(t)||[])}Nu(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.bu(s)?this.Lu(s)&&this.qu(s):r.push(s);r.length>0&&(this.cu=[...new Set([...this.cu,...r])]),this.Au().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Lu(t){this.cu=this.cu.filter((i=>i!==t));var i=this.ju();return!i.includes(t)&&(this.Bu([...i,t]),this.Hu(),!0)}Ou(t){var i=new Set(t);this.cu=this.cu.filter((t=>!i.has(t)));var e=this.Uu(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.Bu(r),0===r.length&&this.zu()),this.Du(t)}Wu(){var t,i=this._u();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}qu(t){if(this._u()){var i=this.Wu();this.wu(_({},i,{[t]:Date.now()}))}}Du(t){if(this._u()){var i=this.Wu(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],o=s[1];t.includes(n)?r=!0:e[n]=o}r&&(G(e)?this.ku():this.wu(e))}}Vu(){this._u()&&this.ku()}getActivationTimestamp(t){if(this.ju().includes(t)){var i=this.Wu()[t];return Z(i)?i:void 0}}Uu(){var t,i=this.Gu();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}ju(){var t,i,e=this.Uu();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Zu()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Hu(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Qu(i)}zu(){this.Ju()}yu(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Zu()];if(e&&e!==t){var r=this.Uu(),s=this.Wu();r.length>0&&(this.Bu([]),r.filter((t=>Z(s[t]))).forEach((t=>this.$u(t)))),this.zu(),this.Vu()}}getActivatedIds(){return[...new Set([...this.ju(),...this.cu])].filter((t=>!this.Ku(t)))}dispose(){var t,i,e;null==(t=this.mu)||t.call(this),this.mu=void 0,null==(i=this.au)||i.call(this),this.au=void 0,null==(e=this.Ru)||e.dispose(),this.Ru=void 0}reset(){this.cu=[],this.Uu().length>0&&this.Bu([]),this.zu(),this.Vu()}getEventToItemsMap(){return this.fu}Yu(){return this.Ru}}class fh extends ch{constructor(t){super(t)}Gu(){return Er}Zu(){return Sr}_u(){return kr}wu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[kr]:t})}ku(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(kr)}bu(t){var i,e;this.Tu((i=>{e=i.find((i=>i.id===t))}));var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return Z(r)&&r>0}Xu(){return Po.SHOWN}Tu(t){var i;null==(i=this._instance)||i.getSurveys(t)}$u(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Au(){return el}Bu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Er]:t})}Qu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Sr]:t})}Ju(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Sr)}Ku(){return!1}Fu(t,i){var e;this.Tu((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return Va(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===Po.SHOWN?"consume":"ignore":t===Po.SHOWN?"persist":t===Po.DISMISSED||t===Po.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class ph{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);K(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach((t=>this._instance.unregister(t))):this._instance.unregister(t)}}class _h{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=null==v?void 0:v.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new fh(this._instance)}}var gh=null!=t&&t.location?Gn(t.location.hash,"__posthog")||Gn(location.hash,"state"):null,mh="_postHogToolbarParams",yh=Ae("[Toolbar]"),bh=Ae("[FeatureFlags]");class wh{constructor(t,i){void 0===i&&(i=!1),this.th=!1,this.update(t,i)}update(t,i){this.eh=((t,i)=>{var e,r,s,n,o;return{bootstrap:{featureFlags:null==(e=t.bootstrap)?void 0:e.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(s=t.remote_config_refresh_interval_ms)&&void 0!==s?s:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(o=t.evaluation_contexts)&&void 0!==o?o:t.evaluation_environments)&&void 0!==n?n:[],flagKeys:H(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.th||(bh.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.th=!0),K(t.flag_keys)||H(t.flag_keys)||bh.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.eh}}var xh=Ae("[FeatureFlags]"),Eh=Ae("[FeatureFlags]",{debugEnabled:!0}),Sh="\" failed. Feature flags didn't load in time.",kh="connection_error",Th=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},$h=t=>{var i={};for(var e of ss(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},Ph=Ae("[Error tracking]"),Rh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],Ch=["__firefox__","__gCrWeb"],Oh="Refusing to render web experiment since the viewer is a likely bot",Ih={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Wa(i,t),not_regex:(t,i)=>!Wa(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class Ah{get zi(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{Ah.ih("retrieved web experiments from the server"),i.rh=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.rh&&(Ah.ih("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.rh)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);J(r)&&t.variants[r]&&i.nh(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Ah.sh(n,i._instance)&&i.nh(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Ah.ih(Oh);else if(!this.zi.disable_web_experiments){if(X(this.rh))return this.rh=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ah.ih("applying feature flags",t),t.forEach((t=>{var i;if(this.rh&&null!=(i=this.rh)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.rh)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.nh(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Ah.getWindowLocation();if(null!=t&&t.search){var i=Vn(null==t?void 0:t.search,"__experiment_id"),e=Vn(null==t?void 0:t.search,"__experiment_variant");i&&e&&(Ah.ih("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.ah(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.zi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.zi.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.zi.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}ah(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(Ah.ih("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.nh(r[0].name,i,r[0].variants[i].transforms))}static sh(t,i){return!X(t.conditions)&&Ah.oh(t,i)&&Ah.lh(t)}static oh(t,i){var e;if(X(t.conditions)||X(null==(e=t.conditions)?void 0:e.url))return!0;var r=Ah.getWindowLocation();if(r){var s,n,o,a=js(i,r.href);return null==(s=t.conditions)||!s.url||Ih[null!==(n=null==(o=t.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,a)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static lh(t){var i;if(X(t.conditions)||X(null==(i=t.conditions)?void 0:i.utm))return!0;var e=io();if(e.utm_source){var r,s,n,o,a,l,h,u,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==e.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==e.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(h=t.conditions)||null==(h=h.utm)||!h.utm_term||(null==(u=t.conditions)||null==(u=u.utm)?void 0:u.utm_term)==e.utm_term;return d&&c&&f&&v}return!1}static ih(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];Ie.info("[WebExperiments] "+t,e)}nh(t,i,e){this._is_bot()?Ah.ih(Oh):"control"!==i?e.forEach((e=>{if(e.selector){var r;Ah.ih("applying transform of variant "+i+" for experiment "+t+" ",e);var s=null==(r=document)?void 0:r.querySelectorAll(e.selector);null==s||s.forEach((t=>{var i=t;e.html&&(i.innerHTML=e.html),e.css&&i.setAttribute("style",e.css)}))}})):Ah.ih("Control variants leave the page unmodified.")}_is_bot(){return e&&this._instance?qa(e,this.zi.custom_blocked_useragents):void 0}}var Fh=Ae("[Conversations]"),Mh="Conversations not available yet.";function Dh(t,i){var e,r,s,n,o,a,l,h=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,d=null!=i&&i.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,v=K(d)?Math.max(u,2048):Math.max(u,d),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==c?void 0:c["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==n?n:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(a=null==c?void 0:c["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:u,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Nh=["debug","log","warn","error","info"],Lh="console",Uh="__posthogHandledLogsRequestError",jh=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Uh]=!0,e},Bh=t=>!!t&&"object"==typeof t&&!0===t[Uh],zh={featureFlags:class{constructor(t){this.name="featureFlags",this.uh=!1,this.featureFlagEventHandlers=[],this.I=xh,this.hh={},this.dh={},this.fh=[],this.ph=!1,this.gh=!1,this.mh=0,this.yh=!1,this.bh=!1,this._h=!1,this.wh=!1,this.kh=0,this.Et=()=>{var t=this.Sh();this.kh=0,t&&this.reloadFeatureFlags()},this.xh=()=>{var t,i=this.Ch;K(i)||this.zi.remoteRequestsDisabled||!r||"hidden"===r.visibilityState||Date.now()-(null!==(t=this.Th)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Mh())},this.At=()=>{"visible"===(null==r?void 0:r.visibilityState)&&this.xh()},"get"in t?this.hs=t:(this.Eh=new wh(t.config,t.xa()),this.hs=this.Eh)}updateConfig(t,i){var e;null==(e=this.Eh)||e.update(t,i),this.cs&&this.Ih()}setup(t){return this.jl=t,this.I=t.logger.createLogger("[FeatureFlags]"),ah(t.kv.initialize(),(()=>{this.jl===t&&(this.jl=void 0,this.cs=t,this.Rh(t))}))}Rh(i){if(this.cs===i)return t&&us(t,"online",this.Et),this.Ih(),this.Ph=i.registerDynamicEventProperties((()=>this.Ah()?this.hh:this.dh)),this.Fh(),this.initialize()}Ih(){var t=this.zi.refreshIntervalMs,i=!this.zi.remoteRequestsDisabled&&r&&!K(t)&&t>0?t:void 0;i!==this.Ch&&(this.Oh(),K(i)||(this.Ch=i,this.Mh(),null!=r&&r.addEventListener&&us(r,Jr,this.At)))}Mh(){K(this.Ch)||(K(this.Lh)||clearInterval(this.Lh),this.Th=Date.now(),this.Lh=setInterval(this.xh,this.Ch))}Oh(){K(this.Lh)||(clearInterval(this.Lh),this.Lh=void 0,null==r||null==r.removeEventListener||r.removeEventListener(Jr,this.At)),this.Ch=void 0,this.Th=void 0}destroy(){this.Dh()}dispose(){this.Dh()}Dh(){var i;this.Oh(),this.mh++,this.bh=!1,this.jl=void 0,this.cs&&(this.$h(),null==(i=this.Ph)||i.dispose(),this.Ph=void 0,this.fh=[],null==t||t.removeEventListener("online",this.Et),this.cs=void 0)}get zi(){return this.hs.get()}Nh(t){var i;return null==(i=this.cs)?void 0:i.kv.get(t)}Ur(t){this.qh((()=>{var i;return null==(i=this.cs)?void 0:i.kv.set(t)}))}Wr(t){this.qh((()=>{var i;return null==(i=this.cs)?void 0:i.kv.remove(t)}))}qh(t){try{t()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}Fh(){var t={};for(var i of[ur,cr,fr,_r]){var e=this.Nh(i);K(e)||(t[i]=e)}this.hh=t;var r=_({},t),s=this.Nh(hr);if(s)for(var n of Object.entries(s))r["$feature/"+n[0]]=n[1];this.dh=r}Ah(){var t=this.zi.cacheTtlMs;if(!t||0>=t)return!1;var i=this.Nh(Cr);return"number"!=typeof i||Date.now()-i>t}jh(){return!!this.Ah()&&(this.wh||this.gh||(this.wh=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Bh(){var t=this.zi.evaluationContexts;return null!=t&&t.length?t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Hh(){var t=this.zi.flagKeys;if(!K(t))return t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),i}))}initialize(){var t,i,e=this.zi,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((t=>!!r[t])).reduce(((t,i)=>(t[i]=r[i]||!1,t)),{}),l=Object.keys(o).filter((t=>a[t])).reduce(((t,i)=>(t[i]=o[i],t)),{});return this.Uh({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,i,e){var r,s,n=null!=e&&e.merge&&null!==(r=this.Nh(hr))&&void 0!==r?r:{},o=null!=e&&e.merge&&null!==(s=this.Nh(cr))&&void 0!==s?s:{},a=_({},n,t),l=_({},o,i),h={};for(var u of Object.entries(a)){var d=u[0],v=u[1];h[d]={key:d,enabled:y(v),variant:b(v),reason:void 0,metadata:K(null==l?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.Uh({flags:h})}get hasLoadedFlags(){return this.ph}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Nh(vr),i=this.Nh(_r),e=this.Nh(gr);if(!e&&!i)return t||{};var r=rs({},t||{}),s=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(var n of s){var o,a,l=r[n],h=null==i?void 0:i[n],u=K(h)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!h,d=K(h)?null==l?void 0:l.variant:"string"==typeof h?h:void 0,v=null==e?void 0:e[n],c=_({},l,{enabled:u,variant:u?null!=d?d:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=_({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=c}return this.uh||(this.I.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:r}),this.uh=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map((e=>{var r=t[e];return{key:e,enabled:y(r),variant:b(r),payload:m(i[e])}}))}getFlagVariants(){var t=this.Nh(hr),i=this.Nh(_r);if(!i)return t||{};for(var e=rs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.uh||(this.I.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.uh=!0),e}getFlagPayloads(){var t=this.Nh(cr),i=this.Nh(gr);if(!i)return t||{};for(var e=rs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.uh||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.uh=!0),e}reloadFeatureFlags(){this.yh||this.zi.featureFlagsDisabled||this.Sh()||this.zh||(this.fh.slice().forEach((t=>{try{t()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}})),this.zh=setTimeout((()=>{this.Wh()}),5))}$h(){clearTimeout(this.zh),this.zh=void 0}onReloading(t){return this.fh.push(t),()=>{this.fh=this.fh.filter((i=>i!==t))}}ensureFlagsLoaded(){this.ph||this.gh||this.zh||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.yh=t}resetFlagCallReported(){this.Wr($r)}Wh(t){this.$h();var i=this.cs;if(i&&!this.zi.remoteRequestsDisabled&&!this.Sh())if(this.gh)this.bh=!0;else{var e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:_({},i.initialPersonProperties,this.Nh(mr)||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.Nh(yr),timezone:ho()};K(i.deviceId)||(e.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.zi.featureFlagsDisabled)&&(e.disable_flags=!0);var r=this.Bh();r.length&&(e.evaluation_contexts=r);var s=this.Hh();K(s)||(e.flag_keys=s);var n=this.zi.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.mh;this.gh=!0;var l=()=>{this.bh&&(this.bh=!1,this.Wh())},h=t=>{this.gh=!1,a===this.mh?(this.Ur({[Rr]:[kh]}),this.I.error("Feature flag request failed",t),l()):l()};try{i.sendRequest(o,{target:"flags",method:"POST",body:e,compression:this.zi.compression,sentAt:"body",timeoutMs:this.zi.requestTimeoutMs}).then((t=>{var i,r,s=null!==(i=t.json)&&void 0!==i?i:{},o=200!==t.statusCode;if(this.gh=!1,a===this.mh){if(this.Vh(t.statusCode),o||this.bh||(this.$anon_distinct_id=void 0),!e.disable_flags||this.bh){this._h=!o;var h=[];t.error?h.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?kh:"unknown_error"):200!==t.statusCode&&h.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");var u=!(null==(r=s.quotaLimited)||!r.includes("feature_flags"));u&&h.push("quota_limited"),this.Ur({[Rr]:h}),u?this.I.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."):e.disable_flags||this.Uh(s,o,{partialResponse:n}),l()}}else l()})).catch(h)}catch(t){h(t)}}}Sh(){return Kn(this.kh,3)}Vh(t){this.kh=Jn(t,this.kh,3,(()=>this.I.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this._h)if(this.ph||this.getFlags()&&this.getFlags().length>0){if(!this.jh()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+t+Sh)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this._h)if(this.ph||this.getFlags()&&this.getFlags().length>0){if(!this.jh()){var e,r=this.getFlagVariants(),s=t in r,n=r[t],o=this.getFlagPayloads()[t],a=String(n),l=this.Nh(fr)||void 0,h=this.Nh(Cr)||void 0,u=this.Nh($r)||{};if(this.zi.deduplicateCallsPerSession){var d,v=null==(d=this.cs)?void 0:d.session.sessionId,c=this.Nh(Pr);v&&v!==c&&(u={},e=v)}if(i.send_event||!("send_event"in i))if(t in u&&u[t].includes(a))e&&this.Ur({[$r]:u,[Pr]:e});else{var f,p,g,y,b,w,x,E,S,k,T,P;H(u[t])?u[t].push(a):u[t]=[a],this.Ur(_({[$r]:u},e?{[Pr]:e}:{}));var R=this.getFeatureFlagDetails(t),C=[...null!==(f=this.Nh(Rr))&&void 0!==f?f:[]];K(n)&&C.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:null!==(p=null==(g=this.zi.bootstrap)||null==(g=g.featureFlags)?void 0:g[t])&&void 0!==p?p:null,$feature_flag_bootstrapped_payload:null!==(y=null==(b=this.zi.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])&&void 0!==y?y:null,$used_bootstrap_value:!this._h};K(null==R||null==(w=R.metadata)?void 0:w.has_experiment)||(O.$feature_flag_has_experiment=R.metadata.has_experiment),K(null==R||null==(x=R.metadata)?void 0:x.version)||(O.$feature_flag_version=R.metadata.version);var I,A=null!==(E=null==R||null==(S=R.reason)?void 0:S.description)&&void 0!==E?E:null==R||null==(k=R.reason)?void 0:k.code;A&&(O.$feature_flag_reason=A),null!=R&&null!=(T=R.metadata)&&T.id&&(O.$feature_flag_id=R.metadata.id),K(null==R?void 0:R.original_variant)&&K(null==R?void 0:R.original_enabled)||(O.$feature_flag_original_response=K(R.original_variant)?R.original_enabled:R.original_variant),null!=R&&null!=(P=R.metadata)&&P.original_payload&&(O.$feature_flag_original_payload=null==R||null==(I=R.metadata)?void 0:I.original_payload),C.length&&(O.$feature_flag_error=C.join(",")),this.Gh(O)}else e&&this.Ur({[$r]:u,[Pr]:e});if(s)return{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:m(o)}}}else this.I.warn('getFeatureFlagResult for key "'+t+Sh)}Gh(t){try{var i;null==(i=this.cs)||i.capture("$feature_flag_called",t).catch((t=>{this.I.error("Failed to capture feature flag call",t)}))}catch(t){this.I.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Zh(t,i)}Zh(t,i){var e=this;return p((function*(){var r=e.cs;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e.Bh();n.length&&(s.evaluation_contexts=n);var o,a=e.Hh();K(a)||(s.flag_keys=a);try{var l,h=null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.zi.compression,sentAt:"body",timeoutMs:e.zi.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;o=(null==h?void 0:h[t])||void 0}catch(t){return void e.I.error("Remote config feature flag request failed",t)}try{i(o)}catch(t){e.I.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this._h)return i.defaultValue;if(!(this.ph||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+t+Sh),i.defaultValue;var e=this.getFeatureFlag(t,i);return K(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((i=>i!==t))}receivedFeatureFlags(t,i,e){this.Uh(t,i,e)}Uh(t,i,e){if(this.cs){this.ph=!0;var r=function(t,i,e,r,s,n){void 0===i&&(i={}),void 0===e&&(e={}),void 0===r&&(r={}),void 0===n&&(n=xh);var o=((t,i)=>{var e=t.flags;return e?_({},t,{featureFlags:Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),featureFlagPayloads:Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,n),a=o.flags,l=o.featureFlags,h=o.featureFlagPayloads;if(l){var u=t.requestId,d=t.evaluatedAt;if(H(l)){n.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var v={};if(l)for(var c=0;l.length>c;c++)v[l[c]]=!0;return{[ur]:l,[hr]:v,[pr]:!1}}var f=l,p=h,g=a;if(null!=s&&s.partialResponse)f=_({},i,f),p=_({},e,p),g=_({},r,g);else if(t.errorsWhileComputingFlags)if(a){var m=new Set(Object.keys(a).filter((t=>{var i;return!(null!=(i=a[t])&&i.failed)})));f=_({},i,Object.fromEntries(Object.entries(f).filter((t=>m.has(t[0]))))),p=_({},e,Object.fromEntries(Object.entries(p||{}).filter((t=>m.has(t[0]))))),g=_({},r,Object.fromEntries(Object.entries(g||{}).filter((t=>m.has(t[0])))))}else f=_({},i,f),p=_({},e,p),g=_({},r,g);return _({[ur]:Object.keys($h(f)),[hr]:f||{},[cr]:p||{},[vr]:g||{},[pr]:!0===t.minimalFlagCalledEvents},u?{[fr]:u}:{},d?{[Cr]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.I);r&&this.Ur(r),i||(this.wh=!1),this.Qh(i)}}override(t,i){void 0===i&&(i=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Jh(t)}Jh(t){if(this.cs){if(!1===t)return this.Wr([_r,gr]),this.Qh(),void Eh.info("All overrides cleared");if(H(t))return this.Ur({[_r]:Th(t)}),this.Qh(),void Eh.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.uh=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[_r]=H(s)?Th(s):s),n&&(r[gr]=n),Object.keys(r).length&&this.Ur(r),!1===s&&!1===n?this.Wr([_r,gr]):!1===s?this.Wr(_r):!1===n&&this.Wr(gr),this.Qh(),!1===s?Eh.info("Flag overrides cleared"):s&&Eh.info("Flag overrides set",{flags:s}),void(!1===n?Eh.info("Payload overrides cleared"):n&&Eh.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Ur({[_r]:t}),this.Qh(),void Eh.info("Flag overrides set",{flags:t});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.ph){var i=this.Kh(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.I.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var r=(this.Nh(dr)||[]).find((i=>i.flagKey===t)),s={["$feature_enrollment/"+t]:i},n={$feature_flag:t,$feature_enrollment:i,$set:s};r&&(n.$early_access_feature_name=r.name),e&&(n.$feature_enrollment_stage=e);var o=_({},this.getFlagVariants(),{[t]:i});this.Ur({[ur]:Object.keys($h(o)),[hr]:o,[mr]:_({},this.Nh(mr)||{},s)}),this.Qh();try{var a;null==(a=this.cs)||a.capture("$feature_enrollment_update",n).catch((t=>{this.I.error("Failed to capture early access feature enrollment",t)}))}catch(t){this.I.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.Nh(dr);!r||i?this.Yh(t,e):t(r)}Yh(t,i){var e=this;return p((function*(){var r=e.cs;if(r){var s,n=i?"&"+i.map((t=>"stage="+t)).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;e.Ur({[dr]:s=o.json.earlyAccessFeatures})}catch(t){return void e.I.error("Early access feature request failed",t)}try{t(s)}catch(t){e.I.error("Early access feature callback failed",t)}}}))()}Kh(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter((t=>i[t])),flagVariants:Object.keys(i).filter((t=>i[t])).reduce(((t,e)=>(t[e]=i[e],t)),{})}}Qh(t){this.Fh();var i=this.Kh(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.I.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Xh(t,i)}Xh(t,i){void 0===i&&(i=!0);var e=this.Nh(mr)||{},r=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,n={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in e||(n[o]=s[o]));this.Ur({[mr]:_({},e,n,r)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=_({},this.Nh(mr)||{});t.forEach((t=>{delete e[t]})),this.Ur({[mr]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Wr(mr),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=this.Nh(yr)||{},r=_({},e);for(var s of Object.keys(t))r[s]=_({},e[s],t[s]);this.Ur({[yr]:r}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.Nh(yr)||{};this.Ur({[yr]:_({},i,{[t]:{}})})}else this.Wr(yr)}reset(){this.mh++,this.bh=!1,this.hh={},this.dh={},this.ph=!1,this.yh=!1,this._h=!1,this.$anon_distinct_id=void 0,this.$h(),this.uh=!1,this.kh=0}}},qh={sessionRecording:class{get zi(){return this._instance.config}get Ja(){return this._instance.persistence}get started(){var t;return!(null==(t=this.td)||!t.isStarted)}get status(){var t,i;return this.ed===Yl||this.ed===Ql?this.ed:null!==(t=null==(i=this.td)?void 0:i.status)&&void 0!==t?t:this.ed}constructor(i){if(this._forceAllowLocalhostNetworkCapture=!1,this.ed=Kl,this.rd=void 0,this.nd=!1,this.St=(()=>{var i;if(null==r||!r.visibilityState||"visible"===r.visibilityState)return!0;var e=null==t||null==(i=t.performance)||null==i.getEntriesByType?void 0:i.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some((t=>"visible"===t.name))})(),this.At=()=>{var t;"visible"===(null==r?void 0:r.visibilityState)&&(this.St=!0,null==(t=this.td)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=i,!this._instance.sessionManager)throw Zl.error("started without valid sessionManager"),new Error(Xl+" started without valid sessionManager. This is a bug.");if(this.zi.cookieless_mode===Vr)throw new Error(Xl+' cannot be used with cookieless_mode="always"');null!=r&&r.addEventListener&&us(r,"visibilitychange",this.At)}initialize(){this.startIfEnabledOrStop()}dispose(){this.nd=!0,null==r||null==r.removeEventListener||r.removeEventListener("visibilitychange",this.At),this.stopRecording()}get sd(){var i,e=!(null==(i=this._instance.get_property(ir))||!i.enabled),r=!this.zi.disable_session_recording,s=this.zi.disable_session_recording||this._instance.consent.isOptedOut();return t&&e&&r&&!s}startIfEnabledOrStop(t){var i;if(!(this.nd||this.sd&&null!=(i=this.td)&&i.isStarted)){var e=!K(Object.assign)&&!K(Array.from);this.sd&&e?(this.ad(t),Zl.info("starting")):(this.ed=Kl,this.stopRecording())}}ad(t){var i,e,r;this.sd&&(this.ed!==Yl&&this.ed!==Ql&&(this.ed=Jl),null!=v&&null!=(i=v.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=v.__PosthogExtensions__)&&e.initSessionRecording?this.od(t):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.ld,(i=>{if(i)return this._instance.register_for_session({[zr]:!0}),Zl.error("could not load recorder",i);this.od(t)})))}stopRecording(){var t,i;null==(t=this.rd)||t.call(this),this.rd=void 0,null==(i=this.td)||i.stop()}ud(){var t,i;null==(t=this.rd)||t.call(this),this.rd=void 0,null==(i=this.td)||i.discard()}hd(){var t,i;null==(t=this.Ja)||t.unregister(lr),null==(i=this.Ja)||i.unregister(er)}dd(t,i){if(X(t))return null;var e,r=Z(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Zl.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}vd(t){if(this.Ja){var i,e,r=this.Ja,s=()=>{var i,e=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.dd(null==(i=this.zi.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),n=this.dd(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=s?s:n;X(o)&&this.hd();var a=null==e?void 0:e.minimumDurationMilliseconds;r.register({[ir]:_({cache_timestamp:Date.now(),enabled:!!e},e,{networkPayloadCapture:_({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:K(a)?null:a,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};s(),null==(i=this.rd)||i.call(this),this.rd=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(s)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.vd(i),void this.ud()):(this.vd(i),void this.startIfEnabledOrStop()):(this.ed===Yl&&(this.ed=Ql,Zl.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.td)&&e.log?this.td.log(t,i):Zl.warn("log called before recorder was ready")}get ld(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(ir);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}fd(){var t,i=this._instance.get_property(ir);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return Zl.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!X(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}od(t){var i,e,r;if(!this.nd){if(null==(i=v.__PosthogExtensions__)||!i.initSessionRecording)return Zl.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[zr]:!0});var s;if(this.td||(this.td=null==(s=v.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.St),this.td._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.fd()){if(this.ed===Ql||this.ed===Yl)return;return this.ed=Yl,Zl.info("persisted remote config is stale, requesting fresh config before starting"),void new No(this._instance).load()}this.ed=Jl,null==(e=(r=this.td).setDocumentWasEverVisible)||e.call(r,this.St),this.td.start(t)}}onRRwebEmit(t){var i;null==(i=this.td)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.td||null==(i=this.Ja)||i.register({[sr]:!0}),null==(t=this.td)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.td||null==(i=this.Ja)||i.register({[rr]:!0}),null==(t=this.td)||t.overrideSampling()}overrideTrigger(t){var i,e;this.td||null==(e=this.Ja)||e.register({["url"===t?nr:or]:!0}),null==(i=this.td)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.td)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.td)||!e.tryAddCustomEvent(t,i))}}},Hh={autocapture:class extends Dl{constructor(t){super(new Nl(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.pd=this.gd()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.md();return!!(t.path||t.search||this.yd(t))}startIfEnabled(){this.isEnabled&&(Ie.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.pd=this.gd(),this.startIfEnabled()}stop(){this.bd&&this.bd(),this.bd=void 0,this._d&&this._d(),this._d=void 0,Ie.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.wd("pushState"),this.wd("replaceState"),this.kd(),this.yd()&&this.Sd())}wd(i){var e;if(t&&(null==(e=t.history[i])||!e.__posthog_wrapped__)){var r=this;Bl(t.history,i,(t=>function(e,s,n){t.call(this,e,s,n),r.xd(i)}))}}gd(){var i=null==t?void 0:t.location;if(null!=i&&i.pathname)return{pathname:i.pathname,search:i.search,hash:i.hash}}md(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:W(t)?t:{}}yd(t){return void 0===t&&(t=this.md()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Cd(t){var i=this.md(),e=this.pd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.yd(i)&&t.hash!==e.hash))}xd(t){try{var i=this.gd();if(!i)return;this.Cd(i)&&this._instance.capture(Qr,{navigation_type:t}),this.pd=i}catch(i){Ie.error("Error capturing "+t+" pageview",i)}}kd(){if(!this.bd){var i=()=>{this.xd("popstate")};us(t,"popstate",i),this.bd=()=>{t&&t.removeEventListener("popstate",i)}}}Sd(){if(!this._d){var i=()=>{this.xd("hashchange")};us(t,"hashchange",i),this._d=()=>{t&&t.removeEventListener("hashchange",i)}}}},heatmaps:class{get zi(){return this.instance.config}constructor(t){var i;this.Td=!1,this.ns=!1,this.Md=null,this.instance=t,this.Td=!(null==(i=this.instance.persistence)||!i.props[We]),this.rageclicks=new Cl(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return W(this.zi.capture_heatmaps)&&this.zi.capture_heatmaps.flush_interval_milliseconds&&(t=this.zi.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return X(this.zi.capture_heatmaps)?X(this.zi.enable_heatmaps)?this.Td:this.zi.enable_heatmaps:!1!==this.zi.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ns)return;th.info("starting..."),this.Ed(),this.At()}else{var t;clearInterval(null!==(t=this.Md)&&void 0!==t?t:void 0),this.Id(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[We]:e}),this.Td=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.bt;return this.bt=void 0,t}Rd(t){ih(t.originalEvent)&&this.Ei(t.originalEvent,"deadclick")}At(){this.Md&&clearInterval(this.Md),this.Md="visible"===(null==r?void 0:r.visibilityState)?setInterval(this.ja.bind(this),this.flushIntervalMilliseconds):null}Ed(){t&&r&&(this.Pd=this.ja.bind(this),us(t,Yr,this.Pd),this.Ad=i=>this.Ei(i||(null==t?void 0:t.event)),us(r,"click",this.Ad,{capture:!0}),this.Fd=i=>this.Od(i||(null==t?void 0:t.event)),us(r,"mousemove",this.Fd,{capture:!0}),this.Ld=new An(this.instance,On,this.Rd.bind(this)),this.Ld.startIfEnabledOrStop(),this.Dd=this.At.bind(this),us(r,Jr,this.Dd),this.ns=!0)}Id(){var i;t&&r&&(this.Pd&&t.removeEventListener(Yr,this.Pd),this.Ad&&r.removeEventListener("click",this.Ad,{capture:!0}),this.Fd&&r.removeEventListener("mousemove",this.Fd,{capture:!0}),this.Dd&&r.removeEventListener(Jr,this.Dd),clearTimeout(this.$d),null==(i=this.Ld)||i.stop(),this.ns=!1)}Nd(i,e){var r=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(i,e,r){for(var s=i;s&&Ws(s)&&!Gs(s,"body");){if(s===r)return!1;var n=void 0;try{var o,a,l;n=null==(o=null!==(a=null==(l=s.ownerDocument)?void 0:l.defaultView)&&void 0!==a?a:t)?void 0:o.getComputedStyle(s).position}catch(t){return!1}if(N(e,n))return!0;s=on(s)}return!1}(rn(i),["fixed","sticky"],n);return{x:i.clientX+(o?0:s),y:i.clientY+(o?0:r),target_fixed:o,type:e}}Ei(t,i){var e;if(void 0===i&&(i="click"),!Vs(t.target)&&ih(t)){var r=this.Nd(t,i);null!=(e=this.rageclicks)&&e.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&cn(rn(t),this.instance.config.rageclick)&&this.Vn(_({},r,{type:"rageclick"})),this.Vn(r)}}Od(t){!Vs(t.target)&&ih(t)&&(clearTimeout(this.$d),this.$d=setTimeout((()=>{this.Vn(this.Nd(t,"mousemove"))}),500))}Vn(i){if(t){var e=this.zi.disable_capture_url_hashes?xi(t.location.href):t.location.href,r=this.zi.custom_personal_data_properties,s=this.zi.mask_personal_data_properties?[...Qn,...r||[]]:[],n=Wn(e,s,Zn);this.bt=this.bt||{},this.bt[n]||(this.bt[n]=[]),this.bt[n].push(i)}}ja(){this.bt&&!G(this.bt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:An,webVitalsAutocapture:class{constructor(t){var i;this.Td=!1,this.ns=!1,this.bt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.qd=()=>{clearTimeout(this.jd),this.jd=void 0,0!==this.bt.metrics.length&&(this._instance.capture("$web_vitals",_({$current_url:this.bt.url},this.bt.metrics.reduce(((t,i)=>_({},t,{["$web_vitals_"+i.name+"_event"]:_({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.bt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Bd=t=>{var i;if(this.bt=this.bt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},X(null==t?void 0:t.name)||X(null==t?void 0:t.value))ql.error("Invalid metric received",t);else{var e="string"==typeof t.navigationURL?t.navigationURL:void 0,r=this.Hd(e);if(!K(r)){var s=Z(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+r;if(!this.Ud||this.Ud>t.value){this.bt.navigationKey!==s&&(this.qd(),this.jd=setTimeout(this.qd,this.flushToCaptureTimeoutMs)),K(this.bt.navigationKey)&&(this.bt.navigationKey=s,this.bt.url=r),this.bt.firstMetricTimestamp=K(this.bt.firstMetricTimestamp)?Date.now():this.bt.firstMetricTimestamp;var n=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=_({},t,e?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});if(delete o.entries,W(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var a={};for(var l of Gl){var h="url"===l&&"string"==typeof t.attribution[l]?this.Hd(t.attribution[l]):t.attribution[l];K(h)||(a[l]=h)}o.attribution=a}else delete o.attribution;K(n)||(o.$session_id=n.sessionId,o.$window_id=n.windowId),this.bt.metrics.push(o),this.bt.metrics.length===this.allowedMetrics.length&&this.qd()}else ql.error("Ignoring metric with value >= "+this.Ud,t)}}},this.zd=()=>{if(!this.ns){var t,i,e,r,s=!1,n=v.__PosthogExtensions__,o=null==n?void 0:n.postHogWebVitalsCallbacksByFlavor,a=(null==o?void 0:o[this.Wd])||("web-vitals"===this.Wd&&K(o)?null==n?void 0:n.postHogWebVitalsCallbacks:void 0);if(!K(a)){var l=a.withoutAttribution,h=this.attributionMetrics;s=!K(l),t=h.indexOf("LCP")>-1?a.onLCP:(null==l?void 0:l.onLCP)||a.onLCP,i=h.indexOf("CLS")>-1?a.onCLS:(null==l?void 0:l.onCLS)||a.onCLS,e=h.indexOf("FCP")>-1?a.onFCP:(null==l?void 0:l.onFCP)||a.onFCP,r=h.indexOf("INP")>-1?a.onINP:(null==l?void 0:l.onINP)||a.onINP}if(t&&i&&e&&r){var u={reportSoftNavs:this.useSoftNavs},d=s&&this.attributionMetrics.indexOf("INP")>-1?_({},u,{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Bd.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Bd.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&e(this.Bd.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&r(this.Bd.bind(this),d),this.ns=!0}else ql.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Td=!(null==(i=this._instance.persistence)||!i.props[Ye]),this.startIfEnabled()}get Vd(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=W(this.Vd)?null==(t=this.Vd)?void 0:t.web_vitals_allowed_metrics:void 0;return X(e)?(null==(i=this._instance.persistence)?void 0:i.props[tr])||Vl:e}get flushToCaptureTimeoutMs(){return(W(this.Vd)?this.Vd.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=W(this.Vd)?this.Vd.web_vitals_attribution:void 0;return it(t)?t?Vl:[]:H(t)?t:Wl}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t=W(this.Vd)?this.Vd.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Ud(){var t=W(this.Vd)&&Z(this.Vd.__web_vitals_max_value)?this.Vd.__web_vitals_max_value:Hl;return t>0&&6e4>=t?Hl:t}get isEnabled(){var t=null==s?void 0:s.protocol;if("http:"!==t&&"https:"!==t)return ql.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=W(this.Vd)?this.Vd.web_vitals:it(this.Vd)?this.Vd:void 0;return it(i)?i:this.Td}startIfEnabled(){this.isEnabled&&!this.ns&&(ql.info("enabled, starting..."),this.Es(this.zd))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=W(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=W(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ye]:e}),this._instance.persistence.register({[tr]:r})),this.Td=e,this.startIfEnabled()}}}get Wd(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Es(t){var i=v.__PosthogExtensions__,e=this.Wd,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&K(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?ql.error("failed to load script",i):t()}))}Hd(i){var e=i||(null==t?void 0:t.location.href);if(e){var r=this._instance.config.disable_capture_url_hashes?xi(e):e,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Qn,...s||[]]:[];return Wn(r,n,Zn)}ql.error("Could not determine current URL")}}},Vh={exceptionObserver:class{constructor(i){var e;this.zd=()=>{var i;if(t&&this.isEnabled&&null!=(i=v.__PosthogExtensions__)&&i.errorWrappingFunctions){var e=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Gd&&this.zi.capture_unhandled_errors&&(this.Gd=e(this.captureException.bind(this))),!this.Zd&&this.zi.capture_unhandled_rejections&&(this.Zd=r(this.captureException.bind(this))),!this.Qd&&this.zi.capture_console_errors&&(this.Qd=s(this.captureException.bind(this)))}catch(t){Ll.error("failed to start",t),this.Jd()}}},this._instance=i,this.Kd=!(null==(e=this._instance.persistence)||!e.props[Ge]),this.oe=new ft(_({},function(t){var i,e,r,s;return void 0===t&&(t={}),{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,I:Ll})),this.zi=this.Yd(),this.startIfEnabledOrStop()}Yd(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return W(t)?i=_({},i,t):(K(t)?this.Kd:t)&&(i=_({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.zi.capture_console_errors||this.zi.capture_unhandled_errors||this.zi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ll.info("enabled"),this.Jd(),this.Es(this.zd)):this.Jd()}Es(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Ll.error("failed to load script",i);t()}))}Jd(){var t,i,e;null==(t=this.Gd)||t.call(this),this.Gd=void 0,null==(i=this.Zd)||i.call(this),this.Zd=void 0,null==(e=this.Qd)||e.call(this),this.Qd=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Kd=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ge]:this.Kd}),this.zi=this.Yd(),this.startIfEnabledOrStop())}}onConfigChange(){this.zi=this.Yd()}captureException(t){var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";this.oe.consumeRateLimit(s)?Ll.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var i,e;this.Xd=[],this.tv=new ie([new ce,new Ee,new pe,new fe,new we,new be,new ge,new xe],function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];return function(i,r){void 0===r&&(r=0);for(var s=[],n=i.split("\n"),o=r;n.length>o;o++){var a=n[o];if(1024>=a.length){var l=ve.test(a)?a.replace(ve,"$1"):a;if(!l.match(/\S*Error: /)){for(var h of e){var u=h(l,t);if(u){s.push(u);break}}if(s.length>=50)break}}}return function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map((t=>{return _({},t,{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||ee});var e}))}(s)}}("web:javascript",le,de)),this._instance=t,this.Xd=null!==(i=null==(e=this._instance.persistence)?void 0:e.get_property(Ke))&&void 0!==i?i:[],this.ev=Pe(this.iv()),this.rv=new Re(this.ev)}onConfigChange(){this.ev=Pe(this.iv()),this.rv.setConfig(this.ev)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Xd=n,this._instance.persistence&&this._instance.persistence.register({[Ke]:this.Xd,[Je]:o})}}}get nv(){var t,i=!!this._instance.get_property(Je),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.tv.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.ev.enabled)try{if(!J(t)||0===t.trim().length)return void Ph.warn("Ignoring exception step because message must be a non-empty string");var e=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce(((e,r)=>Te.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.sv(i)),r=e.sanitizedProperties,s=e.droppedKeys;s.length>0&&Ph.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.rv.add(_({[Se]:t,[ke]:(new Date).toISOString()},r))}catch(t){Ph.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.av(i)){if(this.ov(i))return this.lv("Exception dropped: matched a suppression rule"),void Ph.info("Skipping exception capture because a suppression rule matched");if(!this.nv&&this.uv(i))return this.lv("Exception dropped: thrown by a browser extension"),void Ph.info("Skipping exception capture because it was thrown by an extension");if(!this.nv&&this.hv(i))return this.lv("Exception dropped: thrown by an injected browser script"),void Ph.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.dv(i))return this.lv("Exception dropped: thrown by the PostHog SDK"),void Ph.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.ev.enabled&&X(t.$exception_steps)?this.vv(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",_l:!0});return s&&this.rv.clear(),s}catch(t){return Ph.error("Failed to capture exception event. Dropping this exception.",t),void this.rv.clear()}}catch(t){return void Ph.error("Failed to process exception event. Ignoring this exception.",t)}var n}vv(t){try{var i=this.rv.getAttachable();return 0===i.length?t:_({},t,{$exception_steps:i})}catch(i){return Ph.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}lv(t){this.ev.enabled&&this.rv.add({[Se]:t,[ke]:(new Date).toISOString()})}sv(t){return W(t)?_({},t):{}}iv(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}ov(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return J(e)&&e.length>0&&t.$exception_types.push(e),J(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Xd.some((t=>{var e=t.values.map((t=>{var e=Ka[t.operator],r=i[t.key];if(!e||!r)return!1;var s=H(t.value)?t.value:[t.value];return s.length>0&&e(s,r)}));return"OR"===t.type?e.some(Boolean):e.every(Boolean)}))}catch(t){return Ph.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}uv(t){return t.flatMap((t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]})).some((t=>{var i=t.filename;return!!i&&Rh.some((t=>i.startsWith(t)))}))}hv(t){return t.some((t=>{var i=t.value;return J(i)&&Ch.some((t=>i.includes(t)))}))}dv(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}av(t){return!X(t)&&H(t)}}},Wh=_({productTours:class{get Ja(){return this._instance.persistence}constructor(t){this.fv=null,this.pv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.Ja&&this.Ja.register({[Xe]:!!i.productTours}),!rh(this._instance))return!this.fv&&X(null==(e=this.Ja)?void 0:e.props[Tr])||eh.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.fv)||r.stop(),this.fv=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.fv&&rh(this._instance)&&this.Es((()=>this.gv()))}Es(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?eh.error("Could not load product tours script",i):t()}))}gv(){var t;!this.fv&&null!=(t=v.__PosthogExtensions__)&&t.generateProductTours&&(this.fv=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!H(this.pv)||i){var e=this.Ja;if(e){var r=e.props[Tr];if(H(r)&&!i)return this.pv=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(rh(this._instance)){var r=i.statusCode;if(200!==r||!i.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?i.error||eh.warn(s):eh.error(s),void t([],{isLoaded:!1,error:s})}var n=H(i.json.product_tours)?i.json.product_tours:[];this.pv=n,e&&e.register({[Tr]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.pv,{isLoaded:!0})}getActiveProductTours(t){X(this.fv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.fv.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.fv)||i.showTourById(t)}previewTour(t){this.fv?this.fv.previewTour(t):this.Es((()=>{var i;this.gv(),null==(i=this.fv)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.fv)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.fv)||t.nextStep()}previousStep(){var t;null==(t=this.fv)||t.previousStep()}clearCache(){var t;this.pv=null,null==(t=this.Ja)||t.unregister(Tr)}resetTour(t){var i;null==(i=this.fv)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.fv)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.fv)||i.cancelPendingTour(t)}}},zh),Gh={siteApps:class{constructor(t){this.mv=0,this._instance=t,this.yv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}bv(t,i){if(i){var e=this.globalsForEvent(i);this.yv.push(e),this.yv.length>1e3&&(this.yv=this.yv.slice(10))}}get siteAppLoaders(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.bv.bind(this));this._v=()=>{t(),this.yv=[],this._v=void 0}}}globalsForEvent(t){var i,e,r,s,n,o,a;if(!t)throw new Error("Event payload is required");var l={},h=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(u)){var v=d[0];l[v]={id:h[v],type:v,properties:d[1]}}var c=t.$set_once,f=t.$set;return{event:_({},g(t,sh),{properties:_({},t.properties,f?{$set:_({},null!==(i=null==(e=t.properties)?void 0:e.$set)&&void 0!==i?i:{},f)}:{},c?{$set_once:_({},null!==(r=null==(s=t.properties)?void 0:s.$set_once)&&void 0!==r?r:{},c)}:{}),elements_chain:null!==(n=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=t.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}wv(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(nh.error("prepare_external_dependency_stylesheet returned null"),null):"script"===e&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(nh.error("prepare_external_dependency_script returned null"),null):t}Sv(){var t,i,e,s,n,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var h=null==r?void 0:r.defaultView,u=null==h||null==(t=h.Node)?void 0:t.prototype;if(!h||!u)return()=>{};if(this.mv++,this.xv)return this.Cv();var d=[],v=this,c=new WeakSet,f=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),d.push((()=>{t[i]=r}))}},p=t=>{if(c.has(t))return t;var i=v.wv(t);return i&&c.add(i),i},_=t=>t.map((t=>"string"==typeof t?t:p(t))).filter((t=>!Q(t)));return f(u,"appendChild",(t=>function(i){var e=p(i);return e?t.call(this,e):i})),f(u,"insertBefore",(t=>function(i,e){var r=p(i);return r?t.call(this,r,e):i})),f(u,"replaceChild",(t=>function(i,e){var r=p(i);return r?t.call(this,r,e):e})),[null==(i=h.Element)?void 0:i.prototype,null==(e=h.Document)?void 0:e.prototype,null==(s=h.DocumentFragment)?void 0:s.prototype].forEach((t=>{f(t,"append",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))})),f(t,"prepend",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))}))})),[null==(n=h.Element)?void 0:n.prototype,null==(o=h.CharacterData)?void 0:o.prototype,null==(a=h.DocumentType)?void 0:a.prototype].forEach((t=>{f(t,"before",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))})),f(t,"after",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,_(e))})),f(t,"replaceWith",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=_(e);return e.length&&!s.length?void 0:t.apply(this,s)}))})),f(null==(l=h.Element)?void 0:l.prototype,"insertAdjacentElement",(t=>function(i,e){var r=p(e);return r?t.call(this,i,r):null})),this.xv=()=>{d.forEach((t=>t())),this.xv=void 0},this.Cv()}Cv(){var t=!1;return()=>{var i;t||(t=!0,this.mv--,0===this.mv&&(null==(i=this.xv)||i.call(this)))}}Tv(t,i){void 0===i&&(i=!0);var e=this.Sv();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.yv.length&&(nh.info("Processing "+this.yv.length+" events for site app with id "+t.id),this.yv.forEach((t=>this.Tv((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this._v)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,nh.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Tv((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){nh.error(oh+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){nh.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}Mv(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}Ev(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Tv((()=>null==r.processEvent?void 0:r.processEvent(e)))}catch(i){nh.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.Mv(),void this._instance.on("eventCaptured",(t=>this.Ev(t)))):void nh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this._v)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,i=a.id,e=a.url;v["__$$ph_site_app_"+i]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return nh.error(oh+i,t)}))};for(var a of n.siteApps)o()}else nh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Kh={tracingHeaders:class{constructor(t){this.Iv=void 0,this.Rv=void 0,this.Pv=void 0,this.zd=()=>{var t,i,e=this.Av();e?(K(this.Iv)&&(this.Iv=null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),K(this.Rv)&&(this.Rv=null==(i=v.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Jd()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Es(t){var i,e;null!=(i=v.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=v.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return zl.error("failed to load script",i);t()}))}Fv(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Av(){var t=this.Fv();return H(t)?(H(this.Pv)?this.Pv.splice(0,this.Pv.length,...t):this.Pv=[...t],t.length>0?this.Pv:void 0):(H(this.Pv)&&this.Pv.splice(0),this.Pv=t||void 0,this.Pv)}Jd(){var t,i;null==(t=this.Iv)||t.call(this),null==(i=this.Rv)||i.call(this),this.Iv=void 0,this.Rv=void 0}startIfEnabledOrStop(){this.Av()?this.Es(this.zd):this.Jd()}}},Jh=_({surveys:class extends uh{constructor(t){var i;super(new _h(t),{get projectToken(){return i.config.token},kv:new ph(i=t)}),this._instance=t}Wl(t,i){var e=i.query?wa(t,i.query):t;return new Promise((t=>{var r;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})}))}}},zh),Yh={toolbar:class{constructor(t){this.instance=t}Ov(t){v.ph_toolbar_state=t}Lv(){var t;return null!==(t=v.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i,e,s){if(void 0===i&&(i=void 0),void 0===e&&(e=void 0),void 0===s&&(s=void 0),ds(this.instance.config))return!1;if(!t||!r)return!1;i=null!=i?i:t.location,s=null!=s?s:t.history;try{if(!e){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}e=null==t?void 0:t.localStorage}var n,o=gh||Gn(i.hash,"__posthog")||Gn(i.hash,"state"),a=o?ns((()=>JSON.parse(atob(decodeURIComponent(o)))))||ns((()=>JSON.parse(decodeURIComponent(o)))):null;return a&&"ph_authorize"===a.action?((n=a).source="url",n&&Object.keys(n).length>0&&(a.desiredHash?i.hash=a.desiredHash:s?s.replaceState(s.state,"",i.pathname+i.search):i.hash="")):((n=JSON.parse(e.getItem(mh)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}Dv(t){var i=v.ph_load_toolbar||v.ph_load_editor;!X(i)&&V(i)?i(t,this.instance):yh.warn("No toolbar load function found")}loadToolbar(i){var e=!(null==r||!r.getElementById(Bs));if(!t||e)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=_({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(t.localStorage.setItem(mh,JSON.stringify(_({},n,{source:void 0}))),2===this.Lv())this.Dv(n);else if(0===this.Lv()){var o;this.Ov(1),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return yh.error("[Toolbar] Failed to load",t),void this.Ov(0);this.Ov(2),this.Dv(n)})),us(t,"turbolinks:load",(()=>{this.Ov(0),this.loadToolbar(n)}))}return!0}$v(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},Qh=_({experiments:Ah},zh),Xh={conversations:class{constructor(t){this.Nv=void 0,this._conversationsManager=null,this.qv=!1,this.Me=null,this.jv=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Bv=t.ok,t.ok)){var i=t.config.conversations;X(i)||(it(i)?this.Nv=i:(this.Nv=i.enabled,this.Me=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Nv=void 0,this.Me=null,this.Bv=void 0,this.jv=!1}loadIfEnabled(){if(!(this._conversationsManager||this.qv||this._instance.config.disable_conversations||ds(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==v?void 0:v.__PosthogExtensions__;if(t&&!K(this.Nv)&&this.Nv)if(this.Me&&this.Me.token){this.qv=!0;try{var i=t.initConversations;if(i)return this.Hv(i),void(this.qv=!1);var e=t.loadExternalDependency;if(!e)return void this.Uv(qr);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.Uv("Could not load conversations script",i):this.Hv(t.initConversations),this.qv=!1}))}catch(t){this.Uv("Error initializing conversations",t),this.qv=!1}}else Fh.error("Conversations enabled but missing token in remote config.")}}Hv(t){if(this.Me)try{this._conversationsManager=t(this.Me,this._instance),this.jv=!1,Fh.info("Conversations loaded successfully")}catch(t){this.Uv("Error completing conversations initialization",t)}else Fh.error("Cannot complete initialization: remote config is null")}Uv(t,i){Fh.error(t,i),this._conversationsManager=null,this.qv=!1,this.jv=!0}show(){this._conversationsManager?this._conversationsManager.show():Fh.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Nv&&!Q(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":ds(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Bv?"remote_config_failed":K(this.Nv)?this.Bv?"disabled_in_project":"remote_config_pending":this.Nv?X(this.Me)||!this.Me.token?"missing_token":null!=v&&v.__PosthogExtensions__?this.qv?"initializing":this.jv?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var r=this;return p((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,i,e):(Fh.warn(Mh),null)}))()}getMessages(t,i){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Fh.warn(Mh),null)}))()}markAsRead(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Fh.warn(Mh),null)}))()}getTickets(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Fh.warn(Mh),null)}))()}requestRestoreLink(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Fh.warn(Mh),null)}))()}restoreFromToken(t){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Fh.warn(Mh),null)}))()}restoreFromUrlToken(){var t=this;return p((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Fh.warn(Mh),null)}))()}getCurrentTicketId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}Il(){var t;null==(t=this._conversationsManager)||t.setIdentity()}Rl(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},Zh={logs:class{constructor(i){var e,r=this;this.name="logs",this.zv=!1,this.Wv=!1,this.Vv=!1,this.I=Ae("[logs]"),this.Gv=_({},this.I,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(Bh)||r.I.error(...i)}}),this.Ea=[],this.Zv=[],this.kh=0,this.us=!1,this.Qv=[],this.Jv=[],this.Kv=!1,this.Yv=!1,this.Xv=()=>{var t,i;this.us||(this.kh=0,null==(t=this.tc)||t.onReconnect(),null==(i=this.ec)||i.onReconnect())},this._instance=i,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.zv=!0),t&&us(t,"online",this.Xv)}ic(t,i,e,r){var s,n=Dh(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new Wi(this.rc(t,i),n,this.Gv,(()=>this.nc()),(t=>t()),void 0,r),n]}sc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.tc||this.ac!==i){var e;null==(e=this.tc)||e.reset(),this.ac=i;var r=this.ic((()=>this.Ea),(t=>{this.Ea=t}));this.tc=r[0],this.oc=r[1]}return this.tc}lc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.ec||this.uc!==i){var e;null==(e=this.ec)||e.reset(),this.uc=i;var r=this.ic((()=>this.Zv),(t=>{this.Zv=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Lh);this.ec=r[0],this.hc=r[1]}return this.ec}setup(t){var i;if(!this.us){this.cs=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.zv=!0),(this.zv||this.dc()&&this.vc())&&this.cc();var e=!1,r=t.onRemoteConfig((t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)}));this.us?r.dispose():(this.fs=r,e||this.loadIfEnabled())}}dispose(){var i,e,r,s;this.us||(this.us=!0,this.fc(),null==(i=this.fs)||i.dispose(),this.fs=void 0,this.cs=void 0,this.Vv=!1,null==t||t.removeEventListener("online",this.Xv),null==(e=this.gc)||e.call(this),this.gc=void 0,null==(r=this.tc)||r.reset(),null==(s=this.ec)||s.reset())}onRemoteConfig(t){var i,e;if(!this.us){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;X(r)?this.mc():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[Ze]:!!r}),r?(this.zv=!0,this.Wv||this.cc(),this.loadIfEnabled()):this.mc())}}reset(){var t,i,e,r;this.fc(),null==(t=this.tc)||t.clearQueue(),this.Ea=[],null==(i=this.tc)||i.reset(),null==(e=this.ec)||e.clearQueue(),this.Zv=[],null==(r=this.ec)||r.reset(),this.kh=0}captureLog(t){this.us||this.sc().captureLog(t)}captureConsoleLog(t){this.us||this.lc().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.us||this.lc().captureLog(t,{context:i,occurredAtMs:e})}vc(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[Ze])}dc(){var t,i;return null==(t=this._instance)||null==t.xa||!t.xa()||!(null==(i=v._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}Al(){var t;this.fc(),null==(t=this.ec)||t.clearQueue(),this.Zv=[]}mc(){this.zv||this.fc()}cc(){var t,i=this;if(!this.Kv&&null!=v&&v.console){var e=Dh(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(v.console[t])}catch(t){return 0}if(!r)return 0;i.Jv.push(Bl(v.console,t,(s=>{var n=function(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];try{i.yc(t,n,e)}catch(t){}return s.apply(v.console,n)};return n.__rrweb_original__=r,n})))};for(var s of Nh)r(s);this.Kv=!0,this.bc=setTimeout((()=>{this.fc()}),3e4)}}yc(t,i,e){var r;if(this.Kv&&!this.Yv&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Qv.length){this.Yv=!0;try{this.Qv.push({level:t,args:i,occurredAtMs:Date.now(),context:this.nc()})}finally{this.Yv=!1}}}else this.fc()}fc(){if(this.Qv=[],this.Kv){for(var t of(this.Kv=!1,this.bc&&(clearTimeout(this.bc),this.bc=void 0),this.Jv))t();this.Jv=[]}}_c(){var t=this.Qv;return this.fc(),t}get logger(){return this.wc||(this.wc={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.wc}flushLogs(t){t?this.kc(t):(this.tc&&this.tc.flush().catch((t=>this.Sc(t))),this.ec&&this.ec.flush().catch((t=>this.Sc(t))))}Sc(t){Bh(t)||this.I.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.us&&this.zv&&!this.Wv&&!this.Vv){var t=null==v?void 0:v.__PosthogExtensions__;if(!t)return this.I.error("PostHog Extensions not found."),void this.fc();var i=t.loadExternalDependency;if(!i)return this.I.error(qr),void this.fc();this.Vv=!0;try{i(this._instance,"logs",(i=>{if(this.Vv=!1,!this.us&&this.zv){var e=t.logs;if(i||null==e||!e.initializeLogs)this.I.error("Could not load logs script",i),this.fc();else{var r,s,n=this._c();this.gc=e.initializeLogs(null!==(r=this.cs)&&void 0!==r?r:this._instance),this.Wv=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.cs)&&void 0!==s?s:this._instance,n))}}}))}catch(t){throw this.Vv=!1,t}}}rc(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===x.LogsQueue?t():void 0,setPersistedProperty(t,e){var r;t===x.LogsQueue&&i(null!==(r=e)&&void 0!==r?r:[])},Ln:t=>this.Ln(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Ln(t){return new Promise((i=>{if(Kn(this.kh,3))i({kind:"fatal",error:jh(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout((()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:jh(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.xc(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.Cc(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:jh(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}}))}Cc(t){(0!==t||this._instance.__loaded)&&(this.kh=Jn(t,this.kh,3,(()=>this.I.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."))))}kc(t){this.Ea.length>0&&this.Tc(t,this.Ea,this.oc,c.LIB_NAME,(t=>{this.Ea=t})),this.Zv.length>0&&this.Tc(t,this.Zv,this.hc,Lh,(t=>{this.Zv=t}))}Tc(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var o=Vi(n,Hi(e,c.LIB_NAME,c.LIB_VERSION),r,c.LIB_VERSION);this._instance._send_request({method:"POST",url:this.xc(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}xc(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}nc(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,X(s)||(i.sessionStartTimestamp=s),X(n)||(i.lastActivityTimestamp=n)}if(null!=v&&null!=(t=v.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?xi(v.location.href):v.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}}},tu={metrics:class{constructor(t){this.I=Ae("[metrics]"),this._instance=t}initialize(){}sc(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.tc&&this.ac===e||(null==(i=this.tc)||i.reset(),this.ac=e,this.tc=new Yi(this.rc(),function(t){var i,e,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(e),this.I)),this.tc}count(t,i,e){void 0===i&&(i=1),this.sc().count(t,i,e)}gauge(t,i,e){this.sc().gauge(t,i,e)}histogram(t,i,e){this.sc().histogram(t,i,e)}flush(t){if(!this.tc)return Promise.resolve();if(t){var i=this.tc.drainWindow();return i&&this.Kn(i,t),Promise.resolve()}return this.tc.flush().catch((t=>this.I.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.tc)||t.reset()}rc(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Kn:t=>i.Kn(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Kn(t,i){return new Promise((e=>{var r=!1,s=t=>{r||(r=!0,clearTimeout(n),e(t))},n=setTimeout((()=>s({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(_({method:"POST",url:this.Mc(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var i=t.statusCode;if(i>=200&&300>i)s({kind:"ok"});else if(413===i)s({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)s({kind:"fatal",error:new Error("metrics request failed with status "+i)});else{var e;s({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("metrics request failed with status "+i)})}}}))}))}Mc(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},iu=_({},zh,qh,Hh,Vh,Wh,Gh,Jh,Kh,Yh,Qh,Xh,Zh,tu);Rl.__defaultExtensionClasses=_({},iu);var eu=function(){c.SDK_DIST_CHANNEL="npm";var i=fl[xl]=new Rl;return function(){function i(){i.done||(i.done=!0,El=!1,es(fl,(function(t){t._dom_loaded()})))}null!=r&&r.addEventListener?"complete"===r.readyState?i():us(r,"DOMContentLoaded",i,{capture:!1}):t&&Ie.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),i}();export{yo as Compression,Oo as DEFAULT_PRODUCT_TOUR_APPEARANCE,Co as DisplaySurveyType,Rl as PostHog,Io as ProductTourEventName,Ao as ProductTourEventProperties,Po as SurveyEventName,Ro as SurveyEventProperties,bo as SurveyEventType,xo as SurveyPosition,To as SurveyQuestionBranchingType,ko as SurveyQuestionType,$o as SurveySchedule,Eo as SurveyTabPosition,So as SurveyType,wo as SurveyWidgetType,eu as default,eu as posthog,Lo as severityLevels};
2
2
  //# sourceMappingURL=module.js.map