posthog-js 1.386.1 → 1.386.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.386.1",s="web",n=["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"],a=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return n.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function o(t,e){return-1!==t.indexOf(e)}var l=function(t){return t.trim()},u=Object.prototype,h=u.hasOwnProperty,v=u.toString,d=Array.isArray||function(t){return"[object Array]"===v.call(t)},c=t=>"function"==typeof t,f=t=>t===Object(t)&&!d(t),p=t=>void 0===t,g=t=>"[object String]"==v.call(t),_=t=>null===t,b=t=>p(t)||_(t),m=t=>"[object Number]"==v.call(t)&&t==t,y=t=>"[object Boolean]"===v.call(t),w=t=>t instanceof FormData;function x(t){return null===t||"object"!=typeof t}function E(t,e){return{}.toString.call(t)==="[object "+e+"]"}function k(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function S(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),m(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),S(i,e,i,r))}class F{constructor(t){this.$t={},this.zt=t.zt,this.Gt=S(t.bucketSize,0,100,t.Zt),this.Qt=S(t.refillRate,0,this.Gt,t.Zt),this.Jt=S(t.refillInterval,0,864e5,t.Zt)}Kt(t,e){var i=Math.floor((e-t.lastAccess)/this.Jt);i>0&&(t.tokens=Math.min(t.tokens+i*this.Qt,this.Gt),t.lastAccess=t.lastAccess+i*this.Jt)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.$t[r];return s?this.Kt(s,i):this.$t[r]=s={tokens:this.Gt,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.zt)||e.call(this,t)),0===s.tokens)}stop(){this.$t={}}}var C,R,P,I={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}},T=I.info;function O(t){if(y(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(d(t))return{arrayValue:{values:t.map((t=>O(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function A(t){var e=[];for(var i in t){var r=t[i];_(r)||p(r)||e.push({key:i,value:O(r)})}return e}function j(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return P&&i.length===R?P:(R=i.length,P=i.reduce(((i,r)=>{C||(C={});var s=C[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,C[r]=[l,u];break}}return i}),{}))}}class M{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&&d(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:j(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 L="?";function D(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?L:i,in_app:!0};return p(r)||(n.lineno=r),p(s)||(n.colno=s),n}var N=(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]:L,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},z=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,U=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,H=/\((\S*)(?::(\d+))(?::(\d+))\)/,V=(t,e)=>{var i=z.exec(t);if(i){var[,r,s,n]=i;return D(e,r,L,+s,+n)}var a=U.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=H.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=N(a[1]||L,a[2]);return D(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},W=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,B=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,J=(t,e)=>{var i=W.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=B.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]||L;return[n,s]=N(n,s),D(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},q=/\(error: (.*)\)/;class G{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=g(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 E(t,"DOMException")}isDOMError(t){return E(t,"DOMError")}}class K{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 Y{constructor(){}match(t){return E(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 X=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Z{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(X);return r&&(e=r[1],i=r[2]),[e,i]}}var Q=["fatal","error","warning","log","info","debug"];function tt(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 et{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 k(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: "+tt(t)}isSeverityLevel(t){return g(t)&&!(t=>g(t)&&0===t.trim().length)(t)&&Q.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 it{match(t){return k(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+tt(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class rt{match(t){return x(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 st{match(t){return E(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(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 x(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 nt="$message",at="$timestamp",ot=new Set([nt,at]),lt={enabled:!0,max_bytes:32768};function ut(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:lt.enabled,max_bytes:vt(t.max_bytes,lt.max_bytes)}:i({},lt)}class ht{constructor(t){this.Yt=[],this.Xt=0,this.qt=ut(t)}setConfig(t){this.qt=ut(t),this.er()}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(!f(i))return;var r=i,s=r[nt],n=r[at];if(!g(s)||0===s.trim().length)return;if(!g(n)&&!m(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.qt.max_bytes||(this.Yt.push({step:e.step,bytes:i}),this.Xt+=i,this.er())}}getAttachable(){return this.Yt.map((t=>t.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var t=this.Yt.shift();t&&(this.Xt-=t.bytes)}}}function vt(t,e){if(!m(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var dt="undefined"!=typeof window?window:void 0,ct="undefined"!=typeof globalThis?globalThis:dt;"undefined"==typeof self&&(ct.self=ct),"undefined"==typeof File&&(ct.File=function(){});var ft=null==ct?void 0:ct.navigator,pt=null==ct?void 0:ct.document,gt=null==ct?void 0:ct.location;null!=ct&&ct.XMLHttpRequest&&new ct.XMLHttpRequest;var _t=null!=dt?dt:{},bt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(dt&&(_t.POSTHOG_DEBUG||i)&&!p(dt.console)&&dt.console){for(var r=("__rrweb_original__"in dt.console[e]?dt.console[e].__rrweb_original__:dt.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)=>bt(t+" "+e,i)};return r},mt=bt("[PostHog.js]"),yt=mt.createLogger;function wt(t,e){if(!b(t))if(d(t))t.forEach(e);else if(w(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)h.call(t,i)&&e(t[i],i)}var xt=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 Et(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 kt=function(t){try{return t()}catch(t){return}};function St(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 Ft(t){return"ph_toolbar_internal"===t.name}var Ct="$autocapture_disabled_server_side",Rt="$heatmaps_enabled_server_side",Pt="$exception_capture_enabled_server_side",$t="$error_tracking_suppression_rules",It="$error_tracking_capture_extension_exceptions",Tt="$web_vitals_enabled_server_side",Ot="$product_tours_enabled_server_side",At="$web_vitals_allowed_metrics",jt="$session_recording_remote_config",Mt="$enabled_feature_flags",Lt="$active_feature_flags",Dt="$early_access_features",Nt="$feature_flag_details",zt="$feature_flag_payloads",Ut="$feature_flag_request_id",Ht="$override_feature_flags",Vt="$override_feature_flag_payloads",Wt="$stored_person_properties",Bt="$stored_group_properties",Jt="$surveys",qt="$surveys_activated",Gt="ph_product_tours",Kt="$flag_call_reported",Yt="$flag_call_reported_session_id",Xt="$feature_flag_errors",Zt="$feature_flag_evaluated_at",Qt="__POSTHOG_TOOLBAR__",te="PostHog loadExternalDependency extension not found.",ee="visibilitychange",ie="beforeunload",re=1,se=3,ne=11;function ae(t){return t instanceof Element&&(t.id===Qt||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function oe(t){return!!t&&t.nodeType===re}function le(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ue(t){return!!t&&t.nodeType===se}function he(t){return!!t&&t.nodeType===ne&&oe(t.host)}function ve(t){return t?l(t).split(/\s+/):[]}function de(t){var e=null==dt?void 0:dt.location.href;return!!(e&&t&&t.some((t=>e.match(t))))}function ce(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 ve(e)}function fe(t){return b(t)?null:l(t).split(/(\s+)/).filter((t=>je(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function pe(t){var e="";return Ce(t)&&!Re(t)&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;ue(t)&&t.textContent&&(e+=null!==(i=fe(t.textContent))&&void 0!==i?i:"")})),l(e)}function ge(t){return p(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var _e=["a","button","form","input","select","textarea","label"];function be(t,e){if(p(e))return!0;var i,r=function(t){if(e.some((e=>t.matches(e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function me(t){var e=t.parentNode;return!(!e||!oe(e))&&e}var ye=["next","previous","prev",">","<"],we=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,xe=[".ph-no-rageclick",".ph-no-capture"],Ee=["","text","search","email","password","url","tel","number"];function ke(t,e){if(!dt||Se(t))return!1;var i,r,s,n,a;if(y(e)?(i=!!e&&xe,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:xe,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||!oe(t))&&(!!le(t,"textarea")||(le(t,"input")?o(Ee,(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:l}=Fe(t,!1);return!function(t,e){if(!1===t||p(t))return!1;var i;if(!0===t)i=ye;else{if(!d(t))return!1;if(t.length>10)return mt.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=>we(e,t)||we(r,t)))}))}(r,l.map((t=>{var e;return{safeText:pe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!be(l,i)}var Se=t=>!t||le(t,"html")||!oe(t),Fe=(t,e)=>{if(!dt||Se(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!le(s,"body");)if(he(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=me(s);if(!n)break;if(e||_e.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=dt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ce(t){for(var e=t;e.parentNode&&!le(e,"body");e=e.parentNode){var i=ce(e);if(o(i,"ph-sensitive")||o(i,"ph-no-capture"))return!1}if(o(ce(t),"ph-include"))return!0;var r=t.type||"";if(g(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!g(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 Re(t){return!!(le(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||le(t,"select")||le(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Pe="(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})",$e=new RegExp("^(?:"+Pe+")$"),Ie=new RegExp(Pe),Te="\\d{3}-?\\d{2}-?\\d{4}",Oe=new RegExp("^("+Te+")$"),Ae=new RegExp("("+Te+")");function je(t,e){if(void 0===e&&(e=!0),b(t))return!1;if(g(t)){if(t=l(t),(e?$e:Ie).test((t||"").replace(/[- ]/g,"")))return!1;if((e?Oe:Ae).test(t))return!1}return!0}function Me(t){var e=pe(t);return je(e=(e+" "+Le(t)).trim())?e:""}function Le(t){var e="";return t&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=pe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Le(t)).trim())}catch(t){mt.error("[AutoCapture]",t)}})),e}function De(t){return t.replace(/"|\\"/g,'\\"')}function Ne(t){var e=t.attr__class;return e?d(e)?e:ve(e):void 0}class ze{constructor(t){this.disabled=!1===t;var e=f(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 Ue=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(!d(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){mt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},He=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("=");d(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},Ve=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},We="$copy_autocapture",Be=yt("[AutoCapture]");function Je(t,e){return e.length>t?e.slice(0,t)+"...":e}function qe(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!oe(e));return e}function Ge(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:l,elementAttributeIgnoreList:u,elementsChainAsString:h}=e;if(!oe(t))return{props:{}};for(var v=[t],d=t;d.parentNode&&!le(d,"body");)if(he(d.parentNode))v.push(d.parentNode.host),d=d.parentNode.host;else{if(!oe(d.parentNode))break;v.push(d.parentNode),d=d.parentNode}var c,f,_=[],b={},m=!1,y=!1;if(wt(v,(t=>{var e=Ce(t);if(le(t,"a")){var i=t.getAttribute("href");m=e&&!!i&&je(i)&&i}o(ce(t),"ph-no-capture")&&(y=!0),_.push(function(t,e,i,r){var s=t.tagName.toLowerCase(),n={tag_name:s};_e.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Je(1024,Me(t)):Je(1024,pe(t)));var a=ce(t);a.length>0&&(n.classes=a.filter((function(t){return""!==t}))),wt(t.attributes,(function(i){var s;if((!Re(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&je(i.value)&&(!g(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var a=i.value;"class"===i.name&&(a=ve(a).join(" ")),n["attr__"+i.name]=Je(1024,a)}}));for(var o=1,l=1,u=t;u=qe(u);)o++,u.tagName===t.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}(t,a,l,u));var r=function(t){if(!Ce(t))return{};var e={};return wt(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&&je(r)&&(e[i]=r)}})),e}(t);xt(b,r)})),y)return{props:{},explicitNoCapture:y};if(l||(_[0].$el_text=le(t,"a")||le(t,"button")?Me(t):pe(t)),m){var w,x;_[0].attr__href=m;var E=null==(w=(t=>{var e=null==pt?void 0:pt.createElement("a");return p(e)?null:(e.href=t,e)})(m))?void 0:w.host,k=null==dt||null==(x=dt.location)?void 0:x.host;E&&k&&E!==k&&(c=m)}return{props:xt({$event_type:n.type,$ce_version:1},h?{}:{$elements:_},{$elements_chain:(f=_,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 Et(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[De(e.toString())]=De(i.toString())})),(s+=":")+Et(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:Ne(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Et(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=_[0])&&r.$el_text?{$el_text:null==(s=_[0])?void 0:s.$el_text}:{},c&&"click"===n.type?{$external_click_url:c}:{},b)}}var Ke=yt("[Dead Clicks]"),Ye=()=>!0;class Xe{get lazyLoadedDeadClicksAutocapture(){return this.ur}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.lr((()=>{this.hr()})):this.stop()}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.initDeadClicksAutocapture&&t(),null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?Ke.error("failed to load script",e):t()}))}hr(){var t;if(pt){if(!this.ur&&null!=(t=_t.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=f(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.ur=_t.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.ur.start(pt),Ke.info("starting...")}}else Ke.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Ke.info("stopping..."))}}var Ze=yt("[ExceptionAutocapture]"),Qe=yt("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return m(t)&&isFinite(t)&&Math.floor(t)===t});class ti{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 ti(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 ti(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 ei{constructor(){this.S=0,this.C=0,this.I=new si}generate(){var t=this.generateOrAbort();if(p(t)){this.S=0;var e=this.generateOrAbort();if(p(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.T();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return ti.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var ii,ri=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};dt&&!p(dt.crypto)&&crypto.getRandomValues&&(ri=t=>crypto.getRandomValues(t));class si{constructor(){this.M=new Uint32Array(8),this.R=1/0}nextUint32(){return this.M.length>this.R||(ri(this.M),this.R=0),this.M[this.R++]}}var ni=()=>(ii||(ii=new ei)).generate(),ai="",oi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function li(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=pt),ai)return ai;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_"+ni().toString();!ai&&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",ai=n)}return ai}(t);if(!i){var r=(t=>{var e=t.match(oi);return e?e[0]:""})(t);r!==i&&mt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var ui={O:()=>!!pt,D(t){mt.error("cookieStore error: "+t)},A(t){if(pt){try{for(var e=t+"=",i=pt.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(ui.A(t))||{}}catch(t){}return e},N(t,e,i,r,s){if(!pt)return!1;try{var n="",a="",o=li(pt.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&&mt.warn("cookieStore warning: large cookie, len="+u.length),pt.cookie=u,!0}catch(t){return!1}},q(t,e){if(null!=pt&&pt.cookie)try{ui.N(t,"",-1,e)}catch(t){return}}},hi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],vi=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...hi],di="<masked>",ci=["li_fat_id"];function fi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var pi=yt("[Web Vitals]"),gi=9e5,_i=yt("[RemoteConfig]");class bi{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=_t._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Gr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zr(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 _i.info("Using preloaded remote config",this.remoteConfig),this.Qr(this.remoteConfig),void this.Jr();if(this._instance.Kr())return void _i.warn("Remote config is disabled. Falling back to local config.");this.Gr((t=>{if(!t)return _i.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zr((t=>{this.Qr(t),this.Jr()}));this.Qr(t),this.Jr()}))}catch(t){_i.error("Error loading remote config",t)}}stop(){this.Yr&&(clearInterval(this.Yr),this.Yr=void 0)}refresh(){!this._instance.Kr()&&pt&&"hidden"!==pt.visibilityState&&this._instance.reloadFeatureFlags()}Jr(){var t;if(!this.Yr){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Yr=setInterval((()=>{this.refresh()}),e))}}Qr(t){var e;t||_i.error("Failed to fetch remote config from PostHog."),this._instance.Qr(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 mi="disabled",yi="lazy_loading",wi="awaiting_config",xi="missing_config",Ei="base64",ki=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}},Si={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=>ki(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!ki(e,t))))),icontains:(t,e)=>e.map(Fi).some((e=>t.map(Fi).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(Fi).every((e=>t.map(Fi).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)))}))},Fi=t=>t.toLowerCase();function Ci(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(p(s)||_(s))return!1;var n=[String(s)],a=Si[r.operator];return!!a&&a(r.values,n)}))}yt("[SessionRecording]"),yt("[SessionRecording]");var Ri="[SessionRecording]",Pi=yt(Ri),$i=yt("[Heatmaps]");function Ii(t){return f(t)&&"clientX"in t&&"clientY"in t&&m(t.clientX)&&m(t.clientY)}var Ti=yt("[Product Tours]"),Oi=["$set_once","$set"],Ai=yt("[SiteApps]"),ji="Error while initializing PostHog app with config id ",Mi="events",Li="cancelEvents",Di=yt("[Surveys]"),Ni=["popover","widget","api"];class zi{constructor(){this.Ii={}}on(t,e){return this.Ii[t]||(this.Ii[t]=[]),this.Ii[t].push(e),()=>{this.Ii[t]=this.Ii[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Ii[t]||[])i(e);for(var r of this.Ii["*"]||[])r(t,e)}}function Ui(t,e,i){if(b(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 Hi{constructor(t){this.Dn=new zi,this.$n=(t,e)=>this.qn(t,e)&&this.jn(t,e)&&this.Bn(t,e)&&this.Hn(t,e),this.qn=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.Un=new Set,this.zn=new Set}init(){var t,e;p(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(!p(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.zn)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.Un)||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.Un.has(t)||this.Un.has(null==e?void 0:e.event))&&this.zn&&(null==(i=this.zn)?void 0:i.size)>0&&this.zn.forEach((t=>{this.Vn(e,t)&&this.Dn.emit("actionCaptured",t.name)}))}Wn(t){this.onAction("actionCaptured",(e=>t(e)))}Vn(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.$n(t,i))return!0;return!1}onAction(t,e){return this.Dn.on(t,e)}jn(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(!Ui(r,e.url,e.url_matching||"contains"))return!1}return!0}Bn(t,e){return!!this.Gn(t,e)&&!!this.Zn(t,e)&&!!this.Qn(t,e)}Gn(t,e){var i;if(null==e||!e.href)return!0;var r=this.Jn(t);if(r.length>0)return r.some((t=>Ui(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Ui((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}Zn(t,e){var i;if(null==e||!e.text)return!0;var r=this.Jn(t);if(r.length>0)return r.some((t=>Ui(t.text,e.text,e.text_matching||"exact")||Ui(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;!b(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=>Ui(t,n,a))))}Qn(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}Jn(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Hn(t,e){return null==e||!e.properties||0===e.properties.length||Ci(e.properties.reduce(((t,e)=>{var i=d(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 Vi{constructor(t){this._instance=t,this.Kn=new Map,this.Yn=new Map,this.Xn=new Map}es(t,e){return!!t&&Ci(t.propertyFilters,null==e?void 0:e.properties)}ts(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}rs(t,e,i){var r=(i===Mi?this.Kn:this.Yn).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.es(n,e)}))}register(t){var e;p(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.ss(t),this.os(t))}os(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.us&&(this.us=new Hi(this._instance),this.us.init(),this.us.Wn((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.us)||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.Xn.get(e.name);i&&i.push(t.id),this.Xn.set(e.name,i||[t.id])}})))})))}ss(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.Kn=this.ts(t,Mi),this.Yn=this.ts(t,Li))}onEvent(t,e){var i,r=this.le(),s=this.ls(),n=this.hs(),a=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===t&&e&&a.length>0){var o,l;r.info("event matched, removing item from activated items",{event:t,eventPayload:e,existingActivatedItems:a});var u=(null==e||null==(o=e.properties)?void 0:o.$survey_id)||(null==e||null==(l=e.properties)?void 0:l.$product_tour_id);if(u){var h=a.indexOf(u);0>h||(a.splice(h,1),this.cs(a))}}else{if(this.Yn.has(t)){var v=this.rs(t,e,Li);v.length>0&&(r.info("cancel event matched, cancelling items",{event:t,itemsToCancel:v.map((t=>t.id))}),v.forEach((t=>{var e=a.indexOf(t.id);0>e||a.splice(e,1),this.ds(t.id)})),this.cs(a))}if(this.Kn.has(t)){r.info("event name matched",{event:t,eventPayload:e,items:this.Kn.get(t)});var d=this.rs(t,e,Mi);this.cs(a.concat(d.map((t=>t.id))||[]))}}}onAction(t){var e,i=this.ls(),r=(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[i])||[];this.Xn.has(t)&&this.cs(r.concat(this.Xn.get(t)||[]))}cs(t){var e=this.le(),i=[...new Set(t)].filter((t=>!this.vs(t)));e.info("updating activated items",{activatedItems:i}),this.fs(i)}getActivatedIds(){var t,e=this.ls();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getEventToItemsMap(){return this.Kn}ps(){return this.us}}class Wi extends Vi{constructor(t){super(t)}ls(){return qt}hs(){return"survey shown"}ns(t){var e;null==(e=this._instance)||e.getSurveys(t)}ds(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}le(){return Di}fs(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[qt]:t})}vs(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Bi="SDK is not enabled or survey functionality is not yet loaded",Ji="Disabled. Not loading surveys.",qi=null!=dt&&dt.location?Ve(dt.location.hash,"__posthog")||Ve(location.hash,"state"):null,Gi="_postHogToolbarParams",Ki=yt("[Toolbar]"),Yi=yt("[FeatureFlags]"),Xi=yt("[FeatureFlags]",{debugEnabled:!0}),Zi="\" failed. Feature flags didn't load in time.",Qi=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},tr=t=>{var e={};for(var[i,r]of Et(t||{}))r&&(e[i]=r);return e},er=yt("[Error tracking]"),ir="Refusing to render web experiment since the viewer is a likely bot",rr={icontains:(t,e)=>!!dt&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!dt&&-1===e.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>!!dt&&ki(e.href,t),not_regex:(t,e)=>!!dt&&!ki(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class sr{get qt(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{sr.gs("retrieved web experiments from the server"),e.ys=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.ys&&(sr.gs("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);g(r)&&t.variants[r]&&e.bs(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];sr._s(n)&&e.bs(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())sr.gs(ir);else if(!this.qt.disable_web_experiments){if(b(this.ys))return this.ys=new Map,this.loadIfEnabled(),void this.previewWebExperiment();sr.gs("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.bs(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=sr.getWindowLocation();if(null!=t&&t.search){var e=Ue(null==t?void 0:t.search,"__experiment_id"),i=Ue(null==t?void 0:t.search,"__experiment_variant");e&&i&&(sr.gs("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.ws(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.qt.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.qt.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}ws(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(sr.gs("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.bs(r[0].name,e,r[0].variants[e].transforms))}static _s(t){return!b(t.conditions)&&sr.xs(t)&&sr.ks(t)}static xs(t){var e;if(b(t.conditions)||b(null==(e=t.conditions)?void 0:e.url))return!0;var i,r,s,n=sr.getWindowLocation();return!!n&&(null==(i=t.conditions)||!i.url||rr[null!==(r=null==(s=t.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](t.conditions.url,n))}static getWindowLocation(){return null==dt?void 0:dt.location}static ks(t){var e;if(b(t.conditions)||b(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!pt)return{};var r,s,n,a=(r=He(pt.URL,[],di),s=vi.concat([]),n={},wt(s,(function(t){var e=Ue(r,t);n[t]=e||null})),n),o=function(){var t={};return wt(ci,(function(e){var i=ui.A(e);t[e]=i||null})),t}();return xt(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 gs(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];mt.info("[WebExperiments] "+t,i)}bs(t,e,i){this._is_bot()?sr.gs(ir):"control"!==e?i.forEach((i=>{if(i.selector){var r;sr.gs("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)}))}})):sr.gs("Control variants leave the page unmodified.")}_is_bot(){return ft&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&a(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>a(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(ft,this.qt.custom_blocked_useragents):void 0}}var nr=yt("[Conversations]"),ar="Conversations not available yet.",or={featureFlags:class{constructor(t){this.Ss=!1,this.Cs=!1,this.Is=!1,this.Ts=!1,this.Es=!1,this.Ms=!1,this.Rs=!1,this.Ps=!1,this._instance=t,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get Si(){return this._instance.persistence}Os(t){return this._instance.get_property(t)}Ls(){var t,e;return null!==(t=null==(e=this.Si)?void 0:e.Mr(this.qt.feature_flag_cache_ttl_ms))&&void 0!==t&&t}As(){return!!this.Ls()&&(this.Ps||this.Is||(this.Ps=!0,Yi.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Fs(){var t,e=null!==(t=this.qt.evaluation_contexts)&&void 0!==t?t:this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.Rs||(Yi.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Rs=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Yi.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}Ns(){return this.Fs().length>0}Ds(){var t=this.qt.flag_keys;if(!p(t)){if(d(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Yi.error("Invalid flag key found:",t,"Expected non-empty string"),e}));Yi.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=null!=r&&r.merge?this.getFlagVariants():{},n=null!=r&&r.merge?this.getFlagPayloads():{},a=i({},s,t),o=i({},n,e),l={};for(var[u,h]of Object.entries(a)){var v="string"==typeof h;l[u]={key:u,enabled:!!v||Boolean(h),variant:v?h:void 0,reason:void 0,metadata:p(null==o?void 0:o[u])?void 0:{id:0,version:void 0,description:void 0,payload:o[u]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this.Cs}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Os(Nt),e=this.Os(Ht),r=this.Os(Vt);if(!r&&!e)return t||{};var s=xt({},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=p(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=p(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.Ss||(Yi.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Ss=!0),s}getFlagVariants(){var t=this.Os(Mt),e=this.Os(Ht);if(!e)return t||{};for(var i=xt({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Ss||(Yi.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Ss=!0),i}getFlagPayloads(){var t=this.Os(zt),e=this.Os(Vt);if(!e)return t||{};for(var i=xt({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Ss||(Yi.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Ss=!0),i}reloadFeatureFlags(){this.Ts||this.qt.advanced_disable_feature_flags||this.$s||(this._instance.nn.emit("featureFlagsReloading",!0),this.$s=setTimeout((()=>{this.qs()}),5))}js(){clearTimeout(this.$s),this.$s=void 0}ensureFlagsLoaded(){this.Cs||this.Is||this.$s||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Ts=t}qs(t){var e;if(this.js(),!this._instance.Kr())if(this.Is)this.Es=!0;else{var r=this.qt.token,s=this.Os("$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.Si)?void 0:e.get_initial_props())||{},this.Os(Wt)||{}),group_properties:this.Os(Bt),timezone:fi()};_(s)||p(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.qt.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.Ns()&&(n.evaluation_contexts=this.Fs());var a=this.Ds();p(a)||(n.flag_keys=a);var o=!!this.qt.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.qt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Is=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.qt.disable_compression?void 0:Ei,timeout:this.qt.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(200===t.statusCode&&(this.Es||(this.$anon_distinct_id=void 0),s=!1),this.Is=!1,!n.disable_flags||this.Es){this.Ms=!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.Si)||r.register({[Xt]:a}),u)Yi.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.Es&&(this.Es=!1,this.qs())}}})}}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.Ms)if(this.Cs||this.getFlags()&&this.getFlags().length>0){if(!this.As()){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 Yi.warn('getFeatureFlag for key "'+t+Zi)}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.Ms)if(this.Cs||this.getFlags()&&this.getFlags().length>0){if(!this.As()){var i=this.getFlagVariants(),r=t in i,s=i[t],n=this.getFlagPayloads()[t],a=String(s),o=this.Os(Ut)||void 0,l=this.Os(Zt)||void 0,u=this.Os(Kt)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var h,v=this._instance.get_session_id(),c=this.Os(Yt);v&&v!==c&&(u={},null==(h=this.Si)||h.register({[Kt]:u,[Yt]:v}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(a))){var f,g,_,b,m,y,w,x,E,k;d(u[t])?u[t].push(a):u[t]=[a],null==(f=this.Si)||f.register({[Kt]:u});var S=this.getFeatureFlagDetails(t),F=[...null!==(g=this.Os(Xt))&&void 0!==g?g:[]];p(s)&&F.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:o,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(_=this.qt.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(b=this.qt.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])||null,$used_bootstrap_value:!this.Ms};p(null==S||null==(m=S.metadata)?void 0:m.version)||(C.$feature_flag_version=S.metadata.version);var R,P=null!==(y=null==S||null==(w=S.reason)?void 0:w.description)&&void 0!==y?y:null==S||null==(x=S.reason)?void 0:x.code;P&&(C.$feature_flag_reason=P),null!=S&&null!=(E=S.metadata)&&E.id&&(C.$feature_flag_id=S.metadata.id),p(null==S?void 0:S.original_variant)&&p(null==S?void 0:S.original_enabled)||(C.$feature_flag_original_response=p(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(k=S.metadata)&&k.original_payload&&(C.$feature_flag_original_payload=null==S||null==(R=S.metadata)?void 0:R.original_payload),F.length&&(C.$feature_flag_error=F.join(",")),this._instance.capture("$feature_flag_called",C)}if(r){var I=n;if(!p(n))try{I=JSON.parse(n)}catch(t){}return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:I}}}}else Yi.warn('getFeatureFlagResult for key "'+t+Zi)}getRemoteConfigPayload(t,e){var i=this.qt.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.Ns()&&(r.evaluation_contexts=this.Fs());var s=this.Ds();p(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.qt.disable_compression?void 0:Ei,timeout:this.qt.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.Ms){if(this.Cs||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return p(i)?void 0:!!i}Yi.warn('isFeatureEnabled for key "'+t+Zi)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.Si){this.Cs=!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]})))):Yi.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,c=t.evaluatedAt;if(d(u)){Yi.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var f={};if(u)for(var p=0;u.length>p;p++)f[u[p]]=!0;e&&e.register({[Lt]:u,[Mt]:f})}else{var g=u,_=h,b=l;if(null!=a&&a.partialResponse)g=i({},r,g),_=i({},s,_),b=i({},n,b);else if(t.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((t=>{var[e]=t;return m.has(e)})))),_=i({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return m.has(e)})))),b=i({},n,Object.fromEntries(Object.entries(b||{}).filter((t=>{var[e]=t;return m.has(e)}))))}else g=i({},r,g),_=i({},s,_),b=i({},n,b);e&&e.register(i({[Lt]:Object.keys(tr(g)),[Mt]:g||{},[zt]:_||{},[Nt]:b||{}},v?{[Ut]:v}:{},c?{[Zt]:c}:{}))}}}(t,this.Si,s,n,a,r),e||(this.Ps=!1),this.Bs(e)}}override(t,e){void 0===e&&(e=!1),Yi.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Si)return Yi.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Si.unregister(Ht),this.Si.unregister(Vt),this.Bs(),Xi.info("All overrides cleared");if(d(t)){var e=Qi(t);return this.Si.register({[Ht]:e}),this.Bs(),Xi.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.Ss=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.Si.unregister(Ht),Xi.info("Flag overrides cleared");else if(r.flags){if(d(r.flags)){var s=Qi(r.flags);this.Si.register({[Ht]:s})}else this.Si.register({[Ht]:r.flags});Xi.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Si.unregister(Vt),Xi.info("Payload overrides cleared")):r.payloads&&(this.Si.register({[Vt]:r.payloads}),Xi.info("Payload overrides set",{payloads:r.payloads}))),void this.Bs()}if(t&&"object"==typeof t)return this.Si.register({[Ht]:t}),this.Bs(),Xi.info("Flag overrides set",{flags:t});Yi.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Cs){var{flags:e,flagVariants:i}=this.Hs();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.Os(Dt)||[]).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.Si)||s.register({[Lt]:Object.keys(tr(l)),[Mt]:l}),this.Bs()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.Os(Dt),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.qt.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.Si)||i.unregister(Dt),null==(r=this.Si)||r.register({[Dt]:s}),t(s)}}})}Hs(){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)),{})}}Bs(t){var{flags:e,flagVariants:i}=this.Hs();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.Os(Wt)||{},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({[Wt]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Wt),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.Os(Bt)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[Bt]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.Os(Bt)||{};this._instance.register({[Bt]:i({},e,{[t]:{}})})}else this._instance.unregister(Bt)}reset(){this.Cs=!1,this.Is=!1,this.Ts=!1,this.Es=!1,this.Ms=!1,this.$anon_distinct_id=void 0,this.js(),this.Ss=!1}}},lr={sessionRecording:class{get qt(){return this._instance.config}get Si(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Us)||!t.isStarted)}get status(){var t,e;return this.zs===wi||this.zs===xi?this.zs:null!==(t=null==(e=this.Us)?void 0:e.status)&&void 0!==t?t:this.zs}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.zs=mi,this.Vs=void 0,this._instance=t,!this._instance.sessionManager)throw Pi.error("started without valid sessionManager"),new Error(Ri+" started without valid sessionManager. This is a bug.");if("always"===this.qt.cookieless_mode)throw new Error(Ri+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Ws(){var t,e=!(null==(t=this._instance.get_property(jt))||!t.enabled),i=!this.qt.disable_session_recording,r=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return dt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.Ws||null==(e=this.Us)||!e.isStarted){var i=!p(Object.assign)&&!p(Array.from);this.Ws&&i?(this.Gs(t),Pi.info("starting")):(this.zs=mi,this.stopRecording())}}Gs(t){var e,i,r;this.Ws&&(this.zs!==wi&&this.zs!==xi&&(this.zs=yi),null!=_t&&null!=(e=_t.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=_t.__PosthogExtensions__)&&i.initSessionRecording?this.Zs(t):null==(r=_t.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Qs,(e=>{if(e)return Pi.error("could not load recorder",e);this.Zs(t)})))}stopRecording(){var t,e;null==(t=this.Vs)||t.call(this),this.Vs=void 0,null==(e=this.Us)||e.stop()}Js(){var t,e;null==(t=this.Vs)||t.call(this),this.Vs=void 0,null==(e=this.Us)||e.discard()}Ks(){var t,e;null==(t=this.Si)||t.unregister("$session_is_sampled"),null==(e=this.Si)||e.unregister("$replay_sample_rate")}Ys(t,e){if(b(t))return null;var i,r=m(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Pi.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Xs(t){if(this.Si){var e,r,s=this.Si,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Ys(null==(e=this.qt.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Ys(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;b(o)&&this.Ks();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[jt]: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:p(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.Vs)||e.call(this),this.Vs=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Xs(t),void this.Js()):(this.Xs(t),void this.startIfEnabledOrStop()):(this.zs===wi&&(this.zs=xi,Pi.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.Us)&&i.log?this.Us.log(t,e):Pi.warn("log called before recorder was ready")}get Qs(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(jt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}eo(){var t,e,i=this._instance.get_property(jt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Pi.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}Zs(t){var e,i;if(null==(e=_t.__PosthogExtensions__)||!e.initSessionRecording)return Pi.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.Us||(this.Us=null==(i=_t.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Us._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.eo()){if(this.zs===xi||this.zs===wi)return;return this.zs=wi,Pi.info("persisted remote config is stale, requesting fresh config before starting"),void new bi(this._instance).load()}this.zs=yi,this.Us.start(t)}onRRwebEmit(t){var e;null==(e=this.Us)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Us||null==(e=this.Si)||e.register({$replay_override_linked_flag:!0}),null==(t=this.Us)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Us||null==(e=this.Si)||e.register({$replay_override_sampling:!0}),null==(t=this.Us)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Us||null==(i=this.Si)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.Us)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Us)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Us)||!i.tryAddCustomEvent(t,e))}}},ur={autocapture:class{constructor(t){this.ro=!1,this.io=null,this.no=!1,this.instance=t,this.rageclicks=new ze(t.config.rageclick),this.so=null}initialize(){this.startIfEnabled()}get qt(){var t,e,i=f(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}oo(){if(this.isBrowserSupported()){if(dt&&pt){var t=t=>{t=t||(null==dt?void 0:dt.event);try{this.ao(t)}catch(t){Be.error("Failed to capture event",t)}};if(St(pt,"submit",t,{capture:!0}),St(pt,"change",t,{capture:!0}),St(pt,"click",t,{capture:!0}),this.qt.capture_copied_text){var e=t=>{t=t||(null==dt?void 0:dt.event);try{this.ao(t,We)}catch(t){Be.error("Failed to capture copy/cut event",t)}};St(pt,"copy",e,{capture:!0}),St(pt,"cut",e,{capture:!0})}}}else Be.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.ro&&(this.oo(),this.ro=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.no=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ct]:!!t.autocapture_opt_out}),this.io=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.so=t}getElementSelectors(t){var e,i=[];return null==(e=this.so)||e.forEach((e=>{var r=null==pt?void 0:pt.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[Ct];if(_(this.io)&&!y(i)&&!this.instance.Kr())return!1;var r=null!==(e=this.io)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}ao(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=ge(t);ue(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())&&ke(r,this.instance.config.rageclick)&&this.ao(t,"$rageclick");var s=e===We;if(r&&function(t,e,i,r,s){var n,a,o,l;if(void 0===i&&(i=void 0),!dt||Se(t))return!1;if(null!=(n=i)&&n.url_allowlist&&!de(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&de(i.url_ignorelist))return!1;if(null!=(o=i)&&o.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:h,targetElementList:v}=Fe(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(p(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}(v,i))return!1;if(!be(v,null==(l=i)?void 0:l.css_selector_allowlist))return!1;var d=dt.getComputedStyle(t);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===e.type)return!0;var c=t.tagName.toLowerCase();switch(c){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 h?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(_e.indexOf(c)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.qt,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=Ge(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.no});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===We){var l,u=fe(null==dt||null==(l=dt.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 c(null==pt?void 0:pt.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.uo=(null==dt||null==(e=dt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(mt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.lo&&this.lo(),this.lo=void 0,mt.info("History API monitoring stopped")}monitorHistoryChanges(){dt&&dt.history&&(this.ho("pushState"),this.ho("replaceState"),this.co())}ho(t){var e;if(dt&&(null==(e=dt.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 c(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()=>{}}}(dt.history,t,(e=>function(r,s,n){e.call(this,r,s,n),i.do(t)}))}}do(t){try{var e,i=null==dt||null==(e=dt.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){mt.error("Error capturing "+t+" pageview",e)}}co(){if(!this.lo){var t=()=>{this.do("popstate")};St(dt,"popstate",t),this.lo=()=>{dt&&dt.removeEventListener("popstate",t)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(t){var e;this.vo=!1,this.ro=!1,this.fo=null,this.instance=t,this.vo=!(null==(e=this.instance.persistence)||!e.props[Rt]),this.rageclicks=new ze(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return f(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(t=this.qt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return b(this.qt.capture_heatmaps)?b(this.qt.enable_heatmaps)?this.vo:this.qt.enable_heatmaps:!1!==this.qt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ro)return;$i.info("starting..."),this.po(),this.At()}else{var t;clearInterval(null!==(t=this.fo)&&void 0!==t?t:void 0),this.mo(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Rt]:e}),this.vo=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.M;return this.M=void 0,t}yo(t){this.Mt(t.originalEvent,"deadclick")}At(){this.fo&&clearInterval(this.fo),this.fo="visible"===(null==pt?void 0:pt.visibilityState)?setInterval(this.ci.bind(this),this.flushIntervalMilliseconds):null}po(){dt&&pt&&(this.bo=this.ci.bind(this),St(dt,ie,this.bo),this._o=t=>this.Mt(t||(null==dt?void 0:dt.event)),St(pt,"click",this._o,{capture:!0}),this.wo=t=>this.xo(t||(null==dt?void 0:dt.event)),St(pt,"mousemove",this.wo,{capture:!0}),this.ko=new Xe(this.instance,Ye,this.yo.bind(this)),this.ko.startIfEnabledOrStop(),this.So=this.At.bind(this),St(pt,ee,this.So),this.ro=!0)}mo(){var t;dt&&pt&&(this.bo&&dt.removeEventListener(ie,this.bo),this._o&&pt.removeEventListener("click",this._o,{capture:!0}),this.wo&&pt.removeEventListener("mousemove",this.wo,{capture:!0}),this.So&&pt.removeEventListener(ee,this.So),clearTimeout(this.Co),null==(t=this.ko)||t.stop(),this.ro=!1)}Io(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&&oe(r)&&!le(r,"body");){if(r===i)return!1;if(o(e,null==dt?void 0:dt.getComputedStyle(r).position))return!0;r=me(r)}return!1}(ge(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}Mt(t,e){var r;if(void 0===e&&(e="click"),!ae(t.target)&&Ii(t)){var s=this.Io(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&ke(ge(t),this.instance.config.rageclick)&&this.To(i({},s,{type:"rageclick"})),this.To(s)}}xo(t){!ae(t.target)&&Ii(t)&&(clearTimeout(this.Co),this.Co=setTimeout((()=>{this.To(this.Io(t,"mousemove"))}),500))}To(t){if(dt){var e=dt.location.href,i=this.qt.custom_personal_data_properties,r=this.qt.mask_personal_data_properties?[...hi,...i||[]]:[],s=He(e,r,di);this.M=this.M||{},this.M[s]||(this.M[s]=[]),this.M[s].push(t)}}ci(){this.M&&!(t=>{if(f(t)){for(var e in t)if(h.call(t,e))return!1;return!0}return!1})(this.M)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Xe,webVitalsAutocapture:class{constructor(t){var e;this.vo=!1,this.ro=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Eo=()=>{clearTimeout(this.Mo),0!==this.M.metrics.length&&(this._instance.capture("$web_vitals",this.M.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=t=>{var e;this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.Ro();if(!p(r))if(b(null==t?void 0:t.name)||b(null==t?void 0:t.value))pi.error("Invalid metric received",t);else if(!this.Po||this.Po>t.value){this.M.url!==r&&(this.Eo(),this.Mo=setTimeout(this.Eo,this.flushToCaptureTimeoutMs)),p(this.M.url)&&(this.M.url=r),this.M.firstMetricTimestamp=p(this.M.firstMetricTimestamp)?Date.now():this.M.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()});p(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.M.metrics.push(n),this.M.metrics.length===this.allowedMetrics.length&&this.Eo()}else pi.error("Ignoring metric with value >= "+this.Po,t)},this.Oo=()=>{if(!this.ro){var t,e,i,r,s=_t.__PosthogExtensions__;p(s)||p(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.ht.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.ht.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.ht.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.ht.bind(this)),this.ro=!0):pi.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.vo=!(null==(e=this._instance.persistence)||!e.props[Tt]),this.startIfEnabled()}get Lo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=f(this.Lo)?null==(t=this.Lo)?void 0:t.web_vitals_allowed_metrics:void 0;return b(i)?(null==(e=this._instance.persistence)?void 0:e.props[At])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(f(this.Lo)?this.Lo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=f(this.Lo)?this.Lo.web_vitals_attribution:void 0;return null!=t&&t}get Po(){var t=f(this.Lo)&&m(this.Lo.__web_vitals_max_value)?this.Lo.__web_vitals_max_value:gi;return t>0&&6e4>=t?gi:t}get isEnabled(){var t=null==gt?void 0:gt.protocol;if("http:"!==t&&"https:"!==t)return pi.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=f(this.Lo)?this.Lo.web_vitals:y(this.Lo)?this.Lo:void 0;return y(e)?e:this.vo}startIfEnabled(){this.isEnabled&&!this.ro&&(pi.info("enabled, starting..."),this.lr(this.Oo))}onRemoteConfig(t){if("capturePerformance"in t){var e=f(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=f(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Tt]:e}),this._instance.persistence.register({[At]:i})),this.vo=e,this.startIfEnabled()}}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?pi.error("failed to load script",e):t()}))}Ro(){var t=dt?dt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...hi,...e||[]]:[];return He(t,i,di)}pi.error("Could not determine current URL")}}},hr={exceptionObserver:class{constructor(t){var e,i,r;this.Oo=()=>{var t;if(dt&&this.isEnabled&&null!=(t=_t.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=_t.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=_t.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=_t.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Ao&&this.qt.capture_unhandled_errors&&(this.Ao=e(this.captureException.bind(this))),!this.Fo&&this.qt.capture_unhandled_rejections&&(this.Fo=i(this.captureException.bind(this))),!this.No&&this.qt.capture_console_errors&&(this.No=r(this.captureException.bind(this)))}catch(t){Ze.error("failed to start",t),this.Do()}}},this._instance=t,this.$o=!(null==(e=this._instance.persistence)||!e.props[Pt]),this.qo=new F({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,Zt:Ze}),this.qt=this.jo(),this.startIfEnabledOrStop()}jo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return f(t)?e=i({},e,t):(p(t)?this.$o:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ze.info("enabled"),this.Do(),this.lr(this.Oo)):this.Do()}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.errorWrappingFunctions&&t(),null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return Ze.error("failed to load script",e);t()}))}Do(){var t,e,i;null==(t=this.Ao)||t.call(this),this.Ao=void 0,null==(e=this.Fo)||e.call(this),this.Fo=void 0,null==(i=this.No)||i.call(this),this.No=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.$o=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pt]:this.$o}),this.qt=this.jo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.jo()}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.qo.consumeRateLimit(s)?Ze.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.Bo=[],this.Ho=new M([new G,new st,new Y,new K,new it,new et,new Z,new rt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=q.test(l)?l.replace(q,"$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||L});var r}))}(n)}}("web:javascript",V,J)),this._instance=t,this.Bo=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property($t))&&void 0!==e?e:[],this.Uo=ut(this.zo()),this.Vo=new ht(this.Uo)}onConfigChange(){this.Uo=ut(this.zo()),this.Vo.setConfig(this.Uo)}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.Bo=s,this._instance.persistence&&this._instance.persistence.register({[$t]:this.Bo,[It]:n})}}get Wo(){var t,e=!!this._instance.get_property(It),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.Ho.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.Uo.enabled)try{if(!g(t)||0===t.trim().length)return void er.warn("Ignoring exception step because message must be a non-empty string");var r=this.Go(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>ot.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&er.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Vo.add(i({[nt]:t,[at]:(new Date).toISOString()},s))}catch(t){er.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Zo(e)){if(this.Qo(e))return this.Jo("Exception dropped: matched a suppression rule"),void er.info("Skipping exception capture because a suppression rule matched");if(!this.Wo&&this.Ko(e))return this.Jo("Exception dropped: thrown by a browser extension"),void er.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Yo(e))return this.Jo("Exception dropped: thrown by the PostHog SDK"),void er.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Uo.enabled&&b(t.$exception_steps)?this.Xo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",In:!0});return r&&this.Vo.clear(),r}catch(t){return er.error("Failed to capture exception event. Dropping this exception.",t),void this.Vo.clear()}}catch(t){return void er.error("Failed to process exception event. Ignoring this exception.",t)}}Xo(t){try{var e=this.Vo.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return er.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Jo(t){this.Uo.enabled&&this.Vo.add({[nt]:t,[at]:(new Date).toISOString()})}Go(t){return f(t)?i({},t):{}}zo(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Qo(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return g(i)&&i.length>0&&t.$exception_types.push(i),g(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Bo.some((t=>{var i=t.values.map((t=>{var i,r=Si[t.operator],s=d(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)}))}Ko(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://")))}Yo(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}Zo(t){return!b(t)&&d(t)}}},vr=i({productTours:class{get Si(){return this._instance.persistence}constructor(t){this.ea=null,this.ta=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.Si&&this.Si.register({[Ot]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.ea||(t=this._instance).config.disable_product_tours||null==(e=t.persistence)||!e.get_property(Ot)||this.lr((()=>this.ra()))}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Ti.error("Could not load product tours script",e):t()}))}ra(){var t;!this.ea&&null!=(t=_t.__PosthogExtensions__)&&t.generateProductTours&&(this.ea=_t.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!d(this.ta)||e){var i=this.Si;if(i){var r=i.props[Gt];if(d(r)&&!e)return this.ta=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=>{var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Ti.error(s),void t([],{isLoaded:!1,error:s})}var n=d(e.json.product_tours)?e.json.product_tours:[];this.ta=n,i&&i.register({[Gt]:n}),t(n,{isLoaded:!0})}})}else t(this.ta,{isLoaded:!0})}getActiveProductTours(t){b(this.ea)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.ea.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.ea)||e.showTourById(t)}previewTour(t){this.ea?this.ea.previewTour(t):this.lr((()=>{var e;this.ra(),null==(e=this.ea)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.ea)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.ea)||t.nextStep()}previousStep(){var t;null==(t=this.ea)||t.previousStep()}clearCache(){var t;this.ta=null,null==(t=this.Si)||t.unregister(Gt)}resetTour(t){var e;null==(e=this.ea)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.ea)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.ea)||e.cancelPendingTour(t)}}},or),dr={siteApps:class{constructor(t){this._instance=t,this.ia=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}na(t,e){if(e){var i=this.globalsForEvent(e);this.ia.push(i),this.ia.length>1e3&&(this.ia=this.ia.slice(10))}}get siteAppLoaders(){var t;return null==(t=_t._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.na.bind(this));this.sa=()=>{t(),this.ia=[],this.sa=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,Oi),{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}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.ia.length&&(Ai.info("Processing "+this.ia.length+" events for site app with id "+t.id),this.ia.forEach((t=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.sa)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Ai.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=t.init({posthog:this._instance,callback(t){s(t)}});n&&(e.processEvent=n),r=!0}catch(e){Ai.error(ji+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Ai.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}oa(){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)}aa(t){if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(e)}catch(e){Ai.error("Error while processing event "+t.event+" for site app "+i.id,e)}}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.oa(),void this._instance.on("eventCaptured",(t=>this.aa(t)))):void Ai.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.sa)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;_t["__$$ph_site_app_"+t]=s._instance,null==(e=_t.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Ai.error(ji+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Ai.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},cr={tracingHeaders:class{constructor(t){this.ua=void 0,this.la=void 0,this.ha=void 0,this.Oo=()=>{var t,e,i=this.ca();i?(p(this.ua)&&(this.ua=null==(t=_t.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),p(this.la)&&(this.la=null==(e=_t.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Do()},this._instance=t}initialize(){this.startIfEnabledOrStop()}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return Qe.error("failed to load script",e);t()}))}da(){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}ca(){var t=this.da();return d(t)?(d(this.ha)?this.ha.splice(0,this.ha.length,...t):this.ha=[...t],t.length>0?this.ha:void 0):(d(this.ha)&&this.ha.splice(0),this.ha=t||void 0,this.ha)}Do(){var t,e;null==(t=this.ua)||t.call(this),null==(e=this.la)||e.call(this),this.ua=void 0,this.la=void 0}startIfEnabledOrStop(){this.ca()?this.lr(this.Oo):this.Do()}}},fr=i({surveys:class{get qt(){return this._instance.config}constructor(t){this.va=void 0,this._surveyManager=null,this.fa=!1,this.pa=[],this.ga=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qt.disable_surveys){var e=t.surveys;if(b(e))return Di.warn("Flags not loaded yet. Not loading surveys.");var i=d(e);this.va=i?e.length>0:e,Di.info("flags response received, isSurveysEnabled: "+this.va),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var i=localStorage.key(e);(null!=i&&i.startsWith("seenSurvey_")||null!=i&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((t=>localStorage.removeItem(t)))}loadIfEnabled(){if(!this._surveyManager)if(this.fa)Di.info("Already initializing surveys, skipping...");else if(this.qt.disable_surveys)Di.info(Ji);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())Di.info("Not loading surveys in cookieless mode without consent.");else{var t=null==_t?void 0:_t.__PosthogExtensions__;if(t){if(!p(this.va)||this.qt.advanced_enable_surveys){var e=this.va||this.qt.advanced_enable_surveys;this.fa=!0;try{var i=t.generateSurveys;if(i)return void this.ma(i,e);var r=t.loadExternalDependency;if(!r)return void this.ya(te);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.ya("Could not load surveys script",i):this.ma(t.generateSurveys,e)}))}catch(t){throw this.ya("Error initializing surveys",t),t}finally{this.fa=!1}}}else Di.error("PostHog Extensions not found.")}}ma(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new Wi(this._instance),Di.info("Surveys loaded successfully"),this.ba({isLoaded:!0})}ya(t,e){Di.error(t,e),this.ba({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.pa.push(t),this._surveyManager&&this.ba({isLoaded:!0}),()=>{this.pa=this.pa.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.qt.disable_surveys)return Di.info(Ji),t([]);var i,r=this._instance.get_property(Jt);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.ga?this.ga.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.ga=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qt.token),method:"GET",timeout:this.qt.surveys_request_timeout_ms,callback:e=>{var r;this.ga=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Di.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({[Jt]:l,$surveys_loaded_at:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}ba(t){for(var e of this.pa)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Di.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!b(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Di.warn("init was not called")}_a(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}wa(t){if(b(this._surveyManager))return{eligible:!1,reason:Bi};var e="string"==typeof t?this._a(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(b(this._surveyManager))return Di.warn("init was not called"),{visible:!1,disabledReason:Bi};var e=this.wa(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return b(this._surveyManager)?(Di.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Bi})):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.wa(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(b(this._surveyManager))Di.warn("init was not called");else{var s="string"==typeof t?this._a(t):t;if(null!=s&&s.id)if(Ni.includes(s.type)){var n=null==pt?void 0:pt.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Di.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Di.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),Di.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Di.warn("Survey element not found")}else Di.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Di.warn("Survey not found")}}displaySurvey(t,e){var r;if(b(this._surveyManager))Di.warn("init was not called");else{var s=this._a(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&&Di.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 Di.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 Di.warn("Survey not found")}}cancelPendingSurvey(t){b(this._surveyManager)?Di.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},or),pr={toolbar:class{constructor(t){this.instance=t}xa(t){_t.ph_toolbar_state=t}ka(){var t;return null!==(t=_t.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),Ft(this.instance.config))return!1;if(!dt||!pt)return!1;t=null!=t?t:dt.location,i=null!=i?i:dt.history;try{if(!e){try{dt.localStorage.setItem("test","test"),dt.localStorage.removeItem("test")}catch(t){return!1}e=null==dt?void 0:dt.localStorage}var r,s=qi||Ve(t.hash,"__posthog")||Ve(t.hash,"state"),n=s?kt((()=>JSON.parse(atob(decodeURIComponent(s)))))||kt((()=>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(Gi)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Sa(t){var e=_t.ph_load_toolbar||_t.ph_load_editor;!b(e)&&c(e)?e(t,this.instance):Ki.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==pt||!pt.getElementById(Qt));if(!dt||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(dt.localStorage.setItem(Gi,JSON.stringify(i({},s,{source:void 0}))),2===this.ka())this.Sa(s);else if(0===this.ka()){var n;this.xa(1),null==(n=_t.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return Ki.error("[Toolbar] Failed to load",t),void this.xa(0);this.xa(2),this.Sa(s)})),St(dt,"turbolinks:load",(()=>{this.xa(0),this.loadToolbar(s)}))}return!0}Ca(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)}}},gr=i({experiments:sr},or),_r={conversations:class{constructor(t){this.Ia=void 0,this._conversationsManager=null,this.Ta=!1,this.Ea=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;b(e)||(y(e)?this.Ia=e:(this.Ia=e.enabled,this.Ea=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Ia=void 0,this.Ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ta||this._instance.config.disable_conversations||Ft(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==_t?void 0:_t.__PosthogExtensions__;if(t&&!p(this.Ia)&&this.Ia)if(this.Ea&&this.Ea.token){this.Ta=!0;try{var e=t.initConversations;if(e)return this.Ma(e),void(this.Ta=!1);var i=t.loadExternalDependency;if(!i)return void this.Ra(te);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.Ra("Could not load conversations script",e):this.Ma(t.initConversations),this.Ta=!1}))}catch(t){this.Ra("Error initializing conversations",t),this.Ta=!1}}else nr.error("Conversations enabled but missing token in remote config.")}}Ma(t){if(this.Ea)try{this._conversationsManager=t(this.Ea,this._instance),nr.info("Conversations loaded successfully")}catch(t){this.Ra("Error completing conversations initialization",t)}else nr.error("Cannot complete initialization: remote config is null")}Ra(t,e){nr.error(t,e),this._conversationsManager=null,this.Ta=!1}show(){this._conversationsManager?this._conversationsManager.show():nr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Ia&&!_(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):(nr.warn(ar),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(nr.warn(ar),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(nr.warn(ar),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(nr.warn(ar),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(nr.warn(ar),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(nr.warn(ar),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(nr.warn(ar),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}Ln(){var t;null==(t=this._conversationsManager)||t.setIdentity()}An(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},br={logs:class{constructor(t){var e;this.Pa=!1,this.Oa=!1,this.Zt=yt("[logs]"),this.La=[],this.Aa=0,this.Fa=0,this.Na=!1,this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.Pa=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!b(i)&&i&&(this.Pa=!0,this.loadIfEnabled())}reset(){this.La=[],this.ii&&(clearTimeout(this.ii),this.ii=void 0),this.Aa=0,this.Fa=0,this.Na=!1}loadIfEnabled(){if(this.Pa&&!this.Oa){var t=null==_t?void 0:_t.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Zt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.Oa=!0)})):this.Zt.error(te)}else this.Zt.error("PostHog Extensions not found.")}}captureLog(t){var e,r,s,n,a,o;if(this._instance.is_capturing())if(t&&t.body){var l=null!==(e=null==(r=this._instance.config.logs)?void 0:r.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(s=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==s?s:1e3,h=Date.now();if(l>h-this.Fa||(this.Fa=h,this.Aa=0,this.Na=!1),u>this.Aa){this.Aa++;var v=function(t,e){var r=t.level||"info",{text:s,number:n}=I[r]||T,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:A(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),p(t.trace_flags)||(u.flags=t.trace_flags),u}(t,this.Da());this.La.push({record:v}),(null!==(a=null==(o=this._instance.config.logs)?void 0:o.maxBufferSize)&&void 0!==a?a:100)>this.La.length?this.$a():this.flushLogs()}else this.Na||(this.Zt.warn("captureLog dropping logs: exceeded "+u+" logs per "+l+"ms"),this.Na=!0)}else this.Zt.warn("captureLog requires a body")}get logger(){return this.qa||(this.qa={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.qa}flushLogs(t){if(this.ii&&(clearTimeout(this.ii),this.ii=void 0),0!==this.La.length){var e=this.La;this.La=[];var n=this._instance.config.logs,a=i({"service.name":(null==n?void 0:n.serviceName)||"unknown_service"},(null==n?void 0:n.environment)&&{"deployment.environment":n.environment},(null==n?void 0:n.serviceVersion)&&{"service.version":n.serviceVersion},null==n?void 0:n.resourceAttributes),o=function(t,e,i,r){return{resourceLogs:[{resource:{attributes:A(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}(e.map((t=>t.record)),a,s,r),l=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.pn({method:"POST",url:l,data:o,compression:"best-available",batchKey:"logs",transport:t})}}$a(){var t,e;this.ii||(this.ii=setTimeout((()=>{this.ii=void 0,this.flushLogs()}),null!==(t=null==(e=this._instance.config.logs)?void 0:e.flushIntervalMs)&&void 0!==t?t:3e3))}Da(){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!=_t&&null!=(t=_t.location)&&t.href&&(e.currentUrl=_t.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(e.activeFeatureFlags=r)}return e}}},mr=i({},or,lr,ur,hr,vr,dr,fr,cr,pr,gr,_r,br),yr=or,wr=lr,xr=ur,Er=hr,kr=vr,Sr=dr,Fr=fr,Cr=cr,Rr=pr,Pr=gr,$r=_r,Ir=br;export{mr as AllExtensions,xr as AnalyticsExtensions,$r as ConversationsExtensions,Er as ErrorTrackingExtensions,Pr as ExperimentsExtensions,yr as FeatureFlagsExtensions,Ir as LogsExtensions,kr as ProductToursExtensions,wr as SessionReplayExtensions,Sr as SiteAppsExtensions,Fr as SurveysExtensions,Rr as ToolbarExtensions,Cr 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.386.2",s="web",n=["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"],a=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return n.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function o(t,e){return-1!==t.indexOf(e)}var l=function(t){return t.trim()},u=Object.prototype,h=u.hasOwnProperty,v=u.toString,d=Array.isArray||function(t){return"[object Array]"===v.call(t)},c=t=>"function"==typeof t,f=t=>t===Object(t)&&!d(t),p=t=>void 0===t,g=t=>"[object String]"==v.call(t),_=t=>null===t,b=t=>p(t)||_(t),m=t=>"[object Number]"==v.call(t)&&t==t,y=t=>"[object Boolean]"===v.call(t),w=t=>t instanceof FormData;function x(t){return null===t||"object"!=typeof t}function E(t,e){return{}.toString.call(t)==="[object "+e+"]"}function k(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function S(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),m(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),S(i,e,i,r))}class F{constructor(t){this.$t={},this.zt=t.zt,this.Gt=S(t.bucketSize,0,100,t.Zt),this.Qt=S(t.refillRate,0,this.Gt,t.Zt),this.Jt=S(t.refillInterval,0,864e5,t.Zt)}Kt(t,e){var i=Math.floor((e-t.lastAccess)/this.Jt);i>0&&(t.tokens=Math.min(t.tokens+i*this.Qt,this.Gt),t.lastAccess=t.lastAccess+i*this.Jt)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.$t[r];return s?this.Kt(s,i):this.$t[r]=s={tokens:this.Gt,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.zt)||e.call(this,t)),0===s.tokens)}stop(){this.$t={}}}var C,R,P,I={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}},T=I.info;function O(t){if(y(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(d(t))return{arrayValue:{values:t.map((t=>O(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function A(t){var e=[];for(var i in t){var r=t[i];_(r)||p(r)||e.push({key:i,value:O(r)})}return e}function j(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return P&&i.length===R?P:(R=i.length,P=i.reduce(((i,r)=>{C||(C={});var s=C[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,C[r]=[l,u];break}}return i}),{}))}}class M{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&&d(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:j(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 L="?";function D(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?L:i,in_app:!0};return p(r)||(n.lineno=r),p(s)||(n.colno=s),n}var N=(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]:L,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},z=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,U=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,H=/\((\S*)(?::(\d+))(?::(\d+))\)/,V=(t,e)=>{var i=z.exec(t);if(i){var[,r,s,n]=i;return D(e,r,L,+s,+n)}var a=U.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=H.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=N(a[1]||L,a[2]);return D(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},W=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,B=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,J=(t,e)=>{var i=W.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=B.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]||L;return[n,s]=N(n,s),D(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},q=/\(error: (.*)\)/;class G{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=g(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 E(t,"DOMException")}isDOMError(t){return E(t,"DOMError")}}class K{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 Y{constructor(){}match(t){return E(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 X=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Z{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(X);return r&&(e=r[1],i=r[2]),[e,i]}}var Q=["fatal","error","warning","log","info","debug"];function tt(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 et{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 k(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: "+tt(t)}isSeverityLevel(t){return g(t)&&!(t=>g(t)&&0===t.trim().length)(t)&&Q.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 it{match(t){return k(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+tt(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class rt{match(t){return x(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 st{match(t){return E(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(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 x(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 nt="$message",at="$timestamp",ot=new Set([nt,at]),lt={enabled:!0,max_bytes:32768};function ut(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:lt.enabled,max_bytes:vt(t.max_bytes,lt.max_bytes)}:i({},lt)}class ht{constructor(t){this.Yt=[],this.Xt=0,this.qt=ut(t)}setConfig(t){this.qt=ut(t),this.er()}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(!f(i))return;var r=i,s=r[nt],n=r[at];if(!g(s)||0===s.trim().length)return;if(!g(n)&&!m(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.qt.max_bytes||(this.Yt.push({step:e.step,bytes:i}),this.Xt+=i,this.er())}}getAttachable(){return this.Yt.map((t=>t.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var t=this.Yt.shift();t&&(this.Xt-=t.bytes)}}}function vt(t,e){if(!m(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var dt="undefined"!=typeof window?window:void 0,ct="undefined"!=typeof globalThis?globalThis:dt;"undefined"==typeof self&&(ct.self=ct),"undefined"==typeof File&&(ct.File=function(){});var ft=null==ct?void 0:ct.navigator,pt=null==ct?void 0:ct.document,gt=null==ct?void 0:ct.location;null!=ct&&ct.XMLHttpRequest&&new ct.XMLHttpRequest;var _t=null!=dt?dt:{},bt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(dt&&(_t.POSTHOG_DEBUG||i)&&!p(dt.console)&&dt.console){for(var r=("__rrweb_original__"in dt.console[e]?dt.console[e].__rrweb_original__:dt.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)=>bt(t+" "+e,i)};return r},mt=bt("[PostHog.js]"),yt=mt.createLogger;function wt(t,e){if(!b(t))if(d(t))t.forEach(e);else if(w(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)h.call(t,i)&&e(t[i],i)}var xt=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 Et(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 kt=function(t){try{return t()}catch(t){return}};function St(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 Ft(t){return"ph_toolbar_internal"===t.name}var Ct="$autocapture_disabled_server_side",Rt="$heatmaps_enabled_server_side",Pt="$exception_capture_enabled_server_side",$t="$error_tracking_suppression_rules",It="$error_tracking_capture_extension_exceptions",Tt="$web_vitals_enabled_server_side",Ot="$product_tours_enabled_server_side",At="$web_vitals_allowed_metrics",jt="$session_recording_remote_config",Mt="$enabled_feature_flags",Lt="$active_feature_flags",Dt="$early_access_features",Nt="$feature_flag_details",zt="$feature_flag_payloads",Ut="$feature_flag_request_id",Ht="$override_feature_flags",Vt="$override_feature_flag_payloads",Wt="$stored_person_properties",Bt="$stored_group_properties",Jt="$surveys",qt="$surveys_activated",Gt="ph_product_tours",Kt="$flag_call_reported",Yt="$flag_call_reported_session_id",Xt="$feature_flag_errors",Zt="$feature_flag_evaluated_at",Qt="__POSTHOG_TOOLBAR__",te="PostHog loadExternalDependency extension not found.",ee="visibilitychange",ie="beforeunload",re=1,se=3,ne=11;function ae(t){return t instanceof Element&&(t.id===Qt||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function oe(t){return!!t&&t.nodeType===re}function le(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ue(t){return!!t&&t.nodeType===se}function he(t){return!!t&&t.nodeType===ne&&oe(t.host)}function ve(t){return t?l(t).split(/\s+/):[]}function de(t){var e=null==dt?void 0:dt.location.href;return!!(e&&t&&t.some((t=>e.match(t))))}function ce(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 ve(e)}function fe(t){return b(t)?null:l(t).split(/(\s+)/).filter((t=>je(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function pe(t){var e="";return Ce(t)&&!Re(t)&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;ue(t)&&t.textContent&&(e+=null!==(i=fe(t.textContent))&&void 0!==i?i:"")})),l(e)}function ge(t){return p(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var _e=["a","button","form","input","select","textarea","label"];function be(t,e){if(p(e))return!0;var i,r=function(t){if(e.some((e=>t.matches(e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function me(t){var e=t.parentNode;return!(!e||!oe(e))&&e}var ye=["next","previous","prev",">","<"],we=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,xe=[".ph-no-rageclick",".ph-no-capture"],Ee=["","text","search","email","password","url","tel","number"];function ke(t,e){if(!dt||Se(t))return!1;var i,r,s,n,a;if(y(e)?(i=!!e&&xe,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:xe,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||!oe(t))&&(!!le(t,"textarea")||(le(t,"input")?o(Ee,(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:l}=Fe(t,!1);return!function(t,e){if(!1===t||p(t))return!1;var i;if(!0===t)i=ye;else{if(!d(t))return!1;if(t.length>10)return mt.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=>we(e,t)||we(r,t)))}))}(r,l.map((t=>{var e;return{safeText:pe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!be(l,i)}var Se=t=>!t||le(t,"html")||!oe(t),Fe=(t,e)=>{if(!dt||Se(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!le(s,"body");)if(he(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=me(s);if(!n)break;if(e||_e.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=dt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ce(t){for(var e=t;e.parentNode&&!le(e,"body");e=e.parentNode){var i=ce(e);if(o(i,"ph-sensitive")||o(i,"ph-no-capture"))return!1}if(o(ce(t),"ph-include"))return!0;var r=t.type||"";if(g(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!g(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 Re(t){return!!(le(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||le(t,"select")||le(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Pe="(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})",$e=new RegExp("^(?:"+Pe+")$"),Ie=new RegExp(Pe),Te="\\d{3}-?\\d{2}-?\\d{4}",Oe=new RegExp("^("+Te+")$"),Ae=new RegExp("("+Te+")");function je(t,e){if(void 0===e&&(e=!0),b(t))return!1;if(g(t)){if(t=l(t),(e?$e:Ie).test((t||"").replace(/[- ]/g,"")))return!1;if((e?Oe:Ae).test(t))return!1}return!0}function Me(t){var e=pe(t);return je(e=(e+" "+Le(t)).trim())?e:""}function Le(t){var e="";return t&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=pe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Le(t)).trim())}catch(t){mt.error("[AutoCapture]",t)}})),e}function De(t){return t.replace(/"|\\"/g,'\\"')}function Ne(t){var e=t.attr__class;return e?d(e)?e:ve(e):void 0}class ze{constructor(t){this.disabled=!1===t;var e=f(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 Ue=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(!d(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){mt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},He=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("=");d(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},Ve=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},We="$copy_autocapture",Be=yt("[AutoCapture]");function Je(t,e){return e.length>t?e.slice(0,t)+"...":e}function qe(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!oe(e));return e}function Ge(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:l,elementAttributeIgnoreList:u,elementsChainAsString:h}=e;if(!oe(t))return{props:{}};for(var v=[t],d=t;d.parentNode&&!le(d,"body");)if(he(d.parentNode))v.push(d.parentNode.host),d=d.parentNode.host;else{if(!oe(d.parentNode))break;v.push(d.parentNode),d=d.parentNode}var c,f,_=[],b={},m=!1,y=!1;if(wt(v,(t=>{var e=Ce(t);if(le(t,"a")){var i=t.getAttribute("href");m=e&&!!i&&je(i)&&i}o(ce(t),"ph-no-capture")&&(y=!0),_.push(function(t,e,i,r){var s=t.tagName.toLowerCase(),n={tag_name:s};_e.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Je(1024,Me(t)):Je(1024,pe(t)));var a=ce(t);a.length>0&&(n.classes=a.filter((function(t){return""!==t}))),wt(t.attributes,(function(i){var s;if((!Re(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&je(i.value)&&(!g(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var a=i.value;"class"===i.name&&(a=ve(a).join(" ")),n["attr__"+i.name]=Je(1024,a)}}));for(var o=1,l=1,u=t;u=qe(u);)o++,u.tagName===t.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}(t,a,l,u));var r=function(t){if(!Ce(t))return{};var e={};return wt(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&&je(r)&&(e[i]=r)}})),e}(t);xt(b,r)})),y)return{props:{},explicitNoCapture:y};if(l||(_[0].$el_text=le(t,"a")||le(t,"button")?Me(t):pe(t)),m){var w,x;_[0].attr__href=m;var E=null==(w=(t=>{var e=null==pt?void 0:pt.createElement("a");return p(e)?null:(e.href=t,e)})(m))?void 0:w.host,k=null==dt||null==(x=dt.location)?void 0:x.host;E&&k&&E!==k&&(c=m)}return{props:xt({$event_type:n.type,$ce_version:1},h?{}:{$elements:_},{$elements_chain:(f=_,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 Et(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[De(e.toString())]=De(i.toString())})),(s+=":")+Et(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:Ne(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Et(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=_[0])&&r.$el_text?{$el_text:null==(s=_[0])?void 0:s.$el_text}:{},c&&"click"===n.type?{$external_click_url:c}:{},b)}}var Ke=yt("[Dead Clicks]"),Ye=()=>!0;class Xe{get lazyLoadedDeadClicksAutocapture(){return this.ur}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.lr((()=>{this.hr()})):this.stop()}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.initDeadClicksAutocapture&&t(),null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?Ke.error("failed to load script",e):t()}))}hr(){var t;if(pt){if(!this.ur&&null!=(t=_t.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=f(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.ur=_t.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.ur.start(pt),Ke.info("starting...")}}else Ke.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Ke.info("stopping..."))}}var Ze=yt("[ExceptionAutocapture]"),Qe=yt("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return m(t)&&isFinite(t)&&Math.floor(t)===t});class ti{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 ti(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 ti(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 ei{constructor(){this.S=0,this.C=0,this.I=new si}generate(){var t=this.generateOrAbort();if(p(t)){this.S=0;var e=this.generateOrAbort();if(p(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.T();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return ti.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var ii,ri=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};dt&&!p(dt.crypto)&&crypto.getRandomValues&&(ri=t=>crypto.getRandomValues(t));class si{constructor(){this.M=new Uint32Array(8),this.R=1/0}nextUint32(){return this.M.length>this.R||(ri(this.M),this.R=0),this.M[this.R++]}}var ni=()=>(ii||(ii=new ei)).generate(),ai="",oi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function li(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=pt),ai)return ai;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_"+ni().toString();!ai&&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",ai=n)}return ai}(t);if(!i){var r=(t=>{var e=t.match(oi);return e?e[0]:""})(t);r!==i&&mt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var ui={O:()=>!!pt,D(t){mt.error("cookieStore error: "+t)},A(t){if(pt){try{for(var e=t+"=",i=pt.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(ui.A(t))||{}}catch(t){}return e},N(t,e,i,r,s){if(!pt)return!1;try{var n="",a="",o=li(pt.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&&mt.warn("cookieStore warning: large cookie, len="+u.length),pt.cookie=u,!0}catch(t){return!1}},q(t,e){if(null!=pt&&pt.cookie)try{ui.N(t,"",-1,e)}catch(t){return}}},hi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],vi=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...hi],di="<masked>",ci=["li_fat_id"];function fi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var pi=yt("[Web Vitals]"),gi=9e5,_i=yt("[RemoteConfig]");class bi{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=_t._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Gr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zr(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 _i.info("Using preloaded remote config",this.remoteConfig),this.Qr(this.remoteConfig),void this.Jr();if(this._instance.Kr())return void _i.warn("Remote config is disabled. Falling back to local config.");this.Gr((t=>{if(!t)return _i.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zr((t=>{this.Qr(t),this.Jr()}));this.Qr(t),this.Jr()}))}catch(t){_i.error("Error loading remote config",t)}}stop(){this.Yr&&(clearInterval(this.Yr),this.Yr=void 0)}refresh(){!this._instance.Kr()&&pt&&"hidden"!==pt.visibilityState&&this._instance.reloadFeatureFlags()}Jr(){var t;if(!this.Yr){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Yr=setInterval((()=>{this.refresh()}),e))}}Qr(t){var e;t||_i.error("Failed to fetch remote config from PostHog."),this._instance.Qr(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 mi="disabled",yi="lazy_loading",wi="awaiting_config",xi="missing_config",Ei="base64",ki=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}},Si={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=>ki(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!ki(e,t))))),icontains:(t,e)=>e.map(Fi).some((e=>t.map(Fi).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(Fi).every((e=>t.map(Fi).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)))}))},Fi=t=>t.toLowerCase();function Ci(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(p(s)||_(s))return!1;var n=[String(s)],a=Si[r.operator];return!!a&&a(r.values,n)}))}yt("[SessionRecording]"),yt("[SessionRecording]");var Ri="[SessionRecording]",Pi=yt(Ri),$i=yt("[Heatmaps]");function Ii(t){return f(t)&&"clientX"in t&&"clientY"in t&&m(t.clientX)&&m(t.clientY)}var Ti=yt("[Product Tours]"),Oi=["$set_once","$set"],Ai=yt("[SiteApps]"),ji="Error while initializing PostHog app with config id ",Mi="events",Li="cancelEvents",Di=yt("[Surveys]"),Ni=["popover","widget","api"];class zi{constructor(){this.Ii={}}on(t,e){return this.Ii[t]||(this.Ii[t]=[]),this.Ii[t].push(e),()=>{this.Ii[t]=this.Ii[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Ii[t]||[])i(e);for(var r of this.Ii["*"]||[])r(t,e)}}function Ui(t,e,i){if(b(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 Hi{constructor(t){this.Dn=new zi,this.$n=(t,e)=>this.qn(t,e)&&this.jn(t,e)&&this.Bn(t,e)&&this.Hn(t,e),this.qn=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.Un=new Set,this.zn=new Set}init(){var t,e;p(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(!p(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.zn)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.Un)||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.Un.has(t)||this.Un.has(null==e?void 0:e.event))&&this.zn&&(null==(i=this.zn)?void 0:i.size)>0&&this.zn.forEach((t=>{this.Vn(e,t)&&this.Dn.emit("actionCaptured",t.name)}))}Wn(t){this.onAction("actionCaptured",(e=>t(e)))}Vn(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.$n(t,i))return!0;return!1}onAction(t,e){return this.Dn.on(t,e)}jn(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(!Ui(r,e.url,e.url_matching||"contains"))return!1}return!0}Bn(t,e){return!!this.Gn(t,e)&&!!this.Zn(t,e)&&!!this.Qn(t,e)}Gn(t,e){var i;if(null==e||!e.href)return!0;var r=this.Jn(t);if(r.length>0)return r.some((t=>Ui(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Ui((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}Zn(t,e){var i;if(null==e||!e.text)return!0;var r=this.Jn(t);if(r.length>0)return r.some((t=>Ui(t.text,e.text,e.text_matching||"exact")||Ui(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;!b(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=>Ui(t,n,a))))}Qn(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}Jn(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Hn(t,e){return null==e||!e.properties||0===e.properties.length||Ci(e.properties.reduce(((t,e)=>{var i=d(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 Vi{constructor(t){this._instance=t,this.Kn=new Map,this.Yn=new Map,this.Xn=new Map}es(t,e){return!!t&&Ci(t.propertyFilters,null==e?void 0:e.properties)}ts(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}rs(t,e,i){var r=(i===Mi?this.Kn:this.Yn).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.es(n,e)}))}register(t){var e;p(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.ss(t),this.os(t))}os(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.us&&(this.us=new Hi(this._instance),this.us.init(),this.us.Wn((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.us)||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.Xn.get(e.name);i&&i.push(t.id),this.Xn.set(e.name,i||[t.id])}})))})))}ss(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.Kn=this.ts(t,Mi),this.Yn=this.ts(t,Li))}onEvent(t,e){var i,r=this.le(),s=this.ls(),n=this.hs(),a=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===t&&e&&a.length>0){var o,l;r.info("event matched, removing item from activated items",{event:t,eventPayload:e,existingActivatedItems:a});var u=(null==e||null==(o=e.properties)?void 0:o.$survey_id)||(null==e||null==(l=e.properties)?void 0:l.$product_tour_id);if(u){var h=a.indexOf(u);0>h||(a.splice(h,1),this.cs(a))}}else{if(this.Yn.has(t)){var v=this.rs(t,e,Li);v.length>0&&(r.info("cancel event matched, cancelling items",{event:t,itemsToCancel:v.map((t=>t.id))}),v.forEach((t=>{var e=a.indexOf(t.id);0>e||a.splice(e,1),this.ds(t.id)})),this.cs(a))}if(this.Kn.has(t)){r.info("event name matched",{event:t,eventPayload:e,items:this.Kn.get(t)});var d=this.rs(t,e,Mi);this.cs(a.concat(d.map((t=>t.id))||[]))}}}onAction(t){var e,i=this.ls(),r=(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[i])||[];this.Xn.has(t)&&this.cs(r.concat(this.Xn.get(t)||[]))}cs(t){var e=this.le(),i=[...new Set(t)].filter((t=>!this.vs(t)));e.info("updating activated items",{activatedItems:i}),this.fs(i)}getActivatedIds(){var t,e=this.ls();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getEventToItemsMap(){return this.Kn}ps(){return this.us}}class Wi extends Vi{constructor(t){super(t)}ls(){return qt}hs(){return"survey shown"}ns(t){var e;null==(e=this._instance)||e.getSurveys(t)}ds(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}le(){return Di}fs(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[qt]:t})}vs(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Bi="SDK is not enabled or survey functionality is not yet loaded",Ji="Disabled. Not loading surveys.",qi=null!=dt&&dt.location?Ve(dt.location.hash,"__posthog")||Ve(location.hash,"state"):null,Gi="_postHogToolbarParams",Ki=yt("[Toolbar]"),Yi=yt("[FeatureFlags]"),Xi=yt("[FeatureFlags]",{debugEnabled:!0}),Zi="\" failed. Feature flags didn't load in time.",Qi=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},tr=t=>{var e={};for(var[i,r]of Et(t||{}))r&&(e[i]=r);return e},er=yt("[Error tracking]"),ir="Refusing to render web experiment since the viewer is a likely bot",rr={icontains:(t,e)=>!!dt&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!dt&&-1===e.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>!!dt&&ki(e.href,t),not_regex:(t,e)=>!!dt&&!ki(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class sr{get qt(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{sr.gs("retrieved web experiments from the server"),e.ys=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.ys&&(sr.gs("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);g(r)&&t.variants[r]&&e.bs(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];sr._s(n)&&e.bs(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())sr.gs(ir);else if(!this.qt.disable_web_experiments){if(b(this.ys))return this.ys=new Map,this.loadIfEnabled(),void this.previewWebExperiment();sr.gs("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.bs(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=sr.getWindowLocation();if(null!=t&&t.search){var e=Ue(null==t?void 0:t.search,"__experiment_id"),i=Ue(null==t?void 0:t.search,"__experiment_variant");e&&i&&(sr.gs("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.ws(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.qt.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.qt.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}ws(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(sr.gs("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.bs(r[0].name,e,r[0].variants[e].transforms))}static _s(t){return!b(t.conditions)&&sr.xs(t)&&sr.ks(t)}static xs(t){var e;if(b(t.conditions)||b(null==(e=t.conditions)?void 0:e.url))return!0;var i,r,s,n=sr.getWindowLocation();return!!n&&(null==(i=t.conditions)||!i.url||rr[null!==(r=null==(s=t.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](t.conditions.url,n))}static getWindowLocation(){return null==dt?void 0:dt.location}static ks(t){var e;if(b(t.conditions)||b(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!pt)return{};var r,s,n,a=(r=He(pt.URL,[],di),s=vi.concat([]),n={},wt(s,(function(t){var e=Ue(r,t);n[t]=e||null})),n),o=function(){var t={};return wt(ci,(function(e){var i=ui.A(e);t[e]=i||null})),t}();return xt(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 gs(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];mt.info("[WebExperiments] "+t,i)}bs(t,e,i){this._is_bot()?sr.gs(ir):"control"!==e?i.forEach((i=>{if(i.selector){var r;sr.gs("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)}))}})):sr.gs("Control variants leave the page unmodified.")}_is_bot(){return ft&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&a(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>a(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(ft,this.qt.custom_blocked_useragents):void 0}}var nr=yt("[Conversations]"),ar="Conversations not available yet.",or={featureFlags:class{constructor(t){this.Ss=!1,this.Cs=!1,this.Is=!1,this.Ts=!1,this.Es=!1,this.Ms=!1,this.Rs=!1,this.Ps=!1,this._instance=t,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get Si(){return this._instance.persistence}Os(t){return this._instance.get_property(t)}Ls(){var t,e;return null!==(t=null==(e=this.Si)?void 0:e.Mr(this.qt.feature_flag_cache_ttl_ms))&&void 0!==t&&t}As(){return!!this.Ls()&&(this.Ps||this.Is||(this.Ps=!0,Yi.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Fs(){var t,e=null!==(t=this.qt.evaluation_contexts)&&void 0!==t?t:this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.Rs||(Yi.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Rs=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Yi.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}Ns(){return this.Fs().length>0}Ds(){var t=this.qt.flag_keys;if(!p(t)){if(d(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Yi.error("Invalid flag key found:",t,"Expected non-empty string"),e}));Yi.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=null!=r&&r.merge?this.getFlagVariants():{},n=null!=r&&r.merge?this.getFlagPayloads():{},a=i({},s,t),o=i({},n,e),l={};for(var[u,h]of Object.entries(a)){var v="string"==typeof h;l[u]={key:u,enabled:!!v||Boolean(h),variant:v?h:void 0,reason:void 0,metadata:p(null==o?void 0:o[u])?void 0:{id:0,version:void 0,description:void 0,payload:o[u]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this.Cs}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Os(Nt),e=this.Os(Ht),r=this.Os(Vt);if(!r&&!e)return t||{};var s=xt({},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=p(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=p(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.Ss||(Yi.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Ss=!0),s}getFlagVariants(){var t=this.Os(Mt),e=this.Os(Ht);if(!e)return t||{};for(var i=xt({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Ss||(Yi.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Ss=!0),i}getFlagPayloads(){var t=this.Os(zt),e=this.Os(Vt);if(!e)return t||{};for(var i=xt({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Ss||(Yi.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Ss=!0),i}reloadFeatureFlags(){this.Ts||this.qt.advanced_disable_feature_flags||this.$s||(this._instance.nn.emit("featureFlagsReloading",!0),this.$s=setTimeout((()=>{this.qs()}),5))}js(){clearTimeout(this.$s),this.$s=void 0}ensureFlagsLoaded(){this.Cs||this.Is||this.$s||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Ts=t}qs(t){var e;if(this.js(),!this._instance.Kr())if(this.Is)this.Es=!0;else{var r=this.qt.token,s=this.Os("$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.Si)?void 0:e.get_initial_props())||{},this.Os(Wt)||{}),group_properties:this.Os(Bt),timezone:fi()};_(s)||p(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.qt.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.Ns()&&(n.evaluation_contexts=this.Fs());var a=this.Ds();p(a)||(n.flag_keys=a);var o=!!this.qt.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.qt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Is=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.qt.disable_compression?void 0:Ei,timeout:this.qt.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(200===t.statusCode&&(this.Es||(this.$anon_distinct_id=void 0),s=!1),this.Is=!1,!n.disable_flags||this.Es){this.Ms=!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.Si)||r.register({[Xt]:a}),u)Yi.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.Es&&(this.Es=!1,this.qs())}}})}}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.Ms)if(this.Cs||this.getFlags()&&this.getFlags().length>0){if(!this.As()){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 Yi.warn('getFeatureFlag for key "'+t+Zi)}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.Ms)if(this.Cs||this.getFlags()&&this.getFlags().length>0){if(!this.As()){var i=this.getFlagVariants(),r=t in i,s=i[t],n=this.getFlagPayloads()[t],a=String(s),o=this.Os(Ut)||void 0,l=this.Os(Zt)||void 0,u=this.Os(Kt)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var h,v=this._instance.get_session_id(),c=this.Os(Yt);v&&v!==c&&(u={},null==(h=this.Si)||h.register({[Kt]:u,[Yt]:v}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(a))){var f,g,_,b,m,y,w,x,E,k;d(u[t])?u[t].push(a):u[t]=[a],null==(f=this.Si)||f.register({[Kt]:u});var S=this.getFeatureFlagDetails(t),F=[...null!==(g=this.Os(Xt))&&void 0!==g?g:[]];p(s)&&F.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:o,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(_=this.qt.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(b=this.qt.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])||null,$used_bootstrap_value:!this.Ms};p(null==S||null==(m=S.metadata)?void 0:m.version)||(C.$feature_flag_version=S.metadata.version);var R,P=null!==(y=null==S||null==(w=S.reason)?void 0:w.description)&&void 0!==y?y:null==S||null==(x=S.reason)?void 0:x.code;P&&(C.$feature_flag_reason=P),null!=S&&null!=(E=S.metadata)&&E.id&&(C.$feature_flag_id=S.metadata.id),p(null==S?void 0:S.original_variant)&&p(null==S?void 0:S.original_enabled)||(C.$feature_flag_original_response=p(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(k=S.metadata)&&k.original_payload&&(C.$feature_flag_original_payload=null==S||null==(R=S.metadata)?void 0:R.original_payload),F.length&&(C.$feature_flag_error=F.join(",")),this._instance.capture("$feature_flag_called",C)}if(r){var I=n;if(!p(n))try{I=JSON.parse(n)}catch(t){}return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:I}}}}else Yi.warn('getFeatureFlagResult for key "'+t+Zi)}getRemoteConfigPayload(t,e){var i=this.qt.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.Ns()&&(r.evaluation_contexts=this.Fs());var s=this.Ds();p(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.qt.disable_compression?void 0:Ei,timeout:this.qt.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.Ms){if(this.Cs||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return p(i)?void 0:!!i}Yi.warn('isFeatureEnabled for key "'+t+Zi)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.Si){this.Cs=!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]})))):Yi.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,c=t.evaluatedAt;if(d(u)){Yi.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var f={};if(u)for(var p=0;u.length>p;p++)f[u[p]]=!0;e&&e.register({[Lt]:u,[Mt]:f})}else{var g=u,_=h,b=l;if(null!=a&&a.partialResponse)g=i({},r,g),_=i({},s,_),b=i({},n,b);else if(t.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((t=>{var[e]=t;return m.has(e)})))),_=i({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return m.has(e)})))),b=i({},n,Object.fromEntries(Object.entries(b||{}).filter((t=>{var[e]=t;return m.has(e)}))))}else g=i({},r,g),_=i({},s,_),b=i({},n,b);e&&e.register(i({[Lt]:Object.keys(tr(g)),[Mt]:g||{},[zt]:_||{},[Nt]:b||{}},v?{[Ut]:v}:{},c?{[Zt]:c}:{}))}}}(t,this.Si,s,n,a,r),e||(this.Ps=!1),this.Bs(e)}}override(t,e){void 0===e&&(e=!1),Yi.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Si)return Yi.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Si.unregister(Ht),this.Si.unregister(Vt),this.Bs(),Xi.info("All overrides cleared");if(d(t)){var e=Qi(t);return this.Si.register({[Ht]:e}),this.Bs(),Xi.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.Ss=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.Si.unregister(Ht),Xi.info("Flag overrides cleared");else if(r.flags){if(d(r.flags)){var s=Qi(r.flags);this.Si.register({[Ht]:s})}else this.Si.register({[Ht]:r.flags});Xi.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Si.unregister(Vt),Xi.info("Payload overrides cleared")):r.payloads&&(this.Si.register({[Vt]:r.payloads}),Xi.info("Payload overrides set",{payloads:r.payloads}))),void this.Bs()}if(t&&"object"==typeof t)return this.Si.register({[Ht]:t}),this.Bs(),Xi.info("Flag overrides set",{flags:t});Yi.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Cs){var{flags:e,flagVariants:i}=this.Hs();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.Os(Dt)||[]).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.Si)||s.register({[Lt]:Object.keys(tr(l)),[Mt]:l}),this.Bs()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.Os(Dt),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.qt.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.Si)||i.unregister(Dt),null==(r=this.Si)||r.register({[Dt]:s}),t(s)}}})}Hs(){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)),{})}}Bs(t){var{flags:e,flagVariants:i}=this.Hs();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.Os(Wt)||{},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({[Wt]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Wt),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.Os(Bt)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[Bt]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.Os(Bt)||{};this._instance.register({[Bt]:i({},e,{[t]:{}})})}else this._instance.unregister(Bt)}reset(){this.Cs=!1,this.Is=!1,this.Ts=!1,this.Es=!1,this.Ms=!1,this.$anon_distinct_id=void 0,this.js(),this.Ss=!1}}},lr={sessionRecording:class{get qt(){return this._instance.config}get Si(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Us)||!t.isStarted)}get status(){var t,e;return this.zs===wi||this.zs===xi?this.zs:null!==(t=null==(e=this.Us)?void 0:e.status)&&void 0!==t?t:this.zs}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.zs=mi,this.Vs=void 0,this._instance=t,!this._instance.sessionManager)throw Pi.error("started without valid sessionManager"),new Error(Ri+" started without valid sessionManager. This is a bug.");if("always"===this.qt.cookieless_mode)throw new Error(Ri+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Ws(){var t,e=!(null==(t=this._instance.get_property(jt))||!t.enabled),i=!this.qt.disable_session_recording,r=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return dt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.Ws||null==(e=this.Us)||!e.isStarted){var i=!p(Object.assign)&&!p(Array.from);this.Ws&&i?(this.Gs(t),Pi.info("starting")):(this.zs=mi,this.stopRecording())}}Gs(t){var e,i,r;this.Ws&&(this.zs!==wi&&this.zs!==xi&&(this.zs=yi),null!=_t&&null!=(e=_t.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=_t.__PosthogExtensions__)&&i.initSessionRecording?this.Zs(t):null==(r=_t.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Qs,(e=>{if(e)return Pi.error("could not load recorder",e);this.Zs(t)})))}stopRecording(){var t,e;null==(t=this.Vs)||t.call(this),this.Vs=void 0,null==(e=this.Us)||e.stop()}Js(){var t,e;null==(t=this.Vs)||t.call(this),this.Vs=void 0,null==(e=this.Us)||e.discard()}Ks(){var t,e;null==(t=this.Si)||t.unregister("$session_is_sampled"),null==(e=this.Si)||e.unregister("$replay_sample_rate")}Ys(t,e){if(b(t))return null;var i,r=m(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Pi.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Xs(t){if(this.Si){var e,r,s=this.Si,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Ys(null==(e=this.qt.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Ys(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;b(o)&&this.Ks();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[jt]: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:p(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.Vs)||e.call(this),this.Vs=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Xs(t),void this.Js()):(this.Xs(t),void this.startIfEnabledOrStop()):(this.zs===wi&&(this.zs=xi,Pi.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.Us)&&i.log?this.Us.log(t,e):Pi.warn("log called before recorder was ready")}get Qs(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(jt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}eo(){var t,e,i=this._instance.get_property(jt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Pi.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}Zs(t){var e,i;if(null==(e=_t.__PosthogExtensions__)||!e.initSessionRecording)return Pi.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.Us||(this.Us=null==(i=_t.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Us._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.eo()){if(this.zs===xi||this.zs===wi)return;return this.zs=wi,Pi.info("persisted remote config is stale, requesting fresh config before starting"),void new bi(this._instance).load()}this.zs=yi,this.Us.start(t)}onRRwebEmit(t){var e;null==(e=this.Us)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Us||null==(e=this.Si)||e.register({$replay_override_linked_flag:!0}),null==(t=this.Us)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Us||null==(e=this.Si)||e.register({$replay_override_sampling:!0}),null==(t=this.Us)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Us||null==(i=this.Si)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.Us)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Us)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Us)||!i.tryAddCustomEvent(t,e))}}},ur={autocapture:class{constructor(t){this.ro=!1,this.io=null,this.no=!1,this.instance=t,this.rageclicks=new ze(t.config.rageclick),this.so=null}initialize(){this.startIfEnabled()}get qt(){var t,e,i=f(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}oo(){if(this.isBrowserSupported()){if(dt&&pt){var t=t=>{t=t||(null==dt?void 0:dt.event);try{this.ao(t)}catch(t){Be.error("Failed to capture event",t)}};if(St(pt,"submit",t,{capture:!0}),St(pt,"change",t,{capture:!0}),St(pt,"click",t,{capture:!0}),this.qt.capture_copied_text){var e=t=>{t=t||(null==dt?void 0:dt.event);try{this.ao(t,We)}catch(t){Be.error("Failed to capture copy/cut event",t)}};St(pt,"copy",e,{capture:!0}),St(pt,"cut",e,{capture:!0})}}}else Be.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.ro&&(this.oo(),this.ro=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.no=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ct]:!!t.autocapture_opt_out}),this.io=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.so=t}getElementSelectors(t){var e,i=[];return null==(e=this.so)||e.forEach((e=>{var r=null==pt?void 0:pt.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[Ct];if(_(this.io)&&!y(i)&&!this.instance.Kr())return!1;var r=null!==(e=this.io)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}ao(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=ge(t);ue(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())&&ke(r,this.instance.config.rageclick)&&this.ao(t,"$rageclick");var s=e===We;if(r&&function(t,e,i,r,s){var n,a,o,l;if(void 0===i&&(i=void 0),!dt||Se(t))return!1;if(null!=(n=i)&&n.url_allowlist&&!de(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&de(i.url_ignorelist))return!1;if(null!=(o=i)&&o.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:h,targetElementList:v}=Fe(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(p(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}(v,i))return!1;if(!be(v,null==(l=i)?void 0:l.css_selector_allowlist))return!1;var d=dt.getComputedStyle(t);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===e.type)return!0;var c=t.tagName.toLowerCase();switch(c){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 h?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(_e.indexOf(c)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.qt,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=Ge(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.no});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===We){var l,u=fe(null==dt||null==(l=dt.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 c(null==pt?void 0:pt.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.uo=(null==dt||null==(e=dt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(mt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.lo&&this.lo(),this.lo=void 0,mt.info("History API monitoring stopped")}monitorHistoryChanges(){dt&&dt.history&&(this.ho("pushState"),this.ho("replaceState"),this.co())}ho(t){var e;if(dt&&(null==(e=dt.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 c(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()=>{}}}(dt.history,t,(e=>function(r,s,n){e.call(this,r,s,n),i.do(t)}))}}do(t){try{var e,i=null==dt||null==(e=dt.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){mt.error("Error capturing "+t+" pageview",e)}}co(){if(!this.lo){var t=()=>{this.do("popstate")};St(dt,"popstate",t),this.lo=()=>{dt&&dt.removeEventListener("popstate",t)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(t){var e;this.vo=!1,this.ro=!1,this.fo=null,this.instance=t,this.vo=!(null==(e=this.instance.persistence)||!e.props[Rt]),this.rageclicks=new ze(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return f(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(t=this.qt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return b(this.qt.capture_heatmaps)?b(this.qt.enable_heatmaps)?this.vo:this.qt.enable_heatmaps:!1!==this.qt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ro)return;$i.info("starting..."),this.po(),this.At()}else{var t;clearInterval(null!==(t=this.fo)&&void 0!==t?t:void 0),this.mo(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Rt]:e}),this.vo=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.M;return this.M=void 0,t}yo(t){this.Mt(t.originalEvent,"deadclick")}At(){this.fo&&clearInterval(this.fo),this.fo="visible"===(null==pt?void 0:pt.visibilityState)?setInterval(this.ci.bind(this),this.flushIntervalMilliseconds):null}po(){dt&&pt&&(this.bo=this.ci.bind(this),St(dt,ie,this.bo),this._o=t=>this.Mt(t||(null==dt?void 0:dt.event)),St(pt,"click",this._o,{capture:!0}),this.wo=t=>this.xo(t||(null==dt?void 0:dt.event)),St(pt,"mousemove",this.wo,{capture:!0}),this.ko=new Xe(this.instance,Ye,this.yo.bind(this)),this.ko.startIfEnabledOrStop(),this.So=this.At.bind(this),St(pt,ee,this.So),this.ro=!0)}mo(){var t;dt&&pt&&(this.bo&&dt.removeEventListener(ie,this.bo),this._o&&pt.removeEventListener("click",this._o,{capture:!0}),this.wo&&pt.removeEventListener("mousemove",this.wo,{capture:!0}),this.So&&pt.removeEventListener(ee,this.So),clearTimeout(this.Co),null==(t=this.ko)||t.stop(),this.ro=!1)}Io(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&&oe(r)&&!le(r,"body");){if(r===i)return!1;if(o(e,null==dt?void 0:dt.getComputedStyle(r).position))return!0;r=me(r)}return!1}(ge(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}Mt(t,e){var r;if(void 0===e&&(e="click"),!ae(t.target)&&Ii(t)){var s=this.Io(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&ke(ge(t),this.instance.config.rageclick)&&this.To(i({},s,{type:"rageclick"})),this.To(s)}}xo(t){!ae(t.target)&&Ii(t)&&(clearTimeout(this.Co),this.Co=setTimeout((()=>{this.To(this.Io(t,"mousemove"))}),500))}To(t){if(dt){var e=dt.location.href,i=this.qt.custom_personal_data_properties,r=this.qt.mask_personal_data_properties?[...hi,...i||[]]:[],s=He(e,r,di);this.M=this.M||{},this.M[s]||(this.M[s]=[]),this.M[s].push(t)}}ci(){this.M&&!(t=>{if(f(t)){for(var e in t)if(h.call(t,e))return!1;return!0}return!1})(this.M)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Xe,webVitalsAutocapture:class{constructor(t){var e;this.vo=!1,this.ro=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Eo=()=>{clearTimeout(this.Mo),0!==this.M.metrics.length&&(this._instance.capture("$web_vitals",this.M.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=t=>{var e;this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.Ro();if(!p(r))if(b(null==t?void 0:t.name)||b(null==t?void 0:t.value))pi.error("Invalid metric received",t);else if(!this.Po||this.Po>t.value){this.M.url!==r&&(this.Eo(),this.Mo=setTimeout(this.Eo,this.flushToCaptureTimeoutMs)),p(this.M.url)&&(this.M.url=r),this.M.firstMetricTimestamp=p(this.M.firstMetricTimestamp)?Date.now():this.M.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()});p(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.M.metrics.push(n),this.M.metrics.length===this.allowedMetrics.length&&this.Eo()}else pi.error("Ignoring metric with value >= "+this.Po,t)},this.Oo=()=>{if(!this.ro){var t,e,i,r,s=_t.__PosthogExtensions__;p(s)||p(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.ht.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.ht.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.ht.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.ht.bind(this)),this.ro=!0):pi.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.vo=!(null==(e=this._instance.persistence)||!e.props[Tt]),this.startIfEnabled()}get Lo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=f(this.Lo)?null==(t=this.Lo)?void 0:t.web_vitals_allowed_metrics:void 0;return b(i)?(null==(e=this._instance.persistence)?void 0:e.props[At])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(f(this.Lo)?this.Lo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=f(this.Lo)?this.Lo.web_vitals_attribution:void 0;return null!=t&&t}get Po(){var t=f(this.Lo)&&m(this.Lo.__web_vitals_max_value)?this.Lo.__web_vitals_max_value:gi;return t>0&&6e4>=t?gi:t}get isEnabled(){var t=null==gt?void 0:gt.protocol;if("http:"!==t&&"https:"!==t)return pi.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=f(this.Lo)?this.Lo.web_vitals:y(this.Lo)?this.Lo:void 0;return y(e)?e:this.vo}startIfEnabled(){this.isEnabled&&!this.ro&&(pi.info("enabled, starting..."),this.lr(this.Oo))}onRemoteConfig(t){if("capturePerformance"in t){var e=f(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=f(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Tt]:e}),this._instance.persistence.register({[At]:i})),this.vo=e,this.startIfEnabled()}}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?pi.error("failed to load script",e):t()}))}Ro(){var t=dt?dt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...hi,...e||[]]:[];return He(t,i,di)}pi.error("Could not determine current URL")}}},hr={exceptionObserver:class{constructor(t){var e,i,r;this.Oo=()=>{var t;if(dt&&this.isEnabled&&null!=(t=_t.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=_t.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=_t.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=_t.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Ao&&this.qt.capture_unhandled_errors&&(this.Ao=e(this.captureException.bind(this))),!this.Fo&&this.qt.capture_unhandled_rejections&&(this.Fo=i(this.captureException.bind(this))),!this.No&&this.qt.capture_console_errors&&(this.No=r(this.captureException.bind(this)))}catch(t){Ze.error("failed to start",t),this.Do()}}},this._instance=t,this.$o=!(null==(e=this._instance.persistence)||!e.props[Pt]),this.qo=new F({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,Zt:Ze}),this.qt=this.jo(),this.startIfEnabledOrStop()}jo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return f(t)?e=i({},e,t):(p(t)?this.$o:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ze.info("enabled"),this.Do(),this.lr(this.Oo)):this.Do()}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.errorWrappingFunctions&&t(),null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return Ze.error("failed to load script",e);t()}))}Do(){var t,e,i;null==(t=this.Ao)||t.call(this),this.Ao=void 0,null==(e=this.Fo)||e.call(this),this.Fo=void 0,null==(i=this.No)||i.call(this),this.No=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.$o=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pt]:this.$o}),this.qt=this.jo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.jo()}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.qo.consumeRateLimit(s)?Ze.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.Bo=[],this.Ho=new M([new G,new st,new Y,new K,new it,new et,new Z,new rt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=q.test(l)?l.replace(q,"$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||L});var r}))}(n)}}("web:javascript",V,J)),this._instance=t,this.Bo=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property($t))&&void 0!==e?e:[],this.Uo=ut(this.zo()),this.Vo=new ht(this.Uo)}onConfigChange(){this.Uo=ut(this.zo()),this.Vo.setConfig(this.Uo)}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.Bo=s,this._instance.persistence&&this._instance.persistence.register({[$t]:this.Bo,[It]:n})}}get Wo(){var t,e=!!this._instance.get_property(It),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.Ho.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.Uo.enabled)try{if(!g(t)||0===t.trim().length)return void er.warn("Ignoring exception step because message must be a non-empty string");var r=this.Go(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>ot.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&er.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Vo.add(i({[nt]:t,[at]:(new Date).toISOString()},s))}catch(t){er.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Zo(e)){if(this.Qo(e))return this.Jo("Exception dropped: matched a suppression rule"),void er.info("Skipping exception capture because a suppression rule matched");if(!this.Wo&&this.Ko(e))return this.Jo("Exception dropped: thrown by a browser extension"),void er.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Yo(e))return this.Jo("Exception dropped: thrown by the PostHog SDK"),void er.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Uo.enabled&&b(t.$exception_steps)?this.Xo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",In:!0});return r&&this.Vo.clear(),r}catch(t){return er.error("Failed to capture exception event. Dropping this exception.",t),void this.Vo.clear()}}catch(t){return void er.error("Failed to process exception event. Ignoring this exception.",t)}}Xo(t){try{var e=this.Vo.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return er.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Jo(t){this.Uo.enabled&&this.Vo.add({[nt]:t,[at]:(new Date).toISOString()})}Go(t){return f(t)?i({},t):{}}zo(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Qo(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return g(i)&&i.length>0&&t.$exception_types.push(i),g(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Bo.some((t=>{var i=t.values.map((t=>{var i,r=Si[t.operator],s=d(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)}))}Ko(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://")))}Yo(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}Zo(t){return!b(t)&&d(t)}}},vr=i({productTours:class{get Si(){return this._instance.persistence}constructor(t){this.ea=null,this.ta=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.Si&&this.Si.register({[Ot]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.ea||(t=this._instance).config.disable_product_tours||null==(e=t.persistence)||!e.get_property(Ot)||this.lr((()=>this.ra()))}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Ti.error("Could not load product tours script",e):t()}))}ra(){var t;!this.ea&&null!=(t=_t.__PosthogExtensions__)&&t.generateProductTours&&(this.ea=_t.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!d(this.ta)||e){var i=this.Si;if(i){var r=i.props[Gt];if(d(r)&&!e)return this.ta=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=>{var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Ti.error(s),void t([],{isLoaded:!1,error:s})}var n=d(e.json.product_tours)?e.json.product_tours:[];this.ta=n,i&&i.register({[Gt]:n}),t(n,{isLoaded:!0})}})}else t(this.ta,{isLoaded:!0})}getActiveProductTours(t){b(this.ea)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.ea.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.ea)||e.showTourById(t)}previewTour(t){this.ea?this.ea.previewTour(t):this.lr((()=>{var e;this.ra(),null==(e=this.ea)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.ea)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.ea)||t.nextStep()}previousStep(){var t;null==(t=this.ea)||t.previousStep()}clearCache(){var t;this.ta=null,null==(t=this.Si)||t.unregister(Gt)}resetTour(t){var e;null==(e=this.ea)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.ea)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.ea)||e.cancelPendingTour(t)}}},or),dr={siteApps:class{constructor(t){this._instance=t,this.ia=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}na(t,e){if(e){var i=this.globalsForEvent(e);this.ia.push(i),this.ia.length>1e3&&(this.ia=this.ia.slice(10))}}get siteAppLoaders(){var t;return null==(t=_t._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.na.bind(this));this.sa=()=>{t(),this.ia=[],this.sa=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,Oi),{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}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.ia.length&&(Ai.info("Processing "+this.ia.length+" events for site app with id "+t.id),this.ia.forEach((t=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.sa)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Ai.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=t.init({posthog:this._instance,callback(t){s(t)}});n&&(e.processEvent=n),r=!0}catch(e){Ai.error(ji+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Ai.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}oa(){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)}aa(t){if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(e)}catch(e){Ai.error("Error while processing event "+t.event+" for site app "+i.id,e)}}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.oa(),void this._instance.on("eventCaptured",(t=>this.aa(t)))):void Ai.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.sa)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;_t["__$$ph_site_app_"+t]=s._instance,null==(e=_t.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Ai.error(ji+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Ai.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},cr={tracingHeaders:class{constructor(t){this.ua=void 0,this.la=void 0,this.ha=void 0,this.Oo=()=>{var t,e,i=this.ca();i?(p(this.ua)&&(this.ua=null==(t=_t.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),p(this.la)&&(this.la=null==(e=_t.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Do()},this._instance=t}initialize(){this.startIfEnabledOrStop()}lr(t){var e,i;null!=(e=_t.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=_t.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return Qe.error("failed to load script",e);t()}))}da(){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}ca(){var t=this.da();return d(t)?(d(this.ha)?this.ha.splice(0,this.ha.length,...t):this.ha=[...t],t.length>0?this.ha:void 0):(d(this.ha)&&this.ha.splice(0),this.ha=t||void 0,this.ha)}Do(){var t,e;null==(t=this.ua)||t.call(this),null==(e=this.la)||e.call(this),this.ua=void 0,this.la=void 0}startIfEnabledOrStop(){this.ca()?this.lr(this.Oo):this.Do()}}},fr=i({surveys:class{get qt(){return this._instance.config}constructor(t){this.va=void 0,this._surveyManager=null,this.fa=!1,this.pa=[],this.ga=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qt.disable_surveys){var e=t.surveys;if(b(e))return Di.warn("Flags not loaded yet. Not loading surveys.");var i=d(e);this.va=i?e.length>0:e,Di.info("flags response received, isSurveysEnabled: "+this.va),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var i=localStorage.key(e);(null!=i&&i.startsWith("seenSurvey_")||null!=i&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((t=>localStorage.removeItem(t)))}loadIfEnabled(){if(!this._surveyManager)if(this.fa)Di.info("Already initializing surveys, skipping...");else if(this.qt.disable_surveys)Di.info(Ji);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())Di.info("Not loading surveys in cookieless mode without consent.");else{var t=null==_t?void 0:_t.__PosthogExtensions__;if(t){if(!p(this.va)||this.qt.advanced_enable_surveys){var e=this.va||this.qt.advanced_enable_surveys;this.fa=!0;try{var i=t.generateSurveys;if(i)return void this.ma(i,e);var r=t.loadExternalDependency;if(!r)return void this.ya(te);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.ya("Could not load surveys script",i):this.ma(t.generateSurveys,e)}))}catch(t){throw this.ya("Error initializing surveys",t),t}finally{this.fa=!1}}}else Di.error("PostHog Extensions not found.")}}ma(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new Wi(this._instance),Di.info("Surveys loaded successfully"),this.ba({isLoaded:!0})}ya(t,e){Di.error(t,e),this.ba({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.pa.push(t),this._surveyManager&&this.ba({isLoaded:!0}),()=>{this.pa=this.pa.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.qt.disable_surveys)return Di.info(Ji),t([]);var i,r=this._instance.get_property(Jt);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.ga?this.ga.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.ga=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qt.token),method:"GET",timeout:this.qt.surveys_request_timeout_ms,callback:e=>{var r;this.ga=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Di.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({[Jt]:l,$surveys_loaded_at:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}ba(t){for(var e of this.pa)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Di.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!b(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Di.warn("init was not called")}_a(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}wa(t){if(b(this._surveyManager))return{eligible:!1,reason:Bi};var e="string"==typeof t?this._a(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(b(this._surveyManager))return Di.warn("init was not called"),{visible:!1,disabledReason:Bi};var e=this.wa(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return b(this._surveyManager)?(Di.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Bi})):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.wa(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(b(this._surveyManager))Di.warn("init was not called");else{var s="string"==typeof t?this._a(t):t;if(null!=s&&s.id)if(Ni.includes(s.type)){var n=null==pt?void 0:pt.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Di.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Di.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),Di.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Di.warn("Survey element not found")}else Di.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Di.warn("Survey not found")}}displaySurvey(t,e){var r;if(b(this._surveyManager))Di.warn("init was not called");else{var s=this._a(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&&Di.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 Di.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 Di.warn("Survey not found")}}cancelPendingSurvey(t){b(this._surveyManager)?Di.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},or),pr={toolbar:class{constructor(t){this.instance=t}xa(t){_t.ph_toolbar_state=t}ka(){var t;return null!==(t=_t.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),Ft(this.instance.config))return!1;if(!dt||!pt)return!1;t=null!=t?t:dt.location,i=null!=i?i:dt.history;try{if(!e){try{dt.localStorage.setItem("test","test"),dt.localStorage.removeItem("test")}catch(t){return!1}e=null==dt?void 0:dt.localStorage}var r,s=qi||Ve(t.hash,"__posthog")||Ve(t.hash,"state"),n=s?kt((()=>JSON.parse(atob(decodeURIComponent(s)))))||kt((()=>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(Gi)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Sa(t){var e=_t.ph_load_toolbar||_t.ph_load_editor;!b(e)&&c(e)?e(t,this.instance):Ki.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==pt||!pt.getElementById(Qt));if(!dt||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(dt.localStorage.setItem(Gi,JSON.stringify(i({},s,{source:void 0}))),2===this.ka())this.Sa(s);else if(0===this.ka()){var n;this.xa(1),null==(n=_t.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return Ki.error("[Toolbar] Failed to load",t),void this.xa(0);this.xa(2),this.Sa(s)})),St(dt,"turbolinks:load",(()=>{this.xa(0),this.loadToolbar(s)}))}return!0}Ca(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)}}},gr=i({experiments:sr},or),_r={conversations:class{constructor(t){this.Ia=void 0,this._conversationsManager=null,this.Ta=!1,this.Ea=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;b(e)||(y(e)?this.Ia=e:(this.Ia=e.enabled,this.Ea=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Ia=void 0,this.Ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ta||this._instance.config.disable_conversations||Ft(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==_t?void 0:_t.__PosthogExtensions__;if(t&&!p(this.Ia)&&this.Ia)if(this.Ea&&this.Ea.token){this.Ta=!0;try{var e=t.initConversations;if(e)return this.Ma(e),void(this.Ta=!1);var i=t.loadExternalDependency;if(!i)return void this.Ra(te);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.Ra("Could not load conversations script",e):this.Ma(t.initConversations),this.Ta=!1}))}catch(t){this.Ra("Error initializing conversations",t),this.Ta=!1}}else nr.error("Conversations enabled but missing token in remote config.")}}Ma(t){if(this.Ea)try{this._conversationsManager=t(this.Ea,this._instance),nr.info("Conversations loaded successfully")}catch(t){this.Ra("Error completing conversations initialization",t)}else nr.error("Cannot complete initialization: remote config is null")}Ra(t,e){nr.error(t,e),this._conversationsManager=null,this.Ta=!1}show(){this._conversationsManager?this._conversationsManager.show():nr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Ia&&!_(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):(nr.warn(ar),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(nr.warn(ar),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(nr.warn(ar),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(nr.warn(ar),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(nr.warn(ar),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(nr.warn(ar),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(nr.warn(ar),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}Ln(){var t;null==(t=this._conversationsManager)||t.setIdentity()}An(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},br={logs:class{constructor(t){var e;this.Pa=!1,this.Oa=!1,this.Zt=yt("[logs]"),this.La=[],this.Aa=0,this.Fa=0,this.Na=!1,this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.Pa=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!b(i)&&i&&(this.Pa=!0,this.loadIfEnabled())}reset(){this.La=[],this.ii&&(clearTimeout(this.ii),this.ii=void 0),this.Aa=0,this.Fa=0,this.Na=!1}loadIfEnabled(){if(this.Pa&&!this.Oa){var t=null==_t?void 0:_t.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Zt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.Oa=!0)})):this.Zt.error(te)}else this.Zt.error("PostHog Extensions not found.")}}captureLog(t){var e,r,s,n,a,o;if(this._instance.is_capturing())if(t&&t.body){var l=null!==(e=null==(r=this._instance.config.logs)?void 0:r.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(s=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==s?s:1e3,h=Date.now();if(l>h-this.Fa||(this.Fa=h,this.Aa=0,this.Na=!1),u>this.Aa){this.Aa++;var v=function(t,e){var r=t.level||"info",{text:s,number:n}=I[r]||T,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:A(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),p(t.trace_flags)||(u.flags=t.trace_flags),u}(t,this.Da());this.La.push({record:v}),(null!==(a=null==(o=this._instance.config.logs)?void 0:o.maxBufferSize)&&void 0!==a?a:100)>this.La.length?this.$a():this.flushLogs()}else this.Na||(this.Zt.warn("captureLog dropping logs: exceeded "+u+" logs per "+l+"ms"),this.Na=!0)}else this.Zt.warn("captureLog requires a body")}get logger(){return this.qa||(this.qa={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.qa}flushLogs(t){if(this.ii&&(clearTimeout(this.ii),this.ii=void 0),0!==this.La.length){var e=this.La;this.La=[];var n=this._instance.config.logs,a=i({"service.name":(null==n?void 0:n.serviceName)||"unknown_service"},(null==n?void 0:n.environment)&&{"deployment.environment":n.environment},(null==n?void 0:n.serviceVersion)&&{"service.version":n.serviceVersion},null==n?void 0:n.resourceAttributes),o=function(t,e,i,r){return{resourceLogs:[{resource:{attributes:A(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}(e.map((t=>t.record)),a,s,r),l=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.pn({method:"POST",url:l,data:o,compression:"best-available",batchKey:"logs",transport:t})}}$a(){var t,e;this.ii||(this.ii=setTimeout((()=>{this.ii=void 0,this.flushLogs()}),null!==(t=null==(e=this._instance.config.logs)?void 0:e.flushIntervalMs)&&void 0!==t?t:3e3))}Da(){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!=_t&&null!=(t=_t.location)&&t.href&&(e.currentUrl=_t.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(e.activeFeatureFlags=r)}return e}}},mr=i({},or,lr,ur,hr,vr,dr,fr,cr,pr,gr,_r,br),yr=or,wr=lr,xr=ur,Er=hr,kr=vr,Sr=dr,Fr=fr,Cr=cr,Rr=pr,Pr=gr,$r=_r,Ir=br;export{mr as AllExtensions,xr as AnalyticsExtensions,$r as ConversationsExtensions,Er as ErrorTrackingExtensions,Pr as ExperimentsExtensions,yr as FeatureFlagsExtensions,Ir as LogsExtensions,kr as ProductToursExtensions,wr as SessionReplayExtensions,Sr as SiteAppsExtensions,Fr as SurveysExtensions,Rr as ToolbarExtensions,Cr as TracingExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map