posthog-js 1.429.2 → 1.429.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/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.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/conversations.js +1 -1
- package/dist/customizations.d.ts +2 -0
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/dead-clicks-autocapture.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/default-extensions.js.map +1 -1
- package/dist/exception-autocapture.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/extension-bundles.js.map +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +2 -0
- package/dist/module.full.d.ts +2 -0
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +2 -0
- 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.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/module.no-external.d.ts +2 -0
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.js.map +1 -1
- package/dist/module.slim.no-external.d.ts +2 -0
- package/dist/module.slim.no-external.js +1 -1
- package/dist/module.slim.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/src/extensions/surveys.d.ts +2 -0
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.d.ts +2 -0
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/surveys.d.ts +2 -0
- package/lib/src/extensions/surveys.js +18 -1
- package/lib/src/extensions/surveys.js.map +1 -1
- package/lib/src/feature-flags-config.js +5 -5
- package/lib/src/feature-flags-config.js.map +1 -1
- package/lib/src/posthog-core.js +3 -7
- package/lib/src/posthog-core.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t=["$set_once","$set"];function i(){return i=Object.assign?Object.assign.bind():function(t){for(var i=1;arguments.length>i;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},i.apply(null,arguments)}function e(t,i,e,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void e(t)}o.done?i(l):Promise.resolve(l).then(r,s)}function r(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)})}}var s=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function n(t,i){return-1!==t.indexOf(i)}var a=function(t){return t.trim()},o=Object.prototype,l=o.hasOwnProperty,u=o.toString,h=Array.isArray||function(t){return"[object Array]"===u.call(t)},v=t=>"function"==typeof t,d=t=>t===Object(t)&&!h(t),c=t=>{if(d(t)){for(var i in t)if(l.call(t,i))return!1;return!0}return!1},f=t=>void 0===t,p=t=>"[object String]"==u.call(t),g=t=>p(t)&&0===t.trim().length,_=t=>null===t,b=t=>f(t)||_(t),m=t=>"[object Number]"==u.call(t)&&t==t,y=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function S(t,i){return{}.toString.call(t)==="[object "+i+"]"}function x(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return E(t,Error)}}function k(t){return"u">typeof Event&&E(t,Event)}function E(t,i){try{return t instanceof i}catch(t){return!1}}var F=["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","pinterestbot","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"],P=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return F.concat(i).some(t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)})};function C(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),m(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),C(null!=s?s:e,i,e,r))}var T=class{constructor(t){this.C={},this.I=t.I,this.R=C(t.bucketSize,0,100,t.$),this.A=C(t.refillRate,0,this.R,t.$),this.O=C(t.refillInterval,0,864e5,t.$)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.C[r];return s?this.F(s,e):this.C[r]=s={tokens:this.R,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.I)||i.call(this,t)),0===s.tokens)}stop(){this.C={}}},R="Mobile",A="Android",O="Nintendo",M="PlayStation",I="Xbox",j="Windows";R.toLowerCase(),"Tablet".toLowerCase(),new RegExp(I,"i");var D,L,N,B=new RegExp("BlackBerry|PlayBook|BB10","i"),z={"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"},H=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[I,t&&t[1]||""]],[new RegExp(O,"i"),[O,""]],[new RegExp(M,"i"),[M,""]],[B,["BlackBerry",""]],[new RegExp(j,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return["Windows Phone",""];if(new RegExp(R).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=z[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[j,r]}return[j,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=f(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[A,[t[2],t[3],t[4]||"0"].join(".")]:[A,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],U="[Truncated]",V="[Unserializable]";function q(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}function W(t){return t?t.split("#")[0]:t}function K(t,i){var e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function J(t,i,e){return G.apply(this,arguments)}function G(){return(G=r(function*(t,i,e){var r;try{return yield Promise.race([t,new Promise((t,s)=>{r=K(()=>{try{null==e||e(),t()}catch(t){s(t)}},i)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function X(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return N&&e.length===L?N:(L=e.length,N=e.reduce((e,r)=>{D||(D={});var s=D[r];if(s)e[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o,l=null==(o=n[a])?void 0:o.filename,u=i[r];if(l&&u){e[l]=u,D[r]=[l,u];break}}return e},{}))}}Date,Date;var Z=class{constructor(t,i,e){void 0===e&&(e=[]),this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i){void 0===i&&(i={});var e=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(e,i,0).apply(t),s=this.buildParsingContext(i),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,e),$exception_level:"error"}}modifyFrames(t){var i=this;return r(function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&h(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,e){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(var e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return r(function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e})()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,i({},e,{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:X(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}};function Q(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:!!i&&!i.startsWith("webkit-masked-url://")&&"<anonymous>"!==i};return f(r)||(n.lineno=r),f(s)||(n.colno=s),n}var Y=(t,i)=>{var e=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return e||r?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},tt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,it=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,et=/\((\S*)(?::(\d+))(?::(\d+))\)/,rt=(t,i)=>{var e=tt.exec(t);if(e)return Q(i,e[1],"?",+e[2],+e[3]);var r=it.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=et.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=Y(r[1]||"?",r[2]);return Q(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},st=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,nt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,at=(t,i)=>{var e=st.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=nt.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}var s=e[3],n=e[1]||"?",a=Y(n,s);return Q(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ot=/\(error: (.*)\)/;function lt(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function ut(t){for(var i=1;10>=i;i++){var e=t.length-2*i;if(0>e)break;for(var r=!0,s=0;i>s;s++)if(!lt(t[e+s],t[e+i+s])){r=!1;break}if(r){for(var n=0;i>n;n++)t[e+n]=t[e+i+n];return t.length=e+i,{start:e,length:i}}}}function ht(t,i){var e=i.start+i.length,r=dt(t,i);r&&t.splice(e+r===t.length?e:i.start,r)}function vt(t,i){for(var e=i.start;e>0&<(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function dt(t,i){for(var e=i.start+i.length,r=e;t.length>r&<(t[r],t[r-i.length]);)r++;return r-e}function ct(t,i){var e=i[0],r=t.length-(e?vt(t,e):0);for(var s of i)r-=dt(t,s);return r}function ft(t,i,e){for(var r=0;t.length>r;r++){var s=t[(i+r)%t.length],n=t[(e+r)%t.length];if(s!==n)return n>s}return!1}var pt=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=p(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?i+": "+t.message:i}isDOMException(t){return S(t,"DOMException")}isDOMError(t){return S(t,"DOMError")}},gt=class{match(t){return x(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}},_t=class{match(t){return!!S(t,"ErrorEvent")&&(null!=t.error||this.sr(t))}coerce(t,e){var r;if(null!=t.error)return e.apply(t.error);var s=e.apply(t.message);return i({},s,{stack:null!==(r=this.ar(t))&&void 0!==r?r:s.stack,synthetic:!0})}sr(t){return p(t.message)&&t.message.length>0}ar(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(p(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}},bt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,mt=class{match(t){return"string"==typeof t}coerce(t,i){var e,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}getInfos(t){var i="Error",e=t,r=t.match(bt);return r&&(i=r[1],e=r[2]),[i,e]}},yt=["fatal","error","warning","log","info","debug"];function wt(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}var St=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,r,s=this.getErrorPropertyFromObject(t);return s?i.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null==(r=i.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(k(t))return t.constructor.name;var i="name"in t?t.name:void 0;return p(i)&&!g(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var i="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(i+=" with message: '"+t.message+"'"),i}if("message"in t&&"string"==typeof t.message)return t.message;var e=this.getObjectClassName(t);return(e&&"Object"!==e?"'"+e+"'":"Object")+" captured as exception with keys: "+wt(t)}isSeverityLevel(t){return p(t)&&!g(t)&&yt.indexOf(t)>=0}getStack(t){try{return p(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:p(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(x(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},xt=class{match(t){return k(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+wt(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},kt=class{match(t){return w(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Et=class{match(t){return S(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(t))return!1;try{var i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e,r=this.getUnhandledRejectionReason(t);return w(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}},Ft="$message",Pt="$timestamp",Ct=new Set([Ft,Pt]),Tt={enabled:!0,max_bytes:32768};function Rt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:Tt.enabled,max_bytes:Ot(t.max_bytes,Tt.max_bytes)}:i({},Tt)}var At=class{constructor(t){this.ts=[],this.es=0,this.Sr=Rt(t)}setConfig(t){this.Sr=Rt(t),this.ns()}add(t){var i=function(t){var i,e,r;try{r=[],i=null!==(e=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return"[Circular]";r.push(i)}return i}}))&&void 0!==e?e:"null"}catch(t){return}try{var s=JSON.parse(i);if(!d(s))return;var n=s,a=n[Ft],o=n[Pt];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!m(o))return;return{step:n,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.Sr.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.ns())}}getAttachable(){return this.ts.map(t=>t.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}ns(){for(;this.es>this.Sr.max_bytes&&this.ts.length>0;){var t=this.ts.shift();t&&(this.es-=t.bytes)}}};function Ot(t,i){if(!m(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var $t=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Mt(t){return"string"==typeof t||t}function It(t){return"string"==typeof t?t:void 0}var jt={}.propertyIsEnumerable;function Dt(t,i){try{return Bt(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Lt(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:U};if(e.remainingNodes--,y(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==i||i.debug("Attribute "+e+" is outside the int64 range; encoding it as a string"),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var s=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:q(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:U};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?q(a):String(a)}}e.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Lt(o.call(t),i,e,r+1)}catch(t){}return h(t)?{arrayValue:{values:Nt(t,i,e,r+1)}}:{kvlistValue:{values:Bt(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:q(String(t))}}function Nt(t,i,e,r){for(var s=[],n=Math.min(t.length,1e3),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(b(o))continue;s.push(Lt(o,i,e,r))}catch(t){s.push({stringValue:V})}return t.length>a&&s.push({stringValue:U}),s}function Bt(t,i,e,r){var s=[];for(var n in t)if(jt.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(_(a)||f(a))continue;s.push({key:q(n),value:Lt(a,i,e,r)})}catch(t){s.push({key:q(n),value:{stringValue:V}})}}return s}function zt(t,e,r){return i({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}var Ht={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var Ut={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Vt=Ut.info;function qt(t){try{return q(String(t))}catch(t){return V}}function Wt(t,e,r,s){var n,a=Ut[t.level||"info"]||Vt,o=a.text,l=a.number,u=(void 0===(n=m(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),h={};e.distinctId&&(h.posthogDistinctId=e.distinctId),e.sessionId&&(h.sessionId=e.sessionId),e.windowId&&(h["window.id"]=e.windowId),b(e.sessionStartTimestamp)||(h.sessionStartTimestamp=String(e.sessionStartTimestamp)),b(e.lastActivityTimestamp)||(h.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(h["url.full"]=e.currentUrl),e.screenName&&(h["screen.name"]=e.screenName),e.appState&&(h["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(h.feature_flags=e.activeFeatureFlags);var v=i({},h),d=t.attributes;if(d){var c=[];try{c=Object.keys(d)}catch(t){c=[]}for(var p of c){var g=void 0;try{g=d[p]}catch(t){g=V}Object.defineProperty(v,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:qt(t.body)},attributes:Dt(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),f(t.trace_flags)||(_.flags=t.trace_flags),_}function Kt(t,i,e){return zt(t,i,e)}function Jt(t,i,e,r){return{resourceLogs:[{resource:{attributes:Dt(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}var Gt=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Sr=i,this.$=e,this.ss=r,this.rs=s,this.ls=n,this.us=a,this.hs=null,this.cs=0,this.ds=0,this.vs=0,this.fs=0,this.ps=0,this.gs=!1,this.ys=i.maxBufferSize,this.bs=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this._s=i.flushIntervalMs,this.ws=i.maxBatchRecordsPerPost,this.ks=i.rateCapWindowMs,this.Ss=i.maxLogsPerInterval}clearQueue(){this.ds++,this._instance.setPersistedProperty(s.LogsQueue,[])}reset(){this.xs(),this.fs=0,this.ps=0,this.gs=!1,this.vs=0,this.ws=this.Sr.maxBatchRecordsPerPost}onReconnect(){this.vs=0,this.Cs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.$s(t);if(null!==r)if(r.body){if(this.Ts()){var s={record:Wt(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.ss(),this.$,null==i?void 0:i.occurredAtMs)};this.rs(()=>this.Is(s))}}else this.$.info("Log was rejected in beforeSend function")}}$s(t){var i=this.Sr.beforeSend;if(!i)return t;var e=h(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.$.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.$.error("Error in beforeSend function for log:",t),null}return r}Ts(){if(void 0===this.Ss)return!0;var t=Date.now(),i=t-this.fs;return this.ks>i&&i>=0||(this.fs=t,this.ps=0,this.gs=!1),this.Ss>this.ps?(this.ps++,!0):(this.gs||(this.$.warn("captureLog dropping logs: exceeded "+this.Ss+" logs per "+this.ks+"ms"),this.gs=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.hs||(t.hs=t.Ms().finally(()=>{t.hs=null})),t.hs})()}Ms(){var t=this;return r(function*(){var i;t.xs();var e=null!==(i=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,n=0;e.length>0&&r>n;){var a,o,l=t.ds;t.cs=0;var u=Math.min(e.length,t.ws),h=e.slice(0,u),v=Jt(h.map(t=>t.record),t.Es(),null!==(a=t.us)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.Ps(v);if(t.ds!==l)return;if("too-large"===d.kind&&h.length>1)t.ws=Math.max(1,Math.floor(h.length/2)),t.$.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.ws);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.$.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.Sr.maxBatchRecordsPerPost>t.ws&&(t.ws=Math.min(t.Sr.maxBatchRecordsPerPost,t.ws+1)),yield t.Rs(h.length),e=null!==(o=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==o?o:[],n+=h.length,"fatal"===d.kind)throw d.error}}})()}Rs(t){var i=this;return r(function*(){var e,r=Math.max(0,t-i.cs),n=null!==(e=i._instance.getPersistedProperty(s.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(s.LogsQueue,n.slice(r)),yield i.ls()})()}Es(){return Kt(this.Sr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Is(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];this.bs>e.length||(e.shift(),this.cs++,this.$.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(s.LogsQueue,e),this.ys>e.length?this.As():this.Cs()}}As(t){void 0===t&&(t=this._s),this.Fs||(this.Fs=K(()=>{this.Fs=void 0,this.Cs()},t))}Os(){var t=Math.min(Math.max(0,this.vs-1),6);return this._s*Math.pow(2,t)}Ds(){var t=this._instance.getPersistedProperty(s.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return r(function*(){i.xs();var e=i.flush().catch(()=>{});void 0!==t?yield J(e,t):yield e})()}flushWithTimeout(t){var i=this;return r(function*(){var e=i.flush();yield J(e,t,()=>{e.catch(()=>{})})})()}Cs(){this.flush().then(()=>{this.vs=0},t=>{this.vs++,this.$.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ds()&&this.As(this.Os())})}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}},Xt=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Zt(t){return String(t)+"000000"}function Qt(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}var Yt=class{constructor(t,i,e){this._instance=t,this.Sr=i,this.$=e,this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Bs=0}count(t,i,e){void 0===i&&(i=1),this.Hs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Hs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Hs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,i=this.hs,e=function(){var e=r(function*(){i&&(yield i.catch(()=>{})),yield t.zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.hs===e&&(this.hs=null)});return this.hs=e,e}drainWindow(){if(0===this.Ls.size)return null;var t=this.Ls;return this.Ls=new Map,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Us(t)}reset(){this.Bs++,this.xs(),this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set}Hs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.$s(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.$.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=e.attributes?i({},e.attributes):void 0,s=Qt(e.type,e.name,e.unit,r)}catch(t){return void this.$.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var n=this.Ls.get(s);if(!n){if(!this.Ws())return;n={name:e.name,type:e.type,unit:e.unit,attributes:r,windowStartMs:Date.now()},this.Ls.set(s,n)}var a=this.qs.get(e.name);void 0===a?this.qs.set(e.name,e.type):a===e.type||this.js.has(e.name)||(this.js.add(e.name),this.$.warn("Metric name '"+e.name+"' is already used as a "+a+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Vs(n,e.value),this.As()}else this.$.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.$.warn("Dropping metric with empty name")}}Ws(){return this.Sr.maxSeriesPerFlush>this.Ls.size||(this.Ns||(this.Ns=!0,this.$.warn("Metric series cap reached ("+this.Sr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Vs(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Xt.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=i,r.min=Math.min(r.min,i),r.max=Math.max(r.max,i),r.bucketCounts[function(t,i){for(var e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Xt)]+=1}}$s(t){var i=this.Sr.beforeSend;if(!i)return t;var e=h(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.$.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.$.error("Error in beforeSend function for metric:",t),null}return r}As(){this.Fs||(this.Fs=K(()=>{this.Fs=void 0,this.flush().catch(t=>{this.$.error("Metrics flush failed:",t)})},this.Sr.flushIntervalMs))}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}zs(){var t=this;return r(function*(){if(0!==t.Ls.size){var i=t.Ls;t.Ls=new Map,t.Ns=!1,t.qs=new Map,t.js=new Set;var e=t.Bs,r=yield t._instance.Gs(t.Us(i));if(e===t.Bs)switch(r.kind){case"ok":return;case"retry-later":return t.Zs(i),void t.As();case"too-large":return void t.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.$.error("Failed to send metrics batch:",r.error)}}})()}Us(t){return i=this.Qs(t),e=function(t,i,e){return zt(t,i,e)}(this.Sr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Dt(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Qs(t){var e=Zt(Date.now()),r=new Map;for(var s of t.values()){var n,a=Qt(s.type,s.name,s.unit,void 0),o=r.get(a);o||(o=i({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Dt(null!==(n=s.attributes)&&void 0!==n?n:{},this.$),u=Zt(s.windowStartMs);if("count"===s.type){var h,v={attributes:l,startTimeUnixNano:u,timeUnixNano:e,asDouble:null!==(h=s.total)&&void 0!==h?h:0};o.sum.dataPoints.push(v)}else if("gauge"===s.type){var d,c={attributes:l,timeUnixNano:e,asDouble:null!==(d=s.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(c)}else s.hist&&o.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:e,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:Xt})}return Array.from(r.values())}Zs(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.Ls.get(s);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,n.windowStartMs),a.type){case"count":a.total=(null!==(i=a.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(a.hist){a.hist.count+=n.hist.count,a.hist.sum+=n.hist.sum,a.hist.min=Math.min(a.hist.min,n.hist.min),a.hist.max=Math.max(a.hist.max,n.hist.max);for(var o=0;a.hist.bucketCounts.length>o;o++)a.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else a.hist=n.hist}else this.Ws()&&this.Ls.set(s,n)}}},ti="0.8.2",ii={DEBUG:!1,LIB_VERSION:ti,LIB_NAME:"browser-common",JS_SDK_VERSION:ti},ei="u">typeof window?window:void 0,ri="u">typeof globalThis?globalThis:ei,si=null==ri?void 0:ri.navigator,ni=null==ri?void 0:ri.document,ai=null==ri?void 0:ri.location;function oi(){return!(!ei||!1===ei.navigator.onLine)}null!=ri&&ri.XMLHttpRequest&&new ri.XMLHttpRequest;var li=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={N(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;r>n;n++)s[n-1]=arguments[n];ei&&(ii.DEBUG||ei.POSTHOG_DEBUG||e)&&!f(ei.console)&&ei.console&&("__rrweb_original__"in ei.console[i]?ei.console[i].__rrweb_original__:ei.console[i])(t,...s)},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("error",...i)},critical(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];console.error(t,...e)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(i,e)=>li(t+" "+i,e)};return r},ui=li("[PostHog.js]"),hi=ui.createLogger;function vi(t,i){if(!b(t))if(h(t))t.forEach(i);else if(t instanceof FormData)t.forEach((t,e)=>i(t,e));else for(var e in t)l.call(t,e)&&i(t[e],e)}var di=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];for(var s of e)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function ci(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var fi=function(t){try{return t()}catch(t){return}};function pi(t,i,e,r){var s=null!=r?r:{},n=s.capture,a=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===a||a})}function gi(t){return"ph_toolbar_internal"===t.name}function _i(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!v(r))return i;try{var s=r(i);return p(s)&&s?s:i}catch(t){return ui.error("Error in get_current_url, falling back to window.location.href",t),i}}function bi(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function mi(t){return!!t&&1===t.nodeType}function yi(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function wi(t){return!!t&&3===t.nodeType}function Si(t){return!!t&&11===t.nodeType&&mi(t.host)}function xi(t){return t?a(t).split(/\s+/):[]}function ki(t,i){var e=function(t){var i,e=null==ei||null==(i=ei.location)?void 0:i.href;return f(e)?void 0:_i(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Ei(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return xi(i)}function Fi(t){return b(t)?null:a(t).split(/(\s+)/).filter(t=>Xi(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Pi(t){var i="";return zi(t)&&!Hi(t)&&t.childNodes&&t.childNodes.length&&vi(t.childNodes,function(t){var e;wi(t)&&t.textContent&&(i+=null!==(e=Fi(t.textContent))&&void 0!==e?e:"")}),a(i)}function Ci(t){var i;return f(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var Ti=["a","button","form","input","select","textarea","label"];function Ri(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function Ai(t,i){if(f(i))return!0;var e,r=function(t){if(i.some(i=>Ri(t,i)))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function Oi(t){var i=t.parentNode;return!(!i||!mi(i))&&i}var $i=[".ph-no-autocapture","[data-ph-no-autocapture]"],Mi=["next","previous","prev",">","<"],Ii=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,ji=[".ph-no-rageclick",".ph-no-capture"],Di=["","text","search","email","password","url","tel","number"];function Li(t,i){if(!ei||Ni(t))return!1;var e,r,s,a,o;if(y(i)?(e=!!i&&ji,r=void 0,s=!1):(e=null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:ji,r=null==i?void 0:i.content_ignorelist,s=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(s&&function(t){return!(!t||!mi(t))&&(!!yi(t,"textarea")||(yi(t,"input")?n(Di,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var i=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===i||""===i}(t)))}(t))return!1;var l=Bi(t,!1).targetElementList;return!function(t,i){if(!1===t||f(t))return!1;var e;if(!0===t)e=Mi;else{if(!h(t))return!1;if(t.length>10)return ui.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(t=>{var i=t.safeText,r=t.ariaLabel;return e.some(t=>Ii(i,t)||Ii(r,t))})}(r,l.map(t=>{var i;return{safeText:Pi(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}}))&&!Ai(l,e)}var Ni=t=>!t||yi(t,"html")||!mi(t),Bi=(t,i)=>{if(!ei||Ni(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!yi(s,"body");)if(Si(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Oi(s);if(!n)break;if(i||Ti.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=ei.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function zi(t){for(var i=new Set,e=0,r=t;r.parentNode&&!yi(r,"body");r=r.parentNode){if(e++>=1e3||i.has(r))return!1;i.add(r);var s=Ei(r);if(n(s,"ph-sensitive")||n(s,"ph-no-capture"))return!1}if(n(Ei(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function Hi(t){return!!(yi(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||yi(t,"select")||yi(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ui=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Vi=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,qi=[16,15,14,13],Wi=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ki=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ji=/[0-9A-Za-z_]/;function Gi(t){for(var i=0,e=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;e&&(s*=2)>9&&(s-=9),i+=s,e=!e}return i%10==0}function Xi(t,i){if(void 0===i&&(i=!0),b(t))return!1;if(p(t)){if(t=a(t),i?Ui.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(Vi.lastIndex=0;i=Vi.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of qi){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(Ui.test(o)&&Gi(o))return!0}}}return!1}(t))return!1;if(i?Wi.test(t):function(t){var i;for(Ki.lastIndex=0;i=Ki.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&Ji.test(e)&&Ji.test(r)))return!0}return!1}(t))return!1}return!0}function Zi(t){var i=Pi(t);return Xi(i=(i+" "+Qi(t)).trim())?i:""}function Qi(t){var i="";return t&&t.childNodes&&t.childNodes.length&&vi(t.childNodes,function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=Pi(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+Qi(t)).trim())}catch(t){ui.error("[AutoCapture]",t)}}),i}function Yi(t){return t.replace(/"|\\"/g,'\\"')}function te(t){var i=t.attr__class;if(i)return h(i)?i:xi(i)}var ie=class{constructor(t){this.disabled=!1===t;var i=d(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}},ee="$autocapture_disabled_server_side",re="$heatmaps_enabled_server_side",se="$exception_capture_enabled_server_side",ne="$error_tracking_suppression_rules",ae="$error_tracking_capture_extension_exceptions",oe="$web_vitals_enabled_server_side",le="$dead_clicks_enabled_server_side",ue="$product_tours_enabled_server_side",he="$logs_capture_enabled_server_side",ve="$web_vitals_allowed_metrics",de="$session_recording_remote_config",ce="$replay_override_sampling",fe="$replay_override_linked_flag",pe="$enabled_feature_flags",ge="$active_feature_flags",_e="$early_access_features",be="$feature_flag_details",me="$feature_flag_payloads",ye="$feature_flag_request_id",we="$minimal_flag_called_events",Se="$override_feature_flags",xe="$override_feature_flag_payloads",ke="$stored_person_properties",Ee="$stored_group_properties",Fe="$surveys",Pe="$surveys_loaded_at",Ce="$surveys_activated",Te="$surveys_activated_session",Re="$surveys_activated_timestamps",Ae="ph_product_tours",Oe="$flag_call_reported",$e="$flag_call_reported_session_id",Me="$feature_flag_errors",Ie="$feature_flag_evaluated_at",je="$sdk_debug_recording_script_not_loaded",De="PostHog loadExternalDependency extension not found.",Le="visibilitychange",Ne="beforeunload",Be=function(t,i){for(var e,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===i){e=n;break}}if(!h(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){ui.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ze=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],v=0;l.length>v;v++){var d=l[v].split("=");h(d)&&(i.includes(d[0])?u.push(d[0]+"="+e):u.push(l[v]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},He=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Ue=(t,i)=>t>=i&&oi(),Ve=(t,i,e,r)=>{if(0===t){if(oi()){var s=i+1;return s===e&&r(),s}return i}return 0},qe="$copy_autocapture",We=hi("[AutoCapture]");function Ke(t,i){return i.length>t?i.slice(0,t)+"...":i}function Je(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!mi(i));return i}function Ge(t,e){var r,s,a=e.e,o=e.maskAllElementAttributes,l=e.maskAllText,u=e.elementAttributeIgnoreList,v=e.elementsChainAsString,d=e.disableCaptureUrlHashes;if(!mi(t))return{props:{}};for(var c=[t],g=new Set([t]),_=t;_.parentNode&&!yi(_,"body")&&1e3>c.length;)if(Si(_.parentNode)){var b=_.parentNode.host;if(g.has(b))break;g.add(b),c.push(b),_=b}else{if(!mi(_.parentNode))break;if(g.has(_.parentNode))break;g.add(_.parentNode),c.push(_.parentNode),_=_.parentNode}var m="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?c.findIndex(t=>yi(t,"button")||yi(t,"a")):-1;m>0&&(l=l||c.slice(0,m+1).some(t=>!zi(t)||Hi(t)));var y,w,S,x=[],k={},E=!1,F=!1;if(vi(c,t=>{var i=zi(t);if(yi(t,"a")){var e=t.getAttribute("href");E=!!(i&&e&&Xi(e))&&(d?W(e):e)}n(Ei(t),"ph-no-capture")&&(F=!0),x.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};Ti.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Ke(1024,Zi(t)):Ke(1024,Pi(t)));var o=Ei(t);o.length>0&&(a.classes=o.filter(function(t){return""!==t})),vi(t.attributes,function(e){var n;if((!Hi(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Xi(e.value)&&(!p(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=xi(o).join(" ")),a["attr__"+e.name]=Ke(1024,"href"===e.name&&s?W(o):o)}});for(var l=1,u=1,h=t;h=Je(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,d)),vi(function(t){if(!zi(t))return{};var i={};return vi(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&Xi(r)&&(i[e]=r)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(k,i)||(k[i]=t)})}),F)return{props:{},explicitNoCapture:F};if(m>0&&(t=c[m],x.splice(0,m)),l||(x[0].$el_text=yi(t,"a")||yi(t,"button")?Zi(t):Pi(t)),E){var P,C;x[0].attr__href=E;var T=null==(P=(t=>{var i=null==ni?void 0:ni.createElement("a");return f(i)?null:(i.href=t,i)})(E))?void 0:P.host,R=null==ei||null==(C=ei.location)?void 0:C.host;T&&R&&T!==R&&(y=E)}return{props:di((w=a.type,{$event_type:w,$ce_version:1}),v?{}:{$elements:x},{$elements_chain:(S=x,h(S)?function(t){return t.map(t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return ci(a).sort((t,i)=>{return(r=i[0])>(e=t[0])?-1:e>r?1:0;var e,r}).forEach(t=>{var i=t[1];return o[Yi(t[0].toString())]=Yi(i.toString())}),(s+=":")+ci(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:te(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return ci(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(S)):"")},null!=(r=x[0])&&r.$el_text?{$el_text:null==(s=x[0])?void 0:s.$el_text}:{},y&&"click"===a.type?{$external_click_url:y}:{},k),target:t}}var Xe=class{Js(){this.Ks=void 0,clearTimeout(this.Ys),this.Ys=void 0}Xs(t){var i;if(!zi(t))return!0;for(var e,r=null!==(i=this.so().css_selector_ignorelist)&&void 0!==i?i:$i,s=new Set,a=t,o=function(){if(s.size>=1e3||s.has(a))return{v:!0};s.add(a);var t=a,i=Ei(t);if(n(i,"ph-no-capture")||n(i,"ph-sensitive")||Hi(t)||r.some(i=>Ri(t,i)))return{v:!0};var e=a.parentNode;a=Si(e)?e.host:e&&mi(e)?e:null};a;)if(e=o())return e.v;return!1}oo(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var i=this.Ks;i&&(t.pointerId!==i.id||Math.abs(t.clientX-i.x)>5||Math.abs(t.clientY-i.y)>5?this.Js():"pointerup"===t.type&&(i.released=!0,this.Ys=setTimeout(()=>this.Js(),0)))}else{var e;this.Js();var r=Ci(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&mi(r)&&(this.Ks={target:r,excluded:this.Xs(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(e=this.lo)?void 0:e.distinctId})}else this.Js()}ao(t){var i,e=this.Ks;this.Js();var r=Ci(t);if(null!=e&&e.released&&e.target.isConnected&&e.distinctId===(null==(i=this.lo)?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&r&&(yi(r,"html")||yi(r,"body"))){var s;if(e.excluded)return null;var a=null!==(s=this.so().css_selector_ignorelist)&&void 0!==s?s:$i;return[r,null==ni?void 0:ni.documentElement,null==ni?void 0:ni.body].some(t=>{if(!t)return!1;var i=Ei(t);return n(i,"ph-no-capture")||n(i,"ph-sensitive")||!zi(t)||Hi(t)||a.some(i=>Ri(t,i))})?null:e.target}}constructor(t){this.uo=t,this.name="autocapture",this.ho=!1,this.co=null,this.do=!1,this.vo=!1,this.Sr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.fo=!1,this.uo.refresh(this.Sr),this.rageclicks=new ie(this.Sr.rageclick),this.po=null}setup(t){this.mo(),this.lo=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.fo?i.dispose():(this.yo=i,this.startIfEnabled())}dispose(){var t;this.fo||(this.fo=!0,this.lo=void 0,null==(t=this.yo)||t.dispose(),this.yo=void 0,this.bo())}so(){return this.uo.refresh(this.Sr),this.Sr}mo(){var t,i;return this.so(),this.Sr.url_allowlist=null==(t=this.Sr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Sr.url_ignorelist=null==(i=this.Sr.url_ignorelist)?void 0:i.map(t=>new RegExp(t)),this.Sr}_o(){if(this.isBrowserSupported()){if(ei&&ni){var t=this.wo=t=>{t=t||(null==ei?void 0:ei.event);try{if("blur"===t.type)return void this.Js();if(0===t.type.indexOf("pointer"))return void this.oo(t);var i="click"===t.type?this.ao(t):void 0;if(_(i))return;this.ko(t,"$autocapture",i)}catch(t){We.error("Failed to capture event",t)}};if(pi(ei,"blur",t),pi(ni,"submit",t,{capture:!0}),pi(ni,"change",t,{capture:!0}),pi(ni,"click",t,{capture:!0}),vi(["pointerdown","pointermove","pointerup","pointercancel"],i=>{pi(ni,i,t,{capture:!0})}),this.so().capture_copied_text){var i=this.So=t=>{t=t||(null==ei?void 0:ei.event);try{this.ko(t,qe)}catch(t){We.error("Failed to capture clipboard event",t)}};pi(ni,"copy",i,{capture:!0}),pi(ni,"cut",i,{capture:!0}),pi(ni,"paste",i,{capture:!0})}}}else We.info("Disabling Automatic Event Collection because this browser is not supported")}bo(){this.Js(),this.wo&&(null==ei||ei.removeEventListener("blur",this.wo),vi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==ni||ni.removeEventListener(t,this.wo,!0)}),null==ni||ni.removeEventListener("submit",this.wo,!0),null==ni||ni.removeEventListener("change",this.wo,!0),null==ni||ni.removeEventListener("click",this.wo,!0),this.wo=void 0),this.So&&(null==ni||ni.removeEventListener("copy",this.So,!0),null==ni||ni.removeEventListener("cut",this.So,!0),null==ni||ni.removeEventListener("paste",this.So,!0),this.So=void 0),this.ho=!1}startIfEnabled(){this.isEnabled||this.Js(),!this.fo&&this.lo&&this.isEnabled&&!this.ho&&(this._o(),this.ho=!0)}onRemoteConfig(t){if(!this.fo)if(this.do=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.vo=i.elementsChainAsString);var e,r=i.autocapture_opt_out;y(r)&&(null==(e=this.lo)||e.kv.set(ee,r),this.co=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.po=t}getElementSelectors(t,i){var e,r=[];return null==(e=this.po)||e.forEach(e=>{var s;null==ni||null==(s=ni.querySelectorAll(e))||s.forEach(s=>{t!==s&&i!==s||n(r,e)||r.push(e)})}),r}get isEnabled(){var t,i;if(this.fo)return!1;var e=null==(t=this.lo)?void 0:t.kv.get(ee),r=this.co,s=this.so();if(!s.remoteRequestsDisabled&&!this.do)return!1;var n=s.remoteRequestsDisabled&&!this.do;if(_(r)&&!y(e)&&!n)return!1;var a=null!==(i=this.co)&&void 0!==i?i:!!e;return!!s.enabled&&!a}ko(t,e,r){if(void 0===e&&(e="$autocapture"),this.isEnabled){var s=r||Ci(t);wi(s)&&(s=s.parentNode||null);var n,a=this.mo();"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&a.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Li(s,a.rageclick)&&this.ko(t,"$rageclick",r);var o=e===qe,l=o?i({},a,{dom_event_allowlist:void 0}):a;if(s&&function(t,i,e,r,s,n){var a;if(!ei||Ni(t))return!1;if(null!=e&&e.url_allowlist&&!ki(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&ki(e.url_ignorelist,n))return!1;if(null!=e&&e.dom_event_allowlist){var o=e.dom_event_allowlist;if(o&&!o.some(t=>i.type===t))return!1}var l=Bi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(f(e))return!0;var r,s=function(t){if(e.some(i=>t.tagName.toLowerCase()===i))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(h,e))return!1;if(!Ai(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Ai(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:$i))return!1;try{var v=ei.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return u?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(Ti.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:a.getCurrentUrl}})){var u,h=Ge(s,{e:t,maskAllElementAttributes:a.maskAllElementAttributes,maskAllText:a.maskAllText,elementAttributeIgnoreList:a.element_attribute_ignorelist,elementsChainAsString:this.vo,disableCaptureUrlHashes:a.disableCaptureUrlHashes}),v=h.props;if(h.explicitNoCapture)return!1;var d=this.getElementSelectors(s,h.target);if(d&&d.length>0&&(v.$element_selectors=d),e===qe){var c=t.type||"clipboard";if("paste"!==c){var p,g,_=null==ei||null==(p=ei.getSelection())?void 0:p.toString(),b=Fi(_);if(!b)return!1;v.$selected_content=b,v.$clipboard_text_length=null!==(g=null==_?void 0:_.length)&&void 0!==g?g:0}v.$copy_type=c}return null==(u=this.lo)||u.capture(e,v).catch(t=>We.error("Failed to capture event",t)),!0}}else this.Js()}isBrowserSupported(){return v(null==ni?void 0:ni.querySelectorAll)}},Ze=class{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=d(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance._shouldDisableFlags(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}},Qe="undefined"!=typeof globalThis?globalThis:ei;Qe&&"undefined"==typeof self&&(Qe.self=Qe),Qe&&"undefined"==typeof File&&(Qe.File=function(){});var Ye=null!=ei?ei:{},tr=hi("[Dead Clicks]"),ir=()=>!0,er=class{get lazyLoadedDeadClicksAutocapture(){return this.Mo}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[le]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Eo(()=>{this.Po()}):this.stop()}Eo(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?tr.error("failed to load script",i):t()})}Po(){var t;if(ni){if(!this.Mo&&null!=(t=Ye.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=d(this.instance.config.capture_dead_clicks)?i({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Mo=Ye.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Mo.start(ni),tr.info("starting...")}}else tr.error("`document` not found. Cannot start.")}stop(){this.Mo&&(this.Mo.stop(),this.Mo=void 0,tr.info("stopping..."))}},rr=hi("[ExceptionAutocapture]"),sr=()=>{},nr=t=>{var i;if(v(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function ar(t,i,e){try{if(!(i in t))return sr;var r={next:t[i]},s=e(function(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];return r.next.apply(this,i)});return v(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[i]=s,()=>{if(t[i]!==s)for(var e=t[i],n=nr(e);n;){if(n.next===s)return void(n.next=r.next);n=nr(e=n.next)}else t[i]=r.next}}catch(t){return sr}}var or=hi("[TracingHeaders]"),lr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ur=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...lr],hr="<masked>",vr=["li_fat_id"];function dr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var cr=hi("[Web Vitals]"),fr=9e5,pr=["CLS","FCP","INP","LCP"],gr=["INP","LCP"],_r=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],br=hi("[RemoteConfig]"),mr=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ye._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Bl(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Hl(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return br.info("Using preloaded remote config",this.remoteConfig),void this.zl(this.remoteConfig);if(this._instance._shouldDisableFlags())return void br.warn("Remote config is disabled. Falling back to local config.");this.Bl(t=>{if(!t)return br.info("No config found after loading remote JS config. Falling back to JSON."),void this.Hl(t=>{this.zl(t.json,t)});this.zl(t)})}catch(t){br.error("Error loading remote config",t),this.zl()}}zl(t,i){!t&&i&&(0===i.statusCode?i.error||br.warn("Failed to fetch remote config from PostHog."):br.error("Failed to fetch remote config from PostHog."));try{this._instance.zl(t?{ok:!0,config:t}:{ok:!1})}catch(t){br.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded()}catch(t){br.error("Error loading feature flags",t)}}},yr="disabled",wr="lazy_loading",Sr=hi("[SessionRecording]"),xr=hi("[Heatmaps]");function kr(t){return d(t)&&"clientX"in t&&"clientY"in t&&m(t.clientX)&&m(t.clientY)}var Er=hi("[Product Tours]"),Fr=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(ue))},Pr=hi("[SiteApps]"),Cr="Error while initializing PostHog app with config id ",Tr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Rr="events",Ar="cancelEvents",Or="survey shown";function $r(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var Mr=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Ir=t=>t.toLowerCase(),jr={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>Mr(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!Mr(i,t))),icontains:(t,i)=>i.map(Ir).some(i=>t.map(Ir).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Ir).every(i=>t.map(Ir).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function Dr(t,i){return!t||Object.entries(t).every(t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(null==r)return!1;var s=jr[e.operator];return!!s&&s(e.values,[String(r)])})}var Lr=hi("[Surveys]"),Nr=["popover","widget","api"],Br="SDK is not enabled or survey functionality is not yet loaded",zr="Disabled. Not loading surveys.",Hr=class{constructor(t,i){this.uo=t,this.oh=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.ah=!1,this.uh=[],this.hh=null,this.dh=null,this.fo=!1,this.fh=new Set,this.onRemoteConfig=t=>{if(!this.fo&&!this.Sr.disableSurveys){if(!t.ok)return Lr.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(b(i))return Lr.warn("Flags not loaded yet. Not loading surveys.");this.ph=y(i)?i:i.length>0,Lr.info("flags response received, isSurveysEnabled: "+this.ph),this.loadIfEnabled()}}}setup(t){if(!this.fo)return this.gh=t,Tr(t.kv.initialize(),()=>{if(this.gh===t&&!this.fo){this.gh=void 0,this.lo=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.fo?i.dispose():(this.yo=i,this.loadIfEnabled())}})}dispose(){var t,i,e;this.fo||(this.fo=!0,this.gh=void 0,this.lo=void 0,null==(t=this.yo)||t.dispose(),this.yo=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.uh=[],this.hh=null,this.fh.forEach(t=>clearTimeout(t)),this.fh.clear())}get Sr(){return this.uo.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}}loadIfEnabled(){if(!this.fo&&this.lo){var t=this.Sr;if(!this._surveyManager)if(this.ah)Lr.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Lr.info(zr);else if(t.cookielessMode&&this.uo.isOptedOut())Lr.info("Not loading surveys in cookieless mode without consent.");else{var i=this.uo.getExtensions();if(i){if(!f(this.ph)||t.advancedEnableSurveys){var e=this.ph||t.advancedEnableSurveys;this.ah=!0;try{var r=i.generateSurveys;if(r)return this.mh(r,e),void(this.ah=!1);var s=i.loadExternalDependency;if(!s)return this.yh(De),void(this.ah=!1);s(t=>{try{if(this.fo)return;var i=this.uo.getExtensions();t||null==i||!i.generateSurveys?this.yh("Could not load surveys script",t):this.mh(i.generateSurveys,e)}finally{this.ah=!1}})}catch(t){throw this.ah=!1,this.yh("Error initializing surveys",t),t}}}else Lr.error("PostHog Extensions not found.")}}}mh(t,i){this.fo||(this._surveyManager=t(i),this._surveyEventReceiver=this.uo.createEventReceiver(),Lr.info("Surveys loaded successfully"),this.bh({isLoaded:!0}))}yh(t,i){Lr.error(t,i),this.bh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.uh.push(t),this._surveyManager&&this.bh({isLoaded:!0}),()=>{this.uh=this.uh.filter(i=>i!==t)}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.lo)&&void 0!==e?e:this.oh;if(r&&!this.fo){if(this.Sr.disableSurveys)return Lr.info(zr),t([]);var s=r.kv.get(Fe);if(s&&!i)return t(s,{isLoaded:!0}),void(this._h()&&this.getSurveys(()=>{},!0));if(this.hh)this.hh.then(i=>{this.fo||t(i.surveys,i.context)}).catch(t=>Lr.error("Error in survey callback",t));else{var n=this.wh("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.Sr.requestTimeoutMs}).then(t=>{try{return this.kh(r,t)}catch(t){return Lr.error("Error processing surveys response",t),this.kh(r,{statusCode:0,error:t})}},t=>this.kh(r,{statusCode:0,error:t}));this.hh=n;var a=()=>{this.hh===n&&(this.hh=null)};n.then(i=>{a(),this.fo||t(i.surveys,i.context)},a).catch(t=>Lr.error("Error in survey callback",t))}}}wh(t,i){var e=this.lo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(Br)}))}kh(t,i){var e;if(this.fo)return{surveys:[],context:{isLoaded:!1,error:Br}};var r=i.statusCode;if(200!==r||!i.json){var s="Surveys API could not be loaded, status: "+r;return 0!==r?Lr.error(s):i.error||Lr.warn(s),this.dh=Date.now(),{surveys:[],context:{isLoaded:!1,error:s}}}this.dh=null;var n=i.json.surveys||[],a=n.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&($r(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t)));return a.length>0&&(null==(e=this._surveyEventReceiver)||e.register(a)),t.kv.set({[Fe]:n,[Pe]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}_h(){return this.Sh()&&!this.hh&&!this.xh()}Sh(){var t,i,e=null==(t=null!==(i=this.lo)&&void 0!==i?i:this.oh)?void 0:t.kv.get(Pe);return m(e)&&Date.now()-e>3e5}xh(){return m(this.dh)&&3e5>Date.now()-this.dh}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(i))(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){Lr.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}bh(t){for(var i of this.uh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Lr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!b(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Lr.warn("init was not called")}Ch(t){var i=null;return this.getSurveys(e=>{var r;i=null!==(r=e.find(i=>i.id===t))&&void 0!==r?r:null}),i}$h(t){if(b(this._surveyManager))return{eligible:!1,reason:Br};var i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Th(t){if(!this.uo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(b(this._surveyManager))return{eligible:!1,reason:Br};var i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(b(this._surveyManager))return Lr.warn("init was not called"),{visible:!1,disabledReason:Br};var i=this.Th(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return b(this._surveyManager)?(Lr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Br})):new Promise(e=>{this.getSurveys(i=>{var r,s=null!==(r=i.find(i=>i.id===t))&&void 0!==r?r:null;if(s){var n=this.Th(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var r;if(this.uo.isCapturing())if(b(this._surveyManager))Lr.warn("init was not called");else{var s="string"==typeof t?this.Ch(t):t;if(null!=s&&s.id)if(Nr.includes(s.type)){var n=null==ni?void 0:ni.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){Lr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout(()=>{var t,i;this.fh.delete(a),!this.fo&&this.uo.isCapturing()&&(Lr.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(s,n,e),Lr.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.fh.add(a)}else this._surveyManager.renderSurvey(s,n,e);else Lr.warn("Survey element not found")}else Lr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Lr.warn("Survey not found")}}displaySurvey(t,e){var r;if(this.uo.isCapturing())if(b(this._surveyManager))Lr.warn("init was not called");else{var s=this.Ch(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&Lr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.$h(s);if(!a.eligible)return void Lr.warn("Survey is not eligible to be displayed: ",a.reason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else Lr.warn("Survey not found")}}cancelPendingSurvey(t){b(this._surveyManager)?Lr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};ii.DEBUG=!1,ii.LIB_VERSION="1.429.2",ii.LIB_NAME="web";var Ur=ii,Vr=class{on(t,i){return this.ya[t]||(this.ya[t]=[]),this.ya[t].push(i),()=>{this.ya[t]=this.ya[t].filter(t=>t!==i)}}emit(t,i){for(var e of this.ya[t]||[])e(i);for(var r of this.ya["*"]||[])r(t,i)}constructor(){this.ya={}}};function qr(t,i,e){if(b(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var Wr=class{constructor(t){this._instance=t,this.Ih=new Set,this.Mh=new Set,this.Eh=new Vr,this.Ph=(t,i)=>this.Rh(t,i)&&this.Ah(t,i)&&this.Fh(t,i)&&this.Oh(t,i),this.Rh=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;f(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.Dh=null==(i=this._instance)?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t;null==(t=this.Dh)||t.call(this),this.Dh=void 0,this.Eh=new Vr}register(t){var i,e;if(!f(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Ih.add(t),null==(i=t.steps)||i.forEach(t=>{this.Mh.add((null==t?void 0:t.event)||"")})}),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Ih.forEach(t=>{var i;null==(i=t.steps)||i.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Ih.clear(),this.Mh.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Mh.has(t)||this.Mh.has(i.event))&&this.Ih.forEach(t=>{this.Lh(i,t)&&this.Eh.emit("actionCaptured",t.name)})}Nh(t){this.onAction("actionCaptured",i=>t(i))}Lh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Ph(t,e))return!0;return!1}onAction(t,i){return this.Eh.on(t,i)}Ah(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!qr(r,i.url,i.url_matching||"contains"))return!1}return!0}Fh(t,i){return!!this.qh(t,i)&&!!this.jh(t,i)&&!!this.Bh(t,i)}qh(t,i){var e;if(null==i||!i.href)return!0;var r=this.Hh(t);if(r.length>0)return r.some(t=>qr(t.href,i.href,i.href_matching||"exact"));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&qr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}jh(t,i){var e;if(null==i||!i.text)return!0;var r=this.Hh(t);if(r.length>0)return r.some(t=>qr(t.text,i.text,i.text_matching||"exact")||qr(t.$el_text,i.text,i.text_matching||"exact"));var s,n,a,o=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!o&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!b(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(o),n=i.text,a=i.text_matching||"exact",s.some(t=>qr(t,n,a)))}Bh(t,i){var e,r;if(null==i||!i.selector)return!0;if(null!=t&&null!=(e=t.properties)&&null!=(e=e.$element_selectors)&&e.includes(i.selector))return!0;var s=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&s)try{return new RegExp(i.selector_regex).test(s)}catch(t){return!1}return!1}Hh(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}Oh(t,i){return null==i||!i.properties||0===i.properties.length||Dr(i.properties.reduce((t,i)=>{var e=h(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},Kr=class{constructor(t){var i;this.zh=[],this._instance=t,this.Uh=new Map,this.Wh=new Map,this.Vh=new Map,this.Gh=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId(t=>this.Zh(t))}Qh(t){return!1}Jh(){return null}Kh(t){}Yh(){}Xh(t,i){return!!t&&Dr(t.propertyFilters,null==i?void 0:i.properties)}tc(t,i){var e=new Map;return t.forEach(t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach(i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}})}),e}ec(t,i,e){var r=(e===Rr?this.Uh:this.Wh).get(t),s=[];return this.nc(t=>{s=t.filter(t=>null==r?void 0:r.includes(t.id))}),s.filter(r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find(i=>i.name===t);return this.Xh(n,i)})}register(t){this.sc(t,!1)}replace(t){this.sc(t,!0)}sc(t,i){var e;f(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.rc(t,i),this.oc(t,i))}oc(t,i){var e=t.filter(t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length});if(i&&this.Vh.clear(),0!==e.length){this.lc||(this.lc=new Wr(this._instance),this.lc.init(),this.lc.Nh(t=>this.onAction(t)));var r=[];e.forEach(t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach(i=>{if(r.push(i),i.name){var e,s=null!==(e=this.Vh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.Vh.set(i.name,s)}})}),i?this.lc.replace(r):this.lc.register(r)}else{var s;i&&(null==(s=this.lc)||s.replace([]))}}ac(t,i){i.forEach((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach(t=>{s.includes(t)||s.push(t)}),t.set(e,s)})}rc(t,i){var e,r,s=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0}),n=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0}),a=this.tc(t,Rr),o=this.tc(t,Ar);i?(this.Uh=a,this.Wh=o):(this.ac(this.Uh,a),this.ac(this.Wh,o)),(0!==s.length||0!==n.length)&&(null!==(e=this.Dh)&&void 0!==e||(this.Dh=null==(r=this._instance)?void 0:r._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,r,s=this.uc(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.hc(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.cc([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.dc(n),void this.vc([n])}if(this.Wh.has(t)){var o=this.ec(t,i,Ar);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.cc(o.map(t=>t.id)),o.forEach(t=>this.fc(t.id)))}if(this.Uh.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.Uh.get(t)});var l=this.ec(t,i,Rr);this.gc(l.map(t=>t.id))}}onAction(t){this.Vh.has(t)&&this.gc(this.Vh.get(t)||[])}gc(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.Qh(s)?this.dc(s)&&this.mc(s):r.push(s);r.length>0&&(this.zh=[...new Set([...this.zh,...r])]),this.uc().info("updating activated items",{activatedItems:this.getActivatedIds()})}}dc(t){this.zh=this.zh.filter(i=>i!==t);var i=this.yc();return!i.includes(t)&&(this.bc([...i,t]),this._c(),!0)}cc(t){var i=new Set(t);this.zh=this.zh.filter(t=>!i.has(t));var e=this.wc(),r=e.filter(t=>!i.has(t));r.length!==e.length&&(this.bc(r),0===r.length&&this.kc()),this.vc(t)}Sc(){var t,i=this.Jh();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}mc(t){if(this.Jh()){var e=this.Sc();this.Kh(i({},e,{[t]:Date.now()}))}}vc(t){if(this.Jh()){var i=this.Sc(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],a=s[1];t.includes(n)?r=!0:e[n]=a}r&&(c(e)?this.Yh():this.Kh(e))}}xc(){this.Jh()&&this.Yh()}getActivationTimestamp(t){if(this.yc().includes(t)){var i=this.Sc()[t];return m(i)?i:void 0}}wc(){var t,i=this.Cc();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}yc(){var t,i,e=this.wc();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.$c()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}_c(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Tc(i)}kc(){this.Ic()}Zh(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.$c()];if(e&&e!==t){var r=this.wc(),s=this.Sc();r.length>0&&(this.bc([]),r.filter(t=>m(s[t])).forEach(t=>this.fc(t))),this.kc(),this.xc()}}getActivatedIds(){return[...new Set([...this.yc(),...this.zh])].filter(t=>!this.Mc(t))}dispose(){var t,i,e;null==(t=this.Gh)||t.call(this),this.Gh=void 0,null==(i=this.Dh)||i.call(this),this.Dh=void 0,null==(e=this.lc)||e.dispose(),this.lc=void 0}reset(){this.zh=[],this.wc().length>0&&this.bc([]),this.kc(),this.xc()}getEventToItemsMap(){return this.Uh}Ec(){return this.lc}},Jr=class extends Kr{constructor(t){super(t)}Cc(){return Ce}$c(){return Te}Jh(){return Re}Kh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Re]:t})}Yh(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Re)}Qh(t){var i,e;this.nc(i=>{e=i.find(i=>i.id===t)});var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return m(r)&&r>0}Pc(){return Or}nc(t){var i;null==(i=this._instance)||i.getSurveys(t)}fc(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}uc(){return Lr}bc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Ce]:t})}Tc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Te]:t})}Ic(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Te)}Mc(){return!1}hc(t,i){var e;return this.nc(t=>{e=t.find(t=>t.id===i)}),!e||function(t){var i;return $r(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e)?t===Or?"consume":"ignore":t===Or?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Gr=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);f(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},Xr=class{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){var t=null==Ye?void 0:Ye.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new Jr(this._instance)}},Zr=null!=ei&&ei.location?He(ei.location.hash,"__posthog")||He(location.hash,"state"):null,Qr="_postHogToolbarParams",Yr=hi("[Toolbar]"),ts=hi("[FeatureFlags]"),is=class{constructor(t,i){void 0===i&&(i=!1),this.Rc=!1,this.update(t,i)}update(t,i){this.Ac=((t,i)=>{var e,r,s,n,a;return{bootstrap:{featureFlags:null==(e=t.bootstrap)?void 0:e.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(s=t.remote_config_refresh_interval_ms)&&void 0!==s?s:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(a=t.evaluation_contexts)&&void 0!==a?a:t.evaluation_environments)&&void 0!==n?n:[],flagKeys:h(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Rc||(ts.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Rc=!0),f(t.flag_keys)||h(t.flag_keys)||ts.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Ac}},es=hi("[FeatureFlags]"),rs=hi("[FeatureFlags]",{debugEnabled:!0}),ss="\" failed. Feature flags didn't load in time.",ns="connection_error",as=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},os=t=>{var i={};for(var e of ci(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},ls=t=>x(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),us=hi("[Error tracking]"),hs="webkit-masked-url:",vs=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],ds=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",hs],cs=["__firefox__","__gCrWeb"],fs="Refusing to render web experiment since the viewer is a likely bot",ps={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Mr(i,t),not_regex:(t,i)=>!Mr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},gs=hi("[Conversations]"),_s="Conversations not available yet.";function bs(){var t="",e="";try{var r=null==si?void 0:si.userAgent;if(r){var s=function(t){for(var i=0;H.length>i;i++){var e=H[i],r=e[1],s=e[0].exec(t),n=s&&(v(r)?r(s,t):r);if(n)return n}return["",""]}(r);t=s[0],e=s[1]}}catch(t){}return function(t,e){var r=function(t){if(t)return{}.hasOwnProperty.call(Ht,t)?Ht[t]:t}(t);return i({},r?{"os.name":r}:{},e?{"os.version":e}:{})}(t,e)}function ms(t,e){var r,s,n,a,o,l,u,h=null!==(r=null==t?void 0:t.flushIntervalMs)&&void 0!==r?r:3e3,v=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=null!=e&&e.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=f(d)?Math.max(v,2048):Math.max(v,d),p=i({},bs(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(a=null!==(o=null==p?void 0:p["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==a?a:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(l=null==p?void 0:p["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(u=null==p?void 0:p["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:p,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:v,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var ys=["debug","log","warn","error","info"],ws="console",Ss="__posthogHandledLogsRequestError",xs=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Ss]=!0,e},ks=t=>!!t&&"object"==typeof t&&!0===t[Ss],Es={featureFlags:class{constructor(t){this.name="featureFlags",this.Fc=!1,this.featureFlagEventHandlers=[],this.$=es,this.Oc={},this.Dc={},this.Lc=[],this.Nc=!1,this.qc=!1,this.jc=0,this.Bc=!1,this.Hc=!1,this.zc=!1,this.Uc=!1,this.Wc=0,this.sn=()=>{var t=this.Vc();this.Wc=0,t&&this.reloadFeatureFlags()},this.Gc=()=>{var t,i=this.Zc;f(i)||this.Sr.remoteRequestsDisabled||!ni||"hidden"===ni.visibilityState||Date.now()-(null!==(t=this.Qc)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Jc())},this.an=()=>{"visible"===(null==ni?void 0:ni.visibilityState)&&this.Gc()},"get"in t?this.uo=t:(this._instance=t,this.Kc=new is(t.config,t._shouldDisableFlags()),this.uo=this.Kc)}updateConfig(t,i){var e;null==(e=this.Kc)||e.update(t,i),this.lo&&this.Yc()}setup(t){return this.gh=t,this.$=t.logger.createLogger("[FeatureFlags]"),Tr(t.kv.initialize(),()=>{this.gh===t&&(this.gh=void 0,this.lo=t,this.Xc(t))})}Xc(t){var i;if(this.lo===t)return ei&&pi(ei,"online",this.sn),this.Yc(),this.td=t.registerDynamicEventProperties(()=>this.ed()?this.Oc:this.Dc),this.nd=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange(()=>{this.sd(),this.rd(),this.od()}),this.rd(),this.initialize()}Yc(){var t=this.Sr.refreshIntervalMs,i=!this.Sr.remoteRequestsDisabled&&ni&&!f(t)&&t>0?t:void 0;i!==this.Zc&&(this.ld(),f(i)||(this.Zc=i,this.Jc(),null!=ni&&ni.addEventListener&&pi(ni,Le,this.an)))}Jc(){f(this.Zc)||(f(this.ad)||clearInterval(this.ad),this.Qc=Date.now(),this.ad=setInterval(this.Gc,this.Zc))}ld(){f(this.ad)||(clearInterval(this.ad),this.ad=void 0,null==ni||null==ni.removeEventListener||ni.removeEventListener(Le,this.an)),this.Zc=void 0,this.Qc=void 0}destroy(){this.ud()}dispose(){this.ud()}ud(){var t,i;this.ld(),this.jc++,this.Hc=!1,this.gh=void 0,this.lo&&(this.hd(),null==(t=this.td)||t.dispose(),this.td=void 0,null==(i=this.nd)||i.call(this),this.nd=void 0,this.Lc=[],null==ei||ei.removeEventListener("online",this.sn),this.lo=void 0)}get Sr(){return this.uo.get()}dd(t){var i;return this.vd&&t in this.vd?this.vd[t]:null==(i=this.lo)?void 0:i.kv.get(t)}sd(){return!!this.vd&&(this.vd=void 0,!0)}fd(){var t;return!f(null==(t=this.lo)?void 0:t.kv.get("$enabled_feature_flags"))&&this.sd()}At(t){this.pd(()=>{var i;return null==(i=this.lo)?void 0:i.kv.set(t)})}gd(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t.$enabled_feature_flags){var s=this.dd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},a=i.flags||i.featureFlags,o=i.flags?Object.entries(i.flags).filter(t=>{var i=t[1];return!(null!=i&&i.failed)}).map(t=>t[0]):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,u=l?o:e&&!h(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),v=this.dd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=l||e?u:Array.from(new Set([...Object.keys(v),...Object.keys(d)])),p=!l&&!e,g=!!p||u,_=!!p||c,b={[ge]:g,[pe]:g,[me]:_};for(var m of(t.$feature_flag_details&&(b[be]=g),[ye,Ie,we]))f(t[m])||(b[m]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(b)}}Lt(t){this.pd(()=>{var i;return null==(i=this.lo)?void 0:i.kv.remove(t)})}pd(t){try{t()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}rd(){var t={};for(var e of[ge,me,ye,Se]){var r=this.dd(e);f(r)||(t[e]=r)}this.Oc=t;var s=i({},t),n=this.dd(pe);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.Dc=s}ed(){var t=this.Sr.cacheTtlMs;if(!t||0>=t)return!1;var i=this.dd(Ie);return"number"!=typeof i||Date.now()-i>t}md(){return!!this.ed()&&(this.Uc||this.qc||(this.Uc=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}yd(){var t=this.Sr.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}bd(){var t=this.Sr.flagKeys;if(!f(t))return t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i,e=this.Sr,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,i)=>(t[i]=r[i],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,i)=>(t[i]=a[i],t),{});return this._d({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,r){var s,n,a=null!=r&&r.merge&&null!==(s=this.dd("$enabled_feature_flags"))&&void 0!==s?s:{},o=null!=r&&r.merge&&null!==(n=this.dd("$feature_flag_payloads"))&&void 0!==n?n:{},l=i({},a,t),u=i({},o,e),h={};for(var v of Object.entries(l)){var d=v[0],c=v[1];h[d]={key:d,enabled:Mt(c),variant:It(c),reason:void 0,metadata:f(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}}}this._d({flags:h})}get hasLoadedFlags(){return this.Nc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.dd(be),e=this.dd(Se),r=this.dd(xe);if(!r&&!e)return t||{};var s=di({},t||{});for(var n of[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])]){var a,o,l=s[n],u=null==e?void 0:e[n],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,v=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,d=null==r?void 0:r[n],c=i({},l,{enabled:h,variant:h?null!=v?v:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),v!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),d&&(c.metadata=i({},null==l?void 0:l.metadata,{payload:d,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),s[n]=c}return this.Fc||(this.$.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Fc=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{var r=t[e];return{key:e,enabled:Mt(r),variant:It(r),payload:$t(i[e])}})}getFlagVariants(){var t=this.dd(pe),i=this.dd(Se);if(!i)return t||{};for(var e=di({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Fc||(this.$.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.Fc=!0),e}getFlagPayloads(){var t=this.dd(me),i=this.dd(xe);if(!i)return t||{};for(var e=di({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Fc||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.Fc=!0),e}reloadFeatureFlags(){this.Bc||this.Sr.featureFlagsDisabled||this.Vc()||(this.qc&&(this.Hc=!0),this.wd||(this.Lc.slice().forEach(t=>{try{t()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.wd=setTimeout(()=>{this.kd()},5)))}hd(){clearTimeout(this.wd),this.wd=void 0}onReloading(t){return this.Lc.push(t),()=>{this.Lc=this.Lc.filter(i=>i!==t)}}ensureFlagsLoaded(){this.Nc||this.qc||this.wd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Bc=t}resetFlagCallReported(){this.Lt(Oe)}kd(t){this.hd();var e=this.lo;if(e&&!this.Sr.remoteRequestsDisabled&&!this.Vc())if(this.qc)this.Hc=!0;else{var r={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},e.initialPersonProperties,this.dd("$stored_person_properties")||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.dd(Ee),timezone:dr()};f(e.deviceId)||(r.$device_id=e.deviceId),(null!=t&&t.disableFlags||this.Sr.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this.yd();s.length&&(r.evaluation_contexts=s);var n=this.bd();f(n)||(r.flag_keys=n);var a=this.Sr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),l=this.jc;this.qc=!0;var u=()=>{this.Hc&&(this.Hc=!1,this.kd())},h=t=>{this.qc=!1,l===this.jc?(this.At({[Me]:[ns]}),this.$.error("Feature flag request failed",t),this.fd()&&this.od(!0),u()):u()};try{e.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.Sr.compression,sentAt:"body",timeoutMs:this.Sr.requestTimeoutMs}).then(t=>{var i,e,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.qc=!1,l===this.jc){if(this.Sd(t.statusCode),n||this.Hc||(this.$anon_distinct_id=void 0),!r.disable_flags||this.Hc){this.zc=!n;var o=[];t.error?o.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?ns:"unknown_error"):200!==t.statusCode&&o.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var h=!(null==(e=s.quotaLimited)||!e.includes("feature_flags"));h&&o.push("quota_limited"),this.At({[Me]:o}),h?this.$.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):r.disable_flags||this._d(s,n,{partialResponse:a}),u()}}else u()}).catch(h)}catch(t){h(t)}}}Vc(){return Ue(this.Wc,3)}Sd(t){this.Wc=Ve(t,this.Wc,3,()=>this.$.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this.zc)if(this.Nc||this.getFlags()&&this.getFlags().length>0){if(!this.md()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.$.warn('getFeatureFlag for key "'+t+ss)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i;return null==(i=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:i.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.zc)if(this.Nc||this.getFlags()&&this.getFlags().length>0){if(!this.md()){var r,s=this.getFlagVariants(),n=t in s,a=s[t],o=this.getFlagPayloads()[t],l=String(a),u=this.dd("$feature_flag_request_id")||void 0,v=this.dd("$feature_flag_evaluated_at")||void 0,d=this.dd("$flag_call_reported")||{};if(this.Sr.deduplicateCallsPerSession){var c,p=null==(c=this.lo)?void 0:c.session.sessionId,g=this.dd($e);p&&p!==g&&(d={},r=p)}if(e.send_event||!("send_event"in e))if(t in d&&d[t].includes(l))r&&this.At({[Oe]:d,[$e]:r});else{var _,b,m,y,w,S,x,k,E,F,P,C,T;h(d[t])?d[t].push(l):d[t]=[l],this.At(i({[Oe]:d},r?{[$e]:r}:{}));var R=this.getFeatureFlagDetails(t),A=[...null!==(_=this.dd("$feature_flag_errors"))&&void 0!==_?_:[]];f(a)&&A.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:v,$feature_flag_bootstrapped_response:null!==(b=null==(m=this.Sr.bootstrap)||null==(m=m.featureFlags)?void 0:m[t])&&void 0!==b?b:null,$feature_flag_bootstrapped_payload:null!==(y=null==(w=this.Sr.bootstrap)||null==(w=w.featureFlagPayloads)?void 0:w[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.zc};f(null==R||null==(S=R.metadata)?void 0:S.has_experiment)||(O.$feature_flag_has_experiment=R.metadata.has_experiment),f(null==R||null==(x=R.metadata)?void 0:x.version)||(O.$feature_flag_version=R.metadata.version);var M=null!==(k=null==R||null==(E=R.reason)?void 0:E.description)&&void 0!==k?k:null==R||null==(F=R.reason)?void 0:F.code;M&&(O.$feature_flag_reason=M),null!=R&&null!=(P=R.metadata)&&P.id&&(O.$feature_flag_id=R.metadata.id),f(null==R?void 0:R.original_variant)&&f(null==R?void 0:R.original_enabled)||(O.$feature_flag_original_response=f(R.original_variant)?R.original_enabled:R.original_variant),null!=R&&null!=(C=R.metadata)&&C.original_payload&&(O.$feature_flag_original_payload=null==R||null==(T=R.metadata)?void 0:T.original_payload),A.length&&(O.$feature_flag_error=A.join(",")),this.xd(O)}else r&&this.At({[Oe]:d,[$e]:r});if(n)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:$t(o)}}}else this.$.warn('getFeatureFlagResult for key "'+t+ss)}xd(t){try{var i;null==(i=this.lo)||i.capture("$feature_flag_called",t).catch(t=>{this.$.error("Failed to capture feature flag call",t)})}catch(t){this.$.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Cd(t,i)}Cd(t,i){var e=this;return r(function*(){var r=e.lo;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e.yd();n.length&&(s.evaluation_contexts=n);var a,o=e.bd();f(o)||(s.flag_keys=o);try{var l;a=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.Sr.compression,sentAt:"body",timeoutMs:e.Sr.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void e.$.error("Remote config feature flag request failed",t)}try{i(a)}catch(t){e.$.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.zc)return i.defaultValue;if(!(this.Nc||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+t+ss),i.defaultValue;var e=this.getFeatureFlag(t,i);return f(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this._d(t,i,e)}_d(t,e,r){if(this.lo){this.Nc=!0;var s=function(t,e,r,s,n,a){void 0===e&&(e={}),void 0===r&&(r={}),void 0===s&&(s={}),void 0===a&&(a=es);var o=((t,e)=>{var r=t.flags;return r?i({},t,{featureFlags:Object.fromEntries(Object.keys(r).map(t=>{var i;return[t,null!==(i=r[t].variant)&&void 0!==i?i:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>r[t].enabled).filter(t=>{var i;return!f(null==(i=r[t].metadata)?void 0:i.payload)}).map(t=>{var i;return[t,null==(i=r[t].metadata)?void 0:i.payload]}))}):(t.featureFlags&&e.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,a),l=o.flags,u=o.featureFlags,v=o.featureFlagPayloads;if(u){var d=t.requestId,c=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[ge]:u,[pe]:p,[we]:!1}}var _=u,b=v,m=l;if(null!=n&&n.partialResponse){var y=Object.keys(_),w=b||{};_=i({},e,_),b=i({},r,w),y.forEach(t=>{var i;t in w||null==(i=b)||delete i[t]}),m=i({},s,m)}else if(t.errorsWhileComputingFlags)if(l){var S=new Set(Object.keys(l).filter(t=>{var i;return!(null!=(i=l[t])&&i.failed)}));_=i({},e,Object.fromEntries(Object.entries(_).filter(t=>S.has(t[0]))));var x=Object.fromEntries(Object.entries(b||{}).filter(t=>S.has(t[0])));b=i({},r,x),S.forEach(t=>{var i;t in x||null==(i=b)||delete i[t]}),m=i({},s,Object.fromEntries(Object.entries(m||{}).filter(t=>S.has(t[0]))))}else _=i({},e,_),b=i({},r,b),m=i({},s,m);return i({[ge]:Object.keys(os(_)),[pe]:_||{},[me]:b||{},[be]:m||{},[we]:!0===t.minimalFlagCalledEvents},d?{[ye]:d}:{},c?{[Ie]:c}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.$);if(s)if(!1===(null==r?void 0:r.persist)){var n=!f(this.lo.kv.get(pe));this.vd=s,n||this.At(s)}else this.sd(),this.gd(s,t,!(null==r||!r.partialResponse)),this.At(s);else e&&this.fd();e||(this.Uc=!1),this.od(e)}}override(t,i){void 0===i&&(i=!1),this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.$d(t)}$d(t){if(this.lo){if(!1===t)return this.Lt([Se,xe]),this.od(),void rs.info("All overrides cleared");if(h(t))return this.At({[Se]:as(t)}),this.od(),void rs.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.Fc=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[Se]=h(s)?as(s):s),n&&(r[xe]=n),Object.keys(r).length&&this.At(r),!1===s&&!1===n?this.Lt([Se,xe]):!1===s?this.Lt(Se):!1===n&&this.Lt(xe),this.od(),!1===s?rs.info("Flag overrides cleared"):s&&rs.info("Flag overrides set",{flags:s}),void(!1===n?rs.info("Payload overrides cleared"):n&&rs.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.At({[Se]:t}),this.od(),void rs.info("Flag overrides set",{flags:t});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Nc){var i=this.Td(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.$.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.dd("$early_access_features")||[]).find(i=>i.flagKey===t),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[ge]:[t],[pe]:[t],[ke]:Object.keys(a)}),this.At({[ge]:Object.keys(os(l)),[pe]:l,[ke]:i({},this.dd("$stored_person_properties")||{},a)}),this.od();try{var u;null==(u=this.lo)||u.capture("$feature_enrollment_update",o).catch(t=>{this.$.error("Failed to capture early access feature enrollment",t)})}catch(t){this.$.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.dd(_e);!r||i?this.Id(t,e):t(r)}Id(t,i){var e=this;return r(function*(){var r=e.lo;if(r){var s,n=i?"&"+i.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;s=a.json.earlyAccessFeatures,e.At({[_e]:s})}catch(t){return void e.$.error("Early access feature request failed",t)}try{t(s)}catch(t){e.$.error("Early access feature callback failed",t)}}})()}Td(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}od(t){this.rd();var i=this.Td(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.$.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Md(t,i)}Md(t,e){void 0===e&&(e=!0);var r=this.dd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this.At({[ke]:i({},r,a,s)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.dd("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.At({[ke]:r}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Lt(ke),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.dd("$stored_group_properties")||{},s=i({},r);for(var n of Object.keys(t))s[n]=i({},r[n],t[n]);this.At({[Ee]:s}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.dd("$stored_group_properties")||{};this.At({[Ee]:i({},e,{[t]:{}})})}else this.Lt(Ee)}reset(){this.jc++,this.Hc=!1,this.Oc={},this.Dc={},this.vd=void 0,this.Nc=!1,this.Bc=!1,this.zc=!1,this.$anon_distinct_id=void 0,this.hd(),this.Fc=!1,this.Wc=0}}},Fs={sessionRecording:class{get Sr(){return this._instance.config}get ga(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Ed)||!t.isStarted)}get status(){var t,i;return"awaiting_config"===this.Pd||"missing_config"===this.Pd?this.Pd:null!==(t=null==(i=this.Ed)?void 0:i.status)&&void 0!==t?t:this.Pd}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Pd=yr,this.Rd=void 0,this.Ad=!1,this.Ke=(()=>{var t;if(null==ni||!ni.visibilityState||"visible"===ni.visibilityState)return!0;var i=null==ei||null==(t=ei.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some(t=>"visible"===t.name)})(),this.an=()=>{var t;"visible"===(null==ni?void 0:ni.visibilityState)&&(this.Ke=!0,null==(t=this.Ed)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Sr.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Sr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=ni&&ni.addEventListener&&pi(ni,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.Ad=!0,null==ni||null==ni.removeEventListener||ni.removeEventListener("visibilitychange",this.an),e?this.Fd(!0):this.stopRecording()}get Od(){var t,i=!(null==(t=this._instance.get_property(de))||!t.enabled),e=!this.Sr.disable_session_recording,r=this.Sr.disable_session_recording||this._instance.consent.isOptedOut();return ei&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.Ad||this.Od&&null!=(i=this.Ed)&&i.isStarted)){var e=!f(Object.assign)&&!f(Array.from);this.Od&&e?(this.Dd(t),Sr.info("starting")):(this.Pd=yr,this.stopRecording())}}Dd(t){var i,e;if(this.Od)if("awaiting_config"!==this.Pd&&"missing_config"!==this.Pd&&(this.Pd=wr),null!=Ye&&null!=(i=Ye.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=Ye.__PosthogExtensions__)&&e.initSessionRecording)this.Ld(t);else{var r,s=this._instance.sessionManager;null==(r=Ye.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Nd,i=>{if(!this.Ad&&this.Od&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[je]:!0}),Sr.error("could not load recorder",i)):void this.Ld(t);this.Pd=yr})}}stopRecording(){var t,i;null==(t=this.Rd)||t.call(this),this.Rd=void 0,null==(i=this.Ed)||i.stop()}Fd(t){var i,e;void 0===t&&(t=!1),null==(i=this.Rd)||i.call(this),this.Rd=void 0,null==(e=this.Ed)||e.discard({discardProducerEvents:t})}qd(){var t,i;null==(t=this.ga)||t.unregister("$session_is_sampled"),null==(i=this.ga)||i.unregister("$replay_sample_rate")}jd(t,i){if(b(t))return null;var e,r=m(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Sr.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Bd(t){if(this.ga){var e,r,s=this.ga,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.jd(null==(e=this.Sr.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.jd(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;b(o)&&this.qd();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[de]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.Rd)||e.call(this),this.Rd=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.Bd(i),void this.Fd()):(this.Bd(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.Pd&&(this.Pd="missing_config",Sr.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.Ed)&&e.log?this.Ed.log(t,i):Sr.warn("log called before recorder was ready")}get Nd(){var t;return(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.get_property("$session_recording_remote_config"))||null==(t=t.scriptConfig)?void 0:t.script)||"lazy-recorder"}Hd(){var t,i=this._instance.get_property(de);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return Sr.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!b(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Ld(t){var i,e,r;if(!this.Ad&&this.Od&&this._instance.sessionManager){if(null==(i=Ye.__PosthogExtensions__)||!i.initSessionRecording)return Sr.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[je]:!0});var s;if(this.Ed||(this.Ed=null==(s=Ye.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.Ke),this.Ed._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Hd()){if("missing_config"===this.Pd||"awaiting_config"===this.Pd)return;return this.Pd="awaiting_config",Sr.info("persisted remote config is stale, requesting fresh config before starting"),void new mr(this._instance).load()}this.Pd=wr,null==(e=(r=this.Ed).setDocumentWasEverVisible)||e.call(r,this.Ke),this.Ed.start(t)}else this.Pd=yr}onRRwebEmit(t){var i;null==(i=this.Ed)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Ed||null==(t=this.ga)||t.register({[fe]:!0}),null==(i=this.Ed)||i.overrideLinkedFlag()}overrideSampling(){var t,i;this.Ed||null==(t=this.ga)||t.register({[ce]:!0}),null==(i=this.Ed)||i.overrideSampling()}overrideTrigger(t){var i,e;this.Ed||null==(i=this.ga)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.Ed)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Ed)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Ed)||!e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t;null==(t=this.Ed)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Ps={autocapture:class extends Xe{constructor(t){super(new Ze(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.zd=this.Ud()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Wd();return!!(t.path||t.search||this.Vd(t))}startIfEnabled(){this.isEnabled&&(ui.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.zd=this.Ud(),this.startIfEnabled()}stop(){this.Gd&&this.Gd(),this.Gd=void 0,this.Zd&&this.Zd(),this.Zd=void 0,ui.info("History API monitoring stopped")}monitorHistoryChanges(){ei&&ei.history&&(this.Qd("pushState"),this.Qd("replaceState"),this.Jd(),this.Vd()&&this.Kd())}Qd(t){var i;if(ei&&(null==(i=ei.history[t])||!i.__posthog_wrapped__)){var e=this;ar(ei.history,t,i=>function(r,s,n){i.call(this,r,s,n),e.Yd(t)})}}Ud(){var t=null==ei?void 0:ei.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Wd(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:d(t)?t:{}}Vd(t){return void 0===t&&(t=this.Wd()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Xd(t){var i=this.Wd(),e=this.zd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Vd(i)&&t.hash!==e.hash))}Yd(t){try{var i=this.Ud();if(!i)return;this.Xd(i)&&this._instance.capture("$pageview",{navigation_type:t}),this.zd=i}catch(i){ui.error("Error capturing "+t+" pageview",i)}}Jd(){if(!this.Gd){var t=()=>{this.Yd("popstate")};pi(ei,"popstate",t),this.Gd=()=>{ei&&ei.removeEventListener("popstate",t)}}}Kd(){if(!this.Zd){var t=()=>{this.Yd("hashchange")};pi(ei,"hashchange",t),this.Zd=()=>{ei&&ei.removeEventListener("hashchange",t)}}}},heatmaps:class{get Sr(){return this.instance.config}constructor(t){var i;this.tv=!1,this.ho=!1,this.ev=null,this.instance=t,this.tv=!(null==(i=this.instance.persistence)||!i.props[re]),this.rageclicks=new ie(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return d(this.Sr.capture_heatmaps)&&this.Sr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Sr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return b(this.Sr.capture_heatmaps)?b(this.Sr.enable_heatmaps)?this.tv:this.Sr.enable_heatmaps:!1!==this.Sr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ho)return;xr.info("starting..."),this.iv(),this.an()}else{var t;clearInterval(null!==(t=this.ev)&&void 0!==t?t:void 0),this.nv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[re]:e}),this.tv=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}sv(t){kr(t.originalEvent)&&this._r(t.originalEvent,"deadclick")}an(){this.ev&&clearInterval(this.ev),this.ev="visible"===(null==ni?void 0:ni.visibilityState)?setInterval(this.oa.bind(this),this.flushIntervalMilliseconds):null}iv(){ei&&ni&&(this.rv=this.oa.bind(this),pi(ei,Ne,this.rv),this.ov=t=>this._r(t||(null==ei?void 0:ei.event)),pi(ni,"click",this.ov,{capture:!0}),this.lv=t=>this.av(t||(null==ei?void 0:ei.event)),pi(ni,"mousemove",this.lv,{capture:!0}),this.uv=new er(this.instance,ir,this.sv.bind(this)),this.uv.startIfEnabledOrStop(),this.hv=this.an.bind(this),pi(ni,Le,this.hv),this.ho=!0)}nv(){var t;ei&&ni&&(this.rv&&ei.removeEventListener(Ne,this.rv),this.ov&&ni.removeEventListener("click",this.ov,{capture:!0}),this.lv&&ni.removeEventListener("mousemove",this.lv,{capture:!0}),this.hv&&ni.removeEventListener(Le,this.hv),clearTimeout(this.dv),null==(t=this.uv)||t.stop(),this.ho=!1)}vv(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),a=function(t,i,e){for(var r=t;r&&mi(r)&&!yi(r,"body");){if(r===e)return!1;var s=void 0;try{var a,o,l;s=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:ei)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(n(i,s))return!0;r=Oi(r)}return!1}(Ci(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:e),target_fixed:a,type:i}}_r(t,e){var r;if(void 0===e&&(e="click"),!bi(t.target)&&kr(t)){var s=this.vv(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Li(Ci(t),this.instance.config.rageclick)&&this.Hs(i({},s,{type:"rageclick"})),this.Hs(s)}}av(t){!bi(t.target)&&kr(t)&&(clearTimeout(this.dv),this.dv=setTimeout(()=>{this.Hs(this.vv(t,"mousemove"))},500))}Hs(t){if(ei){var i=this.Sr.disable_capture_url_hashes?W(ei.location.href):ei.location.href,e=this.Sr.custom_personal_data_properties,r=ze(i,this.Sr.mask_personal_data_properties?[...lr,...e||[]]:[],hr);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}oa(){this.Rt&&!c(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:er,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.tv=!1,this.ho=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.fv=()=>{clearTimeout(this.pv),this.pv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",i({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.gv=t=>{var e;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},b(null==t?void 0:t.name)||b(null==t?void 0:t.value))cr.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.mv(r);if(!f(s)){var n=m(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.yv||this.yv>t.value){this.Rt.navigationKey!==n&&(this.fv(),this.pv=setTimeout(this.fv,this.flushToCaptureTimeoutMs)),f(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=f(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=i({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,d(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of _r){var h="url"===u&&"string"==typeof t.attribution[u]?this.mv(t.attribution[u]):t.attribution[u];f(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;f(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.fv()}else cr.error("Ignoring metric with value >= "+this.yv,t)}}},this.bv=()=>{if(!this.ho){var t,e,r,s,n=!1,a=Ye.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this._v])||("web-vitals"===this._v&&f(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!f(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!f(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,e=h.indexOf("CLS")>-1?l.onCLS:(null==u?void 0:u.onCLS)||l.onCLS,r=h.indexOf("FCP")>-1?l.onFCP:(null==u?void 0:u.onFCP)||l.onFCP,s=h.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(t&&e&&r&&s){var v={reportSoftNavs:this.useSoftNavs},d=n&&this.attributionMetrics.indexOf("INP")>-1?i({},v,{includeProcessedEventEntries:!1}):v;this.allowedMetrics.indexOf("LCP")>-1&&t(this.gv.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&e(this.gv.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.gv.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.gv.bind(this),d),this.ho=!0}else cr.error("web vitals callbacks not loaded - not starting")}},this.tv=!(null==(e=this._instance.persistence)||!e.props[oe]),this.startIfEnabled()}get wv(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=d(this.wv)?null==(t=this.wv)?void 0:t.web_vitals_allowed_metrics:void 0;return b(e)?(null==(i=this._instance.persistence)?void 0:i.props.$web_vitals_allowed_metrics)||pr:e}get flushToCaptureTimeoutMs(){return(d(this.wv)?this.wv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=d(this.wv)?this.wv.web_vitals_attribution:void 0;return y(t)?t?pr:[]:h(t)?t:gr}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=d(this.wv)?this.wv.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get yv(){var t=d(this.wv)&&m(this.wv.__web_vitals_max_value)?this.wv.__web_vitals_max_value:fr;return t>0&&6e4>=t?fr:t}get isEnabled(){var t=null==ai?void 0:ai.protocol;if("http:"!==t&&"https:"!==t)return cr.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=d(this.wv)?this.wv.web_vitals:y(this.wv)?this.wv:void 0;return y(i)?i:this.tv}startIfEnabled(){this.isEnabled&&!this.ho&&(cr.info("enabled, starting..."),this.Eo(this.bv))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=d(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=d(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[oe]:e}),this._instance.persistence.register({[ve]:r})),this.tv=e,this.startIfEnabled()}}}get _v(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Eo(t){var i=Ye.__PosthogExtensions__,e=this._v,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&f(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,i=>{i?cr.error("failed to load script",i):t()})}mv(t){var i=t||(null==ei?void 0:ei.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?W(i):i,r=this._instance.config.custom_personal_data_properties;return ze(e,this._instance.config.mask_personal_data_properties?[...lr,...r||[]]:[],hr)}cr.error("Could not determine current URL")}}},Cs={exceptionObserver:class{constructor(t){var e;this.bv=()=>{var t;if(ei&&this.isEnabled&&null!=(t=Ye.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=Ye.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=Ye.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ye.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Sv&&this.Sr.capture_unhandled_errors&&(this.Sv=i(this.captureException.bind(this))),!this.xv&&this.Sr.capture_unhandled_rejections&&(this.xv=e(this.captureException.bind(this))),!this.Cv&&this.Sr.capture_console_errors&&(this.Cv=r(this.captureException.bind(this)))}catch(t){rr.error("failed to start",t),this.$v()}}},this._instance=t,this.Tv=!(null==(e=this._instance.persistence)||!e.props[se]),this.wt=new T(i({},function(t){var i,e,r,s;return void 0===t&&(t={}),{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,$:rr})),this.Sr=this.Iv(),this.startIfEnabledOrStop()}Iv(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return d(t)?e=i({},e,t):(f(t)?this.Tv:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Sr.capture_console_errors||this.Sr.capture_unhandled_errors||this.Sr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(rr.info("enabled"),this.$v(),this.Eo(this.bv)):this.$v()}Eo(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return rr.error("failed to load script",i);t()})}$v(){var t,i,e;null==(t=this.Sv)||t.call(this),this.Sv=void 0,null==(i=this.xv)||i.call(this),this.xv=void 0,null==(e=this.Cv)||e.call(this),this.Cv=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Tv=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[se]:this.Tv}),this.Sr=this.Iv(),this.startIfEnabledOrStop())}}onConfigChange(){this.Sr=this.Iv()}captureException(t){try{var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(s))return void rr.info("Skipping exception capture because of client rate limiting.",{exception:s});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var e,r;this.Mv=[],this.Ev=new Z([new pt,new Et,new _t,new gt,new xt,new St,new mt,new kt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=Math.min(a.length,s+1e3),l=[],u=s;o>u;u++){var h=a[u];if(1024>=h.length){var v=ot.test(h)?h.replace(ot,"$1"):h;if(!v.match(/\S*Error: /)){for(var d of r){var c=d(v,t);if(c){n.push(c);var f=ut(n);if(f){for(var p=l.length-1;p>=0;p--){var g=l[p];if(f.start>=g.start+g.length)break;l.pop()}l.push(f)}break}}if(ct(n,l)>=50)break}}}var _=[...l].sort((t,i)=>i.start-t.start),b=_[_.length-1];if(b){var m=vt(n,b);for(var y of(n.splice(b.start-m,m),_))y.start-=m}for(var w of _)ht(n,w);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){for(var i=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),e=0,r=1;i.length>r;r++)ft(i,r,e)&&(e=r);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map(t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||"?"});var r})}(n)}}("web:javascript",rt,at)),this._instance=t,this.Mv=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==e?e:[],this.Pv=Rt(this.Rv()),this.Av=new At(this.Pv)}onConfigChange(){this.Pv=Rt(this.Rv()),this.Av.setConfig(this.Pv)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],a=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Mv=n,this._instance.persistence&&this._instance.persistence.register({[ne]:this.Mv,[ae]:a})}}}get Fv(){var t,i,e=!!this._instance.get_property(ae);return null!==(t=null!==(i=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==i?i:e)&&void 0!==t&&t}buildProperties(t,i){return this.Ev.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,e){if(this.Pv.enabled)try{if(!p(t)||0===t.trim().length)return void us.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce((e,r)=>Ct.has(r)?(i.push(r),e):(e[r]=t[r],e),{}),droppedKeys:i}}(this.Ov(e)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&us.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Av.add(i({[Ft]:t,[Pt]:(new Date).toISOString()},s))}catch(t){us.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.Dv(i)){if(this.Lv(i))return this.Nv("Exception dropped: matched a suppression rule"),void us.info("Skipping exception capture because a suppression rule matched");if(!this.Fv&&this.qv(i))return this.Nv("Exception dropped: thrown by a browser extension"),void us.info("Skipping exception capture because it was thrown by an extension");if(!this.Fv&&this.jv(i))return this.Nv("Exception dropped: thrown by an injected browser script"),void us.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Bv(i))return this.Nv("Exception dropped: thrown by the PostHog SDK"),void us.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.Pv.enabled&&b(t.$exception_steps)?this.Hv(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return s&&this.Av.clear(),s}catch(t){return ls(t)||us.error("Failed to capture exception event. Dropping this exception.",t),void this.Av.clear()}}catch(t){return void(ls(t)||us.error("Failed to process exception event. Ignoring this exception.",t))}var n}Hv(t){try{var e=this.Av.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(i){return us.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}Nv(t){this.Pv.enabled&&this.Av.add({[Ft]:t,[Pt]:(new Date).toISOString()})}Ov(t){return d(t)?i({},t):{}}Rv(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}Lv(t){if(0===t.length)return!1;try{var i=t.reduce((t,i)=>{var e=i.type,r=i.value;return p(e)&&e.length>0&&t.$exception_types.push(e),p(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.Mv.some(t=>{var e=t.values.map(t=>{var e=jr[t.operator],r=i[t.key];if(!e||!r)return!1;var s=h(t.value)?t.value:[t.value];return s.length>0&&e(s,r)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return us.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qv(t){var i=t.flatMap(t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(t=>{var i=t.filename;return!!i&&ds.some(t=>i.startsWith(t))});return 0!==e.length&&(!e.every(t=>{var i=t.filename;return!!i&&i.startsWith(hs)})||t.some(t=>{var i=t.value;return"NoResponse"===t.type||p(i)&&vs.some(t=>{var e=t.value;return t.exact?i===e:i.includes(e)})})&&!i.some(t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(hs))}))}jv(t){return t.some(t=>{var i=t.value;return p(i)&&cs.some(t=>i.includes(t))})}Bv(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[];return null!==(r=null==(s=n[n.length-1])||null==(s=s.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Dv(t){return!b(t)&&h(t)}}},Ts=i({productTours:class{get ga(){return this._instance.persistence}constructor(t){this.zv=null,this.Uv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.ga&&this.ga.register({[ue]:!!i.productTours}),!Fr(this._instance))return!this.zv&&b(null==(e=this.ga)?void 0:e.props.ph_product_tours)||Er.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.zv)||r.stop(),this.zv=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.zv&&Fr(this._instance)&&this.Eo(()=>this.Wv())}Eo(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",i=>{i?Er.error("Could not load product tours script",i):t()})}Wv(){var t;!this.zv&&null!=(t=Ye.__PosthogExtensions__)&&t.generateProductTours&&(this.zv=Ye.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!h(this.Uv)||i){var e=this.ga;if(e){var r=e.props[Ae];if(h(r)&&!i)return this.Uv=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(Fr(this._instance)){var r=i.statusCode;if(200!==r||!i.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?i.error||Er.warn(s):Er.error(s),void t([],{isLoaded:!1,error:s})}var n=h(i.json.product_tours)?i.json.product_tours:[];this.Uv=n,e&&e.register({[Ae]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Uv,{isLoaded:!0})}getActiveProductTours(t){b(this.zv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.zv.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.zv)||i.showTourById(t)}previewTour(t){this.zv?this.zv.previewTour(t):this.Eo(()=>{var i;this.Wv(),null==(i=this.zv)||i.previewTour(t)})}dismissProductTour(){var t;null==(t=this.zv)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.zv)||t.nextStep()}previousStep(){var t;null==(t=this.zv)||t.previousStep()}clearCache(){var t;this.Uv=null,null==(t=this.ga)||t.unregister(Ae)}resetTour(t){var i;null==(i=this.zv)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.zv)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.zv)||i.cancelPendingTour(t)}}},Es),Rs={siteApps:class{constructor(t){this._instance=t,this.Vv=0,this.Gv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zv(t,i){if(i){var e=this.globalsForEvent(i);this.Gv.push(e),this.Gv.length>1e3&&(this.Gv=this.Gv.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ye._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Zv.bind(this));this.Qv=()=>{t(),this.Gv=[],this.Qv=void 0}}}globalsForEvent(e){var r,s,n,a,o,l,u;if(!e)throw new Error("Event payload is required");var h={},v=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var c of Object.entries(d)){var f=c[0];h[f]={id:v[f],type:f,properties:c[1]}}var p=e.$set_once,g=e.$set;return{event:i({},function(t,i){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==i.indexOf(r))continue;e[r]=t[r]}return e}(e,t),{properties:i({},e.properties,g?{$set:i({},null!==(r=null==(s=e.properties)?void 0:s.$set)&&void 0!==r?r:{},g)}:{},p?{$set_once:i({},null!==(n=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==n?n:{},p)}:{}),elements_chain:null!==(o=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}Jv(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Pr.error("prepare_external_dependency_stylesheet returned null"),null):"script"===e&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Pr.error("prepare_external_dependency_script returned null"),null):t}Kv(){var t,i,e,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==ni?void 0:ni.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Vv++,this.Yv)return this.Xv();var h=[],v=this,d=new WeakSet,c=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),h.push(()=>{t[i]=r})}},f=t=>{if(d.has(t))return t;var i=v.Jv(t);return i&&d.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!_(t));return c(u,"appendChild",t=>function(i){var e=f(i);return e?t.call(this,e):i}),c(u,"insertBefore",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i}),c(u,"replaceChild",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e}),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{c(t,"append",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"prepend",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})}),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach(t=>{c(t,"before",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"after",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"replaceWith",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)})}),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null}),this.Yv=()=>{h.forEach(t=>t()),this.Yv=void 0},this.Xv()}Xv(){var t=!1;return()=>{var i;t||(t=!0,this.Vv--,0===this.Vv&&(null==(i=this.Yv)||i.call(this)))}}tf(t,i){void 0===i&&(i=!0);var e=this.Kv();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Gv.length&&(Pr.info("Processing "+this.Gv.length+" events for site app with id "+t.id),this.Gv.forEach(t=>this.tf(()=>null==i.processEvent?void 0:i.processEvent(t))),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(e=this.Qv)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,Pr.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.tf(i=>t.init({posthog:this._instance,callback(t){i(),s(t)}}),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){Pr.error(Cr+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){Pr.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}ef(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}if(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.tf(()=>null==r.processEvent?void 0:r.processEvent(e))}catch(i){Pr.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.ef(),void this._instance.on("eventCaptured",t=>this.if(t))):void Pr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Qv)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,i=o.id,e=o.url;Ye["__$$ph_site_app_"+i]=s._instance,null==(t=Ye.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,t=>{if(t)return Pr.error(Cr+i,t)})};for(var o of n.siteApps)a()}else Pr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},As={tracingHeaders:class{constructor(t){this._instance=t,this.nf=void 0,this.sf=void 0,this.rf=void 0,this.bv=()=>{var t,i,e=this.lf();e?(f(this.nf)&&(this.nf=null==(t=Ye.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.sf)&&(this.sf=null==(i=Ye.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.$v()}}initialize(){this.startIfEnabledOrStop()}Eo(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return or.error("failed to load script",i);t()})}af(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}lf(){var t=this.af();return h(t)?(h(this.rf)?this.rf.splice(0,this.rf.length,...t):this.rf=[...t],t.length>0?this.rf:void 0):(h(this.rf)&&this.rf.splice(0),this.rf=t||void 0,this.rf)}$v(){var t,i;null==(t=this.nf)||t.call(this),null==(i=this.sf)||i.call(this),this.nf=void 0,this.sf=void 0}startIfEnabledOrStop(){this.lf()?this.Eo(this.bv):this.$v()}}},Os=i({surveys:class extends Hr{constructor(t){var i;super(new Xr(t),(i=t,{get projectToken(){return i.config.token},kv:new Gr(i)})),this._instance=t}wh(t,e){var r=e.query?function(t,e,r){var s;void 0===r&&(r=!0);var n=t.split("?"),a=n[0],o=n[1],l=i({},e),u=null!==(s=null==o?void 0:o.split("&").map(t=>{var i,e=t.split("="),s=e[0],n=r&&null!==(i=l[s])&&void 0!==i?i:e[1];return delete l[s],s+"="+n}))&&void 0!==s?s:[],h=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return vi(t,function(t,i){f(t)||f(i)||"undefined"===i||(e=encodeURIComponent(t instanceof File?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)}),s.join(i)}(l);return h&&u.push(h),u.length>0?a+"?"+u.join("&"):a}(t,e.query):t;return new Promise(t=>{var i;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor(null!==(i=e.target)&&void 0!==i?i:"api",r),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:t})})}}},Es),$s={toolbar:class{constructor(t){this.instance=t}uf(t){Ye.ph_toolbar_state=t}hf(){var t;return null!==(t=Ye.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,i,e){if(void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),gi(this.instance.config))return!1;if(!ei||!ni)return!1;t=null!=t?t:ei.location,e=null!=e?e:ei.history;try{if(!i){try{ei.localStorage.setItem("test","test"),ei.localStorage.removeItem("test")}catch(t){return!1}i=null==ei?void 0:ei.localStorage}var r,s=Zr||He(t.hash,"__posthog")||He(t.hash,"state"),n=s?fi(()=>JSON.parse(atob(decodeURIComponent(s))))||fi(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(i.getItem(Qr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}cf(t){var i=Ye.ph_load_toolbar||Ye.ph_load_editor;!b(i)&&v(i)?i(t,this.instance):Yr.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==ni||!ni.getElementById("__POSTHOG_TOOLBAR__"));if(!ei||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(ei.localStorage.setItem(Qr,JSON.stringify(i({},s,{source:void 0}))),2===this.hf())this.cf(s);else if(0===this.hf()){var n;this.uf(1),null==(n=Ye.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return Yr.error("[Toolbar] Failed to load",t),void this.uf(0);this.uf(2),this.cf(s)}),pi(ei,"turbolinks:load",()=>{this.uf(0),this.loadToolbar(s)})}return!0}df(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},Ms=i({experiments:class t{get Sr(){return this._instance.config}constructor(i){var e=this;this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){void 0===i&&(i=!1),e.getWebExperiments(i=>{t.vf("retrieved web experiments from the server"),e.ff=new Map,i.forEach(i=>{if(i.feature_flag_key){var r;e.ff&&(t.vf("setting flag key ",i.feature_flag_key," to web experiment ",i),null==(r=e.ff)||r.set(i.feature_flag_key,i));var s=e._instance.getFeatureFlag(i.feature_flag_key);p(s)&&i.variants[s]&&e.pf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(var n in i.variants){var a=i.variants[n];t.gf(a,e._instance)&&e.pf(i.name,n,a.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.vf(fs);else if(!this.Sr.disable_web_experiments){if(b(this.ff))return this.ff=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.vf("applying feature flags",i),i.forEach(t=>{var i;if(this.ff&&null!=(i=this.ff)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ff)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.pf(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var i=t.getWindowLocation();if(null!=i&&i.search){var e=Be(null==i?void 0:i.search,"__experiment_id"),r=Be(null==i?void 0:i.search,"__experiment_variant");e&&r&&(t.vf("previewing web experiments "+e+" && "+r),this.getWebExperiments(t=>{this.mf(parseInt(e),r,t)},!1,!0))}}loadIfEnabled(){this.Sr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Sr.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Sr.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}mf(i,e,r){var s=r.filter(t=>t.id===i);s&&s.length>0&&(t.vf("Previewing web experiment ["+s[0].name+"] with variant ["+e+"]"),this.pf(s[0].name,e,s[0].variants[e].transforms))}static gf(i,e){return!b(i.conditions)&&t.yf(i,e)&&t.bf(i)}static yf(i,e){var r;if(b(i.conditions)||b(null==(r=i.conditions)?void 0:r.url))return!0;var s=t.getWindowLocation();if(s){var n,a,o,l=_i(e,s.href);return null==(n=i.conditions)||!n.url||ps[null!==(a=null==(o=i.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](i.conditions.url,l)}return!1}static getWindowLocation(){return null==ei?void 0:ei.location}static bf(t){var i;if(b(t.conditions)||b(null==(i=t.conditions)?void 0:i.utm))return!0;var e=function(t,i,e){if(!ni)return{};var r,s,n,a=i?[...lr,...e||[]]:[],o=(r=ze(ni.URL,a,hr),s=ur.concat(t||[]),n={},vi(s,function(t){var i=Be(r,t);n[t]=i||null}),n);return di(function(){var t={};return vi(vr,function(i){var e=(t=>{if(ni){try{for(var i=t+"=",e=ni.cookie.split(";").filter(t=>t.length),r=0;e.length>r;r++){for(var s=e[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}})(i);t[i]=e||null}),t}(),o)}();if(e.utm_source){var r,s,n,a,o,l,u,h,v=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==e.utm_campaign,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==e.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==e.utm_term;return v&&c&&f&&d}return!1}static vf(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];ui.info("[WebExperiments] "+t,e)}pf(i,e,r){this._is_bot()?t.vf(fs):"control"!==e?r.forEach(r=>{var s;r.selector&&(t.vf("applying transform of variant "+e+" for experiment "+i+" ",r),null==(s=document)||null==(s=s.querySelectorAll(r.selector))||s.forEach(t=>{var i=t;r.html&&(i.innerHTML=r.html),r.css&&i.setAttribute("style",r.css)}))}):t.vf("Control variants leave the page unmodified.")}_is_bot(){return si&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&P(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>P(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver}(si,this.Sr.custom_blocked_useragents):void 0}}},Es),Is={conversations:class{constructor(t){this._instance=t,this._f=void 0,this._conversationsManager=null,this.wf=!1,this.ne=null,this.kf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Sf=t.ok,t.ok)){var i=t.config.conversations;b(i)||(y(i)?this._f=i:(this._f=i.enabled,this.ne=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this._f=void 0,this.ne=null,this.Sf=void 0,this.kf=!1}loadIfEnabled(){if(!(this._conversationsManager||this.wf||this._instance.config.disable_conversations||gi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ye?void 0:Ye.__PosthogExtensions__;if(t&&!f(this._f)&&this._f)if(this.ne&&this.ne.token){this.wf=!0;try{var i=t.initConversations;if(i)return this.xf(i),void(this.wf=!1);var e=t.loadExternalDependency;if(!e)return void this.Cf(De);e(this._instance,"conversations",i=>{i||!t.initConversations?this.Cf("Could not load conversations script",i):this.xf(t.initConversations),this.wf=!1})}catch(t){this.Cf("Error initializing conversations",t),this.wf=!1}}else gs.error("Conversations enabled but missing token in remote config.")}}xf(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.kf=!1,gs.info("Conversations loaded successfully")}catch(t){this.Cf("Error completing conversations initialization",t)}else gs.error("Cannot complete initialization: remote config is null")}Cf(t,i){gs.error(t,i),this._conversationsManager=null,this.wf=!1,this.kf=!0}show(){this._conversationsManager?this._conversationsManager.show():gs.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._f&&!_(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":gi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Sf?"remote_config_failed":f(this._f)?this.Sf?"disabled_in_project":"remote_config_pending":this._f?b(this.ne)||!this.ne.token?"missing_token":null!=Ye&&Ye.__PosthogExtensions__?this.wf?"initializing":this.kf?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return r(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(gs.warn(_s),null)})()}getMessages(t,i){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(gs.warn(_s),null)})()}markAsRead(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(gs.warn(_s),null)})()}getTickets(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(gs.warn(_s),null)})()}requestRestoreLink(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(gs.warn(_s),null)})()}restoreFromToken(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(gs.warn(_s),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(gs.warn(_s),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},js={logs:class{constructor(t){var e,r=this;this._instance=t,this.name="logs",this.$f=!1,this.Tf=!1,this.If=!1,this.$=hi("[logs]"),this.Mf=i({},this.$,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(ks)||r.$.error(...i)}}),this.Zl=[],this.Ef=[],this.Wc=0,this.fo=!1,this.Pf=[],this.Rf=[],this.Af=!1,this.Ff=!1,this.Of=()=>{var t,i;this.fo||(this.Wc=0,null==(t=this.Df)||t.onReconnect(),null==(i=this.Lf)||i.onReconnect())},this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.$f=!0),ei&&pi(ei,"online",this.Of)}Nf(t,i,e,r){var s,n=ms(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new Gt(this.qf(t,i),n,this.Mf,()=>this.jf(),t=>t(),void 0,r),n]}Bf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Df||this.Hf!==i){var e;null==(e=this.Df)||e.reset(),this.Hf=i;var r=this.Nf(()=>this.Zl,t=>{this.Zl=t});this.Df=r[0],this.zf=r[1]}return this.Df}Uf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Lf||this.Wf!==i){var e;null==(e=this.Lf)||e.reset(),this.Wf=i;var r=this.Nf(()=>this.Ef,t=>{this.Ef=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},ws);this.Lf=r[0],this.Vf=r[1]}return this.Lf}setup(t){var i;if(!this.fo){this.lo=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.$f=!0),(this.$f||this.Gf()&&this.Zf())&&this.Qf();var e=!1,r=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.fo?r.dispose():(this.yo=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.fo||(this.fo=!0,this.Jf(),null==(t=this.yo)||t.dispose(),this.yo=void 0,this.lo=void 0,this.If=!1,null==ei||ei.removeEventListener("online",this.Of),null==(i=this.Kf)||i.call(this),this.Kf=void 0,null==(e=this.Df)||e.reset(),null==(r=this.Lf)||r.reset())}onRemoteConfig(t){var i,e;if(!this.fo){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;b(r)?this.Yf():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[he]:!!r}),r?(this.$f=!0,this.Tf||this.Qf(),this.loadIfEnabled()):this.Yf())}}reset(){var t,i,e,r;this.Jf(),null==(t=this.Df)||t.clearQueue(),this.Zl=[],null==(i=this.Df)||i.reset(),null==(e=this.Lf)||e.clearQueue(),this.Ef=[],null==(r=this.Lf)||r.reset(),this.Wc=0}captureLog(t){this.fo||this.Bf().captureLog(t)}captureConsoleLog(t){this.fo||this.Uf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.fo||this.Uf().captureLog(t,{context:i,occurredAtMs:e})}Zf(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[he])}Gf(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=Ye._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.Jf(),null==(t=this.Lf)||t.clearQueue(),this.Ef=[]}Yf(){this.$f||this.Jf()}Qf(){var t,i=this;if(!this.Af&&null!=Ye&&Ye.console){var e=ms(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(Ye.console[t])}catch(t){return 0}if(!r)return 0;i.Rf.push(ar(Ye.console,t,s=>{var n=function(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];try{i.Xf(t,n,e)}catch(t){}return s.apply(Ye.console,n)};return n.__rrweb_original__=r,n}))};for(var s of ys)r(s);this.Af=!0,this.tp=setTimeout(()=>{this.Jf()},3e4)}}Xf(t,i,e){var r;if(this.Af&&!this.Ff&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Pf.length){this.Ff=!0;try{this.Pf.push({level:t,args:i,occurredAtMs:Date.now(),context:this.jf()})}finally{this.Ff=!1}}}else this.Jf()}Jf(){if(this.Pf=[],this.Af){for(var t of(this.Af=!1,this.tp&&(clearTimeout(this.tp),this.tp=void 0),this.Rf))t();this.Rf=[]}}ep(){var t=this.Pf;return this.Jf(),t}get logger(){return this.np||(this.np={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.np}flushLogs(t){t?this.sp(t):(this.Df&&this.Df.flush().catch(t=>this.rp(t)),this.Lf&&this.Lf.flush().catch(t=>this.rp(t)))}rp(t){ks(t)||this.$.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.fo&&this.$f&&!this.Tf&&!this.If){var t=null==Ye?void 0:Ye.__PosthogExtensions__;if(!t)return this.$.error("PostHog Extensions not found."),void this.Jf();var i=t.loadExternalDependency;if(!i)return this.$.error(De),void this.Jf();this.If=!0;try{i(this._instance,"logs",i=>{if(this.If=!1,!this.fo&&this.$f){var e=t.logs;if(i||null==e||!e.initializeLogs)this.$.error("Could not load logs script",i),this.Jf();else{var r,s,n=this.ep();this.Kf=e.initializeLogs(null!==(r=this.lo)&&void 0!==r?r:this._instance),this.Tf=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.lo)&&void 0!==s?s:this._instance,n))}}})}catch(t){throw this.If=!1,t}}}qf(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===s.LogsQueue?t():void 0,setPersistedProperty(t,e){t===s.LogsQueue&&i(null!=e?e:[])},Ps:t=>this.Ps(t),getLibraryId:()=>Ur.LIB_NAME,getLibraryVersion:()=>Ur.LIB_VERSION}}Ps(t){return new Promise(i=>{if(Ue(this.Wc,3))i({kind:"fatal",error:xs(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:xs(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.op(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.lp(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.$.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:xs(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}})}lp(t){(0!==t||this._instance.__loaded)&&(this.Wc=Ve(t,this.Wc,3,()=>this.$.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}sp(t){this.Zl.length>0&&this.ap(t,this.Zl,this.zf,Ur.LIB_NAME,t=>{this.Zl=t}),this.Ef.length>0&&this.ap(t,this.Ef,this.Vf,ws,t=>{this.Ef=t})}ap(t,i,e,r,s){if(0!==i.length){var n=i.map(t=>t.record);s([]);var a=Jt(n,Kt(e,Ur.LIB_NAME,Ur.LIB_VERSION),r,Ur.LIB_VERSION);this._instance._send_request({method:"POST",url:this.op(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}op(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}jf(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,b(s)||(i.sessionStartTimestamp=s),b(n)||(i.lastActivityTimestamp=n)}if(null!=Ye&&null!=(t=Ye.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?W(Ye.location.href):Ye.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Ds={metrics:class{constructor(t){this._instance=t,this.$=hi("[metrics]")}initialize(){}Bf(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Df&&this.Hf===e||(null==(i=this.Df)||i.reset(),this.Hf=e,this.Df=new Yt(this.qf(),function(t){var i,e,r,s,n,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==a?void 0:a["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==a?void 0:a["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(e),this.$)),this.Df}count(t,i,e){void 0===i&&(i=1),this.Bf().count(t,i,e)}gauge(t,i,e){this.Bf().gauge(t,i,e)}histogram(t,i,e){this.Bf().histogram(t,i,e)}flush(t){if(!this.Df)return Promise.resolve();if(t){var i=this.Df.drainWindow();return i&&this.Gs(i,t),Promise.resolve()}return this.Df.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Df)||t.reset()}qf(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Gs:t=>i.Gs(t),getLibraryId:()=>Ur.LIB_NAME,getLibraryVersion:()=>Ur.LIB_VERSION}}Gs(t,e){return new Promise(r=>{var s=!1,n=t=>{s||(s=!0,clearTimeout(a),r(t))},a=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(i({method:"POST",url:this.up(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var i,e=t.statusCode;n(e>=200&&300>e?{kind:"ok"}:413===e?{kind:"too-large"}:0!==e&&408!==e&&429!==e&&500>e?{kind:"fatal",error:new Error("metrics request failed with status "+e)}:{kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}))})}up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Ls=i({},Es,Fs,Ps,Cs,Ts,Rs,Os,As,$s,Ms,Is,js,Ds),Ns=Es,Bs=Fs,zs=Ps,Hs=Cs,Us=Ts,Vs=Rs,qs=Os,Ws=As,Ks=$s,Js=Ms,Gs=Is,Xs=js,Zs=Ds;export{Ls as AllExtensions,zs as AnalyticsExtensions,Gs as ConversationsExtensions,Hs as ErrorTrackingExtensions,Js as ExperimentsExtensions,Ns as FeatureFlagsExtensions,Xs as LogsExtensions,Zs as MetricsExtensions,Us as ProductToursExtensions,Bs as SessionReplayExtensions,Vs as SiteAppsExtensions,qs as SurveysExtensions,Ks as ToolbarExtensions,Ws as TracingExtensions};
|
|
1
|
+
var t=["$set_once","$set"];function i(){return i=Object.assign?Object.assign.bind():function(t){for(var i=1;arguments.length>i;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},i.apply(null,arguments)}function e(t,i,e,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void e(t)}o.done?i(l):Promise.resolve(l).then(r,s)}function r(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)})}}var s=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function n(t,i){return-1!==t.indexOf(i)}var a=function(t){return t.trim()},o=Object.prototype,l=o.hasOwnProperty,u=o.toString,h=Array.isArray||function(t){return"[object Array]"===u.call(t)},v=t=>"function"==typeof t,d=t=>t===Object(t)&&!h(t),c=t=>{if(d(t)){for(var i in t)if(l.call(t,i))return!1;return!0}return!1},f=t=>void 0===t,p=t=>"[object String]"==u.call(t),g=t=>p(t)&&0===t.trim().length,_=t=>null===t,b=t=>f(t)||_(t),m=t=>"[object Number]"==u.call(t)&&t==t,y=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function S(t,i){return{}.toString.call(t)==="[object "+i+"]"}function x(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return E(t,Error)}}function k(t){return"u">typeof Event&&E(t,Event)}function E(t,i){try{return t instanceof i}catch(t){return!1}}var F=["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","pinterestbot","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"],P=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return F.concat(i).some(t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)})};function C(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),m(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),C(null!=s?s:e,i,e,r))}var T=class{constructor(t){this.C={},this.I=t.I,this.R=C(t.bucketSize,0,100,t.$),this.A=C(t.refillRate,0,this.R,t.$),this.O=C(t.refillInterval,0,864e5,t.$)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.C[r];return s?this.F(s,e):this.C[r]=s={tokens:this.R,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.I)||i.call(this,t)),0===s.tokens)}stop(){this.C={}}},R="Mobile",A="Android",O="Nintendo",M="PlayStation",I="Xbox",j="Windows";R.toLowerCase(),"Tablet".toLowerCase(),new RegExp(I,"i");var D,L,N,B=new RegExp("BlackBerry|PlayBook|BB10","i"),z={"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"},H=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[I,t&&t[1]||""]],[new RegExp(O,"i"),[O,""]],[new RegExp(M,"i"),[M,""]],[B,["BlackBerry",""]],[new RegExp(j,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return["Windows Phone",""];if(new RegExp(R).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=z[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[j,r]}return[j,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=f(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[A,[t[2],t[3],t[4]||"0"].join(".")]:[A,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],U="[Truncated]",V="[Unserializable]";function q(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}function W(t){return t?t.split("#")[0]:t}function K(t,i){var e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function J(t,i,e){return G.apply(this,arguments)}function G(){return(G=r(function*(t,i,e){var r;try{return yield Promise.race([t,new Promise((t,s)=>{r=K(()=>{try{null==e||e(),t()}catch(t){s(t)}},i)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function X(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return N&&e.length===L?N:(L=e.length,N=e.reduce((e,r)=>{D||(D={});var s=D[r];if(s)e[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o,l=null==(o=n[a])?void 0:o.filename,u=i[r];if(l&&u){e[l]=u,D[r]=[l,u];break}}return e},{}))}}Date,Date;var Z=class{constructor(t,i,e){void 0===e&&(e=[]),this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i){void 0===i&&(i={});var e=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(e,i,0).apply(t),s=this.buildParsingContext(i),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,e),$exception_level:"error"}}modifyFrames(t){var i=this;return r(function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&h(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,e){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(var e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return r(function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e})()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,i({},e,{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:X(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}};function Q(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:!!i&&!i.startsWith("webkit-masked-url://")&&"<anonymous>"!==i};return f(r)||(n.lineno=r),f(s)||(n.colno=s),n}var Y=(t,i)=>{var e=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return e||r?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},tt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,it=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,et=/\((\S*)(?::(\d+))(?::(\d+))\)/,rt=(t,i)=>{var e=tt.exec(t);if(e)return Q(i,e[1],"?",+e[2],+e[3]);var r=it.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=et.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=Y(r[1]||"?",r[2]);return Q(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},st=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,nt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,at=(t,i)=>{var e=st.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=nt.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}var s=e[3],n=e[1]||"?",a=Y(n,s);return Q(i,s=a[1],n=a[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},ot=/\(error: (.*)\)/;function lt(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function ut(t){for(var i=1;10>=i;i++){var e=t.length-2*i;if(0>e)break;for(var r=!0,s=0;i>s;s++)if(!lt(t[e+s],t[e+i+s])){r=!1;break}if(r){for(var n=0;i>n;n++)t[e+n]=t[e+i+n];return t.length=e+i,{start:e,length:i}}}}function ht(t,i){var e=i.start+i.length,r=dt(t,i);r&&t.splice(e+r===t.length?e:i.start,r)}function vt(t,i){for(var e=i.start;e>0&<(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function dt(t,i){for(var e=i.start+i.length,r=e;t.length>r&<(t[r],t[r-i.length]);)r++;return r-e}function ct(t,i){var e=i[0],r=t.length-(e?vt(t,e):0);for(var s of i)r-=dt(t,s);return r}function ft(t,i,e){for(var r=0;t.length>r;r++){var s=t[(i+r)%t.length],n=t[(e+r)%t.length];if(s!==n)return n>s}return!1}var pt=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=p(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?i+": "+t.message:i}isDOMException(t){return S(t,"DOMException")}isDOMError(t){return S(t,"DOMError")}},gt=class{match(t){return x(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}},_t=class{match(t){return!!S(t,"ErrorEvent")&&(null!=t.error||this.lr(t))}coerce(t,e){var r;if(null!=t.error)return e.apply(t.error);var s=e.apply(t.message);return i({},s,{stack:null!==(r=this.ur(t))&&void 0!==r?r:s.stack,synthetic:!0})}lr(t){return p(t.message)&&t.message.length>0}ur(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(p(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}},bt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,mt=class{match(t){return"string"==typeof t}coerce(t,i){var e,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}getInfos(t){var i="Error",e=t,r=t.match(bt);return r&&(i=r[1],e=r[2]),[i,e]}},yt=["fatal","error","warning","log","info","debug"];function wt(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}var St=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,r,s=this.getErrorPropertyFromObject(t);return s?i.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null==(r=i.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(k(t))return t.constructor.name;var i="name"in t?t.name:void 0;return p(i)&&!g(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var i="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(i+=" with message: '"+t.message+"'"),i}if("message"in t&&"string"==typeof t.message)return t.message;var e=this.getObjectClassName(t);return(e&&"Object"!==e?"'"+e+"'":"Object")+" captured as exception with keys: "+wt(t)}isSeverityLevel(t){return p(t)&&!g(t)&&yt.indexOf(t)>=0}getStack(t){try{return p(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:p(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(x(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},xt=class{match(t){return k(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+wt(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},kt=class{match(t){return w(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Et=class{match(t){return S(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(t))return!1;try{var i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e,r=this.getUnhandledRejectionReason(t);return w(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}},Ft="$message",Pt="$timestamp",Ct=new Set([Ft,Pt]),Tt={enabled:!0,max_bytes:32768};function Rt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:Tt.enabled,max_bytes:Ot(t.max_bytes,Tt.max_bytes)}:i({},Tt)}var At=class{constructor(t){this.ts=[],this.es=0,this.Mr=Rt(t)}setConfig(t){this.Mr=Rt(t),this.ns()}add(t){var i=function(t){var i,e,r;try{r=[],i=null!==(e=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return"[Circular]";r.push(i)}return i}}))&&void 0!==e?e:"null"}catch(t){return}try{var s=JSON.parse(i);if(!d(s))return;var n=s,a=n[Ft],o=n[Pt];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!m(o))return;return{step:n,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.Mr.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.ns())}}getAttachable(){return this.ts.map(t=>t.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}ns(){for(;this.es>this.Mr.max_bytes&&this.ts.length>0;){var t=this.ts.shift();t&&(this.es-=t.bytes)}}};function Ot(t,i){if(!m(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var $t=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Mt(t){return"string"==typeof t||t}function It(t){return"string"==typeof t?t:void 0}var jt={}.propertyIsEnumerable;function Dt(t,i){try{return Bt(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Lt(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:U};if(e.remainingNodes--,y(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==i||i.debug("Attribute "+e+" is outside the int64 range; encoding it as a string"),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var s=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:q(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:U};if(t instanceof Date){var n=t.getTime(),a=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof a?q(a):String(a)}}e.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Lt(o.call(t),i,e,r+1)}catch(t){}return h(t)?{arrayValue:{values:Nt(t,i,e,r+1)}}:{kvlistValue:{values:Bt(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:q(String(t))}}function Nt(t,i,e,r){for(var s=[],n=Math.min(t.length,1e3),a=0;n>a&&e.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(b(o))continue;s.push(Lt(o,i,e,r))}catch(t){s.push({stringValue:V})}return t.length>a&&s.push({stringValue:U}),s}function Bt(t,i,e,r){var s=[];for(var n in t)if(jt.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[n];if(_(a)||f(a))continue;s.push({key:q(n),value:Lt(a,i,e,r)})}catch(t){s.push({key:q(n),value:{stringValue:V}})}}return s}function zt(t,e,r){return i({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}var Ht={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var Ut={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Vt=Ut.info;function qt(t){try{return q(String(t))}catch(t){return V}}function Wt(t,e,r,s){var n,a=Ut[t.level||"info"]||Vt,o=a.text,l=a.number,u=(void 0===(n=m(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),h={};e.distinctId&&(h.posthogDistinctId=e.distinctId),e.sessionId&&(h.sessionId=e.sessionId),e.windowId&&(h["window.id"]=e.windowId),b(e.sessionStartTimestamp)||(h.sessionStartTimestamp=String(e.sessionStartTimestamp)),b(e.lastActivityTimestamp)||(h.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(h["url.full"]=e.currentUrl),e.screenName&&(h["screen.name"]=e.screenName),e.appState&&(h["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(h.feature_flags=e.activeFeatureFlags);var v=i({},h),d=t.attributes;if(d){var c=[];try{c=Object.keys(d)}catch(t){c=[]}for(var p of c){var g=void 0;try{g=d[p]}catch(t){g=V}Object.defineProperty(v,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:qt(t.body)},attributes:Dt(v,r)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),f(t.trace_flags)||(_.flags=t.trace_flags),_}function Kt(t,i,e){return zt(t,i,e)}function Jt(t,i,e,r){return{resourceLogs:[{resource:{attributes:Dt(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}var Gt=class{constructor(t,i,e,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Mr=i,this.$=e,this.ss=r,this.rs=s,this.ls=n,this.us=a,this.hs=null,this.cs=0,this.ds=0,this.vs=0,this.fs=0,this.ps=0,this.gs=!1,this.ys=i.maxBufferSize,this.bs=Math.max(null!==(o=i.maxQueueSize)&&void 0!==o?o:i.maxBufferSize,i.maxBufferSize),this._s=i.flushIntervalMs,this.ws=i.maxBatchRecordsPerPost,this.ks=i.rateCapWindowMs,this.Ss=i.maxLogsPerInterval}clearQueue(){this.ds++,this._instance.setPersistedProperty(s.LogsQueue,[])}reset(){this.xs(),this.fs=0,this.ps=0,this.gs=!1,this.vs=0,this.ws=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.vs=0,this.Cs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.$s(t);if(null!==r)if(r.body){if(this.Ts()){var s={record:Wt(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.ss(),this.$,null==i?void 0:i.occurredAtMs)};this.rs(()=>this.Is(s))}}else this.$.info("Log was rejected in beforeSend function")}}$s(t){var i=this.Mr.beforeSend;if(!i)return t;var e=h(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.$.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.$.error("Error in beforeSend function for log:",t),null}return r}Ts(){if(void 0===this.Ss)return!0;var t=Date.now(),i=t-this.fs;return this.ks>i&&i>=0||(this.fs=t,this.ps=0,this.gs=!1),this.Ss>this.ps?(this.ps++,!0):(this.gs||(this.$.warn("captureLog dropping logs: exceeded "+this.Ss+" logs per "+this.ks+"ms"),this.gs=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.hs||(t.hs=t.Ms().finally(()=>{t.hs=null})),t.hs})()}Ms(){var t=this;return r(function*(){var i;t.xs();var e=null!==(i=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,n=0;e.length>0&&r>n;){var a,o,l=t.ds;t.cs=0;var u=Math.min(e.length,t.ws),h=e.slice(0,u),v=Jt(h.map(t=>t.record),t.Es(),null!==(a=t.us)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.Ps(v);if(t.ds!==l)return;if("too-large"===d.kind&&h.length>1)t.ws=Math.max(1,Math.floor(h.length/2)),t.$.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.ws);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.$.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.Mr.maxBatchRecordsPerPost>t.ws&&(t.ws=Math.min(t.Mr.maxBatchRecordsPerPost,t.ws+1)),yield t.Rs(h.length),e=null!==(o=t._instance.getPersistedProperty(s.LogsQueue))&&void 0!==o?o:[],n+=h.length,"fatal"===d.kind)throw d.error}}})()}Rs(t){var i=this;return r(function*(){var e,r=Math.max(0,t-i.cs),n=null!==(e=i._instance.getPersistedProperty(s.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(s.LogsQueue,n.slice(r)),yield i.ls()})()}Es(){return Kt(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Is(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(s.LogsQueue))&&void 0!==i?i:[];this.bs>e.length||(e.shift(),this.cs++,this.$.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(s.LogsQueue,e),this.ys>e.length?this.As():this.Cs()}}As(t){void 0===t&&(t=this._s),this.Fs||(this.Fs=K(()=>{this.Fs=void 0,this.Cs()},t))}Os(){var t=Math.min(Math.max(0,this.vs-1),6);return this._s*Math.pow(2,t)}Ds(){var t=this._instance.getPersistedProperty(s.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return r(function*(){i.xs();var e=i.flush().catch(()=>{});void 0!==t?yield J(e,t):yield e})()}flushWithTimeout(t){var i=this;return r(function*(){var e=i.flush();yield J(e,t,()=>{e.catch(()=>{})})})()}Cs(){this.flush().then(()=>{this.vs=0},t=>{this.vs++,this.$.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ds()&&this.As(this.Os())})}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}},Xt=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Zt(t){return String(t)+"000000"}function Qt(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}var Yt=class{constructor(t,i,e){this._instance=t,this.Mr=i,this.$=e,this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Bs=0}count(t,i,e){void 0===i&&(i=1),this.Hs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Hs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Hs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,i=this.hs,e=function(){var e=r(function*(){i&&(yield i.catch(()=>{})),yield t.zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.hs===e&&(this.hs=null)});return this.hs=e,e}drainWindow(){if(0===this.Ls.size)return null;var t=this.Ls;return this.Ls=new Map,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Us(t)}reset(){this.Bs++,this.xs(),this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set}Hs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.$s(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.$.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var r,s;try{r=e.attributes?i({},e.attributes):void 0,s=Qt(e.type,e.name,e.unit,r)}catch(t){return void this.$.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var n=this.Ls.get(s);if(!n){if(!this.Ws())return;n={name:e.name,type:e.type,unit:e.unit,attributes:r,windowStartMs:Date.now()},this.Ls.set(s,n)}var a=this.qs.get(e.name);void 0===a?this.qs.set(e.name,e.type):a===e.type||this.js.has(e.name)||(this.js.add(e.name),this.$.warn("Metric name '"+e.name+"' is already used as a "+a+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Vs(n,e.value),this.As()}else this.$.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.$.warn("Dropping metric with empty name")}}Ws(){return this.Mr.maxSeriesPerFlush>this.Ls.size||(this.Ns||(this.Ns=!0,this.$.warn("Metric series cap reached ("+this.Mr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Vs(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Xt.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=i,r.min=Math.min(r.min,i),r.max=Math.max(r.max,i),r.bucketCounts[function(t,i){for(var e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Xt)]+=1}}$s(t){var i=this.Mr.beforeSend;if(!i)return t;var e=h(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.$.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.$.error("Error in beforeSend function for metric:",t),null}return r}As(){this.Fs||(this.Fs=K(()=>{this.Fs=void 0,this.flush().catch(t=>{this.$.error("Metrics flush failed:",t)})},this.Mr.flushIntervalMs))}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}zs(){var t=this;return r(function*(){if(0!==t.Ls.size){var i=t.Ls;t.Ls=new Map,t.Ns=!1,t.qs=new Map,t.js=new Set;var e=t.Bs,r=yield t._instance.Gs(t.Us(i));if(e===t.Bs)switch(r.kind){case"ok":return;case"retry-later":return t.Zs(i),void t.As();case"too-large":return void t.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.$.error("Failed to send metrics batch:",r.error)}}})()}Us(t){return i=this.Qs(t),e=function(t,i,e){return zt(t,i,e)}(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Dt(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Qs(t){var e=Zt(Date.now()),r=new Map;for(var s of t.values()){var n,a=Qt(s.type,s.name,s.unit,void 0),o=r.get(a);o||(o=i({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Dt(null!==(n=s.attributes)&&void 0!==n?n:{},this.$),u=Zt(s.windowStartMs);if("count"===s.type){var h,v={attributes:l,startTimeUnixNano:u,timeUnixNano:e,asDouble:null!==(h=s.total)&&void 0!==h?h:0};o.sum.dataPoints.push(v)}else if("gauge"===s.type){var d,c={attributes:l,timeUnixNano:e,asDouble:null!==(d=s.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(c)}else s.hist&&o.histogram.dataPoints.push({attributes:l,startTimeUnixNano:u,timeUnixNano:e,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:Xt})}return Array.from(r.values())}Zs(t){var i,e;for(var r of t){var s=r[0],n=r[1],a=this.Ls.get(s);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,n.windowStartMs),a.type){case"count":a.total=(null!==(i=a.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(a.hist){a.hist.count+=n.hist.count,a.hist.sum+=n.hist.sum,a.hist.min=Math.min(a.hist.min,n.hist.min),a.hist.max=Math.max(a.hist.max,n.hist.max);for(var o=0;a.hist.bucketCounts.length>o;o++)a.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else a.hist=n.hist}else this.Ws()&&this.Ls.set(s,n)}}},ti="0.8.2",ii={DEBUG:!1,LIB_VERSION:ti,LIB_NAME:"browser-common",JS_SDK_VERSION:ti},ei="u">typeof window?window:void 0,ri="u">typeof globalThis?globalThis:ei,si=null==ri?void 0:ri.navigator,ni=null==ri?void 0:ri.document,ai=null==ri?void 0:ri.location;function oi(){return!(!ei||!1===ei.navigator.onLine)}null!=ri&&ri.XMLHttpRequest&&new ri.XMLHttpRequest;var li=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={N(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;r>n;n++)s[n-1]=arguments[n];ei&&(ii.DEBUG||ei.POSTHOG_DEBUG||e)&&!f(ei.console)&&ei.console&&("__rrweb_original__"in ei.console[i]?ei.console[i].__rrweb_original__:ei.console[i])(t,...s)},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.N("error",...i)},critical(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];console.error(t,...e)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(i,e)=>li(t+" "+i,e)};return r},ui=li("[PostHog.js]"),hi=ui.createLogger;function vi(t,i){if(!b(t))if(h(t))t.forEach(i);else if(t instanceof FormData)t.forEach((t,e)=>i(t,e));else for(var e in t)l.call(t,e)&&i(t[e],e)}var di=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];for(var s of e)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function ci(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var fi=function(t){try{return t()}catch(t){return}};function pi(t,i,e,r){var s=null!=r?r:{},n=s.capture,a=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===a||a})}function gi(t){return"ph_toolbar_internal"===t.name}function _i(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!v(r))return i;try{var s=r(i);return p(s)&&s?s:i}catch(t){return ui.error("Error in get_current_url, falling back to window.location.href",t),i}}function bi(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function mi(t){return!!t&&1===t.nodeType}function yi(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function wi(t){return!!t&&3===t.nodeType}function Si(t){return!!t&&11===t.nodeType&&mi(t.host)}function xi(t){return t?a(t).split(/\s+/):[]}function ki(t,i){var e=function(t){var i,e=null==ei||null==(i=ei.location)?void 0:i.href;return f(e)?void 0:_i(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function Ei(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return xi(i)}function Fi(t){return b(t)?null:a(t).split(/(\s+)/).filter(t=>Xi(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Pi(t){var i="";return zi(t)&&!Hi(t)&&t.childNodes&&t.childNodes.length&&vi(t.childNodes,function(t){var e;wi(t)&&t.textContent&&(i+=null!==(e=Fi(t.textContent))&&void 0!==e?e:"")}),a(i)}function Ci(t){var i;return f(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var Ti=["a","button","form","input","select","textarea","label"];function Ri(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function Ai(t,i){if(f(i))return!0;var e,r=function(t){if(i.some(i=>Ri(t,i)))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function Oi(t){var i=t.parentNode;return!(!i||!mi(i))&&i}var $i=[".ph-no-autocapture","[data-ph-no-autocapture]"],Mi=["next","previous","prev",">","<"],Ii=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,ji=[".ph-no-rageclick",".ph-no-capture"],Di=["","text","search","email","password","url","tel","number"];function Li(t,i){if(!ei||Ni(t))return!1;var e,r,s,a,o;if(y(i)?(e=!!i&&ji,r=void 0,s=!1):(e=null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:ji,r=null==i?void 0:i.content_ignorelist,s=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(s&&function(t){return!(!t||!mi(t))&&(!!yi(t,"textarea")||(yi(t,"input")?n(Di,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var i=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===i||""===i}(t)))}(t))return!1;var l=Bi(t,!1).targetElementList;return!function(t,i){if(!1===t||f(t))return!1;var e;if(!0===t)e=Mi;else{if(!h(t))return!1;if(t.length>10)return ui.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(t=>{var i=t.safeText,r=t.ariaLabel;return e.some(t=>Ii(i,t)||Ii(r,t))})}(r,l.map(t=>{var i;return{safeText:Pi(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}}))&&!Ai(l,e)}var Ni=t=>!t||yi(t,"html")||!mi(t),Bi=(t,i)=>{if(!ei||Ni(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!yi(s,"body");)if(Si(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Oi(s);if(!n)break;if(i||Ti.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var a=ei.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function zi(t){for(var i=new Set,e=0,r=t;r.parentNode&&!yi(r,"body");r=r.parentNode){if(e++>=1e3||i.has(r))return!1;i.add(r);var s=Ei(r);if(n(s,"ph-sensitive")||n(s,"ph-no-capture"))return!1}if(n(Ei(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function Hi(t){return!!(yi(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||yi(t,"select")||yi(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ui=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Vi=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,qi=[16,15,14,13],Wi=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ki=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Ji=/[0-9A-Za-z_]/;function Gi(t){for(var i=0,e=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;e&&(s*=2)>9&&(s-=9),i+=s,e=!e}return i%10==0}function Xi(t,i){if(void 0===i&&(i=!0),b(t))return!1;if(p(t)){if(t=a(t),i?Ui.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(Vi.lastIndex=0;i=Vi.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of qi){var a=s+n;if(r.length>=a){var o=r.slice(s,a);if(Ui.test(o)&&Gi(o))return!0}}}return!1}(t))return!1;if(i?Wi.test(t):function(t){var i;for(Ki.lastIndex=0;i=Ki.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&Ji.test(e)&&Ji.test(r)))return!0}return!1}(t))return!1}return!0}function Zi(t){var i=Pi(t);return Xi(i=(i+" "+Qi(t)).trim())?i:""}function Qi(t){var i="";return t&&t.childNodes&&t.childNodes.length&&vi(t.childNodes,function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=Pi(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+Qi(t)).trim())}catch(t){ui.error("[AutoCapture]",t)}}),i}function Yi(t){return t.replace(/"|\\"/g,'\\"')}function te(t){var i=t.attr__class;if(i)return h(i)?i:xi(i)}var ie=class{constructor(t){this.disabled=!1===t;var i=d(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}},ee="$autocapture_disabled_server_side",re="$heatmaps_enabled_server_side",se="$exception_capture_enabled_server_side",ne="$error_tracking_suppression_rules",ae="$error_tracking_capture_extension_exceptions",oe="$web_vitals_enabled_server_side",le="$dead_clicks_enabled_server_side",ue="$product_tours_enabled_server_side",he="$logs_capture_enabled_server_side",ve="$web_vitals_allowed_metrics",de="$session_recording_remote_config",ce="$replay_override_sampling",fe="$replay_override_linked_flag",pe="$enabled_feature_flags",ge="$active_feature_flags",_e="$early_access_features",be="$feature_flag_details",me="$feature_flag_payloads",ye="$feature_flag_request_id",we="$minimal_flag_called_events",Se="$override_feature_flags",xe="$override_feature_flag_payloads",ke="$stored_person_properties",Ee="$stored_group_properties",Fe="$surveys",Pe="$surveys_loaded_at",Ce="$surveys_activated",Te="$surveys_activated_session",Re="$surveys_activated_timestamps",Ae="ph_product_tours",Oe="$flag_call_reported",$e="$flag_call_reported_session_id",Me="$feature_flag_errors",Ie="$feature_flag_evaluated_at",je="$sdk_debug_recording_script_not_loaded",De="PostHog loadExternalDependency extension not found.",Le="visibilitychange",Ne="beforeunload",Be=function(t,i){for(var e,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===i){e=n;break}}if(!h(e)||2>e.length)return"";var a=e[1];try{a=decodeURIComponent(a)}catch(t){ui.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ze=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],v=0;l.length>v;v++){var d=l[v].split("=");h(d)&&(i.includes(d[0])?u.push(d[0]+"="+e):u.push(l[v]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},He=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},Ue=(t,i)=>t>=i&&oi(),Ve=(t,i,e,r)=>{if(0===t){if(oi()){var s=i+1;return s===e&&r(),s}return i}return 0},qe="$copy_autocapture",We=hi("[AutoCapture]");function Ke(t,i){return i.length>t?i.slice(0,t)+"...":i}function Je(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!mi(i));return i}function Ge(t,e){var r,s,a=e.e,o=e.maskAllElementAttributes,l=e.maskAllText,u=e.elementAttributeIgnoreList,v=e.elementsChainAsString,d=e.disableCaptureUrlHashes;if(!mi(t))return{props:{}};for(var c=[t],g=new Set([t]),_=t;_.parentNode&&!yi(_,"body")&&1e3>c.length;)if(Si(_.parentNode)){var b=_.parentNode.host;if(g.has(b))break;g.add(b),c.push(b),_=b}else{if(!mi(_.parentNode))break;if(g.has(_.parentNode))break;g.add(_.parentNode),c.push(_.parentNode),_=_.parentNode}var m="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?c.findIndex(t=>yi(t,"button")||yi(t,"a")):-1;m>0&&(l=l||c.slice(0,m+1).some(t=>!zi(t)||Hi(t)));var y,w,S,x=[],k={},E=!1,F=!1;if(vi(c,t=>{var i=zi(t);if(yi(t,"a")){var e=t.getAttribute("href");E=!!(i&&e&&Xi(e))&&(d?W(e):e)}n(Ei(t),"ph-no-capture")&&(F=!0),x.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};Ti.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Ke(1024,Zi(t)):Ke(1024,Pi(t)));var o=Ei(t);o.length>0&&(a.classes=o.filter(function(t){return""!==t})),vi(t.attributes,function(e){var n;if((!Hi(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Xi(e.value)&&(!p(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=e.value;"class"===e.name&&(o=xi(o).join(" ")),a["attr__"+e.name]=Ke(1024,"href"===e.name&&s?W(o):o)}});for(var l=1,u=1,h=t;h=Je(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,d)),vi(function(t){if(!zi(t))return{};var i={};return vi(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&Xi(r)&&(i[e]=r)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(k,i)||(k[i]=t)})}),F)return{props:{},explicitNoCapture:F};if(m>0&&(t=c[m],x.splice(0,m)),l||(x[0].$el_text=yi(t,"a")||yi(t,"button")?Zi(t):Pi(t)),E){var P,C;x[0].attr__href=E;var T=null==(P=(t=>{var i=null==ni?void 0:ni.createElement("a");return f(i)?null:(i.href=t,i)})(E))?void 0:P.host,R=null==ei||null==(C=ei.location)?void 0:C.host;T&&R&&T!==R&&(y=E)}return{props:di((w=a.type,{$event_type:w,$ce_version:1}),v?{}:{$elements:x},{$elements_chain:(S=x,h(S)?function(t){return t.map(t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return ci(a).sort((t,i)=>{return(r=i[0])>(e=t[0])?-1:e>r?1:0;var e,r}).forEach(t=>{var i=t[1];return o[Yi(t[0].toString())]=Yi(i.toString())}),(s+=":")+ci(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:te(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return ci(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(S)):"")},null!=(r=x[0])&&r.$el_text?{$el_text:null==(s=x[0])?void 0:s.$el_text}:{},y&&"click"===a.type?{$external_click_url:y}:{},k),target:t}}var Xe=class{Js(){this.Ks=void 0,clearTimeout(this.Ys),this.Ys=void 0}Xs(t){var i;if(!zi(t))return!0;for(var e,r=null!==(i=this.lo().css_selector_ignorelist)&&void 0!==i?i:$i,s=new Set,a=t,o=function(){if(s.size>=1e3||s.has(a))return{v:!0};s.add(a);var t=a,i=Ei(t);if(n(i,"ph-no-capture")||n(i,"ph-sensitive")||Hi(t)||r.some(i=>Ri(t,i)))return{v:!0};var e=a.parentNode;a=Si(e)?e.host:e&&mi(e)?e:null};a;)if(e=o())return e.v;return!1}ao(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var i=this.Ks;i&&(t.pointerId!==i.id||Math.abs(t.clientX-i.x)>5||Math.abs(t.clientY-i.y)>5?this.Js():"pointerup"===t.type&&(i.released=!0,this.Ys=setTimeout(()=>this.Js(),0)))}else{var e;this.Js();var r=Ci(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&mi(r)&&(this.Ks={target:r,excluded:this.Xs(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(e=this.uo)?void 0:e.distinctId})}else this.Js()}ho(t){var i,e=this.Ks;this.Js();var r=Ci(t);if(null!=e&&e.released&&e.target.isConnected&&e.distinctId===(null==(i=this.uo)?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&r&&(yi(r,"html")||yi(r,"body"))){var s;if(e.excluded)return null;var a=null!==(s=this.lo().css_selector_ignorelist)&&void 0!==s?s:$i;return[r,null==ni?void 0:ni.documentElement,null==ni?void 0:ni.body].some(t=>{if(!t)return!1;var i=Ei(t);return n(i,"ph-no-capture")||n(i,"ph-sensitive")||!zi(t)||Hi(t)||a.some(i=>Ri(t,i))})?null:e.target}}constructor(t){this.co=t,this.name="autocapture",this.do=!1,this.vo=null,this.fo=!1,this.po=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.mo=!1,this.co.refresh(this.Mr),this.rageclicks=new ie(this.Mr.rageclick),this.yo=null}setup(t){this.bo(),this.uo=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.mo?i.dispose():(this._o=i,this.startIfEnabled())}dispose(){var t;this.mo||(this.mo=!0,this.uo=void 0,null==(t=this._o)||t.dispose(),this._o=void 0,this.wo())}lo(){return this.co.refresh(this.Mr),this.Mr}bo(){var t,i;return this.lo(),this.Mr.url_allowlist=null==(t=this.Mr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Mr.url_ignorelist=null==(i=this.Mr.url_ignorelist)?void 0:i.map(t=>new RegExp(t)),this.Mr}ko(){if(this.isBrowserSupported()){if(ei&&ni){var t=this.So=t=>{t=t||(null==ei?void 0:ei.event);try{if("blur"===t.type)return void this.Js();if(0===t.type.indexOf("pointer"))return void this.ao(t);var i="click"===t.type?this.ho(t):void 0;if(_(i))return;this.xo(t,"$autocapture",i)}catch(t){We.error("Failed to capture event",t)}};if(pi(ei,"blur",t),pi(ni,"submit",t,{capture:!0}),pi(ni,"change",t,{capture:!0}),pi(ni,"click",t,{capture:!0}),vi(["pointerdown","pointermove","pointerup","pointercancel"],i=>{pi(ni,i,t,{capture:!0})}),this.lo().capture_copied_text){var i=this.Co=t=>{t=t||(null==ei?void 0:ei.event);try{this.xo(t,qe)}catch(t){We.error("Failed to capture clipboard event",t)}};pi(ni,"copy",i,{capture:!0}),pi(ni,"cut",i,{capture:!0}),pi(ni,"paste",i,{capture:!0})}}}else We.info("Disabling Automatic Event Collection because this browser is not supported")}wo(){this.Js(),this.So&&(null==ei||ei.removeEventListener("blur",this.So),vi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==ni||ni.removeEventListener(t,this.So,!0)}),null==ni||ni.removeEventListener("submit",this.So,!0),null==ni||ni.removeEventListener("change",this.So,!0),null==ni||ni.removeEventListener("click",this.So,!0),this.So=void 0),this.Co&&(null==ni||ni.removeEventListener("copy",this.Co,!0),null==ni||ni.removeEventListener("cut",this.Co,!0),null==ni||ni.removeEventListener("paste",this.Co,!0),this.Co=void 0),this.do=!1}startIfEnabled(){this.isEnabled||this.Js(),!this.mo&&this.uo&&this.isEnabled&&!this.do&&(this.ko(),this.do=!0)}onRemoteConfig(t){if(!this.mo)if(this.fo=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.po=i.elementsChainAsString);var e,r=i.autocapture_opt_out;y(r)&&(null==(e=this.uo)||e.kv.set(ee,r),this.vo=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.yo=t}getElementSelectors(t,i){var e,r=[];return null==(e=this.yo)||e.forEach(e=>{var s;null==ni||null==(s=ni.querySelectorAll(e))||s.forEach(s=>{t!==s&&i!==s||n(r,e)||r.push(e)})}),r}get isEnabled(){var t,i;if(this.mo)return!1;var e=null==(t=this.uo)?void 0:t.kv.get(ee),r=this.vo,s=this.lo();if(!s.remoteRequestsDisabled&&!this.fo)return!1;var n=s.remoteRequestsDisabled&&!this.fo;if(_(r)&&!y(e)&&!n)return!1;var a=null!==(i=this.vo)&&void 0!==i?i:!!e;return!!s.enabled&&!a}xo(t,e,r){if(void 0===e&&(e="$autocapture"),this.isEnabled){var s=r||Ci(t);wi(s)&&(s=s.parentNode||null);var n,a=this.bo();"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&a.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Li(s,a.rageclick)&&this.xo(t,"$rageclick",r);var o=e===qe,l=o?i({},a,{dom_event_allowlist:void 0}):a;if(s&&function(t,i,e,r,s,n){var a;if(!ei||Ni(t))return!1;if(null!=e&&e.url_allowlist&&!ki(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&ki(e.url_ignorelist,n))return!1;if(null!=e&&e.dom_event_allowlist){var o=e.dom_event_allowlist;if(o&&!o.some(t=>i.type===t))return!1}var l=Bi(t,r),u=l.parentIsUsefulElement,h=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(f(e))return!0;var r,s=function(t){if(e.some(i=>t.tagName.toLowerCase()===i))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(h,e))return!1;if(!Ai(h,null==e?void 0:e.css_selector_allowlist))return!1;if(Ai(h,null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:$i))return!1;try{var v=ei.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return u?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(Ti.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:a.getCurrentUrl}})){var u,h=Ge(s,{e:t,maskAllElementAttributes:a.maskAllElementAttributes,maskAllText:a.maskAllText,elementAttributeIgnoreList:a.element_attribute_ignorelist,elementsChainAsString:this.po,disableCaptureUrlHashes:a.disableCaptureUrlHashes}),v=h.props;if(h.explicitNoCapture)return!1;var d=this.getElementSelectors(s,h.target);if(d&&d.length>0&&(v.$element_selectors=d),e===qe){var c=t.type||"clipboard";if("paste"!==c){var p,g,_=null==ei||null==(p=ei.getSelection())?void 0:p.toString(),b=Fi(_);if(!b)return!1;v.$selected_content=b,v.$clipboard_text_length=null!==(g=null==_?void 0:_.length)&&void 0!==g?g:0}v.$copy_type=c}return null==(u=this.uo)||u.capture(e,v).catch(t=>We.error("Failed to capture event",t)),!0}}else this.Js()}isBrowserSupported(){return v(null==ni?void 0:ni.querySelectorAll)}},Ze=class{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=d(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance._shouldDisableFlags(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}},Qe="undefined"!=typeof globalThis?globalThis:ei;Qe&&"undefined"==typeof self&&(Qe.self=Qe),Qe&&"undefined"==typeof File&&(Qe.File=function(){});var Ye=null!=ei?ei:{},tr=hi("[Dead Clicks]"),ir=()=>!0,er=class{get lazyLoadedDeadClicksAutocapture(){return this.Po}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[le]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ro(()=>{this.Ao()}):this.stop()}Ro(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?tr.error("failed to load script",i):t()})}Ao(){var t;if(ni){if(!this.Po&&null!=(t=Ye.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=d(this.instance.config.capture_dead_clicks)?i({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Po=Ye.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Po.start(ni),tr.info("starting...")}}else tr.error("`document` not found. Cannot start.")}stop(){this.Po&&(this.Po.stop(),this.Po=void 0,tr.info("stopping..."))}},rr=hi("[ExceptionAutocapture]"),sr=()=>{},nr=t=>{var i;if(v(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function ar(t,i,e){try{if(!(i in t))return sr;var r={next:t[i]},s=e(function(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];return r.next.apply(this,i)});return v(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[i]=s,()=>{if(t[i]!==s)for(var e=t[i],n=nr(e);n;){if(n.next===s)return void(n.next=r.next);n=nr(e=n.next)}else t[i]=r.next}}catch(t){return sr}}var or=hi("[TracingHeaders]"),lr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ur=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...lr],hr="<masked>",vr=["li_fat_id"];function dr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var cr=hi("[Web Vitals]"),fr=9e5,pr=["CLS","FCP","INP","LCP"],gr=["INP","LCP"],_r=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],br=hi("[RemoteConfig]"),mr=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ye._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}zl(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Ul(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return br.info("Using preloaded remote config",this.remoteConfig),void this.Wl(this.remoteConfig);if(this._instance._shouldDisableFlags())return void br.warn("Remote config is disabled. Falling back to local config.");this.zl(t=>{if(!t)return br.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ul(t=>{this.Wl(t.json,t)});this.Wl(t)})}catch(t){br.error("Error loading remote config",t),this.Wl()}}Wl(t,i){!t&&i&&(0===i.statusCode?i.error||br.warn("Failed to fetch remote config from PostHog."):br.error("Failed to fetch remote config from PostHog."));try{this._instance.Wl(t?{ok:!0,config:t}:{ok:!1})}catch(t){br.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded()}catch(t){br.error("Error loading feature flags",t)}}},yr="disabled",wr="lazy_loading",Sr=hi("[SessionRecording]"),xr=hi("[Heatmaps]");function kr(t){return d(t)&&"clientX"in t&&"clientY"in t&&m(t.clientX)&&m(t.clientY)}var Er=hi("[Product Tours]"),Fr=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(ue))},Pr=hi("[SiteApps]"),Cr="Error while initializing PostHog app with config id ",Tr=(t,i)=>null!=t&&t.then?t.then(i):i(t),Rr="events",Ar="cancelEvents",Or="survey shown";function $r(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var Mr=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},Ir=t=>t.toLowerCase(),jr={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>Mr(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!Mr(i,t))),icontains:(t,i)=>i.map(Ir).some(i=>t.map(Ir).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(Ir).every(i=>t.map(Ir).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function Dr(t,i){return!t||Object.entries(t).every(t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(null==r)return!1;var s=jr[e.operator];return!!s&&s(e.values,[String(r)])})}var Lr=hi("[Surveys]"),Nr=["popover","widget","api"],Br="SDK is not enabled or survey functionality is not yet loaded",zr="Disabled. Not loading surveys.",Hr=class{constructor(t,i){this.co=t,this.uh=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.hh=!1,this.dh=[],this.fh=null,this.ph=null,this.mo=!1,this.gh=new Set,this.onRemoteConfig=t=>{if(!this.mo&&!this.Mr.disableSurveys){if(!t.ok)return Lr.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(b(i))return Lr.warn("Flags not loaded yet. Not loading surveys.");this.mh=y(i)?i:i.length>0,Lr.info("flags response received, isSurveysEnabled: "+this.mh),this.loadIfEnabled()}}}setup(t){if(!this.mo)return this.yh=t,Tr(t.kv.initialize(),()=>{if(this.yh===t&&!this.mo){this.yh=void 0,this.uo=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.mo?i.dispose():(this._o=i,this.loadIfEnabled())}})}dispose(){var t,i,e;this.mo||(this.mo=!0,this.yh=void 0,this.uo=void 0,null==(t=this._o)||t.dispose(),this._o=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.dh=[],this.fh=null,this.gh.forEach(t=>clearTimeout(t)),this.gh.clear())}get Mr(){return this.co.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}}loadIfEnabled(){if(!this.mo&&this.uo){var t=this.Mr;if(!this._surveyManager)if(this.hh)Lr.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Lr.info(zr);else if(t.cookielessMode&&this.co.isOptedOut())Lr.info("Not loading surveys in cookieless mode without consent.");else{var i=this.co.getExtensions();if(i){if(!f(this.mh)||t.advancedEnableSurveys){var e=this.mh||t.advancedEnableSurveys;this.hh=!0;try{var r=i.generateSurveys;if(r)return this.bh(r,e),void(this.hh=!1);var s=i.loadExternalDependency;if(!s)return this._h(De),void(this.hh=!1);s(t=>{try{if(this.mo)return;var i=this.co.getExtensions();t||null==i||!i.generateSurveys?this._h("Could not load surveys script",t):this.bh(i.generateSurveys,e)}finally{this.hh=!1}})}catch(t){throw this.hh=!1,this._h("Error initializing surveys",t),t}}}else Lr.error("PostHog Extensions not found.")}}}bh(t,i){this.mo||(this._surveyManager=t(i),this._surveyEventReceiver=this.co.createEventReceiver(),Lr.info("Surveys loaded successfully"),this.wh({isLoaded:!0}))}_h(t,i){Lr.error(t,i),this.wh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.dh.push(t),this._surveyManager&&this.wh({isLoaded:!0}),()=>{this.dh=this.dh.filter(i=>i!==t)}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.uo)&&void 0!==e?e:this.uh;if(r&&!this.mo){if(this.Mr.disableSurveys)return Lr.info(zr),t([]);var s=r.kv.get(Fe);if(s&&!i)return t(s,{isLoaded:!0}),void(this.kh()&&this.getSurveys(()=>{},!0));if(this.fh)this.fh.then(i=>{this.mo||t(i.surveys,i.context)}).catch(t=>Lr.error("Error in survey callback",t));else{var n=this.Sh("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(t=>{try{return this.xh(r,t)}catch(t){return Lr.error("Error processing surveys response",t),this.xh(r,{statusCode:0,error:t})}},t=>this.xh(r,{statusCode:0,error:t}));this.fh=n;var a=()=>{this.fh===n&&(this.fh=null)};n.then(i=>{a(),this.mo||t(i.surveys,i.context)},a).catch(t=>Lr.error("Error in survey callback",t))}}}Sh(t,i){var e=this.uo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(Br)}))}xh(t,i){var e;if(this.mo)return{surveys:[],context:{isLoaded:!1,error:Br}};var r=i.statusCode;if(200!==r||!i.json){var s="Surveys API could not be loaded, status: "+r;return 0!==r?Lr.error(s):i.error||Lr.warn(s),this.ph=Date.now(),{surveys:[],context:{isLoaded:!1,error:s}}}this.ph=null;var n=i.json.surveys||[],a=n.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&($r(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t)));return a.length>0&&(null==(e=this._surveyEventReceiver)||e.register(a)),t.kv.set({[Fe]:n,[Pe]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}kh(){return this.Ch()&&!this.fh&&!this.$h()}Ch(){var t,i,e=null==(t=null!==(i=this.uo)&&void 0!==i?i:this.uh)?void 0:t.kv.get(Pe);return m(e)&&Date.now()-e>3e5}$h(){return m(this.ph)&&3e5>Date.now()-this.ph}markSurveyAsSeen(t,i){var e;(t=>{try{var i=(t=>((t,i)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(i))(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){Lr.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}wh(t){for(var i of this.dh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Lr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!b(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Lr.warn("init was not called")}Th(t){var i=null;return this.getSurveys(e=>{var r;i=null!==(r=e.find(i=>i.id===t))&&void 0!==r?r:null}),i}Ih(t){if(b(this._surveyManager))return{eligible:!1,reason:Br};var i="string"==typeof t?this.Th(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Mh(t){if(!this.co.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(b(this._surveyManager))return{eligible:!1,reason:Br};var i="string"==typeof t?this.Th(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(b(this._surveyManager))return Lr.warn("init was not called"),{visible:!1,disabledReason:Br};var i=this.Mh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return b(this._surveyManager)?(Lr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Br})):new Promise(e=>{this.getSurveys(i=>{var r,s=null!==(r=i.find(i=>i.id===t))&&void 0!==r?r:null;if(s){var n=this.Mh(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var r;if(this.co.isCapturing())if(b(this._surveyManager))Lr.warn("init was not called");else{var s="string"==typeof t?this.Th(t):t;if(null!=s&&s.id)if(Nr.includes(s.type)){var n=null==ni?void 0:ni.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){Lr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var a=setTimeout(()=>{var t,i;this.gh.delete(a),!this.mo&&this.co.isCapturing()&&(Lr.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(s,n,e),Lr.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.gh.add(a)}else this._surveyManager.renderSurvey(s,n,e);else Lr.warn("Survey element not found")}else Lr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Lr.warn("Survey not found")}}displaySurvey(t,e){var r;if(this.co.isCapturing())if(b(this._surveyManager))Lr.warn("init was not called");else{var s=this.Th(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&Lr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.Ih(s);if(!a.eligible)return void Lr.warn("Survey is not eligible to be displayed: ",a.reason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else Lr.warn("Survey not found")}}cancelPendingSurvey(t){b(this._surveyManager)?Lr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};ii.DEBUG=!1,ii.LIB_VERSION="1.429.3",ii.LIB_NAME="web";var Ur=ii,Vr=class{on(t,i){return this._a[t]||(this._a[t]=[]),this._a[t].push(i),()=>{this._a[t]=this._a[t].filter(t=>t!==i)}}emit(t,i){for(var e of this._a[t]||[])e(i);for(var r of this._a["*"]||[])r(t,i)}constructor(){this._a={}}};function qr(t,i,e){if(b(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var Wr=class{constructor(t){this._instance=t,this.Eh=new Set,this.Ph=new Set,this.Rh=new Vr,this.Ah=(t,i)=>this.Fh(t,i)&&this.Oh(t,i)&&this.Dh(t,i)&&this.Lh(t,i),this.Fh=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;f(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.Nh=null==(i=this._instance)?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t;null==(t=this.Nh)||t.call(this),this.Nh=void 0,this.Rh=new Vr}register(t){var i,e;if(!f(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Eh.add(t),null==(i=t.steps)||i.forEach(t=>{this.Ph.add((null==t?void 0:t.event)||"")})}),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Eh.forEach(t=>{var i;null==(i=t.steps)||i.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Eh.clear(),this.Ph.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Ph.has(t)||this.Ph.has(i.event))&&this.Eh.forEach(t=>{this.qh(i,t)&&this.Rh.emit("actionCaptured",t.name)})}jh(t){this.onAction("actionCaptured",i=>t(i))}qh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Ah(t,e))return!0;return!1}onAction(t,i){return this.Rh.on(t,i)}Oh(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!qr(r,i.url,i.url_matching||"contains"))return!1}return!0}Dh(t,i){return!!this.Bh(t,i)&&!!this.Hh(t,i)&&!!this.zh(t,i)}Bh(t,i){var e;if(null==i||!i.href)return!0;var r=this.Uh(t);if(r.length>0)return r.some(t=>qr(t.href,i.href,i.href_matching||"exact"));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&qr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}Hh(t,i){var e;if(null==i||!i.text)return!0;var r=this.Uh(t);if(r.length>0)return r.some(t=>qr(t.text,i.text,i.text_matching||"exact")||qr(t.$el_text,i.text,i.text_matching||"exact"));var s,n,a,o=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!o&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!b(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(o),n=i.text,a=i.text_matching||"exact",s.some(t=>qr(t,n,a)))}zh(t,i){var e,r;if(null==i||!i.selector)return!0;if(null!=t&&null!=(e=t.properties)&&null!=(e=e.$element_selectors)&&e.includes(i.selector))return!0;var s=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&s)try{return new RegExp(i.selector_regex).test(s)}catch(t){return!1}return!1}Uh(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}Lh(t,i){return null==i||!i.properties||0===i.properties.length||Dr(i.properties.reduce((t,i)=>{var e=h(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},Kr=class{constructor(t){var i;this.Wh=[],this._instance=t,this.Vh=new Map,this.Gh=new Map,this.Zh=new Map,this.Qh=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId(t=>this.Jh(t))}Kh(t){return!1}Yh(){return null}Xh(t){}tc(){}ec(t,i){return!!t&&Dr(t.propertyFilters,null==i?void 0:i.properties)}nc(t,i){var e=new Map;return t.forEach(t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach(i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}})}),e}sc(t,i,e){var r=(e===Rr?this.Vh:this.Gh).get(t),s=[];return this.rc(t=>{s=t.filter(t=>null==r?void 0:r.includes(t.id))}),s.filter(r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find(i=>i.name===t);return this.ec(n,i)})}register(t){this.oc(t,!1)}replace(t){this.oc(t,!0)}oc(t,i){var e;f(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.lc(t,i),this.ac(t,i))}ac(t,i){var e=t.filter(t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length});if(i&&this.Zh.clear(),0!==e.length){this.uc||(this.uc=new Wr(this._instance),this.uc.init(),this.uc.jh(t=>this.onAction(t)));var r=[];e.forEach(t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach(i=>{if(r.push(i),i.name){var e,s=null!==(e=this.Zh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.Zh.set(i.name,s)}})}),i?this.uc.replace(r):this.uc.register(r)}else{var s;i&&(null==(s=this.uc)||s.replace([]))}}hc(t,i){i.forEach((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach(t=>{s.includes(t)||s.push(t)}),t.set(e,s)})}lc(t,i){var e,r,s=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0}),n=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0}),a=this.nc(t,Rr),o=this.nc(t,Ar);i?(this.Vh=a,this.Gh=o):(this.hc(this.Vh,a),this.hc(this.Gh,o)),(0!==s.length||0!==n.length)&&(null!==(e=this.Nh)&&void 0!==e||(this.Nh=null==(r=this._instance)?void 0:r._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,r,s=this.cc(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.dc(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.vc([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.fc(n),void this.gc([n])}if(this.Gh.has(t)){var o=this.sc(t,i,Ar);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.vc(o.map(t=>t.id)),o.forEach(t=>this.mc(t.id)))}if(this.Vh.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.Vh.get(t)});var l=this.sc(t,i,Rr);this.yc(l.map(t=>t.id))}}onAction(t){this.Zh.has(t)&&this.yc(this.Zh.get(t)||[])}yc(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.Kh(s)?this.fc(s)&&this.bc(s):r.push(s);r.length>0&&(this.Wh=[...new Set([...this.Wh,...r])]),this.cc().info("updating activated items",{activatedItems:this.getActivatedIds()})}}fc(t){this.Wh=this.Wh.filter(i=>i!==t);var i=this._c();return!i.includes(t)&&(this.wc([...i,t]),this.kc(),!0)}vc(t){var i=new Set(t);this.Wh=this.Wh.filter(t=>!i.has(t));var e=this.Sc(),r=e.filter(t=>!i.has(t));r.length!==e.length&&(this.wc(r),0===r.length&&this.xc()),this.gc(t)}Cc(){var t,i=this.Yh();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}bc(t){if(this.Yh()){var e=this.Cc();this.Xh(i({},e,{[t]:Date.now()}))}}gc(t){if(this.Yh()){var i=this.Cc(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],a=s[1];t.includes(n)?r=!0:e[n]=a}r&&(c(e)?this.tc():this.Xh(e))}}$c(){this.Yh()&&this.tc()}getActivationTimestamp(t){if(this._c().includes(t)){var i=this.Cc()[t];return m(i)?i:void 0}}Sc(){var t,i=this.Tc();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}_c(){var t,i,e=this.Sc();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Ic()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}kc(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Mc(i)}xc(){this.Ec()}Jh(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Ic()];if(e&&e!==t){var r=this.Sc(),s=this.Cc();r.length>0&&(this.wc([]),r.filter(t=>m(s[t])).forEach(t=>this.mc(t))),this.xc(),this.$c()}}getActivatedIds(){return[...new Set([...this._c(),...this.Wh])].filter(t=>!this.Pc(t))}dispose(){var t,i,e;null==(t=this.Qh)||t.call(this),this.Qh=void 0,null==(i=this.Nh)||i.call(this),this.Nh=void 0,null==(e=this.uc)||e.dispose(),this.uc=void 0}reset(){this.Wh=[],this.Sc().length>0&&this.wc([]),this.xc(),this.$c()}getEventToItemsMap(){return this.Vh}Rc(){return this.uc}},Jr=class extends Kr{constructor(t){super(t)}Tc(){return Ce}Ic(){return Te}Yh(){return Re}Xh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Re]:t})}tc(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Re)}Kh(t){var i,e;this.rc(i=>{e=i.find(i=>i.id===t)});var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return m(r)&&r>0}Ac(){return Or}rc(t){var i;null==(i=this._instance)||i.getSurveys(t)}mc(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}cc(){return Lr}wc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Ce]:t})}Mc(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[Te]:t})}Ec(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(Te)}Pc(){return!1}dc(t,i){var e;return this.rc(t=>{e=t.find(t=>t.id===i)}),!e||function(t){var i;return $r(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e)?t===Or?"consume":"ignore":t===Or?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Gr=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);f(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},Xr=class{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){var t=null==Ye?void 0:Ye.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new Jr(this._instance)}},Zr=null!=ei&&ei.location?He(ei.location.hash,"__posthog")||He(location.hash,"state"):null,Qr="_postHogToolbarParams",Yr=hi("[Toolbar]"),ts=hi("[FeatureFlags]"),is=class{constructor(t,i){void 0===i&&(i=!1),this.Fc=!1,this.update(t,i)}update(t,i){this.Oc=((t,i)=>{var e,r,s,n,a,o,l;return{bootstrap:{featureFlags:null!==(e=null==(r=t.bootstrap)?void 0:r.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(s=null==(n=t.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(a=t.remote_config_refresh_interval_ms)&&void 0!==a?a:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(o=null!==(l=t.evaluation_contexts)&&void 0!==l?l:t.evaluation_environments)&&void 0!==o?o:[],flagKeys:h(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Fc||(ts.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Fc=!0),f(t.flag_keys)||h(t.flag_keys)||ts.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Oc}},es=hi("[FeatureFlags]"),rs=hi("[FeatureFlags]",{debugEnabled:!0}),ss="\" failed. Feature flags didn't load in time.",ns="connection_error",as=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},os=t=>{var i={};for(var e of ci(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},ls=t=>x(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),us=hi("[Error tracking]"),hs="webkit-masked-url:",vs=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],ds=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",hs],cs=["__firefox__","__gCrWeb"],fs="Refusing to render web experiment since the viewer is a likely bot",ps={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>Mr(i,t),not_regex:(t,i)=>!Mr(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},gs=hi("[Conversations]"),_s="Conversations not available yet.";function bs(){var t="",e="";try{var r=null==si?void 0:si.userAgent;if(r){var s=function(t){for(var i=0;H.length>i;i++){var e=H[i],r=e[1],s=e[0].exec(t),n=s&&(v(r)?r(s,t):r);if(n)return n}return["",""]}(r);t=s[0],e=s[1]}}catch(t){}return function(t,e){var r=function(t){if(t)return{}.hasOwnProperty.call(Ht,t)?Ht[t]:t}(t);return i({},r?{"os.name":r}:{},e?{"os.version":e}:{})}(t,e)}function ms(t,e){var r,s,n,a,o,l,u,h=null!==(r=null==t?void 0:t.flushIntervalMs)&&void 0!==r?r:3e3,v=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,d=null!=e&&e.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=f(d)?Math.max(v,2048):Math.max(v,d),p=i({},bs(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(a=null!==(o=null==p?void 0:p["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==a?a:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(l=null==p?void 0:p["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(u=null==p?void 0:p["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:p,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:v,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var ys=["debug","log","warn","error","info"],ws="console",Ss="__posthogHandledLogsRequestError",xs=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[Ss]=!0,e},ks=t=>!!t&&"object"==typeof t&&!0===t[Ss],Es={featureFlags:class{constructor(t){this.name="featureFlags",this.Dc=!1,this.featureFlagEventHandlers=[],this.$=es,this.Lc={},this.Nc={},this.qc=[],this.jc=!1,this.Bc=!1,this.Hc=0,this.zc=!1,this.Uc=!1,this.Wc=!1,this.Vc=!1,this.Gc=0,this.sn=()=>{var t=this.Zc();this.Gc=0,t&&this.reloadFeatureFlags()},this.Qc=()=>{var t,i=this.Jc;f(i)||this.Mr.remoteRequestsDisabled||!ni||"hidden"===ni.visibilityState||Date.now()-(null!==(t=this.Kc)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Yc())},this.an=()=>{"visible"===(null==ni?void 0:ni.visibilityState)&&this.Qc()},"get"in t?this.co=t:(this._instance=t,this.Xc=new is(t.config,t._shouldDisableFlags()),this.co=this.Xc)}updateConfig(t,i){var e;null==(e=this.Xc)||e.update(t,i),this.uo&&this.td()}setup(t){return this.yh=t,this.$=t.logger.createLogger("[FeatureFlags]"),Tr(t.kv.initialize(),()=>{this.yh===t&&(this.yh=void 0,this.uo=t,this.ed(t))})}ed(t){var i;if(this.uo===t)return ei&&pi(ei,"online",this.sn),this.td(),this.nd=t.registerDynamicEventProperties(()=>this.sd()?this.Lc:this.Nc),this.rd=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange(()=>{this.od(),this.ld(),this.ad()}),this.ld(),this.initialize()}td(){var t=this.Mr.refreshIntervalMs,i=!this.Mr.remoteRequestsDisabled&&ni&&!f(t)&&t>0?t:void 0;i!==this.Jc&&(this.ud(),f(i)||(this.Jc=i,this.Yc(),null!=ni&&ni.addEventListener&&pi(ni,Le,this.an)))}Yc(){f(this.Jc)||(f(this.hd)||clearInterval(this.hd),this.Kc=Date.now(),this.hd=setInterval(this.Qc,this.Jc))}ud(){f(this.hd)||(clearInterval(this.hd),this.hd=void 0,null==ni||null==ni.removeEventListener||ni.removeEventListener(Le,this.an)),this.Jc=void 0,this.Kc=void 0}destroy(){this.dd()}dispose(){this.dd()}dd(){var t,i;this.ud(),this.Hc++,this.Uc=!1,this.yh=void 0,this.uo&&(this.vd(),null==(t=this.nd)||t.dispose(),this.nd=void 0,null==(i=this.rd)||i.call(this),this.rd=void 0,this.qc=[],null==ei||ei.removeEventListener("online",this.sn),this.uo=void 0)}get Mr(){return this.co.get()}fd(t){var i;return this.pd&&t in this.pd?this.pd[t]:null==(i=this.uo)?void 0:i.kv.get(t)}od(){return!!this.pd&&(this.pd=void 0,!0)}gd(){var t;return!f(null==(t=this.uo)?void 0:t.kv.get("$enabled_feature_flags"))&&this.od()}At(t){this.md(()=>{var i;return null==(i=this.uo)?void 0:i.kv.set(t)})}yd(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t.$enabled_feature_flags){var s=this.fd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},a=i.flags||i.featureFlags,o=i.flags?Object.entries(i.flags).filter(t=>{var i=t[1];return!(null!=i&&i.failed)}).map(t=>t[0]):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,u=l?o:e&&!h(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),v=this.fd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=l||e?u:Array.from(new Set([...Object.keys(v),...Object.keys(d)])),p=!l&&!e,g=!!p||u,_=!!p||c,b={[ge]:g,[pe]:g,[me]:_};for(var m of(t.$feature_flag_details&&(b[be]=g),[ye,Ie,we]))f(t[m])||(b[m]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(b)}}Lt(t){this.md(()=>{var i;return null==(i=this.uo)?void 0:i.kv.remove(t)})}md(t){try{t()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}ld(){var t={};for(var e of[ge,me,ye,Se]){var r=this.fd(e);f(r)||(t[e]=r)}this.Lc=t;var s=i({},t),n=this.fd(pe);if(n)for(var a of Object.entries(n))s["$feature/"+a[0]]=a[1];this.Nc=s}sd(){var t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;var i=this.fd(Ie);return"number"!=typeof i||Date.now()-i>t}bd(){return!!this.sd()&&(this.Vc||this.Bc||(this.Vc=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_d(){var t=this.Mr.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}wd(){var t=this.Mr.flagKeys;if(!f(t))return t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i,e=this.Mr,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,i)=>(t[i]=r[i],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,i)=>(t[i]=a[i],t),{});return this.kd({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,r){var s,n,a=null!=r&&r.merge&&null!==(s=this.fd("$enabled_feature_flags"))&&void 0!==s?s:{},o=null!=r&&r.merge&&null!==(n=this.fd("$feature_flag_payloads"))&&void 0!==n?n:{},l=i({},a,t),u=i({},o,e),h={};for(var v of Object.entries(l)){var d=v[0],c=v[1];h[d]={key:d,enabled:Mt(c),variant:It(c),reason:void 0,metadata:f(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}}}this.kd({flags:h})}get hasLoadedFlags(){return this.jc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.fd(be),e=this.fd(Se),r=this.fd(xe);if(!r&&!e)return t||{};var s=di({},t||{});for(var n of[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])]){var a,o,l=s[n],u=null==e?void 0:e[n],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,v=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,d=null==r?void 0:r[n],c=i({},l,{enabled:h,variant:h?null!=v?v:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),v!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),d&&(c.metadata=i({},null==l?void 0:l.metadata,{payload:d,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),s[n]=c}return this.Dc||(this.$.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Dc=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{var r=t[e];return{key:e,enabled:Mt(r),variant:It(r),payload:$t(i[e])}})}getFlagVariants(){var t=this.fd(pe),i=this.fd(Se);if(!i)return t||{};for(var e=di({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Dc||(this.$.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.Dc=!0),e}getFlagPayloads(){var t=this.fd(me),i=this.fd(xe);if(!i)return t||{};for(var e=di({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Dc||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.Dc=!0),e}reloadFeatureFlags(){this.zc||this.Mr.featureFlagsDisabled||this.Zc()||(this.Bc&&(this.Uc=!0),this.Sd||(this.qc.slice().forEach(t=>{try{t()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.Sd=setTimeout(()=>{this.xd()},5)))}vd(){clearTimeout(this.Sd),this.Sd=void 0}onReloading(t){return this.qc.push(t),()=>{this.qc=this.qc.filter(i=>i!==t)}}ensureFlagsLoaded(){this.jc||this.Bc||this.Sd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.zc=t}resetFlagCallReported(){this.Lt(Oe)}xd(t){this.vd();var e=this.uo;if(e&&!this.Mr.remoteRequestsDisabled&&!this.Zc())if(this.Bc)this.Uc=!0;else{var r={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},e.initialPersonProperties,this.fd("$stored_person_properties")||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.fd(Ee),timezone:dr()};f(e.deviceId)||(r.$device_id=e.deviceId),(null!=t&&t.disableFlags||this.Mr.featureFlagsDisabled)&&(r.disable_flags=!0);var s=this._d();s.length&&(r.evaluation_contexts=s);var n=this.wd();f(n)||(r.flag_keys=n);var a=this.Mr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),l=this.Hc;this.Bc=!0;var u=()=>{this.Uc&&(this.Uc=!1,this.xd())},h=t=>{this.Bc=!1,l===this.Hc?(this.At({[Me]:[ns]}),this.$.error("Feature flag request failed",t),this.gd()&&this.ad(!0),u()):u()};try{e.sendRequest(o,{target:"flags",method:"POST",body:r,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(t=>{var i,e,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.Bc=!1,l===this.Hc){if(this.Cd(t.statusCode),n||this.Uc||(this.$anon_distinct_id=void 0),!r.disable_flags||this.Uc){this.Wc=!n;var o=[];t.error?o.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?ns:"unknown_error"):200!==t.statusCode&&o.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var h=!(null==(e=s.quotaLimited)||!e.includes("feature_flags"));h&&o.push("quota_limited"),this.At({[Me]:o}),h?this.$.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):r.disable_flags||this.kd(s,n,{partialResponse:a}),u()}}else u()}).catch(h)}catch(t){h(t)}}}Zc(){return Ue(this.Gc,3)}Cd(t){this.Gc=Ve(t,this.Gc,3,()=>this.$.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this.Wc)if(this.jc||this.getFlags()&&this.getFlags().length>0){if(!this.bd()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.$.warn('getFeatureFlag for key "'+t+ss)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i;return null==(i=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:i.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.Wc)if(this.jc||this.getFlags()&&this.getFlags().length>0){if(!this.bd()){var r,s=this.getFlagVariants(),n=t in s,a=s[t],o=this.getFlagPayloads()[t],l=String(a),u=this.fd("$feature_flag_request_id")||void 0,v=this.fd("$feature_flag_evaluated_at")||void 0,d=this.fd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var c,p=null==(c=this.uo)?void 0:c.session.sessionId,g=this.fd($e);p&&p!==g&&(d={},r=p)}if(e.send_event||!("send_event"in e))if(t in d&&d[t].includes(l))r&&this.At({[Oe]:d,[$e]:r});else{var _,b,m,y,w,S,x,k,E,F,P,C,T;h(d[t])?d[t].push(l):d[t]=[l],this.At(i({[Oe]:d},r?{[$e]:r}:{}));var R=this.getFeatureFlagDetails(t),A=[...null!==(_=this.fd("$feature_flag_errors"))&&void 0!==_?_:[]];f(a)&&A.push("flag_missing");var O={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:v,$feature_flag_bootstrapped_response:null!==(b=null==(m=this.Mr.bootstrap)||null==(m=m.featureFlags)?void 0:m[t])&&void 0!==b?b:null,$feature_flag_bootstrapped_payload:null!==(y=null==(w=this.Mr.bootstrap)||null==(w=w.featureFlagPayloads)?void 0:w[t])&&void 0!==y?y:null,$used_bootstrap_value:!this.Wc};f(null==R||null==(S=R.metadata)?void 0:S.has_experiment)||(O.$feature_flag_has_experiment=R.metadata.has_experiment),f(null==R||null==(x=R.metadata)?void 0:x.version)||(O.$feature_flag_version=R.metadata.version);var M=null!==(k=null==R||null==(E=R.reason)?void 0:E.description)&&void 0!==k?k:null==R||null==(F=R.reason)?void 0:F.code;M&&(O.$feature_flag_reason=M),null!=R&&null!=(P=R.metadata)&&P.id&&(O.$feature_flag_id=R.metadata.id),f(null==R?void 0:R.original_variant)&&f(null==R?void 0:R.original_enabled)||(O.$feature_flag_original_response=f(R.original_variant)?R.original_enabled:R.original_variant),null!=R&&null!=(C=R.metadata)&&C.original_payload&&(O.$feature_flag_original_payload=null==R||null==(T=R.metadata)?void 0:T.original_payload),A.length&&(O.$feature_flag_error=A.join(",")),this.$d(O)}else r&&this.At({[Oe]:d,[$e]:r});if(n)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:$t(o)}}}else this.$.warn('getFeatureFlagResult for key "'+t+ss)}$d(t){try{var i;null==(i=this.uo)||i.capture("$feature_flag_called",t).catch(t=>{this.$.error("Failed to capture feature flag call",t)})}catch(t){this.$.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Td(t,i)}Td(t,i){var e=this;return r(function*(){var r=e.uo;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e._d();n.length&&(s.evaluation_contexts=n);var a,o=e.wd();f(o)||(s.flag_keys=o);try{var l;a=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.Mr.compression,sentAt:"body",timeoutMs:e.Mr.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void e.$.error("Remote config feature flag request failed",t)}try{i(a)}catch(t){e.$.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.Wc)return i.defaultValue;if(!(this.jc||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+t+ss),i.defaultValue;var e=this.getFeatureFlag(t,i);return f(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.kd(t,i,e)}kd(t,e,r){if(this.uo){this.jc=!0;var s=function(t,e,r,s,n,a){void 0===e&&(e={}),void 0===r&&(r={}),void 0===s&&(s={}),void 0===a&&(a=es);var o=((t,e)=>{var r=t.flags;return r?i({},t,{featureFlags:Object.fromEntries(Object.keys(r).map(t=>{var i;return[t,null!==(i=r[t].variant)&&void 0!==i?i:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>r[t].enabled).filter(t=>{var i;return!f(null==(i=r[t].metadata)?void 0:i.payload)}).map(t=>{var i;return[t,null==(i=r[t].metadata)?void 0:i.payload]}))}):(t.featureFlags&&e.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,a),l=o.flags,u=o.featureFlags,v=o.featureFlagPayloads;if(u){var d=t.requestId,c=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[ge]:u,[pe]:p,[we]:!1}}var _=u,b=v,m=l;if(null!=n&&n.partialResponse){var y=Object.keys(_),w=b||{};_=i({},e,_),b=i({},r,w),y.forEach(t=>{var i;t in w||null==(i=b)||delete i[t]}),m=i({},s,m)}else if(t.errorsWhileComputingFlags)if(l){var S=new Set(Object.keys(l).filter(t=>{var i;return!(null!=(i=l[t])&&i.failed)}));_=i({},e,Object.fromEntries(Object.entries(_).filter(t=>S.has(t[0]))));var x=Object.fromEntries(Object.entries(b||{}).filter(t=>S.has(t[0])));b=i({},r,x),S.forEach(t=>{var i;t in x||null==(i=b)||delete i[t]}),m=i({},s,Object.fromEntries(Object.entries(m||{}).filter(t=>S.has(t[0]))))}else _=i({},e,_),b=i({},r,b),m=i({},s,m);return i({[ge]:Object.keys(os(_)),[pe]:_||{},[me]:b||{},[be]:m||{},[we]:!0===t.minimalFlagCalledEvents},d?{[ye]:d}:{},c?{[Ie]:c}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.$);if(s)if(!1===(null==r?void 0:r.persist)){var n=!f(this.uo.kv.get(pe));this.pd=s,n||this.At(s)}else this.od(),this.yd(s,t,!(null==r||!r.partialResponse)),this.At(s);else e&&this.gd();e||(this.Vc=!1),this.ad(e)}}override(t,i){void 0===i&&(i=!1),this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Id(t)}Id(t){if(this.uo){if(!1===t)return this.Lt([Se,xe]),this.ad(),void rs.info("All overrides cleared");if(h(t))return this.At({[Se]:as(t)}),this.ad(),void rs.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.Dc=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[Se]=h(s)?as(s):s),n&&(r[xe]=n),Object.keys(r).length&&this.At(r),!1===s&&!1===n?this.Lt([Se,xe]):!1===s?this.Lt(Se):!1===n&&this.Lt(xe),this.ad(),!1===s?rs.info("Flag overrides cleared"):s&&rs.info("Flag overrides set",{flags:s}),void(!1===n?rs.info("Payload overrides cleared"):n&&rs.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.At({[Se]:t}),this.ad(),void rs.info("Flag overrides set",{flags:t});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.jc){var i=this.Md(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.$.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.fd("$early_access_features")||[]).find(i=>i.flagKey===t),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[ge]:[t],[pe]:[t],[ke]:Object.keys(a)}),this.At({[ge]:Object.keys(os(l)),[pe]:l,[ke]:i({},this.fd("$stored_person_properties")||{},a)}),this.ad();try{var u;null==(u=this.uo)||u.capture("$feature_enrollment_update",o).catch(t=>{this.$.error("Failed to capture early access feature enrollment",t)})}catch(t){this.$.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.fd(_e);!r||i?this.Ed(t,e):t(r)}Ed(t,i){var e=this;return r(function*(){var r=e.uo;if(r){var s,n=i?"&"+i.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;s=a.json.earlyAccessFeatures,e.At({[_e]:s})}catch(t){return void e.$.error("Early access feature request failed",t)}try{t(s)}catch(t){e.$.error("Early access feature callback failed",t)}}})()}Md(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}ad(t){this.ld();var i=this.Md(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.$.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Pd(t,i)}Pd(t,e){void 0===e&&(e=!0);var r=this.fd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this.At({[ke]:i({},r,a,s)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.fd("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.At({[ke]:r}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Lt(ke),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.fd("$stored_group_properties")||{},s=i({},r);for(var n of Object.keys(t))s[n]=i({},r[n],t[n]);this.At({[Ee]:s}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.fd("$stored_group_properties")||{};this.At({[Ee]:i({},e,{[t]:{}})})}else this.Lt(Ee)}reset(){this.Hc++,this.Uc=!1,this.Lc={},this.Nc={},this.pd=void 0,this.jc=!1,this.zc=!1,this.Wc=!1,this.$anon_distinct_id=void 0,this.vd(),this.Dc=!1,this.Gc=0}}},Fs={sessionRecording:class{get Mr(){return this._instance.config}get ya(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Rd)||!t.isStarted)}get status(){var t,i;return"awaiting_config"===this.Ad||"missing_config"===this.Ad?this.Ad:null!==(t=null==(i=this.Rd)?void 0:i.status)&&void 0!==t?t:this.Ad}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Ad=yr,this.Fd=void 0,this.Od=!1,this.Ke=(()=>{var t;if(null==ni||!ni.visibilityState||"visible"===ni.visibilityState)return!0;var i=null==ei||null==(t=ei.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some(t=>"visible"===t.name)})(),this.an=()=>{var t;"visible"===(null==ni?void 0:ni.visibilityState)&&(this.Ke=!0,null==(t=this.Rd)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Sr.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Mr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=ni&&ni.addEventListener&&pi(ni,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.Od=!0,null==ni||null==ni.removeEventListener||ni.removeEventListener("visibilitychange",this.an),e?this.Dd(!0):this.stopRecording()}get Ld(){var t,i=!(null==(t=this._instance.get_property(de))||!t.enabled),e=!this.Mr.disable_session_recording,r=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return ei&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.Od||this.Ld&&null!=(i=this.Rd)&&i.isStarted)){var e=!f(Object.assign)&&!f(Array.from);this.Ld&&e?(this.Nd(t),Sr.info("starting")):(this.Ad=yr,this.stopRecording())}}Nd(t){var i,e;if(this.Ld)if("awaiting_config"!==this.Ad&&"missing_config"!==this.Ad&&(this.Ad=wr),null!=Ye&&null!=(i=Ye.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=Ye.__PosthogExtensions__)&&e.initSessionRecording)this.qd(t);else{var r,s=this._instance.sessionManager;null==(r=Ye.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.jd,i=>{if(!this.Od&&this.Ld&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[je]:!0}),Sr.error("could not load recorder",i)):void this.qd(t);this.Ad=yr})}}stopRecording(){var t,i;null==(t=this.Fd)||t.call(this),this.Fd=void 0,null==(i=this.Rd)||i.stop()}Dd(t){var i,e;void 0===t&&(t=!1),null==(i=this.Fd)||i.call(this),this.Fd=void 0,null==(e=this.Rd)||e.discard({discardProducerEvents:t})}Bd(){var t,i;null==(t=this.ya)||t.unregister("$session_is_sampled"),null==(i=this.ya)||i.unregister("$replay_sample_rate")}Hd(t,i){if(b(t))return null;var e,r=m(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(Sr.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}zd(t){if(this.ya){var e,r,s=this.ya,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Hd(null==(e=this.Mr.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Hd(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;b(o)&&this.Bd();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[de]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.Fd)||e.call(this),this.Fd=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.zd(i),void this.Dd()):(this.zd(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.Ad&&(this.Ad="missing_config",Sr.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.Rd)&&e.log?this.Rd.log(t,i):Sr.warn("log called before recorder was ready")}get jd(){var t;return(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.get_property("$session_recording_remote_config"))||null==(t=t.scriptConfig)?void 0:t.script)||"lazy-recorder"}Ud(){var t,i=this._instance.get_property(de);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return Sr.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!b(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}qd(t){var i,e,r;if(!this.Od&&this.Ld&&this._instance.sessionManager){if(null==(i=Ye.__PosthogExtensions__)||!i.initSessionRecording)return Sr.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[je]:!0});var s;if(this.Rd||(this.Rd=null==(s=Ye.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.Ke),this.Rd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ud()){if("missing_config"===this.Ad||"awaiting_config"===this.Ad)return;return this.Ad="awaiting_config",Sr.info("persisted remote config is stale, requesting fresh config before starting"),void new mr(this._instance).load()}this.Ad=wr,null==(e=(r=this.Rd).setDocumentWasEverVisible)||e.call(r,this.Ke),this.Rd.start(t)}else this.Ad=yr}onRRwebEmit(t){var i;null==(i=this.Rd)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Rd||null==(t=this.ya)||t.register({[fe]:!0}),null==(i=this.Rd)||i.overrideLinkedFlag()}overrideSampling(){var t,i;this.Rd||null==(t=this.ya)||t.register({[ce]:!0}),null==(i=this.Rd)||i.overrideSampling()}overrideTrigger(t){var i,e;this.Rd||null==(i=this.ya)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.Rd)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Rd)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Rd)||!e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t;null==(t=this.Rd)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Ps={autocapture:class extends Xe{constructor(t){super(new Ze(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.Wd=this.Vd()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Gd();return!!(t.path||t.search||this.Zd(t))}startIfEnabled(){this.isEnabled&&(ui.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Wd=this.Vd(),this.startIfEnabled()}stop(){this.Qd&&this.Qd(),this.Qd=void 0,this.Jd&&this.Jd(),this.Jd=void 0,ui.info("History API monitoring stopped")}monitorHistoryChanges(){ei&&ei.history&&(this.Kd("pushState"),this.Kd("replaceState"),this.Yd(),this.Zd()&&this.Xd())}Kd(t){var i;if(ei&&(null==(i=ei.history[t])||!i.__posthog_wrapped__)){var e=this;ar(ei.history,t,i=>function(r,s,n){i.call(this,r,s,n),e.tv(t)})}}Vd(){var t=null==ei?void 0:ei.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Gd(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:d(t)?t:{}}Zd(t){return void 0===t&&(t=this.Gd()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}ev(t){var i=this.Gd(),e=this.Wd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Zd(i)&&t.hash!==e.hash))}tv(t){try{var i=this.Vd();if(!i)return;this.ev(i)&&this._instance.capture("$pageview",{navigation_type:t}),this.Wd=i}catch(i){ui.error("Error capturing "+t+" pageview",i)}}Yd(){if(!this.Qd){var t=()=>{this.tv("popstate")};pi(ei,"popstate",t),this.Qd=()=>{ei&&ei.removeEventListener("popstate",t)}}}Xd(){if(!this.Jd){var t=()=>{this.tv("hashchange")};pi(ei,"hashchange",t),this.Jd=()=>{ei&&ei.removeEventListener("hashchange",t)}}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var i;this.iv=!1,this.do=!1,this.nv=null,this.instance=t,this.iv=!(null==(i=this.instance.persistence)||!i.props[re]),this.rageclicks=new ie(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return d(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return b(this.Mr.capture_heatmaps)?b(this.Mr.enable_heatmaps)?this.iv:this.Mr.enable_heatmaps:!1!==this.Mr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.do)return;xr.info("starting..."),this.sv(),this.an()}else{var t;clearInterval(null!==(t=this.nv)&&void 0!==t?t:void 0),this.rv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[re]:e}),this.iv=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}ov(t){kr(t.originalEvent)&&this.Cr(t.originalEvent,"deadclick")}an(){this.nv&&clearInterval(this.nv),this.nv="visible"===(null==ni?void 0:ni.visibilityState)?setInterval(this.aa.bind(this),this.flushIntervalMilliseconds):null}sv(){ei&&ni&&(this.lv=this.aa.bind(this),pi(ei,Ne,this.lv),this.av=t=>this.Cr(t||(null==ei?void 0:ei.event)),pi(ni,"click",this.av,{capture:!0}),this.uv=t=>this.hv(t||(null==ei?void 0:ei.event)),pi(ni,"mousemove",this.uv,{capture:!0}),this.dv=new er(this.instance,ir,this.ov.bind(this)),this.dv.startIfEnabledOrStop(),this.vv=this.an.bind(this),pi(ni,Le,this.vv),this.do=!0)}rv(){var t;ei&&ni&&(this.lv&&ei.removeEventListener(Ne,this.lv),this.av&&ni.removeEventListener("click",this.av,{capture:!0}),this.uv&&ni.removeEventListener("mousemove",this.uv,{capture:!0}),this.vv&&ni.removeEventListener(Le,this.vv),clearTimeout(this.fv),null==(t=this.dv)||t.stop(),this.do=!1)}pv(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),a=function(t,i,e){for(var r=t;r&&mi(r)&&!yi(r,"body");){if(r===e)return!1;var s=void 0;try{var a,o,l;s=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:ei)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(n(i,s))return!0;r=Oi(r)}return!1}(Ci(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:e),target_fixed:a,type:i}}Cr(t,e){var r;if(void 0===e&&(e="click"),!bi(t.target)&&kr(t)){var s=this.pv(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Li(Ci(t),this.instance.config.rageclick)&&this.Hs(i({},s,{type:"rageclick"})),this.Hs(s)}}hv(t){!bi(t.target)&&kr(t)&&(clearTimeout(this.fv),this.fv=setTimeout(()=>{this.Hs(this.pv(t,"mousemove"))},500))}Hs(t){if(ei){var i=this.Mr.disable_capture_url_hashes?W(ei.location.href):ei.location.href,e=this.Mr.custom_personal_data_properties,r=ze(i,this.Mr.mask_personal_data_properties?[...lr,...e||[]]:[],hr);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}aa(){this.Rt&&!c(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:er,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.iv=!1,this.do=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.gv=()=>{clearTimeout(this.mv),this.mv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",i({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.yv=t=>{var e;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},b(null==t?void 0:t.name)||b(null==t?void 0:t.value))cr.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.bv(r);if(!f(s)){var n=m(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this._v||this._v>t.value){this.Rt.navigationKey!==n&&(this.gv(),this.mv=setTimeout(this.gv,this.flushToCaptureTimeoutMs)),f(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=f(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=i({},t,r?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,d(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of _r){var h="url"===u&&"string"==typeof t.attribution[u]?this.bv(t.attribution[u]):t.attribution[u];f(h)||(l[u]=h)}o.attribution=l}else delete o.attribution;f(a)||(o.$session_id=a.sessionId,o.$window_id=a.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.gv()}else cr.error("Ignoring metric with value >= "+this._v,t)}}},this.wv=()=>{if(!this.do){var t,e,r,s,n=!1,a=Ye.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Sv])||("web-vitals"===this.Sv&&f(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!f(l)){var u=l.withoutAttribution,h=this.attributionMetrics;n=!f(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,e=h.indexOf("CLS")>-1?l.onCLS:(null==u?void 0:u.onCLS)||l.onCLS,r=h.indexOf("FCP")>-1?l.onFCP:(null==u?void 0:u.onFCP)||l.onFCP,s=h.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(t&&e&&r&&s){var v={reportSoftNavs:this.useSoftNavs},d=n&&this.attributionMetrics.indexOf("INP")>-1?i({},v,{includeProcessedEventEntries:!1}):v;this.allowedMetrics.indexOf("LCP")>-1&&t(this.yv.bind(this),v),this.allowedMetrics.indexOf("CLS")>-1&&e(this.yv.bind(this),v),this.allowedMetrics.indexOf("FCP")>-1&&r(this.yv.bind(this),v),this.allowedMetrics.indexOf("INP")>-1&&s(this.yv.bind(this),d),this.do=!0}else cr.error("web vitals callbacks not loaded - not starting")}},this.iv=!(null==(e=this._instance.persistence)||!e.props[oe]),this.startIfEnabled()}get xv(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=d(this.xv)?null==(t=this.xv)?void 0:t.web_vitals_allowed_metrics:void 0;return b(e)?(null==(i=this._instance.persistence)?void 0:i.props.$web_vitals_allowed_metrics)||pr:e}get flushToCaptureTimeoutMs(){return(d(this.xv)?this.xv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=d(this.xv)?this.xv.web_vitals_attribution:void 0;return y(t)?t?pr:[]:h(t)?t:gr}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=d(this.xv)?this.xv.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get _v(){var t=d(this.xv)&&m(this.xv.__web_vitals_max_value)?this.xv.__web_vitals_max_value:fr;return t>0&&6e4>=t?fr:t}get isEnabled(){var t=null==ai?void 0:ai.protocol;if("http:"!==t&&"https:"!==t)return cr.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=d(this.xv)?this.xv.web_vitals:y(this.xv)?this.xv:void 0;return y(i)?i:this.iv}startIfEnabled(){this.isEnabled&&!this.do&&(cr.info("enabled, starting..."),this.Ro(this.wv))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=d(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=d(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[oe]:e}),this._instance.persistence.register({[ve]:r})),this.iv=e,this.startIfEnabled()}}}get Sv(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ro(t){var i=Ye.__PosthogExtensions__,e=this.Sv,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&f(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,i=>{i?cr.error("failed to load script",i):t()})}bv(t){var i=t||(null==ei?void 0:ei.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?W(i):i,r=this._instance.config.custom_personal_data_properties;return ze(e,this._instance.config.mask_personal_data_properties?[...lr,...r||[]]:[],hr)}cr.error("Could not determine current URL")}}},Cs={exceptionObserver:class{constructor(t){var e;this.wv=()=>{var t;if(ei&&this.isEnabled&&null!=(t=Ye.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=Ye.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=Ye.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ye.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Cv&&this.Mr.capture_unhandled_errors&&(this.Cv=i(this.captureException.bind(this))),!this.$v&&this.Mr.capture_unhandled_rejections&&(this.$v=e(this.captureException.bind(this))),!this.Tv&&this.Mr.capture_console_errors&&(this.Tv=r(this.captureException.bind(this)))}catch(t){rr.error("failed to start",t),this.Iv()}}},this._instance=t,this.Mv=!(null==(e=this._instance.persistence)||!e.props[se]),this.wt=new T(i({},function(t){var i,e,r,s;return void 0===t&&(t={}),{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,$:rr})),this.Mr=this.Ev(),this.startIfEnabledOrStop()}Ev(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return d(t)?e=i({},e,t):(f(t)?this.Mv:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(rr.info("enabled"),this.Iv(),this.Ro(this.wv)):this.Iv()}Ro(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return rr.error("failed to load script",i);t()})}Iv(){var t,i,e;null==(t=this.Cv)||t.call(this),this.Cv=void 0,null==(i=this.$v)||i.call(this),this.$v=void 0,null==(e=this.Tv)||e.call(this),this.Tv=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Mv=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[se]:this.Mv}),this.Mr=this.Ev(),this.startIfEnabledOrStop())}}onConfigChange(){this.Mr=this.Ev()}captureException(t){try{var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(s))return void rr.info("Skipping exception capture because of client rate limiting.",{exception:s});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var e,r;this.Pv=[],this.Rv=new Z([new pt,new Et,new _t,new gt,new xt,new St,new mt,new kt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=Math.min(a.length,s+1e3),l=[],u=s;o>u;u++){var h=a[u];if(1024>=h.length){var v=ot.test(h)?h.replace(ot,"$1"):h;if(!v.match(/\S*Error: /)){for(var d of r){var c=d(v,t);if(c){n.push(c);var f=ut(n);if(f){for(var p=l.length-1;p>=0;p--){var g=l[p];if(f.start>=g.start+g.length)break;l.pop()}l.push(f)}break}}if(ct(n,l)>=50)break}}}var _=[...l].sort((t,i)=>i.start-t.start),b=_[_.length-1];if(b){var m=vt(n,b);for(var y of(n.splice(b.start-m,m),_))y.start-=m}for(var w of _)ht(n,w);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){for(var i=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),e=0,r=1;i.length>r;r++)ft(i,r,e)&&(e=r);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map(t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||"?"});var r})}(n)}}("web:javascript",rt,at)),this._instance=t,this.Pv=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==e?e:[],this.Av=Rt(this.Fv()),this.Ov=new At(this.Av)}onConfigChange(){this.Av=Rt(this.Fv()),this.Ov.setConfig(this.Av)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],a=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Pv=n,this._instance.persistence&&this._instance.persistence.register({[ne]:this.Pv,[ae]:a})}}}get Dv(){var t,i,e=!!this._instance.get_property(ae);return null!==(t=null!==(i=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==i?i:e)&&void 0!==t&&t}buildProperties(t,i){return this.Rv.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,e){if(this.Av.enabled)try{if(!p(t)||0===t.trim().length)return void us.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce((e,r)=>Ct.has(r)?(i.push(r),e):(e[r]=t[r],e),{}),droppedKeys:i}}(this.Lv(e)),s=r.sanitizedProperties,n=r.droppedKeys;n.length>0&&us.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Ov.add(i({[Ft]:t,[Pt]:(new Date).toISOString()},s))}catch(t){us.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.Nv(i)){if(this.qv(i))return this.jv("Exception dropped: matched a suppression rule"),void us.info("Skipping exception capture because a suppression rule matched");if(!this.Dv&&this.Bv(i))return this.jv("Exception dropped: thrown by a browser extension"),void us.info("Skipping exception capture because it was thrown by an extension");if(!this.Dv&&this.Hv(i))return this.jv("Exception dropped: thrown by an injected browser script"),void us.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.zv(i))return this.jv("Exception dropped: thrown by the PostHog SDK"),void us.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.Av.enabled&&b(t.$exception_steps)?this.Uv(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return s&&this.Ov.clear(),s}catch(t){return ls(t)||us.error("Failed to capture exception event. Dropping this exception.",t),void this.Ov.clear()}}catch(t){return void(ls(t)||us.error("Failed to process exception event. Ignoring this exception.",t))}var n}Uv(t){try{var e=this.Ov.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(i){return us.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}jv(t){this.Av.enabled&&this.Ov.add({[Ft]:t,[Pt]:(new Date).toISOString()})}Lv(t){return d(t)?i({},t):{}}Fv(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}qv(t){if(0===t.length)return!1;try{var i=t.reduce((t,i)=>{var e=i.type,r=i.value;return p(e)&&e.length>0&&t.$exception_types.push(e),p(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.Pv.some(t=>{var e=t.values.map(t=>{var e=jr[t.operator],r=i[t.key];if(!e||!r)return!1;var s=h(t.value)?t.value:[t.value];return s.length>0&&e(s,r)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return us.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Bv(t){var i=t.flatMap(t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(t=>{var i=t.filename;return!!i&&ds.some(t=>i.startsWith(t))});return 0!==e.length&&(!e.every(t=>{var i=t.filename;return!!i&&i.startsWith(hs)})||t.some(t=>{var i=t.value;return"NoResponse"===t.type||p(i)&&vs.some(t=>{var e=t.value;return t.exact?i===e:i.includes(e)})})&&!i.some(t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(hs))}))}Hv(t){return t.some(t=>{var i=t.value;return p(i)&&cs.some(t=>i.includes(t))})}zv(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[];return null!==(r=null==(s=n[n.length-1])||null==(s=s.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Nv(t){return!b(t)&&h(t)}}},Ts=i({productTours:class{get ya(){return this._instance.persistence}constructor(t){this.Wv=null,this.Vv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.ya&&this.ya.register({[ue]:!!i.productTours}),!Fr(this._instance))return!this.Wv&&b(null==(e=this.ya)?void 0:e.props.ph_product_tours)||Er.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Wv)||r.stop(),this.Wv=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Wv&&Fr(this._instance)&&this.Ro(()=>this.Gv())}Ro(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",i=>{i?Er.error("Could not load product tours script",i):t()})}Gv(){var t;!this.Wv&&null!=(t=Ye.__PosthogExtensions__)&&t.generateProductTours&&(this.Wv=Ye.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!h(this.Vv)||i){var e=this.ya;if(e){var r=e.props[Ae];if(h(r)&&!i)return this.Vv=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(Fr(this._instance)){var r=i.statusCode;if(200!==r||!i.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?i.error||Er.warn(s):Er.error(s),void t([],{isLoaded:!1,error:s})}var n=h(i.json.product_tours)?i.json.product_tours:[];this.Vv=n,e&&e.register({[Ae]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Vv,{isLoaded:!0})}getActiveProductTours(t){b(this.Wv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Wv.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.Wv)||i.showTourById(t)}previewTour(t){this.Wv?this.Wv.previewTour(t):this.Ro(()=>{var i;this.Gv(),null==(i=this.Wv)||i.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Wv)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Wv)||t.nextStep()}previousStep(){var t;null==(t=this.Wv)||t.previousStep()}clearCache(){var t;this.Vv=null,null==(t=this.ya)||t.unregister(Ae)}resetTour(t){var i;null==(i=this.Wv)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.Wv)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.Wv)||i.cancelPendingTour(t)}}},Es),Rs={siteApps:class{constructor(t){this._instance=t,this.Zv=0,this.Qv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Jv(t,i){if(i){var e=this.globalsForEvent(i);this.Qv.push(e),this.Qv.length>1e3&&(this.Qv=this.Qv.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ye._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Jv.bind(this));this.Kv=()=>{t(),this.Qv=[],this.Kv=void 0}}}globalsForEvent(e){var r,s,n,a,o,l,u;if(!e)throw new Error("Event payload is required");var h={},v=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var c of Object.entries(d)){var f=c[0];h[f]={id:v[f],type:f,properties:c[1]}}var p=e.$set_once,g=e.$set;return{event:i({},function(t,i){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==i.indexOf(r))continue;e[r]=t[r]}return e}(e,t),{properties:i({},e.properties,g?{$set:i({},null!==(r=null==(s=e.properties)?void 0:s.$set)&&void 0!==r?r:{},g)}:{},p?{$set_once:i({},null!==(n=null==(a=e.properties)?void 0:a.$set_once)&&void 0!==n?n:{},p)}:{}),elements_chain:null!==(o=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}Yv(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Pr.error("prepare_external_dependency_stylesheet returned null"),null):"script"===e&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Pr.error("prepare_external_dependency_script returned null"),null):t}Xv(){var t,i,e,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==ni?void 0:ni.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Zv++,this.tf)return this.ef();var h=[],v=this,d=new WeakSet,c=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),h.push(()=>{t[i]=r})}},f=t=>{if(d.has(t))return t;var i=v.Yv(t);return i&&d.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!_(t));return c(u,"appendChild",t=>function(i){var e=f(i);return e?t.call(this,e):i}),c(u,"insertBefore",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i}),c(u,"replaceChild",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e}),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{c(t,"append",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"prepend",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})}),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach(t=>{c(t,"before",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"after",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"replaceWith",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)})}),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null}),this.tf=()=>{h.forEach(t=>t()),this.tf=void 0},this.ef()}ef(){var t=!1;return()=>{var i;t||(t=!0,this.Zv--,0===this.Zv&&(null==(i=this.tf)||i.call(this)))}}if(t,i){void 0===i&&(i=!0);var e=this.Xv();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Qv.length&&(Pr.info("Processing "+this.Qv.length+" events for site app with id "+t.id),this.Qv.forEach(t=>this.if(()=>null==i.processEvent?void 0:i.processEvent(t))),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(e=this.Kv)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,Pr.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.if(i=>t.init({posthog:this._instance,callback(t){i(),s(t)}}),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){Pr.error(Cr+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){Pr.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}nf(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}sf(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.if(()=>null==r.processEvent?void 0:r.processEvent(e))}catch(i){Pr.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.nf(),void this._instance.on("eventCaptured",t=>this.sf(t))):void Pr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Kv)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,i=o.id,e=o.url;Ye["__$$ph_site_app_"+i]=s._instance,null==(t=Ye.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,t=>{if(t)return Pr.error(Cr+i,t)})};for(var o of n.siteApps)a()}else Pr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},As={tracingHeaders:class{constructor(t){this._instance=t,this.rf=void 0,this.lf=void 0,this.af=void 0,this.wv=()=>{var t,i,e=this.uf();e?(f(this.rf)&&(this.rf=null==(t=Ye.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.lf)&&(this.lf=null==(i=Ye.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Iv()}}initialize(){this.startIfEnabledOrStop()}Ro(t){var i,e;null!=(i=Ye.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=Ye.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return or.error("failed to load script",i);t()})}hf(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}uf(){var t=this.hf();return h(t)?(h(this.af)?this.af.splice(0,this.af.length,...t):this.af=[...t],t.length>0?this.af:void 0):(h(this.af)&&this.af.splice(0),this.af=t||void 0,this.af)}Iv(){var t,i;null==(t=this.rf)||t.call(this),null==(i=this.lf)||i.call(this),this.rf=void 0,this.lf=void 0}startIfEnabledOrStop(){this.uf()?this.Ro(this.wv):this.Iv()}}},Os=i({surveys:class extends Hr{constructor(t){var i;super(new Xr(t),(i=t,{get projectToken(){return i.config.token},kv:new Gr(i)})),this._instance=t}Sh(t,e){var r=e.query?function(t,e,r){var s;void 0===r&&(r=!0);var n=t.split("?"),a=n[0],o=n[1],l=i({},e),u=null!==(s=null==o?void 0:o.split("&").map(t=>{var i,e=t.split("="),s=e[0],n=r&&null!==(i=l[s])&&void 0!==i?i:e[1];return delete l[s],s+"="+n}))&&void 0!==s?s:[],h=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return vi(t,function(t,i){f(t)||f(i)||"undefined"===i||(e=encodeURIComponent(t instanceof File?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)}),s.join(i)}(l);return h&&u.push(h),u.length>0?a+"?"+u.join("&"):a}(t,e.query):t;return new Promise(t=>{var i;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor(null!==(i=e.target)&&void 0!==i?i:"api",r),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:t})})}}},Es),$s={toolbar:class{constructor(t){this.instance=t}cf(t){Ye.ph_toolbar_state=t}df(){var t;return null!==(t=Ye.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,i,e){if(void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),gi(this.instance.config))return!1;if(!ei||!ni)return!1;t=null!=t?t:ei.location,e=null!=e?e:ei.history;try{if(!i){try{ei.localStorage.setItem("test","test"),ei.localStorage.removeItem("test")}catch(t){return!1}i=null==ei?void 0:ei.localStorage}var r,s=Zr||He(t.hash,"__posthog")||He(t.hash,"state"),n=s?fi(()=>JSON.parse(atob(decodeURIComponent(s))))||fi(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(i.getItem(Qr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}vf(t){var i=Ye.ph_load_toolbar||Ye.ph_load_editor;!b(i)&&v(i)?i(t,this.instance):Yr.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==ni||!ni.getElementById("__POSTHOG_TOOLBAR__"));if(!ei||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(ei.localStorage.setItem(Qr,JSON.stringify(i({},s,{source:void 0}))),2===this.df())this.vf(s);else if(0===this.df()){var n;this.cf(1),null==(n=Ye.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return Yr.error("[Toolbar] Failed to load",t),void this.cf(0);this.cf(2),this.vf(s)}),pi(ei,"turbolinks:load",()=>{this.cf(0),this.loadToolbar(s)})}return!0}ff(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},Ms=i({experiments:class t{get Mr(){return this._instance.config}constructor(i){var e=this;this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){void 0===i&&(i=!1),e.getWebExperiments(i=>{t.pf("retrieved web experiments from the server"),e.gf=new Map,i.forEach(i=>{if(i.feature_flag_key){var r;e.gf&&(t.pf("setting flag key ",i.feature_flag_key," to web experiment ",i),null==(r=e.gf)||r.set(i.feature_flag_key,i));var s=e._instance.getFeatureFlag(i.feature_flag_key);p(s)&&i.variants[s]&&e.mf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(var n in i.variants){var a=i.variants[n];t.yf(a,e._instance)&&e.mf(i.name,n,a.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.pf(fs);else if(!this.Mr.disable_web_experiments){if(b(this.gf))return this.gf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.pf("applying feature flags",i),i.forEach(t=>{var i;if(this.gf&&null!=(i=this.gf)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.gf)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.mf(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var i=t.getWindowLocation();if(null!=i&&i.search){var e=Be(null==i?void 0:i.search,"__experiment_id"),r=Be(null==i?void 0:i.search,"__experiment_variant");e&&r&&(t.pf("previewing web experiments "+e+" && "+r),this.getWebExperiments(t=>{this.bf(parseInt(e),r,t)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Mr.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Mr.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}bf(i,e,r){var s=r.filter(t=>t.id===i);s&&s.length>0&&(t.pf("Previewing web experiment ["+s[0].name+"] with variant ["+e+"]"),this.mf(s[0].name,e,s[0].variants[e].transforms))}static yf(i,e){return!b(i.conditions)&&t._f(i,e)&&t.wf(i)}static _f(i,e){var r;if(b(i.conditions)||b(null==(r=i.conditions)?void 0:r.url))return!0;var s=t.getWindowLocation();if(s){var n,a,o,l=_i(e,s.href);return null==(n=i.conditions)||!n.url||ps[null!==(a=null==(o=i.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](i.conditions.url,l)}return!1}static getWindowLocation(){return null==ei?void 0:ei.location}static wf(t){var i;if(b(t.conditions)||b(null==(i=t.conditions)?void 0:i.utm))return!0;var e=function(t,i,e){if(!ni)return{};var r,s,n,a=i?[...lr,...e||[]]:[],o=(r=ze(ni.URL,a,hr),s=ur.concat(t||[]),n={},vi(s,function(t){var i=Be(r,t);n[t]=i||null}),n);return di(function(){var t={};return vi(vr,function(i){var e=(t=>{if(ni){try{for(var i=t+"=",e=ni.cookie.split(";").filter(t=>t.length),r=0;e.length>r;r++){for(var s=e[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}})(i);t[i]=e||null}),t}(),o)}();if(e.utm_source){var r,s,n,a,o,l,u,h,v=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==e.utm_campaign,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==e.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==e.utm_term;return v&&c&&f&&d}return!1}static pf(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];ui.info("[WebExperiments] "+t,e)}mf(i,e,r){this._is_bot()?t.pf(fs):"control"!==e?r.forEach(r=>{var s;r.selector&&(t.pf("applying transform of variant "+e+" for experiment "+i+" ",r),null==(s=document)||null==(s=s.querySelectorAll(r.selector))||s.forEach(t=>{var i=t;r.html&&(i.innerHTML=r.html),r.css&&i.setAttribute("style",r.css)}))}):t.pf("Control variants leave the page unmodified.")}_is_bot(){return si&&this._instance?function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&P(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>P(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver}(si,this.Mr.custom_blocked_useragents):void 0}}},Es),Is={conversations:class{constructor(t){this._instance=t,this.kf=void 0,this._conversationsManager=null,this.Sf=!1,this.ne=null,this.xf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Cf=t.ok,t.ok)){var i=t.config.conversations;b(i)||(y(i)?this.kf=i:(this.kf=i.enabled,this.ne=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.kf=void 0,this.ne=null,this.Cf=void 0,this.xf=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Sf||this._instance.config.disable_conversations||gi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ye?void 0:Ye.__PosthogExtensions__;if(t&&!f(this.kf)&&this.kf)if(this.ne&&this.ne.token){this.Sf=!0;try{var i=t.initConversations;if(i)return this.$f(i),void(this.Sf=!1);var e=t.loadExternalDependency;if(!e)return void this.Tf(De);e(this._instance,"conversations",i=>{i||!t.initConversations?this.Tf("Could not load conversations script",i):this.$f(t.initConversations),this.Sf=!1})}catch(t){this.Tf("Error initializing conversations",t),this.Sf=!1}}else gs.error("Conversations enabled but missing token in remote config.")}}$f(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.xf=!1,gs.info("Conversations loaded successfully")}catch(t){this.Tf("Error completing conversations initialization",t)}else gs.error("Cannot complete initialization: remote config is null")}Tf(t,i){gs.error(t,i),this._conversationsManager=null,this.Sf=!1,this.xf=!0}show(){this._conversationsManager?this._conversationsManager.show():gs.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.kf&&!_(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":gi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Cf?"remote_config_failed":f(this.kf)?this.Cf?"disabled_in_project":"remote_config_pending":this.kf?b(this.ne)||!this.ne.token?"missing_token":null!=Ye&&Ye.__PosthogExtensions__?this.Sf?"initializing":this.xf?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return r(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(gs.warn(_s),null)})()}getMessages(t,i){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(gs.warn(_s),null)})()}markAsRead(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(gs.warn(_s),null)})()}getTickets(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(gs.warn(_s),null)})()}requestRestoreLink(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(gs.warn(_s),null)})()}restoreFromToken(t){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(gs.warn(_s),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(gs.warn(_s),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},js={logs:class{constructor(t){var e,r=this;this._instance=t,this.name="logs",this.If=!1,this.Mf=!1,this.Ef=!1,this.$=hi("[logs]"),this.Pf=i({},this.$,{error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];i.some(ks)||r.$.error(...i)}}),this.Jl=[],this.Rf=[],this.Gc=0,this.mo=!1,this.Af=[],this.Ff=[],this.Of=!1,this.Df=!1,this.Lf=()=>{var t,i;this.mo||(this.Gc=0,null==(t=this.Nf)||t.onReconnect(),null==(i=this.qf)||i.onReconnect())},this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.If=!0),ei&&pi(ei,"online",this.Lf)}jf(t,i,e,r){var s,n=ms(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new Gt(this.Bf(t,i),n,this.Pf,()=>this.Hf(),t=>t(),void 0,r),n]}zf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Nf||this.Uf!==i){var e;null==(e=this.Nf)||e.reset(),this.Uf=i;var r=this.jf(()=>this.Jl,t=>{this.Jl=t});this.Nf=r[0],this.Wf=r[1]}return this.Nf}Vf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.qf||this.Gf!==i){var e;null==(e=this.qf)||e.reset(),this.Gf=i;var r=this.jf(()=>this.Rf,t=>{this.Rf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},ws);this.qf=r[0],this.Zf=r[1]}return this.qf}setup(t){var i;if(!this.mo){this.uo=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.If=!0),(this.If||this.Qf()&&this.Jf())&&this.Kf();var e=!1,r=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.mo?r.dispose():(this._o=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.mo||(this.mo=!0,this.Yf(),null==(t=this._o)||t.dispose(),this._o=void 0,this.uo=void 0,this.Ef=!1,null==ei||ei.removeEventListener("online",this.Lf),null==(i=this.Xf)||i.call(this),this.Xf=void 0,null==(e=this.Nf)||e.reset(),null==(r=this.qf)||r.reset())}onRemoteConfig(t){var i,e;if(!this.mo){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;b(r)?this.tp():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[he]:!!r}),r?(this.If=!0,this.Mf||this.Kf(),this.loadIfEnabled()):this.tp())}}reset(){var t,i,e,r;this.Yf(),null==(t=this.Nf)||t.clearQueue(),this.Jl=[],null==(i=this.Nf)||i.reset(),null==(e=this.qf)||e.clearQueue(),this.Rf=[],null==(r=this.qf)||r.reset(),this.Gc=0}captureLog(t){this.mo||this.zf().captureLog(t)}captureConsoleLog(t){this.mo||this.Vf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.mo||this.Vf().captureLog(t,{context:i,occurredAtMs:e})}Jf(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[he])}Qf(){var t,i;return null==(t=this._instance)||null==t._shouldDisableFlags||!t._shouldDisableFlags()||!(null==(i=Ye._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}_onOptOut(){var t;this.Yf(),null==(t=this.qf)||t.clearQueue(),this.Rf=[]}tp(){this.If||this.Yf()}Kf(){var t,i=this;if(!this.Of&&null!=Ye&&Ye.console){var e=ms(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(Ye.console[t])}catch(t){return 0}if(!r)return 0;i.Ff.push(ar(Ye.console,t,s=>{var n=function(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];try{i.ep(t,n,e)}catch(t){}return s.apply(Ye.console,n)};return n.__rrweb_original__=r,n}))};for(var s of ys)r(s);this.Of=!0,this.np=setTimeout(()=>{this.Yf()},3e4)}}ep(t,i,e){var r;if(this.Of&&!this.Df&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Af.length){this.Df=!0;try{this.Af.push({level:t,args:i,occurredAtMs:Date.now(),context:this.Hf()})}finally{this.Df=!1}}}else this.Yf()}Yf(){if(this.Af=[],this.Of){for(var t of(this.Of=!1,this.np&&(clearTimeout(this.np),this.np=void 0),this.Ff))t();this.Ff=[]}}sp(){var t=this.Af;return this.Yf(),t}get logger(){return this.rp||(this.rp={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.rp}flushLogs(t){t?this.op(t):(this.Nf&&this.Nf.flush().catch(t=>this.lp(t)),this.qf&&this.qf.flush().catch(t=>this.lp(t)))}lp(t){ks(t)||this.$.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.mo&&this.If&&!this.Mf&&!this.Ef){var t=null==Ye?void 0:Ye.__PosthogExtensions__;if(!t)return this.$.error("PostHog Extensions not found."),void this.Yf();var i=t.loadExternalDependency;if(!i)return this.$.error(De),void this.Yf();this.Ef=!0;try{i(this._instance,"logs",i=>{if(this.Ef=!1,!this.mo&&this.If){var e=t.logs;if(i||null==e||!e.initializeLogs)this.$.error("Could not load logs script",i),this.Yf();else{var r,s,n=this.sp();this.Xf=e.initializeLogs(null!==(r=this.uo)&&void 0!==r?r:this._instance),this.Mf=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.uo)&&void 0!==s?s:this._instance,n))}}})}catch(t){throw this.Ef=!1,t}}}Bf(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===s.LogsQueue?t():void 0,setPersistedProperty(t,e){t===s.LogsQueue&&i(null!=e?e:[])},Ps:t=>this.Ps(t),getLibraryId:()=>Ur.LIB_NAME,getLibraryVersion:()=>Ur.LIB_VERSION}}Ps(t){return new Promise(i=>{if(Ue(this.Gc,3))i({kind:"fatal",error:xs(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:xs(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.ap(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.up(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.$.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:xs(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}})}up(t){(0!==t||this._instance.__loaded)&&(this.Gc=Ve(t,this.Gc,3,()=>this.$.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}op(t){this.Jl.length>0&&this.hp(t,this.Jl,this.Wf,Ur.LIB_NAME,t=>{this.Jl=t}),this.Rf.length>0&&this.hp(t,this.Rf,this.Zf,ws,t=>{this.Rf=t})}hp(t,i,e,r,s){if(0!==i.length){var n=i.map(t=>t.record);s([]);var a=Jt(n,Kt(e,Ur.LIB_NAME,Ur.LIB_VERSION),r,Ur.LIB_VERSION);this._instance._send_request({method:"POST",url:this.ap(),data:a,compression:"best-available",batchKey:"logs",transport:t})}}ap(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Hf(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,b(s)||(i.sessionStartTimestamp=s),b(n)||(i.lastActivityTimestamp=n)}if(null!=Ye&&null!=(t=Ye.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?W(Ye.location.href):Ye.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(i.activeFeatureFlags=a)}return i}}},Ds={metrics:class{constructor(t){this._instance=t,this.$=hi("[metrics]")}initialize(){}zf(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Nf&&this.Uf===e||(null==(i=this.Nf)||i.reset(),this.Uf=e,this.Nf=new Yt(this.Bf(),function(t){var i,e,r,s,n,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==a?void 0:a["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==a?void 0:a["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(e),this.$)),this.Nf}count(t,i,e){void 0===i&&(i=1),this.zf().count(t,i,e)}gauge(t,i,e){this.zf().gauge(t,i,e)}histogram(t,i,e){this.zf().histogram(t,i,e)}flush(t){if(!this.Nf)return Promise.resolve();if(t){var i=this.Nf.drainWindow();return i&&this.Gs(i,t),Promise.resolve()}return this.Nf.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Nf)||t.reset()}Bf(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Gs:t=>i.Gs(t),getLibraryId:()=>Ur.LIB_NAME,getLibraryVersion:()=>Ur.LIB_VERSION}}Gs(t,e){return new Promise(r=>{var s=!1,n=t=>{s||(s=!0,clearTimeout(a),r(t))},a=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(i({method:"POST",url:this.cp(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var i,e=t.statusCode;n(e>=200&&300>e?{kind:"ok"}:413===e?{kind:"too-large"}:0!==e&&408!==e&&429!==e&&500>e?{kind:"fatal",error:new Error("metrics request failed with status "+e)}:{kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}))})}cp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Ls=i({},Es,Fs,Ps,Cs,Ts,Rs,Os,As,$s,Ms,Is,js,Ds),Ns=Es,Bs=Fs,zs=Ps,Hs=Cs,Us=Ts,Vs=Rs,qs=Os,Ws=As,Ks=$s,Js=Ms,Gs=Is,Xs=js,Zs=Ds;export{Ls as AllExtensions,zs as AnalyticsExtensions,Gs as ConversationsExtensions,Hs as ErrorTrackingExtensions,Js as ExperimentsExtensions,Ns as FeatureFlagsExtensions,Xs as LogsExtensions,Zs as MetricsExtensions,Us as ProductToursExtensions,Bs as SessionReplayExtensions,Vs as SiteAppsExtensions,qs as SurveysExtensions,Ks as ToolbarExtensions,Ws as TracingExtensions};
|
|
2
2
|
//# sourceMappingURL=extension-bundles.js.map
|