posthog-js 1.274.2 → 1.274.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/replay/session-recording.js +4 -2
- package/lib/src/extensions/replay/session-recording.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,i,r,s,n,a){try{var o=e[n](a),l=o.value}catch(e){return void i(e)}o.done?t(l):Promise.resolve(l).then(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=t.apply(i,r);function o(t){e(a,s,n,o,l,"next",t)}function l(t){e(a,s,n,o,l,"throw",t)}o(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:s,a=Array.prototype,o=a.forEach,l=a.indexOf,c=null==n?void 0:n.navigator,u=null==n?void 0:n.document,d=null==n?void 0:n.location,_=null==n?void 0:n.fetch,h=null!=n&&n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest?n.XMLHttpRequest:void 0,p=null==n?void 0:n.AbortController,g=null==c?void 0:c.userAgent,v=null!=s?s:{},f={DEBUG:!1,LIB_VERSION:"1.274.2"},m=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function y(e,t){return-1!==e.indexOf(t)}var b=function(e){return e.trim()},w=function(e){return e.replace(/^\$/,"")};var E=Array.isArray,S=Object.prototype,x=S.hasOwnProperty,k=S.toString,P=E||function(e){return"[object Array]"===k.call(e)},I=e=>"function"==typeof e,C=e=>e===Object(e)&&!P(e),F=e=>{if(C(e)){for(var t in e)if(x.call(e,t))return!1;return!0}return!1},R=e=>void 0===e,T=e=>"[object String]"==k.call(e),O=e=>T(e)&&0===e.trim().length,L=e=>null===e,A=e=>R(e)||L(e),M=e=>"[object Number]"==k.call(e),D=e=>"[object Boolean]"===k.call(e),N=e=>e instanceof FormData,q=e=>y(m,e);function j(e){return null===e||"object"!=typeof e}function U(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function H(e){return!R(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var B=[!0,"true",1,"1","yes"],z=e=>y(B,e),W=[!1,"false",0,"0","no"];function V(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),M(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),V(s||i,t,i,r))}class G{constructor(e){this._options=e,this._buckets={},this._refillBuckets=()=>{Object.keys(this._buckets).forEach((e=>{var t=this._getBucket(e)+this._refillRate;t>=this._bucketSize?delete this._buckets[e]:this._setBucket(e,t)}))},this._getBucket=e=>this._buckets[String(e)],this._setBucket=(e,t)=>{this._buckets[String(e)]=t},this.consumeRateLimit=e=>{var t,i,r=null!==(t=this._getBucket(e))&&void 0!==t?t:this._bucketSize;if(0===(r=Math.max(r-1,0)))return!0;this._setBucket(e,r);var s=0===r;return s&&(null==(i=this._onBucketRateLimited)||i.call(this,e)),s},this._onBucketRateLimited=this._options._onBucketRateLimited,this._bucketSize=V(this._options.bucketSize,0,100,this._options._logger),this._refillRate=V(this._options.refillRate,0,this._bucketSize,this._options._logger),this._refillInterval=V(this._options.refillInterval,0,864e5,this._options._logger),this._removeInterval=setInterval((()=>{this._refillBuckets()}),this._refillInterval)}stop(){this._removeInterval&&(clearInterval(this._removeInterval),this._removeInterval=void 0)}}var Y,J,K,X=e=>e instanceof Error;function Q(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return K&&i.length===J||(J=i.length,K=i.reduce(((i,r)=>{Y||(Y={});var s=Y[r];if(s)i[s[0]]=s[1];else for(var n=e(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,c=t[r];if(l&&c){i[l]=c,Y[r]=[l,c];break}}return i}),{})),K}}var Z="?";function ee(e,t,i,r){var s={platform:"web:javascript",filename:e,function:"<anonymous>"===t?Z:t,in_app:!0};return R(i)||(s.lineno=i),R(r)||(s.colno=r),s}var te=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:Z,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},ie=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,re=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,se=/\((\S*)(?::(\d+))(?::(\d+))\)/,ne=e=>{var t=ie.exec(e);if(t){var[,i,r,s]=t;return ee(i,Z,+r,+s)}var n=re.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){var a=se.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}var[o,l]=te(n[1]||Z,n[2]);return ee(l,o,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},ae=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,oe=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,le=e=>{var t=ae.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=oe.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],s=t[1]||Z;return[s,r]=te(s,r),ee(r,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},ce=/\(error: (.*)\)/,ue=50;function de(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r){void 0===r&&(r=0);for(var s=[],n=e.split("\n"),a=r;a<n.length;a++){var o=n[a];if(!(o.length>1024)){var l=ce.test(o)?o.replace(ce,"$1"):o;if(!l.match(/\S*Error: /)){for(var c of t){var u=c(l);if(u){s.push(u);break}}if(s.length>=ue)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,ue).map((e=>{return i({},e,{filename:e.filename||(r=t,r[r.length-1]||{}).filename,function:e.function||Z});var r}))}(s)}}class _e{constructor(e,t,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=[]),this.coercers=e,this.modifiers=i,this.stackParser=de(...t)}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&P(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var i=this;return t((function*(){var t=e;for(var r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,a={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var o=[a];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),o}buildParsingContext(){return{chunkIdMap:Q(this.stackParser)}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(r<=4){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}class he{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=T(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return U(e,"DOMException")}isDOMError(e){return U(e,"DOMError")}}class pe{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return i.error&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class ge{constructor(){}match(e){return U(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i,r=t.apply(e.error);return r||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var ve=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class fe{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(ve);return r&&(t=r[1],i=r[2]),[t,i]}}var me=["fatal","error","warning","log","info","debug"];function ye(e,t){void 0===t&&(t=40);var i=Object.keys(e);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(!(s.length>t))return r===i.length||s.length<=t?s:s.slice(0,t)+"..."}return""}class be{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return H(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ye(e)}isSeverityLevel(e){return T(e)&&!O(e)&&me.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(X(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class we{match(e){return H(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ye(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Ee{match(e){return j(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Se{match(e){return U(e,"PromiseRejectionEvent")}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return j(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){if(j(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var xe=e=>{var t={_log:function(t){if(s&&(f.DEBUG||v.POSTHOG_DEBUG)&&!R(s.console)&&s.console){for(var i=("__rrweb_original__"in s.console[t]?s.console[t].__rrweb_original__:s.console[t]),r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];i(e,...n)}},info:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];t._log("log",...i)},warn:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];t._log("warn",...i)},error:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];t._log("error",...i)},critical:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning:e=>{t.error("You must initialize PostHog before calling "+e)},createLogger:t=>xe(e+" "+t)};return t},ke=xe("[PostHog.js]"),Pe=ke.createLogger,Ie={};function Ce(e,t,i){if(P(e))if(o&&e.forEach===o)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,s=e.length;r<s;r++)if(r in e&&t.call(i,e[r],r)===Ie)return}function Fe(e,t,i){if(!A(e)){if(P(e))return Ce(e,t,i);if(N(e)){for(var r of e.entries())if(t.call(i,r[1],r[0])===Ie)return}else for(var s in e)if(x.call(e,s)&&t.call(i,e[s],s)===Ie)return}}var Re=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ce(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Te=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ce(i,(function(t){Ce(t,(function(t){e.push(t)}))})),e};function $e(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Oe=function(e){try{return e()}catch(e){return}},Le=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){ke.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),ke.critical(e)}}},Ae=function(e){var t={};return Fe(e,(function(e,i){(T(e)&&e.length>0||M(e))&&(t[i]=e)})),t};function Me(e,t){return i=e,r=e=>T(e)&&!L(t)?e.slice(0,t):e,s=new Set,function e(t,i){return t!==Object(t)?r?r(t,i):t:s.has(t)?void 0:(s.add(t),P(t)?(n=[],Ce(t,(t=>{n.push(e(t))}))):(n={},Fe(t,((t,i)=>{s.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,r,s}var De=["herokuapp.com","vercel.app","netlify.app"];function Ne(e){var t=null==e?void 0:e.hostname;if(!T(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of De)if(i===r)return!1;return!0}function qe(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function je(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}var Ue="$people_distinct_id",He="__alias",Be="__timers",ze="$autocapture_disabled_server_side",We="$heatmaps_enabled_server_side",Ve="$exception_capture_enabled_server_side",Ge="$error_tracking_suppression_rules",Ye="$error_tracking_capture_extension_exceptions",Je="$web_vitals_enabled_server_side",Ke="$dead_clicks_enabled_server_side",Xe="$web_vitals_allowed_metrics",Qe="$session_recording_remote_config",Ze="$sesid",et="$session_is_sampled",tt="$enabled_feature_flags",it="$early_access_features",rt="$feature_flag_details",st="$stored_person_properties",nt="$stored_group_properties",at="$surveys",ot="$surveys_activated",lt="$flag_call_reported",ct="$user_state",ut="$client_session_props",dt="$capture_rate_limit",_t="$initial_campaign_params",ht="$initial_referrer_info",pt="$initial_person_info",gt="$epp",vt="__POSTHOG_TOOLBAR__",ft="$posthog_cookieless",mt=[Ue,He,"__cmpns",Be,"$session_recording_enabled_server_side",We,Ze,tt,Ge,ct,it,rt,nt,st,at,lt,ut,dt,_t,ht,gt,pt];function yt(e){return e instanceof Element&&(e.id===vt||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function bt(e){return!!e&&1===e.nodeType}function wt(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Et(e){return!!e&&3===e.nodeType}function St(e){return!!e&&11===e.nodeType}function xt(e){return e?b(e).split(/\s+/):[]}function kt(e){var t=null==s?void 0:s.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Pt(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return xt(t)}function It(e){return A(e)?null:b(e).split(/(\s+)/).filter((e=>Wt(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ct(e){var t="";return Dt(e)&&!Nt(e)&&e.childNodes&&e.childNodes.length&&Fe(e.childNodes,(function(e){var i;Et(e)&&e.textContent&&(t+=null!==(i=It(e.textContent))&&void 0!==i?i:"")})),b(t)}function Ft(e){return R(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Rt=["a","button","form","input","select","textarea","label"];function Tt(e,t){if(R(t))return!0;var i,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function $t(e){var t=e.parentNode;return!(!t||!bt(t))&&t}var Ot=[".ph-no-rageclick",".ph-no-capture"];var Lt=e=>!e||wt(e,"html")||!bt(e),At=(e,t)=>{if(!s||Lt(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],n=e;n.parentNode&&!wt(n,"body");)if(St(n.parentNode))r.push(n.parentNode.host),n=n.parentNode.host;else{var a=$t(n);if(!a)break;if(t||Rt.indexOf(a.tagName.toLowerCase())>-1)i=!0;else{var o=s.getComputedStyle(a);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(a),n=a}return{parentIsUsefulElement:i,targetElementList:r}};function Mt(e,t,i,r,n){var a,o,l,c;if(void 0===i&&(i=void 0),!s||Lt(e))return!1;if(null!=(a=i)&&a.url_allowlist&&!kt(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&kt(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=At(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(R(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(_,i))return!1;if(!Tt(_,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var h=s.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var p=e.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Rt.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function Dt(e){for(var t=e;t.parentNode&&!wt(t,"body");t=t.parentNode){var i=Pt(t);if(y(i,"ph-sensitive")||y(i,"ph-no-capture"))return!1}if(y(Pt(e),"ph-include"))return!0;var r=e.type||"";if(T(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";if(T(s)){if(/^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,"")))return!1}return!0}function Nt(e){return!!(wt(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||wt(e,"select")||wt(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var qt="(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})",jt=new RegExp("^(?:"+qt+")$"),Ut=new RegExp(qt),Ht="\\d{3}-?\\d{2}-?\\d{4}",Bt=new RegExp("^("+Ht+")$"),zt=new RegExp("("+Ht+")");function Wt(e,t){if(void 0===t&&(t=!0),A(e))return!1;if(T(e)){if(e=b(e),(t?jt:Ut).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Bt:zt).test(e))return!1}return!0}function Vt(e){var t=Ct(e);return Wt(t=(t+" "+Gt(e)).trim())?t:""}function Gt(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Fe(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Ct(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Gt(e)).trim())}catch(e){ke.error("[AutoCapture]",e)}})),t}function Yt(e){return function(e){var t=e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var a=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),o={};return $e(a).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return o[Jt(t.toString())]=Jt(i.toString())})),s+=":",s+=$e(o).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Kt(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return $e(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(e))}function Jt(e){return e.replace(/"|\\"/g,'\\"')}function Kt(e){var t=e.attr__class;return t?P(t)?t:xt(t):void 0}class Xt{constructor(){this.clicks=[]}isRageClick(e,t,i){var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<30&&i-r.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Qt="$copy_autocapture",Zt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ei=["fatal","error","warning","log","info","debug"],ti=e=>{var t=null==u?void 0:u.createElement("a");return R(t)?null:(t.href=e,t)},ii=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return Fe(e,(function(e,t){R(e)||R(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)},ri=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<r.length;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!P(i)||i.length<2)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(e){ke.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},si=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[0]||"",n=r[1],a=s.split("?"),o=a[1],l=a[0],c=(o||"").split("&"),u=[],d=0;d<c.length;d++){var _=c[d].split("=");P(_)&&(t.includes(_[0])?u.push(_[0]+"="+i):u.push(c[d]))}var h=l;return null!=o&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},ni=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ai=Pe("[AutoCapture]");function oi(e,t){return t.length>e?t.slice(0,e)+"...":t}function li(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!bt(t));return t}function ci(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};Rt.indexOf(s)>-1&&!i&&("a"===s.toLowerCase()||"button"===s.toLowerCase()?n.$el_text=oi(1024,Vt(e)):n.$el_text=oi(1024,Ct(e)));var a=Pt(e);a.length>0&&(n.classes=a.filter((function(e){return""!==e}))),Fe(e.attributes,(function(i){var s;if((!Nt(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==r||!r.includes(i.name))&&!t&&Wt(i.value)&&(s=i.name,!T(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7)))){var a=i.value;"class"===i.name&&(a=xt(a).join(" ")),n["attr__"+i.name]=oi(1024,a)}}));for(var o=1,l=1,c=e;c=li(c);)o++,c.tagName===e.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}function ui(e,t){for(var i,r,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!wt(d,"body");)St(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(Fe(u,(e=>{var t=Dt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Wt(g)&&g),y(Pt(e),"ph-no-capture")&&(v=!0),h.push(ci(e,a,o,l));var i=function(e){if(!Dt(e))return{};var t={};return Fe(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Wt(r)&&(t[i]=r)}})),t}(e);Re(p,i)})),v)return{props:{},explicitNoCapture:v};if(o||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=Vt(e):h[0].$el_text=Ct(e)),g){var f,m;h[0].attr__href=g;var b=null==(f=ti(g))?void 0:f.host,w=null==s||null==(m=s.location)?void 0:m.host;b&&w&&b!==w&&(_=g)}return{props:Re({$event_type:n.type,$ce_version:1},c?{}:{$elements:h},{$elements_chain:Yt(h)},null!=(i=h[0])&&i.$el_text?{$el_text:null==(r=h[0])?void 0:r.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},p)}}class di{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new Xt,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,i=C(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(s&&u){var e=e=>{e=e||(null==s?void 0:s.event);try{this._captureEvent(e)}catch(e){ai.error("Failed to capture event",e)}};if(je(u,"submit",e,{capture:!0}),je(u,"change",e,{capture:!0}),je(u,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==s?void 0:s.event),this._captureEvent(e,Qt)};je(u,"copy",t,{capture:!0}),je(u,"cut",t,{capture:!0})}}}else ai.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[ze]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==u?void 0:u.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[ze],r=this._isDisabledServerSide;if(L(r)&&!D(i)&&!this.instance._shouldDisableFlags())return!1;var s=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!s}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=Ft(e);if(Et(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&function(e,t){if(!s||Lt(e))return!1;var i,r;if(!1===(i=D(t)?!!t&&Ot:null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:Ot))return!1;var{targetElementList:n}=At(e,!1);return!Tt(n,i)}(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===Qt;if(r&&Mt(r,e,this._config,n,n?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=ui(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(a.$element_selectors=l),t===Qt){var c,u=It(null==s||null==(c=s.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=d}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return I(null==u?void 0:u.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return M(e)&&isFinite(e)&&Math.floor(e)===e});var _i="0123456789abcdef";class hi{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||e<0||t<0||i<0||r<0||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new hi(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+_i.charAt(this.bytes[t]>>>4)+_i.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new hi(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class pi{constructor(){this._timestamp=0,this._counter=0,this._random=new fi}generate(){var e=this.generateOrAbort();if(R(e)){this._timestamp=0;var t=this.generateOrAbort();if(R(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return hi.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var gi,vi=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};s&&!R(s.crypto)&&crypto.getRandomValues&&(vi=e=>crypto.getRandomValues(e));class fi{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(vi(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var mi=()=>yi().toString(),yi=()=>(gi||(gi=new pi)).generate(),bi="";var wi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ei(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=u),bi)return bi;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+mi();!bi&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";t.cookie=a+";max-age=3",t.cookie.includes(s)&&(t.cookie=a+";max-age=0",bi=n)}return bi}(e);if(!i){var r=(e=>{var t=e.match(wi);return t?t[0]:""})(e);r!==i&&ke.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var Si={_is_supported:()=>!!u,_error:function(e){ke.error("cookieStore error: "+e)},_get:function(e){if(u){try{for(var t=e+"=",i=u.cookie.split(";").filter((e=>e.length)),r=0;r<i.length;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(Si._get(e))||{}}catch(e){}return t},_set:function(e,t,i,r,s){if(u)try{var n="",a="",o=Ei(u.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}s&&(a="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+o+a;return c.length>3686.4&&ke.warn("cookieStore warning: large cookie, len="+c.length),u.cookie=c,c}catch(e){return}},_remove:function(e,t){if(null!=u&&u.cookie)try{Si._set(e,"",-1,t)}catch(e){return}}},xi=null,ki={_is_supported:function(){if(!L(xi))return xi;var e=!0;if(R(s))e=!1;else try{var t="__mplssupport__";ki._set(t,"xyz"),'"xyz"'!==ki._get(t)&&(e=!1),ki._remove(t)}catch(t){e=!1}return e||ke.error("localStorage unsupported; falling back to cookie store"),xi=e,e},_error:function(e){ke.error("localStorage error: "+e)},_get:function(e){try{return null==s?void 0:s.localStorage.getItem(e)}catch(e){ki._error(e)}return null},_parse:function(e){try{return JSON.parse(ki._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==s||s.localStorage.setItem(e,JSON.stringify(t))}catch(e){ki._error(e)}},_remove:function(e){try{null==s||s.localStorage.removeItem(e)}catch(e){ki._error(e)}}},Pi=["distinct_id",Ze,et,gt,pt],Ii=i({},ki,{_parse:function(e){try{var t={};try{t=Si._parse(e)||{}}catch(e){}var i=Re(t,JSON.parse(ki._get(e)||"{}"));return ki._set(e,i),i}catch(e){}return null},_set:function(e,t,i,r,s,n){try{ki._set(e,t,void 0,void 0,n);var a={};Pi.forEach((e=>{t[e]&&(a[e]=t[e])})),Object.keys(a).length&&Si._set(e,a,i,r,s,n)}catch(e){ki._error(e)}},_remove:function(e,t){try{null==s||s.localStorage.removeItem(e),Si._remove(e,t)}catch(e){ki._error(e)}}}),Ci={},Fi={_is_supported:function(){return!0},_error:function(e){ke.error("memoryStorage error: "+e)},_get:function(e){return Ci[e]||null},_parse:function(e){return Ci[e]||null},_set:function(e,t){Ci[e]=t},_remove:function(e){delete Ci[e]}},Ri=null,Ti={_is_supported:function(){if(!L(Ri))return Ri;if(Ri=!0,R(s))Ri=!1;else try{var e="__support__";Ti._set(e,"xyz"),'"xyz"'!==Ti._get(e)&&(Ri=!1),Ti._remove(e)}catch(e){Ri=!1}return Ri},_error:function(e){ke.error("sessionStorage error: ",e)},_get:function(e){try{return null==s?void 0:s.sessionStorage.getItem(e)}catch(e){Ti._error(e)}return null},_parse:function(e){try{return JSON.parse(Ti._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==s||s.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Ti._error(e)}},_remove:function(e){try{null==s||s.sessionStorage.removeItem(e)}catch(e){Ti._error(e)}}},$i=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class Oi{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?$i.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===$i.DENIED||this.consent===$i.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===$i.DENIED}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){var e=this._storage._get(this._storageKey);return z(e)?$i.GRANTED:y(W,e)?$i.DENIED:$i.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?ki:Si;var t="localStorage"===e?Si:ki;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(z(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!qe([null==c?void 0:c.doNotTrack,null==c?void 0:c.msDoNotTrack,v.doNotTrack],(e=>z(e)))}}var Li=Pe("[Dead Clicks]"),Ai=()=>!0,Mi=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Ke)),r=e.instance.config.capture_dead_clicks;return D(r)?r:i};class Di{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Ke]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this._loadScript((()=>{this._start()}))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Li.error("failed to load script",t):e()}))}_start(){var e;if(u){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=C(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(u),Li.info("starting...")}}else Li.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Li.info("stopping..."))}}var Ni=Pe("[ExceptionAutocapture]");class qi{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(s&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=r(this.captureException.bind(this)))}catch(e){Ni.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Ve]),this._config=this._requiredConfig(),this._rateLimiter=new G({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,_logger:Ni}),this.startIfEnabled()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return C(e)?t=i({},t,e):(R(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(Ni.info("enabled"),this._loadScript(this._startCapturing))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return Ni.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this._remoteEnabled=!!t||!1,this._config=this._requiredConfig(),this._instance.persistence&&this._instance.persistence.register({[Ve]:this._remoteEnabled}),this.startIfEnabled()}captureException(e){var t,i,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(r)?Ni.info("Skipping exception capture because of client rate limiting.",{exception:r}):this._instance.exceptions.sendExceptionEvent(e)}}function ji(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return I(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]=r}}catch(e){return()=>{}}}class Ui{constructor(e){var t;this._instance=e,this._lastPathname=(null==s||null==(t=s.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(ke.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,ke.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(s&&s.history){var i=this;null!=(e=s.history.pushState)&&e.__posthog_wrapped__||ji(s.history,"pushState",(e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("pushState")})),null!=(t=s.history.replaceState)&&t.__posthog_wrapped__||ji(s.history,"replaceState",(e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("replaceState")})),this._setupPopstateListener()}}_capturePageview(e){try{var t,i=null==s||null==(t=s.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._lastPathname=i}catch(t){ke.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};je(s,"popstate",e),this._popstateListener=()=>{s&&s.removeEventListener("popstate",e)}}}}var Hi=Pe("[SegmentIntegration]");function Bi(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||mi();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(ct,"identified")),t()},s=i.user();"then"in s&&I(s.then)?s.then((e=>r(e))):r(s)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Hi.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Hi.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Hi.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var zi="posthog-js";function Wi(e,t){var{organization:r,projectId:s,prefix:n,severityAllowList:a=["error"],sendExceptionsToPostHog:o=!0}=void 0===t?{}:t;return t=>{var l,c,u,d,_;if(!("*"===a||a.includes(t.level))||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(l=t.exception)?void 0:l.values)||[],g=p.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),v={$exception_message:(null==(c=p[0])?void 0:c.value)||t.message,$exception_type:null==(u=p[0])?void 0:u.type,$exception_personURL:h,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=p[0])?void 0:_.type,$sentry_tags:t.tags};return r&&s&&(v.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),o&&e.exceptions.sendExceptionEvent(v),t}}class Vi{constructor(e,t,i,r,s,n){this.name=zi,this.setupOnce=function(a){a(Wi(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}var Gi=null!=s&&s.location?ni(s.location.hash,"__posthog")||ni(location.hash,"state"):null,Yi="_postHogToolbarParams",Ji=Pe("[Toolbar]"),Ki=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Ki||{});class Xi{constructor(e){this.instance=e}_setToolbarState(e){v.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=v.ph_toolbar_state)&&void 0!==e?e:Ki.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!s||!u)return!1;e=null!=e?e:s.location,i=null!=i?i:s.history;try{if(!t){try{s.localStorage.setItem("test","test"),s.localStorage.removeItem("test")}catch(e){return!1}t=null==s?void 0:s.localStorage}var r,n=Gi||ni(e.hash,"__posthog")||ni(e.hash,"state"),a=n?Oe((()=>JSON.parse(atob(decodeURIComponent(n)))))||Oe((()=>JSON.parse(decodeURIComponent(n)))):null;return a&&"ph_authorize"===a.action?((r=a).source="url",r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(Yi)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token)&&(this.loadToolbar(r),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=v.ph_load_toolbar||v.ph_load_editor;!A(t)&&I(t)?t(e,this.instance):Ji.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==u||!u.getElementById(vt));if(!s||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(s.localStorage.setItem(Yi,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Ki.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Ki.UNINITIALIZED){var a;this._setToolbarState(Ki.LOADING),null==(a=v.__PosthogExtensions__)||null==a.loadExternalDependency||a.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Ji.error("[Toolbar] Failed to load",e),void this._setToolbarState(Ki.UNINITIALIZED);this._setToolbarState(Ki.LOADED),this._callLoadToolbar(n)})),je(s,"turbolinks:load",(()=>{this._setToolbarState(Ki.UNINITIALIZED),this.loadToolbar(n)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Qi=Pe("[TracingHeaders]");class Zi{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;R(this._restoreXHRPatch)&&(null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager));R(this._restoreFetchPatch)&&(null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Qi.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var er=Pe("[Web Vitals]"),tr=9e5;class ir{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t,r=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(R(r))er.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this._currentURL();if(!R(s))if(A(null==e?void 0:e.name)||A(null==e?void 0:e.value))er.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)er.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),R(this._buffer.url)&&(this._buffer.url=s),this._buffer.firstMetricTimestamp=R(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this._buffer.metrics.push(i({},e,{$current_url:s,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}},this._startCapturing=()=>{var e,t,i,r,s=v.__PosthogExtensions__;R(s)||R(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this)),this._initialized=!0):er.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Je]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=C(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return R(i)?(null==(t=this._instance.persistence)?void 0:t.props[Xe])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=C(this._instance.config.capture_performance)&&M(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:tr;return 0<e&&e<=6e4?tr:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return er.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:D(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return D(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(er.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=C(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=C(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Je]:t}),this._instance.persistence.register({[Xe]:i})),this._enabledServerSide=t,this.startIfEnabled()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"web-vitals",(t=>{t?er.error("failed to load script",t):e()}))}_currentURL(){var e=s?s.location.href:void 0;return e||er.error("Could not determine current URL"),e}}var rr=Pe("[Heatmaps]");function sr(e){return C(e)&&"clientX"in e&&"clientY"in e&&M(e.clientX)&&M(e.clientY)}class nr{constructor(e){var t;this.rageclicks=new Xt,this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[We])}get flushIntervalMilliseconds(){var e=5e3;return C(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return R(this.instance.config.capture_heatmaps)?R(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;rr.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this._flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null==(t=this._deadClicksCapture)||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[We]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){s&&u&&(je(s,"beforeunload",this._flush.bind(this)),je(u,"click",(e=>this._onClick(e||(null==s?void 0:s.event))),{capture:!0}),je(u,"mousemove",(e=>this._onMouseMove(e||(null==s?void 0:s.event))),{capture:!0}),this._deadClicksCapture=new Di(this.instance,Ai,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(e,t,i){for(var r=e;r&&bt(r)&&!wt(r,"body");){if(r===i)return!1;if(y(t,null==s?void 0:s.getComputedStyle(r).position))return!0;r=$t(r)}return!1}(Ft(e),["fixed","sticky"],n);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:i),target_fixed:a,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!yt(e.target)&&sr(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!yt(e.target)&&sr(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(s){var t=s.location.href;this._buffer=this._buffer||{},this._buffer[t]||(this._buffer[t]=[]),this._buffer[t].push(e)}}_flush(){this._buffer&&!F(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class ar{constructor(e){this._instance=e}doPageView(e,t){var i,r=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==s?void 0:s.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:a,maxScrollY:o,maxContentHeight:l,lastContentY:c,maxContentY:u}=s;if(!(R(n)||R(a)||R(o)||R(l)||R(c)||R(u))){n=Math.ceil(n),a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:V(a/n,0,1,ke),_=n<=1?1:V(o/n,0,1,ke),h=l<=1?1:V(c/l,0,1,ke),p=l<=1?1:V(u/l,0,1,ke);r=Re(r,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:o,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var or=Uint8Array,lr=Uint16Array,cr=Uint32Array,ur=new or([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),dr=new or([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_r=new or([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hr=function(e,t){for(var i=new lr(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var s=new cr(i[30]);for(r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return[i,s]},pr=hr(ur,2),gr=pr[0],vr=pr[1];gr[28]=258,vr[258]=28;for(var fr=hr(dr,0)[1],mr=new lr(32768),yr=0;yr<32768;++yr){var br=(43690&yr)>>>1|(21845&yr)<<1;br=(61680&(br=(52428&br)>>>2|(13107&br)<<2))>>>4|(3855&br)<<4,mr[yr]=((65280&br)>>>8|(255&br)<<8)>>>1}var wr=function(e,t,i){for(var r=e.length,s=0,n=new lr(t);s<r;++s)++n[e[s]-1];var a,o=new lr(t);for(s=0;s<t;++s)o[s]=o[s-1]+n[s-1]<<1;if(i){a=new lr(1<<t);var l=15-t;for(s=0;s<r;++s)if(e[s])for(var c=s<<4|e[s],u=t-e[s],d=o[e[s]-1]++<<u,_=d|(1<<u)-1;d<=_;++d)a[mr[d]>>>l]=c}else for(a=new lr(r),s=0;s<r;++s)a[s]=mr[o[e[s]-1]++]>>>15-e[s];return a},Er=new or(288);for(yr=0;yr<144;++yr)Er[yr]=8;for(yr=144;yr<256;++yr)Er[yr]=9;for(yr=256;yr<280;++yr)Er[yr]=7;for(yr=280;yr<288;++yr)Er[yr]=8;var Sr=new or(32);for(yr=0;yr<32;++yr)Sr[yr]=5;var xr=wr(Er,9,0),kr=wr(Sr,5,0),Pr=function(e){return(e/8>>0)+(7&e&&1)},Ir=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof lr?lr:e instanceof cr?cr:or)(i-t);return r.set(e.subarray(t,i)),r},Cr=function(e,t,i){i<<=7&t;var r=t/8>>0;e[r]|=i,e[r+1]|=i>>>8},Fr=function(e,t,i){i<<=7&t;var r=t/8>>0;e[r]|=i,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Rr=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new or(0),0];if(1==s){var a=new or(i[0].s+1);return a[i[0].s]=1,[a,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var o=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=s-1;)o=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:o.f+l.f,l:o,r:l};var _=n[0].s;for(r=1;r<s;++r)n[r].s>_&&(_=n[r].s);var h=new lr(_+1),p=Tr(i[u-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));r<s;++r){var m=n[r].s;if(!(h[m]>t))break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;h[y]<t?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new or(h),p]},Tr=function(e,t,i){return-1==e.s?Math.max(Tr(e.l,t,i+1),Tr(e.r,t,i+1)):t[e.s]=i},$r=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new lr(++t),r=0,s=e[0],n=1,a=function(e){i[r++]=e},o=1;o<=t;++o)if(e[o]==s&&o!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(s),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(s);n=1,s=e[o]}return[i.subarray(0,r),t]},Or=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},Lr=function(e,t,i){var r=i.length,s=Pr(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;n<r;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Ar=function(e,t,i,r,s,n,a,o,l,c,u){Cr(t,u++,i),++s[256];for(var d=Rr(s,15),_=d[0],h=d[1],p=Rr(n,15),g=p[0],v=p[1],f=$r(_),m=f[0],y=f[1],b=$r(g),w=b[0],E=b[1],S=new lr(19),x=0;x<m.length;++x)S[31&m[x]]++;for(x=0;x<w.length;++x)S[31&w[x]]++;for(var k=Rr(S,7),P=k[0],I=k[1],C=19;C>4&&!P[_r[C-1]];--C);var F,R,T,O,L=c+5<<3,A=Or(s,Er)+Or(n,Sr)+a,M=Or(s,_)+Or(n,g)+a+14+3*C+Or(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(L<=A&&L<=M)return Lr(t,u,e.subarray(l,l+c));if(Cr(t,u,1+(M<A)),u+=2,M<A){F=wr(_,h,0),R=_,T=wr(g,v,0),O=g;var D=wr(P,I,0);Cr(t,u,y-257),Cr(t,u+5,E-1),Cr(t,u+10,C-4),u+=14;for(x=0;x<C;++x)Cr(t,u+3*x,P[_r[x]]);u+=3*C;for(var N=[m,w],q=0;q<2;++q){var j=N[q];for(x=0;x<j.length;++x){var U=31&j[x];Cr(t,u,D[U]),u+=P[U],U>15&&(Cr(t,u,j[x]>>>5&127),u+=j[x]>>>12)}}}else F=xr,R=Er,T=kr,O=Sr;for(x=0;x<o;++x)if(r[x]>255){U=r[x]>>>18&31;Fr(t,u,F[U+257]),u+=R[U+257],U>7&&(Cr(t,u,r[x]>>>23&31),u+=ur[U]);var H=31&r[x];Fr(t,u,T[H]),u+=O[H],H>3&&(Fr(t,u,r[x]>>>5&8191),u+=dr[H])}else Fr(t,u,F[r[x]]),u+=R[r[x]];return Fr(t,u,F[256]),u+R[256]},Mr=new cr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Dr=function(){for(var e=new cr(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Nr=function(e,t,i,r,s){return function(e,t,i,r,s,n){var a=e.length,o=new or(r+a+5*(1+Math.floor(a/7e3))+s),l=o.subarray(r,o.length-s),c=0;if(!t||a<8)for(var u=0;u<=a;u+=65535){var d=u+65535;d<a?c=Lr(l,c,e.subarray(u,d)):(l[u]=n,c=Lr(l,c,e.subarray(u,a)))}else{for(var _=Mr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new lr(32768),f=new lr(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new cr(25e3),E=new lr(288),S=new lr(32),x=0,k=0,P=(u=0,0),I=0,C=0;u<a;++u){var F=b(u),R=32767&u,T=f[F];if(v[R]=T,f[F]=R,I<=u){var O=a-u;if((x>7e3||P>24576)&&O>423){c=Ar(e,l,0,w,E,S,k,P,C,u-C,c),P=x=k=0,C=u;for(var L=0;L<286;++L)E[L]=0;for(L=0;L<30;++L)S[L]=0}var A=2,M=0,D=p,N=R-T&32767;if(O>2&&F==b(u-N))for(var q=Math.min(h,O)-1,j=Math.min(32767,u),U=Math.min(258,O);N<=j&&--D&&R!=T;){if(e[u+A]==e[u+A-N]){for(var H=0;H<U&&e[u+H]==e[u+H-N];++H);if(H>A){if(A=H,M=N,H>q)break;var B=Math.min(N,H-2),z=0;for(L=0;L<B;++L){var W=u-N+L+32768&32767,V=W-v[W]+32768&32767;V>z&&(z=V,T=W)}}}N+=(R=T)-(T=v[R])+32768&32767}if(M){w[P++]=268435456|vr[A]<<18|fr[M];var G=31&vr[A],Y=31&fr[M];k+=ur[G]+dr[Y],++E[257+G],++S[Y],I=u+A,++x}else w[P++]=e[u],++E[e[u]]}}c=Ar(e,l,n,w,E,S,k,P,C,u-C,c)}return Ir(o,0,r+Pr(c)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,r,!0)},qr=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function jr(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=Dr[255&i^t[r]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n=Nr(e,t,10+((s=t).filename&&s.filename.length+1||0),8),a=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&qr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(n,t),qr(n,a-8,i.d()),qr(n,a-4,r),n}var Ur=function(e){var t,i,r,s,n="";for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s<r;s++){var a=e.charCodeAt(s),o=null;a<128?i++:o=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),L(o)||(i>t&&(n+=e.substring(t,i)),n+=o,t=i=s+1)}return i>t&&(n+=e.substring(t,e.length)),n},Hr=!!h||!!_,Br="text/plain",zr=(e,t)=>{var[r,s]=e.split("?"),n=i({},t);null==s||s.split("&").forEach((e=>{var[t]=e.split("=");delete n[t]}));var a=ii(n);return r+"?"+(a=a?(s?s+"&":"")+a:s)},Wr=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Vr=e=>{var{data:t,compression:i}=e;if(t){if(i===Zt.GZipJS){var r=jr(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new or(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},a=0;a<i;++a){if(s+5>r.length){var o=new or(s+8+(i-a<<1));o.set(r),r=o}var l=e.charCodeAt(a);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Ir(r,0,s)}(Wr(t)),{mtime:0}),s=new Blob([r],{type:Br});return{contentType:Br,body:s,estimatedSize:s.size}}if(i===Zt.Base64){var n=function(e){var t,i,r,s,n,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,l=0,c="",u=[];if(!e)return e;e=Ur(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,i=n>>12&63,r=n>>6&63,s=63&n,u[l++]=a.charAt(t)+a.charAt(i)+a.charAt(r)+a.charAt(s)}while(o<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Wr(t)),a=(e=>"data="+encodeURIComponent("string"==typeof e?e:Wr(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var o=Wr(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Gr=[];_&&Gr.push({transport:"fetch",method:e=>{var t,r,{contentType:s,body:n,estimatedSize:a}=null!==(t=Vr(e))&&void 0!==t?t:{},o=new Headers;Fe(e.headers,(function(e,t){o.append(t,e)})),s&&o.append("Content-Type",s);var l=e.url,c=null;if(p){var u=new p;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,i({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(a||0)<52428.8,body:n,signal:null==(r=c)?void 0:r.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){ke.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{ke.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),h&&Gr.push({transport:"XHR",method:e=>{var t,i=new h;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:s}=null!==(t=Vr(e))&&void 0!==t?t:{};Fe(e.headers,(function(e,t){i.setRequestHeader(t,e)})),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(s)}}),null!=c&&c.sendBeacon&&Gr.push({transport:"sendBeacon",method:e=>{var t=zr(e.url,{beacon:"1"});try{var i,{contentType:r,body:s}=null!==(i=Vr(e))&&void 0!==i?i:{},n="string"==typeof s?new Blob([s],{type:r}):s;c.sendBeacon(t,n)}catch(e){}}});var Yr=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function Jr(e,t,i){return Wr({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Kr={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>Yr(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Yr(t,e))))),icontains:(e,t)=>t.map(Xr).some((t=>e.map(Xr).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Xr).every((t=>e.map(Xr).every((e=>!t.includes(e)))))},Xr=e=>e.toLowerCase(),Qr=Pe("[Error tracking]");class Zr{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new _e([new he,new Se,new ge,new pe,new we,new be,new fe,new Ee],[ne,le]),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Ge))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,r,s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,this._instance.persistence&&this._instance.persistence.register({[Ge]:this._suppressionRules,[Ye]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Ye),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){if(this._matchesSuppressionRule(e))Qr.info("Skipping exception capture because a suppression rule matched");else{if(this._captureExtensionExceptions||!this._isExtensionException(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});Qr.info("Skipping exception capture because it was thrown by an extension")}}_matchesSuppressionRule(e){var t=e.$exception_list;if(!t||!P(t)||0===t.length)return!1;var i=t.reduce(((e,t)=>{var{type:i,value:r}=t;return T(i)&&i.length>0&&e.$exception_types.push(i),T(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var t=e.values.map((e=>{var t,r=Kr[e.operator],s=P(e.value)?e.value:[e.value],n=null!==(t=i[e.key])&&void 0!==t?t:[];return s.length>0&&r(s,n)}));return"OR"===e.type?t.some(Boolean):t.every(Boolean)}))}_isExtensionException(e){var t=e.$exception_list;return!(!t||!P(t))&&t.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}}var es="Mobile",ts="iOS",is="Android",rs="Tablet",ss=is+" "+rs,ns="iPad",as="Apple",os=as+" Watch",ls="Safari",cs="BlackBerry",us="Samsung",ds=us+"Browser",_s=us+" Internet",hs="Chrome",ps=hs+" OS",gs=hs+" "+ts,vs="Internet Explorer",fs=vs+" "+es,ms="Opera",ys=ms+" Mini",bs="Edge",ws="Microsoft "+bs,Es="Firefox",Ss=Es+" "+ts,xs="Nintendo",ks="PlayStation",Ps="Xbox",Is=is+" "+es,Cs=es+" "+ls,Fs="Windows",Rs=Fs+" Phone",Ts="Nokia",$s="Ouya",Os="Generic",Ls=Os+" "+es.toLowerCase(),As=Os+" "+rs.toLowerCase(),Ms="Konqueror",Ds="(\\d+(\\.\\d+)?)",Ns=new RegExp("Version/"+Ds),qs=new RegExp(Ps,"i"),js=new RegExp(ks+" \\w+","i"),Us=new RegExp(xs+" \\w+","i"),Hs=new RegExp(cs+"|PlayBook|BB10","i"),Bs={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var zs=(e,t)=>t&&y(t,as)||function(e){return y(e,ls)&&!y(e,hs)&&!y(e,is)}(e),Ws=function(e,t){return t=t||"",y(e," OPR/")&&y(e,"Mini")?ys:y(e," OPR/")?ms:Hs.test(e)?cs:y(e,"IE"+es)||y(e,"WPDesktop")?fs:y(e,ds)?_s:y(e,bs)||y(e,"Edg/")?ws:y(e,"FBIOS")?"Facebook "+es:y(e,"UCWEB")||y(e,"UCBrowser")?"UC Browser":y(e,"CriOS")?gs:y(e,"CrMo")||y(e,hs)?hs:y(e,is)&&y(e,ls)?Is:y(e,"FxiOS")?Ss:y(e.toLowerCase(),Ms.toLowerCase())?Ms:zs(e,t)?y(e,es)?Cs:ls:y(e,Es)?Es:y(e,"MSIE")||y(e,"Trident/")?vs:y(e,"Gecko")?Es:""},Vs={[fs]:[new RegExp("rv:"+Ds)],[ws]:[new RegExp(bs+"?\\/"+Ds)],[hs]:[new RegExp("("+hs+"|CrMo)\\/"+Ds)],[gs]:[new RegExp("CriOS\\/"+Ds)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ds)],[ls]:[Ns],[Cs]:[Ns],[ms]:[new RegExp("(Opera|OPR)\\/"+Ds)],[Es]:[new RegExp(Es+"\\/"+Ds)],[Ss]:[new RegExp("FxiOS\\/"+Ds)],[Ms]:[new RegExp("Konqueror[:/]?"+Ds,"i")],[cs]:[new RegExp(cs+" "+Ds),Ns],[Is]:[new RegExp("android\\s"+Ds,"i")],[_s]:[new RegExp(ds+"\\/"+Ds)],[vs]:[new RegExp("(rv:|MSIE )"+Ds)],Mozilla:[new RegExp("rv:"+Ds)]},Gs=function(e,t){var i=Ws(e,t),r=Vs[i];if(R(r))return null;for(var s=0;s<r.length;s++){var n=r[s],a=e.match(n);if(a)return parseFloat(a[a.length-2])}return null},Ys=[[new RegExp(Ps+"; "+Ps+" (.*?)[);]","i"),e=>[Ps,e&&e[1]||""]],[new RegExp(xs,"i"),[xs,""]],[new RegExp(ks,"i"),[ks,""]],[Hs,[cs,""]],[new RegExp(Fs,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Rs,""];if(new RegExp(es).test(t)&&!/IEMobile\b/.test(t))return[Fs+" "+es,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],s=Bs[r]||"";return/arm/i.test(t)&&(s="RT"),[Fs,s]}return[Fs,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[ts,t.join(".")]}return[ts,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=R(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+is+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+is+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[is,t.join(".")]}return[is,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ps,""]],[/Linux|debian/i,["Linux",""]]],Js=function(e){return Us.test(e)?xs:js.test(e)?ks:qs.test(e)?Ps:new RegExp($s,"i").test(e)?$s:new RegExp("("+Rs+"|WPDesktop)","i").test(e)?Rs:/iPad/.test(e)?ns:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?os:Hs.test(e)?cs:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Ts,"i").test(e)?Ts:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(es).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?is:ss:is:new RegExp("(pda|"+es+")","i").test(e)?Ls:new RegExp(rs,"i").test(e)&&!new RegExp(rs+" pc","i").test(e)?As:""},Ks="https?://(.*)",Xs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Qs=Te(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Xs),Zs="<masked>",en=["li_fat_id"];function tn(e,t,i){if(!u)return{};var r,s=t?Te([],Xs,i||[]):[],n=rn(si(u.URL,s,Zs),e),a=(r={},Fe(en,(function(e){var t=Si._get(e);r[e]=t||null})),r);return Re(a,n)}function rn(e,t){var i=Qs.concat(t||[]),r={};return Fe(i,(function(t){var i=ri(e,t);r[t]=i||null})),r}function sn(e){var t=function(e){return e?0===e.search(Ks+"google.([^/?]*)")?"google":0===e.search(Ks+"bing.com")?"bing":0===e.search(Ks+"yahoo.com")?"yahoo":0===e.search(Ks+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!L(t)){r.$search_engine=t;var s=u?ri(u.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function nn(){return navigator.language||navigator.userLanguage}function an(){return(null==u?void 0:u.referrer)||"$direct"}function on(e,t){var i=e?Te([],Xs,t||[]):[],r=null==d?void 0:d.href.substring(0,1e3);return{r:an().substring(0,1e3),u:r?si(r,i,Zs):void 0}}function ln(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=ti(i))?void 0:t.host};if(r){s.$current_url=r;var n=ti(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var a=rn(r);Re(s,a)}if(i){var o=sn(i);Re(s,o)}return s}function cn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function un(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function dn(e,t){if(!g)return{};var i,r,n,a=e?Te([],Xs,t||[]):[],[o,l]=function(e){for(var t=0;t<Ys.length;t++){var[i,r]=Ys[t],s=i.exec(e),n=s&&(I(r)?r(s,e):r);if(n)return n}return["",""]}(g);return Re(Ae({$os:o,$os_version:l,$browser:Ws(g,navigator.vendor),$device:Js(g),$device_type:(r=g,n=Js(r),n===ns||n===ss||"Kobo"===n||"Kindle Fire"===n||n===As?rs:n===xs||n===Ps||n===ks||n===$s?"Console":n===os?"Wearable":n?es:"Desktop"),$timezone:cn(),$timezone_offset:un()}),{$current_url:si(null==d?void 0:d.href,a,Zs),$host:null==d?void 0:d.host,$pathname:null==d?void 0:d.pathname,$raw_user_agent:g.length>1e3?g.substring(0,997)+"...":g,$browser_version:Gs(g,navigator.vendor),$browser_language:nn(),$browser_language_prefix:(i=nn(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==s?void 0:s.screen.height,$screen_width:null==s?void 0:s.screen.width,$viewport_height:null==s?void 0:s.innerHeight,$viewport_width:null==s?void 0:s.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var _n=Pe("[FeatureFlags]"),hn="$active_feature_flags",pn="$override_feature_flags",gn="$feature_flag_payloads",vn="$override_feature_flag_payloads",fn="$feature_flag_request_id",mn=e=>{var t={};for(var[i,r]of $e(e||{}))r&&(t[i]=r);return t},yn=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):_n.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},bn=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class wn{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this._instance=e,this.featureFlagEventHandlers=[]}_getValidEvaluationEnvironments(){var e=this._instance.config.evaluation_environments;return null!=e&&e.length?e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||_n.error("Invalid evaluation environment found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}flags(){if(this._instance.config.__preview_remote_config)this._flagsCalled=!0;else{var e=!this._reloadDebouncer&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this._callFlagsEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(rt),t=this._instance.get_property(pn),r=this._instance.get_property(vn);if(!r&&!t)return e||{};var s=Re({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var a of n){var o,l,c=s[a],u=null==t?void 0:t[a],d=R(u)?null!==(o=null==c?void 0:c.enabled)&&void 0!==o&&o:!!u,_=R(u)?c.variant:"string"==typeof u?u:void 0,h=null==r?void 0:r[a],p=i({},c,{enabled:d,variant:d?null!=_?_:null==c?void 0:c.variant:void 0});if(d!==(null==c?void 0:c.enabled)&&(p.original_enabled=null==c?void 0:c.enabled),_!==(null==c?void 0:c.variant)&&(p.original_variant=null==c?void 0:c.variant),h)p.metadata=i({},null==c?void 0:c.metadata,{payload:h,original_payload:null==c||null==(l=c.metadata)?void 0:l.payload});s[a]=p}return this._override_warning||(_n.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getFlagVariants(){var e=this._instance.get_property(tt),t=this._instance.get_property(pn);if(!t)return e||{};for(var i=Re({},e),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this._override_warning||(_n.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(gn),t=this._instance.get_property(vn);if(!t)return e||{};for(var i=Re({},e||{}),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this._override_warning||(_n.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(st)||{}),group_properties:this._instance.get_property(nt)};(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_environments=this._getValidEvaluationEnvironments());var s=this._instance.config.__preview_remote_config,n=s?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",o=this._instance.requestRouter.endpointFor("api",n+a);s&&(r.timezone=cn()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:o,data:r,compression:this._instance.config.disable_compression?void 0:Zt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,s=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,this._flagsCalled)||(this._flagsCalled=!0,this._instance._onRemoteConfig(null!==(i=e.json)&&void 0!==i?i:{}));if(!r.disable_flags||this._additionalReloadRequested)if(this._flagsLoadedFromRemote=!s,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(bn.FeatureFlags))_n.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{var n;if(!r.disable_flags)this.receivedFeatureFlags(null!==(n=e.json)&&void 0!==n?n:{},s);this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants()[e],r=""+i,s=this._instance.get_property(fn)||void 0,n=this._instance.get_property(lt)||{};if((t.send_event||!("send_event"in t))&&(!(e in n)||!n[e].includes(r))){var a,o,l,c,u,d,_,h,p;P(n[e])?n[e].push(r):n[e]=[r],null==(a=this._instance.persistence)||a.register({[lt]:n});var g=this.getFeatureFlagDetails(e),v={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:(null==(o=this._instance.config.bootstrap)||null==(o=o.featureFlags)?void 0:o[e])||null,$feature_flag_bootstrapped_payload:(null==(l=this._instance.config.bootstrap)||null==(l=l.featureFlagPayloads)?void 0:l[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};R(null==g||null==(c=g.metadata)?void 0:c.version)||(v.$feature_flag_version=g.metadata.version);var f,m=null!==(u=null==g||null==(d=g.reason)?void 0:d.description)&&void 0!==u?u:null==g||null==(_=g.reason)?void 0:_.code;if(m&&(v.$feature_flag_reason=m),null!=g&&null!=(h=g.metadata)&&h.id&&(v.$feature_flag_id=g.metadata.id),R(null==g?void 0:g.original_variant)&&R(null==g?void 0:g.original_enabled)||(v.$feature_flag_original_response=R(g.original_variant)?g.original_enabled:g.original_variant),null!=g&&null!=(p=g.metadata)&&p.original_payload)v.$feature_flag_original_payload=null==g||null==(f=g.metadata)?void 0:f.original_payload;this._instance.capture("$feature_flag_called",v)}return i}_n.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var i=this._instance.config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_environments=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:r,compression:this._instance.config.disable_compression?void 0:Zt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return R(i)?void 0:!!i}_n.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this._hasLoadedFlags=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,r,s,n){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var a=yn(e),o=a.flags,l=a.featureFlags,c=a.featureFlagPayloads;if(l){var u=e.requestId;if(P(l)){_n.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var d={};if(l)for(var _=0;_<l.length;_++)d[l[_]]=!0;t&&t.register({[hn]:l,[tt]:d})}else{var h=l,p=c,g=o;e.errorsWhileComputingFlags&&(h=i({},r,h),p=i({},s,p),g=i({},n,g)),t&&t.register(i({[hn]:Object.keys(mn(h)),[tt]:h||{},[gn]:p||{},[rt]:g||{}},u?{[fn]:u}:{}))}}}(e,this._instance.persistence,r,s,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),_n.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return _n.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(pn),this._instance.persistence.unregister(vn),void this._fireFeatureFlagsCallbacks();if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(pn);else if(i.flags)if(P(i.flags)){for(var r={},s=0;s<i.flags.length;s++)r[i.flags[s]]=!0;this._instance.persistence.register({[pn]:r})}else this._instance.persistence.register({[pn]:i.flags});return"payloads"in i&&(!1===i.payloads?this._instance.persistence.unregister(vn):i.payloads&&this._instance.persistence.register({[vn]:i.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._instance.get_property(it)||[]).find((t=>t.flagKey===e)),a={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$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(),{[e]:t});null==(s=this._instance.persistence)||s.register({[hn]:Object.keys(mn(l)),[tt]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._instance.get_property(it),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(it),null==(r=this._instance.persistence)||r.register({[it]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>r(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._instance.get_property(st)||{};this._instance.register({[st]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(st)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._instance.get_property(nt)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[nt]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(nt)||{};this._instance.register({[nt]:i({},t,{[e]:{}})})}else this._instance.unregister(nt)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}var En=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Sn{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&ke.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===En.indexOf(e.persistence.toLowerCase())&&(ke.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&ki._is_supported()?ki:"localstorage+cookie"===t&&Ii._is_supported()?Ii:"sessionstorage"===t&&Ti._is_supported()?Ti:"memory"===t?Fi:"cookie"===t?Si:Ii._is_supported()?Ii:Si}properties(){var e={};return Fe(this.props,(function(t,i){if(i===tt&&C(t))for(var r=Object.keys(t),s=0;s<r.length;s++)e["$feature/"+r[s]]=t[r[s]];else a=i,o=!1,(L(n=mt)?o:l&&n.indexOf===l?-1!=n.indexOf(a):(Fe(n,(function(e){if(o||(o=e===a))return Ie})),o))||(e[i]=t);var n,a,o})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Re({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(C(e)){R(t)&&(t="None"),this._expire_days=R(i)?this._default_expiry:i;var r=!1;if(Fe(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(C(e)){this._expire_days=R(t)?this._default_expiry:t;var i=!1;if(Fe(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=tn(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);F(Ae(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==u?void 0:u.referrer)?sn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:an(),$referring_domain:null!=u&&u.referrer&&(null==(e=ti(u.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[_t]||this.props[ht]||this.register_once({[pt]:on(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Fe([ht,_t],(t=>{var i=this.props[t];i&&Fe(i,(function(t,i){e["$initial_"+w(i)]=t}))}));var t,i,r=this.props[pt];if(r){var s=(t=ln(r),i={},Fe(t,(function(e,t){i["$initial_"+w(t)]=e})),i);Re(e,s)}return e}safe_merge(e){return Fe(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var r=this._buildStorage(e),s=this.props;this.clear(),this._storage=r,this.props=s,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[Be]||{};i[e]=t,this.props[Be]=i,this.save()}remove_event_timer(e){var t=(this.props[Be]||{})[e];return R(t)||(delete this.props[Be][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var xn=function(e){return e.Button="button",e.Tab="tab",e.Selector="selector",e}({}),kn=function(e){return e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger",e}({}),Pn=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),In=function(e){return e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link",e}({}),Cn=function(e){return e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question",e}({}),Fn=function(e){return e.Once="once",e.Recurring="recurring",e.Always="always",e}({}),Rn=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e}({}),Tn=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e}({}),$n=function(e){return e.Popover="popover",e.Inline="inline",e}({});class On{constructor(){this._events={},this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var r of this._events["*"]||[])r(e,t)}}class Ln{constructor(e){this._debugEventEmitter=new On,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e;if(!R(null==(e=this._instance)?void 0:e._addCaptureHook)){var t;null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!R(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ln._matchString(r,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static _matchString(e,t,i){switch(i){case"regex":return!!s&&Yr(e,t);case"exact":return t===e;case"contains":var r=Ln._escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return Yr(e,r);default:return!1}}static _escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}_checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this._getElementsList(e).some((e=>!(null!=t&&t.href&&!Ln._matchString(e.href||"",null==t?void 0:t.href,(null==t?void 0:t.href_matching)||"exact"))&&((null==t||!t.tag_name||e.tag_name===(null==t?void 0:t.tag_name))&&!(null!=t&&t.text&&!Ln._matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Ln._matchString(e.$el_text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact"))))))return!1;if(null!=t&&t.selector){var i,r=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(!r)return!1;if(!r.includes(null==t?void 0:t.selector))return!1}return!0}_getElementsList(e){return null==(null==e?void 0:e.properties.$elements)?[]:null==e?void 0:e.properties.$elements}}var An=Pe("[Surveys]");var Mn="seenSurvey_",Dn=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},Nn=e=>{var t=""+Mn+e.id;return e.current_iteration&&e.current_iteration>0&&(t=""+Mn+e.id+"_"+e.current_iteration),t},qn=[Pn.Popover,Pn.Widget,Pn.API],jn={ignoreConditions:!1,ignoreDelay:!1,displayType:$n.Popover};class Un{constructor(e){this._instance=e,this._eventToSurveys=new Map,this._actionToSurveys=new Map}register(e){var t;R(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedSurveys(e),this._setupActionBasedSurveys(e))}_setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));if(0!==t.length){if(null==this._actionMatcher){this._actionMatcher=new Ln(this._instance),this._actionMatcher.init();this._actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToSurveys.get(t.name);i&&i.push(e.id),this._actionToSurveys.set(t.name,i||[e.id])}})))}))}}_setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})).length){null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t;null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||t.forEach((t=>{if(t&&t.name){var i=this._eventToSurveys.get(t.name);i&&i.push(e.id),this._eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,r,s=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[ot])||[];if(Rn.SHOWN===e&&t&&s.length>0){var n;An.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:t,existingActivatedSurveys:s});var a=null==t||null==(n=t.properties)?void 0:n.$survey_id;if(a){var o=s.indexOf(a);o>=0&&(s.splice(o,1),this._updateActivatedSurveys(s))}}else if(this._eventToSurveys.has(e)){An.info("survey event name matched",{event:e,eventPayload:t,surveys:this._eventToSurveys.get(e)});var l=[];null==(r=this._instance)||r.getSurveys((t=>{l=t.filter((t=>{var i;return null==(i=this._eventToSurveys.get(e))?void 0:i.includes(t.id)}))}));var c=l.filter((i=>{var r,s=null==(r=i.conditions)||null==(r=r.events)||null==(r=r.values)?void 0:r.find((t=>t.name===e));return!!s&&(!s.propertyFilters||Object.entries(s.propertyFilters).every((e=>{var i,[r,s]=e,n=null==t||null==(i=t.properties)?void 0:i[r];if(R(n)||L(n))return!1;var a=[String(n)],o=Kr[s.operator];return o?o(s.values,a):(An.warn("Unknown property comparison operator: "+s.operator),!1)})))}));this._updateActivatedSurveys(s.concat(c.map((e=>e.id))||[]))}}onAction(e){var t,i=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[ot])||[];this._actionToSurveys.has(e)&&this._updateActivatedSurveys(i.concat(this._actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t;An.info("updating activated surveys",{activatedSurveys:e}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[ot]:[...new Set(e)]})}getSurveys(){var e,t=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[ot];return t||[]}getEventToSurveys(){return this._eventToSurveys}_getActionMatcher(){return this._actionMatcher}}class Hn{constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isFetchingSurveys=!1,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(A(t))return An.warn("Flags not loaded yet. Not loading surveys.");var i=P(t);this._isSurveysEnabled=i?t.length>0:t,An.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith(Mn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)An.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)An.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())An.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!R(this._isSurveysEnabled)||this._instance.config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._instance.config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError("PostHog loadExternalDependency extension not found.");r(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else An.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Un(this._instance),An.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){An.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return An.info("Disabled. Not loading surveys."),e([]);var i=this._instance.get_property(at);if(i&&!t)return e(i,{isLoaded:!0});if(this._isFetchingSurveys)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:t=>{var i;this._isFetchingSurveys=!1;var r=t.statusCode;if(200!==r||!t.json){var s="Surveys API could not be loaded, status: "+r;return An.error(s),e([],{isLoaded:!1,error:s})}var n,a=t.json.surveys||[],o=a.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));o.length>0&&(null==(n=this._surveyEventReceiver)||n.register(o));return null==(i=this._instance.persistence)||i.register({[at]:a}),e(a,{isLoaded:!0})}})}catch(e){throw this._isFetchingSurveys=!1,e}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){An.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!A(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);An.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(A(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(A(this._surveyManager))return An.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return A(this._surveyManager)?(An.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t){var i;if(A(this._surveyManager))An.warn("init was not called");else{var r="string"==typeof e?this._getSurveyById(e):e;if(null!=r&&r.id)if(qn.includes(r.type)){var s=null==u?void 0:u.querySelector(t);if(s)return null!=(i=r.appearance)&&i.surveyPopupDelaySeconds?(An.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;An.info("Rendering survey "+r.id+" with delay of "+(null==(e=r.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(r,s),An.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,s);An.warn("Survey element not found")}else An.warn("Surveys of type "+r.type+" cannot be rendered in the app");else An.warn("Survey not found")}}displaySurvey(e,t){var r;if(A(this._surveyManager))An.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),!1===t.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void An.warn("Survey is not eligible to be displayed: ",a.disabledReason)}t.displayType!==$n.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else An.warn("Survey not found")}}}var Bn=Pe("[RateLimiter]");class zn{constructor(e){var t,i;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Bn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Bn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.captureEventsPerSecond=(null==(t=e.config.rate_limiting)?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null==(i=e.config.rate_limiting)?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var s=(new Date).getTime(),n=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(dt))&&void 0!==t?t:{tokens:this.captureEventsBurstLimit,last:s};n.tokens+=(s-n.last)/1e3*this.captureEventsPerSecond,n.last=s,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var a=n.tokens<1;return a||e||(n.tokens=Math.max(0,n.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,null==(r=this.instance.persistence)||r.set_property(dt,n),{isRateLimited:a,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Wn=Pe("[RemoteConfig]");class Vn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Wn.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Wn.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Wn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Wn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e)}));this._onRemoteConfig(e)}))}catch(e){Wn.error("Error loading remote config",e)}}_onRemoteConfig(e){e?this._instance.config.__preview_remote_config?(this._instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):Wn.info("__preview_remote_config is disabled. Logging config instead",e):Wn.error("Failed to fetch remote config from PostHog.")}}var Gn=3e3;class Yn{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=V((null==t?void 0:t.flush_interval_ms)||Gn,250,5e3,ke.createLogger("flush interval"),Gn),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[r],s=(new Date).getTime();i.data&&P(i.data)&&Fe(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequest(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Fe(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;R(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Jn=["retriesPerformedSoFar"];class Kn{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!R(s)&&"onLine"in s.navigator&&(this._areWeOnline=s.navigator.onLine,je(s,"online",(()=>{this._areWeOnline=!0,this._flush()})),je(s,"offline",(()=>{this._areWeOnline=!1})))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,Jn);M(t)&&t>0&&(s.url=zr(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this._enqueue(i({retriesPerformedSoFar:t},s)):null==s.callback||s.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),s=(Math.random()-.5)*(r-i);return Math.ceil(r+s)}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),ke.warn(s),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){ke.error(e)}this._queue=[]}}class Xn{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),a=s?Math.max(0,s.scrollHeight-s.clientHeight):0,o=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(a,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=o,this._context.maxContentY=Math.max(o,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(r=this._context.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){je(s,"scroll",this._updateScrollData,{capture:!0}),je(s,"scrollend",this._updateScrollData,{capture:!0}),je(s,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==s?void 0:s.document.documentElement;var e=P(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var i=null==s?void 0:s.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return s&&(s.scrollY||s.pageYOffset||s.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return s&&(s.scrollX||s.pageXOffset||s.document.documentElement.scrollLeft)||0}}var Qn=e=>on(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Zn{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[ut]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||Qn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[ut]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?ln(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Fe(Ae(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+w(i)]=t})),e}}var ea=Pe("[SessionId]");class ta{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._sessionIdChangedHandlers=[],this._eventEmitter=new On,this._sessionHasBeenIdleTooLong=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||mi,this._windowIdGenerator=i||mi;var s=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*V(n,60,36e3,ea.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var a=Ti._parse(this._window_id_storage_key),o=Ti._parse(this._primary_window_exists_storage_key);a&&!o?this._windowId=a:Ti._remove(this._window_id_storage_key),Ti._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this._config.bootstrap.sessionID);this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){ea.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return R(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Ti._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Ti._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Ti._parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this._persistence.register({[Ze]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[Ze];return P(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){je(s,"beforeunload",(()=>{this._canUseSessionStorage()&&Ti._remove(this._primary_window_exists_storage_key)}),{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,s,n]=this._getSessionId(),a=this._getWindowId(),o=M(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!s,u=!e&&this._sessionHasBeenIdleTooLong(i,r);c||u||o?(s=this._sessionIdGenerator(),a=this._windowIdGenerator(),ea.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:o}}),n=i,l=!0):a||(a=this._windowIdGenerator(),l=!0);var d=0===r||!e||o?i:r,_=0===n?(new Date).getTime():n;return this._setWindowId(a),this._setSessionId(s,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(s,a,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:o}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:_,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:o}:void 0,lastActivityTimestamp:r}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{var[e]=this._getSessionId();if(this._sessionHasBeenIdleTooLong((new Date).getTime(),e)){var t=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var ia=["$set_once","$set"],ra=Pe("[SiteApps]");class sa{constructor(e){this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,s,n,a,o,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))u[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,ia),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(o=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(ra.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null==(i=this._stopBuffering)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,ra.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{s(e)}});n&&(t.processEvent=n),r=!0}catch(t){ra.error("Error while initializing PostHog app with config id "+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){ra.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(t){ra.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void ra.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;v["__$$ph_site_app_"+e]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,o,(t=>{if(t)return ra.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:a,url:o}of e.siteApps)n(a)}else ra.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var na=["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"],aa=function(e,t){if(!e)return!1;var i=e.toLowerCase();return na.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},oa=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&aa(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>aa(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},la=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ca="i.posthog.com";class ua{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ca,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=la.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=la.EU:this._regionCache[this.apiHost]=la.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if(this.region===la.CUSTOM)return this.apiHost+t;var i=ca+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var da={icontains:(e,t)=>!!s&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!s&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!s&&Yr(t.href,e),not_regex:(e,t)=>!!s&&!Yr(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class _a{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{_a._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)_a._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e);var r=t._instance.getFeatureFlag(e.feature_flag_key);T(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];_a._matchesTestVariant(n)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())_a._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(A(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();_a._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=_a.getWindowLocation();if(null!=e&&e.search){var t=ri(null==e?void 0:e.search,"__experiment_id"),i=ri(null==e?void 0:e.search,"__experiment_variant");t&&i&&(_a._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(_a._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e){return!A(e.conditions)&&(_a._matchUrlConditions(e)&&_a._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(A(e.conditions)||A(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=_a.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||da[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==s?void 0:s.location}static _matchUTMConditions(e){var t;if(A(e.conditions)||A(null==(t=e.conditions)?void 0:t.utm))return!0;var i=tn();if(i.utm_source){var r,s,n,a,o,l,c,u,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=e.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,h=null==(o=e.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];ke.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?_a._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var r;_a._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):_a._logInfo("Control variants leave the page unmodified.")}_is_bot(){return c&&this._instance?oa(c,this._instance.config.custom_blocked_useragents):void 0}}var ha=Pe("[PostHog ExternalIntegrations]"),pa={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class ga{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return ha.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;(!r||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(pa[t],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=v.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t])&&(null==(n=v.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var va="[SessionRecording]",fa=Pe(va);class ma{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){return this._lazyLoadedSessionRecording?this._lazyLoadedSessionRecording.status:this._receivedFlags&&!this._isRecordingEnabled?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw fa.error("started without valid sessionManager"),new Error(va+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(va+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(Qe))||!e.enabled),i=!this._instance.config.disable_session_recording,r=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return s&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!R(Object.assign)&&!R(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),fa.info("starting")):this.stopRecording()}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(null!=v&&null!=(t=v.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return fa.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e;null==(e=this._lazyLoadedSessionRecording)||e.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(et)}_persistRemoteConfig(e){if(this._instance.persistence){var t,r,s=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=null==t?void 0:t.sampleRate,n=A(r)?null:parseFloat(r);A(n)&&this._resetSampling();var a=null==t?void 0:t.minimumDurationMilliseconds;s.register({[Qe]:i({enabled:!!t},t,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:R(a)?null:a,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this._persistRemoteConfig(e),this._receivedFlags=!0,this.startIfEnabledOrStop()):this._receivedFlags=!0:fa.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):fa.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(Qe);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_onScriptLoaded(e){var t,i;if(null==(t=v.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture);this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t;null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}var ya={},ba=()=>{},wa="posthog",Ea=!Hr&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),Sa=e=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Ne(null==u?void 0:u.location),persistence:"localStorage+cookie",persistence_name:"",loaded:ba,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:"2025-05-24"!==e||"history_change",capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",debug:d&&T(null==d?void 0:d.search)&&-1!==d.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==s||null==(t=s.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;ke.error(t)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Gn},error_tracking:{},_onCapture:ba,__preview_eager_load_replay:!1}},xa=e=>{var t={};R(e.process_person)||(t.person_profiles=e.process_person),R(e.xhr_headers)||(t.request_headers=e.xhr_headers),R(e.cookie_name)||(t.persistence_name=e.cookie_name),R(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),R(e.store_google)||(t.save_campaign_params=e.store_google),R(e.verbose)||(t.debug=e.verbose);var i=Re({},t,e);return P(e.property_blacklist)&&(R(e.property_denylist)?i.property_denylist=e.property_blacklist:P(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:ke.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class ka{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){ke.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Pa{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new ka,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new On,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Sa(),this.SentryIntegration=Vi,this.sentryIntegration=e=>function(e,t){var i=Wi(e,t);return{name:zi,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new wn(this),this.toolbar=new Xi(this),this.scrollManager=new Xn(this),this.pageViewManager=new ar(this),this.surveys=new Hn(this),this.experiments=new _a(this),this.exceptions=new Zr(this),this.rateLimiter=new zn(this),this.requestRouter=new ua(this),this.consent=new Oi(this),this.externalIntegrations=new ga(this),this.people={set:(e,t,i)=>{var r=T(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=T(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>ke.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==wa){var r,s=null!==(r=ya[i])&&void 0!==r?r:new Pa;return s._init(e,t,i),ya[i]=s,ya[wa][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var n,a;if(void 0===t&&(t={}),R(e)||O(e))return ke.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return ke.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config(Re({},Sa(t.defaults),xa(t),{name:r,token:e})),this.config.on_xhr_error&&ke.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Zt.GZipJS;var o=this._is_persistence_disabled();this.persistence=new Sn(this.config,o),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sn(i({},this.config,{persistence:"sessionStorage"}),o);var l=i({},this.persistence.props),c=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Yn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Kn(this),this.__request_queue=[];var u="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(u||(this.sessionManager=new ta(this),this.sessionPropsManager=new Zn(this,this.sessionManager,this.persistence)),new Zi(this).startIfEnabledOrStop(),this.siteApps=new sa(this),null==(n=this.siteApps)||n.init(),u||(this.sessionRecording=new ma(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new di(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new nr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new ir(this),this.exceptionObserver=new qi(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Di(this,Mi),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Ui(this),this.historyAutocapture.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&ke.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:c}),void 0!==(null==(a=t.bootstrap)?void 0:a.distinctID)){var d,_,h=this.config.get_device_id(mi()),p=null!=(d=t.bootstrap)&&d.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(ct,null!=(_=t.bootstrap)&&_.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:p})}if(this._hasBootstrappedFeatureFlags()){var g,v,m=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlags)||{}).filter((e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])})).reduce(((e,i)=>{var r;return e[i]=(null==(r=t.bootstrap)||null==(r=r.featureFlags)?void 0:r[i])||!1,e}),{}),y=Object.keys((null==(v=t.bootstrap)?void 0:v.featureFlagPayloads)||{}).filter((e=>m[e])).reduce(((e,i)=>{var r,s;null!=(r=t.bootstrap)&&null!=(r=r.featureFlagPayloads)&&r[i]&&(e[i]=null==(s=t.bootstrap)||null==(s=s.featureFlagPayloads)?void 0:s[i]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:m,featureFlagPayloads:y})}if(u)this.register_once({distinct_id:ft,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(mi());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(ct,"anonymous")}return je(s,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Bi(this,(()=>this._loaded())):this._loaded(),I(this.config._onCapture)&&this.config._onCapture!==ba&&(ke.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&ke.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}_onRemoteConfig(e){var t,i,r,s,n,a,o,l;if(!u||!u.body)return ke.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=y(e.supportedCompression,Zt.GZipJS)?Zt.GZipJS:y(e.supportedCompression,Zt.Base64)?Zt.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(r=this.sessionRecording)||r.onRemoteConfig(e),null==(s=this.autocapture)||s.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(o=this.exceptionObserver)||o.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(l=this.deadClicksAutocapture)||l.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){ke.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this._captureInitialPageview()}),1),new Vn(this).load(),this.featureFlags.flags()}_start_queue_if_opted_in(){var e;this.is_capturing()&&(this.config.request_batching&&(null==(e=this._requestQueue)||e.enable()))}_dom_loaded(){this.is_capturing()&&Ce(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null==(e=this._requestQueue)||e.unload(),null==(t=this._retryQueue)||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Ea?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=zr(e.url,{ip:this.config.ip?1:0}),e.headers=i({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,r,s,n=i({},e);n.timeout=n.timeout||6e4,n.url=zr(n.url,{_:(new Date).getTime().toString(),ver:f.LIB_VERSION,compression:n.compression});var a=null!==(t=n.transport)&&void 0!==t?t:"fetch",o=Gr.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=qe(o,(e=>e.transport===a)))?void 0:s.method)&&void 0!==r?r:o[0].method;if(!l)throw new Error("No available transport method");l(n)})(i({},e,{callback:t=>{var i,r;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null==(i=(r=this.config).on_request_error)||i.call(r,t));null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],r=[],s=[];Ce(e,(e=>{e&&(t=e[0],P(t)?s.push(e):I(e)?e.call(this):P(e)&&"alias"===t?i.push(e):P(e)&&-1!==t.indexOf("capture")&&I(this[t])?s.push(e):r.push(e))}));var n=function(e,t){Ce(e,(function(e){if(P(e[0])){var i=t;Fe(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(r,this),n(s,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!R(e)&&T(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var n=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){null!=t&&t.$current_url&&!T(null==t?void 0:t.$current_url)&&(ke.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,o=(null==r?void 0:r.timestamp)||a,l=mi(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},o,l)};n&&(c.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==r?void 0:r.$set)&&(c.$set=null==r?void 0:r.$set);var u,d=this._calculate_set_once_properties(null==r?void 0:r.$set_once);if(d&&(c.$set_once=d),(c=Me(c,null!=r&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=o,R(null==r?void 0:r.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=a),e===Rn.DISMISSED||e===Rn.SENT){var _=null==t?void 0:t[Tn.SURVEY_ID],h=null==t?void 0:t[Tn.SURVEY_ITERATION];u={id:_,current_iteration:h},localStorage.getItem(Nn(u))||localStorage.setItem(Nn(u),"true"),c.$set=i({},c.$set,{[Dn({id:_,current_iteration:h},e===Rn.SENT?"responded":"dismissed")]:!0})}var p=i({},c.properties.$set,c.$set);if(F(p)||this.setPersonPropertiesForFlags(p),!A(this.config.before_send)){var g=this._runBeforeSend(c);if(!g)return;c=g}this._internalEventEmitter.emit("eventCaptured",c);var v={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==r?void 0:r._batchKey};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(v):this._requestQueue.enqueue(v),c}ke.critical("This capture call is ignored due to client rate limiting.")}}else ke.error("No event name provided to posthog.capture")}else ke.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,n){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var a=n?void 0:this.persistence.remove_event_timer(e),o=i({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(o.$cookieless_mode=!0),"$snapshot"===e){var l=i({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=l.distinct_id,(!T(o.distinct_id)&&!M(o.distinct_id)||O(o.distinct_id))&&ke.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var c,d=dn(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(n,r.getTime());o.$session_id=_,o.$window_id=h}this.sessionPropsManager&&Re(o,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Re(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===la.CUSTOM&&(o.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),o=Re(o,c),"$pageview"===e&&u&&(o.title=u.title),!R(a)){var v=r.getTime()-a;o.$duration=parseFloat((v/1e3).toFixed(3))}g&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser"),(o=Re({},d,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),P(this.config.property_denylist)?Fe(this.config.property_denylist,(function(e){delete o[e]})):ke.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(ke.error("sanitize_properties is deprecated. Use before_send instead"),o=f(o,e));var m=this._hasPersonProcessing();return o.$process_person_profile=m,m&&!n&&this._requirePersonProcessing("_calculate_event_properties"),o}_calculate_set_once_properties(e){var t;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var i=this.persistence.get_initial_props(),r=null==(t=this.sessionPropsManager)?void 0:t.getSetOnceProps(),s=Re({},i,r||{},e||{}),n=this.config.sanitize_properties;return n&&(ke.error("sanitize_properties is deprecated. Use before_send instead"),s=n(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,F(s)?void 0:s}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=jn),this.surveys.displaySurvey(e,t)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return ke.uninitializedWarning("posthog.identify");if(M(e)&&(e=e.toString(),ke.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))ke.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==ft){if(this._requirePersonProcessing("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==s&&e!==this.get_property(He)&&(this.unregister(He),this.register({distinct_id:e}));var a="anonymous"===(this.persistence.get_property(ct)||"anonymous");e!==s&&a?(this.persistence.set_property(ct,"identified"),this.setPersonPropertiesForFlags(i({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:r||{}}),this._cachedPersonProperties=Jr(e,t,r),this.featureFlags.setAnonymousDistinctId(s)):(t||r)&&this.setPersonProperties(t,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(lt))}}else ke.critical('The string "'+ft+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else ke.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var r=Jr(this.get_distinct_id(),e,t);this._cachedPersonProperties!==r?(this.setPersonPropertiesForFlags(i({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=r):ke.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){if(this._requirePersonProcessing("posthog.group")){var s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),s[e]===t||r||this.reloadFeatureFlags()}}else ke.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,s;if(ke.info("reset"),!this.__loaded)return ke.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(r=this.persistence)||r.set_property(ct,"anonymous"),null==(s=this.sessionManager)||s.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:ft,$device_id:null},"");else{var a=this.config.get_device_id(mi());this.register_once({distinct_id:a,$device_id:e?a:n},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(Ue)?(ke.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(R(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(He,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(ke.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(C(e)){var r,s,n,a,o;Re(this.config,xa(e));var l=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,l),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sn(i({},this.config,{persistence:"sessionStorage"}),l),ki._is_supported()&&"true"===ki._get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(f.DEBUG=!0,ke.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})),null==(s=this.sessionRecording)||s.startIfEnabledOrStop(),null==(n=this.autocapture)||n.startIfEnabled(),null==(a=this.heatmaps)||a.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(o=this.externalIntegrations)||o.startIfEnabledOrStop()}}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var r,s,n,a,o;if(null==(r=this.sessionManager)||r.checkAndGetSessionAndWindowId(),i.sampling)null==(s=this.sessionRecording)||s.overrideSampling();if(i.linked_flag)null==(n=this.sessionRecording)||n.overrideLinkedFlag();if(i.url_trigger)null==(a=this.sessionRecording)||a.overrideTrigger("url");if(i.event_trigger)null==(o=this.sessionRecording)||o.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,t))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:wa;return t!==wa&&(t=wa+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ct))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ct))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&F(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[He])&&(null==(t=this.persistence)||null==(t=t.props)||!t[gt]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(ke.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(gt,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s));(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s));return s}opt_in_capturing(e){if("always"!==this.config.cookieless_mode){var t;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new ta(this),this.persistence&&(this.sessionPropsManager=new Zn(this,this.sessionManager,this.persistence)),this.sessionRecording=new ma(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),R(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(t=null==e?void 0:e.captureEventName)&&void 0!==t?t:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else ke.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:ft,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):ke.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===$i.GRANTED?"granted":e===$i.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return c?oa(c,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){u&&("visible"===u.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:u.title},{send_instantly:!0}),this._visibilityStateListener&&(u.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),je(u,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==s||s.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==s||s.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_shouldDisableFlags(){var e,t,i,r,s,n,a,o=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(ke.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",r=!1,s=ke,n=(t="advanced_disable_flags")in(e=o)&&!R(e[t]),a=i in e&&!R(e[i]),n?e[t]:a?(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):r)}_runBeforeSend(e){if(A(this.config.before_send))return e;var t=P(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),A(i)){var s="Event '"+e.event+"' was rejected in beforeSend function";return q(e.event)?ke.warn(s+". This can cause unexpected behavior."):ke.info(s),null}i.properties&&!F(i.properties)||ke.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Le(e.prototype[t[i]])}(Pa,["identify"]);var Ia,Ca=(Ia=ya[wa]=new Pa,function(){function e(){e.done||(e.done=!0,Ea=!1,Fe(ya,(function(e){e._dom_loaded()})))}null!=u&&u.addEventListener?"complete"===u.readyState?e():je(u,"DOMContentLoaded",e,{capture:!1}):s&&ke.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Ia);export{Qt as COPY_AUTOCAPTURE_EVENT,Zt as Compression,$n as DisplaySurveyType,Pa as PostHog,Rn as SurveyEventName,Tn as SurveyEventProperties,kn as SurveyPosition,Cn as SurveyQuestionBranchingType,In as SurveyQuestionType,Fn as SurveySchedule,Pn as SurveyType,xn as SurveyWidgetType,Ca as default,Ca as posthog,ei as severityLevels};
|
|
1
|
+
function e(e,t,i,r,s,n,a){try{var o=e[n](a),l=o.value}catch(e){return void i(e)}o.done?t(l):Promise.resolve(l).then(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=t.apply(i,r);function o(t){e(a,s,n,o,l,"next",t)}function l(t){e(a,s,n,o,l,"throw",t)}o(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:s,a=Array.prototype,o=a.forEach,l=a.indexOf,c=null==n?void 0:n.navigator,u=null==n?void 0:n.document,d=null==n?void 0:n.location,_=null==n?void 0:n.fetch,h=null!=n&&n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest?n.XMLHttpRequest:void 0,p=null==n?void 0:n.AbortController,g=null==c?void 0:c.userAgent,v=null!=s?s:{},f={DEBUG:!1,LIB_VERSION:"1.274.3"},m=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function y(e,t){return-1!==e.indexOf(t)}var b=function(e){return e.trim()},w=function(e){return e.replace(/^\$/,"")};var E=Array.isArray,S=Object.prototype,x=S.hasOwnProperty,k=S.toString,P=E||function(e){return"[object Array]"===k.call(e)},I=e=>"function"==typeof e,C=e=>e===Object(e)&&!P(e),F=e=>{if(C(e)){for(var t in e)if(x.call(e,t))return!1;return!0}return!1},R=e=>void 0===e,T=e=>"[object String]"==k.call(e),O=e=>T(e)&&0===e.trim().length,L=e=>null===e,A=e=>R(e)||L(e),M=e=>"[object Number]"==k.call(e),D=e=>"[object Boolean]"===k.call(e),N=e=>e instanceof FormData,q=e=>y(m,e);function j(e){return null===e||"object"!=typeof e}function U(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function H(e){return!R(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var B=[!0,"true",1,"1","yes"],z=e=>y(B,e),W=[!1,"false",0,"0","no"];function V(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),M(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),V(s||i,t,i,r))}class G{constructor(e){this._options=e,this._buckets={},this._refillBuckets=()=>{Object.keys(this._buckets).forEach((e=>{var t=this._getBucket(e)+this._refillRate;t>=this._bucketSize?delete this._buckets[e]:this._setBucket(e,t)}))},this._getBucket=e=>this._buckets[String(e)],this._setBucket=(e,t)=>{this._buckets[String(e)]=t},this.consumeRateLimit=e=>{var t,i,r=null!==(t=this._getBucket(e))&&void 0!==t?t:this._bucketSize;if(0===(r=Math.max(r-1,0)))return!0;this._setBucket(e,r);var s=0===r;return s&&(null==(i=this._onBucketRateLimited)||i.call(this,e)),s},this._onBucketRateLimited=this._options._onBucketRateLimited,this._bucketSize=V(this._options.bucketSize,0,100,this._options._logger),this._refillRate=V(this._options.refillRate,0,this._bucketSize,this._options._logger),this._refillInterval=V(this._options.refillInterval,0,864e5,this._options._logger),this._removeInterval=setInterval((()=>{this._refillBuckets()}),this._refillInterval)}stop(){this._removeInterval&&(clearInterval(this._removeInterval),this._removeInterval=void 0)}}var Y,J,K,X=e=>e instanceof Error;function Q(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return K&&i.length===J||(J=i.length,K=i.reduce(((i,r)=>{Y||(Y={});var s=Y[r];if(s)i[s[0]]=s[1];else for(var n=e(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,c=t[r];if(l&&c){i[l]=c,Y[r]=[l,c];break}}return i}),{})),K}}var Z="?";function ee(e,t,i,r){var s={platform:"web:javascript",filename:e,function:"<anonymous>"===t?Z:t,in_app:!0};return R(i)||(s.lineno=i),R(r)||(s.colno=r),s}var te=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:Z,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},ie=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,re=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,se=/\((\S*)(?::(\d+))(?::(\d+))\)/,ne=e=>{var t=ie.exec(e);if(t){var[,i,r,s]=t;return ee(i,Z,+r,+s)}var n=re.exec(e);if(n){if(n[2]&&0===n[2].indexOf("eval")){var a=se.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}var[o,l]=te(n[1]||Z,n[2]);return ee(l,o,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},ae=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,oe=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,le=e=>{var t=ae.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=oe.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],s=t[1]||Z;return[s,r]=te(s,r),ee(r,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},ce=/\(error: (.*)\)/,ue=50;function de(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r){void 0===r&&(r=0);for(var s=[],n=e.split("\n"),a=r;a<n.length;a++){var o=n[a];if(!(o.length>1024)){var l=ce.test(o)?o.replace(ce,"$1"):o;if(!l.match(/\S*Error: /)){for(var c of t){var u=c(l);if(u){s.push(u);break}}if(s.length>=ue)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,ue).map((e=>{return i({},e,{filename:e.filename||(r=t,r[r.length-1]||{}).filename,function:e.function||Z});var r}))}(s)}}class _e{constructor(e,t,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=[]),this.coercers=e,this.modifiers=i,this.stackParser=de(...t)}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&P(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var i=this;return t((function*(){var t=e;for(var r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,a={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var o=[a];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),o}buildParsingContext(){return{chunkIdMap:Q(this.stackParser)}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(r<=4){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}class he{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=T(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return U(e,"DOMException")}isDOMError(e){return U(e,"DOMError")}}class pe{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return i.error&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class ge{constructor(){}match(e){return U(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i,r=t.apply(e.error);return r||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var ve=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class fe{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(ve);return r&&(t=r[1],i=r[2]),[t,i]}}var me=["fatal","error","warning","log","info","debug"];function ye(e,t){void 0===t&&(t=40);var i=Object.keys(e);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(!(s.length>t))return r===i.length||s.length<=t?s:s.slice(0,t)+"..."}return""}class be{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return H(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ye(e)}isSeverityLevel(e){return T(e)&&!O(e)&&me.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(X(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class we{match(e){return H(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ye(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Ee{match(e){return j(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Se{match(e){return U(e,"PromiseRejectionEvent")}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return j(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){if(j(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var xe=e=>{var t={_log:function(t){if(s&&(f.DEBUG||v.POSTHOG_DEBUG)&&!R(s.console)&&s.console){for(var i=("__rrweb_original__"in s.console[t]?s.console[t].__rrweb_original__:s.console[t]),r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];i(e,...n)}},info:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];t._log("log",...i)},warn:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];t._log("warn",...i)},error:function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];t._log("error",...i)},critical:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning:e=>{t.error("You must initialize PostHog before calling "+e)},createLogger:t=>xe(e+" "+t)};return t},ke=xe("[PostHog.js]"),Pe=ke.createLogger,Ie={};function Ce(e,t,i){if(P(e))if(o&&e.forEach===o)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,s=e.length;r<s;r++)if(r in e&&t.call(i,e[r],r)===Ie)return}function Fe(e,t,i){if(!A(e)){if(P(e))return Ce(e,t,i);if(N(e)){for(var r of e.entries())if(t.call(i,r[1],r[0])===Ie)return}else for(var s in e)if(x.call(e,s)&&t.call(i,e[s],s)===Ie)return}}var Re=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ce(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Te=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Ce(i,(function(t){Ce(t,(function(t){e.push(t)}))})),e};function $e(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Oe=function(e){try{return e()}catch(e){return}},Le=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){ke.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),ke.critical(e)}}},Ae=function(e){var t={};return Fe(e,(function(e,i){(T(e)&&e.length>0||M(e))&&(t[i]=e)})),t};function Me(e,t){return i=e,r=e=>T(e)&&!L(t)?e.slice(0,t):e,s=new Set,function e(t,i){return t!==Object(t)?r?r(t,i):t:s.has(t)?void 0:(s.add(t),P(t)?(n=[],Ce(t,(t=>{n.push(e(t))}))):(n={},Fe(t,((t,i)=>{s.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,r,s}var De=["herokuapp.com","vercel.app","netlify.app"];function Ne(e){var t=null==e?void 0:e.hostname;if(!T(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of De)if(i===r)return!1;return!0}function qe(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function je(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}var Ue="$people_distinct_id",He="__alias",Be="__timers",ze="$autocapture_disabled_server_side",We="$heatmaps_enabled_server_side",Ve="$exception_capture_enabled_server_side",Ge="$error_tracking_suppression_rules",Ye="$error_tracking_capture_extension_exceptions",Je="$web_vitals_enabled_server_side",Ke="$dead_clicks_enabled_server_side",Xe="$web_vitals_allowed_metrics",Qe="$session_recording_remote_config",Ze="$sesid",et="$session_is_sampled",tt="$enabled_feature_flags",it="$early_access_features",rt="$feature_flag_details",st="$stored_person_properties",nt="$stored_group_properties",at="$surveys",ot="$surveys_activated",lt="$flag_call_reported",ct="$user_state",ut="$client_session_props",dt="$capture_rate_limit",_t="$initial_campaign_params",ht="$initial_referrer_info",pt="$initial_person_info",gt="$epp",vt="__POSTHOG_TOOLBAR__",ft="$posthog_cookieless",mt=[Ue,He,"__cmpns",Be,"$session_recording_enabled_server_side",We,Ze,tt,Ge,ct,it,rt,nt,st,at,lt,ut,dt,_t,ht,gt,pt];function yt(e){return e instanceof Element&&(e.id===vt||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function bt(e){return!!e&&1===e.nodeType}function wt(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Et(e){return!!e&&3===e.nodeType}function St(e){return!!e&&11===e.nodeType}function xt(e){return e?b(e).split(/\s+/):[]}function kt(e){var t=null==s?void 0:s.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Pt(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return xt(t)}function It(e){return A(e)?null:b(e).split(/(\s+)/).filter((e=>Wt(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ct(e){var t="";return Dt(e)&&!Nt(e)&&e.childNodes&&e.childNodes.length&&Fe(e.childNodes,(function(e){var i;Et(e)&&e.textContent&&(t+=null!==(i=It(e.textContent))&&void 0!==i?i:"")})),b(t)}function Ft(e){return R(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Rt=["a","button","form","input","select","textarea","label"];function Tt(e,t){if(R(t))return!0;var i,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function $t(e){var t=e.parentNode;return!(!t||!bt(t))&&t}var Ot=[".ph-no-rageclick",".ph-no-capture"];var Lt=e=>!e||wt(e,"html")||!bt(e),At=(e,t)=>{if(!s||Lt(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],n=e;n.parentNode&&!wt(n,"body");)if(St(n.parentNode))r.push(n.parentNode.host),n=n.parentNode.host;else{var a=$t(n);if(!a)break;if(t||Rt.indexOf(a.tagName.toLowerCase())>-1)i=!0;else{var o=s.getComputedStyle(a);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(a),n=a}return{parentIsUsefulElement:i,targetElementList:r}};function Mt(e,t,i,r,n){var a,o,l,c;if(void 0===i&&(i=void 0),!s||Lt(e))return!1;if(null!=(a=i)&&a.url_allowlist&&!kt(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&kt(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=At(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(R(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(_,i))return!1;if(!Tt(_,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var h=s.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var p=e.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Rt.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function Dt(e){for(var t=e;t.parentNode&&!wt(t,"body");t=t.parentNode){var i=Pt(t);if(y(i,"ph-sensitive")||y(i,"ph-no-capture"))return!1}if(y(Pt(e),"ph-include"))return!0;var r=e.type||"";if(T(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";if(T(s)){if(/^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,"")))return!1}return!0}function Nt(e){return!!(wt(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||wt(e,"select")||wt(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var qt="(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})",jt=new RegExp("^(?:"+qt+")$"),Ut=new RegExp(qt),Ht="\\d{3}-?\\d{2}-?\\d{4}",Bt=new RegExp("^("+Ht+")$"),zt=new RegExp("("+Ht+")");function Wt(e,t){if(void 0===t&&(t=!0),A(e))return!1;if(T(e)){if(e=b(e),(t?jt:Ut).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Bt:zt).test(e))return!1}return!0}function Vt(e){var t=Ct(e);return Wt(t=(t+" "+Gt(e)).trim())?t:""}function Gt(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Fe(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Ct(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Gt(e)).trim())}catch(e){ke.error("[AutoCapture]",e)}})),t}function Yt(e){return function(e){var t=e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var a=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),o={};return $e(a).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return o[Jt(t.toString())]=Jt(i.toString())})),s+=":",s+=$e(o).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Kt(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return $e(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(e))}function Jt(e){return e.replace(/"|\\"/g,'\\"')}function Kt(e){var t=e.attr__class;return t?P(t)?t:xt(t):void 0}class Xt{constructor(){this.clicks=[]}isRageClick(e,t,i){var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<30&&i-r.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Qt="$copy_autocapture",Zt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ei=["fatal","error","warning","log","info","debug"],ti=e=>{var t=null==u?void 0:u.createElement("a");return R(t)?null:(t.href=e,t)},ii=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return Fe(e,(function(e,t){R(e)||R(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)},ri=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<r.length;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!P(i)||i.length<2)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(e){ke.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},si=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[0]||"",n=r[1],a=s.split("?"),o=a[1],l=a[0],c=(o||"").split("&"),u=[],d=0;d<c.length;d++){var _=c[d].split("=");P(_)&&(t.includes(_[0])?u.push(_[0]+"="+i):u.push(c[d]))}var h=l;return null!=o&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},ni=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ai=Pe("[AutoCapture]");function oi(e,t){return t.length>e?t.slice(0,e)+"...":t}function li(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!bt(t));return t}function ci(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};Rt.indexOf(s)>-1&&!i&&("a"===s.toLowerCase()||"button"===s.toLowerCase()?n.$el_text=oi(1024,Vt(e)):n.$el_text=oi(1024,Ct(e)));var a=Pt(e);a.length>0&&(n.classes=a.filter((function(e){return""!==e}))),Fe(e.attributes,(function(i){var s;if((!Nt(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==r||!r.includes(i.name))&&!t&&Wt(i.value)&&(s=i.name,!T(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7)))){var a=i.value;"class"===i.name&&(a=xt(a).join(" ")),n["attr__"+i.name]=oi(1024,a)}}));for(var o=1,l=1,c=e;c=li(c);)o++,c.tagName===e.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}function ui(e,t){for(var i,r,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!wt(d,"body");)St(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(Fe(u,(e=>{var t=Dt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Wt(g)&&g),y(Pt(e),"ph-no-capture")&&(v=!0),h.push(ci(e,a,o,l));var i=function(e){if(!Dt(e))return{};var t={};return Fe(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Wt(r)&&(t[i]=r)}})),t}(e);Re(p,i)})),v)return{props:{},explicitNoCapture:v};if(o||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=Vt(e):h[0].$el_text=Ct(e)),g){var f,m;h[0].attr__href=g;var b=null==(f=ti(g))?void 0:f.host,w=null==s||null==(m=s.location)?void 0:m.host;b&&w&&b!==w&&(_=g)}return{props:Re({$event_type:n.type,$ce_version:1},c?{}:{$elements:h},{$elements_chain:Yt(h)},null!=(i=h[0])&&i.$el_text?{$el_text:null==(r=h[0])?void 0:r.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},p)}}class di{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new Xt,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,i=C(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(s&&u){var e=e=>{e=e||(null==s?void 0:s.event);try{this._captureEvent(e)}catch(e){ai.error("Failed to capture event",e)}};if(je(u,"submit",e,{capture:!0}),je(u,"change",e,{capture:!0}),je(u,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==s?void 0:s.event),this._captureEvent(e,Qt)};je(u,"copy",t,{capture:!0}),je(u,"cut",t,{capture:!0})}}}else ai.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[ze]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==u?void 0:u.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[ze],r=this._isDisabledServerSide;if(L(r)&&!D(i)&&!this.instance._shouldDisableFlags())return!1;var s=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!s}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=Ft(e);if(Et(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&function(e,t){if(!s||Lt(e))return!1;var i,r;if(!1===(i=D(t)?!!t&&Ot:null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:Ot))return!1;var{targetElementList:n}=At(e,!1);return!Tt(n,i)}(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===Qt;if(r&&Mt(r,e,this._config,n,n?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=ui(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(a.$element_selectors=l),t===Qt){var c,u=It(null==s||null==(c=s.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=d}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return I(null==u?void 0:u.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return M(e)&&isFinite(e)&&Math.floor(e)===e});var _i="0123456789abcdef";class hi{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||e<0||t<0||i<0||r<0||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new hi(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+_i.charAt(this.bytes[t]>>>4)+_i.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new hi(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class pi{constructor(){this._timestamp=0,this._counter=0,this._random=new fi}generate(){var e=this.generateOrAbort();if(R(e)){this._timestamp=0;var t=this.generateOrAbort();if(R(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return hi.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var gi,vi=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};s&&!R(s.crypto)&&crypto.getRandomValues&&(vi=e=>crypto.getRandomValues(e));class fi{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(vi(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var mi=()=>yi().toString(),yi=()=>(gi||(gi=new pi)).generate(),bi="";var wi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ei(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=u),bi)return bi;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+mi();!bi&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";t.cookie=a+";max-age=3",t.cookie.includes(s)&&(t.cookie=a+";max-age=0",bi=n)}return bi}(e);if(!i){var r=(e=>{var t=e.match(wi);return t?t[0]:""})(e);r!==i&&ke.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var Si={_is_supported:()=>!!u,_error:function(e){ke.error("cookieStore error: "+e)},_get:function(e){if(u){try{for(var t=e+"=",i=u.cookie.split(";").filter((e=>e.length)),r=0;r<i.length;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(Si._get(e))||{}}catch(e){}return t},_set:function(e,t,i,r,s){if(u)try{var n="",a="",o=Ei(u.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}s&&(a="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+o+a;return c.length>3686.4&&ke.warn("cookieStore warning: large cookie, len="+c.length),u.cookie=c,c}catch(e){return}},_remove:function(e,t){if(null!=u&&u.cookie)try{Si._set(e,"",-1,t)}catch(e){return}}},xi=null,ki={_is_supported:function(){if(!L(xi))return xi;var e=!0;if(R(s))e=!1;else try{var t="__mplssupport__";ki._set(t,"xyz"),'"xyz"'!==ki._get(t)&&(e=!1),ki._remove(t)}catch(t){e=!1}return e||ke.error("localStorage unsupported; falling back to cookie store"),xi=e,e},_error:function(e){ke.error("localStorage error: "+e)},_get:function(e){try{return null==s?void 0:s.localStorage.getItem(e)}catch(e){ki._error(e)}return null},_parse:function(e){try{return JSON.parse(ki._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==s||s.localStorage.setItem(e,JSON.stringify(t))}catch(e){ki._error(e)}},_remove:function(e){try{null==s||s.localStorage.removeItem(e)}catch(e){ki._error(e)}}},Pi=["distinct_id",Ze,et,gt,pt],Ii=i({},ki,{_parse:function(e){try{var t={};try{t=Si._parse(e)||{}}catch(e){}var i=Re(t,JSON.parse(ki._get(e)||"{}"));return ki._set(e,i),i}catch(e){}return null},_set:function(e,t,i,r,s,n){try{ki._set(e,t,void 0,void 0,n);var a={};Pi.forEach((e=>{t[e]&&(a[e]=t[e])})),Object.keys(a).length&&Si._set(e,a,i,r,s,n)}catch(e){ki._error(e)}},_remove:function(e,t){try{null==s||s.localStorage.removeItem(e),Si._remove(e,t)}catch(e){ki._error(e)}}}),Ci={},Fi={_is_supported:function(){return!0},_error:function(e){ke.error("memoryStorage error: "+e)},_get:function(e){return Ci[e]||null},_parse:function(e){return Ci[e]||null},_set:function(e,t){Ci[e]=t},_remove:function(e){delete Ci[e]}},Ri=null,Ti={_is_supported:function(){if(!L(Ri))return Ri;if(Ri=!0,R(s))Ri=!1;else try{var e="__support__";Ti._set(e,"xyz"),'"xyz"'!==Ti._get(e)&&(Ri=!1),Ti._remove(e)}catch(e){Ri=!1}return Ri},_error:function(e){ke.error("sessionStorage error: ",e)},_get:function(e){try{return null==s?void 0:s.sessionStorage.getItem(e)}catch(e){Ti._error(e)}return null},_parse:function(e){try{return JSON.parse(Ti._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==s||s.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Ti._error(e)}},_remove:function(e){try{null==s||s.sessionStorage.removeItem(e)}catch(e){Ti._error(e)}}},$i=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class Oi{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?$i.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===$i.DENIED||this.consent===$i.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===$i.DENIED}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){var e=this._storage._get(this._storageKey);return z(e)?$i.GRANTED:y(W,e)?$i.DENIED:$i.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?ki:Si;var t="localStorage"===e?Si:ki;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(z(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!qe([null==c?void 0:c.doNotTrack,null==c?void 0:c.msDoNotTrack,v.doNotTrack],(e=>z(e)))}}var Li=Pe("[Dead Clicks]"),Ai=()=>!0,Mi=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Ke)),r=e.instance.config.capture_dead_clicks;return D(r)?r:i};class Di{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Ke]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this._loadScript((()=>{this._start()}))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Li.error("failed to load script",t):e()}))}_start(){var e;if(u){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=C(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(u),Li.info("starting...")}}else Li.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Li.info("stopping..."))}}var Ni=Pe("[ExceptionAutocapture]");class qi{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(s&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=r(this.captureException.bind(this)))}catch(e){Ni.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Ve]),this._config=this._requiredConfig(),this._rateLimiter=new G({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,_logger:Ni}),this.startIfEnabled()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return C(e)?t=i({},t,e):(R(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(Ni.info("enabled"),this._loadScript(this._startCapturing))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return Ni.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this._remoteEnabled=!!t||!1,this._config=this._requiredConfig(),this._instance.persistence&&this._instance.persistence.register({[Ve]:this._remoteEnabled}),this.startIfEnabled()}captureException(e){var t,i,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(r)?Ni.info("Skipping exception capture because of client rate limiting.",{exception:r}):this._instance.exceptions.sendExceptionEvent(e)}}function ji(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return I(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]=r}}catch(e){return()=>{}}}class Ui{constructor(e){var t;this._instance=e,this._lastPathname=(null==s||null==(t=s.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(ke.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,ke.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(s&&s.history){var i=this;null!=(e=s.history.pushState)&&e.__posthog_wrapped__||ji(s.history,"pushState",(e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("pushState")})),null!=(t=s.history.replaceState)&&t.__posthog_wrapped__||ji(s.history,"replaceState",(e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("replaceState")})),this._setupPopstateListener()}}_capturePageview(e){try{var t,i=null==s||null==(t=s.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._lastPathname=i}catch(t){ke.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};je(s,"popstate",e),this._popstateListener=()=>{s&&s.removeEventListener("popstate",e)}}}}var Hi=Pe("[SegmentIntegration]");function Bi(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||mi();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(ct,"identified")),t()},s=i.user();"then"in s&&I(s.then)?s.then((e=>r(e))):r(s)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Hi.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Hi.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Hi.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var zi="posthog-js";function Wi(e,t){var{organization:r,projectId:s,prefix:n,severityAllowList:a=["error"],sendExceptionsToPostHog:o=!0}=void 0===t?{}:t;return t=>{var l,c,u,d,_;if(!("*"===a||a.includes(t.level))||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(l=t.exception)?void 0:l.values)||[],g=p.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),v={$exception_message:(null==(c=p[0])?void 0:c.value)||t.message,$exception_type:null==(u=p[0])?void 0:u.type,$exception_personURL:h,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=p[0])?void 0:_.type,$sentry_tags:t.tags};return r&&s&&(v.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),o&&e.exceptions.sendExceptionEvent(v),t}}class Vi{constructor(e,t,i,r,s,n){this.name=zi,this.setupOnce=function(a){a(Wi(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}var Gi=null!=s&&s.location?ni(s.location.hash,"__posthog")||ni(location.hash,"state"):null,Yi="_postHogToolbarParams",Ji=Pe("[Toolbar]"),Ki=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Ki||{});class Xi{constructor(e){this.instance=e}_setToolbarState(e){v.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=v.ph_toolbar_state)&&void 0!==e?e:Ki.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!s||!u)return!1;e=null!=e?e:s.location,i=null!=i?i:s.history;try{if(!t){try{s.localStorage.setItem("test","test"),s.localStorage.removeItem("test")}catch(e){return!1}t=null==s?void 0:s.localStorage}var r,n=Gi||ni(e.hash,"__posthog")||ni(e.hash,"state"),a=n?Oe((()=>JSON.parse(atob(decodeURIComponent(n)))))||Oe((()=>JSON.parse(decodeURIComponent(n)))):null;return a&&"ph_authorize"===a.action?((r=a).source="url",r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(Yi)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token)&&(this.loadToolbar(r),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=v.ph_load_toolbar||v.ph_load_editor;!A(t)&&I(t)?t(e,this.instance):Ji.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==u||!u.getElementById(vt));if(!s||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(s.localStorage.setItem(Yi,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Ki.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Ki.UNINITIALIZED){var a;this._setToolbarState(Ki.LOADING),null==(a=v.__PosthogExtensions__)||null==a.loadExternalDependency||a.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Ji.error("[Toolbar] Failed to load",e),void this._setToolbarState(Ki.UNINITIALIZED);this._setToolbarState(Ki.LOADED),this._callLoadToolbar(n)})),je(s,"turbolinks:load",(()=>{this._setToolbarState(Ki.UNINITIALIZED),this.loadToolbar(n)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Qi=Pe("[TracingHeaders]");class Zi{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;R(this._restoreXHRPatch)&&(null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager));R(this._restoreFetchPatch)&&(null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Qi.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var er=Pe("[Web Vitals]"),tr=9e5;class ir{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t,r=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(R(r))er.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this._currentURL();if(!R(s))if(A(null==e?void 0:e.name)||A(null==e?void 0:e.value))er.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)er.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),R(this._buffer.url)&&(this._buffer.url=s),this._buffer.firstMetricTimestamp=R(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this._buffer.metrics.push(i({},e,{$current_url:s,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}},this._startCapturing=()=>{var e,t,i,r,s=v.__PosthogExtensions__;R(s)||R(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this)),this._initialized=!0):er.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Je]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=C(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return R(i)?(null==(t=this._instance.persistence)?void 0:t.props[Xe])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=C(this._instance.config.capture_performance)&&M(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:tr;return 0<e&&e<=6e4?tr:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return er.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:D(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return D(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(er.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=C(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=C(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Je]:t}),this._instance.persistence.register({[Xe]:i})),this._enabledServerSide=t,this.startIfEnabled()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"web-vitals",(t=>{t?er.error("failed to load script",t):e()}))}_currentURL(){var e=s?s.location.href:void 0;return e||er.error("Could not determine current URL"),e}}var rr=Pe("[Heatmaps]");function sr(e){return C(e)&&"clientX"in e&&"clientY"in e&&M(e.clientX)&&M(e.clientY)}class nr{constructor(e){var t;this.rageclicks=new Xt,this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[We])}get flushIntervalMilliseconds(){var e=5e3;return C(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return R(this.instance.config.capture_heatmaps)?R(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;rr.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this._flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null==(t=this._deadClicksCapture)||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[We]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){s&&u&&(je(s,"beforeunload",this._flush.bind(this)),je(u,"click",(e=>this._onClick(e||(null==s?void 0:s.event))),{capture:!0}),je(u,"mousemove",(e=>this._onMouseMove(e||(null==s?void 0:s.event))),{capture:!0}),this._deadClicksCapture=new Di(this.instance,Ai,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(e,t,i){for(var r=e;r&&bt(r)&&!wt(r,"body");){if(r===i)return!1;if(y(t,null==s?void 0:s.getComputedStyle(r).position))return!0;r=$t(r)}return!1}(Ft(e),["fixed","sticky"],n);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:i),target_fixed:a,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!yt(e.target)&&sr(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!yt(e.target)&&sr(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(s){var t=s.location.href;this._buffer=this._buffer||{},this._buffer[t]||(this._buffer[t]=[]),this._buffer[t].push(e)}}_flush(){this._buffer&&!F(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class ar{constructor(e){this._instance=e}doPageView(e,t){var i,r=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==s?void 0:s.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:a,maxScrollY:o,maxContentHeight:l,lastContentY:c,maxContentY:u}=s;if(!(R(n)||R(a)||R(o)||R(l)||R(c)||R(u))){n=Math.ceil(n),a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:V(a/n,0,1,ke),_=n<=1?1:V(o/n,0,1,ke),h=l<=1?1:V(c/l,0,1,ke),p=l<=1?1:V(u/l,0,1,ke);r=Re(r,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:o,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var or=Uint8Array,lr=Uint16Array,cr=Uint32Array,ur=new or([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),dr=new or([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_r=new or([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hr=function(e,t){for(var i=new lr(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var s=new cr(i[30]);for(r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return[i,s]},pr=hr(ur,2),gr=pr[0],vr=pr[1];gr[28]=258,vr[258]=28;for(var fr=hr(dr,0)[1],mr=new lr(32768),yr=0;yr<32768;++yr){var br=(43690&yr)>>>1|(21845&yr)<<1;br=(61680&(br=(52428&br)>>>2|(13107&br)<<2))>>>4|(3855&br)<<4,mr[yr]=((65280&br)>>>8|(255&br)<<8)>>>1}var wr=function(e,t,i){for(var r=e.length,s=0,n=new lr(t);s<r;++s)++n[e[s]-1];var a,o=new lr(t);for(s=0;s<t;++s)o[s]=o[s-1]+n[s-1]<<1;if(i){a=new lr(1<<t);var l=15-t;for(s=0;s<r;++s)if(e[s])for(var c=s<<4|e[s],u=t-e[s],d=o[e[s]-1]++<<u,_=d|(1<<u)-1;d<=_;++d)a[mr[d]>>>l]=c}else for(a=new lr(r),s=0;s<r;++s)a[s]=mr[o[e[s]-1]++]>>>15-e[s];return a},Er=new or(288);for(yr=0;yr<144;++yr)Er[yr]=8;for(yr=144;yr<256;++yr)Er[yr]=9;for(yr=256;yr<280;++yr)Er[yr]=7;for(yr=280;yr<288;++yr)Er[yr]=8;var Sr=new or(32);for(yr=0;yr<32;++yr)Sr[yr]=5;var xr=wr(Er,9,0),kr=wr(Sr,5,0),Pr=function(e){return(e/8>>0)+(7&e&&1)},Ir=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof lr?lr:e instanceof cr?cr:or)(i-t);return r.set(e.subarray(t,i)),r},Cr=function(e,t,i){i<<=7&t;var r=t/8>>0;e[r]|=i,e[r+1]|=i>>>8},Fr=function(e,t,i){i<<=7&t;var r=t/8>>0;e[r]|=i,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Rr=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new or(0),0];if(1==s){var a=new or(i[0].s+1);return a[i[0].s]=1,[a,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var o=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=s-1;)o=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:o.f+l.f,l:o,r:l};var _=n[0].s;for(r=1;r<s;++r)n[r].s>_&&(_=n[r].s);var h=new lr(_+1),p=Tr(i[u-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));r<s;++r){var m=n[r].s;if(!(h[m]>t))break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;h[y]<t?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new or(h),p]},Tr=function(e,t,i){return-1==e.s?Math.max(Tr(e.l,t,i+1),Tr(e.r,t,i+1)):t[e.s]=i},$r=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new lr(++t),r=0,s=e[0],n=1,a=function(e){i[r++]=e},o=1;o<=t;++o)if(e[o]==s&&o!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(s),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(s);n=1,s=e[o]}return[i.subarray(0,r),t]},Or=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},Lr=function(e,t,i){var r=i.length,s=Pr(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;n<r;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Ar=function(e,t,i,r,s,n,a,o,l,c,u){Cr(t,u++,i),++s[256];for(var d=Rr(s,15),_=d[0],h=d[1],p=Rr(n,15),g=p[0],v=p[1],f=$r(_),m=f[0],y=f[1],b=$r(g),w=b[0],E=b[1],S=new lr(19),x=0;x<m.length;++x)S[31&m[x]]++;for(x=0;x<w.length;++x)S[31&w[x]]++;for(var k=Rr(S,7),P=k[0],I=k[1],C=19;C>4&&!P[_r[C-1]];--C);var F,R,T,O,L=c+5<<3,A=Or(s,Er)+Or(n,Sr)+a,M=Or(s,_)+Or(n,g)+a+14+3*C+Or(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(L<=A&&L<=M)return Lr(t,u,e.subarray(l,l+c));if(Cr(t,u,1+(M<A)),u+=2,M<A){F=wr(_,h,0),R=_,T=wr(g,v,0),O=g;var D=wr(P,I,0);Cr(t,u,y-257),Cr(t,u+5,E-1),Cr(t,u+10,C-4),u+=14;for(x=0;x<C;++x)Cr(t,u+3*x,P[_r[x]]);u+=3*C;for(var N=[m,w],q=0;q<2;++q){var j=N[q];for(x=0;x<j.length;++x){var U=31&j[x];Cr(t,u,D[U]),u+=P[U],U>15&&(Cr(t,u,j[x]>>>5&127),u+=j[x]>>>12)}}}else F=xr,R=Er,T=kr,O=Sr;for(x=0;x<o;++x)if(r[x]>255){U=r[x]>>>18&31;Fr(t,u,F[U+257]),u+=R[U+257],U>7&&(Cr(t,u,r[x]>>>23&31),u+=ur[U]);var H=31&r[x];Fr(t,u,T[H]),u+=O[H],H>3&&(Fr(t,u,r[x]>>>5&8191),u+=dr[H])}else Fr(t,u,F[r[x]]),u+=R[r[x]];return Fr(t,u,F[256]),u+R[256]},Mr=new cr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Dr=function(){for(var e=new cr(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Nr=function(e,t,i,r,s){return function(e,t,i,r,s,n){var a=e.length,o=new or(r+a+5*(1+Math.floor(a/7e3))+s),l=o.subarray(r,o.length-s),c=0;if(!t||a<8)for(var u=0;u<=a;u+=65535){var d=u+65535;d<a?c=Lr(l,c,e.subarray(u,d)):(l[u]=n,c=Lr(l,c,e.subarray(u,a)))}else{for(var _=Mr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new lr(32768),f=new lr(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new cr(25e3),E=new lr(288),S=new lr(32),x=0,k=0,P=(u=0,0),I=0,C=0;u<a;++u){var F=b(u),R=32767&u,T=f[F];if(v[R]=T,f[F]=R,I<=u){var O=a-u;if((x>7e3||P>24576)&&O>423){c=Ar(e,l,0,w,E,S,k,P,C,u-C,c),P=x=k=0,C=u;for(var L=0;L<286;++L)E[L]=0;for(L=0;L<30;++L)S[L]=0}var A=2,M=0,D=p,N=R-T&32767;if(O>2&&F==b(u-N))for(var q=Math.min(h,O)-1,j=Math.min(32767,u),U=Math.min(258,O);N<=j&&--D&&R!=T;){if(e[u+A]==e[u+A-N]){for(var H=0;H<U&&e[u+H]==e[u+H-N];++H);if(H>A){if(A=H,M=N,H>q)break;var B=Math.min(N,H-2),z=0;for(L=0;L<B;++L){var W=u-N+L+32768&32767,V=W-v[W]+32768&32767;V>z&&(z=V,T=W)}}}N+=(R=T)-(T=v[R])+32768&32767}if(M){w[P++]=268435456|vr[A]<<18|fr[M];var G=31&vr[A],Y=31&fr[M];k+=ur[G]+dr[Y],++E[257+G],++S[Y],I=u+A,++x}else w[P++]=e[u],++E[e[u]]}}c=Ar(e,l,n,w,E,S,k,P,C,u-C,c)}return Ir(o,0,r+Pr(c)+s)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,r,!0)},qr=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function jr(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=Dr[255&i^t[r]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n=Nr(e,t,10+((s=t).filename&&s.filename.length+1||0),8),a=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&qr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(n,t),qr(n,a-8,i.d()),qr(n,a-4,r),n}var Ur=function(e){var t,i,r,s,n="";for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s<r;s++){var a=e.charCodeAt(s),o=null;a<128?i++:o=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),L(o)||(i>t&&(n+=e.substring(t,i)),n+=o,t=i=s+1)}return i>t&&(n+=e.substring(t,e.length)),n},Hr=!!h||!!_,Br="text/plain",zr=(e,t)=>{var[r,s]=e.split("?"),n=i({},t);null==s||s.split("&").forEach((e=>{var[t]=e.split("=");delete n[t]}));var a=ii(n);return r+"?"+(a=a?(s?s+"&":"")+a:s)},Wr=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Vr=e=>{var{data:t,compression:i}=e;if(t){if(i===Zt.GZipJS){var r=jr(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new or(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},a=0;a<i;++a){if(s+5>r.length){var o=new or(s+8+(i-a<<1));o.set(r),r=o}var l=e.charCodeAt(a);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Ir(r,0,s)}(Wr(t)),{mtime:0}),s=new Blob([r],{type:Br});return{contentType:Br,body:s,estimatedSize:s.size}}if(i===Zt.Base64){var n=function(e){var t,i,r,s,n,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,l=0,c="",u=[];if(!e)return e;e=Ur(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,i=n>>12&63,r=n>>6&63,s=63&n,u[l++]=a.charAt(t)+a.charAt(i)+a.charAt(r)+a.charAt(s)}while(o<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Wr(t)),a=(e=>"data="+encodeURIComponent("string"==typeof e?e:Wr(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var o=Wr(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Gr=[];_&&Gr.push({transport:"fetch",method:e=>{var t,r,{contentType:s,body:n,estimatedSize:a}=null!==(t=Vr(e))&&void 0!==t?t:{},o=new Headers;Fe(e.headers,(function(e,t){o.append(t,e)})),s&&o.append("Content-Type",s);var l=e.url,c=null;if(p){var u=new p;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,i({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(a||0)<52428.8,body:n,signal:null==(r=c)?void 0:r.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){ke.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{ke.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),h&&Gr.push({transport:"XHR",method:e=>{var t,i=new h;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:s}=null!==(t=Vr(e))&&void 0!==t?t:{};Fe(e.headers,(function(e,t){i.setRequestHeader(t,e)})),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(s)}}),null!=c&&c.sendBeacon&&Gr.push({transport:"sendBeacon",method:e=>{var t=zr(e.url,{beacon:"1"});try{var i,{contentType:r,body:s}=null!==(i=Vr(e))&&void 0!==i?i:{},n="string"==typeof s?new Blob([s],{type:r}):s;c.sendBeacon(t,n)}catch(e){}}});var Yr=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function Jr(e,t,i){return Wr({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Kr={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>Yr(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Yr(t,e))))),icontains:(e,t)=>t.map(Xr).some((t=>e.map(Xr).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Xr).every((t=>e.map(Xr).every((e=>!t.includes(e)))))},Xr=e=>e.toLowerCase(),Qr=Pe("[Error tracking]");class Zr{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new _e([new he,new Se,new ge,new pe,new we,new be,new fe,new Ee],[ne,le]),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Ge))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,r,s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,this._instance.persistence&&this._instance.persistence.register({[Ge]:this._suppressionRules,[Ye]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Ye),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){if(this._matchesSuppressionRule(e))Qr.info("Skipping exception capture because a suppression rule matched");else{if(this._captureExtensionExceptions||!this._isExtensionException(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});Qr.info("Skipping exception capture because it was thrown by an extension")}}_matchesSuppressionRule(e){var t=e.$exception_list;if(!t||!P(t)||0===t.length)return!1;var i=t.reduce(((e,t)=>{var{type:i,value:r}=t;return T(i)&&i.length>0&&e.$exception_types.push(i),T(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var t=e.values.map((e=>{var t,r=Kr[e.operator],s=P(e.value)?e.value:[e.value],n=null!==(t=i[e.key])&&void 0!==t?t:[];return s.length>0&&r(s,n)}));return"OR"===e.type?t.some(Boolean):t.every(Boolean)}))}_isExtensionException(e){var t=e.$exception_list;return!(!t||!P(t))&&t.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}}var es="Mobile",ts="iOS",is="Android",rs="Tablet",ss=is+" "+rs,ns="iPad",as="Apple",os=as+" Watch",ls="Safari",cs="BlackBerry",us="Samsung",ds=us+"Browser",_s=us+" Internet",hs="Chrome",ps=hs+" OS",gs=hs+" "+ts,vs="Internet Explorer",fs=vs+" "+es,ms="Opera",ys=ms+" Mini",bs="Edge",ws="Microsoft "+bs,Es="Firefox",Ss=Es+" "+ts,xs="Nintendo",ks="PlayStation",Ps="Xbox",Is=is+" "+es,Cs=es+" "+ls,Fs="Windows",Rs=Fs+" Phone",Ts="Nokia",$s="Ouya",Os="Generic",Ls=Os+" "+es.toLowerCase(),As=Os+" "+rs.toLowerCase(),Ms="Konqueror",Ds="(\\d+(\\.\\d+)?)",Ns=new RegExp("Version/"+Ds),qs=new RegExp(Ps,"i"),js=new RegExp(ks+" \\w+","i"),Us=new RegExp(xs+" \\w+","i"),Hs=new RegExp(cs+"|PlayBook|BB10","i"),Bs={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var zs=(e,t)=>t&&y(t,as)||function(e){return y(e,ls)&&!y(e,hs)&&!y(e,is)}(e),Ws=function(e,t){return t=t||"",y(e," OPR/")&&y(e,"Mini")?ys:y(e," OPR/")?ms:Hs.test(e)?cs:y(e,"IE"+es)||y(e,"WPDesktop")?fs:y(e,ds)?_s:y(e,bs)||y(e,"Edg/")?ws:y(e,"FBIOS")?"Facebook "+es:y(e,"UCWEB")||y(e,"UCBrowser")?"UC Browser":y(e,"CriOS")?gs:y(e,"CrMo")||y(e,hs)?hs:y(e,is)&&y(e,ls)?Is:y(e,"FxiOS")?Ss:y(e.toLowerCase(),Ms.toLowerCase())?Ms:zs(e,t)?y(e,es)?Cs:ls:y(e,Es)?Es:y(e,"MSIE")||y(e,"Trident/")?vs:y(e,"Gecko")?Es:""},Vs={[fs]:[new RegExp("rv:"+Ds)],[ws]:[new RegExp(bs+"?\\/"+Ds)],[hs]:[new RegExp("("+hs+"|CrMo)\\/"+Ds)],[gs]:[new RegExp("CriOS\\/"+Ds)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ds)],[ls]:[Ns],[Cs]:[Ns],[ms]:[new RegExp("(Opera|OPR)\\/"+Ds)],[Es]:[new RegExp(Es+"\\/"+Ds)],[Ss]:[new RegExp("FxiOS\\/"+Ds)],[Ms]:[new RegExp("Konqueror[:/]?"+Ds,"i")],[cs]:[new RegExp(cs+" "+Ds),Ns],[Is]:[new RegExp("android\\s"+Ds,"i")],[_s]:[new RegExp(ds+"\\/"+Ds)],[vs]:[new RegExp("(rv:|MSIE )"+Ds)],Mozilla:[new RegExp("rv:"+Ds)]},Gs=function(e,t){var i=Ws(e,t),r=Vs[i];if(R(r))return null;for(var s=0;s<r.length;s++){var n=r[s],a=e.match(n);if(a)return parseFloat(a[a.length-2])}return null},Ys=[[new RegExp(Ps+"; "+Ps+" (.*?)[);]","i"),e=>[Ps,e&&e[1]||""]],[new RegExp(xs,"i"),[xs,""]],[new RegExp(ks,"i"),[ks,""]],[Hs,[cs,""]],[new RegExp(Fs,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Rs,""];if(new RegExp(es).test(t)&&!/IEMobile\b/.test(t))return[Fs+" "+es,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],s=Bs[r]||"";return/arm/i.test(t)&&(s="RT"),[Fs,s]}return[Fs,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[ts,t.join(".")]}return[ts,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=R(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+is+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+is+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[is,t.join(".")]}return[is,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ps,""]],[/Linux|debian/i,["Linux",""]]],Js=function(e){return Us.test(e)?xs:js.test(e)?ks:qs.test(e)?Ps:new RegExp($s,"i").test(e)?$s:new RegExp("("+Rs+"|WPDesktop)","i").test(e)?Rs:/iPad/.test(e)?ns:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?os:Hs.test(e)?cs:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Ts,"i").test(e)?Ts:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(es).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?is:ss:is:new RegExp("(pda|"+es+")","i").test(e)?Ls:new RegExp(rs,"i").test(e)&&!new RegExp(rs+" pc","i").test(e)?As:""},Ks="https?://(.*)",Xs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Qs=Te(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Xs),Zs="<masked>",en=["li_fat_id"];function tn(e,t,i){if(!u)return{};var r,s=t?Te([],Xs,i||[]):[],n=rn(si(u.URL,s,Zs),e),a=(r={},Fe(en,(function(e){var t=Si._get(e);r[e]=t||null})),r);return Re(a,n)}function rn(e,t){var i=Qs.concat(t||[]),r={};return Fe(i,(function(t){var i=ri(e,t);r[t]=i||null})),r}function sn(e){var t=function(e){return e?0===e.search(Ks+"google.([^/?]*)")?"google":0===e.search(Ks+"bing.com")?"bing":0===e.search(Ks+"yahoo.com")?"yahoo":0===e.search(Ks+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!L(t)){r.$search_engine=t;var s=u?ri(u.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function nn(){return navigator.language||navigator.userLanguage}function an(){return(null==u?void 0:u.referrer)||"$direct"}function on(e,t){var i=e?Te([],Xs,t||[]):[],r=null==d?void 0:d.href.substring(0,1e3);return{r:an().substring(0,1e3),u:r?si(r,i,Zs):void 0}}function ln(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=ti(i))?void 0:t.host};if(r){s.$current_url=r;var n=ti(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var a=rn(r);Re(s,a)}if(i){var o=sn(i);Re(s,o)}return s}function cn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function un(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function dn(e,t){if(!g)return{};var i,r,n,a=e?Te([],Xs,t||[]):[],[o,l]=function(e){for(var t=0;t<Ys.length;t++){var[i,r]=Ys[t],s=i.exec(e),n=s&&(I(r)?r(s,e):r);if(n)return n}return["",""]}(g);return Re(Ae({$os:o,$os_version:l,$browser:Ws(g,navigator.vendor),$device:Js(g),$device_type:(r=g,n=Js(r),n===ns||n===ss||"Kobo"===n||"Kindle Fire"===n||n===As?rs:n===xs||n===Ps||n===ks||n===$s?"Console":n===os?"Wearable":n?es:"Desktop"),$timezone:cn(),$timezone_offset:un()}),{$current_url:si(null==d?void 0:d.href,a,Zs),$host:null==d?void 0:d.host,$pathname:null==d?void 0:d.pathname,$raw_user_agent:g.length>1e3?g.substring(0,997)+"...":g,$browser_version:Gs(g,navigator.vendor),$browser_language:nn(),$browser_language_prefix:(i=nn(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==s?void 0:s.screen.height,$screen_width:null==s?void 0:s.screen.width,$viewport_height:null==s?void 0:s.innerHeight,$viewport_width:null==s?void 0:s.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var _n=Pe("[FeatureFlags]"),hn="$active_feature_flags",pn="$override_feature_flags",gn="$feature_flag_payloads",vn="$override_feature_flag_payloads",fn="$feature_flag_request_id",mn=e=>{var t={};for(var[i,r]of $e(e||{}))r&&(t[i]=r);return t},yn=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):_n.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},bn=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class wn{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this._instance=e,this.featureFlagEventHandlers=[]}_getValidEvaluationEnvironments(){var e=this._instance.config.evaluation_environments;return null!=e&&e.length?e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||_n.error("Invalid evaluation environment found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}flags(){if(this._instance.config.__preview_remote_config)this._flagsCalled=!0;else{var e=!this._reloadDebouncer&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this._callFlagsEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(rt),t=this._instance.get_property(pn),r=this._instance.get_property(vn);if(!r&&!t)return e||{};var s=Re({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var a of n){var o,l,c=s[a],u=null==t?void 0:t[a],d=R(u)?null!==(o=null==c?void 0:c.enabled)&&void 0!==o&&o:!!u,_=R(u)?c.variant:"string"==typeof u?u:void 0,h=null==r?void 0:r[a],p=i({},c,{enabled:d,variant:d?null!=_?_:null==c?void 0:c.variant:void 0});if(d!==(null==c?void 0:c.enabled)&&(p.original_enabled=null==c?void 0:c.enabled),_!==(null==c?void 0:c.variant)&&(p.original_variant=null==c?void 0:c.variant),h)p.metadata=i({},null==c?void 0:c.metadata,{payload:h,original_payload:null==c||null==(l=c.metadata)?void 0:l.payload});s[a]=p}return this._override_warning||(_n.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getFlagVariants(){var e=this._instance.get_property(tt),t=this._instance.get_property(pn);if(!t)return e||{};for(var i=Re({},e),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this._override_warning||(_n.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(gn),t=this._instance.get_property(vn);if(!t)return e||{};for(var i=Re({},e||{}),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this._override_warning||(_n.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(st)||{}),group_properties:this._instance.get_property(nt)};(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_environments=this._getValidEvaluationEnvironments());var s=this._instance.config.__preview_remote_config,n=s?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",o=this._instance.requestRouter.endpointFor("api",n+a);s&&(r.timezone=cn()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:o,data:r,compression:this._instance.config.disable_compression?void 0:Zt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,s=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,this._flagsCalled)||(this._flagsCalled=!0,this._instance._onRemoteConfig(null!==(i=e.json)&&void 0!==i?i:{}));if(!r.disable_flags||this._additionalReloadRequested)if(this._flagsLoadedFromRemote=!s,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(bn.FeatureFlags))_n.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{var n;if(!r.disable_flags)this.receivedFeatureFlags(null!==(n=e.json)&&void 0!==n?n:{},s);this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants()[e],r=""+i,s=this._instance.get_property(fn)||void 0,n=this._instance.get_property(lt)||{};if((t.send_event||!("send_event"in t))&&(!(e in n)||!n[e].includes(r))){var a,o,l,c,u,d,_,h,p;P(n[e])?n[e].push(r):n[e]=[r],null==(a=this._instance.persistence)||a.register({[lt]:n});var g=this.getFeatureFlagDetails(e),v={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:(null==(o=this._instance.config.bootstrap)||null==(o=o.featureFlags)?void 0:o[e])||null,$feature_flag_bootstrapped_payload:(null==(l=this._instance.config.bootstrap)||null==(l=l.featureFlagPayloads)?void 0:l[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};R(null==g||null==(c=g.metadata)?void 0:c.version)||(v.$feature_flag_version=g.metadata.version);var f,m=null!==(u=null==g||null==(d=g.reason)?void 0:d.description)&&void 0!==u?u:null==g||null==(_=g.reason)?void 0:_.code;if(m&&(v.$feature_flag_reason=m),null!=g&&null!=(h=g.metadata)&&h.id&&(v.$feature_flag_id=g.metadata.id),R(null==g?void 0:g.original_variant)&&R(null==g?void 0:g.original_enabled)||(v.$feature_flag_original_response=R(g.original_variant)?g.original_enabled:g.original_variant),null!=g&&null!=(p=g.metadata)&&p.original_payload)v.$feature_flag_original_payload=null==g||null==(f=g.metadata)?void 0:f.original_payload;this._instance.capture("$feature_flag_called",v)}return i}_n.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var i=this._instance.config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_environments=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:r,compression:this._instance.config.disable_compression?void 0:Zt.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return R(i)?void 0:!!i}_n.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this._hasLoadedFlags=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,r,s,n){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var a=yn(e),o=a.flags,l=a.featureFlags,c=a.featureFlagPayloads;if(l){var u=e.requestId;if(P(l)){_n.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var d={};if(l)for(var _=0;_<l.length;_++)d[l[_]]=!0;t&&t.register({[hn]:l,[tt]:d})}else{var h=l,p=c,g=o;e.errorsWhileComputingFlags&&(h=i({},r,h),p=i({},s,p),g=i({},n,g)),t&&t.register(i({[hn]:Object.keys(mn(h)),[tt]:h||{},[gn]:p||{},[rt]:g||{}},u?{[fn]:u}:{}))}}}(e,this._instance.persistence,r,s,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),_n.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return _n.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(pn),this._instance.persistence.unregister(vn),void this._fireFeatureFlagsCallbacks();if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(pn);else if(i.flags)if(P(i.flags)){for(var r={},s=0;s<i.flags.length;s++)r[i.flags[s]]=!0;this._instance.persistence.register({[pn]:r})}else this._instance.persistence.register({[pn]:i.flags});return"payloads"in i&&(!1===i.payloads?this._instance.persistence.unregister(vn):i.payloads&&this._instance.persistence.register({[vn]:i.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._instance.get_property(it)||[]).find((t=>t.flagKey===e)),a={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$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(),{[e]:t});null==(s=this._instance.persistence)||s.register({[hn]:Object.keys(mn(l)),[tt]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._instance.get_property(it),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(it),null==(r=this._instance.persistence)||r.register({[it]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>r(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._instance.get_property(st)||{};this._instance.register({[st]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(st)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._instance.get_property(nt)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[nt]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(nt)||{};this._instance.register({[nt]:i({},t,{[e]:{}})})}else this._instance.unregister(nt)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}var En=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Sn{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&ke.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===En.indexOf(e.persistence.toLowerCase())&&(ke.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&ki._is_supported()?ki:"localstorage+cookie"===t&&Ii._is_supported()?Ii:"sessionstorage"===t&&Ti._is_supported()?Ti:"memory"===t?Fi:"cookie"===t?Si:Ii._is_supported()?Ii:Si}properties(){var e={};return Fe(this.props,(function(t,i){if(i===tt&&C(t))for(var r=Object.keys(t),s=0;s<r.length;s++)e["$feature/"+r[s]]=t[r[s]];else a=i,o=!1,(L(n=mt)?o:l&&n.indexOf===l?-1!=n.indexOf(a):(Fe(n,(function(e){if(o||(o=e===a))return Ie})),o))||(e[i]=t);var n,a,o})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Re({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(C(e)){R(t)&&(t="None"),this._expire_days=R(i)?this._default_expiry:i;var r=!1;if(Fe(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(C(e)){this._expire_days=R(t)?this._default_expiry:t;var i=!1;if(Fe(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=tn(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);F(Ae(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==u?void 0:u.referrer)?sn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:an(),$referring_domain:null!=u&&u.referrer&&(null==(e=ti(u.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[_t]||this.props[ht]||this.register_once({[pt]:on(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Fe([ht,_t],(t=>{var i=this.props[t];i&&Fe(i,(function(t,i){e["$initial_"+w(i)]=t}))}));var t,i,r=this.props[pt];if(r){var s=(t=ln(r),i={},Fe(t,(function(e,t){i["$initial_"+w(t)]=e})),i);Re(e,s)}return e}safe_merge(e){return Fe(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var r=this._buildStorage(e),s=this.props;this.clear(),this._storage=r,this.props=s,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[Be]||{};i[e]=t,this.props[Be]=i,this.save()}remove_event_timer(e){var t=(this.props[Be]||{})[e];return R(t)||(delete this.props[Be][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var xn=function(e){return e.Button="button",e.Tab="tab",e.Selector="selector",e}({}),kn=function(e){return e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger",e}({}),Pn=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),In=function(e){return e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link",e}({}),Cn=function(e){return e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question",e}({}),Fn=function(e){return e.Once="once",e.Recurring="recurring",e.Always="always",e}({}),Rn=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e}({}),Tn=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e}({}),$n=function(e){return e.Popover="popover",e.Inline="inline",e}({});class On{constructor(){this._events={},this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var r of this._events["*"]||[])r(e,t)}}class Ln{constructor(e){this._debugEventEmitter=new On,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e;if(!R(null==(e=this._instance)?void 0:e._addCaptureHook)){var t;null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!R(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ln._matchString(r,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static _matchString(e,t,i){switch(i){case"regex":return!!s&&Yr(e,t);case"exact":return t===e;case"contains":var r=Ln._escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return Yr(e,r);default:return!1}}static _escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}_checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this._getElementsList(e).some((e=>!(null!=t&&t.href&&!Ln._matchString(e.href||"",null==t?void 0:t.href,(null==t?void 0:t.href_matching)||"exact"))&&((null==t||!t.tag_name||e.tag_name===(null==t?void 0:t.tag_name))&&!(null!=t&&t.text&&!Ln._matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Ln._matchString(e.$el_text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact"))))))return!1;if(null!=t&&t.selector){var i,r=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(!r)return!1;if(!r.includes(null==t?void 0:t.selector))return!1}return!0}_getElementsList(e){return null==(null==e?void 0:e.properties.$elements)?[]:null==e?void 0:e.properties.$elements}}var An=Pe("[Surveys]");var Mn="seenSurvey_",Dn=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},Nn=e=>{var t=""+Mn+e.id;return e.current_iteration&&e.current_iteration>0&&(t=""+Mn+e.id+"_"+e.current_iteration),t},qn=[Pn.Popover,Pn.Widget,Pn.API],jn={ignoreConditions:!1,ignoreDelay:!1,displayType:$n.Popover};class Un{constructor(e){this._instance=e,this._eventToSurveys=new Map,this._actionToSurveys=new Map}register(e){var t;R(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedSurveys(e),this._setupActionBasedSurveys(e))}_setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));if(0!==t.length){if(null==this._actionMatcher){this._actionMatcher=new Ln(this._instance),this._actionMatcher.init();this._actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToSurveys.get(t.name);i&&i.push(e.id),this._actionToSurveys.set(t.name,i||[e.id])}})))}))}}_setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})).length){null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t;null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||t.forEach((t=>{if(t&&t.name){var i=this._eventToSurveys.get(t.name);i&&i.push(e.id),this._eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,r,s=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[ot])||[];if(Rn.SHOWN===e&&t&&s.length>0){var n;An.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:t,existingActivatedSurveys:s});var a=null==t||null==(n=t.properties)?void 0:n.$survey_id;if(a){var o=s.indexOf(a);o>=0&&(s.splice(o,1),this._updateActivatedSurveys(s))}}else if(this._eventToSurveys.has(e)){An.info("survey event name matched",{event:e,eventPayload:t,surveys:this._eventToSurveys.get(e)});var l=[];null==(r=this._instance)||r.getSurveys((t=>{l=t.filter((t=>{var i;return null==(i=this._eventToSurveys.get(e))?void 0:i.includes(t.id)}))}));var c=l.filter((i=>{var r,s=null==(r=i.conditions)||null==(r=r.events)||null==(r=r.values)?void 0:r.find((t=>t.name===e));return!!s&&(!s.propertyFilters||Object.entries(s.propertyFilters).every((e=>{var i,[r,s]=e,n=null==t||null==(i=t.properties)?void 0:i[r];if(R(n)||L(n))return!1;var a=[String(n)],o=Kr[s.operator];return o?o(s.values,a):(An.warn("Unknown property comparison operator: "+s.operator),!1)})))}));this._updateActivatedSurveys(s.concat(c.map((e=>e.id))||[]))}}onAction(e){var t,i=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[ot])||[];this._actionToSurveys.has(e)&&this._updateActivatedSurveys(i.concat(this._actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t;An.info("updating activated surveys",{activatedSurveys:e}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[ot]:[...new Set(e)]})}getSurveys(){var e,t=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[ot];return t||[]}getEventToSurveys(){return this._eventToSurveys}_getActionMatcher(){return this._actionMatcher}}class Hn{constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isFetchingSurveys=!1,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(A(t))return An.warn("Flags not loaded yet. Not loading surveys.");var i=P(t);this._isSurveysEnabled=i?t.length>0:t,An.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith(Mn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)An.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)An.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())An.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!R(this._isSurveysEnabled)||this._instance.config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._instance.config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError("PostHog loadExternalDependency extension not found.");r(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else An.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Un(this._instance),An.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){An.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return An.info("Disabled. Not loading surveys."),e([]);var i=this._instance.get_property(at);if(i&&!t)return e(i,{isLoaded:!0});if(this._isFetchingSurveys)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:t=>{var i;this._isFetchingSurveys=!1;var r=t.statusCode;if(200!==r||!t.json){var s="Surveys API could not be loaded, status: "+r;return An.error(s),e([],{isLoaded:!1,error:s})}var n,a=t.json.surveys||[],o=a.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));o.length>0&&(null==(n=this._surveyEventReceiver)||n.register(o));return null==(i=this._instance.persistence)||i.register({[at]:a}),e(a,{isLoaded:!0})}})}catch(e){throw this._isFetchingSurveys=!1,e}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){An.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!A(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);An.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(A(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(A(this._surveyManager))return An.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return A(this._surveyManager)?(An.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t){var i;if(A(this._surveyManager))An.warn("init was not called");else{var r="string"==typeof e?this._getSurveyById(e):e;if(null!=r&&r.id)if(qn.includes(r.type)){var s=null==u?void 0:u.querySelector(t);if(s)return null!=(i=r.appearance)&&i.surveyPopupDelaySeconds?(An.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;An.info("Rendering survey "+r.id+" with delay of "+(null==(e=r.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(r,s),An.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,s);An.warn("Survey element not found")}else An.warn("Surveys of type "+r.type+" cannot be rendered in the app");else An.warn("Survey not found")}}displaySurvey(e,t){var r;if(A(this._surveyManager))An.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),!1===t.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void An.warn("Survey is not eligible to be displayed: ",a.disabledReason)}t.displayType!==$n.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else An.warn("Survey not found")}}}var Bn=Pe("[RateLimiter]");class zn{constructor(e){var t,i;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Bn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Bn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.captureEventsPerSecond=(null==(t=e.config.rate_limiting)?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null==(i=e.config.rate_limiting)?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var s=(new Date).getTime(),n=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(dt))&&void 0!==t?t:{tokens:this.captureEventsBurstLimit,last:s};n.tokens+=(s-n.last)/1e3*this.captureEventsPerSecond,n.last=s,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var a=n.tokens<1;return a||e||(n.tokens=Math.max(0,n.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,null==(r=this.instance.persistence)||r.set_property(dt,n),{isRateLimited:a,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Wn=Pe("[RemoteConfig]");class Vn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Wn.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Wn.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Wn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Wn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e)}));this._onRemoteConfig(e)}))}catch(e){Wn.error("Error loading remote config",e)}}_onRemoteConfig(e){e?this._instance.config.__preview_remote_config?(this._instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):Wn.info("__preview_remote_config is disabled. Logging config instead",e):Wn.error("Failed to fetch remote config from PostHog.")}}var Gn=3e3;class Yn{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=V((null==t?void 0:t.flush_interval_ms)||Gn,250,5e3,ke.createLogger("flush interval"),Gn),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[r],s=(new Date).getTime();i.data&&P(i.data)&&Fe(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequest(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Fe(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;R(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var Jn=["retriesPerformedSoFar"];class Kn{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!R(s)&&"onLine"in s.navigator&&(this._areWeOnline=s.navigator.onLine,je(s,"online",(()=>{this._areWeOnline=!0,this._flush()})),je(s,"offline",(()=>{this._areWeOnline=!1})))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,Jn);M(t)&&t>0&&(s.url=zr(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this._enqueue(i({retriesPerformedSoFar:t},s)):null==s.callback||s.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),s=(Math.random()-.5)*(r-i);return Math.ceil(r+s)}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),ke.warn(s),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){ke.error(e)}this._queue=[]}}class Xn{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),a=s?Math.max(0,s.scrollHeight-s.clientHeight):0,o=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(a,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=o,this._context.maxContentY=Math.max(o,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(r=this._context.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){je(s,"scroll",this._updateScrollData,{capture:!0}),je(s,"scrollend",this._updateScrollData,{capture:!0}),je(s,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==s?void 0:s.document.documentElement;var e=P(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var i=null==s?void 0:s.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return s&&(s.scrollY||s.pageYOffset||s.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return s&&(s.scrollX||s.pageXOffset||s.document.documentElement.scrollLeft)||0}}var Qn=e=>on(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Zn{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[ut]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||Qn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[ut]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?ln(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Fe(Ae(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+w(i)]=t})),e}}var ea=Pe("[SessionId]");class ta{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._sessionIdChangedHandlers=[],this._eventEmitter=new On,this._sessionHasBeenIdleTooLong=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||mi,this._windowIdGenerator=i||mi;var s=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*V(n,60,36e3,ea.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var a=Ti._parse(this._window_id_storage_key),o=Ti._parse(this._primary_window_exists_storage_key);a&&!o?this._windowId=a:Ti._remove(this._window_id_storage_key),Ti._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this._config.bootstrap.sessionID);this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){ea.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return R(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Ti._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Ti._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Ti._parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this._persistence.register({[Ze]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[Ze];return P(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){je(s,"beforeunload",(()=>{this._canUseSessionStorage()&&Ti._remove(this._primary_window_exists_storage_key)}),{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,s,n]=this._getSessionId(),a=this._getWindowId(),o=M(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!s,u=!e&&this._sessionHasBeenIdleTooLong(i,r);c||u||o?(s=this._sessionIdGenerator(),a=this._windowIdGenerator(),ea.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:o}}),n=i,l=!0):a||(a=this._windowIdGenerator(),l=!0);var d=0===r||!e||o?i:r,_=0===n?(new Date).getTime():n;return this._setWindowId(a),this._setSessionId(s,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(s,a,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:o}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:_,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:o}:void 0,lastActivityTimestamp:r}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{var[e]=this._getSessionId();if(this._sessionHasBeenIdleTooLong((new Date).getTime(),e)){var t=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var ia=["$set_once","$set"],ra=Pe("[SiteApps]");class sa{constructor(e){this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,s,n,a,o,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))u[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,ia),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(o=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(ra.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null==(i=this._stopBuffering)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,ra.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{s(e)}});n&&(t.processEvent=n),r=!0}catch(t){ra.error("Error while initializing PostHog app with config id "+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){ra.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(t){ra.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void ra.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;v["__$$ph_site_app_"+e]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,o,(t=>{if(t)return ra.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:a,url:o}of e.siteApps)n(a)}else ra.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var na=["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"],aa=function(e,t){if(!e)return!1;var i=e.toLowerCase();return na.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},oa=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&aa(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>aa(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},la=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ca="i.posthog.com";class ua{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ca,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=la.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=la.EU:this._regionCache[this.apiHost]=la.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if(this.region===la.CUSTOM)return this.apiHost+t;var i=ca+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var da={icontains:(e,t)=>!!s&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!s&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!s&&Yr(t.href,e),not_regex:(e,t)=>!!s&&!Yr(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class _a{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{_a._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)_a._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e);var r=t._instance.getFeatureFlag(e.feature_flag_key);T(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];_a._matchesTestVariant(n)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())_a._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(A(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();_a._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=_a.getWindowLocation();if(null!=e&&e.search){var t=ri(null==e?void 0:e.search,"__experiment_id"),i=ri(null==e?void 0:e.search,"__experiment_variant");t&&i&&(_a._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(_a._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e){return!A(e.conditions)&&(_a._matchUrlConditions(e)&&_a._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(A(e.conditions)||A(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=_a.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||da[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==s?void 0:s.location}static _matchUTMConditions(e){var t;if(A(e.conditions)||A(null==(t=e.conditions)?void 0:t.utm))return!0;var i=tn();if(i.utm_source){var r,s,n,a,o,l,c,u,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=e.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,h=null==(o=e.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];ke.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?_a._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var r;_a._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):_a._logInfo("Control variants leave the page unmodified.")}_is_bot(){return c&&this._instance?oa(c,this._instance.config.custom_blocked_useragents):void 0}}var ha=Pe("[PostHog ExternalIntegrations]"),pa={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class ga{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return ha.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;(!r||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(pa[t],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=v.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t])&&(null==(n=v.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var va="[SessionRecording]",fa=Pe(va);class ma{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){return this._lazyLoadedSessionRecording?this._lazyLoadedSessionRecording.status:this._receivedFlags&&!this._isRecordingEnabled?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw fa.error("started without valid sessionManager"),new Error(va+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(va+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(Qe))||!e.enabled),i=!this._instance.config.disable_session_recording,r=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return s&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!R(Object.assign)&&!R(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),fa.info("starting")):this.stopRecording()}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(null!=v&&null!=(t=v.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return fa.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(et)}_persistRemoteConfig(e){if(this._instance.persistence){var t,r,s=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=null==t?void 0:t.sampleRate,n=A(r)?null:parseFloat(r);A(n)&&this._resetSampling();var a=null==t?void 0:t.minimumDurationMilliseconds;s.register({[Qe]:i({enabled:!!t},t,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:R(a)?null:a,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this._persistRemoteConfig(e),this._receivedFlags=!0,this.startIfEnabledOrStop()):this._receivedFlags=!0:fa.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):fa.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(Qe);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_onScriptLoaded(e){var t,i;if(null==(t=v.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture);this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e;null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t;null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}var ya={},ba=()=>{},wa="posthog",Ea=!Hr&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),Sa=e=>{var t;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Ne(null==u?void 0:u.location),persistence:"localStorage+cookie",persistence_name:"",loaded:ba,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:"2025-05-24"!==e||"history_change",capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",debug:d&&T(null==d?void 0:d.search)&&-1!==d.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==s||null==(t=s.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;ke.error(t)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Gn},error_tracking:{},_onCapture:ba,__preview_eager_load_replay:!1}},xa=e=>{var t={};R(e.process_person)||(t.person_profiles=e.process_person),R(e.xhr_headers)||(t.request_headers=e.xhr_headers),R(e.cookie_name)||(t.persistence_name=e.cookie_name),R(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),R(e.store_google)||(t.save_campaign_params=e.store_google),R(e.verbose)||(t.debug=e.verbose);var i=Re({},t,e);return P(e.property_blacklist)&&(R(e.property_denylist)?i.property_denylist=e.property_blacklist:P(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:ke.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class ka{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){ke.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Pa{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new ka,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new On,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Sa(),this.SentryIntegration=Vi,this.sentryIntegration=e=>function(e,t){var i=Wi(e,t);return{name:zi,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new wn(this),this.toolbar=new Xi(this),this.scrollManager=new Xn(this),this.pageViewManager=new ar(this),this.surveys=new Hn(this),this.experiments=new _a(this),this.exceptions=new Zr(this),this.rateLimiter=new zn(this),this.requestRouter=new ua(this),this.consent=new Oi(this),this.externalIntegrations=new ga(this),this.people={set:(e,t,i)=>{var r=T(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=T(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>ke.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==wa){var r,s=null!==(r=ya[i])&&void 0!==r?r:new Pa;return s._init(e,t,i),ya[i]=s,ya[wa][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var n,a;if(void 0===t&&(t={}),R(e)||O(e))return ke.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return ke.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config(Re({},Sa(t.defaults),xa(t),{name:r,token:e})),this.config.on_xhr_error&&ke.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Zt.GZipJS;var o=this._is_persistence_disabled();this.persistence=new Sn(this.config,o),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sn(i({},this.config,{persistence:"sessionStorage"}),o);var l=i({},this.persistence.props),c=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Yn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Kn(this),this.__request_queue=[];var u="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(u||(this.sessionManager=new ta(this),this.sessionPropsManager=new Zn(this,this.sessionManager,this.persistence)),new Zi(this).startIfEnabledOrStop(),this.siteApps=new sa(this),null==(n=this.siteApps)||n.init(),u||(this.sessionRecording=new ma(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new di(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new nr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new ir(this),this.exceptionObserver=new qi(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Di(this,Mi),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Ui(this),this.historyAutocapture.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&ke.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:c}),void 0!==(null==(a=t.bootstrap)?void 0:a.distinctID)){var d,_,h=this.config.get_device_id(mi()),p=null!=(d=t.bootstrap)&&d.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(ct,null!=(_=t.bootstrap)&&_.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:p})}if(this._hasBootstrappedFeatureFlags()){var g,v,m=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlags)||{}).filter((e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])})).reduce(((e,i)=>{var r;return e[i]=(null==(r=t.bootstrap)||null==(r=r.featureFlags)?void 0:r[i])||!1,e}),{}),y=Object.keys((null==(v=t.bootstrap)?void 0:v.featureFlagPayloads)||{}).filter((e=>m[e])).reduce(((e,i)=>{var r,s;null!=(r=t.bootstrap)&&null!=(r=r.featureFlagPayloads)&&r[i]&&(e[i]=null==(s=t.bootstrap)||null==(s=s.featureFlagPayloads)?void 0:s[i]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:m,featureFlagPayloads:y})}if(u)this.register_once({distinct_id:ft,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(mi());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(ct,"anonymous")}return je(s,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Bi(this,(()=>this._loaded())):this._loaded(),I(this.config._onCapture)&&this.config._onCapture!==ba&&(ke.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&ke.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}_onRemoteConfig(e){var t,i,r,s,n,a,o,l;if(!u||!u.body)return ke.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=y(e.supportedCompression,Zt.GZipJS)?Zt.GZipJS:y(e.supportedCompression,Zt.Base64)?Zt.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(r=this.sessionRecording)||r.onRemoteConfig(e),null==(s=this.autocapture)||s.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(o=this.exceptionObserver)||o.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(l=this.deadClicksAutocapture)||l.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){ke.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this._captureInitialPageview()}),1),new Vn(this).load(),this.featureFlags.flags()}_start_queue_if_opted_in(){var e;this.is_capturing()&&(this.config.request_batching&&(null==(e=this._requestQueue)||e.enable()))}_dom_loaded(){this.is_capturing()&&Ce(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null==(e=this._requestQueue)||e.unload(),null==(t=this._retryQueue)||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Ea?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=zr(e.url,{ip:this.config.ip?1:0}),e.headers=i({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,r,s,n=i({},e);n.timeout=n.timeout||6e4,n.url=zr(n.url,{_:(new Date).getTime().toString(),ver:f.LIB_VERSION,compression:n.compression});var a=null!==(t=n.transport)&&void 0!==t?t:"fetch",o=Gr.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=qe(o,(e=>e.transport===a)))?void 0:s.method)&&void 0!==r?r:o[0].method;if(!l)throw new Error("No available transport method");l(n)})(i({},e,{callback:t=>{var i,r;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null==(i=(r=this.config).on_request_error)||i.call(r,t));null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],r=[],s=[];Ce(e,(e=>{e&&(t=e[0],P(t)?s.push(e):I(e)?e.call(this):P(e)&&"alias"===t?i.push(e):P(e)&&-1!==t.indexOf("capture")&&I(this[t])?s.push(e):r.push(e))}));var n=function(e,t){Ce(e,(function(e){if(P(e[0])){var i=t;Fe(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(r,this),n(s,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!R(e)&&T(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var n=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){null!=t&&t.$current_url&&!T(null==t?void 0:t.$current_url)&&(ke.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,o=(null==r?void 0:r.timestamp)||a,l=mi(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},o,l)};n&&(c.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==r?void 0:r.$set)&&(c.$set=null==r?void 0:r.$set);var u,d=this._calculate_set_once_properties(null==r?void 0:r.$set_once);if(d&&(c.$set_once=d),(c=Me(c,null!=r&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=o,R(null==r?void 0:r.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=a),e===Rn.DISMISSED||e===Rn.SENT){var _=null==t?void 0:t[Tn.SURVEY_ID],h=null==t?void 0:t[Tn.SURVEY_ITERATION];u={id:_,current_iteration:h},localStorage.getItem(Nn(u))||localStorage.setItem(Nn(u),"true"),c.$set=i({},c.$set,{[Dn({id:_,current_iteration:h},e===Rn.SENT?"responded":"dismissed")]:!0})}var p=i({},c.properties.$set,c.$set);if(F(p)||this.setPersonPropertiesForFlags(p),!A(this.config.before_send)){var g=this._runBeforeSend(c);if(!g)return;c=g}this._internalEventEmitter.emit("eventCaptured",c);var v={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==r?void 0:r._batchKey};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(v):this._requestQueue.enqueue(v),c}ke.critical("This capture call is ignored due to client rate limiting.")}}else ke.error("No event name provided to posthog.capture")}else ke.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,n){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var a=n?void 0:this.persistence.remove_event_timer(e),o=i({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(o.$cookieless_mode=!0),"$snapshot"===e){var l=i({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=l.distinct_id,(!T(o.distinct_id)&&!M(o.distinct_id)||O(o.distinct_id))&&ke.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var c,d=dn(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(n,r.getTime());o.$session_id=_,o.$window_id=h}this.sessionPropsManager&&Re(o,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Re(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===la.CUSTOM&&(o.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),o=Re(o,c),"$pageview"===e&&u&&(o.title=u.title),!R(a)){var v=r.getTime()-a;o.$duration=parseFloat((v/1e3).toFixed(3))}g&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser"),(o=Re({},d,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),P(this.config.property_denylist)?Fe(this.config.property_denylist,(function(e){delete o[e]})):ke.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(ke.error("sanitize_properties is deprecated. Use before_send instead"),o=f(o,e));var m=this._hasPersonProcessing();return o.$process_person_profile=m,m&&!n&&this._requirePersonProcessing("_calculate_event_properties"),o}_calculate_set_once_properties(e){var t;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var i=this.persistence.get_initial_props(),r=null==(t=this.sessionPropsManager)?void 0:t.getSetOnceProps(),s=Re({},i,r||{},e||{}),n=this.config.sanitize_properties;return n&&(ke.error("sanitize_properties is deprecated. Use before_send instead"),s=n(s,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,F(s)?void 0:s}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=jn),this.surveys.displaySurvey(e,t)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return ke.uninitializedWarning("posthog.identify");if(M(e)&&(e=e.toString(),ke.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))ke.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==ft){if(this._requirePersonProcessing("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==s&&e!==this.get_property(He)&&(this.unregister(He),this.register({distinct_id:e}));var a="anonymous"===(this.persistence.get_property(ct)||"anonymous");e!==s&&a?(this.persistence.set_property(ct,"identified"),this.setPersonPropertiesForFlags(i({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:r||{}}),this._cachedPersonProperties=Jr(e,t,r),this.featureFlags.setAnonymousDistinctId(s)):(t||r)&&this.setPersonProperties(t,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(lt))}}else ke.critical('The string "'+ft+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else ke.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var r=Jr(this.get_distinct_id(),e,t);this._cachedPersonProperties!==r?(this.setPersonPropertiesForFlags(i({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=r):ke.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){if(this._requirePersonProcessing("posthog.group")){var s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),s[e]===t||r||this.reloadFeatureFlags()}}else ke.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,s;if(ke.info("reset"),!this.__loaded)return ke.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(r=this.persistence)||r.set_property(ct,"anonymous"),null==(s=this.sessionManager)||s.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:ft,$device_id:null},"");else{var a=this.config.get_device_id(mi());this.register_once({distinct_id:a,$device_id:e?a:n},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(Ue)?(ke.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(R(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(He,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(ke.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(C(e)){var r,s,n,a,o;Re(this.config,xa(e));var l=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,l),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sn(i({},this.config,{persistence:"sessionStorage"}),l),ki._is_supported()&&"true"===ki._get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(f.DEBUG=!0,ke.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})),null==(s=this.sessionRecording)||s.startIfEnabledOrStop(),null==(n=this.autocapture)||n.startIfEnabled(),null==(a=this.heatmaps)||a.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(o=this.externalIntegrations)||o.startIfEnabledOrStop()}}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var r,s,n,a,o;if(null==(r=this.sessionManager)||r.checkAndGetSessionAndWindowId(),i.sampling)null==(s=this.sessionRecording)||s.overrideSampling();if(i.linked_flag)null==(n=this.sessionRecording)||n.overrideLinkedFlag();if(i.url_trigger)null==(a=this.sessionRecording)||a.overrideTrigger("url");if(i.event_trigger)null==(o=this.sessionRecording)||o.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,t))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:wa;return t!==wa&&(t=wa+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ct))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ct))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&F(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[He])&&(null==(t=this.persistence)||null==(t=t.props)||!t[gt]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(ke.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(gt,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s));(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s));return s}opt_in_capturing(e){if("always"!==this.config.cookieless_mode){var t;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new ta(this),this.persistence&&(this.sessionPropsManager=new Zn(this,this.sessionManager,this.persistence)),this.sessionRecording=new ma(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),R(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(t=null==e?void 0:e.captureEventName)&&void 0!==t?t:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else ke.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:ft,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):ke.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===$i.GRANTED?"granted":e===$i.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return c?oa(c,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){u&&("visible"===u.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:u.title},{send_instantly:!0}),this._visibilityStateListener&&(u.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),je(u,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==s||s.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==s||s.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_shouldDisableFlags(){var e,t,i,r,s,n,a,o=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(ke.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",r=!1,s=ke,n=(t="advanced_disable_flags")in(e=o)&&!R(e[t]),a=i in e&&!R(e[i]),n?e[t]:a?(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):r)}_runBeforeSend(e){if(A(this.config.before_send))return e;var t=P(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),A(i)){var s="Event '"+e.event+"' was rejected in beforeSend function";return q(e.event)?ke.warn(s+". This can cause unexpected behavior."):ke.info(s),null}i.properties&&!F(i.properties)||ke.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Le(e.prototype[t[i]])}(Pa,["identify"]);var Ia,Ca=(Ia=ya[wa]=new Pa,function(){function e(){e.done||(e.done=!0,Ea=!1,Fe(ya,(function(e){e._dom_loaded()})))}null!=u&&u.addEventListener?"complete"===u.readyState?e():je(u,"DOMContentLoaded",e,{capture:!1}):s&&ke.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Ia);export{Qt as COPY_AUTOCAPTURE_EVENT,Zt as Compression,$n as DisplaySurveyType,Pa as PostHog,Rn as SurveyEventName,Tn as SurveyEventProperties,kn as SurveyPosition,Cn as SurveyQuestionBranchingType,In as SurveyQuestionType,Fn as SurveySchedule,Pn as SurveyType,xn as SurveyWidgetType,Ca as default,Ca as posthog,ei as severityLevels};
|
|
2
2
|
//# sourceMappingURL=module.no-external.js.map
|