posthog-js 1.435.2 → 1.435.4

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 (55) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.es5.js +1 -1
  4. package/dist/array.full.js +1 -1
  5. package/dist/array.full.js.map +1 -1
  6. package/dist/array.full.no-external.js +1 -1
  7. package/dist/array.full.no-external.js.map +1 -1
  8. package/dist/array.js +1 -1
  9. package/dist/array.no-external.js +1 -1
  10. package/dist/conversations.js +1 -1
  11. package/dist/customizations.full.js +1 -1
  12. package/dist/customizations.js +1 -1
  13. package/dist/dead-clicks-autocapture.js +1 -1
  14. package/dist/default-extensions.js +1 -1
  15. package/dist/exception-autocapture.js +1 -1
  16. package/dist/extension-bundles.js +1 -1
  17. package/dist/lazy-recorder.js +1 -1
  18. package/dist/lazy-recorder.js.map +1 -1
  19. package/dist/main.js +1 -1
  20. package/dist/module.full.cjs +1 -1
  21. package/dist/module.full.js +1 -1
  22. package/dist/module.full.js.map +1 -1
  23. package/dist/module.full.no-external.cjs +1 -1
  24. package/dist/module.full.no-external.js +1 -1
  25. package/dist/module.full.no-external.js.map +1 -1
  26. package/dist/module.js +1 -1
  27. package/dist/module.mjs +1 -1
  28. package/dist/module.no-external.cjs +1 -1
  29. package/dist/module.no-external.js +1 -1
  30. package/dist/module.slim.js +1 -1
  31. package/dist/module.slim.no-external.js +1 -1
  32. package/dist/posthog-recorder.d.ts +1 -0
  33. package/dist/posthog-recorder.js +1 -1
  34. package/dist/posthog-recorder.js.map +1 -1
  35. package/dist/product-tours.js +1 -1
  36. package/dist/recorder-v2.js +1 -1
  37. package/dist/recorder-v2.js.map +1 -1
  38. package/dist/recorder.d.ts +1 -0
  39. package/dist/recorder.js +1 -1
  40. package/dist/recorder.js.map +1 -1
  41. package/dist/rrweb.d.ts +1 -0
  42. package/dist/rrweb.js +1 -1
  43. package/dist/rrweb.js.map +1 -1
  44. package/dist/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +6 -0
  45. package/dist/src/extensions/replay/types/rrweb.d.ts +1 -0
  46. package/dist/surveys-preview.js +1 -1
  47. package/dist/surveys.js +1 -1
  48. package/lib/package.json +1 -1
  49. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +6 -0
  50. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +26 -3
  51. package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
  52. package/lib/src/extensions/replay/external/network-plugin.js +3 -1
  53. package/lib/src/extensions/replay/external/network-plugin.js.map +1 -1
  54. package/lib/src/extensions/replay/types/rrweb.d.ts +1 -0
  55. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- var t=["$set_once","$set"];function i(){return i=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},i.apply(null,arguments)}function e(t,i,e,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void e(t)}o.done?i(l):Promise.resolve(l).then(r,s)}function r(t){return function(){var i=this,r=arguments;return new Promise(function(s,n){var a=t.apply(i,r);function o(t){e(a,s,n,o,l,"next",t)}function l(t){e(a,s,n,o,l,"throw",t)}o(void 0)})}}var s=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.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function n(t,i){return-1!==t.indexOf(i)}var a=function(t){return t.trim()},o=Object.prototype,l=o.hasOwnProperty,u=o.toString,h=Array.isArray||function(t){return"[object Array]"===u.call(t)},v=t=>"function"==typeof t,d=t=>t===Object(t)&&!h(t),c=t=>{if(d(t)){for(var i in t)if(l.call(t,i))return!1;return!0}return!1},f=t=>void 0===t,p=t=>"[object String]"==u.call(t),g=t=>p(t)&&0===t.trim().length,_=t=>null===t,b=t=>f(t)||_(t),y=t=>"[object Number]"==u.call(t)&&t==t,m=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function S(t,i){return{}.toString.call(t)==="[object "+i+"]"}function k(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 E(t,Error)}}function x(t){return"u">typeof Event&&E(t,Event)}function E(t,i){try{return t instanceof i}catch(t){return!1}}var C=["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"],P=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return C.concat(i).some(t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)})};function F(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),y(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),F(null!=s?s:e,i,e,r))}var T=class{constructor(t){this.C={},this.I=t.I,this.R=F(t.bucketSize,0,100,t.A),this.$=F(t.refillRate,0,this.R,t.A),this.O=F(t.refillInterval,0,864e5,t.A)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.$,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.C[r];return s?this.F(s,e):this.C[r]=s={tokens:this.R,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.I)||i.call(this,t)),0===s.tokens)}stop(){this.C={}}},A="Mobile",R="Android",O="Nintendo",M="PlayStation",I="Xbox",j="Windows";A.toLowerCase(),"Tablet".toLowerCase(),new RegExp(I,"i");var D=new RegExp("BlackBerry|PlayBook|BB10","i"),L={"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"},N=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[I,t&&t[1]||""]],[new RegExp(O,"i"),[O,""]],[new RegExp(M,"i"),[M,""]],[D,["BlackBerry",""]],[new RegExp(j,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return["Windows Phone",""];if(new RegExp(A).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=L[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[j,r]}return[j,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=f(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[R,[t[2],t[3],t[4]||"0"].join(".")]:[R,""]],[/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/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],H="[Truncated]",B="[Unserializable]";function z(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}function U(t,i){if(!i)return t;var e=[];try{e=Object.keys(i)}catch(t){e=[]}for(var r of e){var s=void 0;try{s=i[r]}catch(t){s=B}Object.defineProperty(t,r,{value:s,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;var q,V,W,K=3e5,J=class{record(t){if("too-large"!==t.kind)if("retry-later"===t.kind){if(t.retryAfterMs){var i=this.isOpen(),e=Date.now(),r=Math.min(t.retryAfterMs,K);if(!i)return this.ts=e,void(this.es=e+r);this.es=Math.max(this.es,Math.min(e+r,this.ts+K))}}else this.reset()}remainingMs(){var t=Date.now();if(this.ts-5e3>t)return this.reset(),0;var i=Math.min(K,Math.max(0,this.es-t));return 0===i&&this.reset(),i}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};function G(t){return t?t.split("#")[0]:t}function X(t){try{return t()}catch(t){return}}function Z(t,i){var e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function Q(t,i,e){return Y.apply(this,arguments)}function Y(){return(Y=r(function*(t,i,e){var r;try{return yield Promise.race([t,new Promise((t,s)=>{r=Z(()=>{try{null==e||e(),t()}catch(t){s(t)}},i)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function tt(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return W&&e.length===V?W:(V=e.length,W=e.reduce((e,r)=>{q||(q={});var s=q[r];if(s)e[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o,l=null==(o=n[a])?void 0:o.filename,u=i[r];if(l&&u){e[l]=u,q[r]=[l,u];break}}return e},{}))}}var it=class{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 r(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,e){var r,s,n;if(null!=t.cause&&(s=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)}catch(t){}return i({},t,{cause:s,stack:n,errors:null==(r=t.errors)?void 0:r.map(t=>this.parseStacktrace(t,e))})}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 r(function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e})()}convertToExceptionList(t,e){var r=[],s=(t,n,a)=>{var o=r.length,l=void 0===n?i({type:"string"==typeof e.type&&e.type.length>0?e.type:"generic"},"boolean"==typeof e.handled?{handled:e.handled}:void 0===e.handled?{handled:!0}:{},{synthetic:"boolean"==typeof e.synthetic?e.synthetic:t.synthetic,exception_id:o}):{type:"chained",source:a,synthetic:t.synthetic,exception_id:o,parent_id:n},u={type:t.type,value:t.value,mechanism:l};for(var h of(t.stack&&(u.stacktrace={type:"raw",frames:t.stack}),r.push(u),t.cause&&s(t.cause,o,"cause"),null!==(v=t.errors)&&void 0!==v?v:[])){var v;s(h,o,"member")}};return s(t),r}buildParsingContext(t){var i;return{chunkIdMap:tt(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}getAggregateErrors(t){try{if(k(t))for(var i=Object.getPrototypeOf(t),e=0;i&&100>e;e++){var r,s=null==(r=Object.getOwnPropertyDescriptor(i,"constructor"))?void 0:r.value;if("function"==typeof s&&"AggregateError"===s.name){var n=t.errors;return h(n)?n:void 0}i=Object.getPrototypeOf(i)}}catch(t){}}buildCoercingContext(t,e,r){var s=this;void 0===r&&(r=0);var n=0,a=0,o=!1,l=new Set,u=[],h={},v=function(t,e,r){void 0===r&&(r=0);var v=d(e,r),c=v.apply;if(v.apply=i=>{u.push(t);try{return c(i)}finally{u.pop()}},r>4||r>0&&-1!==u.indexOf(t))return s.coerceFallback(v);var f="object"==typeof t&&null!==t||"function"==typeof t;if(!(0===r&&n>=50||f&&l.has(t))){f&&l.add(t),0===r&&n++;var p,g,_=s.getAggregateErrors(t);o||(o=!!_);try{if(!(p=s.applyCoercers(t,v)))throw h}catch(t){if(t===h)return void(0===r&&n--);if(!o)throw t;p=s.coerceFallback(v)}if(!_||n>=50)return p;try{g=_.length}catch(t){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;for(var b=[],y=0;50>n&&1e3>a&&g>y;y++){a++;var m=void 0;try{m=v.next(_[y])}catch(t){n++,m=s.coerceFallback(d(e+1))}m&&b.push(m)}return i({},p,{errors:b})}},d=function(r,s){return void 0===s&&(s=0),i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:0==r?t:{},apply(t){var i=v(t,r,s+1);if(!i)throw h;return i},next:t=>v(t,r+1)})},c=d(r);return i({},c,{apply:t=>{var i;return null!==(i=v(t,r))&&void 0!==i?i:this.coerceFallback(c)}})}},et=/^([a-z][a-z0-9.+-]+):/i,rt=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function st(t){if(!t||"<anonymous>"===t)return!1;var i=et.exec(t);return!i||rt.includes(i[1].toLowerCase())}function nt(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:st(i)};return f(r)||(n.lineno=r),f(s)||(n.colno=s),n}var at=(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]:"?",e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},ot=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,lt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ut=/\((\S*)(?::(\d+))(?::(\d+))\)/,ht=(t,i)=>{var e=ot.exec(t);if(e)return nt(i,e[1],"?",+e[2],+e[3]);var r=lt.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ut.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=at(r[1]||"?",r[2]);return nt(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},vt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,dt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ct=(t,i)=>{var e=vt.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=dt.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]||"?",a=at(n,s);return nt(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ft=/\(error: (.*)\)/;function pt(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function gt(t){for(var i=1;10>=i;i++){var e=t.length-2*i;if(0>e)break;for(var r=!0,s=0;i>s;s++)if(!pt(t[e+s],t[e+i+s])){r=!1;break}if(r){for(var n=0;i>n;n++)t[e+n]=t[e+i+n];return t.length=e+i,{start:e,length:i}}}}function _t(t,i){var e=i.start+i.length,r=yt(t,i);r&&t.splice(e+r===t.length?e:i.start,r)}function bt(t,i){for(var e=i.start;e>0&&pt(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function yt(t,i){for(var e=i.start+i.length,r=e;t.length>r&&pt(t[r],t[r-i.length]);)r++;return r-e}function mt(t,i){var e=i[0],r=t.length-(e?bt(t,e):0);for(var s of i)r-=yt(t,s);return r}function wt(t,i,e){for(var r=0;t.length>r;r++){var s=t[(i+r)%t.length],n=t[(e+r)%t.length];if(s!==n)return n>s}return!1}var St=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=p(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 S(t,"DOMException")}isDOMError(t){return S(t,"DOMError")}},kt=class{match(t){return k(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r?null==(e=i.syntheticException)?void 0:e.stack:void 0,n=!!s;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:s,cause:t.cause?i.next(t.cause):void 0,synthetic:n}}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){try{var i=t.stacktrace;if("string"==typeof i&&i.length>0)return i;var e=t.stack;return"string"==typeof e&&e.length>0?e:void 0}catch(t){return}}},xt=class{match(t){return!!S(t,"ErrorEvent")&&(null!=t.error||this.sr(t))}coerce(t,e){var r;if(null!=t.error)return e.apply(t.error);var s=e.apply(t.message);return i({},s,{stack:null!==(r=this.ar(t))&&void 0!==r?r:s.stack,synthetic:!0})}sr(t){return p(t.message)&&t.message.length>0}ar(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(p(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}},Et=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Ct=class{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(Et);return r&&(i=r[1],e=r[2]),[i,e]}},Pt=["fatal","error","warning","log","info","debug"];function Ft(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""}var Tt=class{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(x(t))return t.constructor.name;var i="name"in t?t.name:void 0;return p(i)&&!g(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: "+Ft(t)}isSeverityLevel(t){return p(t)&&!g(t)&&Pt.indexOf(t)>=0}getStack(t){try{return p(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:p(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(k(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},At=class{match(t){return x(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Ft(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Rt=class{match(t){return w(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}}},Ot=class{match(t){return S(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!x(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 w(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}},Mt="$message",$t="$timestamp",It=new Set([Mt,$t]),jt={enabled:!0,max_bytes:32768};function Dt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:jt.enabled,max_bytes:Nt(t.max_bytes,jt.max_bytes)}:i({},jt)}var Lt=class{constructor(t){this.ns=[],this.ss=0,this.Mr=Dt(t)}setConfig(t){this.Mr=Dt(t),this.rs()}add(t){var i=function(t){var i,e,r;try{r=[],i=null!==(e=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(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return"[Circular]";r.push(i)}return i}}))&&void 0!==e?e:"null"}catch(t){return}try{var s=JSON.parse(i);if(!d(s))return;var n=s,a=n[Mt],o=n[$t];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!y(o))return;return{step:n,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("u">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.Mr.max_bytes||(this.ns.push({step:i.step,bytes:e}),this.ss+=e,this.rs())}}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function Nt(t,i){if(!y(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var Ht=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Bt(t){return"string"==typeof t||t}function zt(t){return"string"==typeof t?t:void 0}var Ut={}.propertyIsEnumerable;function qt(t,i){try{return Kt(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Vt(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:H};if(e.remainingNodes--,m(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==i||i.debug("Attribute "+e+" is outside the int64 range; encoding it as a string"),{stringValue:e}):{intValue:e}}(t,i);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(typeof BigInt>"u")return{stringValue:String(t)};var s=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>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:z(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:H};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?z(a):String(a)}}e.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Vt(o.call(t),i,e,r+1)}catch(t){}return h(t)?{arrayValue:{values:Wt(t,i,e,r+1)}}:{kvlistValue:{values:Kt(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:z(String(t))}}function Wt(t,i,e,r){for(var s=[],n=Math.min(t.length,1e3),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(b(o))continue;s.push(Vt(o,i,e,r))}catch(t){s.push({stringValue:B})}return t.length>a&&s.push({stringValue:H}),s}function Kt(t,i,e,r){var s=[];for(var n in t)if(Ut.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(_(a)||f(a))continue;s.push({key:z(n),value:Vt(a,i,e,r)})}catch(t){s.push({key:z(n),value:{stringValue:B}})}}return s}function Jt(t,e,r){return i({},U({},t.resourceAttributes),{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}var Gt=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Xt(t,i){var e=U({},t),r={};for(var s of Gt)({}).hasOwnProperty.call(e,s)&&(r[s]=e[s],delete e[s]);return[...qt(e,i),...qt(r,i)]}var Zt={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};var Qt={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}},Yt=Qt.info;function ti(t){try{return z(String(t))}catch(t){return B}}function ii(t,e,r,s){var n,a=Qt[t.level||"info"]||Yt,o=a.text,l=a.number,u=(void 0===(n=y(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),h={};e.distinctId&&(h.posthogDistinctId=e.distinctId),e.sessionId&&(h.sessionId=e.sessionId),e.windowId&&(h["window.id"]=e.windowId),b(e.sessionStartTimestamp)||(h.sessionStartTimestamp=String(e.sessionStartTimestamp)),b(e.lastActivityTimestamp)||(h.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(h["url.full"]=e.currentUrl),e.screenName&&(h["screen.name"]=e.screenName),e.appState&&(h["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(h.feature_flags=e.activeFeatureFlags);var v=i({},h),d=t.attributes;if(d){var c=[];try{c=Object.keys(d)}catch(t){c=[]}for(var p of c){var g=void 0;try{g=d[p]}catch(t){g=B}Object.defineProperty(v,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:ti(t.body)},attributes:qt(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),f(t.trace_flags)||(_.flags=t.trace_flags),_}function ei(t,i,e){return Jt(t,i,e)}function ri(t,i,e,r){return{resourceLogs:[{resource:{attributes:Xt(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}var si=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.hs}arm(t){this.clear(),this.us=Date.now()+t,this.hs=Z(()=>{this.hs=void 0,this.ls()},t)}armNoEarlierThan(t){this.hs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function ni(){return.75+.5*Math.random()}function ai(t,i,e,r){var s=t*Math.pow(2,Math.min(Math.max(0,i-1),6));return Math.round((void 0===r?s:Math.min(s,Math.max(r,t)))*e)}var oi=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Mr=i,this.A=e,this.cs=r,this.ds=s,this.vs=n,this.fs=a,this.ps=new si(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new J,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=i.maxBufferSize,this.Is=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.Ms=i.flushIntervalMs,this.Es=i.maxBatchRecordsPerPost,this.Ps=i.rateCapWindowMs,this.Rs=i.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(s.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Os(t);if(null!==r)if(r.body){if(this.Ds()){var s={record:ii(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.cs(),this.A,null==i?void 0:i.occurredAtMs)};this.ds(()=>this.Ls(s))}}else this.A.info("Log was rejected in beforeSend function")}}Os(t){var i=this.Mr.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.A.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return r}Ds(){if(void 0===this.Rs)return!0;var t=Date.now(),i=t-this.xs;return this.Ps>i&&i>=0||(this.xs=t,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||(this.A.warn("captureLog dropping logs: exceeded "+this.Rs+" logs per "+this.Ps+"ms"),this.$s=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return r(function*(){var i;t.ps.clear();var e=null!==(i=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,n=0;e.length>0&&r>n;){var a,o,l=t._s;t.bs=0;var u=Math.min(e.length,t.Es),h=e.slice(0,u),v=ri(h.map(t=>t.record),t.qs(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.js(v);if(t._s!==l)return;if("too-large"===d.kind&&h.length>1)t.Es=Math.max(1,Math.floor(h.length/2)),t.A.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Es);else{if(t.ws.record(d),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),"retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.Mr.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Mr.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(h.length),e=null!==(o=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==o?o:[],n+=h.length,"fatal"===d.kind)throw d.error}}})()}Bs(t){var i=this;return r(function*(){var e,r=Math.max(0,t-i.bs),n=null!==(e=i._instance.getPersistedProperty(s.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(s.LogsQueue,n.slice(r)),yield i.vs()})()}qs(){return ei(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];this.Is>e.length||(e.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(s.LogsQueue,e),this.Ts>e.length||this.ws.isOpen()?this.Fs():this.gs()}}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(ai(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){var t=this._instance.getPersistedProperty(s.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return r(function*(){i.ps.clear();var e=i.flush().catch(()=>{});void 0!==t?yield Q(e,t):yield e})()}flushWithTimeout(t){var i=this;return r(function*(){var e=i.flush();yield Q(e,t,()=>{e.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=ni(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}},li=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ui(t){return String(t)+"000000"}function hi(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}var vi=class{constructor(t,i,e){this._instance=t,this.Mr=i,this.A=e,this.zs=new Map,this.ps=new si(()=>this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new J,this.ks=0,this.Ss=1,this.Gs=0}count(t,i,e){void 0===i&&(i=1),this.Zs({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.Zs({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.Zs({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.ys,e=function(){var e=r(function*(){i&&(yield i.catch(()=>{})),yield t.Qs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.ys===e&&(this.ys=null)});return this.ys=e,e}drainWindow(){if(0===this.zs.size)return null;var t=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.Os(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.A.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=e.attributes?i({},e.attributes):void 0,s=hi(e.type,e.name,e.unit,r)}catch(t){return void this.A.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var n=this.zs.get(s);if(!n){if(!this.Ks())return;n={name:e.name,type:e.type,unit:e.unit,attributes:r,windowStartMs:Date.now()},this.zs.set(s,n)}var a=this.Ws.get(e.name);void 0===a?this.Ws.set(e.name,e.type):a===e.type||this.Vs.has(e.name)||(this.Vs.add(e.name),this.A.warn("Metric name '"+e.name+"' is already used as a "+a+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Xs(n,e.value),this.Fs()}else this.A.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn("Metric series cap reached ("+this.Mr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Xs(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(li.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,li)]+=1}}Os(t){var i=this.Mr.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.A.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return r}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(ai(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var t=this;return r(function*(){if(t.ps.clear(),0!==t.zs.size){var i=t.zs;t.zs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;var e=t.Gs,r=yield t._instance.Ys(t.Js(i));if(e===t.Gs)switch(t.ws.record(r),"retry-later"===r.kind?(t.ks++,t.Ss=ni()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.Hs()),r.kind){case"ok":return;case"retry-later":return t.uo(i),void t.ps.armNoEarlierThan(t.Hs());case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",r.error)}}})()}Js(t){return i=this.ho(t),e=function(t,i,e){return Jt(t,i,e)}(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Xt(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}ho(t){var e=ui(Date.now()),r=new Map;for(var s of t.values()){var n,a=hi(s.type,s.name,s.unit,void 0),o=r.get(a);o||(o=i({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=qt(null!==(n=s.attributes)&&void 0!==n?n:{},this.A),u=ui(s.windowStartMs);if("count"===s.type){var h,v={attributes:l,startTimeUnixNano:u,timeUnixNano:e,asDouble:null!==(h=s.total)&&void 0!==h?h:0};o.sum.dataPoints.push(v)}else if("gauge"===s.type){var d,c={attributes:l,timeUnixNano:e,asDouble:null!==(d=s.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(c)}else s.hist&&o.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:e,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:li})}return Array.from(r.values())}uo(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.zs.get(s);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,n.windowStartMs),a.type){case"count":a.total=(null!==(i=a.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(a.hist){a.hist.count+=n.hist.count,a.hist.sum+=n.hist.sum,a.hist.min=Math.min(a.hist.min,n.hist.min),a.hist.max=Math.max(a.hist.max,n.hist.max);for(var o=0;a.hist.bucketCounts.length>o;o++)a.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else a.hist=n.hist}else this.Ks()&&this.zs.set(s,n)}}},di="0.9.0",ci={DEBUG:!1,LIB_VERSION:di,LIB_NAME:"browser-common",JS_SDK_VERSION:di},fi="u">typeof window?window:void 0,pi="u">typeof globalThis?globalThis:fi,gi=null==pi?void 0:pi.navigator,_i=null==pi?void 0:pi.document,bi=null==pi?void 0:pi.location;function yi(){return!(!fi||!1===fi.navigator.onLine)}null!=pi&&pi.XMLHttpRequest&&new pi.XMLHttpRequest;var mi=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={N(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;r>n;n++)s[n-1]=arguments[n];fi&&(ci.DEBUG||fi.POSTHOG_DEBUG||e)&&!f(fi.console)&&fi.console&&("__rrweb_original__"in fi.console[i]?fi.console[i].__rrweb_original__:fi.console[i])(t,...s)},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("error",...i)},critical(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];console.error(t,...e)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(i,e)=>mi(t+" "+i,e)};return r},wi=mi("[PostHog.js]"),Si=wi.createLogger;function ki(t,i){h(t)&&t.forEach(i)}function xi(t,i){if(!b(t))if(h(t))t.forEach(i);else if(t instanceof FormData)t.forEach((t,e)=>i(t,e));else for(var e in t)l.call(t,e)&&i(t[e],e)}var Ei=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 Ci(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}function Pi(t,i,e,r){var s=null!=r?r:{},n=s.capture,a=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===a||a})}function Fi(t){return"ph_toolbar_internal"===t.name}function Ti(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 p(s)&&s?s:i}catch(t){return wi.error("Error in get_current_url, falling back to window.location.href",t),i}}function Ai(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Ri(t){return!!t&&1===t.nodeType}function Oi(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Mi(t){return!!t&&3===t.nodeType}function $i(t){return!!t&&11===t.nodeType&&Ri(t.host)}function Ii(t){return t?a(t).split(/\s+/):[]}function ji(t,i){var e=function(t){var i,e=null==fi||null==(i=fi.location)?void 0:i.href;return f(e)?void 0:Ti(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Di(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 Ii(i)}function Li(t){return b(t)?null:a(t).split(/(\s+)/).filter(t=>le(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ni(t){var i="";return Yi(t)&&!te(t)&&t.childNodes&&t.childNodes.length&&xi(t.childNodes,function(t){var e;Mi(t)&&t.textContent&&(i+=null!==(e=Li(t.textContent))&&void 0!==e?e:"")}),a(i)}function Hi(t){var i;return f(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var Bi=["a","button","form","input","select","textarea","label"];function zi(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}}function Ui(t,i){if(f(i))return!0;var e,r=function(t){if(i.some(i=>zi(t,i)))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function qi(t){var i=t.parentNode;return!(!i||!Ri(i))&&i}var Vi=[".ph-no-autocapture","[data-ph-no-autocapture]"],Wi=["next","previous","prev",">","<"],Ki=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Ji=[".ph-no-rageclick",".ph-no-capture"],Gi=["","text","search","email","password","url","tel","number"];function Xi(t,i){if(!fi||Zi(t))return!1;var e,r,s,a,o;if(m(i)?(e=!!i&&Ji,r=void 0,s=!1):(e=null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Ji,r=null==i?void 0:i.content_ignorelist,s=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(s&&function(t){return!(!t||!Ri(t))&&(!!Oi(t,"textarea")||(Oi(t,"input")?n(Gi,(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)))}(t))return!1;var l=Qi(t,!1).targetElementList;return!function(t,i){if(!1===t||f(t))return!1;var e;if(!0===t)e=Wi;else{if(!h(t))return!1;if(t.length>10)return wi.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=>Ki(i,t)||Ki(r,t))})}(r,l.map(t=>{var i;return{safeText:Ni(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}}))&&!Ui(l,e)}var Zi=t=>!t||Oi(t,"html")||!Ri(t),Qi=(t,i)=>{if(!fi||Zi(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!Oi(s,"body");)if($i(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=qi(s);if(!n)break;if(i||Bi.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=fi.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Yi(t){for(var i=new Set,e=0,r=t;r.parentNode&&!Oi(r,"body");r=r.parentNode){if(e++>=1e3||i.has(r))return!1;i.add(r);var s=Di(r);if(n(s,"ph-sensitive")||n(s,"ph-no-capture"))return!1}if(n(Di(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(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 te(t){return!!(Oi(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Oi(t,"select")||Oi(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var ie=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}))$"),ee=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,re=[16,15,14,13],se=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),ne=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),ae=/[0-9A-Za-z_]/;function oe(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 le(t,i){if(void 0===i&&(i=!0),b(t))return!1;if(p(t)){if(t=a(t),i?ie.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(ee.lastIndex=0;i=ee.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of re){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(ie.test(o)&&oe(o))return!0}}}return!1}(t))return!1;if(i?se.test(t):function(t){var i;for(ne.lastIndex=0;i=ne.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&ae.test(e)&&ae.test(r)))return!0}return!1}(t))return!1}return!0}function ue(t){var i=Ni(t);return le(i=(i+" "+he(t)).trim())?i:""}function he(t){var i="";return t&&t.childNodes&&t.childNodes.length&&xi(t.childNodes,function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=Ni(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+he(t)).trim())}catch(t){wi.error("[AutoCapture]",t)}}),i}function ve(t){return t.replace(/"|\\"/g,'\\"')}function de(t){var i=t.attr__class;if(i)return h(i)?i:Ii(i)}var ce=class{constructor(t){this.disabled=!1===t;var i=d(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}},fe="$autocapture_disabled_server_side",pe="$heatmaps_enabled_server_side",ge="$exception_capture_enabled_server_side",_e="$error_tracking_suppression_rules",be="$error_tracking_capture_extension_exceptions",ye="$web_vitals_enabled_server_side",me="$dead_clicks_enabled_server_side",we="$product_tours_enabled_server_side",Se="$logs_capture_enabled_server_side",ke="$web_vitals_allowed_metrics",xe="$session_recording_remote_config",Ee="$replay_override_sampling",Ce="$replay_override_linked_flag",Pe="$enabled_feature_flags",Fe="$active_feature_flags",Te="$early_access_features",Ae="$feature_flag_details",Re="$feature_flag_payloads",Oe="$feature_flag_request_id",Me="$minimal_flag_called_events",$e="$override_feature_flags",Ie="$override_feature_flag_payloads",je="$stored_person_properties",De="$stored_group_properties",Le="$surveys",Ne="$surveys_loaded_at",He="$surveys_activated",Be="$surveys_activated_session",ze="$surveys_activated_timestamps",Ue="ph_product_tours",qe="$flag_call_reported",Ve="$flag_call_reported_session_id",We="$feature_flag_errors",Ke="$feature_flag_evaluated_at",Je="$sdk_debug_recording_script_not_loaded",Ge="$sdk_debug_replay_stale_config",Xe="PostHog loadExternalDependency extension not found.",Ze="visibilitychange",Qe="beforeunload",Ye=t=>{var i=null==_i?void 0:_i.createElement("a");return f(i)?null:(i.href=t,i)},tr=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 a=e[1];try{a=decodeURIComponent(a)}catch(t){wi.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ir=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],v=0;l.length>v;v++){var d=l[v].split("=");h(d)&&(i.includes(d[0])?u.push(d[0]+"="+e):u.push(l[v]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},er=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},rr=(t,i)=>t>=i&&yi(),sr=(t,i,e,r)=>{if(0===t){if(yi()){var s=i+1;return s===e&&r(),s}return i}return 0},nr="$copy_autocapture",ar=Si("[AutoCapture]");function or(t,i){return i.length>t?i.slice(0,t)+"...":i}function lr(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Ri(i));return i}function ur(t,e){var r,s,a=e.e,o=e.maskAllElementAttributes,l=e.maskAllText,u=e.elementAttributeIgnoreList,v=e.elementsChainAsString,d=e.disableCaptureUrlHashes;if(!Ri(t))return{props:{}};for(var c=[t],f=new Set([t]),g=t;g.parentNode&&!Oi(g,"body")&&1e3>c.length;)if($i(g.parentNode)){var _=g.parentNode.host;if(f.has(_))break;f.add(_),c.push(_),g=_}else{if(!Ri(g.parentNode))break;if(f.has(g.parentNode))break;f.add(g.parentNode),c.push(g.parentNode),g=g.parentNode}var b="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?c.findIndex(t=>Oi(t,"button")||Oi(t,"a")):-1;b>0&&(l=l||c.slice(0,b+1).some(t=>!Yi(t)||te(t)));var y,m,w,S=[],k={},x=!1,E=!1;if(xi(c,t=>{var i=Yi(t);if(Oi(t,"a")&&!o&&(null==u||!u.includes("href"))){var e=t.getAttribute("href");x=!!(i&&e&&le(e))&&(d?G(e):e)}n(Di(t),"ph-no-capture")&&(E=!0),S.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};Bi.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?or(1024,ue(t)):or(1024,Ni(t)));var o=Di(t);i||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),xi(t.attributes,function(e){var n;if((!te(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&le(e.value)&&(!p(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=Ii(o).join(" ")),a["attr__"+e.name]=or(1024,"href"===e.name&&s?G(o):o)}});for(var l=1,u=1,h=t;h=lr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,d)),xi(function(t){if(!Yi(t))return{};var i={};return xi(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&&le(r)&&(i[e]=r)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(k,i)||(k[i]=t)})}),E)return{props:{},explicitNoCapture:E};if(b>0&&(t=c[b],S.splice(0,b)),l||(S[0].$el_text=Oi(t,"a")||Oi(t,"button")?ue(t):Ni(t)),x){var C,P;S[0].attr__href=x;var F=null==(C=Ye(x))?void 0:C.host,T=null==fi||null==(P=fi.location)?void 0:P.host;F&&T&&F!==T&&(y=x)}return{props:Ei((m=a.type,{$event_type:m,$ce_version:1}),v?{}:{$elements:S},{$elements_chain:(w=S,h(w)?function(t){return t.map(t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Ci(a).sort((t,i)=>{return(r=i[0])>(e=t[0])?-1:e>r?1:0;var e,r}).forEach(t=>{var i=t[1];return o[ve(t[0].toString())]=ve(i.toString())}),(s+=":")+Ci(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:de(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ci(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(w)):"")},null!=(r=S[0])&&r.$el_text?{$el_text:null==(s=S[0])?void 0:s.$el_text}:{},y&&"click"===a.type?{$external_click_url:y}:{},k),target:t}}var hr=class{co(){this.do=void 0,clearTimeout(this.vo),this.vo=void 0}fo(t){var i;if(!Yi(t))return!0;for(var e,r=null!==(i=this.po().css_selector_ignorelist)&&void 0!==i?i:Vi,s=new Set,a=t,o=function(){if(s.size>=1e3||s.has(a))return{v:!0};s.add(a);var t=a,i=Di(t);if(n(i,"ph-no-capture")||n(i,"ph-sensitive")||te(t)||r.some(i=>zi(t,i)))return{v:!0};var e=a.parentNode;a=$i(e)?e.host:e&&Ri(e)?e:null};a;)if(e=o())return e.v;return!1}mo(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var i=this.do;i&&(t.pointerId!==i.id||Math.abs(t.clientX-i.x)>5||Math.abs(t.clientY-i.y)>5?this.co():"pointerup"===t.type&&(i.released=!0,this.vo=setTimeout(()=>this.co(),0)))}else{var e;this.co();var r=Hi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&Ri(r)&&(this.do={target:r,excluded:this.fo(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(e=this.yo)?void 0:e.distinctId})}else this.co()}bo(t){var i,e=this.do;this.co();var r=Hi(t);if(null!=e&&e.released&&e.target.isConnected&&e.distinctId===(null==(i=this.yo)?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&r&&(Oi(r,"html")||Oi(r,"body"))){var s;if(e.excluded)return null;var a=null!==(s=this.po().css_selector_ignorelist)&&void 0!==s?s:Vi;return[r,null==_i?void 0:_i.documentElement,null==_i?void 0:_i.body].some(t=>{if(!t)return!1;var i=Di(t);return n(i,"ph-no-capture")||n(i,"ph-sensitive")||!Yi(t)||te(t)||a.some(i=>zi(t,i))})?null:e.target}}constructor(t){this._o=t,this.name="autocapture",this.wo=!1,this.ko=null,this.So=!1,this.xo=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.$o=!1,this._o.refresh(this.Mr),this.rageclicks=new ce(this.Mr.rageclick),this.To=null}setup(t){this.Io(),this.yo=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.$o?i.dispose():(this.Mo=i,this.startIfEnabled())}dispose(){var t;this.$o||(this.$o=!0,this.yo=void 0,null==(t=this.Mo)||t.dispose(),this.Mo=void 0,this.xo.clear(),this.To=null,this.Eo())}po(){return this._o.refresh(this.Mr),this.Mr}Io(){var t,i;return this.po(),this.Mr.url_allowlist=null==(t=this.Mr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Mr.url_ignorelist=null==(i=this.Mr.url_ignorelist)?void 0:i.map(t=>new RegExp(t)),this.Mr}Po(){if(this.isBrowserSupported()){if(fi&&_i){var t=this.Ro=t=>{t=t||(null==fi?void 0:fi.event);try{if("blur"===t.type)return void this.co();if(0===t.type.indexOf("pointer"))return void this.mo(t);var i="click"===t.type?this.bo(t):void 0;if(_(i))return;this.Ao(t,"$autocapture",i)}catch(t){ar.error("Failed to capture event",t)}};if(Pi(fi,"blur",t),Pi(_i,"submit",t,{capture:!0}),Pi(_i,"change",t,{capture:!0}),Pi(_i,"click",t,{capture:!0}),xi(["pointerdown","pointermove","pointerup","pointercancel"],i=>{Pi(_i,i,t,{capture:!0})}),this.po().capture_copied_text){var i=this.Fo=t=>{t=t||(null==fi?void 0:fi.event);try{this.Ao(t,nr)}catch(t){ar.error("Failed to capture clipboard event",t)}};Pi(_i,"copy",i,{capture:!0}),Pi(_i,"cut",i,{capture:!0}),Pi(_i,"paste",i,{capture:!0})}}}else ar.info("Disabling Automatic Event Collection because this browser is not supported")}Eo(){this.co(),this.Ro&&(null==fi||fi.removeEventListener("blur",this.Ro),xi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==_i||_i.removeEventListener(t,this.Ro,!0)}),null==_i||_i.removeEventListener("submit",this.Ro,!0),null==_i||_i.removeEventListener("change",this.Ro,!0),null==_i||_i.removeEventListener("click",this.Ro,!0),this.Ro=void 0),this.Fo&&(null==_i||_i.removeEventListener("copy",this.Fo,!0),null==_i||_i.removeEventListener("cut",this.Fo,!0),null==_i||_i.removeEventListener("paste",this.Fo,!0),this.Fo=void 0),this.wo=!1}startIfEnabled(){this.isEnabled||this.co(),!this.$o&&this.yo&&this.isEnabled&&!this.wo&&(this.Po(),this.wo=!0)}onRemoteConfig(t){if(!this.$o)if(this.So=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.Co=i.elementsChainAsString);var e,r=i.autocapture_opt_out;m(r)&&(null==(e=this.yo)||e.kv.set(fe,r),this.ko=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,i){if(void 0===i&&(i=this),!this.$o){t.size?this.xo.set(i,new Set(t)):this.xo.delete(i);var e=new Set;this.xo.forEach(t=>{t.forEach(t=>e.add(t))}),this.To=e}}getElementSelectors(t,i){var e,r=[];return null==(e=this.To)||e.forEach(e=>{var s;null==_i||null==(s=_i.querySelectorAll(e))||s.forEach(s=>{t!==s&&i!==s||n(r,e)||r.push(e)})}),r}get isEnabled(){var t,i;if(this.$o)return!1;var e=null==(t=this.yo)?void 0:t.kv.get(fe),r=this.ko,s=this.po();if(!s.remoteRequestsDisabled&&!this.So)return!1;var n=s.remoteRequestsDisabled&&!this.So;if(_(r)&&!m(e)&&!n)return!1;var a=null!==(i=this.ko)&&void 0!==i?i:!!e;return!!s.enabled&&!a}Ao(t,e,r){if(void 0===e&&(e="$autocapture"),this.isEnabled){var s=r||Hi(t);Mi(s)&&(s=s.parentNode||null);var n,a=this.Io();"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&a.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Xi(s,a.rageclick)&&this.Ao(t,"$rageclick",r);var o=e===nr,l=o?i({},a,{dom_event_allowlist:void 0}):a;if(s&&function(t,i,e,r,s,n){var a;if(!fi||Zi(t))return!1;if(null!=e&&e.url_allowlist&&!ji(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&ji(e.url_ignorelist,n))return!1;if(null!=e&&e.dom_event_allowlist){var o=e.dom_event_allowlist;if(o&&!o.some(t=>i.type===t))return!1}var l=Qi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(f(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}(h,e))return!1;if(!Ui(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Ui(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:Vi))return!1;try{var v=fi.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return u?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(Bi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:a.getCurrentUrl}})){var u,h=ur(s,{e:t,maskAllElementAttributes:a.maskAllElementAttributes,maskAllText:a.maskAllText,elementAttributeIgnoreList:a.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:a.disableCaptureUrlHashes}),v=h.props;if(h.explicitNoCapture)return!1;var d=this.getElementSelectors(s,h.target);if(d&&d.length>0&&(v.$element_selectors=d),e===nr){var c=t.type||"clipboard";if("paste"!==c){var p,g,_=null==fi||null==(p=fi.getSelection())?void 0:p.toString(),b=Li(_);if(!b)return!1;v.$selected_content=b,v.$clipboard_text_length=null!==(g=null==_?void 0:_.length)&&void 0!==g?g:0}v.$copy_type=c}return null==(u=this.yo)||u.capture(e,v),!0}}else this.co()}isBrowserSupported(){return v(null==_i?void 0:_i.querySelectorAll)}},vr=class{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=d(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._shouldDisableFlags(),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}},dr="undefined"!=typeof globalThis?globalThis:fi;dr&&"undefined"==typeof self&&(dr.self=dr),dr&&"undefined"==typeof File&&(dr.File=function(){});var cr=null!=fi?fi:{},fr=Si("[Dead Clicks]"),pr=()=>!0,gr=class{get lazyLoadedDeadClicksAutocapture(){return this.jo}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({[me]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Bo(()=>{this.Ho()}):this.stop()}Bo(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?fr.error("failed to load script",i):t()})}Ho(){var t;if(_i){if(!this.jo&&null!=(t=cr.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=d(this.instance.config.capture_dead_clicks)?i({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.jo=cr.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.jo.start(_i),fr.info("starting...")}}else fr.error("`document` not found. Cannot start.")}stop(){this.jo&&(this.jo.stop(),this.jo=void 0,fr.info("stopping..."))}},_r=Si("[ExceptionAutocapture]"),br=()=>{},yr=t=>{var i;if(v(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function mr(t,i,e){try{if(!(i in t))return br;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=yr(e);n;){if(n.next===s)return void(n.next=r.next);n=yr(e=n.next)}else t[i]=r.next}}catch(t){return br}}var wr=Si("[TracingHeaders]"),Sr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],kr=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Sr],xr="<masked>",Er=["li_fat_id"];function Cr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Pr=Si("[Web Vitals]"),Fr=9e5,Tr=["CLS","FCP","INP","LCP"],Ar=["INP","LCP"],Rr=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Or=Si("[RemoteConfig]"),Mr=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=cr._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Xa(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Ya(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 Or.info("Using preloaded remote config",this.remoteConfig),void this.tl(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Or.warn("Remote config is disabled. Falling back to local config.");this.Xa(t=>{if(!t)return Or.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ya(t=>{this.tl(t.json,t)});this.tl(t)})}catch(t){Or.error("Error loading remote config",t),this.tl()}}tl(t,i){!t&&i&&(0===i.statusCode?i.error||Or.warn("Failed to fetch remote config from PostHog."):Or.error("Failed to fetch remote config from PostHog."));try{this._instance.tl(t?{ok:!0,config:t}:{ok:!1})}catch(t){Or.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){Or.error("Error loading feature flags",t)}}},$r="disabled",Ir="lazy_loading",jr=Si("[SessionRecording]"),Dr=[Je,Ge,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],Lr=Si("[Heatmaps]");function Nr(t){return d(t)&&"clientX"in t&&"clientY"in t&&y(t.clientX)&&y(t.clientY)}var Hr=Si("[Product Tours]"),Br=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(we))},zr=Si("[SiteApps]"),Ur="Error while initializing PostHog app with config id ",qr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Vr="events",Wr="cancelEvents",Kr="survey shown",Jr="survey dismissed",Gr="survey sent";function Xr(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var Zr=(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}},Qr=t=>t.toLowerCase(),Yr={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=>Zr(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!Zr(i,t))),icontains:(t,i)=>i.map(Qr).some(i=>t.map(Qr).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Qr).every(i=>t.map(Qr).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 ts(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=Yr[e.operator];return!!s&&s(e.values.map(String),[String(r)])})}var is=Si("[Surveys]"),es=["popover","widget","api"],rs="SDK is not enabled or survey functionality is not yet loaded",ss="Disabled. Not loading surveys.",ns=class{constructor(t,i){this._o=t,this.$h=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Th=!1,this.Ih=!1,this.Mh=[],this.Eh=[],this.Ph=null,this.Rh=null,this.$o=!1,this.Ah=new Set,this.onRemoteConfig=t=>{if(!this.$o&&!this.Mr.disableSurveys){if(!t.ok)return this.Ih=!0,this.Fh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),is.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(b(i))return is.warn("Flags not loaded yet. Not loading surveys.");this.Oh=m(i)?i:i.length>0,is.info("flags response received, isSurveysEnabled: "+this.Oh),this.loadIfEnabled()}},this.Fh=t=>{this.Eh.slice().forEach(i=>this.Dh(i,t))}}setup(t){if(!this.$o)return this.Lh=t,qr(t.kv.initialize(),()=>{if(this.Lh===t&&!this.$o){this.Lh=void 0,this.yo=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.$o?i.dispose():(this.Mo=i,this.loadIfEnabled())}})}dispose(){var t,i,e,r;this.$o||(this.$o=!0,this.Lh=void 0,this.yo=void 0,null==(t=this.Mo)||t.dispose(),this.Mo=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Mh=[],this.Eh.forEach(t=>{t.active=!1}),this.Eh=[],null==(r=this.Nh)||r.call(this),this.Nh=void 0,this.Ph=null,this.Ah.forEach(t=>clearTimeout(t)),this.Ah.clear())}get Mr(){return this._o.get()}initialize(){this.loadIfEnabled()}reset(){var t;null==(t=this._surveyManager)||null==t.clearInMemoryInProgressSurveyState||t.clearInMemoryInProgressSurveyState();try{var i;null==(i=this._surveyEventReceiver)||i.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],r=0;r<localStorage.length;r++){var s=localStorage.key(r);(null!=s&&s.startsWith("seenSurvey_")||null!=s&&s.startsWith("inProgressSurvey_"))&&e.push(s)}e.forEach(t=>localStorage.removeItem(t))}catch(t){}this.Fh()}loadIfEnabled(){if(!this.$o&&this.yo){var t=this.Mr;if(!this._surveyManager)if(this.Th)is.info("Already initializing surveys, skipping...");else if(t.disableSurveys)is.info(ss);else if(t.cookielessMode&&this._o.isOptedOut())is.info("Not loading surveys in cookieless mode without consent.");else{var i=this._o.getExtensions();if(i){if(!f(this.Oh)||t.advancedEnableSurveys){var e=this.Oh||t.advancedEnableSurveys;this.Th=!0,this.Ih=!1;try{var r=i.generateSurveys;if(r)return this.jh(r,e),void(this.Th=!1);var s=i.loadExternalDependency;if(!s)return this.qh(Xe),void(this.Th=!1);s(t=>{try{if(this.$o)return;var i=this._o.getExtensions();t||null==i||!i.generateSurveys?this.qh("Could not load surveys script",t):this.jh(i.generateSurveys,e)}finally{this.Th=!1}})}catch(t){throw this.Th=!1,this.qh("Error initializing surveys",t),t}}}else this.qh("PostHog Extensions not found.")}}}jh(t,i){var e,r;if(!this.$o){this._surveyManager=t(i),this._surveyEventReceiver=this._o.createEventReceiver(this.Fh);var s=null==(e=null!==(r=this.yo)&&void 0!==r?r:this.$h)?void 0:e.kv.get(Le);s&&this.Bh(s),is.info("Surveys loaded successfully"),this.Hh(),this.Fh(),this.zh({isLoaded:!0})}}qh(t,i){this.Ih=!0,is.error(t,i),this.Fh({isLoaded:!1,error:t}),this.zh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Mh.push(t),this._surveyManager&&this.zh({isLoaded:!0}),()=>{this.Mh=this.Mh.filter(i=>i!==t)}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.yo)&&void 0!==e?e:this.$h;if(r&&!this.$o){if(this.Mr.disableSurveys)return is.info(ss),t([]);var s=r.kv.get(Le);if(s&&!i)return t(s,{isLoaded:!0}),void(this.Uh()&&this.getSurveys(()=>{},!0));if(this.Ph)this.Ph.then(i=>{this.$o||t(i.surveys,i.context)}).catch(t=>is.error("Error in survey callback",t));else{var n=this.Wh("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(t=>{try{return this.Vh(r,t)}catch(t){return is.error("Error processing surveys response",t),this.Vh(r,{statusCode:0,error:t})}},t=>this.Vh(r,{statusCode:0,error:t}));this.Ph=n;var a=()=>{this.Ph===n&&(this.Ph=null)};n.then(i=>{a(),this.$o||(this.Fh(i.context),t(i.surveys,i.context))},a).catch(t=>is.error("Error in survey callback",t))}}}Wh(t,i){var e=this.yo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(rs)}))}Vh(t,i){if(this.$o)return{surveys:[],context:{isLoaded:!1,error:rs}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?is.error(r):i.error||is.warn(r),this.Rh=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Rh=null;var s=i.json.surveys||[];return t.kv.set({[Le]:s,[Ne]:Date.now()}),this.Bh(s),{surveys:s,context:{isLoaded:!0}}}Bh(t){var i,e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Xr(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t)));null==(i=this._surveyEventReceiver)||i.replace(e)}Uh(){return this.Gh()&&!this.Ph&&!this.Zh()}Gh(){var t,i,e=null==(t=null!==(i=this.yo)&&void 0!==i?i:this.$h)?void 0:t.kv.get(Ne);return y(e)&&Date.now()-e>3e5}Zh(){return y(this.Rh)&&3e5>Date.now()-this.Rh}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>"seenSurvey_"+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){is.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Fh()}zh(t){for(var i of this.Mh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){is.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!b(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);is.warn("init was not called")}onActiveMatchingSurveysChanged(t){var i,e;if(this.$o)return()=>{};var r={callback:t,active:!0,revision:0};this.Eh.push(r),this.Hh();var s=null==(i=null!==(e=this.yo)&&void 0!==e?e:this.$h)?void 0:i.kv.get(Le);return this.Mr.disableSurveys||!this._surveyManager&&this.Ih&&!this.Th||!s&&!b(this.Rh)&&!this.Ph?this.Dh(r,{isLoaded:!1}):this._surveyManager&&this.Dh(r),()=>{var t;r.active=!1,this.Eh=this.Eh.filter(t=>t!==r),0===this.Eh.length&&(null==(t=this.Nh)||t.call(this),this.Nh=void 0)}}Hh(){var t,i,e;this._surveyManager&&this.Eh.length>0&&(null!==(t=this.Nh)&&void 0!==t||(this.Nh=null==(i=(e=this._o).onMatchingConditionsChanged)?void 0:i.call(e,this.Fh)))}Dh(t,i){if(!this.$o&&t.active){var e=++t.revision,r=r=>{if(!this.$o&&t.active&&e===t.revision)try{var s=null!=i?i:{isLoaded:!0},n=JSON.stringify([r,s]);if(n===t.lastResult)return;t.lastResult=n,t.callback(r,s)}catch(t){is.error("Error in active matching surveys callback",t)}};try{i&&!i.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){is.error("Error in active matching surveys callback",t)}}}Qh(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}Jh(t){if(b(this._surveyManager))return{eligible:!1,reason:rs};var i="string"==typeof t?this.Qh(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Kh(t){if(!this._o.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(b(this._surveyManager))return{eligible:!1,reason:rs};var i="string"==typeof t?this.Qh(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(b(this._surveyManager))return is.warn("init was not called"),{visible:!1,disabledReason:rs};var i=this.Kh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return b(this._surveyManager)?(is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:rs})):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.Kh(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var r;if(this._o.isCapturing())if(b(this._surveyManager))is.warn("init was not called");else{var s="string"==typeof t?this.Qh(t):t;if(null!=s&&s.id)if(es.includes(s.type)){var n=null==_i?void 0:_i.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){is.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout(()=>{var t,i;this.Ah.delete(a),!this.$o&&this._o.isCapturing()&&(is.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(s,n,e),is.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.Ah.add(a)}else this._surveyManager.renderSurvey(s,n,e);else is.warn("Survey element not found")}else is.warn("Surveys of type "+s.type+" cannot be rendered in the app");else is.warn("Survey not found")}}displaySurvey(t,e){var r;if(this._o.isCapturing())if(b(this._surveyManager))is.warn("init was not called");else{var s=this.Qh(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.Jh(s);if(!a.eligible)return void is.warn("Survey is not eligible to be displayed: ",a.reason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else is.warn("Survey not found")}}cancelPendingSurvey(t){b(this._surveyManager)?is.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};ci.DEBUG=!1,ci.LIB_VERSION="1.435.2",ci.LIB_NAME="web";var as=ci,os=new WeakMap,ls=class{on(t,i){return this.Ml[t]||(this.Ml[t]=[]),this.Ml[t].push(i),()=>{this.Ml[t]=this.Ml[t].filter(t=>t!==i)}}emit(t,i){for(var e of this.Ml[t]||[])e(i);for(var r of this.Ml["*"]||[])r(t,i)}constructor(){this.Ml={}}};function us(t,i,e){if(b(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}}var hs=class{constructor(t){this._instance=t,this.Xh=new Set,this.Yh=new Set,this.tc=new ls,this.ec=(t,i)=>this.nc(t,i)&&this.sc(t,i)&&this.rc(t,i)&&this.oc(t,i),this.nc=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;f(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.ac=null==(i=this._instance)?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t,i;null==(t=this.ac)||t.call(this),this.ac=void 0,null==(i=this._instance)||null==(i=i.autocapture)||i.setElementSelectors(new Set,this),this.tc=new ls}register(t){var i,e;if(!f(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Xh.add(t),null==(i=t.steps)||i.forEach(t=>{this.Yh.add((null==t?void 0:t.event)||"")})}),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Xh.forEach(t=>{var i;null==(i=t.steps)||i.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this._instance.autocapture.setElementSelectors(r,this)}}replace(t){this.Xh.clear(),this.Yh.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Yh.has(t)||this.Yh.has(i.event))&&this.Xh.forEach(t=>{this.lc(i,t)&&this.tc.emit("actionCaptured",t.name)})}uc(t){this.onAction("actionCaptured",i=>t(i))}lc(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.ec(t,e))return!0;return!1}onAction(t,i){return this.tc.on(t,i)}sc(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(!us(r,i.url,i.url_matching||"contains"))return!1}return!0}rc(t,i){return!!this.hc(t,i)&&!!this.cc(t,i)&&!!this.dc(t,i)}hc(t,i){var e;if(null==i||!i.href)return!0;var r=this.vc(t);if(r.length>0)return r.some(t=>us(t.href,i.href,i.href_matching||"exact"));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&us((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}cc(t,i){var e;if(null==i||!i.text)return!0;var r=this.vc(t);if(r.length>0)return r.some(t=>us(t.text,i.text,i.text_matching||"exact")||us(t.$el_text,i.text,i.text_matching||"exact"));var s,n,a,o=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!o&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!b(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(o),n=i.text,a=i.text_matching||"exact",s.some(t=>us(t,n,a)))}dc(t,i){var e,r;if(null==i||!i.selector)return!0;if(null!=t&&null!=(e=t.properties)&&null!=(e=e.$element_selectors)&&e.includes(i.selector))return!0;var s=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&s)try{return new RegExp(i.selector_regex).test(s)}catch(t){return!1}return!1}vc(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}oc(t,i){return null==i||!i.properties||0===i.properties.length||ts(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)}},vs=class{constructor(t,i){var e;this.fc=[],this._instance=t,this.gc=i,this.mc=new Map,this.yc=new Map,this.bc=new Map,this._c=null==(e=this._instance)||null==e.onSessionId?void 0:e.onSessionId(t=>this.wc(t))}kc(t){return!1}Sc(){return null}xc(t){}Cc(){}$c(t,i){return!!t&&ts(t.propertyFilters,null==i?void 0:i.properties)}Tc(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}Ic(t,i,e){var r=(e===Vr?this.mc:this.yc).get(t),s=[];return this.Mc(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.$c(n,i)})}register(t){this.Ec(t,!1)}replace(t){this.Ec(t,!0)}Ec(t,i){var e;f(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Pc(t,i),this.Rc(t,i))}Rc(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.bc.clear(),0!==e.length){this.Ac||(this.Ac=new hs(this._instance),this.Ac.init(),this.Ac.uc(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.bc.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.bc.set(i.name,s)}})}),i?this.Ac.replace(r):this.Ac.register(r)}else{var s;i&&(null==(s=this.Ac)||s.replace([]))}}Fc(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)})}Pc(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}),a=this.Tc(t,Vr),o=this.Tc(t,Wr);i?(this.mc=a,this.yc=o):(this.Fc(this.mc,a),this.Fc(this.yc,o)),(0!==s.length||0!==n.length||t.some(t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length}))&&(null!==(e=this.ac)&&void 0!==e||(this.ac=null==(r=this._instance)?void 0:r._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,r,s=this.Oc(),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 a=this.Dc(t,n,i);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Lc([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Nc(n),void this.qc([n])}if(this.yc.has(t)){var o=this.Ic(t,i,Wr);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.Lc(o.map(t=>t.id)),o.forEach(t=>this.jc(t.id)))}if(this.mc.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.mc.get(t)});var l=this.Ic(t,i,Vr);this.Bc(l.map(t=>t.id))}}onAction(t){this.bc.has(t)&&this.Bc(this.bc.get(t)||[])}Bc(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.kc(s)?this.Nc(s)&&this.Hc(s):r.push(s);r.length>0&&(this.fc=[...new Set([...this.fc,...r])]),this.Oc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.zc()}}Nc(t){this.fc=this.fc.filter(i=>i!==t);var i=this.Uc();return!i.includes(t)&&(this.Wc([...i,t]),this.Vc(),!0)}Lc(t){var i=new Set(t);this.fc=this.fc.filter(t=>!i.has(t));var e=this.Gc(),r=e.filter(t=>!i.has(t));r.length!==e.length&&(this.Wc(r),0===r.length&&this.Zc()),this.qc(t),this.zc()}zc(){try{var t;null==(t=this.gc)||t.call(this)}catch(t){this.Oc().error("Error while handling activated items change",t)}}Qc(){var t,i=this.Sc();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}Hc(t){if(this.Sc()){var e=this.Qc();this.xc(i({},e,{[t]:Date.now()}))}}qc(t){if(this.Sc()){var i=this.Qc(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],a=s[1];t.includes(n)?r=!0:e[n]=a}r&&(c(e)?this.Cc():this.xc(e))}}Jc(){this.Sc()&&this.Cc()}getActivationTimestamp(t){if(this.Uc().includes(t)){var i=this.Qc()[t];return y(i)?i:void 0}}Gc(){var t,i=this.Kc();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}Uc(){var t,i,e=this.Gc();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Xc()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Vc(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Yc(i)}Zc(){this.td()}wc(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Xc()];if(e&&e!==t){var r=this.Gc(),s=this.Qc();r.length>0&&(this.Wc([]),r.filter(t=>y(s[t])).forEach(t=>this.jc(t))),this.Zc(),this.Jc(),r.length>0&&this.zc()}}getActivatedIds(){return[...new Set([...this.Uc(),...this.fc])].filter(t=>!this.ed(t))}dispose(){var t,i,e;null==(t=this._c)||t.call(this),this._c=void 0,null==(i=this.ac)||i.call(this),this.ac=void 0,null==(e=this.Ac)||e.dispose(),this.Ac=void 0}reset(){this.fc=[],this.Gc().length>0&&this.Wc([]),this.Zc(),this.Jc(),this.zc()}getEventToItemsMap(){return this.mc}nd(){return this.Ac}},ds=class extends vs{constructor(t,i){super(t,i)}Kc(){return He}Xc(){return Be}Sc(){return ze}xc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[ze]:t})}Cc(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(ze)}kc(t){var i,e;this.Mc(i=>{e=i.find(i=>i.id===t)});var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return y(r)&&r>0}sd(){return Kr}Mc(t){var i;null==(i=this._instance)||i.getSurveys(t)}jc(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Oc(){return is}Wc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[He]:t})}Yc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Be]:t})}td(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Be)}ed(){return!1}Dc(t,i,e){var r,s;return t===Gr&&!1===(null==e||null==(r=e.properties)?void 0:r.$survey_completed)?"ignore":(this.Mc(t=>{s=t.find(t=>t.id===i)}),!s||function(t){var i;return Xr(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(s)?t===Kr?"consume":"ignore":t===Kr?"persist":t===Jr||t===Gr?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},cs=class{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);f(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)}},fs=class{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()}isCapturing(){return this._instance.is_capturing()}getExtensions(){var t=null==cr?void 0:cr.__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(t){return new ds(this._instance,t)}onMatchingConditionsChanged(t){var i=this._instance._addCaptureHook(i=>{"$pageview"!==i&&i!==Kr&&i!==Jr&&i!==Gr||t()}),e=()=>t();Pi(fi,"PHSurveyShown",e);var r=!1,s=this._instance.onFeatureFlags(()=>{r&&t()});return r=!0,()=>{r=!1,i(),s(),null==fi||fi.removeEventListener("PHSurveyShown",e)}}},ps=null!=fi&&fi.location?er(fi.location.hash,"__posthog")||er(location.hash,"state"):null,gs="_postHogToolbarParams",_s=Si("[Toolbar]"),bs=Si("[FeatureFlags]"),ys=class{constructor(t,i){void 0===i&&(i=!1),this.rd=!1,this.update(t,i)}update(t,i){this.od=((t,i)=>{var e,r,s,n,a,o,l,u;return{bootstrap:{featureFlags:null!==(e=null==(r=t.bootstrap)?void 0:r.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(s=null==(n=t.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:void 0},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!==(a=t.remote_config_refresh_interval_ms)&&void 0!==a?a:3e5,idleRefreshBackoff:f(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(o=t.feature_flag_request_max_retries)&&void 0!==o?o:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(u=t.evaluation_contexts)&&void 0!==u?u:t.evaluation_environments)&&void 0!==l?l:[],flagKeys:h(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.rd||(bs.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.rd=!0),f(t.flag_keys)||h(t.flag_keys)||bs.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.od}},ms=Si("[FeatureFlags]"),ws=Si("[FeatureFlags]",{debugEnabled:!0}),Ss="\" failed. Feature flags didn't load in time.",ks=[502,504],xs=["click","keydown","wheel","touchstart","pointerdown"],Es="connection_error",Cs=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},Ps=t=>{var i={};for(var e of Ci(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},Fs=t=>k(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Ts=Si("[Error tracking]"),As="webkit-masked-url:",Rs=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Os=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",As],Ms=["__firefox__","__gCrWeb"],$s="Refusing to render web experiment since the viewer is a likely bot",Is={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Zr(i,t),not_regex:(t,i)=>!Zr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},js=Si("[Conversations]"),Ds="Conversations not available yet.";function Ls(){var t="",e="";try{var r=null==gi?void 0:gi.userAgent;if(r){var s=function(t){for(var i=0;N.length>i;i++){var e=N[i],r=e[1],s=e[0].exec(t),n=s&&(v(r)?r(s,t):r);if(n)return n}return["",""]}(r);t=s[0],e=s[1]}}catch(t){}return function(t,e){var r=function(t){if(t)return{}.hasOwnProperty.call(Zt,t)?Zt[t]:t}(t);return i({},r?{"os.name":r}:{},e?{"os.version":e}:{})}(t,e)}function Ns(t,e){var r,s,n,a,o,l,u,h=null!==(r=null==t?void 0:t.flushIntervalMs)&&void 0!==r?r:3e3,v=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=null!=e&&e.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=f(d)?Math.max(v,2048):Math.max(v,d),p=i({},Ls(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(a=null!==(o=null==p?void 0:p["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==a?a:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(l=null==p?void 0:p["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(u=null==p?void 0:p["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:p,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:v,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Hs=["debug","log","warn","error","info"],Bs="console",zs="__posthogHandledLogsRequestError",Us=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[zs]=!0,e},qs=t=>!!t&&"object"==typeof t&&!0===t[zs],Vs=Si("[NetworkMetrics]"),Ws=()=>{var t;return null!=fi&&null!=(t=fi.performance)&&t.now?fi.performance.now():Date.now()},Ks={"http:":80,"https:":443},Js=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Gs=(t,i)=>{var e,r=String(i);return{method:String(t).toUpperCase(),url:(null==(e=Ye(r))?void 0:e.href)||r}},Xs=function(t,e,r,s,n,a,o){void 0===o&&(o=!1);try{var l,u=n();if(!u)return;var h=r||void 0,d=Ws()-s,c=Ye(e.url);if(c&&"http:"!==c.protocol&&"https:"!==c.protocol)return;var f={url:(null==c?void 0:c.href)||e.url,method:e.method},g=v(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var _=o&&!h?void 0:((t,i)=>t?400>t?void 0:String(t):(null==i?void 0:i.name)||"_OTHER")(h,a),b=i({},i({"http.request.method":m=Js.has(y=f.method)?y:"_OTHER"},"_OTHER"===m&&y!==m?{"http.request.method_original":y}:{}),c?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Ks[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(i=t.pathname,i.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var i})(c):{},h?{"http.response.status_code":h}:{},_?{"error.type":_}:{},null==u.attributes?void 0:u.attributes(f,{status:h,durationMs:d}));null==(l=t.metrics)||l.histogram(g,d,{unit:"ms",attributes:b})}catch(t){Vs.error("Failed to record network metric",t)}var y,m},Zs=()=>{},Qs=(t,i)=>v(null==fi?void 0:fi.fetch)?mr(fi,"fetch",e=>function(){for(var r=Ws(),s=arguments.length,n=new Array(s),a=0;s>a;a++)n[a]=arguments[a];var o=e.apply(this,n);if(!i())return o;try{var l,u,h,v=n[0],d=n[1],c=Gs(null!==(l=null!==(u=null==d?void 0:d.method)&&void 0!==u?u:null==v?void 0:v.method)&&void 0!==l?l:"GET",null!==(h=null==v?void 0:v.url)&&void 0!==h?h:v);return o.then(e=>(Xs(t,c,null==e?void 0:e.status,r,i,void 0,!0),e),e=>{throw Xs(t,c,void 0,r,i,e),e})}catch(t){return Vs.error("Failed to observe fetch",t),o}}):Zs,Ys=(t,i)=>{var e,r=null==fi||null==(e=fi.XMLHttpRequest)?void 0:e.prototype;if(!r)return Zs;var s=new WeakMap,n=mr(r,"open",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];try{os.has(this)||s.set(this,Gs(e[0],e[1]))}catch(t){Vs.error("Failed to observe XHR open",t)}return t.apply(this,e)}),a=mr(r,"send",e=>function(){var r;try{var n=s.get(this);if(n&&i()){var a=Ws();Pi(this,"loadend",r=()=>{this.removeEventListener("loadend",r),Xs(t,n,this.status,a,i)})}}catch(t){Vs.error("Failed to observe XHR send",t)}try{for(var o=arguments.length,l=new Array(o),u=0;o>u;u++)l[u]=arguments[u];return e.apply(this,l)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{n(),a()}},tn={featureFlags:class{constructor(t){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.A=ms,this.ld={},this.ud={},this.hd=[],this.dd=!1,this.vd=!1,this.fd=0,this.pd=!1,this.gd=!1,this.md=!1,this.yd=!1,this.bd=0,this._d=!1,this.rn=()=>{var t=this.wd();this.bd=0,t&&this.reloadFeatureFlags()},this.kd=()=>{var t,i,e=this.Sd,r=null!==(t=this.xd)&&void 0!==t?t:e;f(e)||f(r)||this.Mr.remoteRequestsDisabled||!_i||"hidden"===_i.visibilityState||Date.now()-(null!==(i=this.Cd)&&void 0!==i?i:0)<r||(this.xd=this._d||!this.Mr.idleRefreshBackoff?e:Math.min(2*r,36e5),this._d=!1,this.reloadFeatureFlags(),this.$d())},this.Td=()=>{this._d&&this.xd===this.Sd||this.Id()},this.sn=()=>{"visible"===(null==_i?void 0:_i.visibilityState)&&this.Id()},"get"in t?this._o=t:(this._instance=t,this.Md=new ys(t.config,t._shouldDisableFlags()),this._o=this.Md)}updateConfig(t,i){var e;null==(e=this.Md)||e.update(t,i),this.yo&&this.Ed()}setup(t){return this.Lh=t,this.A=t.logger.createLogger("[FeatureFlags]"),qr(t.kv.initialize(),()=>{this.Lh===t&&(this.Lh=void 0,this.yo=t,this.Pd(t))})}Pd(t){var i;if(this.yo===t)return fi&&Pi(fi,"online",this.rn),this.Ed(),this.Rd=t.registerDynamicEventProperties(()=>this.Ad()?this.ld:this.ud),this.Fd=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange(()=>{this.Od(),this.Dd(),this.Ld()}),this.Dd(),this.initialize()}Id(){this._d=!0,this.xd=this.Sd,this.kd()}Ed(){var t=this.Mr.refreshIntervalMs,i=!this.Mr.remoteRequestsDisabled&&_i&&!f(t)&&t>0?t:void 0;this.Mr.idleRefreshBackoff||(this.xd=i),i!==this.Sd&&(this.Nd(),f(i)||(this.Sd=i,this.xd=i,this.$d(),null!=_i&&_i.addEventListener&&(Pi(_i,Ze,this.sn),ki(xs,t=>{Pi(_i,t,this.Td,{capture:!0})}))))}$d(){f(this.Sd)||(f(this.qd)||clearInterval(this.qd),this.Cd=Date.now(),this.qd=setInterval(this.kd,this.Sd))}Nd(){f(this.qd)||(clearInterval(this.qd),this.qd=void 0,null==_i||null==_i.removeEventListener||_i.removeEventListener(Ze,this.sn),ki(xs,t=>{null==_i||null==_i.removeEventListener||_i.removeEventListener(t,this.Td,{capture:!0})})),this.Sd=void 0,this.xd=void 0,this._d=!1,this.Cd=void 0}destroy(){this.jd()}dispose(){this.jd()}jd(){var t,i;this.Nd(),this.fd++,this.gd=!1,this.Lh=void 0,this.yo&&(this.Bd(),null==(t=this.Rd)||t.dispose(),this.Rd=void 0,null==(i=this.Fd)||i.call(this),this.Fd=void 0,this.hd=[],null==fi||fi.removeEventListener("online",this.rn),this.yo=void 0)}get Mr(){return this._o.get()}Hd(t){var i;return this.zd&&t in this.zd?this.zd[t]:null==(i=this.yo)?void 0:i.kv.get(t)}Od(){return!!this.zd&&(this.zd=void 0,!0)}Ud(){var t;return!f(null==(t=this.yo)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Od()}$t(t){this.Wd(()=>{var i;return null==(i=this.yo)?void 0:i.kv.set(t)})}Vd(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t.$enabled_feature_flags){var s=this.Hd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},a=i.flags||i.featureFlags,o=i.flags?Object.entries(i.flags).filter(t=>{var i=t[1];return!(null!=i&&i.failed)}).map(t=>t[0]):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,u=l?o:e&&!h(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),v=this.Hd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=l||e?u:Array.from(new Set([...Object.keys(v),...Object.keys(d)])),p=!l&&!e,g=!!p||u,_=!!p||c,b={[Fe]:g,[Pe]:g,[Re]:_};for(var y of(t.$feature_flag_details&&(b[Ae]=g),[Oe,Ke,Me]))f(t[y])||(b[y]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(b)}}Lt(t){this.Wd(()=>{var i;return null==(i=this.yo)?void 0:i.kv.remove(t)})}Wd(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Dd(){var t={};for(var e of[Fe,Re,Oe,$e]){var r=this.Hd(e);f(r)||(t[e]=r)}this.ld=t;var s=i({},t),n=this.Hd(Pe);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.ud=s}Ad(){var t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;var i=this.Hd(Ke);return"number"!=typeof i||Date.now()-i>t}Gd(){return!!this.Ad()&&(this.yd||this.vd||(this.yd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Zd(){var t=this.Mr.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}Qd(){var t=this.Mr.flagKeys;if(!f(t))return t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i,e=this.Mr,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,i)=>(t[i]=r[i],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,i)=>(t[i]=a[i],t),{});return this.Jd({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,r){var s,n,a=null!=r&&r.merge&&null!==(s=this.Hd("$enabled_feature_flags"))&&void 0!==s?s:{},o=null!=r&&r.merge&&null!==(n=this.Hd("$feature_flag_payloads"))&&void 0!==n?n:{},l=i({},a,t),u=i({},o,e),h={};for(var v of Object.entries(l)){var d=v[0],c=v[1];h[d]={key:d,enabled:Bt(c),variant:zt(c),reason:void 0,metadata:f(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}}}this.Jd({flags:h})}get hasLoadedFlags(){return this.dd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Hd(Ae),e=this.Hd($e),r=this.Hd(Ie);if(!r&&!e)return t||{};var s=Ei({},t||{});for(var n of[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])]){var a,o,l=s[n],u=null==e?void 0:e[n],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,v=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,d=null==r?void 0:r[n],c=i({},l,{enabled:h,variant:h?null!=v?v:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),v!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),d&&(c.metadata=i({},null==l?void 0:l.metadata,{payload:d,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),s[n]=c}return this.ad||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.ad=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{var r=t[e];return{key:e,enabled:Bt(r),variant:zt(r),payload:Ht(i[e])}})}getFlagVariants(){var t=this.Hd(Pe),i=this.Hd($e);if(!i)return t||{};for(var e=Ei({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.ad||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.ad=!0),e}getFlagPayloads(){var t=this.Hd(Re),i=this.Hd(Ie);if(!i)return t||{};for(var e=Ei({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.ad||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.ad=!0),e}reloadFeatureFlags(){this.pd||this.Mr.featureFlagsDisabled||this.wd()||(this.vd&&(this.gd=!0),this.Kd||(this.hd.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.Kd=setTimeout(()=>{this.Xd()},5)))}Bd(){clearTimeout(this.Kd),this.Kd=void 0}onReloading(t){return this.hd.push(t),()=>{this.hd=this.hd.filter(i=>i!==t)}}ensureFlagsLoaded(){this.dd||this.vd||this.Kd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.pd=t}resetFlagCallReported(){this.Lt(qe)}Xd(t){this.Bd();var e=this.yo;if(e&&!this.Mr.remoteRequestsDisabled&&!this.wd())if(this.vd)this.gd=!0;else{var r={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},e.initialPersonProperties,this.Hd("$stored_person_properties")||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Hd(De),timezone:Cr()};f(e.deviceId)||(r.$device_id=e.deviceId),(null!=t&&t.disableFlags||this.Mr.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this.Zd();s.length&&(r.evaluation_contexts=s);var n=this.Qd();f(n)||(r.flag_keys=n);var a=this.Mr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),l=this.fd;this.vd=!0;var u=()=>{this.gd&&(this.gd=!1,this.Xd())},h=t=>{var i,e,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.vd=!1,l===this.fd){if(this.Yd(t.statusCode),n||this.gd||(this.$anon_distinct_id=void 0),!r.disable_flags||this.gd){this.md=!n;var o=[];t.error?o.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Es:"unknown_error"):200!==t.statusCode&&o.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var h=!(null==(e=s.quotaLimited)||!e.includes("feature_flags"));h&&o.push("quota_limited"),this.$t({[We]:o}),h?this.A.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."):r.disable_flags||this.Jd(s,n,{partialResponse:a}),u()}}else u()},v=t=>{this.vd=!1,l===this.fd?(this.$t({[We]:[Es]}),this.A.error("Feature flag request failed",t),this.Ud()&&this.Ld(!0),u()):u()},d=this.Mr.requestMaxRetries,c=()=>d>0&&l===this.fd,p=()=>{if(l!==this.fd||!this.yo||this.Mr.remoteRequestsDisabled)return this.vd=!1,void u();try{e.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(t=>{if((t=>ks.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&c())return d--,void setTimeout(p,500);h(t)}).catch(v)}catch(t){v(t)}};p()}}wd(){return rr(this.bd,3)}Yd(t){this.bd=sr(t,this.bd,3,()=>this.A.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.md)if(this.dd||this.getFlags()&&this.getFlags().length>0){if(!this.Gd()){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.A.warn('getFeatureFlag for key "'+t+Ss)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i;return null==(i=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:i.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.md)if(this.dd||this.getFlags()&&this.getFlags().length>0){if(!this.Gd()){var r,s=this.getFlagVariants(),n=t in s,a=s[t],o=this.getFlagPayloads()[t],l=String(a),u=this.Hd("$feature_flag_request_id")||void 0,v=this.Hd("$feature_flag_evaluated_at")||void 0,d=this.Hd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var c,p=null==(c=this.yo)?void 0:c.session.sessionId,g=this.Hd(Ve);p&&p!==g&&(d={},r=p)}if(e.send_event||!("send_event"in e))if(t in d&&d[t].includes(l))r&&this.$t({[qe]:d,[Ve]:r});else{var _,b,y,m,w,S,k,x,E,C,P,F,T;h(d[t])?d[t].push(l):d[t]=[l],this.$t(i({[qe]:d},r?{[Ve]:r}:{}));var A=this.getFeatureFlagDetails(t),R=[...null!==(_=this.Hd("$feature_flag_errors"))&&void 0!==_?_:[]];f(a)&&R.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:v,$feature_flag_bootstrapped_response:null!==(b=null==(y=this.Mr.bootstrap)||null==(y=y.featureFlags)?void 0:y[t])&&void 0!==b?b:null,$feature_flag_bootstrapped_payload:null!==(m=null==(w=this.Mr.bootstrap)||null==(w=w.featureFlagPayloads)?void 0:w[t])&&void 0!==m?m:null,$used_bootstrap_value:!this.md};f(null==A||null==(S=A.metadata)?void 0:S.has_experiment)||(O.$feature_flag_has_experiment=A.metadata.has_experiment),f(null==A||null==(k=A.metadata)?void 0:k.version)||(O.$feature_flag_version=A.metadata.version);var M=null!==(x=null==A||null==(E=A.reason)?void 0:E.description)&&void 0!==x?x:null==A||null==(C=A.reason)?void 0:C.code;M&&(O.$feature_flag_reason=M),null!=A&&null!=(P=A.metadata)&&P.id&&(O.$feature_flag_id=A.metadata.id),f(null==A?void 0:A.original_variant)&&f(null==A?void 0:A.original_enabled)||(O.$feature_flag_original_response=f(A.original_variant)?A.original_enabled:A.original_variant),null!=A&&null!=(F=A.metadata)&&F.original_payload&&(O.$feature_flag_original_payload=null==A||null==(T=A.metadata)?void 0:T.original_payload),R.length&&(O.$feature_flag_error=R.join(",")),this.tv(O)}else r&&this.$t({[qe]:d,[Ve]:r});if(n)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:Ht(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+Ss)}tv(t){try{var i;null==(i=this.yo)||i.capture("$feature_flag_called",t)}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.ev(t,i)}ev(t,i){var e=this;return r(function*(){var r=e.yo;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e.Zd();n.length&&(s.evaluation_contexts=n);var a,o=e.Qd();f(o)||(s.flag_keys=o);try{var l;a=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.Mr.compression,sentAt:"body",timeoutMs:e.Mr.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void e.A.error("Remote config feature flag request failed",t)}try{i(a)}catch(t){e.A.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.md)return i.defaultValue;if(!(this.dd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+Ss),i.defaultValue;var e=this.getFeatureFlag(t,i);return f(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.Jd(t,i,e)}Jd(t,e,r){if(this.yo){this.dd=!0;var s=function(t,e,r,s,n,a){void 0===e&&(e={}),void 0===r&&(r={}),void 0===s&&(s={}),void 0===a&&(a=ms);var o=((t,e)=>{var r=t.flags;return r?i({},t,{featureFlags:Object.fromEntries(Object.keys(r).map(t=>{var i;return[t,null!==(i=r[t].variant)&&void 0!==i?i:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>r[t].enabled).filter(t=>{var i;return!f(null==(i=r[t].metadata)?void 0:i.payload)}).map(t=>{var i;return[t,null==(i=r[t].metadata)?void 0:i.payload]}))}):(t.featureFlags&&e.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,a),l=o.flags,u=o.featureFlags,v=o.featureFlagPayloads;if(u){var d=t.requestId,c=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[Fe]:u,[Pe]:p,[Me]:!1}}var _=u,b=v,y=l;if(null!=n&&n.partialResponse){var m=Object.keys(_),w=b||{};_=i({},e,_),b=i({},r,w),m.forEach(t=>{var i;t in w||null==(i=b)||delete i[t]}),y=i({},s,y)}else if(t.errorsWhileComputingFlags)if(l){var S=new Set(Object.keys(l).filter(t=>{var i;return!(null!=(i=l[t])&&i.failed)}));_=i({},e,Object.fromEntries(Object.entries(_).filter(t=>S.has(t[0]))));var k=Object.fromEntries(Object.entries(b||{}).filter(t=>S.has(t[0])));b=i({},r,k),S.forEach(t=>{var i;t in k||null==(i=b)||delete i[t]}),y=i({},s,Object.fromEntries(Object.entries(y||{}).filter(t=>S.has(t[0]))))}else _=i({},e,_),b=i({},r,b),y=i({},s,y);return i({[Fe]:Object.keys(Ps(_)),[Pe]:_||{},[Re]:b||{},[Ae]:y||{},[Me]:!0===t.minimalFlagCalledEvents},d?{[Oe]:d}:{},c?{[Ke]:c}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.A);if(s)if(!1===(null==r?void 0:r.persist)){var n=!f(this.yo.kv.get(Pe));this.zd=s,n||this.$t(s)}else this.Od(),this.Vd(s,t,!(null==r||!r.partialResponse)),this.$t(s);else e&&this.Ud();e||(this.yd=!1),this.Ld(e)}}override(t,i){void 0===i&&(i=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.iv(t)}iv(t){if(this.yo){if(!1===t)return this.Lt([$e,Ie]),this.Ld(),void ws.info("All overrides cleared");if(h(t))return this.$t({[$e]:Cs(t)}),this.Ld(),void ws.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.ad=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[$e]=h(s)?Cs(s):s),n&&(r[Ie]=n),Object.keys(r).length&&this.$t(r),!1===s&&!1===n?this.Lt([$e,Ie]):!1===s?this.Lt($e):!1===n&&this.Lt(Ie),this.Ld(),!1===s?ws.info("Flag overrides cleared"):s&&ws.info("Flag overrides set",{flags:s}),void(!1===n?ws.info("Payload overrides cleared"):n&&ws.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.$t({[$e]:t}),this.Ld(),void ws.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.dd){var i=this.nv(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.Hd("$early_access_features")||[]).find(i=>i.flagKey===t),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[Fe]:[t],[Pe]:[t],[je]:Object.keys(a)}),this.$t({[Fe]:Object.keys(Ps(l)),[Pe]:l,[je]:i({},this.Hd("$stored_person_properties")||{},a)}),this.Ld();try{var u;null==(u=this.yo)||u.capture("$feature_enrollment_update",o)}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.Hd(Te);!r||i?this.sv(t,e):t(r)}sv(t,i){var e=this;return r(function*(){var r=e.yo;if(r){var s,n=i?"&"+i.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;s=a.json.earlyAccessFeatures,e.$t({[Te]:s})}catch(t){return void e.A.error("Early access feature request failed",t)}try{t(s)}catch(t){e.A.error("Early access feature callback failed",t)}}})()}nv(){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),{})}}Ld(t){this.Dd();var i=this.nv(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.rv(t,i)}rv(t,e){void 0===e&&(e=!0);var r=this.Hd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this.$t({[je]:i({},r,a,s)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.Hd("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[je]:r}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Lt(je),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.Hd("$stored_group_properties")||{},s=i({},r);for(var n of Object.keys(t))s[n]=i({},r[n],t[n]);this.$t({[De]:s}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.Hd("$stored_group_properties")||{};this.$t({[De]:i({},e,{[t]:{}})})}else this.Lt(De)}reset(){this.fd++,this.gd=!1,this.ld={},this.ud={},this.zd=void 0,this.dd=!1,this.pd=!1,this.md=!1,this.$anon_distinct_id=void 0,this.Bd(),this.ad=!1,this.bd=0}}},en={sessionRecording:class{get Mr(){return this._instance.config}get Tl(){return this._instance.persistence}get started(){var t;return!(null==(t=this.ov)||!t.isStarted)}get status(){var t,i;return"awaiting_config"===this.av||"missing_config"===this.av?this.av:null!==(t=null==(i=this.ov)?void 0:i.status)&&void 0!==t?t:this.av}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.av=$r,this.lv=void 0,this.uv=!1,this.Je=(()=>{var t;if(null==_i||!_i.visibilityState||"visible"===_i.visibilityState)return!0;var i=null==fi||null==(t=fi.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some(t=>"visible"===t.name)})(),this.sn=()=>{var t;"visible"===(null==_i?void 0:_i.visibilityState)&&(this.Je=!0,null==(t=this.ov)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw jr.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Mr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=_i&&_i.addEventListener&&Pi(_i,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.uv=!0,null==_i||null==_i.removeEventListener||_i.removeEventListener("visibilitychange",this.sn),e?this.hv(!0):this.stopRecording()}get dv(){var t,i=!(null==(t=this._instance.get_property(xe))||!t.enabled),e=!this.Mr.disable_session_recording,r=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return fi&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.uv||this.dv&&null!=(i=this.ov)&&i.isStarted)){var e=!f(Object.assign)&&!f(Array.from);this.dv&&e?(this.vv(t),jr.info("starting")):(this.av=$r,this.stopRecording())}}vv(t){var i,e;if(this.dv)if("awaiting_config"!==this.av&&"missing_config"!==this.av&&(this.av=Ir),null!=cr&&null!=(i=cr.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=cr.__PosthogExtensions__)&&e.initSessionRecording)this.fv(t);else{var r,s=this._instance.sessionManager;null==(r=cr.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.pv,i=>{if(!this.uv&&this.dv&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[Je]:!0}),jr.error("could not load recorder",i)):void this.fv(t);this.av=$r})}}stopRecording(){var t,i;null==(t=this.lv)||t.call(this),this.lv=void 0,null==(i=this.ov)||i.stop()}hv(t){var i,e;void 0===t&&(t=!1),null==(i=this.lv)||i.call(this),this.lv=void 0,null==(e=this.ov)||e.discard({discardProducerEvents:t})}gv(){var t,i;null==(t=this.Tl)||t.unregister("$session_is_sampled"),null==(i=this.Tl)||i.unregister("$replay_sample_rate")}mv(t,i){if(b(t))return null;var e,r=y(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(jr.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}yv(t){if(this.Tl){var e,r,s=this.Tl,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.mv(null==(e=this.Mr.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.mv(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;b(o)&&this.gv();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[xe]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.lv)||e.call(this),this.lv=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.yv(i),void this.hv()):(this.yv(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.av&&(this.av="missing_config",this._instance.register_for_session({[Ge]:!0}),jr.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.ov)&&e.log?this.ov.log(t,i):jr.warn("log called before recorder was ready")}get pv(){var t;return(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.get_property("$session_recording_remote_config"))||null==(t=t.scriptConfig)?void 0:t.script)||"lazy-recorder"}bv(){var t,i=this._instance.get_property(xe);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return jr.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!b(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}fv(t){var i,e,r;if(!this.uv&&this.dv&&this._instance.sessionManager){if(null==(i=cr.__PosthogExtensions__)||!i.initSessionRecording)return jr.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Je]:!0});var s;if(this.ov||(this.ov=null==(s=cr.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.Je),this.ov._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.bv()){if("missing_config"===this.av||"awaiting_config"===this.av)return;return this.av="awaiting_config",jr.info("persisted remote config is stale, requesting fresh config before starting"),void new Mr(this._instance).load()}this.av=Ir,null==(e=(r=this.ov).setDocumentWasEverVisible)||e.call(r,this.Je),this.ov.start(t)}else this.av=$r}onRRwebEmit(t){var i;null==(i=this.ov)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.ov||null==(t=this.Tl)||t.register({[Ce]:!0}),null==(i=this.ov)||i.overrideLinkedFlag()}overrideSampling(){var t,i;this.ov||null==(t=this.Tl)||t.register({[Ee]:!0}),null==(i=this.ov)||i.overrideSampling()}overrideTrigger(t){var i,e;this.ov||null==(i=this.Tl)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.ov)||e.overrideTrigger(t)}get sdkDebugProperties(){var t,e={};for(var r of Dr){var s,n=null==(s=this._instance.sessionPersistence)?void 0:s.get_property(r);f(n)||(e[r]=n)}return i({},e,(null==(t=this.ov)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,i){var e;return!(null==(e=this.ov)||!e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t;null==(t=this.ov)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},rn={autocapture:class extends hr{constructor(t){super(new vr(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._v=!1,this._instance=t,this.wv=this.Sv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.xv();return!!(t.path||t.search||this.Cv(t))}startIfEnabled(){this.isEnabled&&(wi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.wv=this.Sv(),this.startIfEnabled()}stop(){this.$v&&this.$v(),this.$v=void 0,this.Tv&&this.Tv(),this.Tv=void 0,wi.info("History API monitoring stopped")}monitorHistoryChanges(){fi&&fi.history&&(this.Iv("pushState"),this.Iv("replaceState"),this.Mv(),this.Cv()&&this.Ev())}Iv(t){var i;if(fi&&(null==(i=fi.history[t])||!i.__posthog_wrapped__)){var e=this;mr(fi.history,t,i=>function(r,s,n){var a;e.Pv(n)&&e.Rv(),i.call(this,r,s,n),e.Av(t,!e._v&&"popstate"!==(null==fi||null==(a=fi.event)?void 0:a.type))})}}Sv(){var t=null==fi?void 0:fi.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}xv(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:d(t)?t:{}}Cv(t){return void 0===t&&(t=this.xv()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Fv(t){var i=this.xv(),e=this.wv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Cv(i)&&t.hash!==e.hash))}Av(t,i){void 0===i&&(i=!1);try{i||this.Rv();var e=this.Sv();if(!e)return;if(this.Fv(e)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});i?(this.Ov=r,Promise.resolve().then(()=>this.Rv())):r()}this.wv=e}catch(i){wi.error("Error capturing "+t+" pageview",i)}}Pv(t){var i,e;return!(b(t)||!fi)&&(null==(i=Ye(String(t)))?void 0:i.href)!==(null==(e=fi.location)?void 0:e.href)}Rv(){var t=this.Ov;if(t){this.Ov=void 0,this._v=!0;try{t()}catch(t){wi.error("Error capturing deferred pageview",t)}finally{this._v=!1}this.wv=this.Sv()}}Mv(){if(!this.$v){var t=()=>{this.Av("popstate")};Pi(fi,"popstate",t),this.$v=()=>{fi&&fi.removeEventListener("popstate",t)}}}Ev(){if(!this.Tv){var t=()=>{this.Av("hashchange")};Pi(fi,"hashchange",t),this.Tv=()=>{fi&&fi.removeEventListener("hashchange",t)}}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var i;this.Dv=!1,this.wo=!1,this.Lv=null,this.instance=t,this.Dv=!(null==(i=this.instance.persistence)||!i.props[pe]),this.rageclicks=new ce(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return d(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return b(this.Mr.capture_heatmaps)?b(this.Mr.enable_heatmaps)?this.Dv:this.Mr.enable_heatmaps:!1!==this.Mr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.wo)return;Lr.info("starting..."),this.Nv(),this.sn()}else{var t;clearInterval(null!==(t=this.Lv)&&void 0!==t?t:void 0),this.qv(),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({[pe]:e}),this.Dv=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}jv(t){Nr(t.originalEvent)&&this.Cr(t.originalEvent,"deadclick")}sn(){this.Lv&&clearInterval(this.Lv),this.Lv="visible"===(null==_i?void 0:_i.visibilityState)?setInterval(this.ml.bind(this),this.flushIntervalMilliseconds):null}Nv(){fi&&_i&&(this.Bv=this.ml.bind(this),Pi(fi,Qe,this.Bv),this.Hv=t=>this.Cr(t||(null==fi?void 0:fi.event)),Pi(_i,"click",this.Hv,{capture:!0}),this.zv=t=>this.Uv(t||(null==fi?void 0:fi.event)),Pi(_i,"mousemove",this.zv,{capture:!0}),this.Wv=new gr(this.instance,pr,this.jv.bind(this)),this.Wv.startIfEnabledOrStop(),this.Vv=this.sn.bind(this),Pi(_i,Ze,this.Vv),this.wo=!0)}qv(){var t;fi&&_i&&(this.Bv&&fi.removeEventListener(Qe,this.Bv),this.Hv&&_i.removeEventListener("click",this.Hv,{capture:!0}),this.zv&&_i.removeEventListener("mousemove",this.zv,{capture:!0}),this.Vv&&_i.removeEventListener(Ze,this.Vv),clearTimeout(this.Gv),null==(t=this.Wv)||t.stop(),this.wo=!1)}Zv(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),a=function(t,i,e){for(var r=t;r&&Ri(r)&&!Oi(r,"body");){if(r===e)return!1;var s=void 0;try{var a,o,l;s=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:fi)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(n(i,s))return!0;r=qi(r)}return!1}(Hi(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:e),target_fixed:a,type:i}}Cr(t,e){var r;if(void 0===e&&(e="click"),!Ai(t.target)&&Nr(t)){var s=this.Zv(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Xi(Hi(t),this.instance.config.rageclick)&&this.Zs(i({},s,{type:"rageclick"})),this.Zs(s)}}Uv(t){!Ai(t.target)&&Nr(t)&&(clearTimeout(this.Gv),this.Gv=setTimeout(()=>{this.Zs(this.Zv(t,"mousemove"))},500))}Zs(t){if(fi){var i=this.Mr.disable_capture_url_hashes?G(fi.location.href):fi.location.href,e=this.Mr.custom_personal_data_properties,r=ir(i,this.Mr.mask_personal_data_properties?[...Sr,...e||[]]:[],xr);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}ml(){this.Rt&&!c(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:gr,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.Dv=!1,this.wo=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Qv=()=>{clearTimeout(this.Jv),this.Jv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",i({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Kv=t=>{var e;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},b(null==t?void 0:t.name)||b(null==t?void 0:t.value))Pr.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Xv(r);if(!f(s)){var n=y(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.Yv||this.Yv>t.value){this.Rt.navigationKey!==n&&(this.Qv(),this.Jv=setTimeout(this.Qv,this.flushToCaptureTimeoutMs)),f(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=f(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=i({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,d(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of Rr){var h="url"===u&&"string"==typeof t.attribution[u]?this.Xv(t.attribution[u]):t.attribution[u];f(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;f(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.Qv()}else Pr.error("Ignoring metric with value >= "+this.Yv,t)}}},this.tf=()=>{if(!this.wo){var t,e,r,s,n=!1,a=cr.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.ef])||("web-vitals"===this.ef&&f(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!f(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!f(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,e=h.indexOf("CLS")>-1?l.onCLS:(null==u?void 0:u.onCLS)||l.onCLS,r=h.indexOf("FCP")>-1?l.onFCP:(null==u?void 0:u.onFCP)||l.onFCP,s=h.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(t&&e&&r&&s){var v={reportSoftNavs:this.useSoftNavs},d=n&&this.attributionMetrics.indexOf("INP")>-1?i({},v,{includeProcessedEventEntries:!1}):v;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Kv.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&e(this.Kv.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Kv.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.Kv.bind(this),d),this.wo=!0}else Pr.error("web vitals callbacks not loaded - not starting")}},this.Dv=!(null==(e=this._instance.persistence)||!e.props[ye]),this.startIfEnabled()}get if(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=d(this.if)?null==(t=this.if)?void 0:t.web_vitals_allowed_metrics:void 0;return b(e)?(null==(i=this._instance.persistence)?void 0:i.props.$web_vitals_allowed_metrics)||Tr:e}get flushToCaptureTimeoutMs(){return(d(this.if)?this.if.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=d(this.if)?this.if.web_vitals_attribution:void 0;return m(t)?t?Tr:[]:h(t)?t:Ar}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=d(this.if)?this.if.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get Yv(){var t=d(this.if)&&y(this.if.__web_vitals_max_value)?this.if.__web_vitals_max_value:Fr;return t>0&&6e4>=t?Fr:t}get isEnabled(){var t=null==bi?void 0:bi.protocol;if("http:"!==t&&"https:"!==t)return Pr.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=d(this.if)?this.if.web_vitals:m(this.if)?this.if:void 0;return m(i)?i:this.Dv}startIfEnabled(){this.isEnabled&&!this.wo&&(Pr.info("enabled, starting..."),this.Bo(this.tf))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=d(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=d(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ye]:e}),this._instance.persistence.register({[ke]:r})),this.Dv=e,this.startIfEnabled()}}}get ef(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Bo(t){var i=cr.__PosthogExtensions__,e=this.ef,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&f(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,i=>{i?Pr.error("failed to load script",i):t()})}Xv(t){var i=t||(null==fi?void 0:fi.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?G(i):i,r=this._instance.config.custom_personal_data_properties;return ir(e,this._instance.config.mask_personal_data_properties?[...Sr,...r||[]]:[],xr)}Pr.error("Could not determine current URL")}}},sn={exceptionObserver:class{constructor(t){var e;this.tf=()=>{var t;if(fi&&this.isEnabled&&null!=(t=cr.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=cr.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=cr.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=cr.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.nf&&this.Mr.capture_unhandled_errors&&(this.nf=i(this.captureException.bind(this))),!this.sf&&this.Mr.capture_unhandled_rejections&&(this.sf=e(this.captureException.bind(this))),!this.rf&&this.Mr.capture_console_errors&&(this.rf=r(this.captureException.bind(this)))}catch(t){_r.error("failed to start",t),this.af()}}},this._instance=t,this.lf=!(null==(e=this._instance.persistence)||!e.props[ge]),this.wt=new T(i({},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,A:_r})),this.Mr=this.uf(),this.startIfEnabledOrStop()}uf(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return d(t)?e=i({},e,t):(f(t)?this.lf:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(_r.info("enabled"),this.af(),this.Bo(this.tf)):this.af()}Bo(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return _r.error("failed to load script",i);t()})}af(){var t,i,e;null==(t=this.nf)||t.call(this),this.nf=void 0,null==(i=this.sf)||i.call(this),this.sf=void 0,null==(e=this.rf)||e.call(this),this.rf=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.lf=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[ge]:this.lf}),this.Mr=this.uf(),this.startIfEnabledOrStop())}}onConfigChange(){this.Mr=this.uf()}captureException(t){try{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";if(this.wt.consumeRateLimit(s))return void _r.info("Skipping exception capture because of client rate limiting.",{exception:s});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var e,r;this.hf=[],this.cf=new it([new St,new Ot,new xt,new kt,new At,new Tt,new Ct,new Rt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=Math.min(a.length,s+1e3),l=[],u=s;o>u;u++){var h=a[u];if(1024>=h.length){var v=ft.test(h)?h.replace(ft,"$1"):h;if(!v.match(/\S*Error: /)){for(var d of r){var c=d(v,t);if(c){n.push(c);var f=gt(n);if(f){for(var p=l.length-1;p>=0;p--){var g=l[p];if(f.start>=g.start+g.length)break;l.pop()}l.push(f)}break}}if(mt(n,l)>=50)break}}}var _=[...l].sort((t,i)=>i.start-t.start),b=_[_.length-1];if(b){var y=bt(n,b);for(var m of(n.splice(b.start-y,y),_))m.start-=y}for(var w of _)_t(n,w);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){for(var i=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),e=0,r=1;i.length>r;r++)wt(i,r,e)&&(e=r);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map(t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||"?"});var r})}(n)}}("web:javascript",ht,ct)),this._instance=t,this.hf=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==e?e:[],this.df=Dt(this.vf()),this.ff=new Lt(this.df)}onConfigChange(){this.df=Dt(this.vf()),this.ff.setConfig(this.df)}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:[],a=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.hf=n,this._instance.persistence&&this._instance.persistence.register({[_e]:this.hf,[be]:a})}}}get pf(){var t,i,e=!!this._instance.get_property(be);return null!==(t=null!==(i=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==i?i:e)&&void 0!==t&&t}buildProperties(t,i){return this.cf.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,e){if(this.df.enabled)try{if(!p(t)||0===t.trim().length)return void Ts.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce((e,r)=>It.has(r)?(i.push(r),e):(e[r]=t[r],e),{}),droppedKeys:i}}(this.gf(e)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&Ts.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.ff.add(i({[Mt]:t,[$t]:(new Date).toISOString()},s))}catch(t){Ts.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.mf(i)){if(this.yf(i))return this.bf("Exception dropped: matched a suppression rule"),void Ts.info("Skipping exception capture because a suppression rule matched");if(!this.pf&&this._f(i))return this.bf("Exception dropped: thrown by a browser extension"),void Ts.info("Skipping exception capture because it was thrown by an extension");if(!this.pf&&this.wf(i))return this.bf("Exception dropped: thrown by an injected browser script"),void Ts.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.kf(i))return this.bf("Exception dropped: thrown by the PostHog SDK"),void Ts.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.df.enabled&&b(t.$exception_steps)?this.Sf(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",_originatedFromCaptureException:!0});return s&&this.ff.clear(),s}catch(t){return Fs(t)||Ts.error("Failed to capture exception event. Dropping this exception.",t),void this.ff.clear()}}catch(t){return void(Fs(t)||Ts.error("Failed to process exception event. Ignoring this exception.",t))}var n}Sf(t){try{var e=this.ff.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(i){return Ts.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}bf(t){this.df.enabled&&this.ff.add({[Mt]:t,[$t]:(new Date).toISOString()})}gf(t){return d(t)?i({},t):{}}vf(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}yf(t){if(0===t.length)return!1;try{var i=t.reduce((t,i)=>{var e=i.type,r=i.value;return p(e)&&e.length>0&&t.$exception_types.push(e),p(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.hf.some(t=>{var e=t.values.map(t=>{var e=Yr[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 Ts.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}_f(t){var i=t.flatMap(t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(t=>{var i=t.filename;return!!i&&Os.some(t=>i.startsWith(t))});return 0!==e.length&&(!e.every(t=>{var i=t.filename;return!!i&&i.startsWith(As)})||t.some(t=>{var i=t.value;return"NoResponse"===t.type||p(i)&&Rs.some(t=>{var e=t.value;return t.exact?i===e:i.includes(e)})})&&!i.some(t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(As))}))}wf(t){return t.some(t=>{var i=t.value;return p(i)&&Ms.some(t=>i.includes(t))})}kf(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:[];return null!==(r=null==(s=n[n.length-1])||null==(s=s.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}mf(t){return!b(t)&&h(t)}}},nn=i({productTours:class{get Tl(){return this._instance.persistence}constructor(t){this.xf=null,this.Cf=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.Tl&&this.Tl.register({[we]:!!i.productTours}),!Br(this._instance))return!this.xf&&b(null==(e=this.Tl)?void 0:e.props.ph_product_tours)||Hr.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.xf)||r.stop(),this.xf=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.xf&&Br(this._instance)&&this.Bo(()=>this.$f())}Bo(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",i=>{i?Hr.error("Could not load product tours script",i):t()})}$f(){var t;!this.xf&&null!=(t=cr.__PosthogExtensions__)&&t.generateProductTours&&(this.xf=cr.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!h(this.Cf)||i){var e=this.Tl;if(e){var r=e.props[Ue];if(h(r)&&!i)return this.Cf=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(Br(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||Hr.warn(s):Hr.error(s),void t([],{isLoaded:!1,error:s})}var n=h(i.json.product_tours)?i.json.product_tours:[];this.Cf=n,e&&e.register({[Ue]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Cf,{isLoaded:!0})}getActiveProductTours(t){b(this.xf)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.xf.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.xf)||i.showTourById(t)}previewTour(t){this.xf?this.xf.previewTour(t):this.Bo(()=>{var i;this.$f(),null==(i=this.xf)||i.previewTour(t)})}dismissProductTour(){var t;null==(t=this.xf)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.xf)||t.nextStep()}previousStep(){var t;null==(t=this.xf)||t.previousStep()}clearCache(){var t;this.Cf=null,null==(t=this.Tl)||t.unregister(Ue)}resetTour(t){var i;null==(i=this.xf)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.xf)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.xf)||i.cancelPendingTour(t)}}},tn),an={siteApps:class{constructor(t){this._instance=t,this.Tf=0,this.If=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Mf(t,i){if(i){var e=this.globalsForEvent(i);this.If.push(e),this.If.length>1e3&&(this.If=this.If.slice(10))}}get siteAppLoaders(){var t;return null==(t=cr._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Mf.bind(this));this.Ef=()=>{t(),this.If=[],this.Ef=void 0}}}globalsForEvent(e){var r,s,n,a,o,l,u;if(!e)throw new Error("Event payload is required");var h={},v=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var c of Object.entries(d)){var f=c[0];h[f]={id:v[f],type:f,properties:c[1]}}var p=e.$set_once,g=e.$set;return{event:i({},function(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}(e,t),{properties:i({},e.properties,g?{$set:i({},null!==(r=null==(s=e.properties)?void 0:s.$set)&&void 0!==r?r:{},g)}:{},p?{$set_once:i({},null!==(n=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==n?n:{},p)}:{}),elements_chain:null!==(o=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}Pf(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)||(zr.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)||(zr.error("prepare_external_dependency_script returned null"),null):t}Rf(){var t,i,e,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==_i?void 0:_i.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Tf++,this.Af)return this.Ff();var h=[],v=this,d=new WeakSet,c=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),h.push(()=>{t[i]=r})}},f=t=>{if(d.has(t))return t;var i=v.Pf(t);return i&&d.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!_(t));return c(u,"appendChild",t=>function(i){var e=f(i);return e?t.call(this,e):i}),c(u,"insertBefore",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i}),c(u,"replaceChild",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e}),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{c(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,p(e))}),c(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,p(e))})}),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach(t=>{c(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,p(e))}),c(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,p(e))}),c(t,"replaceWith",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)})}),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null}),this.Af=()=>{h.forEach(t=>t()),this.Af=void 0},this.Ff()}Ff(){var t=!1;return()=>{var i;t||(t=!0,this.Tf--,0===this.Tf&&(null==(i=this.Af)||i.call(this)))}}Of(t,i){void 0===i&&(i=!0);var e=this.Rf();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.If.length&&(zr.info("Processing "+this.If.length+" events for site app with id "+t.id),this.If.forEach(t=>this.Of(()=>null==i.processEvent?void 0:i.processEvent(t))),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(e=this.Ef)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,zr.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Of(i=>t.init({posthog:this._instance,callback(t){i(),s(t)}}),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){zr.error(Ur+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){zr.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}Df(){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)}Lf(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Of(()=>null==r.processEvent?void 0:r.processEvent(e))}catch(i){zr.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.Df(),void this._instance.on("eventCaptured",t=>this.Lf(t))):void zr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Ef)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,i=o.id,e=o.url;cr["__$$ph_site_app_"+i]=s._instance,null==(t=cr.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,t=>{if(t)return zr.error(Ur+i,t)})};for(var o of n.siteApps)a()}else zr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},on={tracingHeaders:class{constructor(t){this._instance=t,this.Nf=void 0,this.qf=void 0,this.jf=void 0,this.tf=()=>{var t,i,e=this.Bf();e?(f(this.Nf)&&(this.Nf=null==(t=cr.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.qf)&&(this.qf=null==(i=cr.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.af()}}initialize(){this.startIfEnabledOrStop()}Bo(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return wr.error("failed to load script",i);t()})}Hf(){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}Bf(){var t=this.Hf();return h(t)?(h(this.jf)?this.jf.splice(0,this.jf.length,...t):this.jf=[...t],t.length>0?this.jf:void 0):(h(this.jf)&&this.jf.splice(0),this.jf=t||void 0,this.jf)}af(){var t,i;null==(t=this.Nf)||t.call(this),null==(i=this.qf)||i.call(this),this.Nf=void 0,this.qf=void 0}startIfEnabledOrStop(){this.Bf()?this.Bo(this.tf):this.af()}}},ln=i({surveys:class extends ns{constructor(t){var i;super(new fs(t),(i=t,{get projectToken(){return i.config.token},kv:new cs(i)})),this._instance=t}Wh(t,e){var r=e.query?function(t,e,r){var s;void 0===r&&(r=!0);var n=t.split("?"),a=n[0],o=n[1],l=i({},e),u=null!==(s=null==o?void 0:o.split("&").map(t=>{var i,e=t.split("="),s=e[0],n=r&&null!==(i=l[s])&&void 0!==i?i:e[1];return delete l[s],s+"="+n}))&&void 0!==s?s:[],h=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return xi(t,function(t,i){f(t)||f(i)||"undefined"===i||(e=encodeURIComponent(t instanceof File?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)}),s.join(i)}(l);return h&&u.push(h),u.length>0?a+"?"+u.join("&"):a}(t,e.query):t;return new Promise(t=>{var i;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor(null!==(i=e.target)&&void 0!==i?i:"api",r),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:t})})}}},tn),un={toolbar:class{constructor(t){this.instance=t}zf(t){cr.ph_toolbar_state=t}Uf(){var t;return null!==(t=cr.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,i,e){if(void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),Fi(this.instance.config))return!1;if(!fi||!_i)return!1;t=null!=t?t:fi.location,e=null!=e?e:fi.history;try{if(!i){try{fi.localStorage.setItem("test","test"),fi.localStorage.removeItem("test")}catch(t){return!1}i=null==fi?void 0:fi.localStorage}var r,s=ps||er(t.hash,"__posthog")||er(t.hash,"state"),n=s?X(()=>JSON.parse(atob(decodeURIComponent(s))))||X(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(i.getItem(gs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Wf(t){var i=cr.ph_load_toolbar||cr.ph_load_editor;!b(i)&&v(i)?i(t,this.instance):_s.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==_i||!_i.getElementById("__POSTHOG_TOOLBAR__"));if(!fi||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(fi.localStorage.setItem(gs,JSON.stringify(i({},s,{source:void 0}))),2===this.Uf())this.Wf(s);else if(0===this.Uf()){var n;this.zf(1),null==(n=cr.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return _s.error("[Toolbar] Failed to load",t),void this.zf(0);this.zf(2),this.Wf(s)}),Pi(fi,"turbolinks:load",()=>{this.zf(0),this.loadToolbar(s)})}return!0}Vf(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)}}},hn=i({experiments:class t{get Mr(){return this._instance.config}constructor(i){var e=this;this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){void 0===i&&(i=!1),e.getWebExperiments(i=>{t.Gf("retrieved web experiments from the server"),e.Zf=new Map,i.forEach(i=>{if(i.feature_flag_key){var r;e.Zf&&(t.Gf("setting flag key ",i.feature_flag_key," to web experiment ",i),null==(r=e.Zf)||r.set(i.feature_flag_key,i));var s=e._instance.getFeatureFlag(i.feature_flag_key);p(s)&&i.variants[s]&&e.Qf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(var n in i.variants){var a=i.variants[n];t.Jf(a,e._instance)&&e.Qf(i.name,n,a.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.Gf($s);else if(!this.Mr.disable_web_experiments){if(b(this.Zf))return this.Zf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.Gf("applying feature flags",i),i.forEach(t=>{var i;if(this.Zf&&null!=(i=this.Zf)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.Zf)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.Qf(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var i=t.getWindowLocation();if(null!=i&&i.search){var e=tr(null==i?void 0:i.search,"__experiment_id"),r=tr(null==i?void 0:i.search,"__experiment_variant");e&&r&&(t.Gf("previewing web experiments "+e+" && "+r),this.getWebExperiments(t=>{this.Kf(parseInt(e),r,t)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Mr.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.Mr.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}Kf(i,e,r){var s=r.filter(t=>t.id===i);s&&s.length>0&&(t.Gf("Previewing web experiment ["+s[0].name+"] with variant ["+e+"]"),this.Qf(s[0].name,e,s[0].variants[e].transforms))}static Jf(i,e){return!b(i.conditions)&&t.Xf(i,e)&&t.Yf(i)}static Xf(i,e){var r;if(b(i.conditions)||b(null==(r=i.conditions)?void 0:r.url))return!0;var s=t.getWindowLocation();if(s){var n,a,o,l=Ti(e,s.href);return null==(n=i.conditions)||!n.url||Is[null!==(a=null==(o=i.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](i.conditions.url,l)}return!1}static getWindowLocation(){return null==fi?void 0:fi.location}static Yf(t){var i;if(b(t.conditions)||b(null==(i=t.conditions)?void 0:i.utm))return!0;var e=function(t,i,e){if(!_i)return{};var r,s,n,a=i?[...Sr,...e||[]]:[],o=(r=ir(_i.URL,a,xr),s=kr.concat(t||[]),n={},xi(s,function(t){var i=tr(r,t);n[t]=i||null}),n);return Ei(function(){var t={};return xi(Er,function(i){var e=(t=>{if(_i){try{for(var i=t+"=",e=_i.cookie.split(";").filter(t=>t.length),r=0;e.length>r;r++){for(var s=e[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}})(i);t[i]=e||null}),t}(),o)}();if(e.utm_source){var r,s,n,a,o,l,u,h,v=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,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==e.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==e.utm_term;return v&&c&&f&&d}return!1}static Gf(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];wi.info("[WebExperiments] "+t,e)}Qf(i,e,r){this._is_bot()?t.Gf($s):"control"!==e?r.forEach(r=>{var s;r.selector&&(t.Gf("applying transform of variant "+e+" for experiment "+i+" ",r),null==(s=document)||null==(s=s.querySelectorAll(r.selector))||s.forEach(t=>{var i=t;r.html&&(i.innerHTML=r.html),r.css&&i.setAttribute("style",r.css)}))}):t.Gf("Control variants leave the page unmodified.")}_is_bot(){return gi&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&P(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>P(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver}(gi,this.Mr.custom_blocked_useragents):void 0}}},tn),vn={conversations:class{constructor(t){this._instance=t,this.tp=void 0,this._conversationsManager=null,this.ep=!1,this.ne=null,this.np=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.sp=t.ok,t.ok)){var i=t.config.conversations;b(i)||(m(i)?this.tp=i:(this.tp=i.enabled,this.ne=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.tp=void 0,this.ne=null,this.sp=void 0,this.np=!1}loadIfEnabled(){if(!(this._conversationsManager||this.ep||this._instance.config.disable_conversations||Fi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==cr?void 0:cr.__PosthogExtensions__;if(t&&!f(this.tp)&&this.tp)if(this.ne&&this.ne.token){this.ep=!0;try{var i=t.initConversations;if(i)return this.rp(i),void(this.ep=!1);var e=t.loadExternalDependency;if(!e)return void this.op(Xe);e(this._instance,"conversations",i=>{i||!t.initConversations?this.op("Could not load conversations script",i):this.rp(t.initConversations),this.ep=!1})}catch(t){this.op("Error initializing conversations",t),this.ep=!1}}else js.error("Conversations enabled but missing token in remote config.")}}rp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.np=!1,js.info("Conversations loaded successfully")}catch(t){this.op("Error completing conversations initialization",t)}else js.error("Cannot complete initialization: remote config is null")}op(t,i){js.error(t,i),this._conversationsManager=null,this.ep=!1,this.np=!0}show(){this._conversationsManager?this._conversationsManager.show():js.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.tp&&!_(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Fi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.sp?"remote_config_failed":f(this.tp)?this.sp?"disabled_in_project":"remote_config_pending":this.tp?b(this.ne)||!this.ne.token?"missing_token":null!=cr&&cr.__PosthogExtensions__?this.ep?"initializing":this.np?"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 s=this;return r(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(js.warn(Ds),null)})()}getMessages(t,i){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(js.warn(Ds),null)})()}markAsRead(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(js.warn(Ds),null)})()}getTickets(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(js.warn(Ds),null)})()}requestRestoreLink(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(js.warn(Ds),null)})()}restoreFromToken(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(js.warn(Ds),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(js.warn(Ds),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}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},dn={logs:class{constructor(t){var e,r=this;this._instance=t,this.name="logs",this.ap=!1,this.lp=!1,this.up=!1,this.A=Si("[logs]"),this.hp=i({},this.A,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(qs)||r.A.error(...i)}}),this.rl=[],this.cp=[],this.bd=0,this.$o=!1,this.dp=[],this.vp=[],this.fp=!1,this.pp=!1,this.gp=()=>{var t,i;this.$o||(this.bd=0,null==(t=this.mp)||t.onReconnect(),null==(i=this.yp)||i.onReconnect())},this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.ap=!0),fi&&Pi(fi,"online",this.gp)}bp(t,i,e,r){var s,n=Ns(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new oi(this._p(t,i),n,this.hp,()=>this.wp(),t=>t(),void 0,r),n]}kp(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.mp||this.Sp!==i){var e;null==(e=this.mp)||e.reset(),this.Sp=i;var r=this.bp(()=>this.rl,t=>{this.rl=t});this.mp=r[0],this.xp=r[1]}return this.mp}Cp(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.yp||this.$p!==i){var e;null==(e=this.yp)||e.reset(),this.$p=i;var r=this.bp(()=>this.cp,t=>{this.cp=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Bs);this.yp=r[0],this.Tp=r[1]}return this.yp}setup(t){var i;if(!this.$o){this.yo=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.ap=!0),(this.ap||this.Ip()&&this.Mp())&&this.Ep();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.$o?r.dispose():(this.Mo=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.$o||(this.$o=!0,this.Pp(),null==(t=this.Mo)||t.dispose(),this.Mo=void 0,this.yo=void 0,this.up=!1,null==fi||fi.removeEventListener("online",this.gp),null==(i=this.Rp)||i.call(this),this.Rp=void 0,null==(e=this.mp)||e.reset(),null==(r=this.yp)||r.reset())}onRemoteConfig(t){var i,e;if(!this.$o){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;b(r)?this.Ap():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[Se]:!!r}),r?(this.ap=!0,this.lp||this.Ep(),this.loadIfEnabled()):this.Ap())}}reset(){var t,i,e,r;this.Pp(),null==(t=this.mp)||t.clearQueue(),this.rl=[],null==(i=this.mp)||i.reset(),null==(e=this.yp)||e.clearQueue(),this.cp=[],null==(r=this.yp)||r.reset(),this.bd=0}captureLog(t){this.$o||this.kp().captureLog(t)}captureConsoleLog(t){this.$o||this.Cp().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.$o||this.Cp().captureLog(t,{context:i,occurredAtMs:e})}Mp(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[Se])}Ip(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=cr._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.Pp(),null==(t=this.yp)||t.clearQueue(),this.cp=[]}Ap(){this.ap||this.Pp()}Ep(){var t,i=this;if(!this.fp&&null!=cr&&cr.console){var e=Ns(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=!0;this.vp.push(()=>{r=!1});var s=function(t){var s;try{s=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(cr.console[t])}catch(t){return 0}if(!s)return 0;i.vp.push(mr(cr.console,t,n=>{var a=function(){for(var s=arguments.length,a=new Array(s),o=0;s>o;o++)a[o]=arguments[o];try{r&&i.Fp(t,a,e)}catch(t){}return n.apply(cr.console,a)};return a.__rrweb_original__=s,a}))};for(var n of Hs)s(n);this.fp=!0,this.Op=setTimeout(()=>{this.Pp()},3e4)}}Fp(t,i,e){var r;if(this.fp&&!this.pp&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.dp.length){this.pp=!0;try{this.dp.push({level:t,args:i,occurredAtMs:Date.now(),context:this.wp()})}finally{this.pp=!1}}}else this.Pp()}Pp(){if(this.dp=[],this.fp){for(var t of(this.fp=!1,this.Op&&(clearTimeout(this.Op),this.Op=void 0),this.vp))t();this.vp=[]}}Dp(){var t=this.dp;return this.Pp(),t}get logger(){return this.Lp||(this.Lp={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.Lp}flushLogs(t){t?this.Np(t):(this.mp&&this.mp.flush().catch(t=>this.qp(t)),this.yp&&this.yp.flush().catch(t=>this.qp(t)))}qp(t){qs(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.$o&&this.ap&&!this.lp&&!this.up){var t=null==cr?void 0:cr.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Pp();var i=t.loadExternalDependency;if(!i)return this.A.error(Xe),void this.Pp();this.up=!0;try{i(this._instance,"logs",i=>{if(this.up=!1,!this.$o&&this.ap){var e=t.logs;if(i||null==e||!e.initializeLogs)this.A.error("Could not load logs script",i),this.Pp();else{var r,s,n=this.Dp();this.Rp=e.initializeLogs(null!==(r=this.yo)&&void 0!==r?r:this._instance),this.lp=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.yo)&&void 0!==s?s:this._instance,n))}}})}catch(t){throw this.up=!1,t}}}_p(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===s.LogsQueue?t():void 0,setPersistedProperty(t,e){t===s.LogsQueue&&i(null!=e?e:[])},js:t=>this.js(t),getLibraryId:()=>as.LIB_NAME,getLibraryVersion:()=>as.LIB_VERSION}}js(t){return new Promise(i=>{if(rr(this.bd,3))i({kind:"fatal",error:Us(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Us(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.jp(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.Bp(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.A.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Us(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)})}}})}})}Bp(t){(0!==t||this._instance.__loaded)&&(this.bd=sr(t,this.bd,3,()=>this.A.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.")))}Np(t){this.rl.length>0&&this.Hp(t,this.rl,this.xp,as.LIB_NAME,t=>{this.rl=t}),this.cp.length>0&&this.Hp(t,this.cp,this.Tp,Bs,t=>{this.cp=t})}Hp(t,i,e,r,s){if(0!==i.length){var n=i.map(t=>t.record);s([]);var a=ri(n,ei(e,as.LIB_NAME,as.LIB_VERSION),r,as.LIB_VERSION);this._instance._send_request({method:"POST",url:this.jp(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}jp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}wp(){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,b(s)||(i.sessionStartTimestamp=s),b(n)||(i.lastActivityTimestamp=n)}if(null!=cr&&null!=(t=cr.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?G(cr.location.href):cr.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},cn={metrics:class{constructor(t){this._instance=t,this.A=Si("[metrics]"),this.$o=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.$o){var i=!(null==(t=this._instance.config.metrics)||!t.network);i&&!this.zp?this.zp=(t=>{var i=!0,e=()=>i?(t=>{var i,e=null==(i=t.config.metrics)?void 0:i.network;return!0===e?{}:e||void 0})(t):void 0,r=Qs(t,e),s=Ys(t,e);return()=>{i=!1,r(),s()}})(this._instance):!i&&this.zp&&(this.zp(),this.zp=void 0)}}kp(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.mp&&this.Sp===e||(null==(i=this.mp)||i.reset(),this.Sp=e,this.mp=new vi(this._p(),function(t){var i,e,r,s,n,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==a?void 0:a["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==a?void 0:a["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,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.A)),this.mp}count(t,i,e){void 0===i&&(i=1),this.kp().count(t,i,e)}gauge(t,i,e){this.kp().gauge(t,i,e)}histogram(t,i,e){this.kp().histogram(t,i,e)}flush(t){if(!this.mp)return Promise.resolve();if(t){var i=this.mp.drainWindow();return i&&this.Ys(i,t),Promise.resolve()}return this.mp.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.mp)||t.reset()}dispose(){var t,i;this.$o=!0,null==(t=this.zp)||t.call(this),this.zp=void 0,null==(i=this.mp)||i.reset()}_p(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:t=>i.Ys(t),getLibraryId:()=>as.LIB_NAME,getLibraryVersion:()=>as.LIB_VERSION}}Ys(t,e){return new Promise(r=>{var s=!1,n=t=>{s||(s=!0,clearTimeout(a),r(t))},a=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(i({method:"POST",url:this.Up(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var i,e=t.statusCode;n(e>=200&&300>e?{kind:"ok"}:413===e?{kind:"too-large"}:0!==e&&408!==e&&429!==e&&500>e?{kind:"fatal",error:new Error("metrics request failed with status "+e)}:{kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}))})}Up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},fn=i({},tn,en,rn,sn,nn,an,ln,on,un,hn,vn,dn,cn),pn=tn,gn=en,_n=rn,bn=sn,yn=nn,mn=an,wn=ln,Sn=on,kn=un,xn=hn,En=vn,Cn=dn,Pn=cn;export{fn as AllExtensions,_n as AnalyticsExtensions,En as ConversationsExtensions,bn as ErrorTrackingExtensions,xn as ExperimentsExtensions,pn as FeatureFlagsExtensions,Cn as LogsExtensions,Pn as MetricsExtensions,yn as ProductToursExtensions,gn as SessionReplayExtensions,mn as SiteAppsExtensions,wn as SurveysExtensions,kn as ToolbarExtensions,Sn as TracingExtensions};
1
+ var t=["$set_once","$set"];function i(){return i=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},i.apply(null,arguments)}function e(t,i,e,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void e(t)}o.done?i(l):Promise.resolve(l).then(r,s)}function r(t){return function(){var i=this,r=arguments;return new Promise(function(s,n){var a=t.apply(i,r);function o(t){e(a,s,n,o,l,"next",t)}function l(t){e(a,s,n,o,l,"throw",t)}o(void 0)})}}var s=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.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function n(t,i){return-1!==t.indexOf(i)}var a=function(t){return t.trim()},o=Object.prototype,l=o.hasOwnProperty,u=o.toString,h=Array.isArray||function(t){return"[object Array]"===u.call(t)},v=t=>"function"==typeof t,d=t=>t===Object(t)&&!h(t),c=t=>{if(d(t)){for(var i in t)if(l.call(t,i))return!1;return!0}return!1},f=t=>void 0===t,p=t=>"[object String]"==u.call(t),g=t=>p(t)&&0===t.trim().length,_=t=>null===t,b=t=>f(t)||_(t),y=t=>"[object Number]"==u.call(t)&&t==t,m=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function S(t,i){return{}.toString.call(t)==="[object "+i+"]"}function k(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 E(t,Error)}}function x(t){return"u">typeof Event&&E(t,Event)}function E(t,i){try{return t instanceof i}catch(t){return!1}}var C=["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"],P=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return C.concat(i).some(t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)})};function F(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),y(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),F(null!=s?s:e,i,e,r))}var T=class{constructor(t){this.C={},this.I=t.I,this.R=F(t.bucketSize,0,100,t.A),this.$=F(t.refillRate,0,this.R,t.A),this.O=F(t.refillInterval,0,864e5,t.A)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.$,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.C[r];return s?this.F(s,e):this.C[r]=s={tokens:this.R,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.I)||i.call(this,t)),0===s.tokens)}stop(){this.C={}}},A="Mobile",R="Android",O="Nintendo",M="PlayStation",I="Xbox",j="Windows";A.toLowerCase(),"Tablet".toLowerCase(),new RegExp(I,"i");var D=new RegExp("BlackBerry|PlayBook|BB10","i"),L={"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"},N=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[I,t&&t[1]||""]],[new RegExp(O,"i"),[O,""]],[new RegExp(M,"i"),[M,""]],[D,["BlackBerry",""]],[new RegExp(j,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return["Windows Phone",""];if(new RegExp(A).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=L[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[j,r]}return[j,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=f(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[R,[t[2],t[3],t[4]||"0"].join(".")]:[R,""]],[/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/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],H="[Truncated]",B="[Unserializable]";function z(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}function U(t,i){if(!i)return t;var e=[];try{e=Object.keys(i)}catch(t){e=[]}for(var r of e){var s=void 0;try{s=i[r]}catch(t){s=B}Object.defineProperty(t,r,{value:s,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;var q,V,W,K=3e5,J=class{record(t){if("too-large"!==t.kind)if("retry-later"===t.kind){if(t.retryAfterMs){var i=this.isOpen(),e=Date.now(),r=Math.min(t.retryAfterMs,K);if(!i)return this.ts=e,void(this.es=e+r);this.es=Math.max(this.es,Math.min(e+r,this.ts+K))}}else this.reset()}remainingMs(){var t=Date.now();if(this.ts-5e3>t)return this.reset(),0;var i=Math.min(K,Math.max(0,this.es-t));return 0===i&&this.reset(),i}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};function G(t){return t?t.split("#")[0]:t}function X(t){try{return t()}catch(t){return}}function Z(t,i){var e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function Q(t,i,e){return Y.apply(this,arguments)}function Y(){return(Y=r(function*(t,i,e){var r;try{return yield Promise.race([t,new Promise((t,s)=>{r=Z(()=>{try{null==e||e(),t()}catch(t){s(t)}},i)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function tt(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return W&&e.length===V?W:(V=e.length,W=e.reduce((e,r)=>{q||(q={});var s=q[r];if(s)e[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o,l=null==(o=n[a])?void 0:o.filename,u=i[r];if(l&&u){e[l]=u,q[r]=[l,u];break}}return e},{}))}}var it=class{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 r(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,e){var r,s,n;if(null!=t.cause&&(s=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)}catch(t){}return i({},t,{cause:s,stack:n,errors:null==(r=t.errors)?void 0:r.map(t=>this.parseStacktrace(t,e))})}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 r(function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e})()}convertToExceptionList(t,e){var r=[],s=(t,n,a)=>{var o=r.length,l=void 0===n?i({type:"string"==typeof e.type&&e.type.length>0?e.type:"generic"},"boolean"==typeof e.handled?{handled:e.handled}:void 0===e.handled?{handled:!0}:{},{synthetic:"boolean"==typeof e.synthetic?e.synthetic:t.synthetic,exception_id:o}):{type:"chained",source:a,synthetic:t.synthetic,exception_id:o,parent_id:n},u={type:t.type,value:t.value,mechanism:l};for(var h of(t.stack&&(u.stacktrace={type:"raw",frames:t.stack}),r.push(u),t.cause&&s(t.cause,o,"cause"),null!==(v=t.errors)&&void 0!==v?v:[])){var v;s(h,o,"member")}};return s(t),r}buildParsingContext(t){var i;return{chunkIdMap:tt(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}getAggregateErrors(t){try{if(k(t))for(var i=Object.getPrototypeOf(t),e=0;i&&100>e;e++){var r,s=null==(r=Object.getOwnPropertyDescriptor(i,"constructor"))?void 0:r.value;if("function"==typeof s&&"AggregateError"===s.name){var n=t.errors;return h(n)?n:void 0}i=Object.getPrototypeOf(i)}}catch(t){}}buildCoercingContext(t,e,r){var s=this;void 0===r&&(r=0);var n=0,a=0,o=!1,l=new Set,u=[],h={},v=function(t,e,r){void 0===r&&(r=0);var v=d(e,r),c=v.apply;if(v.apply=i=>{u.push(t);try{return c(i)}finally{u.pop()}},r>4||r>0&&-1!==u.indexOf(t))return s.coerceFallback(v);var f="object"==typeof t&&null!==t||"function"==typeof t;if(!(0===r&&n>=50||f&&l.has(t))){f&&l.add(t),0===r&&n++;var p,g,_=s.getAggregateErrors(t);o||(o=!!_);try{if(!(p=s.applyCoercers(t,v)))throw h}catch(t){if(t===h)return void(0===r&&n--);if(!o)throw t;p=s.coerceFallback(v)}if(!_||n>=50)return p;try{g=_.length}catch(t){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;for(var b=[],y=0;50>n&&1e3>a&&g>y;y++){a++;var m=void 0;try{m=v.next(_[y])}catch(t){n++,m=s.coerceFallback(d(e+1))}m&&b.push(m)}return i({},p,{errors:b})}},d=function(r,s){return void 0===s&&(s=0),i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:0==r?t:{},apply(t){var i=v(t,r,s+1);if(!i)throw h;return i},next:t=>v(t,r+1)})},c=d(r);return i({},c,{apply:t=>{var i;return null!==(i=v(t,r))&&void 0!==i?i:this.coerceFallback(c)}})}},et=/^([a-z][a-z0-9.+-]+):/i,rt=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function st(t){if(!t||"<anonymous>"===t)return!1;var i=et.exec(t);return!i||rt.includes(i[1].toLowerCase())}function nt(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:st(i)};return f(r)||(n.lineno=r),f(s)||(n.colno=s),n}var at=(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]:"?",e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},ot=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,lt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ut=/\((\S*)(?::(\d+))(?::(\d+))\)/,ht=(t,i)=>{var e=ot.exec(t);if(e)return nt(i,e[1],"?",+e[2],+e[3]);var r=lt.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ut.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=at(r[1]||"?",r[2]);return nt(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},vt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,dt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ct=(t,i)=>{var e=vt.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=dt.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]||"?",a=at(n,s);return nt(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ft=/\(error: (.*)\)/;function pt(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function gt(t){for(var i=1;10>=i;i++){var e=t.length-2*i;if(0>e)break;for(var r=!0,s=0;i>s;s++)if(!pt(t[e+s],t[e+i+s])){r=!1;break}if(r){for(var n=0;i>n;n++)t[e+n]=t[e+i+n];return t.length=e+i,{start:e,length:i}}}}function _t(t,i){var e=i.start+i.length,r=yt(t,i);r&&t.splice(e+r===t.length?e:i.start,r)}function bt(t,i){for(var e=i.start;e>0&&pt(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function yt(t,i){for(var e=i.start+i.length,r=e;t.length>r&&pt(t[r],t[r-i.length]);)r++;return r-e}function mt(t,i){var e=i[0],r=t.length-(e?bt(t,e):0);for(var s of i)r-=yt(t,s);return r}function wt(t,i,e){for(var r=0;t.length>r;r++){var s=t[(i+r)%t.length],n=t[(e+r)%t.length];if(s!==n)return n>s}return!1}var St=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=p(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 S(t,"DOMException")}isDOMError(t){return S(t,"DOMError")}},kt=class{match(t){return k(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r?null==(e=i.syntheticException)?void 0:e.stack:void 0,n=!!s;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:s,cause:t.cause?i.next(t.cause):void 0,synthetic:n}}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){try{var i=t.stacktrace;if("string"==typeof i&&i.length>0)return i;var e=t.stack;return"string"==typeof e&&e.length>0?e:void 0}catch(t){return}}},xt=class{match(t){return!!S(t,"ErrorEvent")&&(null!=t.error||this.ar(t))}coerce(t,e){var r;if(null!=t.error)return e.apply(t.error);var s=e.apply(t.message);return i({},s,{stack:null!==(r=this.lr(t))&&void 0!==r?r:s.stack,synthetic:!0})}ar(t){return p(t.message)&&t.message.length>0}lr(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(p(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}},Et=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Ct=class{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(Et);return r&&(i=r[1],e=r[2]),[i,e]}},Pt=["fatal","error","warning","log","info","debug"];function Ft(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""}var Tt=class{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(x(t))return t.constructor.name;var i="name"in t?t.name:void 0;return p(i)&&!g(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: "+Ft(t)}isSeverityLevel(t){return p(t)&&!g(t)&&Pt.indexOf(t)>=0}getStack(t){try{return p(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:p(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(k(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},At=class{match(t){return x(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Ft(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Rt=class{match(t){return w(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}}},Ot=class{match(t){return S(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!x(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 w(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}},Mt="$message",$t="$timestamp",It=new Set([Mt,$t]),jt={enabled:!0,max_bytes:32768};function Dt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:jt.enabled,max_bytes:Nt(t.max_bytes,jt.max_bytes)}:i({},jt)}var Lt=class{constructor(t){this.ns=[],this.ss=0,this.Ir=Dt(t)}setConfig(t){this.Ir=Dt(t),this.rs()}add(t){var i=function(t){var i,e,r;try{r=[],i=null!==(e=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(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return"[Circular]";r.push(i)}return i}}))&&void 0!==e?e:"null"}catch(t){return}try{var s=JSON.parse(i);if(!d(s))return;var n=s,a=n[Mt],o=n[$t];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!y(o))return;return{step:n,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("u">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.Ir.max_bytes||(this.ns.push({step:i.step,bytes:e}),this.ss+=e,this.rs())}}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Ir.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function Nt(t,i){if(!y(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var Ht=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Bt(t){return"string"==typeof t||t}function zt(t){return"string"==typeof t?t:void 0}var Ut={}.propertyIsEnumerable;function qt(t,i){try{return Kt(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Vt(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:H};if(e.remainingNodes--,m(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==i||i.debug("Attribute "+e+" is outside the int64 range; encoding it as a string"),{stringValue:e}):{intValue:e}}(t,i);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(typeof BigInt>"u")return{stringValue:String(t)};var s=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>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:z(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:H};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?z(a):String(a)}}e.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Vt(o.call(t),i,e,r+1)}catch(t){}return h(t)?{arrayValue:{values:Wt(t,i,e,r+1)}}:{kvlistValue:{values:Kt(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:z(String(t))}}function Wt(t,i,e,r){for(var s=[],n=Math.min(t.length,1e3),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(b(o))continue;s.push(Vt(o,i,e,r))}catch(t){s.push({stringValue:B})}return t.length>a&&s.push({stringValue:H}),s}function Kt(t,i,e,r){var s=[];for(var n in t)if(Ut.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(_(a)||f(a))continue;s.push({key:z(n),value:Vt(a,i,e,r)})}catch(t){s.push({key:z(n),value:{stringValue:B}})}}return s}function Jt(t,e,r){return i({},U({},t.resourceAttributes),{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}var Gt=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Xt(t,i){var e=U({},t),r={};for(var s of Gt)({}).hasOwnProperty.call(e,s)&&(r[s]=e[s],delete e[s]);return[...qt(e,i),...qt(r,i)]}var Zt={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};var Qt={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}},Yt=Qt.info;function ti(t){try{return z(String(t))}catch(t){return B}}function ii(t,e,r,s){var n,a=Qt[t.level||"info"]||Yt,o=a.text,l=a.number,u=(void 0===(n=y(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),h={};e.distinctId&&(h.posthogDistinctId=e.distinctId),e.sessionId&&(h.sessionId=e.sessionId),e.windowId&&(h["window.id"]=e.windowId),b(e.sessionStartTimestamp)||(h.sessionStartTimestamp=String(e.sessionStartTimestamp)),b(e.lastActivityTimestamp)||(h.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(h["url.full"]=e.currentUrl),e.screenName&&(h["screen.name"]=e.screenName),e.appState&&(h["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(h.feature_flags=e.activeFeatureFlags);var v=i({},h),d=t.attributes;if(d){var c=[];try{c=Object.keys(d)}catch(t){c=[]}for(var p of c){var g=void 0;try{g=d[p]}catch(t){g=B}Object.defineProperty(v,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:ti(t.body)},attributes:qt(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),f(t.trace_flags)||(_.flags=t.trace_flags),_}function ei(t,i,e){return Jt(t,i,e)}function ri(t,i,e,r){return{resourceLogs:[{resource:{attributes:Xt(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}var si=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.hs}arm(t){this.clear(),this.us=Date.now()+t,this.hs=Z(()=>{this.hs=void 0,this.ls()},t)}armNoEarlierThan(t){this.hs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function ni(){return.75+.5*Math.random()}function ai(t,i,e,r){var s=t*Math.pow(2,Math.min(Math.max(0,i-1),6));return Math.round((void 0===r?s:Math.min(s,Math.max(r,t)))*e)}var oi=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Ir=i,this.A=e,this.cs=r,this.ds=s,this.vs=n,this.fs=a,this.ps=new si(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new J,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=i.maxBufferSize,this.Is=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.Ms=i.flushIntervalMs,this.Es=i.maxBatchRecordsPerPost,this.Ps=i.rateCapWindowMs,this.Rs=i.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(s.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Ir.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Os(t);if(null!==r)if(r.body){if(this.Ds()){var s={record:ii(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.cs(),this.A,null==i?void 0:i.occurredAtMs)};this.ds(()=>this.Ls(s))}}else this.A.info("Log was rejected in beforeSend function")}}Os(t){var i=this.Ir.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.A.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return r}Ds(){if(void 0===this.Rs)return!0;var t=Date.now(),i=t-this.xs;return this.Ps>i&&i>=0||(this.xs=t,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||(this.A.warn("captureLog dropping logs: exceeded "+this.Rs+" logs per "+this.Ps+"ms"),this.$s=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return r(function*(){var i;t.ps.clear();var e=null!==(i=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,n=0;e.length>0&&r>n;){var a,o,l=t._s;t.bs=0;var u=Math.min(e.length,t.Es),h=e.slice(0,u),v=ri(h.map(t=>t.record),t.qs(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.js(v);if(t._s!==l)return;if("too-large"===d.kind&&h.length>1)t.Es=Math.max(1,Math.floor(h.length/2)),t.A.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Es);else{if(t.ws.record(d),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),"retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.A.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.Ir.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Ir.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(h.length),e=null!==(o=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==o?o:[],n+=h.length,"fatal"===d.kind)throw d.error}}})()}Bs(t){var i=this;return r(function*(){var e,r=Math.max(0,t-i.bs),n=null!==(e=i._instance.getPersistedProperty(s.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(s.LogsQueue,n.slice(r)),yield i.vs()})()}qs(){return ei(this.Ir,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];this.Is>e.length||(e.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(s.LogsQueue,e),this.Ts>e.length||this.ws.isOpen()?this.Fs():this.gs()}}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(ai(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){var t=this._instance.getPersistedProperty(s.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return r(function*(){i.ps.clear();var e=i.flush().catch(()=>{});void 0!==t?yield Q(e,t):yield e})()}flushWithTimeout(t){var i=this;return r(function*(){var e=i.flush();yield Q(e,t,()=>{e.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=ni(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}},li=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ui(t){return String(t)+"000000"}function hi(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}var vi=class{constructor(t,i,e){this._instance=t,this.Ir=i,this.A=e,this.zs=new Map,this.ps=new si(()=>this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new J,this.ks=0,this.Ss=1,this.Gs=0}count(t,i,e){void 0===i&&(i=1),this.Zs({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.Zs({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.Zs({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.ys,e=function(){var e=r(function*(){i&&(yield i.catch(()=>{})),yield t.Qs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.ys===e&&(this.ys=null)});return this.ys=e,e}drainWindow(){if(0===this.zs.size)return null;var t=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.Os(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.A.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=e.attributes?i({},e.attributes):void 0,s=hi(e.type,e.name,e.unit,r)}catch(t){return void this.A.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var n=this.zs.get(s);if(!n){if(!this.Ks())return;n={name:e.name,type:e.type,unit:e.unit,attributes:r,windowStartMs:Date.now()},this.zs.set(s,n)}var a=this.Ws.get(e.name);void 0===a?this.Ws.set(e.name,e.type):a===e.type||this.Vs.has(e.name)||(this.Vs.add(e.name),this.A.warn("Metric name '"+e.name+"' is already used as a "+a+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Xs(n,e.value),this.Fs()}else this.A.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Ks(){return this.Ir.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn("Metric series cap reached ("+this.Ir.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Xs(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(li.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,li)]+=1}}Os(t){var i=this.Ir.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.A.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return r}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(ai(this.Ir.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var t=this;return r(function*(){if(t.ps.clear(),0!==t.zs.size){var i=t.zs;t.zs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;var e=t.Gs,r=yield t._instance.Ys(t.Js(i));if(e===t.Gs)switch(t.ws.record(r),"retry-later"===r.kind?(t.ks++,t.Ss=ni()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.Hs()),r.kind){case"ok":return;case"retry-later":return t.ho(i),void t.ps.armNoEarlierThan(t.Hs());case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",r.error)}}})()}Js(t){return i=this.co(t),e=function(t,i,e){return Jt(t,i,e)}(this.Ir,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Xt(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}co(t){var e=ui(Date.now()),r=new Map;for(var s of t.values()){var n,a=hi(s.type,s.name,s.unit,void 0),o=r.get(a);o||(o=i({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=qt(null!==(n=s.attributes)&&void 0!==n?n:{},this.A),u=ui(s.windowStartMs);if("count"===s.type){var h,v={attributes:l,startTimeUnixNano:u,timeUnixNano:e,asDouble:null!==(h=s.total)&&void 0!==h?h:0};o.sum.dataPoints.push(v)}else if("gauge"===s.type){var d,c={attributes:l,timeUnixNano:e,asDouble:null!==(d=s.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(c)}else s.hist&&o.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:e,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:li})}return Array.from(r.values())}ho(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.zs.get(s);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,n.windowStartMs),a.type){case"count":a.total=(null!==(i=a.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(a.hist){a.hist.count+=n.hist.count,a.hist.sum+=n.hist.sum,a.hist.min=Math.min(a.hist.min,n.hist.min),a.hist.max=Math.max(a.hist.max,n.hist.max);for(var o=0;a.hist.bucketCounts.length>o;o++)a.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else a.hist=n.hist}else this.Ks()&&this.zs.set(s,n)}}},di="0.9.0",ci={DEBUG:!1,LIB_VERSION:di,LIB_NAME:"browser-common",JS_SDK_VERSION:di},fi="u">typeof window?window:void 0,pi="u">typeof globalThis?globalThis:fi,gi=null==pi?void 0:pi.navigator,_i=null==pi?void 0:pi.document,bi=null==pi?void 0:pi.location;function yi(){return!(!fi||!1===fi.navigator.onLine)}null!=pi&&pi.XMLHttpRequest&&new pi.XMLHttpRequest;var mi=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={N(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;r>n;n++)s[n-1]=arguments[n];fi&&(ci.DEBUG||fi.POSTHOG_DEBUG||e)&&!f(fi.console)&&fi.console&&("__rrweb_original__"in fi.console[i]?fi.console[i].__rrweb_original__:fi.console[i])(t,...s)},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("error",...i)},critical(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];console.error(t,...e)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(i,e)=>mi(t+" "+i,e)};return r},wi=mi("[PostHog.js]"),Si=wi.createLogger;function ki(t,i){h(t)&&t.forEach(i)}function xi(t,i){if(!b(t))if(h(t))t.forEach(i);else if(t instanceof FormData)t.forEach((t,e)=>i(t,e));else for(var e in t)l.call(t,e)&&i(t[e],e)}var Ei=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 Ci(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}function Pi(t,i,e,r){var s=null!=r?r:{},n=s.capture,a=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===a||a})}function Fi(t){return"ph_toolbar_internal"===t.name}function Ti(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 p(s)&&s?s:i}catch(t){return wi.error("Error in get_current_url, falling back to window.location.href",t),i}}function Ai(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Ri(t){return!!t&&1===t.nodeType}function Oi(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Mi(t){return!!t&&3===t.nodeType}function $i(t){return!!t&&11===t.nodeType&&Ri(t.host)}function Ii(t){return t?a(t).split(/\s+/):[]}function ji(t,i){var e=function(t){var i,e=null==fi||null==(i=fi.location)?void 0:i.href;return f(e)?void 0:Ti(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Di(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 Ii(i)}function Li(t){return b(t)?null:a(t).split(/(\s+)/).filter(t=>le(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ni(t){var i="";return Yi(t)&&!te(t)&&t.childNodes&&t.childNodes.length&&xi(t.childNodes,function(t){var e;Mi(t)&&t.textContent&&(i+=null!==(e=Li(t.textContent))&&void 0!==e?e:"")}),a(i)}function Hi(t){var i;return f(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var Bi=["a","button","form","input","select","textarea","label"];function zi(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}}function Ui(t,i){if(f(i))return!0;var e,r=function(t){if(i.some(i=>zi(t,i)))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function qi(t){var i=t.parentNode;return!(!i||!Ri(i))&&i}var Vi=[".ph-no-autocapture","[data-ph-no-autocapture]"],Wi=["next","previous","prev",">","<"],Ki=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Ji=[".ph-no-rageclick",".ph-no-capture"],Gi=["","text","search","email","password","url","tel","number"];function Xi(t,i){if(!fi||Zi(t))return!1;var e,r,s,a,o;if(m(i)?(e=!!i&&Ji,r=void 0,s=!1):(e=null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Ji,r=null==i?void 0:i.content_ignorelist,s=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(s&&function(t){return!(!t||!Ri(t))&&(!!Oi(t,"textarea")||(Oi(t,"input")?n(Gi,(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)))}(t))return!1;var l=Qi(t,!1).targetElementList;return!function(t,i){if(!1===t||f(t))return!1;var e;if(!0===t)e=Wi;else{if(!h(t))return!1;if(t.length>10)return wi.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=>Ki(i,t)||Ki(r,t))})}(r,l.map(t=>{var i;return{safeText:Ni(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}}))&&!Ui(l,e)}var Zi=t=>!t||Oi(t,"html")||!Ri(t),Qi=(t,i)=>{if(!fi||Zi(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!Oi(s,"body");)if($i(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=qi(s);if(!n)break;if(i||Bi.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=fi.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Yi(t){for(var i=new Set,e=0,r=t;r.parentNode&&!Oi(r,"body");r=r.parentNode){if(e++>=1e3||i.has(r))return!1;i.add(r);var s=Di(r);if(n(s,"ph-sensitive")||n(s,"ph-no-capture"))return!1}if(n(Di(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(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 te(t){return!!(Oi(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Oi(t,"select")||Oi(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var ie=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}))$"),ee=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,re=[16,15,14,13],se=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),ne=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),ae=/[0-9A-Za-z_]/;function oe(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 le(t,i){if(void 0===i&&(i=!0),b(t))return!1;if(p(t)){if(t=a(t),i?ie.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(ee.lastIndex=0;i=ee.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of re){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(ie.test(o)&&oe(o))return!0}}}return!1}(t))return!1;if(i?se.test(t):function(t){var i;for(ne.lastIndex=0;i=ne.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&ae.test(e)&&ae.test(r)))return!0}return!1}(t))return!1}return!0}function ue(t){var i=Ni(t);return le(i=(i+" "+he(t)).trim())?i:""}function he(t){var i="";return t&&t.childNodes&&t.childNodes.length&&xi(t.childNodes,function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=Ni(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+he(t)).trim())}catch(t){wi.error("[AutoCapture]",t)}}),i}function ve(t){return t.replace(/"|\\"/g,'\\"')}function de(t){var i=t.attr__class;if(i)return h(i)?i:Ii(i)}var ce=class{constructor(t){this.disabled=!1===t;var i=d(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}},fe="$autocapture_disabled_server_side",pe="$heatmaps_enabled_server_side",ge="$exception_capture_enabled_server_side",_e="$error_tracking_suppression_rules",be="$error_tracking_capture_extension_exceptions",ye="$web_vitals_enabled_server_side",me="$dead_clicks_enabled_server_side",we="$product_tours_enabled_server_side",Se="$logs_capture_enabled_server_side",ke="$web_vitals_allowed_metrics",xe="$session_recording_remote_config",Ee="$replay_override_sampling",Ce="$replay_override_linked_flag",Pe="$enabled_feature_flags",Fe="$active_feature_flags",Te="$early_access_features",Ae="$feature_flag_details",Re="$feature_flag_payloads",Oe="$feature_flag_request_id",Me="$minimal_flag_called_events",$e="$override_feature_flags",Ie="$override_feature_flag_payloads",je="$stored_person_properties",De="$stored_group_properties",Le="$surveys",Ne="$surveys_loaded_at",He="$surveys_activated",Be="$surveys_activated_session",ze="$surveys_activated_timestamps",Ue="ph_product_tours",qe="$flag_call_reported",Ve="$flag_call_reported_session_id",We="$feature_flag_errors",Ke="$feature_flag_evaluated_at",Je="$sdk_debug_recording_script_not_loaded",Ge="$sdk_debug_replay_stale_config",Xe="PostHog loadExternalDependency extension not found.",Ze="visibilitychange",Qe="beforeunload",Ye=t=>{var i=null==_i?void 0:_i.createElement("a");return f(i)?null:(i.href=t,i)},tr=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 a=e[1];try{a=decodeURIComponent(a)}catch(t){wi.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ir=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],v=0;l.length>v;v++){var d=l[v].split("=");h(d)&&(i.includes(d[0])?u.push(d[0]+"="+e):u.push(l[v]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},er=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},rr=(t,i)=>t>=i&&yi(),sr=(t,i,e,r)=>{if(0===t){if(yi()){var s=i+1;return s===e&&r(),s}return i}return 0},nr="$copy_autocapture",ar=Si("[AutoCapture]");function or(t,i){return i.length>t?i.slice(0,t)+"...":i}function lr(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Ri(i));return i}function ur(t,e){var r,s,a=e.e,o=e.maskAllElementAttributes,l=e.maskAllText,u=e.elementAttributeIgnoreList,v=e.elementsChainAsString,d=e.disableCaptureUrlHashes;if(!Ri(t))return{props:{}};for(var c=[t],f=new Set([t]),g=t;g.parentNode&&!Oi(g,"body")&&1e3>c.length;)if($i(g.parentNode)){var _=g.parentNode.host;if(f.has(_))break;f.add(_),c.push(_),g=_}else{if(!Ri(g.parentNode))break;if(f.has(g.parentNode))break;f.add(g.parentNode),c.push(g.parentNode),g=g.parentNode}var b="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?c.findIndex(t=>Oi(t,"button")||Oi(t,"a")):-1;b>0&&(l=l||c.slice(0,b+1).some(t=>!Yi(t)||te(t)));var y,m,w,S=[],k={},x=!1,E=!1;if(xi(c,t=>{var i=Yi(t);if(Oi(t,"a")&&!o&&(null==u||!u.includes("href"))){var e=t.getAttribute("href");x=!!(i&&e&&le(e))&&(d?G(e):e)}n(Di(t),"ph-no-capture")&&(E=!0),S.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};Bi.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?or(1024,ue(t)):or(1024,Ni(t)));var o=Di(t);i||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),xi(t.attributes,function(e){var n;if((!te(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&le(e.value)&&(!p(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=Ii(o).join(" ")),a["attr__"+e.name]=or(1024,"href"===e.name&&s?G(o):o)}});for(var l=1,u=1,h=t;h=lr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,d)),xi(function(t){if(!Yi(t))return{};var i={};return xi(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&&le(r)&&(i[e]=r)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(k,i)||(k[i]=t)})}),E)return{props:{},explicitNoCapture:E};if(b>0&&(t=c[b],S.splice(0,b)),l||(S[0].$el_text=Oi(t,"a")||Oi(t,"button")?ue(t):Ni(t)),x){var C,P;S[0].attr__href=x;var F=null==(C=Ye(x))?void 0:C.host,T=null==fi||null==(P=fi.location)?void 0:P.host;F&&T&&F!==T&&(y=x)}return{props:Ei((m=a.type,{$event_type:m,$ce_version:1}),v?{}:{$elements:S},{$elements_chain:(w=S,h(w)?function(t){return t.map(t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Ci(a).sort((t,i)=>{return(r=i[0])>(e=t[0])?-1:e>r?1:0;var e,r}).forEach(t=>{var i=t[1];return o[ve(t[0].toString())]=ve(i.toString())}),(s+=":")+Ci(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:de(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ci(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(w)):"")},null!=(r=S[0])&&r.$el_text?{$el_text:null==(s=S[0])?void 0:s.$el_text}:{},y&&"click"===a.type?{$external_click_url:y}:{},k),target:t}}var hr=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(t){var i;if(!Yi(t))return!0;for(var e,r=null!==(i=this.mo().css_selector_ignorelist)&&void 0!==i?i:Vi,s=new Set,a=t,o=function(){if(s.size>=1e3||s.has(a))return{v:!0};s.add(a);var t=a,i=Di(t);if(n(i,"ph-no-capture")||n(i,"ph-sensitive")||te(t)||r.some(i=>zi(t,i)))return{v:!0};var e=a.parentNode;a=$i(e)?e.host:e&&Ri(e)?e:null};a;)if(e=o())return e.v;return!1}yo(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var i=this.vo;i&&(t.pointerId!==i.id||Math.abs(t.clientX-i.x)>5||Math.abs(t.clientY-i.y)>5?this.do():"pointerup"===t.type&&(i.released=!0,this.fo=setTimeout(()=>this.do(),0)))}else{var e;this.do();var r=Hi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&Ri(r)&&(this.vo={target:r,excluded:this.po(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(e=this.bo)?void 0:e.distinctId})}else this.do()}_o(t){var i,e=this.vo;this.do();var r=Hi(t);if(null!=e&&e.released&&e.target.isConnected&&e.distinctId===(null==(i=this.bo)?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&r&&(Oi(r,"html")||Oi(r,"body"))){var s;if(e.excluded)return null;var a=null!==(s=this.mo().css_selector_ignorelist)&&void 0!==s?s:Vi;return[r,null==_i?void 0:_i.documentElement,null==_i?void 0:_i.body].some(t=>{if(!t)return!1;var i=Di(t);return n(i,"ph-no-capture")||n(i,"ph-sensitive")||!Yi(t)||te(t)||a.some(i=>zi(t,i))})?null:e.target}}constructor(t){this.wo=t,this.name="autocapture",this.ko=!1,this.So=null,this.xo=!1,this.Co=new Map,this.$o=!1,this.Ir={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Ir),this.rageclicks=new ce(this.Ir.rageclick),this.Io=null}setup(t){this.Mo(),this.bo=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?i.dispose():(this.Eo=i,this.startIfEnabled())}dispose(){var t;this.To||(this.To=!0,this.bo=void 0,null==(t=this.Eo)||t.dispose(),this.Eo=void 0,this.Co.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Ir),this.Ir}Mo(){var t,i;return this.mo(),this.Ir.url_allowlist=null==(t=this.Ir.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Ir.url_ignorelist=null==(i=this.Ir.url_ignorelist)?void 0:i.map(t=>new RegExp(t)),this.Ir}Ro(){if(this.isBrowserSupported()){if(fi&&_i){var t=this.Ao=t=>{t=t||(null==fi?void 0:fi.event);try{if("blur"===t.type)return void this.do();if(0===t.type.indexOf("pointer"))return void this.yo(t);var i="click"===t.type?this._o(t):void 0;if(_(i))return;this.Fo(t,"$autocapture",i)}catch(t){ar.error("Failed to capture event",t)}};if(Pi(fi,"blur",t),Pi(_i,"submit",t,{capture:!0}),Pi(_i,"change",t,{capture:!0}),Pi(_i,"click",t,{capture:!0}),xi(["pointerdown","pointermove","pointerup","pointercancel"],i=>{Pi(_i,i,t,{capture:!0})}),this.mo().capture_copied_text){var i=this.Oo=t=>{t=t||(null==fi?void 0:fi.event);try{this.Fo(t,nr)}catch(t){ar.error("Failed to capture clipboard event",t)}};Pi(_i,"copy",i,{capture:!0}),Pi(_i,"cut",i,{capture:!0}),Pi(_i,"paste",i,{capture:!0})}}}else ar.info("Disabling Automatic Event Collection because this browser is not supported")}Po(){this.do(),this.Ao&&(null==fi||fi.removeEventListener("blur",this.Ao),xi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==_i||_i.removeEventListener(t,this.Ao,!0)}),null==_i||_i.removeEventListener("submit",this.Ao,!0),null==_i||_i.removeEventListener("change",this.Ao,!0),null==_i||_i.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Oo&&(null==_i||_i.removeEventListener("copy",this.Oo,!0),null==_i||_i.removeEventListener("cut",this.Oo,!0),null==_i||_i.removeEventListener("paste",this.Oo,!0),this.Oo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(t){if(!this.To)if(this.xo=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.$o=i.elementsChainAsString);var e,r=i.autocapture_opt_out;m(r)&&(null==(e=this.bo)||e.kv.set(fe,r),this.So=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,i){if(void 0===i&&(i=this),!this.To){t.size?this.Co.set(i,new Set(t)):this.Co.delete(i);var e=new Set;this.Co.forEach(t=>{t.forEach(t=>e.add(t))}),this.Io=e}}getElementSelectors(t,i){var e,r=[];return null==(e=this.Io)||e.forEach(e=>{var s;null==_i||null==(s=_i.querySelectorAll(e))||s.forEach(s=>{t!==s&&i!==s||n(r,e)||r.push(e)})}),r}get isEnabled(){var t,i;if(this.To)return!1;var e=null==(t=this.bo)?void 0:t.kv.get(fe),r=this.So,s=this.mo();if(!s.remoteRequestsDisabled&&!this.xo)return!1;var n=s.remoteRequestsDisabled&&!this.xo;if(_(r)&&!m(e)&&!n)return!1;var a=null!==(i=this.So)&&void 0!==i?i:!!e;return!!s.enabled&&!a}Fo(t,e,r){if(void 0===e&&(e="$autocapture"),this.isEnabled){var s=r||Hi(t);Mi(s)&&(s=s.parentNode||null);var n,a=this.Mo();"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&a.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Xi(s,a.rageclick)&&this.Fo(t,"$rageclick",r);var o=e===nr,l=o?i({},a,{dom_event_allowlist:void 0}):a;if(s&&function(t,i,e,r,s,n){var a;if(!fi||Zi(t))return!1;if(null!=e&&e.url_allowlist&&!ji(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&ji(e.url_ignorelist,n))return!1;if(null!=e&&e.dom_event_allowlist){var o=e.dom_event_allowlist;if(o&&!o.some(t=>i.type===t))return!1}var l=Qi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(f(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}(h,e))return!1;if(!Ui(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Ui(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:Vi))return!1;try{var v=fi.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return u?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(Bi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:a.getCurrentUrl}})){var u,h=ur(s,{e:t,maskAllElementAttributes:a.maskAllElementAttributes,maskAllText:a.maskAllText,elementAttributeIgnoreList:a.element_attribute_ignorelist,elementsChainAsString:this.$o,disableCaptureUrlHashes:a.disableCaptureUrlHashes}),v=h.props;if(h.explicitNoCapture)return!1;var d=this.getElementSelectors(s,h.target);if(d&&d.length>0&&(v.$element_selectors=d),e===nr){var c=t.type||"clipboard";if("paste"!==c){var p,g,_=null==fi||null==(p=fi.getSelection())?void 0:p.toString(),b=Li(_);if(!b)return!1;v.$selected_content=b,v.$clipboard_text_length=null!==(g=null==_?void 0:_.length)&&void 0!==g?g:0}v.$copy_type=c}return null==(u=this.bo)||u.capture(e,v),!0}}else this.do()}isBrowserSupported(){return v(null==_i?void 0:_i.querySelectorAll)}},vr=class{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=d(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._shouldDisableFlags(),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}},dr="undefined"!=typeof globalThis?globalThis:fi;dr&&"undefined"==typeof self&&(dr.self=dr),dr&&"undefined"==typeof File&&(dr.File=function(){});var cr=null!=fi?fi:{},fr=Si("[Dead Clicks]"),pr=()=>!0,gr=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}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({[me]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ho(()=>{this.zo()}):this.stop()}Ho(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?fr.error("failed to load script",i):t()})}zo(){var t;if(_i){if(!this.Bo&&null!=(t=cr.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=d(this.instance.config.capture_dead_clicks)?i({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Bo=cr.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Bo.start(_i),fr.info("starting...")}}else fr.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,fr.info("stopping..."))}},_r=Si("[ExceptionAutocapture]"),br=()=>{},yr=t=>{var i;if(v(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function mr(t,i,e){try{if(!(i in t))return br;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=yr(e);n;){if(n.next===s)return void(n.next=r.next);n=yr(e=n.next)}else t[i]=r.next}}catch(t){return br}}var wr=Si("[TracingHeaders]"),Sr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],kr=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Sr],xr="<masked>",Er=["li_fat_id"];function Cr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Pr=Si("[Web Vitals]"),Fr=9e5,Tr=["CLS","FCP","INP","LCP"],Ar=["INP","LCP"],Rr=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Or=Si("[RemoteConfig]"),Mr=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=cr._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Ya(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}tl(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 Or.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Or.warn("Remote config is disabled. Falling back to local config.");this.Ya(t=>{if(!t)return Or.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(t=>{this.el(t.json,t)});this.el(t)})}catch(t){Or.error("Error loading remote config",t),this.el()}}el(t,i){!t&&i&&(0===i.statusCode?i.error||Or.warn("Failed to fetch remote config from PostHog."):Or.error("Failed to fetch remote config from PostHog."));try{this._instance.el(t?{ok:!0,config:t}:{ok:!1})}catch(t){Or.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){Or.error("Error loading feature flags",t)}}},$r="disabled",Ir="lazy_loading",jr=Si("[SessionRecording]"),Dr=[Je,Ge,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],Lr=Si("[Heatmaps]");function Nr(t){return d(t)&&"clientX"in t&&"clientY"in t&&y(t.clientX)&&y(t.clientY)}var Hr=Si("[Product Tours]"),Br=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(we))},zr=Si("[SiteApps]"),Ur="Error while initializing PostHog app with config id ",qr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Vr="events",Wr="cancelEvents",Kr="survey shown",Jr="survey dismissed",Gr="survey sent";function Xr(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var Zr=(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}},Qr=t=>t.toLowerCase(),Yr={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=>Zr(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!Zr(i,t))),icontains:(t,i)=>i.map(Qr).some(i=>t.map(Qr).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Qr).every(i=>t.map(Qr).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 ts(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=Yr[e.operator];return!!s&&s(e.values.map(String),[String(r)])})}var is=Si("[Surveys]"),es=["popover","widget","api"],rs="SDK is not enabled or survey functionality is not yet loaded",ss="Disabled. Not loading surveys.",ns=class{constructor(t,i){this.wo=t,this.Th=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Ih=!1,this.Mh=!1,this.Eh=[],this.Ph=[],this.Rh=null,this.Ah=null,this.To=!1,this.Fh=new Set,this.onRemoteConfig=t=>{if(!this.To&&!this.Ir.disableSurveys){if(!t.ok)return this.Mh=!0,this.Oh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),is.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(b(i))return is.warn("Flags not loaded yet. Not loading surveys.");this.Dh=m(i)?i:i.length>0,is.info("flags response received, isSurveysEnabled: "+this.Dh),this.loadIfEnabled()}},this.Oh=t=>{this.Ph.slice().forEach(i=>this.Lh(i,t))}}setup(t){if(!this.To)return this.Nh=t,qr(t.kv.initialize(),()=>{if(this.Nh===t&&!this.To){this.Nh=void 0,this.bo=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.To?i.dispose():(this.Eo=i,this.loadIfEnabled())}})}dispose(){var t,i,e,r;this.To||(this.To=!0,this.Nh=void 0,this.bo=void 0,null==(t=this.Eo)||t.dispose(),this.Eo=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Eh=[],this.Ph.forEach(t=>{t.active=!1}),this.Ph=[],null==(r=this.qh)||r.call(this),this.qh=void 0,this.Rh=null,this.Fh.forEach(t=>clearTimeout(t)),this.Fh.clear())}get Ir(){return this.wo.get()}initialize(){this.loadIfEnabled()}reset(){var t;null==(t=this._surveyManager)||null==t.clearInMemoryInProgressSurveyState||t.clearInMemoryInProgressSurveyState();try{var i;null==(i=this._surveyEventReceiver)||i.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],r=0;r<localStorage.length;r++){var s=localStorage.key(r);(null!=s&&s.startsWith("seenSurvey_")||null!=s&&s.startsWith("inProgressSurvey_"))&&e.push(s)}e.forEach(t=>localStorage.removeItem(t))}catch(t){}this.Oh()}loadIfEnabled(){if(!this.To&&this.bo){var t=this.Ir;if(!this._surveyManager)if(this.Ih)is.info("Already initializing surveys, skipping...");else if(t.disableSurveys)is.info(ss);else if(t.cookielessMode&&this.wo.isOptedOut())is.info("Not loading surveys in cookieless mode without consent.");else{var i=this.wo.getExtensions();if(i){if(!f(this.Dh)||t.advancedEnableSurveys){var e=this.Dh||t.advancedEnableSurveys;this.Ih=!0,this.Mh=!1;try{var r=i.generateSurveys;if(r)return this.Bh(r,e),void(this.Ih=!1);var s=i.loadExternalDependency;if(!s)return this.jh(Xe),void(this.Ih=!1);s(t=>{try{if(this.To)return;var i=this.wo.getExtensions();t||null==i||!i.generateSurveys?this.jh("Could not load surveys script",t):this.Bh(i.generateSurveys,e)}finally{this.Ih=!1}})}catch(t){throw this.Ih=!1,this.jh("Error initializing surveys",t),t}}}else this.jh("PostHog Extensions not found.")}}}Bh(t,i){var e,r;if(!this.To){this._surveyManager=t(i),this._surveyEventReceiver=this.wo.createEventReceiver(this.Oh);var s=null==(e=null!==(r=this.bo)&&void 0!==r?r:this.Th)?void 0:e.kv.get(Le);s&&this.Hh(s),is.info("Surveys loaded successfully"),this.zh(),this.Oh(),this.Uh({isLoaded:!0})}}jh(t,i){this.Mh=!0,is.error(t,i),this.Oh({isLoaded:!1,error:t}),this.Uh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Eh.push(t),this._surveyManager&&this.Uh({isLoaded:!0}),()=>{this.Eh=this.Eh.filter(i=>i!==t)}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.bo)&&void 0!==e?e:this.Th;if(r&&!this.To){if(this.Ir.disableSurveys)return is.info(ss),t([]);var s=r.kv.get(Le);if(s&&!i)return t(s,{isLoaded:!0}),void(this.Wh()&&this.getSurveys(()=>{},!0));if(this.Rh)this.Rh.then(i=>{this.To||t(i.surveys,i.context)}).catch(t=>is.error("Error in survey callback",t));else{var n=this.Vh("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.Ir.requestTimeoutMs}).then(t=>{try{return this.Gh(r,t)}catch(t){return is.error("Error processing surveys response",t),this.Gh(r,{statusCode:0,error:t})}},t=>this.Gh(r,{statusCode:0,error:t}));this.Rh=n;var a=()=>{this.Rh===n&&(this.Rh=null)};n.then(i=>{a(),this.To||(this.Oh(i.context),t(i.surveys,i.context))},a).catch(t=>is.error("Error in survey callback",t))}}}Vh(t,i){var e=this.bo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(rs)}))}Gh(t,i){if(this.To)return{surveys:[],context:{isLoaded:!1,error:rs}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?is.error(r):i.error||is.warn(r),this.Ah=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Ah=null;var s=i.json.surveys||[];return t.kv.set({[Le]:s,[Ne]:Date.now()}),this.Hh(s),{surveys:s,context:{isLoaded:!0}}}Hh(t){var i,e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Xr(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t)));null==(i=this._surveyEventReceiver)||i.replace(e)}Wh(){return this.Zh()&&!this.Rh&&!this.Qh()}Zh(){var t,i,e=null==(t=null!==(i=this.bo)&&void 0!==i?i:this.Th)?void 0:t.kv.get(Ne);return y(e)&&Date.now()-e>3e5}Qh(){return y(this.Ah)&&3e5>Date.now()-this.Ah}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>"seenSurvey_"+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){is.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Oh()}Uh(t){for(var i of this.Eh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){is.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!b(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);is.warn("init was not called")}onActiveMatchingSurveysChanged(t){var i,e;if(this.To)return()=>{};var r={callback:t,active:!0,revision:0};this.Ph.push(r),this.zh();var s=null==(i=null!==(e=this.bo)&&void 0!==e?e:this.Th)?void 0:i.kv.get(Le);return this.Ir.disableSurveys||!this._surveyManager&&this.Mh&&!this.Ih||!s&&!b(this.Ah)&&!this.Rh?this.Lh(r,{isLoaded:!1}):this._surveyManager&&this.Lh(r),()=>{var t;r.active=!1,this.Ph=this.Ph.filter(t=>t!==r),0===this.Ph.length&&(null==(t=this.qh)||t.call(this),this.qh=void 0)}}zh(){var t,i,e;this._surveyManager&&this.Ph.length>0&&(null!==(t=this.qh)&&void 0!==t||(this.qh=null==(i=(e=this.wo).onMatchingConditionsChanged)?void 0:i.call(e,this.Oh)))}Lh(t,i){if(!this.To&&t.active){var e=++t.revision,r=r=>{if(!this.To&&t.active&&e===t.revision)try{var s=null!=i?i:{isLoaded:!0},n=JSON.stringify([r,s]);if(n===t.lastResult)return;t.lastResult=n,t.callback(r,s)}catch(t){is.error("Error in active matching surveys callback",t)}};try{i&&!i.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){is.error("Error in active matching surveys callback",t)}}}Jh(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}Kh(t){if(b(this._surveyManager))return{eligible:!1,reason:rs};var i="string"==typeof t?this.Jh(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Xh(t){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(b(this._surveyManager))return{eligible:!1,reason:rs};var i="string"==typeof t?this.Jh(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(b(this._surveyManager))return is.warn("init was not called"),{visible:!1,disabledReason:rs};var i=this.Xh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return b(this._surveyManager)?(is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:rs})):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.Xh(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var r;if(this.wo.isCapturing())if(b(this._surveyManager))is.warn("init was not called");else{var s="string"==typeof t?this.Jh(t):t;if(null!=s&&s.id)if(es.includes(s.type)){var n=null==_i?void 0:_i.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){is.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout(()=>{var t,i;this.Fh.delete(a),!this.To&&this.wo.isCapturing()&&(is.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(s,n,e),is.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.Fh.add(a)}else this._surveyManager.renderSurvey(s,n,e);else is.warn("Survey element not found")}else is.warn("Surveys of type "+s.type+" cannot be rendered in the app");else is.warn("Survey not found")}}displaySurvey(t,e){var r;if(this.wo.isCapturing())if(b(this._surveyManager))is.warn("init was not called");else{var s=this.Jh(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.Kh(s);if(!a.eligible)return void is.warn("Survey is not eligible to be displayed: ",a.reason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else is.warn("Survey not found")}}cancelPendingSurvey(t){b(this._surveyManager)?is.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};ci.DEBUG=!1,ci.LIB_VERSION="1.435.4",ci.LIB_NAME="web";var as=ci,os=new WeakMap,ls=class{on(t,i){return this.El[t]||(this.El[t]=[]),this.El[t].push(i),()=>{this.El[t]=this.El[t].filter(t=>t!==i)}}emit(t,i){for(var e of this.El[t]||[])e(i);for(var r of this.El["*"]||[])r(t,i)}constructor(){this.El={}}};function us(t,i,e){if(b(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}}var hs=class{constructor(t){this._instance=t,this.Yh=new Set,this.tc=new Set,this.ec=new ls,this.nc=(t,i)=>this.sc(t,i)&&this.rc(t,i)&&this.oc(t,i)&&this.ac(t,i),this.sc=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;f(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.lc=null==(i=this._instance)?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t,i;null==(t=this.lc)||t.call(this),this.lc=void 0,null==(i=this._instance)||null==(i=i.autocapture)||i.setElementSelectors(new Set,this),this.ec=new ls}register(t){var i,e;if(!f(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Yh.add(t),null==(i=t.steps)||i.forEach(t=>{this.tc.add((null==t?void 0:t.event)||"")})}),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Yh.forEach(t=>{var i;null==(i=t.steps)||i.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this._instance.autocapture.setElementSelectors(r,this)}}replace(t){this.Yh.clear(),this.tc.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.tc.has(t)||this.tc.has(i.event))&&this.Yh.forEach(t=>{this.uc(i,t)&&this.ec.emit("actionCaptured",t.name)})}hc(t){this.onAction("actionCaptured",i=>t(i))}uc(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.nc(t,e))return!0;return!1}onAction(t,i){return this.ec.on(t,i)}rc(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(!us(r,i.url,i.url_matching||"contains"))return!1}return!0}oc(t,i){return!!this.cc(t,i)&&!!this.dc(t,i)&&!!this.vc(t,i)}cc(t,i){var e;if(null==i||!i.href)return!0;var r=this.fc(t);if(r.length>0)return r.some(t=>us(t.href,i.href,i.href_matching||"exact"));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&us((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}dc(t,i){var e;if(null==i||!i.text)return!0;var r=this.fc(t);if(r.length>0)return r.some(t=>us(t.text,i.text,i.text_matching||"exact")||us(t.$el_text,i.text,i.text_matching||"exact"));var s,n,a,o=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!o&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!b(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(o),n=i.text,a=i.text_matching||"exact",s.some(t=>us(t,n,a)))}vc(t,i){var e,r;if(null==i||!i.selector)return!0;if(null!=t&&null!=(e=t.properties)&&null!=(e=e.$element_selectors)&&e.includes(i.selector))return!0;var s=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&s)try{return new RegExp(i.selector_regex).test(s)}catch(t){return!1}return!1}fc(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}ac(t,i){return null==i||!i.properties||0===i.properties.length||ts(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)}},vs=class{constructor(t,i){var e;this.gc=[],this._instance=t,this.mc=i,this.yc=new Map,this.bc=new Map,this._c=new Map,this.wc=null==(e=this._instance)||null==e.onSessionId?void 0:e.onSessionId(t=>this.kc(t))}Sc(t){return!1}xc(){return null}Cc(t){}$c(){}Tc(t,i){return!!t&&ts(t.propertyFilters,null==i?void 0:i.properties)}Ic(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}Mc(t,i,e){var r=(e===Vr?this.yc:this.bc).get(t),s=[];return this.Ec(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.Tc(n,i)})}register(t){this.Pc(t,!1)}replace(t){this.Pc(t,!0)}Pc(t,i){var e;f(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Rc(t,i),this.Ac(t,i))}Ac(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._c.clear(),0!==e.length){this.Fc||(this.Fc=new hs(this._instance),this.Fc.init(),this.Fc.hc(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._c.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this._c.set(i.name,s)}})}),i?this.Fc.replace(r):this.Fc.register(r)}else{var s;i&&(null==(s=this.Fc)||s.replace([]))}}Oc(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)})}Rc(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}),a=this.Ic(t,Vr),o=this.Ic(t,Wr);i?(this.yc=a,this.bc=o):(this.Oc(this.yc,a),this.Oc(this.bc,o)),(0!==s.length||0!==n.length||t.some(t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length}))&&(null!==(e=this.lc)&&void 0!==e||(this.lc=null==(r=this._instance)?void 0:r._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,r,s=this.Dc(),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 a=this.Lc(t,n,i);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Nc([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.qc(n),void this.jc([n])}if(this.bc.has(t)){var o=this.Mc(t,i,Wr);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.Nc(o.map(t=>t.id)),o.forEach(t=>this.Bc(t.id)))}if(this.yc.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.yc.get(t)});var l=this.Mc(t,i,Vr);this.Hc(l.map(t=>t.id))}}onAction(t){this._c.has(t)&&this.Hc(this._c.get(t)||[])}Hc(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.Sc(s)?this.qc(s)&&this.zc(s):r.push(s);r.length>0&&(this.gc=[...new Set([...this.gc,...r])]),this.Dc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Uc()}}qc(t){this.gc=this.gc.filter(i=>i!==t);var i=this.Wc();return!i.includes(t)&&(this.Vc([...i,t]),this.Gc(),!0)}Nc(t){var i=new Set(t);this.gc=this.gc.filter(t=>!i.has(t));var e=this.Zc(),r=e.filter(t=>!i.has(t));r.length!==e.length&&(this.Vc(r),0===r.length&&this.Qc()),this.jc(t),this.Uc()}Uc(){try{var t;null==(t=this.mc)||t.call(this)}catch(t){this.Dc().error("Error while handling activated items change",t)}}Jc(){var t,i=this.xc();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}zc(t){if(this.xc()){var e=this.Jc();this.Cc(i({},e,{[t]:Date.now()}))}}jc(t){if(this.xc()){var i=this.Jc(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],a=s[1];t.includes(n)?r=!0:e[n]=a}r&&(c(e)?this.$c():this.Cc(e))}}Kc(){this.xc()&&this.$c()}getActivationTimestamp(t){if(this.Wc().includes(t)){var i=this.Jc()[t];return y(i)?i:void 0}}Zc(){var t,i=this.Xc();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}Wc(){var t,i,e=this.Zc();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Yc()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Gc(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.td(i)}Qc(){this.ed()}kc(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Yc()];if(e&&e!==t){var r=this.Zc(),s=this.Jc();r.length>0&&(this.Vc([]),r.filter(t=>y(s[t])).forEach(t=>this.Bc(t))),this.Qc(),this.Kc(),r.length>0&&this.Uc()}}getActivatedIds(){return[...new Set([...this.Wc(),...this.gc])].filter(t=>!this.nd(t))}dispose(){var t,i,e;null==(t=this.wc)||t.call(this),this.wc=void 0,null==(i=this.lc)||i.call(this),this.lc=void 0,null==(e=this.Fc)||e.dispose(),this.Fc=void 0}reset(){this.gc=[],this.Zc().length>0&&this.Vc([]),this.Qc(),this.Kc(),this.Uc()}getEventToItemsMap(){return this.yc}sd(){return this.Fc}},ds=class extends vs{constructor(t,i){super(t,i)}Xc(){return He}Yc(){return Be}xc(){return ze}Cc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[ze]:t})}$c(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(ze)}Sc(t){var i,e;this.Ec(i=>{e=i.find(i=>i.id===t)});var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return y(r)&&r>0}rd(){return Kr}Ec(t){var i;null==(i=this._instance)||i.getSurveys(t)}Bc(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Dc(){return is}Vc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[He]:t})}td(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Be]:t})}ed(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Be)}nd(){return!1}Lc(t,i,e){var r,s;return t===Gr&&!1===(null==e||null==(r=e.properties)?void 0:r.$survey_completed)?"ignore":(this.Ec(t=>{s=t.find(t=>t.id===i)}),!s||function(t){var i;return Xr(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(s)?t===Kr?"consume":"ignore":t===Kr?"persist":t===Jr||t===Gr?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},cs=class{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);f(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)}},fs=class{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()}isCapturing(){return this._instance.is_capturing()}getExtensions(){var t=null==cr?void 0:cr.__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(t){return new ds(this._instance,t)}onMatchingConditionsChanged(t){var i=this._instance._addCaptureHook(i=>{"$pageview"!==i&&i!==Kr&&i!==Jr&&i!==Gr||t()}),e=()=>t();Pi(fi,"PHSurveyShown",e);var r=!1,s=this._instance.onFeatureFlags(()=>{r&&t()});return r=!0,()=>{r=!1,i(),s(),null==fi||fi.removeEventListener("PHSurveyShown",e)}}},ps=null!=fi&&fi.location?er(fi.location.hash,"__posthog")||er(location.hash,"state"):null,gs="_postHogToolbarParams",_s=Si("[Toolbar]"),bs=Si("[FeatureFlags]"),ys=class{constructor(t,i){void 0===i&&(i=!1),this.od=!1,this.update(t,i)}update(t,i){this.ad=((t,i)=>{var e,r,s,n,a,o,l,u;return{bootstrap:{featureFlags:null!==(e=null==(r=t.bootstrap)?void 0:r.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(s=null==(n=t.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:void 0},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!==(a=t.remote_config_refresh_interval_ms)&&void 0!==a?a:3e5,idleRefreshBackoff:f(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(o=t.feature_flag_request_max_retries)&&void 0!==o?o:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(u=t.evaluation_contexts)&&void 0!==u?u:t.evaluation_environments)&&void 0!==l?l:[],flagKeys:h(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.od||(bs.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.od=!0),f(t.flag_keys)||h(t.flag_keys)||bs.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.ad}},ms=Si("[FeatureFlags]"),ws=Si("[FeatureFlags]",{debugEnabled:!0}),Ss="\" failed. Feature flags didn't load in time.",ks=[502,504],xs=["click","keydown","wheel","touchstart","pointerdown"],Es="connection_error",Cs=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},Ps=t=>{var i={};for(var e of Ci(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},Fs=t=>k(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Ts=Si("[Error tracking]"),As="webkit-masked-url:",Rs=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Os=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",As],Ms=["__firefox__","__gCrWeb"],$s="Refusing to render web experiment since the viewer is a likely bot",Is={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Zr(i,t),not_regex:(t,i)=>!Zr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},js=Si("[Conversations]"),Ds="Conversations not available yet.";function Ls(){var t="",e="";try{var r=null==gi?void 0:gi.userAgent;if(r){var s=function(t){for(var i=0;N.length>i;i++){var e=N[i],r=e[1],s=e[0].exec(t),n=s&&(v(r)?r(s,t):r);if(n)return n}return["",""]}(r);t=s[0],e=s[1]}}catch(t){}return function(t,e){var r=function(t){if(t)return{}.hasOwnProperty.call(Zt,t)?Zt[t]:t}(t);return i({},r?{"os.name":r}:{},e?{"os.version":e}:{})}(t,e)}function Ns(t,e){var r,s,n,a,o,l,u,h=null!==(r=null==t?void 0:t.flushIntervalMs)&&void 0!==r?r:3e3,v=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=null!=e&&e.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=f(d)?Math.max(v,2048):Math.max(v,d),p=i({},Ls(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(a=null!==(o=null==p?void 0:p["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==a?a:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(l=null==p?void 0:p["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(u=null==p?void 0:p["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:p,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:v,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Hs=["debug","log","warn","error","info"],Bs="console",zs="__posthogHandledLogsRequestError",Us=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[zs]=!0,e},qs=t=>!!t&&"object"==typeof t&&!0===t[zs],Vs=Si("[NetworkMetrics]"),Ws=()=>{var t;return null!=fi&&null!=(t=fi.performance)&&t.now?fi.performance.now():Date.now()},Ks={"http:":80,"https:":443},Js=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Gs=(t,i)=>{var e,r=String(i);return{method:String(t).toUpperCase(),url:(null==(e=Ye(r))?void 0:e.href)||r}},Xs=function(t,e,r,s,n,a,o){void 0===o&&(o=!1);try{var l,u=n();if(!u)return;var h=r||void 0,d=Ws()-s,c=Ye(e.url);if(c&&"http:"!==c.protocol&&"https:"!==c.protocol)return;var f={url:(null==c?void 0:c.href)||e.url,method:e.method},g=v(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var _=o&&!h?void 0:((t,i)=>t?400>t?void 0:String(t):(null==i?void 0:i.name)||"_OTHER")(h,a),b=i({},i({"http.request.method":m=Js.has(y=f.method)?y:"_OTHER"},"_OTHER"===m&&y!==m?{"http.request.method_original":y}:{}),c?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Ks[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(i=t.pathname,i.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var i})(c):{},h?{"http.response.status_code":h}:{},_?{"error.type":_}:{},null==u.attributes?void 0:u.attributes(f,{status:h,durationMs:d}));null==(l=t.metrics)||l.histogram(g,d,{unit:"ms",attributes:b})}catch(t){Vs.error("Failed to record network metric",t)}var y,m},Zs=()=>{},Qs=(t,i)=>v(null==fi?void 0:fi.fetch)?mr(fi,"fetch",e=>function(){for(var r=Ws(),s=arguments.length,n=new Array(s),a=0;s>a;a++)n[a]=arguments[a];var o=e.apply(this,n);if(!i())return o;try{var l,u,h,v=n[0],d=n[1],c=Gs(null!==(l=null!==(u=null==d?void 0:d.method)&&void 0!==u?u:null==v?void 0:v.method)&&void 0!==l?l:"GET",null!==(h=null==v?void 0:v.url)&&void 0!==h?h:v);return o.then(e=>(Xs(t,c,null==e?void 0:e.status,r,i,void 0,!0),e),e=>{throw Xs(t,c,void 0,r,i,e),e})}catch(t){return Vs.error("Failed to observe fetch",t),o}}):Zs,Ys=(t,i)=>{var e,r=null==fi||null==(e=fi.XMLHttpRequest)?void 0:e.prototype;if(!r)return Zs;var s=new WeakMap,n=mr(r,"open",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];try{os.has(this)||s.set(this,Gs(e[0],e[1]))}catch(t){Vs.error("Failed to observe XHR open",t)}return t.apply(this,e)}),a=mr(r,"send",e=>function(){var r;try{var n=s.get(this);if(n&&i()){var a=Ws();Pi(this,"loadend",r=()=>{this.removeEventListener("loadend",r),Xs(t,n,this.status,a,i)})}}catch(t){Vs.error("Failed to observe XHR send",t)}try{for(var o=arguments.length,l=new Array(o),u=0;o>u;u++)l[u]=arguments[u];return e.apply(this,l)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{n(),a()}},tn={featureFlags:class{constructor(t){this.name="featureFlags",this.ld=!1,this.featureFlagEventHandlers=[],this.A=ms,this.ud={},this.hd={},this.dd=[],this.vd=!1,this.fd=!1,this.pd=0,this.gd=!1,this.md=!1,this.yd=!1,this.bd=!1,this._d=0,this.wd=!1,this.rn=()=>{var t=this.kd();this._d=0,t&&this.reloadFeatureFlags()},this.Sd=()=>{var t,i,e=this.xd,r=null!==(t=this.Cd)&&void 0!==t?t:e;f(e)||f(r)||this.Ir.remoteRequestsDisabled||!_i||"hidden"===_i.visibilityState||Date.now()-(null!==(i=this.$d)&&void 0!==i?i:0)<r||(this.Cd=this.wd||!this.Ir.idleRefreshBackoff?e:Math.min(2*r,36e5),this.wd=!1,this.reloadFeatureFlags(),this.Td())},this.Id=()=>{this.wd&&this.Cd===this.xd||this.Md()},this.sn=()=>{"visible"===(null==_i?void 0:_i.visibilityState)&&this.Md()},"get"in t?this.wo=t:(this._instance=t,this.Ed=new ys(t.config,t._shouldDisableFlags()),this.wo=this.Ed)}updateConfig(t,i){var e;null==(e=this.Ed)||e.update(t,i),this.bo&&this.Pd()}setup(t){return this.Nh=t,this.A=t.logger.createLogger("[FeatureFlags]"),qr(t.kv.initialize(),()=>{this.Nh===t&&(this.Nh=void 0,this.bo=t,this.Rd(t))})}Rd(t){var i;if(this.bo===t)return fi&&Pi(fi,"online",this.rn),this.Pd(),this.Ad=t.registerDynamicEventProperties(()=>this.Fd()?this.ud:this.hd),this.Od=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange(()=>{this.Dd(),this.Ld(),this.Nd()}),this.Ld(),this.initialize()}Md(){this.wd=!0,this.Cd=this.xd,this.Sd()}Pd(){var t=this.Ir.refreshIntervalMs,i=!this.Ir.remoteRequestsDisabled&&_i&&!f(t)&&t>0?t:void 0;this.Ir.idleRefreshBackoff||(this.Cd=i),i!==this.xd&&(this.qd(),f(i)||(this.xd=i,this.Cd=i,this.Td(),null!=_i&&_i.addEventListener&&(Pi(_i,Ze,this.sn),ki(xs,t=>{Pi(_i,t,this.Id,{capture:!0})}))))}Td(){f(this.xd)||(f(this.jd)||clearInterval(this.jd),this.$d=Date.now(),this.jd=setInterval(this.Sd,this.xd))}qd(){f(this.jd)||(clearInterval(this.jd),this.jd=void 0,null==_i||null==_i.removeEventListener||_i.removeEventListener(Ze,this.sn),ki(xs,t=>{null==_i||null==_i.removeEventListener||_i.removeEventListener(t,this.Id,{capture:!0})})),this.xd=void 0,this.Cd=void 0,this.wd=!1,this.$d=void 0}destroy(){this.Bd()}dispose(){this.Bd()}Bd(){var t,i;this.qd(),this.pd++,this.md=!1,this.Nh=void 0,this.bo&&(this.Hd(),null==(t=this.Ad)||t.dispose(),this.Ad=void 0,null==(i=this.Od)||i.call(this),this.Od=void 0,this.dd=[],null==fi||fi.removeEventListener("online",this.rn),this.bo=void 0)}get Ir(){return this.wo.get()}zd(t){var i;return this.Ud&&t in this.Ud?this.Ud[t]:null==(i=this.bo)?void 0:i.kv.get(t)}Dd(){return!!this.Ud&&(this.Ud=void 0,!0)}Wd(){var t;return!f(null==(t=this.bo)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Dd()}$t(t){this.Vd(()=>{var i;return null==(i=this.bo)?void 0:i.kv.set(t)})}Gd(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t.$enabled_feature_flags){var s=this.zd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},a=i.flags||i.featureFlags,o=i.flags?Object.entries(i.flags).filter(t=>{var i=t[1];return!(null!=i&&i.failed)}).map(t=>t[0]):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,u=l?o:e&&!h(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),v=this.zd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=l||e?u:Array.from(new Set([...Object.keys(v),...Object.keys(d)])),p=!l&&!e,g=!!p||u,_=!!p||c,b={[Fe]:g,[Pe]:g,[Re]:_};for(var y of(t.$feature_flag_details&&(b[Ae]=g),[Oe,Ke,Me]))f(t[y])||(b[y]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(b)}}Lt(t){this.Vd(()=>{var i;return null==(i=this.bo)?void 0:i.kv.remove(t)})}Vd(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Ld(){var t={};for(var e of[Fe,Re,Oe,$e]){var r=this.zd(e);f(r)||(t[e]=r)}this.ud=t;var s=i({},t),n=this.zd(Pe);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.hd=s}Fd(){var t=this.Ir.cacheTtlMs;if(!t||0>=t)return!1;var i=this.zd(Ke);return"number"!=typeof i||Date.now()-i>t}Zd(){return!!this.Fd()&&(this.bd||this.fd||(this.bd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Qd(){var t=this.Ir.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}Jd(){var t=this.Ir.flagKeys;if(!f(t))return t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i,e=this.Ir,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,i)=>(t[i]=r[i],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,i)=>(t[i]=a[i],t),{});return this.Kd({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,r){var s,n,a=null!=r&&r.merge&&null!==(s=this.zd("$enabled_feature_flags"))&&void 0!==s?s:{},o=null!=r&&r.merge&&null!==(n=this.zd("$feature_flag_payloads"))&&void 0!==n?n:{},l=i({},a,t),u=i({},o,e),h={};for(var v of Object.entries(l)){var d=v[0],c=v[1];h[d]={key:d,enabled:Bt(c),variant:zt(c),reason:void 0,metadata:f(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}}}this.Kd({flags:h})}get hasLoadedFlags(){return this.vd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.zd(Ae),e=this.zd($e),r=this.zd(Ie);if(!r&&!e)return t||{};var s=Ei({},t||{});for(var n of[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])]){var a,o,l=s[n],u=null==e?void 0:e[n],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,v=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,d=null==r?void 0:r[n],c=i({},l,{enabled:h,variant:h?null!=v?v:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),v!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),d&&(c.metadata=i({},null==l?void 0:l.metadata,{payload:d,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),s[n]=c}return this.ld||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.ld=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{var r=t[e];return{key:e,enabled:Bt(r),variant:zt(r),payload:Ht(i[e])}})}getFlagVariants(){var t=this.zd(Pe),i=this.zd($e);if(!i)return t||{};for(var e=Ei({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.ld||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.ld=!0),e}getFlagPayloads(){var t=this.zd(Re),i=this.zd(Ie);if(!i)return t||{};for(var e=Ei({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.ld||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.ld=!0),e}reloadFeatureFlags(){this.gd||this.Ir.featureFlagsDisabled||this.kd()||(this.fd&&(this.md=!0),this.Xd||(this.dd.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.Xd=setTimeout(()=>{this.Yd()},5)))}Hd(){clearTimeout(this.Xd),this.Xd=void 0}onReloading(t){return this.dd.push(t),()=>{this.dd=this.dd.filter(i=>i!==t)}}ensureFlagsLoaded(){this.vd||this.fd||this.Xd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.gd=t}resetFlagCallReported(){this.Lt(qe)}Yd(t){this.Hd();var e=this.bo;if(e&&!this.Ir.remoteRequestsDisabled&&!this.kd())if(this.fd)this.md=!0;else{var r={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},e.initialPersonProperties,this.zd("$stored_person_properties")||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.zd(De),timezone:Cr()};f(e.deviceId)||(r.$device_id=e.deviceId),(null!=t&&t.disableFlags||this.Ir.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this.Qd();s.length&&(r.evaluation_contexts=s);var n=this.Jd();f(n)||(r.flag_keys=n);var a=this.Ir.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),l=this.pd;this.fd=!0;var u=()=>{this.md&&(this.md=!1,this.Yd())},h=t=>{var i,e,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.fd=!1,l===this.pd){if(this.tv(t.statusCode),n||this.md||(this.$anon_distinct_id=void 0),!r.disable_flags||this.md){this.yd=!n;var o=[];t.error?o.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Es:"unknown_error"):200!==t.statusCode&&o.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var h=!(null==(e=s.quotaLimited)||!e.includes("feature_flags"));h&&o.push("quota_limited"),this.$t({[We]:o}),h?this.A.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."):r.disable_flags||this.Kd(s,n,{partialResponse:a}),u()}}else u()},v=t=>{this.fd=!1,l===this.pd?(this.$t({[We]:[Es]}),this.A.error("Feature flag request failed",t),this.Wd()&&this.Nd(!0),u()):u()},d=this.Ir.requestMaxRetries,c=()=>d>0&&l===this.pd,p=()=>{if(l!==this.pd||!this.bo||this.Ir.remoteRequestsDisabled)return this.fd=!1,void u();try{e.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.Ir.compression,sentAt:"body",timeoutMs:this.Ir.requestTimeoutMs}).then(t=>{if((t=>ks.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&c())return d--,void setTimeout(p,500);h(t)}).catch(v)}catch(t){v(t)}};p()}}kd(){return rr(this._d,3)}tv(t){this._d=sr(t,this._d,3,()=>this.A.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.yd)if(this.vd||this.getFlags()&&this.getFlags().length>0){if(!this.Zd()){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.A.warn('getFeatureFlag for key "'+t+Ss)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i;return null==(i=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:i.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.yd)if(this.vd||this.getFlags()&&this.getFlags().length>0){if(!this.Zd()){var r,s=this.getFlagVariants(),n=t in s,a=s[t],o=this.getFlagPayloads()[t],l=String(a),u=this.zd("$feature_flag_request_id")||void 0,v=this.zd("$feature_flag_evaluated_at")||void 0,d=this.zd("$flag_call_reported")||{};if(this.Ir.deduplicateCallsPerSession){var c,p=null==(c=this.bo)?void 0:c.session.sessionId,g=this.zd(Ve);p&&p!==g&&(d={},r=p)}if(e.send_event||!("send_event"in e))if(t in d&&d[t].includes(l))r&&this.$t({[qe]:d,[Ve]:r});else{var _,b,y,m,w,S,k,x,E,C,P,F,T;h(d[t])?d[t].push(l):d[t]=[l],this.$t(i({[qe]:d},r?{[Ve]:r}:{}));var A=this.getFeatureFlagDetails(t),R=[...null!==(_=this.zd("$feature_flag_errors"))&&void 0!==_?_:[]];f(a)&&R.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:v,$feature_flag_bootstrapped_response:null!==(b=null==(y=this.Ir.bootstrap)||null==(y=y.featureFlags)?void 0:y[t])&&void 0!==b?b:null,$feature_flag_bootstrapped_payload:null!==(m=null==(w=this.Ir.bootstrap)||null==(w=w.featureFlagPayloads)?void 0:w[t])&&void 0!==m?m:null,$used_bootstrap_value:!this.yd};f(null==A||null==(S=A.metadata)?void 0:S.has_experiment)||(O.$feature_flag_has_experiment=A.metadata.has_experiment),f(null==A||null==(k=A.metadata)?void 0:k.version)||(O.$feature_flag_version=A.metadata.version);var M=null!==(x=null==A||null==(E=A.reason)?void 0:E.description)&&void 0!==x?x:null==A||null==(C=A.reason)?void 0:C.code;M&&(O.$feature_flag_reason=M),null!=A&&null!=(P=A.metadata)&&P.id&&(O.$feature_flag_id=A.metadata.id),f(null==A?void 0:A.original_variant)&&f(null==A?void 0:A.original_enabled)||(O.$feature_flag_original_response=f(A.original_variant)?A.original_enabled:A.original_variant),null!=A&&null!=(F=A.metadata)&&F.original_payload&&(O.$feature_flag_original_payload=null==A||null==(T=A.metadata)?void 0:T.original_payload),R.length&&(O.$feature_flag_error=R.join(",")),this.ev(O)}else r&&this.$t({[qe]:d,[Ve]:r});if(n)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:Ht(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+Ss)}ev(t){try{var i;null==(i=this.bo)||i.capture("$feature_flag_called",t)}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.iv(t,i)}iv(t,i){var e=this;return r(function*(){var r=e.bo;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e.Qd();n.length&&(s.evaluation_contexts=n);var a,o=e.Jd();f(o)||(s.flag_keys=o);try{var l;a=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.Ir.compression,sentAt:"body",timeoutMs:e.Ir.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void e.A.error("Remote config feature flag request failed",t)}try{i(a)}catch(t){e.A.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.yd)return i.defaultValue;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+Ss),i.defaultValue;var e=this.getFeatureFlag(t,i);return f(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.Kd(t,i,e)}Kd(t,e,r){if(this.bo){this.vd=!0;var s=function(t,e,r,s,n,a){void 0===e&&(e={}),void 0===r&&(r={}),void 0===s&&(s={}),void 0===a&&(a=ms);var o=((t,e)=>{var r=t.flags;return r?i({},t,{featureFlags:Object.fromEntries(Object.keys(r).map(t=>{var i;return[t,null!==(i=r[t].variant)&&void 0!==i?i:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>r[t].enabled).filter(t=>{var i;return!f(null==(i=r[t].metadata)?void 0:i.payload)}).map(t=>{var i;return[t,null==(i=r[t].metadata)?void 0:i.payload]}))}):(t.featureFlags&&e.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,a),l=o.flags,u=o.featureFlags,v=o.featureFlagPayloads;if(u){var d=t.requestId,c=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[Fe]:u,[Pe]:p,[Me]:!1}}var _=u,b=v,y=l;if(null!=n&&n.partialResponse){var m=Object.keys(_),w=b||{};_=i({},e,_),b=i({},r,w),m.forEach(t=>{var i;t in w||null==(i=b)||delete i[t]}),y=i({},s,y)}else if(t.errorsWhileComputingFlags)if(l){var S=new Set(Object.keys(l).filter(t=>{var i;return!(null!=(i=l[t])&&i.failed)}));_=i({},e,Object.fromEntries(Object.entries(_).filter(t=>S.has(t[0]))));var k=Object.fromEntries(Object.entries(b||{}).filter(t=>S.has(t[0])));b=i({},r,k),S.forEach(t=>{var i;t in k||null==(i=b)||delete i[t]}),y=i({},s,Object.fromEntries(Object.entries(y||{}).filter(t=>S.has(t[0]))))}else _=i({},e,_),b=i({},r,b),y=i({},s,y);return i({[Fe]:Object.keys(Ps(_)),[Pe]:_||{},[Re]:b||{},[Ae]:y||{},[Me]:!0===t.minimalFlagCalledEvents},d?{[Oe]:d}:{},c?{[Ke]:c}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.A);if(s)if(!1===(null==r?void 0:r.persist)){var n=!f(this.bo.kv.get(Pe));this.Ud=s,n||this.$t(s)}else this.Dd(),this.Gd(s,t,!(null==r||!r.partialResponse)),this.$t(s);else e&&this.Wd();e||(this.bd=!1),this.Nd(e)}}override(t,i){void 0===i&&(i=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.nv(t)}nv(t){if(this.bo){if(!1===t)return this.Lt([$e,Ie]),this.Nd(),void ws.info("All overrides cleared");if(h(t))return this.$t({[$e]:Cs(t)}),this.Nd(),void ws.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.ld=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[$e]=h(s)?Cs(s):s),n&&(r[Ie]=n),Object.keys(r).length&&this.$t(r),!1===s&&!1===n?this.Lt([$e,Ie]):!1===s?this.Lt($e):!1===n&&this.Lt(Ie),this.Nd(),!1===s?ws.info("Flag overrides cleared"):s&&ws.info("Flag overrides set",{flags:s}),void(!1===n?ws.info("Payload overrides cleared"):n&&ws.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.$t({[$e]:t}),this.Nd(),void ws.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.vd){var i=this.sv(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.zd("$early_access_features")||[]).find(i=>i.flagKey===t),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[Fe]:[t],[Pe]:[t],[je]:Object.keys(a)}),this.$t({[Fe]:Object.keys(Ps(l)),[Pe]:l,[je]:i({},this.zd("$stored_person_properties")||{},a)}),this.Nd();try{var u;null==(u=this.bo)||u.capture("$feature_enrollment_update",o)}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.zd(Te);!r||i?this.rv(t,e):t(r)}rv(t,i){var e=this;return r(function*(){var r=e.bo;if(r){var s,n=i?"&"+i.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;s=a.json.earlyAccessFeatures,e.$t({[Te]:s})}catch(t){return void e.A.error("Early access feature request failed",t)}try{t(s)}catch(t){e.A.error("Early access feature callback failed",t)}}})()}sv(){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),{})}}Nd(t){this.Ld();var i=this.sv(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.ov(t,i)}ov(t,e){void 0===e&&(e=!0);var r=this.zd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this.$t({[je]:i({},r,a,s)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.zd("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[je]:r}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Lt(je),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.zd("$stored_group_properties")||{},s=i({},r);for(var n of Object.keys(t))s[n]=i({},r[n],t[n]);this.$t({[De]:s}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.zd("$stored_group_properties")||{};this.$t({[De]:i({},e,{[t]:{}})})}else this.Lt(De)}reset(){this.pd++,this.md=!1,this.ud={},this.hd={},this.Ud=void 0,this.vd=!1,this.gd=!1,this.yd=!1,this.$anon_distinct_id=void 0,this.Hd(),this.ld=!1,this._d=0}}},en={sessionRecording:class{get Ir(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!(null==(t=this.av)||!t.isStarted)}get status(){var t,i;return"awaiting_config"===this.lv||"missing_config"===this.lv?this.lv:null!==(t=null==(i=this.av)?void 0:i.status)&&void 0!==t?t:this.lv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.lv=$r,this.uv=void 0,this.hv=!1,this.Je=(()=>{var t;if(null==_i||!_i.visibilityState||"visible"===_i.visibilityState)return!0;var i=null==fi||null==(t=fi.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some(t=>"visible"===t.name)})(),this.sn=()=>{var t;"visible"===(null==_i?void 0:_i.visibilityState)&&(this.Je=!0,null==(t=this.av)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw jr.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Ir.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=_i&&_i.addEventListener&&Pi(_i,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.hv=!0,null==_i||null==_i.removeEventListener||_i.removeEventListener("visibilitychange",this.sn),e?this.dv(!0):this.stopRecording()}get vv(){var t,i=!(null==(t=this._instance.get_property(xe))||!t.enabled),e=!this.Ir.disable_session_recording,r=this.Ir.disable_session_recording||this._instance.consent.isOptedOut();return fi&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.hv||this.vv&&null!=(i=this.av)&&i.isStarted)){var e=!f(Object.assign)&&!f(Array.from);this.vv&&e?(this.fv(t),jr.info("starting")):(this.lv=$r,this.stopRecording())}}fv(t){var i,e;if(this.vv)if("awaiting_config"!==this.lv&&"missing_config"!==this.lv&&(this.lv=Ir),null!=cr&&null!=(i=cr.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=cr.__PosthogExtensions__)&&e.initSessionRecording)this.pv(t);else{var r,s=this._instance.sessionManager;null==(r=cr.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.gv,i=>{if(!this.hv&&this.vv&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[Je]:!0}),jr.error("could not load recorder",i)):void this.pv(t);this.lv=$r})}}stopRecording(){var t,i;null==(t=this.uv)||t.call(this),this.uv=void 0,null==(i=this.av)||i.stop()}dv(t){var i,e;void 0===t&&(t=!1),null==(i=this.uv)||i.call(this),this.uv=void 0,null==(e=this.av)||e.discard({discardProducerEvents:t})}mv(){var t,i;null==(t=this.Il)||t.unregister("$session_is_sampled"),null==(i=this.Il)||i.unregister("$replay_sample_rate")}yv(t,i){if(b(t))return null;var e,r=y(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(jr.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}bv(t){if(this.Il){var e,r,s=this.Il,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.yv(null==(e=this.Ir.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.yv(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;b(o)&&this.mv();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[xe]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.uv)||e.call(this),this.uv=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.bv(i),void this.dv()):(this.bv(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.lv&&(this.lv="missing_config",this._instance.register_for_session({[Ge]:!0}),jr.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.av)&&e.log?this.av.log(t,i):jr.warn("log called before recorder was ready")}get gv(){var t;return(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.get_property("$session_recording_remote_config"))||null==(t=t.scriptConfig)?void 0:t.script)||"lazy-recorder"}_v(){var t,i=this._instance.get_property(xe);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return jr.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!b(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}pv(t){var i,e,r;if(!this.hv&&this.vv&&this._instance.sessionManager){if(null==(i=cr.__PosthogExtensions__)||!i.initSessionRecording)return jr.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Je]:!0});var s;if(this.av||(this.av=null==(s=cr.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.Je),this.av._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._v()){if("missing_config"===this.lv||"awaiting_config"===this.lv)return;return this.lv="awaiting_config",jr.info("persisted remote config is stale, requesting fresh config before starting"),void new Mr(this._instance).load()}this.lv=Ir,null==(e=(r=this.av).setDocumentWasEverVisible)||e.call(r,this.Je),this.av.start(t)}else this.lv=$r}onRRwebEmit(t){var i;null==(i=this.av)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.av||null==(t=this.Il)||t.register({[Ce]:!0}),null==(i=this.av)||i.overrideLinkedFlag()}overrideSampling(){var t,i;this.av||null==(t=this.Il)||t.register({[Ee]:!0}),null==(i=this.av)||i.overrideSampling()}overrideTrigger(t){var i,e;this.av||null==(i=this.Il)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.av)||e.overrideTrigger(t)}get sdkDebugProperties(){var t,e={};for(var r of Dr){var s,n=null==(s=this._instance.sessionPersistence)?void 0:s.get_property(r);f(n)||(e[r]=n)}return i({},e,(null==(t=this.av)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,i){var e;return!(null==(e=this.av)||!e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t;null==(t=this.av)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},rn={autocapture:class extends hr{constructor(t){super(new vr(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.wv=!1,this._instance=t,this.Sv=this.xv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Cv();return!!(t.path||t.search||this.$v(t))}startIfEnabled(){this.isEnabled&&(wi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Sv=this.xv(),this.startIfEnabled()}stop(){this.Tv&&this.Tv(),this.Tv=void 0,this.Iv&&this.Iv(),this.Iv=void 0,wi.info("History API monitoring stopped")}monitorHistoryChanges(){fi&&fi.history&&(this.Mv("pushState"),this.Mv("replaceState"),this.Ev(),this.$v()&&this.Pv())}Mv(t){var i;if(fi&&(null==(i=fi.history[t])||!i.__posthog_wrapped__)){var e=this;mr(fi.history,t,i=>function(r,s,n){var a;e.Rv(n)&&e.Av(),i.call(this,r,s,n),e.Fv(t,!e.wv&&"popstate"!==(null==fi||null==(a=fi.event)?void 0:a.type))})}}xv(){var t=null==fi?void 0:fi.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Cv(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:d(t)?t:{}}$v(t){return void 0===t&&(t=this.Cv()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Ov(t){var i=this.Cv(),e=this.Sv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.$v(i)&&t.hash!==e.hash))}Fv(t,i){void 0===i&&(i=!1);try{i||this.Av();var e=this.xv();if(!e)return;if(this.Ov(e)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});i?(this.Dv=r,Promise.resolve().then(()=>this.Av())):r()}this.Sv=e}catch(i){wi.error("Error capturing "+t+" pageview",i)}}Rv(t){var i,e;return!(b(t)||!fi)&&(null==(i=Ye(String(t)))?void 0:i.href)!==(null==(e=fi.location)?void 0:e.href)}Av(){var t=this.Dv;if(t){this.Dv=void 0,this.wv=!0;try{t()}catch(t){wi.error("Error capturing deferred pageview",t)}finally{this.wv=!1}this.Sv=this.xv()}}Ev(){if(!this.Tv){var t=()=>{this.Fv("popstate")};Pi(fi,"popstate",t),this.Tv=()=>{fi&&fi.removeEventListener("popstate",t)}}}Pv(){if(!this.Iv){var t=()=>{this.Fv("hashchange")};Pi(fi,"hashchange",t),this.Iv=()=>{fi&&fi.removeEventListener("hashchange",t)}}}},heatmaps:class{get Ir(){return this.instance.config}constructor(t){var i;this.Lv=!1,this.ko=!1,this.Nv=null,this.instance=t,this.Lv=!(null==(i=this.instance.persistence)||!i.props[pe]),this.rageclicks=new ce(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return d(this.Ir.capture_heatmaps)&&this.Ir.capture_heatmaps.flush_interval_milliseconds&&(t=this.Ir.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return b(this.Ir.capture_heatmaps)?b(this.Ir.enable_heatmaps)?this.Lv:this.Ir.enable_heatmaps:!1!==this.Ir.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ko)return;Lr.info("starting..."),this.qv(),this.sn()}else{var t;clearInterval(null!==(t=this.Nv)&&void 0!==t?t:void 0),this.jv(),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({[pe]:e}),this.Lv=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}Bv(t){Nr(t.originalEvent)&&this.Mr(t.originalEvent,"deadclick")}sn(){this.Nv&&clearInterval(this.Nv),this.Nv="visible"===(null==_i?void 0:_i.visibilityState)?setInterval(this.yl.bind(this),this.flushIntervalMilliseconds):null}qv(){fi&&_i&&(this.Hv=this.yl.bind(this),Pi(fi,Qe,this.Hv),this.zv=t=>this.Mr(t||(null==fi?void 0:fi.event)),Pi(_i,"click",this.zv,{capture:!0}),this.Uv=t=>this.Wv(t||(null==fi?void 0:fi.event)),Pi(_i,"mousemove",this.Uv,{capture:!0}),this.Vv=new gr(this.instance,pr,this.Bv.bind(this)),this.Vv.startIfEnabledOrStop(),this.Gv=this.sn.bind(this),Pi(_i,Ze,this.Gv),this.ko=!0)}jv(){var t;fi&&_i&&(this.Hv&&fi.removeEventListener(Qe,this.Hv),this.zv&&_i.removeEventListener("click",this.zv,{capture:!0}),this.Uv&&_i.removeEventListener("mousemove",this.Uv,{capture:!0}),this.Gv&&_i.removeEventListener(Ze,this.Gv),clearTimeout(this.Zv),null==(t=this.Vv)||t.stop(),this.ko=!1)}Qv(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),a=function(t,i,e){for(var r=t;r&&Ri(r)&&!Oi(r,"body");){if(r===e)return!1;var s=void 0;try{var a,o,l;s=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:fi)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(n(i,s))return!0;r=qi(r)}return!1}(Hi(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:e),target_fixed:a,type:i}}Mr(t,e){var r;if(void 0===e&&(e="click"),!Ai(t.target)&&Nr(t)){var s=this.Qv(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Xi(Hi(t),this.instance.config.rageclick)&&this.Zs(i({},s,{type:"rageclick"})),this.Zs(s)}}Wv(t){!Ai(t.target)&&Nr(t)&&(clearTimeout(this.Zv),this.Zv=setTimeout(()=>{this.Zs(this.Qv(t,"mousemove"))},500))}Zs(t){if(fi){var i=this.Ir.disable_capture_url_hashes?G(fi.location.href):fi.location.href,e=this.Ir.custom_personal_data_properties,r=ir(i,this.Ir.mask_personal_data_properties?[...Sr,...e||[]]:[],xr);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}yl(){this.Rt&&!c(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:gr,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.Lv=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Jv=()=>{clearTimeout(this.Kv),this.Kv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",i({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Xv=t=>{var e;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},b(null==t?void 0:t.name)||b(null==t?void 0:t.value))Pr.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Yv(r);if(!f(s)){var n=y(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.tf||this.tf>t.value){this.Rt.navigationKey!==n&&(this.Jv(),this.Kv=setTimeout(this.Jv,this.flushToCaptureTimeoutMs)),f(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=f(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=i({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,d(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of Rr){var h="url"===u&&"string"==typeof t.attribution[u]?this.Yv(t.attribution[u]):t.attribution[u];f(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;f(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.Jv()}else Pr.error("Ignoring metric with value >= "+this.tf,t)}}},this.ef=()=>{if(!this.ko){var t,e,r,s,n=!1,a=cr.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.if])||("web-vitals"===this.if&&f(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!f(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!f(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,e=h.indexOf("CLS")>-1?l.onCLS:(null==u?void 0:u.onCLS)||l.onCLS,r=h.indexOf("FCP")>-1?l.onFCP:(null==u?void 0:u.onFCP)||l.onFCP,s=h.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(t&&e&&r&&s){var v={reportSoftNavs:this.useSoftNavs},d=n&&this.attributionMetrics.indexOf("INP")>-1?i({},v,{includeProcessedEventEntries:!1}):v;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Xv.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&e(this.Xv.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Xv.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.Xv.bind(this),d),this.ko=!0}else Pr.error("web vitals callbacks not loaded - not starting")}},this.Lv=!(null==(e=this._instance.persistence)||!e.props[ye]),this.startIfEnabled()}get nf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=d(this.nf)?null==(t=this.nf)?void 0:t.web_vitals_allowed_metrics:void 0;return b(e)?(null==(i=this._instance.persistence)?void 0:i.props.$web_vitals_allowed_metrics)||Tr:e}get flushToCaptureTimeoutMs(){return(d(this.nf)?this.nf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=d(this.nf)?this.nf.web_vitals_attribution:void 0;return m(t)?t?Tr:[]:h(t)?t:Ar}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=d(this.nf)?this.nf.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get tf(){var t=d(this.nf)&&y(this.nf.__web_vitals_max_value)?this.nf.__web_vitals_max_value:Fr;return t>0&&6e4>=t?Fr:t}get isEnabled(){var t=null==bi?void 0:bi.protocol;if("http:"!==t&&"https:"!==t)return Pr.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=d(this.nf)?this.nf.web_vitals:m(this.nf)?this.nf:void 0;return m(i)?i:this.Lv}startIfEnabled(){this.isEnabled&&!this.ko&&(Pr.info("enabled, starting..."),this.Ho(this.ef))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=d(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=d(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ye]:e}),this._instance.persistence.register({[ke]:r})),this.Lv=e,this.startIfEnabled()}}}get if(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ho(t){var i=cr.__PosthogExtensions__,e=this.if,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&f(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,i=>{i?Pr.error("failed to load script",i):t()})}Yv(t){var i=t||(null==fi?void 0:fi.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?G(i):i,r=this._instance.config.custom_personal_data_properties;return ir(e,this._instance.config.mask_personal_data_properties?[...Sr,...r||[]]:[],xr)}Pr.error("Could not determine current URL")}}},sn={exceptionObserver:class{constructor(t){var e;this.ef=()=>{var t;if(fi&&this.isEnabled&&null!=(t=cr.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=cr.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=cr.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=cr.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.sf&&this.Ir.capture_unhandled_errors&&(this.sf=i(this.captureException.bind(this))),!this.rf&&this.Ir.capture_unhandled_rejections&&(this.rf=e(this.captureException.bind(this))),!this.af&&this.Ir.capture_console_errors&&(this.af=r(this.captureException.bind(this)))}catch(t){_r.error("failed to start",t),this.lf()}}},this._instance=t,this.uf=!(null==(e=this._instance.persistence)||!e.props[ge]),this.wt=new T(i({},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,A:_r})),this.Ir=this.hf(),this.startIfEnabledOrStop()}hf(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return d(t)?e=i({},e,t):(f(t)?this.uf:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Ir.capture_console_errors||this.Ir.capture_unhandled_errors||this.Ir.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(_r.info("enabled"),this.lf(),this.Ho(this.ef)):this.lf()}Ho(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return _r.error("failed to load script",i);t()})}lf(){var t,i,e;null==(t=this.sf)||t.call(this),this.sf=void 0,null==(i=this.rf)||i.call(this),this.rf=void 0,null==(e=this.af)||e.call(this),this.af=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.uf=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[ge]:this.uf}),this.Ir=this.hf(),this.startIfEnabledOrStop())}}onConfigChange(){this.Ir=this.hf()}captureException(t){try{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";if(this.wt.consumeRateLimit(s))return void _r.info("Skipping exception capture because of client rate limiting.",{exception:s});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var e,r;this.cf=[],this.df=new it([new St,new Ot,new xt,new kt,new At,new Tt,new Ct,new Rt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=Math.min(a.length,s+1e3),l=[],u=s;o>u;u++){var h=a[u];if(1024>=h.length){var v=ft.test(h)?h.replace(ft,"$1"):h;if(!v.match(/\S*Error: /)){for(var d of r){var c=d(v,t);if(c){n.push(c);var f=gt(n);if(f){for(var p=l.length-1;p>=0;p--){var g=l[p];if(f.start>=g.start+g.length)break;l.pop()}l.push(f)}break}}if(mt(n,l)>=50)break}}}var _=[...l].sort((t,i)=>i.start-t.start),b=_[_.length-1];if(b){var y=bt(n,b);for(var m of(n.splice(b.start-y,y),_))m.start-=y}for(var w of _)_t(n,w);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){for(var i=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),e=0,r=1;i.length>r;r++)wt(i,r,e)&&(e=r);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map(t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||"?"});var r})}(n)}}("web:javascript",ht,ct)),this._instance=t,this.cf=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==e?e:[],this.vf=Dt(this.ff()),this.pf=new Lt(this.vf)}onConfigChange(){this.vf=Dt(this.ff()),this.pf.setConfig(this.vf)}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:[],a=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.cf=n,this._instance.persistence&&this._instance.persistence.register({[_e]:this.cf,[be]:a})}}}get gf(){var t,i,e=!!this._instance.get_property(be);return null!==(t=null!==(i=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==i?i:e)&&void 0!==t&&t}buildProperties(t,i){return this.df.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,e){if(this.vf.enabled)try{if(!p(t)||0===t.trim().length)return void Ts.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce((e,r)=>It.has(r)?(i.push(r),e):(e[r]=t[r],e),{}),droppedKeys:i}}(this.mf(e)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&Ts.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.pf.add(i({[Mt]:t,[$t]:(new Date).toISOString()},s))}catch(t){Ts.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.yf(i)){if(this.bf(i))return this._f("Exception dropped: matched a suppression rule"),void Ts.info("Skipping exception capture because a suppression rule matched");if(!this.gf&&this.wf(i))return this._f("Exception dropped: thrown by a browser extension"),void Ts.info("Skipping exception capture because it was thrown by an extension");if(!this.gf&&this.kf(i))return this._f("Exception dropped: thrown by an injected browser script"),void Ts.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Sf(i))return this._f("Exception dropped: thrown by the PostHog SDK"),void Ts.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.vf.enabled&&b(t.$exception_steps)?this.xf(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",_originatedFromCaptureException:!0});return s&&this.pf.clear(),s}catch(t){return Fs(t)||Ts.error("Failed to capture exception event. Dropping this exception.",t),void this.pf.clear()}}catch(t){return void(Fs(t)||Ts.error("Failed to process exception event. Ignoring this exception.",t))}var n}xf(t){try{var e=this.pf.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(i){return Ts.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}_f(t){this.vf.enabled&&this.pf.add({[Mt]:t,[$t]:(new Date).toISOString()})}mf(t){return d(t)?i({},t):{}}ff(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}bf(t){if(0===t.length)return!1;try{var i=t.reduce((t,i)=>{var e=i.type,r=i.value;return p(e)&&e.length>0&&t.$exception_types.push(e),p(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.cf.some(t=>{var e=t.values.map(t=>{var e=Yr[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 Ts.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}wf(t){var i=t.flatMap(t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(t=>{var i=t.filename;return!!i&&Os.some(t=>i.startsWith(t))});return 0!==e.length&&(!e.every(t=>{var i=t.filename;return!!i&&i.startsWith(As)})||t.some(t=>{var i=t.value;return"NoResponse"===t.type||p(i)&&Rs.some(t=>{var e=t.value;return t.exact?i===e:i.includes(e)})})&&!i.some(t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(As))}))}kf(t){return t.some(t=>{var i=t.value;return p(i)&&Ms.some(t=>i.includes(t))})}Sf(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:[];return null!==(r=null==(s=n[n.length-1])||null==(s=s.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}yf(t){return!b(t)&&h(t)}}},nn=i({productTours:class{get Il(){return this._instance.persistence}constructor(t){this.Cf=null,this.$f=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.Il&&this.Il.register({[we]:!!i.productTours}),!Br(this._instance))return!this.Cf&&b(null==(e=this.Il)?void 0:e.props.ph_product_tours)||Hr.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Cf)||r.stop(),this.Cf=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Cf&&Br(this._instance)&&this.Ho(()=>this.Tf())}Ho(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",i=>{i?Hr.error("Could not load product tours script",i):t()})}Tf(){var t;!this.Cf&&null!=(t=cr.__PosthogExtensions__)&&t.generateProductTours&&(this.Cf=cr.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!h(this.$f)||i){var e=this.Il;if(e){var r=e.props[Ue];if(h(r)&&!i)return this.$f=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(Br(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||Hr.warn(s):Hr.error(s),void t([],{isLoaded:!1,error:s})}var n=h(i.json.product_tours)?i.json.product_tours:[];this.$f=n,e&&e.register({[Ue]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.$f,{isLoaded:!0})}getActiveProductTours(t){b(this.Cf)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Cf.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.Cf)||i.showTourById(t)}previewTour(t){this.Cf?this.Cf.previewTour(t):this.Ho(()=>{var i;this.Tf(),null==(i=this.Cf)||i.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Cf)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Cf)||t.nextStep()}previousStep(){var t;null==(t=this.Cf)||t.previousStep()}clearCache(){var t;this.$f=null,null==(t=this.Il)||t.unregister(Ue)}resetTour(t){var i;null==(i=this.Cf)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.Cf)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.Cf)||i.cancelPendingTour(t)}}},tn),an={siteApps:class{constructor(t){this._instance=t,this.If=0,this.Mf=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Ef(t,i){if(i){var e=this.globalsForEvent(i);this.Mf.push(e),this.Mf.length>1e3&&(this.Mf=this.Mf.slice(10))}}get siteAppLoaders(){var t;return null==(t=cr._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Ef.bind(this));this.Pf=()=>{t(),this.Mf=[],this.Pf=void 0}}}globalsForEvent(e){var r,s,n,a,o,l,u;if(!e)throw new Error("Event payload is required");var h={},v=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var c of Object.entries(d)){var f=c[0];h[f]={id:v[f],type:f,properties:c[1]}}var p=e.$set_once,g=e.$set;return{event:i({},function(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}(e,t),{properties:i({},e.properties,g?{$set:i({},null!==(r=null==(s=e.properties)?void 0:s.$set)&&void 0!==r?r:{},g)}:{},p?{$set_once:i({},null!==(n=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==n?n:{},p)}:{}),elements_chain:null!==(o=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}Rf(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)||(zr.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)||(zr.error("prepare_external_dependency_script returned null"),null):t}Af(){var t,i,e,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==_i?void 0:_i.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.If++,this.Ff)return this.Of();var h=[],v=this,d=new WeakSet,c=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),h.push(()=>{t[i]=r})}},f=t=>{if(d.has(t))return t;var i=v.Rf(t);return i&&d.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!_(t));return c(u,"appendChild",t=>function(i){var e=f(i);return e?t.call(this,e):i}),c(u,"insertBefore",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i}),c(u,"replaceChild",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e}),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{c(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,p(e))}),c(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,p(e))})}),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach(t=>{c(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,p(e))}),c(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,p(e))}),c(t,"replaceWith",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)})}),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null}),this.Ff=()=>{h.forEach(t=>t()),this.Ff=void 0},this.Of()}Of(){var t=!1;return()=>{var i;t||(t=!0,this.If--,0===this.If&&(null==(i=this.Ff)||i.call(this)))}}Df(t,i){void 0===i&&(i=!0);var e=this.Af();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.Mf.length&&(zr.info("Processing "+this.Mf.length+" events for site app with id "+t.id),this.Mf.forEach(t=>this.Df(()=>null==i.processEvent?void 0:i.processEvent(t))),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(e=this.Pf)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,zr.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Df(i=>t.init({posthog:this._instance,callback(t){i(),s(t)}}),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){zr.error(Ur+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){zr.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}Lf(){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)}Nf(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Df(()=>null==r.processEvent?void 0:r.processEvent(e))}catch(i){zr.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.Lf(),void this._instance.on("eventCaptured",t=>this.Nf(t))):void zr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Pf)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,i=o.id,e=o.url;cr["__$$ph_site_app_"+i]=s._instance,null==(t=cr.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,t=>{if(t)return zr.error(Ur+i,t)})};for(var o of n.siteApps)a()}else zr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},on={tracingHeaders:class{constructor(t){this._instance=t,this.qf=void 0,this.jf=void 0,this.Bf=void 0,this.ef=()=>{var t,i,e=this.Hf();e?(f(this.qf)&&(this.qf=null==(t=cr.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.jf)&&(this.jf=null==(i=cr.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.lf()}}initialize(){this.startIfEnabledOrStop()}Ho(t){var i,e;null!=(i=cr.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=cr.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return wr.error("failed to load script",i);t()})}zf(){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}Hf(){var t=this.zf();return h(t)?(h(this.Bf)?this.Bf.splice(0,this.Bf.length,...t):this.Bf=[...t],t.length>0?this.Bf:void 0):(h(this.Bf)&&this.Bf.splice(0),this.Bf=t||void 0,this.Bf)}lf(){var t,i;null==(t=this.qf)||t.call(this),null==(i=this.jf)||i.call(this),this.qf=void 0,this.jf=void 0}startIfEnabledOrStop(){this.Hf()?this.Ho(this.ef):this.lf()}}},ln=i({surveys:class extends ns{constructor(t){var i;super(new fs(t),(i=t,{get projectToken(){return i.config.token},kv:new cs(i)})),this._instance=t}Vh(t,e){var r=e.query?function(t,e,r){var s;void 0===r&&(r=!0);var n=t.split("?"),a=n[0],o=n[1],l=i({},e),u=null!==(s=null==o?void 0:o.split("&").map(t=>{var i,e=t.split("="),s=e[0],n=r&&null!==(i=l[s])&&void 0!==i?i:e[1];return delete l[s],s+"="+n}))&&void 0!==s?s:[],h=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return xi(t,function(t,i){f(t)||f(i)||"undefined"===i||(e=encodeURIComponent(t instanceof File?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)}),s.join(i)}(l);return h&&u.push(h),u.length>0?a+"?"+u.join("&"):a}(t,e.query):t;return new Promise(t=>{var i;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor(null!==(i=e.target)&&void 0!==i?i:"api",r),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:t})})}}},tn),un={toolbar:class{constructor(t){this.instance=t}Uf(t){cr.ph_toolbar_state=t}Wf(){var t;return null!==(t=cr.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,i,e){if(void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),Fi(this.instance.config))return!1;if(!fi||!_i)return!1;t=null!=t?t:fi.location,e=null!=e?e:fi.history;try{if(!i){try{fi.localStorage.setItem("test","test"),fi.localStorage.removeItem("test")}catch(t){return!1}i=null==fi?void 0:fi.localStorage}var r,s=ps||er(t.hash,"__posthog")||er(t.hash,"state"),n=s?X(()=>JSON.parse(atob(decodeURIComponent(s))))||X(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(i.getItem(gs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Vf(t){var i=cr.ph_load_toolbar||cr.ph_load_editor;!b(i)&&v(i)?i(t,this.instance):_s.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==_i||!_i.getElementById("__POSTHOG_TOOLBAR__"));if(!fi||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(fi.localStorage.setItem(gs,JSON.stringify(i({},s,{source:void 0}))),2===this.Wf())this.Vf(s);else if(0===this.Wf()){var n;this.Uf(1),null==(n=cr.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return _s.error("[Toolbar] Failed to load",t),void this.Uf(0);this.Uf(2),this.Vf(s)}),Pi(fi,"turbolinks:load",()=>{this.Uf(0),this.loadToolbar(s)})}return!0}Gf(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)}}},hn=i({experiments:class t{get Ir(){return this._instance.config}constructor(i){var e=this;this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){void 0===i&&(i=!1),e.getWebExperiments(i=>{t.Zf("retrieved web experiments from the server"),e.Qf=new Map,i.forEach(i=>{if(i.feature_flag_key){var r;e.Qf&&(t.Zf("setting flag key ",i.feature_flag_key," to web experiment ",i),null==(r=e.Qf)||r.set(i.feature_flag_key,i));var s=e._instance.getFeatureFlag(i.feature_flag_key);p(s)&&i.variants[s]&&e.Jf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(var n in i.variants){var a=i.variants[n];t.Kf(a,e._instance)&&e.Jf(i.name,n,a.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.Zf($s);else if(!this.Ir.disable_web_experiments){if(b(this.Qf))return this.Qf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.Zf("applying feature flags",i),i.forEach(t=>{var i;if(this.Qf&&null!=(i=this.Qf)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.Qf)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.Jf(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var i=t.getWindowLocation();if(null!=i&&i.search){var e=tr(null==i?void 0:i.search,"__experiment_id"),r=tr(null==i?void 0:i.search,"__experiment_variant");e&&r&&(t.Zf("previewing web experiments "+e+" && "+r),this.getWebExperiments(t=>{this.Xf(parseInt(e),r,t)},!1,!0))}}loadIfEnabled(){this.Ir.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Ir.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.Ir.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}Xf(i,e,r){var s=r.filter(t=>t.id===i);s&&s.length>0&&(t.Zf("Previewing web experiment ["+s[0].name+"] with variant ["+e+"]"),this.Jf(s[0].name,e,s[0].variants[e].transforms))}static Kf(i,e){return!b(i.conditions)&&t.Yf(i,e)&&t.tp(i)}static Yf(i,e){var r;if(b(i.conditions)||b(null==(r=i.conditions)?void 0:r.url))return!0;var s=t.getWindowLocation();if(s){var n,a,o,l=Ti(e,s.href);return null==(n=i.conditions)||!n.url||Is[null!==(a=null==(o=i.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](i.conditions.url,l)}return!1}static getWindowLocation(){return null==fi?void 0:fi.location}static tp(t){var i;if(b(t.conditions)||b(null==(i=t.conditions)?void 0:i.utm))return!0;var e=function(t,i,e){if(!_i)return{};var r,s,n,a=i?[...Sr,...e||[]]:[],o=(r=ir(_i.URL,a,xr),s=kr.concat(t||[]),n={},xi(s,function(t){var i=tr(r,t);n[t]=i||null}),n);return Ei(function(){var t={};return xi(Er,function(i){var e=(t=>{if(_i){try{for(var i=t+"=",e=_i.cookie.split(";").filter(t=>t.length),r=0;e.length>r;r++){for(var s=e[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}})(i);t[i]=e||null}),t}(),o)}();if(e.utm_source){var r,s,n,a,o,l,u,h,v=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,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==e.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==e.utm_term;return v&&c&&f&&d}return!1}static Zf(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];wi.info("[WebExperiments] "+t,e)}Jf(i,e,r){this._is_bot()?t.Zf($s):"control"!==e?r.forEach(r=>{var s;r.selector&&(t.Zf("applying transform of variant "+e+" for experiment "+i+" ",r),null==(s=document)||null==(s=s.querySelectorAll(r.selector))||s.forEach(t=>{var i=t;r.html&&(i.innerHTML=r.html),r.css&&i.setAttribute("style",r.css)}))}):t.Zf("Control variants leave the page unmodified.")}_is_bot(){return gi&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&P(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>P(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver}(gi,this.Ir.custom_blocked_useragents):void 0}}},tn),vn={conversations:class{constructor(t){this._instance=t,this.ep=void 0,this._conversationsManager=null,this.np=!1,this.ne=null,this.sp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.rp=t.ok,t.ok)){var i=t.config.conversations;b(i)||(m(i)?this.ep=i:(this.ep=i.enabled,this.ne=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.ep=void 0,this.ne=null,this.rp=void 0,this.sp=!1}loadIfEnabled(){if(!(this._conversationsManager||this.np||this._instance.config.disable_conversations||Fi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==cr?void 0:cr.__PosthogExtensions__;if(t&&!f(this.ep)&&this.ep)if(this.ne&&this.ne.token){this.np=!0;try{var i=t.initConversations;if(i)return this.op(i),void(this.np=!1);var e=t.loadExternalDependency;if(!e)return void this.ap(Xe);e(this._instance,"conversations",i=>{i||!t.initConversations?this.ap("Could not load conversations script",i):this.op(t.initConversations),this.np=!1})}catch(t){this.ap("Error initializing conversations",t),this.np=!1}}else js.error("Conversations enabled but missing token in remote config.")}}op(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.sp=!1,js.info("Conversations loaded successfully")}catch(t){this.ap("Error completing conversations initialization",t)}else js.error("Cannot complete initialization: remote config is null")}ap(t,i){js.error(t,i),this._conversationsManager=null,this.np=!1,this.sp=!0}show(){this._conversationsManager?this._conversationsManager.show():js.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.ep&&!_(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Fi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.rp?"remote_config_failed":f(this.ep)?this.rp?"disabled_in_project":"remote_config_pending":this.ep?b(this.ne)||!this.ne.token?"missing_token":null!=cr&&cr.__PosthogExtensions__?this.np?"initializing":this.sp?"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 s=this;return r(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(js.warn(Ds),null)})()}getMessages(t,i){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(js.warn(Ds),null)})()}markAsRead(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(js.warn(Ds),null)})()}getTickets(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(js.warn(Ds),null)})()}requestRestoreLink(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(js.warn(Ds),null)})()}restoreFromToken(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(js.warn(Ds),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(js.warn(Ds),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}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},dn={logs:class{constructor(t){var e,r=this;this._instance=t,this.name="logs",this.lp=!1,this.up=!1,this.hp=!1,this.A=Si("[logs]"),this.cp=i({},this.A,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(qs)||r.A.error(...i)}}),this.ol=[],this.dp=[],this._d=0,this.To=!1,this.vp=[],this.fp=[],this.pp=!1,this.gp=!1,this.mp=()=>{var t,i;this.To||(this._d=0,null==(t=this.yp)||t.onReconnect(),null==(i=this.bp)||i.onReconnect())},this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.lp=!0),fi&&Pi(fi,"online",this.mp)}_p(t,i,e,r){var s,n=Ns(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new oi(this.wp(t,i),n,this.cp,()=>this.kp(),t=>t(),void 0,r),n]}Sp(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.yp||this.xp!==i){var e;null==(e=this.yp)||e.reset(),this.xp=i;var r=this._p(()=>this.ol,t=>{this.ol=t});this.yp=r[0],this.Cp=r[1]}return this.yp}$p(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.bp||this.Tp!==i){var e;null==(e=this.bp)||e.reset(),this.Tp=i;var r=this._p(()=>this.dp,t=>{this.dp=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Bs);this.bp=r[0],this.Ip=r[1]}return this.bp}setup(t){var i;if(!this.To){this.bo=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.lp=!0),(this.lp||this.Mp()&&this.Ep())&&this.Pp();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.To?r.dispose():(this.Eo=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.To||(this.To=!0,this.Rp(),null==(t=this.Eo)||t.dispose(),this.Eo=void 0,this.bo=void 0,this.hp=!1,null==fi||fi.removeEventListener("online",this.mp),null==(i=this.Ap)||i.call(this),this.Ap=void 0,null==(e=this.yp)||e.reset(),null==(r=this.bp)||r.reset())}onRemoteConfig(t){var i,e;if(!this.To){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;b(r)?this.Fp():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[Se]:!!r}),r?(this.lp=!0,this.up||this.Pp(),this.loadIfEnabled()):this.Fp())}}reset(){var t,i,e,r;this.Rp(),null==(t=this.yp)||t.clearQueue(),this.ol=[],null==(i=this.yp)||i.reset(),null==(e=this.bp)||e.clearQueue(),this.dp=[],null==(r=this.bp)||r.reset(),this._d=0}captureLog(t){this.To||this.Sp().captureLog(t)}captureConsoleLog(t){this.To||this.$p().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.To||this.$p().captureLog(t,{context:i,occurredAtMs:e})}Ep(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[Se])}Mp(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=cr._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.Rp(),null==(t=this.bp)||t.clearQueue(),this.dp=[]}Fp(){this.lp||this.Rp()}Pp(){var t,i=this;if(!this.pp&&null!=cr&&cr.console){var e=Ns(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=!0;this.fp.push(()=>{r=!1});var s=function(t){var s;try{s=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(cr.console[t])}catch(t){return 0}if(!s)return 0;i.fp.push(mr(cr.console,t,n=>{var a=function(){for(var s=arguments.length,a=new Array(s),o=0;s>o;o++)a[o]=arguments[o];try{r&&i.Op(t,a,e)}catch(t){}return n.apply(cr.console,a)};return a.__rrweb_original__=s,a}))};for(var n of Hs)s(n);this.pp=!0,this.Dp=setTimeout(()=>{this.Rp()},3e4)}}Op(t,i,e){var r;if(this.pp&&!this.gp&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.vp.length){this.gp=!0;try{this.vp.push({level:t,args:i,occurredAtMs:Date.now(),context:this.kp()})}finally{this.gp=!1}}}else this.Rp()}Rp(){if(this.vp=[],this.pp){for(var t of(this.pp=!1,this.Dp&&(clearTimeout(this.Dp),this.Dp=void 0),this.fp))t();this.fp=[]}}Lp(){var t=this.vp;return this.Rp(),t}get logger(){return this.Np||(this.Np={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.Np}flushLogs(t){t?this.qp(t):(this.yp&&this.yp.flush().catch(t=>this.jp(t)),this.bp&&this.bp.flush().catch(t=>this.jp(t)))}jp(t){qs(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.To&&this.lp&&!this.up&&!this.hp){var t=null==cr?void 0:cr.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Rp();var i=t.loadExternalDependency;if(!i)return this.A.error(Xe),void this.Rp();this.hp=!0;try{i(this._instance,"logs",i=>{if(this.hp=!1,!this.To&&this.lp){var e=t.logs;if(i||null==e||!e.initializeLogs)this.A.error("Could not load logs script",i),this.Rp();else{var r,s,n=this.Lp();this.Ap=e.initializeLogs(null!==(r=this.bo)&&void 0!==r?r:this._instance),this.up=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.bo)&&void 0!==s?s:this._instance,n))}}})}catch(t){throw this.hp=!1,t}}}wp(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===s.LogsQueue?t():void 0,setPersistedProperty(t,e){t===s.LogsQueue&&i(null!=e?e:[])},js:t=>this.js(t),getLibraryId:()=>as.LIB_NAME,getLibraryVersion:()=>as.LIB_VERSION}}js(t){return new Promise(i=>{if(rr(this._d,3))i({kind:"fatal",error:Us(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Us(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Bp(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.Hp(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.A.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Us(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)})}}})}})}Hp(t){(0!==t||this._instance.__loaded)&&(this._d=sr(t,this._d,3,()=>this.A.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.")))}qp(t){this.ol.length>0&&this.zp(t,this.ol,this.Cp,as.LIB_NAME,t=>{this.ol=t}),this.dp.length>0&&this.zp(t,this.dp,this.Ip,Bs,t=>{this.dp=t})}zp(t,i,e,r,s){if(0!==i.length){var n=i.map(t=>t.record);s([]);var a=ri(n,ei(e,as.LIB_NAME,as.LIB_VERSION),r,as.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Bp(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}Bp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}kp(){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,b(s)||(i.sessionStartTimestamp=s),b(n)||(i.lastActivityTimestamp=n)}if(null!=cr&&null!=(t=cr.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?G(cr.location.href):cr.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},cn={metrics:class{constructor(t){this._instance=t,this.A=Si("[metrics]"),this.To=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.To){var i=!(null==(t=this._instance.config.metrics)||!t.network);i&&!this.Up?this.Up=(t=>{var i=!0,e=()=>i?(t=>{var i,e=null==(i=t.config.metrics)?void 0:i.network;return!0===e?{}:e||void 0})(t):void 0,r=Qs(t,e),s=Ys(t,e);return()=>{i=!1,r(),s()}})(this._instance):!i&&this.Up&&(this.Up(),this.Up=void 0)}}Sp(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.yp&&this.xp===e||(null==(i=this.yp)||i.reset(),this.xp=e,this.yp=new vi(this.wp(),function(t){var i,e,r,s,n,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==a?void 0:a["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==a?void 0:a["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,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.A)),this.yp}count(t,i,e){void 0===i&&(i=1),this.Sp().count(t,i,e)}gauge(t,i,e){this.Sp().gauge(t,i,e)}histogram(t,i,e){this.Sp().histogram(t,i,e)}flush(t){if(!this.yp)return Promise.resolve();if(t){var i=this.yp.drainWindow();return i&&this.Ys(i,t),Promise.resolve()}return this.yp.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.yp)||t.reset()}dispose(){var t,i;this.To=!0,null==(t=this.Up)||t.call(this),this.Up=void 0,null==(i=this.yp)||i.reset()}wp(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:t=>i.Ys(t),getLibraryId:()=>as.LIB_NAME,getLibraryVersion:()=>as.LIB_VERSION}}Ys(t,e){return new Promise(r=>{var s=!1,n=t=>{s||(s=!0,clearTimeout(a),r(t))},a=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(i({method:"POST",url:this.Wp(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var i,e=t.statusCode;n(e>=200&&300>e?{kind:"ok"}:413===e?{kind:"too-large"}:0!==e&&408!==e&&429!==e&&500>e?{kind:"fatal",error:new Error("metrics request failed with status "+e)}:{kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}))})}Wp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},fn=i({},tn,en,rn,sn,nn,an,ln,on,un,hn,vn,dn,cn),pn=tn,gn=en,_n=rn,bn=sn,yn=nn,mn=an,wn=ln,Sn=on,kn=un,xn=hn,En=vn,Cn=dn,Pn=cn;export{fn as AllExtensions,_n as AnalyticsExtensions,En as ConversationsExtensions,bn as ErrorTrackingExtensions,xn as ExperimentsExtensions,pn as FeatureFlagsExtensions,Cn as LogsExtensions,Pn as MetricsExtensions,yn as ProductToursExtensions,gn as SessionReplayExtensions,mn as SiteAppsExtensions,wn as SurveysExtensions,kn as ToolbarExtensions,Sn as TracingExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map