posthog-js 1.391.7 → 1.391.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/array.full.es5.js +1 -1
  2. package/dist/array.full.js +1 -1
  3. package/dist/array.full.no-external.js +1 -1
  4. package/dist/array.js +1 -1
  5. package/dist/array.no-external.js +1 -1
  6. package/dist/customizations.full.js +1 -1
  7. package/dist/default-extensions.js +1 -1
  8. package/dist/extension-bundles.js +1 -1
  9. package/dist/lazy-recorder.js +1 -1
  10. package/dist/main.js +1 -1
  11. package/dist/module.full.js +1 -1
  12. package/dist/module.full.no-external.js +1 -1
  13. package/dist/module.js +1 -1
  14. package/dist/module.no-external.js +1 -1
  15. package/dist/module.slim.js +1 -1
  16. package/dist/module.slim.no-external.js +1 -1
  17. package/dist/posthog-recorder.js +1 -1
  18. package/dist/product-tours-preview.d.ts +4576 -3
  19. package/dist/product-tours-preview.js +1 -1
  20. package/dist/product-tours-preview.js.map +1 -1
  21. package/dist/product-tours.js +1 -1
  22. package/dist/product-tours.js.map +1 -1
  23. package/dist/src/extensions/product-tours/preview.d.ts +3 -1
  24. package/dist/src/extensions/product-tours/product-tours-utils.d.ts +2 -1
  25. package/lib/package.json +1 -1
  26. package/lib/src/extensions/product-tours/preview.d.ts +3 -1
  27. package/lib/src/extensions/product-tours/preview.js +2 -2
  28. package/lib/src/extensions/product-tours/preview.js.map +1 -1
  29. package/lib/src/extensions/product-tours/product-tours-utils.d.ts +2 -1
  30. package/lib/src/extensions/product-tours/product-tours-utils.js +2 -2
  31. package/lib/src/extensions/product-tours/product-tours-utils.js.map +1 -1
  32. package/lib/src/extensions/product-tours/product-tours.js +6 -6
  33. package/lib/src/extensions/product-tours/product-tours.js.map +1 -1
  34. package/package.json +4 -4
  35. package/react/dist/esm/index.js +9 -1
  36. package/react/dist/esm/index.js.map +1 -1
  37. package/react/dist/esm/slim/index.js +9 -1
  38. package/react/dist/esm/slim/index.js.map +1 -1
  39. package/react/dist/umd/index.js +9 -1
  40. package/react/dist/umd/index.js.map +1 -1
  41. package/react/dist/umd/slim/index.js +9 -1
  42. package/react/dist/umd/slim/index.js.map +1 -1
@@ -1,2 +1,2 @@
1
- function t(t,e,i,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,s)}function e(e){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=e.apply(i,r);function o(e){t(a,s,n,o,l,"next",e)}function l(e){t(a,s,n,o,l,"throw",e)}o(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},i.apply(null,arguments)}var r="1.391.7",s="web",n=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function a(t){return"string"==typeof t||t}function o(t){return"string"==typeof t?t:void 0}var l=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.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.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}({}),u=["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"],h=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return u.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function v(t,e){return-1!==t.indexOf(e)}var d=function(t){return t.trim()},c=Object.prototype,f=c.hasOwnProperty,p=c.toString,g=Array.isArray||function(t){return"[object Array]"===p.call(t)},_=t=>"function"==typeof t,m=t=>t===Object(t)&&!g(t),b=t=>void 0===t,y=t=>"[object String]"==p.call(t),w=t=>null===t,x=t=>b(t)||w(t),E=t=>"[object Number]"==p.call(t)&&t==t,k=t=>"[object Boolean]"===p.call(t),S=t=>t instanceof FormData;function F(t){return null===t||"object"!=typeof t}function P(t,e){return{}.toString.call(t)==="[object "+e+"]"}function C(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function R(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),E(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),R(i,e,i,r))}class I{constructor(t){this.$t={},this.Gt=t.Gt,this.Zt=R(t.bucketSize,0,100,t.Qt),this.Jt=R(t.refillRate,0,this.Zt,t.Qt),this.Kt=R(t.refillInterval,0,864e5,t.Qt)}Yt(t,e){var i=Math.floor((e-t.lastAccess)/this.Kt);i>0&&(t.tokens=Math.min(t.tokens+i*this.Jt,this.Zt),t.lastAccess=t.lastAccess+i*this.Kt)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.$t[r];return s?this.Yt(s,i):this.$t[r]=s={tokens:this.Zt,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.Gt)||e.call(this,t)),0===s.tokens)}stop(){this.$t={}}}function A(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var T={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}},O=T.info;function M(t){if(k(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(g(t))return{arrayValue:{values:t.map((t=>M(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function j(t){var e=[];for(var i in t){var r=t[i];w(r)||b(r)||e.push({key:i,value:M(r)})}return e}function L(t,e){var r=t.level||"info",{text:s,number:n}=T[r]||O,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var l=i({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:j(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),b(t.trace_flags)||(u.flags=t.trace_flags),u}function D(t,e,r){return i({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}function N(t,e,i,r){return{resourceLogs:[{resource:{attributes:j(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let z=class{constructor(t,e,i,r,s,n){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Dt=e,this.Qt=i,this.Xt=r,this.er=s,this.tr=n,this.rr=null,this.ir=0,this.nr=0,this.sr=0,this.ar=0,this.lr=!1,this.ur=e.maxBufferSize,this.ot=Math.max(null!==(a=e.maxQueueSize)&&void 0!==a?a:e.maxBufferSize,e.maxBufferSize),this.hr=e.flushIntervalMs,this.cr=e.maxBatchRecordsPerPost,this.dr=e.rateCapWindowMs,this.vr=e.maxLogsPerInterval}reset(){this.pr(),this.rr=null,this.sr=0,this.ar=0,this.lr=!1,this.ir=0,this.nr=0,this.cr=this.Dt.maxBatchRecordsPerPost}onReconnect(){this.nr=0,this.gr()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this.mr(t);if(null!==e)if(e.body){if(this.yr()){var i={record:L(e,this.Xt())};this.er((()=>this.br(i)))}}else this.Qt.info("Log was rejected in beforeSend function")}}mr(t){var e=this.Dt.beforeSend;if(!e)return t;var i=g(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.Qt.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.Qt.error("Error in beforeSend function for log:",t),null}return r}yr(){if(void 0===this.vr)return!0;var t=Date.now(),e=t-this.sr;return this.dr>e&&e>=0||(this.sr=t,this.ar=0,this.lr=!1),this.vr>this.ar?(this.ar++,!0):(this.lr||(this.Qt.warn("captureLog dropping logs: exceeded "+this.vr+" logs per "+this.dr+"ms"),this.lr=!0),!1)}flush(){var t=this;return e((function*(){if(!t._instance.isDisabled)return t.rr||(t.rr=t._r().finally((()=>{t.rr=null}))),t.rr}))()}_r(){var t=this;return e((function*(){var e;t.pr();var i=null!==(e=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n;t.ir=0;var a=Math.min(i.length,t.cr),o=i.slice(0,a),u=N(o.map((t=>t.record)),t.wr(),t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.kr(u);if("too-large"===h.kind&&o.length>1)t.cr=Math.max(1,Math.floor(o.length/2)),t.Qt.warn("Received 413 when sending logs batch of size "+o.length+", reducing batch size to "+t.cr);else{if("retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.Qt.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"===h.kind&&t.Dt.maxBatchRecordsPerPost>t.cr&&(t.cr=Math.min(t.Dt.maxBatchRecordsPerPost,t.cr+1)),yield t.Sr(o.length),i=null!==(n=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==n?n:[],s+=o.length,"fatal"===h.kind)throw h.error}}}))()}Sr(t){var i=this;return e((function*(){var e,r=Math.max(0,t-i.ir),s=null!==(e=i._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(l.LogsQueue,s.slice(r)),yield i.tr()}))()}wr(){return D(this.Dt,this._instance.getLibraryId(),this._instance.getLibraryVersion())}br(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];this.ot>i.length||(i.shift(),this.ir++,this.Qt.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(l.LogsQueue,i),this.ur>i.length?this.Cr():this.gr()}}Cr(t){void 0===t&&(t=this.hr),this.Ir||(this.Ir=A((()=>{this.Ir=void 0,this.gr()}),t))}Tr(){var t=Math.min(Math.max(0,this.nr-1),6);return this.hr*Math.pow(2,t)}Er(){var t=this._instance.getPersistedProperty(l.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return e((function*(){i.pr();var e=i.flush().catch((()=>{}));void 0!==t?yield Promise.race([e,new Promise((e=>A(e,t)))]):yield e}))()}flushWithTimeout(t){var i=this;return e((function*(){var e=!1,r=i.flush(),s=new Promise((i=>A((()=>{e=!0,i()}),t)));try{yield Promise.race([r,s])}finally{e&&r.catch((()=>{}))}}))()}gr(){this.flush().then((()=>{this.nr=0}),(t=>{this.nr++,this.Qt.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.Er()&&this.Cr(this.Tr())}))}pr(){this.Ir&&(clearTimeout(this.Ir),this.Ir=void 0)}};var U,H,V;function B(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return V&&i.length===H?V:(H=i.length,V=i.reduce(((i,r)=>{U||(U={});var s=U[r];if(s)i[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=e[r];if(l&&u){i[l]=u,U[r]=[l,u];break}}return i}),{}))}}class W{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var i=this;return e((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&g(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var i=this;return e((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.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,i({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:B(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var q="?";function J(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?q:i,in_app:!0};return b(r)||(n.lineno=r),b(s)||(n.colno=s),n}var K=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:q,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},G=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Y=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Q=/\((\S*)(?::(\d+))(?::(\d+))\)/,X=(t,e)=>{var i=G.exec(t);if(i){var[,r,s,n]=i;return J(e,r,q,+s,+n)}var a=Y.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=Q.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=K(a[1]||q,a[2]);return J(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},Z=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,tt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,et=(t,e)=>{var i=Z.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=tt.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||q;return[n,s]=K(n,s),J(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},it=/\(error: (.*)\)/;class rt{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=y(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return P(t,"DOMException")}isDOMError(t){return P(t,"DOMError")}}class st{match(t){return t instanceof Error}coerce(t,e){return{type:this.getType(t),value:this.getMessage(t,e),stack:this.getStack(t),cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class nt{constructor(){}match(t){return P(t,"ErrorEvent")&&null!=t.error}coerce(t,e){var i;return e.apply(t.error)||{type:"ErrorEvent",value:t.message,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}var at=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ot{match(t){return"string"==typeof t}coerce(t,e){var i,[r,s]=this.getInfos(t);return{type:null!=r?r:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(at);return r&&(e=r[1],i=r[2]),[e,i]}}var lt=["fatal","error","warning","log","info","debug"];function ut(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class ht{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:null==(i=e.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return C(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ut(t)}isSeverityLevel(t){return y(t)&&!(t=>y(t)&&0===t.trim().length)(t)&&lt.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(i instanceof Error)return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class vt{match(t){return C(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ut(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class dt{match(t){return F(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ct{match(t){return P(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!C(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return F(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.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 ft="$message",pt="$timestamp",gt=new Set([ft,pt]),_t={enabled:!0,max_bytes:32768};function mt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:_t.enabled,max_bytes:yt(t.max_bytes,_t.max_bytes)}:i({},_t)}class bt{constructor(t){this.Mr=[],this.Rr=0,this.Dt=mt(t)}setConfig(t){this.Dt=mt(t),this.Pr()}add(t){var e=function(t){var e=function(t){var e=new WeakSet;try{return JSON.stringify(t,((t,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(e.has(i))return"[Circular]";e.add(i)}return i}}))}catch(t){return}}(t);if(e)try{var i=JSON.parse(e);if(!m(i))return;var r=i,s=r[ft],n=r[pt];if(!y(s)||0===s.trim().length)return;if(!y(n)&&!E(n))return;return{step:r,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Dt.max_bytes||(this.Mr.push({step:e.step,bytes:i}),this.Rr+=i,this.Pr())}}getAttachable(){return this.Mr.map((t=>t.step))}clear(){this.Mr=[],this.Rr=0}size(){return this.Mr.length}Pr(){for(;this.Rr>this.Dt.max_bytes&&this.Mr.length>0;){var t=this.Mr.shift();t&&(this.Rr-=t.bytes)}}}function yt(t,e){if(!E(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var wt="undefined"!=typeof window?window:void 0,xt="undefined"!=typeof globalThis?globalThis:wt;"undefined"==typeof self&&(xt.self=xt),"undefined"==typeof File&&(xt.File=function(){});var Et=null==xt?void 0:xt.navigator,kt=null==xt?void 0:xt.document,St=null==xt?void 0:xt.location;null!=xt&&xt.XMLHttpRequest&&new xt.XMLHttpRequest;var Ft=null!=wt?wt:{},Pt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(wt&&(Ft.POSTHOG_DEBUG||i)&&!b(wt.console)&&wt.console){for(var r=("__rrweb_original__"in wt.console[e]?wt.console[e].__rrweb_original__:wt.console[e]),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,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>Pt(t+" "+e,i)};return r},Ct=Pt("[PostHog.js]"),Rt=Ct.createLogger;function $t(t,e){if(!x(t))if(g(t))t.forEach(e);else if(S(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)f.call(t,i)&&e(t[i],i)}var It=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function At(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var Tt=function(t){try{return t()}catch(t){return}};function Ot(t,e,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==t||t.addEventListener(e,i,{capture:s,passive:n})}function Mt(t){return"ph_toolbar_internal"===t.name}var jt="$autocapture_disabled_server_side",Lt="$heatmaps_enabled_server_side",Dt="$exception_capture_enabled_server_side",Nt="$error_tracking_suppression_rules",zt="$error_tracking_capture_extension_exceptions",Ut="$web_vitals_enabled_server_side",Ht="$product_tours_enabled_server_side",Vt="$web_vitals_allowed_metrics",Bt="$session_recording_remote_config",Wt="$enabled_feature_flags",qt="$active_feature_flags",Jt="$early_access_features",Kt="$feature_flag_details",Gt="$feature_flag_payloads",Yt="$feature_flag_request_id",Qt="$override_feature_flags",Xt="$override_feature_flag_payloads",Zt="$stored_person_properties",te="$stored_group_properties",ee="$surveys",ie="$surveys_activated",re="ph_product_tours",se="$flag_call_reported",ne="$flag_call_reported_session_id",ae="$feature_flag_errors",oe="$feature_flag_evaluated_at",le="__POSTHOG_TOOLBAR__",ue="PostHog loadExternalDependency extension not found.",he="visibilitychange",ve="beforeunload",de=1,ce=3,fe=11;function pe(t){return t instanceof Element&&(t.id===le||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ge(t){return!!t&&t.nodeType===de}function _e(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function me(t){return!!t&&t.nodeType===ce}function be(t){return!!t&&t.nodeType===fe&&ge(t.host)}function ye(t){return t?d(t).split(/\s+/):[]}function we(t){var e=null==wt?void 0:wt.location.href;return!!(e&&t&&t.some((t=>e.match(t))))}function xe(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return ye(e)}function Ee(t){return x(t)?null:d(t).split(/(\s+)/).filter((t=>We(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ke(t){var e="";return Le(t)&&!De(t)&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;me(t)&&t.textContent&&(e+=null!==(i=Ee(t.textContent))&&void 0!==i?i:"")})),d(e)}function Se(t){return b(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Fe=["a","button","form","input","select","textarea","label"];function Pe(t,e){if(b(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function Ce(t){var e=t.parentNode;return!(!e||!ge(e))&&e}var Re=[".ph-no-autocapture","[data-ph-no-autocapture]"],$e=["next","previous","prev",">","<"],Ie=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,Ae=[".ph-no-rageclick",".ph-no-capture"],Te=["","text","search","email","password","url","tel","number"];function Oe(t,e){if(!wt||Me(t))return!1;var i,r,s,n,a;if(k(e)?(i=!!e&&Ae,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:Ae,r=null==e?void 0:e.content_ignorelist,s=null!==(a=null==e?void 0:e.ignore_text_selection)&&void 0!==a&&a),!1===i)return!1;if(s&&function(t){return!(!t||!ge(t))&&(!!_e(t,"textarea")||(_e(t,"input")?v(Te,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var{targetElementList:o}=je(t,!1);return!function(t,e){if(!1===t||b(t))return!1;var i;if(!0===t)i=$e;else{if(!g(t))return!1;if(t.length>10)return Ct.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var{safeText:e,ariaLabel:r}=t;return i.some((t=>Ie(e,t)||Ie(r,t)))}))}(r,o.map((t=>{var e;return{safeText:ke(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Pe(o,i)}var Me=t=>!t||_e(t,"html")||!ge(t),je=(t,e)=>{if(!wt||Me(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!_e(s,"body");)if(be(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ce(s);if(!n)break;if(e||Fe.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=wt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Le(t){for(var e=t;e.parentNode&&!_e(e,"body");e=e.parentNode){var i=xe(e);if(v(i,"ph-sensitive")||v(i,"ph-no-capture"))return!1}if(v(xe(t),"ph-include"))return!0;var r=t.type||"";if(y(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!y(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function De(t){return!!(_e(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||_e(t,"select")||_e(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ne="(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})",ze=new RegExp("^(?:"+Ne+")$"),Ue=new RegExp(Ne),He="\\d{3}-?\\d{2}-?\\d{4}",Ve=new RegExp("^("+He+")$"),Be=new RegExp("("+He+")");function We(t,e){if(void 0===e&&(e=!0),x(t))return!1;if(y(t)){if(t=d(t),(e?ze:Ue).test((t||"").replace(/[- ]/g,"")))return!1;if((e?Ve:Be).test(t))return!1}return!0}function qe(t){var e=ke(t);return We(e=(e+" "+Je(t)).trim())?e:""}function Je(t){var e="";return t&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=ke(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Je(t)).trim())}catch(t){Ct.error("[AutoCapture]",t)}})),e}function Ke(t){return t.replace(/"|\\"/g,'\\"')}function Ge(t){var e=t.attr__class;return e?g(e)?e:ye(e):void 0}class Ye{constructor(t){this.disabled=!1===t;var e=m(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var Qe=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!g(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){Ct.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Xe=function(t,e,i){if(!t||!e||!e.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("=");g(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=s&&(d+="#"+s),d},Ze=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},ti="$copy_autocapture",ei=Rt("[AutoCapture]");function ii(t,e){return e.length>t?e.slice(0,t)+"...":e}function ri(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ge(e));return e}function si(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:u}=e;if(!ge(t))return{props:{}};for(var h=[t],d=t;d.parentNode&&!_e(d,"body");)if(be(d.parentNode))h.push(d.parentNode.host),d=d.parentNode.host;else{if(!ge(d.parentNode))break;h.push(d.parentNode),d=d.parentNode}var c,f,p=[],g={},_=!1,m=!1;if($t(h,(t=>{var e=Le(t);if(_e(t,"a")){var i=t.getAttribute("href");_=e&&!!i&&We(i)&&i}v(xe(t),"ph-no-capture")&&(m=!0),p.push(function(t,e,i,r){var s=t.tagName.toLowerCase(),n={tag_name:s};Fe.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?ii(1024,qe(t)):ii(1024,ke(t)));var a=xe(t);a.length>0&&(n.classes=a.filter((function(t){return""!==t}))),$t(t.attributes,(function(i){var s;if((!De(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&We(i.value)&&(!y(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var a=i.value;"class"===i.name&&(a=ye(a).join(" ")),n["attr__"+i.name]=ii(1024,a)}}));for(var o=1,l=1,u=t;u=ri(u);)o++,u.tagName===t.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}(t,a,o,l));var r=function(t){if(!Le(t))return{};var e={};return $t(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&We(r)&&(e[i]=r)}})),e}(t);It(g,r)})),m)return{props:{},explicitNoCapture:m};if(o||(p[0].$el_text=_e(t,"a")||_e(t,"button")?qe(t):ke(t)),_){var w,x;p[0].attr__href=_;var E=null==(w=(t=>{var e=null==kt?void 0:kt.createElement("a");return b(e)?null:(e.href=t,e)})(_))?void 0:w.host,k=null==wt||null==(x=wt.location)?void 0:x.host;E&&k&&E!==k&&(c=_)}return{props:It({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(f=p,function(t){return t.map((t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return At(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[Ke(e.toString())]=Ke(i.toString())})),(s+=":")+At(o).map((t=>{var[e,i]=t;return e+'="'+i+'"'})).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Ge(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return At(t).filter((t=>{var[e]=t;return 0===e.indexOf("attr__")})).forEach((t=>{var[e,i]=t;return r.attributes[e]=i})),r}))}(f)))},null!=(r=p[0])&&r.$el_text?{$el_text:null==(s=p[0])?void 0:s.$el_text}:{},c&&"click"===n.type?{$external_click_url:c}:{},g)}}var ni=Rt("[Dead Clicks]"),ai=()=>!0;class oi{get lazyLoadedDeadClicksAutocapture(){return this.$r}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.qr((()=>{this.jr()})):this.stop()}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?ni.error("failed to load script",e):t()}))}jr(){var t;if(kt){if(!this.$r&&null!=(t=Ft.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=m(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.$r=Ft.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.$r.start(kt),ni.info("starting...")}}else ni.error("`document` not found. Cannot start.")}stop(){this.$r&&(this.$r.stop(),this.$r=void 0,ni.info("stopping..."))}}var li=Rt("[ExceptionAutocapture]"),ui=Rt("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return E(t)&&isFinite(t)&&Math.floor(t)===t});class hi{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|e>>>8,s[7]=e,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new hi(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new hi(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class vi{constructor(){this.S=0,this.C=0,this.I=new fi}generate(){var t=this.generateOrAbort();if(b(t)){this.S=0;var e=this.generateOrAbort();if(b(e))throw new Error("Could not generate UUID after timestamp reset");return e}return t}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.M();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.M())}return hi.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}M(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var di,ci=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};wt&&!b(wt.crypto)&&crypto.getRandomValues&&(ci=t=>crypto.getRandomValues(t));class fi{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(ci(this.R),this.O=0),this.R[this.O++]}}var pi=()=>(di||(di=new vi)).generate(),gi="",_i=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function mi(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=kt),gi)return gi;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),r=Math.min(i.length,8),s="dmn_chk_"+pi().toString();!gi&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(s)&&(e.cookie=a+";max-age=0",gi=n)}return gi}(t);if(!i){var r=(t=>{var e=t.match(_i);return e?e[0]:""})(t);r!==i&&Ct.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var bi={N:()=>!!kt,D(t){Ct.error("cookieStore error: "+t)},P(t){if(kt){try{for(var e=t+"=",i=kt.cookie.split(";").filter((t=>t.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return decodeURIComponent(s.substring(e.length,s.length))}}catch(t){}return null}},F(t){var e;try{e=JSON.parse(bi.P(t))||{}}catch(t){}return e},A(t,e,i,r,s){if(!kt)return!1;try{var n="",a="",o=mi(kt.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&Ct.warn("cookieStore warning: large cookie, len="+u.length),kt.cookie=u,!0}catch(t){return!1}},q(t,e){if(null!=kt&&kt.cookie)try{bi.A(t,"",-1,e)}catch(t){return}}},yi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],wi=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...yi],xi="<masked>",Ei=["li_fat_id"];function ki(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Si=Rt("[Web Vitals]"),Fi=9e5,Pi=Rt("[RemoteConfig]");class Ci{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}xi(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}ki(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(e){t(e.json)}})}load(){try{if(this.remoteConfig)return Pi.info("Using preloaded remote config",this.remoteConfig),this.Si(this.remoteConfig),void this.Ci();if(this._instance.Ii())return void Pi.warn("Remote config is disabled. Falling back to local config.");this.xi((t=>{if(!t)return Pi.info("No config found after loading remote JS config. Falling back to JSON."),void this.ki((t=>{this.Si(t),this.Ci()}));this.Si(t),this.Ci()}))}catch(t){Pi.error("Error loading remote config",t)}}stop(){this.Ti&&(clearInterval(this.Ti),this.Ti=void 0)}refresh(){!this._instance.Ii()&&kt&&"hidden"!==kt.visibilityState&&this._instance.reloadFeatureFlags()}Ci(){var t;if(!this.Ti){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Ti=setInterval((()=>{this.refresh()}),e))}}Si(t){var e;t||Pi.error("Failed to fetch remote config from PostHog."),this._instance.Si(null!=t?t:{}),!1!==(null==t?void 0:t.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded())}}var Ri="disabled",$i="lazy_loading",Ii="awaiting_config",Ai="missing_config",Ti="base64",Oi=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},Mi={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>Oi(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!Oi(e,t))))),icontains:(t,e)=>e.map(ji).some((e=>t.map(ji).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(ji).every((e=>t.map(ji).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},ji=t=>t.toLowerCase();function Li(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(b(s)||w(s))return!1;var n=[String(s)],a=Mi[r.operator];return!!a&&a(r.values,n)}))}Rt("[SessionRecording]"),Rt("[SessionRecording]");var Di="[SessionRecording]",Ni=Rt(Di),zi=Rt("[Heatmaps]");function Ui(t){return m(t)&&"clientX"in t&&"clientY"in t&&E(t.clientX)&&E(t.clientY)}var Hi=Rt("[Product Tours]"),Vi=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Ht))},Bi=["$set_once","$set"],Wi=Rt("[SiteApps]"),qi="Error while initializing PostHog app with config id ",Ji="events",Ki="cancelEvents",Gi="survey shown",Yi=Rt("[Surveys]"),Qi=["popover","widget","api"];class Xi{constructor(){this.Xi={}}on(t,e){return this.Xi[t]||(this.Xi[t]=[]),this.Xi[t].push(e),()=>{this.Xi[t]=this.Xi[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Xi[t]||[])i(e);for(var r of this.Xi["*"]||[])r(t,e)}}function Zi(t,e,i){if(x(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class tr{constructor(t){this.fs=new Xi,this.ps=(t,e)=>this.gs(t,e)&&this.ys(t,e)&&this.bs(t,e)&&this._s(t,e),this.gs=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.ws=new Set,this.xs=new Set}init(){var t,e;b(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!b(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.xs)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.ws)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.ws.has(t)||this.ws.has(null==e?void 0:e.event))&&this.xs&&(null==(i=this.xs)?void 0:i.size)>0&&this.xs.forEach((t=>{this.ks(e,t)&&this.fs.emit("actionCaptured",t.name)}))}Ss(t){this.onAction("actionCaptured",(e=>t(e)))}ks(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.ps(t,i))return!0;return!1}onAction(t,e){return this.fs.on(t,e)}ys(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Zi(r,e.url,e.url_matching||"contains"))return!1}return!0}bs(t,e){return!!this.Cs(t,e)&&!!this.Is(t,e)&&!!this.Ts(t,e)}Cs(t,e){var i;if(null==e||!e.href)return!0;var r=this.Es(t);if(r.length>0)return r.some((t=>Zi(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Zi((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}Is(t,e){var i;if(null==e||!e.text)return!0;var r=this.Es(t);if(r.length>0)return r.some((t=>Zi(t.text,e.text,e.text_matching||"exact")||Zi(t.$el_text,e.text,e.text_matching||"exact")));var s,n,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!x(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),n=e.text,a=e.text_matching||"exact",s.some((t=>Zi(t,n,a))))}Ts(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}Es(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}_s(t,e){return null==e||!e.properties||0===e.properties.length||Li(e.properties.reduce(((t,e)=>{var i=g(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class er{constructor(t){this.Ms=[],this._instance=t,this.Rs=new Map,this.Ps=new Map,this.Os=new Map}Ls(t,e){return!!t&&Li(t.propertyFilters,null==e?void 0:e.properties)}As(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}Fs(t,e,i){var r=(i===Ji?this.Rs:this.Ps).get(t),s=[];return this.Ns((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[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Ls(n,e)}))}register(t){var e;b(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Ds(t),this.$s(t))}$s(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.qs&&(this.qs=new tr(this._instance),this.qs.init(),this.qs.Ss((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.qs)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.Os.get(e.name);i&&i.push(t.id),this.Os.set(e.name,i||[t.id])}})))})))}Ds(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.Rs=this.As(t,Ji),this.Ps=this.As(t,Ki))}onEvent(t,e){var i,r,s=this.ce(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.js(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Bs([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),void this.Hs(n)}if(this.Ps.has(t)){var o=this.Fs(t,e,Ki);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Bs(o.map((t=>t.id))),o.forEach((t=>this.Us(t.id))))}if(this.Rs.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.Rs.get(t)});var l=this.Fs(t,e,Ji);this.zs(l.map((t=>t.id)))}}onAction(t){this.Os.has(t)&&this.zs(this.Os.get(t)||[])}zs(t){0!==t.length&&(this.Ms=[...new Set([...this.Ms,...t])],this.ce().info("updating activated items",{activatedItems:this.getActivatedIds()}))}Hs(t){this.Ms=this.Ms.filter((e=>e!==t));var e=this.Vs();e.includes(t)||this.Ws([...e,t])}Bs(t){var e=new Set(t);this.Ms=this.Ms.filter((t=>!e.has(t)));var i=this.Vs(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&this.Ws(r)}Vs(){var t,e=this.Gs();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getActivatedIds(){return[...new Set([...this.Vs(),...this.Ms])].filter((t=>!this.Zs(t)))}reset(){this.Ms=[],this.Vs().length>0&&this.Ws([])}getEventToItemsMap(){return this.Rs}Qs(){return this.qs}}class ir extends er{constructor(t){super(t)}Gs(){return ie}Js(){return Gi}Ns(t){var e;null==(e=this._instance)||e.getSurveys(t)}Us(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}ce(){return Yi}Ws(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[ie]:t})}Zs(){return!1}js(t,e){var i;this.Ns((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e,i,r,s=(null!==(e=null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==e?e:0)>0;return"always"===t.schedule||!(null==(r=t.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?t===Gi?"consume":"ignore":t===Gi?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var rr="SDK is not enabled or survey functionality is not yet loaded",sr="Disabled. Not loading surveys.",nr=null!=wt&&wt.location?Ze(wt.location.hash,"__posthog")||Ze(location.hash,"state"):null,ar="_postHogToolbarParams",or=Rt("[Toolbar]"),lr=Rt("[FeatureFlags]"),ur=Rt("[FeatureFlags]",{debugEnabled:!0}),hr="\" failed. Feature flags didn't load in time.",vr=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},dr=t=>{var e={};for(var[i,r]of At(t||{}))r&&(e[i]=r);return e},cr=Rt("[Error tracking]"),fr="Refusing to render web experiment since the viewer is a likely bot",pr={icontains:(t,e)=>!!wt&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!wt&&-1===e.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>!!wt&&Oi(e.href,t),not_regex:(t,e)=>!!wt&&!Oi(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class gr{get Dt(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{gr.Ks("retrieved web experiments from the server"),e.Ys=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.Ys&&(gr.Ks("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.Ys)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);y(r)&&t.variants[r]&&e.Xs(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];gr.eo(n)&&e.Xs(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())gr.Ks(fr);else if(!this.Dt.disable_web_experiments){if(x(this.Ys))return this.Ys=new Map,this.loadIfEnabled(),void this.previewWebExperiment();gr.Ks("applying feature flags",t),t.forEach((t=>{var e;if(this.Ys&&null!=(e=this.Ys)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.Ys)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.Xs(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=gr.getWindowLocation();if(null!=t&&t.search){var e=Qe(null==t?void 0:t.search,"__experiment_id"),i=Qe(null==t?void 0:t.search,"__experiment_variant");e&&i&&(gr.Ks("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.ro(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Dt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Dt.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Dt.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}ro(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(gr.Ks("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.Xs(r[0].name,e,r[0].variants[e].transforms))}static eo(t){return!x(t.conditions)&&gr.io(t)&&gr.no(t)}static io(t){var e;if(x(t.conditions)||x(null==(e=t.conditions)?void 0:e.url))return!0;var i,r,s,n=gr.getWindowLocation();return!!n&&(null==(i=t.conditions)||!i.url||pr[null!==(r=null==(s=t.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](t.conditions.url,n))}static getWindowLocation(){return null==wt?void 0:wt.location}static no(t){var e;if(x(t.conditions)||x(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!kt)return{};var r,s,n,a=(r=Xe(kt.URL,[],xi),s=wi.concat([]),n={},$t(s,(function(t){var e=Qe(r,t);n[t]=e||null})),n),o=function(){var t={};return $t(Ei,(function(e){var i=bi.P(e);t[e]=i||null})),t}();return It(o,a)}();if(i.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)==i.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)==i.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)==i.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)==i.utm_term;return v&&c&&f&&d}return!1}static Ks(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];Ct.info("[WebExperiments] "+t,i)}Xs(t,e,i){this._is_bot()?gr.Ks(fr):"control"!==e?i.forEach((i=>{if(i.selector){var r;gr.Ks("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):gr.Ks("Control variants leave the page unmodified.")}_is_bot(){return Et&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&h(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>h(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(Et,this.Dt.custom_blocked_useragents):void 0}}var _r=Rt("[Conversations]"),mr="Conversations not available yet.",br={featureFlags:class{constructor(t){this.so=!1,this.oo=!1,this.ao=!1,this.lo=!1,this.uo=!1,this.ho=!1,this.co=!1,this.do=!1,this._instance=t,this.featureFlagEventHandlers=[]}get Dt(){return this._instance.config}get Ki(){return this._instance.persistence}vo(t){return this._instance.get_property(t)}fo(){var t,e;return null!==(t=null==(e=this.Ki)?void 0:e.ii(this.Dt.feature_flag_cache_ttl_ms))&&void 0!==t&&t}po(){return!!this.fo()&&(this.do||this.ao||(this.do=!0,lr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}mo(){var t,e=null!==(t=this.Dt.evaluation_contexts)&&void 0!==t?t:this.Dt.evaluation_environments;return!this.Dt.evaluation_environments||this.Dt.evaluation_contexts||this.co||(lr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.co=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||lr.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}yo(){return this.mo().length>0}bo(){var t=this.Dt.flag_keys;if(!b(t)){if(g(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||lr.error("Invalid flag key found:",t,"Expected non-empty string"),e}));lr.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,{config:i}=this._instance,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(a).filter((t=>o[t])).reduce(((t,e)=>(a[e]&&(t[e]=a[e]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,e,r){var s,n,l=null!=r&&r.merge&&null!==(s=this.vo(Wt))&&void 0!==s?s:{},u=null!=r&&r.merge&&null!==(n=this.vo(Gt))&&void 0!==n?n:{},h=i({},l,t),v=i({},u,e),d={};for(var[c,f]of Object.entries(h))d[c]={key:c,enabled:a(f),variant:o(f),reason:void 0,metadata:b(null==v?void 0:v[c])?void 0:{id:0,version:void 0,description:void 0,payload:v[c]}};this.receivedFeatureFlags({flags:d})}get hasLoadedFlags(){return this.oo}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.vo(Kt),e=this.vo(Qt),r=this.vo(Xt);if(!r&&!e)return t||{};var s=It({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])];for(var a of n){var o,l,u=s[a],h=null==e?void 0:e[a],v=b(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=b(h)?u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=i({},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=i({},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.so||(lr.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.so=!0),s}getFlagVariants(){var t=this.vo(Wt),e=this.vo(Qt);if(!e)return t||{};for(var i=It({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.so||(lr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.so=!0),i}getFlagPayloads(){var t=this.vo(Gt),e=this.vo(Xt);if(!e)return t||{};for(var i=It({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.so||(lr.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.so=!0),i}reloadFeatureFlags(){this.lo||this.Dt.advanced_disable_feature_flags||this._o||(this._instance.Fn.emit("featureFlagsReloading",!0),this._o=setTimeout((()=>{this.wo()}),5))}xo(){clearTimeout(this._o),this._o=void 0}ensureFlagsLoaded(){this.oo||this.ao||this._o||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.lo=t}wo(t){var e;if(this.xo(),!this._instance.Ii())if(this.ao)this.uo=!0;else{var r=this.Dt.token,s=this.vo("$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:i({},(null==(e=this.Ki)?void 0:e.get_initial_props())||{},this.vo(Zt)||{}),group_properties:this.vo(te),timezone:ki()};w(s)||b(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Dt.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.yo()&&(n.evaluation_contexts=this.mo());var a=this.bo();b(a)||(n.flag_keys=a);var o=!!this.Dt.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Dt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.ao=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.Dt.disable_compression?void 0:Ti,timeout:this.Dt.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(200===t.statusCode&&(this.uo||(this.$anon_distinct_id=void 0),s=!1),this.ao=!1,!n.disable_flags||this.uo){this.ho=!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!=(e=t.json)&&e.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(i=t.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.Ki)||r.register({[ae]:a}),u)lr.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.uo&&(this.uo=!1,this.wo())}}})}}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.ho)if(this.oo||this.getFlags()&&this.getFlags().length>0){if(!this.po()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else lr.warn('getFeatureFlag for key "'+t+hr)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.ho)if(this.oo||this.getFlags()&&this.getFlags().length>0){if(!this.po()){var i=this.getFlagVariants(),r=t in i,s=i[t],a=this.getFlagPayloads()[t],o=String(s),l=this.vo(Yt)||void 0,u=this.vo(oe)||void 0,h=this.vo(se)||{};if(this.Dt.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.vo(ne);d&&d!==c&&(h={},null==(v=this.Ki)||v.register({[se]:h,[ne]:d}))}if((e.send_event||!("send_event"in e))&&(!(t in h)||!h[t].includes(o))){var f,p,_,m,y,w,x,E,k,S;g(h[t])?h[t].push(o):h[t]=[o],null==(f=this.Ki)||f.register({[se]:h});var F=this.getFeatureFlagDetails(t),P=[...null!==(p=this.vo(ae))&&void 0!==p?p:[]];b(s)&&P.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:a||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(null==(_=this.Dt.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(m=this.Dt.bootstrap)||null==(m=m.featureFlagPayloads)?void 0:m[t])||null,$used_bootstrap_value:!this.ho};b(null==F||null==(y=F.metadata)?void 0:y.version)||(C.$feature_flag_version=F.metadata.version);var R,I=null!==(w=null==F||null==(x=F.reason)?void 0:x.description)&&void 0!==w?w:null==F||null==(E=F.reason)?void 0:E.code;I&&(C.$feature_flag_reason=I),null!=F&&null!=(k=F.metadata)&&k.id&&(C.$feature_flag_id=F.metadata.id),b(null==F?void 0:F.original_variant)&&b(null==F?void 0:F.original_enabled)||(C.$feature_flag_original_response=b(F.original_variant)?F.original_enabled:F.original_variant),null!=F&&null!=(S=F.metadata)&&S.original_payload&&(C.$feature_flag_original_payload=null==F||null==(R=F.metadata)?void 0:R.original_payload),P.length&&(C.$feature_flag_error=P.join(",")),this._instance.capture("$feature_flag_called",C)}if(r)return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:n(a)}}}else lr.warn('getFeatureFlagResult for key "'+t+hr)}getRemoteConfigPayload(t,e){var i=this.Dt.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.yo()&&(r.evaluation_contexts=this.mo());var s=this.bo();b(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Dt.disable_compression?void 0:Ti,timeout:this.Dt.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;e((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,e){if(void 0===e&&(e={}),!e.fresh||this.ho){if(this.oo||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return b(i)?void 0:!!i}lr.warn('isFeatureEnabled for key "'+t+hr)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.Ki){this.oo=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,e,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var o=(t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))):lr.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(g(u)){lr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var f=0;u.length>f;f++)c[u[f]]=!0;e&&e.register({[qt]:u,[Wt]:c})}else{var p=u,_=h,m=l;if(null!=a&&a.partialResponse)p=i({},r,p),_=i({},s,_),m=i({},n,m);else if(t.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));p=i({},r,Object.fromEntries(Object.entries(p).filter((t=>{var[e]=t;return b.has(e)})))),_=i({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return b.has(e)})))),m=i({},n,Object.fromEntries(Object.entries(m||{}).filter((t=>{var[e]=t;return b.has(e)}))))}else p=i({},r,p),_=i({},s,_),m=i({},n,m);e&&e.register(i({[qt]:Object.keys(dr(p)),[Wt]:p||{},[Gt]:_||{},[Kt]:m||{}},v?{[Yt]:v}:{},d?{[oe]:d}:{}))}}}(t,this.Ki,s,n,a,r),e||(this.do=!1),this.ko(e)}}override(t,e){void 0===e&&(e=!1),lr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Ki)return lr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Ki.unregister(Qt),this.Ki.unregister(Xt),this.ko(),ur.info("All overrides cleared");if(g(t)){var e=vr(t);return this.Ki.register({[Qt]:e}),this.ko(),ur.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.so=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.Ki.unregister(Qt),ur.info("Flag overrides cleared");else if(r.flags){if(g(r.flags)){var s=vr(r.flags);this.Ki.register({[Qt]:s})}else this.Ki.register({[Qt]:r.flags});ur.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Ki.unregister(Xt),ur.info("Payload overrides cleared")):r.payloads&&(this.Ki.register({[Xt]:r.payloads}),ur.info("Payload overrides set",{payloads:r.payloads}))),void this.ko()}if(t&&"object"==typeof t)return this.Ki.register({[Qt]:t}),this.ko(),ur.info("Flag overrides set",{flags:t});lr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.oo){var{flags:e,flagVariants:i}=this.So();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.vo(Jt)||[]).find((e=>e.flagKey===t)),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this.Ki)||s.register({[qt]:Object.keys(dr(l)),[Wt]:l}),this.ko()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.vo(Jt),s=i?"&"+i.map((t=>"stage="+t)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Dt.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.Ki)||i.unregister(Jt),null==(r=this.Ki)||r.register({[Jt]:s}),t(s)}}})}So(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}ko(t){var{flags:e,flagVariants:i}=this.So();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.vo(Zt)||{},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({[Zt]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.vo(Zt)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[Zt]:r}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Zt),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.vo(te)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[te]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.vo(te)||{};this._instance.register({[te]:i({},e,{[t]:{}})})}else this._instance.unregister(te)}reset(){this.oo=!1,this.ao=!1,this.lo=!1,this.uo=!1,this.ho=!1,this.$anon_distinct_id=void 0,this.xo(),this.so=!1}}},yr={sessionRecording:class{get Dt(){return this._instance.config}get Ki(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Co)||!t.isStarted)}get status(){var t,e;return this.Io===Ii||this.Io===Ai?this.Io:null!==(t=null==(e=this.Co)?void 0:e.status)&&void 0!==t?t:this.Io}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Io=Ri,this.To=void 0,this._instance=t,!this._instance.sessionManager)throw Ni.error("started without valid sessionManager"),new Error(Di+" started without valid sessionManager. This is a bug.");if("always"===this.Dt.cookieless_mode)throw new Error(Di+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Eo(){var t,e=!(null==(t=this._instance.get_property(Bt))||!t.enabled),i=!this.Dt.disable_session_recording,r=this.Dt.disable_session_recording||this._instance.consent.isOptedOut();return wt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.Eo||null==(e=this.Co)||!e.isStarted){var i=!b(Object.assign)&&!b(Array.from);this.Eo&&i?(this.Mo(t),Ni.info("starting")):(this.Io=Ri,this.stopRecording())}}Mo(t){var e,i,r;this.Eo&&(this.Io!==Ii&&this.Io!==Ai&&(this.Io=$i),null!=Ft&&null!=(e=Ft.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=Ft.__PosthogExtensions__)&&i.initSessionRecording?this.Ro(t):null==(r=Ft.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Po,(e=>{if(e)return Ni.error("could not load recorder",e);this.Ro(t)})))}stopRecording(){var t,e;null==(t=this.To)||t.call(this),this.To=void 0,null==(e=this.Co)||e.stop()}Oo(){var t,e;null==(t=this.To)||t.call(this),this.To=void 0,null==(e=this.Co)||e.discard()}Lo(){var t,e;null==(t=this.Ki)||t.unregister("$session_is_sampled"),null==(e=this.Ki)||e.unregister("$replay_sample_rate")}Ao(t,e){if(x(t))return null;var i,r=E(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ni.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Fo(t){if(this.Ki){var e,r,s=this.Ki,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Ao(null==(e=this.Dt.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Ao(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;x(o)&&this.Lo();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[Bt]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:b(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.To)||e.call(this),this.To=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Fo(t),void this.Oo()):(this.Fo(t),void this.startIfEnabledOrStop()):(this.Io===Ii&&(this.Io=Ai,Ni.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Co)&&i.log?this.Co.log(t,e):Ni.warn("log called before recorder was ready")}get Po(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Bt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}No(){var t,e,i=this._instance.get_property(Bt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Ni.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=e.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Ro(t){var e,i;if(null==(e=Ft.__PosthogExtensions__)||!e.initSessionRecording)return Ni.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.Co||(this.Co=null==(i=Ft.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Co._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.No()){if(this.Io===Ai||this.Io===Ii)return;return this.Io=Ii,Ni.info("persisted remote config is stale, requesting fresh config before starting"),void new Ci(this._instance).load()}this.Io=$i,this.Co.start(t)}onRRwebEmit(t){var e;null==(e=this.Co)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Co||null==(e=this.Ki)||e.register({$replay_override_linked_flag:!0}),null==(t=this.Co)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Co||null==(e=this.Ki)||e.register({$replay_override_sampling:!0}),null==(t=this.Co)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Co||null==(i=this.Ki)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.Co)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Co)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Co)||!i.tryAddCustomEvent(t,e))}}},wr={autocapture:class{constructor(t){this.Do=!1,this.$o=null,this.qo=!1,this.instance=t,this.rageclicks=new Ye(t.config.rageclick),this.jo=null}initialize(){this.startIfEnabled()}get Dt(){var t,e,i=m(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}Bo(){if(this.isBrowserSupported()){if(wt&&kt){var t=t=>{t=t||(null==wt?void 0:wt.event);try{this.Ho(t)}catch(t){ei.error("Failed to capture event",t)}};if(Ot(kt,"submit",t,{capture:!0}),Ot(kt,"change",t,{capture:!0}),Ot(kt,"click",t,{capture:!0}),this.Dt.capture_copied_text){var e=t=>{t=t||(null==wt?void 0:wt.event);try{this.Ho(t,ti)}catch(t){ei.error("Failed to capture copy/cut event",t)}};Ot(kt,"copy",e,{capture:!0}),Ot(kt,"cut",e,{capture:!0})}}}else ei.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Do&&(this.Bo(),this.Do=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.qo=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[jt]:!!t.autocapture_opt_out}),this.$o=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.jo=t}getElementSelectors(t){var e,i=[];return null==(e=this.jo)||e.forEach((e=>{var r=null==kt?void 0:kt.querySelectorAll(e);null==r||r.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[jt];if(w(this.$o)&&!k(i)&&!this.instance.Ii())return!1;var r=null!==(e=this.$o)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}Ho(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=Se(t);me(r)&&(r=r.parentNode||null),"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Oe(r,this.instance.config.rageclick)&&this.Ho(t,"$rageclick");var s=e===ti;if(r&&function(t,e,i,r,s){var n,a,o,l,u,h;if(void 0===i&&(i=void 0),!wt||Me(t))return!1;if(null!=(n=i)&&n.url_allowlist&&!we(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&we(i.url_ignorelist))return!1;if(null!=(o=i)&&o.dom_event_allowlist){var v=i.dom_event_allowlist;if(v&&!v.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:d,targetElementList:c}=je(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(b(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(c,i))return!1;if(!Pe(c,null==(l=i)?void 0:l.css_selector_allowlist))return!1;if(Pe(c,null!==(u=null==(h=i)?void 0:h.css_selector_ignorelist)&&void 0!==u?u:Re))return!1;var f=wt.getComputedStyle(t);if(f&&"pointer"===f.getPropertyValue("cursor")&&"click"===e.type)return!0;var p=t.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return d?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(Fe.indexOf(p)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Dt,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=si(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Dt.element_attribute_ignorelist,elementsChainAsString:this.qo});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===ti){var l,u=Ee(null==wt||null==(l=wt.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return _(null==kt?void 0:kt.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Uo=(null==wt||null==(e=wt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Ct.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.zo&&this.zo(),this.zo=void 0,Ct.info("History API monitoring stopped")}monitorHistoryChanges(){wt&&wt.history&&(this.Vo("pushState"),this.Vo("replaceState"),this.Wo())}Vo(t){var e;if(wt&&(null==(e=wt.history[t])||!e.__posthog_wrapped__)){var i=this;!function(t,e,i){try{if(!(e in t))return()=>{};var r=t[e],s=i(r);return _(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]===s&&(t[e]=r)}}catch(t){return()=>{}}}(wt.history,t,(e=>function(r,s,n){e.call(this,r,s,n),i.Go(t)}))}}Go(t){try{var e,i=null==wt||null==(e=wt.location)?void 0:e.pathname;if(!i)return;i!==this.Uo&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.Uo=i}catch(e){Ct.error("Error capturing "+t+" pageview",e)}}Wo(){if(!this.zo){var t=()=>{this.Go("popstate")};Ot(wt,"popstate",t),this.zo=()=>{wt&&wt.removeEventListener("popstate",t)}}}},heatmaps:class{get Dt(){return this.instance.config}constructor(t){var e;this.Zo=!1,this.Do=!1,this.Qo=null,this.instance=t,this.Zo=!(null==(e=this.instance.persistence)||!e.props[Lt]),this.rageclicks=new Ye(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return m(this.Dt.capture_heatmaps)&&this.Dt.capture_heatmaps.flush_interval_milliseconds&&(t=this.Dt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return x(this.Dt.capture_heatmaps)?x(this.Dt.enable_heatmaps)?this.Zo:this.Dt.enable_heatmaps:!1!==this.Dt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Do)return;zi.info("starting..."),this.Jo(),this.Pt()}else{var t;clearInterval(null!==(t=this.Qo)&&void 0!==t?t:void 0),this.Ko(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Lt]:e}),this.Zo=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Yo(t){this._t(t.originalEvent,"deadclick")}Pt(){this.Qo&&clearInterval(this.Qo),this.Qo="visible"===(null==kt?void 0:kt.visibilityState)?setInterval(this.ji.bind(this),this.flushIntervalMilliseconds):null}Jo(){wt&&kt&&(this.Xo=this.ji.bind(this),Ot(wt,ve,this.Xo),this.ea=t=>this._t(t||(null==wt?void 0:wt.event)),Ot(kt,"click",this.ea,{capture:!0}),this.ta=t=>this.ra(t||(null==wt?void 0:wt.event)),Ot(kt,"mousemove",this.ta,{capture:!0}),this.ia=new oi(this.instance,ai,this.Yo.bind(this)),this.ia.startIfEnabledOrStop(),this.na=this.Pt.bind(this),Ot(kt,he,this.na),this.Do=!0)}Ko(){var t;wt&&kt&&(this.Xo&&wt.removeEventListener(ve,this.Xo),this.ea&&kt.removeEventListener("click",this.ea,{capture:!0}),this.ta&&kt.removeEventListener("mousemove",this.ta,{capture:!0}),this.na&&kt.removeEventListener(he,this.na),clearTimeout(this.sa),null==(t=this.ia)||t.stop(),this.Do=!1)}oa(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,e,i){for(var r=t;r&&ge(r)&&!_e(r,"body");){if(r===i)return!1;if(v(e,null==wt?void 0:wt.getComputedStyle(r).position))return!0;r=Ce(r)}return!1}(Se(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}_t(t,e){var r;if(void 0===e&&(e="click"),!pe(t.target)&&Ui(t)){var s=this.oa(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Oe(Se(t),this.instance.config.rageclick)&&this.aa(i({},s,{type:"rageclick"})),this.aa(s)}}ra(t){!pe(t.target)&&Ui(t)&&(clearTimeout(this.sa),this.sa=setTimeout((()=>{this.aa(this.oa(t,"mousemove"))}),500))}aa(t){if(wt){var e=wt.location.href,i=this.Dt.custom_personal_data_properties,r=this.Dt.mask_personal_data_properties?[...yi,...i||[]]:[],s=Xe(e,r,xi);this.R=this.R||{},this.R[s]||(this.R[s]=[]),this.R[s].push(t)}}ji(){this.R&&!(t=>{if(m(t)){for(var e in t)if(f.call(t,e))return!1;return!0}return!1})(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:oi,webVitalsAutocapture:class{constructor(t){var e;this.Zo=!1,this.Do=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.la=()=>{clearTimeout(this.ua),0!==this.R.metrics.length&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.vt=t=>{var e;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.ha();if(!b(r))if(x(null==t?void 0:t.name)||x(null==t?void 0:t.value))Si.error("Invalid metric received",t);else if(!this.ca||this.ca>t.value){this.R.url!==r&&(this.la(),this.ua=setTimeout(this.la,this.flushToCaptureTimeoutMs)),b(this.R.url)&&(this.R.url=r),this.R.firstMetricTimestamp=b(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var s=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),n=i({},t,{$current_url:r,timestamp:Date.now()});b(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.R.metrics.push(n),this.R.metrics.length===this.allowedMetrics.length&&this.la()}else Si.error("Ignoring metric with value >= "+this.ca,t)},this.da=()=>{if(!this.Do){var t,e,i,r,s=Ft.__PosthogExtensions__;b(s)||b(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.vt.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.vt.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.vt.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.vt.bind(this)),this.Do=!0):Si.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Zo=!(null==(e=this._instance.persistence)||!e.props[Ut]),this.startIfEnabled()}get va(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=m(this.va)?null==(t=this.va)?void 0:t.web_vitals_allowed_metrics:void 0;return x(i)?(null==(e=this._instance.persistence)?void 0:e.props[Vt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(m(this.va)?this.va.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=m(this.va)?this.va.web_vitals_attribution:void 0;return null!=t&&t}get ca(){var t=m(this.va)&&E(this.va.__web_vitals_max_value)?this.va.__web_vitals_max_value:Fi;return t>0&&6e4>=t?Fi:t}get isEnabled(){var t=null==St?void 0:St.protocol;if("http:"!==t&&"https:"!==t)return Si.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=m(this.va)?this.va.web_vitals:k(this.va)?this.va:void 0;return k(e)?e:this.Zo}startIfEnabled(){this.isEnabled&&!this.Do&&(Si.info("enabled, starting..."),this.qr(this.da))}onRemoteConfig(t){if("capturePerformance"in t){var e=m(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=m(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ut]:e}),this._instance.persistence.register({[Vt]:i})),this.Zo=e,this.startIfEnabled()}}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?Si.error("failed to load script",e):t()}))}ha(){var t=wt?wt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...yi,...e||[]]:[];return Xe(t,i,xi)}Si.error("Could not determine current URL")}}},xr={exceptionObserver:class{constructor(t){var e,i,r;this.da=()=>{var t;if(wt&&this.isEnabled&&null!=(t=Ft.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.fa&&this.Dt.capture_unhandled_errors&&(this.fa=e(this.captureException.bind(this))),!this.pa&&this.Dt.capture_unhandled_rejections&&(this.pa=i(this.captureException.bind(this))),!this.ga&&this.Dt.capture_console_errors&&(this.ga=r(this.captureException.bind(this)))}catch(t){li.error("failed to start",t),this.ma()}}},this._instance=t,this.ya=!(null==(e=this._instance.persistence)||!e.props[Dt]),this.ba=new I({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,Qt:li}),this.Dt=this._a(),this.startIfEnabledOrStop()}_a(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return m(t)?e=i({},e,t):(b(t)?this.ya:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Dt.capture_console_errors||this.Dt.capture_unhandled_errors||this.Dt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(li.info("enabled"),this.ma(),this.qr(this.da)):this.ma()}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return li.error("failed to load script",e);t()}))}ma(){var t,e,i;null==(t=this.fa)||t.call(this),this.fa=void 0,null==(e=this.pa)||e.call(this),this.pa=void 0,null==(i=this.ga)||i.call(this),this.ga=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.ya=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Dt]:this.ya}),this.Dt=this._a(),this.startIfEnabledOrStop())}onConfigChange(){this.Dt=this._a()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.ba.consumeRateLimit(s)?li.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,r;this.wa=[],this.xa=new W([new rt,new ct,new nt,new st,new vt,new ht,new ot,new dt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=it.test(l)?l.replace(it,"$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 e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||q});var r}))}(n)}}("web:javascript",X,et)),this._instance=t,this.wa=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property(Nt))&&void 0!==e?e:[],this.ka=mt(this.Sa()),this.Ca=new bt(this.ka)}onConfigChange(){this.ka=mt(this.Sa()),this.Ca.setConfig(this.ka)}onRemoteConfig(t){var e,i,r;if("errorTracking"in t){var s=null!==(e=null==(i=t.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],n=null==(r=t.errorTracking)?void 0:r.captureExtensionExceptions;this.wa=s,this._instance.persistence&&this._instance.persistence.register({[Nt]:this.wa,[zt]:n})}}get Ia(){var t,e=!!this._instance.get_property(zt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.xa.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.ka.enabled)try{if(!y(t)||0===t.trim().length)return void cr.warn("Ignoring exception step because message must be a non-empty string");var r=this.Ta(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>gt.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&cr.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Ca.add(i({[ft]:t,[pt]:(new Date).toISOString()},s))}catch(t){cr.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Ea(e)){if(this.Ma(e))return this.Ra("Exception dropped: matched a suppression rule"),void cr.info("Skipping exception capture because a suppression rule matched");if(!this.Ia&&this.Pa(e))return this.Ra("Exception dropped: thrown by a browser extension"),void cr.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Oa(e))return this.Ra("Exception dropped: thrown by the PostHog SDK"),void cr.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.ka.enabled&&x(t.$exception_steps)?this.La(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",rs:!0});return r&&this.Ca.clear(),r}catch(t){return cr.error("Failed to capture exception event. Dropping this exception.",t),void this.Ca.clear()}}catch(t){return void cr.error("Failed to process exception event. Ignoring this exception.",t)}}La(t){try{var e=this.Ca.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return cr.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Ra(t){this.ka.enabled&&this.Ca.add({[ft]:t,[pt]:(new Date).toISOString()})}Ta(t){return m(t)?i({},t):{}}Sa(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Ma(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return y(i)&&i.length>0&&t.$exception_types.push(i),y(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.wa.some((t=>{var i=t.values.map((t=>{var i,r=Mi[t.operator],s=g(t.value)?t.value:[t.value],n=null!==(i=e[t.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}Pa(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}Oa(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],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}Ea(t){return!x(t)&&g(t)}}},Er=i({productTours:class{get Ki(){return this._instance.persistence}constructor(t){this.Aa=null,this.Fa=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if("productTours"in t){var e,i;if(this.Ki&&this.Ki.register({[Ht]:!!t.productTours}),!Vi(this._instance))return!this.Aa&&x(null==(e=this.Ki)?void 0:e.props[re])||Hi.info("product tours disabled; stopping and clearing cached tours"),null==(i=this.Aa)||i.stop(),this.Aa=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Aa&&Vi(this._instance)&&this.qr((()=>this.Na()))}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Hi.error("Could not load product tours script",e):t()}))}Na(){var t;!this.Aa&&null!=(t=Ft.__PosthogExtensions__)&&t.generateProductTours&&(this.Aa=Ft.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!g(this.Fa)||e){var i=this.Ki;if(i){var r=i.props[re];if(g(r)&&!e)return this.Fa=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",callback:e=>{if(Vi(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Hi.error(s),void t([],{isLoaded:!1,error:s})}var n=g(e.json.product_tours)?e.json.product_tours:[];this.Fa=n,i&&i.register({[re]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Fa,{isLoaded:!0})}getActiveProductTours(t){x(this.Aa)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Aa.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Aa)||e.showTourById(t)}previewTour(t){this.Aa?this.Aa.previewTour(t):this.qr((()=>{var e;this.Na(),null==(e=this.Aa)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Aa)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Aa)||t.nextStep()}previousStep(){var t;null==(t=this.Aa)||t.previousStep()}clearCache(){var t;this.Fa=null,null==(t=this.Ki)||t.unregister(re)}resetTour(t){var e;null==(e=this.Aa)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Aa)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Aa)||e.cancelPendingTour(t)}}},br),kr={siteApps:class{constructor(t){this.Da=0,this._instance=t,this.$a=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}qa(t,e){if(e){var i=this.globalsForEvent(e);this.$a.push(i),this.$a.length>1e3&&(this.$a=this.$a.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.qa.bind(this));this.ja=()=>{t(),this.$a=[],this.ja=void 0}}}globalsForEvent(t){var e,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,c]of Object.entries(v))u[d]={id:h[d],type:d,properties:c};var{$set_once:f,$set:p}=t;return{event:i({},function(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}(t,Bi),{properties:i({},t.properties,p?{$set:i({},null!==(e=null==(r=t.properties)?void 0:r.$set)&&void 0!==e?e:{},p)}:{},f?{$set_once:i({},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}}Ba(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Wi.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Wi.error("prepare_external_dependency_script returned null"),null):t}Ha(){var t,e,i,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==kt?void 0:kt.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Da++,this.Ua)return this.za();var h=[],v=this,d=new WeakSet,c=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),h.push((()=>{t[e]=r}))}},f=t=>{if(d.has(t))return t;var e=v.Ba(t);return e&&d.add(e),e},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!w(t)));return c(u,"appendChild",(t=>function(e){var i=f(e);return i?t.call(this,i):e})),c(u,"insertBefore",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):e})),c(u,"replaceChild",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):i})),[null==(e=l.Element)?void 0:e.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((t=>{c(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}))})),[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 e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=p(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",(t=>function(e,i){var r=f(i);return r?t.call(this,e,r):null})),this.Ua=()=>{h.forEach((t=>t())),this.Ua=void 0},this.za()}za(){var t=!1;return()=>{var e;t||(t=!0,this.Da--,0===this.Da&&(null==(e=this.Ua)||e.call(this)))}}Va(t,e){void 0===e&&(e=!0);var i=this.Ha();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.$a.length&&(Wi.info("Processing "+this.$a.length+" events for site app with id "+t.id),this.$a.forEach((t=>this.Va((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.ja)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Wi.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this.Va((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1);n&&(e.processEvent=n),r=!0}catch(e){Wi.error(qi+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Wi.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Wa(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Ga(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Va((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Wi.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Wa(),void this._instance.on("eventCaptured",(t=>this.Ga(t)))):void Wi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.ja)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;Ft["__$$ph_site_app_"+t]=s._instance,null==(e=Ft.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Wi.error(qi+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Wi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Sr={tracingHeaders:class{constructor(t){this.Za=void 0,this.Qa=void 0,this.Ja=void 0,this.da=()=>{var t,e,i=this.Ka();i?(b(this.Za)&&(this.Za=null==(t=Ft.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),b(this.Qa)&&(this.Qa=null==(e=Ft.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.ma()},this._instance=t}initialize(){this.startIfEnabledOrStop()}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return ui.error("failed to load script",e);t()}))}Ya(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Ka(){var t=this.Ya();return g(t)?(g(this.Ja)?this.Ja.splice(0,this.Ja.length,...t):this.Ja=[...t],t.length>0?this.Ja:void 0):(g(this.Ja)&&this.Ja.splice(0),this.Ja=t||void 0,this.Ja)}ma(){var t,e;null==(t=this.Za)||t.call(this),null==(e=this.Qa)||e.call(this),this.Za=void 0,this.Qa=void 0}startIfEnabledOrStop(){this.Ka()?this.qr(this.da):this.ma()}}},Fr=i({surveys:class{get Dt(){return this._instance.config}constructor(t){this.Xa=void 0,this._surveyManager=null,this.el=!1,this.tl=[],this.rl=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Dt.disable_surveys){var e=t.surveys;if(x(e))return Yi.warn("Flags not loaded yet. Not loading surveys.");var i=g(e);this.Xa=i?e.length>0:e,Yi.info("flags response received, isSurveysEnabled: "+this.Xa),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.el)Yi.info("Already initializing surveys, skipping...");else if(this.Dt.disable_surveys)Yi.info(sr);else if(this.Dt.cookieless_mode&&this._instance.consent.isOptedOut())Yi.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){if(!b(this.Xa)||this.Dt.advanced_enable_surveys){var e=this.Xa||this.Dt.advanced_enable_surveys;this.el=!0;try{var i=t.generateSurveys;if(i)return void this.il(i,e);var r=t.loadExternalDependency;if(!r)return void this.nl(ue);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.nl("Could not load surveys script",i):this.il(t.generateSurveys,e)}))}catch(t){throw this.nl("Error initializing surveys",t),t}finally{this.el=!1}}}else Yi.error("PostHog Extensions not found.")}}il(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new ir(this._instance),Yi.info("Surveys loaded successfully"),this.sl({isLoaded:!0})}nl(t,e){Yi.error(t,e),this.sl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.tl.push(t),this._surveyManager&&this.sl({isLoaded:!0}),()=>{this.tl=this.tl.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Dt.disable_surveys)return Yi.info(sr),t([]);var i,r=this._instance.get_property(ee);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.rl?this.rl.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.rl=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Dt.token),method:"GET",timeout:this.Dt.surveys_request_timeout_ms,callback:e=>{var r;this.rl=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Yi.error(n);var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}var o,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(function(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[ee]:l,$surveys_loaded_at:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}sl(t){for(var e of this.tl)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Yi.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!x(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Yi.warn("init was not called")}ol(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}al(t){if(x(this._surveyManager))return{eligible:!1,reason:rr};var e="string"==typeof t?this.ol(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(x(this._surveyManager))return Yi.warn("init was not called"),{visible:!1,disabledReason:rr};var e=this.al(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return x(this._surveyManager)?(Yi.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:rr})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this.al(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(x(this._surveyManager))Yi.warn("init was not called");else{var s="string"==typeof t?this.ol(t):t;if(null!=s&&s.id)if(Qi.includes(s.type)){var n=null==kt?void 0:kt.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Yi.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Yi.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(s,n,i),Yi.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Yi.warn("Survey element not found")}else Yi.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Yi.warn("Survey not found")}}displaySurvey(t,e){var r;if(x(this._surveyManager))Yi.warn("init was not called");else{var s=this.ol(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&Yi.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void Yi.warn("Survey is not eligible to be displayed: ",a.disabledReason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else Yi.warn("Survey not found")}}cancelPendingSurvey(t){x(this._surveyManager)?Yi.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},br),Pr={toolbar:class{constructor(t){this.instance=t}ll(t){Ft.ph_toolbar_state=t}ul(){var t;return null!==(t=Ft.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),Mt(this.instance.config))return!1;if(!wt||!kt)return!1;t=null!=t?t:wt.location,i=null!=i?i:wt.history;try{if(!e){try{wt.localStorage.setItem("test","test"),wt.localStorage.removeItem("test")}catch(t){return!1}e=null==wt?void 0:wt.localStorage}var r,s=nr||Ze(t.hash,"__posthog")||Ze(t.hash,"state"),n=s?Tt((()=>JSON.parse(atob(decodeURIComponent(s)))))||Tt((()=>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:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(ar)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}hl(t){var e=Ft.ph_load_toolbar||Ft.ph_load_editor;!x(e)&&_(e)?e(t,this.instance):or.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==kt||!kt.getElementById(le));if(!wt||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(wt.localStorage.setItem(ar,JSON.stringify(i({},s,{source:void 0}))),2===this.ul())this.hl(s);else if(0===this.ul()){var n;this.ll(1),null==(n=Ft.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return or.error("[Toolbar] Failed to load",t),void this.ll(0);this.ll(2),this.hl(s)})),Ot(wt,"turbolinks:load",(()=>{this.ll(0),this.loadToolbar(s)}))}return!0}cl(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Cr=i({experiments:gr},br),Rr={conversations:class{constructor(t){this.dl=void 0,this._conversationsManager=null,this.vl=!1,this.fl=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;x(e)||(k(e)?this.dl=e:(this.dl=e.enabled,this.fl=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.dl=void 0,this.fl=null}loadIfEnabled(){if(!(this._conversationsManager||this.vl||this._instance.config.disable_conversations||Mt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t&&!b(this.dl)&&this.dl)if(this.fl&&this.fl.token){this.vl=!0;try{var e=t.initConversations;if(e)return this.pl(e),void(this.vl=!1);var i=t.loadExternalDependency;if(!i)return void this.gl(ue);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.gl("Could not load conversations script",e):this.pl(t.initConversations),this.vl=!1}))}catch(t){this.gl("Error initializing conversations",t),this.vl=!1}}else _r.error("Conversations enabled but missing token in remote config.")}}pl(t){if(this.fl)try{this._conversationsManager=t(this.fl,this._instance),_r.info("Conversations loaded successfully")}catch(t){this.gl("Error completing conversations initialization",t)}else _r.error("Cannot complete initialization: remote config is null")}gl(t,e){_r.error(t,e),this._conversationsManager=null,this.vl=!1}show(){this._conversationsManager?this._conversationsManager.show():_r.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.dl&&!w(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,i,r){var s=this;return e((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,r):(_r.warn(mr),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(_r.warn(mr),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(_r.warn(mr),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(_r.warn(mr),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(_r.warn(mr),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(_r.warn(mr),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(_r.warn(mr),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}hs(){var t;null==(t=this._conversationsManager)||t.setIdentity()}cs(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},$r={logs:class{constructor(t){var e;this.ml=!1,this.yl=!1,this.Qt=Rt("[logs]"),this.Mi=[],this.bl=()=>{var t;null==(t=this._l)||t.onReconnect()},this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.ml=!0),wt&&Ot(wt,"online",this.bl)}wl(){var t,e,i,r,s,n,a,o,l,u,h,v,d,c,f=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this._l&&this.xl===f||(null==(e=this._l)||e.reset(),this.xl=f,this.kl=(u=null!==(r=null==(i=f)?void 0:i.flushIntervalMs)&&void 0!==r?r:3e3,h=null!==(s=null==i?void 0:i.maxBufferSize)&&void 0!==s?s:100,v=null!==(n=null==i?void 0:i.maxLogsPerInterval)&&void 0!==n?n:1e3,d=Math.max(h,v),{serviceName:null!==(a=null==(c=null==i?void 0:i.resourceAttributes)?void 0:c["service.name"])&&void 0!==a?a:null==i?void 0:i.serviceName,serviceVersion:null!==(o=null==c?void 0:c["service.version"])&&void 0!==o?o:null==i?void 0:i.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==i?void 0:i.environment,resourceAttributes:c,beforeSend:null==i?void 0:i.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}),this._l=new z(this.Sl(),this.kl,this.Qt,(()=>this.Cl()),(t=>t()))),this._l}Il(){return this.wl(),this.kl}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!x(i)&&i&&(this.ml=!0,this.loadIfEnabled())}reset(){var t;this.Mi=[],null==(t=this._l)||t.reset()}captureLog(t){this.wl().captureLog(t)}get logger(){return this.Tl||(this.Tl={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Tl}flushLogs(t){t?this.El(t):this.wl().flush().catch((t=>this.Qt.error("PostHog logs flush failed:",t)))}loadIfEnabled(){if(this.ml&&!this.yl){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Qt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.yl=!0)})):this.Qt.error(ue)}else this.Qt.error("PostHog Extensions not found.")}}Sl(){var t=this._instance;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},getPersistedProperty:t=>t===l.LogsQueue?this.Mi:void 0,setPersistedProperty:(t,e)=>{var i;t===l.LogsQueue&&(this.Mi=null!==(i=e)&&void 0!==i?i:[])},kr:t=>this.kr(t),getLibraryId:()=>s,getLibraryVersion:()=>r}}kr(t){return new Promise((e=>{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this.Ml(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}))}El(t){var e=this.Il();if(0!==this.Mi.length){var i=this.Mi.map((t=>t.record));this.Mi=[];var n=N(i,D(e,s,r),s,r);this._instance._send_request({method:"POST",url:this.Ml(),data:n,compression:"best-available",batchKey:"logs",transport:t})}}Ml(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Cl(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i}if(null!=Ft&&null!=(t=Ft.location)&&t.href&&(e.currentUrl=Ft.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(e.activeFeatureFlags=r)}return e}}},Ir=i({},br,yr,wr,xr,Er,kr,Fr,Sr,Pr,Cr,Rr,$r),Ar=br,Tr=yr,Or=wr,Mr=xr,jr=Er,Lr=kr,Dr=Fr,Nr=Sr,zr=Pr,Ur=Cr,Hr=Rr,Vr=$r;export{Ir as AllExtensions,Or as AnalyticsExtensions,Hr as ConversationsExtensions,Mr as ErrorTrackingExtensions,Ur as ExperimentsExtensions,Ar as FeatureFlagsExtensions,Vr as LogsExtensions,jr as ProductToursExtensions,Tr as SessionReplayExtensions,Lr as SiteAppsExtensions,Dr as SurveysExtensions,zr as ToolbarExtensions,Nr as TracingExtensions};
1
+ function t(t,e,i,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,s)}function e(e){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=e.apply(i,r);function o(e){t(a,s,n,o,l,"next",e)}function l(e){t(a,s,n,o,l,"throw",e)}o(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},i.apply(null,arguments)}var r="1.391.8",s="web",n=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function a(t){return"string"==typeof t||t}function o(t){return"string"==typeof t?t:void 0}var l=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.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.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}({}),u=["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"],h=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return u.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function v(t,e){return-1!==t.indexOf(e)}var d=function(t){return t.trim()},c=Object.prototype,f=c.hasOwnProperty,p=c.toString,g=Array.isArray||function(t){return"[object Array]"===p.call(t)},_=t=>"function"==typeof t,m=t=>t===Object(t)&&!g(t),b=t=>void 0===t,y=t=>"[object String]"==p.call(t),w=t=>null===t,x=t=>b(t)||w(t),E=t=>"[object Number]"==p.call(t)&&t==t,k=t=>"[object Boolean]"===p.call(t),S=t=>t instanceof FormData;function F(t){return null===t||"object"!=typeof t}function P(t,e){return{}.toString.call(t)==="[object "+e+"]"}function C(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function R(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),E(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),R(i,e,i,r))}class I{constructor(t){this.$t={},this.Gt=t.Gt,this.Zt=R(t.bucketSize,0,100,t.Qt),this.Jt=R(t.refillRate,0,this.Zt,t.Qt),this.Kt=R(t.refillInterval,0,864e5,t.Qt)}Yt(t,e){var i=Math.floor((e-t.lastAccess)/this.Kt);i>0&&(t.tokens=Math.min(t.tokens+i*this.Jt,this.Zt),t.lastAccess=t.lastAccess+i*this.Kt)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.$t[r];return s?this.Yt(s,i):this.$t[r]=s={tokens:this.Zt,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.Gt)||e.call(this,t)),0===s.tokens)}stop(){this.$t={}}}function A(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var T={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}},O=T.info;function M(t){if(k(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(g(t))return{arrayValue:{values:t.map((t=>M(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function j(t){var e=[];for(var i in t){var r=t[i];w(r)||b(r)||e.push({key:i,value:M(r)})}return e}function L(t,e){var r=t.level||"info",{text:s,number:n}=T[r]||O,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var l=i({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:j(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),b(t.trace_flags)||(u.flags=t.trace_flags),u}function D(t,e,r){return i({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}function N(t,e,i,r){return{resourceLogs:[{resource:{attributes:j(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let z=class{constructor(t,e,i,r,s,n){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Dt=e,this.Qt=i,this.Xt=r,this.er=s,this.tr=n,this.rr=null,this.ir=0,this.nr=0,this.sr=0,this.ar=0,this.lr=!1,this.ur=e.maxBufferSize,this.ot=Math.max(null!==(a=e.maxQueueSize)&&void 0!==a?a:e.maxBufferSize,e.maxBufferSize),this.hr=e.flushIntervalMs,this.cr=e.maxBatchRecordsPerPost,this.dr=e.rateCapWindowMs,this.vr=e.maxLogsPerInterval}reset(){this.pr(),this.rr=null,this.sr=0,this.ar=0,this.lr=!1,this.ir=0,this.nr=0,this.cr=this.Dt.maxBatchRecordsPerPost}onReconnect(){this.nr=0,this.gr()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this.mr(t);if(null!==e)if(e.body){if(this.yr()){var i={record:L(e,this.Xt())};this.er((()=>this.br(i)))}}else this.Qt.info("Log was rejected in beforeSend function")}}mr(t){var e=this.Dt.beforeSend;if(!e)return t;var i=g(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.Qt.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.Qt.error("Error in beforeSend function for log:",t),null}return r}yr(){if(void 0===this.vr)return!0;var t=Date.now(),e=t-this.sr;return this.dr>e&&e>=0||(this.sr=t,this.ar=0,this.lr=!1),this.vr>this.ar?(this.ar++,!0):(this.lr||(this.Qt.warn("captureLog dropping logs: exceeded "+this.vr+" logs per "+this.dr+"ms"),this.lr=!0),!1)}flush(){var t=this;return e((function*(){if(!t._instance.isDisabled)return t.rr||(t.rr=t._r().finally((()=>{t.rr=null}))),t.rr}))()}_r(){var t=this;return e((function*(){var e;t.pr();var i=null!==(e=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n;t.ir=0;var a=Math.min(i.length,t.cr),o=i.slice(0,a),u=N(o.map((t=>t.record)),t.wr(),t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.kr(u);if("too-large"===h.kind&&o.length>1)t.cr=Math.max(1,Math.floor(o.length/2)),t.Qt.warn("Received 413 when sending logs batch of size "+o.length+", reducing batch size to "+t.cr);else{if("retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.Qt.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"===h.kind&&t.Dt.maxBatchRecordsPerPost>t.cr&&(t.cr=Math.min(t.Dt.maxBatchRecordsPerPost,t.cr+1)),yield t.Sr(o.length),i=null!==(n=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==n?n:[],s+=o.length,"fatal"===h.kind)throw h.error}}}))()}Sr(t){var i=this;return e((function*(){var e,r=Math.max(0,t-i.ir),s=null!==(e=i._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(l.LogsQueue,s.slice(r)),yield i.tr()}))()}wr(){return D(this.Dt,this._instance.getLibraryId(),this._instance.getLibraryVersion())}br(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];this.ot>i.length||(i.shift(),this.ir++,this.Qt.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(l.LogsQueue,i),this.ur>i.length?this.Cr():this.gr()}}Cr(t){void 0===t&&(t=this.hr),this.Ir||(this.Ir=A((()=>{this.Ir=void 0,this.gr()}),t))}Tr(){var t=Math.min(Math.max(0,this.nr-1),6);return this.hr*Math.pow(2,t)}Er(){var t=this._instance.getPersistedProperty(l.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return e((function*(){i.pr();var e=i.flush().catch((()=>{}));void 0!==t?yield Promise.race([e,new Promise((e=>A(e,t)))]):yield e}))()}flushWithTimeout(t){var i=this;return e((function*(){var e=!1,r=i.flush(),s=new Promise((i=>A((()=>{e=!0,i()}),t)));try{yield Promise.race([r,s])}finally{e&&r.catch((()=>{}))}}))()}gr(){this.flush().then((()=>{this.nr=0}),(t=>{this.nr++,this.Qt.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.Er()&&this.Cr(this.Tr())}))}pr(){this.Ir&&(clearTimeout(this.Ir),this.Ir=void 0)}};var U,H,V;function B(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return V&&i.length===H?V:(H=i.length,V=i.reduce(((i,r)=>{U||(U={});var s=U[r];if(s)i[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=e[r];if(l&&u){i[l]=u,U[r]=[l,u];break}}return i}),{}))}}class W{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var i=this;return e((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&g(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var i=this;return e((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.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,i({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:B(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var q="?";function J(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?q:i,in_app:!0};return b(r)||(n.lineno=r),b(s)||(n.colno=s),n}var K=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:q,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},G=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Y=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Q=/\((\S*)(?::(\d+))(?::(\d+))\)/,X=(t,e)=>{var i=G.exec(t);if(i){var[,r,s,n]=i;return J(e,r,q,+s,+n)}var a=Y.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=Q.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=K(a[1]||q,a[2]);return J(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},Z=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,tt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,et=(t,e)=>{var i=Z.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=tt.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||q;return[n,s]=K(n,s),J(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},it=/\(error: (.*)\)/;class rt{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=y(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return P(t,"DOMException")}isDOMError(t){return P(t,"DOMError")}}class st{match(t){return t instanceof Error}coerce(t,e){return{type:this.getType(t),value:this.getMessage(t,e),stack:this.getStack(t),cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class nt{constructor(){}match(t){return P(t,"ErrorEvent")&&null!=t.error}coerce(t,e){var i;return e.apply(t.error)||{type:"ErrorEvent",value:t.message,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}var at=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ot{match(t){return"string"==typeof t}coerce(t,e){var i,[r,s]=this.getInfos(t);return{type:null!=r?r:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(at);return r&&(e=r[1],i=r[2]),[e,i]}}var lt=["fatal","error","warning","log","info","debug"];function ut(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class ht{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:null==(i=e.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return C(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ut(t)}isSeverityLevel(t){return y(t)&&!(t=>y(t)&&0===t.trim().length)(t)&&lt.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(i instanceof Error)return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class vt{match(t){return C(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ut(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class dt{match(t){return F(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ct{match(t){return P(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!C(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return F(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.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 ft="$message",pt="$timestamp",gt=new Set([ft,pt]),_t={enabled:!0,max_bytes:32768};function mt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:_t.enabled,max_bytes:yt(t.max_bytes,_t.max_bytes)}:i({},_t)}class bt{constructor(t){this.Mr=[],this.Rr=0,this.Dt=mt(t)}setConfig(t){this.Dt=mt(t),this.Pr()}add(t){var e=function(t){var e=function(t){var e=new WeakSet;try{return JSON.stringify(t,((t,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(e.has(i))return"[Circular]";e.add(i)}return i}}))}catch(t){return}}(t);if(e)try{var i=JSON.parse(e);if(!m(i))return;var r=i,s=r[ft],n=r[pt];if(!y(s)||0===s.trim().length)return;if(!y(n)&&!E(n))return;return{step:r,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Dt.max_bytes||(this.Mr.push({step:e.step,bytes:i}),this.Rr+=i,this.Pr())}}getAttachable(){return this.Mr.map((t=>t.step))}clear(){this.Mr=[],this.Rr=0}size(){return this.Mr.length}Pr(){for(;this.Rr>this.Dt.max_bytes&&this.Mr.length>0;){var t=this.Mr.shift();t&&(this.Rr-=t.bytes)}}}function yt(t,e){if(!E(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var wt="undefined"!=typeof window?window:void 0,xt="undefined"!=typeof globalThis?globalThis:wt;"undefined"==typeof self&&(xt.self=xt),"undefined"==typeof File&&(xt.File=function(){});var Et=null==xt?void 0:xt.navigator,kt=null==xt?void 0:xt.document,St=null==xt?void 0:xt.location;null!=xt&&xt.XMLHttpRequest&&new xt.XMLHttpRequest;var Ft=null!=wt?wt:{},Pt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(wt&&(Ft.POSTHOG_DEBUG||i)&&!b(wt.console)&&wt.console){for(var r=("__rrweb_original__"in wt.console[e]?wt.console[e].__rrweb_original__:wt.console[e]),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,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>Pt(t+" "+e,i)};return r},Ct=Pt("[PostHog.js]"),Rt=Ct.createLogger;function $t(t,e){if(!x(t))if(g(t))t.forEach(e);else if(S(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)f.call(t,i)&&e(t[i],i)}var It=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function At(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var Tt=function(t){try{return t()}catch(t){return}};function Ot(t,e,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==t||t.addEventListener(e,i,{capture:s,passive:n})}function Mt(t){return"ph_toolbar_internal"===t.name}var jt="$autocapture_disabled_server_side",Lt="$heatmaps_enabled_server_side",Dt="$exception_capture_enabled_server_side",Nt="$error_tracking_suppression_rules",zt="$error_tracking_capture_extension_exceptions",Ut="$web_vitals_enabled_server_side",Ht="$product_tours_enabled_server_side",Vt="$web_vitals_allowed_metrics",Bt="$session_recording_remote_config",Wt="$enabled_feature_flags",qt="$active_feature_flags",Jt="$early_access_features",Kt="$feature_flag_details",Gt="$feature_flag_payloads",Yt="$feature_flag_request_id",Qt="$override_feature_flags",Xt="$override_feature_flag_payloads",Zt="$stored_person_properties",te="$stored_group_properties",ee="$surveys",ie="$surveys_activated",re="ph_product_tours",se="$flag_call_reported",ne="$flag_call_reported_session_id",ae="$feature_flag_errors",oe="$feature_flag_evaluated_at",le="__POSTHOG_TOOLBAR__",ue="PostHog loadExternalDependency extension not found.",he="visibilitychange",ve="beforeunload",de=1,ce=3,fe=11;function pe(t){return t instanceof Element&&(t.id===le||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ge(t){return!!t&&t.nodeType===de}function _e(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function me(t){return!!t&&t.nodeType===ce}function be(t){return!!t&&t.nodeType===fe&&ge(t.host)}function ye(t){return t?d(t).split(/\s+/):[]}function we(t){var e=null==wt?void 0:wt.location.href;return!!(e&&t&&t.some((t=>e.match(t))))}function xe(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return ye(e)}function Ee(t){return x(t)?null:d(t).split(/(\s+)/).filter((t=>We(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ke(t){var e="";return Le(t)&&!De(t)&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;me(t)&&t.textContent&&(e+=null!==(i=Ee(t.textContent))&&void 0!==i?i:"")})),d(e)}function Se(t){return b(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Fe=["a","button","form","input","select","textarea","label"];function Pe(t,e){if(b(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function Ce(t){var e=t.parentNode;return!(!e||!ge(e))&&e}var Re=[".ph-no-autocapture","[data-ph-no-autocapture]"],$e=["next","previous","prev",">","<"],Ie=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,Ae=[".ph-no-rageclick",".ph-no-capture"],Te=["","text","search","email","password","url","tel","number"];function Oe(t,e){if(!wt||Me(t))return!1;var i,r,s,n,a;if(k(e)?(i=!!e&&Ae,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:Ae,r=null==e?void 0:e.content_ignorelist,s=null!==(a=null==e?void 0:e.ignore_text_selection)&&void 0!==a&&a),!1===i)return!1;if(s&&function(t){return!(!t||!ge(t))&&(!!_e(t,"textarea")||(_e(t,"input")?v(Te,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var{targetElementList:o}=je(t,!1);return!function(t,e){if(!1===t||b(t))return!1;var i;if(!0===t)i=$e;else{if(!g(t))return!1;if(t.length>10)return Ct.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var{safeText:e,ariaLabel:r}=t;return i.some((t=>Ie(e,t)||Ie(r,t)))}))}(r,o.map((t=>{var e;return{safeText:ke(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Pe(o,i)}var Me=t=>!t||_e(t,"html")||!ge(t),je=(t,e)=>{if(!wt||Me(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!_e(s,"body");)if(be(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ce(s);if(!n)break;if(e||Fe.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=wt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Le(t){for(var e=t;e.parentNode&&!_e(e,"body");e=e.parentNode){var i=xe(e);if(v(i,"ph-sensitive")||v(i,"ph-no-capture"))return!1}if(v(xe(t),"ph-include"))return!0;var r=t.type||"";if(y(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!y(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function De(t){return!!(_e(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||_e(t,"select")||_e(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ne="(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})",ze=new RegExp("^(?:"+Ne+")$"),Ue=new RegExp(Ne),He="\\d{3}-?\\d{2}-?\\d{4}",Ve=new RegExp("^("+He+")$"),Be=new RegExp("("+He+")");function We(t,e){if(void 0===e&&(e=!0),x(t))return!1;if(y(t)){if(t=d(t),(e?ze:Ue).test((t||"").replace(/[- ]/g,"")))return!1;if((e?Ve:Be).test(t))return!1}return!0}function qe(t){var e=ke(t);return We(e=(e+" "+Je(t)).trim())?e:""}function Je(t){var e="";return t&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=ke(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Je(t)).trim())}catch(t){Ct.error("[AutoCapture]",t)}})),e}function Ke(t){return t.replace(/"|\\"/g,'\\"')}function Ge(t){var e=t.attr__class;return e?g(e)?e:ye(e):void 0}class Ye{constructor(t){this.disabled=!1===t;var e=m(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var Qe=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!g(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){Ct.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Xe=function(t,e,i){if(!t||!e||!e.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("=");g(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=s&&(d+="#"+s),d},Ze=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},ti="$copy_autocapture",ei=Rt("[AutoCapture]");function ii(t,e){return e.length>t?e.slice(0,t)+"...":e}function ri(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ge(e));return e}function si(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:u}=e;if(!ge(t))return{props:{}};for(var h=[t],d=t;d.parentNode&&!_e(d,"body");)if(be(d.parentNode))h.push(d.parentNode.host),d=d.parentNode.host;else{if(!ge(d.parentNode))break;h.push(d.parentNode),d=d.parentNode}var c,f,p=[],g={},_=!1,m=!1;if($t(h,(t=>{var e=Le(t);if(_e(t,"a")){var i=t.getAttribute("href");_=e&&!!i&&We(i)&&i}v(xe(t),"ph-no-capture")&&(m=!0),p.push(function(t,e,i,r){var s=t.tagName.toLowerCase(),n={tag_name:s};Fe.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?ii(1024,qe(t)):ii(1024,ke(t)));var a=xe(t);a.length>0&&(n.classes=a.filter((function(t){return""!==t}))),$t(t.attributes,(function(i){var s;if((!De(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&We(i.value)&&(!y(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var a=i.value;"class"===i.name&&(a=ye(a).join(" ")),n["attr__"+i.name]=ii(1024,a)}}));for(var o=1,l=1,u=t;u=ri(u);)o++,u.tagName===t.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}(t,a,o,l));var r=function(t){if(!Le(t))return{};var e={};return $t(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&We(r)&&(e[i]=r)}})),e}(t);It(g,r)})),m)return{props:{},explicitNoCapture:m};if(o||(p[0].$el_text=_e(t,"a")||_e(t,"button")?qe(t):ke(t)),_){var w,x;p[0].attr__href=_;var E=null==(w=(t=>{var e=null==kt?void 0:kt.createElement("a");return b(e)?null:(e.href=t,e)})(_))?void 0:w.host,k=null==wt||null==(x=wt.location)?void 0:x.host;E&&k&&E!==k&&(c=_)}return{props:It({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(f=p,function(t){return t.map((t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return At(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[Ke(e.toString())]=Ke(i.toString())})),(s+=":")+At(o).map((t=>{var[e,i]=t;return e+'="'+i+'"'})).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Ge(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return At(t).filter((t=>{var[e]=t;return 0===e.indexOf("attr__")})).forEach((t=>{var[e,i]=t;return r.attributes[e]=i})),r}))}(f)))},null!=(r=p[0])&&r.$el_text?{$el_text:null==(s=p[0])?void 0:s.$el_text}:{},c&&"click"===n.type?{$external_click_url:c}:{},g)}}var ni=Rt("[Dead Clicks]"),ai=()=>!0;class oi{get lazyLoadedDeadClicksAutocapture(){return this.$r}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.qr((()=>{this.jr()})):this.stop()}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?ni.error("failed to load script",e):t()}))}jr(){var t;if(kt){if(!this.$r&&null!=(t=Ft.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=m(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.$r=Ft.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.$r.start(kt),ni.info("starting...")}}else ni.error("`document` not found. Cannot start.")}stop(){this.$r&&(this.$r.stop(),this.$r=void 0,ni.info("stopping..."))}}var li=Rt("[ExceptionAutocapture]"),ui=Rt("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return E(t)&&isFinite(t)&&Math.floor(t)===t});class hi{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|e>>>8,s[7]=e,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new hi(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new hi(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class vi{constructor(){this.S=0,this.C=0,this.I=new fi}generate(){var t=this.generateOrAbort();if(b(t)){this.S=0;var e=this.generateOrAbort();if(b(e))throw new Error("Could not generate UUID after timestamp reset");return e}return t}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.M();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.M())}return hi.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}M(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var di,ci=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};wt&&!b(wt.crypto)&&crypto.getRandomValues&&(ci=t=>crypto.getRandomValues(t));class fi{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(ci(this.R),this.O=0),this.R[this.O++]}}var pi=()=>(di||(di=new vi)).generate(),gi="",_i=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function mi(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=kt),gi)return gi;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),r=Math.min(i.length,8),s="dmn_chk_"+pi().toString();!gi&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(s)&&(e.cookie=a+";max-age=0",gi=n)}return gi}(t);if(!i){var r=(t=>{var e=t.match(_i);return e?e[0]:""})(t);r!==i&&Ct.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var bi={N:()=>!!kt,D(t){Ct.error("cookieStore error: "+t)},P(t){if(kt){try{for(var e=t+"=",i=kt.cookie.split(";").filter((t=>t.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return decodeURIComponent(s.substring(e.length,s.length))}}catch(t){}return null}},F(t){var e;try{e=JSON.parse(bi.P(t))||{}}catch(t){}return e},A(t,e,i,r,s){if(!kt)return!1;try{var n="",a="",o=mi(kt.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&Ct.warn("cookieStore warning: large cookie, len="+u.length),kt.cookie=u,!0}catch(t){return!1}},q(t,e){if(null!=kt&&kt.cookie)try{bi.A(t,"",-1,e)}catch(t){return}}},yi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],wi=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...yi],xi="<masked>",Ei=["li_fat_id"];function ki(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Si=Rt("[Web Vitals]"),Fi=9e5,Pi=Rt("[RemoteConfig]");class Ci{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}xi(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}ki(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(e){t(e.json)}})}load(){try{if(this.remoteConfig)return Pi.info("Using preloaded remote config",this.remoteConfig),this.Si(this.remoteConfig),void this.Ci();if(this._instance.Ii())return void Pi.warn("Remote config is disabled. Falling back to local config.");this.xi((t=>{if(!t)return Pi.info("No config found after loading remote JS config. Falling back to JSON."),void this.ki((t=>{this.Si(t),this.Ci()}));this.Si(t),this.Ci()}))}catch(t){Pi.error("Error loading remote config",t)}}stop(){this.Ti&&(clearInterval(this.Ti),this.Ti=void 0)}refresh(){!this._instance.Ii()&&kt&&"hidden"!==kt.visibilityState&&this._instance.reloadFeatureFlags()}Ci(){var t;if(!this.Ti){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Ti=setInterval((()=>{this.refresh()}),e))}}Si(t){var e;t||Pi.error("Failed to fetch remote config from PostHog."),this._instance.Si(null!=t?t:{}),!1!==(null==t?void 0:t.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded())}}var Ri="disabled",$i="lazy_loading",Ii="awaiting_config",Ai="missing_config",Ti="base64",Oi=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},Mi={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>Oi(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!Oi(e,t))))),icontains:(t,e)=>e.map(ji).some((e=>t.map(ji).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(ji).every((e=>t.map(ji).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},ji=t=>t.toLowerCase();function Li(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(b(s)||w(s))return!1;var n=[String(s)],a=Mi[r.operator];return!!a&&a(r.values,n)}))}Rt("[SessionRecording]"),Rt("[SessionRecording]");var Di="[SessionRecording]",Ni=Rt(Di),zi=Rt("[Heatmaps]");function Ui(t){return m(t)&&"clientX"in t&&"clientY"in t&&E(t.clientX)&&E(t.clientY)}var Hi=Rt("[Product Tours]"),Vi=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Ht))},Bi=["$set_once","$set"],Wi=Rt("[SiteApps]"),qi="Error while initializing PostHog app with config id ",Ji="events",Ki="cancelEvents",Gi="survey shown",Yi=Rt("[Surveys]"),Qi=["popover","widget","api"];class Xi{constructor(){this.Xi={}}on(t,e){return this.Xi[t]||(this.Xi[t]=[]),this.Xi[t].push(e),()=>{this.Xi[t]=this.Xi[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Xi[t]||[])i(e);for(var r of this.Xi["*"]||[])r(t,e)}}function Zi(t,e,i){if(x(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class tr{constructor(t){this.fs=new Xi,this.ps=(t,e)=>this.gs(t,e)&&this.ys(t,e)&&this.bs(t,e)&&this._s(t,e),this.gs=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.ws=new Set,this.xs=new Set}init(){var t,e;b(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!b(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.xs)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.ws)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.ws.has(t)||this.ws.has(null==e?void 0:e.event))&&this.xs&&(null==(i=this.xs)?void 0:i.size)>0&&this.xs.forEach((t=>{this.ks(e,t)&&this.fs.emit("actionCaptured",t.name)}))}Ss(t){this.onAction("actionCaptured",(e=>t(e)))}ks(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.ps(t,i))return!0;return!1}onAction(t,e){return this.fs.on(t,e)}ys(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Zi(r,e.url,e.url_matching||"contains"))return!1}return!0}bs(t,e){return!!this.Cs(t,e)&&!!this.Is(t,e)&&!!this.Ts(t,e)}Cs(t,e){var i;if(null==e||!e.href)return!0;var r=this.Es(t);if(r.length>0)return r.some((t=>Zi(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Zi((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}Is(t,e){var i;if(null==e||!e.text)return!0;var r=this.Es(t);if(r.length>0)return r.some((t=>Zi(t.text,e.text,e.text_matching||"exact")||Zi(t.$el_text,e.text,e.text_matching||"exact")));var s,n,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!x(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),n=e.text,a=e.text_matching||"exact",s.some((t=>Zi(t,n,a))))}Ts(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}Es(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}_s(t,e){return null==e||!e.properties||0===e.properties.length||Li(e.properties.reduce(((t,e)=>{var i=g(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class er{constructor(t){this.Ms=[],this._instance=t,this.Rs=new Map,this.Ps=new Map,this.Os=new Map}Ls(t,e){return!!t&&Li(t.propertyFilters,null==e?void 0:e.properties)}As(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}Fs(t,e,i){var r=(i===Ji?this.Rs:this.Ps).get(t),s=[];return this.Ns((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[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Ls(n,e)}))}register(t){var e;b(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Ds(t),this.$s(t))}$s(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.qs&&(this.qs=new tr(this._instance),this.qs.init(),this.qs.Ss((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.qs)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.Os.get(e.name);i&&i.push(t.id),this.Os.set(e.name,i||[t.id])}})))})))}Ds(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.Rs=this.As(t,Ji),this.Ps=this.As(t,Ki))}onEvent(t,e){var i,r,s=this.ce(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.js(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Bs([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),void this.Hs(n)}if(this.Ps.has(t)){var o=this.Fs(t,e,Ki);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Bs(o.map((t=>t.id))),o.forEach((t=>this.Us(t.id))))}if(this.Rs.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.Rs.get(t)});var l=this.Fs(t,e,Ji);this.zs(l.map((t=>t.id)))}}onAction(t){this.Os.has(t)&&this.zs(this.Os.get(t)||[])}zs(t){0!==t.length&&(this.Ms=[...new Set([...this.Ms,...t])],this.ce().info("updating activated items",{activatedItems:this.getActivatedIds()}))}Hs(t){this.Ms=this.Ms.filter((e=>e!==t));var e=this.Vs();e.includes(t)||this.Ws([...e,t])}Bs(t){var e=new Set(t);this.Ms=this.Ms.filter((t=>!e.has(t)));var i=this.Vs(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&this.Ws(r)}Vs(){var t,e=this.Gs();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getActivatedIds(){return[...new Set([...this.Vs(),...this.Ms])].filter((t=>!this.Zs(t)))}reset(){this.Ms=[],this.Vs().length>0&&this.Ws([])}getEventToItemsMap(){return this.Rs}Qs(){return this.qs}}class ir extends er{constructor(t){super(t)}Gs(){return ie}Js(){return Gi}Ns(t){var e;null==(e=this._instance)||e.getSurveys(t)}Us(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}ce(){return Yi}Ws(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[ie]:t})}Zs(){return!1}js(t,e){var i;this.Ns((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e,i,r,s=(null!==(e=null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==e?e:0)>0;return"always"===t.schedule||!(null==(r=t.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?t===Gi?"consume":"ignore":t===Gi?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var rr="SDK is not enabled or survey functionality is not yet loaded",sr="Disabled. Not loading surveys.",nr=null!=wt&&wt.location?Ze(wt.location.hash,"__posthog")||Ze(location.hash,"state"):null,ar="_postHogToolbarParams",or=Rt("[Toolbar]"),lr=Rt("[FeatureFlags]"),ur=Rt("[FeatureFlags]",{debugEnabled:!0}),hr="\" failed. Feature flags didn't load in time.",vr=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},dr=t=>{var e={};for(var[i,r]of At(t||{}))r&&(e[i]=r);return e},cr=Rt("[Error tracking]"),fr="Refusing to render web experiment since the viewer is a likely bot",pr={icontains:(t,e)=>!!wt&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!wt&&-1===e.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>!!wt&&Oi(e.href,t),not_regex:(t,e)=>!!wt&&!Oi(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class gr{get Dt(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{gr.Ks("retrieved web experiments from the server"),e.Ys=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.Ys&&(gr.Ks("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.Ys)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);y(r)&&t.variants[r]&&e.Xs(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];gr.eo(n)&&e.Xs(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())gr.Ks(fr);else if(!this.Dt.disable_web_experiments){if(x(this.Ys))return this.Ys=new Map,this.loadIfEnabled(),void this.previewWebExperiment();gr.Ks("applying feature flags",t),t.forEach((t=>{var e;if(this.Ys&&null!=(e=this.Ys)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.Ys)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.Xs(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=gr.getWindowLocation();if(null!=t&&t.search){var e=Qe(null==t?void 0:t.search,"__experiment_id"),i=Qe(null==t?void 0:t.search,"__experiment_variant");e&&i&&(gr.Ks("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.ro(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Dt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Dt.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Dt.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}ro(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(gr.Ks("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.Xs(r[0].name,e,r[0].variants[e].transforms))}static eo(t){return!x(t.conditions)&&gr.io(t)&&gr.no(t)}static io(t){var e;if(x(t.conditions)||x(null==(e=t.conditions)?void 0:e.url))return!0;var i,r,s,n=gr.getWindowLocation();return!!n&&(null==(i=t.conditions)||!i.url||pr[null!==(r=null==(s=t.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](t.conditions.url,n))}static getWindowLocation(){return null==wt?void 0:wt.location}static no(t){var e;if(x(t.conditions)||x(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!kt)return{};var r,s,n,a=(r=Xe(kt.URL,[],xi),s=wi.concat([]),n={},$t(s,(function(t){var e=Qe(r,t);n[t]=e||null})),n),o=function(){var t={};return $t(Ei,(function(e){var i=bi.P(e);t[e]=i||null})),t}();return It(o,a)}();if(i.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)==i.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)==i.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)==i.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)==i.utm_term;return v&&c&&f&&d}return!1}static Ks(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];Ct.info("[WebExperiments] "+t,i)}Xs(t,e,i){this._is_bot()?gr.Ks(fr):"control"!==e?i.forEach((i=>{if(i.selector){var r;gr.Ks("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):gr.Ks("Control variants leave the page unmodified.")}_is_bot(){return Et&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&h(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>h(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(Et,this.Dt.custom_blocked_useragents):void 0}}var _r=Rt("[Conversations]"),mr="Conversations not available yet.",br={featureFlags:class{constructor(t){this.so=!1,this.oo=!1,this.ao=!1,this.lo=!1,this.uo=!1,this.ho=!1,this.co=!1,this.do=!1,this._instance=t,this.featureFlagEventHandlers=[]}get Dt(){return this._instance.config}get Ki(){return this._instance.persistence}vo(t){return this._instance.get_property(t)}fo(){var t,e;return null!==(t=null==(e=this.Ki)?void 0:e.ii(this.Dt.feature_flag_cache_ttl_ms))&&void 0!==t&&t}po(){return!!this.fo()&&(this.do||this.ao||(this.do=!0,lr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}mo(){var t,e=null!==(t=this.Dt.evaluation_contexts)&&void 0!==t?t:this.Dt.evaluation_environments;return!this.Dt.evaluation_environments||this.Dt.evaluation_contexts||this.co||(lr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.co=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||lr.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}yo(){return this.mo().length>0}bo(){var t=this.Dt.flag_keys;if(!b(t)){if(g(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||lr.error("Invalid flag key found:",t,"Expected non-empty string"),e}));lr.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,{config:i}=this._instance,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(a).filter((t=>o[t])).reduce(((t,e)=>(a[e]&&(t[e]=a[e]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,e,r){var s,n,l=null!=r&&r.merge&&null!==(s=this.vo(Wt))&&void 0!==s?s:{},u=null!=r&&r.merge&&null!==(n=this.vo(Gt))&&void 0!==n?n:{},h=i({},l,t),v=i({},u,e),d={};for(var[c,f]of Object.entries(h))d[c]={key:c,enabled:a(f),variant:o(f),reason:void 0,metadata:b(null==v?void 0:v[c])?void 0:{id:0,version:void 0,description:void 0,payload:v[c]}};this.receivedFeatureFlags({flags:d})}get hasLoadedFlags(){return this.oo}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.vo(Kt),e=this.vo(Qt),r=this.vo(Xt);if(!r&&!e)return t||{};var s=It({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])];for(var a of n){var o,l,u=s[a],h=null==e?void 0:e[a],v=b(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=b(h)?u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=i({},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=i({},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.so||(lr.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.so=!0),s}getFlagVariants(){var t=this.vo(Wt),e=this.vo(Qt);if(!e)return t||{};for(var i=It({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.so||(lr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.so=!0),i}getFlagPayloads(){var t=this.vo(Gt),e=this.vo(Xt);if(!e)return t||{};for(var i=It({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.so||(lr.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.so=!0),i}reloadFeatureFlags(){this.lo||this.Dt.advanced_disable_feature_flags||this._o||(this._instance.Fn.emit("featureFlagsReloading",!0),this._o=setTimeout((()=>{this.wo()}),5))}xo(){clearTimeout(this._o),this._o=void 0}ensureFlagsLoaded(){this.oo||this.ao||this._o||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.lo=t}wo(t){var e;if(this.xo(),!this._instance.Ii())if(this.ao)this.uo=!0;else{var r=this.Dt.token,s=this.vo("$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:i({},(null==(e=this.Ki)?void 0:e.get_initial_props())||{},this.vo(Zt)||{}),group_properties:this.vo(te),timezone:ki()};w(s)||b(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Dt.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.yo()&&(n.evaluation_contexts=this.mo());var a=this.bo();b(a)||(n.flag_keys=a);var o=!!this.Dt.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Dt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.ao=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.Dt.disable_compression?void 0:Ti,timeout:this.Dt.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(200===t.statusCode&&(this.uo||(this.$anon_distinct_id=void 0),s=!1),this.ao=!1,!n.disable_flags||this.uo){this.ho=!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!=(e=t.json)&&e.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(i=t.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.Ki)||r.register({[ae]:a}),u)lr.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.uo&&(this.uo=!1,this.wo())}}})}}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.ho)if(this.oo||this.getFlags()&&this.getFlags().length>0){if(!this.po()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else lr.warn('getFeatureFlag for key "'+t+hr)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.ho)if(this.oo||this.getFlags()&&this.getFlags().length>0){if(!this.po()){var i=this.getFlagVariants(),r=t in i,s=i[t],a=this.getFlagPayloads()[t],o=String(s),l=this.vo(Yt)||void 0,u=this.vo(oe)||void 0,h=this.vo(se)||{};if(this.Dt.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.vo(ne);d&&d!==c&&(h={},null==(v=this.Ki)||v.register({[se]:h,[ne]:d}))}if((e.send_event||!("send_event"in e))&&(!(t in h)||!h[t].includes(o))){var f,p,_,m,y,w,x,E,k,S;g(h[t])?h[t].push(o):h[t]=[o],null==(f=this.Ki)||f.register({[se]:h});var F=this.getFeatureFlagDetails(t),P=[...null!==(p=this.vo(ae))&&void 0!==p?p:[]];b(s)&&P.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:a||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(null==(_=this.Dt.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(m=this.Dt.bootstrap)||null==(m=m.featureFlagPayloads)?void 0:m[t])||null,$used_bootstrap_value:!this.ho};b(null==F||null==(y=F.metadata)?void 0:y.version)||(C.$feature_flag_version=F.metadata.version);var R,I=null!==(w=null==F||null==(x=F.reason)?void 0:x.description)&&void 0!==w?w:null==F||null==(E=F.reason)?void 0:E.code;I&&(C.$feature_flag_reason=I),null!=F&&null!=(k=F.metadata)&&k.id&&(C.$feature_flag_id=F.metadata.id),b(null==F?void 0:F.original_variant)&&b(null==F?void 0:F.original_enabled)||(C.$feature_flag_original_response=b(F.original_variant)?F.original_enabled:F.original_variant),null!=F&&null!=(S=F.metadata)&&S.original_payload&&(C.$feature_flag_original_payload=null==F||null==(R=F.metadata)?void 0:R.original_payload),P.length&&(C.$feature_flag_error=P.join(",")),this._instance.capture("$feature_flag_called",C)}if(r)return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:n(a)}}}else lr.warn('getFeatureFlagResult for key "'+t+hr)}getRemoteConfigPayload(t,e){var i=this.Dt.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.yo()&&(r.evaluation_contexts=this.mo());var s=this.bo();b(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Dt.disable_compression?void 0:Ti,timeout:this.Dt.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;e((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,e){if(void 0===e&&(e={}),!e.fresh||this.ho){if(this.oo||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return b(i)?void 0:!!i}lr.warn('isFeatureEnabled for key "'+t+hr)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.Ki){this.oo=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,e,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var o=(t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))):lr.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(g(u)){lr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var f=0;u.length>f;f++)c[u[f]]=!0;e&&e.register({[qt]:u,[Wt]:c})}else{var p=u,_=h,m=l;if(null!=a&&a.partialResponse)p=i({},r,p),_=i({},s,_),m=i({},n,m);else if(t.errorsWhileComputingFlags)if(l){var b=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));p=i({},r,Object.fromEntries(Object.entries(p).filter((t=>{var[e]=t;return b.has(e)})))),_=i({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return b.has(e)})))),m=i({},n,Object.fromEntries(Object.entries(m||{}).filter((t=>{var[e]=t;return b.has(e)}))))}else p=i({},r,p),_=i({},s,_),m=i({},n,m);e&&e.register(i({[qt]:Object.keys(dr(p)),[Wt]:p||{},[Gt]:_||{},[Kt]:m||{}},v?{[Yt]:v}:{},d?{[oe]:d}:{}))}}}(t,this.Ki,s,n,a,r),e||(this.do=!1),this.ko(e)}}override(t,e){void 0===e&&(e=!1),lr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Ki)return lr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Ki.unregister(Qt),this.Ki.unregister(Xt),this.ko(),ur.info("All overrides cleared");if(g(t)){var e=vr(t);return this.Ki.register({[Qt]:e}),this.ko(),ur.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.so=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.Ki.unregister(Qt),ur.info("Flag overrides cleared");else if(r.flags){if(g(r.flags)){var s=vr(r.flags);this.Ki.register({[Qt]:s})}else this.Ki.register({[Qt]:r.flags});ur.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Ki.unregister(Xt),ur.info("Payload overrides cleared")):r.payloads&&(this.Ki.register({[Xt]:r.payloads}),ur.info("Payload overrides set",{payloads:r.payloads}))),void this.ko()}if(t&&"object"==typeof t)return this.Ki.register({[Qt]:t}),this.ko(),ur.info("Flag overrides set",{flags:t});lr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.oo){var{flags:e,flagVariants:i}=this.So();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.vo(Jt)||[]).find((e=>e.flagKey===t)),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this.Ki)||s.register({[qt]:Object.keys(dr(l)),[Wt]:l}),this.ko()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.vo(Jt),s=i?"&"+i.map((t=>"stage="+t)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Dt.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.Ki)||i.unregister(Jt),null==(r=this.Ki)||r.register({[Jt]:s}),t(s)}}})}So(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}ko(t){var{flags:e,flagVariants:i}=this.So();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.vo(Zt)||{},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({[Zt]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.vo(Zt)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[Zt]:r}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Zt),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.vo(te)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[te]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.vo(te)||{};this._instance.register({[te]:i({},e,{[t]:{}})})}else this._instance.unregister(te)}reset(){this.oo=!1,this.ao=!1,this.lo=!1,this.uo=!1,this.ho=!1,this.$anon_distinct_id=void 0,this.xo(),this.so=!1}}},yr={sessionRecording:class{get Dt(){return this._instance.config}get Ki(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Co)||!t.isStarted)}get status(){var t,e;return this.Io===Ii||this.Io===Ai?this.Io:null!==(t=null==(e=this.Co)?void 0:e.status)&&void 0!==t?t:this.Io}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Io=Ri,this.To=void 0,this._instance=t,!this._instance.sessionManager)throw Ni.error("started without valid sessionManager"),new Error(Di+" started without valid sessionManager. This is a bug.");if("always"===this.Dt.cookieless_mode)throw new Error(Di+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Eo(){var t,e=!(null==(t=this._instance.get_property(Bt))||!t.enabled),i=!this.Dt.disable_session_recording,r=this.Dt.disable_session_recording||this._instance.consent.isOptedOut();return wt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.Eo||null==(e=this.Co)||!e.isStarted){var i=!b(Object.assign)&&!b(Array.from);this.Eo&&i?(this.Mo(t),Ni.info("starting")):(this.Io=Ri,this.stopRecording())}}Mo(t){var e,i,r;this.Eo&&(this.Io!==Ii&&this.Io!==Ai&&(this.Io=$i),null!=Ft&&null!=(e=Ft.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=Ft.__PosthogExtensions__)&&i.initSessionRecording?this.Ro(t):null==(r=Ft.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Po,(e=>{if(e)return Ni.error("could not load recorder",e);this.Ro(t)})))}stopRecording(){var t,e;null==(t=this.To)||t.call(this),this.To=void 0,null==(e=this.Co)||e.stop()}Oo(){var t,e;null==(t=this.To)||t.call(this),this.To=void 0,null==(e=this.Co)||e.discard()}Lo(){var t,e;null==(t=this.Ki)||t.unregister("$session_is_sampled"),null==(e=this.Ki)||e.unregister("$replay_sample_rate")}Ao(t,e){if(x(t))return null;var i,r=E(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ni.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Fo(t){if(this.Ki){var e,r,s=this.Ki,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Ao(null==(e=this.Dt.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Ao(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;x(o)&&this.Lo();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[Bt]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:b(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.To)||e.call(this),this.To=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Fo(t),void this.Oo()):(this.Fo(t),void this.startIfEnabledOrStop()):(this.Io===Ii&&(this.Io=Ai,Ni.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Co)&&i.log?this.Co.log(t,e):Ni.warn("log called before recorder was ready")}get Po(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Bt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}No(){var t,e,i=this._instance.get_property(Bt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Ni.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=e.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Ro(t){var e,i;if(null==(e=Ft.__PosthogExtensions__)||!e.initSessionRecording)return Ni.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.Co||(this.Co=null==(i=Ft.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Co._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.No()){if(this.Io===Ai||this.Io===Ii)return;return this.Io=Ii,Ni.info("persisted remote config is stale, requesting fresh config before starting"),void new Ci(this._instance).load()}this.Io=$i,this.Co.start(t)}onRRwebEmit(t){var e;null==(e=this.Co)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Co||null==(e=this.Ki)||e.register({$replay_override_linked_flag:!0}),null==(t=this.Co)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Co||null==(e=this.Ki)||e.register({$replay_override_sampling:!0}),null==(t=this.Co)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Co||null==(i=this.Ki)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.Co)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Co)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Co)||!i.tryAddCustomEvent(t,e))}}},wr={autocapture:class{constructor(t){this.Do=!1,this.$o=null,this.qo=!1,this.instance=t,this.rageclicks=new Ye(t.config.rageclick),this.jo=null}initialize(){this.startIfEnabled()}get Dt(){var t,e,i=m(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}Bo(){if(this.isBrowserSupported()){if(wt&&kt){var t=t=>{t=t||(null==wt?void 0:wt.event);try{this.Ho(t)}catch(t){ei.error("Failed to capture event",t)}};if(Ot(kt,"submit",t,{capture:!0}),Ot(kt,"change",t,{capture:!0}),Ot(kt,"click",t,{capture:!0}),this.Dt.capture_copied_text){var e=t=>{t=t||(null==wt?void 0:wt.event);try{this.Ho(t,ti)}catch(t){ei.error("Failed to capture copy/cut event",t)}};Ot(kt,"copy",e,{capture:!0}),Ot(kt,"cut",e,{capture:!0})}}}else ei.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Do&&(this.Bo(),this.Do=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.qo=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[jt]:!!t.autocapture_opt_out}),this.$o=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.jo=t}getElementSelectors(t){var e,i=[];return null==(e=this.jo)||e.forEach((e=>{var r=null==kt?void 0:kt.querySelectorAll(e);null==r||r.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[jt];if(w(this.$o)&&!k(i)&&!this.instance.Ii())return!1;var r=null!==(e=this.$o)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}Ho(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=Se(t);me(r)&&(r=r.parentNode||null),"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Oe(r,this.instance.config.rageclick)&&this.Ho(t,"$rageclick");var s=e===ti;if(r&&function(t,e,i,r,s){var n,a,o,l,u,h;if(void 0===i&&(i=void 0),!wt||Me(t))return!1;if(null!=(n=i)&&n.url_allowlist&&!we(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&we(i.url_ignorelist))return!1;if(null!=(o=i)&&o.dom_event_allowlist){var v=i.dom_event_allowlist;if(v&&!v.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:d,targetElementList:c}=je(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(b(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(c,i))return!1;if(!Pe(c,null==(l=i)?void 0:l.css_selector_allowlist))return!1;if(Pe(c,null!==(u=null==(h=i)?void 0:h.css_selector_ignorelist)&&void 0!==u?u:Re))return!1;var f=wt.getComputedStyle(t);if(f&&"pointer"===f.getPropertyValue("cursor")&&"click"===e.type)return!0;var p=t.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return d?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(Fe.indexOf(p)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Dt,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=si(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Dt.element_attribute_ignorelist,elementsChainAsString:this.qo});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===ti){var l,u=Ee(null==wt||null==(l=wt.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return _(null==kt?void 0:kt.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Uo=(null==wt||null==(e=wt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Ct.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.zo&&this.zo(),this.zo=void 0,Ct.info("History API monitoring stopped")}monitorHistoryChanges(){wt&&wt.history&&(this.Vo("pushState"),this.Vo("replaceState"),this.Wo())}Vo(t){var e;if(wt&&(null==(e=wt.history[t])||!e.__posthog_wrapped__)){var i=this;!function(t,e,i){try{if(!(e in t))return()=>{};var r=t[e],s=i(r);return _(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]===s&&(t[e]=r)}}catch(t){return()=>{}}}(wt.history,t,(e=>function(r,s,n){e.call(this,r,s,n),i.Go(t)}))}}Go(t){try{var e,i=null==wt||null==(e=wt.location)?void 0:e.pathname;if(!i)return;i!==this.Uo&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.Uo=i}catch(e){Ct.error("Error capturing "+t+" pageview",e)}}Wo(){if(!this.zo){var t=()=>{this.Go("popstate")};Ot(wt,"popstate",t),this.zo=()=>{wt&&wt.removeEventListener("popstate",t)}}}},heatmaps:class{get Dt(){return this.instance.config}constructor(t){var e;this.Zo=!1,this.Do=!1,this.Qo=null,this.instance=t,this.Zo=!(null==(e=this.instance.persistence)||!e.props[Lt]),this.rageclicks=new Ye(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return m(this.Dt.capture_heatmaps)&&this.Dt.capture_heatmaps.flush_interval_milliseconds&&(t=this.Dt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return x(this.Dt.capture_heatmaps)?x(this.Dt.enable_heatmaps)?this.Zo:this.Dt.enable_heatmaps:!1!==this.Dt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Do)return;zi.info("starting..."),this.Jo(),this.Pt()}else{var t;clearInterval(null!==(t=this.Qo)&&void 0!==t?t:void 0),this.Ko(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Lt]:e}),this.Zo=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Yo(t){this._t(t.originalEvent,"deadclick")}Pt(){this.Qo&&clearInterval(this.Qo),this.Qo="visible"===(null==kt?void 0:kt.visibilityState)?setInterval(this.ji.bind(this),this.flushIntervalMilliseconds):null}Jo(){wt&&kt&&(this.Xo=this.ji.bind(this),Ot(wt,ve,this.Xo),this.ea=t=>this._t(t||(null==wt?void 0:wt.event)),Ot(kt,"click",this.ea,{capture:!0}),this.ta=t=>this.ra(t||(null==wt?void 0:wt.event)),Ot(kt,"mousemove",this.ta,{capture:!0}),this.ia=new oi(this.instance,ai,this.Yo.bind(this)),this.ia.startIfEnabledOrStop(),this.na=this.Pt.bind(this),Ot(kt,he,this.na),this.Do=!0)}Ko(){var t;wt&&kt&&(this.Xo&&wt.removeEventListener(ve,this.Xo),this.ea&&kt.removeEventListener("click",this.ea,{capture:!0}),this.ta&&kt.removeEventListener("mousemove",this.ta,{capture:!0}),this.na&&kt.removeEventListener(he,this.na),clearTimeout(this.sa),null==(t=this.ia)||t.stop(),this.Do=!1)}oa(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,e,i){for(var r=t;r&&ge(r)&&!_e(r,"body");){if(r===i)return!1;if(v(e,null==wt?void 0:wt.getComputedStyle(r).position))return!0;r=Ce(r)}return!1}(Se(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}_t(t,e){var r;if(void 0===e&&(e="click"),!pe(t.target)&&Ui(t)){var s=this.oa(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Oe(Se(t),this.instance.config.rageclick)&&this.aa(i({},s,{type:"rageclick"})),this.aa(s)}}ra(t){!pe(t.target)&&Ui(t)&&(clearTimeout(this.sa),this.sa=setTimeout((()=>{this.aa(this.oa(t,"mousemove"))}),500))}aa(t){if(wt){var e=wt.location.href,i=this.Dt.custom_personal_data_properties,r=this.Dt.mask_personal_data_properties?[...yi,...i||[]]:[],s=Xe(e,r,xi);this.R=this.R||{},this.R[s]||(this.R[s]=[]),this.R[s].push(t)}}ji(){this.R&&!(t=>{if(m(t)){for(var e in t)if(f.call(t,e))return!1;return!0}return!1})(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:oi,webVitalsAutocapture:class{constructor(t){var e;this.Zo=!1,this.Do=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.la=()=>{clearTimeout(this.ua),0!==this.R.metrics.length&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.vt=t=>{var e;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.ha();if(!b(r))if(x(null==t?void 0:t.name)||x(null==t?void 0:t.value))Si.error("Invalid metric received",t);else if(!this.ca||this.ca>t.value){this.R.url!==r&&(this.la(),this.ua=setTimeout(this.la,this.flushToCaptureTimeoutMs)),b(this.R.url)&&(this.R.url=r),this.R.firstMetricTimestamp=b(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var s=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),n=i({},t,{$current_url:r,timestamp:Date.now()});b(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.R.metrics.push(n),this.R.metrics.length===this.allowedMetrics.length&&this.la()}else Si.error("Ignoring metric with value >= "+this.ca,t)},this.da=()=>{if(!this.Do){var t,e,i,r,s=Ft.__PosthogExtensions__;b(s)||b(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.vt.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.vt.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.vt.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.vt.bind(this)),this.Do=!0):Si.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Zo=!(null==(e=this._instance.persistence)||!e.props[Ut]),this.startIfEnabled()}get va(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=m(this.va)?null==(t=this.va)?void 0:t.web_vitals_allowed_metrics:void 0;return x(i)?(null==(e=this._instance.persistence)?void 0:e.props[Vt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(m(this.va)?this.va.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=m(this.va)?this.va.web_vitals_attribution:void 0;return null!=t&&t}get ca(){var t=m(this.va)&&E(this.va.__web_vitals_max_value)?this.va.__web_vitals_max_value:Fi;return t>0&&6e4>=t?Fi:t}get isEnabled(){var t=null==St?void 0:St.protocol;if("http:"!==t&&"https:"!==t)return Si.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=m(this.va)?this.va.web_vitals:k(this.va)?this.va:void 0;return k(e)?e:this.Zo}startIfEnabled(){this.isEnabled&&!this.Do&&(Si.info("enabled, starting..."),this.qr(this.da))}onRemoteConfig(t){if("capturePerformance"in t){var e=m(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=m(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ut]:e}),this._instance.persistence.register({[Vt]:i})),this.Zo=e,this.startIfEnabled()}}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?Si.error("failed to load script",e):t()}))}ha(){var t=wt?wt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...yi,...e||[]]:[];return Xe(t,i,xi)}Si.error("Could not determine current URL")}}},xr={exceptionObserver:class{constructor(t){var e,i,r;this.da=()=>{var t;if(wt&&this.isEnabled&&null!=(t=Ft.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.fa&&this.Dt.capture_unhandled_errors&&(this.fa=e(this.captureException.bind(this))),!this.pa&&this.Dt.capture_unhandled_rejections&&(this.pa=i(this.captureException.bind(this))),!this.ga&&this.Dt.capture_console_errors&&(this.ga=r(this.captureException.bind(this)))}catch(t){li.error("failed to start",t),this.ma()}}},this._instance=t,this.ya=!(null==(e=this._instance.persistence)||!e.props[Dt]),this.ba=new I({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,Qt:li}),this.Dt=this._a(),this.startIfEnabledOrStop()}_a(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return m(t)?e=i({},e,t):(b(t)?this.ya:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Dt.capture_console_errors||this.Dt.capture_unhandled_errors||this.Dt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(li.info("enabled"),this.ma(),this.qr(this.da)):this.ma()}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return li.error("failed to load script",e);t()}))}ma(){var t,e,i;null==(t=this.fa)||t.call(this),this.fa=void 0,null==(e=this.pa)||e.call(this),this.pa=void 0,null==(i=this.ga)||i.call(this),this.ga=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.ya=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Dt]:this.ya}),this.Dt=this._a(),this.startIfEnabledOrStop())}onConfigChange(){this.Dt=this._a()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.ba.consumeRateLimit(s)?li.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,r;this.wa=[],this.xa=new W([new rt,new ct,new nt,new st,new vt,new ht,new ot,new dt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=it.test(l)?l.replace(it,"$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 e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||q});var r}))}(n)}}("web:javascript",X,et)),this._instance=t,this.wa=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property(Nt))&&void 0!==e?e:[],this.ka=mt(this.Sa()),this.Ca=new bt(this.ka)}onConfigChange(){this.ka=mt(this.Sa()),this.Ca.setConfig(this.ka)}onRemoteConfig(t){var e,i,r;if("errorTracking"in t){var s=null!==(e=null==(i=t.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],n=null==(r=t.errorTracking)?void 0:r.captureExtensionExceptions;this.wa=s,this._instance.persistence&&this._instance.persistence.register({[Nt]:this.wa,[zt]:n})}}get Ia(){var t,e=!!this._instance.get_property(zt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.xa.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.ka.enabled)try{if(!y(t)||0===t.trim().length)return void cr.warn("Ignoring exception step because message must be a non-empty string");var r=this.Ta(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>gt.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&cr.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Ca.add(i({[ft]:t,[pt]:(new Date).toISOString()},s))}catch(t){cr.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Ea(e)){if(this.Ma(e))return this.Ra("Exception dropped: matched a suppression rule"),void cr.info("Skipping exception capture because a suppression rule matched");if(!this.Ia&&this.Pa(e))return this.Ra("Exception dropped: thrown by a browser extension"),void cr.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Oa(e))return this.Ra("Exception dropped: thrown by the PostHog SDK"),void cr.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.ka.enabled&&x(t.$exception_steps)?this.La(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",rs:!0});return r&&this.Ca.clear(),r}catch(t){return cr.error("Failed to capture exception event. Dropping this exception.",t),void this.Ca.clear()}}catch(t){return void cr.error("Failed to process exception event. Ignoring this exception.",t)}}La(t){try{var e=this.Ca.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return cr.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Ra(t){this.ka.enabled&&this.Ca.add({[ft]:t,[pt]:(new Date).toISOString()})}Ta(t){return m(t)?i({},t):{}}Sa(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Ma(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return y(i)&&i.length>0&&t.$exception_types.push(i),y(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.wa.some((t=>{var i=t.values.map((t=>{var i,r=Mi[t.operator],s=g(t.value)?t.value:[t.value],n=null!==(i=e[t.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}Pa(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}Oa(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],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}Ea(t){return!x(t)&&g(t)}}},Er=i({productTours:class{get Ki(){return this._instance.persistence}constructor(t){this.Aa=null,this.Fa=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if("productTours"in t){var e,i;if(this.Ki&&this.Ki.register({[Ht]:!!t.productTours}),!Vi(this._instance))return!this.Aa&&x(null==(e=this.Ki)?void 0:e.props[re])||Hi.info("product tours disabled; stopping and clearing cached tours"),null==(i=this.Aa)||i.stop(),this.Aa=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Aa&&Vi(this._instance)&&this.qr((()=>this.Na()))}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Hi.error("Could not load product tours script",e):t()}))}Na(){var t;!this.Aa&&null!=(t=Ft.__PosthogExtensions__)&&t.generateProductTours&&(this.Aa=Ft.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!g(this.Fa)||e){var i=this.Ki;if(i){var r=i.props[re];if(g(r)&&!e)return this.Fa=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",callback:e=>{if(Vi(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Hi.error(s),void t([],{isLoaded:!1,error:s})}var n=g(e.json.product_tours)?e.json.product_tours:[];this.Fa=n,i&&i.register({[re]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Fa,{isLoaded:!0})}getActiveProductTours(t){x(this.Aa)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Aa.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Aa)||e.showTourById(t)}previewTour(t){this.Aa?this.Aa.previewTour(t):this.qr((()=>{var e;this.Na(),null==(e=this.Aa)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Aa)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Aa)||t.nextStep()}previousStep(){var t;null==(t=this.Aa)||t.previousStep()}clearCache(){var t;this.Fa=null,null==(t=this.Ki)||t.unregister(re)}resetTour(t){var e;null==(e=this.Aa)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Aa)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Aa)||e.cancelPendingTour(t)}}},br),kr={siteApps:class{constructor(t){this.Da=0,this._instance=t,this.$a=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}qa(t,e){if(e){var i=this.globalsForEvent(e);this.$a.push(i),this.$a.length>1e3&&(this.$a=this.$a.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.qa.bind(this));this.ja=()=>{t(),this.$a=[],this.ja=void 0}}}globalsForEvent(t){var e,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,c]of Object.entries(v))u[d]={id:h[d],type:d,properties:c};var{$set_once:f,$set:p}=t;return{event:i({},function(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}(t,Bi),{properties:i({},t.properties,p?{$set:i({},null!==(e=null==(r=t.properties)?void 0:r.$set)&&void 0!==e?e:{},p)}:{},f?{$set_once:i({},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}}Ba(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Wi.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Wi.error("prepare_external_dependency_script returned null"),null):t}Ha(){var t,e,i,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==kt?void 0:kt.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Da++,this.Ua)return this.za();var h=[],v=this,d=new WeakSet,c=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),h.push((()=>{t[e]=r}))}},f=t=>{if(d.has(t))return t;var e=v.Ba(t);return e&&d.add(e),e},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!w(t)));return c(u,"appendChild",(t=>function(e){var i=f(e);return i?t.call(this,i):e})),c(u,"insertBefore",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):e})),c(u,"replaceChild",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):i})),[null==(e=l.Element)?void 0:e.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((t=>{c(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}))})),[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 e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=p(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",(t=>function(e,i){var r=f(i);return r?t.call(this,e,r):null})),this.Ua=()=>{h.forEach((t=>t())),this.Ua=void 0},this.za()}za(){var t=!1;return()=>{var e;t||(t=!0,this.Da--,0===this.Da&&(null==(e=this.Ua)||e.call(this)))}}Va(t,e){void 0===e&&(e=!0);var i=this.Ha();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.$a.length&&(Wi.info("Processing "+this.$a.length+" events for site app with id "+t.id),this.$a.forEach((t=>this.Va((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.ja)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Wi.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this.Va((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1);n&&(e.processEvent=n),r=!0}catch(e){Wi.error(qi+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Wi.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Wa(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Ga(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Va((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Wi.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Wa(),void this._instance.on("eventCaptured",(t=>this.Ga(t)))):void Wi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.ja)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;Ft["__$$ph_site_app_"+t]=s._instance,null==(e=Ft.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Wi.error(qi+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Wi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Sr={tracingHeaders:class{constructor(t){this.Za=void 0,this.Qa=void 0,this.Ja=void 0,this.da=()=>{var t,e,i=this.Ka();i?(b(this.Za)&&(this.Za=null==(t=Ft.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),b(this.Qa)&&(this.Qa=null==(e=Ft.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.ma()},this._instance=t}initialize(){this.startIfEnabledOrStop()}qr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return ui.error("failed to load script",e);t()}))}Ya(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Ka(){var t=this.Ya();return g(t)?(g(this.Ja)?this.Ja.splice(0,this.Ja.length,...t):this.Ja=[...t],t.length>0?this.Ja:void 0):(g(this.Ja)&&this.Ja.splice(0),this.Ja=t||void 0,this.Ja)}ma(){var t,e;null==(t=this.Za)||t.call(this),null==(e=this.Qa)||e.call(this),this.Za=void 0,this.Qa=void 0}startIfEnabledOrStop(){this.Ka()?this.qr(this.da):this.ma()}}},Fr=i({surveys:class{get Dt(){return this._instance.config}constructor(t){this.Xa=void 0,this._surveyManager=null,this.el=!1,this.tl=[],this.rl=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Dt.disable_surveys){var e=t.surveys;if(x(e))return Yi.warn("Flags not loaded yet. Not loading surveys.");var i=g(e);this.Xa=i?e.length>0:e,Yi.info("flags response received, isSurveysEnabled: "+this.Xa),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.el)Yi.info("Already initializing surveys, skipping...");else if(this.Dt.disable_surveys)Yi.info(sr);else if(this.Dt.cookieless_mode&&this._instance.consent.isOptedOut())Yi.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){if(!b(this.Xa)||this.Dt.advanced_enable_surveys){var e=this.Xa||this.Dt.advanced_enable_surveys;this.el=!0;try{var i=t.generateSurveys;if(i)return void this.il(i,e);var r=t.loadExternalDependency;if(!r)return void this.nl(ue);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.nl("Could not load surveys script",i):this.il(t.generateSurveys,e)}))}catch(t){throw this.nl("Error initializing surveys",t),t}finally{this.el=!1}}}else Yi.error("PostHog Extensions not found.")}}il(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new ir(this._instance),Yi.info("Surveys loaded successfully"),this.sl({isLoaded:!0})}nl(t,e){Yi.error(t,e),this.sl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.tl.push(t),this._surveyManager&&this.sl({isLoaded:!0}),()=>{this.tl=this.tl.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Dt.disable_surveys)return Yi.info(sr),t([]);var i,r=this._instance.get_property(ee);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.rl?this.rl.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.rl=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Dt.token),method:"GET",timeout:this.Dt.surveys_request_timeout_ms,callback:e=>{var r;this.rl=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Yi.error(n);var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}var o,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(function(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[ee]:l,$surveys_loaded_at:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}sl(t){for(var e of this.tl)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Yi.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!x(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Yi.warn("init was not called")}ol(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}al(t){if(x(this._surveyManager))return{eligible:!1,reason:rr};var e="string"==typeof t?this.ol(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(x(this._surveyManager))return Yi.warn("init was not called"),{visible:!1,disabledReason:rr};var e=this.al(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return x(this._surveyManager)?(Yi.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:rr})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this.al(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(x(this._surveyManager))Yi.warn("init was not called");else{var s="string"==typeof t?this.ol(t):t;if(null!=s&&s.id)if(Qi.includes(s.type)){var n=null==kt?void 0:kt.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Yi.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Yi.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(s,n,i),Yi.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Yi.warn("Survey element not found")}else Yi.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Yi.warn("Survey not found")}}displaySurvey(t,e){var r;if(x(this._surveyManager))Yi.warn("init was not called");else{var s=this.ol(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&Yi.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void Yi.warn("Survey is not eligible to be displayed: ",a.disabledReason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else Yi.warn("Survey not found")}}cancelPendingSurvey(t){x(this._surveyManager)?Yi.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},br),Pr={toolbar:class{constructor(t){this.instance=t}ll(t){Ft.ph_toolbar_state=t}ul(){var t;return null!==(t=Ft.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),Mt(this.instance.config))return!1;if(!wt||!kt)return!1;t=null!=t?t:wt.location,i=null!=i?i:wt.history;try{if(!e){try{wt.localStorage.setItem("test","test"),wt.localStorage.removeItem("test")}catch(t){return!1}e=null==wt?void 0:wt.localStorage}var r,s=nr||Ze(t.hash,"__posthog")||Ze(t.hash,"state"),n=s?Tt((()=>JSON.parse(atob(decodeURIComponent(s)))))||Tt((()=>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:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(ar)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}hl(t){var e=Ft.ph_load_toolbar||Ft.ph_load_editor;!x(e)&&_(e)?e(t,this.instance):or.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==kt||!kt.getElementById(le));if(!wt||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(wt.localStorage.setItem(ar,JSON.stringify(i({},s,{source:void 0}))),2===this.ul())this.hl(s);else if(0===this.ul()){var n;this.ll(1),null==(n=Ft.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return or.error("[Toolbar] Failed to load",t),void this.ll(0);this.ll(2),this.hl(s)})),Ot(wt,"turbolinks:load",(()=>{this.ll(0),this.loadToolbar(s)}))}return!0}cl(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Cr=i({experiments:gr},br),Rr={conversations:class{constructor(t){this.dl=void 0,this._conversationsManager=null,this.vl=!1,this.fl=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;x(e)||(k(e)?this.dl=e:(this.dl=e.enabled,this.fl=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.dl=void 0,this.fl=null}loadIfEnabled(){if(!(this._conversationsManager||this.vl||this._instance.config.disable_conversations||Mt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t&&!b(this.dl)&&this.dl)if(this.fl&&this.fl.token){this.vl=!0;try{var e=t.initConversations;if(e)return this.pl(e),void(this.vl=!1);var i=t.loadExternalDependency;if(!i)return void this.gl(ue);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.gl("Could not load conversations script",e):this.pl(t.initConversations),this.vl=!1}))}catch(t){this.gl("Error initializing conversations",t),this.vl=!1}}else _r.error("Conversations enabled but missing token in remote config.")}}pl(t){if(this.fl)try{this._conversationsManager=t(this.fl,this._instance),_r.info("Conversations loaded successfully")}catch(t){this.gl("Error completing conversations initialization",t)}else _r.error("Cannot complete initialization: remote config is null")}gl(t,e){_r.error(t,e),this._conversationsManager=null,this.vl=!1}show(){this._conversationsManager?this._conversationsManager.show():_r.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.dl&&!w(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,i,r){var s=this;return e((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,r):(_r.warn(mr),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(_r.warn(mr),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(_r.warn(mr),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(_r.warn(mr),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(_r.warn(mr),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(_r.warn(mr),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(_r.warn(mr),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}hs(){var t;null==(t=this._conversationsManager)||t.setIdentity()}cs(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},$r={logs:class{constructor(t){var e;this.ml=!1,this.yl=!1,this.Qt=Rt("[logs]"),this.Mi=[],this.bl=()=>{var t;null==(t=this._l)||t.onReconnect()},this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.ml=!0),wt&&Ot(wt,"online",this.bl)}wl(){var t,e,i,r,s,n,a,o,l,u,h,v,d,c,f=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this._l&&this.xl===f||(null==(e=this._l)||e.reset(),this.xl=f,this.kl=(u=null!==(r=null==(i=f)?void 0:i.flushIntervalMs)&&void 0!==r?r:3e3,h=null!==(s=null==i?void 0:i.maxBufferSize)&&void 0!==s?s:100,v=null!==(n=null==i?void 0:i.maxLogsPerInterval)&&void 0!==n?n:1e3,d=Math.max(h,v),{serviceName:null!==(a=null==(c=null==i?void 0:i.resourceAttributes)?void 0:c["service.name"])&&void 0!==a?a:null==i?void 0:i.serviceName,serviceVersion:null!==(o=null==c?void 0:c["service.version"])&&void 0!==o?o:null==i?void 0:i.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==i?void 0:i.environment,resourceAttributes:c,beforeSend:null==i?void 0:i.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}),this._l=new z(this.Sl(),this.kl,this.Qt,(()=>this.Cl()),(t=>t()))),this._l}Il(){return this.wl(),this.kl}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!x(i)&&i&&(this.ml=!0,this.loadIfEnabled())}reset(){var t;this.Mi=[],null==(t=this._l)||t.reset()}captureLog(t){this.wl().captureLog(t)}get logger(){return this.Tl||(this.Tl={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Tl}flushLogs(t){t?this.El(t):this.wl().flush().catch((t=>this.Qt.error("PostHog logs flush failed:",t)))}loadIfEnabled(){if(this.ml&&!this.yl){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Qt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.yl=!0)})):this.Qt.error(ue)}else this.Qt.error("PostHog Extensions not found.")}}Sl(){var t=this._instance;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},getPersistedProperty:t=>t===l.LogsQueue?this.Mi:void 0,setPersistedProperty:(t,e)=>{var i;t===l.LogsQueue&&(this.Mi=null!==(i=e)&&void 0!==i?i:[])},kr:t=>this.kr(t),getLibraryId:()=>s,getLibraryVersion:()=>r}}kr(t){return new Promise((e=>{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this.Ml(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}))}El(t){var e=this.Il();if(0!==this.Mi.length){var i=this.Mi.map((t=>t.record));this.Mi=[];var n=N(i,D(e,s,r),s,r);this._instance._send_request({method:"POST",url:this.Ml(),data:n,compression:"best-available",batchKey:"logs",transport:t})}}Ml(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Cl(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i}if(null!=Ft&&null!=(t=Ft.location)&&t.href&&(e.currentUrl=Ft.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(e.activeFeatureFlags=r)}return e}}},Ir=i({},br,yr,wr,xr,Er,kr,Fr,Sr,Pr,Cr,Rr,$r),Ar=br,Tr=yr,Or=wr,Mr=xr,jr=Er,Lr=kr,Dr=Fr,Nr=Sr,zr=Pr,Ur=Cr,Hr=Rr,Vr=$r;export{Ir as AllExtensions,Or as AnalyticsExtensions,Hr as ConversationsExtensions,Mr as ErrorTrackingExtensions,Ur as ExperimentsExtensions,Ar as FeatureFlagsExtensions,Vr as LogsExtensions,jr as ProductToursExtensions,Tr as SessionReplayExtensions,Lr as SiteAppsExtensions,Dr as SurveysExtensions,zr as ToolbarExtensions,Nr as TracingExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map