posthog-js 1.421.2 → 1.422.0
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.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.no-external.js +1 -1
- package/dist/conversations.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/dead-clicks-autocapture.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/exception-autocapture.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/lazy-recorder.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- 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.no-external.js +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.no-external.js +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/posthog-recorder.js.map +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +1 -0
- package/dist/src/extensions/replay/external/mutation-throttler.d.ts +1 -0
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys.js +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.d.ts +1 -0
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js +9 -0
- package/lib/src/extensions/replay/external/lazy-loaded-session-recorder.js.map +1 -1
- package/lib/src/extensions/replay/external/mutation-throttler.d.ts +1 -0
- package/lib/src/extensions/replay/external/mutation-throttler.js +9 -0
- package/lib/src/extensions/replay/external/mutation-throttler.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=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function s(t){return"string"==typeof t||t}function n(t){return"string"==typeof t?t:void 0}var a=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}({}),o=20,l=1e3,u=1e4,h="[Circular]",v="[Truncated]",d="[Unserializable]",c="[Function]";function f(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}var p=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],g=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return p.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function _(t,i){return-1!==t.indexOf(i)}var b=function(t){return t.trim()},m=Object.prototype,y=m.hasOwnProperty,w=m.toString,k=Array.isArray||function(t){return"[object Array]"===w.call(t)},S=t=>"function"==typeof t,x=t=>t===Object(t)&&!k(t),E=t=>{if(x(t)){for(var i in t)if(y.call(t,i))return!1;return!0}return!1},F=t=>void 0===t,C=t=>"[object String]"==w.call(t),P=t=>C(t)&&0===t.trim().length,T=t=>null===t,A=t=>F(t)||T(t),R=t=>"[object Number]"==w.call(t)&&t==t,O=t=>"[object Boolean]"===w.call(t),M=t=>t instanceof FormData;function I(t){return null===t||"object"!=typeof t}function j(t,i){return{}.toString.call(t)==="[object "+i+"]"}function L(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 N(t,Error)}}function D(t){return"undefined"!=typeof Event&&N(t,Event)}function N(t,i){try{return t instanceof i}catch(t){return!1}}function z(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),R(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),z(e,i,e,r))}class U{constructor(t){this.k={},this.S=t.S,this.C=z(t.bucketSize,0,100,t.I),this.R=z(t.refillRate,0,this.C,t.I),this.A=z(t.refillInterval,0,864e5,t.I)}O(t,i){var e=Math.floor((i-t.lastAccess)/this.A);e>0&&(t.tokens=Math.min(t.tokens+e*this.R,this.C),t.lastAccess=t.lastAccess+e*this.A)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.k[r];return s?this.O(s,e):this.k[r]=s={tokens:this.C,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.S)||i.call(this,t)),0===s.tokens)}stop(){this.k={}}}function H(t){return t?t.split("#")[0]:t}function q(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function V(t,i,e){return B.apply(this,arguments)}function B(){return(B=i((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=q((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var W={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}},K=W.info,J=0x8000000000000000,G={}.propertyIsEnumerable;function Z(t,i){try{return X(t,i,{ancestors:new WeakSet,remainingNodes:u},0)}catch(t){return[]}}function Q(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:v};if(e.remainingNodes--,O(t))return{boolValue:t};if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if("undefined"==typeof BigInt)return{stringValue:String(t)};var s=BigInt(t).toString();return t>=J||-J>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:f(t)};if("function"==typeof t)return{stringValue:c};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:h};if(r>=o)return{stringValue:v};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?f(a):String(a)}}e.ancestors.add(t);try{try{var l=t.toJSON;if("function"==typeof l)return Q(l.call(t),i,e,r+1)}catch(t){}return k(t)?{arrayValue:{values:Y(t,i,e,r+1)}}:{kvlistValue:{values:X(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:f(String(t))}}function Y(t,i,e,r){for(var s=[],n=Math.min(t.length,l),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(A(o))continue;s.push(Q(o,i,e,r))}catch(t){s.push({stringValue:d})}return t.length>a&&s.push({stringValue:v}),s}function X(t,i,e,r){var s=[];for(var n in t)if(G.call(t,n)){if(s.length>=l||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(T(a)||F(a))continue;s.push({key:f(n),value:Q(a,i,e,r)})}catch(t){s.push({key:f(n),value:{stringValue:d}})}}return s}function tt(t){try{return f(String(t))}catch(t){return d}}function it(t,i,r,s){var n,a=W[t.level||"info"]||K,o=a.text,l=a.number,u=(void 0===(n=R(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),A(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),A(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),c=t.attributes;if(c){var f=[];try{f=Object.keys(c)}catch(t){f=[]}for(var p of f){var g=void 0;try{g=c[p]}catch(t){g=d}Object.defineProperty(v,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:tt(t.body)},attributes:Z(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),F(t.trace_flags)||(_.flags=t.trace_flags),_}function et(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})}function rt(t,i,e,r){return{resourceLogs:[{resource:{attributes:Z(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let st=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Wi=i,this.I=e,this.hn=r,this.dn=s,this.vn=n,this.cn=a,this.fn=null,this.pn=0,this.gn=0,this.mn=0,this.yn=0,this.bn=0,this._n=!1,this.wn=i.maxBufferSize,this.kn=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.Sn=i.flushIntervalMs,this.xn=i.maxBatchRecordsPerPost,this.Cn=i.rateCapWindowMs,this.Tn=i.maxLogsPerInterval}clearQueue(){this.gn++,this._instance.setPersistedProperty(a.LogsQueue,[])}reset(){this.Mn(),this.yn=0,this.bn=0,this._n=!1,this.mn=0,this.xn=this.Wi.maxBatchRecordsPerPost}onReconnect(){this.mn=0,this.En()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.In(t);if(null!==r)if(r.body){if(this.Rn()){var s={record:it(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.hn(),this.I,null==i?void 0:i.occurredAtMs)};this.dn((()=>this.Pn(s)))}}else this.I.info("Log was rejected in beforeSend function")}}In(t){var i=this.Wi.beforeSend;if(!i)return t;var e=k(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for log:",t),null}return r}Rn(){if(void 0===this.Tn)return!0;var t=Date.now(),i=t-this.yn;return this.Cn>i&&i>=0||(this.yn=t,this.bn=0,this._n=!1),this.Tn>this.bn?(this.bn++,!0):(this._n||(this.I.warn("captureLog dropping logs: exceeded "+this.Tn+" logs per "+this.Cn+"ms"),this._n=!0),!1)}flush(){var t=this;return i((function*(){if(!t._instance.isDisabled)return t.fn||(t.fn=t.An().finally((()=>{t.fn=null}))),t.fn}))()}An(){var t=this;return i((function*(){var i;t.Mn();var e=null!==(i=t._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,o,l=t.gn;t.pn=0;var u=Math.min(e.length,t.xn),h=e.slice(0,u),v=rt(h.map((t=>t.record)),t.Fn(),null!==(n=t.cn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.On(v);if(t.gn!==l)return;if("too-large"===d.kind&&h.length>1)t.xn=Math.max(1,Math.floor(h.length/2)),t.I.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.xn);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.Wi.maxBatchRecordsPerPost>t.xn&&(t.xn=Math.min(t.Wi.maxBatchRecordsPerPost,t.xn+1)),yield t.Ln(h.length),e=null!==(o=t._instance.getPersistedProperty(a.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===d.kind)throw d.error}}}))()}Ln(t){var e=this;return i((function*(){var i,r=Math.max(0,t-e.pn),s=null!==(i=e._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(a.LogsQueue,s.slice(r)),yield e.vn()}))()}Fn(){return et(this.Wi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Pn(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];this.kn>e.length||(e.shift(),this.pn++,this.I.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(a.LogsQueue,e),this.wn>e.length?this.Dn():this.En()}}Dn(t){void 0===t&&(t=this.Sn),this.$n||(this.$n=q((()=>{this.$n=void 0,this.En()}),t))}Nn(){var t=Math.min(Math.max(0,this.mn-1),6);return this.Sn*Math.pow(2,t)}qn(){var t=this._instance.getPersistedProperty(a.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return i((function*(){e.Mn();var i=e.flush().catch((()=>{}));void 0!==t?yield V(i,t):yield i}))()}flushWithTimeout(t){var e=this;return i((function*(){var i=e.flush();yield V(i,t,(()=>{i.catch((()=>{}))}))}))()}En(){this.flush().then((()=>{this.mn=0}),(t=>{this.mn++,this.I.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.qn()&&this.Dn(this.Nn())}))}Mn(){this.$n&&(clearTimeout(this.$n),this.$n=void 0)}};var nt=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function at(t){return String(t)+"000000"}function ot(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 lt=class{constructor(t,i,e){this._instance=t,this.Wi=i,this.I=e,this.jn=new Map,this.fn=null,this.Bn=!1,this.Hn=new Map,this.Un=new Set,this.zn=0}count(t,i,e){void 0===i&&(i=1),this.Wn({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Wn({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Wn({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,e=this.fn,r=function(){var r=i((function*(){e&&(yield e.catch((()=>{}))),yield t.Vn()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this.fn===s&&(this.fn=null)}));return this.fn=s,s}drainWindow(){if(0===this.jn.size)return null;var t=this.jn;return this.jn=new Map,this.Bn=!1,this.Hn=new Map,this.Un=new Set,this.Gn(t)}reset(){this.zn++,this.Mn(),this.jn=new Map,this.fn=null,this.Bn=!1,this.Hn=new Map,this.Un=new Set}Wn(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.In(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.I.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=i.attributes?e({},i.attributes):void 0,s=ot(i.type,i.name,i.unit,r)}catch(t){return void this.I.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.jn.get(s);if(!n){if(!this.Zn())return;n={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.jn.set(s,n)}var a=this.Hn.get(i.name);void 0===a?this.Hn.set(i.name,i.type):a===i.type||this.Un.has(i.name)||(this.Un.add(i.name),this.I.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.Qn(n,i.value),this.Dn()}else this.I.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}Zn(){return this.Wi.maxSeriesPerFlush>this.jn.size||(this.Bn||(this.Bn=!0,this.I.warn("Metric series cap reached ("+this.Wi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Qn(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(nt.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,nt)]+=1}}In(t){var i=this.Wi.beforeSend;if(!i)return t;var e=k(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for metric:",t),null}return r}Dn(){this.$n||(this.$n=q((()=>{this.$n=void 0,this.flush().catch((t=>{this.I.error("Metrics flush failed:",t)}))}),this.Wi.flushIntervalMs))}Mn(){this.$n&&(clearTimeout(this.$n),this.$n=void 0)}Vn(){var t=this;return i((function*(){if(0!==t.jn.size){var i=t.jn;t.jn=new Map,t.Bn=!1,t.Hn=new Map,t.Un=new Set;var e=t.zn,r=yield t._instance.Jn(t.Gn(i));if(e===t.zn)switch(r.kind){case"ok":return;case"retry-later":return t.Kn(i),void t.Dn();case"too-large":return void t.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.I.error("Failed to send metrics batch:",r.error)}}}))()}Gn(t){return i=this.Yn(t),r=function(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})}(this.Wi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Z(r)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,r,s,n}Yn(t){var i=at(Date.now()),r=new Map;for(var s of t.values()){var n,a=ot(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=Z(null!==(n=s.attributes)&&void 0!==n?n:{},this.I),u=at(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:nt})}return Array.from(r.values())}Kn(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.jn.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.Zn()&&this.jn.set(s,n)}}};var ut,ht,vt;function dt(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return vt&&e.length===ht?vt:(ht=e.length,vt=e.reduce(((e,r)=>{ut||(ut={});var s=ut[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,ut[r]=[l,u];break}}return e}),{}))}}class ct{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&&k(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:dt(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 ft="?";function pt(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?ft:e,in_app:!(null!=i&&i.startsWith("webkit-masked-url://"))&&"<anonymous>"!==i};return F(r)||(n.lineno=r),F(s)||(n.colno=s),n}var gt=(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]:ft,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},_t=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,bt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mt=/\((\S*)(?::(\d+))(?::(\d+))\)/,yt=(t,i)=>{var e=_t.exec(t);if(e)return pt(i,e[1],ft,+e[2],+e[3]);var r=bt.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=mt.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=gt(r[1]||ft,r[2]);return pt(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},wt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,kt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,St=(t,i)=>{var e=wt.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=kt.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]||ft,a=gt(n,s);return pt(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},xt=/\(error: (.*)\)/;class Et{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=C(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 j(t,"DOMException")}isDOMError(t){return j(t,"DOMError")}}class Ft{match(t){return L(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 Ct{constructor(){}match(t){return!!j(t,"ErrorEvent")&&(null!=t.error||this.wi(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.ki(t))&&void 0!==r?r:s.stack,synthetic:!0})}wi(t){return C(t.message)&&t.message.length>0}ki(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(C(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var Pt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Tt{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(Pt);return r&&(i=r[1],e=r[2]),[i,e]}}var At=["fatal","error","warning","log","info","debug"];function Rt(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 Ot{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(D(t))return t.constructor.name;var i="name"in t?t.name:void 0;return C(i)&&!P(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: "+Rt(t)}isSeverityLevel(t){return C(t)&&!P(t)&&At.indexOf(t)>=0}getStack(t){try{return C(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:C(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(L(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}}class Mt{match(t){return D(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Rt(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class $t{match(t){return I(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 It{match(t){return j(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!D(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 I(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 jt="$message",Lt="$timestamp",Dt=new Set([jt,Lt]),Nt={enabled:!0,max_bytes:32768};function zt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Nt.enabled,max_bytes:Ht(t.max_bytes,Nt.max_bytes)}:e({},Nt)}class Ut{constructor(t){this.Xn=[],this.ts=0,this.Wi=zt(t)}setConfig(t){this.Wi=zt(t),this.es()}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(!x(s))return;var n=s,a=n[jt],o=n[Lt];if(!C(a)||0===a.trim().length)return;if(!C(o)&&!R(o))return;return{step:n,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.Wi.max_bytes||(this.Xn.push({step:i.step,bytes:e}),this.ts+=e,this.es())}}getAttachable(){return this.Xn.map((t=>t.step))}clear(){this.Xn=[],this.ts=0}size(){return this.Xn.length}es(){for(;this.ts>this.Wi.max_bytes&&this.Xn.length>0;){var t=this.Xn.shift();t&&(this.ts-=t.bytes)}}}function Ht(t,i){if(!R(t)||t===1/0||t===-1/0)return i;var e=Math.floor(t);return 0>e?i:e}var qt={DEBUG:!1,LIB_VERSION:"0.6.0",LIB_NAME:"browser-common"},Vt="undefined"!=typeof window?window:void 0,Bt="undefined"!=typeof globalThis?globalThis:Vt,Wt=null==Bt?void 0:Bt.navigator,Kt=null==Bt?void 0:Bt.document,Jt=null==Bt?void 0:Bt.location;function Gt(){return!(!Vt||!1===Vt.navigator.onLine)}null!=Bt&&Bt.XMLHttpRequest&&new Bt.XMLHttpRequest;var Zt=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={P(i){if(Vt&&(qt.DEBUG||Vt.POSTHOG_DEBUG||e)&&!F(Vt.console)&&Vt.console){for(var r=("__rrweb_original__"in Vt.console[i]?Vt.console[i].__rrweb_original__:Vt.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.P("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.P("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.P("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.P("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)=>Zt(t+" "+i,e)};return r},Qt=Zt("[PostHog.js]"),Yt=Qt.createLogger;function Xt(t,i){if(!A(t))if(k(t))t.forEach(i);else if(M(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)y.call(t,e)&&i(t[e],e)}var ti=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 ii(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 ei=function(t){try{return t()}catch(t){return}};function ri(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 si(t){return"ph_toolbar_internal"===t.name}function ni(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!S(r))return i;try{var s=r(i);return C(s)&&s?s:i}catch(t){return Qt.error("Error in get_current_url, falling back to window.location.href",t),i}}var ai="__POSTHOG_TOOLBAR__",oi=1,li=3,ui=11;function hi(t){return t instanceof Element&&(t.id===ai||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function vi(t){return!!t&&t.nodeType===oi}function di(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function ci(t){return!!t&&t.nodeType===li}function fi(t){return!!t&&t.nodeType===ui&&vi(t.host)}var pi=1e3;function gi(t){return t?b(t).split(/\s+/):[]}function _i(t,i){var e=function(t){var i,e=null==Vt||null==(i=Vt.location)?void 0:i.href;return F(e)?void 0:ni(t,e)}(i);return!!(e&&t&&t.some((t=>e.match(t))))}function bi(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 gi(i)}function mi(t){return A(t)?null:b(t).split(/(\s+)/).filter((t=>Hi(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function yi(t){var i="";return Mi(t)&&!$i(t)&&t.childNodes&&t.childNodes.length&&Xt(t.childNodes,(function(t){var e;ci(t)&&t.textContent&&(i+=null!==(e=mi(t.textContent))&&void 0!==e?e:"")})),b(i)}function wi(t){var i;return F(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var ki=["a","button","form","input","select","textarea","label"];function Si(t,i){if(F(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 xi(t){var i=t.parentNode;return!(!i||!vi(i))&&i}var Ei=[".ph-no-autocapture","[data-ph-no-autocapture]"],Fi=["next","previous","prev",">","<"],Ci=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Pi=[".ph-no-rageclick",".ph-no-capture"],Ti=["","text","search","email","password","url","tel","number"];function Ai(t,i){if(!Vt||Ri(t))return!1;var e,r,s,n,a;if(O(i)?(e=!!i&&Pi,r=void 0,s=!1):(e=null!==(n=null==i?void 0:i.css_selector_ignorelist)&&void 0!==n?n:Pi,r=null==i?void 0:i.content_ignorelist,s=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===e)return!1;if(s&&function(t){return!(!t||!vi(t))&&(!!di(t,"textarea")||(di(t,"input")?_(Ti,(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 o=Oi(t,!1).targetElementList;return!function(t,i){if(!1===t||F(t))return!1;var e;if(!0===t)e=Fi;else{if(!k(t))return!1;if(t.length>10)return Qt.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=>Ci(i,t)||Ci(r,t)))}))}(r,o.map((t=>{var i;return{safeText:yi(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!Si(o,e)}var Ri=t=>!t||di(t,"html")||!vi(t),Oi=(t,i)=>{if(!Vt||Ri(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!di(s,"body");)if(fi(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=xi(s);if(!n)break;if(i||ki.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=Vt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Mi(t){for(var i=new Set,e=0,r=t;r.parentNode&&!di(r,"body");r=r.parentNode){if(e++>=pi||i.has(r))return!1;i.add(r);var s=bi(r);if(_(s,"ph-sensitive")||_(s,"ph-no-capture"))return!1}if(_(bi(t),"ph-include"))return!0;var n=t.type||"";if(C(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!C(a)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,""))}function $i(t){return!!(di(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||di(t,"select")||di(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ii=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}))$"),ji=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Li=[16,15,14,13],Di=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ni=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),zi=/[0-9A-Za-z_]/;function Ui(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 Hi(t,i){if(void 0===i&&(i=!0),A(t))return!1;if(C(t)){t=b(t);var e=i?Ii.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(ji.lastIndex=0;i=ji.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of Li){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(Ii.test(o)&&Ui(o))return!0}}}return!1}(t);if(e)return!1;var r=i?Di.test(t):function(t){var i;for(Ni.lastIndex=0;i=Ni.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&zi.test(e)&&zi.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function qi(t){var i=yi(t);return Hi(i=(i+" "+Vi(t)).trim())?i:""}function Vi(t){var i="";return t&&t.childNodes&&t.childNodes.length&&Xt(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=yi(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+Vi(t)).trim())}catch(t){Qt.error("[AutoCapture]",t)}})),i}function Bi(t){return t.replace(/"|\\"/g,'\\"')}function Wi(t){var i=t.attr__class;if(i)return k(i)?i:gi(i)}class Ki{constructor(t){this.disabled=!1===t;var i=x(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 Ji="$autocapture_disabled_server_side",Gi="$heatmaps_enabled_server_side",Zi="$exception_capture_enabled_server_side",Qi="$error_tracking_suppression_rules",Yi="$error_tracking_capture_extension_exceptions",Xi="$web_vitals_enabled_server_side",te="$product_tours_enabled_server_side",ie="$logs_capture_enabled_server_side",ee="$web_vitals_allowed_metrics",re="$session_recording_remote_config",se="$enabled_feature_flags",ne="$active_feature_flags",ae="$early_access_features",oe="$feature_flag_details",le="$feature_flag_payloads",ue="$feature_flag_request_id",he="$minimal_flag_called_events",ve="$override_feature_flags",de="$override_feature_flag_payloads",ce="$stored_person_properties",fe="$stored_group_properties",pe="$surveys",ge="$surveys_loaded_at",_e="$surveys_activated",be="$surveys_activated_session",me="$surveys_activated_timestamps",ye="ph_product_tours",we="$flag_call_reported",ke="$flag_call_reported_session_id",Se="$feature_flag_errors",xe="$feature_flag_evaluated_at",Ee="$sdk_debug_recording_script_not_loaded",Fe="PostHog loadExternalDependency extension not found.",Ce="visibilitychange",Pe="beforeunload",Te=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(!k(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){Qt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ae=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 v=l[h].split("=");k(v)&&(i.includes(v[0])?u.push(v[0]+"="+e):u.push(l[h]))}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=s&&(d+="#"+s),d},Re=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Oe=(t,i)=>t>=i&&Gt(),Me=(t,i,e,r)=>{if(0===t){if(Gt()){var s=i+1;return s===e&&r(),s}return i}return 0},$e="$copy_autocapture",Ie=Yt("[AutoCapture]");function je(t,i){return i.length>t?i.slice(0,t)+"...":i}function Le(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!vi(i));return i}function De(t,i){var r,s,n=i.e,a=i.maskAllElementAttributes,o=i.maskAllText,l=i.elementAttributeIgnoreList,u=i.elementsChainAsString,h=i.disableCaptureUrlHashes;if(!vi(t))return{props:{}};for(var v=[t],d=new Set([t]),c=t;c.parentNode&&!di(c,"body")&&pi>v.length;)if(fi(c.parentNode)){var f=c.parentNode.host;if(d.has(f))break;d.add(f),v.push(f),c=f}else{if(!vi(c.parentNode))break;if(d.has(c.parentNode))break;d.add(c.parentNode),v.push(c.parentNode),c=c.parentNode}var p,g,b=[],m={},y=!1,w=!1;if(Xt(v,(t=>{var i=Mi(t);if(di(t,"a")){var e=t.getAttribute("href");y=!!(i&&e&&Hi(e))&&(h?H(e):e)}_(bi(t),"ph-no-capture")&&(w=!0),b.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};ki.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?je(1024,qi(t)):je(1024,yi(t)));var o=bi(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),Xt(t.attributes,(function(e){var n;if((!$i(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Hi(e.value)&&(!C(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=gi(o).join(" ")),a["attr__"+e.name]=je(1024,"href"===e.name&&s?H(o):o)}}));for(var l=1,u=1,h=t;h=Le(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,a,o,l,h));var r=function(t){if(!Mi(t))return{};var i={};return Xt(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&&Hi(r)&&(i[e]=r)}})),i}(t);ti(m,r)})),w)return{props:{},explicitNoCapture:w};if(o||(b[0].$el_text=di(t,"a")||di(t,"button")?qi(t):yi(t)),y){var k,S;b[0].attr__href=y;var x=null==(k=(t=>{var i=null==Kt?void 0:Kt.createElement("a");return F(i)?null:(i.href=t,i)})(y))?void 0:k.host,E=null==Vt||null==(S=Vt.location)?void 0:S.host;x&&E&&x!==E&&(p=y)}return{props:ti({$event_type:n.type,$ce_version:1},u?{}:{$elements:b},{$elements_chain:(g=b,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 ii(a).sort(((t,i)=>t[0].localeCompare(i[0]))).forEach((t=>{var i=t[1];return o[Bi(t[0].toString())]=Bi(i.toString())})),(s+=":")+ii(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:Wi(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return ii(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=b[0])&&r.$el_text?{$el_text:null==(s=b[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},m)}}class Ne{constructor(t){this.name="autocapture",this.rs=!1,this.ns=null,this.ss=!1,this.os=!1,this.Wi={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.ls=!1,this.us=t,this.us.refresh(this.Wi),this.rageclicks=new Ki(this.Wi.rageclick),this.hs=null}setup(t){this.ds(),this.vs=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.ls?i.dispose():(this.cs=i,this.startIfEnabled())}dispose(){var t;this.ls||(this.ls=!0,this.vs=void 0,null==(t=this.cs)||t.dispose(),this.cs=void 0,this.fs())}ps(){return this.us.refresh(this.Wi),this.Wi}ds(){var t,i;return this.ps(),this.Wi.url_allowlist=null==(t=this.Wi.url_allowlist)?void 0:t.map((t=>new RegExp(t))),this.Wi.url_ignorelist=null==(i=this.Wi.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),this.Wi}gs(){if(this.isBrowserSupported()){if(Vt&&Kt){var t=this.ys=t=>{t=t||(null==Vt?void 0:Vt.event);try{this.bs(t)}catch(t){Ie.error("Failed to capture event",t)}};if(ri(Kt,"submit",t,{capture:!0}),ri(Kt,"change",t,{capture:!0}),ri(Kt,"click",t,{capture:!0}),this.ps().capture_copied_text){var i=this._s=t=>{t=t||(null==Vt?void 0:Vt.event);try{this.bs(t,$e)}catch(t){Ie.error("Failed to capture clipboard event",t)}};ri(Kt,"copy",i,{capture:!0}),ri(Kt,"cut",i,{capture:!0}),ri(Kt,"paste",i,{capture:!0})}}}else Ie.info("Disabling Automatic Event Collection because this browser is not supported")}fs(){this.ys&&(null==Kt||Kt.removeEventListener("submit",this.ys,!0),null==Kt||Kt.removeEventListener("change",this.ys,!0),null==Kt||Kt.removeEventListener("click",this.ys,!0),this.ys=void 0),this._s&&(null==Kt||Kt.removeEventListener("copy",this._s,!0),null==Kt||Kt.removeEventListener("cut",this._s,!0),null==Kt||Kt.removeEventListener("paste",this._s,!0),this._s=void 0),this.rs=!1}startIfEnabled(){!this.ls&&this.vs&&this.isEnabled&&!this.rs&&(this.gs(),this.rs=!0)}onRemoteConfig(t){if(!this.ls)if(this.ss=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.os=i.elementsChainAsString);var e,r=i.autocapture_opt_out;O(r)&&(null==(e=this.vs)||e.kv.set(Ji,r),this.ns=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.hs=t}getElementSelectors(t){var i,e=[];return null==(i=this.hs)||i.forEach((i=>{var r=null==Kt?void 0:Kt.querySelectorAll(i);null==r||r.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i;if(this.ls)return!1;var e=null==(t=this.vs)?void 0:t.kv.get(Ji),r=this.ns,s=this.ps(),n=s.remoteRequestsDisabled&&!this.ss;if(T(r)&&!O(e)&&!n)return!1;var a=null!==(i=this.ns)&&void 0!==i?i:!!e;return!!s.enabled&&!a}bs(t,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r=wi(t);ci(r)&&(r=r.parentNode||null);var s,n=this.ds();"$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())&&Ai(r,n.rageclick)&&this.bs(t,"$rageclick");var a=i===$e,o=a?e({},n,{dom_event_allowlist:void 0}):n;if(r&&function(t,i,e,r,s,n){var a;if(!Vt||Ri(t))return!1;if(null!=e&&e.url_allowlist&&!_i(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&_i(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=Oi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(F(e))return!0;var r,s=function(t){if(e.some((i=>t.tagName.toLowerCase()===i)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(h,e))return!1;if(!Si(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Si(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:Ei))return!1;try{var v=Vt.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&&(ki.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=De(r,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.os,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===$e){var d=t.type||"clipboard";if("paste"!==d){var c,f,p=null==Vt||null==(c=Vt.getSelection())?void 0:c.toString(),g=mi(p);if(!g)return!1;h.$selected_content=g,h.$clipboard_text_length=null!==(f=null==p?void 0:p.length)&&void 0!==f?f:0}h.$copy_type=d}return null==(l=this.vs)||l.capture(i,h).catch((t=>Ie.error("Failed to capture event",t))),!0}}}isBrowserSupported(){return S(null==Kt?void 0:Kt.querySelectorAll)}}class ze{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=x(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 Ue="undefined"!=typeof globalThis?globalThis:Vt;Ue&&"undefined"==typeof self&&(Ue.self=Ue),Ue&&"undefined"==typeof File&&(Ue.File=function(){});var He=null!=Vt?Vt:{},qe=Yt("[Dead Clicks]"),Ve=()=>!0;class Be{get lazyLoadedDeadClicksAutocapture(){return this.Ts}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ms((()=>{this.Es()})):this.stop()}Ms(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?qe.error("failed to load script",i):t()}))}Es(){var t;if(Kt){if(!this.Ts&&null!=(t=He.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=x(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.Ts=He.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ts.start(Kt),qe.info("starting...")}}else qe.error("`document` not found. Cannot start.")}stop(){this.Ts&&(this.Ts.stop(),this.Ts=void 0,qe.info("stopping..."))}}var We=Yt("[ExceptionAutocapture]"),Ke=()=>{},Je=t=>{var i;if(S(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function Ge(t,i,e){try{if(!(i in t))return Ke;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 S(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=Je(e);n;){if(n.next===s)return void(n.next=r.next);n=Je(e=n.next)}else t[i]=r.next}}catch(t){return Ke}}var Ze=Yt("[TracingHeaders]"),Qe=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ye=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qe],Xe="<masked>",tr=["li_fat_id"];function ir(t,i,e){if(!Kt)return{};var r,s,n,a=(r=Ae(Kt.URL,[],Xe),s=Ye.concat([]),n={},Xt(s,(function(t){var i=Te(r,t);n[t]=i||null})),n),o=function(){var t={};return Xt(tr,(function(i){var e=(t=>{if(Kt){try{for(var i=t+"=",e=Kt.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 ti(o,a)}function er(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var rr=Yt("[Web Vitals]"),sr=9e5,nr=["CLS","FCP","INP","LCP"],ar=["INP","LCP"],or=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],lr=Yt("[RemoteConfig]");class ur{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=He._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}_a(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}wa(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return lr.info("Using preloaded remote config",this.remoteConfig),void this.ka(this.remoteConfig);if(this._instance._shouldDisableFlags())return void lr.warn("Remote config is disabled. Falling back to local config.");this._a((t=>{if(!t)return lr.info("No config found after loading remote JS config. Falling back to JSON."),void this.wa((t=>{this.ka(t.json,t)}));this.ka(t)}))}catch(t){lr.error("Error loading remote config",t),this.ka()}}ka(t,i){!t&&i&&(0===i.statusCode?i.error||lr.warn("Failed to fetch remote config from PostHog."):lr.error("Failed to fetch remote config from PostHog."));try{this._instance.ka(t?{ok:!0,config:t}:{ok:!1})}catch(t){lr.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){lr.error("Error loading feature flags",t)}}}var hr="disabled",vr="lazy_loading",dr="awaiting_config",cr="missing_config";function fr(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}qt.DEBUG=!1,qt.LIB_VERSION="1.421.2",qt.LIB_NAME="web";var pr=(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}},gr=t=>t.toLowerCase(),_r={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=>pr(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!pr(i,t))))),icontains:(t,i)=>i.map(gr).some((i=>t.map(gr).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(gr).every((i=>t.map(gr).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 br(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=_r[e.operator];return!!s&&s(e.values,[String(r)])}))}Yt("[SessionRecording]"),Yt("[SessionRecording]");var mr="[SessionRecording]",yr=Yt(mr),wr=Yt("[Heatmaps]");function kr(t){return x(t)&&"clientX"in t&&"clientY"in t&&R(t.clientX)&&R(t.clientY)}var Sr=Yt("[Product Tours]"),xr=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(te))},Er=["$set_once","$set"],Fr=Yt("[SiteApps]"),Cr="Error while initializing PostHog app with config id ",Pr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Tr="events",Ar="cancelEvents",Rr="survey shown",Or=Yt("[Surveys]"),Mr="seenSurvey_",$r=["popover","widget","api"],Ir="SDK is not enabled or survey functionality is not yet loaded",jr="Disabled. Not loading surveys.";class Lr{constructor(t,i){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Al=!1,this.Fl=[],this.Ol=null,this.Ll=null,this.ls=!1,this.Dl=new Set,this.onRemoteConfig=t=>{if(!this.ls&&!this.Wi.disableSurveys){if(!t.ok)return Or.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(A(i))return Or.warn("Flags not loaded yet. Not loading surveys.");this.$l=O(i)?i:i.length>0,Or.info("flags response received, isSurveysEnabled: "+this.$l),this.loadIfEnabled()}},this.us=t,this.Nl=i}setup(t){if(!this.ls)return this.ql=t,Pr(t.kv.initialize(),(()=>{if(this.ql===t&&!this.ls){this.ql=void 0,this.vs=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.ls?i.dispose():(this.cs=i,this.loadIfEnabled())}}))}dispose(){var t,i,e;this.ls||(this.ls=!0,this.ql=void 0,this.vs=void 0,null==(t=this.cs)||t.dispose(),this.cs=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Fl=[],this.Ol=null,this.Dl.forEach((t=>clearTimeout(t))),this.Dl.clear())}get Wi(){return this.us.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith(Mr)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this.ls&&this.vs){var t=this.Wi;if(!this._surveyManager)if(this.Al)Or.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Or.info(jr);else if(t.cookielessMode&&this.us.isOptedOut())Or.info("Not loading surveys in cookieless mode without consent.");else{var i=this.us.getExtensions();if(i){if(!F(this.$l)||t.advancedEnableSurveys){var e=this.$l||t.advancedEnableSurveys;this.Al=!0;try{var r=i.generateSurveys;if(r)return this.jl(r,e),void(this.Al=!1);var s=i.loadExternalDependency;if(!s)return this.Bl(Fe),void(this.Al=!1);s((t=>{try{if(this.ls)return;var i=this.us.getExtensions();t||null==i||!i.generateSurveys?this.Bl("Could not load surveys script",t):this.jl(i.generateSurveys,e)}finally{this.Al=!1}}))}catch(t){throw this.Al=!1,this.Bl("Error initializing surveys",t),t}}}else Or.error("PostHog Extensions not found.")}}}jl(t,i){this.ls||(this._surveyManager=t(i),this._surveyEventReceiver=this.us.createEventReceiver(),Or.info("Surveys loaded successfully"),this.Hl({isLoaded:!0}))}Bl(t,i){Or.error(t,i),this.Hl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Fl.push(t),this._surveyManager&&this.Hl({isLoaded:!0}),()=>{this.Fl=this.Fl.filter((i=>i!==t))}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.vs)&&void 0!==e?e:this.Nl;if(r&&!this.ls){if(this.Wi.disableSurveys)return Or.info(jr),t([]);var s=r.kv.get(pe);if(s&&!i)return t(s,{isLoaded:!0}),void(this.Ul()&&this.getSurveys((()=>{}),!0));if(this.Ol)this.Ol.then((i=>{this.ls||t(i.surveys,i.context)})).catch((t=>Or.error("Error in survey callback",t)));else{var n=this.zl("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.Wi.requestTimeoutMs}).then((t=>{try{return this.Wl(r,t)}catch(t){return Or.error("Error processing surveys response",t),this.Wl(r,{statusCode:0,error:t})}}),(t=>this.Wl(r,{statusCode:0,error:t})));this.Ol=n;var a=()=>{this.Ol===n&&(this.Ol=null)};n.then((i=>{a(),this.ls||t(i.surveys,i.context)}),a).catch((t=>Or.error("Error in survey callback",t)))}}}zl(t,i){var e=this.vs;return e?e.sendRequest(t,i):new Promise((t=>t({statusCode:0,error:new Error(Ir)})))}Wl(t,i){if(this.ls)return{surveys:[],context:{isLoaded:!1,error:Ir}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?Or.error(r):i.error||Or.warn(r),this.Ll=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Ll=null;var s,n=i.json.surveys||[],a=n.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(fr(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({[pe]:n,[ge]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}Ul(){return this.Vl()&&!this.Ol&&!this.Gl()}Vl(){var t,i,e=null==(t=null!==(i=this.vs)&&void 0!==i?i:this.Nl)?void 0:t.kv.get(ge);return R(e)&&Date.now()-e>3e5}Gl(){return R(this.Ll)&&3e5>Date.now()-this.Ll}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>""+Mr+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){Or.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){}}Hl(t){for(var i of this.Fl)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Or.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!A(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Or.warn("init was not called")}Zl(t){var i=null;return this.getSurveys((e=>{var r;i=null!==(r=e.find((i=>i.id===t)))&&void 0!==r?r:null})),i}Ql(t){if(A(this._surveyManager))return{eligible:!1,reason:Ir};var i="string"==typeof t?this.Zl(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Jl(t){if(A(this._surveyManager))return{eligible:!1,reason:Ir};var i="string"==typeof t?this.Zl(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(A(this._surveyManager))return Or.warn("init was not called"),{visible:!1,disabledReason:Ir};var i=this.Jl(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return A(this._surveyManager)?(Or.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ir})):new Promise((e=>{this.getSurveys((i=>{var r,s=null!==(r=i.find((i=>i.id===t)))&&void 0!==r?r:null;if(s){var n=this.Jl(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var r;if(A(this._surveyManager))Or.warn("init was not called");else{var s="string"==typeof t?this.Zl(t):t;if(null!=s&&s.id)if($r.includes(s.type)){var n=null==Kt?void 0:Kt.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){Or.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout((()=>{var t,i;this.Dl.delete(a),this.ls||(Or.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),Or.info("Survey "+s.id+" rendered"))}),1e3*s.appearance.surveyPopupDelaySeconds);this.Dl.add(a)}else this._surveyManager.renderSurvey(s,n,e);else Or.warn("Survey element not found")}else Or.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Or.warn("Survey not found")}}displaySurvey(t,i){var r;if(A(this._surveyManager))Or.warn("init was not called");else{var s=this.Zl(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&&Or.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var a=this.Ql(s);if(!a.eligible)return void Or.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 Or.warn("Survey not found")}}cancelPendingSurvey(t){A(this._surveyManager)?Or.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}class Dr{on(t,i){return this.Ka[t]||(this.Ka[t]=[]),this.Ka[t].push(i),()=>{this.Ka[t]=this.Ka[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.Ka[t]||[])e(i);for(var r of this.Ka["*"]||[])r(t,i)}constructor(){this.Ka={}}}function Nr(t,i,e){if(A(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 zr{constructor(t){this.Kl=new Set,this.Yl=new Set,this.Xl=new Dr,this.tu=(t,i)=>this.eu(t,i)&&this.iu(t,i)&&this.ru(t,i)&&this.nu(t,i),this.eu=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t}init(){var t,i;F(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.su=null==(i=this._instance)?void 0:i._addCaptureHook(((t,i)=>{this.on(t,i)})))}dispose(){var t;null==(t=this.su)||t.call(this),this.su=void 0,this.Xl=new Dr}register(t){var i,e;if(!F(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i;this.Kl.add(t),null==(i=t.steps)||i.forEach((t=>{this.Yl.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Kl.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&r.add(t.selector)}))})),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Kl.clear(),this.Yl.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Yl.has(t)||this.Yl.has(i.event))&&this.Kl.forEach((t=>{this.au(i,t)&&this.Xl.emit("actionCaptured",t.name)}))}ou(t){this.onAction("actionCaptured",(i=>t(i)))}au(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.tu(t,e))return!0;return!1}onAction(t,i){return this.Xl.on(t,i)}iu(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!Nr(r,i.url,i.url_matching||"contains"))return!1}return!0}ru(t,i){return!!this.lu(t,i)&&!!this.uu(t,i)&&!!this.hu(t,i)}lu(t,i){var e;if(null==i||!i.href)return!0;var r=this.du(t);if(r.length>0)return r.some((t=>Nr(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&Nr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}uu(t,i){var e;if(null==i||!i.text)return!0;var r=this.du(t);if(r.length>0)return r.some((t=>Nr(t.text,i.text,i.text_matching||"exact")||Nr(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;!A(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=>Nr(t,n,a))))}hu(t,i){var e,r;if(null==i||!i.selector)return!0;var s=null==t||null==(e=t.properties)?void 0:e.$element_selectors;if(null!=s&&s.includes(i.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&n)try{return new RegExp(i.selector_regex).test(n)}catch(t){return!1}return!1}du(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}nu(t,i){return null==i||!i.properties||0===i.properties.length||br(i.properties.reduce(((t,i)=>{var e=k(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 Ur{constructor(t){var i;this.vu=[],this._instance=t,this.cu=new Map,this.fu=new Map,this.pu=new Map,this.gu=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId((t=>this.mu(t)))}yu(t){return!1}bu(){return null}_u(t){}wu(){}ku(t,i){return!!t&&br(t.propertyFilters,null==i?void 0:i.properties)}Su(t,i){var e=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach((i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}}))})),e}xu(t,i,e){var r=(e===Tr?this.cu:this.fu).get(t),s=[];return this.Cu((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find((i=>i.name===t));return this.ku(n,i)}))}register(t){this.Tu(t,!1)}replace(t){this.Tu(t,!0)}Tu(t,i){var e;F(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Mu(t,i),this.Eu(t,i))}Eu(t,i){var e=t.filter((t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length}));if(i&&this.pu.clear(),0!==e.length){this.Iu||(this.Iu=new zr(this._instance),this.Iu.init(),this.Iu.ou((t=>this.onAction(t))));var r=[];e.forEach((t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach((i=>{if(r.push(i),i.name){var e,s=null!==(e=this.pu.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.pu.set(i.name,s)}}))})),i?this.Iu.replace(r):this.Iu.register(r)}else{var s;i&&(null==(s=this.Iu)||s.replace([]))}}Ru(t,i){i.forEach(((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach((t=>{s.includes(t)||s.push(t)})),t.set(e,s)}))}Mu(t,i){var e,r,s=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0})),n=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0})),a=this.Su(t,Tr),o=this.Su(t,Ar);i?(this.cu=a,this.fu=o):(this.Ru(this.cu,a),this.Ru(this.fu,o)),(0!==s.length||0!==n.length)&&(null!==(e=this.su)&&void 0!==e||(this.su=null==(r=this._instance)?void 0:r._addCaptureHook(((t,i)=>{this.onEvent(t,i)}))))}onEvent(t,i){var e,r,s=this.Pu(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.Au(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Fu([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Ou(n),void this.Lu([n])}if(this.fu.has(t)){var o=this.xu(t,i,Ar);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Fu(o.map((t=>t.id))),o.forEach((t=>this.Du(t.id))))}if(this.cu.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.cu.get(t)});var l=this.xu(t,i,Tr);this.$u(l.map((t=>t.id)))}}onAction(t){this.pu.has(t)&&this.$u(this.pu.get(t)||[])}$u(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.yu(s)?this.Ou(s)&&this.Nu(s):r.push(s);r.length>0&&(this.vu=[...new Set([...this.vu,...r])]),this.Pu().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Ou(t){this.vu=this.vu.filter((i=>i!==t));var i=this.qu();return!i.includes(t)&&(this.ju([...i,t]),this.Bu(),!0)}Fu(t){var i=new Set(t);this.vu=this.vu.filter((t=>!i.has(t)));var e=this.Hu(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.ju(r),0===r.length&&this.Uu()),this.Lu(t)}zu(){var t,i=this.bu();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}Nu(t){if(this.bu()){var i=this.zu();this._u(e({},i,{[t]:Date.now()}))}}Lu(t){if(this.bu()){var i=this.zu(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],a=s[1];t.includes(n)?r=!0:e[n]=a}r&&(E(e)?this.wu():this._u(e))}}Wu(){this.bu()&&this.wu()}getActivationTimestamp(t){if(this.qu().includes(t)){var i=this.zu()[t];return R(i)?i:void 0}}Hu(){var t,i=this.Vu();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}qu(){var t,i,e=this.Hu();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Gu()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Bu(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Zu(i)}Uu(){this.Qu()}mu(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Gu()];if(e&&e!==t){var r=this.Hu(),s=this.zu();r.length>0&&(this.ju([]),r.filter((t=>R(s[t]))).forEach((t=>this.Du(t)))),this.Uu(),this.Wu()}}getActivatedIds(){return[...new Set([...this.qu(),...this.vu])].filter((t=>!this.Ju(t)))}dispose(){var t,i,e;null==(t=this.gu)||t.call(this),this.gu=void 0,null==(i=this.su)||i.call(this),this.su=void 0,null==(e=this.Iu)||e.dispose(),this.Iu=void 0}reset(){this.vu=[],this.Hu().length>0&&this.ju([]),this.Uu(),this.Wu()}getEventToItemsMap(){return this.cu}Ku(){return this.Iu}}class Hr extends Ur{constructor(t){super(t)}Vu(){return _e}Gu(){return be}bu(){return me}_u(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[me]:t})}wu(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(me)}yu(t){var i,e;this.Cu((i=>{e=i.find((i=>i.id===t))}));var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return R(r)&&r>0}Yu(){return Rr}Cu(t){var i;null==(i=this._instance)||i.getSurveys(t)}Du(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Pu(){return Or}ju(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[_e]:t})}Zu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[be]:t})}Qu(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(be)}Ju(){return!1}Au(t,i){var e;this.Cu((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return fr(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===Rr?"consume":"ignore":t===Rr?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class qr{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);F(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach((t=>this._instance.unregister(t))):this._instance.unregister(t)}}class Vr{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==He?void 0:He.__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 Hr(this._instance)}}var Br=null!=Vt&&Vt.location?Re(Vt.location.hash,"__posthog")||Re(location.hash,"state"):null,Wr="_postHogToolbarParams",Kr=Yt("[Toolbar]"),Jr=Yt("[FeatureFlags]");class Gr{constructor(t,i){void 0===i&&(i=!1),this.Xu=!1,this.update(t,i)}update(t,i){this.th=((t,i)=>{var e,r,s,n,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:k(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Xu||(Jr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Xu=!0),F(t.flag_keys)||k(t.flag_keys)||Jr.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.th}}var Zr=Yt("[FeatureFlags]"),Qr=Yt("[FeatureFlags]",{debugEnabled:!0}),Yr="\" failed. Feature flags didn't load in time.",Xr="connection_error",ts=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},is=t=>{var i={};for(var e of ii(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},es=Yt("[Error tracking]"),rs=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],ss=["__firefox__","__gCrWeb"],ns="Refusing to render web experiment since the viewer is a likely bot",as={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>pr(i,t),not_regex:(t,i)=>!pr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class os{get Wi(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{os.eh("retrieved web experiments from the server"),i.ih=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.ih&&(os.eh("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.ih)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);C(r)&&t.variants[r]&&i.rh(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];os.nh(n,i._instance)&&i.rh(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())os.eh(ns);else if(!this.Wi.disable_web_experiments){if(A(this.ih))return this.ih=new Map,this.loadIfEnabled(),void this.previewWebExperiment();os.eh("applying feature flags",t),t.forEach((t=>{var i;if(this.ih&&null!=(i=this.ih)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ih)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.rh(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=os.getWindowLocation();if(null!=t&&t.search){var i=Te(null==t?void 0:t.search,"__experiment_id"),e=Te(null==t?void 0:t.search,"__experiment_variant");i&&e&&(os.eh("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.sh(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.Wi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Wi.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Wi.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}sh(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(os.eh("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.rh(r[0].name,i,r[0].variants[i].transforms))}static nh(t,i){return!A(t.conditions)&&os.ah(t,i)&&os.oh(t)}static ah(t,i){var e;if(A(t.conditions)||A(null==(e=t.conditions)?void 0:e.url))return!0;var r=os.getWindowLocation();if(r){var s,n,a,o=ni(i,r.href);return null==(s=t.conditions)||!s.url||as[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==Vt?void 0:Vt.location}static oh(t){var i;if(A(t.conditions)||A(null==(i=t.conditions)?void 0:i.utm))return!0;var e=ir();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 eh(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];Qt.info("[WebExperiments] "+t,e)}rh(t,i,e){this._is_bot()?os.eh(ns):"control"!==i?e.forEach((e=>{if(e.selector){var r;os.eh("applying transform of variant "+i+" for experiment "+t+" ",e);var s=null==(r=document)?void 0:r.querySelectorAll(e.selector);null==s||s.forEach((t=>{var i=t;e.html&&(i.innerHTML=e.html),e.css&&i.setAttribute("style",e.css)}))}})):os.eh("Control variants leave the page unmodified.")}_is_bot(){return Wt&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&g(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>g(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver}(Wt,this.Wi.custom_blocked_useragents):void 0}}var ls=Yt("[Conversations]"),us="Conversations not available yet.";function hs(t,i){var e,r,s,n,a,o,l,u=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,v=null!=i&&i.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,d=F(v)?Math.max(h,2048):Math.max(h,v),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(a=null==c?void 0:c["service.name"])&&void 0!==a?a:null==t?void 0:t.serviceName)&&void 0!==n?n:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(o=null==c?void 0:c["service.version"])&&void 0!==o?o:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var vs=["debug","log","warn","error","info"],ds="console",cs="__posthogHandledLogsRequestError",fs=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[cs]=!0,e},ps=t=>!!t&&"object"==typeof t&&!0===t[cs],gs={featureFlags:class{constructor(t){this.name="featureFlags",this.lh=!1,this.featureFlagEventHandlers=[],this.I=Zr,this.uh={},this.hh={},this.dh=[],this.fh=!1,this.ph=!1,this.gh=0,this.mh=!1,this.yh=!1,this.bh=!1,this._h=!1,this.wh=0,this.It=()=>{var t=this.kh();this.wh=0,t&&this.reloadFeatureFlags()},this.Sh=()=>{var t,i=this.xh;F(i)||this.Wi.remoteRequestsDisabled||!Kt||"hidden"===Kt.visibilityState||Date.now()-(null!==(t=this.Ch)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Th())},this.Et=()=>{"visible"===(null==Kt?void 0:Kt.visibilityState)&&this.Sh()},"get"in t?this.us=t:(this.Mh=new Gr(t.config,t._shouldDisableFlags()),this.us=this.Mh)}updateConfig(t,i){var e;null==(e=this.Mh)||e.update(t,i),this.vs&&this.Eh()}setup(t){return this.ql=t,this.I=t.logger.createLogger("[FeatureFlags]"),Pr(t.kv.initialize(),(()=>{this.ql===t&&(this.ql=void 0,this.vs=t,this.Ih(t))}))}Ih(t){if(this.vs===t)return Vt&&ri(Vt,"online",this.It),this.Eh(),this.Rh=t.registerDynamicEventProperties((()=>this.Ph()?this.uh:this.hh)),this.Ah(),this.initialize()}Eh(){var t=this.Wi.refreshIntervalMs,i=!this.Wi.remoteRequestsDisabled&&Kt&&!F(t)&&t>0?t:void 0;i!==this.xh&&(this.Fh(),F(i)||(this.xh=i,this.Th(),null!=Kt&&Kt.addEventListener&&ri(Kt,Ce,this.Et)))}Th(){F(this.xh)||(F(this.Oh)||clearInterval(this.Oh),this.Ch=Date.now(),this.Oh=setInterval(this.Sh,this.xh))}Fh(){F(this.Oh)||(clearInterval(this.Oh),this.Oh=void 0,null==Kt||null==Kt.removeEventListener||Kt.removeEventListener(Ce,this.Et)),this.xh=void 0,this.Ch=void 0}destroy(){this.Lh()}dispose(){this.Lh()}Lh(){var t;this.Fh(),this.gh++,this.yh=!1,this.ql=void 0,this.vs&&(this.Dh(),null==(t=this.Rh)||t.dispose(),this.Rh=void 0,this.dh=[],null==Vt||Vt.removeEventListener("online",this.It),this.vs=void 0)}get Wi(){return this.us.get()}$h(t){var i;return null==(i=this.vs)?void 0:i.kv.get(t)}Hr(t){this.Nh((()=>{var i;return null==(i=this.vs)?void 0:i.kv.set(t)}))}$r(t){this.Nh((()=>{var i;return null==(i=this.vs)?void 0:i.kv.remove(t)}))}Nh(t){try{t()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}Ah(){var t={};for(var i of[ne,le,ue,ve]){var r=this.$h(i);F(r)||(t[i]=r)}this.uh=t;var s=e({},t),n=this.$h(se);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.hh=s}Ph(){var t=this.Wi.cacheTtlMs;if(!t||0>=t)return!1;var i=this.$h(xe);return"number"!=typeof i||Date.now()-i>t}qh(){return!!this.Ph()&&(this._h||this.ph||(this._h=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}jh(){var t=this.Wi.evaluationContexts;return null!=t&&t.length?t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Bh(){var t=this.Wi.flagKeys;if(!F(t))return t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),i}))}initialize(){var t,i,e=this.Wi,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,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.Hh({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,i,r){var a,o,l=null!=r&&r.merge&&null!==(a=this.$h(se))&&void 0!==a?a:{},u=null!=r&&r.merge&&null!==(o=this.$h(le))&&void 0!==o?o:{},h=e({},l,t),v=e({},u,i),d={};for(var c of Object.entries(h)){var f=c[0],p=c[1];d[f]={key:f,enabled:s(p),variant:n(p),reason:void 0,metadata:F(null==v?void 0:v[f])?void 0:{id:0,version:void 0,description:void 0,payload:v[f]}}}this.Hh({flags:d})}get hasLoadedFlags(){return this.fh}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.$h(oe),i=this.$h(ve),r=this.$h(de);if(!r&&!i)return t||{};var s=ti({},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=F(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=F(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.lh||(this.I.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.lh=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map((e=>{var a=t[e];return{key:e,enabled:s(a),variant:n(a),payload:r(i[e])}}))}getFlagVariants(){var t=this.$h(se),i=this.$h(ve);if(!i)return t||{};for(var e=ti({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.lh||(this.I.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.lh=!0),e}getFlagPayloads(){var t=this.$h(le),i=this.$h(de);if(!i)return t||{};for(var e=ti({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.lh||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.lh=!0),e}reloadFeatureFlags(){this.mh||this.Wi.featureFlagsDisabled||this.kh()||this.Uh||(this.dh.slice().forEach((t=>{try{t()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}})),this.Uh=setTimeout((()=>{this.zh()}),5))}Dh(){clearTimeout(this.Uh),this.Uh=void 0}onReloading(t){return this.dh.push(t),()=>{this.dh=this.dh.filter((i=>i!==t))}}ensureFlagsLoaded(){this.fh||this.ph||this.Uh||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.mh=t}resetFlagCallReported(){this.$r(we)}zh(t){this.Dh();var i=this.vs;if(i&&!this.Wi.remoteRequestsDisabled&&!this.kh())if(this.ph)this.yh=!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.$h(ce)||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.$h(fe),timezone:er()};F(i.deviceId)||(r.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.Wi.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this.jh();s.length&&(r.evaluation_contexts=s);var n=this.Bh();F(n)||(r.flag_keys=n);var a=this.Wi.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),l=this.gh;this.ph=!0;var u=()=>{this.yh&&(this.yh=!1,this.zh())},h=t=>{this.ph=!1,l===this.gh?(this.Hr({[Se]:[Xr]}),this.I.error("Feature flag request failed",t),u()):u()};try{i.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.Wi.compression,sentAt:"body",timeoutMs:this.Wi.requestTimeoutMs}).then((t=>{var i,e,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.ph=!1,l===this.gh){if(this.Wh(t.statusCode),n||this.yh||(this.$anon_distinct_id=void 0),!r.disable_flags||this.yh){this.bh=!n;var o=[];t.error?o.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Xr:"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.Hr({[Se]:o}),h?this.I.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):r.disable_flags||this.Hh(s,n,{partialResponse:a}),u()}}else u()})).catch(h)}catch(t){h(t)}}}kh(){return Oe(this.wh,3)}Wh(t){this.wh=Me(t,this.wh,3,(()=>this.I.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this.bh)if(this.fh||this.getFlags()&&this.getFlags().length>0){if(!this.qh()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+t+Yr)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.bh)if(this.fh||this.getFlags()&&this.getFlags().length>0){if(!this.qh()){var s,n=this.getFlagVariants(),a=t in n,o=n[t],l=this.getFlagPayloads()[t],u=String(o),h=this.$h(ue)||void 0,v=this.$h(xe)||void 0,d=this.$h(we)||{};if(this.Wi.deduplicateCallsPerSession){var c,f=null==(c=this.vs)?void 0:c.session.sessionId,p=this.$h(ke);f&&f!==p&&(d={},s=f)}if(i.send_event||!("send_event"in i))if(t in d&&d[t].includes(u))s&&this.Hr({[we]:d,[ke]:s});else{var g,_,b,m,y,w,S,x,E,C,P,T;k(d[t])?d[t].push(u):d[t]=[u],this.Hr(e({[we]:d},s?{[ke]:s}:{}));var A=this.getFeatureFlagDetails(t),R=[...null!==(g=this.$h(Se))&&void 0!==g?g:[]];F(o)&&R.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:o,$feature_flag_payload:null!=l?l:null,$feature_flag_request_id:h,$feature_flag_evaluated_at:v,$feature_flag_bootstrapped_response:null!==(_=null==(b=this.Wi.bootstrap)||null==(b=b.featureFlags)?void 0:b[t])&&void 0!==_?_:null,$feature_flag_bootstrapped_payload:null!==(m=null==(y=this.Wi.bootstrap)||null==(y=y.featureFlagPayloads)?void 0:y[t])&&void 0!==m?m:null,$used_bootstrap_value:!this.bh};F(null==A||null==(w=A.metadata)?void 0:w.has_experiment)||(O.$feature_flag_has_experiment=A.metadata.has_experiment),F(null==A||null==(S=A.metadata)?void 0:S.version)||(O.$feature_flag_version=A.metadata.version);var M,I=null!==(x=null==A||null==(E=A.reason)?void 0:E.description)&&void 0!==x?x:null==A||null==(C=A.reason)?void 0:C.code;I&&(O.$feature_flag_reason=I),null!=A&&null!=(P=A.metadata)&&P.id&&(O.$feature_flag_id=A.metadata.id),F(null==A?void 0:A.original_variant)&&F(null==A?void 0:A.original_enabled)||(O.$feature_flag_original_response=F(A.original_variant)?A.original_enabled:A.original_variant),null!=A&&null!=(T=A.metadata)&&T.original_payload&&(O.$feature_flag_original_payload=null==A||null==(M=A.metadata)?void 0:M.original_payload),R.length&&(O.$feature_flag_error=R.join(",")),this.Vh(O)}else s&&this.Hr({[we]:d,[ke]:s});if(a)return{key:t,enabled:!!o,variant:"string"==typeof o?o:void 0,payload:r(l)}}}else this.I.warn('getFeatureFlagResult for key "'+t+Yr)}Vh(t){try{var i;null==(i=this.vs)||i.capture("$feature_flag_called",t).catch((t=>{this.I.error("Failed to capture feature flag call",t)}))}catch(t){this.I.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Gh(t,i)}Gh(t,e){var r=this;return i((function*(){var i=r.vs;if(i){var s={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=r.jh();n.length&&(s.evaluation_contexts=n);var a,o=r.Bh();F(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.Wi.compression,sentAt:"body",timeoutMs:r.Wi.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;a=(null==u?void 0:u[t])||void 0}catch(t){return void r.I.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){r.I.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.bh)return i.defaultValue;if(!(this.fh||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+t+Yr),i.defaultValue;var e=this.getFeatureFlag(t,i);return F(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((i=>i!==t))}receivedFeatureFlags(t,i,e){this.Hh(t,i,e)}Hh(t,i,r){if(this.vs){this.fh=!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=Zr);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 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 v=t.requestId,d=t.evaluatedAt;if(k(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var f=0;u.length>f;f++)c[u[f]]=!0;return{[ne]:u,[se]:c,[he]:!1}}var p=u,g=h,_=l;if(null!=n&&n.partialResponse)p=e({},i,p),g=e({},r,g),_=e({},s,_);else if(t.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter((t=>{var i;return!(null!=(i=l[t])&&i.failed)})));p=e({},i,Object.fromEntries(Object.entries(p).filter((t=>b.has(t[0]))))),g=e({},r,Object.fromEntries(Object.entries(g||{}).filter((t=>b.has(t[0]))))),_=e({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>b.has(t[0])))))}else p=e({},i,p),g=e({},r,g),_=e({},s,_);return e({[ne]:Object.keys(is(p)),[se]:p||{},[le]:g||{},[oe]:_||{},[he]:!0===t.minimalFlagCalledEvents},v?{[ue]:v}:{},d?{[xe]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.I);s&&this.Hr(s),i||(this._h=!1),this.Zh(i)}}override(t,i){void 0===i&&(i=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Qh(t)}Qh(t){if(this.vs){if(!1===t)return this.$r([ve,de]),this.Zh(),void Qr.info("All overrides cleared");if(k(t))return this.Hr({[ve]:ts(t)}),this.Zh(),void Qr.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.lh=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[ve]=k(s)?ts(s):s),n&&(r[de]=n),Object.keys(r).length&&this.Hr(r),!1===s&&!1===n?this.$r([ve,de]):!1===s?this.$r(ve):!1===n&&this.$r(de),this.Zh(),!1===s?Qr.info("Flag overrides cleared"):s&&Qr.info("Flag overrides set",{flags:s}),void(!1===n?Qr.info("Payload overrides cleared"):n&&Qr.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Hr({[ve]:t}),this.Zh(),void Qr.info("Flag overrides set",{flags:t});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.fh){var i=this.Jh(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.I.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var s=(this.$h(ae)||[]).find((i=>i.flagKey===t)),n={["$feature_enrollment/"+t]:i},a={$feature_flag:t,$feature_enrollment:i,$set:n};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r);var o=e({},this.getFlagVariants(),{[t]:i});this.Hr({[ne]:Object.keys(is(o)),[se]:o,[ce]:e({},this.$h(ce)||{},n)}),this.Zh();try{var l;null==(l=this.vs)||l.capture("$feature_enrollment_update",a).catch((t=>{this.I.error("Failed to capture early access feature enrollment",t)}))}catch(t){this.I.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.$h(ae);!r||i?this.Kh(t,e):t(r)}Kh(t,e){var r=this;return i((function*(){var i=r.vs;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.Hr({[ae]:s=a.json.earlyAccessFeatures})}catch(t){return void r.I.error("Early access feature request failed",t)}try{t(s)}catch(t){r.I.error("Early access feature callback failed",t)}}}))()}Jh(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter((t=>i[t])),flagVariants:Object.keys(i).filter((t=>i[t])).reduce(((t,e)=>(t[e]=i[e],t)),{})}}Zh(t){this.Ah();var i=this.Jh(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.I.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Yh(t,i)}Yh(t,i){void 0===i&&(i=!0);var r=this.$h(ce)||{},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.Hr({[ce]:e({},r,a,s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.$h(ce)||{});t.forEach((t=>{delete r[t]})),this.Hr({[ce]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.$r(ce),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.$h(fe)||{},s=e({},r);for(var n of Object.keys(t))s[n]=e({},r[n],t[n]);this.Hr({[fe]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.$h(fe)||{};this.Hr({[fe]:e({},i,{[t]:{}})})}else this.$r(fe)}reset(){this.gh++,this.yh=!1,this.uh={},this.hh={},this.fh=!1,this.mh=!1,this.bh=!1,this.$anon_distinct_id=void 0,this.Dh(),this.lh=!1,this.wh=0}}},_s={sessionRecording:class{get Wi(){return this._instance.config}get Qa(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Xh)||!t.isStarted)}get status(){var t,i;return this.td===dr||this.td===cr?this.td:null!==(t=null==(i=this.Xh)?void 0:i.status)&&void 0!==t?t:this.td}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.td=hr,this.ed=void 0,this.rd=!1,this._t=(()=>{var t;if(null==Kt||!Kt.visibilityState||"visible"===Kt.visibilityState)return!0;var i=null==Vt||null==(t=Vt.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some((t=>"visible"===t.name))})(),this.Et=()=>{var t;"visible"===(null==Kt?void 0:Kt.visibilityState)&&(this._t=!0,null==(t=this.Xh)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=t,!this._instance.sessionManager)throw yr.error("started without valid sessionManager"),new Error(mr+" started without valid sessionManager. This is a bug.");if("always"===this.Wi.cookieless_mode)throw new Error(mr+' cannot be used with cookieless_mode="always"');null!=Kt&&Kt.addEventListener&&ri(Kt,"visibilitychange",this.Et)}initialize(){this.startIfEnabledOrStop()}dispose(){this.rd=!0,null==Kt||null==Kt.removeEventListener||Kt.removeEventListener("visibilitychange",this.Et),this.stopRecording()}get nd(){var t,i=!(null==(t=this._instance.get_property(re))||!t.enabled),e=!this.Wi.disable_session_recording,r=this.Wi.disable_session_recording||this._instance.consent.isOptedOut();return Vt&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.rd||this.nd&&null!=(i=this.Xh)&&i.isStarted)){var e=!F(Object.assign)&&!F(Array.from);this.nd&&e?(this.sd(t),yr.info("starting")):(this.td=hr,this.stopRecording())}}sd(t){var i,e,r;this.nd&&(this.td!==dr&&this.td!==cr&&(this.td=vr),null!=He&&null!=(i=He.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=He.__PosthogExtensions__)&&e.initSessionRecording?this.ad(t):null==(r=He.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.od,(i=>{if(i)return this._instance.register_for_session({[Ee]:!0}),yr.error("could not load recorder",i);this.ad(t)})))}stopRecording(){var t,i;null==(t=this.ed)||t.call(this),this.ed=void 0,null==(i=this.Xh)||i.stop()}ld(){var t,i;null==(t=this.ed)||t.call(this),this.ed=void 0,null==(i=this.Xh)||i.discard()}ud(){var t,i;null==(t=this.Qa)||t.unregister("$session_is_sampled"),null==(i=this.Qa)||i.unregister("$replay_sample_rate")}hd(t,i){if(A(t))return null;var e,r=R(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(yr.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}dd(t){if(this.Qa){var i,r,s=this.Qa,n=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.hd(null==(i=this.Wi.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.hd(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;A(o)&&this.ud();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[re]: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:F(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(i=this.ed)||i.call(this),this.ed=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.dd(i),void this.ld()):(this.dd(i),void this.startIfEnabledOrStop()):(this.td===dr&&(this.td=cr,yr.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.Xh)&&e.log?this.Xh.log(t,i):yr.warn("log called before recorder was ready")}get od(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(re);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}vd(){var t,i=this._instance.get_property(re);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return yr.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!A(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}ad(t){var i,e,r;if(!this.rd){if(null==(i=He.__PosthogExtensions__)||!i.initSessionRecording)return yr.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Ee]:!0});var s;if(this.Xh||(this.Xh=null==(s=He.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this._t),this.Xh._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.vd()){if(this.td===cr||this.td===dr)return;return this.td=dr,yr.info("persisted remote config is stale, requesting fresh config before starting"),void new ur(this._instance).load()}this.td=vr,null==(e=(r=this.Xh).setDocumentWasEverVisible)||e.call(r,this._t),this.Xh.start(t)}}onRRwebEmit(t){var i;null==(i=this.Xh)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Xh||null==(i=this.Qa)||i.register({$replay_override_linked_flag:!0}),null==(t=this.Xh)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.Xh||null==(i=this.Qa)||i.register({$replay_override_sampling:!0}),null==(t=this.Xh)||t.overrideSampling()}overrideTrigger(t){var i,e;this.Xh||null==(e=this.Qa)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Xh)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Xh)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Xh)||!e.tryAddCustomEvent(t,i))}}},bs={autocapture:class extends Ne{constructor(t){super(new ze(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.fd=this.pd()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.gd();return!!(t.path||t.search||this.md(t))}startIfEnabled(){this.isEnabled&&(Qt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.fd=this.pd(),this.startIfEnabled()}stop(){this.yd&&this.yd(),this.yd=void 0,this.bd&&this.bd(),this.bd=void 0,Qt.info("History API monitoring stopped")}monitorHistoryChanges(){Vt&&Vt.history&&(this._d("pushState"),this._d("replaceState"),this.wd(),this.md()&&this.kd())}_d(t){var i;if(Vt&&(null==(i=Vt.history[t])||!i.__posthog_wrapped__)){var e=this;Ge(Vt.history,t,(i=>function(r,s,n){i.call(this,r,s,n),e.Sd(t)}))}}pd(){var t=null==Vt?void 0:Vt.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}gd(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:x(t)?t:{}}md(t){return void 0===t&&(t=this.gd()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}xd(t){var i=this.gd(),e=this.fd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.md(i)&&t.hash!==e.hash))}Sd(t){try{var i=this.pd();if(!i)return;this.xd(i)&&this._instance.capture("$pageview",{navigation_type:t}),this.fd=i}catch(i){Qt.error("Error capturing "+t+" pageview",i)}}wd(){if(!this.yd){var t=()=>{this.Sd("popstate")};ri(Vt,"popstate",t),this.yd=()=>{Vt&&Vt.removeEventListener("popstate",t)}}}kd(){if(!this.bd){var t=()=>{this.Sd("hashchange")};ri(Vt,"hashchange",t),this.bd=()=>{Vt&&Vt.removeEventListener("hashchange",t)}}}},heatmaps:class{get Wi(){return this.instance.config}constructor(t){var i;this.Cd=!1,this.rs=!1,this.Td=null,this.instance=t,this.Cd=!(null==(i=this.instance.persistence)||!i.props[Gi]),this.rageclicks=new Ki(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return x(this.Wi.capture_heatmaps)&&this.Wi.capture_heatmaps.flush_interval_milliseconds&&(t=this.Wi.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return A(this.Wi.capture_heatmaps)?A(this.Wi.enable_heatmaps)?this.Cd:this.Wi.enable_heatmaps:!1!==this.Wi.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.rs)return;wr.info("starting..."),this.Md(),this.Et()}else{var t;clearInterval(null!==(t=this.Td)&&void 0!==t?t:void 0),this.Ed(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Gi]:e}),this.Cd=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.yt;return this.yt=void 0,t}Id(t){kr(t.originalEvent)&&this.Ii(t.originalEvent,"deadclick")}Et(){this.Td&&clearInterval(this.Td),this.Td="visible"===(null==Kt?void 0:Kt.visibilityState)?setInterval(this.qa.bind(this),this.flushIntervalMilliseconds):null}Md(){Vt&&Kt&&(this.Rd=this.qa.bind(this),ri(Vt,Pe,this.Rd),this.Pd=t=>this.Ii(t||(null==Vt?void 0:Vt.event)),ri(Kt,"click",this.Pd,{capture:!0}),this.Ad=t=>this.Fd(t||(null==Vt?void 0:Vt.event)),ri(Kt,"mousemove",this.Ad,{capture:!0}),this.Od=new Be(this.instance,Ve,this.Id.bind(this)),this.Od.startIfEnabledOrStop(),this.Ld=this.Et.bind(this),ri(Kt,Ce,this.Ld),this.rs=!0)}Ed(){var t;Vt&&Kt&&(this.Rd&&Vt.removeEventListener(Pe,this.Rd),this.Pd&&Kt.removeEventListener("click",this.Pd,{capture:!0}),this.Ad&&Kt.removeEventListener("mousemove",this.Ad,{capture:!0}),this.Ld&&Kt.removeEventListener(Ce,this.Ld),clearTimeout(this.Dd),null==(t=this.Od)||t.stop(),this.rs=!1)}$d(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,i,e){for(var r=t;r&&vi(r)&&!di(r,"body");){if(r===e)return!1;var s=void 0;try{var n,a,o;s=null==(n=null!==(a=null==(o=r.ownerDocument)?void 0:o.defaultView)&&void 0!==a?a:Vt)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(_(i,s))return!0;r=xi(r)}return!1}(wi(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:e),target_fixed:n,type:i}}Ii(t,i){var r;if(void 0===i&&(i="click"),!hi(t.target)&&kr(t)){var s=this.$d(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Ai(wi(t),this.instance.config.rageclick)&&this.Wn(e({},s,{type:"rageclick"})),this.Wn(s)}}Fd(t){!hi(t.target)&&kr(t)&&(clearTimeout(this.Dd),this.Dd=setTimeout((()=>{this.Wn(this.$d(t,"mousemove"))}),500))}Wn(t){if(Vt){var i=this.Wi.disable_capture_url_hashes?H(Vt.location.href):Vt.location.href,e=this.Wi.custom_personal_data_properties,r=this.Wi.mask_personal_data_properties?[...Qe,...e||[]]:[],s=Ae(i,r,Xe);this.yt=this.yt||{},this.yt[s]||(this.yt[s]=[]),this.yt[s].push(t)}}qa(){this.yt&&!E(this.yt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Be,webVitalsAutocapture:class{constructor(t){var i;this.Cd=!1,this.rs=!1,this.yt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Nd=()=>{clearTimeout(this.qd),this.qd=void 0,0!==this.yt.metrics.length&&(this._instance.capture("$web_vitals",e({$current_url:this.yt.url},this.yt.metrics.reduce(((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.yt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.jd=t=>{var i;if(this.yt=this.yt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},A(null==t?void 0:t.name)||A(null==t?void 0:t.value))rr.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Bd(r);if(!F(s)){var n=R(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.Hd||this.Hd>t.value){this.yt.navigationKey!==n&&(this.Nd(),this.qd=setTimeout(this.Nd,this.flushToCaptureTimeoutMs)),F(this.yt.navigationKey)&&(this.yt.navigationKey=n,this.yt.url=s),this.yt.firstMetricTimestamp=F(this.yt.firstMetricTimestamp)?Date.now():this.yt.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,x(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of or){var h="url"===u&&"string"==typeof t.attribution[u]?this.Bd(t.attribution[u]):t.attribution[u];F(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;F(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.yt.metrics.push(o),this.yt.metrics.length===this.allowedMetrics.length&&this.Nd()}else rr.error("Ignoring metric with value >= "+this.Hd,t)}}},this.Ud=()=>{if(!this.rs){var t,i,r,s,n=!1,a=He.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.zd])||("web-vitals"===this.zd&&F(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!F(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!F(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,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.jd.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&i(this.jd.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.jd.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.jd.bind(this),d),this.rs=!0}else rr.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Cd=!(null==(i=this._instance.persistence)||!i.props[Xi]),this.startIfEnabled()}get Wd(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=x(this.Wd)?null==(t=this.Wd)?void 0:t.web_vitals_allowed_metrics:void 0;return A(e)?(null==(i=this._instance.persistence)?void 0:i.props[ee])||nr:e}get flushToCaptureTimeoutMs(){return(x(this.Wd)?this.Wd.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=x(this.Wd)?this.Wd.web_vitals_attribution:void 0;return O(t)?t?nr:[]:k(t)?t:ar}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t=x(this.Wd)?this.Wd.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Hd(){var t=x(this.Wd)&&R(this.Wd.__web_vitals_max_value)?this.Wd.__web_vitals_max_value:sr;return t>0&&6e4>=t?sr:t}get isEnabled(){var t=null==Jt?void 0:Jt.protocol;if("http:"!==t&&"https:"!==t)return rr.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=x(this.Wd)?this.Wd.web_vitals:O(this.Wd)?this.Wd:void 0;return O(i)?i:this.Cd}startIfEnabled(){this.isEnabled&&!this.rs&&(rr.info("enabled, starting..."),this.Ms(this.Ud))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=x(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=x(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xi]:e}),this._instance.persistence.register({[ee]:r})),this.Cd=e,this.startIfEnabled()}}}get zd(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ms(t){var i=He.__PosthogExtensions__,e=this.zd,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&F(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?rr.error("failed to load script",i):t()}))}Bd(t){var i=t||(null==Vt?void 0:Vt.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?H(i):i,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...Qe,...r||[]]:[];return Ae(e,s,Xe)}rr.error("Could not determine current URL")}}},ms={exceptionObserver:class{constructor(t){var i;this.Ud=()=>{var t;if(Vt&&this.isEnabled&&null!=(t=He.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=He.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=He.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=He.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Vd&&this.Wi.capture_unhandled_errors&&(this.Vd=i(this.captureException.bind(this))),!this.Gd&&this.Wi.capture_unhandled_rejections&&(this.Gd=e(this.captureException.bind(this))),!this.Zd&&this.Wi.capture_console_errors&&(this.Zd=r(this.captureException.bind(this)))}catch(t){We.error("failed to start",t),this.Qd()}}},this._instance=t,this.Jd=!(null==(i=this._instance.persistence)||!i.props[Zi]),this.oe=new U(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,I:We})),this.Wi=this.Kd(),this.startIfEnabledOrStop()}Kd(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return x(t)?i=e({},i,t):(F(t)?this.Jd:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Wi.capture_console_errors||this.Wi.capture_unhandled_errors||this.Wi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(We.info("enabled"),this.Qd(),this.Ms(this.Ud)):this.Qd()}Ms(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return We.error("failed to load script",i);t()}))}Qd(){var t,i,e;null==(t=this.Vd)||t.call(this),this.Vd=void 0,null==(i=this.Gd)||i.call(this),this.Gd=void 0,null==(e=this.Zd)||e.call(this),this.Zd=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Jd=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Zi]:this.Jd}),this.Wi=this.Kd(),this.startIfEnabledOrStop())}}onConfigChange(){this.Wi=this.Kd()}captureException(t){var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";this.oe.consumeRateLimit(s)?We.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.Yd=[],this.Xd=new ct([new Et,new It,new Ct,new Ft,new Mt,new Ot,new Tt,new $t],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=xt.test(l)?l.replace(xt,"$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||ft});var r}))}(n)}}("web:javascript",yt,St)),this._instance=t,this.Yd=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property(Qi))&&void 0!==i?i:[],this.tv=zt(this.ev()),this.iv=new Ut(this.tv)}onConfigChange(){this.tv=zt(this.ev()),this.iv.setConfig(this.tv)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],a=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Yd=n,this._instance.persistence&&this._instance.persistence.register({[Qi]:this.Yd,[Yi]:a})}}}get rv(){var t,i=!!this._instance.get_property(Yi),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.Xd.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.tv.enabled)try{if(!C(t)||0===t.trim().length)return void es.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)=>Dt.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.nv(i)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&es.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.iv.add(e({[jt]:t,[Lt]:(new Date).toISOString()},s))}catch(t){es.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.sv(i)){if(this.av(i))return this.ov("Exception dropped: matched a suppression rule"),void es.info("Skipping exception capture because a suppression rule matched");if(!this.rv&&this.lv(i))return this.ov("Exception dropped: thrown by a browser extension"),void es.info("Skipping exception capture because it was thrown by an extension");if(!this.rv&&this.uv(i))return this.ov("Exception dropped: thrown by an injected browser script"),void es.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.hv(i))return this.ov("Exception dropped: thrown by the PostHog SDK"),void es.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.tv.enabled&&A(t.$exception_steps)?this.dv(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return s&&this.iv.clear(),s}catch(t){return es.error("Failed to capture exception event. Dropping this exception.",t),void this.iv.clear()}}catch(t){return void es.error("Failed to process exception event. Ignoring this exception.",t)}var n}dv(t){try{var i=this.iv.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(i){return es.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}ov(t){this.tv.enabled&&this.iv.add({[jt]:t,[Lt]:(new Date).toISOString()})}nv(t){return x(t)?e({},t):{}}ev(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}av(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return C(e)&&e.length>0&&t.$exception_types.push(e),C(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Yd.some((t=>{var e=t.values.map((t=>{var e=_r[t.operator],r=i[t.key];if(!e||!r)return!1;var s=k(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 es.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}lv(t){return t.flatMap((t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]})).some((t=>{var i=t.filename;return!!i&&rs.some((t=>i.startsWith(t)))}))}uv(t){return t.some((t=>{var i=t.value;return C(i)&&ss.some((t=>i.includes(t)))}))}hv(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[],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}sv(t){return!A(t)&&k(t)}}},ys=e({productTours:class{get Qa(){return this._instance.persistence}constructor(t){this.vv=null,this.fv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.Qa&&this.Qa.register({[te]:!!i.productTours}),!xr(this._instance))return!this.vv&&A(null==(e=this.Qa)?void 0:e.props[ye])||Sr.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.vv)||r.stop(),this.vv=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.vv&&xr(this._instance)&&this.Ms((()=>this.pv()))}Ms(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?Sr.error("Could not load product tours script",i):t()}))}pv(){var t;!this.vv&&null!=(t=He.__PosthogExtensions__)&&t.generateProductTours&&(this.vv=He.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!k(this.fv)||i){var e=this.Qa;if(e){var r=e.props[ye];if(k(r)&&!i)return this.fv=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(xr(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||Sr.warn(s):Sr.error(s),void t([],{isLoaded:!1,error:s})}var n=k(i.json.product_tours)?i.json.product_tours:[];this.fv=n,e&&e.register({[ye]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.fv,{isLoaded:!0})}getActiveProductTours(t){A(this.vv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.vv.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.vv)||i.showTourById(t)}previewTour(t){this.vv?this.vv.previewTour(t):this.Ms((()=>{var i;this.pv(),null==(i=this.vv)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.vv)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.vv)||t.nextStep()}previousStep(){var t;null==(t=this.vv)||t.previousStep()}clearCache(){var t;this.fv=null,null==(t=this.Qa)||t.unregister(ye)}resetTour(t){var i;null==(i=this.vv)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.vv)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.vv)||i.cancelPendingTour(t)}}},gs),ws={siteApps:class{constructor(t){this.gv=0,this._instance=t,this.mv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yv(t,i){if(i){var e=this.globalsForEvent(i);this.mv.push(e),this.mv.length>1e3&&(this.mv=this.mv.slice(10))}}get siteAppLoaders(){var t;return null==(t=He._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.yv.bind(this));this.bv=()=>{t(),this.mv=[],this.bv=void 0}}}globalsForEvent(t){var i,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,Er),{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}}_v(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Fr.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)||(Fr.error("prepare_external_dependency_script returned null"),null):t}wv(){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==Kt?void 0:Kt.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.gv++,this.Sv)return this.xv();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._v(t);return i&&d.add(i),i},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!T(t)));return c(u,"appendChild",(t=>function(i){var e=f(i);return e?t.call(this,e):i})),c(u,"insertBefore",(t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i})),c(u,"replaceChild",(t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e})),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((t=>{c(t,"append",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})),c(t,"prepend",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach((t=>{c(t,"before",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})),c(t,"after",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})),c(t,"replaceWith",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)}))})),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",(t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null})),this.Sv=()=>{h.forEach((t=>t())),this.Sv=void 0},this.xv()}xv(){var t=!1;return()=>{var i;t||(t=!0,this.gv--,0===this.gv&&(null==(i=this.Sv)||i.call(this)))}}Cv(t,i){void 0===i&&(i=!0);var e=this.wv();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.mv.length&&(Fr.info("Processing "+this.mv.length+" events for site app with id "+t.id),this.mv.forEach((t=>this.Cv((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this.bv)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,Fr.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Cv((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){Fr.error(Cr+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){Fr.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}Tv(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}Mv(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Cv((()=>null==r.processEvent?void 0:r.processEvent(e)))}catch(i){Fr.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.Tv(),void this._instance.on("eventCaptured",(t=>this.Mv(t)))):void Fr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.bv)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,i=o.id,e=o.url;He["__$$ph_site_app_"+i]=s._instance,null==(t=He.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return Fr.error(Cr+i,t)}))};for(var o of n.siteApps)a()}else Fr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},ks={tracingHeaders:class{constructor(t){this.Ev=void 0,this.Iv=void 0,this.Rv=void 0,this.Ud=()=>{var t,i,e=this.Pv();e?(F(this.Ev)&&(this.Ev=null==(t=He.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),F(this.Iv)&&(this.Iv=null==(i=He.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Qd()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Ms(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return Ze.error("failed to load script",i);t()}))}Av(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Pv(){var t=this.Av();return k(t)?(k(this.Rv)?this.Rv.splice(0,this.Rv.length,...t):this.Rv=[...t],t.length>0?this.Rv:void 0):(k(this.Rv)&&this.Rv.splice(0),this.Rv=t||void 0,this.Rv)}Qd(){var t,i;null==(t=this.Ev)||t.call(this),null==(i=this.Iv)||i.call(this),this.Ev=void 0,this.Iv=void 0}startIfEnabledOrStop(){this.Pv()?this.Ms(this.Ud):this.Qd()}}},Ss=e({surveys:class extends Lr{constructor(t){var i;super(new Vr(t),{get projectToken(){return i.config.token},kv:new qr(i=t)}),this._instance=t}zl(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 Xt(t,(function(t,i){F(t)||F(i)||"undefined"===i||(e=encodeURIComponent(t instanceof File?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)})),s.join(i)}(l);return h&&u.push(h),u.length>0?a+"?"+u.join("&"):a}(t,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})}))}}},gs),xs={toolbar:class{constructor(t){this.instance=t}Fv(t){He.ph_toolbar_state=t}Ov(){var t;return null!==(t=He.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),si(this.instance.config))return!1;if(!Vt||!Kt)return!1;t=null!=t?t:Vt.location,e=null!=e?e:Vt.history;try{if(!i){try{Vt.localStorage.setItem("test","test"),Vt.localStorage.removeItem("test")}catch(t){return!1}i=null==Vt?void 0:Vt.localStorage}var r,s=Br||Re(t.hash,"__posthog")||Re(t.hash,"state"),n=s?ei((()=>JSON.parse(atob(decodeURIComponent(s)))))||ei((()=>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(Wr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Lv(t){var i=He.ph_load_toolbar||He.ph_load_editor;!A(i)&&S(i)?i(t,this.instance):Kr.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==Kt||!Kt.getElementById(ai));if(!Vt||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(Vt.localStorage.setItem(Wr,JSON.stringify(e({},s,{source:void 0}))),2===this.Ov())this.Lv(s);else if(0===this.Ov()){var n;this.Fv(1),null==(n=He.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return Kr.error("[Toolbar] Failed to load",t),void this.Fv(0);this.Fv(2),this.Lv(s)})),ri(Vt,"turbolinks:load",(()=>{this.Fv(0),this.loadToolbar(s)}))}return!0}Dv(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},Es=e({experiments:os},gs),Fs={conversations:class{constructor(t){this.$v=void 0,this._conversationsManager=null,this.Nv=!1,this.Me=null,this.qv=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.jv=t.ok,t.ok)){var i=t.config.conversations;A(i)||(O(i)?this.$v=i:(this.$v=i.enabled,this.Me=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.$v=void 0,this.Me=null,this.jv=void 0,this.qv=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Nv||this._instance.config.disable_conversations||si(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==He?void 0:He.__PosthogExtensions__;if(t&&!F(this.$v)&&this.$v)if(this.Me&&this.Me.token){this.Nv=!0;try{var i=t.initConversations;if(i)return this.Bv(i),void(this.Nv=!1);var e=t.loadExternalDependency;if(!e)return void this.Hv(Fe);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.Hv("Could not load conversations script",i):this.Bv(t.initConversations),this.Nv=!1}))}catch(t){this.Hv("Error initializing conversations",t),this.Nv=!1}}else ls.error("Conversations enabled but missing token in remote config.")}}Bv(t){if(this.Me)try{this._conversationsManager=t(this.Me,this._instance),this.qv=!1,ls.info("Conversations loaded successfully")}catch(t){this.Hv("Error completing conversations initialization",t)}else ls.error("Cannot complete initialization: remote config is null")}Hv(t,i){ls.error(t,i),this._conversationsManager=null,this.Nv=!1,this.qv=!0}show(){this._conversationsManager?this._conversationsManager.show():ls.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.$v&&!T(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":si(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.jv?"remote_config_failed":F(this.$v)?this.jv?"disabled_in_project":"remote_config_pending":this.$v?A(this.Me)||!this.Me.token?"missing_token":null!=He&&He.__PosthogExtensions__?this.Nv?"initializing":this.qv?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,e,r){var s=this;return i((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,r):(ls.warn(us),null)}))()}getMessages(t,e){var r=this;return i((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,e):(ls.warn(us),null)}))()}markAsRead(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(ls.warn(us),null)}))()}getTickets(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(ls.warn(us),null)}))()}requestRestoreLink(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(ls.warn(us),null)}))()}restoreFromToken(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(ls.warn(us),null)}))()}restoreFromUrlToken(){var t=this;return i((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(ls.warn(us),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()}}},Cs={logs:class{constructor(t){var i,r=this;this.name="logs",this.Uv=!1,this.zv=!1,this.Wv=!1,this.I=Yt("[logs]"),this.Vv=e({},this.I,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(ps)||r.I.error(...i)}}),this.Ma=[],this.Gv=[],this.wh=0,this.ls=!1,this.Zv=[],this.Qv=[],this.Jv=!1,this.Kv=!1,this.Yv=()=>{var t,i;this.ls||(this.wh=0,null==(t=this.Xv)||t.onReconnect(),null==(i=this.tc)||i.onReconnect())},this._instance=t,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Uv=!0),Vt&&ri(Vt,"online",this.Yv)}ec(t,i,e,r){var s,n=hs(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new st(this.ic(t,i),n,this.Vv,(()=>this.rc()),(t=>t()),void 0,r),n]}nc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Xv||this.sc!==i){var e;null==(e=this.Xv)||e.reset(),this.sc=i;var r=this.ec((()=>this.Ma),(t=>{this.Ma=t}));this.Xv=r[0],this.ac=r[1]}return this.Xv}oc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.tc||this.lc!==i){var e;null==(e=this.tc)||e.reset(),this.lc=i;var r=this.ec((()=>this.Gv),(t=>{this.Gv=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},ds);this.tc=r[0],this.uc=r[1]}return this.tc}setup(t){var i;if(!this.ls){this.vs=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.Uv=!0),(this.Uv||this.hc()&&this.dc())&&this.vc();var e=!1,r=t.onRemoteConfig((t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)}));this.ls?r.dispose():(this.cs=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.ls||(this.ls=!0,this.cc(),null==(t=this.cs)||t.dispose(),this.cs=void 0,this.vs=void 0,this.Wv=!1,null==Vt||Vt.removeEventListener("online",this.Yv),null==(i=this.fc)||i.call(this),this.fc=void 0,null==(e=this.Xv)||e.reset(),null==(r=this.tc)||r.reset())}onRemoteConfig(t){var i,e;if(!this.ls){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;A(r)?this.gc():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[ie]:!!r}),r?(this.Uv=!0,this.zv||this.vc(),this.loadIfEnabled()):this.gc())}}reset(){var t,i,e,r;this.cc(),null==(t=this.Xv)||t.clearQueue(),this.Ma=[],null==(i=this.Xv)||i.reset(),null==(e=this.tc)||e.clearQueue(),this.Gv=[],null==(r=this.tc)||r.reset(),this.wh=0}captureLog(t){this.ls||this.nc().captureLog(t)}captureConsoleLog(t){this.ls||this.oc().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.ls||this.oc().captureLog(t,{context:i,occurredAtMs:e})}dc(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[ie])}hc(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=He._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.cc(),null==(t=this.tc)||t.clearQueue(),this.Gv=[]}gc(){this.Uv||this.cc()}vc(){var t,i=this;if(!this.Jv&&null!=He&&He.console){var e=hs(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})(He.console[t])}catch(t){return 0}if(!r)return 0;i.Qv.push(Ge(He.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.mc(t,n,e)}catch(t){}return s.apply(He.console,n)};return n.__rrweb_original__=r,n})))};for(var s of vs)r(s);this.Jv=!0,this.yc=setTimeout((()=>{this.cc()}),3e4)}}mc(t,i,e){var r;if(this.Jv&&!this.Kv&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Zv.length){this.Kv=!0;try{this.Zv.push({level:t,args:i,occurredAtMs:Date.now(),context:this.rc()})}finally{this.Kv=!1}}}else this.cc()}cc(){if(this.Zv=[],this.Jv){for(var t of(this.Jv=!1,this.yc&&(clearTimeout(this.yc),this.yc=void 0),this.Qv))t();this.Qv=[]}}bc(){var t=this.Zv;return this.cc(),t}get logger(){return this._c||(this._c={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this._c}flushLogs(t){t?this.wc(t):(this.Xv&&this.Xv.flush().catch((t=>this.kc(t))),this.tc&&this.tc.flush().catch((t=>this.kc(t))))}kc(t){ps(t)||this.I.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.ls&&this.Uv&&!this.zv&&!this.Wv){var t=null==He?void 0:He.__PosthogExtensions__;if(!t)return this.I.error("PostHog Extensions not found."),void this.cc();var i=t.loadExternalDependency;if(!i)return this.I.error(Fe),void this.cc();this.Wv=!0;try{i(this._instance,"logs",(i=>{if(this.Wv=!1,!this.ls&&this.Uv){var e=t.logs;if(i||null==e||!e.initializeLogs)this.I.error("Could not load logs script",i),this.cc();else{var r,s,n=this.bc();this.fc=e.initializeLogs(null!==(r=this.vs)&&void 0!==r?r:this._instance),this.zv=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.vs)&&void 0!==s?s:this._instance,n))}}}))}catch(t){throw this.Wv=!1,t}}}ic(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===a.LogsQueue?t():void 0,setPersistedProperty(t,e){var r;t===a.LogsQueue&&i(null!==(r=e)&&void 0!==r?r:[])},On:t=>this.On(t),getLibraryId:()=>qt.LIB_NAME,getLibraryVersion:()=>qt.LIB_VERSION}}On(t){return new Promise((i=>{if(Oe(this.wh,3))i({kind:"fatal",error:fs(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout((()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:fs(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Sc(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.xc(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:fs(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}}))}xc(t){(0!==t||this._instance.__loaded)&&(this.wh=Me(t,this.wh,3,(()=>this.I.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes."))))}wc(t){this.Ma.length>0&&this.Cc(t,this.Ma,this.ac,qt.LIB_NAME,(t=>{this.Ma=t})),this.Gv.length>0&&this.Cc(t,this.Gv,this.uc,ds,(t=>{this.Gv=t}))}Cc(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var a=rt(n,et(e,qt.LIB_NAME,qt.LIB_VERSION),r,qt.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Sc(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}Sc(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}rc(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,A(s)||(i.sessionStartTimestamp=s),A(n)||(i.lastActivityTimestamp=n)}if(null!=He&&null!=(t=He.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?H(He.location.href):He.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Ps={metrics:class{constructor(t){this.I=Yt("[metrics]"),this._instance=t}initialize(){}nc(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Xv&&this.sc===e||(null==(i=this.Xv)||i.reset(),this.sc=e,this.Xv=new lt(this.ic(),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.I)),this.Xv}count(t,i,e){void 0===i&&(i=1),this.nc().count(t,i,e)}gauge(t,i,e){this.nc().gauge(t,i,e)}histogram(t,i,e){this.nc().histogram(t,i,e)}flush(t){if(!this.Xv)return Promise.resolve();if(t){var i=this.Xv.drainWindow();return i&&this.Jn(i,t),Promise.resolve()}return this.Xv.flush().catch((t=>this.I.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Xv)||t.reset()}ic(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Jn:t=>i.Jn(t),getLibraryId:()=>qt.LIB_NAME,getLibraryVersion:()=>qt.LIB_VERSION}}Jn(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.Tc(),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)})}}}))}))}Tc(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Ts=e({},gs,_s,bs,ms,ys,ws,Ss,ks,xs,Es,Fs,Cs,Ps),As=gs,Rs=_s,Os=bs,Ms=ms,$s=ys,Is=ws,js=Ss,Ls=ks,Ds=xs,Ns=Es,zs=Fs,Us=Cs,Hs=Ps;export{Ts as AllExtensions,Os as AnalyticsExtensions,zs as ConversationsExtensions,Ms as ErrorTrackingExtensions,Ns as ExperimentsExtensions,As as FeatureFlagsExtensions,Us as LogsExtensions,Hs as MetricsExtensions,$s as ProductToursExtensions,Rs as SessionReplayExtensions,Is as SiteAppsExtensions,js as SurveysExtensions,Ds as ToolbarExtensions,Ls 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=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function s(t){return"string"==typeof t||t}function n(t){return"string"==typeof t?t:void 0}var a=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}({}),o=20,l=1e3,u=1e4,h="[Circular]",v="[Truncated]",d="[Unserializable]",c="[Function]";function f(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}var p=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],g=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return p.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function _(t,i){return-1!==t.indexOf(i)}var b=function(t){return t.trim()},m=Object.prototype,y=m.hasOwnProperty,w=m.toString,k=Array.isArray||function(t){return"[object Array]"===w.call(t)},S=t=>"function"==typeof t,x=t=>t===Object(t)&&!k(t),E=t=>{if(x(t)){for(var i in t)if(y.call(t,i))return!1;return!0}return!1},F=t=>void 0===t,C=t=>"[object String]"==w.call(t),P=t=>C(t)&&0===t.trim().length,T=t=>null===t,A=t=>F(t)||T(t),R=t=>"[object Number]"==w.call(t)&&t==t,O=t=>"[object Boolean]"===w.call(t),M=t=>t instanceof FormData;function I(t){return null===t||"object"!=typeof t}function j(t,i){return{}.toString.call(t)==="[object "+i+"]"}function L(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 N(t,Error)}}function D(t){return"undefined"!=typeof Event&&N(t,Event)}function N(t,i){try{return t instanceof i}catch(t){return!1}}function z(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),R(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),z(e,i,e,r))}class U{constructor(t){this.k={},this.S=t.S,this.C=z(t.bucketSize,0,100,t.I),this.A=z(t.refillRate,0,this.C,t.I),this.R=z(t.refillInterval,0,864e5,t.I)}O(t,i){var e=Math.floor((i-t.lastAccess)/this.R);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.C),t.lastAccess=t.lastAccess+e*this.R)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.k[r];return s?this.O(s,e):this.k[r]=s={tokens:this.C,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.S)||i.call(this,t)),0===s.tokens)}stop(){this.k={}}}function H(t){return t?t.split("#")[0]:t}function q(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function V(t,i,e){return B.apply(this,arguments)}function B(){return(B=i((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=q((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var W={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}},K=W.info,J=0x8000000000000000,G={}.propertyIsEnumerable;function Z(t,i){try{return X(t,i,{ancestors:new WeakSet,remainingNodes:u},0)}catch(t){return[]}}function Q(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:v};if(e.remainingNodes--,O(t))return{boolValue:t};if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if("undefined"==typeof BigInt)return{stringValue:String(t)};var s=BigInt(t).toString();return t>=J||-J>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:f(t)};if("function"==typeof t)return{stringValue:c};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:h};if(r>=o)return{stringValue:v};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?f(a):String(a)}}e.ancestors.add(t);try{try{var l=t.toJSON;if("function"==typeof l)return Q(l.call(t),i,e,r+1)}catch(t){}return k(t)?{arrayValue:{values:Y(t,i,e,r+1)}}:{kvlistValue:{values:X(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:f(String(t))}}function Y(t,i,e,r){for(var s=[],n=Math.min(t.length,l),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(A(o))continue;s.push(Q(o,i,e,r))}catch(t){s.push({stringValue:d})}return t.length>a&&s.push({stringValue:v}),s}function X(t,i,e,r){var s=[];for(var n in t)if(G.call(t,n)){if(s.length>=l||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(T(a)||F(a))continue;s.push({key:f(n),value:Q(a,i,e,r)})}catch(t){s.push({key:f(n),value:{stringValue:d}})}}return s}function tt(t){try{return f(String(t))}catch(t){return d}}function it(t,i,r,s){var n,a=W[t.level||"info"]||K,o=a.text,l=a.number,u=(void 0===(n=R(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),A(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),A(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),c=t.attributes;if(c){var f=[];try{f=Object.keys(c)}catch(t){f=[]}for(var p of f){var g=void 0;try{g=c[p]}catch(t){g=d}Object.defineProperty(v,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:tt(t.body)},attributes:Z(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),F(t.trace_flags)||(_.flags=t.trace_flags),_}function et(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})}function rt(t,i,e,r){return{resourceLogs:[{resource:{attributes:Z(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let st=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.zi=i,this.I=e,this.hn=r,this.dn=s,this.vn=n,this.fn=a,this.pn=null,this.gn=0,this.mn=0,this.yn=0,this.bn=0,this._n=0,this.wn=!1,this.kn=i.maxBufferSize,this.Sn=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.xn=i.flushIntervalMs,this.Cn=i.maxBatchRecordsPerPost,this.Tn=i.rateCapWindowMs,this.Mn=i.maxLogsPerInterval}clearQueue(){this.mn++,this._instance.setPersistedProperty(a.LogsQueue,[])}reset(){this.En(),this.bn=0,this._n=0,this.wn=!1,this.yn=0,this.Cn=this.zi.maxBatchRecordsPerPost}onReconnect(){this.yn=0,this.In()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Rn(t);if(null!==r)if(r.body){if(this.Pn()){var s={record:it(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.hn(),this.I,null==i?void 0:i.occurredAtMs)};this.dn((()=>this.An(s)))}}else this.I.info("Log was rejected in beforeSend function")}}Rn(t){var i=this.zi.beforeSend;if(!i)return t;var e=k(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for log:",t),null}return r}Pn(){if(void 0===this.Mn)return!0;var t=Date.now(),i=t-this.bn;return this.Tn>i&&i>=0||(this.bn=t,this._n=0,this.wn=!1),this.Mn>this._n?(this._n++,!0):(this.wn||(this.I.warn("captureLog dropping logs: exceeded "+this.Mn+" logs per "+this.Tn+"ms"),this.wn=!0),!1)}flush(){var t=this;return i((function*(){if(!t._instance.isDisabled)return t.pn||(t.pn=t.Fn().finally((()=>{t.pn=null}))),t.pn}))()}Fn(){var t=this;return i((function*(){var i;t.En();var e=null!==(i=t._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,o,l=t.mn;t.gn=0;var u=Math.min(e.length,t.Cn),h=e.slice(0,u),v=rt(h.map((t=>t.record)),t.On(),null!==(n=t.fn)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.Ln(v);if(t.mn!==l)return;if("too-large"===d.kind&&h.length>1)t.Cn=Math.max(1,Math.floor(h.length/2)),t.I.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.Cn);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.zi.maxBatchRecordsPerPost>t.Cn&&(t.Cn=Math.min(t.zi.maxBatchRecordsPerPost,t.Cn+1)),yield t.Dn(h.length),e=null!==(o=t._instance.getPersistedProperty(a.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===d.kind)throw d.error}}}))()}Dn(t){var e=this;return i((function*(){var i,r=Math.max(0,t-e.gn),s=null!==(i=e._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(a.LogsQueue,s.slice(r)),yield e.vn()}))()}On(){return et(this.zi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}An(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];this.Sn>e.length||(e.shift(),this.gn++,this.I.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(a.LogsQueue,e),this.kn>e.length?this.$n():this.In()}}$n(t){void 0===t&&(t=this.xn),this.Nn||(this.Nn=q((()=>{this.Nn=void 0,this.In()}),t))}qn(){var t=Math.min(Math.max(0,this.yn-1),6);return this.xn*Math.pow(2,t)}jn(){var t=this._instance.getPersistedProperty(a.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return i((function*(){e.En();var i=e.flush().catch((()=>{}));void 0!==t?yield V(i,t):yield i}))()}flushWithTimeout(t){var e=this;return i((function*(){var i=e.flush();yield V(i,t,(()=>{i.catch((()=>{}))}))}))()}In(){this.flush().then((()=>{this.yn=0}),(t=>{this.yn++,this.I.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.jn()&&this.$n(this.qn())}))}En(){this.Nn&&(clearTimeout(this.Nn),this.Nn=void 0)}};var nt=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function at(t){return String(t)+"000000"}function ot(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 lt=class{constructor(t,i,e){this._instance=t,this.zi=i,this.I=e,this.Bn=new Map,this.pn=null,this.Hn=!1,this.Un=new Map,this.zn=new Set,this.Wn=0}count(t,i,e){void 0===i&&(i=1),this.Vn({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Vn({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Vn({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,e=this.pn,r=function(){var r=i((function*(){e&&(yield e.catch((()=>{}))),yield t.Gn()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this.pn===s&&(this.pn=null)}));return this.pn=s,s}drainWindow(){if(0===this.Bn.size)return null;var t=this.Bn;return this.Bn=new Map,this.Hn=!1,this.Un=new Map,this.zn=new Set,this.Zn(t)}reset(){this.Wn++,this.En(),this.Bn=new Map,this.pn=null,this.Hn=!1,this.Un=new Map,this.zn=new Set}Vn(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Rn(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.I.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=i.attributes?e({},i.attributes):void 0,s=ot(i.type,i.name,i.unit,r)}catch(t){return void this.I.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.Bn.get(s);if(!n){if(!this.Qn())return;n={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.Bn.set(s,n)}var a=this.Un.get(i.name);void 0===a?this.Un.set(i.name,i.type):a===i.type||this.zn.has(i.name)||(this.zn.add(i.name),this.I.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.Jn(n,i.value),this.$n()}else this.I.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}Qn(){return this.zi.maxSeriesPerFlush>this.Bn.size||(this.Hn||(this.Hn=!0,this.I.warn("Metric series cap reached ("+this.zi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Jn(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(nt.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,nt)]+=1}}Rn(t){var i=this.zi.beforeSend;if(!i)return t;var e=k(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.I.error("Error in beforeSend function for metric:",t),null}return r}$n(){this.Nn||(this.Nn=q((()=>{this.Nn=void 0,this.flush().catch((t=>{this.I.error("Metrics flush failed:",t)}))}),this.zi.flushIntervalMs))}En(){this.Nn&&(clearTimeout(this.Nn),this.Nn=void 0)}Gn(){var t=this;return i((function*(){if(0!==t.Bn.size){var i=t.Bn;t.Bn=new Map,t.Hn=!1,t.Un=new Map,t.zn=new Set;var e=t.Wn,r=yield t._instance.Kn(t.Zn(i));if(e===t.Wn)switch(r.kind){case"ok":return;case"retry-later":return t.Yn(i),void t.$n();case"too-large":return void t.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.I.error("Failed to send metrics batch:",r.error)}}}))()}Zn(t){return i=this.Xn(t),r=function(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})}(this.zi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Z(r)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,r,s,n}Xn(t){var i=at(Date.now()),r=new Map;for(var s of t.values()){var n,a=ot(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=Z(null!==(n=s.attributes)&&void 0!==n?n:{},this.I),u=at(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:nt})}return Array.from(r.values())}Yn(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.Bn.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.Qn()&&this.Bn.set(s,n)}}};var ut,ht,vt;function dt(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return vt&&e.length===ht?vt:(ht=e.length,vt=e.reduce(((e,r)=>{ut||(ut={});var s=ut[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,ut[r]=[l,u];break}}return e}),{}))}}class ct{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&&k(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:dt(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 ft="?";function pt(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?ft:e,in_app:!(null!=i&&i.startsWith("webkit-masked-url://"))&&"<anonymous>"!==i};return F(r)||(n.lineno=r),F(s)||(n.colno=s),n}var gt=(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]:ft,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},_t=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,bt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mt=/\((\S*)(?::(\d+))(?::(\d+))\)/,yt=(t,i)=>{var e=_t.exec(t);if(e)return pt(i,e[1],ft,+e[2],+e[3]);var r=bt.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=mt.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=gt(r[1]||ft,r[2]);return pt(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},wt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,kt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,St=(t,i)=>{var e=wt.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=kt.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]||ft,a=gt(n,s);return pt(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},xt=/\(error: (.*)\)/;class Et{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=C(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 j(t,"DOMException")}isDOMError(t){return j(t,"DOMError")}}class Ft{match(t){return L(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 Ct{constructor(){}match(t){return!!j(t,"ErrorEvent")&&(null!=t.error||this.ki(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.Si(t))&&void 0!==r?r:s.stack,synthetic:!0})}ki(t){return C(t.message)&&t.message.length>0}Si(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(C(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}}var Pt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Tt{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(Pt);return r&&(i=r[1],e=r[2]),[i,e]}}var At=["fatal","error","warning","log","info","debug"];function Rt(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 Ot{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(D(t))return t.constructor.name;var i="name"in t?t.name:void 0;return C(i)&&!P(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: "+Rt(t)}isSeverityLevel(t){return C(t)&&!P(t)&&At.indexOf(t)>=0}getStack(t){try{return C(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:C(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(L(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}}class Mt{match(t){return D(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Rt(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class $t{match(t){return I(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 It{match(t){return j(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!D(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 I(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 jt="$message",Lt="$timestamp",Dt=new Set([jt,Lt]),Nt={enabled:!0,max_bytes:32768};function zt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Nt.enabled,max_bytes:Ht(t.max_bytes,Nt.max_bytes)}:e({},Nt)}class Ut{constructor(t){this.ts=[],this.es=0,this.zi=zt(t)}setConfig(t){this.zi=zt(t),this.rs()}add(t){var i=function(t){var i,e,r;try{r=[],i=null!==(e=JSON.stringify(t,(function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return"[Circular]";r.push(i)}return i}})))&&void 0!==e?e:"null"}catch(t){return}try{var s=JSON.parse(i);if(!x(s))return;var n=s,a=n[jt],o=n[Lt];if(!C(a)||0===a.trim().length)return;if(!C(o)&&!R(o))return;return{step:n,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.zi.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.rs())}}getAttachable(){return this.ts.map((t=>t.step))}clear(){this.ts=[],this.es=0}size(){return this.ts.length}rs(){for(;this.es>this.zi.max_bytes&&this.ts.length>0;){var t=this.ts.shift();t&&(this.es-=t.bytes)}}}function Ht(t,i){if(!R(t)||t===1/0||t===-1/0)return i;var e=Math.floor(t);return 0>e?i:e}var qt={DEBUG:!1,LIB_VERSION:"0.6.0",LIB_NAME:"browser-common"},Vt="undefined"!=typeof window?window:void 0,Bt="undefined"!=typeof globalThis?globalThis:Vt,Wt=null==Bt?void 0:Bt.navigator,Kt=null==Bt?void 0:Bt.document,Jt=null==Bt?void 0:Bt.location;function Gt(){return!(!Vt||!1===Vt.navigator.onLine)}null!=Bt&&Bt.XMLHttpRequest&&new Bt.XMLHttpRequest;var Zt=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={P(i){if(Vt&&(qt.DEBUG||Vt.POSTHOG_DEBUG||e)&&!F(Vt.console)&&Vt.console){for(var r=("__rrweb_original__"in Vt.console[i]?Vt.console[i].__rrweb_original__:Vt.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.P("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.P("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.P("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.P("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)=>Zt(t+" "+i,e)};return r},Qt=Zt("[PostHog.js]"),Yt=Qt.createLogger;function Xt(t,i){if(!A(t))if(k(t))t.forEach(i);else if(M(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)y.call(t,e)&&i(t[e],e)}var ti=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 ii(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 ei=function(t){try{return t()}catch(t){return}};function ri(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 si(t){return"ph_toolbar_internal"===t.name}function ni(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!S(r))return i;try{var s=r(i);return C(s)&&s?s:i}catch(t){return Qt.error("Error in get_current_url, falling back to window.location.href",t),i}}var ai="__POSTHOG_TOOLBAR__",oi=1,li=3,ui=11;function hi(t){return t instanceof Element&&(t.id===ai||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function vi(t){return!!t&&t.nodeType===oi}function di(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function ci(t){return!!t&&t.nodeType===li}function fi(t){return!!t&&t.nodeType===ui&&vi(t.host)}var pi=1e3;function gi(t){return t?b(t).split(/\s+/):[]}function _i(t,i){var e=function(t){var i,e=null==Vt||null==(i=Vt.location)?void 0:i.href;return F(e)?void 0:ni(t,e)}(i);return!!(e&&t&&t.some((t=>e.match(t))))}function bi(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 gi(i)}function mi(t){return A(t)?null:b(t).split(/(\s+)/).filter((t=>Hi(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function yi(t){var i="";return Mi(t)&&!$i(t)&&t.childNodes&&t.childNodes.length&&Xt(t.childNodes,(function(t){var e;ci(t)&&t.textContent&&(i+=null!==(e=mi(t.textContent))&&void 0!==e?e:"")})),b(i)}function wi(t){var i;return F(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var ki=["a","button","form","input","select","textarea","label"];function Si(t,i){if(F(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 xi(t){var i=t.parentNode;return!(!i||!vi(i))&&i}var Ei=[".ph-no-autocapture","[data-ph-no-autocapture]"],Fi=["next","previous","prev",">","<"],Ci=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Pi=[".ph-no-rageclick",".ph-no-capture"],Ti=["","text","search","email","password","url","tel","number"];function Ai(t,i){if(!Vt||Ri(t))return!1;var e,r,s,n,a;if(O(i)?(e=!!i&&Pi,r=void 0,s=!1):(e=null!==(n=null==i?void 0:i.css_selector_ignorelist)&&void 0!==n?n:Pi,r=null==i?void 0:i.content_ignorelist,s=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===e)return!1;if(s&&function(t){return!(!t||!vi(t))&&(!!di(t,"textarea")||(di(t,"input")?_(Ti,(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 o=Oi(t,!1).targetElementList;return!function(t,i){if(!1===t||F(t))return!1;var e;if(!0===t)e=Fi;else{if(!k(t))return!1;if(t.length>10)return Qt.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=>Ci(i,t)||Ci(r,t)))}))}(r,o.map((t=>{var i;return{safeText:yi(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!Si(o,e)}var Ri=t=>!t||di(t,"html")||!vi(t),Oi=(t,i)=>{if(!Vt||Ri(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!di(s,"body");)if(fi(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=xi(s);if(!n)break;if(i||ki.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=Vt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Mi(t){for(var i=new Set,e=0,r=t;r.parentNode&&!di(r,"body");r=r.parentNode){if(e++>=pi||i.has(r))return!1;i.add(r);var s=bi(r);if(_(s,"ph-sensitive")||_(s,"ph-no-capture"))return!1}if(_(bi(t),"ph-include"))return!0;var n=t.type||"";if(C(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!C(a)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,""))}function $i(t){return!!(di(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||di(t,"select")||di(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ii=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}))$"),ji=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Li=[16,15,14,13],Di=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ni=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),zi=/[0-9A-Za-z_]/;function Ui(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 Hi(t,i){if(void 0===i&&(i=!0),A(t))return!1;if(C(t)){t=b(t);var e=i?Ii.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(ji.lastIndex=0;i=ji.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of Li){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(Ii.test(o)&&Ui(o))return!0}}}return!1}(t);if(e)return!1;var r=i?Di.test(t):function(t){var i;for(Ni.lastIndex=0;i=Ni.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&zi.test(e)&&zi.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function qi(t){var i=yi(t);return Hi(i=(i+" "+Vi(t)).trim())?i:""}function Vi(t){var i="";return t&&t.childNodes&&t.childNodes.length&&Xt(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=yi(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+Vi(t)).trim())}catch(t){Qt.error("[AutoCapture]",t)}})),i}function Bi(t){return t.replace(/"|\\"/g,'\\"')}function Wi(t){var i=t.attr__class;if(i)return k(i)?i:gi(i)}class Ki{constructor(t){this.disabled=!1===t;var i=x(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 Ji="$autocapture_disabled_server_side",Gi="$heatmaps_enabled_server_side",Zi="$exception_capture_enabled_server_side",Qi="$error_tracking_suppression_rules",Yi="$error_tracking_capture_extension_exceptions",Xi="$web_vitals_enabled_server_side",te="$product_tours_enabled_server_side",ie="$logs_capture_enabled_server_side",ee="$web_vitals_allowed_metrics",re="$session_recording_remote_config",se="$enabled_feature_flags",ne="$active_feature_flags",ae="$early_access_features",oe="$feature_flag_details",le="$feature_flag_payloads",ue="$feature_flag_request_id",he="$minimal_flag_called_events",ve="$override_feature_flags",de="$override_feature_flag_payloads",ce="$stored_person_properties",fe="$stored_group_properties",pe="$surveys",ge="$surveys_loaded_at",_e="$surveys_activated",be="$surveys_activated_session",me="$surveys_activated_timestamps",ye="ph_product_tours",we="$flag_call_reported",ke="$flag_call_reported_session_id",Se="$feature_flag_errors",xe="$feature_flag_evaluated_at",Ee="$sdk_debug_recording_script_not_loaded",Fe="PostHog loadExternalDependency extension not found.",Ce="visibilitychange",Pe="beforeunload",Te=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(!k(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){Qt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ae=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 v=l[h].split("=");k(v)&&(i.includes(v[0])?u.push(v[0]+"="+e):u.push(l[h]))}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=s&&(d+="#"+s),d},Re=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Oe=(t,i)=>t>=i&&Gt(),Me=(t,i,e,r)=>{if(0===t){if(Gt()){var s=i+1;return s===e&&r(),s}return i}return 0},$e="$copy_autocapture",Ie=Yt("[AutoCapture]");function je(t,i){return i.length>t?i.slice(0,t)+"...":i}function Le(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!vi(i));return i}function De(t,i){var r,s,n=i.e,a=i.maskAllElementAttributes,o=i.maskAllText,l=i.elementAttributeIgnoreList,u=i.elementsChainAsString,h=i.disableCaptureUrlHashes;if(!vi(t))return{props:{}};for(var v=[t],d=new Set([t]),c=t;c.parentNode&&!di(c,"body")&&pi>v.length;)if(fi(c.parentNode)){var f=c.parentNode.host;if(d.has(f))break;d.add(f),v.push(f),c=f}else{if(!vi(c.parentNode))break;if(d.has(c.parentNode))break;d.add(c.parentNode),v.push(c.parentNode),c=c.parentNode}var p,g,b=[],m={},y=!1,w=!1;if(Xt(v,(t=>{var i=Mi(t);if(di(t,"a")){var e=t.getAttribute("href");y=!!(i&&e&&Hi(e))&&(h?H(e):e)}_(bi(t),"ph-no-capture")&&(w=!0),b.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};ki.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?je(1024,qi(t)):je(1024,yi(t)));var o=bi(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),Xt(t.attributes,(function(e){var n;if((!$i(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Hi(e.value)&&(!C(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=gi(o).join(" ")),a["attr__"+e.name]=je(1024,"href"===e.name&&s?H(o):o)}}));for(var l=1,u=1,h=t;h=Le(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,a,o,l,h));var r=function(t){if(!Mi(t))return{};var i={};return Xt(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&&Hi(r)&&(i[e]=r)}})),i}(t);ti(m,r)})),w)return{props:{},explicitNoCapture:w};if(o||(b[0].$el_text=di(t,"a")||di(t,"button")?qi(t):yi(t)),y){var k,S;b[0].attr__href=y;var x=null==(k=(t=>{var i=null==Kt?void 0:Kt.createElement("a");return F(i)?null:(i.href=t,i)})(y))?void 0:k.host,E=null==Vt||null==(S=Vt.location)?void 0:S.host;x&&E&&x!==E&&(p=y)}return{props:ti({$event_type:n.type,$ce_version:1},u?{}:{$elements:b},{$elements_chain:(g=b,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 ii(a).sort(((t,i)=>t[0].localeCompare(i[0]))).forEach((t=>{var i=t[1];return o[Bi(t[0].toString())]=Bi(i.toString())})),(s+=":")+ii(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:Wi(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return ii(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=b[0])&&r.$el_text?{$el_text:null==(s=b[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},m)}}class Ne{constructor(t){this.name="autocapture",this.ns=!1,this.ss=null,this.os=!1,this.ls=!1,this.zi={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.us=!1,this.hs=t,this.hs.refresh(this.zi),this.rageclicks=new Ki(this.zi.rageclick),this.ds=null}setup(t){this.vs(),this.cs=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.us?i.dispose():(this.fs=i,this.startIfEnabled())}dispose(){var t;this.us||(this.us=!0,this.cs=void 0,null==(t=this.fs)||t.dispose(),this.fs=void 0,this.ps())}gs(){return this.hs.refresh(this.zi),this.zi}vs(){var t,i;return this.gs(),this.zi.url_allowlist=null==(t=this.zi.url_allowlist)?void 0:t.map((t=>new RegExp(t))),this.zi.url_ignorelist=null==(i=this.zi.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),this.zi}ys(){if(this.isBrowserSupported()){if(Vt&&Kt){var t=this.bs=t=>{t=t||(null==Vt?void 0:Vt.event);try{this._s(t)}catch(t){Ie.error("Failed to capture event",t)}};if(ri(Kt,"submit",t,{capture:!0}),ri(Kt,"change",t,{capture:!0}),ri(Kt,"click",t,{capture:!0}),this.gs().capture_copied_text){var i=this.ws=t=>{t=t||(null==Vt?void 0:Vt.event);try{this._s(t,$e)}catch(t){Ie.error("Failed to capture clipboard event",t)}};ri(Kt,"copy",i,{capture:!0}),ri(Kt,"cut",i,{capture:!0}),ri(Kt,"paste",i,{capture:!0})}}}else Ie.info("Disabling Automatic Event Collection because this browser is not supported")}ps(){this.bs&&(null==Kt||Kt.removeEventListener("submit",this.bs,!0),null==Kt||Kt.removeEventListener("change",this.bs,!0),null==Kt||Kt.removeEventListener("click",this.bs,!0),this.bs=void 0),this.ws&&(null==Kt||Kt.removeEventListener("copy",this.ws,!0),null==Kt||Kt.removeEventListener("cut",this.ws,!0),null==Kt||Kt.removeEventListener("paste",this.ws,!0),this.ws=void 0),this.ns=!1}startIfEnabled(){!this.us&&this.cs&&this.isEnabled&&!this.ns&&(this.ys(),this.ns=!0)}onRemoteConfig(t){if(!this.us)if(this.os=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.ls=i.elementsChainAsString);var e,r=i.autocapture_opt_out;O(r)&&(null==(e=this.cs)||e.kv.set(Ji,r),this.ss=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.ds=t}getElementSelectors(t){var i,e=[];return null==(i=this.ds)||i.forEach((i=>{var r=null==Kt?void 0:Kt.querySelectorAll(i);null==r||r.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i;if(this.us)return!1;var e=null==(t=this.cs)?void 0:t.kv.get(Ji),r=this.ss,s=this.gs(),n=s.remoteRequestsDisabled&&!this.os;if(T(r)&&!O(e)&&!n)return!1;var a=null!==(i=this.ss)&&void 0!==i?i:!!e;return!!s.enabled&&!a}_s(t,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r=wi(t);ci(r)&&(r=r.parentNode||null);var s,n=this.vs();"$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())&&Ai(r,n.rageclick)&&this._s(t,"$rageclick");var a=i===$e,o=a?e({},n,{dom_event_allowlist:void 0}):n;if(r&&function(t,i,e,r,s,n){var a;if(!Vt||Ri(t))return!1;if(null!=e&&e.url_allowlist&&!_i(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&_i(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=Oi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(F(e))return!0;var r,s=function(t){if(e.some((i=>t.tagName.toLowerCase()===i)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(h,e))return!1;if(!Si(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Si(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:Ei))return!1;try{var v=Vt.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&&(ki.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=De(r,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.ls,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===$e){var d=t.type||"clipboard";if("paste"!==d){var c,f,p=null==Vt||null==(c=Vt.getSelection())?void 0:c.toString(),g=mi(p);if(!g)return!1;h.$selected_content=g,h.$clipboard_text_length=null!==(f=null==p?void 0:p.length)&&void 0!==f?f:0}h.$copy_type=d}return null==(l=this.cs)||l.capture(i,h).catch((t=>Ie.error("Failed to capture event",t))),!0}}}isBrowserSupported(){return S(null==Kt?void 0:Kt.querySelectorAll)}}class ze{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=x(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 Ue="undefined"!=typeof globalThis?globalThis:Vt;Ue&&"undefined"==typeof self&&(Ue.self=Ue),Ue&&"undefined"==typeof File&&(Ue.File=function(){});var He=null!=Vt?Vt:{},qe=Yt("[Dead Clicks]"),Ve=()=>!0;class Be{get lazyLoadedDeadClicksAutocapture(){return this.Ms}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Es((()=>{this.Is()})):this.stop()}Es(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?qe.error("failed to load script",i):t()}))}Is(){var t;if(Kt){if(!this.Ms&&null!=(t=He.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=x(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.Ms=He.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ms.start(Kt),qe.info("starting...")}}else qe.error("`document` not found. Cannot start.")}stop(){this.Ms&&(this.Ms.stop(),this.Ms=void 0,qe.info("stopping..."))}}var We=Yt("[ExceptionAutocapture]"),Ke=()=>{},Je=t=>{var i;if(S(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function Ge(t,i,e){try{if(!(i in t))return Ke;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 S(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=Je(e);n;){if(n.next===s)return void(n.next=r.next);n=Je(e=n.next)}else t[i]=r.next}}catch(t){return Ke}}var Ze=Yt("[TracingHeaders]"),Qe=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ye=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qe],Xe="<masked>",tr=["li_fat_id"];function ir(t,i,e){if(!Kt)return{};var r,s,n,a=(r=Ae(Kt.URL,[],Xe),s=Ye.concat([]),n={},Xt(s,(function(t){var i=Te(r,t);n[t]=i||null})),n),o=function(){var t={};return Xt(tr,(function(i){var e=(t=>{if(Kt){try{for(var i=t+"=",e=Kt.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 ti(o,a)}function er(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var rr=Yt("[Web Vitals]"),sr=9e5,nr=["CLS","FCP","INP","LCP"],ar=["INP","LCP"],or=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],lr=Yt("[RemoteConfig]");class ur{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=He._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}wa(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}ka(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return lr.info("Using preloaded remote config",this.remoteConfig),void this.Sa(this.remoteConfig);if(this._instance._shouldDisableFlags())return void lr.warn("Remote config is disabled. Falling back to local config.");this.wa((t=>{if(!t)return lr.info("No config found after loading remote JS config. Falling back to JSON."),void this.ka((t=>{this.Sa(t.json,t)}));this.Sa(t)}))}catch(t){lr.error("Error loading remote config",t),this.Sa()}}Sa(t,i){!t&&i&&(0===i.statusCode?i.error||lr.warn("Failed to fetch remote config from PostHog."):lr.error("Failed to fetch remote config from PostHog."));try{this._instance.Sa(t?{ok:!0,config:t}:{ok:!1})}catch(t){lr.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){lr.error("Error loading feature flags",t)}}}var hr="disabled",vr="lazy_loading",dr="awaiting_config",cr="missing_config";function fr(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}qt.DEBUG=!1,qt.LIB_VERSION="1.422.0",qt.LIB_NAME="web";var pr=(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}},gr=t=>t.toLowerCase(),_r={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=>pr(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!pr(i,t))))),icontains:(t,i)=>i.map(gr).some((i=>t.map(gr).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(gr).every((i=>t.map(gr).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 br(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=_r[e.operator];return!!s&&s(e.values,[String(r)])}))}Yt("[SessionRecording]"),Yt("[SessionRecording]");var mr="[SessionRecording]",yr=Yt(mr),wr=Yt("[Heatmaps]");function kr(t){return x(t)&&"clientX"in t&&"clientY"in t&&R(t.clientX)&&R(t.clientY)}var Sr=Yt("[Product Tours]"),xr=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(te))},Er=["$set_once","$set"],Fr=Yt("[SiteApps]"),Cr="Error while initializing PostHog app with config id ",Pr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Tr="events",Ar="cancelEvents",Rr="survey shown",Or=Yt("[Surveys]"),Mr="seenSurvey_",$r=["popover","widget","api"],Ir="SDK is not enabled or survey functionality is not yet loaded",jr="Disabled. Not loading surveys.";class Lr{constructor(t,i){this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Fl=!1,this.Ol=[],this.Ll=null,this.Dl=null,this.us=!1,this.$l=new Set,this.onRemoteConfig=t=>{if(!this.us&&!this.zi.disableSurveys){if(!t.ok)return Or.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(A(i))return Or.warn("Flags not loaded yet. Not loading surveys.");this.Nl=O(i)?i:i.length>0,Or.info("flags response received, isSurveysEnabled: "+this.Nl),this.loadIfEnabled()}},this.hs=t,this.ql=i}setup(t){if(!this.us)return this.jl=t,Pr(t.kv.initialize(),(()=>{if(this.jl===t&&!this.us){this.jl=void 0,this.cs=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.us?i.dispose():(this.fs=i,this.loadIfEnabled())}}))}dispose(){var t,i,e;this.us||(this.us=!0,this.jl=void 0,this.cs=void 0,null==(t=this.fs)||t.dispose(),this.fs=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.Ol=[],this.Ll=null,this.$l.forEach((t=>clearTimeout(t))),this.$l.clear())}get zi(){return this.hs.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith(Mr)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this.us&&this.cs){var t=this.zi;if(!this._surveyManager)if(this.Fl)Or.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Or.info(jr);else if(t.cookielessMode&&this.hs.isOptedOut())Or.info("Not loading surveys in cookieless mode without consent.");else{var i=this.hs.getExtensions();if(i){if(!F(this.Nl)||t.advancedEnableSurveys){var e=this.Nl||t.advancedEnableSurveys;this.Fl=!0;try{var r=i.generateSurveys;if(r)return this.Bl(r,e),void(this.Fl=!1);var s=i.loadExternalDependency;if(!s)return this.Hl(Fe),void(this.Fl=!1);s((t=>{try{if(this.us)return;var i=this.hs.getExtensions();t||null==i||!i.generateSurveys?this.Hl("Could not load surveys script",t):this.Bl(i.generateSurveys,e)}finally{this.Fl=!1}}))}catch(t){throw this.Fl=!1,this.Hl("Error initializing surveys",t),t}}}else Or.error("PostHog Extensions not found.")}}}Bl(t,i){this.us||(this._surveyManager=t(i),this._surveyEventReceiver=this.hs.createEventReceiver(),Or.info("Surveys loaded successfully"),this.Ul({isLoaded:!0}))}Hl(t,i){Or.error(t,i),this.Ul({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ol.push(t),this._surveyManager&&this.Ul({isLoaded:!0}),()=>{this.Ol=this.Ol.filter((i=>i!==t))}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.cs)&&void 0!==e?e:this.ql;if(r&&!this.us){if(this.zi.disableSurveys)return Or.info(jr),t([]);var s=r.kv.get(pe);if(s&&!i)return t(s,{isLoaded:!0}),void(this.zl()&&this.getSurveys((()=>{}),!0));if(this.Ll)this.Ll.then((i=>{this.us||t(i.surveys,i.context)})).catch((t=>Or.error("Error in survey callback",t)));else{var n=this.Wl("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.zi.requestTimeoutMs}).then((t=>{try{return this.Vl(r,t)}catch(t){return Or.error("Error processing surveys response",t),this.Vl(r,{statusCode:0,error:t})}}),(t=>this.Vl(r,{statusCode:0,error:t})));this.Ll=n;var a=()=>{this.Ll===n&&(this.Ll=null)};n.then((i=>{a(),this.us||t(i.surveys,i.context)}),a).catch((t=>Or.error("Error in survey callback",t)))}}}Wl(t,i){var e=this.cs;return e?e.sendRequest(t,i):new Promise((t=>t({statusCode:0,error:new Error(Ir)})))}Vl(t,i){if(this.us)return{surveys:[],context:{isLoaded:!1,error:Ir}};var e=i.statusCode;if(200!==e||!i.json){var r="Surveys API could not be loaded, status: "+e;return 0!==e?Or.error(r):i.error||Or.warn(r),this.Dl=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Dl=null;var s,n=i.json.surveys||[],a=n.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(fr(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({[pe]:n,[ge]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}zl(){return this.Gl()&&!this.Ll&&!this.Zl()}Gl(){var t,i,e=null==(t=null!==(i=this.cs)&&void 0!==i?i:this.ql)?void 0:t.kv.get(ge);return R(e)&&Date.now()-e>3e5}Zl(){return R(this.Dl)&&3e5>Date.now()-this.Dl}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>""+Mr+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){Or.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){}}Ul(t){for(var i of this.Ol)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Or.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!A(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Or.warn("init was not called")}Ql(t){var i=null;return this.getSurveys((e=>{var r;i=null!==(r=e.find((i=>i.id===t)))&&void 0!==r?r:null})),i}Jl(t){if(A(this._surveyManager))return{eligible:!1,reason:Ir};var i="string"==typeof t?this.Ql(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Kl(t){if(A(this._surveyManager))return{eligible:!1,reason:Ir};var i="string"==typeof t?this.Ql(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(A(this._surveyManager))return Or.warn("init was not called"),{visible:!1,disabledReason:Ir};var i=this.Kl(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return A(this._surveyManager)?(Or.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ir})):new Promise((e=>{this.getSurveys((i=>{var r,s=null!==(r=i.find((i=>i.id===t)))&&void 0!==r?r:null;if(s){var n=this.Kl(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var r;if(A(this._surveyManager))Or.warn("init was not called");else{var s="string"==typeof t?this.Ql(t):t;if(null!=s&&s.id)if($r.includes(s.type)){var n=null==Kt?void 0:Kt.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){Or.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout((()=>{var t,i;this.$l.delete(a),this.us||(Or.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),Or.info("Survey "+s.id+" rendered"))}),1e3*s.appearance.surveyPopupDelaySeconds);this.$l.add(a)}else this._surveyManager.renderSurvey(s,n,e);else Or.warn("Survey element not found")}else Or.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Or.warn("Survey not found")}}displaySurvey(t,i){var r;if(A(this._surveyManager))Or.warn("init was not called");else{var s=this.Ql(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&&Or.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var a=this.Jl(s);if(!a.eligible)return void Or.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 Or.warn("Survey not found")}}cancelPendingSurvey(t){A(this._surveyManager)?Or.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}class Dr{on(t,i){return this.Ya[t]||(this.Ya[t]=[]),this.Ya[t].push(i),()=>{this.Ya[t]=this.Ya[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.Ya[t]||[])e(i);for(var r of this.Ya["*"]||[])r(t,i)}constructor(){this.Ya={}}}function Nr(t,i,e){if(A(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 zr{constructor(t){this.Yl=new Set,this.Xl=new Set,this.tu=new Dr,this.eu=(t,i)=>this.iu(t,i)&&this.ru(t,i)&&this.nu(t,i)&&this.su(t,i),this.iu=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t}init(){var t,i;F(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.au=null==(i=this._instance)?void 0:i._addCaptureHook(((t,i)=>{this.on(t,i)})))}dispose(){var t;null==(t=this.au)||t.call(this),this.au=void 0,this.tu=new Dr}register(t){var i,e;if(!F(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i;this.Yl.add(t),null==(i=t.steps)||i.forEach((t=>{this.Xl.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Yl.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&r.add(t.selector)}))})),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Yl.clear(),this.Xl.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Xl.has(t)||this.Xl.has(i.event))&&this.Yl.forEach((t=>{this.ou(i,t)&&this.tu.emit("actionCaptured",t.name)}))}lu(t){this.onAction("actionCaptured",(i=>t(i)))}ou(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.eu(t,e))return!0;return!1}onAction(t,i){return this.tu.on(t,i)}ru(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!Nr(r,i.url,i.url_matching||"contains"))return!1}return!0}nu(t,i){return!!this.uu(t,i)&&!!this.hu(t,i)&&!!this.du(t,i)}uu(t,i){var e;if(null==i||!i.href)return!0;var r=this.vu(t);if(r.length>0)return r.some((t=>Nr(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&Nr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}hu(t,i){var e;if(null==i||!i.text)return!0;var r=this.vu(t);if(r.length>0)return r.some((t=>Nr(t.text,i.text,i.text_matching||"exact")||Nr(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;!A(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=>Nr(t,n,a))))}du(t,i){var e,r;if(null==i||!i.selector)return!0;var s=null==t||null==(e=t.properties)?void 0:e.$element_selectors;if(null!=s&&s.includes(i.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&n)try{return new RegExp(i.selector_regex).test(n)}catch(t){return!1}return!1}vu(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}su(t,i){return null==i||!i.properties||0===i.properties.length||br(i.properties.reduce(((t,i)=>{var e=k(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 Ur{constructor(t){var i;this.cu=[],this._instance=t,this.fu=new Map,this.pu=new Map,this.gu=new Map,this.mu=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId((t=>this.yu(t)))}bu(t){return!1}_u(){return null}wu(t){}ku(){}Su(t,i){return!!t&&br(t.propertyFilters,null==i?void 0:i.properties)}xu(t,i){var e=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach((i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}}))})),e}Cu(t,i,e){var r=(e===Tr?this.fu:this.pu).get(t),s=[];return this.Tu((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find((i=>i.name===t));return this.Su(n,i)}))}register(t){this.Mu(t,!1)}replace(t){this.Mu(t,!0)}Mu(t,i){var e;F(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Eu(t,i),this.Iu(t,i))}Iu(t,i){var e=t.filter((t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length}));if(i&&this.gu.clear(),0!==e.length){this.Ru||(this.Ru=new zr(this._instance),this.Ru.init(),this.Ru.lu((t=>this.onAction(t))));var r=[];e.forEach((t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach((i=>{if(r.push(i),i.name){var e,s=null!==(e=this.gu.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.gu.set(i.name,s)}}))})),i?this.Ru.replace(r):this.Ru.register(r)}else{var s;i&&(null==(s=this.Ru)||s.replace([]))}}Pu(t,i){i.forEach(((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach((t=>{s.includes(t)||s.push(t)})),t.set(e,s)}))}Eu(t,i){var e,r,s=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0})),n=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0})),a=this.xu(t,Tr),o=this.xu(t,Ar);i?(this.fu=a,this.pu=o):(this.Pu(this.fu,a),this.Pu(this.pu,o)),(0!==s.length||0!==n.length)&&(null!==(e=this.au)&&void 0!==e||(this.au=null==(r=this._instance)?void 0:r._addCaptureHook(((t,i)=>{this.onEvent(t,i)}))))}onEvent(t,i){var e,r,s=this.Au(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.Fu(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Ou([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Lu(n),void this.Du([n])}if(this.pu.has(t)){var o=this.Cu(t,i,Ar);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Ou(o.map((t=>t.id))),o.forEach((t=>this.$u(t.id))))}if(this.fu.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.fu.get(t)});var l=this.Cu(t,i,Tr);this.Nu(l.map((t=>t.id)))}}onAction(t){this.gu.has(t)&&this.Nu(this.gu.get(t)||[])}Nu(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.bu(s)?this.Lu(s)&&this.qu(s):r.push(s);r.length>0&&(this.cu=[...new Set([...this.cu,...r])]),this.Au().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Lu(t){this.cu=this.cu.filter((i=>i!==t));var i=this.ju();return!i.includes(t)&&(this.Bu([...i,t]),this.Hu(),!0)}Ou(t){var i=new Set(t);this.cu=this.cu.filter((t=>!i.has(t)));var e=this.Uu(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.Bu(r),0===r.length&&this.zu()),this.Du(t)}Wu(){var t,i=this._u();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}qu(t){if(this._u()){var i=this.Wu();this.wu(e({},i,{[t]:Date.now()}))}}Du(t){if(this._u()){var i=this.Wu(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],a=s[1];t.includes(n)?r=!0:e[n]=a}r&&(E(e)?this.ku():this.wu(e))}}Vu(){this._u()&&this.ku()}getActivationTimestamp(t){if(this.ju().includes(t)){var i=this.Wu()[t];return R(i)?i:void 0}}Uu(){var t,i=this.Gu();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}ju(){var t,i,e=this.Uu();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Zu()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Hu(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Qu(i)}zu(){this.Ju()}yu(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Zu()];if(e&&e!==t){var r=this.Uu(),s=this.Wu();r.length>0&&(this.Bu([]),r.filter((t=>R(s[t]))).forEach((t=>this.$u(t)))),this.zu(),this.Vu()}}getActivatedIds(){return[...new Set([...this.ju(),...this.cu])].filter((t=>!this.Ku(t)))}dispose(){var t,i,e;null==(t=this.mu)||t.call(this),this.mu=void 0,null==(i=this.au)||i.call(this),this.au=void 0,null==(e=this.Ru)||e.dispose(),this.Ru=void 0}reset(){this.cu=[],this.Uu().length>0&&this.Bu([]),this.zu(),this.Vu()}getEventToItemsMap(){return this.fu}Yu(){return this.Ru}}class Hr extends Ur{constructor(t){super(t)}Gu(){return _e}Zu(){return be}_u(){return me}wu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[me]:t})}ku(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(me)}bu(t){var i,e;this.Tu((i=>{e=i.find((i=>i.id===t))}));var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return R(r)&&r>0}Xu(){return Rr}Tu(t){var i;null==(i=this._instance)||i.getSurveys(t)}$u(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Au(){return Or}Bu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[_e]:t})}Qu(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[be]:t})}Ju(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(be)}Ku(){return!1}Fu(t,i){var e;this.Tu((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return fr(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===Rr?"consume":"ignore":t===Rr?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class qr{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);F(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach((t=>this._instance.unregister(t))):this._instance.unregister(t)}}class Vr{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==He?void 0:He.__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 Hr(this._instance)}}var Br=null!=Vt&&Vt.location?Re(Vt.location.hash,"__posthog")||Re(location.hash,"state"):null,Wr="_postHogToolbarParams",Kr=Yt("[Toolbar]"),Jr=Yt("[FeatureFlags]");class Gr{constructor(t,i){void 0===i&&(i=!1),this.th=!1,this.update(t,i)}update(t,i){this.eh=((t,i)=>{var e,r,s,n,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:k(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.th||(Jr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.th=!0),F(t.flag_keys)||k(t.flag_keys)||Jr.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.eh}}var Zr=Yt("[FeatureFlags]"),Qr=Yt("[FeatureFlags]",{debugEnabled:!0}),Yr="\" failed. Feature flags didn't load in time.",Xr="connection_error",ts=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},is=t=>{var i={};for(var e of ii(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},es=Yt("[Error tracking]"),rs=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],ss=["__firefox__","__gCrWeb"],ns="Refusing to render web experiment since the viewer is a likely bot",as={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>pr(i,t),not_regex:(t,i)=>!pr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class os{get zi(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{os.ih("retrieved web experiments from the server"),i.rh=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.rh&&(os.ih("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.rh)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);C(r)&&t.variants[r]&&i.nh(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];os.sh(n,i._instance)&&i.nh(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())os.ih(ns);else if(!this.zi.disable_web_experiments){if(A(this.rh))return this.rh=new Map,this.loadIfEnabled(),void this.previewWebExperiment();os.ih("applying feature flags",t),t.forEach((t=>{var i;if(this.rh&&null!=(i=this.rh)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.rh)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.nh(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=os.getWindowLocation();if(null!=t&&t.search){var i=Te(null==t?void 0:t.search,"__experiment_id"),e=Te(null==t?void 0:t.search,"__experiment_variant");i&&e&&(os.ih("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.ah(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.zi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.zi.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.zi.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}ah(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(os.ih("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.nh(r[0].name,i,r[0].variants[i].transforms))}static sh(t,i){return!A(t.conditions)&&os.oh(t,i)&&os.lh(t)}static oh(t,i){var e;if(A(t.conditions)||A(null==(e=t.conditions)?void 0:e.url))return!0;var r=os.getWindowLocation();if(r){var s,n,a,o=ni(i,r.href);return null==(s=t.conditions)||!s.url||as[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==Vt?void 0:Vt.location}static lh(t){var i;if(A(t.conditions)||A(null==(i=t.conditions)?void 0:i.utm))return!0;var e=ir();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 ih(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];Qt.info("[WebExperiments] "+t,e)}nh(t,i,e){this._is_bot()?os.ih(ns):"control"!==i?e.forEach((e=>{if(e.selector){var r;os.ih("applying transform of variant "+i+" for experiment "+t+" ",e);var s=null==(r=document)?void 0:r.querySelectorAll(e.selector);null==s||s.forEach((t=>{var i=t;e.html&&(i.innerHTML=e.html),e.css&&i.setAttribute("style",e.css)}))}})):os.ih("Control variants leave the page unmodified.")}_is_bot(){return Wt&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&g(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>g(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver}(Wt,this.zi.custom_blocked_useragents):void 0}}var ls=Yt("[Conversations]"),us="Conversations not available yet.";function hs(t,i){var e,r,s,n,a,o,l,u=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,v=null!=i&&i.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,d=F(v)?Math.max(h,2048):Math.max(h,v),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(a=null==c?void 0:c["service.name"])&&void 0!==a?a:null==t?void 0:t.serviceName)&&void 0!==n?n:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(o=null==c?void 0:c["service.version"])&&void 0!==o?o:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var vs=["debug","log","warn","error","info"],ds="console",cs="__posthogHandledLogsRequestError",fs=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[cs]=!0,e},ps=t=>!!t&&"object"==typeof t&&!0===t[cs],gs={featureFlags:class{constructor(t){this.name="featureFlags",this.uh=!1,this.featureFlagEventHandlers=[],this.I=Zr,this.hh={},this.dh={},this.fh=[],this.ph=!1,this.gh=!1,this.mh=0,this.yh=!1,this.bh=!1,this._h=!1,this.wh=!1,this.kh=0,this.Et=()=>{var t=this.Sh();this.kh=0,t&&this.reloadFeatureFlags()},this.xh=()=>{var t,i=this.Ch;F(i)||this.zi.remoteRequestsDisabled||!Kt||"hidden"===Kt.visibilityState||Date.now()-(null!==(t=this.Th)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Mh())},this.At=()=>{"visible"===(null==Kt?void 0:Kt.visibilityState)&&this.xh()},"get"in t?this.hs=t:(this.Eh=new Gr(t.config,t._shouldDisableFlags()),this.hs=this.Eh)}updateConfig(t,i){var e;null==(e=this.Eh)||e.update(t,i),this.cs&&this.Ih()}setup(t){return this.jl=t,this.I=t.logger.createLogger("[FeatureFlags]"),Pr(t.kv.initialize(),(()=>{this.jl===t&&(this.jl=void 0,this.cs=t,this.Rh(t))}))}Rh(t){if(this.cs===t)return Vt&&ri(Vt,"online",this.Et),this.Ih(),this.Ph=t.registerDynamicEventProperties((()=>this.Ah()?this.hh:this.dh)),this.Fh(),this.initialize()}Ih(){var t=this.zi.refreshIntervalMs,i=!this.zi.remoteRequestsDisabled&&Kt&&!F(t)&&t>0?t:void 0;i!==this.Ch&&(this.Oh(),F(i)||(this.Ch=i,this.Mh(),null!=Kt&&Kt.addEventListener&&ri(Kt,Ce,this.At)))}Mh(){F(this.Ch)||(F(this.Lh)||clearInterval(this.Lh),this.Th=Date.now(),this.Lh=setInterval(this.xh,this.Ch))}Oh(){F(this.Lh)||(clearInterval(this.Lh),this.Lh=void 0,null==Kt||null==Kt.removeEventListener||Kt.removeEventListener(Ce,this.At)),this.Ch=void 0,this.Th=void 0}destroy(){this.Dh()}dispose(){this.Dh()}Dh(){var t;this.Oh(),this.mh++,this.bh=!1,this.jl=void 0,this.cs&&(this.$h(),null==(t=this.Ph)||t.dispose(),this.Ph=void 0,this.fh=[],null==Vt||Vt.removeEventListener("online",this.Et),this.cs=void 0)}get zi(){return this.hs.get()}Nh(t){var i;return null==(i=this.cs)?void 0:i.kv.get(t)}Ur(t){this.qh((()=>{var i;return null==(i=this.cs)?void 0:i.kv.set(t)}))}Wr(t){this.qh((()=>{var i;return null==(i=this.cs)?void 0:i.kv.remove(t)}))}qh(t){try{t()}catch(t){this.I.error("Failed to update feature flag persistence",t)}}Fh(){var t={};for(var i of[ne,le,ue,ve]){var r=this.Nh(i);F(r)||(t[i]=r)}this.hh=t;var s=e({},t),n=this.Nh(se);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.dh=s}Ah(){var t=this.zi.cacheTtlMs;if(!t||0>=t)return!1;var i=this.Nh(xe);return"number"!=typeof i||Date.now()-i>t}jh(){return!!this.Ah()&&(this.wh||this.gh||(this.wh=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Bh(){var t=this.zi.evaluationContexts;return null!=t&&t.length?t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Hh(){var t=this.zi.flagKeys;if(!F(t))return t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.I.error("Invalid flag key found:",t,"Expected non-empty string"),i}))}initialize(){var t,i,e=this.zi,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,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.Uh({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,i,r){var a,o,l=null!=r&&r.merge&&null!==(a=this.Nh(se))&&void 0!==a?a:{},u=null!=r&&r.merge&&null!==(o=this.Nh(le))&&void 0!==o?o:{},h=e({},l,t),v=e({},u,i),d={};for(var c of Object.entries(h)){var f=c[0],p=c[1];d[f]={key:f,enabled:s(p),variant:n(p),reason:void 0,metadata:F(null==v?void 0:v[f])?void 0:{id:0,version:void 0,description:void 0,payload:v[f]}}}this.Uh({flags:d})}get hasLoadedFlags(){return this.ph}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Nh(oe),i=this.Nh(ve),r=this.Nh(de);if(!r&&!i)return t||{};var s=ti({},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=F(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=F(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.uh||(this.I.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.uh=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map((e=>{var a=t[e];return{key:e,enabled:s(a),variant:n(a),payload:r(i[e])}}))}getFlagVariants(){var t=this.Nh(se),i=this.Nh(ve);if(!i)return t||{};for(var e=ti({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.uh||(this.I.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.uh=!0),e}getFlagPayloads(){var t=this.Nh(le),i=this.Nh(de);if(!i)return t||{};for(var e=ti({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.uh||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.uh=!0),e}reloadFeatureFlags(){this.yh||this.zi.featureFlagsDisabled||this.Sh()||this.zh||(this.fh.slice().forEach((t=>{try{t()}catch(t){this.I.error("Error while running feature flags reloading callback",t)}})),this.zh=setTimeout((()=>{this.Wh()}),5))}$h(){clearTimeout(this.zh),this.zh=void 0}onReloading(t){return this.fh.push(t),()=>{this.fh=this.fh.filter((i=>i!==t))}}ensureFlagsLoaded(){this.ph||this.gh||this.zh||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.yh=t}resetFlagCallReported(){this.Wr(we)}Wh(t){this.$h();var i=this.cs;if(i&&!this.zi.remoteRequestsDisabled&&!this.Sh())if(this.gh)this.bh=!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.Nh(ce)||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.Nh(fe),timezone:er()};F(i.deviceId)||(r.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.zi.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this.Bh();s.length&&(r.evaluation_contexts=s);var n=this.Hh();F(n)||(r.flag_keys=n);var a=this.zi.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),l=this.mh;this.gh=!0;var u=()=>{this.bh&&(this.bh=!1,this.Wh())},h=t=>{this.gh=!1,l===this.mh?(this.Ur({[Se]:[Xr]}),this.I.error("Feature flag request failed",t),u()):u()};try{i.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.zi.compression,sentAt:"body",timeoutMs:this.zi.requestTimeoutMs}).then((t=>{var i,e,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.gh=!1,l===this.mh){if(this.Vh(t.statusCode),n||this.bh||(this.$anon_distinct_id=void 0),!r.disable_flags||this.bh){this._h=!n;var o=[];t.error?o.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Xr:"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.Ur({[Se]:o}),h?this.I.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):r.disable_flags||this.Uh(s,n,{partialResponse:a}),u()}}else u()})).catch(h)}catch(t){h(t)}}}Sh(){return Oe(this.kh,3)}Vh(t){this.kh=Me(t,this.kh,3,(()=>this.I.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this._h)if(this.ph||this.getFlags()&&this.getFlags().length>0){if(!this.jh()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.I.warn('getFeatureFlag for key "'+t+Yr)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this._h)if(this.ph||this.getFlags()&&this.getFlags().length>0){if(!this.jh()){var s,n=this.getFlagVariants(),a=t in n,o=n[t],l=this.getFlagPayloads()[t],u=String(o),h=this.Nh(ue)||void 0,v=this.Nh(xe)||void 0,d=this.Nh(we)||{};if(this.zi.deduplicateCallsPerSession){var c,f=null==(c=this.cs)?void 0:c.session.sessionId,p=this.Nh(ke);f&&f!==p&&(d={},s=f)}if(i.send_event||!("send_event"in i))if(t in d&&d[t].includes(u))s&&this.Ur({[we]:d,[ke]:s});else{var g,_,b,m,y,w,S,x,E,C,P,T;k(d[t])?d[t].push(u):d[t]=[u],this.Ur(e({[we]:d},s?{[ke]:s}:{}));var A=this.getFeatureFlagDetails(t),R=[...null!==(g=this.Nh(Se))&&void 0!==g?g:[]];F(o)&&R.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:o,$feature_flag_payload:null!=l?l:null,$feature_flag_request_id:h,$feature_flag_evaluated_at:v,$feature_flag_bootstrapped_response:null!==(_=null==(b=this.zi.bootstrap)||null==(b=b.featureFlags)?void 0:b[t])&&void 0!==_?_:null,$feature_flag_bootstrapped_payload:null!==(m=null==(y=this.zi.bootstrap)||null==(y=y.featureFlagPayloads)?void 0:y[t])&&void 0!==m?m:null,$used_bootstrap_value:!this._h};F(null==A||null==(w=A.metadata)?void 0:w.has_experiment)||(O.$feature_flag_has_experiment=A.metadata.has_experiment),F(null==A||null==(S=A.metadata)?void 0:S.version)||(O.$feature_flag_version=A.metadata.version);var M,I=null!==(x=null==A||null==(E=A.reason)?void 0:E.description)&&void 0!==x?x:null==A||null==(C=A.reason)?void 0:C.code;I&&(O.$feature_flag_reason=I),null!=A&&null!=(P=A.metadata)&&P.id&&(O.$feature_flag_id=A.metadata.id),F(null==A?void 0:A.original_variant)&&F(null==A?void 0:A.original_enabled)||(O.$feature_flag_original_response=F(A.original_variant)?A.original_enabled:A.original_variant),null!=A&&null!=(T=A.metadata)&&T.original_payload&&(O.$feature_flag_original_payload=null==A||null==(M=A.metadata)?void 0:M.original_payload),R.length&&(O.$feature_flag_error=R.join(",")),this.Gh(O)}else s&&this.Ur({[we]:d,[ke]:s});if(a)return{key:t,enabled:!!o,variant:"string"==typeof o?o:void 0,payload:r(l)}}}else this.I.warn('getFeatureFlagResult for key "'+t+Yr)}Gh(t){try{var i;null==(i=this.cs)||i.capture("$feature_flag_called",t).catch((t=>{this.I.error("Failed to capture feature flag call",t)}))}catch(t){this.I.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Zh(t,i)}Zh(t,e){var r=this;return i((function*(){var i=r.cs;if(i){var s={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=r.Bh();n.length&&(s.evaluation_contexts=n);var a,o=r.Hh();F(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.zi.compression,sentAt:"body",timeoutMs:r.zi.requestTimeoutMs})).json)?void 0:l.featureFlagPayloads;a=(null==u?void 0:u[t])||void 0}catch(t){return void r.I.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){r.I.error("Remote config feature flag callback failed",t)}}}))()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this._h)return i.defaultValue;if(!(this.ph||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+t+Yr),i.defaultValue;var e=this.getFeatureFlag(t,i);return F(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((i=>i!==t))}receivedFeatureFlags(t,i,e){this.Uh(t,i,e)}Uh(t,i,r){if(this.cs){this.ph=!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=Zr);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 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 v=t.requestId,d=t.evaluatedAt;if(k(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var f=0;u.length>f;f++)c[u[f]]=!0;return{[ne]:u,[se]:c,[he]:!1}}var p=u,g=h,_=l;if(null!=n&&n.partialResponse)p=e({},i,p),g=e({},r,g),_=e({},s,_);else if(t.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter((t=>{var i;return!(null!=(i=l[t])&&i.failed)})));p=e({},i,Object.fromEntries(Object.entries(p).filter((t=>b.has(t[0]))))),g=e({},r,Object.fromEntries(Object.entries(g||{}).filter((t=>b.has(t[0]))))),_=e({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>b.has(t[0])))))}else p=e({},i,p),g=e({},r,g),_=e({},s,_);return e({[ne]:Object.keys(is(p)),[se]:p||{},[le]:g||{},[oe]:_||{},[he]:!0===t.minimalFlagCalledEvents},v?{[ue]:v}:{},d?{[xe]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.I);s&&this.Ur(s),i||(this.wh=!1),this.Qh(i)}}override(t,i){void 0===i&&(i=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Jh(t)}Jh(t){if(this.cs){if(!1===t)return this.Wr([ve,de]),this.Qh(),void Qr.info("All overrides cleared");if(k(t))return this.Ur({[ve]:ts(t)}),this.Qh(),void Qr.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.uh=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[ve]=k(s)?ts(s):s),n&&(r[de]=n),Object.keys(r).length&&this.Ur(r),!1===s&&!1===n?this.Wr([ve,de]):!1===s?this.Wr(ve):!1===n&&this.Wr(de),this.Qh(),!1===s?Qr.info("Flag overrides cleared"):s&&Qr.info("Flag overrides set",{flags:s}),void(!1===n?Qr.info("Payload overrides cleared"):n&&Qr.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Ur({[ve]:t}),this.Qh(),void Qr.info("Flag overrides set",{flags:t});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.ph){var i=this.Kh(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.I.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var s=(this.Nh(ae)||[]).find((i=>i.flagKey===t)),n={["$feature_enrollment/"+t]:i},a={$feature_flag:t,$feature_enrollment:i,$set:n};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r);var o=e({},this.getFlagVariants(),{[t]:i});this.Ur({[ne]:Object.keys(is(o)),[se]:o,[ce]:e({},this.Nh(ce)||{},n)}),this.Qh();try{var l;null==(l=this.cs)||l.capture("$feature_enrollment_update",a).catch((t=>{this.I.error("Failed to capture early access feature enrollment",t)}))}catch(t){this.I.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.Nh(ae);!r||i?this.Yh(t,e):t(r)}Yh(t,e){var r=this;return i((function*(){var i=r.cs;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.Ur({[ae]:s=a.json.earlyAccessFeatures})}catch(t){return void r.I.error("Early access feature request failed",t)}try{t(s)}catch(t){r.I.error("Early access feature callback failed",t)}}}))()}Kh(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter((t=>i[t])),flagVariants:Object.keys(i).filter((t=>i[t])).reduce(((t,e)=>(t[e]=i[e],t)),{})}}Qh(t){this.Fh();var i=this.Kh(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.I.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Xh(t,i)}Xh(t,i){void 0===i&&(i=!0);var r=this.Nh(ce)||{},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.Ur({[ce]:e({},r,a,s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.Nh(ce)||{});t.forEach((t=>{delete r[t]})),this.Ur({[ce]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Wr(ce),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.Nh(fe)||{},s=e({},r);for(var n of Object.keys(t))s[n]=e({},r[n],t[n]);this.Ur({[fe]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.Nh(fe)||{};this.Ur({[fe]:e({},i,{[t]:{}})})}else this.Wr(fe)}reset(){this.mh++,this.bh=!1,this.hh={},this.dh={},this.ph=!1,this.yh=!1,this._h=!1,this.$anon_distinct_id=void 0,this.$h(),this.uh=!1,this.kh=0}}},_s={sessionRecording:class{get zi(){return this._instance.config}get Ja(){return this._instance.persistence}get started(){var t;return!(null==(t=this.td)||!t.isStarted)}get status(){var t,i;return this.ed===dr||this.ed===cr?this.ed:null!==(t=null==(i=this.td)?void 0:i.status)&&void 0!==t?t:this.ed}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.ed=hr,this.rd=void 0,this.nd=!1,this.St=(()=>{var t;if(null==Kt||!Kt.visibilityState||"visible"===Kt.visibilityState)return!0;var i=null==Vt||null==(t=Vt.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some((t=>"visible"===t.name))})(),this.At=()=>{var t;"visible"===(null==Kt?void 0:Kt.visibilityState)&&(this.St=!0,null==(t=this.td)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},this._instance=t,!this._instance.sessionManager)throw yr.error("started without valid sessionManager"),new Error(mr+" started without valid sessionManager. This is a bug.");if("always"===this.zi.cookieless_mode)throw new Error(mr+' cannot be used with cookieless_mode="always"');null!=Kt&&Kt.addEventListener&&ri(Kt,"visibilitychange",this.At)}initialize(){this.startIfEnabledOrStop()}dispose(){this.nd=!0,null==Kt||null==Kt.removeEventListener||Kt.removeEventListener("visibilitychange",this.At),this.stopRecording()}get sd(){var t,i=!(null==(t=this._instance.get_property(re))||!t.enabled),e=!this.zi.disable_session_recording,r=this.zi.disable_session_recording||this._instance.consent.isOptedOut();return Vt&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.nd||this.sd&&null!=(i=this.td)&&i.isStarted)){var e=!F(Object.assign)&&!F(Array.from);this.sd&&e?(this.ad(t),yr.info("starting")):(this.ed=hr,this.stopRecording())}}ad(t){var i,e,r;this.sd&&(this.ed!==dr&&this.ed!==cr&&(this.ed=vr),null!=He&&null!=(i=He.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=He.__PosthogExtensions__)&&e.initSessionRecording?this.od(t):null==(r=He.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.ld,(i=>{if(i)return this._instance.register_for_session({[Ee]:!0}),yr.error("could not load recorder",i);this.od(t)})))}stopRecording(){var t,i;null==(t=this.rd)||t.call(this),this.rd=void 0,null==(i=this.td)||i.stop()}ud(){var t,i;null==(t=this.rd)||t.call(this),this.rd=void 0,null==(i=this.td)||i.discard()}hd(){var t,i;null==(t=this.Ja)||t.unregister("$session_is_sampled"),null==(i=this.Ja)||i.unregister("$replay_sample_rate")}dd(t,i){if(A(t))return null;var e,r=R(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(yr.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}vd(t){if(this.Ja){var i,r,s=this.Ja,n=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.dd(null==(i=this.zi.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.dd(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;A(o)&&this.hd();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[re]: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:F(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(i=this.rd)||i.call(this),this.rd=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.vd(i),void this.ud()):(this.vd(i),void this.startIfEnabledOrStop()):(this.ed===dr&&(this.ed=cr,yr.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.td)&&e.log?this.td.log(t,i):yr.warn("log called before recorder was ready")}get ld(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(re);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}fd(){var t,i=this._instance.get_property(re);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return yr.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!A(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}od(t){var i,e,r;if(!this.nd){if(null==(i=He.__PosthogExtensions__)||!i.initSessionRecording)return yr.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Ee]:!0});var s;if(this.td||(this.td=null==(s=He.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.St),this.td._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.fd()){if(this.ed===cr||this.ed===dr)return;return this.ed=dr,yr.info("persisted remote config is stale, requesting fresh config before starting"),void new ur(this._instance).load()}this.ed=vr,null==(e=(r=this.td).setDocumentWasEverVisible)||e.call(r,this.St),this.td.start(t)}}onRRwebEmit(t){var i;null==(i=this.td)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.td||null==(i=this.Ja)||i.register({$replay_override_linked_flag:!0}),null==(t=this.td)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.td||null==(i=this.Ja)||i.register({$replay_override_sampling:!0}),null==(t=this.td)||t.overrideSampling()}overrideTrigger(t){var i,e;this.td||null==(e=this.Ja)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.td)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.td)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.td)||!e.tryAddCustomEvent(t,i))}}},bs={autocapture:class extends Ne{constructor(t){super(new ze(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.pd=this.gd()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.md();return!!(t.path||t.search||this.yd(t))}startIfEnabled(){this.isEnabled&&(Qt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.pd=this.gd(),this.startIfEnabled()}stop(){this.bd&&this.bd(),this.bd=void 0,this._d&&this._d(),this._d=void 0,Qt.info("History API monitoring stopped")}monitorHistoryChanges(){Vt&&Vt.history&&(this.wd("pushState"),this.wd("replaceState"),this.kd(),this.yd()&&this.Sd())}wd(t){var i;if(Vt&&(null==(i=Vt.history[t])||!i.__posthog_wrapped__)){var e=this;Ge(Vt.history,t,(i=>function(r,s,n){i.call(this,r,s,n),e.xd(t)}))}}gd(){var t=null==Vt?void 0:Vt.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}md(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:x(t)?t:{}}yd(t){return void 0===t&&(t=this.md()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Cd(t){var i=this.md(),e=this.pd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.yd(i)&&t.hash!==e.hash))}xd(t){try{var i=this.gd();if(!i)return;this.Cd(i)&&this._instance.capture("$pageview",{navigation_type:t}),this.pd=i}catch(i){Qt.error("Error capturing "+t+" pageview",i)}}kd(){if(!this.bd){var t=()=>{this.xd("popstate")};ri(Vt,"popstate",t),this.bd=()=>{Vt&&Vt.removeEventListener("popstate",t)}}}Sd(){if(!this._d){var t=()=>{this.xd("hashchange")};ri(Vt,"hashchange",t),this._d=()=>{Vt&&Vt.removeEventListener("hashchange",t)}}}},heatmaps:class{get zi(){return this.instance.config}constructor(t){var i;this.Td=!1,this.ns=!1,this.Md=null,this.instance=t,this.Td=!(null==(i=this.instance.persistence)||!i.props[Gi]),this.rageclicks=new Ki(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return x(this.zi.capture_heatmaps)&&this.zi.capture_heatmaps.flush_interval_milliseconds&&(t=this.zi.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return A(this.zi.capture_heatmaps)?A(this.zi.enable_heatmaps)?this.Td:this.zi.enable_heatmaps:!1!==this.zi.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ns)return;wr.info("starting..."),this.Ed(),this.At()}else{var t;clearInterval(null!==(t=this.Md)&&void 0!==t?t:void 0),this.Id(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Gi]:e}),this.Td=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.bt;return this.bt=void 0,t}Rd(t){kr(t.originalEvent)&&this.Ei(t.originalEvent,"deadclick")}At(){this.Md&&clearInterval(this.Md),this.Md="visible"===(null==Kt?void 0:Kt.visibilityState)?setInterval(this.ja.bind(this),this.flushIntervalMilliseconds):null}Ed(){Vt&&Kt&&(this.Pd=this.ja.bind(this),ri(Vt,Pe,this.Pd),this.Ad=t=>this.Ei(t||(null==Vt?void 0:Vt.event)),ri(Kt,"click",this.Ad,{capture:!0}),this.Fd=t=>this.Od(t||(null==Vt?void 0:Vt.event)),ri(Kt,"mousemove",this.Fd,{capture:!0}),this.Ld=new Be(this.instance,Ve,this.Rd.bind(this)),this.Ld.startIfEnabledOrStop(),this.Dd=this.At.bind(this),ri(Kt,Ce,this.Dd),this.ns=!0)}Id(){var t;Vt&&Kt&&(this.Pd&&Vt.removeEventListener(Pe,this.Pd),this.Ad&&Kt.removeEventListener("click",this.Ad,{capture:!0}),this.Fd&&Kt.removeEventListener("mousemove",this.Fd,{capture:!0}),this.Dd&&Kt.removeEventListener(Ce,this.Dd),clearTimeout(this.$d),null==(t=this.Ld)||t.stop(),this.ns=!1)}Nd(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,i,e){for(var r=t;r&&vi(r)&&!di(r,"body");){if(r===e)return!1;var s=void 0;try{var n,a,o;s=null==(n=null!==(a=null==(o=r.ownerDocument)?void 0:o.defaultView)&&void 0!==a?a:Vt)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(_(i,s))return!0;r=xi(r)}return!1}(wi(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:e),target_fixed:n,type:i}}Ei(t,i){var r;if(void 0===i&&(i="click"),!hi(t.target)&&kr(t)){var s=this.Nd(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Ai(wi(t),this.instance.config.rageclick)&&this.Vn(e({},s,{type:"rageclick"})),this.Vn(s)}}Od(t){!hi(t.target)&&kr(t)&&(clearTimeout(this.$d),this.$d=setTimeout((()=>{this.Vn(this.Nd(t,"mousemove"))}),500))}Vn(t){if(Vt){var i=this.zi.disable_capture_url_hashes?H(Vt.location.href):Vt.location.href,e=this.zi.custom_personal_data_properties,r=this.zi.mask_personal_data_properties?[...Qe,...e||[]]:[],s=Ae(i,r,Xe);this.bt=this.bt||{},this.bt[s]||(this.bt[s]=[]),this.bt[s].push(t)}}ja(){this.bt&&!E(this.bt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Be,webVitalsAutocapture:class{constructor(t){var i;this.Td=!1,this.ns=!1,this.bt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.qd=()=>{clearTimeout(this.jd),this.jd=void 0,0!==this.bt.metrics.length&&(this._instance.capture("$web_vitals",e({$current_url:this.bt.url},this.bt.metrics.reduce(((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.bt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Bd=t=>{var i;if(this.bt=this.bt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},A(null==t?void 0:t.name)||A(null==t?void 0:t.value))rr.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.Hd(r);if(!F(s)){var n=R(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.Ud||this.Ud>t.value){this.bt.navigationKey!==n&&(this.qd(),this.jd=setTimeout(this.qd,this.flushToCaptureTimeoutMs)),F(this.bt.navigationKey)&&(this.bt.navigationKey=n,this.bt.url=s),this.bt.firstMetricTimestamp=F(this.bt.firstMetricTimestamp)?Date.now():this.bt.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,x(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of or){var h="url"===u&&"string"==typeof t.attribution[u]?this.Hd(t.attribution[u]):t.attribution[u];F(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;F(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.bt.metrics.push(o),this.bt.metrics.length===this.allowedMetrics.length&&this.qd()}else rr.error("Ignoring metric with value >= "+this.Ud,t)}}},this.zd=()=>{if(!this.ns){var t,i,r,s,n=!1,a=He.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Wd])||("web-vitals"===this.Wd&&F(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!F(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!F(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,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.Bd.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Bd.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Bd.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.Bd.bind(this),d),this.ns=!0}else rr.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Td=!(null==(i=this._instance.persistence)||!i.props[Xi]),this.startIfEnabled()}get Vd(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=x(this.Vd)?null==(t=this.Vd)?void 0:t.web_vitals_allowed_metrics:void 0;return A(e)?(null==(i=this._instance.persistence)?void 0:i.props[ee])||nr:e}get flushToCaptureTimeoutMs(){return(x(this.Vd)?this.Vd.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=x(this.Vd)?this.Vd.web_vitals_attribution:void 0;return O(t)?t?nr:[]:k(t)?t:ar}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t=x(this.Vd)?this.Vd.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get Ud(){var t=x(this.Vd)&&R(this.Vd.__web_vitals_max_value)?this.Vd.__web_vitals_max_value:sr;return t>0&&6e4>=t?sr:t}get isEnabled(){var t=null==Jt?void 0:Jt.protocol;if("http:"!==t&&"https:"!==t)return rr.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=x(this.Vd)?this.Vd.web_vitals:O(this.Vd)?this.Vd:void 0;return O(i)?i:this.Td}startIfEnabled(){this.isEnabled&&!this.ns&&(rr.info("enabled, starting..."),this.Es(this.zd))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=x(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=x(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xi]:e}),this._instance.persistence.register({[ee]:r})),this.Td=e,this.startIfEnabled()}}}get Wd(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Es(t){var i=He.__PosthogExtensions__,e=this.Wd,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&F(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?rr.error("failed to load script",i):t()}))}Hd(t){var i=t||(null==Vt?void 0:Vt.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?H(i):i,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...Qe,...r||[]]:[];return Ae(e,s,Xe)}rr.error("Could not determine current URL")}}},ms={exceptionObserver:class{constructor(t){var i;this.zd=()=>{var t;if(Vt&&this.isEnabled&&null!=(t=He.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=He.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=He.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=He.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Gd&&this.zi.capture_unhandled_errors&&(this.Gd=i(this.captureException.bind(this))),!this.Zd&&this.zi.capture_unhandled_rejections&&(this.Zd=e(this.captureException.bind(this))),!this.Qd&&this.zi.capture_console_errors&&(this.Qd=r(this.captureException.bind(this)))}catch(t){We.error("failed to start",t),this.Jd()}}},this._instance=t,this.Kd=!(null==(i=this._instance.persistence)||!i.props[Zi]),this.oe=new U(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,I:We})),this.zi=this.Yd(),this.startIfEnabledOrStop()}Yd(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return x(t)?i=e({},i,t):(F(t)?this.Kd:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.zi.capture_console_errors||this.zi.capture_unhandled_errors||this.zi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(We.info("enabled"),this.Jd(),this.Es(this.zd)):this.Jd()}Es(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return We.error("failed to load script",i);t()}))}Jd(){var t,i,e;null==(t=this.Gd)||t.call(this),this.Gd=void 0,null==(i=this.Zd)||i.call(this),this.Zd=void 0,null==(e=this.Qd)||e.call(this),this.Qd=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Kd=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Zi]:this.Kd}),this.zi=this.Yd(),this.startIfEnabledOrStop())}}onConfigChange(){this.zi=this.Yd()}captureException(t){var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";this.oe.consumeRateLimit(s)?We.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.Xd=[],this.tv=new ct([new Et,new It,new Ct,new Ft,new Mt,new Ot,new Tt,new $t],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=xt.test(l)?l.replace(xt,"$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||ft});var r}))}(n)}}("web:javascript",yt,St)),this._instance=t,this.Xd=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property(Qi))&&void 0!==i?i:[],this.ev=zt(this.iv()),this.rv=new Ut(this.ev)}onConfigChange(){this.ev=zt(this.iv()),this.rv.setConfig(this.ev)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],a=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Xd=n,this._instance.persistence&&this._instance.persistence.register({[Qi]:this.Xd,[Yi]:a})}}}get nv(){var t,i=!!this._instance.get_property(Yi),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.tv.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.ev.enabled)try{if(!C(t)||0===t.trim().length)return void es.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)=>Dt.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.sv(i)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&es.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.rv.add(e({[jt]:t,[Lt]:(new Date).toISOString()},s))}catch(t){es.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.av(i)){if(this.ov(i))return this.lv("Exception dropped: matched a suppression rule"),void es.info("Skipping exception capture because a suppression rule matched");if(!this.nv&&this.uv(i))return this.lv("Exception dropped: thrown by a browser extension"),void es.info("Skipping exception capture because it was thrown by an extension");if(!this.nv&&this.hv(i))return this.lv("Exception dropped: thrown by an injected browser script"),void es.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.dv(i))return this.lv("Exception dropped: thrown by the PostHog SDK"),void es.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.ev.enabled&&A(t.$exception_steps)?this.vv(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return s&&this.rv.clear(),s}catch(t){return es.error("Failed to capture exception event. Dropping this exception.",t),void this.rv.clear()}}catch(t){return void es.error("Failed to process exception event. Ignoring this exception.",t)}var n}vv(t){try{var i=this.rv.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(i){return es.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}lv(t){this.ev.enabled&&this.rv.add({[jt]:t,[Lt]:(new Date).toISOString()})}sv(t){return x(t)?e({},t):{}}iv(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}ov(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return C(e)&&e.length>0&&t.$exception_types.push(e),C(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Xd.some((t=>{var e=t.values.map((t=>{var e=_r[t.operator],r=i[t.key];if(!e||!r)return!1;var s=k(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 es.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}uv(t){return t.flatMap((t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]})).some((t=>{var i=t.filename;return!!i&&rs.some((t=>i.startsWith(t)))}))}hv(t){return t.some((t=>{var i=t.value;return C(i)&&ss.some((t=>i.includes(t)))}))}dv(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[],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}av(t){return!A(t)&&k(t)}}},ys=e({productTours:class{get Ja(){return this._instance.persistence}constructor(t){this.fv=null,this.pv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.Ja&&this.Ja.register({[te]:!!i.productTours}),!xr(this._instance))return!this.fv&&A(null==(e=this.Ja)?void 0:e.props[ye])||Sr.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.fv)||r.stop(),this.fv=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.fv&&xr(this._instance)&&this.Es((()=>this.gv()))}Es(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?Sr.error("Could not load product tours script",i):t()}))}gv(){var t;!this.fv&&null!=(t=He.__PosthogExtensions__)&&t.generateProductTours&&(this.fv=He.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!k(this.pv)||i){var e=this.Ja;if(e){var r=e.props[ye];if(k(r)&&!i)return this.pv=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(xr(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||Sr.warn(s):Sr.error(s),void t([],{isLoaded:!1,error:s})}var n=k(i.json.product_tours)?i.json.product_tours:[];this.pv=n,e&&e.register({[ye]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.pv,{isLoaded:!0})}getActiveProductTours(t){A(this.fv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.fv.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.fv)||i.showTourById(t)}previewTour(t){this.fv?this.fv.previewTour(t):this.Es((()=>{var i;this.gv(),null==(i=this.fv)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.fv)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.fv)||t.nextStep()}previousStep(){var t;null==(t=this.fv)||t.previousStep()}clearCache(){var t;this.pv=null,null==(t=this.Ja)||t.unregister(ye)}resetTour(t){var i;null==(i=this.fv)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.fv)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.fv)||i.cancelPendingTour(t)}}},gs),ws={siteApps:class{constructor(t){this.mv=0,this._instance=t,this.yv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}bv(t,i){if(i){var e=this.globalsForEvent(i);this.yv.push(e),this.yv.length>1e3&&(this.yv=this.yv.slice(10))}}get siteAppLoaders(){var t;return null==(t=He._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.bv.bind(this));this._v=()=>{t(),this.yv=[],this._v=void 0}}}globalsForEvent(t){var i,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,Er),{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}}wv(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Fr.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)||(Fr.error("prepare_external_dependency_script returned null"),null):t}Sv(){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==Kt?void 0:Kt.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.mv++,this.xv)return this.Cv();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.wv(t);return i&&d.add(i),i},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!T(t)));return c(u,"appendChild",(t=>function(i){var e=f(i);return e?t.call(this,e):i})),c(u,"insertBefore",(t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i})),c(u,"replaceChild",(t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e})),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((t=>{c(t,"append",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})),c(t,"prepend",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach((t=>{c(t,"before",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})),c(t,"after",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})),c(t,"replaceWith",(t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)}))})),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",(t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null})),this.xv=()=>{h.forEach((t=>t())),this.xv=void 0},this.Cv()}Cv(){var t=!1;return()=>{var i;t||(t=!0,this.mv--,0===this.mv&&(null==(i=this.xv)||i.call(this)))}}Tv(t,i){void 0===i&&(i=!0);var e=this.Sv();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.yv.length&&(Fr.info("Processing "+this.yv.length+" events for site app with id "+t.id),this.yv.forEach((t=>this.Tv((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this._v)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,Fr.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Tv((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){Fr.error(Cr+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){Fr.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}Mv(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}Ev(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Tv((()=>null==r.processEvent?void 0:r.processEvent(e)))}catch(i){Fr.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.Mv(),void this._instance.on("eventCaptured",(t=>this.Ev(t)))):void Fr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this._v)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,i=o.id,e=o.url;He["__$$ph_site_app_"+i]=s._instance,null==(t=He.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return Fr.error(Cr+i,t)}))};for(var o of n.siteApps)a()}else Fr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},ks={tracingHeaders:class{constructor(t){this.Iv=void 0,this.Rv=void 0,this.Pv=void 0,this.zd=()=>{var t,i,e=this.Av();e?(F(this.Iv)&&(this.Iv=null==(t=He.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),F(this.Rv)&&(this.Rv=null==(i=He.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Jd()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Es(t){var i,e;null!=(i=He.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=He.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return Ze.error("failed to load script",i);t()}))}Fv(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Av(){var t=this.Fv();return k(t)?(k(this.Pv)?this.Pv.splice(0,this.Pv.length,...t):this.Pv=[...t],t.length>0?this.Pv:void 0):(k(this.Pv)&&this.Pv.splice(0),this.Pv=t||void 0,this.Pv)}Jd(){var t,i;null==(t=this.Iv)||t.call(this),null==(i=this.Rv)||i.call(this),this.Iv=void 0,this.Rv=void 0}startIfEnabledOrStop(){this.Av()?this.Es(this.zd):this.Jd()}}},Ss=e({surveys:class extends Lr{constructor(t){var i;super(new Vr(t),{get projectToken(){return i.config.token},kv:new qr(i=t)}),this._instance=t}Wl(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 Xt(t,(function(t,i){F(t)||F(i)||"undefined"===i||(e=encodeURIComponent(t instanceof File?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)})),s.join(i)}(l);return h&&u.push(h),u.length>0?a+"?"+u.join("&"):a}(t,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})}))}}},gs),xs={toolbar:class{constructor(t){this.instance=t}Ov(t){He.ph_toolbar_state=t}Lv(){var t;return null!==(t=He.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),si(this.instance.config))return!1;if(!Vt||!Kt)return!1;t=null!=t?t:Vt.location,e=null!=e?e:Vt.history;try{if(!i){try{Vt.localStorage.setItem("test","test"),Vt.localStorage.removeItem("test")}catch(t){return!1}i=null==Vt?void 0:Vt.localStorage}var r,s=Br||Re(t.hash,"__posthog")||Re(t.hash,"state"),n=s?ei((()=>JSON.parse(atob(decodeURIComponent(s)))))||ei((()=>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(Wr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Dv(t){var i=He.ph_load_toolbar||He.ph_load_editor;!A(i)&&S(i)?i(t,this.instance):Kr.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==Kt||!Kt.getElementById(ai));if(!Vt||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(Vt.localStorage.setItem(Wr,JSON.stringify(e({},s,{source:void 0}))),2===this.Lv())this.Dv(s);else if(0===this.Lv()){var n;this.Ov(1),null==(n=He.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return Kr.error("[Toolbar] Failed to load",t),void this.Ov(0);this.Ov(2),this.Dv(s)})),ri(Vt,"turbolinks:load",(()=>{this.Ov(0),this.loadToolbar(s)}))}return!0}$v(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},Es=e({experiments:os},gs),Fs={conversations:class{constructor(t){this.Nv=void 0,this._conversationsManager=null,this.qv=!1,this.Me=null,this.jv=!1,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Bv=t.ok,t.ok)){var i=t.config.conversations;A(i)||(O(i)?this.Nv=i:(this.Nv=i.enabled,this.Me=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Nv=void 0,this.Me=null,this.Bv=void 0,this.jv=!1}loadIfEnabled(){if(!(this._conversationsManager||this.qv||this._instance.config.disable_conversations||si(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==He?void 0:He.__PosthogExtensions__;if(t&&!F(this.Nv)&&this.Nv)if(this.Me&&this.Me.token){this.qv=!0;try{var i=t.initConversations;if(i)return this.Hv(i),void(this.qv=!1);var e=t.loadExternalDependency;if(!e)return void this.Uv(Fe);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.Uv("Could not load conversations script",i):this.Hv(t.initConversations),this.qv=!1}))}catch(t){this.Uv("Error initializing conversations",t),this.qv=!1}}else ls.error("Conversations enabled but missing token in remote config.")}}Hv(t){if(this.Me)try{this._conversationsManager=t(this.Me,this._instance),this.jv=!1,ls.info("Conversations loaded successfully")}catch(t){this.Uv("Error completing conversations initialization",t)}else ls.error("Cannot complete initialization: remote config is null")}Uv(t,i){ls.error(t,i),this._conversationsManager=null,this.qv=!1,this.jv=!0}show(){this._conversationsManager?this._conversationsManager.show():ls.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Nv&&!T(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":si(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Bv?"remote_config_failed":F(this.Nv)?this.Bv?"disabled_in_project":"remote_config_pending":this.Nv?A(this.Me)||!this.Me.token?"missing_token":null!=He&&He.__PosthogExtensions__?this.qv?"initializing":this.jv?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,e,r){var s=this;return i((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,r):(ls.warn(us),null)}))()}getMessages(t,e){var r=this;return i((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,e):(ls.warn(us),null)}))()}markAsRead(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(ls.warn(us),null)}))()}getTickets(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(ls.warn(us),null)}))()}requestRestoreLink(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(ls.warn(us),null)}))()}restoreFromToken(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(ls.warn(us),null)}))()}restoreFromUrlToken(){var t=this;return i((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(ls.warn(us),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()}}},Cs={logs:class{constructor(t){var i,r=this;this.name="logs",this.zv=!1,this.Wv=!1,this.Vv=!1,this.I=Yt("[logs]"),this.Gv=e({},this.I,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(ps)||r.I.error(...i)}}),this.Ea=[],this.Zv=[],this.kh=0,this.us=!1,this.Qv=[],this.Jv=[],this.Kv=!1,this.Yv=!1,this.Xv=()=>{var t,i;this.us||(this.kh=0,null==(t=this.tc)||t.onReconnect(),null==(i=this.ec)||i.onReconnect())},this._instance=t,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.zv=!0),Vt&&ri(Vt,"online",this.Xv)}ic(t,i,e,r){var s,n=hs(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new st(this.rc(t,i),n,this.Gv,(()=>this.nc()),(t=>t()),void 0,r),n]}sc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.tc||this.ac!==i){var e;null==(e=this.tc)||e.reset(),this.ac=i;var r=this.ic((()=>this.Ea),(t=>{this.Ea=t}));this.tc=r[0],this.oc=r[1]}return this.tc}lc(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.ec||this.uc!==i){var e;null==(e=this.ec)||e.reset(),this.uc=i;var r=this.ic((()=>this.Zv),(t=>{this.Zv=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},ds);this.ec=r[0],this.hc=r[1]}return this.ec}setup(t){var i;if(!this.us){this.cs=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.zv=!0),(this.zv||this.dc()&&this.vc())&&this.cc();var e=!1,r=t.onRemoteConfig((t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)}));this.us?r.dispose():(this.fs=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.us||(this.us=!0,this.fc(),null==(t=this.fs)||t.dispose(),this.fs=void 0,this.cs=void 0,this.Vv=!1,null==Vt||Vt.removeEventListener("online",this.Xv),null==(i=this.gc)||i.call(this),this.gc=void 0,null==(e=this.tc)||e.reset(),null==(r=this.ec)||r.reset())}onRemoteConfig(t){var i,e;if(!this.us){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;A(r)?this.mc():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[ie]:!!r}),r?(this.zv=!0,this.Wv||this.cc(),this.loadIfEnabled()):this.mc())}}reset(){var t,i,e,r;this.fc(),null==(t=this.tc)||t.clearQueue(),this.Ea=[],null==(i=this.tc)||i.reset(),null==(e=this.ec)||e.clearQueue(),this.Zv=[],null==(r=this.ec)||r.reset(),this.kh=0}captureLog(t){this.us||this.sc().captureLog(t)}captureConsoleLog(t){this.us||this.lc().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.us||this.lc().captureLog(t,{context:i,occurredAtMs:e})}vc(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[ie])}dc(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=He._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.fc(),null==(t=this.ec)||t.clearQueue(),this.Zv=[]}mc(){this.zv||this.fc()}cc(){var t,i=this;if(!this.Kv&&null!=He&&He.console){var e=hs(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})(He.console[t])}catch(t){return 0}if(!r)return 0;i.Jv.push(Ge(He.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.yc(t,n,e)}catch(t){}return s.apply(He.console,n)};return n.__rrweb_original__=r,n})))};for(var s of vs)r(s);this.Kv=!0,this.bc=setTimeout((()=>{this.fc()}),3e4)}}yc(t,i,e){var r;if(this.Kv&&!this.Yv&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Qv.length){this.Yv=!0;try{this.Qv.push({level:t,args:i,occurredAtMs:Date.now(),context:this.nc()})}finally{this.Yv=!1}}}else this.fc()}fc(){if(this.Qv=[],this.Kv){for(var t of(this.Kv=!1,this.bc&&(clearTimeout(this.bc),this.bc=void 0),this.Jv))t();this.Jv=[]}}_c(){var t=this.Qv;return this.fc(),t}get logger(){return this.wc||(this.wc={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.wc}flushLogs(t){t?this.kc(t):(this.tc&&this.tc.flush().catch((t=>this.Sc(t))),this.ec&&this.ec.flush().catch((t=>this.Sc(t))))}Sc(t){ps(t)||this.I.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.us&&this.zv&&!this.Wv&&!this.Vv){var t=null==He?void 0:He.__PosthogExtensions__;if(!t)return this.I.error("PostHog Extensions not found."),void this.fc();var i=t.loadExternalDependency;if(!i)return this.I.error(Fe),void this.fc();this.Vv=!0;try{i(this._instance,"logs",(i=>{if(this.Vv=!1,!this.us&&this.zv){var e=t.logs;if(i||null==e||!e.initializeLogs)this.I.error("Could not load logs script",i),this.fc();else{var r,s,n=this._c();this.gc=e.initializeLogs(null!==(r=this.cs)&&void 0!==r?r:this._instance),this.Wv=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.cs)&&void 0!==s?s:this._instance,n))}}}))}catch(t){throw this.Vv=!1,t}}}rc(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===a.LogsQueue?t():void 0,setPersistedProperty(t,e){var r;t===a.LogsQueue&&i(null!==(r=e)&&void 0!==r?r:[])},Ln:t=>this.Ln(t),getLibraryId:()=>qt.LIB_NAME,getLibraryVersion:()=>qt.LIB_VERSION}}Ln(t){return new Promise((i=>{if(Oe(this.kh,3))i({kind:"fatal",error:fs(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout((()=>{this.I.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:fs(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.xc(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.Cc(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.I.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:fs(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}}))}Cc(t){(0!==t||this._instance.__loaded)&&(this.kh=Me(t,this.kh,3,(()=>this.I.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes."))))}kc(t){this.Ea.length>0&&this.Tc(t,this.Ea,this.oc,qt.LIB_NAME,(t=>{this.Ea=t})),this.Zv.length>0&&this.Tc(t,this.Zv,this.hc,ds,(t=>{this.Zv=t}))}Tc(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var a=rt(n,et(e,qt.LIB_NAME,qt.LIB_VERSION),r,qt.LIB_VERSION);this._instance._send_request({method:"POST",url:this.xc(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}xc(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}nc(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,A(s)||(i.sessionStartTimestamp=s),A(n)||(i.lastActivityTimestamp=n)}if(null!=He&&null!=(t=He.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?H(He.location.href):He.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Ps={metrics:class{constructor(t){this.I=Yt("[metrics]"),this._instance=t}initialize(){}sc(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.tc&&this.ac===e||(null==(i=this.tc)||i.reset(),this.ac=e,this.tc=new lt(this.rc(),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.I)),this.tc}count(t,i,e){void 0===i&&(i=1),this.sc().count(t,i,e)}gauge(t,i,e){this.sc().gauge(t,i,e)}histogram(t,i,e){this.sc().histogram(t,i,e)}flush(t){if(!this.tc)return Promise.resolve();if(t){var i=this.tc.drainWindow();return i&&this.Kn(i,t),Promise.resolve()}return this.tc.flush().catch((t=>this.I.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.tc)||t.reset()}rc(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Kn:t=>i.Kn(t),getLibraryId:()=>qt.LIB_NAME,getLibraryVersion:()=>qt.LIB_VERSION}}Kn(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.Mc(),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)})}}}))}))}Mc(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Ts=e({},gs,_s,bs,ms,ys,ws,Ss,ks,xs,Es,Fs,Cs,Ps),As=gs,Rs=_s,Os=bs,Ms=ms,$s=ys,Is=ws,js=Ss,Ls=ks,Ds=xs,Ns=Es,zs=Fs,Us=Cs,Hs=Ps;export{Ts as AllExtensions,Os as AnalyticsExtensions,zs as ConversationsExtensions,Ms as ErrorTrackingExtensions,Ns as ExperimentsExtensions,As as FeatureFlagsExtensions,Us as LogsExtensions,Hs as MetricsExtensions,$s as ProductToursExtensions,Rs as SessionReplayExtensions,Is as SiteAppsExtensions,js as SurveysExtensions,Ds as ToolbarExtensions,Ls as TracingExtensions};
|
|
2
2
|
//# sourceMappingURL=extension-bundles.js.map
|