posthog-js 1.412.0 → 1.412.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.no-external.js +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/product-tours-preview.js +1 -1
- package/dist/product-tours-preview.js.map +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/product-tours.js.map +1 -1
- package/dist/rrweb.js +1 -1
- package/dist/rrweb.js.map +1 -1
- package/lib/package.json +1 -1
- package/package.json +6 -6
|
@@ -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.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.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=["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"],l=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return o.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function u(t,i){return-1!==t.indexOf(i)}var h=function(t){return t.trim()},v=Object.prototype,d=v.hasOwnProperty,c=v.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},p=t=>"function"==typeof t,g=t=>t===Object(t)&&!f(t),_=t=>{if(g(t)){for(var i in t)if(d.call(t,i))return!1;return!0}return!1},m=t=>void 0===t,b=t=>"[object String]"==c.call(t),y=t=>null===t,w=t=>m(t)||y(t),k=t=>"[object Number]"==c.call(t)&&t==t,S=t=>"[object Boolean]"===c.call(t),x=t=>t instanceof FormData;function E(t){return null===t||"object"!=typeof t}function F(t,i){return{}.toString.call(t)==="[object "+i+"]"}function P(t){return"undefined"!=typeof Event&&T(t,Event)}function T(t,i){try{return t instanceof i}catch(t){return!1}}function C(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),k(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),C(e,i,e,r))}class A{constructor(t){this.tt={},this.et=t.et,this.it=C(t.bucketSize,0,100,t.rt),this.nt=C(t.refillRate,0,this.it,t.rt),this.st=C(t.refillInterval,0,864e5,t.rt)}ot(t,i){var e=Math.floor((i-t.lastAccess)/this.st);e>0&&(t.tokens=Math.min(t.tokens+e*this.nt,this.it),t.lastAccess=t.lastAccess+e*this.st)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.tt[r];return s?this.ot(s,e):this.tt[r]=s={tokens:this.it,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.et)||i.call(this,t)),0===s.tokens)}stop(){this.tt={}}}function R(t){return t?t.split("#")[0]:t}function O(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function M(t,i,e){return I.apply(this,arguments)}function I(){return(I=i((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=O((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var j={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}},L=j.info;function D(t){if(S(t))return{boolValue:t};if("number"==typeof t)return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if("string"==typeof t)return{stringValue:t};if(f(t))return{arrayValue:{values:t.map((t=>D(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(i){return{stringValue:String(t)}}}function N(t){var i=[];for(var e in t){var r=t[e];y(r)||m(r)||i.push({key:e,value:D(r)})}return i}function z(t,i){var r=j[t.level||"info"]||L,s=r.text,n=r.number,a=String(Date.now())+"000000",o={};i.distinctId&&(o.posthogDistinctId=i.distinctId),i.sessionId&&(o.sessionId=i.sessionId),i.windowId&&(o["window.id"]=i.windowId),w(i.sessionStartTimestamp)||(o.sessionStartTimestamp=String(i.sessionStartTimestamp)),w(i.lastActivityTimestamp)||(o.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(o["url.full"]=i.currentUrl),i.screenName&&(o["screen.name"]=i.screenName),i.appState&&(o["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(o.feature_flags=i.activeFeatureFlags);var l=e({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:N(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),m(t.trace_flags)||(u.flags=t.trace_flags),u}function U(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 H(t,i,e,r){return{resourceLogs:[{resource:{attributes:N(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let B=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Pe=i,this.rt=e,this.ut=r,this.ht=s,this.dt=n,this.vt=a,this.ct=null,this.ft=0,this.yt=0,this.bt=0,this._t=0,this.wt=!1,this.xt=i.maxBufferSize,this.kt=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.St=i.flushIntervalMs,this.Ct=i.maxBatchRecordsPerPost,this.Mt=i.rateCapWindowMs,this.Tt=i.maxLogsPerInterval}reset(){this.Et(),this.ct=null,this.bt=0,this._t=0,this.wt=!1,this.ft=0,this.yt=0,this.Ct=this.Pe.maxBatchRecordsPerPost}onReconnect(){this.yt=0,this.It()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var i=this.Pt(t);if(null!==i)if(i.body){if(this.Rt()){var e={record:z(i,this.ut())};this.ht((()=>this.Lt(e)))}}else this.rt.info("Log was rejected in beforeSend function")}}Pt(t){var i=this.Pe.beforeSend;if(!i)return t;var e=f(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.rt.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for log:",t),null}return r}Rt(){if(void 0===this.Tt)return!0;var t=Date.now(),i=t-this.bt;return this.Mt>i&&i>=0||(this.bt=t,this._t=0,this.wt=!1),this.Tt>this._t?(this._t++,!0):(this.wt||(this.rt.warn("captureLog dropping logs: exceeded "+this.Tt+" logs per "+this.Mt+"ms"),this.wt=!0),!1)}flush(){var t=this;return i((function*(){if(!t._instance.isDisabled)return t.ct||(t.ct=t.Ot().finally((()=>{t.ct=null}))),t.ct}))()}Ot(){var t=this;return i((function*(){var i;t.Et();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;t.ft=0;var l=Math.min(e.length,t.Ct),u=e.slice(0,l),h=H(u.map((t=>t.record)),t.Ft(),null!==(n=t.vt)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.At(h);if("too-large"===v.kind&&u.length>1)t.Ct=Math.max(1,Math.floor(u.length/2)),t.rt.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.Ct);else{if("retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.rt.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"===v.kind&&t.Pe.maxBatchRecordsPerPost>t.Ct&&(t.Ct=Math.min(t.Pe.maxBatchRecordsPerPost,t.Ct+1)),yield t.Dt(u.length),e=null!==(o=t._instance.getPersistedProperty(a.LogsQueue))&&void 0!==o?o:[],s+=u.length,"fatal"===v.kind)throw v.error}}}))()}Dt(t){var e=this;return i((function*(){var i,r=Math.max(0,t-e.ft),s=null!==(i=e._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(a.LogsQueue,s.slice(r)),yield e.dt()}))()}Ft(){return U(this.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Lt(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];this.kt>e.length||(e.shift(),this.ft++,this.rt.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(a.LogsQueue,e),this.xt>e.length?this.$t():this.It()}}$t(t){void 0===t&&(t=this.St),this.Nt||(this.Nt=O((()=>{this.Nt=void 0,this.It()}),t))}qt(){var t=Math.min(Math.max(0,this.yt-1),6);return this.St*Math.pow(2,t)}jt(){var t=this._instance.getPersistedProperty(a.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return i((function*(){e.Et();var i=e.flush().catch((()=>{}));void 0!==t?yield M(i,t):yield i}))()}flushWithTimeout(t){var e=this;return i((function*(){var i=e.flush();yield M(i,t,(()=>{i.catch((()=>{}))}))}))()}It(){this.flush().then((()=>{this.yt=0}),(t=>{this.yt++,this.rt.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.jt()&&this.$t(this.qt())}))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}};var q=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function V(t){return String(t)+"000000"}function W(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 K=class{constructor(t,i,e){this._instance=t,this.Pe=i,this.rt=e,this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Wt=0}count(t,i,e){void 0===i&&(i=1),this.Vt({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.Vt({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.Vt({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.ct,r=function(){var r=i((function*(){e&&(yield e.catch((()=>{}))),yield t.Zt()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this.ct===s&&(this.ct=null)}));return this.ct=s,s}drainWindow(){if(0===this.Bt.size)return null;var t=this.Bt;return this.Bt=new Map,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Gt(t)}reset(){this.Wt++,this.Et(),this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set}Vt(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Pt(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.rt.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=W(i.type,i.name,i.unit,r)}catch(t){return void this.rt.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.Bt.get(s);if(!n){if(!this.Qt())return;n={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.Bt.set(s,n)}var a=this.Ut.get(i.name);void 0===a?this.Ut.set(i.name,i.type):a===i.type||this.zt.has(i.name)||(this.zt.add(i.name),this.rt.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.Jt(n,i.value),this.$t()}else this.rt.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.rt.warn("Dropping metric with empty name")}}Qt(){return this.Pe.maxSeriesPerFlush>this.Bt.size||(this.Ht||(this.Ht=!0,this.rt.warn("Metric series cap reached ("+this.Pe.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Jt(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(q.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,q)]+=1}}Pt(t){var i=this.Pe.beforeSend;if(!i)return t;var e=f(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.rt.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for metric:",t),null}return r}$t(){this.Nt||(this.Nt=O((()=>{this.Nt=void 0,this.flush().catch((t=>{this.rt.error("Metrics flush failed:",t)}))}),this.Pe.flushIntervalMs))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}Zt(){var t=this;return i((function*(){if(0!==t.Bt.size){var i=t.Bt;t.Bt=new Map,t.Ht=!1,t.Ut=new Map,t.zt=new Set;var e=t.Wt,r=yield t._instance.Kt(t.Gt(i));if(e===t.Wt)switch(r.kind){case"ok":return;case"retry-later":return t.Yt(i),void t.$t();case"too-large":return void t.rt.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.rt.error("Failed to send metrics batch:",r.error)}}}))()}Gt(t){return i=this.Xt(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.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:N(r)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,r,s,n}Xt(t){var i=V(Date.now()),r=new Map;for(var s of t.values()){var n,a=W(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=N(null!==(n=s.attributes)&&void 0!==n?n:{}),u=V(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:q})}return Array.from(r.values())}Yt(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.Bt.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.Qt()&&this.Bt.set(s,n)}}};var J,G,Z;function Q(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return Z&&e.length===G?Z:(G=e.length,Z=e.reduce(((e,r)=>{J||(J={});var s=J[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,J[r]=[l,u];break}}return e}),{}))}}class Y{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&&f(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:Q(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 X="?";function tt(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?X:e,in_app:!0};return m(r)||(n.lineno=r),m(s)||(n.colno=s),n}var it=(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]:X,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},et=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,rt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,st=/\((\S*)(?::(\d+))(?::(\d+))\)/,nt=(t,i)=>{var e=et.exec(t);if(e)return tt(i,e[1],X,+e[2],+e[3]);var r=rt.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=st.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=it(r[1]||X,r[2]);return tt(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},at=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ot=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,lt=(t,i)=>{var e=at.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=ot.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]||X,a=it(n,s);return tt(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ut=/\(error: (.*)\)/;class ht{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=b(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 F(t,"DOMException")}isDOMError(t){return F(t,"DOMError")}}class vt{match(t){return function(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 T(t,Error)}}(t)}coerce(t,i){return{type:this.getType(t),value:this.getMessage(t,i),stack:this.getStack(t),cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}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 dt{constructor(){}match(t){return!!F(t,"ErrorEvent")&&(null!=t.error||this.fe(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.pe(t))&&void 0!==r?r:s.stack,synthetic:!0})}fe(t){return b(t.message)&&t.message.length>0}pe(t){var i=t;if(b(i.filename)&&i.filename.length>0){var e,r,s=null!==(e=i.lineno)&&void 0!==e?e:0,n=null!==(r=i.colno)&&void 0!==r?r:0;return"Error\n at "+i.filename+":"+s+":"+n}}}var ct=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ft{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(ct);return r&&(i=r[1],e=r[2]),[i,e]}}var pt=["fatal","error","warning","log","info","debug"];function gt(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 _t{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){return P(t)?t.constructor.name:"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: "+gt(t)}isSeverityLevel(t){return b(t)&&!(t=>b(t)&&0===t.trim().length)(t)&&pt.indexOf(t)>=0}getStack(t){try{return b(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:b(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(e instanceof Error)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 P(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+gt(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class bt{match(t){return E(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 yt{match(t){return F(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!P(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 E(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 wt="$message",kt="$timestamp",St=new Set([wt,kt]),xt={enabled:!0,max_bytes:32768};function Et(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:xt.enabled,max_bytes:Pt(t.max_bytes,xt.max_bytes)}:e({},xt)}class Ft{constructor(t){this.Je=[],this.Ke=0,this.Pe=Et(t)}setConfig(t){this.Pe=Et(t),this.Xe()}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(!g(s))return;var n=s,a=n[wt],o=n[kt];if(!b(a)||0===a.trim().length)return;if(!b(o)&&!k(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.Pe.max_bytes||(this.Je.push({step:i.step,bytes:e}),this.Ke+=e,this.Xe())}}getAttachable(){return this.Je.map((t=>t.step))}clear(){this.Je=[],this.Ke=0}size(){return this.Je.length}Xe(){for(;this.Ke>this.Pe.max_bytes&&this.Je.length>0;){var t=this.Je.shift();t&&(this.Ke-=t.bytes)}}}function Pt(t,i){if(!k(t)||t===1/0||t===-1/0)return i;var e=Math.floor(t);return 0>e?i:e}var Tt={DEBUG:!1,LIB_VERSION:"0.3.1",LIB_NAME:"browser-common"},Ct="undefined"!=typeof window?window:void 0,At="undefined"!=typeof globalThis?globalThis:Ct,Rt=null==At?void 0:At.navigator,$t=null==At?void 0:At.document,Ot=null==At?void 0:At.location;function Mt(){return!(!Ct||!1===Ct.navigator.onLine)}null!=At&&At.XMLHttpRequest&&new At.XMLHttpRequest;var It=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={k(i){if(Ct&&(Tt.DEBUG||Ct.POSTHOG_DEBUG||e)&&!m(Ct.console)&&Ct.console){for(var r=("__rrweb_original__"in Ct.console[i]?Ct.console[i].__rrweb_original__:Ct.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.k("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.k("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.k("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.k("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)=>It(t+" "+i,e)};return r},jt=It("[PostHog.js]"),Lt=jt.createLogger;function Dt(t,i){if(!w(t))if(f(t))t.forEach(i);else if(x(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)d.call(t,e)&&i(t[e],e)}var Nt=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 zt(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 Ut=function(t){try{return t()}catch(t){return}};function Ht(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 Bt(t){return"ph_toolbar_internal"===t.name}function qt(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!p(r))return i;try{var s=r(i);return b(s)&&s?s:i}catch(t){return jt.error("Error in get_current_url, falling back to window.location.href",t),i}}var Vt="__POSTHOG_TOOLBAR__",Wt=1,Kt=3,Jt=11;function Gt(t){return t instanceof Element&&(t.id===Vt||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Zt(t){return!!t&&t.nodeType===Wt}function Qt(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Yt(t){return!!t&&t.nodeType===Kt}function Xt(t){return!!t&&t.nodeType===Jt&&Zt(t.host)}var ti=1e3;function ii(t){return t?h(t).split(/\s+/):[]}function ei(t,i){var e=function(t){var i,e=null==Ct||null==(i=Ct.location)?void 0:i.href;return m(e)?void 0:qt(t,e)}(i);return!!(e&&t&&t.some((t=>e.match(t))))}function ri(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return ii(i)}function si(t){return w(t)?null:h(t).split(/(\s+)/).filter((t=>Pi(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ni(t){var i="";return mi(t)&&!bi(t)&&t.childNodes&&t.childNodes.length&&Dt(t.childNodes,(function(t){var e;Yt(t)&&t.textContent&&(i+=null!==(e=si(t.textContent))&&void 0!==e?e:"")})),h(i)}function ai(t){var i;return m(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var oi=["a","button","form","input","select","textarea","label"];function li(t,i){if(m(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 ui(t){var i=t.parentNode;return!(!i||!Zt(i))&&i}var hi=[".ph-no-autocapture","[data-ph-no-autocapture]"],vi=["next","previous","prev",">","<"],di=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,ci=[".ph-no-rageclick",".ph-no-capture"],fi=["","text","search","email","password","url","tel","number"];function pi(t,i){if(!Ct||gi(t))return!1;var e,r,s,n,a;if(S(i)?(e=!!i&&ci,r=void 0,s=!1):(e=null!==(n=null==i?void 0:i.css_selector_ignorelist)&&void 0!==n?n:ci,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||!Zt(t))&&(!!Qt(t,"textarea")||(Qt(t,"input")?u(fi,(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=_i(t,!1).targetElementList;return!function(t,i){if(!1===t||m(t))return!1;var e;if(!0===t)e=vi;else{if(!f(t))return!1;if(t.length>10)return jt.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=>di(i,t)||di(r,t)))}))}(r,o.map((t=>{var i;return{safeText:ni(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!li(o,e)}var gi=t=>!t||Qt(t,"html")||!Zt(t),_i=(t,i)=>{if(!Ct||gi(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!Qt(s,"body");)if(Xt(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=ui(s);if(!n)break;if(i||oi.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=Ct.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&&!Qt(r,"body");r=r.parentNode){if(e++>=ti||i.has(r))return!1;i.add(r);var s=ri(r);if(u(s,"ph-sensitive")||u(s,"ph-no-capture"))return!1}if(u(ri(t),"ph-include"))return!0;var n=t.type||"";if(b(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!b(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 bi(t){return!!(Qt(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Qt(t,"select")||Qt(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var yi=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}))$"),wi=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,ki=[16,15,14,13],Si=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),xi=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ei=/[0-9A-Za-z_]/;function Fi(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 Pi(t,i){if(void 0===i&&(i=!0),w(t))return!1;if(b(t)){t=h(t);var e=i?yi.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(wi.lastIndex=0;i=wi.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of ki){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(yi.test(o)&&Fi(o))return!0}}}return!1}(t);if(e)return!1;var r=i?Si.test(t):function(t){var i;for(xi.lastIndex=0;i=xi.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&Ei.test(e)&&Ei.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function Ti(t){var i=ni(t);return Pi(i=(i+" "+Ci(t)).trim())?i:""}function Ci(t){var i="";return t&&t.childNodes&&t.childNodes.length&&Dt(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=ni(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+Ci(t)).trim())}catch(t){jt.error("[AutoCapture]",t)}})),i}function Ai(t){return t.replace(/"|\\"/g,'\\"')}function Ri(t){var i=t.attr__class;if(i)return f(i)?i:ii(i)}class $i{constructor(t){this.disabled=!1===t;var i=g(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 Oi="$autocapture_disabled_server_side",Mi="$heatmaps_enabled_server_side",Ii="$exception_capture_enabled_server_side",ji="$error_tracking_suppression_rules",Li="$error_tracking_capture_extension_exceptions",Di="$web_vitals_enabled_server_side",Ni="$product_tours_enabled_server_side",zi="$web_vitals_allowed_metrics",Ui="$session_recording_remote_config",Hi="$enabled_feature_flags",Bi="$active_feature_flags",qi="$early_access_features",Vi="$feature_flag_details",Wi="$feature_flag_payloads",Ki="$feature_flag_request_id",Ji="$minimal_flag_called_events",Gi="$override_feature_flags",Zi="$override_feature_flag_payloads",Qi="$stored_person_properties",Yi="$stored_group_properties",Xi="$surveys",te="$surveys_loaded_at",ie="$surveys_activated",ee="$surveys_activated_session",re="$surveys_activated_timestamps",se="ph_product_tours",ne="$flag_call_reported",ae="$flag_call_reported_session_id",oe="$feature_flag_errors",le="$feature_flag_evaluated_at",ue="PostHog loadExternalDependency extension not found.",he="visibilitychange",ve="beforeunload",de=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(!f(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){jt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ce=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("=");f(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},fe=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},pe=(t,i)=>t>=i&&Mt(),ge=(t,i,e,r)=>{if(0===t){if(Mt()){var s=i+1;return s===e&&r(),s}return i}return 0},_e="$copy_autocapture",me=Lt("[AutoCapture]");function be(t,i){return i.length>t?i.slice(0,t)+"...":i}function ye(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Zt(i));return i}function we(t,i){var r,s,n=i.e,a=i.maskAllElementAttributes,o=i.maskAllText,l=i.elementAttributeIgnoreList,h=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!Zt(t))return{props:{}};for(var d=[t],c=new Set([t]),f=t;f.parentNode&&!Qt(f,"body")&&ti>d.length;)if(Xt(f.parentNode)){var p=f.parentNode.host;if(c.has(p))break;c.add(p),d.push(p),f=p}else{if(!Zt(f.parentNode))break;if(c.has(f.parentNode))break;c.add(f.parentNode),d.push(f.parentNode),f=f.parentNode}var g,_,y=[],w={},k=!1,S=!1;if(Dt(d,(t=>{var i=mi(t);if(Qt(t,"a")){var e=t.getAttribute("href");k=!!(i&&e&&Pi(e))&&(v?R(e):e)}u(ri(t),"ph-no-capture")&&(S=!0),y.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};oi.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?be(1024,Ti(t)):be(1024,ni(t)));var o=ri(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),Dt(t.attributes,(function(e){var n;if((!bi(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Pi(e.value)&&(!b(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=ii(o).join(" ")),a["attr__"+e.name]=be(1024,"href"===e.name&&s?R(o):o)}}));for(var l=1,u=1,h=t;h=ye(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,a,o,l,v));var r=function(t){if(!mi(t))return{};var i={};return Dt(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&&Pi(r)&&(i[e]=r)}})),i}(t);Nt(w,r)})),S)return{props:{},explicitNoCapture:S};if(o||(y[0].$el_text=Qt(t,"a")||Qt(t,"button")?Ti(t):ni(t)),k){var x,E;y[0].attr__href=k;var F=null==(x=(t=>{var i=null==$t?void 0:$t.createElement("a");return m(i)?null:(i.href=t,i)})(k))?void 0:x.host,P=null==Ct||null==(E=Ct.location)?void 0:E.host;F&&P&&F!==P&&(g=k)}return{props:Nt({$event_type:n.type,$ce_version:1},h?{}:{$elements:y},{$elements_chain:(_=y,function(t){return t.map((t=>{var i,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return zt(a).sort(((t,i)=>t[0].localeCompare(i[0]))).forEach((t=>{var i=t[1];return o[Ai(t[0].toString())]=Ai(i.toString())})),(s+=":")+zt(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:Ri(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return zt(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(_)))},null!=(r=y[0])&&r.$el_text?{$el_text:null==(s=y[0])?void 0:s.$el_text}:{},g&&"click"===n.type?{$external_click_url:g}:{},w)}}var ke="undefined"!=typeof globalThis?globalThis:Ct;ke&&"undefined"==typeof self&&(ke.self=ke),ke&&"undefined"==typeof File&&(ke.File=function(){});var Se=null!=Ct?Ct:{},xe=Lt("[Dead Clicks]"),Ee=()=>!0;class Fe{get lazyLoadedDeadClicksAutocapture(){return this.si}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.ai((()=>{this.oi()})):this.stop()}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?xe.error("failed to load script",i):t()}))}oi(){var t;if($t){if(!this.si&&null!=(t=Se.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=g(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.si=Se.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.si.start($t),xe.info("starting...")}}else xe.error("`document` not found. Cannot start.")}stop(){this.si&&(this.si.stop(),this.si=void 0,xe.info("stopping..."))}}var Pe=Lt("[ExceptionAutocapture]"),Te=()=>{},Ce=Lt("[TracingHeaders]"),Ae=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Re=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ae],$e="<masked>",Oe=["li_fat_id"];function Me(t,i,e){if(!$t)return{};var r,s,n,a=(r=ce($t.URL,[],$e),s=Re.concat([]),n={},Dt(s,(function(t){var i=de(r,t);n[t]=i||null})),n),o=function(){var t={};return Dt(Oe,(function(i){var e=(t=>{if($t){try{for(var i=t+"=",e=$t.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 Nt(o,a)}function Ie(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var je=Lt("[Web Vitals]"),Le=9e5,De=Lt("[RemoteConfig]");class Ne{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Se._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Vi(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zi(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 De.info("Using preloaded remote config",this.remoteConfig),this.Gi(this.remoteConfig),void this.Qi();if(this._instance._shouldDisableFlags())return void De.warn("Remote config is disabled. Falling back to local config.");this.Vi((t=>{if(!t)return De.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zi((t=>{this.Gi(t.json,t),this.Qi()}));this.Gi(t),this.Qi()}))}catch(t){De.error("Error loading remote config",t),this.Gi()}}stop(){this.Ki&&(clearInterval(this.Ki),this.Ki=void 0)}refresh(){!this._instance._shouldDisableFlags()&&$t&&"hidden"!==$t.visibilityState&&this._instance.reloadFeatureFlags()}Qi(){var t;if(!this.Ki){var i=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==i&&(this.Ki=setInterval((()=>{this.refresh()}),i))}}Gi(t,i){!t&&i&&(0===i.statusCode?i.error||De.warn("Failed to fetch remote config from PostHog."):De.error("Failed to fetch remote config from PostHog."));try{this._instance.Gi(t?{ok:!0,config:t}:{ok:!1})}catch(t){De.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){De.error("Error loading feature flags",t)}}}var ze="disabled",Ue="lazy_loading",He="awaiting_config",Be="missing_config";Tt.DEBUG=!1,Tt.LIB_VERSION="1.412.0",Tt.LIB_NAME="web";var qe=function(t,i){if(!function(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}},Ve={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=>qe(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!qe(i,t))))),icontains:(t,i)=>i.map(We).some((i=>t.map(We).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(We).every((i=>t.map(We).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)))}))},We=t=>t.toLowerCase();function Ke(t,i){return!t||Object.entries(t).every((t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(m(r)||y(r))return!1;var s=[String(r)],n=Ve[e.operator];return!!n&&n(e.values,s)}))}Lt("[SessionRecording]"),Lt("[SessionRecording]");var Je="[SessionRecording]",Ge=Lt(Je),Ze=Lt("[Heatmaps]");function Qe(t){return g(t)&&"clientX"in t&&"clientY"in t&&k(t.clientX)&&k(t.clientY)}var Ye=Lt("[Product Tours]"),Xe=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(Ni))},tr=["$set_once","$set"],ir=Lt("[SiteApps]"),er="Error while initializing PostHog app with config id ",rr="base64",sr="events",nr="cancelEvents",ar="survey shown";function or(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var lr=Lt("[Surveys]"),ur="seenSurvey_",hr=["popover","widget","api"];class vr{on(t,i){return this.Ir[t]||(this.Ir[t]=[]),this.Ir[t].push(i),()=>{this.Ir[t]=this.Ir[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.Ir[t]||[])e(i);for(var r of this.Ir["*"]||[])r(t,i)}constructor(){this.Ir={}}}function dr(t,i,e){if(w(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 cr{constructor(t){this.Yn=new vr,this.Xn=(t,i)=>this.ts(t,i)&&this.es(t,i)&&this.rs(t,i)&&this.ns(t,i),this.ts=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t,this.ss=new Set,this.os=new Set}init(){var t,i;m(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(i=this._instance)||i._addCaptureHook(((t,i)=>{this.on(t,i)})))}register(t){var i,e;if(!m(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i,e;null==(i=this.os)||i.add(t),null==(e=t.steps)||e.forEach((t=>{var i;null==(i=this.ss)||i.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r,s=new Set;t.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,i){var e;null!=i&&0!=t.length&&(this.ss.has(t)||this.ss.has(i.event))&&this.os&&(null==(e=this.os)?void 0:e.size)>0&&this.os.forEach((t=>{this.ls(i,t)&&this.Yn.emit("actionCaptured",t.name)}))}us(t){this.onAction("actionCaptured",(i=>t(i)))}ls(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Xn(t,e))return!0;return!1}onAction(t,i){return this.Yn.on(t,i)}es(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(!dr(r,i.url,i.url_matching||"contains"))return!1}return!0}rs(t,i){return!!this.hs(t,i)&&!!this.ds(t,i)&&!!this.vs(t,i)}hs(t,i){var e;if(null==i||!i.href)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>dr(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&dr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}ds(t,i){var e;if(null==i||!i.text)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>dr(t.text,i.text,i.text_matching||"exact")||dr(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;!w(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=>dr(t,n,a))))}vs(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}cs(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}ns(t,i){return null==i||!i.properties||0===i.properties.length||Ke(i.properties.reduce(((t,i)=>{var e=f(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 fr{constructor(t){var i;this.fs=[],this._instance=t,this.ps=new Map,this.gs=new Map,this.ys=new Map,null==(i=this._instance)||null==i.onSessionId||i.onSessionId((t=>this.bs(t)))}_s(t){return!1}ws(){return null}xs(t){}ks(){}Ss(t,i){return!!t&&Ke(t.propertyFilters,null==i?void 0:i.properties)}Cs(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}Ms(t,i,e){var r=(e===sr?this.ps:this.gs).get(t),s=[];return this.Ts((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.Ss(n,i)}))}register(t){var i;m(null==(i=this._instance)?void 0:i._addCaptureHook)||(this.Es(t),this.Is(t))}Is(t){var i=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.actions)&&(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length)>0}));0!==i.length&&(null==this.Ps&&(this.Ps=new cr(this._instance),this.Ps.init(),this.Ps.us((t=>{this.onAction(t)}))),i.forEach((t=>{var i,e,r,s,n;t.conditions&&null!=(i=t.conditions)&&i.actions&&null!=(e=t.conditions)&&null!=(e=e.actions)&&e.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Ps)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((i=>{if(i&&i.name){var e=this.ys.get(i.name);e&&e.push(t.id),this.ys.set(i.name,e||[t.id])}})))})))}Es(t){var i,e=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})),r=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}));0===e.length&&0===r.length||(null==(i=this._instance)||i._addCaptureHook(((t,i)=>{this.onEvent(t,i)})),this.ps=this.Cs(t,sr),this.gs=this.Cs(t,nr))}onEvent(t,i){var e,r,s=this.Rs(),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.Ls(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Os([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Fs(n),void this.As([n])}if(this.gs.has(t)){var o=this.Ms(t,i,nr);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Os(o.map((t=>t.id))),o.forEach((t=>this.Ds(t.id))))}if(this.ps.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.ps.get(t)});var l=this.Ms(t,i,sr);this.$s(l.map((t=>t.id)))}}onAction(t){this.ys.has(t)&&this.$s(this.ys.get(t)||[])}$s(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._s(s)?this.Fs(s)&&this.Ns(s):r.push(s);r.length>0&&(this.fs=[...new Set([...this.fs,...r])]),this.Rs().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Fs(t){this.fs=this.fs.filter((i=>i!==t));var i=this.qs();return!i.includes(t)&&(this.js([...i,t]),this.Bs(),!0)}Os(t){var i=new Set(t);this.fs=this.fs.filter((t=>!i.has(t)));var e=this.Hs(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.js(r),0===r.length&&this.Us()),this.As(t)}zs(){var t,i=this.ws();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}Ns(t){if(this.ws()){var i=this.zs();this.xs(e({},i,{[t]:Date.now()}))}}As(t){if(this.ws()){var i=this.zs(),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)?this.ks():this.xs(e))}}Ws(){this.ws()&&this.ks()}getActivationTimestamp(t){if(this.qs().includes(t)){var i=this.zs()[t];return k(i)?i:void 0}}Hs(){var t,i=this.Vs();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}qs(){var t,i,e=this.Hs();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Zs()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Bs(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Gs(i)}Us(){this.Qs()}bs(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Zs()];if(e&&e!==t){var r=this.Hs(),s=this.zs();r.length>0&&(this.js([]),r.filter((t=>k(s[t]))).forEach((t=>this.Ds(t)))),this.Us(),this.Ws()}}getActivatedIds(){return[...new Set([...this.qs(),...this.fs])].filter((t=>!this.Js(t)))}reset(){this.fs=[],this.Hs().length>0&&this.js([]),this.Us(),this.Ws()}getEventToItemsMap(){return this.ps}Ks(){return this.Ps}}class pr extends fr{constructor(t){super(t)}Vs(){return ie}Zs(){return ee}ws(){return re}xs(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[re]:t})}ks(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(re)}_s(t){var i,e;this.Ts((i=>{e=i.find((i=>i.id===t))}));var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return k(r)&&r>0}Ys(){return ar}Ts(t){var i;null==(i=this._instance)||i.getSurveys(t)}Ds(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Rs(){return lr}js(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[ie]:t})}Gs(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[ee]:t})}Qs(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(ee)}Js(){return!1}Ls(t,i){var e;this.Ts((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return or(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===ar?"consume":"ignore":t===ar?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var gr="SDK is not enabled or survey functionality is not yet loaded",_r="Disabled. Not loading surveys.",mr=null!=Ct&&Ct.location?fe(Ct.location.hash,"__posthog")||fe(location.hash,"state"):null,br="_postHogToolbarParams",yr=Lt("[Toolbar]"),wr=Lt("[FeatureFlags]"),kr=Lt("[FeatureFlags]",{debugEnabled:!0}),Sr="\" failed. Feature flags didn't load in time.",xr=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},Er=t=>{var i={};for(var e of zt(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},Fr=Lt("[Error tracking]"),Pr="Refusing to render web experiment since the viewer is a likely bot",Tr={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>qe(i,t),not_regex:(t,i)=>!qe(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class Cr{get Pe(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{Cr.Xs("retrieved web experiments from the server"),i.ta=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.ta&&(Cr.Xs("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.ta)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);b(r)&&t.variants[r]&&i.ea(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Cr.ia(n,i._instance)&&i.ea(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Cr.Xs(Pr);else if(!this.Pe.disable_web_experiments){if(w(this.ta))return this.ta=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Cr.Xs("applying feature flags",t),t.forEach((t=>{var i;if(this.ta&&null!=(i=this.ta)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ta)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.ea(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Cr.getWindowLocation();if(null!=t&&t.search){var i=de(null==t?void 0:t.search,"__experiment_id"),e=de(null==t?void 0:t.search,"__experiment_variant");i&&e&&(Cr.Xs("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.ra(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.Pe.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Pe.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.Pe.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}ra(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(Cr.Xs("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.ea(r[0].name,i,r[0].variants[i].transforms))}static ia(t,i){return!w(t.conditions)&&Cr.na(t,i)&&Cr.sa(t)}static na(t,i){var e;if(w(t.conditions)||w(null==(e=t.conditions)?void 0:e.url))return!0;var r=Cr.getWindowLocation();if(r){var s,n,a,o=qt(i,r.href);return null==(s=t.conditions)||!s.url||Tr[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==Ct?void 0:Ct.location}static sa(t){var i;if(w(t.conditions)||w(null==(i=t.conditions)?void 0:i.utm))return!0;var e=Me();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 Xs(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];jt.info("[WebExperiments] "+t,e)}ea(t,i,e){this._is_bot()?Cr.Xs(Pr):"control"!==i?e.forEach((e=>{if(e.selector){var r;Cr.Xs("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)}))}})):Cr.Xs("Control variants leave the page unmodified.")}_is_bot(){return Rt&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&l(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>l(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver}(Rt,this.Pe.custom_blocked_useragents):void 0}}var Ar=Lt("[Conversations]"),Rr="Conversations not available yet.",$r="console",Or="__posthogHandledLogsRequestError",Mr=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Or]=!0,e},Ir=t=>!!t&&"object"==typeof t&&!0===t[Or],jr={featureFlags:class{constructor(t){this.aa=!1,this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.va=!1,this.ca=!1,this.fa=0,this.pa=()=>{var t=this.ga();this.fa=0,t&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],Ct&&Ht(Ct,"online",this.pa)}destroy(){null==Ct||Ct.removeEventListener("online",this.pa)}get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}ma(t){return this._instance.get_property(t)}ya(){var t,i;return null!==(t=null==(i=this.Tr)?void 0:i._isFeatureFlagCacheStale(this.Pe.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ba(){return!!this.ya()&&(this.ca||this.la||(this.ca=!0,wr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_a(){var t,i=null!==(t=this.Pe.evaluation_contexts)&&void 0!==t?t:this.Pe.evaluation_environments;return!this.Pe.evaluation_environments||this.Pe.evaluation_contexts||this.va||(wr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.va=!0),null!=i&&i.length?i.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||wr.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}wa(){return this._a().length>0}xa(){var t=this.Pe.flag_keys;if(!m(t)){if(f(t))return t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||wr.error("Invalid flag key found:",t,"Expected non-empty string"),i}));wr.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,i,e=this._instance.config,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)=>(a[i]&&(t[i]=a[i]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,i,r){var a,o,l=null!=r&&r.merge&&null!==(a=this.ma(Hi))&&void 0!==a?a:{},u=null!=r&&r.merge&&null!==(o=this.ma(Wi))&&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:m(null==v?void 0:v[f])?void 0:{id:0,version:void 0,description:void 0,payload:v[f]}}}this.receivedFeatureFlags({flags:d})}get hasLoadedFlags(){return this.oa}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.ma(Vi),i=this.ma(Gi),r=this.ma(Zi);if(!r&&!i)return t||{};var s=Nt({},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=m(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=m(h)?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.aa||(wr.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.aa=!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.ma(Hi),i=this.ma(Gi);if(!i)return t||{};for(var e=Nt({},t),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.aa||(wr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.aa=!0),e}getFlagPayloads(){var t=this.ma(Wi),i=this.ma(Zi);if(!i)return t||{};for(var e=Nt({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.aa||(wr.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.aa=!0),e}reloadFeatureFlags(){this.ua||this.Pe.advanced_disable_feature_flags||this.ga()||this.ka||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),this.ka=setTimeout((()=>{this.Sa()}),5))}Ca(){clearTimeout(this.ka),this.ka=void 0}ensureFlagsLoaded(){this.oa||this.la||this.ka||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ua=t}Sa(t){var i;if(this.Ca(),!this._instance._shouldDisableFlags()&&!this.ga())if(this.la)this.ha=!0;else{var r=this.Pe.token,s=this.ma("$device_id"),n={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:e({},(null==(i=this.Tr)?void 0:i.get_initial_props())||{},this.ma(Qi)||{},{$lib:Tt.LIB_NAME,$lib_version:Tt.LIB_VERSION}),group_properties:this.ma(Yi),timezone:Ie()};y(s)||m(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Pe.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.wa()&&(n.evaluation_contexts=this._a());var a=this.xa();m(a)||(n.flag_keys=a);var o=!!this.Pe.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Pe.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.la=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.Pe.disable_compression?void 0:rr,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback:t=>{var i,e,r,s=!0;if(this.Ma(t.statusCode),200===t.statusCode&&(this.ha||(this.$anon_distinct_id=void 0),s=!1),this.la=!1,!n.disable_flags||this.ha){this.da=!s;var a=[];t.error?t.error instanceof Error?a.push("AbortError"===t.error.name?"timeout":"connection_error"):a.push("unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),null!=(i=t.json)&&i.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(e=t.json)||null==(e=e.quotaLimited)||!e.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.Tr)||r.register({[oe]:a}),u)wr.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.");else n.disable_flags||this.receivedFeatureFlags(null!==(l=t.json)&&void 0!==l?l:{},s,{partialResponse:o}),this.ha&&(this.ha=!1,this.Sa())}}})}}ga(){return pe(this.fa,3)}Ma(t){this.fa=ge(t,this.fa,3,(()=>wr.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.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){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 wr.warn('getFeatureFlag for key "'+t+Sr)}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.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){var e=this.getFlagVariants(),s=t in e,n=e[t],a=this.getFlagPayloads()[t],o=String(n),l=this.ma(Ki)||void 0,u=this.ma(le)||void 0,h=this.ma(ne)||{};if(this.Pe.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.ma(ae);d&&d!==c&&(h={},null==(v=this.Tr)||v.register({[ne]:h,[ae]:d}))}if((i.send_event||!("send_event"in i))&&(!(t in h)||!h[t].includes(o))){var p,g,_,b,y,w,k,S,x,E,F;f(h[t])?h[t].push(o):h[t]=[o],null==(p=this.Tr)||p.register({[ne]:h});var P=this.getFeatureFlagDetails(t),T=[...null!==(g=this.ma(oe))&&void 0!==g?g:[]];m(n)&&T.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:a||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(null==(_=this.Pe.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(b=this.Pe.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])||null,$used_bootstrap_value:!this.da};m(null==P||null==(y=P.metadata)?void 0:y.has_experiment)||(C.$feature_flag_has_experiment=P.metadata.has_experiment),m(null==P||null==(w=P.metadata)?void 0:w.version)||(C.$feature_flag_version=P.metadata.version);var A,R=null!==(k=null==P||null==(S=P.reason)?void 0:S.description)&&void 0!==k?k:null==P||null==(x=P.reason)?void 0:x.code;R&&(C.$feature_flag_reason=R),null!=P&&null!=(E=P.metadata)&&E.id&&(C.$feature_flag_id=P.metadata.id),m(null==P?void 0:P.original_variant)&&m(null==P?void 0:P.original_enabled)||(C.$feature_flag_original_response=m(P.original_variant)?P.original_enabled:P.original_variant),null!=P&&null!=(F=P.metadata)&&F.original_payload&&(C.$feature_flag_original_payload=null==P||null==(A=P.metadata)?void 0:A.original_payload),T.length&&(C.$feature_flag_error=T.join(",")),this._instance.capture("$feature_flag_called",C)}if(s)return{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:r(a)}}}else wr.warn('getFeatureFlagResult for key "'+t+Sr)}getRemoteConfigPayload(t,i){var e=this.Pe.token,r={distinct_id:this._instance.get_distinct_id(),token:e,person_properties:{$lib:Tt.LIB_NAME,$lib_version:Tt.LIB_VERSION}};this.wa()&&(r.evaluation_contexts=this._a());var s=this.xa();m(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Pe.disable_compression?void 0:rr,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback(e){var r,s=null==(r=e.json)?void 0:r.featureFlagPayloads;i((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.da)return i.defaultValue;if(!(this.oa||this.getFlags()&&this.getFlags().length>0))return wr.warn('isFeatureEnabled for key "'+t+Sr),i.defaultValue;var e=this.getFeatureFlag(t,i);return m(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((i=>i!==t))}receivedFeatureFlags(t,i,r){if(this.Tr){this.oa=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,i,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var o=(t=>{var i=t.flags;return i?(t.featureFlags=Object.fromEntries(Object.keys(i).map((t=>{var e;return[t,null!==(e=i[t].variant)&&void 0!==e?e:i[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(i).filter((t=>i[t].enabled)).filter((t=>{var e;return null==(e=i[t].metadata)?void 0:e.payload})).map((t=>{var e;return[t,null==(e=i[t].metadata)?void 0:e.payload]})))):t.featureFlags&&wr.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),l=o.flags,u=o.featureFlags,h=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(f(u)){wr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var p=0;u.length>p;p++)c[u[p]]=!0;i&&i.register({[Bi]:u,[Hi]:c,[Ji]:!1})}else{var g=u,_=h,m=l;if(null!=a&&a.partialResponse)g=e({},r,g),_=e({},s,_),m=e({},n,m);else if(t.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter((t=>{var i;return!(null!=(i=l[t])&&i.failed)})));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]))))),m=e({},n,Object.fromEntries(Object.entries(m||{}).filter((t=>b.has(t[0])))))}else g=e({},r,g),_=e({},s,_),m=e({},n,m);i&&i.register(e({[Bi]:Object.keys(Er(g)),[Hi]:g||{},[Wi]:_||{},[Vi]:m||{},[Ji]:!0===t.minimalFlagCalledEvents},v?{[Ki]:v}:{},d?{[le]:d}:{}))}}}(t,this.Tr,s,n,a,r),i||(this.ca=!1),this.Ta(i)}}override(t,i){void 0===i&&(i=!1),wr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Tr)return wr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Tr.unregister(Gi),this.Tr.unregister(Zi),this.Ta(),kr.info("All overrides cleared");if(f(t)){var i=xr(t);return this.Tr.register({[Gi]:i}),this.Ta(),kr.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,r=t;if(this.aa=Boolean(null!==(e=r.suppressWarning)&&void 0!==e&&e),"flags"in r)if(!1===r.flags)this.Tr.unregister(Gi),kr.info("Flag overrides cleared");else if(r.flags){if(f(r.flags)){var s=xr(r.flags);this.Tr.register({[Gi]:s})}else this.Tr.register({[Gi]:r.flags});kr.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Tr.unregister(Zi),kr.info("Payload overrides cleared")):r.payloads&&(this.Tr.register({[Zi]:r.payloads}),kr.info("Payload overrides set",{payloads:r.payloads}))),void this.Ta()}if(t&&"object"==typeof t)return this.Tr.register({[Gi]:t}),this.Ta(),kr.info("Flag overrides set",{flags:t});wr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.oa){var i=this.Ea(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){wr.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var s,n=(this.ma(qi)||[]).find((i=>i.flagKey===t)),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=e({},this.getFlagVariants(),{[t]:i});null==(s=this.Tr)||s.register({[Bi]:Object.keys(Er(l)),[Hi]:l}),this.Ta()}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.ma(qi),s=e?"&"+e.map((t=>"stage="+t)).join("&"):"";if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Pe.token+s),method:"GET",timestampMode:"query",callback:i=>{var e,r;if(i.json){var s=i.json.earlyAccessFeatures;return null==(e=this.Tr)||e.unregister(qi),null==(r=this.Tr)||r.register({[qi]:s}),t(s)}}})}Ea(){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)),{})}}Ta(t){var i=this.Ea(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(e,r,{errorsLoading:t})}catch(t){wr.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.ma(Qi)||{},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._instance.register({[Qi]:e({},r,a,s)}),i&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.ma(Qi)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[Qi]:r}),i&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Qi),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.ma(Yi)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((i=>{r[i]=e({},r[i],t[i]),delete t[i]})),this._instance.register({[Yi]:e({},r,t)}),i&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.ma(Yi)||{};this._instance.register({[Yi]:e({},i,{[t]:{}})})}else this._instance.unregister(Yi)}reset(){this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.$anon_distinct_id=void 0,this.Ca(),this.aa=!1,this.fa=0}}},Lr={sessionRecording:class{get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Ia)||!t.isStarted)}get status(){var t,i;return this.Pa===He||this.Pa===Be?this.Pa:null!==(t=null==(i=this.Ia)?void 0:i.status)&&void 0!==t?t:this.Pa}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Pa=ze,this.Ra=void 0,this._instance=t,!this._instance.sessionManager)throw Ge.error("started without valid sessionManager"),new Error(Je+" started without valid sessionManager. This is a bug.");if("always"===this.Pe.cookieless_mode)throw new Error(Je+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get La(){var t,i=!(null==(t=this._instance.get_property(Ui))||!t.enabled),e=!this.Pe.disable_session_recording,r=this.Pe.disable_session_recording||this._instance.consent.isOptedOut();return Ct&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!this.La||null==(i=this.Ia)||!i.isStarted){var e=!m(Object.assign)&&!m(Array.from);this.La&&e?(this.Oa(t),Ge.info("starting")):(this.Pa=ze,this.stopRecording())}}Oa(t){var i,e,r;this.La&&(this.Pa!==He&&this.Pa!==Be&&(this.Pa=Ue),null!=Se&&null!=(i=Se.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=Se.__PosthogExtensions__)&&e.initSessionRecording?this.Fa(t):null==(r=Se.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Aa,(i=>{if(i)return Ge.error("could not load recorder",i);this.Fa(t)})))}stopRecording(){var t,i;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(i=this.Ia)||i.stop()}Da(){var t,i;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(i=this.Ia)||i.discard()}$a(){var t,i;null==(t=this.Tr)||t.unregister("$session_is_sampled"),null==(i=this.Tr)||i.unregister("$replay_sample_rate")}Na(t,i){if(w(t))return null;var e,r=k(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Ge.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}qa(t){if(this.Tr){var i,r,s=this.Tr,n=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Na(null==(i=this.Pe.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Na(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;w(o)&&this.$a();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[Ui]: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:m(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.Ra)||i.call(this),this.Ra=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.qa(i),void this.Da()):(this.qa(i),void this.startIfEnabledOrStop()):(this.Pa===He&&(this.Pa=Be,Ge.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.Ia)&&e.log?this.Ia.log(t,i):Ge.warn("log called before recorder was ready")}get Aa(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Ui);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}ja(){var t,i,e=this._instance.get_property(Ui);if(!e)return!1;try{i="object"==typeof e?e:JSON.parse(e)}catch(t){return Ge.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=i.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Fa(t){var i,e;if(null==(i=Se.__PosthogExtensions__)||!i.initSessionRecording)return Ge.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.Ia||(this.Ia=null==(e=Se.__PosthogExtensions__)?void 0:e.initSessionRecording(this._instance),this.Ia._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ja()){if(this.Pa===Be||this.Pa===He)return;return this.Pa=He,Ge.info("persisted remote config is stale, requesting fresh config before starting"),void new Ne(this._instance).load()}this.Pa=Ue,this.Ia.start(t)}onRRwebEmit(t){var i;null==(i=this.Ia)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Ia||null==(i=this.Tr)||i.register({$replay_override_linked_flag:!0}),null==(t=this.Ia)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.Ia||null==(i=this.Tr)||i.register({$replay_override_sampling:!0}),null==(t=this.Ia)||t.overrideSampling()}overrideTrigger(t){var i,e;this.Ia||null==(e=this.Tr)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Ia)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Ia)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Ia)||!e.tryAddCustomEvent(t,i))}}},Dr={autocapture:class{constructor(t){this.Ba=!1,this.Ha=null,this.Ua=!1,this.za=!1,this.instance=t,this.rageclicks=new $i(t.config.rageclick),this.Wa=null}initialize(){this.startIfEnabled()}get Pe(){var t,i,e=g(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=null==(t=e.url_allowlist)?void 0:t.map((t=>new RegExp(t))),e.url_ignorelist=null==(i=e.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),e}Va(){if(this.isBrowserSupported()){if(Ct&&$t){var t=t=>{t=t||(null==Ct?void 0:Ct.event);try{this.Za(t)}catch(t){me.error("Failed to capture event",t)}};if(Ht($t,"submit",t,{capture:!0}),Ht($t,"change",t,{capture:!0}),Ht($t,"click",t,{capture:!0}),this.Pe.capture_copied_text){var i=t=>{t=t||(null==Ct?void 0:Ct.event);try{this.Za(t,_e)}catch(t){me.error("Failed to capture copy/cut event",t)}};Ht($t,"copy",i,{capture:!0}),Ht($t,"cut",i,{capture:!0})}}}else me.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ba&&(this.Va(),this.Ba=!0)}onRemoteConfig(t){if(this.Ua=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.za=i.elementsChainAsString);var e=i.autocapture_opt_out;S(e)&&(this.instance.persistence&&this.instance.persistence.register({[Oi]:e}),this.Ha=e),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.Wa=t}getElementSelectors(t){var i,e=[];return null==(i=this.Wa)||i.forEach((i=>{var r=null==$t?void 0:$t.querySelectorAll(i);null==r||r.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i,e=null==(t=this.instance.persistence)?void 0:t.props[Oi],r=this.Ha,s=this.instance._shouldDisableFlags()&&!this.Ua;if(y(r)&&!S(e)&&!s)return!1;var n=null!==(i=this.Ha)&&void 0!==i?i:!!e;return!!this.instance.config.autocapture&&!n}Za(t,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var e,r=ai(t);Yt(r)&&(r=r.parentNode||null),"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(e=this.rageclicks)&&e.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&pi(r,this.instance.config.rageclick)&&this.Za(t,"$rageclick");var s=i===_e;if(r&&function(t,i,e,r,s,n){var a;if(!Ct||gi(t))return!1;if(null!=e&&e.url_allowlist&&!ei(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&ei(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=_i(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(m(e))return!0;var r,s=function(t){if(e.some((i=>t.tagName.toLowerCase()===i)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(h,e))return!1;if(!li(h,null==e?void 0:e.css_selector_allowlist))return!1;if(li(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:hi))return!1;try{var v=Ct.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&&(oi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Pe,s,s?["copy","cut"]:void 0,this.instance)){var n=we(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Pe.element_attribute_ignorelist,elementsChainAsString:this.za,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=n.props;if(n.explicitNoCapture)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(a.$element_selectors=o),i===_e){var l,u=si(null==Ct||null==(l=Ct.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=h}return this.instance.capture(i,a),!0}}}isBrowserSupported(){return p(null==$t?void 0:$t.querySelectorAll)}},historyAutocapture:class{constructor(t){var i;this._instance=t,this.Ga=(null==Ct||null==(i=Ct.location)?void 0:i.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(jt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Qa&&this.Qa(),this.Qa=void 0,jt.info("History API monitoring stopped")}monitorHistoryChanges(){Ct&&Ct.history&&(this.Ja("pushState"),this.Ja("replaceState"),this.Ka())}Ja(t){var i;if(Ct&&(null==(i=Ct.history[t])||!i.__posthog_wrapped__)){var e=this;!function(t,i,e){try{if(!(i in t))return Te;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 p(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];p(e)&&e.__posthog_layer__;){var n=e.__posthog_layer__;if(n.next===s)return void(n.next=r.next);e=n.next}else t[i]=r.next}}catch(t){return Te}}(Ct.history,t,(i=>function(r,s,n){i.call(this,r,s,n),e.Ya(t)}))}}Ya(t){try{var i,e=null==Ct||null==(i=Ct.location)?void 0:i.pathname;if(!e)return;e!==this.Ga&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.Ga=e}catch(i){jt.error("Error capturing "+t+" pageview",i)}}Ka(){if(!this.Qa){var t=()=>{this.Ya("popstate")};Ht(Ct,"popstate",t),this.Qa=()=>{Ct&&Ct.removeEventListener("popstate",t)}}}},heatmaps:class{get Pe(){return this.instance.config}constructor(t){var i;this.Xa=!1,this.Ba=!1,this.eo=null,this.instance=t,this.Xa=!(null==(i=this.instance.persistence)||!i.props[Mi]),this.rageclicks=new $i(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return g(this.Pe.capture_heatmaps)&&this.Pe.capture_heatmaps.flush_interval_milliseconds&&(t=this.Pe.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return w(this.Pe.capture_heatmaps)?w(this.Pe.enable_heatmaps)?this.Xa:this.Pe.enable_heatmaps:!1!==this.Pe.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ba)return;Ze.info("starting..."),this.io(),this.Ie()}else{var t;clearInterval(null!==(t=this.eo)&&void 0!==t?t:void 0),this.ro(),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({[Mi]:e}),this.Xa=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.O;return this.O=void 0,t}no(t){Qe(t.originalEvent)&&this.ke(t.originalEvent,"deadclick")}Ie(){this.eo&&clearInterval(this.eo),this.eo="visible"===(null==$t?void 0:$t.visibilityState)?setInterval(this.pr.bind(this),this.flushIntervalMilliseconds):null}io(){Ct&&$t&&(this.so=this.pr.bind(this),Ht(Ct,ve,this.so),this.ao=t=>this.ke(t||(null==Ct?void 0:Ct.event)),Ht($t,"click",this.ao,{capture:!0}),this.oo=t=>this.lo(t||(null==Ct?void 0:Ct.event)),Ht($t,"mousemove",this.oo,{capture:!0}),this.uo=new Fe(this.instance,Ee,this.no.bind(this)),this.uo.startIfEnabledOrStop(),this.ho=this.Ie.bind(this),Ht($t,he,this.ho),this.Ba=!0)}ro(){var t;Ct&&$t&&(this.so&&Ct.removeEventListener(ve,this.so),this.ao&&$t.removeEventListener("click",this.ao,{capture:!0}),this.oo&&$t.removeEventListener("mousemove",this.oo,{capture:!0}),this.ho&&$t.removeEventListener(he,this.ho),clearTimeout(this.do),null==(t=this.uo)||t.stop(),this.Ba=!1)}vo(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&&Zt(r)&&!Qt(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:Ct)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(u(i,s))return!0;r=ui(r)}return!1}(ai(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:e),target_fixed:n,type:i}}ke(t,i){var r;if(void 0===i&&(i="click"),!Gt(t.target)&&Qe(t)){var s=this.vo(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&pi(ai(t),this.instance.config.rageclick)&&this.Vt(e({},s,{type:"rageclick"})),this.Vt(s)}}lo(t){!Gt(t.target)&&Qe(t)&&(clearTimeout(this.do),this.do=setTimeout((()=>{this.Vt(this.vo(t,"mousemove"))}),500))}Vt(t){if(Ct){var i=this.Pe.disable_capture_url_hashes?R(Ct.location.href):Ct.location.href,e=this.Pe.custom_personal_data_properties,r=this.Pe.mask_personal_data_properties?[...Ae,...e||[]]:[],s=ce(i,r,$e);this.O=this.O||{},this.O[s]||(this.O[s]=[]),this.O[s].push(t)}}pr(){this.O&&!_(this.O)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Fe,webVitalsAutocapture:class{constructor(t){var i;this.Xa=!1,this.Ba=!1,this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.co=()=>{clearTimeout(this.fo),this.fo=void 0,0!==this.O.metrics.length&&(this._instance.capture("$web_vitals",e({$current_url:this.O.url},this.O.metrics.reduce(((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.po=t=>{var i;if(this.O=this.O||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},w(null==t?void 0:t.name)||w(null==t?void 0:t.value))je.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.mo(r);if(!m(s)){var n=k(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.yo||this.yo>t.value){this.O.navigationKey!==n&&(this.co(),this.fo=setTimeout(this.co,this.flushToCaptureTimeoutMs)),m(this.O.navigationKey)&&(this.O.navigationKey=n,this.O.url=s),this.O.firstMetricTimestamp=m(this.O.firstMetricTimestamp)?Date.now():this.O.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});m(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.O.metrics.push(o),this.O.metrics.length===this.allowedMetrics.length&&this.co()}else je.error("Ignoring metric with value >= "+this.yo,t)}}},this.bo=()=>{if(!this.Ba){var t,i,e,r,s=Se.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,a=(null==n?void 0:n[this._o])||("web-vitals"===this._o&&m(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(m(a)||(t=a.onLCP,i=a.onCLS,e=a.onFCP,r=a.onINP),t&&i&&e&&r){var o={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.po.bind(this),o),this.allowedMetrics.indexOf("CLS")>-1&&i(this.po.bind(this),o),this.allowedMetrics.indexOf("FCP")>-1&&e(this.po.bind(this),o),this.allowedMetrics.indexOf("INP")>-1&&r(this.po.bind(this),o),this.Ba=!0}else je.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Xa=!(null==(i=this._instance.persistence)||!i.props[Di]),this.startIfEnabled()}get wo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=g(this.wo)?null==(t=this.wo)?void 0:t.web_vitals_allowed_metrics:void 0;return w(e)?(null==(i=this._instance.persistence)?void 0:i.props[zi])||["CLS","FCP","INP","LCP"]:e}get flushToCaptureTimeoutMs(){return(g(this.wo)?this.wo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=g(this.wo)?this.wo.web_vitals_attribution:void 0;return null!=t&&t}get useSoftNavs(){var t=g(this.wo)?this.wo.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get yo(){var t=g(this.wo)&&k(this.wo.__web_vitals_max_value)?this.wo.__web_vitals_max_value:Le;return t>0&&6e4>=t?Le:t}get isEnabled(){var t=null==Ot?void 0:Ot.protocol;if("http:"!==t&&"https:"!==t)return je.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=g(this.wo)?this.wo.web_vitals:S(this.wo)?this.wo:void 0;return S(i)?i:this.Xa}startIfEnabled(){this.isEnabled&&!this.Ba&&(je.info("enabled, starting..."),this.ai(this.bo))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=g(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=g(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Di]:e}),this._instance.persistence.register({[zi]:r})),this.Xa=e,this.startIfEnabled()}}}get _o(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}ai(t){var i=Se.__PosthogExtensions__,e=this._o,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&m(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?je.error("failed to load script",i):t()}))}mo(t){var i=t||(null==Ct?void 0:Ct.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?R(i):i,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...Ae,...r||[]]:[];return ce(e,s,$e)}je.error("Could not determine current URL")}}},Nr={exceptionObserver:class{constructor(t){var i;this.bo=()=>{var t;if(Ct&&this.isEnabled&&null!=(t=Se.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=Se.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=Se.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Se.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.xo&&this.Pe.capture_unhandled_errors&&(this.xo=i(this.captureException.bind(this))),!this.ko&&this.Pe.capture_unhandled_rejections&&(this.ko=e(this.captureException.bind(this))),!this.So&&this.Pe.capture_console_errors&&(this.So=r(this.captureException.bind(this)))}catch(t){Pe.error("failed to start",t),this.Co()}}},this._instance=t,this.Mo=!(null==(i=this._instance.persistence)||!i.props[Ii]),this.To=new A(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,rt:Pe})),this.Pe=this.Eo(),this.startIfEnabledOrStop()}Eo(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return g(t)?i=e({},i,t):(m(t)?this.Mo:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Pe.capture_console_errors||this.Pe.capture_unhandled_errors||this.Pe.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Pe.info("enabled"),this.Co(),this.ai(this.bo)):this.Co()}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Pe.error("failed to load script",i);t()}))}Co(){var t,i,e;null==(t=this.xo)||t.call(this),this.xo=void 0,null==(i=this.ko)||i.call(this),this.ko=void 0,null==(e=this.So)||e.call(this),this.So=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Mo=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ii]:this.Mo}),this.Pe=this.Eo(),this.startIfEnabledOrStop())}}onConfigChange(){this.Pe=this.Eo()}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.To.consumeRateLimit(s)?Pe.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.Io=[],this.Po=new Y([new ht,new yt,new dt,new vt,new mt,new _t,new ft,new bt],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=ut.test(l)?l.replace(ut,"$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||X});var r}))}(n)}}("web:javascript",nt,lt)),this._instance=t,this.Io=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property(ji))&&void 0!==i?i:[],this.Ro=Et(this.Lo()),this.Oo=new Ft(this.Ro)}onConfigChange(){this.Ro=Et(this.Lo()),this.Oo.setConfig(this.Ro)}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.Io=n,this._instance.persistence&&this._instance.persistence.register({[ji]:this.Io,[Li]:a})}}}get Fo(){var t,i=!!this._instance.get_property(Li),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.Po.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.Ro.enabled)try{if(!b(t)||0===t.trim().length)return void Fr.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)=>St.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.Ao(i)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&Fr.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Oo.add(e({[wt]:t,[kt]:(new Date).toISOString()},s))}catch(t){Fr.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.Do(i)){if(this.$o(i))return this.No("Exception dropped: matched a suppression rule"),void Fr.info("Skipping exception capture because a suppression rule matched");if(!this.Fo&&this.qo(i))return this.No("Exception dropped: thrown by a browser extension"),void Fr.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.jo(i))return this.No("Exception dropped: thrown by the PostHog SDK"),void Fr.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.Ro.enabled&&w(t.$exception_steps)?this.Bo(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.Oo.clear(),s}catch(t){return Fr.error("Failed to capture exception event. Dropping this exception.",t),void this.Oo.clear()}}catch(t){return void Fr.error("Failed to process exception event. Ignoring this exception.",t)}var n}Bo(t){try{var i=this.Oo.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(i){return Fr.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}No(t){this.Ro.enabled&&this.Oo.add({[wt]:t,[kt]:(new Date).toISOString()})}Ao(t){return g(t)?e({},t):{}}Lo(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}$o(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return b(e)&&e.length>0&&t.$exception_types.push(e),b(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Io.some((t=>{var e=t.values.map((t=>{var e=Ve[t.operator],r=i[t.key];if(!e||!r)return!1;var s=f(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 Fr.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qo(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=>t.filename&&t.filename.startsWith("chrome-extension://")))}jo(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}Do(t){return!w(t)&&f(t)}}},zr=e({productTours:class{get Tr(){return this._instance.persistence}constructor(t){this.Ho=null,this.Uo=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.Tr&&this.Tr.register({[Ni]:!!i.productTours}),!Xe(this._instance))return!this.Ho&&w(null==(e=this.Tr)?void 0:e.props[se])||Ye.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Ho)||r.stop(),this.Ho=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Ho&&Xe(this._instance)&&this.ai((()=>this.zo()))}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?Ye.error("Could not load product tours script",i):t()}))}zo(){var t;!this.Ho&&null!=(t=Se.__PosthogExtensions__)&&t.generateProductTours&&(this.Ho=Se.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!f(this.Uo)||i){var e=this.Tr;if(e){var r=e.props[se];if(f(r)&&!i)return this.Uo=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(Xe(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||Ye.warn(s):Ye.error(s),void t([],{isLoaded:!1,error:s})}var n=f(i.json.product_tours)?i.json.product_tours:[];this.Uo=n,e&&e.register({[se]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Uo,{isLoaded:!0})}getActiveProductTours(t){w(this.Ho)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ho.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.Ho)||i.showTourById(t)}previewTour(t){this.Ho?this.Ho.previewTour(t):this.ai((()=>{var i;this.zo(),null==(i=this.Ho)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Ho)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Ho)||t.nextStep()}previousStep(){var t;null==(t=this.Ho)||t.previousStep()}clearCache(){var t;this.Uo=null,null==(t=this.Tr)||t.unregister(se)}resetTour(t){var i;null==(i=this.Ho)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.Ho)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.Ho)||i.cancelPendingTour(t)}}},jr),Ur={siteApps:class{constructor(t){this.Wo=0,this._instance=t,this.Vo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zo(t,i){if(i){var e=this.globalsForEvent(i);this.Vo.push(e),this.Vo.length>1e3&&(this.Vo=this.Vo.slice(10))}}get siteAppLoaders(){var t;return null==(t=Se._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Zo.bind(this));this.Go=()=>{t(),this.Vo=[],this.Go=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,tr),{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}}Qo(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)||(ir.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)||(ir.error("prepare_external_dependency_script returned null"),null):t}Jo(){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==$t?void 0:$t.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Wo++,this.Ko)return this.Yo();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.Qo(t);return i&&d.add(i),i},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!y(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.Ko=()=>{h.forEach((t=>t())),this.Ko=void 0},this.Yo()}Yo(){var t=!1;return()=>{var i;t||(t=!0,this.Wo--,0===this.Wo&&(null==(i=this.Ko)||i.call(this)))}}Xo(t,i){void 0===i&&(i=!0);var e=this.Jo();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.Vo.length&&(ir.info("Processing "+this.Vo.length+" events for site app with id "+t.id),this.Vo.forEach((t=>this.Xo((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this.Go)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,ir.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Xo((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){ir.error(er+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){ir.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}tl(){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)}el(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Xo((()=>null==r.processEvent?void 0:r.processEvent(e)))}catch(i){ir.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.tl(),void this._instance.on("eventCaptured",(t=>this.el(t)))):void ir.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Go)||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;Se["__$$ph_site_app_"+i]=s._instance,null==(t=Se.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return ir.error(er+i,t)}))};for(var o of n.siteApps)a()}else ir.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Hr={tracingHeaders:class{constructor(t){this.il=void 0,this.rl=void 0,this.nl=void 0,this.bo=()=>{var t,i,e=this.sl();e?(m(this.il)&&(this.il=null==(t=Se.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),m(this.rl)&&(this.rl=null==(i=Se.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Co()},this._instance=t}initialize(){this.startIfEnabledOrStop()}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return Ce.error("failed to load script",i);t()}))}al(){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}sl(){var t=this.al();return f(t)?(f(this.nl)?this.nl.splice(0,this.nl.length,...t):this.nl=[...t],t.length>0?this.nl:void 0):(f(this.nl)&&this.nl.splice(0),this.nl=t||void 0,this.nl)}Co(){var t,i;null==(t=this.il)||t.call(this),null==(i=this.rl)||i.call(this),this.il=void 0,this.rl=void 0}startIfEnabledOrStop(){this.sl()?this.ai(this.bo):this.Co()}}},Br=e({surveys:class{get Pe(){return this._instance.config}constructor(t){this.ol=void 0,this._surveyManager=null,this.ll=!1,this.ul=[],this.hl=null,this.dl=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Pe.disable_surveys){if(!t.ok)return lr.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(w(i))return lr.warn("Flags not loaded yet. Not loading surveys.");var e=f(i);this.ol=e?i.length>0:i,lr.info("flags response received, isSurveysEnabled: "+this.ol),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(ur)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.ll)lr.info("Already initializing surveys, skipping...");else if(this.Pe.disable_surveys)lr.info(_r);else if(this.Pe.cookieless_mode&&this._instance.consent.isOptedOut())lr.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Se?void 0:Se.__PosthogExtensions__;if(t){if(!m(this.ol)||this.Pe.advanced_enable_surveys){var i=this.ol||this.Pe.advanced_enable_surveys;this.ll=!0;try{var e=t.generateSurveys;if(e)return void this.vl(e,i);var r=t.loadExternalDependency;if(!r)return void this.cl(ue);r(this._instance,"surveys",(e=>{e||!t.generateSurveys?this.cl("Could not load surveys script",e):this.vl(t.generateSurveys,i)}))}catch(t){throw this.cl("Error initializing surveys",t),t}finally{this.ll=!1}}}else lr.error("PostHog Extensions not found.")}}vl(t,i){this._surveyManager=t(this._instance,i),this._surveyEventReceiver=new pr(this._instance),lr.info("Surveys loaded successfully"),this.fl({isLoaded:!0})}cl(t,i){lr.error(t,i),this.fl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.ul.push(t),this._surveyManager&&this.fl({isLoaded:!0}),()=>{this.ul=this.ul.filter((i=>i!==t))}}getSurveys(t,i){if(void 0===i&&(i=!1),this.Pe.disable_surveys)return lr.info(_r),t([]);var e,r=this._instance.get_property(Xi);if(r&&!i)return t(r,{isLoaded:!0}),void(this.pl()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.hl?this.hl.then((i=>t(i.surveys,i.context))):("undefined"!=typeof Promise&&(this.hl=new Promise((t=>{e=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Pe.token),method:"GET",timestampMode:"query",timeout:this.Pe.surveys_request_timeout_ms,callback:i=>{var r;this.hl=null;var s=i.statusCode;if(200!==s||!i.json){var n="Surveys API could not be loaded, status: "+s;0!==s?lr.error(n):i.error||lr.warn(n),this.dl=Date.now();var a={isLoaded:!1,error:n};return t([],a),void(null==e||e({surveys:[],context:a}))}this.dl=null;var o,l=i.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(or(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t))));u.length>0&&(null==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[Xi]:l,[te]:Date.now()});var h={isLoaded:!0};t(l,h),null==e||e({surveys:l,context:h})}}))}pl(){return this.gl()&&!this.hl&&!this.ml()}gl(){var t=this._instance.get_property(te);return k(t)&&Date.now()-t>3e5}ml(){return k(this.dl)&&3e5>Date.now()-this.dl}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>""+ur+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){lr.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){}}fl(t){for(var i of this.ul)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){lr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!w(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);lr.warn("init was not called")}yl(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}bl(t){if(w(this._surveyManager))return{eligible:!1,reason:gr};var i="string"==typeof t?this.yl(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}_l(t){if(w(this._surveyManager))return{eligible:!1,reason:gr};var i="string"==typeof t?this.yl(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(w(this._surveyManager))return lr.warn("init was not called"),{visible:!1,disabledReason:gr};var i=this._l(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return w(this._surveyManager)?(lr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:gr})):new Promise((e=>{this.getSurveys((i=>{var r,s=null!==(r=i.find((i=>i.id===t)))&&void 0!==r?r:null;if(s){var n=this._l(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var r;if(w(this._surveyManager))lr.warn("init was not called");else{var s="string"==typeof t?this.yl(t):t;if(null!=s&&s.id)if(hr.includes(s.type)){var n=null==$t?void 0:$t.querySelector(i);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(lr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,i;lr.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),lr.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,e);lr.warn("Survey element not found")}else lr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else lr.warn("Survey not found")}}displaySurvey(t,i){var r;if(w(this._surveyManager))lr.warn("init was not called");else{var s=this.yl(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&&lr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var a=this.bl(s);if(!a.eligible)return void lr.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 lr.warn("Survey not found")}}cancelPendingSurvey(t){w(this._surveyManager)?lr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}},jr),qr={toolbar:class{constructor(t){this.instance=t}wl(t){Se.ph_toolbar_state=t}xl(){var t;return null!==(t=Se.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),Bt(this.instance.config))return!1;if(!Ct||!$t)return!1;t=null!=t?t:Ct.location,e=null!=e?e:Ct.history;try{if(!i){try{Ct.localStorage.setItem("test","test"),Ct.localStorage.removeItem("test")}catch(t){return!1}i=null==Ct?void 0:Ct.localStorage}var r,s=mr||fe(t.hash,"__posthog")||fe(t.hash,"state"),n=s?Ut((()=>JSON.parse(atob(decodeURIComponent(s)))))||Ut((()=>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(br)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}kl(t){var i=Se.ph_load_toolbar||Se.ph_load_editor;!w(i)&&p(i)?i(t,this.instance):yr.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==$t||!$t.getElementById(Vt));if(!Ct||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(Ct.localStorage.setItem(br,JSON.stringify(e({},s,{source:void 0}))),2===this.xl())this.kl(s);else if(0===this.xl()){var n;this.wl(1),null==(n=Se.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return yr.error("[Toolbar] Failed to load",t),void this.wl(0);this.wl(2),this.kl(s)})),Ht(Ct,"turbolinks:load",(()=>{this.wl(0),this.loadToolbar(s)}))}return!0}Sl(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)}}},Vr=e({experiments:Cr},jr),Wr={conversations:class{constructor(t){this.Cl=void 0,this._conversationsManager=null,this.Ml=!1,this.Tl=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&t.ok){var i=t.config.conversations;w(i)||(S(i)?this.Cl=i:(this.Cl=i.enabled,this.Tl=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Cl=void 0,this.Tl=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ml||this._instance.config.disable_conversations||Bt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Se?void 0:Se.__PosthogExtensions__;if(t&&!m(this.Cl)&&this.Cl)if(this.Tl&&this.Tl.token){this.Ml=!0;try{var i=t.initConversations;if(i)return this.El(i),void(this.Ml=!1);var e=t.loadExternalDependency;if(!e)return void this.Il(ue);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.Il("Could not load conversations script",i):this.El(t.initConversations),this.Ml=!1}))}catch(t){this.Il("Error initializing conversations",t),this.Ml=!1}}else Ar.error("Conversations enabled but missing token in remote config.")}}El(t){if(this.Tl)try{this._conversationsManager=t(this.Tl,this._instance),Ar.info("Conversations loaded successfully")}catch(t){this.Il("Error completing conversations initialization",t)}else Ar.error("Cannot complete initialization: remote config is null")}Il(t,i){Ar.error(t,i),this._conversationsManager=null,this.Ml=!1}show(){this._conversationsManager?this._conversationsManager.show():Ar.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Cl&&!y(this._conversationsManager)}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):(Ar.warn(Rr),null)}))()}getMessages(t,e){var r=this;return i((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,e):(Ar.warn(Rr),null)}))()}markAsRead(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Ar.warn(Rr),null)}))()}getTickets(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Ar.warn(Rr),null)}))()}requestRestoreLink(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Ar.warn(Rr),null)}))()}restoreFromToken(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Ar.warn(Rr),null)}))()}restoreFromUrlToken(){var t=this;return i((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ar.warn(Rr),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()}}},Kr={logs:class{constructor(t){var i,r=this;this.Pl=!1,this.Rl=!1,this.rt=Lt("[logs]"),this.Ll=e({},this.rt,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(Ir)||r.rt.error(...i)}}),this.er=[],this.Ol=[],this.fa=0,this.Fl=()=>{var t,i;this.fa=0,null==(t=this.Al)||t.onReconnect(),null==(i=this.Dl)||i.onReconnect()},this._instance=t,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Pl=!0),Ct&&Ht(Ct,"online",this.Fl)}$l(t,i,e,r){var s,n=function(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=m(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}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new B(this.Nl(t,i),n,this.Ll,(()=>this.ql()),(t=>t()),void 0,r),n]}jl(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Al||this.Bl!==i){var e;null==(e=this.Al)||e.reset(),this.Bl=i;var r=this.$l((()=>this.er),(t=>{this.er=t}));this.Al=r[0],this.Hl=r[1]}return this.Al}Ul(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Dl||this.zl!==i){var e;null==(e=this.Dl)||e.reset(),this.zl=i;var r=this.$l((()=>this.Ol),(t=>{this.Ol=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},$r);this.Dl=r[0],this.Wl=r[1]}return this.Dl}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var i;if(t.ok){var e=null==(i=t.config.logs)?void 0:i.captureConsoleLogs;!w(e)&&e&&(this.Pl=!0,this.loadIfEnabled())}}reset(){var t,i;this.er=[],null==(t=this.Al)||t.reset(),this.Ol=[],null==(i=this.Dl)||i.reset(),this.fa=0}captureLog(t){this.jl().captureLog(t)}he(t){this.Ul().captureLog(t)}get logger(){return this.Vl||(this.Vl={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.Vl}flushLogs(t){t?this.Zl(t):(this.Al&&this.Al.flush().catch((t=>this.Gl(t))),this.Dl&&this.Dl.flush().catch((t=>this.Gl(t))))}Gl(t){Ir(t)||this.rt.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.Pl&&!this.Rl){var t=null==Se?void 0:Se.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",(i=>{var e;i||null==(e=t.logs)||!e.initializeLogs?this.rt.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Rl=!0)})):this.rt.error(ue)}else this.rt.error("PostHog Extensions not found.")}}Nl(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:[])},At:t=>this.At(t),getLibraryId:()=>Tt.LIB_NAME,getLibraryVersion:()=>Tt.LIB_VERSION}}At(t){return new Promise((i=>{if(pe(this.fa,3))i({kind:"fatal",error:Mr(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout((()=>{this.rt.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Mr(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Ql(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.Jl(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==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.rt.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Mr(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)})}}})}}))}Jl(t){(0!==t||this._instance.__loaded)&&(this.fa=ge(t,this.fa,3,(()=>this.rt.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."))))}Zl(t){this.er.length>0&&this.Kl(t,this.er,this.Hl,Tt.LIB_NAME,(t=>{this.er=t})),this.Ol.length>0&&this.Kl(t,this.Ol,this.Wl,$r,(t=>{this.Ol=t}))}Kl(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var a=H(n,U(e,Tt.LIB_NAME,Tt.LIB_VERSION),r,Tt.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Ql(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}Ql(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}ql(){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,w(s)||(i.sessionStartTimestamp=s),w(n)||(i.lastActivityTimestamp=n)}if(null!=Se&&null!=(t=Se.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?R(Se.location.href):Se.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Jr={metrics:class{constructor(t){this.rt=Lt("[metrics]"),this._instance=t}initialize(){}jl(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Al&&this.Bl===e||(null==(i=this.Al)||i.reset(),this.Bl=e,this.Al=new K(this.Nl(),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.rt)),this.Al}count(t,i,e){void 0===i&&(i=1),this.jl().count(t,i,e)}gauge(t,i,e){this.jl().gauge(t,i,e)}histogram(t,i,e){this.jl().histogram(t,i,e)}flush(t){if(!this.Al)return Promise.resolve();if(t){var i=this.Al.drainWindow();return i&&this.Kt(i,t),Promise.resolve()}return this.Al.flush().catch((t=>this.rt.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Al)||t.reset()}Nl(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Kt:t=>i.Kt(t),getLibraryId:()=>Tt.LIB_NAME,getLibraryVersion:()=>Tt.LIB_VERSION}}Kt(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.Yl(),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&&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)})}}}))}))}Yl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Gr=e({},jr,Lr,Dr,Nr,zr,Ur,Br,Hr,qr,Vr,Wr,Kr,Jr),Zr=jr,Qr=Lr,Yr=Dr,Xr=Nr,ts=zr,is=Ur,es=Br,rs=Hr,ss=qr,ns=Vr,as=Wr,os=Kr,ls=Jr;export{Gr as AllExtensions,Yr as AnalyticsExtensions,as as ConversationsExtensions,Xr as ErrorTrackingExtensions,ns as ExperimentsExtensions,Zr as FeatureFlagsExtensions,os as LogsExtensions,ls as MetricsExtensions,ts as ProductToursExtensions,Qr as SessionReplayExtensions,is as SiteAppsExtensions,es as SurveysExtensions,ss as ToolbarExtensions,rs 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.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.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=["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"],l=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return o.concat(i).some((t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)}))};function u(t,i){return-1!==t.indexOf(i)}var h=function(t){return t.trim()},v=Object.prototype,d=v.hasOwnProperty,c=v.toString,f=Array.isArray||function(t){return"[object Array]"===c.call(t)},p=t=>"function"==typeof t,g=t=>t===Object(t)&&!f(t),_=t=>{if(g(t)){for(var i in t)if(d.call(t,i))return!1;return!0}return!1},m=t=>void 0===t,b=t=>"[object String]"==c.call(t),y=t=>null===t,w=t=>m(t)||y(t),k=t=>"[object Number]"==c.call(t)&&t==t,S=t=>"[object Boolean]"===c.call(t),x=t=>t instanceof FormData;function E(t){return null===t||"object"!=typeof t}function F(t,i){return{}.toString.call(t)==="[object "+i+"]"}function P(t){return"undefined"!=typeof Event&&T(t,Event)}function T(t,i){try{return t instanceof i}catch(t){return!1}}function C(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),k(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),C(e,i,e,r))}class A{constructor(t){this.tt={},this.et=t.et,this.it=C(t.bucketSize,0,100,t.rt),this.nt=C(t.refillRate,0,this.it,t.rt),this.st=C(t.refillInterval,0,864e5,t.rt)}ot(t,i){var e=Math.floor((i-t.lastAccess)/this.st);e>0&&(t.tokens=Math.min(t.tokens+e*this.nt,this.it),t.lastAccess=t.lastAccess+e*this.st)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.tt[r];return s?this.ot(s,e):this.tt[r]=s={tokens:this.it,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.et)||i.call(this,t)),0===s.tokens)}stop(){this.tt={}}}function R(t){return t?t.split("#")[0]:t}function O(t,i){var e=setTimeout(t,i);return(null==e?void 0:e.unref)&&(null==e||e.unref()),e}function M(t,i,e){return I.apply(this,arguments)}function I(){return(I=i((function*(t,i,e){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=O((()=>{try{null==e||e(),t()}catch(t){s(t)}}),i)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var j={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}},L=j.info;function D(t){if(S(t))return{boolValue:t};if("number"==typeof t)return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if("string"==typeof t)return{stringValue:t};if(f(t))return{arrayValue:{values:t.map((t=>D(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(i){return{stringValue:String(t)}}}function N(t){var i=[];for(var e in t){var r=t[e];y(r)||m(r)||i.push({key:e,value:D(r)})}return i}function z(t,i){var r=j[t.level||"info"]||L,s=r.text,n=r.number,a=String(Date.now())+"000000",o={};i.distinctId&&(o.posthogDistinctId=i.distinctId),i.sessionId&&(o.sessionId=i.sessionId),i.windowId&&(o["window.id"]=i.windowId),w(i.sessionStartTimestamp)||(o.sessionStartTimestamp=String(i.sessionStartTimestamp)),w(i.lastActivityTimestamp)||(o.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(o["url.full"]=i.currentUrl),i.screenName&&(o["screen.name"]=i.screenName),i.appState&&(o["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(o.feature_flags=i.activeFeatureFlags);var l=e({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:N(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),m(t.trace_flags)||(u.flags=t.trace_flags),u}function U(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 H(t,i,e,r){return{resourceLogs:[{resource:{attributes:N(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}let B=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Pe=i,this.rt=e,this.ut=r,this.ht=s,this.dt=n,this.vt=a,this.ct=null,this.ft=0,this.yt=0,this.bt=0,this._t=0,this.wt=!1,this.xt=i.maxBufferSize,this.kt=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this.St=i.flushIntervalMs,this.Ct=i.maxBatchRecordsPerPost,this.Mt=i.rateCapWindowMs,this.Tt=i.maxLogsPerInterval}reset(){this.Et(),this.ct=null,this.bt=0,this._t=0,this.wt=!1,this.ft=0,this.yt=0,this.Ct=this.Pe.maxBatchRecordsPerPost}onReconnect(){this.yt=0,this.It()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var i=this.Pt(t);if(null!==i)if(i.body){if(this.Rt()){var e={record:z(i,this.ut())};this.ht((()=>this.Lt(e)))}}else this.rt.info("Log was rejected in beforeSend function")}}Pt(t){var i=this.Pe.beforeSend;if(!i)return t;var e=f(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.rt.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for log:",t),null}return r}Rt(){if(void 0===this.Tt)return!0;var t=Date.now(),i=t-this.bt;return this.Mt>i&&i>=0||(this.bt=t,this._t=0,this.wt=!1),this.Tt>this._t?(this._t++,!0):(this.wt||(this.rt.warn("captureLog dropping logs: exceeded "+this.Tt+" logs per "+this.Mt+"ms"),this.wt=!0),!1)}flush(){var t=this;return i((function*(){if(!t._instance.isDisabled)return t.ct||(t.ct=t.Ot().finally((()=>{t.ct=null}))),t.ct}))()}Ot(){var t=this;return i((function*(){var i;t.Et();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;t.ft=0;var l=Math.min(e.length,t.Ct),u=e.slice(0,l),h=H(u.map((t=>t.record)),t.Ft(),null!==(n=t.vt)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.At(h);if("too-large"===v.kind&&u.length>1)t.Ct=Math.max(1,Math.floor(u.length/2)),t.rt.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.Ct);else{if("retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.rt.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"===v.kind&&t.Pe.maxBatchRecordsPerPost>t.Ct&&(t.Ct=Math.min(t.Pe.maxBatchRecordsPerPost,t.Ct+1)),yield t.Dt(u.length),e=null!==(o=t._instance.getPersistedProperty(a.LogsQueue))&&void 0!==o?o:[],s+=u.length,"fatal"===v.kind)throw v.error}}}))()}Dt(t){var e=this;return i((function*(){var i,r=Math.max(0,t-e.ft),s=null!==(i=e._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(a.LogsQueue,s.slice(r)),yield e.dt()}))()}Ft(){return U(this.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Lt(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(a.LogsQueue))&&void 0!==i?i:[];this.kt>e.length||(e.shift(),this.ft++,this.rt.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(a.LogsQueue,e),this.xt>e.length?this.$t():this.It()}}$t(t){void 0===t&&(t=this.St),this.Nt||(this.Nt=O((()=>{this.Nt=void 0,this.It()}),t))}qt(){var t=Math.min(Math.max(0,this.yt-1),6);return this.St*Math.pow(2,t)}jt(){var t=this._instance.getPersistedProperty(a.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return i((function*(){e.Et();var i=e.flush().catch((()=>{}));void 0!==t?yield M(i,t):yield i}))()}flushWithTimeout(t){var e=this;return i((function*(){var i=e.flush();yield M(i,t,(()=>{i.catch((()=>{}))}))}))()}It(){this.flush().then((()=>{this.yt=0}),(t=>{this.yt++,this.rt.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.jt()&&this.$t(this.qt())}))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}};var q=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function V(t){return String(t)+"000000"}function W(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 K=class{constructor(t,i,e){this._instance=t,this.Pe=i,this.rt=e,this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Wt=0}count(t,i,e){void 0===i&&(i=1),this.Vt({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.Vt({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.Vt({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.ct,r=function(){var r=i((function*(){e&&(yield e.catch((()=>{}))),yield t.Zt()}));return function(){return r.apply(this,arguments)}}(),s=r().finally((()=>{this.ct===s&&(this.ct=null)}));return this.ct=s,s}drainWindow(){if(0===this.Bt.size)return null;var t=this.Bt;return this.Bt=new Map,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Gt(t)}reset(){this.Wt++,this.Et(),this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set}Vt(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Pt(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.rt.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=W(i.type,i.name,i.unit,r)}catch(t){return void this.rt.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.Bt.get(s);if(!n){if(!this.Qt())return;n={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.Bt.set(s,n)}var a=this.Ut.get(i.name);void 0===a?this.Ut.set(i.name,i.type):a===i.type||this.zt.has(i.name)||(this.zt.add(i.name),this.rt.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.Jt(n,i.value),this.$t()}else this.rt.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.rt.warn("Dropping metric with empty name")}}Qt(){return this.Pe.maxSeriesPerFlush>this.Bt.size||(this.Ht||(this.Ht=!0,this.rt.warn("Metric series cap reached ("+this.Pe.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Jt(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(q.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,q)]+=1}}Pt(t){var i=this.Pe.beforeSend;if(!i)return t;var e=f(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.rt.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for metric:",t),null}return r}$t(){this.Nt||(this.Nt=O((()=>{this.Nt=void 0,this.flush().catch((t=>{this.rt.error("Metrics flush failed:",t)}))}),this.Pe.flushIntervalMs))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}Zt(){var t=this;return i((function*(){if(0!==t.Bt.size){var i=t.Bt;t.Bt=new Map,t.Ht=!1,t.Ut=new Map,t.zt=new Set;var e=t.Wt,r=yield t._instance.Kt(t.Gt(i));if(e===t.Wt)switch(r.kind){case"ok":return;case"retry-later":return t.Yt(i),void t.$t();case"too-large":return void t.rt.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.rt.error("Failed to send metrics batch:",r.error)}}}))()}Gt(t){return i=this.Xt(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.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:N(r)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,r,s,n}Xt(t){var i=V(Date.now()),r=new Map;for(var s of t.values()){var n,a=W(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=N(null!==(n=s.attributes)&&void 0!==n?n:{}),u=V(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:q})}return Array.from(r.values())}Yt(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.Bt.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.Qt()&&this.Bt.set(s,n)}}};var J,G,Z;function Q(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return Z&&e.length===G?Z:(G=e.length,Z=e.reduce(((e,r)=>{J||(J={});var s=J[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,J[r]=[l,u];break}}return e}),{}))}}class Y{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&&f(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:Q(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 X="?";function tt(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?X:e,in_app:!0};return m(r)||(n.lineno=r),m(s)||(n.colno=s),n}var it=(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]:X,e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},et=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,rt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,st=/\((\S*)(?::(\d+))(?::(\d+))\)/,nt=(t,i)=>{var e=et.exec(t);if(e)return tt(i,e[1],X,+e[2],+e[3]);var r=rt.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=st.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=it(r[1]||X,r[2]);return tt(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},at=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ot=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,lt=(t,i)=>{var e=at.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=ot.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]||X,a=it(n,s);return tt(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ut=/\(error: (.*)\)/;class ht{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=b(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 F(t,"DOMException")}isDOMError(t){return F(t,"DOMError")}}class vt{match(t){return function(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 T(t,Error)}}(t)}coerce(t,i){return{type:this.getType(t),value:this.getMessage(t,i),stack:this.getStack(t),cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}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 dt{constructor(){}match(t){return!!F(t,"ErrorEvent")&&(null!=t.error||this.fe(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.pe(t))&&void 0!==r?r:s.stack,synthetic:!0})}fe(t){return b(t.message)&&t.message.length>0}pe(t){var i=t;if(b(i.filename)&&i.filename.length>0){var e,r,s=null!==(e=i.lineno)&&void 0!==e?e:0,n=null!==(r=i.colno)&&void 0!==r?r:0;return"Error\n at "+i.filename+":"+s+":"+n}}}var ct=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ft{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(ct);return r&&(i=r[1],e=r[2]),[i,e]}}var pt=["fatal","error","warning","log","info","debug"];function gt(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 _t{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){return P(t)?t.constructor.name:"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: "+gt(t)}isSeverityLevel(t){return b(t)&&!(t=>b(t)&&0===t.trim().length)(t)&&pt.indexOf(t)>=0}getStack(t){try{return b(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:b(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(e instanceof Error)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 P(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+gt(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}}class bt{match(t){return E(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 yt{match(t){return F(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!P(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 E(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 wt="$message",kt="$timestamp",St=new Set([wt,kt]),xt={enabled:!0,max_bytes:32768};function Et(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:xt.enabled,max_bytes:Pt(t.max_bytes,xt.max_bytes)}:e({},xt)}class Ft{constructor(t){this.Je=[],this.Ke=0,this.Pe=Et(t)}setConfig(t){this.Pe=Et(t),this.Xe()}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(!g(s))return;var n=s,a=n[wt],o=n[kt];if(!b(a)||0===a.trim().length)return;if(!b(o)&&!k(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.Pe.max_bytes||(this.Je.push({step:i.step,bytes:e}),this.Ke+=e,this.Xe())}}getAttachable(){return this.Je.map((t=>t.step))}clear(){this.Je=[],this.Ke=0}size(){return this.Je.length}Xe(){for(;this.Ke>this.Pe.max_bytes&&this.Je.length>0;){var t=this.Je.shift();t&&(this.Ke-=t.bytes)}}}function Pt(t,i){if(!k(t)||t===1/0||t===-1/0)return i;var e=Math.floor(t);return 0>e?i:e}var Tt={DEBUG:!1,LIB_VERSION:"0.3.1",LIB_NAME:"browser-common"},Ct="undefined"!=typeof window?window:void 0,At="undefined"!=typeof globalThis?globalThis:Ct,Rt=null==At?void 0:At.navigator,$t=null==At?void 0:At.document,Ot=null==At?void 0:At.location;function Mt(){return!(!Ct||!1===Ct.navigator.onLine)}null!=At&&At.XMLHttpRequest&&new At.XMLHttpRequest;var It=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={k(i){if(Ct&&(Tt.DEBUG||Ct.POSTHOG_DEBUG||e)&&!m(Ct.console)&&Ct.console){for(var r=("__rrweb_original__"in Ct.console[i]?Ct.console[i].__rrweb_original__:Ct.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.k("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.k("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.k("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.k("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)=>It(t+" "+i,e)};return r},jt=It("[PostHog.js]"),Lt=jt.createLogger;function Dt(t,i){if(!w(t))if(f(t))t.forEach(i);else if(x(t))t.forEach(((t,e)=>i(t,e)));else for(var e in t)d.call(t,e)&&i(t[e],e)}var Nt=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 zt(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 Ut=function(t){try{return t()}catch(t){return}};function Ht(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 Bt(t){return"ph_toolbar_internal"===t.name}function qt(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!p(r))return i;try{var s=r(i);return b(s)&&s?s:i}catch(t){return jt.error("Error in get_current_url, falling back to window.location.href",t),i}}var Vt="__POSTHOG_TOOLBAR__",Wt=1,Kt=3,Jt=11;function Gt(t){return t instanceof Element&&(t.id===Vt||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Zt(t){return!!t&&t.nodeType===Wt}function Qt(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function Yt(t){return!!t&&t.nodeType===Kt}function Xt(t){return!!t&&t.nodeType===Jt&&Zt(t.host)}var ti=1e3;function ii(t){return t?h(t).split(/\s+/):[]}function ei(t,i){var e=function(t){var i,e=null==Ct||null==(i=Ct.location)?void 0:i.href;return m(e)?void 0:qt(t,e)}(i);return!!(e&&t&&t.some((t=>e.match(t))))}function ri(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return ii(i)}function si(t){return w(t)?null:h(t).split(/(\s+)/).filter((t=>Pi(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ni(t){var i="";return mi(t)&&!bi(t)&&t.childNodes&&t.childNodes.length&&Dt(t.childNodes,(function(t){var e;Yt(t)&&t.textContent&&(i+=null!==(e=si(t.textContent))&&void 0!==e?e:"")})),h(i)}function ai(t){var i;return m(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var oi=["a","button","form","input","select","textarea","label"];function li(t,i){if(m(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 ui(t){var i=t.parentNode;return!(!i||!Zt(i))&&i}var hi=[".ph-no-autocapture","[data-ph-no-autocapture]"],vi=["next","previous","prev",">","<"],di=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,ci=[".ph-no-rageclick",".ph-no-capture"],fi=["","text","search","email","password","url","tel","number"];function pi(t,i){if(!Ct||gi(t))return!1;var e,r,s,n,a;if(S(i)?(e=!!i&&ci,r=void 0,s=!1):(e=null!==(n=null==i?void 0:i.css_selector_ignorelist)&&void 0!==n?n:ci,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||!Zt(t))&&(!!Qt(t,"textarea")||(Qt(t,"input")?u(fi,(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=_i(t,!1).targetElementList;return!function(t,i){if(!1===t||m(t))return!1;var e;if(!0===t)e=vi;else{if(!f(t))return!1;if(t.length>10)return jt.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=>di(i,t)||di(r,t)))}))}(r,o.map((t=>{var i;return{safeText:ni(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}})))&&!li(o,e)}var gi=t=>!t||Qt(t,"html")||!Zt(t),_i=(t,i)=>{if(!Ct||gi(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!Qt(s,"body");)if(Xt(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=ui(s);if(!n)break;if(i||oi.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=Ct.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&&!Qt(r,"body");r=r.parentNode){if(e++>=ti||i.has(r))return!1;i.add(r);var s=ri(r);if(u(s,"ph-sensitive")||u(s,"ph-no-capture"))return!1}if(u(ri(t),"ph-include"))return!0;var n=t.type||"";if(b(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var a=t.name||t.id||"";return!b(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 bi(t){return!!(Qt(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Qt(t,"select")||Qt(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var yi=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}))$"),wi=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,ki=[16,15,14,13],Si=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),xi=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ei=/[0-9A-Za-z_]/;function Fi(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 Pi(t,i){if(void 0===i&&(i=!0),w(t))return!1;if(b(t)){t=h(t);var e=i?yi.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(wi.lastIndex=0;i=wi.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of ki){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(yi.test(o)&&Fi(o))return!0}}}return!1}(t);if(e)return!1;var r=i?Si.test(t):function(t){var i;for(xi.lastIndex=0;i=xi.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&Ei.test(e)&&Ei.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function Ti(t){var i=ni(t);return Pi(i=(i+" "+Ci(t)).trim())?i:""}function Ci(t){var i="";return t&&t.childNodes&&t.childNodes.length&&Dt(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=ni(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+Ci(t)).trim())}catch(t){jt.error("[AutoCapture]",t)}})),i}function Ai(t){return t.replace(/"|\\"/g,'\\"')}function Ri(t){var i=t.attr__class;if(i)return f(i)?i:ii(i)}class $i{constructor(t){this.disabled=!1===t;var i=g(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 Oi="$autocapture_disabled_server_side",Mi="$heatmaps_enabled_server_side",Ii="$exception_capture_enabled_server_side",ji="$error_tracking_suppression_rules",Li="$error_tracking_capture_extension_exceptions",Di="$web_vitals_enabled_server_side",Ni="$product_tours_enabled_server_side",zi="$web_vitals_allowed_metrics",Ui="$session_recording_remote_config",Hi="$enabled_feature_flags",Bi="$active_feature_flags",qi="$early_access_features",Vi="$feature_flag_details",Wi="$feature_flag_payloads",Ki="$feature_flag_request_id",Ji="$minimal_flag_called_events",Gi="$override_feature_flags",Zi="$override_feature_flag_payloads",Qi="$stored_person_properties",Yi="$stored_group_properties",Xi="$surveys",te="$surveys_loaded_at",ie="$surveys_activated",ee="$surveys_activated_session",re="$surveys_activated_timestamps",se="ph_product_tours",ne="$flag_call_reported",ae="$flag_call_reported_session_id",oe="$feature_flag_errors",le="$feature_flag_evaluated_at",ue="PostHog loadExternalDependency extension not found.",he="visibilitychange",ve="beforeunload",de=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(!f(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){jt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ce=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("=");f(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},fe=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},pe=(t,i)=>t>=i&&Mt(),ge=(t,i,e,r)=>{if(0===t){if(Mt()){var s=i+1;return s===e&&r(),s}return i}return 0},_e="$copy_autocapture",me=Lt("[AutoCapture]");function be(t,i){return i.length>t?i.slice(0,t)+"...":i}function ye(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!Zt(i));return i}function we(t,i){var r,s,n=i.e,a=i.maskAllElementAttributes,o=i.maskAllText,l=i.elementAttributeIgnoreList,h=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!Zt(t))return{props:{}};for(var d=[t],c=new Set([t]),f=t;f.parentNode&&!Qt(f,"body")&&ti>d.length;)if(Xt(f.parentNode)){var p=f.parentNode.host;if(c.has(p))break;c.add(p),d.push(p),f=p}else{if(!Zt(f.parentNode))break;if(c.has(f.parentNode))break;c.add(f.parentNode),d.push(f.parentNode),f=f.parentNode}var g,_,y=[],w={},k=!1,S=!1;if(Dt(d,(t=>{var i=mi(t);if(Qt(t,"a")){var e=t.getAttribute("href");k=!!(i&&e&&Pi(e))&&(v?R(e):e)}u(ri(t),"ph-no-capture")&&(S=!0),y.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};oi.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?be(1024,Ti(t)):be(1024,ni(t)));var o=ri(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),Dt(t.attributes,(function(e){var n;if((!bi(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Pi(e.value)&&(!b(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=ii(o).join(" ")),a["attr__"+e.name]=be(1024,"href"===e.name&&s?R(o):o)}}));for(var l=1,u=1,h=t;h=ye(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,a,o,l,v));var r=function(t){if(!mi(t))return{};var i={};return Dt(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&&Pi(r)&&(i[e]=r)}})),i}(t);Nt(w,r)})),S)return{props:{},explicitNoCapture:S};if(o||(y[0].$el_text=Qt(t,"a")||Qt(t,"button")?Ti(t):ni(t)),k){var x,E;y[0].attr__href=k;var F=null==(x=(t=>{var i=null==$t?void 0:$t.createElement("a");return m(i)?null:(i.href=t,i)})(k))?void 0:x.host,P=null==Ct||null==(E=Ct.location)?void 0:E.host;F&&P&&F!==P&&(g=k)}return{props:Nt({$event_type:n.type,$ce_version:1},h?{}:{$elements:y},{$elements_chain:(_=y,function(t){return t.map((t=>{var i,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return zt(a).sort(((t,i)=>t[0].localeCompare(i[0]))).forEach((t=>{var i=t[1];return o[Ai(t[0].toString())]=Ai(i.toString())})),(s+=":")+zt(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:Ri(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return zt(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(_)))},null!=(r=y[0])&&r.$el_text?{$el_text:null==(s=y[0])?void 0:s.$el_text}:{},g&&"click"===n.type?{$external_click_url:g}:{},w)}}var ke="undefined"!=typeof globalThis?globalThis:Ct;ke&&"undefined"==typeof self&&(ke.self=ke),ke&&"undefined"==typeof File&&(ke.File=function(){});var Se=null!=Ct?Ct:{},xe=Lt("[Dead Clicks]"),Ee=()=>!0;class Fe{get lazyLoadedDeadClicksAutocapture(){return this.si}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.ai((()=>{this.oi()})):this.stop()}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?xe.error("failed to load script",i):t()}))}oi(){var t;if($t){if(!this.si&&null!=(t=Se.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=g(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.si=Se.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.si.start($t),xe.info("starting...")}}else xe.error("`document` not found. Cannot start.")}stop(){this.si&&(this.si.stop(),this.si=void 0,xe.info("stopping..."))}}var Pe=Lt("[ExceptionAutocapture]"),Te=()=>{},Ce=Lt("[TracingHeaders]"),Ae=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Re=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ae],$e="<masked>",Oe=["li_fat_id"];function Me(t,i,e){if(!$t)return{};var r,s,n,a=(r=ce($t.URL,[],$e),s=Re.concat([]),n={},Dt(s,(function(t){var i=de(r,t);n[t]=i||null})),n),o=function(){var t={};return Dt(Oe,(function(i){var e=(t=>{if($t){try{for(var i=t+"=",e=$t.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 Nt(o,a)}function Ie(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var je=Lt("[Web Vitals]"),Le=9e5,De=Lt("[RemoteConfig]");class Ne{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Se._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Vi(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zi(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 De.info("Using preloaded remote config",this.remoteConfig),this.Gi(this.remoteConfig),void this.Qi();if(this._instance._shouldDisableFlags())return void De.warn("Remote config is disabled. Falling back to local config.");this.Vi((t=>{if(!t)return De.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zi((t=>{this.Gi(t.json,t),this.Qi()}));this.Gi(t),this.Qi()}))}catch(t){De.error("Error loading remote config",t),this.Gi()}}stop(){this.Ki&&(clearInterval(this.Ki),this.Ki=void 0)}refresh(){!this._instance._shouldDisableFlags()&&$t&&"hidden"!==$t.visibilityState&&this._instance.reloadFeatureFlags()}Qi(){var t;if(!this.Ki){var i=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==i&&(this.Ki=setInterval((()=>{this.refresh()}),i))}}Gi(t,i){!t&&i&&(0===i.statusCode?i.error||De.warn("Failed to fetch remote config from PostHog."):De.error("Failed to fetch remote config from PostHog."));try{this._instance.Gi(t?{ok:!0,config:t}:{ok:!1})}catch(t){De.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){De.error("Error loading feature flags",t)}}}var ze="disabled",Ue="lazy_loading",He="awaiting_config",Be="missing_config";Tt.DEBUG=!1,Tt.LIB_VERSION="1.412.1",Tt.LIB_NAME="web";var qe=function(t,i){if(!function(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}},Ve={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=>qe(i,t))))),not_regex:(t,i)=>i.every((i=>t.every((t=>!qe(i,t))))),icontains:(t,i)=>i.map(We).some((i=>t.map(We).some((t=>i.includes(t))))),not_icontains:(t,i)=>i.map(We).every((i=>t.map(We).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)))}))},We=t=>t.toLowerCase();function Ke(t,i){return!t||Object.entries(t).every((t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(m(r)||y(r))return!1;var s=[String(r)],n=Ve[e.operator];return!!n&&n(e.values,s)}))}Lt("[SessionRecording]"),Lt("[SessionRecording]");var Je="[SessionRecording]",Ge=Lt(Je),Ze=Lt("[Heatmaps]");function Qe(t){return g(t)&&"clientX"in t&&"clientY"in t&&k(t.clientX)&&k(t.clientY)}var Ye=Lt("[Product Tours]"),Xe=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(Ni))},tr=["$set_once","$set"],ir=Lt("[SiteApps]"),er="Error while initializing PostHog app with config id ",rr="base64",sr="events",nr="cancelEvents",ar="survey shown";function or(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var lr=Lt("[Surveys]"),ur="seenSurvey_",hr=["popover","widget","api"];class vr{on(t,i){return this.Ir[t]||(this.Ir[t]=[]),this.Ir[t].push(i),()=>{this.Ir[t]=this.Ir[t].filter((t=>t!==i))}}emit(t,i){for(var e of this.Ir[t]||[])e(i);for(var r of this.Ir["*"]||[])r(t,i)}constructor(){this.Ir={}}}function dr(t,i,e){if(w(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 cr{constructor(t){this.Yn=new vr,this.Xn=(t,i)=>this.ts(t,i)&&this.es(t,i)&&this.rs(t,i)&&this.ns(t,i),this.ts=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event),this._instance=t,this.ss=new Set,this.os=new Set}init(){var t,i;m(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(i=this._instance)||i._addCaptureHook(((t,i)=>{this.on(t,i)})))}register(t){var i,e;if(!m(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach((t=>{var i,e;null==(i=this.os)||i.add(t),null==(e=t.steps)||e.forEach((t=>{var i;null==(i=this.ss)||i.add((null==t?void 0:t.event)||"")}))})),null!=(e=this._instance)&&e.autocapture)){var r,s=new Set;t.forEach((t=>{var i;null==(i=t.steps)||i.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,i){var e;null!=i&&0!=t.length&&(this.ss.has(t)||this.ss.has(i.event))&&this.os&&(null==(e=this.os)?void 0:e.size)>0&&this.os.forEach((t=>{this.ls(i,t)&&this.Yn.emit("actionCaptured",t.name)}))}us(t){this.onAction("actionCaptured",(i=>t(i)))}ls(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Xn(t,e))return!0;return!1}onAction(t,i){return this.Yn.on(t,i)}es(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(!dr(r,i.url,i.url_matching||"contains"))return!1}return!0}rs(t,i){return!!this.hs(t,i)&&!!this.ds(t,i)&&!!this.vs(t,i)}hs(t,i){var e;if(null==i||!i.href)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>dr(t.href,i.href,i.href_matching||"exact")));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&dr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}ds(t,i){var e;if(null==i||!i.text)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>dr(t.text,i.text,i.text_matching||"exact")||dr(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;!w(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=>dr(t,n,a))))}vs(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}cs(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}ns(t,i){return null==i||!i.properties||0===i.properties.length||Ke(i.properties.reduce(((t,i)=>{var e=f(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 fr{constructor(t){var i;this.fs=[],this._instance=t,this.ps=new Map,this.gs=new Map,this.ys=new Map,null==(i=this._instance)||null==i.onSessionId||i.onSessionId((t=>this.bs(t)))}_s(t){return!1}ws(){return null}xs(t){}ks(){}Ss(t,i){return!!t&&Ke(t.propertyFilters,null==i?void 0:i.properties)}Cs(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}Ms(t,i,e){var r=(e===sr?this.ps:this.gs).get(t),s=[];return this.Ts((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.Ss(n,i)}))}register(t){var i;m(null==(i=this._instance)?void 0:i._addCaptureHook)||(this.Es(t),this.Is(t))}Is(t){var i=t.filter((t=>{var i,e;return(null==(i=t.conditions)?void 0:i.actions)&&(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length)>0}));0!==i.length&&(null==this.Ps&&(this.Ps=new cr(this._instance),this.Ps.init(),this.Ps.us((t=>{this.onAction(t)}))),i.forEach((t=>{var i,e,r,s,n;t.conditions&&null!=(i=t.conditions)&&i.actions&&null!=(e=t.conditions)&&null!=(e=e.actions)&&e.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Ps)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((i=>{if(i&&i.name){var e=this.ys.get(i.name);e&&e.push(t.id),this.ys.set(i.name,e||[t.id])}})))})))}Es(t){var i,e=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})),r=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}));0===e.length&&0===r.length||(null==(i=this._instance)||i._addCaptureHook(((t,i)=>{this.onEvent(t,i)})),this.ps=this.Cs(t,sr),this.gs=this.Cs(t,nr))}onEvent(t,i){var e,r,s=this.Rs(),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.Ls(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Os([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Fs(n),void this.As([n])}if(this.gs.has(t)){var o=this.Ms(t,i,nr);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Os(o.map((t=>t.id))),o.forEach((t=>this.Ds(t.id))))}if(this.ps.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.ps.get(t)});var l=this.Ms(t,i,sr);this.$s(l.map((t=>t.id)))}}onAction(t){this.ys.has(t)&&this.$s(this.ys.get(t)||[])}$s(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._s(s)?this.Fs(s)&&this.Ns(s):r.push(s);r.length>0&&(this.fs=[...new Set([...this.fs,...r])]),this.Rs().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Fs(t){this.fs=this.fs.filter((i=>i!==t));var i=this.qs();return!i.includes(t)&&(this.js([...i,t]),this.Bs(),!0)}Os(t){var i=new Set(t);this.fs=this.fs.filter((t=>!i.has(t)));var e=this.Hs(),r=e.filter((t=>!i.has(t)));r.length!==e.length&&(this.js(r),0===r.length&&this.Us()),this.As(t)}zs(){var t,i=this.ws();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}Ns(t){if(this.ws()){var i=this.zs();this.xs(e({},i,{[t]:Date.now()}))}}As(t){if(this.ws()){var i=this.zs(),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)?this.ks():this.xs(e))}}Ws(){this.ws()&&this.ks()}getActivationTimestamp(t){if(this.qs().includes(t)){var i=this.zs()[t];return k(i)?i:void 0}}Hs(){var t,i=this.Vs();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}qs(){var t,i,e=this.Hs();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Zs()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}Bs(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Gs(i)}Us(){this.Qs()}bs(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Zs()];if(e&&e!==t){var r=this.Hs(),s=this.zs();r.length>0&&(this.js([]),r.filter((t=>k(s[t]))).forEach((t=>this.Ds(t)))),this.Us(),this.Ws()}}getActivatedIds(){return[...new Set([...this.qs(),...this.fs])].filter((t=>!this.Js(t)))}reset(){this.fs=[],this.Hs().length>0&&this.js([]),this.Us(),this.Ws()}getEventToItemsMap(){return this.ps}Ks(){return this.Ps}}class pr extends fr{constructor(t){super(t)}Vs(){return ie}Zs(){return ee}ws(){return re}xs(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[re]:t})}ks(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(re)}_s(t){var i,e;this.Ts((i=>{e=i.find((i=>i.id===t))}));var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return k(r)&&r>0}Ys(){return ar}Ts(t){var i;null==(i=this._instance)||i.getSurveys(t)}Ds(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}Rs(){return lr}js(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[ie]:t})}Gs(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[ee]:t})}Qs(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(ee)}Js(){return!1}Ls(t,i){var e;this.Ts((t=>{e=t.find((t=>t.id===i))}));var r=!e||function(t){var i;return or(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e);return r?t===ar?"consume":"ignore":t===ar?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var gr="SDK is not enabled or survey functionality is not yet loaded",_r="Disabled. Not loading surveys.",mr=null!=Ct&&Ct.location?fe(Ct.location.hash,"__posthog")||fe(location.hash,"state"):null,br="_postHogToolbarParams",yr=Lt("[Toolbar]"),wr=Lt("[FeatureFlags]"),kr=Lt("[FeatureFlags]",{debugEnabled:!0}),Sr="\" failed. Feature flags didn't load in time.",xr=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},Er=t=>{var i={};for(var e of zt(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},Fr=Lt("[Error tracking]"),Pr="Refusing to render web experiment since the viewer is a likely bot",Tr={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>qe(i,t),not_regex:(t,i)=>!qe(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t};class Cr{get Pe(){return this._instance.config}constructor(t){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),i.getWebExperiments((t=>{Cr.Xs("retrieved web experiments from the server"),i.ta=new Map,t.forEach((t=>{if(t.feature_flag_key){var e;i.ta&&(Cr.Xs("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(e=i.ta)||e.set(t.feature_flag_key,t));var r=i._instance.getFeatureFlag(t.feature_flag_key);b(r)&&t.variants[r]&&i.ea(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Cr.ia(n,i._instance)&&i.ea(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Cr.Xs(Pr);else if(!this.Pe.disable_web_experiments){if(w(this.ta))return this.ta=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Cr.Xs("applying feature flags",t),t.forEach((t=>{var i;if(this.ta&&null!=(i=this.ta)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ta)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.ea(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Cr.getWindowLocation();if(null!=t&&t.search){var i=de(null==t?void 0:t.search,"__experiment_id"),e=de(null==t?void 0:t.search,"__experiment_variant");i&&e&&(Cr.Xs("previewing web experiments "+i+" && "+e),this.getWebExperiments((t=>{this.ra(parseInt(i),e,t)}),!1,!0))}}loadIfEnabled(){this.Pe.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Pe.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.Pe.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}ra(t,i,e){var r=e.filter((i=>i.id===t));r&&r.length>0&&(Cr.Xs("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.ea(r[0].name,i,r[0].variants[i].transforms))}static ia(t,i){return!w(t.conditions)&&Cr.na(t,i)&&Cr.sa(t)}static na(t,i){var e;if(w(t.conditions)||w(null==(e=t.conditions)?void 0:e.url))return!0;var r=Cr.getWindowLocation();if(r){var s,n,a,o=qt(i,r.href);return null==(s=t.conditions)||!s.url||Tr[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==Ct?void 0:Ct.location}static sa(t){var i;if(w(t.conditions)||w(null==(i=t.conditions)?void 0:i.utm))return!0;var e=Me();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 Xs(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];jt.info("[WebExperiments] "+t,e)}ea(t,i,e){this._is_bot()?Cr.Xs(Pr):"control"!==i?e.forEach((e=>{if(e.selector){var r;Cr.Xs("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)}))}})):Cr.Xs("Control variants leave the page unmodified.")}_is_bot(){return Rt&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&l(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>l(null==t?void 0:t.brand,i))))return!0}catch(t){}return!!t.webdriver}(Rt,this.Pe.custom_blocked_useragents):void 0}}var Ar=Lt("[Conversations]"),Rr="Conversations not available yet.",$r="console",Or="__posthogHandledLogsRequestError",Mr=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Or]=!0,e},Ir=t=>!!t&&"object"==typeof t&&!0===t[Or],jr={featureFlags:class{constructor(t){this.aa=!1,this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.va=!1,this.ca=!1,this.fa=0,this.pa=()=>{var t=this.ga();this.fa=0,t&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],Ct&&Ht(Ct,"online",this.pa)}destroy(){null==Ct||Ct.removeEventListener("online",this.pa)}get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}ma(t){return this._instance.get_property(t)}ya(){var t,i;return null!==(t=null==(i=this.Tr)?void 0:i._isFeatureFlagCacheStale(this.Pe.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ba(){return!!this.ya()&&(this.ca||this.la||(this.ca=!0,wr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_a(){var t,i=null!==(t=this.Pe.evaluation_contexts)&&void 0!==t?t:this.Pe.evaluation_environments;return!this.Pe.evaluation_environments||this.Pe.evaluation_contexts||this.va||(wr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.va=!0),null!=i&&i.length?i.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||wr.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}wa(){return this._a().length>0}xa(){var t=this.Pe.flag_keys;if(!m(t)){if(f(t))return t.filter((t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||wr.error("Invalid flag key found:",t,"Expected non-empty string"),i}));wr.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,i,e=this._instance.config,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)=>(a[i]&&(t[i]=a[i]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,i,r){var a,o,l=null!=r&&r.merge&&null!==(a=this.ma(Hi))&&void 0!==a?a:{},u=null!=r&&r.merge&&null!==(o=this.ma(Wi))&&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:m(null==v?void 0:v[f])?void 0:{id:0,version:void 0,description:void 0,payload:v[f]}}}this.receivedFeatureFlags({flags:d})}get hasLoadedFlags(){return this.oa}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.ma(Vi),i=this.ma(Gi),r=this.ma(Zi);if(!r&&!i)return t||{};var s=Nt({},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=m(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=m(h)?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.aa||(wr.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.aa=!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.ma(Hi),i=this.ma(Gi);if(!i)return t||{};for(var e=Nt({},t),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.aa||(wr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.aa=!0),e}getFlagPayloads(){var t=this.ma(Wi),i=this.ma(Zi);if(!i)return t||{};for(var e=Nt({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.aa||(wr.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.aa=!0),e}reloadFeatureFlags(){this.ua||this.Pe.advanced_disable_feature_flags||this.ga()||this.ka||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),this.ka=setTimeout((()=>{this.Sa()}),5))}Ca(){clearTimeout(this.ka),this.ka=void 0}ensureFlagsLoaded(){this.oa||this.la||this.ka||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ua=t}Sa(t){var i;if(this.Ca(),!this._instance._shouldDisableFlags()&&!this.ga())if(this.la)this.ha=!0;else{var r=this.Pe.token,s=this.ma("$device_id"),n={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:e({},(null==(i=this.Tr)?void 0:i.get_initial_props())||{},this.ma(Qi)||{},{$lib:Tt.LIB_NAME,$lib_version:Tt.LIB_VERSION}),group_properties:this.ma(Yi),timezone:Ie()};y(s)||m(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Pe.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.wa()&&(n.evaluation_contexts=this._a());var a=this.xa();m(a)||(n.flag_keys=a);var o=!!this.Pe.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Pe.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.la=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.Pe.disable_compression?void 0:rr,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback:t=>{var i,e,r,s=!0;if(this.Ma(t.statusCode),200===t.statusCode&&(this.ha||(this.$anon_distinct_id=void 0),s=!1),this.la=!1,!n.disable_flags||this.ha){this.da=!s;var a=[];t.error?t.error instanceof Error?a.push("AbortError"===t.error.name?"timeout":"connection_error"):a.push("unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),null!=(i=t.json)&&i.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(e=t.json)||null==(e=e.quotaLimited)||!e.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.Tr)||r.register({[oe]:a}),u)wr.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.");else n.disable_flags||this.receivedFeatureFlags(null!==(l=t.json)&&void 0!==l?l:{},s,{partialResponse:o}),this.ha&&(this.ha=!1,this.Sa())}}})}}ga(){return pe(this.fa,3)}Ma(t){this.fa=ge(t,this.fa,3,(()=>wr.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.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){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 wr.warn('getFeatureFlag for key "'+t+Sr)}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.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){var e=this.getFlagVariants(),s=t in e,n=e[t],a=this.getFlagPayloads()[t],o=String(n),l=this.ma(Ki)||void 0,u=this.ma(le)||void 0,h=this.ma(ne)||{};if(this.Pe.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.ma(ae);d&&d!==c&&(h={},null==(v=this.Tr)||v.register({[ne]:h,[ae]:d}))}if((i.send_event||!("send_event"in i))&&(!(t in h)||!h[t].includes(o))){var p,g,_,b,y,w,k,S,x,E,F;f(h[t])?h[t].push(o):h[t]=[o],null==(p=this.Tr)||p.register({[ne]:h});var P=this.getFeatureFlagDetails(t),T=[...null!==(g=this.ma(oe))&&void 0!==g?g:[]];m(n)&&T.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:a||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(null==(_=this.Pe.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(b=this.Pe.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])||null,$used_bootstrap_value:!this.da};m(null==P||null==(y=P.metadata)?void 0:y.has_experiment)||(C.$feature_flag_has_experiment=P.metadata.has_experiment),m(null==P||null==(w=P.metadata)?void 0:w.version)||(C.$feature_flag_version=P.metadata.version);var A,R=null!==(k=null==P||null==(S=P.reason)?void 0:S.description)&&void 0!==k?k:null==P||null==(x=P.reason)?void 0:x.code;R&&(C.$feature_flag_reason=R),null!=P&&null!=(E=P.metadata)&&E.id&&(C.$feature_flag_id=P.metadata.id),m(null==P?void 0:P.original_variant)&&m(null==P?void 0:P.original_enabled)||(C.$feature_flag_original_response=m(P.original_variant)?P.original_enabled:P.original_variant),null!=P&&null!=(F=P.metadata)&&F.original_payload&&(C.$feature_flag_original_payload=null==P||null==(A=P.metadata)?void 0:A.original_payload),T.length&&(C.$feature_flag_error=T.join(",")),this._instance.capture("$feature_flag_called",C)}if(s)return{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:r(a)}}}else wr.warn('getFeatureFlagResult for key "'+t+Sr)}getRemoteConfigPayload(t,i){var e=this.Pe.token,r={distinct_id:this._instance.get_distinct_id(),token:e,person_properties:{$lib:Tt.LIB_NAME,$lib_version:Tt.LIB_VERSION}};this.wa()&&(r.evaluation_contexts=this._a());var s=this.xa();m(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Pe.disable_compression?void 0:rr,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback(e){var r,s=null==(r=e.json)?void 0:r.featureFlagPayloads;i((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.da)return i.defaultValue;if(!(this.oa||this.getFlags()&&this.getFlags().length>0))return wr.warn('isFeatureEnabled for key "'+t+Sr),i.defaultValue;var e=this.getFeatureFlag(t,i);return m(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((i=>i!==t))}receivedFeatureFlags(t,i,r){if(this.Tr){this.oa=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,i,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var o=(t=>{var i=t.flags;return i?(t.featureFlags=Object.fromEntries(Object.keys(i).map((t=>{var e;return[t,null!==(e=i[t].variant)&&void 0!==e?e:i[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(i).filter((t=>i[t].enabled)).filter((t=>{var e;return null==(e=i[t].metadata)?void 0:e.payload})).map((t=>{var e;return[t,null==(e=i[t].metadata)?void 0:e.payload]})))):t.featureFlags&&wr.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),l=o.flags,u=o.featureFlags,h=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(f(u)){wr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var p=0;u.length>p;p++)c[u[p]]=!0;i&&i.register({[Bi]:u,[Hi]:c,[Ji]:!1})}else{var g=u,_=h,m=l;if(null!=a&&a.partialResponse)g=e({},r,g),_=e({},s,_),m=e({},n,m);else if(t.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter((t=>{var i;return!(null!=(i=l[t])&&i.failed)})));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]))))),m=e({},n,Object.fromEntries(Object.entries(m||{}).filter((t=>b.has(t[0])))))}else g=e({},r,g),_=e({},s,_),m=e({},n,m);i&&i.register(e({[Bi]:Object.keys(Er(g)),[Hi]:g||{},[Wi]:_||{},[Vi]:m||{},[Ji]:!0===t.minimalFlagCalledEvents},v?{[Ki]:v}:{},d?{[le]:d}:{}))}}}(t,this.Tr,s,n,a,r),i||(this.ca=!1),this.Ta(i)}}override(t,i){void 0===i&&(i=!1),wr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Tr)return wr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Tr.unregister(Gi),this.Tr.unregister(Zi),this.Ta(),kr.info("All overrides cleared");if(f(t)){var i=xr(t);return this.Tr.register({[Gi]:i}),this.Ta(),kr.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,r=t;if(this.aa=Boolean(null!==(e=r.suppressWarning)&&void 0!==e&&e),"flags"in r)if(!1===r.flags)this.Tr.unregister(Gi),kr.info("Flag overrides cleared");else if(r.flags){if(f(r.flags)){var s=xr(r.flags);this.Tr.register({[Gi]:s})}else this.Tr.register({[Gi]:r.flags});kr.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Tr.unregister(Zi),kr.info("Payload overrides cleared")):r.payloads&&(this.Tr.register({[Zi]:r.payloads}),kr.info("Payload overrides set",{payloads:r.payloads}))),void this.Ta()}if(t&&"object"==typeof t)return this.Tr.register({[Gi]:t}),this.Ta(),kr.info("Flag overrides set",{flags:t});wr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.oa){var i=this.Ea(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){wr.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var s,n=(this.ma(qi)||[]).find((i=>i.flagKey===t)),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=e({},this.getFlagVariants(),{[t]:i});null==(s=this.Tr)||s.register({[Bi]:Object.keys(Er(l)),[Hi]:l}),this.Ta()}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.ma(qi),s=e?"&"+e.map((t=>"stage="+t)).join("&"):"";if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Pe.token+s),method:"GET",timestampMode:"query",callback:i=>{var e,r;if(i.json){var s=i.json.earlyAccessFeatures;return null==(e=this.Tr)||e.unregister(qi),null==(r=this.Tr)||r.register({[qi]:s}),t(s)}}})}Ea(){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)),{})}}Ta(t){var i=this.Ea(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(e,r,{errorsLoading:t})}catch(t){wr.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.ma(Qi)||{},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._instance.register({[Qi]:e({},r,a,s)}),i&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.ma(Qi)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[Qi]:r}),i&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Qi),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.ma(Yi)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((i=>{r[i]=e({},r[i],t[i]),delete t[i]})),this._instance.register({[Yi]:e({},r,t)}),i&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.ma(Yi)||{};this._instance.register({[Yi]:e({},i,{[t]:{}})})}else this._instance.unregister(Yi)}reset(){this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.$anon_distinct_id=void 0,this.Ca(),this.aa=!1,this.fa=0}}},Lr={sessionRecording:class{get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Ia)||!t.isStarted)}get status(){var t,i;return this.Pa===He||this.Pa===Be?this.Pa:null!==(t=null==(i=this.Ia)?void 0:i.status)&&void 0!==t?t:this.Pa}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Pa=ze,this.Ra=void 0,this._instance=t,!this._instance.sessionManager)throw Ge.error("started without valid sessionManager"),new Error(Je+" started without valid sessionManager. This is a bug.");if("always"===this.Pe.cookieless_mode)throw new Error(Je+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get La(){var t,i=!(null==(t=this._instance.get_property(Ui))||!t.enabled),e=!this.Pe.disable_session_recording,r=this.Pe.disable_session_recording||this._instance.consent.isOptedOut();return Ct&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!this.La||null==(i=this.Ia)||!i.isStarted){var e=!m(Object.assign)&&!m(Array.from);this.La&&e?(this.Oa(t),Ge.info("starting")):(this.Pa=ze,this.stopRecording())}}Oa(t){var i,e,r;this.La&&(this.Pa!==He&&this.Pa!==Be&&(this.Pa=Ue),null!=Se&&null!=(i=Se.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=Se.__PosthogExtensions__)&&e.initSessionRecording?this.Fa(t):null==(r=Se.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Aa,(i=>{if(i)return Ge.error("could not load recorder",i);this.Fa(t)})))}stopRecording(){var t,i;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(i=this.Ia)||i.stop()}Da(){var t,i;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(i=this.Ia)||i.discard()}$a(){var t,i;null==(t=this.Tr)||t.unregister("$session_is_sampled"),null==(i=this.Tr)||i.unregister("$replay_sample_rate")}Na(t,i){if(w(t))return null;var e,r=k(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Ge.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}qa(t){if(this.Tr){var i,r,s=this.Tr,n=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Na(null==(i=this.Pe.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Na(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;w(o)&&this.$a();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[Ui]: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:m(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.Ra)||i.call(this),this.Ra=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.qa(i),void this.Da()):(this.qa(i),void this.startIfEnabledOrStop()):(this.Pa===He&&(this.Pa=Be,Ge.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.Ia)&&e.log?this.Ia.log(t,i):Ge.warn("log called before recorder was ready")}get Aa(){var t,i,e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Ui);return(null==e||null==(i=e.scriptConfig)?void 0:i.script)||"lazy-recorder"}ja(){var t,i,e=this._instance.get_property(Ui);if(!e)return!1;try{i="object"==typeof e?e:JSON.parse(e)}catch(t){return Ge.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=i.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Fa(t){var i,e;if(null==(i=Se.__PosthogExtensions__)||!i.initSessionRecording)return Ge.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.Ia||(this.Ia=null==(e=Se.__PosthogExtensions__)?void 0:e.initSessionRecording(this._instance),this.Ia._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ja()){if(this.Pa===Be||this.Pa===He)return;return this.Pa=He,Ge.info("persisted remote config is stale, requesting fresh config before starting"),void new Ne(this._instance).load()}this.Pa=Ue,this.Ia.start(t)}onRRwebEmit(t){var i;null==(i=this.Ia)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Ia||null==(i=this.Tr)||i.register({$replay_override_linked_flag:!0}),null==(t=this.Ia)||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.Ia||null==(i=this.Tr)||i.register({$replay_override_sampling:!0}),null==(t=this.Ia)||t.overrideSampling()}overrideTrigger(t){var i,e;this.Ia||null==(e=this.Tr)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Ia)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Ia)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Ia)||!e.tryAddCustomEvent(t,i))}}},Dr={autocapture:class{constructor(t){this.Ba=!1,this.Ha=null,this.Ua=!1,this.za=!1,this.instance=t,this.rageclicks=new $i(t.config.rageclick),this.Wa=null}initialize(){this.startIfEnabled()}get Pe(){var t,i,e=g(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=null==(t=e.url_allowlist)?void 0:t.map((t=>new RegExp(t))),e.url_ignorelist=null==(i=e.url_ignorelist)?void 0:i.map((t=>new RegExp(t))),e}Va(){if(this.isBrowserSupported()){if(Ct&&$t){var t=t=>{t=t||(null==Ct?void 0:Ct.event);try{this.Za(t)}catch(t){me.error("Failed to capture event",t)}};if(Ht($t,"submit",t,{capture:!0}),Ht($t,"change",t,{capture:!0}),Ht($t,"click",t,{capture:!0}),this.Pe.capture_copied_text){var i=t=>{t=t||(null==Ct?void 0:Ct.event);try{this.Za(t,_e)}catch(t){me.error("Failed to capture copy/cut event",t)}};Ht($t,"copy",i,{capture:!0}),Ht($t,"cut",i,{capture:!0})}}}else me.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ba&&(this.Va(),this.Ba=!0)}onRemoteConfig(t){if(this.Ua=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.za=i.elementsChainAsString);var e=i.autocapture_opt_out;S(e)&&(this.instance.persistence&&this.instance.persistence.register({[Oi]:e}),this.Ha=e),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.Wa=t}getElementSelectors(t){var i,e=[];return null==(i=this.Wa)||i.forEach((i=>{var r=null==$t?void 0:$t.querySelectorAll(i);null==r||r.forEach((r=>{t===r&&e.push(i)}))})),e}get isEnabled(){var t,i,e=null==(t=this.instance.persistence)?void 0:t.props[Oi],r=this.Ha,s=this.instance._shouldDisableFlags()&&!this.Ua;if(y(r)&&!S(e)&&!s)return!1;var n=null!==(i=this.Ha)&&void 0!==i?i:!!e;return!!this.instance.config.autocapture&&!n}Za(t,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var e,r=ai(t);Yt(r)&&(r=r.parentNode||null),"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(e=this.rageclicks)&&e.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&pi(r,this.instance.config.rageclick)&&this.Za(t,"$rageclick");var s=i===_e;if(r&&function(t,i,e,r,s,n){var a;if(!Ct||gi(t))return!1;if(null!=e&&e.url_allowlist&&!ei(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&ei(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=_i(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(m(e))return!0;var r,s=function(t){if(e.some((i=>t.tagName.toLowerCase()===i)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(h,e))return!1;if(!li(h,null==e?void 0:e.css_selector_allowlist))return!1;if(li(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:hi))return!1;try{var v=Ct.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&&(oi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Pe,s,s?["copy","cut"]:void 0,this.instance)){var n=we(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Pe.element_attribute_ignorelist,elementsChainAsString:this.za,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=n.props;if(n.explicitNoCapture)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(a.$element_selectors=o),i===_e){var l,u=si(null==Ct||null==(l=Ct.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=h}return this.instance.capture(i,a),!0}}}isBrowserSupported(){return p(null==$t?void 0:$t.querySelectorAll)}},historyAutocapture:class{constructor(t){var i;this._instance=t,this.Ga=(null==Ct||null==(i=Ct.location)?void 0:i.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(jt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Qa&&this.Qa(),this.Qa=void 0,jt.info("History API monitoring stopped")}monitorHistoryChanges(){Ct&&Ct.history&&(this.Ja("pushState"),this.Ja("replaceState"),this.Ka())}Ja(t){var i;if(Ct&&(null==(i=Ct.history[t])||!i.__posthog_wrapped__)){var e=this;!function(t,i,e){try{if(!(i in t))return Te;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 p(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];p(e)&&e.__posthog_layer__;){var n=e.__posthog_layer__;if(n.next===s)return void(n.next=r.next);e=n.next}else t[i]=r.next}}catch(t){return Te}}(Ct.history,t,(i=>function(r,s,n){i.call(this,r,s,n),e.Ya(t)}))}}Ya(t){try{var i,e=null==Ct||null==(i=Ct.location)?void 0:i.pathname;if(!e)return;e!==this.Ga&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.Ga=e}catch(i){jt.error("Error capturing "+t+" pageview",i)}}Ka(){if(!this.Qa){var t=()=>{this.Ya("popstate")};Ht(Ct,"popstate",t),this.Qa=()=>{Ct&&Ct.removeEventListener("popstate",t)}}}},heatmaps:class{get Pe(){return this.instance.config}constructor(t){var i;this.Xa=!1,this.Ba=!1,this.eo=null,this.instance=t,this.Xa=!(null==(i=this.instance.persistence)||!i.props[Mi]),this.rageclicks=new $i(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return g(this.Pe.capture_heatmaps)&&this.Pe.capture_heatmaps.flush_interval_milliseconds&&(t=this.Pe.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return w(this.Pe.capture_heatmaps)?w(this.Pe.enable_heatmaps)?this.Xa:this.Pe.enable_heatmaps:!1!==this.Pe.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ba)return;Ze.info("starting..."),this.io(),this.Ie()}else{var t;clearInterval(null!==(t=this.eo)&&void 0!==t?t:void 0),this.ro(),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({[Mi]:e}),this.Xa=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.O;return this.O=void 0,t}no(t){Qe(t.originalEvent)&&this.ke(t.originalEvent,"deadclick")}Ie(){this.eo&&clearInterval(this.eo),this.eo="visible"===(null==$t?void 0:$t.visibilityState)?setInterval(this.pr.bind(this),this.flushIntervalMilliseconds):null}io(){Ct&&$t&&(this.so=this.pr.bind(this),Ht(Ct,ve,this.so),this.ao=t=>this.ke(t||(null==Ct?void 0:Ct.event)),Ht($t,"click",this.ao,{capture:!0}),this.oo=t=>this.lo(t||(null==Ct?void 0:Ct.event)),Ht($t,"mousemove",this.oo,{capture:!0}),this.uo=new Fe(this.instance,Ee,this.no.bind(this)),this.uo.startIfEnabledOrStop(),this.ho=this.Ie.bind(this),Ht($t,he,this.ho),this.Ba=!0)}ro(){var t;Ct&&$t&&(this.so&&Ct.removeEventListener(ve,this.so),this.ao&&$t.removeEventListener("click",this.ao,{capture:!0}),this.oo&&$t.removeEventListener("mousemove",this.oo,{capture:!0}),this.ho&&$t.removeEventListener(he,this.ho),clearTimeout(this.do),null==(t=this.uo)||t.stop(),this.Ba=!1)}vo(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&&Zt(r)&&!Qt(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:Ct)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(u(i,s))return!0;r=ui(r)}return!1}(ai(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:e),target_fixed:n,type:i}}ke(t,i){var r;if(void 0===i&&(i="click"),!Gt(t.target)&&Qe(t)){var s=this.vo(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&pi(ai(t),this.instance.config.rageclick)&&this.Vt(e({},s,{type:"rageclick"})),this.Vt(s)}}lo(t){!Gt(t.target)&&Qe(t)&&(clearTimeout(this.do),this.do=setTimeout((()=>{this.Vt(this.vo(t,"mousemove"))}),500))}Vt(t){if(Ct){var i=this.Pe.disable_capture_url_hashes?R(Ct.location.href):Ct.location.href,e=this.Pe.custom_personal_data_properties,r=this.Pe.mask_personal_data_properties?[...Ae,...e||[]]:[],s=ce(i,r,$e);this.O=this.O||{},this.O[s]||(this.O[s]=[]),this.O[s].push(t)}}pr(){this.O&&!_(this.O)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Fe,webVitalsAutocapture:class{constructor(t){var i;this.Xa=!1,this.Ba=!1,this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.co=()=>{clearTimeout(this.fo),this.fo=void 0,0!==this.O.metrics.length&&(this._instance.capture("$web_vitals",e({$current_url:this.O.url},this.O.metrics.reduce(((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{}))),this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.po=t=>{var i;if(this.O=this.O||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},w(null==t?void 0:t.name)||w(null==t?void 0:t.value))je.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.mo(r);if(!m(s)){var n=k(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.yo||this.yo>t.value){this.O.navigationKey!==n&&(this.co(),this.fo=setTimeout(this.co,this.flushToCaptureTimeoutMs)),m(this.O.navigationKey)&&(this.O.navigationKey=n,this.O.url=s),this.O.firstMetricTimestamp=m(this.O.firstMetricTimestamp)?Date.now():this.O.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});m(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.O.metrics.push(o),this.O.metrics.length===this.allowedMetrics.length&&this.co()}else je.error("Ignoring metric with value >= "+this.yo,t)}}},this.bo=()=>{if(!this.Ba){var t,i,e,r,s=Se.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,a=(null==n?void 0:n[this._o])||("web-vitals"===this._o&&m(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(m(a)||(t=a.onLCP,i=a.onCLS,e=a.onFCP,r=a.onINP),t&&i&&e&&r){var o={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.po.bind(this),o),this.allowedMetrics.indexOf("CLS")>-1&&i(this.po.bind(this),o),this.allowedMetrics.indexOf("FCP")>-1&&e(this.po.bind(this),o),this.allowedMetrics.indexOf("INP")>-1&&r(this.po.bind(this),o),this.Ba=!0}else je.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Xa=!(null==(i=this._instance.persistence)||!i.props[Di]),this.startIfEnabled()}get wo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=g(this.wo)?null==(t=this.wo)?void 0:t.web_vitals_allowed_metrics:void 0;return w(e)?(null==(i=this._instance.persistence)?void 0:i.props[zi])||["CLS","FCP","INP","LCP"]:e}get flushToCaptureTimeoutMs(){return(g(this.wo)?this.wo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=g(this.wo)?this.wo.web_vitals_attribution:void 0;return null!=t&&t}get useSoftNavs(){var t=g(this.wo)?this.wo.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get yo(){var t=g(this.wo)&&k(this.wo.__web_vitals_max_value)?this.wo.__web_vitals_max_value:Le;return t>0&&6e4>=t?Le:t}get isEnabled(){var t=null==Ot?void 0:Ot.protocol;if("http:"!==t&&"https:"!==t)return je.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=g(this.wo)?this.wo.web_vitals:S(this.wo)?this.wo:void 0;return S(i)?i:this.Xa}startIfEnabled(){this.isEnabled&&!this.Ba&&(je.info("enabled, starting..."),this.ai(this.bo))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=g(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=g(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Di]:e}),this._instance.persistence.register({[zi]:r})),this.Xa=e,this.startIfEnabled()}}}get _o(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}ai(t){var i=Se.__PosthogExtensions__,e=this._o,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&m(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(i=>{i?je.error("failed to load script",i):t()}))}mo(t){var i=t||(null==Ct?void 0:Ct.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?R(i):i,r=this._instance.config.custom_personal_data_properties,s=this._instance.config.mask_personal_data_properties?[...Ae,...r||[]]:[];return ce(e,s,$e)}je.error("Could not determine current URL")}}},Nr={exceptionObserver:class{constructor(t){var i;this.bo=()=>{var t;if(Ct&&this.isEnabled&&null!=(t=Se.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=Se.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=Se.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Se.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.xo&&this.Pe.capture_unhandled_errors&&(this.xo=i(this.captureException.bind(this))),!this.ko&&this.Pe.capture_unhandled_rejections&&(this.ko=e(this.captureException.bind(this))),!this.So&&this.Pe.capture_console_errors&&(this.So=r(this.captureException.bind(this)))}catch(t){Pe.error("failed to start",t),this.Co()}}},this._instance=t,this.Mo=!(null==(i=this._instance.persistence)||!i.props[Ii]),this.To=new A(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,rt:Pe})),this.Pe=this.Eo(),this.startIfEnabledOrStop()}Eo(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return g(t)?i=e({},i,t):(m(t)?this.Mo:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Pe.capture_console_errors||this.Pe.capture_unhandled_errors||this.Pe.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Pe.info("enabled"),this.Co(),this.ai(this.bo)):this.Co()}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Pe.error("failed to load script",i);t()}))}Co(){var t,i,e;null==(t=this.xo)||t.call(this),this.xo=void 0,null==(i=this.ko)||i.call(this),this.ko=void 0,null==(e=this.So)||e.call(this),this.So=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Mo=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ii]:this.Mo}),this.Pe=this.Eo(),this.startIfEnabledOrStop())}}onConfigChange(){this.Pe=this.Eo()}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.To.consumeRateLimit(s)?Pe.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.Io=[],this.Po=new Y([new ht,new yt,new dt,new vt,new mt,new _t,new ft,new bt],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=ut.test(l)?l.replace(ut,"$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||X});var r}))}(n)}}("web:javascript",nt,lt)),this._instance=t,this.Io=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property(ji))&&void 0!==i?i:[],this.Ro=Et(this.Lo()),this.Oo=new Ft(this.Ro)}onConfigChange(){this.Ro=Et(this.Lo()),this.Oo.setConfig(this.Ro)}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.Io=n,this._instance.persistence&&this._instance.persistence.register({[ji]:this.Io,[Li]:a})}}}get Fo(){var t,i=!!this._instance.get_property(Li),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.Po.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.Ro.enabled)try{if(!b(t)||0===t.trim().length)return void Fr.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)=>St.has(r)?(i.push(r),e):(e[r]=t[r],e)),{}),droppedKeys:i}}(this.Ao(i)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&Fr.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Oo.add(e({[wt]:t,[kt]:(new Date).toISOString()},s))}catch(t){Fr.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.Do(i)){if(this.$o(i))return this.No("Exception dropped: matched a suppression rule"),void Fr.info("Skipping exception capture because a suppression rule matched");if(!this.Fo&&this.qo(i))return this.No("Exception dropped: thrown by a browser extension"),void Fr.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.jo(i))return this.No("Exception dropped: thrown by the PostHog SDK"),void Fr.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.Ro.enabled&&w(t.$exception_steps)?this.Bo(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.Oo.clear(),s}catch(t){return Fr.error("Failed to capture exception event. Dropping this exception.",t),void this.Oo.clear()}}catch(t){return void Fr.error("Failed to process exception event. Ignoring this exception.",t)}var n}Bo(t){try{var i=this.Oo.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(i){return Fr.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}No(t){this.Ro.enabled&&this.Oo.add({[wt]:t,[kt]:(new Date).toISOString()})}Ao(t){return g(t)?e({},t):{}}Lo(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}$o(t){if(0===t.length)return!1;try{var i=t.reduce(((t,i)=>{var e=i.type,r=i.value;return b(e)&&e.length>0&&t.$exception_types.push(e),b(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Io.some((t=>{var e=t.values.map((t=>{var e=Ve[t.operator],r=i[t.key];if(!e||!r)return!1;var s=f(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 Fr.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qo(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=>t.filename&&t.filename.startsWith("chrome-extension://")))}jo(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}Do(t){return!w(t)&&f(t)}}},zr=e({productTours:class{get Tr(){return this._instance.persistence}constructor(t){this.Ho=null,this.Uo=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.Tr&&this.Tr.register({[Ni]:!!i.productTours}),!Xe(this._instance))return!this.Ho&&w(null==(e=this.Tr)?void 0:e.props[se])||Ye.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Ho)||r.stop(),this.Ho=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Ho&&Xe(this._instance)&&this.ai((()=>this.zo()))}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",(i=>{i?Ye.error("Could not load product tours script",i):t()}))}zo(){var t;!this.Ho&&null!=(t=Se.__PosthogExtensions__)&&t.generateProductTours&&(this.Ho=Se.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!f(this.Uo)||i){var e=this.Tr;if(e){var r=e.props[se];if(f(r)&&!i)return this.Uo=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(Xe(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||Ye.warn(s):Ye.error(s),void t([],{isLoaded:!1,error:s})}var n=f(i.json.product_tours)?i.json.product_tours:[];this.Uo=n,e&&e.register({[se]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Uo,{isLoaded:!0})}getActiveProductTours(t){w(this.Ho)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ho.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.Ho)||i.showTourById(t)}previewTour(t){this.Ho?this.Ho.previewTour(t):this.ai((()=>{var i;this.zo(),null==(i=this.Ho)||i.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Ho)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Ho)||t.nextStep()}previousStep(){var t;null==(t=this.Ho)||t.previousStep()}clearCache(){var t;this.Uo=null,null==(t=this.Tr)||t.unregister(se)}resetTour(t){var i;null==(i=this.Ho)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.Ho)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.Ho)||i.cancelPendingTour(t)}}},jr),Ur={siteApps:class{constructor(t){this.Wo=0,this._instance=t,this.Vo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zo(t,i){if(i){var e=this.globalsForEvent(i);this.Vo.push(e),this.Vo.length>1e3&&(this.Vo=this.Vo.slice(10))}}get siteAppLoaders(){var t;return null==(t=Se._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Zo.bind(this));this.Go=()=>{t(),this.Vo=[],this.Go=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,tr),{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}}Qo(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)||(ir.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)||(ir.error("prepare_external_dependency_script returned null"),null):t}Jo(){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==$t?void 0:$t.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Wo++,this.Ko)return this.Yo();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.Qo(t);return i&&d.add(i),i},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!y(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.Ko=()=>{h.forEach((t=>t())),this.Ko=void 0},this.Yo()}Yo(){var t=!1;return()=>{var i;t||(t=!0,this.Wo--,0===this.Wo&&(null==(i=this.Ko)||i.call(this)))}}Xo(t,i){void 0===i&&(i=!0);var e=this.Jo();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.Vo.length&&(ir.info("Processing "+this.Vo.length+" events for site app with id "+t.id),this.Vo.forEach((t=>this.Xo((()=>null==i.processEvent?void 0:i.processEvent(t))))),i.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(e=this.Go)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,ir.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.Xo((i=>t.init({posthog:this._instance,callback(t){i(),s(t)}})),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){ir.error(er+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){ir.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}tl(){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)}el(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.Xo((()=>null==r.processEvent?void 0:r.processEvent(e)))}catch(i){ir.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.tl(),void this._instance.on("eventCaptured",(t=>this.el(t)))):void ir.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Go)||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;Se["__$$ph_site_app_"+i]=s._instance,null==(t=Se.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,(t=>{if(t)return ir.error(er+i,t)}))};for(var o of n.siteApps)a()}else ir.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Hr={tracingHeaders:class{constructor(t){this.il=void 0,this.rl=void 0,this.nl=void 0,this.bo=()=>{var t,i,e=this.sl();e?(m(this.il)&&(this.il=null==(t=Se.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),m(this.rl)&&(this.rl=null==(i=Se.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Co()},this._instance=t}initialize(){this.startIfEnabledOrStop()}ai(t){var i,e;null!=(i=Se.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=Se.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return Ce.error("failed to load script",i);t()}))}al(){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}sl(){var t=this.al();return f(t)?(f(this.nl)?this.nl.splice(0,this.nl.length,...t):this.nl=[...t],t.length>0?this.nl:void 0):(f(this.nl)&&this.nl.splice(0),this.nl=t||void 0,this.nl)}Co(){var t,i;null==(t=this.il)||t.call(this),null==(i=this.rl)||i.call(this),this.il=void 0,this.rl=void 0}startIfEnabledOrStop(){this.sl()?this.ai(this.bo):this.Co()}}},Br=e({surveys:class{get Pe(){return this._instance.config}constructor(t){this.ol=void 0,this._surveyManager=null,this.ll=!1,this.ul=[],this.hl=null,this.dl=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Pe.disable_surveys){if(!t.ok)return lr.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(w(i))return lr.warn("Flags not loaded yet. Not loading surveys.");var e=f(i);this.ol=e?i.length>0:i,lr.info("flags response received, isSurveysEnabled: "+this.ol),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(ur)||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.ll)lr.info("Already initializing surveys, skipping...");else if(this.Pe.disable_surveys)lr.info(_r);else if(this.Pe.cookieless_mode&&this._instance.consent.isOptedOut())lr.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Se?void 0:Se.__PosthogExtensions__;if(t){if(!m(this.ol)||this.Pe.advanced_enable_surveys){var i=this.ol||this.Pe.advanced_enable_surveys;this.ll=!0;try{var e=t.generateSurveys;if(e)return void this.vl(e,i);var r=t.loadExternalDependency;if(!r)return void this.cl(ue);r(this._instance,"surveys",(e=>{e||!t.generateSurveys?this.cl("Could not load surveys script",e):this.vl(t.generateSurveys,i)}))}catch(t){throw this.cl("Error initializing surveys",t),t}finally{this.ll=!1}}}else lr.error("PostHog Extensions not found.")}}vl(t,i){this._surveyManager=t(this._instance,i),this._surveyEventReceiver=new pr(this._instance),lr.info("Surveys loaded successfully"),this.fl({isLoaded:!0})}cl(t,i){lr.error(t,i),this.fl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.ul.push(t),this._surveyManager&&this.fl({isLoaded:!0}),()=>{this.ul=this.ul.filter((i=>i!==t))}}getSurveys(t,i){if(void 0===i&&(i=!1),this.Pe.disable_surveys)return lr.info(_r),t([]);var e,r=this._instance.get_property(Xi);if(r&&!i)return t(r,{isLoaded:!0}),void(this.pl()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.hl?this.hl.then((i=>t(i.surveys,i.context))):("undefined"!=typeof Promise&&(this.hl=new Promise((t=>{e=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Pe.token),method:"GET",timestampMode:"query",timeout:this.Pe.surveys_request_timeout_ms,callback:i=>{var r;this.hl=null;var s=i.statusCode;if(200!==s||!i.json){var n="Surveys API could not be loaded, status: "+s;0!==s?lr.error(n):i.error||lr.warn(n),this.dl=Date.now();var a={isLoaded:!1,error:n};return t([],a),void(null==e||e({surveys:[],context:a}))}this.dl=null;var o,l=i.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(or(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t))));u.length>0&&(null==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[Xi]:l,[te]:Date.now()});var h={isLoaded:!0};t(l,h),null==e||e({surveys:l,context:h})}}))}pl(){return this.gl()&&!this.hl&&!this.ml()}gl(){var t=this._instance.get_property(te);return k(t)&&Date.now()-t>3e5}ml(){return k(this.dl)&&3e5>Date.now()-this.dl}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>""+ur+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){lr.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){}}fl(t){for(var i of this.ul)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){lr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!w(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);lr.warn("init was not called")}yl(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}bl(t){if(w(this._surveyManager))return{eligible:!1,reason:gr};var i="string"==typeof t?this.yl(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}_l(t){if(w(this._surveyManager))return{eligible:!1,reason:gr};var i="string"==typeof t?this.yl(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(w(this._surveyManager))return lr.warn("init was not called"),{visible:!1,disabledReason:gr};var i=this._l(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return w(this._surveyManager)?(lr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:gr})):new Promise((e=>{this.getSurveys((i=>{var r,s=null!==(r=i.find((i=>i.id===t)))&&void 0!==r?r:null;if(s){var n=this._l(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})}),i)}))}renderSurvey(t,i,e){var r;if(w(this._surveyManager))lr.warn("init was not called");else{var s="string"==typeof t?this.yl(t):t;if(null!=s&&s.id)if(hr.includes(s.type)){var n=null==$t?void 0:$t.querySelector(i);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(lr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,i;lr.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),lr.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,e);lr.warn("Survey element not found")}else lr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else lr.warn("Survey not found")}}displaySurvey(t,i){var r;if(w(this._surveyManager))lr.warn("init was not called");else{var s=this.yl(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&&lr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var a=this.bl(s);if(!a.eligible)return void lr.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 lr.warn("Survey not found")}}cancelPendingSurvey(t){w(this._surveyManager)?lr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}},jr),qr={toolbar:class{constructor(t){this.instance=t}wl(t){Se.ph_toolbar_state=t}xl(){var t;return null!==(t=Se.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),Bt(this.instance.config))return!1;if(!Ct||!$t)return!1;t=null!=t?t:Ct.location,e=null!=e?e:Ct.history;try{if(!i){try{Ct.localStorage.setItem("test","test"),Ct.localStorage.removeItem("test")}catch(t){return!1}i=null==Ct?void 0:Ct.localStorage}var r,s=mr||fe(t.hash,"__posthog")||fe(t.hash,"state"),n=s?Ut((()=>JSON.parse(atob(decodeURIComponent(s)))))||Ut((()=>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(br)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}kl(t){var i=Se.ph_load_toolbar||Se.ph_load_editor;!w(i)&&p(i)?i(t,this.instance):yr.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==$t||!$t.getElementById(Vt));if(!Ct||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(Ct.localStorage.setItem(br,JSON.stringify(e({},s,{source:void 0}))),2===this.xl())this.kl(s);else if(0===this.xl()){var n;this.wl(1),null==(n=Se.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return yr.error("[Toolbar] Failed to load",t),void this.wl(0);this.wl(2),this.kl(s)})),Ht(Ct,"turbolinks:load",(()=>{this.wl(0),this.loadToolbar(s)}))}return!0}Sl(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)}}},Vr=e({experiments:Cr},jr),Wr={conversations:class{constructor(t){this.Cl=void 0,this._conversationsManager=null,this.Ml=!1,this.Tl=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&t.ok){var i=t.config.conversations;w(i)||(S(i)?this.Cl=i:(this.Cl=i.enabled,this.Tl=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Cl=void 0,this.Tl=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ml||this._instance.config.disable_conversations||Bt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Se?void 0:Se.__PosthogExtensions__;if(t&&!m(this.Cl)&&this.Cl)if(this.Tl&&this.Tl.token){this.Ml=!0;try{var i=t.initConversations;if(i)return this.El(i),void(this.Ml=!1);var e=t.loadExternalDependency;if(!e)return void this.Il(ue);e(this._instance,"conversations",(i=>{i||!t.initConversations?this.Il("Could not load conversations script",i):this.El(t.initConversations),this.Ml=!1}))}catch(t){this.Il("Error initializing conversations",t),this.Ml=!1}}else Ar.error("Conversations enabled but missing token in remote config.")}}El(t){if(this.Tl)try{this._conversationsManager=t(this.Tl,this._instance),Ar.info("Conversations loaded successfully")}catch(t){this.Il("Error completing conversations initialization",t)}else Ar.error("Cannot complete initialization: remote config is null")}Il(t,i){Ar.error(t,i),this._conversationsManager=null,this.Ml=!1}show(){this._conversationsManager?this._conversationsManager.show():Ar.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Cl&&!y(this._conversationsManager)}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):(Ar.warn(Rr),null)}))()}getMessages(t,e){var r=this;return i((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,e):(Ar.warn(Rr),null)}))()}markAsRead(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Ar.warn(Rr),null)}))()}getTickets(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Ar.warn(Rr),null)}))()}requestRestoreLink(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Ar.warn(Rr),null)}))()}restoreFromToken(t){var e=this;return i((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Ar.warn(Rr),null)}))()}restoreFromUrlToken(){var t=this;return i((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ar.warn(Rr),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()}}},Kr={logs:class{constructor(t){var i,r=this;this.Pl=!1,this.Rl=!1,this.rt=Lt("[logs]"),this.Ll=e({},this.rt,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(Ir)||r.rt.error(...i)}}),this.er=[],this.Ol=[],this.fa=0,this.Fl=()=>{var t,i;this.fa=0,null==(t=this.Al)||t.onReconnect(),null==(i=this.Dl)||i.onReconnect()},this._instance=t,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Pl=!0),Ct&&Ht(Ct,"online",this.Fl)}$l(t,i,e,r){var s,n=function(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=m(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}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new B(this.Nl(t,i),n,this.Ll,(()=>this.ql()),(t=>t()),void 0,r),n]}jl(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Al||this.Bl!==i){var e;null==(e=this.Al)||e.reset(),this.Bl=i;var r=this.$l((()=>this.er),(t=>{this.er=t}));this.Al=r[0],this.Hl=r[1]}return this.Al}Ul(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Dl||this.zl!==i){var e;null==(e=this.Dl)||e.reset(),this.zl=i;var r=this.$l((()=>this.Ol),(t=>{this.Ol=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},$r);this.Dl=r[0],this.Wl=r[1]}return this.Dl}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var i;if(t.ok){var e=null==(i=t.config.logs)?void 0:i.captureConsoleLogs;!w(e)&&e&&(this.Pl=!0,this.loadIfEnabled())}}reset(){var t,i;this.er=[],null==(t=this.Al)||t.reset(),this.Ol=[],null==(i=this.Dl)||i.reset(),this.fa=0}captureLog(t){this.jl().captureLog(t)}he(t){this.Ul().captureLog(t)}get logger(){return this.Vl||(this.Vl={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.Vl}flushLogs(t){t?this.Zl(t):(this.Al&&this.Al.flush().catch((t=>this.Gl(t))),this.Dl&&this.Dl.flush().catch((t=>this.Gl(t))))}Gl(t){Ir(t)||this.rt.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.Pl&&!this.Rl){var t=null==Se?void 0:Se.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",(i=>{var e;i||null==(e=t.logs)||!e.initializeLogs?this.rt.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Rl=!0)})):this.rt.error(ue)}else this.rt.error("PostHog Extensions not found.")}}Nl(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:[])},At:t=>this.At(t),getLibraryId:()=>Tt.LIB_NAME,getLibraryVersion:()=>Tt.LIB_VERSION}}At(t){return new Promise((i=>{if(pe(this.fa,3))i({kind:"fatal",error:Mr(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout((()=>{this.rt.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Mr(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Ql(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.Jl(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==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.rt.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Mr(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)})}}})}}))}Jl(t){(0!==t||this._instance.__loaded)&&(this.fa=ge(t,this.fa,3,(()=>this.rt.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."))))}Zl(t){this.er.length>0&&this.Kl(t,this.er,this.Hl,Tt.LIB_NAME,(t=>{this.er=t})),this.Ol.length>0&&this.Kl(t,this.Ol,this.Wl,$r,(t=>{this.Ol=t}))}Kl(t,i,e,r,s){if(0!==i.length){var n=i.map((t=>t.record));s([]);var a=H(n,U(e,Tt.LIB_NAME,Tt.LIB_VERSION),r,Tt.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Ql(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}Ql(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}ql(){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,w(s)||(i.sessionStartTimestamp=s),w(n)||(i.lastActivityTimestamp=n)}if(null!=Se&&null!=(t=Se.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?R(Se.location.href):Se.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Jr={metrics:class{constructor(t){this.rt=Lt("[metrics]"),this._instance=t}initialize(){}jl(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Al&&this.Bl===e||(null==(i=this.Al)||i.reset(),this.Bl=e,this.Al=new K(this.Nl(),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.rt)),this.Al}count(t,i,e){void 0===i&&(i=1),this.jl().count(t,i,e)}gauge(t,i,e){this.jl().gauge(t,i,e)}histogram(t,i,e){this.jl().histogram(t,i,e)}flush(t){if(!this.Al)return Promise.resolve();if(t){var i=this.Al.drainWindow();return i&&this.Kt(i,t),Promise.resolve()}return this.Al.flush().catch((t=>this.rt.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Al)||t.reset()}Nl(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Kt:t=>i.Kt(t),getLibraryId:()=>Tt.LIB_NAME,getLibraryVersion:()=>Tt.LIB_VERSION}}Kt(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.Yl(),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&&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)})}}}))}))}Yl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Gr=e({},jr,Lr,Dr,Nr,zr,Ur,Br,Hr,qr,Vr,Wr,Kr,Jr),Zr=jr,Qr=Lr,Yr=Dr,Xr=Nr,ts=zr,is=Ur,es=Br,rs=Hr,ss=qr,ns=Vr,as=Wr,os=Kr,ls=Jr;export{Gr as AllExtensions,Yr as AnalyticsExtensions,as as ConversationsExtensions,Xr as ErrorTrackingExtensions,ns as ExperimentsExtensions,Zr as FeatureFlagsExtensions,os as LogsExtensions,ls as MetricsExtensions,ts as ProductToursExtensions,Qr as SessionReplayExtensions,is as SiteAppsExtensions,es as SurveysExtensions,ss as ToolbarExtensions,rs as TracingExtensions};
|
|
2
2
|
//# sourceMappingURL=extension-bundles.js.map
|