posthog-js 1.426.0 → 1.426.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/conversations.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/default-extensions.js.map +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/extension-bundles.js.map +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +2 -0
- package/dist/module.full.d.ts +2 -0
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +2 -0
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.mjs +2 -0
- package/dist/module.mjs.map +1 -0
- package/dist/module.no-external.d.ts +2 -0
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.js.map +1 -1
- package/dist/module.slim.no-external.d.ts +2 -0
- package/dist/module.slim.no-external.js +1 -1
- package/dist/module.slim.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/src/entrypoints/web-vitals-with-attribution-soft-navs.d.ts +1 -0
- package/dist/src/entrypoints/web-vitals-with-attribution.d.ts +1 -0
- package/dist/src/extensions/segment-integration.d.ts +1 -1
- package/dist/src/posthog-persistence.d.ts +2 -0
- package/dist/web-vitals-with-attribution-soft-navs.js +1 -1
- package/dist/web-vitals-with-attribution-soft-navs.js.map +1 -1
- package/dist/web-vitals-with-attribution.js +1 -1
- package/dist/web-vitals-with-attribution.js.map +1 -1
- package/lib/package.json +2 -2
- package/lib/src/entrypoints/web-vitals-with-attribution-soft-navs.d.ts +1 -0
- package/lib/src/entrypoints/web-vitals-with-attribution-soft-navs.js +4 -2
- package/lib/src/entrypoints/web-vitals-with-attribution-soft-navs.js.map +1 -1
- package/lib/src/entrypoints/web-vitals-with-attribution.d.ts +1 -0
- package/lib/src/entrypoints/web-vitals-with-attribution.js +4 -2
- package/lib/src/entrypoints/web-vitals-with-attribution.js.map +1 -1
- package/lib/src/extensions/segment-integration.d.ts +1 -1
- package/lib/src/extensions/segment-integration.js +22 -10
- package/lib/src/extensions/segment-integration.js.map +1 -1
- package/lib/src/posthog-core.js +9 -0
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-featureflags.js +10 -5
- package/lib/src/posthog-featureflags.js.map +1 -1
- package/lib/src/posthog-persistence.d.ts +2 -0
- package/lib/src/posthog-persistence.js +76 -24
- package/lib/src/posthog-persistence.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(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 i(i){return function(){var e=this,r=arguments;return new Promise((function(s,n){var a=i.apply(e,r);function o(i){t(a,s,n,o,l,"next",i)}function l(i){t(a,s,n,o,l,"throw",i)}o(void 0)}))}}function e(){return e=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},e.apply(null,arguments)}var r=["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"],s=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return r.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function n(t,i){return-1!==t.indexOf(i)}var a=function(t){return t.trim()},o=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),l=Object.prototype,u=l.hasOwnProperty,h=l.toString,v=Array.isArray||function(t){return"[object Array]"===h.call(t)},d=t=>"function"==typeof t,c=t=>t===Object(t)&&!v(t),f=t=>{if(c(t)){for(var i in t)if(u.call(t,i))return!1;return!0}return!1},p=t=>void 0===t,g=t=>"[object String]"==h.call(t),_=t=>g(t)&&0===t.trim().length,b=t=>null===t,m=t=>p(t)||b(t),y=t=>"[object Number]"==h.call(t)&&t==t,w=t=>"[object Boolean]"===h.call(t),S=t=>t instanceof FormData;function x(t){return null===t||"object"!=typeof t}function k(t,i){return{}.toString.call(t)==="[object "+i+"]"}function E(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 P(t,Error)}}function F(t){return"u">typeof Event&&P(t,Event)}function P(t,i){try{return t instanceof i}catch(t){return!1}}function C(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),C(e,i,e,r))}class T{constructor(t){this.C={},this.I=t.I,this.R=C(t.bucketSize,0,100,t.A),this.O=C(t.refillRate,0,this.R,t.A),this.N=C(t.refillInterval,0,864e5,t.A)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.N);e>0&&(t.tokens=Math.min(t.tokens+e*this.O,this.R),t.lastAccess=t.lastAccess+e*this.N)}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={}}}var A,R,O,M="Mobile",I="Android",j="BlackBerry",L="Nintendo",D="PlayStation",N="Xbox",z="Windows",B=z+" Phone",H=new RegExp(j+"|PlayBook|BB10","i"),U={"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"},V=[[new RegExp(N+"; "+N+" (.*?)[);]","i"),t=>[N,t&&t[1]||""]],[new RegExp(L,"i"),[L,""]],[new RegExp(D,"i"),[D,""]],[H,[j,""]],[new RegExp(z,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[B,""];if(new RegExp(M).test(i)&&!/IEMobile\b/.test(i))return[z+" "+M,""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=U[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[z,r]}return[z,""]}],[/((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=p(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("("+I+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+I+")","i"),t=>t&&t[2]?[I,[t[2],t[3],t[4]||"0"].join(".")]:[I,""]],[/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",""]]],q=20,W=1e3,K=1e4,J="[Circular]",G="[Truncated]",X="[Unserializable]",Z="[Function]";function Q(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 Y(t){return t?t.split("#")[0]:t}function tt(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function it(t,i,e){return et.apply(this,arguments)}function et(){return(et=i((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=tt((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}function rt(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return O&&e.length===R?O:(R=e.length,O=e.reduce(((e,r)=>{A||(A={});var s=A[r];if(s)e[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,u=i[r];if(l&&u){e[l]=u,A[r]=[l,u];break}}return e}),{}))}}class st{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 e=this;return i((function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&v(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t}))()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),e({},t,{cause:r,stack:s})}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 e=this;return i((function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i}))()}convertToExceptionList(t,i){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=i.type)&&void 0!==r?r:"generic",handled:null===(s=i.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,e({},i,{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:rt(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,r){void 0===r&&(r=0);var s=(e,r)=>{if(4>=r){var s=this.buildCoercingContext(t,i,r);return this.applyCoercers(e,s)}};return e({},i,{syntheticException:0==r?i.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var nt="?";function at(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?nt:e,in_app:!(null!=i&&i.startsWith("webkit-masked-url://"))&&"<anonymous>"!==i};return p(r)||(n.lineno=r),p(s)||(n.colno=s),n}var ot=(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]:nt,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},lt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ut=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ht=/\((\S*)(?::(\d+))(?::(\d+))\)/,vt=(t,i)=>{var e=lt.exec(t);if(e)return at(i,e[1],nt,+e[2],+e[3]);var r=ut.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ht.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=ot(r[1]||nt,r[2]);return at(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},dt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ct=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ft=(t,i)=>{var e=dt.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=ct.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]||nt,a=ot(n,s);return at(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},pt=/\(error: (.*)\)/;class gt{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=g(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 k(t,"DOMException")}isDOMError(t){return k(t,"DOMError")}}class _t{match(t){return E(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}}class bt{match(t){return!!k(t,"ErrorEvent")&&(null!=t.error||this.Vi(t))}coerce(t,i){var r;if(null!=t.error)return i.apply(t.error);var s=i.apply(t.message);return e({},s,{stack:null!==(r=this.Zi(t))&&void 0!==r?r:s.stack,synthetic:!0})}Vi(t){return g(t.message)&&t.message.length>0}Zi(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(g(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var mt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class yt{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(mt);return r&&(i=r[1],e=r[2]),[i,e]}}var wt=["fatal","error","warning","log","info","debug"];function St(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}class xt{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(F(t))return t.constructor.name;var i="name"in t?t.name:void 0;return g(i)&&!_(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: "+St(t)}isSeverityLevel(t){return g(t)&&!_(t)&&wt.indexOf(t)>=0}getStack(t){try{return g(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:g(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(E(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}}class kt{match(t){return F(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+St(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class Et{match(t){return x(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class Ft{match(t){return k(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!F(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 x(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var Pt="$message",Ct="$timestamp",Tt=new Set([Pt,Ct]),At={enabled:!0,max_bytes:32768};function Rt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:At.enabled,max_bytes:Mt(t.max_bytes,At.max_bytes)}:e({},At)}class Ot{constructor(t){this.Pn=[],this.Fn=0,this.mn=Rt(t)}setConfig(t){this.mn=Rt(t),this.$n()}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(!c(s))return;var n=s,a=n[Pt],o=n[Ct];if(!g(a)||0===a.trim().length)return;if(!g(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.mn.max_bytes||(this.Pn.push({step:i.step,bytes:e}),this.Fn+=e,this.$n())}}getAttachable(){return this.Pn.map((t=>t.step))}clear(){this.Pn=[],this.Fn=0}size(){return this.Pn.length}$n(){for(;this.Fn>this.mn.max_bytes&&this.Pn.length>0;){var t=this.Pn.shift();t&&(this.Fn-=t.bytes)}}}function Mt(t,i){if(!y(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var It=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function $t(t){return"string"==typeof t||t}function jt(t){return"string"==typeof t?t:void 0}var Lt=0x8000000000000000,Dt="9223372036854775808",Nt={}.propertyIsEnumerable;function zt(t,i){try{return Ut(t,i,{ancestors:new WeakSet,remainingNodes:K},0)}catch(t){return[]}}function Bt(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:G};if(e.remainingNodes--,w(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt(Dt);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>=Lt||-Lt>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:Q(t)};if("function"==typeof t)return{stringValue:Z};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:J};if(r>=q)return{stringValue:G};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?Q(a):String(a)}}e.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Bt(o.call(t),i,e,r+1)}catch(t){}return v(t)?{arrayValue:{values:Ht(t,i,e,r+1)}}:{kvlistValue:{values:Ut(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:Q(String(t))}}function Ht(t,i,e,r){for(var s=[],n=Math.min(t.length,W),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(m(o))continue;s.push(Bt(o,i,e,r))}catch(t){s.push({stringValue:X})}return t.length>a&&s.push({stringValue:G}),s}function Ut(t,i,e,r){var s=[];for(var n in t)if(Nt.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=W||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(b(a)||p(a))continue;s.push({key:Q(n),value:Bt(a,i,e,r)})}catch(t){s.push({key:Q(n),value:{stringValue:X}})}}return s}function Vt(t,i,r){return e({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":r})}var qt={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var Wt={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}},Kt=Wt.info;function Jt(t){try{return Q(String(t))}catch(t){return X}}function Gt(t,i,r,s){var n,a=Wt[t.level||"info"]||Kt,o=a.text,l=a.number,u=(void 0===(n=y(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),m(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),m(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var v=e({},h),d=t.attributes;if(d){var c=[];try{c=Object.keys(d)}catch(t){c=[]}for(var f of c){var g=void 0;try{g=d[f]}catch(t){g=X}Object.defineProperty(v,f,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Jt(t.body)},attributes:zt(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),p(t.trace_flags)||(_.flags=t.trace_flags),_}function Xt(t,i,e){return Vt(t,i,e)}function Zt(t,i,e,r){return{resourceLogs:[{resource:{attributes:zt(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let Qt=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.mn=i,this.A=e,this.Nn=r,this.qn=s,this.jn=n,this.Bn=a,this.Hn=null,this.zn=0,this.Un=0,this.Wn=0,this.Vn=0,this.Gn=0,this.Zn=!1,this.Qn=i.maxBufferSize,this.Jn=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.Kn=i.flushIntervalMs,this.Yn=i.maxBatchRecordsPerPost,this.Xn=i.rateCapWindowMs,this.ts=i.maxLogsPerInterval}clearQueue(){this.Un++,this._instance.setPersistedProperty(o.LogsQueue,[])}reset(){this.es(),this.Vn=0,this.Gn=0,this.Zn=!1,this.Wn=0,this.Yn=this.mn.maxBatchRecordsPerPost}onReconnect(){this.Wn=0,this.rs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.ns(t);if(null!==r)if(r.body){if(this.ss()){var s={record:Gt(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.Nn(),this.A,null==i?void 0:i.occurredAtMs)};this.qn((()=>this.os(s)))}}else this.A.info("Log was rejected in beforeSend function")}}ns(t){var i=this.mn.beforeSend;if(!i)return t;var e=v(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}ss(){if(void 0===this.ts)return!0;var t=Date.now(),i=t-this.Vn;return this.Xn>i&&i>=0||(this.Vn=t,this.Gn=0,this.Zn=!1),this.ts>this.Gn?(this.Gn++,!0):(this.Zn||(this.A.warn("captureLog dropping logs: exceeded "+this.ts+" logs per "+this.Xn+"ms"),this.Zn=!0),!1)}flush(){var t=this;return i((function*(){if(!t._instance.isDisabled)return t.Hn||(t.Hn=t.ls().finally((()=>{t.Hn=null}))),t.Hn}))()}ls(){var t=this;return i((function*(){var i;t.es();var e=null!==(i=t._instance.getPersistedProperty(o.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,a,l=t.Un;t.zn=0;var u=Math.min(e.length,t.Yn),h=e.slice(0,u),v=Zt(h.map((t=>t.record)),t.us(),null!==(n=t.Bn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.hs(v);if(t.Un!==l)return;if("too-large"===d.kind&&h.length>1)t.Yn=Math.max(1,Math.floor(h.length/2)),t.A.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.Yn);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.A.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.mn.maxBatchRecordsPerPost>t.Yn&&(t.Yn=Math.min(t.mn.maxBatchRecordsPerPost,t.Yn+1)),yield t.ds(h.length),e=null!==(a=t._instance.getPersistedProperty(o.LogsQueue))&&void 0!==a?a:[],s+=h.length,"fatal"===d.kind)throw d.error}}}))()}ds(t){var e=this;return i((function*(){var i,r=Math.max(0,t-e.zn),s=null!==(i=e._instance.getPersistedProperty(o.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(o.LogsQueue,s.slice(r)),yield e.jn()}))()}us(){return Xt(this.mn,this._instance.getLibraryId(),this._instance.getLibraryVersion())}os(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(o.LogsQueue))&&void 0!==i?i:[];this.Jn>e.length||(e.shift(),this.zn++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(o.LogsQueue,e),this.Qn>e.length?this.vs():this.rs()}}vs(t){void 0===t&&(t=this.Kn),this.cs||(this.cs=tt((()=>{this.cs=void 0,this.rs()}),t))}fs(){var t=Math.min(Math.max(0,this.Wn-1),6);return this.Kn*Math.pow(2,t)}ps(){var t=this._instance.getPersistedProperty(o.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return i((function*(){e.es();var i=e.flush().catch((()=>{}));void 0!==t?yield it(i,t):yield i}))()}flushWithTimeout(t){var e=this;return i((function*(){var i=e.flush();yield it(i,t,(()=>{i.catch((()=>{}))}))}))()}rs(){this.flush().then((()=>{this.Wn=0}),(t=>{this.Wn++,this.A.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.ps()&&this.vs(this.fs())}))}es(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};var Yt=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ti(t){return String(t)+"000000"}function ii(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}let ei=class{constructor(t,i,e){this._instance=t,this.mn=i,this.A=e,this.gs=new Map,this.Hn=null,this.ys=!1,this.bs=new Map,this._s=new Set,this.ws=0}count(t,i,e){void 0===i&&(i=1),this.ks({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.ks({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.ks({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,e=this.Hn,r=function(){var r=i((function*(){e&&(yield e.catch((()=>{}))),yield t.Ss()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this.Hn===s&&(this.Hn=null)}));return this.Hn=s,s}drainWindow(){if(0===this.gs.size)return null;var t=this.gs;return this.gs=new Map,this.ys=!1,this.bs=new Map,this._s=new Set,this.xs(t)}reset(){this.ws++,this.es(),this.gs=new Map,this.Hn=null,this.ys=!1,this.bs=new Map,this._s=new Set}ks(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.ns(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.A.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=i.attributes?e({},i.attributes):void 0,s=ii(i.type,i.name,i.unit,r)}catch(t){return void this.A.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.gs.get(s);if(!n){if(!this.Cs())return;n={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.gs.set(s,n)}var a=this.bs.get(i.name);void 0===a?this.bs.set(i.name,i.type):a===i.type||this._s.has(i.name)||(this._s.add(i.name),this.A.warn("Metric name '"+i.name+"' is already used as a "+a+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Ts(n,i.value),this.vs()}else this.A.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Cs(){return this.mn.maxSeriesPerFlush>this.gs.size||(this.ys||(this.ys=!0,this.A.warn("Metric series cap reached ("+this.mn.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ts(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(Yt.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,Yt)]+=1}}ns(t){var i=this.mn.beforeSend;if(!i)return t;var e=v(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}vs(){this.cs||(this.cs=tt((()=>{this.cs=void 0,this.flush().catch((t=>{this.A.error("Metrics flush failed:",t)}))}),this.mn.flushIntervalMs))}es(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}Ss(){var t=this;return i((function*(){if(0!==t.gs.size){var i=t.gs;t.gs=new Map,t.ys=!1,t.bs=new Map,t._s=new Set;var e=t.ws,r=yield t._instance.Ms(t.xs(i));if(e===t.ws)switch(r.kind){case"ok":return;case"retry-later":return t.Is(i),void t.vs();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)}}}))()}xs(t){return i=this.Es(t),e=function(t,i,e){return Vt(t,i,e)}(this.mn,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:zt(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Es(t){var i=ti(Date.now()),r=new Map;for(var s of t.values()){var n,a=ii(s.type,s.name,s.unit,void 0),o=r.get(a);o||(o=e({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=zt(null!==(n=s.attributes)&&void 0!==n?n:{},this.A),u=ti(s.windowStartMs);if("count"===s.type){var h,v={attributes:l,startTimeUnixNano:u,timeUnixNano:i,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:i,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:i,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:Yt})}return Array.from(r.values())}Is(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.gs.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.Cs()&&this.gs.set(s,n)}}};var ri={DEBUG:!1,LIB_VERSION:"0.7.1",LIB_NAME:"browser-common"},si="u">typeof window?window:void 0,ni="u">typeof globalThis?globalThis:si,ai=null==ni?void 0:ni.navigator,oi=null==ni?void 0:ni.document,li=null==ni?void 0:ni.location;function ui(){return!(!si||!1===si.navigator.onLine)}null!=ni&&ni.XMLHttpRequest&&new ni.XMLHttpRequest;var hi=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={q(i){if(si&&(ri.DEBUG||si.POSTHOG_DEBUG||e)&&!p(si.console)&&si.console){for(var r=("__rrweb_original__"in si.console[i]?si.console[i].__rrweb_original__:si.console[i]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;s>a;a++)n[a-1]=arguments[a];r(t,...n)}},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("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)=>hi(t+" "+i,e)};return r},vi=hi("[PostHog.js]"),di=vi.createLogger;function ci(t,i){if(!m(t))if(v(t))t.forEach(i);else if(S(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)u.call(t,e)&&i(t[e],e)}var fi=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 pi(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var gi=function(t){try{return t()}catch(t){return}};function _i(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 bi(t){return"ph_toolbar_internal"===t.name}function mi(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!d(r))return i;try{var s=r(i);return g(s)&&s?s:i}catch(t){return vi.error("Error in get_current_url, falling back to window.location.href",t),i}}var yi="__POSTHOG_TOOLBAR__",wi=1,Si=3,xi=11;function ki(t){return t instanceof Element&&(t.id===yi||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Ei(t){return!!t&&t.nodeType===wi}function Fi(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Pi(t){return!!t&&t.nodeType===Si}function Ci(t){return!!t&&t.nodeType===xi&&Ei(t.host)}var Ti=1e3;function Ai(t){return t?a(t).split(/\s+/):[]}function Ri(t,i){var e=function(t){var i,e=null==si||null==(i=si.location)?void 0:i.href;return p(e)?void 0:mi(t,e)}(i);return!!(e&&t&&t.some((t=>e.match(t))))}function Oi(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 Ai(i)}function Mi(t){return m(t)?null:a(t).split(/(\s+)/).filter((t=>ee(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ii(t){var i="";return Ki(t)&&!Ji(t)&&t.childNodes&&t.childNodes.length&&ci(t.childNodes,(function(t){var e;Pi(t)&&t.textContent&&(i+=null!==(e=Mi(t.textContent))&&void 0!==e?e:"")})),a(i)}function $i(t){var i;return p(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var ji=["a","button","form","input","select","textarea","label"];function Li(t,i){if(p(i))return!0;var e,r=function(t){if(i.some((i=>function(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}(t,i))))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function Di(t){var i=t.parentNode;return!(!i||!Ei(i))&&i}var Ni=[".ph-no-autocapture","[data-ph-no-autocapture]"],zi=["next","previous","prev",">","<"],Bi=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Hi=[".ph-no-rageclick",".ph-no-capture"],Ui=["","text","search","email","password","url","tel","number"];function Vi(t,i){if(!si||qi(t))return!1;var e,r,s,a,o;if(w(i)?(e=!!i&&Hi,r=void 0,s=!1):(e=null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Hi,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||!Ei(t))&&(!!Fi(t,"textarea")||(Fi(t,"input")?n(Ui,(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=Wi(t,!1).targetElementList;return!function(t,i){if(!1===t||p(t))return!1;var e;if(!0===t)e=zi;else{if(!v(t))return!1;if(t.length>10)return vi.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=>Bi(i,t)||Bi(r,t)))}))}(r,l.map((t=>{var i;return{safeText:Ii(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!Li(l,e)}var qi=t=>!t||Fi(t,"html")||!Ei(t),Wi=(t,i)=>{if(!si||qi(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!Fi(s,"body");)if(Ci(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Di(s);if(!n)break;if(i||ji.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=si.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Ki(t){for(var i=new Set,e=0,r=t;r.parentNode&&!Fi(r,"body");r=r.parentNode){if(e++>=Ti||i.has(r))return!1;i.add(r);var s=Oi(r);if(n(s,"ph-sensitive")||n(s,"ph-no-capture"))return!1}if(n(Oi(t),"ph-include"))return!0;var a=t.type||"";if(g(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!g(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 Ji(t){return!!(Fi(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Fi(t,"select")||Fi(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Gi=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}))$"),Xi=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Zi=[16,15,14,13],Qi=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Yi=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),te=/[0-9A-Za-z_]/;function ie(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 ee(t,i){if(void 0===i&&(i=!0),m(t))return!1;if(g(t)){t=a(t);var e=i?Gi.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(Xi.lastIndex=0;i=Xi.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of Zi){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(Gi.test(o)&&ie(o))return!0}}}return!1}(t);if(e)return!1;var r=i?Qi.test(t):function(t){var i;for(Yi.lastIndex=0;i=Yi.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&te.test(e)&&te.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function re(t){var i=Ii(t);return ee(i=(i+" "+se(t)).trim())?i:""}function se(t){var i="";return t&&t.childNodes&&t.childNodes.length&&ci(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=Ii(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+se(t)).trim())}catch(t){vi.error("[AutoCapture]",t)}})),i}function ne(t){return t.replace(/"|\\"/g,'\\"')}function ae(t){var i=t.attr__class;if(i)return v(i)?i:Ai(i)}class oe{constructor(t){this.disabled=!1===t;var i=c(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}}var le="$autocapture_disabled_server_side",ue="$heatmaps_enabled_server_side",he="$exception_capture_enabled_server_side",ve="$error_tracking_suppression_rules",de="$error_tracking_capture_extension_exceptions",ce="$web_vitals_enabled_server_side",fe="$product_tours_enabled_server_side",pe="$logs_capture_enabled_server_side",ge="$web_vitals_allowed_metrics",_e="$session_recording_remote_config",be="$enabled_feature_flags",me="$active_feature_flags",ye="$early_access_features",we="$feature_flag_details",Se="$feature_flag_payloads",xe="$feature_flag_request_id",ke="$minimal_flag_called_events",Ee="$override_feature_flags",Fe="$override_feature_flag_payloads",Pe="$stored_person_properties",Ce="$stored_group_properties",Te="$surveys",Ae="$surveys_loaded_at",Re="$surveys_activated",Oe="$surveys_activated_session",Me="$surveys_activated_timestamps",Ie="ph_product_tours",$e="$flag_call_reported",je="$flag_call_reported_session_id",Le="$feature_flag_errors",De="$feature_flag_evaluated_at",Ne="$sdk_debug_recording_script_not_loaded",ze="PostHog loadExternalDependency extension not found.",Be="visibilitychange",He="beforeunload",Ue=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(!v(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){vi.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ve=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=[],h=0;l.length>h;h++){var d=l[h].split("=");v(d)&&(i.includes(d[0])?u.push(d[0]+"="+e):u.push(l[h]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},qe=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},We=(t,i)=>t>=i&&ui(),Ke=(t,i,e,r)=>{if(0===t){if(ui()){var s=i+1;return s===e&&r(),s}return i}return 0},Je="$copy_autocapture",Ge=di("[AutoCapture]");function Xe(t,i){return i.length>t?i.slice(0,t)+"...":i}function Ze(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Ei(i));return i}function Qe(t,i){var r,s,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,h=i.elementsChainAsString,d=i.disableCaptureUrlHashes;if(!Ei(t))return{props:{}};for(var c=[t],f=new Set([t]),_=t;_.parentNode&&!Fi(_,"body")&&Ti>c.length;)if(Ci(_.parentNode)){var b=_.parentNode.host;if(f.has(b))break;f.add(b),c.push(b),_=b}else{if(!Ei(_.parentNode))break;if(f.has(_.parentNode))break;f.add(_.parentNode),c.push(_.parentNode),_=_.parentNode}var m,y,w=[],S={},x=!1,k=!1;if(ci(c,(t=>{var i=Ki(t);if(Fi(t,"a")){var e=t.getAttribute("href");x=!!(i&&e&&ee(e))&&(d?Y(e):e)}n(Oi(t),"ph-no-capture")&&(k=!0),w.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};ji.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Xe(1024,re(t)):Xe(1024,Ii(t)));var o=Oi(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),ci(t.attributes,(function(e){var n;if((!Ji(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&ee(e.value)&&(!g(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=Ai(o).join(" ")),a["attr__"+e.name]=Xe(1024,"href"===e.name&&s?Y(o):o)}}));for(var l=1,u=1,h=t;h=Ze(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,d));var r=function(t){if(!Ki(t))return{};var i={};return ci(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&&ee(r)&&(i[e]=r)}})),i}(t);ci(r,((t,i)=>{({}).hasOwnProperty.call(S,i)||(S[i]=t)}))})),k)return{props:{},explicitNoCapture:k};if(l||(w[0].$el_text=Fi(t,"a")||Fi(t,"button")?re(t):Ii(t)),x){var E,F;w[0].attr__href=x;var P=null==(E=(t=>{var i=null==oi?void 0:oi.createElement("a");return p(i)?null:(i.href=t,i)})(x))?void 0:E.host,C=null==si||null==(F=si.location)?void 0:F.host;P&&C&&P!==C&&(m=x)}return{props:fi({$event_type:a.type,$ce_version:1},h?{}:{$elements:w},{$elements_chain:(y=w,v(y)?function(t){return t.map((t=>{var i,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=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i: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 pi(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[ne(t[0].toString())]=ne(i.toString())})),(s+=":")+pi(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:ae(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return pi(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(y)):"")},null!=(r=w[0])&&r.$el_text?{$el_text:null==(s=w[0])?void 0:s.$el_text}:{},m&&"click"===a.type?{$external_click_url:m}:{},S)}}class Ye{constructor(t){this.name="autocapture",this.Rs=!1,this.Ps=null,this.As=!1,this.Fs=!1,this.mn={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Os=!1,this.Ls=t,this.Ls.refresh(this.mn),this.rageclicks=new oe(this.mn.rageclick),this.Ds=null}setup(t){this.$s(),this.Ns=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Os?i.dispose():(this.qs=i,this.startIfEnabled())}dispose(){var t;this.Os||(this.Os=!0,this.Ns=void 0,null==(t=this.qs)||t.dispose(),this.qs=void 0,this.js())}Bs(){return this.Ls.refresh(this.mn),this.mn}$s(){var t,i;return this.Bs(),this.mn.url_allowlist=null==(t=this.mn.url_allowlist)?void 0:t.map((t=>new RegExp(t))),this.mn.url_ignorelist=null==(i=this.mn.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),this.mn}Hs(){if(this.isBrowserSupported()){if(si&&oi){var t=this.zs=t=>{t=t||(null==si?void 0:si.event);try{this.Us(t)}catch(t){Ge.error("Failed to capture event",t)}};if(_i(oi,"submit",t,{capture:!0}),_i(oi,"change",t,{capture:!0}),_i(oi,"click",t,{capture:!0}),this.Bs().capture_copied_text){var i=this.Ws=t=>{t=t||(null==si?void 0:si.event);try{this.Us(t,Je)}catch(t){Ge.error("Failed to capture clipboard event",t)}};_i(oi,"copy",i,{capture:!0}),_i(oi,"cut",i,{capture:!0}),_i(oi,"paste",i,{capture:!0})}}}else Ge.info("Disabling Automatic Event Collection because this browser is not supported")}js(){this.zs&&(null==oi||oi.removeEventListener("submit",this.zs,!0),null==oi||oi.removeEventListener("change",this.zs,!0),null==oi||oi.removeEventListener("click",this.zs,!0),this.zs=void 0),this.Ws&&(null==oi||oi.removeEventListener("copy",this.Ws,!0),null==oi||oi.removeEventListener("cut",this.Ws,!0),null==oi||oi.removeEventListener("paste",this.Ws,!0),this.Ws=void 0),this.Rs=!1}startIfEnabled(){!this.Os&&this.Ns&&this.isEnabled&&!this.Rs&&(this.Hs(),this.Rs=!0)}onRemoteConfig(t){if(!this.Os)if(this.As=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.Fs=i.elementsChainAsString);var e,r=i.autocapture_opt_out;w(r)&&(null==(e=this.Ns)||e.kv.set(le,r),this.Ps=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.Ds=t}getElementSelectors(t){var i,e=[];return null==(i=this.Ds)||i.forEach((i=>{var r=null==oi?void 0:oi.querySelectorAll(i);null==r||r.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i;if(this.Os)return!1;var e=null==(t=this.Ns)?void 0:t.kv.get(le),r=this.Ps,s=this.Bs(),n=s.remoteRequestsDisabled&&!this.As;if(b(r)&&!w(e)&&!n)return!1;var a=null!==(i=this.Ps)&&void 0!==i?i:!!e;return!!s.enabled&&!a}Us(t,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r=$i(t);Pi(r)&&(r=r.parentNode||null);var s,n=this.$s();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&n.rageclick&&null!=(s=this.rageclicks)&&s.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Vi(r,n.rageclick)&&this.Us(t,"$rageclick");var a=i===Je,o=a?e({},n,{dom_event_allowlist:void 0}):n;if(r&&function(t,i,e,r,s,n){var a;if(!si||qi(t))return!1;if(null!=e&&e.url_allowlist&&!Ri(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&Ri(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=Wi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(p(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(!Li(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Li(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:Ni))return!1;try{var v=si.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&&(ji.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,o,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l,u=Qe(r,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.Fs,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),h=u.props;if(u.explicitNoCapture)return!1;var v=this.getElementSelectors(r);if(v&&v.length>0&&(h.$element_selectors=v),i===Je){var d=t.type||"clipboard";if("paste"!==d){var c,f,g=null==si||null==(c=si.getSelection())?void 0:c.toString(),_=Mi(g);if(!_)return!1;h.$selected_content=_,h.$clipboard_text_length=null!==(f=null==g?void 0:g.length)&&void 0!==f?f:0}h.$copy_type=d}return null==(l=this.Ns)||l.capture(i,h).catch((t=>Ge.error("Failed to capture event",t))),!0}}}isBrowserSupported(){return d(null==oi?void 0:oi.querySelectorAll)}}class tr{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=c(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}}var ir="undefined"!=typeof globalThis?globalThis:si;ir&&"undefined"==typeof self&&(ir.self=ir),ir&&"undefined"==typeof File&&(ir.File=function(){});var er=null!=si?si:{},rr=di("[Dead Clicks]"),sr=()=>!0;class nr{get lazyLoadedDeadClicksAutocapture(){return this.Ks}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({$dead_clicks_enabled_server_side:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ys((()=>{this.Xs()})):this.stop()}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?rr.error("failed to load script",i):t()}))}Xs(){var t;if(oi){if(!this.Ks&&null!=(t=er.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=c(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Ks=er.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ks.start(oi),rr.info("starting...")}}else rr.error("`document` not found. Cannot start.")}stop(){this.Ks&&(this.Ks.stop(),this.Ks=void 0,rr.info("stopping..."))}}var ar=di("[ExceptionAutocapture]"),or=()=>{},lr=t=>{var i;if(d(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function ur(t,i,e){try{if(!(i in t))return or;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 d(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=lr(e);n;){if(n.next===s)return void(n.next=r.next);n=lr(e=n.next)}else t[i]=r.next}}catch(t){return or}}var hr=di("[TracingHeaders]"),vr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],dr=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...vr],cr="<masked>",fr=["li_fat_id"];function pr(t,i,e){if(!oi)return{};var r,s,n,a=(r=Ve(oi.URL,[],cr),s=dr.concat([]),n={},ci(s,(function(t){var i=Ue(r,t);n[t]=i||null})),n),o=function(){var t={};return ci(fr,(function(i){var e=(t=>{if(oi){try{for(var i=t+"=",e=oi.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}();return fi(o,a)}function gr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var _r=di("[Web Vitals]"),br=9e5,mr=["CLS","FCP","INP","LCP"],yr=["INP","LCP"],wr=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Sr=di("[RemoteConfig]");class xr{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=er._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}uo(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}ho(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 Sr.info("Using preloaded remote config",this.remoteConfig),void this.do(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Sr.warn("Remote config is disabled. Falling back to local config.");this.uo((t=>{if(!t)return Sr.info("No config found after loading remote JS config. Falling back to JSON."),void this.ho((t=>{this.do(t.json,t)}));this.do(t)}))}catch(t){Sr.error("Error loading remote config",t),this.do()}}do(t,i){!t&&i&&(0===i.statusCode?i.error||Sr.warn("Failed to fetch remote config from PostHog."):Sr.error("Failed to fetch remote config from PostHog."));try{this._instance.do(t?{ok:!0,config:t}:{ok:!1})}catch(t){Sr.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){Sr.error("Error loading feature flags",t)}}}var kr="disabled",Er="lazy_loading",Fr="awaiting_config",Pr="missing_config";function Cr(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}ri.DEBUG=!1,ri.LIB_VERSION="1.426.0",ri.LIB_NAME="web";var Tr=(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}},Ar=t=>t.toLowerCase(),Rr={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=>Tr(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!Tr(i,t))))),icontains:(t,i)=>i.map(Ar).some((i=>t.map(Ar).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(Ar).every((i=>t.map(Ar).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 Or(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=Rr[e.operator];return!!s&&s(e.values,[String(r)])}))}di("[SessionRecording]"),di("[SessionRecording]");var Mr="[SessionRecording]",Ir=di(Mr),$r=di("[Heatmaps]");function jr(t){return c(t)&&"clientX"in t&&"clientY"in t&&y(t.clientX)&&y(t.clientY)}var Lr=di("[Product Tours]"),Dr=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(fe))},Nr=["$set_once","$set"],zr=di("[SiteApps]"),Br="Error while initializing PostHog app with config id ",Hr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Ur="events",Vr="cancelEvents",qr="survey shown",Wr=di("[Surveys]"),Kr="seenSurvey_",Jr=["popover","widget","api"],Gr="SDK is not enabled or survey functionality is not yet loaded",Xr="Disabled. Not loading surveys.";class Zr{constructor(t,i){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Mu=!1,this.Iu=[],this.Eu=null,this.Ru=null,this.Os=!1,this.Pu=new Set,this.onRemoteConfig=t=>{if(!this.Os&&!this.mn.disableSurveys){if(!t.ok)return Wr.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(m(i))return Wr.warn("Flags not loaded yet. Not loading surveys.");this.Au=w(i)?i:i.length>0,Wr.info("flags response received, isSurveysEnabled: "+this.Au),this.loadIfEnabled()}},this.Ls=t,this.Fu=i}setup(t){if(!this.Os)return this.Ou=t,Hr(t.kv.initialize(),(()=>{if(this.Ou===t&&!this.Os){this.Ou=void 0,this.Ns=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.Os?i.dispose():(this.qs=i,this.loadIfEnabled())}}))}dispose(){var t,i,e;this.Os||(this.Os=!0,this.Ou=void 0,this.Ns=void 0,null==(t=this.qs)||t.dispose(),this.qs=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Iu=[],this.Eu=null,this.Pu.forEach((t=>clearTimeout(t))),this.Pu.clear())}get mn(){return this.Ls.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith(Kr)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this.Os&&this.Ns){var t=this.mn;if(!this._surveyManager)if(this.Mu)Wr.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Wr.info(Xr);else if(t.cookielessMode&&this.Ls.isOptedOut())Wr.info("Not loading surveys in cookieless mode without consent.");else{var i=this.Ls.getExtensions();if(i){if(!p(this.Au)||t.advancedEnableSurveys){var e=this.Au||t.advancedEnableSurveys;this.Mu=!0;try{var r=i.generateSurveys;if(r)return this.Lu(r,e),void(this.Mu=!1);var s=i.loadExternalDependency;if(!s)return this.Du(ze),void(this.Mu=!1);s((t=>{try{if(this.Os)return;var i=this.Ls.getExtensions();t||null==i||!i.generateSurveys?this.Du("Could not load surveys script",t):this.Lu(i.generateSurveys,e)}finally{this.Mu=!1}}))}catch(t){throw this.Mu=!1,this.Du("Error initializing surveys",t),t}}}else Wr.error("PostHog Extensions not found.")}}}Lu(t,i){this.Os||(this._surveyManager=t(i),this._surveyEventReceiver=this.Ls.createEventReceiver(),Wr.info("Surveys loaded successfully"),this.$u({isLoaded:!0}))}Du(t,i){Wr.error(t,i),this.$u({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Iu.push(t),this._surveyManager&&this.$u({isLoaded:!0}),()=>{this.Iu=this.Iu.filter((i=>i!==t))}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.Ns)&&void 0!==e?e:this.Fu;if(r&&!this.Os){if(this.mn.disableSurveys)return Wr.info(Xr),t([]);var s=r.kv.get(Te);if(s&&!i)return t(s,{isLoaded:!0}),void(this.Nu()&&this.getSurveys((()=>{}),!0));if(this.Eu)this.Eu.then((i=>{this.Os||t(i.surveys,i.context)})).catch((t=>Wr.error("Error in survey callback",t)));else{var n=this.qu("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.mn.requestTimeoutMs}).then((t=>{try{return this.ju(r,t)}catch(t){return Wr.error("Error processing surveys response",t),this.ju(r,{statusCode:0,error:t})}}),(t=>this.ju(r,{statusCode:0,error:t})));this.Eu=n;var a=()=>{this.Eu===n&&(this.Eu=null)};n.then((i=>{a(),this.Os||t(i.surveys,i.context)}),a).catch((t=>Wr.error("Error in survey callback",t)))}}}qu(t,i){var e=this.Ns;return e?e.sendRequest(t,i):new Promise((t=>t({statusCode:0,error:new Error(Gr)})))}ju(t,i){if(this.Os)return{surveys:[],context:{isLoaded:!1,error:Gr}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?Wr.error(r):i.error||Wr.warn(r),this.Ru=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Ru=null;var s,n=i.json.surveys||[],a=n.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Cr(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t))));return a.length>0&&(null==(s=this._surveyEventReceiver)||s.register(a)),t.kv.set({[Te]:n,[Ae]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}Nu(){return this.Bu()&&!this.Eu&&!this.Hu()}Bu(){var t,i,e=null==(t=null!==(i=this.Ns)&&void 0!==i?i:this.Fu)?void 0:t.kv.get(Ae);return y(e)&&Date.now()-e>3e5}Hu(){return y(this.Ru)&&3e5>Date.now()-this.Ru}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>""+Kr+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){Wr.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){}}$u(t){for(var i of this.Iu)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Wr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!m(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Wr.warn("init was not called")}zu(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}Uu(t){if(m(this._surveyManager))return{eligible:!1,reason:Gr};var i="string"==typeof t?this.zu(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Wu(t){if(m(this._surveyManager))return{eligible:!1,reason:Gr};var i="string"==typeof t?this.zu(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(m(this._surveyManager))return Wr.warn("init was not called"),{visible:!1,disabledReason:Gr};var i=this.Wu(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return m(this._surveyManager)?(Wr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Gr})):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.Wu(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var r;if(m(this._surveyManager))Wr.warn("init was not called");else{var s="string"==typeof t?this.zu(t):t;if(null!=s&&s.id)if(Jr.includes(s.type)){var n=null==oi?void 0:oi.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){Wr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout((()=>{var t,i;this.Pu.delete(a),this.Os||(Wr.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),Wr.info("Survey "+s.id+" rendered"))}),1e3*s.appearance.surveyPopupDelaySeconds);this.Pu.add(a)}else this._surveyManager.renderSurvey(s,n,e);else Wr.warn("Survey element not found")}else Wr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Wr.warn("Survey not found")}}displaySurvey(t,i){var r;if(m(this._surveyManager))Wr.warn("init was not called");else{var s=this.zu(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&i.ignoreDelay&&(n=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&Wr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var a=this.Uu(s);if(!a.eligible)return void Wr.warn("Survey is not eligible to be displayed: ",a.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}else Wr.warn("Survey not found")}}cancelPendingSurvey(t){m(this._surveyManager)?Wr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}class Qr{on(t,i){return this.Bo[t]||(this.Bo[t]=[]),this.Bo[t].push(i),()=>{this.Bo[t]=this.Bo[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.Bo[t]||[])e(i);for(var r of this.Bo["*"]||[])r(t,i)}constructor(){this.Bo={}}}function Yr(t,i,e){if(m(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}class ts{constructor(t){this.Vu=new Set,this.Gu=new Set,this.Zu=new Qr,this.Qu=(t,i)=>this.Ju(t,i)&&this.Ku(t,i)&&this.Yu(t,i)&&this.Xu(t,i),this.Ju=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t}init(){var t,i;p(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.th=null==(i=this._instance)?void 0:i._addCaptureHook(((t,i)=>{this.on(t,i)})))}dispose(){var t;null==(t=this.th)||t.call(this),this.th=void 0,this.Zu=new Qr}register(t){var i,e;if(!p(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i;this.Vu.add(t),null==(i=t.steps)||i.forEach((t=>{this.Gu.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Vu.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&r.add(t.selector)}))})),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Vu.clear(),this.Gu.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Gu.has(t)||this.Gu.has(i.event))&&this.Vu.forEach((t=>{this.eh(i,t)&&this.Zu.emit("actionCaptured",t.name)}))}ih(t){this.onAction("actionCaptured",(i=>t(i)))}eh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Qu(t,e))return!0;return!1}onAction(t,i){return this.Zu.on(t,i)}Ku(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(!Yr(r,i.url,i.url_matching||"contains"))return!1}return!0}Yu(t,i){return!!this.rh(t,i)&&!!this.nh(t,i)&&!!this.sh(t,i)}rh(t,i){var e;if(null==i||!i.href)return!0;var r=this.ah(t);if(r.length>0)return r.some((t=>Yr(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&Yr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}nh(t,i){var e;if(null==i||!i.text)return!0;var r=this.ah(t);if(r.length>0)return r.some((t=>Yr(t.text,i.text,i.text_matching||"exact")||Yr(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;!m(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=>Yr(t,n,a))))}sh(t,i){var e,r;if(null==i||!i.selector)return!0;var s=null==t||null==(e=t.properties)?void 0:e.$element_selectors;if(null!=s&&s.includes(i.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&n)try{return new RegExp(i.selector_regex).test(n)}catch(t){return!1}return!1}ah(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}Xu(t,i){return null==i||!i.properties||0===i.properties.length||Or(i.properties.reduce(((t,i)=>{var e=v(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class is{constructor(t){var i;this.oh=[],this._instance=t,this.lh=new Map,this.uh=new Map,this.hh=new Map,this.dh=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId((t=>this.fh(t)))}ph(t){return!1}gh(){return null}mh(t){}yh(){}bh(t,i){return!!t&&Or(t.propertyFilters,null==i?void 0:i.properties)}_h(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}wh(t,i,e){var r=(e===Ur?this.lh:this.uh).get(t),s=[];return this.kh((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.bh(n,i)}))}register(t){this.Sh(t,!1)}replace(t){this.Sh(t,!0)}Sh(t,i){var e;p(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.xh(t,i),this.Ch(t,i))}Ch(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.hh.clear(),0!==e.length){this.Th||(this.Th=new ts(this._instance),this.Th.init(),this.Th.ih((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.hh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.hh.set(i.name,s)}}))})),i?this.Th.replace(r):this.Th.register(r)}else{var s;i&&(null==(s=this.Th)||s.replace([]))}}Mh(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)}))}xh(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._h(t,Ur),o=this._h(t,Vr);i?(this.lh=a,this.uh=o):(this.Mh(this.lh,a),this.Mh(this.uh,o)),(0!==s.length||0!==n.length)&&(null!==(e=this.th)&&void 0!==e||(this.th=null==(r=this._instance)?void 0:r._addCaptureHook(((t,i)=>{this.onEvent(t,i)}))))}onEvent(t,i){var e,r,s=this.Ih(),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.Eh(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Rh([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Ph(n),void this.Ah([n])}if(this.uh.has(t)){var o=this.wh(t,i,Vr);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Rh(o.map((t=>t.id))),o.forEach((t=>this.Fh(t.id))))}if(this.lh.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.lh.get(t)});var l=this.wh(t,i,Ur);this.Oh(l.map((t=>t.id)))}}onAction(t){this.hh.has(t)&&this.Oh(this.hh.get(t)||[])}Oh(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.ph(s)?this.Ph(s)&&this.Lh(s):r.push(s);r.length>0&&(this.oh=[...new Set([...this.oh,...r])]),this.Ih().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Ph(t){this.oh=this.oh.filter((i=>i!==t));var i=this.Dh();return!i.includes(t)&&(this.$h([...i,t]),this.Nh(),!0)}Rh(t){var i=new Set(t);this.oh=this.oh.filter((t=>!i.has(t)));var e=this.qh(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.$h(r),0===r.length&&this.jh()),this.Ah(t)}Bh(){var t,i=this.gh();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}Lh(t){if(this.gh()){var i=this.Bh();this.mh(e({},i,{[t]:Date.now()}))}}Ah(t){if(this.gh()){var i=this.Bh(),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&&(f(e)?this.yh():this.mh(e))}}Hh(){this.gh()&&this.yh()}getActivationTimestamp(t){if(this.Dh().includes(t)){var i=this.Bh()[t];return y(i)?i:void 0}}qh(){var t,i=this.zh();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}Dh(){var t,i,e=this.qh();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Uh()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Nh(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Wh(i)}jh(){this.Vh()}fh(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Uh()];if(e&&e!==t){var r=this.qh(),s=this.Bh();r.length>0&&(this.$h([]),r.filter((t=>y(s[t]))).forEach((t=>this.Fh(t)))),this.jh(),this.Hh()}}getActivatedIds(){return[...new Set([...this.Dh(),...this.oh])].filter((t=>!this.Gh(t)))}dispose(){var t,i,e;null==(t=this.dh)||t.call(this),this.dh=void 0,null==(i=this.th)||i.call(this),this.th=void 0,null==(e=this.Th)||e.dispose(),this.Th=void 0}reset(){this.oh=[],this.qh().length>0&&this.$h([]),this.jh(),this.Hh()}getEventToItemsMap(){return this.lh}Zh(){return this.Th}}class es extends is{constructor(t){super(t)}zh(){return Re}Uh(){return Oe}gh(){return Me}mh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Me]:t})}yh(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Me)}ph(t){var i,e;this.kh((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}Qh(){return qr}kh(t){var i;null==(i=this._instance)||i.getSurveys(t)}Fh(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Ih(){return Wr}$h(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Re]:t})}Wh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Oe]:t})}Vh(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Oe)}Gh(){return!1}Eh(t,i){var e;this.kh((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return Cr(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===qr?"consume":"ignore":t===qr?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class rs{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);p(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach((t=>this._instance.unregister(t))):this._instance.unregister(t)}}class ss{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=null==er?void 0:er.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new es(this._instance)}}var ns=null!=si&&si.location?qe(si.location.hash,"__posthog")||qe(location.hash,"state"):null,as="_postHogToolbarParams",os=di("[Toolbar]"),ls=di("[FeatureFlags]");class us{constructor(t,i){void 0===i&&(i=!1),this.Jh=!1,this.update(t,i)}update(t,i){this.Kh=((t,i)=>{var e,r,s,n,a;return{bootstrap:{featureFlags:null==(e=t.bootstrap)?void 0:e.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(s=t.remote_config_refresh_interval_ms)&&void 0!==s?s:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(a=t.evaluation_contexts)&&void 0!==a?a:t.evaluation_environments)&&void 0!==n?n:[],flagKeys:v(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Jh||(ls.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Jh=!0),p(t.flag_keys)||v(t.flag_keys)||ls.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Kh}}var hs=di("[FeatureFlags]"),vs=di("[FeatureFlags]",{debugEnabled:!0}),ds="\" failed. Feature flags didn't load in time.",cs="connection_error",fs=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},ps=t=>{var i={};for(var e of pi(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},gs=di("[Error tracking]"),_s="webkit-masked-url:",bs=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",_s],ms=["__firefox__","__gCrWeb"],ys="Refusing to render web experiment since the viewer is a likely bot",ws={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Tr(i,t),not_regex:(t,i)=>!Tr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class Ss{get mn(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{Ss.Yh("retrieved web experiments from the server"),i.Xh=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.Xh&&(Ss.Yh("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.Xh)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);g(r)&&t.variants[r]&&i.td(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Ss.ed(n,i._instance)&&i.td(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Ss.Yh(ys);else if(!this.mn.disable_web_experiments){if(m(this.Xh))return this.Xh=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ss.Yh("applying feature flags",t),t.forEach((t=>{var i;if(this.Xh&&null!=(i=this.Xh)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.Xh)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.td(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Ss.getWindowLocation();if(null!=t&&t.search){var i=Ue(null==t?void 0:t.search,"__experiment_id"),e=Ue(null==t?void 0:t.search,"__experiment_variant");i&&e&&(Ss.Yh("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.rd(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.mn.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.mn.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.mn.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}rd(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(Ss.Yh("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.td(r[0].name,i,r[0].variants[i].transforms))}static ed(t,i){return!m(t.conditions)&&Ss.nd(t,i)&&Ss.sd(t)}static nd(t,i){var e;if(m(t.conditions)||m(null==(e=t.conditions)?void 0:e.url))return!0;var r=Ss.getWindowLocation();if(r){var s,n,a,o=mi(i,r.href);return null==(s=t.conditions)||!s.url||ws[null!==(n=null==(a=t.conditions)?void 0:a.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,o)}return!1}static getWindowLocation(){return null==si?void 0:si.location}static sd(t){var i;if(m(t.conditions)||m(null==(i=t.conditions)?void 0:i.utm))return!0;var e=pr();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 Yh(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];vi.info("[WebExperiments] "+t,e)}td(t,i,e){this._is_bot()?Ss.Yh(ys):"control"!==i?e.forEach((e=>{if(e.selector){var r;Ss.Yh("applying transform of variant "+i+" for experiment "+t+" ",e);var s=null==(r=document)?void 0:r.querySelectorAll(e.selector);null==s||s.forEach((t=>{var i=t;e.html&&(i.innerHTML=e.html),e.css&&i.setAttribute("style",e.css)}))}})):Ss.Yh("Control variants leave the page unmodified.")}_is_bot(){return ai&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&s(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>s(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver}(ai,this.mn.custom_blocked_useragents):void 0}}var xs=di("[Conversations]"),ks="Conversations not available yet.";function Es(t,i){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,c=null!=i&&i.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,f=p(c)?Math.max(v,2048):Math.max(v,c),g=e({},function(){var t="",i="";try{var r=null==ai?void 0:ai.userAgent;if(r){var s=function(t){for(var i=0;V.length>i;i++){var e=V[i],r=e[1],s=e[0].exec(t),n=s&&(d(r)?r(s,t):r);if(n)return n}return["",""]}(r);t=s[0],i=s[1]}}catch(t){}return function(t,i){var r=function(t){if(t)return{}.hasOwnProperty.call(qt,t)?qt[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(a=null!==(o=null==g?void 0:g["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==a?a:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==g?void 0:g["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(u=null==g?void 0:g["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:g,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:v,maxQueueSize:f,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:c,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Fs=["debug","log","warn","error","info"],Ps="console",Cs="__posthogHandledLogsRequestError",Ts=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Cs]=!0,e},As=t=>!!t&&"object"==typeof t&&!0===t[Cs],Rs={featureFlags:class{constructor(t){this.name="featureFlags",this.ad=!1,this.featureFlagEventHandlers=[],this.A=hs,this.od={},this.ld={},this.ud=[],this.hd=!1,this.dd=!1,this.vd=0,this.fd=!1,this.pd=!1,this.gd=!1,this.md=!1,this.yd=0,this.Wt=()=>{var t=this.bd();this.yd=0,t&&this.reloadFeatureFlags()},this._d=()=>{var t,i=this.wd;p(i)||this.mn.remoteRequestsDisabled||!oi||"hidden"===oi.visibilityState||Date.now()-(null!==(t=this.kd)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Sd())},this.Vt=()=>{"visible"===(null==oi?void 0:oi.visibilityState)&&this._d()},"get"in t?this.Ls=t:(this._instance=t,this.xd=new us(t.config,t._shouldDisableFlags()),this.Ls=this.xd)}updateConfig(t,i){var e;null==(e=this.xd)||e.update(t,i),this.Ns&&this.Cd()}setup(t){return this.Ou=t,this.A=t.logger.createLogger("[FeatureFlags]"),Hr(t.kv.initialize(),(()=>{this.Ou===t&&(this.Ou=void 0,this.Ns=t,this.Td(t))}))}Td(t){var i;if(this.Ns===t)return si&&_i(si,"online",this.Wt),this.Cd(),this.Md=t.registerDynamicEventProperties((()=>this.Id()?this.od:this.ld)),this.Ed=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange((()=>{this.Rd(),this.Pd()})),this.Rd(),this.initialize()}Cd(){var t=this.mn.refreshIntervalMs,i=!this.mn.remoteRequestsDisabled&&oi&&!p(t)&&t>0?t:void 0;i!==this.wd&&(this.Ad(),p(i)||(this.wd=i,this.Sd(),null!=oi&&oi.addEventListener&&_i(oi,Be,this.Vt)))}Sd(){p(this.wd)||(p(this.Fd)||clearInterval(this.Fd),this.kd=Date.now(),this.Fd=setInterval(this._d,this.wd))}Ad(){p(this.Fd)||(clearInterval(this.Fd),this.Fd=void 0,null==oi||null==oi.removeEventListener||oi.removeEventListener(Be,this.Vt)),this.wd=void 0,this.kd=void 0}destroy(){this.Od()}dispose(){this.Od()}Od(){var t,i;this.Ad(),this.vd++,this.pd=!1,this.Ou=void 0,this.Ns&&(this.Ld(),null==(t=this.Md)||t.dispose(),this.Md=void 0,null==(i=this.Ed)||i.call(this),this.Ed=void 0,this.ud=[],null==si||si.removeEventListener("online",this.Wt),this.Ns=void 0)}get mn(){return this.Ls.get()}Dd(t){var i;return null==(i=this.Ns)?void 0:i.kv.get(t)}ni(t){this.$d((()=>{var i;return null==(i=this.Ns)?void 0:i.kv.set(t)}))}Nd(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t[be]){var s=this.Dd(be)||{},n=t[be]||{},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&&!v(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),h=this.Dd(Se)||{},d=t[Se]||{},c=l||e?u:Array.from(new Set([...Object.keys(h),...Object.keys(d)])),f=!l&&!e,g=!!f||u,_={[me]:g,[be]:g,[Se]:!!f||c};for(var b of(t[we]&&(_[we]=g),[xe,De,ke]))p(t[b])||(_[b]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(_)}}oi(t){this.$d((()=>{var i;return null==(i=this.Ns)?void 0:i.kv.remove(t)}))}$d(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Rd(){var t={};for(var i of[me,Se,xe,Ee]){var r=this.Dd(i);p(r)||(t[i]=r)}this.od=t;var s=e({},t),n=this.Dd(be);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.ld=s}Id(){var t=this.mn.cacheTtlMs;if(!t||0>=t)return!1;var i=this.Dd(De);return"number"!=typeof i||Date.now()-i>t}qd(){return!!this.Id()&&(this.md||this.dd||(this.md=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}jd(){var t=this.mn.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})):[]}Bd(){var t=this.mn.flagKeys;if(!p(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.mn,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=>!!r[t])).reduce(((t,i)=>(t[i]=r[i]||!1,t)),{}),l=Object.keys(a).filter((t=>o[t])).reduce(((t,i)=>(t[i]=a[i],t)),{});return this.Hd({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,i,r){var s,n,a=null!=r&&r.merge&&null!==(s=this.Dd(be))&&void 0!==s?s:{},o=null!=r&&r.merge&&null!==(n=this.Dd(Se))&&void 0!==n?n:{},l=e({},a,t),u=e({},o,i),h={};for(var v of Object.entries(l)){var d=v[0],c=v[1];h[d]={key:d,enabled:$t(c),variant:jt(c),reason:void 0,metadata:p(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}}}this.Hd({flags:h})}get hasLoadedFlags(){return this.hd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Dd(we),i=this.Dd(Ee),r=this.Dd(Fe);if(!r&&!i)return t||{};var s=fi({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(i||{})])];for(var a of n){var o,l,u=s[a],h=null==i?void 0:i[a],v=p(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=p(h)?null==u?void 0:u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=e({},u,{enabled:v,variant:v?null!=d?d:null==u?void 0:u.variant:void 0});v!==(null==u?void 0:u.enabled)&&(f.original_enabled=null==u?void 0:u.enabled),d!==(null==u?void 0:u.variant)&&(f.original_variant=null==u?void 0:u.variant),c&&(f.metadata=e({},null==u?void 0:u.metadata,{payload:c,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[a]=f}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:$t(r),variant:jt(r),payload:It(i[e])}}))}getFlagVariants(){var t=this.Dd(be),i=this.Dd(Ee);if(!i)return t||{};for(var e=fi({},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.Dd(Se),i=this.Dd(Fe);if(!i)return t||{};for(var e=fi({},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.fd||this.mn.featureFlagsDisabled||this.bd()||this.zd||(this.ud.slice().forEach((t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}})),this.zd=setTimeout((()=>{this.Ud()}),5))}Ld(){clearTimeout(this.zd),this.zd=void 0}onReloading(t){return this.ud.push(t),()=>{this.ud=this.ud.filter((i=>i!==t))}}ensureFlagsLoaded(){this.hd||this.dd||this.zd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.fd=t}resetFlagCallReported(){this.oi($e)}Ud(t){this.Ld();var i=this.Ns;if(i&&!this.mn.remoteRequestsDisabled&&!this.bd())if(this.dd)this.pd=!0;else{var r={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:e({},i.initialPersonProperties,this.Dd(Pe)||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.Dd(Ce),timezone:gr()};p(i.deviceId)||(r.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.mn.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this.jd();s.length&&(r.evaluation_contexts=s);var n=this.Bd();p(n)||(r.flag_keys=n);var a=this.mn.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),l=this.vd;this.dd=!0;var u=()=>{this.pd&&(this.pd=!1,this.Ud())},h=t=>{this.dd=!1,l===this.vd?(this.ni({[Le]:[cs]}),this.A.error("Feature flag request failed",t),u()):u()};try{i.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.mn.compression,sentAt:"body",timeoutMs:this.mn.requestTimeoutMs}).then((t=>{var i,e,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.dd=!1,l===this.vd){if(this.Wd(t.statusCode),n||this.pd||(this.$anon_distinct_id=void 0),!r.disable_flags||this.pd){this.gd=!n;var o=[];t.error?o.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?cs:"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.ni({[Le]: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.Hd(s,n,{partialResponse:a}),u()}}else u()})).catch(h)}catch(t){h(t)}}}bd(){return We(this.yd,3)}Wd(t){this.yd=Ke(t,this.yd,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.gd)if(this.hd||this.getFlags()&&this.getFlags().length>0){if(!this.qd()){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+ds)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.gd)if(this.hd||this.getFlags()&&this.getFlags().length>0){if(!this.qd()){var r,s=this.getFlagVariants(),n=t in s,a=s[t],o=this.getFlagPayloads()[t],l=String(a),u=this.Dd(xe)||void 0,h=this.Dd(De)||void 0,d=this.Dd($e)||{};if(this.mn.deduplicateCallsPerSession){var c,f=null==(c=this.Ns)?void 0:c.session.sessionId,g=this.Dd(je);f&&f!==g&&(d={},r=f)}if(i.send_event||!("send_event"in i))if(t in d&&d[t].includes(l))r&&this.ni({[$e]:d,[je]:r});else{var _,b,m,y,w,S,x,k,E,F,P,C;v(d[t])?d[t].push(l):d[t]=[l],this.ni(e({[$e]:d},r?{[je]:r}:{}));var T=this.getFeatureFlagDetails(t),A=[...null!==(_=this.Dd(Le))&&void 0!==_?_:[]];p(a)&&A.push("flag_missing");var R={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:null!==(b=null==(m=this.mn.bootstrap)||null==(m=m.featureFlags)?void 0:m[t])&&void 0!==b?b:null,$feature_flag_bootstrapped_payload:null!==(y=null==(w=this.mn.bootstrap)||null==(w=w.featureFlagPayloads)?void 0:w[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.gd};p(null==T||null==(S=T.metadata)?void 0:S.has_experiment)||(R.$feature_flag_has_experiment=T.metadata.has_experiment),p(null==T||null==(x=T.metadata)?void 0:x.version)||(R.$feature_flag_version=T.metadata.version);var O,M=null!==(k=null==T||null==(E=T.reason)?void 0:E.description)&&void 0!==k?k:null==T||null==(F=T.reason)?void 0:F.code;M&&(R.$feature_flag_reason=M),null!=T&&null!=(P=T.metadata)&&P.id&&(R.$feature_flag_id=T.metadata.id),p(null==T?void 0:T.original_variant)&&p(null==T?void 0:T.original_enabled)||(R.$feature_flag_original_response=p(T.original_variant)?T.original_enabled:T.original_variant),null!=T&&null!=(C=T.metadata)&&C.original_payload&&(R.$feature_flag_original_payload=null==T||null==(O=T.metadata)?void 0:O.original_payload),A.length&&(R.$feature_flag_error=A.join(",")),this.Vd(R)}else r&&this.ni({[$e]:d,[je]:r});if(n)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:It(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+ds)}Vd(t){try{var i;null==(i=this.Ns)||i.capture("$feature_flag_called",t).catch((t=>{this.A.error("Failed to capture feature flag call",t)}))}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Gd(t,i)}Gd(t,e){var r=this;return i((function*(){var i=r.Ns;if(i){var s={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=r.jd();n.length&&(s.evaluation_contexts=n);var a,o=r.Bd();p(o)||(s.flag_keys=o);try{var l,u=null==(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:r.mn.compression,sentAt:"body",timeoutMs:r.mn.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;a=(null==u?void 0:u[t])||void 0}catch(t){return void r.A.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){r.A.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.gd)return i.defaultValue;if(!(this.hd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+ds),i.defaultValue;var e=this.getFeatureFlag(t,i);return p(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.Hd(t,i,e)}Hd(t,i,r){if(this.Ns){this.hd=!0;var s=function(t,i,r,s,n,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===s&&(s={}),void 0===a&&(a=hs);var o=((t,i)=>{var r=t.flags;return r?e({},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!p(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&&i.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,h=o.featureFlagPayloads;if(u){var d=t.requestId,c=t.evaluatedAt;if(v(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var f={};if(u)for(var g=0;u.length>g;g++)f[u[g]]=!0;return{[me]:u,[be]:f,[ke]:!1}}var _=u,b=h,m=l;if(null!=n&&n.partialResponse){var y=Object.keys(_),w=b||{};_=e({},i,_),b=e({},r,w),y.forEach((t=>{var i;t in w||null==(i=b)||delete i[t]})),m=e({},s,m)}else if(t.errorsWhileComputingFlags)if(l){var S=new Set(Object.keys(l).filter((t=>{var i;return!(null!=(i=l[t])&&i.failed)})));_=e({},i,Object.fromEntries(Object.entries(_).filter((t=>S.has(t[0])))));var x=Object.fromEntries(Object.entries(b||{}).filter((t=>S.has(t[0]))));b=e({},r,x),S.forEach((t=>{var i;t in x||null==(i=b)||delete i[t]})),m=e({},s,Object.fromEntries(Object.entries(m||{}).filter((t=>S.has(t[0])))))}else _=e({},i,_),b=e({},r,b),m=e({},s,m);return e({[me]:Object.keys(ps(_)),[be]:_||{},[Se]:b||{},[we]:m||{},[ke]:!0===t.minimalFlagCalledEvents},d?{[xe]:d}:{},c?{[De]:c}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.A);s&&(this.Nd(s,t,!(null==r||!r.partialResponse)),this.ni(s)),i||(this.md=!1),this.Pd(i)}}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.Zd(t)}Zd(t){if(this.Ns){if(!1===t)return this.oi([Ee,Fe]),this.Pd(),void vs.info("All overrides cleared");if(v(t))return this.ni({[Ee]:fs(t)}),this.Pd(),void vs.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[Ee]=v(s)?fs(s):s),n&&(r[Fe]=n),Object.keys(r).length&&this.ni(r),!1===s&&!1===n?this.oi([Ee,Fe]):!1===s?this.oi(Ee):!1===n&&this.oi(Fe),this.Pd(),!1===s?vs.info("Flag overrides cleared"):s&&vs.info("Flag overrides set",{flags:s}),void(!1===n?vs.info("Payload overrides cleared"):n&&vs.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.ni({[Ee]:t}),this.Pd(),void vs.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.hd){var i=this.Qd(),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,i,r){var s,n=(this.Dd(ye)||[]).find((i=>i.flagKey===t)),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r);var l=e({},this.getFlagVariants(),{[t]:i});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[me]:[t],[be]:[t],[Pe]:Object.keys(a)}),this.ni({[me]:Object.keys(ps(l)),[be]:l,[Pe]:e({},this.Dd(Pe)||{},a)}),this.Pd();try{var u;null==(u=this.Ns)||u.capture("$feature_enrollment_update",o).catch((t=>{this.A.error("Failed to capture early access feature enrollment",t)}))}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.Dd(ye);!r||i?this.Jd(t,e):t(r)}Jd(t,e){var r=this;return i((function*(){var i=r.Ns;if(i){var s,n=e?"&"+e.map((t=>"stage="+t)).join("&"):"";try{var a=yield i.sendRequest("/api/early_access_features/?token="+i.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;r.ni({[ye]:s=a.json.earlyAccessFeatures})}catch(t){return void r.A.error("Early access feature request failed",t)}try{t(s)}catch(t){r.A.error("Early access feature callback failed",t)}}}))()}Qd(){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)),{})}}Pd(t){this.Rd();var i=this.Qd(),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.Kd(t,i)}Kd(t,i){void 0===i&&(i=!0);var r=this.Dd(Pe)||{},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.ni({[Pe]:e({},r,a,s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.Dd(Pe)||{});t.forEach((t=>{delete r[t]})),this.ni({[Pe]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.oi(Pe),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.Dd(Ce)||{},s=e({},r);for(var n of Object.keys(t))s[n]=e({},r[n],t[n]);this.ni({[Ce]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.Dd(Ce)||{};this.ni({[Ce]:e({},i,{[t]:{}})})}else this.oi(Ce)}reset(){this.vd++,this.pd=!1,this.od={},this.ld={},this.hd=!1,this.fd=!1,this.gd=!1,this.$anon_distinct_id=void 0,this.Ld(),this.ad=!1,this.yd=0}}},Os={sessionRecording:class{get mn(){return this._instance.config}get qo(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Yd)||!t.isStarted)}get status(){var t,i;return this.Xd===Fr||this.Xd===Pr?this.Xd:null!==(t=null==(i=this.Yd)?void 0:i.status)&&void 0!==t?t:this.Xd}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Xd=kr,this.tv=void 0,this.ev=!1,this.jt=(()=>{var t;if(null==oi||!oi.visibilityState||"visible"===oi.visibilityState)return!0;var i=null==si||null==(t=si.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some((t=>"visible"===t.name))})(),this.Vt=()=>{var t;"visible"===(null==oi?void 0:oi.visibilityState)&&(this.jt=!0,null==(t=this.Yd)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=t,!this._instance.sessionManager)throw Ir.error("started without valid sessionManager"),new Error(Mr+" started without valid sessionManager. This is a bug.");if("always"===this.mn.cookieless_mode)throw new Error(Mr+' cannot be used with cookieless_mode="always"');null!=oi&&oi.addEventListener&&_i(oi,"visibilitychange",this.Vt)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.ev=!0,null==oi||null==oi.removeEventListener||oi.removeEventListener("visibilitychange",this.Vt),e?this.iv(!0):this.stopRecording()}get rv(){var t,i=!(null==(t=this._instance.get_property(_e))||!t.enabled),e=!this.mn.disable_session_recording,r=this.mn.disable_session_recording||this._instance.consent.isOptedOut();return si&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.ev||this.rv&&null!=(i=this.Yd)&&i.isStarted)){var e=!p(Object.assign)&&!p(Array.from);this.rv&&e?(this.nv(t),Ir.info("starting")):(this.Xd=kr,this.stopRecording())}}nv(t){var i,e;if(this.rv)if(this.Xd!==Fr&&this.Xd!==Pr&&(this.Xd=Er),null!=er&&null!=(i=er.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=er.__PosthogExtensions__)&&e.initSessionRecording)this.sv(t);else{var r,s=this._instance.sessionManager;null==(r=er.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.av,(i=>{if(!this.ev&&this.rv&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[Ne]:!0}),Ir.error("could not load recorder",i)):void this.sv(t);this.Xd=kr}))}}stopRecording(){var t,i;null==(t=this.tv)||t.call(this),this.tv=void 0,null==(i=this.Yd)||i.stop()}iv(t){var i,e;void 0===t&&(t=!1),null==(i=this.tv)||i.call(this),this.tv=void 0,null==(e=this.Yd)||e.discard({discardProducerEvents:t})}ov(){var t,i;null==(t=this.qo)||t.unregister("$session_is_sampled"),null==(i=this.qo)||i.unregister("$replay_sample_rate")}lv(t,i){if(m(t))return null;var e,r=y(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Ir.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}uv(t){if(this.qo){var i,r,s=this.qo,n=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.lv(null==(i=this.mn.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.lv(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;m(o)&&this.ov();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[_e]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({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:p(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==(i=this.tv)||i.call(this),this.tv=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.uv(i),void this.iv()):(this.uv(i),void this.startIfEnabledOrStop()):(this.Xd===Fr&&(this.Xd=Pr,Ir.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.Yd)&&e.log?this.Yd.log(t,i):Ir.warn("log called before recorder was ready")}get av(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(_e);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}hv(){var t,i=this._instance.get_property(_e);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return Ir.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!m(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}sv(t){var i,e,r;if(!this.ev&&this.rv&&this._instance.sessionManager){if(null==(i=er.__PosthogExtensions__)||!i.initSessionRecording)return Ir.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Ne]:!0});var s;if(this.Yd||(this.Yd=null==(s=er.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.jt),this.Yd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.hv()){if(this.Xd===Pr||this.Xd===Fr)return;return this.Xd=Fr,Ir.info("persisted remote config is stale, requesting fresh config before starting"),void new xr(this._instance).load()}this.Xd=Er,null==(e=(r=this.Yd).setDocumentWasEverVisible)||e.call(r,this.jt),this.Yd.start(t)}else this.Xd=kr}onRRwebEmit(t){var i;null==(i=this.Yd)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Yd||null==(i=this.qo)||i.register({$replay_override_linked_flag:!0}),null==(t=this.Yd)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.Yd||null==(i=this.qo)||i.register({$replay_override_sampling:!0}),null==(t=this.Yd)||t.overrideSampling()}overrideTrigger(t){var i,e;this.Yd||null==(e=this.qo)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Yd)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Yd)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Yd)||!e.tryAddCustomEvent(t,i))}}},Ms={autocapture:class extends Ye{constructor(t){super(new tr(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.dv=this.vv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.fv();return!!(t.path||t.search||this.pv(t))}startIfEnabled(){this.isEnabled&&(vi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.dv=this.vv(),this.startIfEnabled()}stop(){this.gv&&this.gv(),this.gv=void 0,this.mv&&this.mv(),this.mv=void 0,vi.info("History API monitoring stopped")}monitorHistoryChanges(){si&&si.history&&(this.yv("pushState"),this.yv("replaceState"),this.bv(),this.pv()&&this._v())}yv(t){var i;if(si&&(null==(i=si.history[t])||!i.__posthog_wrapped__)){var e=this;ur(si.history,t,(i=>function(r,s,n){i.call(this,r,s,n),e.wv(t)}))}}vv(){var t=null==si?void 0:si.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}fv(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:c(t)?t:{}}pv(t){return void 0===t&&(t=this.fv()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Sv(t){var i=this.fv(),e=this.dv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.pv(i)&&t.hash!==e.hash))}wv(t){try{var i=this.vv();if(!i)return;this.Sv(i)&&this._instance.capture("$pageview",{navigation_type:t}),this.dv=i}catch(i){vi.error("Error capturing "+t+" pageview",i)}}bv(){if(!this.gv){var t=()=>{this.wv("popstate")};_i(si,"popstate",t),this.gv=()=>{si&&si.removeEventListener("popstate",t)}}}_v(){if(!this.mv){var t=()=>{this.wv("hashchange")};_i(si,"hashchange",t),this.mv=()=>{si&&si.removeEventListener("hashchange",t)}}}},heatmaps:class{get mn(){return this.instance.config}constructor(t){var i;this.xv=!1,this.Rs=!1,this.Cv=null,this.instance=t,this.xv=!(null==(i=this.instance.persistence)||!i.props[ue]),this.rageclicks=new oe(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return c(this.mn.capture_heatmaps)&&this.mn.capture_heatmaps.flush_interval_milliseconds&&(t=this.mn.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return m(this.mn.capture_heatmaps)?m(this.mn.enable_heatmaps)?this.xv:this.mn.enable_heatmaps:!1!==this.mn.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Rs)return;$r.info("starting..."),this.Tv(),this.Vt()}else{var t;clearInterval(null!==(t=this.Cv)&&void 0!==t?t:void 0),this.Mv(),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({[ue]:e}),this.xv=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Pt;return this.Pt=void 0,t}Iv(t){jr(t.originalEvent)&&this.Xi(t.originalEvent,"deadclick")}Vt(){this.Cv&&clearInterval(this.Cv),this.Cv="visible"===(null==oi?void 0:oi.visibilityState)?setInterval(this.Eo.bind(this),this.flushIntervalMilliseconds):null}Tv(){si&&oi&&(this.Ev=this.Eo.bind(this),_i(si,He,this.Ev),this.Rv=t=>this.Xi(t||(null==si?void 0:si.event)),_i(oi,"click",this.Rv,{capture:!0}),this.Pv=t=>this.Av(t||(null==si?void 0:si.event)),_i(oi,"mousemove",this.Pv,{capture:!0}),this.Fv=new nr(this.instance,sr,this.Iv.bind(this)),this.Fv.startIfEnabledOrStop(),this.Ov=this.Vt.bind(this),_i(oi,Be,this.Ov),this.Rs=!0)}Mv(){var t;si&&oi&&(this.Ev&&si.removeEventListener(He,this.Ev),this.Rv&&oi.removeEventListener("click",this.Rv,{capture:!0}),this.Pv&&oi.removeEventListener("mousemove",this.Pv,{capture:!0}),this.Ov&&oi.removeEventListener(Be,this.Ov),clearTimeout(this.Lv),null==(t=this.Fv)||t.stop(),this.Rs=!1)}Dv(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&&Ei(r)&&!Fi(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:si)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(n(i,s))return!0;r=Di(r)}return!1}($i(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:e),target_fixed:a,type:i}}Xi(t,i){var r;if(void 0===i&&(i="click"),!ki(t.target)&&jr(t)){var s=this.Dv(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Vi($i(t),this.instance.config.rageclick)&&this.ks(e({},s,{type:"rageclick"})),this.ks(s)}}Av(t){!ki(t.target)&&jr(t)&&(clearTimeout(this.Lv),this.Lv=setTimeout((()=>{this.ks(this.Dv(t,"mousemove"))}),500))}ks(t){if(si){var i=this.mn.disable_capture_url_hashes?Y(si.location.href):si.location.href,e=this.mn.custom_personal_data_properties,r=this.mn.mask_personal_data_properties?[...vr,...e||[]]:[],s=Ve(i,r,cr);this.Pt=this.Pt||{},this.Pt[s]||(this.Pt[s]=[]),this.Pt[s].push(t)}}Eo(){this.Pt&&!f(this.Pt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:nr,webVitalsAutocapture:class{constructor(t){var i;this.xv=!1,this.Rs=!1,this.Pt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.$v=()=>{clearTimeout(this.Nv),this.Nv=void 0,0!==this.Pt.metrics.length&&(this._instance.capture("$web_vitals",e({$current_url:this.Pt.url},this.Pt.metrics.reduce(((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.Pt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.qv=t=>{var i;if(this.Pt=this.Pt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},m(null==t?void 0:t.name)||m(null==t?void 0:t.value))_r.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.jv(r);if(!p(s)){var n=y(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.Bv||this.Bv>t.value){this.Pt.navigationKey!==n&&(this.$v(),this.Nv=setTimeout(this.$v,this.flushToCaptureTimeoutMs)),p(this.Pt.navigationKey)&&(this.Pt.navigationKey=n,this.Pt.url=s),this.Pt.firstMetricTimestamp=p(this.Pt.firstMetricTimestamp)?Date.now():this.Pt.firstMetricTimestamp;var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,c(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of wr){var h="url"===u&&"string"==typeof t.attribution[u]?this.jv(t.attribution[u]):t.attribution[u];p(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;p(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.Pt.metrics.push(o),this.Pt.metrics.length===this.allowedMetrics.length&&this.$v()}else _r.error("Ignoring metric with value >= "+this.Bv,t)}}},this.Hv=()=>{if(!this.Rs){var t,i,r,s,n=!1,a=er.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.zv])||("web-vitals"===this.zv&&p(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!p(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!p(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,i=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&&i&&r&&s){var v={reportSoftNavs:this.useSoftNavs},d=n&&this.attributionMetrics.indexOf("INP")>-1?e({},v,{includeProcessedEventEntries:!1}):v;this.allowedMetrics.indexOf("LCP")>-1&&t(this.qv.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&i(this.qv.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.qv.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.qv.bind(this),d),this.Rs=!0}else _r.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.xv=!(null==(i=this._instance.persistence)||!i.props[ce]),this.startIfEnabled()}get Uv(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=c(this.Uv)?null==(t=this.Uv)?void 0:t.web_vitals_allowed_metrics:void 0;return m(e)?(null==(i=this._instance.persistence)?void 0:i.props[ge])||mr:e}get flushToCaptureTimeoutMs(){return(c(this.Uv)?this.Uv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=c(this.Uv)?this.Uv.web_vitals_attribution:void 0;return w(t)?t?mr:[]:v(t)?t:yr}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t=c(this.Uv)?this.Uv.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Bv(){var t=c(this.Uv)&&y(this.Uv.__web_vitals_max_value)?this.Uv.__web_vitals_max_value:br;return t>0&&6e4>=t?br:t}get isEnabled(){var t=null==li?void 0:li.protocol;if("http:"!==t&&"https:"!==t)return _r.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=c(this.Uv)?this.Uv.web_vitals:w(this.Uv)?this.Uv:void 0;return w(i)?i:this.xv}startIfEnabled(){this.isEnabled&&!this.Rs&&(_r.info("enabled, starting..."),this.Ys(this.Hv))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=c(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=c(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ce]:e}),this._instance.persistence.register({[ge]:r})),this.xv=e,this.startIfEnabled()}}}get zv(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ys(t){var i=er.__PosthogExtensions__,e=this.zv,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&p(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?_r.error("failed to load script",i):t()}))}jv(t){var i=t||(null==si?void 0:si.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?Y(i):i,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...vr,...r||[]]:[];return Ve(e,s,cr)}_r.error("Could not determine current URL")}}},Is={exceptionObserver:class{constructor(t){var i;this.Hv=()=>{var t;if(si&&this.isEnabled&&null!=(t=er.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=er.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=er.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=er.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Wv&&this.mn.capture_unhandled_errors&&(this.Wv=i(this.captureException.bind(this))),!this.Vv&&this.mn.capture_unhandled_rejections&&(this.Vv=e(this.captureException.bind(this))),!this.Gv&&this.mn.capture_console_errors&&(this.Gv=r(this.captureException.bind(this)))}catch(t){ar.error("failed to start",t),this.Zv()}}},this._instance=t,this.Qv=!(null==(i=this._instance.persistence)||!i.props[he]),this.pe=new T(e({},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:ar})),this.mn=this.Jv(),this.startIfEnabledOrStop()}Jv(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return c(t)?i=e({},i,t):(p(t)?this.Qv:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.mn.capture_console_errors||this.mn.capture_unhandled_errors||this.mn.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ar.info("enabled"),this.Zv(),this.Ys(this.Hv)):this.Zv()}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return ar.error("failed to load script",i);t()}))}Zv(){var t,i,e;null==(t=this.Wv)||t.call(this),this.Wv=void 0,null==(i=this.Vv)||i.call(this),this.Vv=void 0,null==(e=this.Gv)||e.call(this),this.Gv=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Qv=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[he]:this.Qv}),this.mn=this.Jv(),this.startIfEnabledOrStop())}}onConfigChange(){this.mn=this.Jv()}captureException(t){var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";this.pe.consumeRateLimit(s)?ar.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var i,r;this.Kv=[],this.Yv=new st([new gt,new Ft,new bt,new _t,new kt,new xt,new yt,new Et],function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),s=1;i>s;s++)r[s-1]=arguments[s];return function(i,s){void 0===s&&(s=0);for(var n=[],a=i.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=pt.test(l)?l.replace(pt,"$1"):l;if(!u.match(/\S*Error: /)){for(var h of r){var v=h(u,t);if(v){n.push(v);break}}if(n.length>=50)break}}}return function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map((t=>{return e({},t,{filename:t.filename||(r=i,r[r.length-1]||{}).filename,function:t.function||nt});var r}))}(n)}}("web:javascript",vt,ft)),this._instance=t,this.Kv=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property(ve))&&void 0!==i?i:[],this.Xv=Rt(this.tc()),this.ec=new Ot(this.Xv)}onConfigChange(){this.Xv=Rt(this.tc()),this.ec.setConfig(this.Xv)}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.Kv=n,this._instance.persistence&&this._instance.persistence.register({[ve]:this.Kv,[de]:a})}}}get ic(){var t,i=!!this._instance.get_property(de),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.Yv.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.Xv.enabled)try{if(!g(t)||0===t.trim().length)return void gs.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)=>Tt.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.rc(i)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&gs.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.ec.add(e({[Pt]:t,[Ct]:(new Date).toISOString()},s))}catch(t){gs.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.nc(i)){if(this.sc(i))return this.ac("Exception dropped: matched a suppression rule"),void gs.info("Skipping exception capture because a suppression rule matched");if(!this.ic&&this.oc(i))return this.ac("Exception dropped: thrown by a browser extension"),void gs.info("Skipping exception capture because it was thrown by an extension");if(!this.ic&&this.lc(i))return this.ac("Exception dropped: thrown by an injected browser script"),void gs.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.uc(i))return this.ac("Exception dropped: thrown by the PostHog SDK"),void gs.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.Xv.enabled&&m(t.$exception_steps)?this.hc(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.ec.clear(),s}catch(t){return gs.error("Failed to capture exception event. Dropping this exception.",t),void this.ec.clear()}}catch(t){return void gs.error("Failed to process exception event. Ignoring this exception.",t)}var n}hc(t){try{var i=this.ec.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(i){return gs.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}ac(t){this.Xv.enabled&&this.ec.add({[Pt]:t,[Ct]:(new Date).toISOString()})}rc(t){return c(t)?e({},t):{}}tc(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}sc(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return g(e)&&e.length>0&&t.$exception_types.push(e),g(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Kv.some((t=>{var e=t.values.map((t=>{var e=Rr[t.operator],r=i[t.key];if(!e||!r)return!1;var s=v(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 gs.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}oc(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&&bs.some((t=>i.startsWith(t)))}));return 0!==e.length&&(!e.every((t=>{var i=t.filename;return!!i&&i.startsWith(_s)}))||t.some((t=>{var i=t.value;return g(i)&&i.includes("isolatedAPI.contexts.topHostname")}))&&!i.some((t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(_s))})))}lc(t){return t.some((t=>{var i=t.value;return g(i)&&ms.some((t=>i.includes(t)))}))}uc(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:[],a=n[n.length-1];return null!==(r=null==a||null==(s=a.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}nc(t){return!m(t)&&v(t)}}},$s=e({productTours:class{get qo(){return this._instance.persistence}constructor(t){this.dc=null,this.vc=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.qo&&this.qo.register({[fe]:!!i.productTours}),!Dr(this._instance))return!this.dc&&m(null==(e=this.qo)?void 0:e.props[Ie])||Lr.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.dc)||r.stop(),this.dc=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.dc&&Dr(this._instance)&&this.Ys((()=>this.cc()))}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?Lr.error("Could not load product tours script",i):t()}))}cc(){var t;!this.dc&&null!=(t=er.__PosthogExtensions__)&&t.generateProductTours&&(this.dc=er.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!v(this.vc)||i){var e=this.qo;if(e){var r=e.props[Ie];if(v(r)&&!i)return this.vc=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(Dr(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||Lr.warn(s):Lr.error(s),void t([],{isLoaded:!1,error:s})}var n=v(i.json.product_tours)?i.json.product_tours:[];this.vc=n,e&&e.register({[Ie]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.vc,{isLoaded:!0})}getActiveProductTours(t){m(this.dc)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.dc.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.dc)||i.showTourById(t)}previewTour(t){this.dc?this.dc.previewTour(t):this.Ys((()=>{var i;this.cc(),null==(i=this.dc)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.dc)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.dc)||t.nextStep()}previousStep(){var t;null==(t=this.dc)||t.previousStep()}clearCache(){var t;this.vc=null,null==(t=this.qo)||t.unregister(Ie)}resetTour(t){var i;null==(i=this.dc)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.dc)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.dc)||i.cancelPendingTour(t)}}},Rs),js={siteApps:class{constructor(t){this.fc=0,this._instance=t,this.gc=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}mc(t,i){if(i){var e=this.globalsForEvent(i);this.gc.push(e),this.gc.length>1e3&&(this.gc=this.gc.slice(10))}}get siteAppLoaders(){var t;return null==(t=er._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.mc.bind(this));this.yc=()=>{t(),this.gc=[],this.yc=void 0}}}globalsForEvent(t){var i,r,s,n,a,o,l;if(!t)throw new Error("Event payload is required");var u={},h=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(v)){var c=d[0];u[c]={id:h[c],type:c,properties:d[1]}}var f=t.$set_once,p=t.$set;return{event:e({},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}(t,Nr),{properties:e({},t.properties,p?{$set:e({},null!==(i=null==(r=t.properties)?void 0:r.$set)&&void 0!==i?i:{},p)}:{},f?{$set_once:e({},null!==(s=null==(n=t.properties)?void 0:n.$set_once)&&void 0!==s?s:{},f)}:{}),elements_chain:null!==(a=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(l=t.properties)?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}bc(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}_c(){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==oi?void 0:oi.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.fc++,this.wc)return this.kc();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.bc(t);return i&&d.add(i),i},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!b(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.wc=()=>{h.forEach((t=>t())),this.wc=void 0},this.kc()}kc(){var t=!1;return()=>{var i;t||(t=!0,this.fc--,0===this.fc&&(null==(i=this.wc)||i.call(this)))}}Sc(t,i){void 0===i&&(i=!0);var e=this._c();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.gc.length&&(zr.info("Processing "+this.gc.length+" events for site app with id "+t.id),this.gc.forEach((t=>this.Sc((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this.yc)||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.Sc((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){zr.error(Br+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}}xc(){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)}Cc(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Sc((()=>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.xc(),void this._instance.on("eventCaptured",(t=>this.Cc(t)))):void zr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.yc)||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;er["__$$ph_site_app_"+i]=s._instance,null==(t=er.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return zr.error(Br+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.')}}}},Ls={tracingHeaders:class{constructor(t){this.Tc=void 0,this.Mc=void 0,this.Ic=void 0,this.Hv=()=>{var t,i,e=this.Ec();e?(p(this.Tc)&&(this.Tc=null==(t=er.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),p(this.Mc)&&(this.Mc=null==(i=er.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Zv()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return hr.error("failed to load script",i);t()}))}Rc(){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}Ec(){var t=this.Rc();return v(t)?(v(this.Ic)?this.Ic.splice(0,this.Ic.length,...t):this.Ic=[...t],t.length>0?this.Ic:void 0):(v(this.Ic)&&this.Ic.splice(0),this.Ic=t||void 0,this.Ic)}Zv(){var t,i;null==(t=this.Tc)||t.call(this),null==(i=this.Mc)||i.call(this),this.Tc=void 0,this.Mc=void 0}startIfEnabledOrStop(){this.Ec()?this.Ys(this.Hv):this.Zv()}}},Ds=e({surveys:class extends Zr{constructor(t){var i;super(new ss(t),{get projectToken(){return i.config.token},kv:new rs(i=t)}),this._instance=t}qu(t,i){var r=i.query?function(t,i,r){var s;void 0===r&&(r=!0);var n=t.split("?"),a=n[0],o=n[1],l=e({},i),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 ci(t,(function(t,i){p(t)||p(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,i.query):t;return new Promise((t=>{var e;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(e=i.target)&&void 0!==e?e:"api",r),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})}))}}},Rs),Ns={toolbar:class{constructor(t){this.instance=t}Pc(t){er.ph_toolbar_state=t}Ac(){var t;return null!==(t=er.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),bi(this.instance.config))return!1;if(!si||!oi)return!1;t=null!=t?t:si.location,e=null!=e?e:si.history;try{if(!i){try{si.localStorage.setItem("test","test"),si.localStorage.removeItem("test")}catch(t){return!1}i=null==si?void 0:si.localStorage}var r,s=ns||qe(t.hash,"__posthog")||qe(t.hash,"state"),n=s?gi((()=>JSON.parse(atob(decodeURIComponent(s)))))||gi((()=>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(as)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Fc(t){var i=er.ph_load_toolbar||er.ph_load_editor;!m(i)&&d(i)?i(t,this.instance):os.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==oi||!oi.getElementById(yi));if(!si||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(si.localStorage.setItem(as,JSON.stringify(e({},s,{source:void 0}))),2===this.Ac())this.Fc(s);else if(0===this.Ac()){var n;this.Pc(1),null==(n=er.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return os.error("[Toolbar] Failed to load",t),void this.Pc(0);this.Pc(2),this.Fc(s)})),_i(si,"turbolinks:load",(()=>{this.Pc(0),this.loadToolbar(s)}))}return!0}Oc(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)}}},zs=e({experiments:Ss},Rs),Bs={conversations:class{constructor(t){this.Lc=void 0,this._conversationsManager=null,this.Dc=!1,this.je=null,this.$c=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Nc=t.ok,t.ok)){var i=t.config.conversations;m(i)||(w(i)?this.Lc=i:(this.Lc=i.enabled,this.je=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Lc=void 0,this.je=null,this.Nc=void 0,this.$c=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Dc||this._instance.config.disable_conversations||bi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==er?void 0:er.__PosthogExtensions__;if(t&&!p(this.Lc)&&this.Lc)if(this.je&&this.je.token){this.Dc=!0;try{var i=t.initConversations;if(i)return this.qc(i),void(this.Dc=!1);var e=t.loadExternalDependency;if(!e)return void this.jc(ze);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.jc("Could not load conversations script",i):this.qc(t.initConversations),this.Dc=!1}))}catch(t){this.jc("Error initializing conversations",t),this.Dc=!1}}else xs.error("Conversations enabled but missing token in remote config.")}}qc(t){if(this.je)try{this._conversationsManager=t(this.je,this._instance),this.$c=!1,xs.info("Conversations loaded successfully")}catch(t){this.jc("Error completing conversations initialization",t)}else xs.error("Cannot complete initialization: remote config is null")}jc(t,i){xs.error(t,i),this._conversationsManager=null,this.Dc=!1,this.$c=!0}show(){this._conversationsManager?this._conversationsManager.show():xs.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Lc&&!b(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":bi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Nc?"remote_config_failed":p(this.Lc)?this.Nc?"disabled_in_project":"remote_config_pending":this.Lc?m(this.je)||!this.je.token?"missing_token":null!=er&&er.__PosthogExtensions__?this.Dc?"initializing":this.$c?"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,e,r){var s=this;return i((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,r):(xs.warn(ks),null)}))()}getMessages(t,e){var r=this;return i((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,e):(xs.warn(ks),null)}))()}markAsRead(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(xs.warn(ks),null)}))()}getTickets(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(xs.warn(ks),null)}))()}requestRestoreLink(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(xs.warn(ks),null)}))()}restoreFromToken(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(xs.warn(ks),null)}))()}restoreFromUrlToken(){var t=this;return i((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(xs.warn(ks),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()}}},Hs={logs:class{constructor(t){var i,r=this;this.name="logs",this.Bc=!1,this.Hc=!1,this.zc=!1,this.A=di("[logs]"),this.Uc=e({},this.A,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(As)||r.A.error(...i)}}),this.mo=[],this.Wc=[],this.yd=0,this.Os=!1,this.Vc=[],this.Gc=[],this.Zc=!1,this.Qc=!1,this.Jc=()=>{var t,i;this.Os||(this.yd=0,null==(t=this.Kc)||t.onReconnect(),null==(i=this.Yc)||i.onReconnect())},this._instance=t,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Bc=!0),si&&_i(si,"online",this.Jc)}Xc(t,i,e,r){var s,n=Es(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new Qt(this.tf(t,i),n,this.Uc,(()=>this.ef()),(t=>t()),void 0,r),n]}if(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Kc||this.rf!==i){var e;null==(e=this.Kc)||e.reset(),this.rf=i;var r=this.Xc((()=>this.mo),(t=>{this.mo=t}));this.Kc=r[0],this.nf=r[1]}return this.Kc}sf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Yc||this.af!==i){var e;null==(e=this.Yc)||e.reset(),this.af=i;var r=this.Xc((()=>this.Wc),(t=>{this.Wc=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Ps);this.Yc=r[0],this.lf=r[1]}return this.Yc}setup(t){var i;if(!this.Os){this.Ns=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.Bc=!0),(this.Bc||this.uf()&&this.hf())&&this.df();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.Os?r.dispose():(this.qs=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.Os||(this.Os=!0,this.vf(),null==(t=this.qs)||t.dispose(),this.qs=void 0,this.Ns=void 0,this.zc=!1,null==si||si.removeEventListener("online",this.Jc),null==(i=this.cf)||i.call(this),this.cf=void 0,null==(e=this.Kc)||e.reset(),null==(r=this.Yc)||r.reset())}onRemoteConfig(t){var i,e;if(!this.Os){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;m(r)?this.ff():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[pe]:!!r}),r?(this.Bc=!0,this.Hc||this.df(),this.loadIfEnabled()):this.ff())}}reset(){var t,i,e,r;this.vf(),null==(t=this.Kc)||t.clearQueue(),this.mo=[],null==(i=this.Kc)||i.reset(),null==(e=this.Yc)||e.clearQueue(),this.Wc=[],null==(r=this.Yc)||r.reset(),this.yd=0}captureLog(t){this.Os||this.if().captureLog(t)}captureConsoleLog(t){this.Os||this.sf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.Os||this.sf().captureLog(t,{context:i,occurredAtMs:e})}hf(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[pe])}uf(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=er._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.vf(),null==(t=this.Yc)||t.clearQueue(),this.Wc=[]}ff(){this.Bc||this.vf()}df(){var t,i=this;if(!this.Zc&&null!=er&&er.console){var e=Es(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(er.console[t])}catch(t){return 0}if(!r)return 0;i.Gc.push(ur(er.console,t,(s=>{var n=function(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];try{i.pf(t,n,e)}catch(t){}return s.apply(er.console,n)};return n.__rrweb_original__=r,n})))};for(var s of Fs)r(s);this.Zc=!0,this.gf=setTimeout((()=>{this.vf()}),3e4)}}pf(t,i,e){var r;if(this.Zc&&!this.Qc&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Vc.length){this.Qc=!0;try{this.Vc.push({level:t,args:i,occurredAtMs:Date.now(),context:this.ef()})}finally{this.Qc=!1}}}else this.vf()}vf(){if(this.Vc=[],this.Zc){for(var t of(this.Zc=!1,this.gf&&(clearTimeout(this.gf),this.gf=void 0),this.Gc))t();this.Gc=[]}}mf(){var t=this.Vc;return this.vf(),t}get logger(){return this.yf||(this.yf={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.yf}flushLogs(t){t?this.bf(t):(this.Kc&&this.Kc.flush().catch((t=>this._f(t))),this.Yc&&this.Yc.flush().catch((t=>this._f(t))))}_f(t){As(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Os&&this.Bc&&!this.Hc&&!this.zc){var t=null==er?void 0:er.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.vf();var i=t.loadExternalDependency;if(!i)return this.A.error(ze),void this.vf();this.zc=!0;try{i(this._instance,"logs",(i=>{if(this.zc=!1,!this.Os&&this.Bc){var e=t.logs;if(i||null==e||!e.initializeLogs)this.A.error("Could not load logs script",i),this.vf();else{var r,s,n=this.mf();this.cf=e.initializeLogs(null!==(r=this.Ns)&&void 0!==r?r:this._instance),this.Hc=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.Ns)&&void 0!==s?s:this._instance,n))}}}))}catch(t){throw this.zc=!1,t}}}tf(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===o.LogsQueue?t():void 0,setPersistedProperty(t,e){var r;t===o.LogsQueue&&i(null!==(r=e)&&void 0!==r?r:[])},hs:t=>this.hs(t),getLibraryId:()=>ri.LIB_NAME,getLibraryVersion:()=>ri.LIB_VERSION}}hs(t){return new Promise((i=>{if(We(this.yd,3))i({kind:"fatal",error:Ts(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:Ts(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.wf(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.kf(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:Ts(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)})}}})}}))}kf(t){(0!==t||this._instance.__loaded)&&(this.yd=Ke(t,this.yd,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."))))}bf(t){this.mo.length>0&&this.Sf(t,this.mo,this.nf,ri.LIB_NAME,(t=>{this.mo=t})),this.Wc.length>0&&this.Sf(t,this.Wc,this.lf,Ps,(t=>{this.Wc=t}))}Sf(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var a=Zt(n,Xt(e,ri.LIB_NAME,ri.LIB_VERSION),r,ri.LIB_VERSION);this._instance._send_request({method:"POST",url:this.wf(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}wf(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}ef(){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,m(s)||(i.sessionStartTimestamp=s),m(n)||(i.lastActivityTimestamp=n)}if(null!=er&&null!=(t=er.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?Y(er.location.href):er.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Us={metrics:class{constructor(t){this.A=di("[metrics]"),this._instance=t}initialize(){}if(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Kc&&this.rf===e||(null==(i=this.Kc)||i.reset(),this.rf=e,this.Kc=new ei(this.tf(),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.Kc}count(t,i,e){void 0===i&&(i=1),this.if().count(t,i,e)}gauge(t,i,e){this.if().gauge(t,i,e)}histogram(t,i,e){this.if().histogram(t,i,e)}flush(t){if(!this.Kc)return Promise.resolve();if(t){var i=this.Kc.drainWindow();return i&&this.Ms(i,t),Promise.resolve()}return this.Kc.flush().catch((t=>this.A.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Kc)||t.reset()}tf(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ms:t=>i.Ms(t),getLibraryId:()=>ri.LIB_NAME,getLibraryVersion:()=>ri.LIB_VERSION}}Ms(t,i){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(e({method:"POST",url:this.xf(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error("metrics request failed with status "+i)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("metrics request failed with status "+i)})}}}))}))}xf(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Vs=e({},Rs,Os,Ms,Is,$s,js,Ds,Ls,Ns,zs,Bs,Hs,Us),qs=Rs,Ws=Os,Ks=Ms,Js=Is,Gs=$s,Xs=js,Zs=Ds,Qs=Ls,Ys=Ns,tn=zs,en=Bs,rn=Hs,sn=Us;export{Vs as AllExtensions,Ks as AnalyticsExtensions,en as ConversationsExtensions,Js as ErrorTrackingExtensions,tn as ExperimentsExtensions,qs as FeatureFlagsExtensions,rn as LogsExtensions,sn as MetricsExtensions,Gs as ProductToursExtensions,Ws as SessionReplayExtensions,Xs as SiteAppsExtensions,Zs as SurveysExtensions,Ys as ToolbarExtensions,Qs as TracingExtensions};
|
|
1
|
+
function t(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 i(i){return function(){var e=this,r=arguments;return new Promise((function(s,n){var a=i.apply(e,r);function o(i){t(a,s,n,o,l,"next",i)}function l(i){t(a,s,n,o,l,"throw",i)}o(void 0)}))}}function e(){return e=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},e.apply(null,arguments)}var r=["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"],s=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return r.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function n(t,i){return-1!==t.indexOf(i)}var a=function(t){return t.trim()},o=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),l=Object.prototype,u=l.hasOwnProperty,h=l.toString,v=Array.isArray||function(t){return"[object Array]"===h.call(t)},d=t=>"function"==typeof t,c=t=>t===Object(t)&&!v(t),f=t=>{if(c(t)){for(var i in t)if(u.call(t,i))return!1;return!0}return!1},p=t=>void 0===t,g=t=>"[object String]"==h.call(t),_=t=>g(t)&&0===t.trim().length,b=t=>null===t,m=t=>p(t)||b(t),y=t=>"[object Number]"==h.call(t)&&t==t,w=t=>"[object Boolean]"===h.call(t),S=t=>t instanceof FormData;function x(t){return null===t||"object"!=typeof t}function k(t,i){return{}.toString.call(t)==="[object "+i+"]"}function E(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 P(t,Error)}}function F(t){return"u">typeof Event&&P(t,Event)}function P(t,i){try{return t instanceof i}catch(t){return!1}}function C(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),C(e,i,e,r))}class T{constructor(t){this.C={},this.I=t.I,this.R=C(t.bucketSize,0,100,t.A),this.O=C(t.refillRate,0,this.R,t.A),this.N=C(t.refillInterval,0,864e5,t.A)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.N);e>0&&(t.tokens=Math.min(t.tokens+e*this.O,this.R),t.lastAccess=t.lastAccess+e*this.N)}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={}}}var A,R,O,M="Mobile",I="Android",j="BlackBerry",L="Nintendo",D="PlayStation",N="Xbox",z="Windows",B=z+" Phone",H=new RegExp(j+"|PlayBook|BB10","i"),U={"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"},V=[[new RegExp(N+"; "+N+" (.*?)[);]","i"),t=>[N,t&&t[1]||""]],[new RegExp(L,"i"),[L,""]],[new RegExp(D,"i"),[D,""]],[H,[j,""]],[new RegExp(z,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[B,""];if(new RegExp(M).test(i)&&!/IEMobile\b/.test(i))return[z+" "+M,""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=U[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[z,r]}return[z,""]}],[/((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=p(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("("+I+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+I+")","i"),t=>t&&t[2]?[I,[t[2],t[3],t[4]||"0"].join(".")]:[I,""]],[/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",""]]],q=20,W=1e3,K=1e4,J="[Circular]",G="[Truncated]",X="[Unserializable]",Z="[Function]";function Q(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 Y(t){return t?t.split("#")[0]:t}function tt(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function it(t,i,e){return et.apply(this,arguments)}function et(){return(et=i((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=tt((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}function rt(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return O&&e.length===R?O:(R=e.length,O=e.reduce(((e,r)=>{A||(A={});var s=A[r];if(s)e[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,u=i[r];if(l&&u){e[l]=u,A[r]=[l,u];break}}return e}),{}))}}class st{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 e=this;return i((function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&v(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t}))()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),e({},t,{cause:r,stack:s})}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 e=this;return i((function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i}))()}convertToExceptionList(t,i){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=i.type)&&void 0!==r?r:"generic",handled:null===(s=i.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,e({},i,{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:rt(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,r){void 0===r&&(r=0);var s=(e,r)=>{if(4>=r){var s=this.buildCoercingContext(t,i,r);return this.applyCoercers(e,s)}};return e({},i,{syntheticException:0==r?i.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var nt="?";function at(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?nt:e,in_app:!(null!=i&&i.startsWith("webkit-masked-url://"))&&"<anonymous>"!==i};return p(r)||(n.lineno=r),p(s)||(n.colno=s),n}var ot=(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]:nt,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},lt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ut=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ht=/\((\S*)(?::(\d+))(?::(\d+))\)/,vt=(t,i)=>{var e=lt.exec(t);if(e)return at(i,e[1],nt,+e[2],+e[3]);var r=ut.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ht.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=ot(r[1]||nt,r[2]);return at(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},dt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ct=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ft=(t,i)=>{var e=dt.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=ct.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]||nt,a=ot(n,s);return at(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},pt=/\(error: (.*)\)/;class gt{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=g(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 k(t,"DOMException")}isDOMError(t){return k(t,"DOMError")}}class _t{match(t){return E(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}}class bt{match(t){return!!k(t,"ErrorEvent")&&(null!=t.error||this.Vi(t))}coerce(t,i){var r;if(null!=t.error)return i.apply(t.error);var s=i.apply(t.message);return e({},s,{stack:null!==(r=this.Zi(t))&&void 0!==r?r:s.stack,synthetic:!0})}Vi(t){return g(t.message)&&t.message.length>0}Zi(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(g(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var mt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class yt{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(mt);return r&&(i=r[1],e=r[2]),[i,e]}}var wt=["fatal","error","warning","log","info","debug"];function St(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}class xt{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(F(t))return t.constructor.name;var i="name"in t?t.name:void 0;return g(i)&&!_(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: "+St(t)}isSeverityLevel(t){return g(t)&&!_(t)&&wt.indexOf(t)>=0}getStack(t){try{return g(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:g(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(E(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}}class kt{match(t){return F(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+St(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class Et{match(t){return x(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class Ft{match(t){return k(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!F(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 x(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var Pt="$message",Ct="$timestamp",Tt=new Set([Pt,Ct]),At={enabled:!0,max_bytes:32768};function Rt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:At.enabled,max_bytes:Mt(t.max_bytes,At.max_bytes)}:e({},At)}class Ot{constructor(t){this.Pn=[],this.Fn=0,this.mn=Rt(t)}setConfig(t){this.mn=Rt(t),this.$n()}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(!c(s))return;var n=s,a=n[Pt],o=n[Ct];if(!g(a)||0===a.trim().length)return;if(!g(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.mn.max_bytes||(this.Pn.push({step:i.step,bytes:e}),this.Fn+=e,this.$n())}}getAttachable(){return this.Pn.map((t=>t.step))}clear(){this.Pn=[],this.Fn=0}size(){return this.Pn.length}$n(){for(;this.Fn>this.mn.max_bytes&&this.Pn.length>0;){var t=this.Pn.shift();t&&(this.Fn-=t.bytes)}}}function Mt(t,i){if(!y(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var It=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function $t(t){return"string"==typeof t||t}function jt(t){return"string"==typeof t?t:void 0}var Lt=0x8000000000000000,Dt="9223372036854775808",Nt={}.propertyIsEnumerable;function zt(t,i){try{return Ut(t,i,{ancestors:new WeakSet,remainingNodes:K},0)}catch(t){return[]}}function Bt(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:G};if(e.remainingNodes--,w(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt(Dt);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>=Lt||-Lt>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:Q(t)};if("function"==typeof t)return{stringValue:Z};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:J};if(r>=q)return{stringValue:G};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?Q(a):String(a)}}e.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Bt(o.call(t),i,e,r+1)}catch(t){}return v(t)?{arrayValue:{values:Ht(t,i,e,r+1)}}:{kvlistValue:{values:Ut(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:Q(String(t))}}function Ht(t,i,e,r){for(var s=[],n=Math.min(t.length,W),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(m(o))continue;s.push(Bt(o,i,e,r))}catch(t){s.push({stringValue:X})}return t.length>a&&s.push({stringValue:G}),s}function Ut(t,i,e,r){var s=[];for(var n in t)if(Nt.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=W||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(b(a)||p(a))continue;s.push({key:Q(n),value:Bt(a,i,e,r)})}catch(t){s.push({key:Q(n),value:{stringValue:X}})}}return s}function Vt(t,i,r){return e({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":r})}var qt={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var Wt={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}},Kt=Wt.info;function Jt(t){try{return Q(String(t))}catch(t){return X}}function Gt(t,i,r,s){var n,a=Wt[t.level||"info"]||Kt,o=a.text,l=a.number,u=(void 0===(n=y(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),m(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),m(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var v=e({},h),d=t.attributes;if(d){var c=[];try{c=Object.keys(d)}catch(t){c=[]}for(var f of c){var g=void 0;try{g=d[f]}catch(t){g=X}Object.defineProperty(v,f,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Jt(t.body)},attributes:zt(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),p(t.trace_flags)||(_.flags=t.trace_flags),_}function Xt(t,i,e){return Vt(t,i,e)}function Zt(t,i,e,r){return{resourceLogs:[{resource:{attributes:zt(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let Qt=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.mn=i,this.A=e,this.Nn=r,this.qn=s,this.jn=n,this.Bn=a,this.Hn=null,this.zn=0,this.Un=0,this.Wn=0,this.Vn=0,this.Gn=0,this.Zn=!1,this.Qn=i.maxBufferSize,this.Jn=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.Kn=i.flushIntervalMs,this.Yn=i.maxBatchRecordsPerPost,this.Xn=i.rateCapWindowMs,this.ts=i.maxLogsPerInterval}clearQueue(){this.Un++,this._instance.setPersistedProperty(o.LogsQueue,[])}reset(){this.es(),this.Vn=0,this.Gn=0,this.Zn=!1,this.Wn=0,this.Yn=this.mn.maxBatchRecordsPerPost}onReconnect(){this.Wn=0,this.rs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.ns(t);if(null!==r)if(r.body){if(this.ss()){var s={record:Gt(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.Nn(),this.A,null==i?void 0:i.occurredAtMs)};this.qn((()=>this.os(s)))}}else this.A.info("Log was rejected in beforeSend function")}}ns(t){var i=this.mn.beforeSend;if(!i)return t;var e=v(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}ss(){if(void 0===this.ts)return!0;var t=Date.now(),i=t-this.Vn;return this.Xn>i&&i>=0||(this.Vn=t,this.Gn=0,this.Zn=!1),this.ts>this.Gn?(this.Gn++,!0):(this.Zn||(this.A.warn("captureLog dropping logs: exceeded "+this.ts+" logs per "+this.Xn+"ms"),this.Zn=!0),!1)}flush(){var t=this;return i((function*(){if(!t._instance.isDisabled)return t.Hn||(t.Hn=t.ls().finally((()=>{t.Hn=null}))),t.Hn}))()}ls(){var t=this;return i((function*(){var i;t.es();var e=null!==(i=t._instance.getPersistedProperty(o.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,a,l=t.Un;t.zn=0;var u=Math.min(e.length,t.Yn),h=e.slice(0,u),v=Zt(h.map((t=>t.record)),t.us(),null!==(n=t.Bn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.hs(v);if(t.Un!==l)return;if("too-large"===d.kind&&h.length>1)t.Yn=Math.max(1,Math.floor(h.length/2)),t.A.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.Yn);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.A.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.mn.maxBatchRecordsPerPost>t.Yn&&(t.Yn=Math.min(t.mn.maxBatchRecordsPerPost,t.Yn+1)),yield t.ds(h.length),e=null!==(a=t._instance.getPersistedProperty(o.LogsQueue))&&void 0!==a?a:[],s+=h.length,"fatal"===d.kind)throw d.error}}}))()}ds(t){var e=this;return i((function*(){var i,r=Math.max(0,t-e.zn),s=null!==(i=e._instance.getPersistedProperty(o.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(o.LogsQueue,s.slice(r)),yield e.jn()}))()}us(){return Xt(this.mn,this._instance.getLibraryId(),this._instance.getLibraryVersion())}os(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(o.LogsQueue))&&void 0!==i?i:[];this.Jn>e.length||(e.shift(),this.zn++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(o.LogsQueue,e),this.Qn>e.length?this.vs():this.rs()}}vs(t){void 0===t&&(t=this.Kn),this.cs||(this.cs=tt((()=>{this.cs=void 0,this.rs()}),t))}fs(){var t=Math.min(Math.max(0,this.Wn-1),6);return this.Kn*Math.pow(2,t)}ps(){var t=this._instance.getPersistedProperty(o.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return i((function*(){e.es();var i=e.flush().catch((()=>{}));void 0!==t?yield it(i,t):yield i}))()}flushWithTimeout(t){var e=this;return i((function*(){var i=e.flush();yield it(i,t,(()=>{i.catch((()=>{}))}))}))()}rs(){this.flush().then((()=>{this.Wn=0}),(t=>{this.Wn++,this.A.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.ps()&&this.vs(this.fs())}))}es(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};var Yt=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ti(t){return String(t)+"000000"}function ii(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}let ei=class{constructor(t,i,e){this._instance=t,this.mn=i,this.A=e,this.gs=new Map,this.Hn=null,this.ys=!1,this.bs=new Map,this._s=new Set,this.ws=0}count(t,i,e){void 0===i&&(i=1),this.ks({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.ks({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.ks({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,e=this.Hn,r=function(){var r=i((function*(){e&&(yield e.catch((()=>{}))),yield t.Ss()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this.Hn===s&&(this.Hn=null)}));return this.Hn=s,s}drainWindow(){if(0===this.gs.size)return null;var t=this.gs;return this.gs=new Map,this.ys=!1,this.bs=new Map,this._s=new Set,this.xs(t)}reset(){this.ws++,this.es(),this.gs=new Map,this.Hn=null,this.ys=!1,this.bs=new Map,this._s=new Set}ks(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.ns(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.A.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=i.attributes?e({},i.attributes):void 0,s=ii(i.type,i.name,i.unit,r)}catch(t){return void this.A.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.gs.get(s);if(!n){if(!this.Cs())return;n={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.gs.set(s,n)}var a=this.bs.get(i.name);void 0===a?this.bs.set(i.name,i.type):a===i.type||this._s.has(i.name)||(this._s.add(i.name),this.A.warn("Metric name '"+i.name+"' is already used as a "+a+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Ts(n,i.value),this.vs()}else this.A.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Cs(){return this.mn.maxSeriesPerFlush>this.gs.size||(this.ys||(this.ys=!0,this.A.warn("Metric series cap reached ("+this.mn.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ts(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(Yt.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,Yt)]+=1}}ns(t){var i=this.mn.beforeSend;if(!i)return t;var e=v(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}vs(){this.cs||(this.cs=tt((()=>{this.cs=void 0,this.flush().catch((t=>{this.A.error("Metrics flush failed:",t)}))}),this.mn.flushIntervalMs))}es(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}Ss(){var t=this;return i((function*(){if(0!==t.gs.size){var i=t.gs;t.gs=new Map,t.ys=!1,t.bs=new Map,t._s=new Set;var e=t.ws,r=yield t._instance.Ms(t.xs(i));if(e===t.ws)switch(r.kind){case"ok":return;case"retry-later":return t.Is(i),void t.vs();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)}}}))()}xs(t){return i=this.Es(t),e=function(t,i,e){return Vt(t,i,e)}(this.mn,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:zt(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Es(t){var i=ti(Date.now()),r=new Map;for(var s of t.values()){var n,a=ii(s.type,s.name,s.unit,void 0),o=r.get(a);o||(o=e({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=zt(null!==(n=s.attributes)&&void 0!==n?n:{},this.A),u=ti(s.windowStartMs);if("count"===s.type){var h,v={attributes:l,startTimeUnixNano:u,timeUnixNano:i,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:i,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:i,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:Yt})}return Array.from(r.values())}Is(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.gs.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.Cs()&&this.gs.set(s,n)}}};var ri={DEBUG:!1,LIB_VERSION:"0.7.2",LIB_NAME:"browser-common"},si="u">typeof window?window:void 0,ni="u">typeof globalThis?globalThis:si,ai=null==ni?void 0:ni.navigator,oi=null==ni?void 0:ni.document,li=null==ni?void 0:ni.location;function ui(){return!(!si||!1===si.navigator.onLine)}null!=ni&&ni.XMLHttpRequest&&new ni.XMLHttpRequest;var hi=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={q(i){if(si&&(ri.DEBUG||si.POSTHOG_DEBUG||e)&&!p(si.console)&&si.console){for(var r=("__rrweb_original__"in si.console[i]?si.console[i].__rrweb_original__:si.console[i]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;s>a;a++)n[a-1]=arguments[a];r(t,...n)}},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("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)=>hi(t+" "+i,e)};return r},vi=hi("[PostHog.js]"),di=vi.createLogger;function ci(t,i){if(!m(t))if(v(t))t.forEach(i);else if(S(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)u.call(t,e)&&i(t[e],e)}var fi=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 pi(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var gi=function(t){try{return t()}catch(t){return}};function _i(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 bi(t){return"ph_toolbar_internal"===t.name}function mi(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!d(r))return i;try{var s=r(i);return g(s)&&s?s:i}catch(t){return vi.error("Error in get_current_url, falling back to window.location.href",t),i}}var yi="__POSTHOG_TOOLBAR__",wi=1,Si=3,xi=11;function ki(t){return t instanceof Element&&(t.id===yi||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Ei(t){return!!t&&t.nodeType===wi}function Fi(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Pi(t){return!!t&&t.nodeType===Si}function Ci(t){return!!t&&t.nodeType===xi&&Ei(t.host)}var Ti=1e3;function Ai(t){return t?a(t).split(/\s+/):[]}function Ri(t,i){var e=function(t){var i,e=null==si||null==(i=si.location)?void 0:i.href;return p(e)?void 0:mi(t,e)}(i);return!!(e&&t&&t.some((t=>e.match(t))))}function Oi(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 Ai(i)}function Mi(t){return m(t)?null:a(t).split(/(\s+)/).filter((t=>ee(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ii(t){var i="";return Ki(t)&&!Ji(t)&&t.childNodes&&t.childNodes.length&&ci(t.childNodes,(function(t){var e;Pi(t)&&t.textContent&&(i+=null!==(e=Mi(t.textContent))&&void 0!==e?e:"")})),a(i)}function $i(t){var i;return p(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var ji=["a","button","form","input","select","textarea","label"];function Li(t,i){if(p(i))return!0;var e,r=function(t){if(i.some((i=>function(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}(t,i))))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function Di(t){var i=t.parentNode;return!(!i||!Ei(i))&&i}var Ni=[".ph-no-autocapture","[data-ph-no-autocapture]"],zi=["next","previous","prev",">","<"],Bi=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Hi=[".ph-no-rageclick",".ph-no-capture"],Ui=["","text","search","email","password","url","tel","number"];function Vi(t,i){if(!si||qi(t))return!1;var e,r,s,a,o;if(w(i)?(e=!!i&&Hi,r=void 0,s=!1):(e=null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Hi,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||!Ei(t))&&(!!Fi(t,"textarea")||(Fi(t,"input")?n(Ui,(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=Wi(t,!1).targetElementList;return!function(t,i){if(!1===t||p(t))return!1;var e;if(!0===t)e=zi;else{if(!v(t))return!1;if(t.length>10)return vi.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=>Bi(i,t)||Bi(r,t)))}))}(r,l.map((t=>{var i;return{safeText:Ii(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!Li(l,e)}var qi=t=>!t||Fi(t,"html")||!Ei(t),Wi=(t,i)=>{if(!si||qi(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!Fi(s,"body");)if(Ci(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Di(s);if(!n)break;if(i||ji.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=si.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Ki(t){for(var i=new Set,e=0,r=t;r.parentNode&&!Fi(r,"body");r=r.parentNode){if(e++>=Ti||i.has(r))return!1;i.add(r);var s=Oi(r);if(n(s,"ph-sensitive")||n(s,"ph-no-capture"))return!1}if(n(Oi(t),"ph-include"))return!0;var a=t.type||"";if(g(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!g(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 Ji(t){return!!(Fi(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Fi(t,"select")||Fi(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Gi=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}))$"),Xi=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Zi=[16,15,14,13],Qi=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Yi=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),te=/[0-9A-Za-z_]/;function ie(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 ee(t,i){if(void 0===i&&(i=!0),m(t))return!1;if(g(t)){t=a(t);var e=i?Gi.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(Xi.lastIndex=0;i=Xi.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of Zi){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(Gi.test(o)&&ie(o))return!0}}}return!1}(t);if(e)return!1;var r=i?Qi.test(t):function(t){var i;for(Yi.lastIndex=0;i=Yi.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&te.test(e)&&te.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function re(t){var i=Ii(t);return ee(i=(i+" "+se(t)).trim())?i:""}function se(t){var i="";return t&&t.childNodes&&t.childNodes.length&&ci(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=Ii(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+se(t)).trim())}catch(t){vi.error("[AutoCapture]",t)}})),i}function ne(t){return t.replace(/"|\\"/g,'\\"')}function ae(t){var i=t.attr__class;if(i)return v(i)?i:Ai(i)}class oe{constructor(t){this.disabled=!1===t;var i=c(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}}var le="$autocapture_disabled_server_side",ue="$heatmaps_enabled_server_side",he="$exception_capture_enabled_server_side",ve="$error_tracking_suppression_rules",de="$error_tracking_capture_extension_exceptions",ce="$web_vitals_enabled_server_side",fe="$product_tours_enabled_server_side",pe="$logs_capture_enabled_server_side",ge="$web_vitals_allowed_metrics",_e="$session_recording_remote_config",be="$enabled_feature_flags",me="$active_feature_flags",ye="$early_access_features",we="$feature_flag_details",Se="$feature_flag_payloads",xe="$feature_flag_request_id",ke="$minimal_flag_called_events",Ee="$override_feature_flags",Fe="$override_feature_flag_payloads",Pe="$stored_person_properties",Ce="$stored_group_properties",Te="$surveys",Ae="$surveys_loaded_at",Re="$surveys_activated",Oe="$surveys_activated_session",Me="$surveys_activated_timestamps",Ie="ph_product_tours",$e="$flag_call_reported",je="$flag_call_reported_session_id",Le="$feature_flag_errors",De="$feature_flag_evaluated_at",Ne="$sdk_debug_recording_script_not_loaded",ze="PostHog loadExternalDependency extension not found.",Be="visibilitychange",He="beforeunload",Ue=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(!v(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){vi.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ve=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=[],h=0;l.length>h;h++){var d=l[h].split("=");v(d)&&(i.includes(d[0])?u.push(d[0]+"="+e):u.push(l[h]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},qe=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},We=(t,i)=>t>=i&&ui(),Ke=(t,i,e,r)=>{if(0===t){if(ui()){var s=i+1;return s===e&&r(),s}return i}return 0},Je="$copy_autocapture",Ge=di("[AutoCapture]");function Xe(t,i){return i.length>t?i.slice(0,t)+"...":i}function Ze(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Ei(i));return i}function Qe(t,i){var r,s,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,h=i.elementsChainAsString,d=i.disableCaptureUrlHashes;if(!Ei(t))return{props:{}};for(var c=[t],f=new Set([t]),_=t;_.parentNode&&!Fi(_,"body")&&Ti>c.length;)if(Ci(_.parentNode)){var b=_.parentNode.host;if(f.has(b))break;f.add(b),c.push(b),_=b}else{if(!Ei(_.parentNode))break;if(f.has(_.parentNode))break;f.add(_.parentNode),c.push(_.parentNode),_=_.parentNode}var m,y,w=[],S={},x=!1,k=!1;if(ci(c,(t=>{var i=Ki(t);if(Fi(t,"a")){var e=t.getAttribute("href");x=!!(i&&e&&ee(e))&&(d?Y(e):e)}n(Oi(t),"ph-no-capture")&&(k=!0),w.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};ji.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Xe(1024,re(t)):Xe(1024,Ii(t)));var o=Oi(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),ci(t.attributes,(function(e){var n;if((!Ji(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&ee(e.value)&&(!g(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=Ai(o).join(" ")),a["attr__"+e.name]=Xe(1024,"href"===e.name&&s?Y(o):o)}}));for(var l=1,u=1,h=t;h=Ze(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,d));var r=function(t){if(!Ki(t))return{};var i={};return ci(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&&ee(r)&&(i[e]=r)}})),i}(t);ci(r,((t,i)=>{({}).hasOwnProperty.call(S,i)||(S[i]=t)}))})),k)return{props:{},explicitNoCapture:k};if(l||(w[0].$el_text=Fi(t,"a")||Fi(t,"button")?re(t):Ii(t)),x){var E,F;w[0].attr__href=x;var P=null==(E=(t=>{var i=null==oi?void 0:oi.createElement("a");return p(i)?null:(i.href=t,i)})(x))?void 0:E.host,C=null==si||null==(F=si.location)?void 0:F.host;P&&C&&P!==C&&(m=x)}return{props:fi({$event_type:a.type,$ce_version:1},h?{}:{$elements:w},{$elements_chain:(y=w,v(y)?function(t){return t.map((t=>{var i,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=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i: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 pi(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[ne(t[0].toString())]=ne(i.toString())})),(s+=":")+pi(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:ae(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return pi(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(y)):"")},null!=(r=w[0])&&r.$el_text?{$el_text:null==(s=w[0])?void 0:s.$el_text}:{},m&&"click"===a.type?{$external_click_url:m}:{},S)}}class Ye{constructor(t){this.name="autocapture",this.Rs=!1,this.Ps=null,this.As=!1,this.Fs=!1,this.mn={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Os=!1,this.Ls=t,this.Ls.refresh(this.mn),this.rageclicks=new oe(this.mn.rageclick),this.Ds=null}setup(t){this.$s(),this.Ns=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Os?i.dispose():(this.qs=i,this.startIfEnabled())}dispose(){var t;this.Os||(this.Os=!0,this.Ns=void 0,null==(t=this.qs)||t.dispose(),this.qs=void 0,this.js())}Bs(){return this.Ls.refresh(this.mn),this.mn}$s(){var t,i;return this.Bs(),this.mn.url_allowlist=null==(t=this.mn.url_allowlist)?void 0:t.map((t=>new RegExp(t))),this.mn.url_ignorelist=null==(i=this.mn.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),this.mn}Hs(){if(this.isBrowserSupported()){if(si&&oi){var t=this.zs=t=>{t=t||(null==si?void 0:si.event);try{this.Us(t)}catch(t){Ge.error("Failed to capture event",t)}};if(_i(oi,"submit",t,{capture:!0}),_i(oi,"change",t,{capture:!0}),_i(oi,"click",t,{capture:!0}),this.Bs().capture_copied_text){var i=this.Ws=t=>{t=t||(null==si?void 0:si.event);try{this.Us(t,Je)}catch(t){Ge.error("Failed to capture clipboard event",t)}};_i(oi,"copy",i,{capture:!0}),_i(oi,"cut",i,{capture:!0}),_i(oi,"paste",i,{capture:!0})}}}else Ge.info("Disabling Automatic Event Collection because this browser is not supported")}js(){this.zs&&(null==oi||oi.removeEventListener("submit",this.zs,!0),null==oi||oi.removeEventListener("change",this.zs,!0),null==oi||oi.removeEventListener("click",this.zs,!0),this.zs=void 0),this.Ws&&(null==oi||oi.removeEventListener("copy",this.Ws,!0),null==oi||oi.removeEventListener("cut",this.Ws,!0),null==oi||oi.removeEventListener("paste",this.Ws,!0),this.Ws=void 0),this.Rs=!1}startIfEnabled(){!this.Os&&this.Ns&&this.isEnabled&&!this.Rs&&(this.Hs(),this.Rs=!0)}onRemoteConfig(t){if(!this.Os)if(this.As=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.Fs=i.elementsChainAsString);var e,r=i.autocapture_opt_out;w(r)&&(null==(e=this.Ns)||e.kv.set(le,r),this.Ps=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.Ds=t}getElementSelectors(t){var i,e=[];return null==(i=this.Ds)||i.forEach((i=>{var r=null==oi?void 0:oi.querySelectorAll(i);null==r||r.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i;if(this.Os)return!1;var e=null==(t=this.Ns)?void 0:t.kv.get(le),r=this.Ps,s=this.Bs(),n=s.remoteRequestsDisabled&&!this.As;if(b(r)&&!w(e)&&!n)return!1;var a=null!==(i=this.Ps)&&void 0!==i?i:!!e;return!!s.enabled&&!a}Us(t,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r=$i(t);Pi(r)&&(r=r.parentNode||null);var s,n=this.$s();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&n.rageclick&&null!=(s=this.rageclicks)&&s.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Vi(r,n.rageclick)&&this.Us(t,"$rageclick");var a=i===Je,o=a?e({},n,{dom_event_allowlist:void 0}):n;if(r&&function(t,i,e,r,s,n){var a;if(!si||qi(t))return!1;if(null!=e&&e.url_allowlist&&!Ri(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&Ri(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=Wi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(p(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(!Li(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Li(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:Ni))return!1;try{var v=si.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&&(ji.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,o,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l,u=Qe(r,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.Fs,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),h=u.props;if(u.explicitNoCapture)return!1;var v=this.getElementSelectors(r);if(v&&v.length>0&&(h.$element_selectors=v),i===Je){var d=t.type||"clipboard";if("paste"!==d){var c,f,g=null==si||null==(c=si.getSelection())?void 0:c.toString(),_=Mi(g);if(!_)return!1;h.$selected_content=_,h.$clipboard_text_length=null!==(f=null==g?void 0:g.length)&&void 0!==f?f:0}h.$copy_type=d}return null==(l=this.Ns)||l.capture(i,h).catch((t=>Ge.error("Failed to capture event",t))),!0}}}isBrowserSupported(){return d(null==oi?void 0:oi.querySelectorAll)}}class tr{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=c(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}}var ir="undefined"!=typeof globalThis?globalThis:si;ir&&"undefined"==typeof self&&(ir.self=ir),ir&&"undefined"==typeof File&&(ir.File=function(){});var er=null!=si?si:{},rr=di("[Dead Clicks]"),sr=()=>!0;class nr{get lazyLoadedDeadClicksAutocapture(){return this.Ks}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({$dead_clicks_enabled_server_side:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ys((()=>{this.Xs()})):this.stop()}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?rr.error("failed to load script",i):t()}))}Xs(){var t;if(oi){if(!this.Ks&&null!=(t=er.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=c(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Ks=er.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ks.start(oi),rr.info("starting...")}}else rr.error("`document` not found. Cannot start.")}stop(){this.Ks&&(this.Ks.stop(),this.Ks=void 0,rr.info("stopping..."))}}var ar=di("[ExceptionAutocapture]"),or=()=>{},lr=t=>{var i;if(d(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function ur(t,i,e){try{if(!(i in t))return or;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 d(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=lr(e);n;){if(n.next===s)return void(n.next=r.next);n=lr(e=n.next)}else t[i]=r.next}}catch(t){return or}}var hr=di("[TracingHeaders]"),vr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],dr=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...vr],cr="<masked>",fr=["li_fat_id"];function pr(t,i,e){if(!oi)return{};var r,s,n,a=(r=Ve(oi.URL,[],cr),s=dr.concat([]),n={},ci(s,(function(t){var i=Ue(r,t);n[t]=i||null})),n),o=function(){var t={};return ci(fr,(function(i){var e=(t=>{if(oi){try{for(var i=t+"=",e=oi.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}();return fi(o,a)}function gr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var _r=di("[Web Vitals]"),br=9e5,mr=["CLS","FCP","INP","LCP"],yr=["INP","LCP"],wr=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Sr=di("[RemoteConfig]");class xr{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=er._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}do(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}vo(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 Sr.info("Using preloaded remote config",this.remoteConfig),void this.co(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Sr.warn("Remote config is disabled. Falling back to local config.");this.do((t=>{if(!t)return Sr.info("No config found after loading remote JS config. Falling back to JSON."),void this.vo((t=>{this.co(t.json,t)}));this.co(t)}))}catch(t){Sr.error("Error loading remote config",t),this.co()}}co(t,i){!t&&i&&(0===i.statusCode?i.error||Sr.warn("Failed to fetch remote config from PostHog."):Sr.error("Failed to fetch remote config from PostHog."));try{this._instance.co(t?{ok:!0,config:t}:{ok:!1})}catch(t){Sr.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){Sr.error("Error loading feature flags",t)}}}var kr="disabled",Er="lazy_loading",Fr="awaiting_config",Pr="missing_config";function Cr(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}ri.DEBUG=!1,ri.LIB_VERSION="1.426.2",ri.LIB_NAME="web";var Tr=(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}},Ar=t=>t.toLowerCase(),Rr={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=>Tr(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!Tr(i,t))))),icontains:(t,i)=>i.map(Ar).some((i=>t.map(Ar).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(Ar).every((i=>t.map(Ar).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 Or(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=Rr[e.operator];return!!s&&s(e.values,[String(r)])}))}di("[SessionRecording]"),di("[SessionRecording]");var Mr="[SessionRecording]",Ir=di(Mr),$r=di("[Heatmaps]");function jr(t){return c(t)&&"clientX"in t&&"clientY"in t&&y(t.clientX)&&y(t.clientY)}var Lr=di("[Product Tours]"),Dr=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(fe))},Nr=["$set_once","$set"],zr=di("[SiteApps]"),Br="Error while initializing PostHog app with config id ",Hr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Ur="events",Vr="cancelEvents",qr="survey shown",Wr=di("[Surveys]"),Kr="seenSurvey_",Jr=["popover","widget","api"],Gr="SDK is not enabled or survey functionality is not yet loaded",Xr="Disabled. Not loading surveys.";class Zr{constructor(t,i){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Eu=!1,this.Ru=[],this.Pu=null,this.Au=null,this.Os=!1,this.Fu=new Set,this.onRemoteConfig=t=>{if(!this.Os&&!this.mn.disableSurveys){if(!t.ok)return Wr.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(m(i))return Wr.warn("Flags not loaded yet. Not loading surveys.");this.Ou=w(i)?i:i.length>0,Wr.info("flags response received, isSurveysEnabled: "+this.Ou),this.loadIfEnabled()}},this.Ls=t,this.Lu=i}setup(t){if(!this.Os)return this.Du=t,Hr(t.kv.initialize(),(()=>{if(this.Du===t&&!this.Os){this.Du=void 0,this.Ns=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.Os?i.dispose():(this.qs=i,this.loadIfEnabled())}}))}dispose(){var t,i,e;this.Os||(this.Os=!0,this.Du=void 0,this.Ns=void 0,null==(t=this.qs)||t.dispose(),this.qs=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Ru=[],this.Pu=null,this.Fu.forEach((t=>clearTimeout(t))),this.Fu.clear())}get mn(){return this.Ls.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith(Kr)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this.Os&&this.Ns){var t=this.mn;if(!this._surveyManager)if(this.Eu)Wr.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Wr.info(Xr);else if(t.cookielessMode&&this.Ls.isOptedOut())Wr.info("Not loading surveys in cookieless mode without consent.");else{var i=this.Ls.getExtensions();if(i){if(!p(this.Ou)||t.advancedEnableSurveys){var e=this.Ou||t.advancedEnableSurveys;this.Eu=!0;try{var r=i.generateSurveys;if(r)return this.$u(r,e),void(this.Eu=!1);var s=i.loadExternalDependency;if(!s)return this.Nu(ze),void(this.Eu=!1);s((t=>{try{if(this.Os)return;var i=this.Ls.getExtensions();t||null==i||!i.generateSurveys?this.Nu("Could not load surveys script",t):this.$u(i.generateSurveys,e)}finally{this.Eu=!1}}))}catch(t){throw this.Eu=!1,this.Nu("Error initializing surveys",t),t}}}else Wr.error("PostHog Extensions not found.")}}}$u(t,i){this.Os||(this._surveyManager=t(i),this._surveyEventReceiver=this.Ls.createEventReceiver(),Wr.info("Surveys loaded successfully"),this.qu({isLoaded:!0}))}Nu(t,i){Wr.error(t,i),this.qu({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ru.push(t),this._surveyManager&&this.qu({isLoaded:!0}),()=>{this.Ru=this.Ru.filter((i=>i!==t))}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.Ns)&&void 0!==e?e:this.Lu;if(r&&!this.Os){if(this.mn.disableSurveys)return Wr.info(Xr),t([]);var s=r.kv.get(Te);if(s&&!i)return t(s,{isLoaded:!0}),void(this.ju()&&this.getSurveys((()=>{}),!0));if(this.Pu)this.Pu.then((i=>{this.Os||t(i.surveys,i.context)})).catch((t=>Wr.error("Error in survey callback",t)));else{var n=this.Bu("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.mn.requestTimeoutMs}).then((t=>{try{return this.Hu(r,t)}catch(t){return Wr.error("Error processing surveys response",t),this.Hu(r,{statusCode:0,error:t})}}),(t=>this.Hu(r,{statusCode:0,error:t})));this.Pu=n;var a=()=>{this.Pu===n&&(this.Pu=null)};n.then((i=>{a(),this.Os||t(i.surveys,i.context)}),a).catch((t=>Wr.error("Error in survey callback",t)))}}}Bu(t,i){var e=this.Ns;return e?e.sendRequest(t,i):new Promise((t=>t({statusCode:0,error:new Error(Gr)})))}Hu(t,i){if(this.Os)return{surveys:[],context:{isLoaded:!1,error:Gr}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?Wr.error(r):i.error||Wr.warn(r),this.Au=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Au=null;var s,n=i.json.surveys||[],a=n.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Cr(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t))));return a.length>0&&(null==(s=this._surveyEventReceiver)||s.register(a)),t.kv.set({[Te]:n,[Ae]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}ju(){return this.zu()&&!this.Pu&&!this.Uu()}zu(){var t,i,e=null==(t=null!==(i=this.Ns)&&void 0!==i?i:this.Lu)?void 0:t.kv.get(Ae);return y(e)&&Date.now()-e>3e5}Uu(){return y(this.Au)&&3e5>Date.now()-this.Au}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>""+Kr+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){Wr.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){}}qu(t){for(var i of this.Ru)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Wr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!m(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Wr.warn("init was not called")}Wu(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}Vu(t){if(m(this._surveyManager))return{eligible:!1,reason:Gr};var i="string"==typeof t?this.Wu(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Gu(t){if(m(this._surveyManager))return{eligible:!1,reason:Gr};var i="string"==typeof t?this.Wu(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(m(this._surveyManager))return Wr.warn("init was not called"),{visible:!1,disabledReason:Gr};var i=this.Gu(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return m(this._surveyManager)?(Wr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Gr})):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.Gu(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var r;if(m(this._surveyManager))Wr.warn("init was not called");else{var s="string"==typeof t?this.Wu(t):t;if(null!=s&&s.id)if(Jr.includes(s.type)){var n=null==oi?void 0:oi.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){Wr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout((()=>{var t,i;this.Fu.delete(a),this.Os||(Wr.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),Wr.info("Survey "+s.id+" rendered"))}),1e3*s.appearance.surveyPopupDelaySeconds);this.Fu.add(a)}else this._surveyManager.renderSurvey(s,n,e);else Wr.warn("Survey element not found")}else Wr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Wr.warn("Survey not found")}}displaySurvey(t,i){var r;if(m(this._surveyManager))Wr.warn("init was not called");else{var s=this.Wu(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&i.ignoreDelay&&(n=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&Wr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var a=this.Vu(s);if(!a.eligible)return void Wr.warn("Survey is not eligible to be displayed: ",a.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}else Wr.warn("Survey not found")}}cancelPendingSurvey(t){m(this._surveyManager)?Wr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}class Qr{on(t,i){return this.zo[t]||(this.zo[t]=[]),this.zo[t].push(i),()=>{this.zo[t]=this.zo[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.zo[t]||[])e(i);for(var r of this.zo["*"]||[])r(t,i)}constructor(){this.zo={}}}function Yr(t,i,e){if(m(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}class ts{constructor(t){this.Zu=new Set,this.Qu=new Set,this.Ju=new Qr,this.Ku=(t,i)=>this.Yu(t,i)&&this.Xu(t,i)&&this.th(t,i)&&this.eh(t,i),this.Yu=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t}init(){var t,i;p(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.ih=null==(i=this._instance)?void 0:i._addCaptureHook(((t,i)=>{this.on(t,i)})))}dispose(){var t;null==(t=this.ih)||t.call(this),this.ih=void 0,this.Ju=new Qr}register(t){var i,e;if(!p(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i;this.Zu.add(t),null==(i=t.steps)||i.forEach((t=>{this.Qu.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Zu.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&r.add(t.selector)}))})),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Zu.clear(),this.Qu.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Qu.has(t)||this.Qu.has(i.event))&&this.Zu.forEach((t=>{this.rh(i,t)&&this.Ju.emit("actionCaptured",t.name)}))}nh(t){this.onAction("actionCaptured",(i=>t(i)))}rh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Ku(t,e))return!0;return!1}onAction(t,i){return this.Ju.on(t,i)}Xu(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(!Yr(r,i.url,i.url_matching||"contains"))return!1}return!0}th(t,i){return!!this.sh(t,i)&&!!this.ah(t,i)&&!!this.oh(t,i)}sh(t,i){var e;if(null==i||!i.href)return!0;var r=this.lh(t);if(r.length>0)return r.some((t=>Yr(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&Yr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}ah(t,i){var e;if(null==i||!i.text)return!0;var r=this.lh(t);if(r.length>0)return r.some((t=>Yr(t.text,i.text,i.text_matching||"exact")||Yr(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;!m(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=>Yr(t,n,a))))}oh(t,i){var e,r;if(null==i||!i.selector)return!0;var s=null==t||null==(e=t.properties)?void 0:e.$element_selectors;if(null!=s&&s.includes(i.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&n)try{return new RegExp(i.selector_regex).test(n)}catch(t){return!1}return!1}lh(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}eh(t,i){return null==i||!i.properties||0===i.properties.length||Or(i.properties.reduce(((t,i)=>{var e=v(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class is{constructor(t){var i;this.uh=[],this._instance=t,this.hh=new Map,this.dh=new Map,this.fh=new Map,this.ph=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId((t=>this.gh(t)))}mh(t){return!1}yh(){return null}bh(t){}_h(){}wh(t,i){return!!t&&Or(t.propertyFilters,null==i?void 0:i.properties)}kh(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}Sh(t,i,e){var r=(e===Ur?this.hh:this.dh).get(t),s=[];return this.xh((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.wh(n,i)}))}register(t){this.Ch(t,!1)}replace(t){this.Ch(t,!0)}Ch(t,i){var e;p(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Th(t,i),this.Mh(t,i))}Mh(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.fh.clear(),0!==e.length){this.Ih||(this.Ih=new ts(this._instance),this.Ih.init(),this.Ih.nh((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.fh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.fh.set(i.name,s)}}))})),i?this.Ih.replace(r):this.Ih.register(r)}else{var s;i&&(null==(s=this.Ih)||s.replace([]))}}Eh(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)}))}Th(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.kh(t,Ur),o=this.kh(t,Vr);i?(this.hh=a,this.dh=o):(this.Eh(this.hh,a),this.Eh(this.dh,o)),(0!==s.length||0!==n.length)&&(null!==(e=this.ih)&&void 0!==e||(this.ih=null==(r=this._instance)?void 0:r._addCaptureHook(((t,i)=>{this.onEvent(t,i)}))))}onEvent(t,i){var e,r,s=this.Rh(),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.Ph(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Ah([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Fh(n),void this.Oh([n])}if(this.dh.has(t)){var o=this.Sh(t,i,Vr);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Ah(o.map((t=>t.id))),o.forEach((t=>this.Lh(t.id))))}if(this.hh.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.hh.get(t)});var l=this.Sh(t,i,Ur);this.Dh(l.map((t=>t.id)))}}onAction(t){this.fh.has(t)&&this.Dh(this.fh.get(t)||[])}Dh(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.mh(s)?this.Fh(s)&&this.$h(s):r.push(s);r.length>0&&(this.uh=[...new Set([...this.uh,...r])]),this.Rh().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Fh(t){this.uh=this.uh.filter((i=>i!==t));var i=this.Nh();return!i.includes(t)&&(this.qh([...i,t]),this.jh(),!0)}Ah(t){var i=new Set(t);this.uh=this.uh.filter((t=>!i.has(t)));var e=this.Bh(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.qh(r),0===r.length&&this.Hh()),this.Oh(t)}zh(){var t,i=this.yh();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}$h(t){if(this.yh()){var i=this.zh();this.bh(e({},i,{[t]:Date.now()}))}}Oh(t){if(this.yh()){var i=this.zh(),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&&(f(e)?this._h():this.bh(e))}}Uh(){this.yh()&&this._h()}getActivationTimestamp(t){if(this.Nh().includes(t)){var i=this.zh()[t];return y(i)?i:void 0}}Bh(){var t,i=this.Wh();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}Nh(){var t,i,e=this.Bh();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Vh()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}jh(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Gh(i)}Hh(){this.Zh()}gh(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Vh()];if(e&&e!==t){var r=this.Bh(),s=this.zh();r.length>0&&(this.qh([]),r.filter((t=>y(s[t]))).forEach((t=>this.Lh(t)))),this.Hh(),this.Uh()}}getActivatedIds(){return[...new Set([...this.Nh(),...this.uh])].filter((t=>!this.Qh(t)))}dispose(){var t,i,e;null==(t=this.ph)||t.call(this),this.ph=void 0,null==(i=this.ih)||i.call(this),this.ih=void 0,null==(e=this.Ih)||e.dispose(),this.Ih=void 0}reset(){this.uh=[],this.Bh().length>0&&this.qh([]),this.Hh(),this.Uh()}getEventToItemsMap(){return this.hh}Jh(){return this.Ih}}class es extends is{constructor(t){super(t)}Wh(){return Re}Vh(){return Oe}yh(){return Me}bh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Me]:t})}_h(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Me)}mh(t){var i,e;this.xh((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}Kh(){return qr}xh(t){var i;null==(i=this._instance)||i.getSurveys(t)}Lh(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Rh(){return Wr}qh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Re]:t})}Gh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Oe]:t})}Zh(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Oe)}Qh(){return!1}Ph(t,i){var e;this.xh((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return Cr(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===qr?"consume":"ignore":t===qr?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class rs{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);p(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach((t=>this._instance.unregister(t))):this._instance.unregister(t)}}class ss{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=null==er?void 0:er.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new es(this._instance)}}var ns=null!=si&&si.location?qe(si.location.hash,"__posthog")||qe(location.hash,"state"):null,as="_postHogToolbarParams",os=di("[Toolbar]"),ls=di("[FeatureFlags]");class us{constructor(t,i){void 0===i&&(i=!1),this.Yh=!1,this.update(t,i)}update(t,i){this.Xh=((t,i)=>{var e,r,s,n,a;return{bootstrap:{featureFlags:null==(e=t.bootstrap)?void 0:e.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(s=t.remote_config_refresh_interval_ms)&&void 0!==s?s:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(a=t.evaluation_contexts)&&void 0!==a?a:t.evaluation_environments)&&void 0!==n?n:[],flagKeys:v(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Yh||(ls.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Yh=!0),p(t.flag_keys)||v(t.flag_keys)||ls.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Xh}}var hs=di("[FeatureFlags]"),vs=di("[FeatureFlags]",{debugEnabled:!0}),ds="\" failed. Feature flags didn't load in time.",cs="connection_error",fs=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},ps=t=>{var i={};for(var e of pi(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},gs=di("[Error tracking]"),_s="webkit-masked-url:",bs=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",_s],ms=["__firefox__","__gCrWeb"],ys="Refusing to render web experiment since the viewer is a likely bot",ws={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Tr(i,t),not_regex:(t,i)=>!Tr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class Ss{get mn(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{Ss.td("retrieved web experiments from the server"),i.ed=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.ed&&(Ss.td("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.ed)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);g(r)&&t.variants[r]&&i.rd(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Ss.nd(n,i._instance)&&i.rd(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Ss.td(ys);else if(!this.mn.disable_web_experiments){if(m(this.ed))return this.ed=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ss.td("applying feature flags",t),t.forEach((t=>{var i;if(this.ed&&null!=(i=this.ed)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ed)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.rd(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Ss.getWindowLocation();if(null!=t&&t.search){var i=Ue(null==t?void 0:t.search,"__experiment_id"),e=Ue(null==t?void 0:t.search,"__experiment_variant");i&&e&&(Ss.td("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.sd(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.mn.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.mn.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.mn.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}sd(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(Ss.td("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.rd(r[0].name,i,r[0].variants[i].transforms))}static nd(t,i){return!m(t.conditions)&&Ss.ad(t,i)&&Ss.od(t)}static ad(t,i){var e;if(m(t.conditions)||m(null==(e=t.conditions)?void 0:e.url))return!0;var r=Ss.getWindowLocation();if(r){var s,n,a,o=mi(i,r.href);return null==(s=t.conditions)||!s.url||ws[null!==(n=null==(a=t.conditions)?void 0:a.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,o)}return!1}static getWindowLocation(){return null==si?void 0:si.location}static od(t){var i;if(m(t.conditions)||m(null==(i=t.conditions)?void 0:i.utm))return!0;var e=pr();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 td(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];vi.info("[WebExperiments] "+t,e)}rd(t,i,e){this._is_bot()?Ss.td(ys):"control"!==i?e.forEach((e=>{if(e.selector){var r;Ss.td("applying transform of variant "+i+" for experiment "+t+" ",e);var s=null==(r=document)?void 0:r.querySelectorAll(e.selector);null==s||s.forEach((t=>{var i=t;e.html&&(i.innerHTML=e.html),e.css&&i.setAttribute("style",e.css)}))}})):Ss.td("Control variants leave the page unmodified.")}_is_bot(){return ai&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&s(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>s(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver}(ai,this.mn.custom_blocked_useragents):void 0}}var xs=di("[Conversations]"),ks="Conversations not available yet.";function Es(t,i){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,c=null!=i&&i.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,f=p(c)?Math.max(v,2048):Math.max(v,c),g=e({},function(){var t="",i="";try{var r=null==ai?void 0:ai.userAgent;if(r){var s=function(t){for(var i=0;V.length>i;i++){var e=V[i],r=e[1],s=e[0].exec(t),n=s&&(d(r)?r(s,t):r);if(n)return n}return["",""]}(r);t=s[0],i=s[1]}}catch(t){}return function(t,i){var r=function(t){if(t)return{}.hasOwnProperty.call(qt,t)?qt[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(a=null!==(o=null==g?void 0:g["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==a?a:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==g?void 0:g["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(u=null==g?void 0:g["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:g,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:v,maxQueueSize:f,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:c,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Fs=["debug","log","warn","error","info"],Ps="console",Cs="__posthogHandledLogsRequestError",Ts=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Cs]=!0,e},As=t=>!!t&&"object"==typeof t&&!0===t[Cs],Rs={featureFlags:class{constructor(t){this.name="featureFlags",this.ld=!1,this.featureFlagEventHandlers=[],this.A=hs,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.Wt=()=>{var t=this.wd();this._d=0,t&&this.reloadFeatureFlags()},this.kd=()=>{var t,i=this.Sd;p(i)||this.mn.remoteRequestsDisabled||!oi||"hidden"===oi.visibilityState||Date.now()-(null!==(t=this.xd)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Cd())},this.Vt=()=>{"visible"===(null==oi?void 0:oi.visibilityState)&&this.kd()},"get"in t?this.Ls=t:(this._instance=t,this.Td=new us(t.config,t._shouldDisableFlags()),this.Ls=this.Td)}updateConfig(t,i){var e;null==(e=this.Td)||e.update(t,i),this.Ns&&this.Md()}setup(t){return this.Du=t,this.A=t.logger.createLogger("[FeatureFlags]"),Hr(t.kv.initialize(),(()=>{this.Du===t&&(this.Du=void 0,this.Ns=t,this.Id(t))}))}Id(t){var i;if(this.Ns===t)return si&&_i(si,"online",this.Wt),this.Md(),this.Ed=t.registerDynamicEventProperties((()=>this.Rd()?this.ud:this.hd)),this.Pd=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange((()=>{this.Ad(),this.Fd()})),this.Ad(),this.initialize()}Md(){var t=this.mn.refreshIntervalMs,i=!this.mn.remoteRequestsDisabled&&oi&&!p(t)&&t>0?t:void 0;i!==this.Sd&&(this.Od(),p(i)||(this.Sd=i,this.Cd(),null!=oi&&oi.addEventListener&&_i(oi,Be,this.Vt)))}Cd(){p(this.Sd)||(p(this.Ld)||clearInterval(this.Ld),this.xd=Date.now(),this.Ld=setInterval(this.kd,this.Sd))}Od(){p(this.Ld)||(clearInterval(this.Ld),this.Ld=void 0,null==oi||null==oi.removeEventListener||oi.removeEventListener(Be,this.Vt)),this.Sd=void 0,this.xd=void 0}destroy(){this.Dd()}dispose(){this.Dd()}Dd(){var t,i;this.Od(),this.pd++,this.md=!1,this.Du=void 0,this.Ns&&(this.$d(),null==(t=this.Ed)||t.dispose(),this.Ed=void 0,null==(i=this.Pd)||i.call(this),this.Pd=void 0,this.dd=[],null==si||si.removeEventListener("online",this.Wt),this.Ns=void 0)}get mn(){return this.Ls.get()}Nd(t){var i;return null==(i=this.Ns)?void 0:i.kv.get(t)}ni(t){this.qd((()=>{var i;return null==(i=this.Ns)?void 0:i.kv.set(t)}))}jd(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t[be]){var s=this.Nd(be)||{},n=t[be]||{},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&&!v(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),h=this.Nd(Se)||{},d=t[Se]||{},c=l||e?u:Array.from(new Set([...Object.keys(h),...Object.keys(d)])),f=!l&&!e,g=!!f||u,_={[me]:g,[be]:g,[Se]:!!f||c};for(var b of(t[we]&&(_[we]=g),[xe,De,ke]))p(t[b])||(_[b]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(_)}}oi(t){this.qd((()=>{var i;return null==(i=this.Ns)?void 0:i.kv.remove(t)}))}qd(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}Ad(){var t={};for(var i of[me,Se,xe,Ee]){var r=this.Nd(i);p(r)||(t[i]=r)}this.ud=t;var s=e({},t),n=this.Nd(be);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.hd=s}Rd(){var t=this.mn.cacheTtlMs;if(!t||0>=t)return!1;var i=this.Nd(De);return"number"!=typeof i||Date.now()-i>t}Bd(){return!!this.Rd()&&(this.bd||this.fd||(this.bd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Hd(){var t=this.mn.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})):[]}zd(){var t=this.mn.flagKeys;if(!p(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.mn,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=>!p(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.Ud({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,i,r){var s,n,a=null!=r&&r.merge&&null!==(s=this.Nd(be))&&void 0!==s?s:{},o=null!=r&&r.merge&&null!==(n=this.Nd(Se))&&void 0!==n?n:{},l=e({},a,t),u=e({},o,i),h={};for(var v of Object.entries(l)){var d=v[0],c=v[1];h[d]={key:d,enabled:$t(c),variant:jt(c),reason:void 0,metadata:p(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}}}this.Ud({flags:h})}get hasLoadedFlags(){return this.vd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Nd(we),i=this.Nd(Ee),r=this.Nd(Fe);if(!r&&!i)return t||{};var s=fi({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(i||{})])];for(var a of n){var o,l,u=s[a],h=null==i?void 0:i[a],v=p(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=p(h)?null==u?void 0:u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=e({},u,{enabled:v,variant:v?null!=d?d:null==u?void 0:u.variant:void 0});v!==(null==u?void 0:u.enabled)&&(f.original_enabled=null==u?void 0:u.enabled),d!==(null==u?void 0:u.variant)&&(f.original_variant=null==u?void 0:u.variant),c&&(f.metadata=e({},null==u?void 0:u.metadata,{payload:c,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[a]=f}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:$t(r),variant:jt(r),payload:It(i[e])}}))}getFlagVariants(){var t=this.Nd(be),i=this.Nd(Ee);if(!i)return t||{};for(var e=fi({},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.Nd(Se),i=this.Nd(Fe);if(!i)return t||{};for(var e=fi({},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.mn.featureFlagsDisabled||this.wd()||(this.fd&&(this.md=!0),this.Wd||(this.dd.slice().forEach((t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}})),this.Wd=setTimeout((()=>{this.Vd()}),5)))}$d(){clearTimeout(this.Wd),this.Wd=void 0}onReloading(t){return this.dd.push(t),()=>{this.dd=this.dd.filter((i=>i!==t))}}ensureFlagsLoaded(){this.vd||this.fd||this.Wd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.gd=t}resetFlagCallReported(){this.oi($e)}Vd(t){this.$d();var i=this.Ns;if(i&&!this.mn.remoteRequestsDisabled&&!this.wd())if(this.fd)this.md=!0;else{var r={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:e({},i.initialPersonProperties,this.Nd(Pe)||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.Nd(Ce),timezone:gr()};p(i.deviceId)||(r.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.mn.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this.Hd();s.length&&(r.evaluation_contexts=s);var n=this.zd();p(n)||(r.flag_keys=n);var a=this.mn.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.Vd())},h=t=>{this.fd=!1,l===this.pd?(this.ni({[Le]:[cs]}),this.A.error("Feature flag request failed",t),u()):u()};try{i.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.mn.compression,sentAt:"body",timeoutMs:this.mn.requestTimeoutMs}).then((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.Gd(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?cs:"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.ni({[Le]: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.Ud(s,n,{partialResponse:a}),u()}}else u()})).catch(h)}catch(t){h(t)}}}wd(){return We(this._d,3)}Gd(t){this._d=Ke(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.Bd()){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+ds)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.yd)if(this.vd||this.getFlags()&&this.getFlags().length>0){if(!this.Bd()){var r,s=this.getFlagVariants(),n=t in s,a=s[t],o=this.getFlagPayloads()[t],l=String(a),u=this.Nd(xe)||void 0,h=this.Nd(De)||void 0,d=this.Nd($e)||{};if(this.mn.deduplicateCallsPerSession){var c,f=null==(c=this.Ns)?void 0:c.session.sessionId,g=this.Nd(je);f&&f!==g&&(d={},r=f)}if(i.send_event||!("send_event"in i))if(t in d&&d[t].includes(l))r&&this.ni({[$e]:d,[je]:r});else{var _,b,m,y,w,S,x,k,E,F,P,C;v(d[t])?d[t].push(l):d[t]=[l],this.ni(e({[$e]:d},r?{[je]:r}:{}));var T=this.getFeatureFlagDetails(t),A=[...null!==(_=this.Nd(Le))&&void 0!==_?_:[]];p(a)&&A.push("flag_missing");var R={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:null!==(b=null==(m=this.mn.bootstrap)||null==(m=m.featureFlags)?void 0:m[t])&&void 0!==b?b:null,$feature_flag_bootstrapped_payload:null!==(y=null==(w=this.mn.bootstrap)||null==(w=w.featureFlagPayloads)?void 0:w[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.yd};p(null==T||null==(S=T.metadata)?void 0:S.has_experiment)||(R.$feature_flag_has_experiment=T.metadata.has_experiment),p(null==T||null==(x=T.metadata)?void 0:x.version)||(R.$feature_flag_version=T.metadata.version);var O,M=null!==(k=null==T||null==(E=T.reason)?void 0:E.description)&&void 0!==k?k:null==T||null==(F=T.reason)?void 0:F.code;M&&(R.$feature_flag_reason=M),null!=T&&null!=(P=T.metadata)&&P.id&&(R.$feature_flag_id=T.metadata.id),p(null==T?void 0:T.original_variant)&&p(null==T?void 0:T.original_enabled)||(R.$feature_flag_original_response=p(T.original_variant)?T.original_enabled:T.original_variant),null!=T&&null!=(C=T.metadata)&&C.original_payload&&(R.$feature_flag_original_payload=null==T||null==(O=T.metadata)?void 0:O.original_payload),A.length&&(R.$feature_flag_error=A.join(",")),this.Zd(R)}else r&&this.ni({[$e]:d,[je]:r});if(n)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:It(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+ds)}Zd(t){try{var i;null==(i=this.Ns)||i.capture("$feature_flag_called",t).catch((t=>{this.A.error("Failed to capture feature flag call",t)}))}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Qd(t,i)}Qd(t,e){var r=this;return i((function*(){var i=r.Ns;if(i){var s={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=r.Hd();n.length&&(s.evaluation_contexts=n);var a,o=r.zd();p(o)||(s.flag_keys=o);try{var l,u=null==(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:r.mn.compression,sentAt:"body",timeoutMs:r.mn.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;a=(null==u?void 0:u[t])||void 0}catch(t){return void r.A.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){r.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+ds),i.defaultValue;var e=this.getFeatureFlag(t,i);return p(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.Ud(t,i,e)}Ud(t,i,r){if(this.Ns){this.vd=!0;var s=function(t,i,r,s,n,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===s&&(s={}),void 0===a&&(a=hs);var o=((t,i)=>{var r=t.flags;return r?e({},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!p(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&&i.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,h=o.featureFlagPayloads;if(u){var d=t.requestId,c=t.evaluatedAt;if(v(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var f={};if(u)for(var g=0;u.length>g;g++)f[u[g]]=!0;return{[me]:u,[be]:f,[ke]:!1}}var _=u,b=h,m=l;if(null!=n&&n.partialResponse){var y=Object.keys(_),w=b||{};_=e({},i,_),b=e({},r,w),y.forEach((t=>{var i;t in w||null==(i=b)||delete i[t]})),m=e({},s,m)}else if(t.errorsWhileComputingFlags)if(l){var S=new Set(Object.keys(l).filter((t=>{var i;return!(null!=(i=l[t])&&i.failed)})));_=e({},i,Object.fromEntries(Object.entries(_).filter((t=>S.has(t[0])))));var x=Object.fromEntries(Object.entries(b||{}).filter((t=>S.has(t[0]))));b=e({},r,x),S.forEach((t=>{var i;t in x||null==(i=b)||delete i[t]})),m=e({},s,Object.fromEntries(Object.entries(m||{}).filter((t=>S.has(t[0])))))}else _=e({},i,_),b=e({},r,b),m=e({},s,m);return e({[me]:Object.keys(ps(_)),[be]:_||{},[Se]:b||{},[we]:m||{},[ke]:!0===t.minimalFlagCalledEvents},d?{[xe]:d}:{},c?{[De]:c}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.A);s&&(this.jd(s,t,!(null==r||!r.partialResponse)),this.ni(s)),i||(this.bd=!1),this.Fd(i)}}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.Jd(t)}Jd(t){if(this.Ns){if(!1===t)return this.oi([Ee,Fe]),this.Fd(),void vs.info("All overrides cleared");if(v(t))return this.ni({[Ee]:fs(t)}),this.Fd(),void vs.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[Ee]=v(s)?fs(s):s),n&&(r[Fe]=n),Object.keys(r).length&&this.ni(r),!1===s&&!1===n?this.oi([Ee,Fe]):!1===s?this.oi(Ee):!1===n&&this.oi(Fe),this.Fd(),!1===s?vs.info("Flag overrides cleared"):s&&vs.info("Flag overrides set",{flags:s}),void(!1===n?vs.info("Payload overrides cleared"):n&&vs.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.ni({[Ee]:t}),this.Fd(),void vs.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.Kd(),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,i,r){var s,n=(this.Nd(ye)||[]).find((i=>i.flagKey===t)),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r);var l=e({},this.getFlagVariants(),{[t]:i});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[me]:[t],[be]:[t],[Pe]:Object.keys(a)}),this.ni({[me]:Object.keys(ps(l)),[be]:l,[Pe]:e({},this.Nd(Pe)||{},a)}),this.Fd();try{var u;null==(u=this.Ns)||u.capture("$feature_enrollment_update",o).catch((t=>{this.A.error("Failed to capture early access feature enrollment",t)}))}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.Nd(ye);!r||i?this.Yd(t,e):t(r)}Yd(t,e){var r=this;return i((function*(){var i=r.Ns;if(i){var s,n=e?"&"+e.map((t=>"stage="+t)).join("&"):"";try{var a=yield i.sendRequest("/api/early_access_features/?token="+i.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;r.ni({[ye]:s=a.json.earlyAccessFeatures})}catch(t){return void r.A.error("Early access feature request failed",t)}try{t(s)}catch(t){r.A.error("Early access feature callback failed",t)}}}))()}Kd(){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)),{})}}Fd(t){this.Ad();var i=this.Kd(),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.Xd(t,i)}Xd(t,i){void 0===i&&(i=!0);var r=this.Nd(Pe)||{},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.ni({[Pe]:e({},r,a,s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.Nd(Pe)||{});t.forEach((t=>{delete r[t]})),this.ni({[Pe]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.oi(Pe),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.Nd(Ce)||{},s=e({},r);for(var n of Object.keys(t))s[n]=e({},r[n],t[n]);this.ni({[Ce]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.Nd(Ce)||{};this.ni({[Ce]:e({},i,{[t]:{}})})}else this.oi(Ce)}reset(){this.pd++,this.md=!1,this.ud={},this.hd={},this.vd=!1,this.gd=!1,this.yd=!1,this.$anon_distinct_id=void 0,this.$d(),this.ld=!1,this._d=0}}},Os={sessionRecording:class{get mn(){return this._instance.config}get Bo(){return this._instance.persistence}get started(){var t;return!(null==(t=this.tv)||!t.isStarted)}get status(){var t,i;return this.ev===Fr||this.ev===Pr?this.ev:null!==(t=null==(i=this.tv)?void 0:i.status)&&void 0!==t?t:this.ev}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.ev=kr,this.iv=void 0,this.rv=!1,this.jt=(()=>{var t;if(null==oi||!oi.visibilityState||"visible"===oi.visibilityState)return!0;var i=null==si||null==(t=si.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some((t=>"visible"===t.name))})(),this.Vt=()=>{var t;"visible"===(null==oi?void 0:oi.visibilityState)&&(this.jt=!0,null==(t=this.tv)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=t,!this._instance.sessionManager)throw Ir.error("started without valid sessionManager"),new Error(Mr+" started without valid sessionManager. This is a bug.");if("always"===this.mn.cookieless_mode)throw new Error(Mr+' cannot be used with cookieless_mode="always"');null!=oi&&oi.addEventListener&&_i(oi,"visibilitychange",this.Vt)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.rv=!0,null==oi||null==oi.removeEventListener||oi.removeEventListener("visibilitychange",this.Vt),e?this.nv(!0):this.stopRecording()}get sv(){var t,i=!(null==(t=this._instance.get_property(_e))||!t.enabled),e=!this.mn.disable_session_recording,r=this.mn.disable_session_recording||this._instance.consent.isOptedOut();return si&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.rv||this.sv&&null!=(i=this.tv)&&i.isStarted)){var e=!p(Object.assign)&&!p(Array.from);this.sv&&e?(this.av(t),Ir.info("starting")):(this.ev=kr,this.stopRecording())}}av(t){var i,e;if(this.sv)if(this.ev!==Fr&&this.ev!==Pr&&(this.ev=Er),null!=er&&null!=(i=er.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=er.__PosthogExtensions__)&&e.initSessionRecording)this.ov(t);else{var r,s=this._instance.sessionManager;null==(r=er.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.lv,(i=>{if(!this.rv&&this.sv&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[Ne]:!0}),Ir.error("could not load recorder",i)):void this.ov(t);this.ev=kr}))}}stopRecording(){var t,i;null==(t=this.iv)||t.call(this),this.iv=void 0,null==(i=this.tv)||i.stop()}nv(t){var i,e;void 0===t&&(t=!1),null==(i=this.iv)||i.call(this),this.iv=void 0,null==(e=this.tv)||e.discard({discardProducerEvents:t})}uv(){var t,i;null==(t=this.Bo)||t.unregister("$session_is_sampled"),null==(i=this.Bo)||i.unregister("$replay_sample_rate")}hv(t,i){if(m(t))return null;var e,r=y(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Ir.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}dv(t){if(this.Bo){var i,r,s=this.Bo,n=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.hv(null==(i=this.mn.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.hv(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;m(o)&&this.uv();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[_e]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({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:p(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==(i=this.iv)||i.call(this),this.iv=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.dv(i),void this.nv()):(this.dv(i),void this.startIfEnabledOrStop()):(this.ev===Fr&&(this.ev=Pr,Ir.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.tv)&&e.log?this.tv.log(t,i):Ir.warn("log called before recorder was ready")}get lv(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(_e);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}vv(){var t,i=this._instance.get_property(_e);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return Ir.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!m(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}ov(t){var i,e,r;if(!this.rv&&this.sv&&this._instance.sessionManager){if(null==(i=er.__PosthogExtensions__)||!i.initSessionRecording)return Ir.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Ne]:!0});var s;if(this.tv||(this.tv=null==(s=er.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.jt),this.tv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.vv()){if(this.ev===Pr||this.ev===Fr)return;return this.ev=Fr,Ir.info("persisted remote config is stale, requesting fresh config before starting"),void new xr(this._instance).load()}this.ev=Er,null==(e=(r=this.tv).setDocumentWasEverVisible)||e.call(r,this.jt),this.tv.start(t)}else this.ev=kr}onRRwebEmit(t){var i;null==(i=this.tv)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.tv||null==(i=this.Bo)||i.register({$replay_override_linked_flag:!0}),null==(t=this.tv)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.tv||null==(i=this.Bo)||i.register({$replay_override_sampling:!0}),null==(t=this.tv)||t.overrideSampling()}overrideTrigger(t){var i,e;this.tv||null==(e=this.Bo)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.tv)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.tv)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.tv)||!e.tryAddCustomEvent(t,i))}}},Ms={autocapture:class extends Ye{constructor(t){super(new tr(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.fv=this.pv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.gv();return!!(t.path||t.search||this.mv(t))}startIfEnabled(){this.isEnabled&&(vi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.fv=this.pv(),this.startIfEnabled()}stop(){this.yv&&this.yv(),this.yv=void 0,this.bv&&this.bv(),this.bv=void 0,vi.info("History API monitoring stopped")}monitorHistoryChanges(){si&&si.history&&(this._v("pushState"),this._v("replaceState"),this.wv(),this.mv()&&this.Sv())}_v(t){var i;if(si&&(null==(i=si.history[t])||!i.__posthog_wrapped__)){var e=this;ur(si.history,t,(i=>function(r,s,n){i.call(this,r,s,n),e.xv(t)}))}}pv(){var t=null==si?void 0:si.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}gv(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:c(t)?t:{}}mv(t){return void 0===t&&(t=this.gv()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Cv(t){var i=this.gv(),e=this.fv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.mv(i)&&t.hash!==e.hash))}xv(t){try{var i=this.pv();if(!i)return;this.Cv(i)&&this._instance.capture("$pageview",{navigation_type:t}),this.fv=i}catch(i){vi.error("Error capturing "+t+" pageview",i)}}wv(){if(!this.yv){var t=()=>{this.xv("popstate")};_i(si,"popstate",t),this.yv=()=>{si&&si.removeEventListener("popstate",t)}}}Sv(){if(!this.bv){var t=()=>{this.xv("hashchange")};_i(si,"hashchange",t),this.bv=()=>{si&&si.removeEventListener("hashchange",t)}}}},heatmaps:class{get mn(){return this.instance.config}constructor(t){var i;this.Tv=!1,this.Rs=!1,this.Mv=null,this.instance=t,this.Tv=!(null==(i=this.instance.persistence)||!i.props[ue]),this.rageclicks=new oe(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return c(this.mn.capture_heatmaps)&&this.mn.capture_heatmaps.flush_interval_milliseconds&&(t=this.mn.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return m(this.mn.capture_heatmaps)?m(this.mn.enable_heatmaps)?this.Tv:this.mn.enable_heatmaps:!1!==this.mn.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Rs)return;$r.info("starting..."),this.Iv(),this.Vt()}else{var t;clearInterval(null!==(t=this.Mv)&&void 0!==t?t:void 0),this.Ev(),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({[ue]:e}),this.Tv=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Pt;return this.Pt=void 0,t}Rv(t){jr(t.originalEvent)&&this.Xi(t.originalEvent,"deadclick")}Vt(){this.Mv&&clearInterval(this.Mv),this.Mv="visible"===(null==oi?void 0:oi.visibilityState)?setInterval(this.Po.bind(this),this.flushIntervalMilliseconds):null}Iv(){si&&oi&&(this.Pv=this.Po.bind(this),_i(si,He,this.Pv),this.Av=t=>this.Xi(t||(null==si?void 0:si.event)),_i(oi,"click",this.Av,{capture:!0}),this.Fv=t=>this.Ov(t||(null==si?void 0:si.event)),_i(oi,"mousemove",this.Fv,{capture:!0}),this.Lv=new nr(this.instance,sr,this.Rv.bind(this)),this.Lv.startIfEnabledOrStop(),this.Dv=this.Vt.bind(this),_i(oi,Be,this.Dv),this.Rs=!0)}Ev(){var t;si&&oi&&(this.Pv&&si.removeEventListener(He,this.Pv),this.Av&&oi.removeEventListener("click",this.Av,{capture:!0}),this.Fv&&oi.removeEventListener("mousemove",this.Fv,{capture:!0}),this.Dv&&oi.removeEventListener(Be,this.Dv),clearTimeout(this.$v),null==(t=this.Lv)||t.stop(),this.Rs=!1)}Nv(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&&Ei(r)&&!Fi(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:si)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(n(i,s))return!0;r=Di(r)}return!1}($i(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:e),target_fixed:a,type:i}}Xi(t,i){var r;if(void 0===i&&(i="click"),!ki(t.target)&&jr(t)){var s=this.Nv(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Vi($i(t),this.instance.config.rageclick)&&this.ks(e({},s,{type:"rageclick"})),this.ks(s)}}Ov(t){!ki(t.target)&&jr(t)&&(clearTimeout(this.$v),this.$v=setTimeout((()=>{this.ks(this.Nv(t,"mousemove"))}),500))}ks(t){if(si){var i=this.mn.disable_capture_url_hashes?Y(si.location.href):si.location.href,e=this.mn.custom_personal_data_properties,r=this.mn.mask_personal_data_properties?[...vr,...e||[]]:[],s=Ve(i,r,cr);this.Pt=this.Pt||{},this.Pt[s]||(this.Pt[s]=[]),this.Pt[s].push(t)}}Po(){this.Pt&&!f(this.Pt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:nr,webVitalsAutocapture:class{constructor(t){var i;this.Tv=!1,this.Rs=!1,this.Pt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.qv=()=>{clearTimeout(this.jv),this.jv=void 0,0!==this.Pt.metrics.length&&(this._instance.capture("$web_vitals",e({$current_url:this.Pt.url},this.Pt.metrics.reduce(((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.Pt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Bv=t=>{var i;if(this.Pt=this.Pt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},m(null==t?void 0:t.name)||m(null==t?void 0:t.value))_r.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Hv(r);if(!p(s)){var n=y(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.zv||this.zv>t.value){this.Pt.navigationKey!==n&&(this.qv(),this.jv=setTimeout(this.qv,this.flushToCaptureTimeoutMs)),p(this.Pt.navigationKey)&&(this.Pt.navigationKey=n,this.Pt.url=s),this.Pt.firstMetricTimestamp=p(this.Pt.firstMetricTimestamp)?Date.now():this.Pt.firstMetricTimestamp;var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,c(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of wr){var h="url"===u&&"string"==typeof t.attribution[u]?this.Hv(t.attribution[u]):t.attribution[u];p(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;p(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.Pt.metrics.push(o),this.Pt.metrics.length===this.allowedMetrics.length&&this.qv()}else _r.error("Ignoring metric with value >= "+this.zv,t)}}},this.Uv=()=>{if(!this.Rs){var t,i,r,s,n=!1,a=er.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Wv])||("web-vitals"===this.Wv&&p(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!p(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!p(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,i=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&&i&&r&&s){var v={reportSoftNavs:this.useSoftNavs},d=n&&this.attributionMetrics.indexOf("INP")>-1?e({},v,{includeProcessedEventEntries:!1}):v;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Bv.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Bv.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Bv.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.Bv.bind(this),d),this.Rs=!0}else _r.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Tv=!(null==(i=this._instance.persistence)||!i.props[ce]),this.startIfEnabled()}get Vv(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=c(this.Vv)?null==(t=this.Vv)?void 0:t.web_vitals_allowed_metrics:void 0;return m(e)?(null==(i=this._instance.persistence)?void 0:i.props[ge])||mr:e}get flushToCaptureTimeoutMs(){return(c(this.Vv)?this.Vv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=c(this.Vv)?this.Vv.web_vitals_attribution:void 0;return w(t)?t?mr:[]:v(t)?t:yr}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t=c(this.Vv)?this.Vv.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get zv(){var t=c(this.Vv)&&y(this.Vv.__web_vitals_max_value)?this.Vv.__web_vitals_max_value:br;return t>0&&6e4>=t?br:t}get isEnabled(){var t=null==li?void 0:li.protocol;if("http:"!==t&&"https:"!==t)return _r.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=c(this.Vv)?this.Vv.web_vitals:w(this.Vv)?this.Vv:void 0;return w(i)?i:this.Tv}startIfEnabled(){this.isEnabled&&!this.Rs&&(_r.info("enabled, starting..."),this.Ys(this.Uv))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=c(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=c(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ce]:e}),this._instance.persistence.register({[ge]:r})),this.Tv=e,this.startIfEnabled()}}}get Wv(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ys(t){var i=er.__PosthogExtensions__,e=this.Wv,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&p(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?_r.error("failed to load script",i):t()}))}Hv(t){var i=t||(null==si?void 0:si.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?Y(i):i,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...vr,...r||[]]:[];return Ve(e,s,cr)}_r.error("Could not determine current URL")}}},Is={exceptionObserver:class{constructor(t){var i;this.Uv=()=>{var t;if(si&&this.isEnabled&&null!=(t=er.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=er.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=er.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=er.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Gv&&this.mn.capture_unhandled_errors&&(this.Gv=i(this.captureException.bind(this))),!this.Zv&&this.mn.capture_unhandled_rejections&&(this.Zv=e(this.captureException.bind(this))),!this.Qv&&this.mn.capture_console_errors&&(this.Qv=r(this.captureException.bind(this)))}catch(t){ar.error("failed to start",t),this.Jv()}}},this._instance=t,this.Kv=!(null==(i=this._instance.persistence)||!i.props[he]),this.pe=new T(e({},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:ar})),this.mn=this.Yv(),this.startIfEnabledOrStop()}Yv(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return c(t)?i=e({},i,t):(p(t)?this.Kv:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.mn.capture_console_errors||this.mn.capture_unhandled_errors||this.mn.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ar.info("enabled"),this.Jv(),this.Ys(this.Uv)):this.Jv()}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return ar.error("failed to load script",i);t()}))}Jv(){var t,i,e;null==(t=this.Gv)||t.call(this),this.Gv=void 0,null==(i=this.Zv)||i.call(this),this.Zv=void 0,null==(e=this.Qv)||e.call(this),this.Qv=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Kv=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[he]:this.Kv}),this.mn=this.Yv(),this.startIfEnabledOrStop())}}onConfigChange(){this.mn=this.Yv()}captureException(t){var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";this.pe.consumeRateLimit(s)?ar.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var i,r;this.Xv=[],this.tc=new st([new gt,new Ft,new bt,new _t,new kt,new xt,new yt,new Et],function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),s=1;i>s;s++)r[s-1]=arguments[s];return function(i,s){void 0===s&&(s=0);for(var n=[],a=i.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=pt.test(l)?l.replace(pt,"$1"):l;if(!u.match(/\S*Error: /)){for(var h of r){var v=h(u,t);if(v){n.push(v);break}}if(n.length>=50)break}}}return function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map((t=>{return e({},t,{filename:t.filename||(r=i,r[r.length-1]||{}).filename,function:t.function||nt});var r}))}(n)}}("web:javascript",vt,ft)),this._instance=t,this.Xv=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property(ve))&&void 0!==i?i:[],this.ec=Rt(this.ic()),this.rc=new Ot(this.ec)}onConfigChange(){this.ec=Rt(this.ic()),this.rc.setConfig(this.ec)}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.Xv=n,this._instance.persistence&&this._instance.persistence.register({[ve]:this.Xv,[de]:a})}}}get nc(){var t,i=!!this._instance.get_property(de),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.tc.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.ec.enabled)try{if(!g(t)||0===t.trim().length)return void gs.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)=>Tt.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.sc(i)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&gs.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.rc.add(e({[Pt]:t,[Ct]:(new Date).toISOString()},s))}catch(t){gs.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.ac(i)){if(this.oc(i))return this.lc("Exception dropped: matched a suppression rule"),void gs.info("Skipping exception capture because a suppression rule matched");if(!this.nc&&this.uc(i))return this.lc("Exception dropped: thrown by a browser extension"),void gs.info("Skipping exception capture because it was thrown by an extension");if(!this.nc&&this.hc(i))return this.lc("Exception dropped: thrown by an injected browser script"),void gs.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.dc(i))return this.lc("Exception dropped: thrown by the PostHog SDK"),void gs.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.ec.enabled&&m(t.$exception_steps)?this.vc(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.rc.clear(),s}catch(t){return gs.error("Failed to capture exception event. Dropping this exception.",t),void this.rc.clear()}}catch(t){return void gs.error("Failed to process exception event. Ignoring this exception.",t)}var n}vc(t){try{var i=this.rc.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(i){return gs.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}lc(t){this.ec.enabled&&this.rc.add({[Pt]:t,[Ct]:(new Date).toISOString()})}sc(t){return c(t)?e({},t):{}}ic(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}oc(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return g(e)&&e.length>0&&t.$exception_types.push(e),g(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Xv.some((t=>{var e=t.values.map((t=>{var e=Rr[t.operator],r=i[t.key];if(!e||!r)return!1;var s=v(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 gs.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}uc(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&&bs.some((t=>i.startsWith(t)))}));return 0!==e.length&&(!e.every((t=>{var i=t.filename;return!!i&&i.startsWith(_s)}))||t.some((t=>{var i=t.value;return g(i)&&i.includes("isolatedAPI.contexts.topHostname")}))&&!i.some((t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(_s))})))}hc(t){return t.some((t=>{var i=t.value;return g(i)&&ms.some((t=>i.includes(t)))}))}dc(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:[],a=n[n.length-1];return null!==(r=null==a||null==(s=a.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ac(t){return!m(t)&&v(t)}}},$s=e({productTours:class{get Bo(){return this._instance.persistence}constructor(t){this.cc=null,this.fc=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.Bo&&this.Bo.register({[fe]:!!i.productTours}),!Dr(this._instance))return!this.cc&&m(null==(e=this.Bo)?void 0:e.props[Ie])||Lr.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.cc)||r.stop(),this.cc=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.cc&&Dr(this._instance)&&this.Ys((()=>this.gc()))}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?Lr.error("Could not load product tours script",i):t()}))}gc(){var t;!this.cc&&null!=(t=er.__PosthogExtensions__)&&t.generateProductTours&&(this.cc=er.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!v(this.fc)||i){var e=this.Bo;if(e){var r=e.props[Ie];if(v(r)&&!i)return this.fc=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(Dr(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||Lr.warn(s):Lr.error(s),void t([],{isLoaded:!1,error:s})}var n=v(i.json.product_tours)?i.json.product_tours:[];this.fc=n,e&&e.register({[Ie]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.fc,{isLoaded:!0})}getActiveProductTours(t){m(this.cc)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.cc.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.cc)||i.showTourById(t)}previewTour(t){this.cc?this.cc.previewTour(t):this.Ys((()=>{var i;this.gc(),null==(i=this.cc)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.cc)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.cc)||t.nextStep()}previousStep(){var t;null==(t=this.cc)||t.previousStep()}clearCache(){var t;this.fc=null,null==(t=this.Bo)||t.unregister(Ie)}resetTour(t){var i;null==(i=this.cc)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.cc)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.cc)||i.cancelPendingTour(t)}}},Rs),js={siteApps:class{constructor(t){this.mc=0,this._instance=t,this.yc=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}bc(t,i){if(i){var e=this.globalsForEvent(i);this.yc.push(e),this.yc.length>1e3&&(this.yc=this.yc.slice(10))}}get siteAppLoaders(){var t;return null==(t=er._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.bc.bind(this));this._c=()=>{t(),this.yc=[],this._c=void 0}}}globalsForEvent(t){var i,r,s,n,a,o,l;if(!t)throw new Error("Event payload is required");var u={},h=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(v)){var c=d[0];u[c]={id:h[c],type:c,properties:d[1]}}var f=t.$set_once,p=t.$set;return{event:e({},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}(t,Nr),{properties:e({},t.properties,p?{$set:e({},null!==(i=null==(r=t.properties)?void 0:r.$set)&&void 0!==i?i:{},p)}:{},f?{$set_once:e({},null!==(s=null==(n=t.properties)?void 0:n.$set_once)&&void 0!==s?s:{},f)}:{}),elements_chain:null!==(a=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(l=t.properties)?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}wc(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}kc(){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==oi?void 0:oi.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.mc++,this.Sc)return this.xc();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.wc(t);return i&&d.add(i),i},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!b(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.Sc=()=>{h.forEach((t=>t())),this.Sc=void 0},this.xc()}xc(){var t=!1;return()=>{var i;t||(t=!0,this.mc--,0===this.mc&&(null==(i=this.Sc)||i.call(this)))}}Cc(t,i){void 0===i&&(i=!0);var e=this.kc();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.yc.length&&(zr.info("Processing "+this.yc.length+" events for site app with id "+t.id),this.yc.forEach((t=>this.Cc((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this._c)||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.Cc((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){zr.error(Br+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}}Tc(){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)}Mc(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Cc((()=>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.Tc(),void this._instance.on("eventCaptured",(t=>this.Mc(t)))):void zr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this._c)||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;er["__$$ph_site_app_"+i]=s._instance,null==(t=er.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return zr.error(Br+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.')}}}},Ls={tracingHeaders:class{constructor(t){this.Ic=void 0,this.Ec=void 0,this.Rc=void 0,this.Uv=()=>{var t,i,e=this.Pc();e?(p(this.Ic)&&(this.Ic=null==(t=er.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),p(this.Ec)&&(this.Ec=null==(i=er.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Jv()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Ys(t){var i,e;null!=(i=er.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=er.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return hr.error("failed to load script",i);t()}))}Ac(){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}Pc(){var t=this.Ac();return v(t)?(v(this.Rc)?this.Rc.splice(0,this.Rc.length,...t):this.Rc=[...t],t.length>0?this.Rc:void 0):(v(this.Rc)&&this.Rc.splice(0),this.Rc=t||void 0,this.Rc)}Jv(){var t,i;null==(t=this.Ic)||t.call(this),null==(i=this.Ec)||i.call(this),this.Ic=void 0,this.Ec=void 0}startIfEnabledOrStop(){this.Pc()?this.Ys(this.Uv):this.Jv()}}},Ds=e({surveys:class extends Zr{constructor(t){var i;super(new ss(t),{get projectToken(){return i.config.token},kv:new rs(i=t)}),this._instance=t}Bu(t,i){var r=i.query?function(t,i,r){var s;void 0===r&&(r=!0);var n=t.split("?"),a=n[0],o=n[1],l=e({},i),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 ci(t,(function(t,i){p(t)||p(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,i.query):t;return new Promise((t=>{var e;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(e=i.target)&&void 0!==e?e:"api",r),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})}))}}},Rs),Ns={toolbar:class{constructor(t){this.instance=t}Fc(t){er.ph_toolbar_state=t}Oc(){var t;return null!==(t=er.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),bi(this.instance.config))return!1;if(!si||!oi)return!1;t=null!=t?t:si.location,e=null!=e?e:si.history;try{if(!i){try{si.localStorage.setItem("test","test"),si.localStorage.removeItem("test")}catch(t){return!1}i=null==si?void 0:si.localStorage}var r,s=ns||qe(t.hash,"__posthog")||qe(t.hash,"state"),n=s?gi((()=>JSON.parse(atob(decodeURIComponent(s)))))||gi((()=>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(as)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Lc(t){var i=er.ph_load_toolbar||er.ph_load_editor;!m(i)&&d(i)?i(t,this.instance):os.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==oi||!oi.getElementById(yi));if(!si||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(si.localStorage.setItem(as,JSON.stringify(e({},s,{source:void 0}))),2===this.Oc())this.Lc(s);else if(0===this.Oc()){var n;this.Fc(1),null==(n=er.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return os.error("[Toolbar] Failed to load",t),void this.Fc(0);this.Fc(2),this.Lc(s)})),_i(si,"turbolinks:load",(()=>{this.Fc(0),this.loadToolbar(s)}))}return!0}Dc(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)}}},zs=e({experiments:Ss},Rs),Bs={conversations:class{constructor(t){this.$c=void 0,this._conversationsManager=null,this.Nc=!1,this.je=null,this.qc=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.jc=t.ok,t.ok)){var i=t.config.conversations;m(i)||(w(i)?this.$c=i:(this.$c=i.enabled,this.je=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.$c=void 0,this.je=null,this.jc=void 0,this.qc=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Nc||this._instance.config.disable_conversations||bi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==er?void 0:er.__PosthogExtensions__;if(t&&!p(this.$c)&&this.$c)if(this.je&&this.je.token){this.Nc=!0;try{var i=t.initConversations;if(i)return this.Bc(i),void(this.Nc=!1);var e=t.loadExternalDependency;if(!e)return void this.Hc(ze);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.Hc("Could not load conversations script",i):this.Bc(t.initConversations),this.Nc=!1}))}catch(t){this.Hc("Error initializing conversations",t),this.Nc=!1}}else xs.error("Conversations enabled but missing token in remote config.")}}Bc(t){if(this.je)try{this._conversationsManager=t(this.je,this._instance),this.qc=!1,xs.info("Conversations loaded successfully")}catch(t){this.Hc("Error completing conversations initialization",t)}else xs.error("Cannot complete initialization: remote config is null")}Hc(t,i){xs.error(t,i),this._conversationsManager=null,this.Nc=!1,this.qc=!0}show(){this._conversationsManager?this._conversationsManager.show():xs.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.$c&&!b(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":bi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.jc?"remote_config_failed":p(this.$c)?this.jc?"disabled_in_project":"remote_config_pending":this.$c?m(this.je)||!this.je.token?"missing_token":null!=er&&er.__PosthogExtensions__?this.Nc?"initializing":this.qc?"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,e,r){var s=this;return i((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,r):(xs.warn(ks),null)}))()}getMessages(t,e){var r=this;return i((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,e):(xs.warn(ks),null)}))()}markAsRead(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(xs.warn(ks),null)}))()}getTickets(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(xs.warn(ks),null)}))()}requestRestoreLink(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(xs.warn(ks),null)}))()}restoreFromToken(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(xs.warn(ks),null)}))()}restoreFromUrlToken(){var t=this;return i((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(xs.warn(ks),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()}}},Hs={logs:class{constructor(t){var i,r=this;this.name="logs",this.zc=!1,this.Uc=!1,this.Wc=!1,this.A=di("[logs]"),this.Vc=e({},this.A,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(As)||r.A.error(...i)}}),this.bo=[],this.Gc=[],this._d=0,this.Os=!1,this.Zc=[],this.Qc=[],this.Jc=!1,this.Kc=!1,this.Yc=()=>{var t,i;this.Os||(this._d=0,null==(t=this.Xc)||t.onReconnect(),null==(i=this.tf)||i.onReconnect())},this._instance=t,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.zc=!0),si&&_i(si,"online",this.Yc)}ef(t,i,e,r){var s,n=Es(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new Qt(this.if(t,i),n,this.Vc,(()=>this.rf()),(t=>t()),void 0,r),n]}nf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Xc||this.sf!==i){var e;null==(e=this.Xc)||e.reset(),this.sf=i;var r=this.ef((()=>this.bo),(t=>{this.bo=t}));this.Xc=r[0],this.af=r[1]}return this.Xc}lf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.tf||this.uf!==i){var e;null==(e=this.tf)||e.reset(),this.uf=i;var r=this.ef((()=>this.Gc),(t=>{this.Gc=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Ps);this.tf=r[0],this.hf=r[1]}return this.tf}setup(t){var i;if(!this.Os){this.Ns=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.zc=!0),(this.zc||this.df()&&this.vf())&&this.cf();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.Os?r.dispose():(this.qs=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.Os||(this.Os=!0,this.ff(),null==(t=this.qs)||t.dispose(),this.qs=void 0,this.Ns=void 0,this.Wc=!1,null==si||si.removeEventListener("online",this.Yc),null==(i=this.pf)||i.call(this),this.pf=void 0,null==(e=this.Xc)||e.reset(),null==(r=this.tf)||r.reset())}onRemoteConfig(t){var i,e;if(!this.Os){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;m(r)?this.gf():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[pe]:!!r}),r?(this.zc=!0,this.Uc||this.cf(),this.loadIfEnabled()):this.gf())}}reset(){var t,i,e,r;this.ff(),null==(t=this.Xc)||t.clearQueue(),this.bo=[],null==(i=this.Xc)||i.reset(),null==(e=this.tf)||e.clearQueue(),this.Gc=[],null==(r=this.tf)||r.reset(),this._d=0}captureLog(t){this.Os||this.nf().captureLog(t)}captureConsoleLog(t){this.Os||this.lf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.Os||this.lf().captureLog(t,{context:i,occurredAtMs:e})}vf(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[pe])}df(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=er._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.ff(),null==(t=this.tf)||t.clearQueue(),this.Gc=[]}gf(){this.zc||this.ff()}cf(){var t,i=this;if(!this.Jc&&null!=er&&er.console){var e=Es(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(er.console[t])}catch(t){return 0}if(!r)return 0;i.Qc.push(ur(er.console,t,(s=>{var n=function(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];try{i.mf(t,n,e)}catch(t){}return s.apply(er.console,n)};return n.__rrweb_original__=r,n})))};for(var s of Fs)r(s);this.Jc=!0,this.yf=setTimeout((()=>{this.ff()}),3e4)}}mf(t,i,e){var r;if(this.Jc&&!this.Kc&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Zc.length){this.Kc=!0;try{this.Zc.push({level:t,args:i,occurredAtMs:Date.now(),context:this.rf()})}finally{this.Kc=!1}}}else this.ff()}ff(){if(this.Zc=[],this.Jc){for(var t of(this.Jc=!1,this.yf&&(clearTimeout(this.yf),this.yf=void 0),this.Qc))t();this.Qc=[]}}bf(){var t=this.Zc;return this.ff(),t}get logger(){return this._f||(this._f={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._f}flushLogs(t){t?this.wf(t):(this.Xc&&this.Xc.flush().catch((t=>this.kf(t))),this.tf&&this.tf.flush().catch((t=>this.kf(t))))}kf(t){As(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Os&&this.zc&&!this.Uc&&!this.Wc){var t=null==er?void 0:er.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.ff();var i=t.loadExternalDependency;if(!i)return this.A.error(ze),void this.ff();this.Wc=!0;try{i(this._instance,"logs",(i=>{if(this.Wc=!1,!this.Os&&this.zc){var e=t.logs;if(i||null==e||!e.initializeLogs)this.A.error("Could not load logs script",i),this.ff();else{var r,s,n=this.bf();this.pf=e.initializeLogs(null!==(r=this.Ns)&&void 0!==r?r:this._instance),this.Uc=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.Ns)&&void 0!==s?s:this._instance,n))}}}))}catch(t){throw this.Wc=!1,t}}}if(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===o.LogsQueue?t():void 0,setPersistedProperty(t,e){var r;t===o.LogsQueue&&i(null!==(r=e)&&void 0!==r?r:[])},hs:t=>this.hs(t),getLibraryId:()=>ri.LIB_NAME,getLibraryVersion:()=>ri.LIB_VERSION}}hs(t){return new Promise((i=>{if(We(this._d,3))i({kind:"fatal",error:Ts(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:Ts(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Sf(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.xf(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:Ts(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)})}}})}}))}xf(t){(0!==t||this._instance.__loaded)&&(this._d=Ke(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."))))}wf(t){this.bo.length>0&&this.Cf(t,this.bo,this.af,ri.LIB_NAME,(t=>{this.bo=t})),this.Gc.length>0&&this.Cf(t,this.Gc,this.hf,Ps,(t=>{this.Gc=t}))}Cf(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var a=Zt(n,Xt(e,ri.LIB_NAME,ri.LIB_VERSION),r,ri.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Sf(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}Sf(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}rf(){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,m(s)||(i.sessionStartTimestamp=s),m(n)||(i.lastActivityTimestamp=n)}if(null!=er&&null!=(t=er.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?Y(er.location.href):er.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Us={metrics:class{constructor(t){this.A=di("[metrics]"),this._instance=t}initialize(){}nf(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Xc&&this.sf===e||(null==(i=this.Xc)||i.reset(),this.sf=e,this.Xc=new ei(this.if(),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.Xc}count(t,i,e){void 0===i&&(i=1),this.nf().count(t,i,e)}gauge(t,i,e){this.nf().gauge(t,i,e)}histogram(t,i,e){this.nf().histogram(t,i,e)}flush(t){if(!this.Xc)return Promise.resolve();if(t){var i=this.Xc.drainWindow();return i&&this.Ms(i,t),Promise.resolve()}return this.Xc.flush().catch((t=>this.A.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Xc)||t.reset()}if(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ms:t=>i.Ms(t),getLibraryId:()=>ri.LIB_NAME,getLibraryVersion:()=>ri.LIB_VERSION}}Ms(t,i){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(e({method:"POST",url:this.Tf(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error("metrics request failed with status "+i)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("metrics request failed with status "+i)})}}}))}))}Tf(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Vs=e({},Rs,Os,Ms,Is,$s,js,Ds,Ls,Ns,zs,Bs,Hs,Us),qs=Rs,Ws=Os,Ks=Ms,Js=Is,Gs=$s,Xs=js,Zs=Ds,Qs=Ls,Ys=Ns,tn=zs,en=Bs,rn=Hs,sn=Us;export{Vs as AllExtensions,Ks as AnalyticsExtensions,en as ConversationsExtensions,Js as ErrorTrackingExtensions,tn as ExperimentsExtensions,qs as FeatureFlagsExtensions,rn as LogsExtensions,sn as MetricsExtensions,Gs as ProductToursExtensions,Ws as SessionReplayExtensions,Xs as SiteAppsExtensions,Zs as SurveysExtensions,Ys as ToolbarExtensions,Qs as TracingExtensions};
|
|
2
2
|
//# sourceMappingURL=extension-bundles.js.map
|