posthog-js 1.453.1 → 1.453.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/external-scripts-loader.js +1 -1
- package/dist/integrity.json +27 -27
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.cjs +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.cjs +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.mjs +1 -1
- package/dist/module.no-external.cjs +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.no-external.js +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t=["$set_once","$set"];function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},e.apply(null,arguments)}function i(t,e,i,r,n,s,a){try{var o=t[s](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,n)}function r(t){return function(){var e=this,r=arguments;return new Promise(function(n,s){var a=t.apply(e,r);function o(t){i(a,n,s,o,l,"next",t)}function l(t){i(a,n,s,o,l,"throw",t)}o(void 0)})}}var n=/*#__PURE__*/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.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function s(t,e){return-1!==t.indexOf(e)}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)},c=t=>"function"==typeof t,v=t=>t===Object(t)&&!h(t),d=t=>{if(v(t)){for(var e in t)if(l.call(t,e))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,m=t=>null===t,y=t=>f(t)||m(t),_=t=>"[object Number]"==u.call(t)&&t==t,b=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function x(t,e){return{}.toString.call(t)==="[object "+e+"]"}function S(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,e){try{return t instanceof e}catch(t){return!1}}var A=["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","lightpanda","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"],T=/* @__PURE__ */new Map,F=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=function(t,e){for(var i="",r=0;e.length>r;r++){var n=e[r];i+=n.length+":"+n}return t.length+":"+t+"|"+e.length+":"+i}(t,e),r=T.get(i);if(void 0!==r)return r;var n=t.toLowerCase(),s=A.concat(e).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>T.size||T.clear(),T.set(i,s),s};function P(t,e,i,r,n){return e>i&&(r.warn("min cannot be greater than max."),e=i),_(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),P(null!=n?n:i,e,i,r))}var C=class{constructor(t){this.C={},this.I=t.I,this.A=P(t.bucketSize,0,100,t.R),this.O=P(t.refillRate,0,this.A,t.R),this.$=P(t.refillInterval,0,864e5,t.R)}F(t,e){var i=Math.floor((e-t.lastAccess)/this.$);i>0&&(t.tokens=Math.min(t.tokens+i*this.O,this.A),t.lastAccess=t.lastAccess+i*this.$)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),n=this.C[r];return n?this.F(n,i):this.C[r]=n={tokens:this.A,lastAccess:i},0===n.tokens||(n.tokens--,0===n.tokens&&(null==(e=this.I)||e.call(this,t)),0===n.tokens)}stop(){this.C={}}},R="Android",O="Nintendo",M="PlayStation",I="Windows",D=/* @__PURE__ */new RegExp("BlackBerry|PlayBook|BB10","i"),j={"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"},L=[[/* @__PURE__ */new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>["Xbox",t&&t[1]||""]],[/* @__PURE__ */new RegExp(O,"i"),[O,""]],[/* @__PURE__ */new RegExp(M,"i"),[M,""]],[D,["BlackBerry",""]],[/* @__PURE__ */new RegExp(I,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return["Windows Phone",""];if(new RegExp("Mobile").test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=j[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[I,r]}return[I,""]}],[/((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 e="";return t&&t.length>=3&&(e=f(t[2])?t[3]:t[2]),["watchOS",e]}],[/* @__PURE__ */new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[R,[t[2],t[3],t[4]||"0"].join(".")]:[R,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],N="[Truncated]",z="[Unserializable]";function B(t){for(var e="",i=0;t.length>i;i++){var r=t.charCodeAt(i);if(55296>r||r>56319)e+=56320>r||r>57343?t[i]:"�";else{var n=t.charCodeAt(i+1);56320>n||n>57343?e+="�":(e+=t[i]+t[i+1],i++)}}return e}function U(t,e){if(!e)return t;var i=[];try{i=Object.keys(e)}catch(t){i=[]}for(var r of i){var n=void 0;try{n=e[r]}catch(t){n=z}Object.defineProperty(t,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;var H,q,V,W,G=3e5,K=class{record(t){if("too-large"!==t.kind)if("retry-later"===t.kind){if(t.retryAfterMs){var e=this.isOpen(),i=Date.now(),r=Math.min(t.retryAfterMs,G);if(!e)return this.ts=i,void(this.es=i+r);this.es=Math.max(this.es,Math.min(i+r,this.ts+G))}}else this.reset()}remainingMs(){var t=Date.now();if(this.ts-5e3>t)return this.reset(),0;var e=Math.min(G,Math.max(0,this.es-t));return 0===e&&this.reset(),e}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};function J(t){return t?t.split("#")[0]:t}function X(t){try{return t()}catch(t){return}}function Y(t,e){var i=setTimeout(t,e);return null!=i&&i.unref&&(null==i||i.unref()),i}function Z(t,e,i){return Q.apply(this,arguments)}function Q(){return(Q=r(function*(t,e,i){var r;try{return yield Promise.race([t,new Promise((t,n)=>{r=Y(()=>{try{null==i||i(),t()}catch(t){n(t)}},e)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function tt(t){var i=globalThis._posthogChunkIds,r=globalThis._debugIds;if(i||r){var n=i?Object.keys(i):[],s=r?Object.keys(r):[];if(W&&et(i,n,q)&&et(r,s,V))return W;q=i?e({},i):void 0,V=r?e({},r):void 0,W={},null!=H||(H={});var a=(e,i)=>{for(var r of e){var n,s=i[r];if(s){var a=null==(n=H)?void 0:n[r];if(a)W[a]=s;else for(var o=t(r),l=o.length-1;l>=0;l--){var u,h=null==(u=o[l])?void 0:u.filename;if(h){W[h]=s,H[r]=h;break}}}}};return r&&a(s,r),i&&a(n,i),W}}function et(t,e,i){return t&&i?e.length===Object.keys(i).length&&e.every(e=>t[e]===i[e]):t===i}var it=class{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),n=this.buildParsingContext(e),s=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(s,i),$exception_level:"error"}}modifyFrames(t){var e=this;return r(function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&h(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t})()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,i){var r,n,s;if(null!=t.cause&&(n=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack)try{s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)}catch(t){}return e({},t,{cause:n,stack:s,errors:null==(r=t.errors)?void 0:r.map(t=>this.parseStacktrace(t,i))})}applyChunkIds(t,e){return t.map(t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return r(function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i})()}convertToExceptionList(t,i){var r=[],n=(t,s,a)=>{var o=r.length,l=void 0===s?e({type:"string"==typeof i.type&&i.type.length>0?i.type:"generic"},"boolean"==typeof i.handled?{handled:i.handled}:void 0===i.handled?{handled:!0}:{},{synthetic:"boolean"==typeof i.synthetic?i.synthetic:t.synthetic,exception_id:o}):{type:"chained",source:a,synthetic:t.synthetic,exception_id:o,parent_id:s},u={type:t.type,value:t.value,mechanism:l};for(var h of(t.stack&&(u.stacktrace={type:"raw",frames:t.stack}),r.push(u),t.cause&&n(t.cause,o,"cause"),null!==(c=t.errors)&&void 0!==c?c:[])){var c;n(h,o,"member")}};return n(t),r}buildParsingContext(t){var e;return{chunkIdMap:tt(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}getAggregateErrors(t){try{if(S(t))for(var e=Object.getPrototypeOf(t),i=0;e&&100>i;i++){var r,n=null==(r=Object.getOwnPropertyDescriptor(e,"constructor"))?void 0:r.value;if("function"==typeof n&&"AggregateError"===n.name){var s=t.errors;return h(s)?s:void 0}e=Object.getPrototypeOf(e)}}catch(t){}}buildCoercingContext(t,i,r){var n=this;void 0===r&&(r=0);var s=0,a=0,o=!1,l=/* @__PURE__ */new Set,u=[],h={},c=function(t,i,r){void 0===r&&(r=0);var c=v(i,r),d=c.apply;if(c.apply=e=>{u.push(t);try{return d(e)}finally{u.pop()}},r>4||r>0&&-1!==u.indexOf(t))return n.coerceFallback(c);var f="object"==typeof t&&null!==t||"function"==typeof t;if(!(0===r&&s>=50||f&&l.has(t))){f&&l.add(t),0===r&&s++;var p,g,m=n.getAggregateErrors(t);o||(o=!!m);try{if(!(p=n.applyCoercers(t,c)))throw h}catch(t){if(t===h)return void(0===r&&s--);if(!o)throw t;p=n.coerceFallback(c)}if(!m||s>=50)return p;try{g=m.length}catch(t){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;for(var y=[],_=0;50>s&&1e3>a&&g>_;_++){a++;var b=void 0;try{b=c.next(m[_])}catch(t){s++,b=n.coerceFallback(v(i+1))}b&&y.push(b)}return e({},p,{errors:y})}},v=function(r,n){return void 0===n&&(n=0),e({},i,{syntheticException:0==r?i.syntheticException:void 0,mechanism:0==r?t:{},apply(t){var e=c(t,r,n+1);if(!e)throw h;return e},next:t=>c(t,r+1)})},d=v(r);return e({},d,{apply:t=>{var e;return null!==(e=c(t,r))&&void 0!==e?e:this.coerceFallback(d)}})}},rt=/^([a-z][a-z0-9.+-]+):/i,nt=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function st(t){if(!t||"<anonymous>"===t)return!1;var e=rt.exec(t);return!e||nt.includes(e[1].toLowerCase())}function at(t,e,i,r,n){var s={platform:t,filename:e,function:"<anonymous>"===i?"?":i,in_app:st(e)};return f(r)||(s.lineno=r),f(n)||(s.colno=n),s}var ot=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:"?",i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},lt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ut=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ht=/\((\S*)(?::(\d+))(?::(\d+))\)/,ct=(t,e)=>{var i=lt.exec(t);if(i)return at(e,i[1],"?",+i[2],+i[3]);var r=ut.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var n=ht.exec(r[2]);n&&(r[2]=n[1],r[3]=n[2],r[4]=n[3])}var s=ot(r[1]||"?",r[2]);return at(e,s[1],s[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},vt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,dt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ft=(t,e)=>{var i=vt.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=dt.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var n=i[3],s=i[1]||"?",a=ot(s,n);return at(e,n=a[1],s=a[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},pt=/\(error: (.*)\)/;function gt(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function mt(t){for(var e=1;10>=e;e++){var i=t.length-2*e;if(0>i)break;for(var r=!0,n=0;e>n;n++)if(!gt(t[i+n],t[i+e+n])){r=!1;break}if(r){for(var s=0;e>s;s++)t[i+s]=t[i+e+s];return t.length=i+e,{start:i,length:e}}}}function yt(t,e){var i=e.start+e.length,r=bt(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function _t(t,e){for(var i=e.start;i>0&>(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function bt(t,e){for(var i=e.start+e.length,r=i;t.length>r&>(t[r],t[r-e.length]);)r++;return r-i}function wt(t,e){var i=e[0],r=t.length-(i?_t(t,i):0);for(var n of e)r-=bt(t,n);return r}function xt(t,e,i){for(var r=0;t.length>r;r++){var n=t[(e+r)%t.length],s=t[(i+r)%t.length];if(n!==s)return s>n}return!1}var St=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=p(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return x(t,"DOMException")}isDOMError(t){return x(t,"DOMError")}},kt=class{match(t){return S(t)}coerce(t,e){var i,r=this.getStack(t),n=void 0===r?null==(i=e.syntheticException)?void 0:i.stack:void 0,s=!!n;return{type:this.getType(t),value:this.getMessage(t,e),stack:null!=r?r:n,cause:t.cause?e.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){try{var e=t.stacktrace;if("string"==typeof e&&e.length>0)return e;var i=t.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(t){return}}},Et=class{match(t){return!!x(t,"ErrorEvent")&&(null!=t.error||this.Sr(t))}coerce(t,i){var r;if(null!=t.error)return i.apply(t.error);var n=i.apply(t.message);return e({},n,{stack:null!==(r=this._r(t))&&void 0!==r?r:n.stack,synthetic:!0})}Sr(t){return p(t.message)&&t.message.length>0}_r(t){var e,i,r=t,n=null!==(e=r.lineno)&&void 0!==e?e:0,s=null!==(i=r.colno)&&void 0!==i?i:0;if(p(r.filename)&&0!==r.filename.length&&0!==n)return"Error\n at "+r.filename+":"+n+":"+s}},At=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Tt=class{match(t){return"string"==typeof t}coerce(t,e){var i,r=this.getInfos(t),n=r[0],s=r[1];return{type:null!=n?n:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(At);return r&&(e=r[1],i=r[2]),[e,i]}},Ft=["fatal","error","warning","log","info","debug"];function Pt(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";var r="";for(var n of i){var s=r?r+", "+n:n;if(s.length>e)break;r=s}return r}var Ct=class{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,n=this.getErrorPropertyFromObject(t);return n?e.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.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 e="name"in t?t.name:void 0;return p(e)&&!g(e)?e:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+Pt(t)}isSeverityLevel(t){return p(t)&&!g(t)&&Ft.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 e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(S(i))return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}},Rt=class{match(t){return k(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Pt(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}},Ot=class{match(t){return w(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}},Mt=class{match(t){return x(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return w(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}},$t="$message",It="$timestamp",Dt=/* @__PURE__ */new Set([$t,It]),jt={enabled:!0,max_bytes:32768};function Lt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:jt.enabled,max_bytes:zt(t.max_bytes,jt.max_bytes)}:e({},jt)}var Nt=class{constructor(t){this.ns=[],this.ss=0,this.Br=Lt(t)}setConfig(t){this.Br=Lt(t),this.rs()}add(t){var e=function(t){var e,i,r;try{r=[],e=null!==(i=JSON.stringify(t,function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(e))return"[Circular]";r.push(e)}return e}}))&&void 0!==i?i:"null"}catch(t){return}try{var n=JSON.parse(e);if(!v(n))return;var s=n,a=s[$t],o=s[It];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!_(o))return;return{step:s,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Br.max_bytes||(this.ns.push({step:e.step,bytes:i}),this.ss+=i,this.rs())}}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Br.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function zt(t,e){if(!_(t)||1/0===t||-1/0===t)return e;var i=Math.floor(t);return 0>i?e:i}var Bt=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function Ut(t){return"string"==typeof t||t}function Ht(t){return"string"==typeof t?t:void 0}var qt="[redacted]",Vt=/^[A-Za-z0-9+/\n\r]+=*$/,Wt=/^[A-Za-z0-9_-]+={0,2}$/,Gt=/[-_]/,Kt=/^data:[^,\s]*;base64,/i,Jt=/^[A-Za-z0-9+/_-]+={0,2}$/,Xt=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Yt=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Zt=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Qt=/[\s<>"]/,te=/* @__PURE__ */(()=>new RegExp(Zt.source,"i"))(),ee=/[a-z][a-z0-9+.-]{0,63}:\/\//i,ie=/* @__PURE__ */(()=>new RegExp("^"+ee.source,"i"))(),re=/* @__PURE__ */(()=>new RegExp(ee.source,"gi"))(),ne=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,se=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ae=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,oe=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,le=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,ue=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,he=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,ce=/\d+/g,ve=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,de=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function fe(t){return function(t){return Yt.test(t)}(t)||ne.test(t)||se.test(t)}function pe(t){return t.split("&",129).length>128}function ge(t,e,i){return fe(t)||e.includes(";")&&function(t){return t.split(";").some(t=>fe(t.split("=",1)[0]))}(e)?qt:te.test(e)?i?xe(e,{allowNestedUrls:!1,stripPunctuation:!0}):qt:e}function me(t,e){var i=new URLSearchParams,r=!1,n=!1;for(var s of new URLSearchParams(t)){var a=s[0],o=s[1],l=Se(a),u=Se(o);r||(r=l!==a||u!==o);var h=ge(l,u,e);r||(r=h!==u),n=fe(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function ye(t,e){if(!t.includes("="))return{value:_e(t,e),lastFieldSensitive:!1};var i=me(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function _e(t,e){return e?xe(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function be(t,e,i){return"#"===t?!e.fragment&&(e.fragment=!0):"?"===t&&(e.fragment?"="!==i&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function we(t,e){var i;if(t.length>8192&&ie.test(t))return qt;var r,n=e.stripPunctuation?function(t){for(var e=t.length;e>0&&".,;:!?)]}'".includes(t[e-1]);)e--;return{address:t.slice(0,e),suffix:t.slice(e)}}(t):{address:t,suffix:""},s=n.address,a=n.suffix;try{r=new URL(s)}catch(t){return qt+a}var o=r.search.slice(1),l=""!==r.hash,u=function(t){var e=t.slice(1),i=e.indexOf("?");return 0>i?{head:e,tail:null}:{head:e.slice(0,i),tail:e.slice(i+1)}}(r.hash);if(pe(o)||pe(u.head)||pe(null!==(i=u.tail)&&void 0!==i?i:""))return qt+a;var h=!1;(r.username||r.password)&&(r.username=qt,r.password="",h=!0);var c=me(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=ye(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":qt,lastFieldSensitive:!0}:ye(v,e.allowNestedUrls)),p=null===f?d.value:d.value+"?"+f.value;p!==r.hash.slice(1)&&(r.hash=p,h=!0);var g=l?null!=f?f:d:c;return(h?Se(r.toString()):s)+(g.lastFieldSensitive?"":a)}function xe(t,i){return t.replace(Zt,r=>function(t,i){var r=function(t){if(!t.includes("://"))return[];for(var e=[...t.matchAll(re)].map(t=>t.index),i=[],r={query:!1,fragment:!1,fragmentQuery:!1},n=0,s=!1,a="",o=0;t.length>o&&e.length>n;o++){e[n]===o&&(o>0&&"="!==a&&i.push(o),n++);var l=t[o];be(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return we(t,i);var n="",s=0;for(var a of r)n+=we(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+we(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function Se(t){return t.replace(Xt,qt)}function ke(t,e){return function(t){return t.length>=10240&&(Vt.test(t)||function(t){var e,i=Kt.exec(t);if(!i)return!1;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Jt.test(e.replace(/[\r\n]/g,""))}(t)||Gt.test(t)&&Wt.test(t))}(t)?"[binary data redacted - not supported by PostHog MCP analytics]":function(t,e,i){var r=4*i.maxStringLength;if(t.length>r){var n=e(t.slice(0,function(t,e){for(var i=e;i>0&&!Qt.test(t[i-1]);)i--;return i}(t,r)));if(n.length>=2*i.maxStringLength)return n+i.truncationSuffix}return e(t)}(t,t=>function(t){return xe(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(ae," ");return(e=(e=(e=function(t){for(var e="",i=0,r=Pe(t,0);null!==r;r=Pe(t,r[1]))e+=t.slice(i,r[0])+Ce(t.slice(r[0],r[1])),i=r[1];return e+t.slice(i)}(e=(e=(e=e.replace(oe,qt)).replace(le,qt)).replace(ue,"$1"+qt))).replace(he,qt)).replace(ve,"$1"+qt)).replace(de,"$1"+qt)}(Se(t))),e)}function Ee(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;if(0>n||n>9)return!1;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function Ae(t,e){var i=t.charCodeAt(e);return i>=48&&57>=i}function Te(t,e){var i=t.charCodeAt(e);return Ae(t,e)||95===i||i>=65&&90>=i||i>=97&&122>=i}function Fe(t,e){for(var i=e;Ae(t,i);)i++;return i}function Pe(t,e){for(var i=e;t.length>i;i++)if(Ae(t,i)&&!Te(t,i-1)){for(var r=0,n=-1,s=i;;){var a=Fe(t,s);if(13>(r+=a-s)||Te(t,a)||(n=a),s=a+1,!" ./-".includes(t.charAt(a))||!Ae(t,s))break}if(n>=0)return[i,n];i=s-1}return null}function Ce(t){for(var e=[],i=ce.exec(t);null!==i;i=ce.exec(t))e.push({digits:i[0],start:i.index,end:i.index+i[0].length});for(var r="",n=0,s=0;e.length>s;){for(var a="",o=-1,l=s;e.length>l&&19>=(a+=e[l].digits).length;l++)a.length>=13&&Ee(a)&&(o=l);0>o?s++:(r+=t.slice(n,e[s].start)+qt,n=e[o].end,s=o+1)}return r+t.slice(n)}var Re={}.propertyIsEnumerable;function Oe(t,e){try{return Ie(t,e,{ancestors:/* @__PURE__ */new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Me(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:N};if(i.remainingNodes--,b(t))return{boolValue:t};if("bigint"==typeof t)return function(t,e){var i=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==e||e.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(t,e);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 n=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==e||e.debug("Attribute "+n+" is outside the int64 range; encoding it as a string"),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:B(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(i.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:N};if(t instanceof Date){var s=t.getTime(),a=Number.isFinite(s)?t.toISOString():String(t);return{stringValue:"string"==typeof a?B(a):String(a)}}i.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Me(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:$e(t,e,i,r+1)}}:{kvlistValue:{values:Ie(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:B(String(t))}}function $e(t,e,i,r){for(var n=[],s=Math.min(t.length,1e3),a=0;s>a&&i.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(y(o))continue;n.push(Me(o,e,i,r))}catch(t){n.push({stringValue:z})}return t.length>a&&n.push({stringValue:N}),n}function Ie(t,e,i,r){var n=[];for(var s in t)if(Re.call(t,s)){if(!s){null==e||e.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[s];if(m(a)||f(a))continue;n.push({key:B(s),value:Me(a,e,i,r)})}catch(t){n.push({key:B(s),value:{stringValue:z}})}}return n}function De(t,i,r){return e({},U({},t.resourceAttributes),{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":r})}var je=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Le(t,e){var i=U({},t),r={};for(var n of je)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Oe(i,e),...Oe(r,e)]}var Ne={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};var ze={text:"INFO",number:9},Be={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:ze,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function Ue(t){try{return B(String(t))}catch(t){return z}}function He(t,i,r,n){var s,a=Be[t.level||"info"]||ze,o=a.text,l=a.number,u=(void 0===(s=_(n)?n:void 0)&&(s=Date.now()),String(s)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),y(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),y(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var c=e({},h),v=t.attributes;if(v){var d=[];try{d=Object.keys(v)}catch(t){d=[]}for(var p of d){var g=void 0;try{g=v[p]}catch(t){g=z}Object.defineProperty(c,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Ue(t.body)},attributes:Oe(c,r)};return t.trace_id&&(m.traceId=t.trace_id),t.span_id&&(m.spanId=t.span_id),f(t.trace_flags)||(m.flags=t.trace_flags),m}function qe(t,e,i){return De(t,e,i)}function Ve(t,e,i,r){return{resourceLogs:[{resource:{attributes:Le(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var We=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=Y(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Ge(){return.75+.5*Math.random()}function Ke(t,e,i,r){var n=t*Math.pow(2,Math.min(Math.max(0,e-1),6));return Math.round((void 0===r?n:Math.min(n,Math.max(r,t)))*i)}var Je=class{constructor(t,e,i,r,n,s,a,o){var l;void 0===s&&(s=()=>Promise.resolve()),void 0===o&&(o=()=>!1),this._instance=t,this.Br=e,this.R=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=o,this.gs=new We(()=>this.ys()),this.bs=null,this._s=0,this.ws=0,this.ks=null,this.Ss=new K,this.xs=0,this.$s=1,this.Cs=0,this.Ts=0,this.Ms=!1,this.Is=e.maxBufferSize,this.Es=Math.max(null!==(l=e.maxQueueSize)&&void 0!==l?l:e.maxBufferSize,e.maxBufferSize),this.As=e.flushIntervalMs,this.Rs=e.maxBatchRecordsPerPost,this.Ps=e.rateCapWindowMs,this.Os=e.maxLogsPerInterval}clearQueue(){this.ws++,this._instance.setPersistedProperty(n.LogsQueue,[])}get throttled(){return this.Ss.isOpen()}reset(){this.gs.clear(),this.Cs=0,this.Ts=0,this.Ms=!1,this.xs=0,this.$s=1,this.Ss.reset(),this.Rs=this.Br.maxBatchRecordsPerPost}onReconnect(){this.xs=0,this.$s=1,this.Ss.isOpen()?this.Fs()&&this.Ls():this.ys()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ds(t);if(null!==r)if(r.body){if(this.Ns()){var n={record:He(r,null!==(i=null==e?void 0:e.context)&&void 0!==i?i:this.hs(),this.R,null==e?void 0:e.occurredAtMs)};this.ds(()=>this.js(n))}}else this.R.info("Log was rejected in beforeSend function")}}Ds(t){var e=this.Br.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Log was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for log:",t),null}return r}Ns(){if(void 0===this.Os)return!0;var t=Date.now(),e=t-this.Cs;return this.Ps>e&&e>=0||(this.Cs=t,this.Ts=0,this.Ms=!1),this.Os>this.Ts?(this.Ts++,!0):(this.Ms||(this.R.warn("captureLog dropping logs: exceeded "+this.Os+" logs per "+this.Ps+"ms"),this.Ms=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.bs||(t.bs=t.qs().finally(()=>{t.bs=null})),t.bs})()}qs(){var t=this;return r(function*(){var e;if(t.gs.clear(),!t.Bs()){var i=null!==(e=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var a,o;if(t.Bs())return;var l=t.ws;t._s=0;var u=Math.min(i.length,t.Rs),h=i.slice(0,u),c=Ve(h.map(t=>t.record),t.zs(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.Hs(c);if(t.ws!==l)return;if("too-large"===v.kind&&h.length>1)t.Rs=Math.max(1,Math.floor(h.length/2)),t.R.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Rs);else{if(t.Ss.record(v),t.gs.pending&&t.gs.arm(Math.max(t.As,t.Ss.remainingMs())),"retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.R.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===v.kind&&t.Br.maxBatchRecordsPerPost>t.Rs&&(t.Rs=Math.min(t.Br.maxBatchRecordsPerPost,t.Rs+1)),yield t.Us(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}}})()}Bs(){return!!this.ps()&&(this.Fs()&&this.clearQueue(),!0)}Us(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e._s),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}zs(){return qe(this.Br,this._instance.getLibraryId(),this._instance.getLibraryVersion())}js(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Es>i.length||(i.shift(),this._s++,this.R.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Is>i.length||this.Ss.isOpen()?this.Ls():this.ys()}}Ls(){this.gs.pending||this.gs.arm(Math.max(this.As,this.Ss.remainingMs()))}Ws(){return Math.max(Ke(this.As,this.xs,this.$s,3e4),this.Ss.remainingMs())}Fs(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.gs.clear();var i=e.flush().catch(()=>{});void 0!==t?yield Z(i,t):yield i})()}flushWithTimeout(t){var e=this;return r(function*(){var i=e.flush();yield Z(i,t,()=>{i.catch(()=>{})})})()}flushInBackground(){if(this.ks)return this.ks;var t=this.flush().then(()=>{this.xs=0,this.$s=1},t=>{this.xs++,this.$s=Ge(),this.R.error("PostHog logs flush failed:",t)}).finally(()=>{this.ks===t&&(this.ks=null),!this._instance.isDisabled&&this.Fs()&&this.gs.armNoEarlierThan(this.Ws())});return this.ks=t,t}ys(){this.flushInBackground()}},Xe=/^[0-9a-f]+$/;function Ye(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Xe.test(t)}var Ze=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Qe="00",ti=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ei(t){return String(t)+"000000"}function ii(t,e,i,r){var n="";return r&&(n=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+n}var ri=class{constructor(t,e,i){this._instance=t,this.Br=e,this.R=i,this.Vs=/* @__PURE__ */new Map,this.gs=new We(()=>this.flush().catch(t=>{this.R.error("Metrics flush failed:",t)})),this.bs=null,this.Gs=null,this.Qs=!1,this.Js=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ks=/* @__PURE__ */new Map,this.Ys=/* @__PURE__ */new Set,this.Xs=!1,this.Ss=new K,this.xs=0,this.$s=1,this.$o=0}count(t,e,i){void 0===e&&(e=1),this.Co({name:t,type:"count",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(t,e,i){this.Co({name:t,type:"gauge",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(t,e,i){this.Co({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:h(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var t=this,e=this.bs,i=/* @__PURE__ */function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.To()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.bs===i&&(this.bs=null)});return this.bs=i,i}flushCoalesced(){var t,e;return this.Mo()?null!==(t=this.bs)&&void 0!==t?t:Promise.resolve():(this.Gs||(this.Gs=(null!==(e=this.bs)&&void 0!==e?e:Promise.resolve()).catch(()=>{}).then(()=>(this.Gs=null,this.Mo()?void 0:this.flush()))),this.Gs)}Mo(){return this.xs>0||this.Ss.remainingMs()>0}drainWindow(){if(0===this.Vs.size)return null;var t=this.Vs;return this.Io(),this.Eo(t)}reset(){this.$o++,this.Ss.reset(),this.xs=0,this.$s=1,this.gs.clear(),this.bs=null,this.Gs=null,this.Io(),this.Ks=/* @__PURE__ */new Map,this.Xs=!1}Io(){this.Vs=/* @__PURE__ */new Map,this.Qs=!1,this.Js=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ys=/* @__PURE__ */new Set}Co(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ds(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type||"gauge"===i.type||"histogram"===i.type)if("count"===i.type&&0>i.value)this.R.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,n;try{r=i.attributes?e({},i.attributes):void 0,n=ii(i.type,i.name,i.unit,r)}catch(t){return void this.R.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s,a=this.Vs.get(n);if((a||this.Ao())&&("histogram"!==i.type||(s=this.Ro(i.name,i.unit,i.bounds)))){a||(a={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now(),hist:s&&si(s)},this.Vs.set(n,a));var o=this.Js.get(i.name);void 0===o?this.Js.set(i.name,i.type):o===i.type||this.Zs.has(i.name)||(this.Zs.add(i.name),this.R.warn("Metric name '"+i.name+"' is already used as a "+o+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Po(a,i.value);var l=this.Oo();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Ls()}}else this.R.warn("Dropping metric '"+i.name+"': unknown type '"+String(i.type)+"'");else this.R.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.R.warn("Dropping metric with empty name")}}Oo(){try{var t,e,i=(r=null==(t=(e=this._instance).getActiveSpan)||null==(t=t.call(e))?void 0:t.traceparent(),s=function(t){if("string"==typeof t){var e=Ze.exec(t.trim());if(e){var i=e[1],r=e[2],n=e[3],s=e[4];if("ff"!==i&&("00"!==i||!e[5])&&function(t){return Ye(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Ye(t,16,"0000000000000000")}(n))return{version:i,traceId:r,spanId:n,flags:s}}}}(r),s&&{traceId:s.traceId,spanId:s.spanId,flags:(n=s.flags,1&parseInt(n,16)?"01":Qe)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}Ao(){return this.Br.maxSeriesPerFlush>this.Vs.size||(this.Qs||(this.Qs=!0,this.R.warn("Metric series cap reached ("+this.Br.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ro(t,e,i){if(void 0===i||function(t){if(!h(t)||0===t.length)return!1;for(var e=0;t.length>e;e++)if(!Number.isFinite(t[e])||e>0&&t[e-1]>=t[e])return!1;return!0}(i)){var r=ii("histogram",t,e,void 0),n=this.Ks.get(r);if(n)return this.Fo(t,r,n,i),n;if(this.Ks.size>=this.Br.maxSeriesPerFlush){if(this.Xs||(this.Xs=!0,this.R.warn("Histogram bounds limit reached ("+this.Br.maxSeriesPerFlush+" distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.")),i&&!ni(i,ti))return;return ti}var s=i?i.slice():ti;return this.Ks.set(r,s),s}this.R.warn("Dropping histogram '"+t+"': bounds must be a non-empty array of finite, strictly increasing numbers")}Fo(t,e,i,r){ni(i,null!=r?r:ti)||this.Ys.has(e)||(this.Ys.add(e),this.R.warn("Histogram '"+t+"' already uses the bounds ["+i.join(", ")+"]; samples that pass different bounds are recorded in those buckets."))}Po(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,r.bounds)]+=1}}Ds(t){var e=this.Br.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Metric was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for metric:",t),null}return r}Ls(){this.gs.pending||this.gs.arm(this.Ws())}Ws(){return Math.max(Ke(this.Br.flushIntervalMs,this.xs,this.$s,3e4),this.Ss.remainingMs())}To(){var t=this;return r(function*(){if(t.gs.clear(),0!==t.Vs.size){var e=t.Vs;t.Io();var i=t.$o,r=yield t._instance.Lo(t.Eo(e));if(i===t.$o)switch(t.Ss.record(r),"retry-later"===r.kind?(t.xs++,t.$s=Ge()):(t.xs=0,t.$s=1),t.gs.pending&&t.gs.arm(t.Ws()),r.kind){case"ok":return;case"retry-later":return t.Do(e),void t.gs.armNoEarlierThan(t.Ws());case"too-large":return void t.R.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.R.error("Failed to send metrics batch:",r.error)}}})()}Eo(t){return e=this.No(t),i=function(t,e,i){return De(t,e,i)}(this.Br,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Le(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}No(t){var i=ei(Date.now()),r=/* @__PURE__ */new Map;for(var n of t.values()){var s,a=ii(n.type,n.name,n.unit,void 0),o=r.get(a);o||(o=e({name:n.name},n.unit&&{unit:n.unit}),"count"===n.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===n.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Oe(null!==(s=n.attributes)&&void 0!==s?s:{},this.R),u=ei(n.windowStartMs),h=ai(n.exemplar);if("count"===n.type){var c,v=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(c=n.total)&&void 0!==c?c:0},h);o.sum.dataPoints.push(v)}else if("gauge"===n.type){var d,f=e({attributes:l,timeUnixNano:i,asDouble:null!==(d=n.last)&&void 0!==d?d:0},h);o.gauge.dataPoints.push(f)}else{var p=n.hist,g=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,count:p.count,sum:p.sum,min:p.min,max:p.max,bucketCounts:p.bucketCounts,explicitBounds:p.bounds},h);o.histogram.dataPoints.push(g)}}return Array.from(r.values())}Do(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Vs.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,a.windowStartMs),o.exemplar=null!==(n=o.exemplar)&&void 0!==n?n:a.exemplar,o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=a.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":var l=o.hist,u=a.hist;l.count+=u.count,l.sum+=u.sum,l.min=Math.min(l.min,u.min),l.max=Math.max(l.max,u.max);for(var h=0;l.bucketCounts.length>h;h++)l.bucketCounts[h]+=u.bucketCounts[h]}else this.Ao()&&this.Vs.set(s,a)}}};function ni(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(var i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}function si(t){return{bounds:t,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(t.length+1).fill(0)}}function ai(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:ei(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var oi="0.12.1",li={DEBUG:!1,LIB_VERSION:oi,LIB_NAME:"browser-common",JS_SDK_VERSION:oi},ui=function(t,e){var i=(void 0===e?{}:e).debugEnabled,r={N(e){var r;try{r=typeof window>"u"?void 0:window}catch(t){return}for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;n>a;a++)s[a-1]=arguments[a];r&&(li.DEBUG||r.POSTHOG_DEBUG||i)&&!f(r.console)&&r.console&&("__rrweb_original__"in r.console[e]?r.console[e].__rrweb_original__:r.console[e])(t,...s)},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>ui(t+" "+e,i)};return r},hi=/* @__PURE__ */ui("[PostHog.js]"),ci=(t,e)=>hi.createLogger(t,e);function vi(t,e){h(t)&&t.forEach(e)}function di(t,e){if(!y(t))if(h(t))t.forEach(e);else if(t instanceof FormData)t.forEach((t,i)=>e(t,i));else for(var i in t)l.call(t,i)&&e(t[i],i)}var fi=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var n of i)for(var s in n)void 0!==n[s]&&(t[s]=n[s]);return t};function pi(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}function gi(t,e,i,r){var n=null!=r?r:{},s=n.capture,a=n.passive;null==t||t.addEventListener(e,i,{capture:void 0!==s&&s,passive:void 0===a||a})}function mi(t){return"ph_toolbar_internal"===t.name}function yi(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!c(r))return e;try{var n=r(e);return p(n)&&n?n:e}catch(t){return hi.error("Error in get_current_url, falling back to window.location.href",t),e}}var _i="$early_access_features",bi="$active_feature_flags",wi="$feature_flag_details",xi="$feature_flag_errors",Si="$feature_flag_evaluated_at",ki="$feature_flag_request_id",Ei="$minimal_flag_called_events",Ai="$enabled_feature_flags",Ti="$stored_group_properties",Fi="$stored_person_properties",Pi="$flag_call_reported",Ci="$flag_call_reported_session_id",Ri="$feature_flag_payloads",Oi="$override_feature_flags",Mi="$override_feature_flag_payloads",$i="visibilitychange",Ii="$autocapture_disabled_server_side";function Di(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ji(t){return!!t&&1===t.nodeType}function Li(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Ni(t){return!!t&&3===t.nodeType}function zi(t){return!!t&&11===t.nodeType&&ji(t.host)}function Bi(t){return t?a(t).split(/\s+/):[]}function Ui(t,e){var i=function(t){var e,i=null==(e=typeof window>"u"?void 0:window)||null==(e=e.location)?void 0:e.href;return f(i)?void 0:yi(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function Hi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Bi(e)}function qi(t){return y(t)?null:a(t).split(/(\s+)/).filter(t=>wr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Vi(t){var e="";return vr(t)&&!dr(t)&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;Ni(t)&&t.textContent&&(e+=null!==(i=qi(t.textContent))&&void 0!==i?i:"")}),a(e)}function Wi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var Gi=["a","button","form","input","select","textarea","label"];function Ki(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}function Ji(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Ki(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Xi(t){var e=t.parentNode;return!(!e||!ji(e))&&e}var Yi=[".ph-no-autocapture","[data-ph-no-autocapture]"],Zi=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Qi=/* @__PURE__ */(()=>[...Zi,"+","-","−","–"])(),tr=/* @__PURE__ */(()=>Qi.length+10)(),er=["button","a","input","select","textarea","label"],ir=["button","link","tab","menuitem","option"],rr=(t,e)=>/[a-z0-9]/i.test(e)?s(Qi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,nr=t=>s(er,t.tagName.toLowerCase())||s(ir,(t.getAttribute("role")||"").toLowerCase());function sr(t){var e="",i="",r=t=>{ji(t)&&vr(t)&&!dr(t)&&(e+=" "+Vi(t),i=i||t.getAttribute("aria-label")||"",di(t.childNodes,r))};r(t);var n=(wr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var ar=[".ph-no-rageclick",".ph-no-capture"],or=["","text","search","email","password","url","tel","number"];function lr(t,e){if(!(typeof window>"u"?void 0:window)||ur(t))return!1;var i,r,n,a,o;if(b(e)?(i=!!e&&ar,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:ar,r=null==e?void 0:e.content_ignorelist,n=null!==(o=null==e?void 0:e.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(t){return!(!t||!ji(t))&&(!!Li(t,"textarea")||(Li(t,"input")?s(or,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var l=hr(t,!1),u=l.targetElementList;return!(!l.isComplete||r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Zi;else{if(!h(t))return!1;if(t.length>tr)return hi.error("[PostHog] content_ignorelist array cannot exceed "+tr+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>rr(r,t)||rr(n,t))}(r,function(t,e){for(var i of e)if(nr(i))return sr(i);for(var r of e){try{var n;if("pointer"!==(null==(n=window)?void 0:n.getComputedStyle(r).getPropertyValue("cursor")))break}catch(t){break}var s=sr(r);if(s.safeText||s.ariaLabel)return s}return sr(t)}(t,u))||Ji(u,i))}var ur=t=>!t||Li(t,"html")||!ji(t),hr=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ur(t))return{parentIsUsefulElement:!1,targetElementList:[],isComplete:!1};for(var r=!1,n=[t],s=t,a=/* @__PURE__ */new Set([t]);!Li(s,"body");){var o=s.assignedSlot||s.parentNode,l=zi(o)?o.host:o&&ji(o)?o:null;if(!l)break;if(a.has(l)||a.size>=1e3)return{parentIsUsefulElement:r,targetElementList:n,isComplete:!1};if(a.add(l),zi(o))n.push(l),s=l;else{if(e||Gi.indexOf(l.tagName.toLowerCase())>-1)r=!0;else try{var u=i.getComputedStyle(l);u&&"pointer"===u.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(l),s=l}}return{parentIsUsefulElement:r,targetElementList:n,isComplete:!0}};function cr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r;){if(i++>=1e3||e.has(r))return!0;e.add(r);var n=Hi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!0;var a=r.assignedSlot||r.parentNode;r=zi(a)?a.host:a&&ji(a)?a:null}return!1}function vr(t){if(cr(t))return!1;if(s(Hi(t),"ph-include"))return!0;var e=t.type||"";if(p(e))switch(e.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";return!p(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,""))}function dr(t){return!!(Li(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Li(t,"select")||Li(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var fr=/* @__PURE__ */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}))$"),pr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,gr=[16,15,14,13],mr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),yr=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),_r=/[0-9A-Za-z_]/;function br(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function wr(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?fr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(pr.lastIndex=0;e=pr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of gr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(fr.test(o)&&br(o))return!0}}}return!1}(t))return!1;if(e?mr.test(t):function(t){var e;for(yr.lastIndex=0;e=yr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&_r.test(i)&&_r.test(r)))return!0}return!1}(t))return!1}return!0}function xr(t){var e=Vi(t);return wr(e=(e+" "+Sr(t)).trim())?e:""}function Sr(t){var e="";return t&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Vi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Sr(t)).trim())}catch(t){hi.error("[AutoCapture]",t)}}),e}function kr(t){return t.replace(/"|\\"/g,'\\"')}function Er(t){var e=t.attr__class;if(e)return h(e)?e:Bi(e)}var Ar=class{constructor(t){this.disabled=!1===t;var e=v(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}},Tr=t=>{var e,i=null==(e=typeof document>"u"?void 0:document)?void 0:e.createElement("a");return f(i)?null:(i.href=t,i)},Fr=()=>typeof window>"u"?void 0:window,Pr=()=>typeof document>"u"?void 0:document,Cr="$copy_autocapture",Rr=["password","hidden","file","checkbox","button","submit","reset","image"],Or=/* @__PURE__ */ci("[AutoCapture]");function Mr(t,e){return e.length>t?e.slice(0,t)+"...":e}function $r(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ji(e));return e}function Ir(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!ji(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;!Li(g,"body")&&1e3>d.length;){var m=g.assignedSlot||g.parentNode,y=zi(m)?m.host:m&&ji(m)?m:null;if(!y||f.has(y))break;f.add(y),d.push(y),g=y}var _="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Li(t,"button")||Li(t,"a")):-1;_>0&&(l=l||d.slice(0,_+1).some(t=>!vr(t)||dr(t)));var b,w,x,S=[],k={},E=!1,A=!1;if(di(d,t=>{var e=vr(t);if(e&&Li(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");E=!!(e&&i&&wr(i))&&(v?J(i):i)}s(Hi(t),"ph-no-capture")&&(A=!0),S.push(function(t,e,i,r,n){void 0===n&&(n=!1);var s=t.tagName.toLowerCase(),a={tag_name:s};Gi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Mr(1024,xr(t)):Mr(1024,Vi(t)));var o=Hi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),di(cr(t)?[]:t.attributes,function(i){var s;if((!dr(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&wr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Bi(o).join(" ")),a["attr__"+i.name]=Mr(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=$r(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),di(function(t){if(!vr(t))return{};var e={};return di(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&wr(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(k,e)||(k[e]=t)})}),A)return{props:{},explicitNoCapture:A};if(_>0&&(t=d[_],S.splice(0,_)),l||(S[0].$el_text=Li(t,"a")||Li(t,"button")?xr(t):Vi(t)),E){var T,F;S[0].attr__href=E;var P=null==(T=Tr(E))?void 0:T.host,C=null==(F=Fr())||null==(F=F.location)?void 0:F.host;P&&C&&P!==C&&(b=E)}return{props:fi((w=a.type,{$event_type:w,$ce_version:1}),c?{}:{$elements:S},{$elements_chain:(x=S,h(x)?function(t){return t.map(t=>{var i,r,n="";if(t.tag_name&&(n+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))n+="."+s.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return pi(a).sort((t,e)=>{return(r=e[0])>(i=t[0])?-1:i>r?1:0;var i,r}).forEach(t=>{var e=t[1];return o[kr(t[0].toString())]=kr(e.toString())}),(n+=":")+pi(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Er(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return pi(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(x)):"")},null!=(r=S[0])&&r.$el_text?{$el_text:null==(n=S[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},k),target:t}}var Dr=class{ka(){this.Sa=void 0,clearTimeout(this.xa),this.xa=void 0}$a(t){var e;if(!vr(t))return!0;for(var i,r=null!==(e=this.Ca().css_selector_ignorelist)&&void 0!==e?e:Yi,n=/* @__PURE__ */new Set,a=t,o=function(){if(n.size>=1e3||n.has(a))return{v:!0};n.add(a);var t=a,e=Hi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||dr(t)||r.some(e=>Ki(t,e)))return{v:!0};var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(i=o())return i.v;return!1}Ta(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.Sa;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.ka():"pointerup"===t.type&&(e.released=!0,this.xa=setTimeout(()=>this.ka(),0)))}else{var i;this.ka();var r=Wi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&ji(r)&&(this.Sa={target:r,excluded:this.$a(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.Wl)?void 0:i.distinctId})}else this.ka()}Ma(t){var e,i=this.Sa;this.ka();var r=Wi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.Wl)?void 0:e.distinctId)&&t.pointerId===i.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-i.x)&&5>=Math.abs(t.clientY-i.y)&&r&&(Li(r,"html")||Li(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.Ca().css_selector_ignorelist)&&void 0!==n?n:Yi;return[r,null==(a=Pr())?void 0:a.documentElement,null==(o=Pr())?void 0:o.body].some(t=>{if(!t)return!1;var e=Hi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!vr(t)||dr(t)||l.some(e=>Ki(t,e))})?null:i.target}}constructor(t){this.Ql=t,this.name="autocapture",this.Ia=!1,this.Ea=null,this.Aa=!1,this.Ra=/* @__PURE__ */new Map,this.Pa=!1,this.Br={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ai=!1,this.Ql.refresh(this.Br),this.rageclicks=new Ar(this.Br.rageclick),this.Oa=null}setup(t){this.Fa(),this.Wl=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ai?e.dispose():(this.oa=e,this.startIfEnabled())}dispose(){var t;this.Ai||(this.Ai=!0,this.Wl=void 0,null==(t=this.oa)||t.dispose(),this.oa=void 0,this.Ra.clear(),this.Oa=null,this.La())}Ca(){return this.Ql.refresh(this.Br),this.Br}Fa(){var t,e;return this.Ca(),this.Br.url_allowlist=null==(t=this.Br.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Br.url_ignorelist=null==(e=this.Br.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Br}Da(){var t=Fr(),e=Pr();if(this.isBrowserSupported()){if(t&&e){this.Na=t,this.ja=e;var i=this.qa=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.ka();if(0===e.type.indexOf("pointer"))return void this.Ta(e);var i="click"===e.type?this.Ma(e):void 0;if(m(i))return;this.Ba(e,"$autocapture",i)}catch(t){Or.error("Failed to capture event",t)}};if(gi(t,"blur",i),gi(e,"submit",i,{capture:!0}),gi(e,"change",i,{capture:!0}),gi(e,"click",i,{capture:!0}),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{gi(e,t,i,{capture:!0})}),this.Ca().capture_copied_text){var r=this.za=e=>{e=e||(null==t?void 0:t.event);try{this.Ba(e,Cr)}catch(t){Or.error("Failed to capture clipboard event",t)}};gi(e,"copy",r,{capture:!0}),gi(e,"cut",r,{capture:!0}),gi(e,"paste",r,{capture:!0})}}}else Or.info("Disabling Automatic Event Collection because this browser is not supported")}La(){var t=this.Na,e=this.ja;this.ka(),this.qa&&(null==t||t.removeEventListener("blur",this.qa),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.qa,!0)}),null==e||e.removeEventListener("submit",this.qa,!0),null==e||e.removeEventListener("change",this.qa,!0),null==e||e.removeEventListener("click",this.qa,!0),this.qa=void 0),this.za&&(null==e||e.removeEventListener("copy",this.za,!0),null==e||e.removeEventListener("cut",this.za,!0),null==e||e.removeEventListener("paste",this.za,!0),this.za=void 0),this.Na=void 0,this.ja=void 0,this.Ia=!1}startIfEnabled(){this.isEnabled||this.ka(),!this.Ai&&this.Wl&&this.isEnabled&&!this.Ia&&(this.Da(),this.Ia=!0)}onRemoteConfig(t){if(!this.Ai)if(this.Aa=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.Pa=e.elementsChainAsString);var i,r=e.autocapture_opt_out;b(r)&&(null==(i=this.Wl)||i.kv.set(Ii,r),this.Ea=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Ai){t.size?this.Ra.set(e,new Set(t)):this.Ra.delete(e);var i=/* @__PURE__ */new Set;this.Ra.forEach(t=>{t.forEach(t=>i.add(t))}),this.Oa=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.Oa)||i.forEach(i=>{var n;null==(n=Pr())||null==(n=n.querySelectorAll(i))||n.forEach(n=>{t!==n&&e!==n||s(r,i)||r.push(i)})}),r}get isEnabled(){var t,e;if(this.Ai)return!1;var i=null==(t=this.Wl)?void 0:t.kv.get(Ii),r=this.Ea,n=this.Ca();if(!n.remoteRequestsDisabled&&!this.Aa)return!1;var s=n.remoteRequestsDisabled&&!this.Aa;if(m(r)&&!b(i)&&!s)return!1;var a=null!==(e=this.Ea)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Ba(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Wi(t);Ni(n)&&(n=n.parentNode||null);var a,o=this.Fa();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(a=this.rageclicks)&&a.isRageClick(t.clientX,t.clientY,t.timeStamp||/* @__PURE__ */(new Date).getTime())&&lr(n,o.rageclick)&&this.Ba(t,"$rageclick",r);var l,u=i===Cr,v=u?e({},o,{dom_event_allowlist:void 0}):o;if(n&&function(t,e,i,r,n,s){var a,o=typeof window>"u"?void 0:window;if(!o||ur(t))return!1;if(null!=i&&i.url_allowlist&&!Ui(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ui(i.url_ignorelist,s))return!1;if(null!=i&&i.dom_event_allowlist){var l=i.dom_event_allowlist;if(l&&!l.some(t=>e.type===t))return!1}var u=hr(t,r),h=u.parentIsUsefulElement,c=u.targetElementList;if(!u.isComplete)return!1;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(f(i))return!0;var r,n=function(t){if(i.some(e=>t.tagName.toLowerCase()===e))return{v:!0}};for(var s of t)if(r=n(s))return r.v;return!1}(c,i))return!1;if(!Ji(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Ji(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Yi))return!1;try{var v=o.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return h?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(Gi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,v,u,u?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var d,p=Ir(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.Pa,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),g=p.props;if(p.explicitNoCapture)return!1;var m=this.getElementSelectors(n,p.target);if(m&&m.length>0&&(g.$element_selectors=m),i===Cr){var y=t.type||"clipboard";if("paste"!==y){var _,b,w=null==(_=Fr())||null==(_=_.getSelection())?void 0:_.toString(),x=qi(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(b=null==w?void 0:w.length)&&void 0!==b?b:0}g.$copy_type=y}if("$autocapture"===i&&"change"===t.type&&o.capture_value_css_selector_allowlist&&!o.maskAllText&&(Li(l=n,"input")?!s(Rr,l.type):Li(l,"textarea")||Li(l,"select")&&!l.multiple)&&function(t,e){var i;if(!vr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Yi,n=/* @__PURE__ */new Set,a=t;Li(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=Hi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Ki(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(o=l())return o.v;return!0}(n,o)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){var S=o.capture_value_css_selector_allowlist,k=!1;try{k=c(S)?!!S(n):h(S)&&S.some(t=>Ki(n,t))}catch(t){Or.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.Wl)||d.capture(i,g),!0}}else this.ka()}isBrowserSupported(){var t;return c(null==(t=Pr())?void 0:t.querySelectorAll)}},jr=["[data-ph-capture-value]"],Lr=class{constructor(t){this._instance=t}refresh(t){var e,i=this._instance.config,r=v(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==r?void 0:r.url_allowlist,t.url_ignorelist=null==r?void 0:r.url_ignorelist,t.dom_event_allowlist=null==r?void 0:r.dom_event_allowlist,t.element_allowlist=null==r?void 0:r.element_allowlist,t.css_selector_allowlist=null==r?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=null==r?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=null==r?void 0:r.element_attribute_ignorelist,t.capture_copied_text=null==r?void 0:r.capture_copied_text,t.capture_value_css_selector_allowlist=null!==(e=null==r?void 0:r.capture_value_css_selector_allowlist)&&void 0!==e?e:jr}},Nr=class extends Dr{constructor(t){super(new Lr(t)),this.instance=t}},zr="$surveys",Br="$surveys_loaded_at",Ur="PostHog loadExternalDependency extension not found.",Hr="$surveys_activated",qr="$surveys_activated_session",Vr="$surveys_activated_timestamps",Wr="$heatmaps_enabled_server_side",Gr="$exception_capture_enabled_server_side",Kr="$error_tracking_suppression_rules",Jr="$error_tracking_capture_extension_exceptions",Xr="$web_vitals_enabled_server_side",Yr="$dead_clicks_enabled_server_side",Zr="$product_tours_enabled_server_side",Qr="$web_vitals_allowed_metrics",tn="$session_recording_remote_config",en="$replay_override_sampling",rn="$replay_override_linked_flag",nn="$session_is_sampled",sn="ph_product_tours",an="$sdk_debug_recording_script_not_loaded",on="$sdk_debug_replay_stale_config",ln="beforeunload",un="u">typeof window?window:void 0,hn="u">typeof globalThis?globalThis:un,cn=null==hn?void 0:hn.navigator,vn=null==hn?void 0:hn.document,dn=null==hn?void 0:hn.location;null!=hn&&hn.XMLHttpRequest&&new hn.XMLHttpRequest;var fn="undefined"!=typeof globalThis?globalThis:un;fn&&"undefined"==typeof self&&(fn.self=fn),fn&&"undefined"==typeof File&&(fn.File=function(){});var pn=null!=un?un:{},gn=t=>{var e;return null!=t&&t.config.require_subresource_integrity?t.__loadExternalDependency:null==(e=pn.__PosthogExtensions__)?void 0:e.loadExternalDependency},mn=/* @__PURE__ */ci("[Dead Clicks]"),yn=()=>!0,_n=class{get lazyLoadedDeadClicksAutocapture(){return this.Ja}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Yr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Za(()=>{this.Ka()}):this.stop()}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=gn(this.instance))||i(this.instance,"dead-clicks-autocapture",e=>{e?mn.error("failed to load script",e):t()})}Ka(){var t;if(vn){if(!this.Ja&&null!=(t=pn.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=v(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Ja=pn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ja.start(vn),mn.info("starting...")}}else mn.error("`document` not found. Cannot start.")}stop(){this.Ja&&(this.Ja.stop(),this.Ja=void 0,mn.info("stopping..."))}},bn=/* @__PURE__ */ci("[ExceptionAutocapture]"),wn=class{constructor(t){var i;this.Vp=()=>{var t;if(un&&this.isEnabled&&null!=(t=pn.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=pn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=pn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=pn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Jp&&this.Br.capture_unhandled_errors&&(this.Jp=e(this.captureException.bind(this))),!this.Zp&&this.Br.capture_unhandled_rejections&&(this.Zp=i(this.captureException.bind(this))),!this.Kp&&this.Br.capture_console_errors&&(this.Kp=r(this.captureException.bind(this)))}catch(t){bn.error("failed to start",t),this.Yp()}}},this._instance=t,this.Xp=!(null==(i=this._instance.persistence)||!i.props[Gr]),this.kt=new C(e({},function(t){var e,i,r,n;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,R:bn})),this.Br=this.tg(),this.startIfEnabledOrStop()}tg(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return v(t)?i=e({},i,t):(f(t)?this.Xp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Br.capture_console_errors||this.Br.capture_unhandled_errors||this.Br.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(bn.info("enabled"),this.Yp(),this.Za(this.Vp)):this.Yp()}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=gn(this._instance))||i(this._instance,"exception-autocapture",e=>{if(e)return bn.error("failed to load script",e);t()})}Yp(){var t,e,i;null==(t=this.Jp)||t.call(this),this.Jp=void 0,null==(e=this.Zp)||e.call(this),this.Zp=void 0,null==(i=this.Kp)||i.call(this),this.Kp=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Xp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Gr]:this.Xp}),this.Br=this.tg(),this.startIfEnabledOrStop())}}onConfigChange(){this.Br=this.tg()}captureException(t){try{var e,i,r,n=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";if(this.kt.consumeRateLimit(n))return void bn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},xn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},Sn=(t,e)=>t>=e&&xn(),kn=(t,e,i,r)=>{if(0===t){if(xn()){var n=e+1;return n===i&&r(),n}return e}return 0},En=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;r.length>n;n++){var s=r[n].split(/=(.*)/);if(s[0]===e){i=s;break}}if(!h(i)||2>i.length)return"";var a=i[1].replace(/\+/g," ");try{a=decodeURIComponent(a)}catch(t){hi.error("Skipping decoding for malformed query param: "+a)}return a},An=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split(/#(.*)/),n=r[1],s=(r[0]||"").split(/\?(.*)/),a=s[1],o=s[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){for(var c=l[h].split("?"),v=0;c.length>v&&!e.includes(c[v].split("=")[0]);)v++;u.push(c.length>v?c.slice(0,v).concat(c[v].split("=")[0]+"="+i).join("?"):l[h])}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=n&&(d+="#"+n),d},Tn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Fn=()=>{},Pn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function Cn(t,e,i){try{if(!(e in t))return Fn;var r={next:t[e]},n=i(function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)});return c(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=n,()=>{if(t[e]!==n)for(var i=t[e],s=Pn(i);s;){if(s.next===n)return void(s.next=r.next);s=Pn(i=s.next)}else t[e]=r.next}}catch(t){return Fn}}var Rn=class{constructor(t){this.vp=!1,this._instance=t,this.fp=this.pp()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.gp();return!!(t.path||t.search||this.mp(t))}startIfEnabled(){this.isEnabled&&(hi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.fp=this.pp(),this.startIfEnabled()}stop(){this.yp&&this.yp(),this.yp=void 0,this.bp&&this.bp(),this.bp=void 0,hi.info("History API monitoring stopped")}monitorHistoryChanges(){un&&un.history&&(this._p("pushState"),this._p("replaceState"),this.wp(),this.mp()&&this.kp())}_p(t){var e;if(un&&(null==(e=un.history[t])||!e.__posthog_wrapped__)){var i=this;Cn(un.history,t,e=>function(r,n,s){var a;i.Sp(s)&&i.xp(),e.call(this,r,n,s),i.$p(t,!i.vp&&"popstate"!==(null==un||null==(a=un.event)?void 0:a.type))})}}pp(){var t=null==un?void 0:un.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}gp(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}mp(t){return void 0===t&&(t=this.gp()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Cp(t){var e=this.gp(),i=this.fp;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.mp(e)&&t.hash!==i.hash))}$p(t,e){void 0===e&&(e=!1);try{e||this.xp();var i=this.pp();if(!i)return;if(this.Cp(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.Tp=r,Promise.resolve().then(()=>this.xp())):r()}this.fp=i}catch(e){hi.error("Error capturing "+t+" pageview",e)}}Sp(t){var e,i;return!(y(t)||!un)&&(null==(e=Tr(String(t)))?void 0:e.href)!==(null==(i=un.location)?void 0:i.href)}xp(){var t=this.Tp;if(t){this.Tp=void 0,this.vp=!0;try{t()}catch(t){hi.error("Error capturing deferred pageview",t)}finally{this.vp=!1}this.fp=this.pp()}}wp(){if(!this.yp){var t=()=>{this.$p("popstate")};gi(un,"popstate",t),this.yp=()=>{un&&un.removeEventListener("popstate",t)}}}kp(){if(!this.bp){var t=()=>{this.$p("hashchange")};gi(un,"hashchange",t),this.bp=()=>{un&&un.removeEventListener("hashchange",t)}}}},On=/* @__PURE__ */ci("[TracingHeaders]"),Mn=class{constructor(t){this._instance=t,this.Ig=void 0,this.Eg=void 0,this.Ag=void 0,this.Rg=void 0,this.Pg=[],this.Vp=()=>{var t,e,i=this.Og(),r=i.hostnames;r||i.traceparentTargets?(r||h(this.Ag)||(this.Ag=[]),this.Rg!==this.Ag&&(this.Yp(),this.Rg=this.Ag),f(this.Ig)&&(this.Ig=null==(t=pn.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(this.Ag,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.Pg)),f(this.Eg)&&(this.Eg=null==(e=pn.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(this.Ag,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.Pg))):this.Yp()}}initialize(){this.startIfEnabledOrStop()}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=gn(this._instance))||i(this._instance,"tracing-headers",e=>{if(e)return On.error("failed to load script",e);t()})}Fg(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Lg(){var t=this.Fg();return h(t)?(h(this.Ag)?this.Ag.splice(0,this.Ag.length,...t):this.Ag=[...t],t.length>0?this.Ag:void 0):!h(this.Ag)||(this.Ag.splice(0),t)?(this.Ag=t||void 0,this.Ag):void 0}Dg(){var t=this._instance.config.trace_propagation_targets,e=h(t)?t.filter(t=>p(t)&&!!t):[];return this.Pg.splice(0,this.Pg.length,...e),e.length>0?this.Pg:void 0}Og(){return{hostnames:this.Lg(),traceparentTargets:this.Dg()}}Yp(){var t,e;null==(t=this.Ig)||t.call(this),null==(e=this.Eg)||e.call(this),this.Ig=void 0,this.Eg=void 0}startIfEnabledOrStop(){var t=this.Og();t.hostnames||t.traceparentTargets?this.Za(this.Vp):this.Yp()}};function $n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var In=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Dn=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...In])(),jn="<masked>",Ln=["li_fat_id"];var Nn=/* @__PURE__ */ci("[Web Vitals]"),zn=9e5,Bn=["CLS","FCP","INP","LCP"],Un=["INP","LCP"],Hn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],qn=class{constructor(t){var i,r=this;this._instance=t,this.Mp=!1,this.Ia=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Bp=function(t){void 0===t&&(t=!1),clearTimeout(r.zp),r.zp=void 0,0!==r.Rt.metrics.length&&(r._instance.capture("$web_vitals",e({$current_url:r.Rt.url},r.Rt.metrics.reduce((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{})),t?{transport:"sendBeacon",send_instantly:!0}:void 0),r.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Hp=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},y(null==t?void 0:t.name)||y(null==t?void 0:t.value))Nn.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.Up(r);if(!f(n)){var s=_(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.Wp||this.Wp>t.value){this.Rt.navigationKey!==s&&(this.Bp(),this.zp=setTimeout(this.Bp,this.flushToCaptureTimeoutMs)),f(this.Rt.navigationKey)&&(this.Rt.navigationKey=s,this.Rt.url=n),this.Rt.firstMetricTimestamp=f(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});if(delete o.entries,v(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of Hn){var h="url"===u&&"string"==typeof t.attribution[u]?this.Up(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.Bp()}else Nn.error("Ignoring metric with value >= "+this.Wp,t)}}},this.Vp=()=>{if(!this.Ia){var t,i,r,n,s=!1,a=pn.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Gp])||("web-vitals"===this.Gp&&f(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!f(l)){var u=l.withoutAttribution,h=this.attributionMetrics;s=!f(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,i=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,n=h.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(t&&i&&r&&n){var c={reportSoftNavs:this.useSoftNavs},v=s&&this.attributionMetrics.indexOf("INP")>-1?e({},c,{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Hp.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Hp.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Hp.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.Hp.bind(this),v);var d=null==un?void 0:un.document;gi(d,$i,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.Bp(!0)}),gi(un,"pagehide",()=>this.Bp(!0)),this.Ia=!0}else Nn.error("web vitals callbacks not loaded - not starting")}},this.Mp=!(null==(i=this._instance.persistence)||!i.props[Xr]),this.startIfEnabled()}get Qp(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.Qp)?null==(t=this.Qp)?void 0:t.web_vitals_allowed_metrics:void 0;return y(i)?(null==(e=this._instance.persistence)?void 0:e.props.$web_vitals_allowed_metrics)||Bn:i}get flushToCaptureTimeoutMs(){return(v(this.Qp)?this.Qp.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.Qp)?this.Qp.web_vitals_attribution:void 0;return b(t)?t?Bn:[]:h(t)?t:Un}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.Qp)?this.Qp.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get Wp(){var t=v(this.Qp)&&_(this.Qp.__web_vitals_max_value)?this.Qp.__web_vitals_max_value:zn;return t>0&&6e4>=t?zn:t}get isEnabled(){var t=null==dn?void 0:dn.protocol;if("http:"!==t&&"https:"!==t)return Nn.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.Qp)?this.Qp.web_vitals:b(this.Qp)?this.Qp:void 0;return b(e)?e:this.Mp}startIfEnabled(){this.isEnabled&&!this.Ia&&(Nn.info("enabled, starting..."),this.Za(this.Vp))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=v(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=v(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xr]:i}),this._instance.persistence.register({[Qr]:r})),this.Mp=i,this.startIfEnabled()}}}get Gp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Za(t){var e,i=pn.__PosthogExtensions__,r=this.Gp,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=n&&n[r]||"web-vitals"===r&&f(n)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==(e=gn(this._instance))||e(this._instance,r,e=>{e?Nn.error("failed to load script",e):t()})}Up(t){var e=t||(null==un?void 0:un.location.href);if(e){var i=this._instance.config.disable_capture_url_hashes?J(e):e,r=this._instance.config.custom_personal_data_properties;return An(i,this._instance.config.mask_personal_data_properties?[...In,...r||[]]:[],jn)}Nn.error("Could not determine current URL")}},Vn=/* @__PURE__ */ci("[RemoteConfig]"),Wn=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}wc(t){var e=gn(this._instance);e?e(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}kc(t){var e=this._instance.__pending_remote_config_callbacks;if(e)e.push(t);else{var i=[t];this._instance.__pending_remote_config_callbacks=i;try{this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),batchKey:"remote_config",fireCallbackOnDrop:!0,callback:t=>{this._instance.__pending_remote_config_callbacks=void 0,i.forEach(e=>e(t))}})}catch(t){throw this._instance.__pending_remote_config_callbacks=void 0,t}}}load(){try{if(this.remoteConfig)return Vn.info("Using preloaded remote config",this.remoteConfig),void this.Sc(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Vn.warn("Remote config is disabled. Falling back to local config.");if(!this._instance.config.opt_in_site_apps)return void this.kc(t=>{this.Sc(t.json,t)});this.wc(t=>{if(!t)return Vn.info("No config found after loading remote JS config. Falling back to JSON."),void this.kc(t=>{this.Sc(t.json,t)});this.Sc(t)})}catch(t){Vn.error("Error loading remote config",t),this.Sc()}}Sc(t,e){!t&&e&&(0===e.statusCode?e.error||Vn.warn("Failed to fetch remote config from PostHog."):Vn.error("Failed to fetch remote config from PostHog."));try{this._instance.Sc(t?{ok:!0,config:t}:{ok:!1})}catch(t){Vn.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 i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){Vn.error("Error loading feature flags",t)}}},Gn="disabled",Kn="lazy_loading",Jn=null,Xn={Ot(){if(!m(Jn))return Jn;if(Jn=!0,f(un))Jn=!1;else try{var t="__support__";Xn.$t(t,"xyz"),'"xyz"'!==Xn.Lt(t)&&(Jn=!1),Xn.Ft(t)}catch(t){Jn=!1}return Jn},Dt(t){hi.error("sessionStorage error: ",t)},Lt(t){try{return null==un?void 0:un.sessionStorage.getItem(t)}catch(t){Xn.Dt(t)}return null},Pt(t){try{return JSON.parse(Xn.Lt(t))||null}catch(t){}return null},$t(t,e){try{return null==un||un.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(t){Xn.Dt(t)}return!1},Ft(t){try{null==un||un.sessionStorage.removeItem(t)}catch(t){Xn.Dt(t)}}};function Yn(t){return"ph_replay_pending_buffer_"+JSON.stringify([t.persistence_name||t.token,t.token])}var Zn=/* @__PURE__ */ci("[SessionRecording]"),Qn=[an,on,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],ts=class{get Br(){return this._instance.config}get Qc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Yf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this.Xf||"missing_config"===this.Xf?this.Xf:null!==(t=null==(e=this.Yf)?void 0:e.status)&&void 0!==t?t:this.Xf}constructor(t){var e;if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Xf=Gn,this.tp=void 0,this.ep=!1,this.Yn=void 0,this.Xe=(()=>{var t;if(null==vn||!vn.visibilityState||"visible"===vn.visibilityState)return!0;var e=null==un||null==(t=un.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.un=()=>{var t;"visible"===(null==vn?void 0:vn.visibilityState)&&(this.Xe=!0,null==(t=this.Yf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Zn.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Br.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');var i=this._instance.get_property(nn);p(i)&&"!"===i[0]&&(null==(e=this.Qc)||e.unregister(nn)),null!=vn&&vn.addEventListener&&gi(vn,"visibilitychange",this.un)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.ep=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.un),i?this.np(!0):this.stopRecording()}get sp(){var t,e=!(null==(t=this._instance.get_property(tn))||!t.enabled),i=!this.Br.disable_session_recording,r=this.Br.disable_session_recording||this._instance.consent.isOptedOut();return un&&e&&i&&!r}startIfEnabledOrStop(t){if(!this.ep){var e;if(this.Yf)if(this.Yn!==(null==(e=this.Br.session_recording)?void 0:e.selectMaskingFn))Xn.Ft(Yn(this.Br)),this.Yf.discard({discardProducerEvents:!0}),this.Yn=void 0;else if(this.Yf.isStarted&&this.sp)return void(this.rp()||this.np(!0));var i=!f(Object.assign)&&!f(Array.from);this.sp&&i?(this.op(t),Zn.info("starting")):(this.Xf=Gn,this.stopRecording())}}op(t){var e,i;if(this.sp)if("awaiting_config"!==this.Xf&&"missing_config"!==this.Xf&&(this.Xf=Kn),null!=pn&&null!=(e=pn.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=pn.__PosthogExtensions__)&&i.initSessionRecording)this.lp(t);else{var r,n=this._instance.sessionManager;null==(r=gn(this._instance))||r(this._instance,this.ap,e=>{if(!this.ep&&this.sp&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[an]:!0}),Zn.error("could not load recorder",e)):void this.lp(t);this.Xf=Gn})}}stopRecording(){var t,e;null==(t=this.tp)||t.call(this),this.tp=void 0,null==(e=this.Yf)||e.stop()}np(t){var e,i,r;void 0===t&&(t=!1),t&&(this.Yn||null!=(e=this.Br.session_recording)&&e.selectMaskingFn)&&Xn.Ft(Yn(this.Br)),null==(i=this.tp)||i.call(this),this.tp=void 0,null==(r=this.Yf)||r.discard({discardProducerEvents:t}),this.Yn=void 0}up(){var t,e;null==(t=this.Qc)||t.unregister(nn),null==(e=this.Qc)||e.unregister("$replay_sample_rate")}cp(t,e){if(y(t))return null;var i,r=_(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Zn.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}hp(t){if(this.Qc){var i,r,n=this.Qc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.cp(null==(i=this.Br.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.cp(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.up();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[tn]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds: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})})};s(),null==(i=this.tp)||i.call(this),this.tp=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?!1===e.sessionRecording?(this.hp(e),void this.np()):(this.hp(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.Xf&&(this.Xf="missing_config",this._instance.register_for_session({[on]:!0}),Zn.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Yf)&&i.log?this.Yf.log(t,e):Zn.warn("log called before recorder was ready")}get ap(){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"}dp(){var t,e=this._instance.get_property(tn);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Zn.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!y(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}rp(){var t,e,i;return null==(t=this.Br.session_recording)||!t.selectMaskingFn||!(!0!==(null==(e=pn.__PosthogExtensions__)||null==(e=e.rrweb)||null==(e=e.record)?void 0:e.supportsSelectMasking)||!0!==(null==(i=pn.__PosthogExtensions__)||null==(i=i.initSessionRecording)?void 0:i.supportsSelectMasking)||this.Yf&&!0!==this.Yf.supportsSelectMasking)||(this.Xf=Gn,Zn.error("Session recording has not started: the recorder does not support selectMaskingFn."),!1)}lp(t){var e,i,r,n,s;if(!this.ep&&this.sp&&this._instance.sessionManager){if(null==(e=pn.__PosthogExtensions__)||!e.initSessionRecording)return Zn.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[an]:!0});var a;if(this.rp())if(this.Yf||(this.Yf=null==(a=pn.__PosthogExtensions__)?void 0:a.initSessionRecording(this._instance,this.Xe),this.Yf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.rp()){if(!this.dp()){if("missing_config"===this.Xf||"awaiting_config"===this.Xf)return;return this.Xf="awaiting_config",Zn.info("persisted remote config is stale, requesting fresh config before starting"),void new Wn(this._instance).load()}this.Xf=Kn,null==(i=(r=this.Yf).setDocumentWasEverVisible)||i.call(r,this.Xe);var o=null==(n=this.Br.session_recording)?void 0:n.selectMaskingFn;this.Yf.start(t),this.Yn=o,this.Yf.isStarted&&o!==(null==(s=this.Br.session_recording)?void 0:s.selectMaskingFn)&&this.startIfEnabledOrStop()}else this.np(!0)}else this.Xf=Gn}onRRwebEmit(t){var e;null==(e=this.Yf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Yf||null==(t=this.Qc)||t.register({[rn]:!0}),null==(e=this.Yf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.Yf||null==(t=this.Qc)||t.register({[en]:!0}),null==(e=this.Yf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.Yf||null==(e=this.Qc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Yf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Qn){var n,s=null==(n=this._instance.sessionPersistence)?void 0:n.get_property(r);f(s)||(i[r]=s)}return e({},i,(null==(t=this.Yf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Yf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.Yf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}},es=/* @__PURE__ */ci("[Heatmaps]");function is(t){return v(t)&&"clientX"in t&&"clientY"in t&&_(t.clientX)&&_(t.clientY)}var rs=class{get Br(){return this.instance.config}constructor(t){var e;this.Mp=!1,this.Ia=!1,this.Ip=null,this.instance=t,this.Mp=!(null==(e=this.instance.persistence)||!e.props[Wr]),this.rageclicks=new Ar(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Br.capture_heatmaps)&&this.Br.capture_heatmaps.flush_interval_milliseconds&&(t=this.Br.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Br.capture_heatmaps)?y(this.Br.enable_heatmaps)?this.Mp:this.Br.enable_heatmaps:!1!==this.Br.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ia)return;es.info("starting..."),this.Ep(),this.un()}else{var t;clearInterval(null!==(t=this.Ip)&&void 0!==t?t:void 0),this.Ap(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Wr]:i}),this.Mp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}Rp(t){is(t.originalEvent)&&this.jr(t.originalEvent,"deadclick")}un(){this.Ip&&clearInterval(this.Ip),this.Ip="visible"===(null==vn?void 0:vn.visibilityState)?setInterval(this.Oc.bind(this),this.flushIntervalMilliseconds):null}Ep(){un&&vn&&(this.Pp=this.Oc.bind(this),gi(un,ln,this.Pp),this.Op=t=>this.jr(t||(null==un?void 0:un.event)),gi(vn,"click",this.Op,{capture:!0}),this.Fp=t=>this.Lp(t||(null==un?void 0:un.event)),gi(vn,"mousemove",this.Fp,{capture:!0}),this.Dp=new _n(this.instance,yn,this.Rp.bind(this)),this.Dp.startIfEnabledOrStop(),this.Np=this.un.bind(this),gi(vn,$i,this.Np),this.Ia=!0)}Ap(){var t;un&&vn&&(this.Pp&&un.removeEventListener(ln,this.Pp),this.Op&&vn.removeEventListener("click",this.Op,{capture:!0}),this.Fp&&vn.removeEventListener("mousemove",this.Fp,{capture:!0}),this.Np&&vn.removeEventListener($i,this.Np),clearTimeout(this.jp),null==(t=this.Dp)||t.stop(),this.Ia=!1)}qp(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(t,e,i){for(var r=t;r&&ji(r)&&!Li(r,"body");){if(r===i)return!1;var n=void 0;try{var a,o,l;n=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:un)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Xi(r)}return!1}(Wi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}jr(t,i){var r;if(void 0===i&&(i="click"),!Di(t.target)&&is(t)){var n=this.qp(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&lr(Wi(t),this.instance.config.rageclick)&&this.Co(e({},n,{type:"rageclick"})),this.Co(n)}}Lp(t){!Di(t.target)&&is(t)&&(clearTimeout(this.jp),this.jp=setTimeout(()=>{this.Co(this.qp(t,"mousemove"))},500))}Co(t){if(un){var e=this.Br.disable_capture_url_hashes?J(un.location.href):un.location.href,i=this.Br.custom_personal_data_properties,r=An(e,this.Br.mask_personal_data_properties?[...In,...i||[]]:[],jn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}Oc(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},ns=/* @__PURE__ */ci("[Product Tours]"),ss=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Zr))},as=class{get Qc(){return this._instance.persistence}constructor(t){this.pg=null,this.gg=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var i,r;if(this.Qc&&this.Qc.register({[Zr]:!!e.productTours}),!ss(this._instance))return!this.pg&&y(null==(i=this.Qc)?void 0:i.props.ph_product_tours)||ns.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.pg)||r.stop(),this.pg=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.pg&&ss(this._instance)&&this.Za(()=>this.mg())}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=gn(this._instance))||i(this._instance,"product-tours",e=>{e?ns.error("Could not load product tours script",e):t()})}mg(){var t;!this.pg&&null!=(t=pn.__PosthogExtensions__)&&t.generateProductTours&&(this.pg=pn.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.gg)||e){var i=this.Qc;if(i){var r=i.props[sn];if(h(r)&&!e)return this.gg=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:e=>{if(ss(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var n="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||ns.warn(n):ns.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.gg=s,i&&i.register({[sn]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.gg,{isLoaded:!0})}getActiveProductTours(t){y(this.pg)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.pg.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.pg)||e.showTourById(t)}previewTour(t){this.pg?this.pg.previewTour(t):this.Za(()=>{var e;this.mg(),null==(e=this.pg)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.pg)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.pg)||t.nextStep()}previousStep(){var t;null==(t=this.pg)||t.previousStep()}clearCache(){var t;this.gg=null,null==(t=this.Qc)||t.unregister(sn)}resetTour(t){var e;null==(e=this.pg)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.pg)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.pg)||e.cancelPendingTour(t)}},os=/* @__PURE__ */ci("[SiteApps]"),ls="Error while initializing PostHog app with config id ",us=class{constructor(t){this._instance=t,this.yg=0,this.bg=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps&&!this._instance.config.require_subresource_integrity}_g(t,e){if(e){var i=this.globalsForEvent(e);this.bg.push(i),this.bg.length>1e3&&(this.bg=this.bg.slice(10))}}get siteAppLoaders(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this._instance.config.opt_in_site_apps&&!this.isEnabled&&os.critical("opt_in_site_apps is ignored: require_subresource_integrity disables site apps"),this.isEnabled){var t=this._instance._addCaptureHook(this._g.bind(this));this.wg=()=>{t(),this.bg=[],this.wg=void 0}}}globalsForEvent(i){var r,n,s,a,o,l,u;if(!i)throw new Error("Event payload is required");var h={},c=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(v)){var f=d[0];h[f]={id:c[f],type:f,properties:d[1]}}var p=i.$set_once,g=i.$set;return{event:e({},function(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}(i,t),{properties:e({},i.properties,g?{$set:e({},null!==(r=null==(n=i.properties)?void 0:n.$set)&&void 0!==r?r:{},g)}:{},p?{$set_once:e({},null!==(s=null==(a=i.properties)?void 0:a.$set_once)&&void 0!==s?s:{},p)}:{}),elements_chain:null!==(o=null==(l=i.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(u=i.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}kg(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(os.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(os.error("prepare_external_dependency_script returned null"),null):t}Sg(){var t,e,i,r,n,s,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==vn?void 0:vn.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.yg++,this.xg)return this.$g();var h=[],c=this,v=/* @__PURE__ */new WeakSet,d=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),h.push(()=>{t[e]=r})}},f=t=>{if(v.has(t))return t;var e=c.kg(t);return e&&v.add(e),e},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!m(t));return d(u,"appendChild",t=>function(e){var i=f(e);return i?t.call(this,i):e}),d(u,"insertBefore",t=>function(e,i){var r=f(e);return r?t.call(this,r,i):e}),d(u,"replaceChild",t=>function(e,i){var r=f(e);return r?t.call(this,r,i):i}),[null==(e=l.Element)?void 0:e.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{d(t,"append",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}),d(t,"prepend",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})}),[null==(n=l.Element)?void 0:n.prototype,null==(s=l.CharacterData)?void 0:s.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach(t=>{d(t,"before",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}),d(t,"after",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}),d(t,"replaceWith",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var n=p(i);return i.length&&!n.length?void 0:t.apply(this,n)})}),d(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",t=>function(e,i){var r=f(i);return r?t.call(this,e,r):null}),this.xg=()=>{h.forEach(t=>t()),this.xg=void 0},this.$g()}$g(){var t=!1;return()=>{var e;t||(t=!0,this.yg--,0===this.yg&&(null==(e=this.xg)||e.call(this)))}}Cg(t,e){void 0===e&&(e=!0);var i=this.Sg();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.bg.length&&(os.info("Processing "+this.bg.length+" events for site app with id "+t.id),this.bg.forEach(t=>this.Cg(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.wg)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,os.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.Cg(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){os.error(ls+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){os.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Tg(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Mg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Cg(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){os.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var n of Object.values(this.apps))r(n)}}onRemoteConfig(t){var e,i,r,n=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Tg(),void this._instance.on("eventCaptured",t=>this.Mg(t))):void os.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.wg)||i.call(this),t.ok){var s=t.config;if(null!=(r=s.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,e=o.id,i=o.url;pn["__$$ph_site_app_"+e]=n._instance,null==(t=pn.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return os.error(ls+e,t)})};for(var o of s.siteApps)a()}else os.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},hs="events",cs="cancelEvents",vs="survey shown",ds="survey dismissed",fs="survey sent";function ps(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var gs=(t,e)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},ms=t=>t.toLowerCase(),ys={exact:(t,e)=>e.some(e=>t.some(t=>e===t)),is_not:(t,e)=>e.every(e=>t.every(t=>e!==t)),regex:(t,e)=>e.some(e=>t.some(t=>gs(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!gs(e,t))),icontains:(t,e)=>e.map(ms).some(e=>t.map(ms).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(ms).every(e=>t.map(ms).every(t=>!e.includes(t))),gt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i>parseFloat(t))}),lt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i<parseFloat(t))})};function _s(t,e){return!t||Object.entries(t).every(t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(null==r)return!1;var n=ys[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var bs=/* @__PURE__ */ci("[Surveys]"),ws=["popover","widget","api"],xs=class{on(t,e){return this.jo[t]||(this.jo[t]=[]),this.jo[t].push(e),()=>{this.jo[t]=this.jo[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.jo[t]||[])i(e);for(var r of this.jo["*"]||[])r(t,e)}constructor(){this.jo={}}};function Ss(t,e,i){if(y(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}var ks=class{constructor(t){this.Di=t,this.qo=/* @__PURE__ */new Set,this.Bo=/* @__PURE__ */new Set,this.zo=new xs,this.Ho=(t,e)=>this.Uo(t,e)&&this.Wo(t,e)&&this.Vo(t,e)&&this.Go(t,e),this.Uo=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event)}init(){var t,e;f(null==(t=this.Di)?void 0:t.subscribeCapture)||(this.Qo=null==(e=this.Di)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.Qo)||t.call(this),this.Qo=void 0,null==(e=this.Di)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.zo=new xs}register(t){var e,i;if(!f(null==(e=this.Di)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.qo.add(t),null==(e=t.steps)||e.forEach(t=>{this.Bo.add((null==t?void 0:t.event)||"")})}),null!=(i=this.Di)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.qo.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.Di.setElementSelectors(r,this)}}replace(t){this.qo.clear(),this.Bo.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.Bo.has(t)||this.Bo.has(e.event))&&this.qo.forEach(t=>{this.Jo(e,t)&&this.zo.emit("actionCaptured",t.name)})}Zo(t){this.onAction("actionCaptured",e=>t(e))}Jo(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Ho(t,i))return!0;return!1}onAction(t,e){return this.zo.on(t,e)}Wo(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(null==t||!t.properties||!("$current_url"in t.properties))try{var n;r=null==(n=this.Di)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!Ss(r,e.url,e.url_matching||"contains"))return!1}return!0}Vo(t,e){return!!this.Ko(t,e)&&!!this.Yo(t,e)&&!!this.Xo(t,e)}Ko(t,e){var i;if(null==e||!e.href)return!0;var r=this.tl(t);if(r.length>0)return r.some(t=>Ss(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&Ss((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Yo(t,e){var i;if(null==e||!e.text)return!0;var r=this.tl(t);if(r.length>0)return r.some(t=>Ss(t.text,e.text,e.text_matching||"exact")||Ss(t.$el_text,e.text,e.text_matching||"exact"));var n,s,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(n=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!y(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),s=e.text,a=e.text_matching||"exact",n.some(t=>Ss(t,s,a)))}Xo(t,e){var i,r;if(null==e||!e.selector)return!0;if(null!=t&&null!=(i=t.properties)&&null!=(i=i.$element_selectors)&&i.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){}return!1}tl(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Go(t,e){return null==e||!e.properties||0===e.properties.length||_s(e.properties.reduce((t,e)=>{var i=h(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t},{}),null==t?void 0:t.properties)}},Es=class{constructor(t,e){this.el=e,this.il=[],this.Di=t,this.nl=/* @__PURE__ */new Map,this.sl=/* @__PURE__ */new Map,this.rl=/* @__PURE__ */new Map}ll(){var t,e;this.al=null==(t=(e=this.Di).subscribeSession)?void 0:t.call(e,t=>this.ul(t))}cl(t){return!1}hl(){return null}dl(t){}vl(){}fl(t,e){return!!t&&_s(t.propertyFilters,null==e?void 0:e.properties)}pl(t,e){var i=/* @__PURE__ */new Map;return t.forEach(t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach(e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}})}),i}gl(t,e,i){var r=(i===hs?this.nl:this.sl).get(t),n=[];return this.ml(t=>{n=t.filter(t=>null==r?void 0:r.includes(t.id))}),n.filter(r=>{var n,s=null==(n=r.conditions)||null==(n=n[i])||null==(n=n.values)?void 0:n.find(e=>e.name===t);return this.fl(s,e)})}register(t){this.yl(t,!1)}replace(t){this.yl(t,!0)}yl(t,e){f(this.Di.subscribeCapture)||(this.bl(t,e),this._l(t,e))}_l(t,e){var i=t.filter(t=>{var e;return null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length});if(e&&this.rl.clear(),0!==i.length){this.wl||(this.wl=new ks(this.Di),this.wl.init(),this.wl.Zo(t=>this.onAction(t)));var r=[];i.forEach(t=>{var e;null==(e=t.conditions)||null==(e=e.actions)||e.values.forEach(e=>{if(r.push(e),e.name){var i,n=null!==(i=this.rl.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.rl.set(e.name,n)}})}),e?this.wl.replace(r):this.wl.register(r)}else{var n;e&&(null==(n=this.wl)||n.replace([]))}}kl(t,e){e.forEach((e,i)=>{var r,n=null!==(r=t.get(i))&&void 0!==r?r:[];e.forEach(t=>{n.includes(t)||n.push(t)}),t.set(i,n)})}bl(t,e){var i,r,n,s=t.filter(t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),a=t.filter(t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}),o=this.pl(t,hs),l=this.pl(t,cs);e?(this.nl=o,this.sl=l):(this.kl(this.nl,o),this.kl(this.sl,l)),(0!==s.length||0!==a.length||t.some(t=>{var e;return null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length}))&&(null!==(i=this.Qo)&&void 0!==i||(this.Qo=null==(r=(n=this.Di).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.Sl(),s=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(s&&this.getActivatedIds().includes(s)){var a=this.xl(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.$l([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.Cl(s),void this.Tl([s])}if(this.sl.has(t)){var o=this.gl(t,e,cs);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.$l(o.map(t=>t.id)),o.forEach(t=>this.Ml(t.id)))}if(this.nl.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.nl.get(t)});var l=this.gl(t,e,hs);this.Il(l.map(t=>t.id))}}onAction(t){this.rl.has(t)&&this.Il(this.rl.get(t)||[])}Il(t){if(0!==t.length){var e=!!this.Di.getSessionId(),i=[];for(var r of t)e&&this.cl(r)?this.Cl(r)&&this.El(r):i.push(r);i.length>0&&(this.il=[.../* @__PURE__ */new Set([...this.il,...i])]),this.Sl().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Al()}}Cl(t){this.il=this.il.filter(e=>e!==t);var e=this.Rl();return!e.includes(t)&&(this.Pl([...e,t]),this.Ol(),!0)}$l(t){var e=new Set(t);this.il=this.il.filter(t=>!e.has(t));var i=this.Fl(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.Pl(r),0===r.length&&this.Ll()),this.Tl(t),this.Al()}Al(){try{var t;null==(t=this.el)||t.call(this)}catch(t){this.Sl().error("Error while handling activated items change",t)}}Dl(){var t=this.hl();if(!t)return{};var e=this.Di.getProperty(t);return e&&"object"==typeof e?e:{}}El(t){if(this.hl()){var i=this.Dl();this.dl(e({},i,{[t]:Date.now()}))}}Tl(t){if(this.hl()){var e=this.Dl(),i={},r=!1;for(var n of Object.entries(e)){var s=n[0],a=n[1];t.includes(s)?r=!0:i[s]=a}r&&(d(i)?this.vl():this.dl(i))}}Nl(){this.hl()&&this.vl()}getActivationTimestamp(t){if(this.Rl().includes(t)){var e=this.Dl()[t];return _(e)?e:void 0}}Fl(){var t=this.jl();return this.Di.getProperty(t)||[]}Rl(){var t=this.Fl();if(0===t.length)return[];var e=this.Di.getProperty(this.ql()),i=this.Di.getSessionId();return i&&e===i?t:[]}Ol(){var t=this.Di.getSessionId();t&&this.Bl(t)}Ll(){this.zl()}ul(t){var e=this.Di.getProperty(this.ql());if(e&&e!==t){var i=this.Fl(),r=this.Dl();i.length>0&&(this.Pl([]),i.filter(t=>_(r[t])).forEach(t=>this.Ml(t))),this.Ll(),this.Nl(),i.length>0&&this.Al()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.Rl(),...this.il])].filter(t=>!this.Hl(t))}dispose(){var t,e,i;null==(t=this.al)||t.call(this),this.al=void 0,null==(e=this.Qo)||e.call(this),this.Qo=void 0,null==(i=this.wl)||i.dispose(),this.wl=void 0}reset(){this.il=[],this.Fl().length>0&&this.Pl([]),this.Ll(),this.Nl(),this.Al()}getEventToItemsMap(){return this.nl}Ul(){return this.wl}},As=class extends Es{constructor(t,e,i,r){var n;super({subscribeCapture(e){var i=t.onEvent(t=>e(t.event,t));return()=>i.dispose()},subscribeSession(e){var i=t.onSession(e);return()=>i.dispose()},getSessionId(){var e;return null==(e=t.session)?void 0:e.sessionId},getProperty:e=>t.kv.get(e),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(n=null==i?void 0:i.setElementSelectors)&&void 0!==n?n:(e,i)=>{var r;return null==(r=t.getExtension("autocapture"))?void 0:r.setElementSelectors(e,i)}},r),this.Wl=t,this.Vl=e,this.ll()}jl(){return Hr}ql(){return qr}hl(){return Vr}dl(t){this.Wl.kv.set({[Vr]:t})}vl(){this.Wl.kv.remove(Vr)}cl(t){var e,i;this.ml(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return _(r)&&r>0}Gl(){return vs}ml(t){this.Vl.getSurveys(t)}Ml(t){this.Vl.cancelPendingSurvey(t)}Sl(){return bs}Pl(t){this.Wl.kv.set({[Hr]:t})}Bl(t){this.Wl.kv.set({[qr]:t})}zl(){this.Wl.kv.remove(qr)}Hl(){return!1}xl(t,e,i){var r,n;return t===fs&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.ml(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return ps(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===vs?"consume":"ignore":t===vs?"persist":t===ds||t===fs?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ts=(t,e)=>null!=t&&t.then?t.then(e):e(t),Fs="SDK is not enabled or survey functionality is not yet loaded",Ps="Disabled. Not loading surveys.",Cs=class{constructor(t){this.Ql=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Jl=!1,this.Zl=!1,this.Kl=[],this.Yl=[],this.Xl=null,this.ta=null,this.Ai=!1,this.ea=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.Ai&&!this.Br.disableSurveys){if(!t.ok)return this.Zl=!0,this.ia({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),bs.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return bs.warn("Flags not loaded yet. Not loading surveys.");this.na=b(e)?e:e.length>0,bs.info("flags response received, isSurveysEnabled: "+this.na),this.loadIfEnabled()}},this.ia=t=>{this.Yl.slice().forEach(e=>this.sa(e,t))}}setup(t){if(!this.Ai)return this.ra=t,Ts(t.kv.initialize(),()=>{if(this.ra===t&&!this.Ai){this.ra=void 0,this.Wl=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Ai?e.dispose():(this.oa=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Ai||(this.Ai=!0,this.ra=void 0,this.Wl=void 0,null==(t=this.oa)||t.dispose(),this.oa=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Kl=[],this.Yl.forEach(t=>{t.active=!1}),this.Yl=[],null==(r=this.la)||r.call(this),this.la=void 0,this.Xl=null,this.ea.forEach(t=>clearTimeout(t)),this.ea.clear())}get Br(){return this.Ql.get()}getRenderContext(){if(this.Wl){var t=this;return{client:this.Wl,get config(){return t.Br},surveys:t}}}initialize(){this.loadIfEnabled()}reset(){var t;null==(t=this._surveyManager)||null==t.clearInMemoryInProgressSurveyState||t.clearInMemoryInProgressSurveyState();try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],r=0;r<localStorage.length;r++){var n=localStorage.key(r);(null!=n&&n.startsWith("seenSurvey_")||null!=n&&n.startsWith("inProgressSurvey_"))&&i.push(n)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}this.ia()}loadIfEnabled(){if(!this.Ai&&this.Wl){var t=this.Br;if(!this._surveyManager)if(this.Jl)bs.info("Already initializing surveys, skipping...");else if(t.disableSurveys)bs.info(Ps);else if(t.cookielessMode&&this.Wl.isOptedOut)bs.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Ql.getExtensions();if(e){if(!f(this.na)||t.advancedEnableSurveys){var i=this.na||t.advancedEnableSurveys;this.Jl=!0,this.Zl=!1;try{var r=e.generateSurveys;if(r)return this.ua(r,i),void(this.Jl=!1);var n=e.loadExternalDependency;if(!n)return this.aa(Ur),void(this.Jl=!1);n(t=>{try{if(this.Ai)return;var e=this.Ql.getExtensions();t||null==e||!e.generateSurveys?this.aa("Could not load surveys script",t):this.ua(e.generateSurveys,i)}finally{this.Jl=!1}})}catch(t){throw this.Jl=!1,this.aa("Error initializing surveys",t),t}}}else this.aa("PostHog Extensions not found.")}}}ua(t,e){var i;if(!this.Ai){this._surveyManager=t(e),this._surveyEventReceiver=this.ca(this.Wl,this.ia);var r=null==(i=this.Wl)?void 0:i.kv.get(zr);r&&this.ha(r),bs.info("Surveys loaded successfully"),this.da(),this.ia(),this.va({isLoaded:!0})}}ca(t,e){return new As(t,this,void 0,e)}aa(t,e){this.Zl=!0,bs.error(t,e),this.ia({isLoaded:!1,error:t}),this.va({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Kl.push(t),this._surveyManager&&this.va({isLoaded:!0}),()=>{this.Kl=this.Kl.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Ai){var i=this.Wl;if(!i)return t([],{isLoaded:!1,error:Fs});if(this.Br.disableSurveys)return bs.info(Ps),t([]);var r=i.kv.get(zr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.fa()&&this.getSurveys(()=>{},!0));if(this.Xl)this.Xl.then(e=>{this.Ai||t(e.surveys,e.context)}).catch(t=>bs.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Br.requestTimeoutMs}).then(t=>{try{return this.pa(i,t)}catch(t){return bs.error("Error processing surveys response",t),this.pa(i,{statusCode:0,error:t})}},t=>this.pa(i,{statusCode:0,error:t}));this.Xl=n;var s=()=>{this.Xl===n&&(this.Xl=null)};n.then(e=>{s(),this.Ai||(this.ia(e.context),t(e.surveys,e.context))},s).catch(t=>bs.error("Error in survey callback",t))}}}pa(t,e){if(this.Ai)return{surveys:[],context:{isLoaded:!1,error:Fs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?bs.error(r):e.error||bs.warn(r),this.ta=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.ta=null;var n=e.json.surveys||[];return t.kv.set({[zr]:n,[Br]:Date.now()}),this.ha(n),{surveys:n,context:{isLoaded:!0}}}ha(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(ps(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.ga(e)}ga(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}fa(){return this.ma()&&!this.Xl&&!this.ya()}ma(){var t,e=null==(t=this.Wl)?void 0:t.kv.get(Br);return _(e)&&Date.now()-e>3e5}ya(){return _(this.ta)&&3e5>Date.now()-this.ta}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){bs.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",/* @__PURE__ */(new Date).toISOString())}catch(t){}this.ia()}va(t){for(var e of this.Kl){if(this.Ai)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){bs.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);bs.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Ai)return()=>{};var i={callback:t,active:!0,revision:0};this.Yl.push(i),this.da();var r=null==(e=this.Wl)?void 0:e.kv.get(zr);return this.Br.disableSurveys||!this._surveyManager&&this.Zl&&!this.Jl||!r&&!y(this.ta)&&!this.Xl?this.sa(i,{isLoaded:!1}):this._surveyManager&&this.sa(i),()=>{var t;i.active=!1,this.Yl=this.Yl.filter(t=>t!==i),0===this.Yl.length&&(null==(t=this.la)||t.call(this),this.la=void 0)}}da(){var t,e,i;this._surveyManager&&this.Yl.length>0&&(null!==(t=this.la)&&void 0!==t||(this.la=null==(e=(i=this.Ql).onMatchingConditionsChanged)?void 0:e.call(i,this.ia)))}sa(t,e){if(!this.Ai&&t.active){var i=++t.revision,r=r=>{if(!this.Ai&&t.active&&i===t.revision)try{var n=null!=e?e:{isLoaded:!0},s=JSON.stringify([r,n]);if(s===t.lastResult)return;t.lastResult=s,t.callback(r,n)}catch(t){bs.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){bs.error("Error in active matching surveys callback",t)}}}ba(t){var e=null;return this.getSurveys(i=>{var r;e=null!==(r=i.find(e=>e.id===t))&&void 0!==r?r:null}),e}_a(t){if(y(this._surveyManager))return{eligible:!1,reason:Fs};var e="string"==typeof t?this.ba(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}wa(t){var e;if(null==(e=this.Wl)||!e.canCapture)return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(y(this._surveyManager))return{eligible:!1,reason:Fs};var i="string"==typeof t?this.ba(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return bs.warn("init was not called"),{visible:!1,disabledReason:Fs};var e=this.wa(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(bs.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Fs})):new Promise(i=>{this.getSurveys(e=>{var r,n=null!==(r=e.find(e=>e.id===t))&&void 0!==r?r:null;if(n){var s=this.wa(n);i({visible:s.eligible,disabledReason:s.reason})}else i({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,i){var r,n,s;if(null!=(r=this.Wl)&&r.canCapture)if(y(this._surveyManager))bs.warn("init was not called");else{var a="string"==typeof t?this.ba(t):t;if(null!=a&&a.id)if(ws.includes(a.type)){var o=null==(n=typeof document>"u"?void 0:document)?void 0:n.querySelector(e);if(o)if(null!=(s=a.appearance)&&s.surveyPopupDelaySeconds){bs.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.ea.delete(l),!this.Ai&&null!=(t=this.Wl)&&t.canCapture&&(bs.info("Rendering survey "+a.id+" with delay of "+(null==(e=a.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(r=this._surveyManager)||r.renderSurvey(a,o,i),bs.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.ea.add(l)}else this._surveyManager.renderSurvey(a,o,i);else bs.warn("Survey element not found")}else bs.warn("Surveys of type "+a.type+" cannot be rendered in the app");else bs.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.Wl)&&r.canCapture)if(y(this._surveyManager))bs.warn("init was not called");else{var s=this.ba(t);if(s){var a=s;if(null!=(n=s.appearance)&&n.surveyPopupDelaySeconds&&i.ignoreDelay&&(a=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&bs.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this._a(s);if(!o.eligible)return void bs.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(a,i):this.renderSurvey(a,i.selector,i.properties)}else bs.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?bs.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};li.DEBUG=!1,li.LIB_VERSION="1.453.1",li.LIB_NAME="web";var Rs,Os=li,Ms=/* @__PURE__ */new WeakMap,$s=()=>{var t;return null!=un&&null!=(t=un.performance)&&t.now?un.performance.now():Date.now()},Is=class{constructor(t){this._instance=t}get(){var t,e,i,r,n=null==(t=this._instance)?void 0:t.config;return{disableSurveys:!(null==n||!n.disable_surveys),cookielessMode:!(null==n||!n.cookieless_mode),advancedEnableSurveys:!(null==n||!n.advanced_enable_surveys),requestTimeoutMs:null!==(e=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==e?e:1e4,prefillFromUrl:!(null==n||null==(i=n.surveys)||!i.prefillFromUrl),automaticDisplay:!(null!=n&&n.disable_surveys_automatic_display),featureFlagEvaluation:!(null!=n&&n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null==(r=this._instance)||null==(r=r.requestRouter)?void 0:r.endpointFor("ui","")}}getExtensions(){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=gn(e);return{generateSurveys:i?t=>i(e,t):void 0,loadExternalDependency:r?t=>r(e,"surveys",t):void 0}}}onMatchingConditionsChanged(t){var e,i,r=null==(e=this._instance)?void 0:e._addCaptureHook(e=>{"$pageview"!==e&&e!==vs&&e!==ds&&e!==fs||t()}),n=()=>t();gi(un,"PHSurveyShown",n);var s=!1,a=null==(i=this._instance)?void 0:i.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,null==r||r(),null==a||a(),null==un||un.removeEventListener("PHSurveyShown",n)}}},Ds=class extends Cs{constructor(t){super(new Is(t))}},js=/* @__PURE__ */(()=>null!=un&&un.location?Tn(un.location.hash,"__posthog")||Tn(location.hash,"state"):null)(),Ls="_postHogToolbarParams",Ns=/* @__PURE__ */ci("[Toolbar]"),zs=class{constructor(t){this.instance=t}Ng(t){pn.ph_toolbar_state=t}jg(){var t;return null!==(t=pn.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),mi(this.instance.config))return!1;if(!un||!vn)return!1;t=null!=t?t:un.location,i=null!=i?i:un.history;try{if(!e){try{un.localStorage.setItem("test","test"),un.localStorage.removeItem("test")}catch(t){return!1}e=null==un?void 0:un.localStorage}var r,n=js||Tn(t.hash,"__posthog")||Tn(t.hash,"state"),s=n?X(()=>JSON.parse(atob(decodeURIComponent(n))))||X(()=>JSON.parse(decodeURIComponent(n))):null;return s&&"ph_authorize"===s.action?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?t.hash=s.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(Ls)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}qg(t){var e=pn.ph_load_toolbar||pn.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):Ns.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==vn||!vn.getElementById("__POSTHOG_TOOLBAR__"));if(!un||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(un.localStorage.setItem(Ls,JSON.stringify(e({},n,{source:void 0}))),2===this.jg())this.qg(n);else if(0===this.jg()){var s;this.Ng(1),null==(s=gn(this.instance))||s(this.instance,"toolbar",t=>{if(t)return Ns.error("[Toolbar] Failed to load",t),void this.Ng(0);this.Ng(2),this.qg(n)}),gi(un,"turbolinks:load",()=>{this.Ng(0),this.loadToolbar(n)})}return!0}Bg(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}},Bs=/* @__PURE__ */ci("[FeatureFlags]"),Us=/* @__PURE__ */ci("[FeatureFlags]",{debugEnabled:!0}),Hs="\" failed. Feature flags didn't load in time.",qs=[502,504],Vs=["click","keydown","wheel","touchstart","pointerdown"],Ws="connection_error",Gs=(t,i)=>{var r=Object.keys(i||{}).filter(t=>{var e;return null==i||null==(e=i[t])?void 0:e.failed});if(!r.length)return t||{};var n=e({},t);return r.forEach(t=>delete n[t]),n},Ks=(t,i)=>{var r=e({},t);return i.forEach(t=>{var e;null!=(e=r[t])&&e.failed&&delete r[t]}),r},Js=(t,e)=>!(null==e||!e.partialResponse)||!!t.errorsWhileComputingFlags,Xs=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Ys=t=>{var e={};for(var i of pi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Zs=(t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed).map(t=>{var e;return[t,null!==(e=r[t].variant)&&void 0!==e?e:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed&&r[t].enabled).filter(t=>{var e;return!f(null==(e=r[t].metadata)?void 0:e.payload)}).map(t=>{var e;return[t,null==(e=r[t].metadata)?void 0:e.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)},Qs=(t,e)=>t.distinctId===e.distinctId&&t.sessionId===e.sessionId&&((t,e)=>{var i=Object.keys(t);return i.length===Object.keys(e).length&&i.every(i=>t[i]===e[i])})(t.groups,e.groups),ta=class{constructor(t){this.name="featureFlags",this.Kd=!1,this.featureFlagEventHandlers=[],this.R=Bs,this.Yd={},this.Xd={},this.tv=[],this.ev=/* @__PURE__ */new Set,this.iv=/* @__PURE__ */new Set,this.nv=!1,this.sv=!1,this.rv=0,this.ov=!1,this.lv=!1,this.av=!1,this.uv=/* @__PURE__ */new Map,this.hv=!1,this.dv=!1,this.vv=!1,this.fv=0,this.pv=!1,this.ln=()=>{var t=this.gv();this.fv=0,t&&this.reloadFeatureFlags()},this.mv=()=>{var t,e,i=this.yv,r=null!==(t=this.bv)&&void 0!==t?t:i;f(i)||f(r)||this.Br.remoteRequestsDisabled||!this._v||"hidden"===this._v.visibilityState||Date.now()-(null!==(e=this.wv)&&void 0!==e?e:0)<r||(this.bv=this.pv||!this.Br.idleRefreshBackoff?i:Math.min(2*r,36e5),this.pv=!1,this.reloadFeatureFlags(),this.Sv())},this.xv=()=>{this.pv&&this.bv===this.yv||this.$v()},this.un=()=>{var t;"visible"===(null==(t=this._v)?void 0:t.visibilityState)&&this.$v()},this.Ql=t}get Cv(){}Tv(){this.Wl&&this.Mv()}setup(t){try{this.Iv=typeof window>"u"?void 0:window,this._v=typeof document>"u"?void 0:document}catch(t){this.Iv=void 0,this._v=void 0}return this.ra=t,this.R=t.logger.createLogger("[FeatureFlags]"),Ts(t.kv.initialize(),()=>{this.ra===t&&(this.ra=void 0,this.Wl=t,this.Ev(t))})}Ev(t){var e;if(this.Wl===t)return this.Iv&&gi(this.Iv,"online",this.ln),this.Mv(),this.Av=t.registerDynamicEventProperties(()=>this.Rv()?this.Yd:this.Xd),this.Pv=null==(e=this.Cv)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Ov(),this.Fv(),this.Lv()}),this.Fv(),this.initialize()}$v(){this.pv=!0,this.bv=this.yv,this.mv()}Mv(){var t,e=this.Br.refreshIntervalMs,i=!this.Br.remoteRequestsDisabled&&this._v&&!f(e)&&e>0?e:void 0;this.Br.idleRefreshBackoff||(this.bv=i),i!==this.yv&&(this.Dv(),f(i)||(this.yv=i,this.bv=i,this.Sv(),null!=(t=this._v)&&t.addEventListener&&(gi(this._v,$i,this.un),vi(Vs,t=>{gi(this._v,t,this.xv,{capture:!0})}))))}Sv(){f(this.yv)||(f(this.Nv)||clearInterval(this.Nv),this.wv=Date.now(),this.Nv=setInterval(this.mv,this.yv))}Dv(){var t;f(this.Nv)||(clearInterval(this.Nv),this.Nv=void 0,null==(t=this._v)||null==t.removeEventListener||t.removeEventListener($i,this.un),vi(Vs,t=>{var e;null==(e=this._v)||null==e.removeEventListener||e.removeEventListener(t,this.xv,{capture:!0})})),this.yv=void 0,this.bv=void 0,this.pv=!1,this.wv=void 0}destroy(){this.jv()}dispose(){this.jv()}jv(){var t,e,i;this.Dv(),this.rv++,this.lv=!1,this.ra=void 0,this.qv(this.ev,"cancelled"),this.qv(this.iv,"cancelled"),this.Wl&&(this.Bv(),null==(t=this.Av)||t.dispose(),this.Av=void 0,null==(e=this.Pv)||e.call(this),this.Pv=void 0,this.tv=[],null==(i=this.Iv)||i.removeEventListener("online",this.ln),this.Wl=void 0)}get Br(){return this.Ql.get()}zv(t){var e;return this.Hv&&t in this.Hv?this.Hv[t]:null==(e=this.Wl)?void 0:e.kv.get(t)}Ov(){return!!this.Hv&&(this.Hv=void 0,!0)}Uv(){var t;return!f(null==(t=this.Wl)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Ov()}$t(t){this.Wv(()=>{var e;return null==(e=this.Wl)?void 0:e.kv.set(t)})}Vv(t,e,i){if(this.Cv&&t.$enabled_feature_flags){var r=this.zv("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(t=>{var e=t[1];return!(null!=e&&e.failed)}).map(t=>t[0]):[],o=!!e.errorsWhileComputingFlags&&!!e.flags,l=o||i&&e.flags?a:i&&!h(s)?Object.keys(s||{}):Array.from(/* @__PURE__ */new Set([...Object.keys(r),...Object.keys(n)])),u=this.zv("$feature_flag_payloads")||{},c=t.$feature_flag_payloads||{},v=o||i?l:Array.from(/* @__PURE__ */new Set([...Object.keys(u),...Object.keys(c)])),d=!o&&!i,p=!!d||l,g=!!d||v,m={[bi]:p,[Ai]:p,[Ri]:g};for(var y of(t.$feature_flag_details&&(m[wi]=p),[ki,Si,Ei]))f(t[y])||(m[y]=!0);this.Cv.markCrossTabFeatureFlagChanges(m)}}Ft(t){this.Wv(()=>{var e;return null==(e=this.Wl)?void 0:e.kv.remove(t)})}Wv(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}Fv(){var t={},i=this.zv(wi);for(var r of[ki,Oi]){var n=this.zv(r);f(n)||(t[r]=n)}var s=this.zv(bi);s&&(t[bi]=s.filter(t=>{var e;return!(null!=i&&null!=(e=i[t])&&e.failed)}));var a=this.zv(Ri);a&&(t[Ri]=Gs(a,i)),this.Yd=t;var o=e({},t),l=Gs(this.zv(Ai),i);if(l)for(var u of Object.entries(l))o["$feature/"+u[0]]=u[1];this.Xd=o}Rv(){var t=this.Br.cacheTtlMs;if(!t||0>=t)return!1;var e=this.zv(Si);return"number"!=typeof e||Date.now()-e>t}Gv(){return!!this.Rv()&&(this.vv||this.sv||(this.vv=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Qv(){var t=this.Br.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.R.error("Invalid evaluation context found:",t,"Expected non-empty string"),e}):[]}Jv(){var t=this.Br.flagKeys;if(!f(t))return t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.R.error("Invalid flag key found:",t,"Expected non-empty string"),e})}initialize(){var t,e,i=this.Br,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var n,s,a=null!==(n=null==(s=i.bootstrap)?void 0:s.featureFlagPayloads)&&void 0!==n?n:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,e)=>(t[e]=r[e],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,e)=>(t[e]=a[e],t),{});return this.Zv({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n=null!=r&&r.merge?Gs(this.zv(Ai),this.zv(wi)):{},s=null!=r&&r.merge?Gs(this.zv(Ri),this.zv(wi)):{},a=e({},n,t),o=e({},s,i),l={};for(var u of Object.entries(a)){var h=u[0],c=u[1];l[h]={key:h,enabled:Ut(c),variant:Ht(c),reason:void 0,metadata:f(null==o?void 0:o[h])?void 0:{id:0,version:void 0,description:void 0,payload:o[h]}}}this.Zv({flags:l})}get hasLoadedFlags(){return this.nv}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.zv(wi),i=this.zv(Oi),r=this.zv(Mi);if(!r&&!i)return t||{};var n=fi({},t||{});for(var s of[.../* @__PURE__ */new Set([...Object.keys(r||{}),...Object.keys(i||{})])]){var a,o,l=n[s],u=null==i?void 0:i[s],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,c=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,v=null==r?void 0:r[s],d=e({},l,{enabled:h,variant:h?null!=c?c:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(d.original_enabled=null==l?void 0:l.enabled),c!==(null==l?void 0:l.variant)&&(d.original_variant=null==l?void 0:l.variant),v&&(d.metadata=e({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),n[s]=d}return this.Kd||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.Kd=!0),n}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(i=>{var r=t[i];return{key:i,enabled:Ut(r),variant:Ht(r),payload:Bt(e[i])}})}getFlagVariants(){var t=Gs(this.zv(Ai),this.zv(wi)),e=this.zv(Oi);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Kd||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Kd=!0),i}getFlagPayloads(){var t=Gs(this.zv(Ri),this.zv(wi)),e=this.zv(Mi);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Kd||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Kd=!0),i}reloadFeatureFlags(){this.ov||this.Br.featureFlagsDisabled||this.gv()||(this.av&&this.R.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this.sv&&(this.lv=!0),this.Kv||(this.tv.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}}),this.Kv=setTimeout(()=>{this.Yv()},5)))}reloadFeatureFlagsAsync(){return!this.Wl||this.ov||this.Br.featureFlagsDisabled||this.Br.remoteRequestsDisabled||this.gv()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.ev.add(t),this.reloadFeatureFlags()})}qv(t,e){t.forEach(t=>t({status:e})),t.clear()}Bv(){clearTimeout(this.Kv),this.Kv=void 0}onReloading(t){return this.tv.push(t),()=>{this.tv=this.tv.filter(e=>e!==t)}}ensureFlagsLoaded(){this.nv||this.sv||this.Kv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ov=t}resetFlagCallReported(){this.Ft(Pi),this.uv=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.uv.size&&!this.hv&&null!=(t=this.Wl)&&t.canCapture&&!this.Wl.isRateLimited){this.hv=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.uv.keys())){var r=this.uv.get(i);if(r){if(r.value!==String(e[i])||!Qs(r.context,this.Xv())){this.uv.delete(i);continue}if(this.getFeatureFlagResult(i),this.uv.has(i))break}}}finally{this.hv=!1}}}Yv(t){var i;this.Bv();var r=this.Wl;if(!r||this.Br.remoteRequestsDisabled||this.gv())this.qv(this.ev,"skipped");else if(this.sv)this.lv=!0;else{var n={token:r.projectToken,distinct_id:r.distinctId,groups:r.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:e({},r.initialPersonProperties,this.zv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.zv(Ti),timezone:$n()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Br.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.Qv();s.length&&(n.evaluation_contexts=s);var a=this.Jv();f(a)||(n.flag_keys=a);var o=this.Br.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.rv,h=this.ev;this.ev=/* @__PURE__ */new Set,this.iv=h,this.sv=!0;var c=()=>{this.lv&&(this.lv=!1,this.Yv())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.sv=!1,u===this.rv)if(this.tf(t.statusCode),s||this.lv||(this.$anon_distinct_id=void 0),!n.disable_flags||this.lv){this.dv=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ws:"unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),r.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l=!(null==(i=r.quotaLimited)||!i.includes("feature_flags"));l&&a.push("quota_limited"),this.$t({[xi]:a}),l?this.R.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."):n.disable_flags||this.Zv(r,s,{partialResponse:o}),this.qv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.qv(h,"skipped");else c()},d=t=>{this.sv=!1,u===this.rv?(this.$t({[xi]:[Ws]}),this.R.error("Feature flag request failed",t),this.Uv()&&this.Lv(!0),this.qv(h,"error"),c()):c()},p=null!==(i=this.Br.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.rv,m=()=>{if(u!==this.rv||!this.Wl||this.Br.remoteRequestsDisabled)return this.sv=!1,this.qv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Br.compression,sentAt:"body",timeoutMs:this.Br.requestTimeoutMs}).then(t=>{if((t=>qs.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&g())return p--,void setTimeout(m,500);v(t)}).catch(d)}catch(t){d(t)}};m()}}gv(){return Sn(this.fv,3)}tf(t){this.fv=kn(t,this.fv,3,()=>this.R.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."))}ef(t){var e;return!(this.nv||this.getFlags().length||null!=(e=this.getFeatureFlagDetails(t))&&e.failed)}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.dv)if(this.ef(t))this.R.warn('getFeatureFlag for key "'+t+Hs);else if(!this.Gv()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e;return null==(e=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:e.payload}getFeatureFlagResult(t,i){var r;if(void 0===i&&(i={}),!i.fresh||this.dv)if(this.ef(t))this.R.warn('getFeatureFlagResult for key "'+t+Hs);else if(!this.Gv()){var n,s=null==(r=this.zv(wi))||null==(r=r[t])?void 0:r.failed,a=s?void 0:this.zv(Ai),o=s?void 0:this.zv(Ri),l=this.zv(Oi),u=!!l&&{}.hasOwnProperty.call(l,t),c=u||!!a&&t in a,v=u?l[t]:null==a?void 0:a[t],d=this.zv(Mi),p=d&&{}.hasOwnProperty.call(d,t)?d[t]:null==o?void 0:o[t],g=String(v),m=this.zv("$feature_flag_request_id")||void 0,y=this.zv("$feature_flag_evaluated_at")||void 0,_=this.zv("$flag_call_reported")||{};if(this.Br.deduplicateCallsPerSession){var b,w=null==(b=this.Wl)||null==(b=b.session)?void 0:b.sessionId,x=this.zv(Ci);w&&w!==x&&(_={},n=w)}if(!i.send_event&&"send_event"in i)n&&this.$t({[Pi]:_,[Ci]:n});else{var S,k,E,A,T=!(null!=(S=this.Wl)&&S.canCapture),F=!(T||null!=(k=this.Wl)&&k.isRateLimited);if(F?this.uv.delete(t):(T&&Object.keys(_).length>0&&(_={},this.$t({[Pi]:_})),null!=(A=_[t])&&A.includes(g)||this.if(t,g)),!F||null!=(E=_[t])&&E.includes(g))n&&this.$t({[Pi]:_,[Ci]:n});else{var P,C,R,O,M,I,D,j,L,N,z,B,U;h(_[t])?_[t].push(g):_[t]=[g],this.$t(e({[Pi]:_},n?{[Ci]:n}:{}));var H=this.getFeatureFlagDetails(t),q=[...null!==(P=this.zv("$feature_flag_errors"))&&void 0!==P?P:[]];f(v)&&q.push(null!=H&&H.failed?"evaluation_failed":"flag_missing");var V={$feature_flag:t,$feature_flag_response:v,$feature_flag_payload:null!=p?p:null,$feature_flag_request_id:m,$feature_flag_evaluated_at:y,$feature_flag_bootstrapped_response:null!==(C=null==(R=this.Br.bootstrap)||null==(R=R.featureFlags)?void 0:R[t])&&void 0!==C?C:null,$feature_flag_bootstrapped_payload:null!==(O=null==(M=this.Br.bootstrap)||null==(M=M.featureFlagPayloads)?void 0:M[t])&&void 0!==O?O:null,$used_bootstrap_value:!this.dv};f(null==H||null==(I=H.metadata)?void 0:I.has_experiment)||(V.$feature_flag_has_experiment=H.metadata.has_experiment),f(null==H||null==(D=H.metadata)?void 0:D.version)||(V.$feature_flag_version=H.metadata.version);var W=null!==(j=null==H||null==(L=H.reason)?void 0:L.description)&&void 0!==j?j:null==H||null==(N=H.reason)?void 0:N.code;W&&(V.$feature_flag_reason=W),null!=H&&null!=(z=H.metadata)&&z.id&&(V.$feature_flag_id=H.metadata.id),f(null==H?void 0:H.original_variant)&&f(null==H?void 0:H.original_enabled)||(V.$feature_flag_original_response=f(H.original_variant)?H.original_enabled:H.original_variant),null!=H&&null!=(B=H.metadata)&&B.original_payload&&(V.$feature_flag_original_payload=null==H||null==(U=H.metadata)?void 0:U.original_payload),q.length&&(V.$feature_flag_error=q.join(",")),this.nf(V)||(this.sf(t,g),this.if(t,g))}}if(c)return{key:t,enabled:!!v,variant:"string"==typeof v?v:void 0,payload:Bt(p)}}}nf(t){try{var e;return!1!==(null==(e=this.Wl)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}if(t,e){this.uv.set(t,{value:e,context:this.Xv()})}Xv(){var t,i,r;return{distinctId:null==(t=this.Wl)?void 0:t.distinctId,groups:e({},null==(i=this.Wl)?void 0:i.groups),sessionId:this.Br.deduplicateCallsPerSession?null==(r=this.Wl)||null==(r=r.session)?void 0:r.sessionId:void 0}}sf(t,e){var i=this.zv("$flag_call_reported")||{},r=i[t];h(r)&&r.includes(e)&&(i[t]=r.filter(t=>t!==e),this.$t({[Pi]:i}))}getRemoteConfigPayload(t,e){this.rf(t,e)}rf(t,e){var i=this;return r(function*(){var r=i.Wl;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.Qv();s.length&&(n.evaluation_contexts=s);var a,o=i.Jv();f(o)||(n.flag_keys=o);try{var l;a=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i.Br.compression,sentAt:"body",timeoutMs:i.Br.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void i.R.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){i.R.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.dv)return e.defaultValue;if(this.ef(t))return this.R.warn('isFeatureEnabled for key "'+t+Hs),e.defaultValue;var i=this.getFeatureFlag(t,e);return f(i)?e.defaultValue:!!i}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e,i){this.Zv(t,e,i)}Zv(t,i,r){if(this.Wl){var n;this.nv=!0,!1!==(null==r?void 0:r.persist)&&Js(t,r)&&null!=(n=this.Cv)&&null!=n.reconcileFeatureFlagsBeforeMerge&&n.reconcileFeatureFlagsBeforeMerge()&&this.Ov();var s=this.getFlagVariants(),a=!t.flags&&h(t.featureFlags),o=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=Bs);var o=Zs(t,a),l=o.flags,u=o.featureFlags,c=o.featureFlagPayloads;if(u){var v=t.requestId,d=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{[bi]:u,[Ai]:p,[wi]:Ks(n,u),[Ri]:Gs(r,n),[Ei]:!1}}var m=u,y=c,_=l;if(Js(t,s)){var b=Object.keys(m),w=y||{};m=e({},i,m),y=e({},r,w),(null!=s&&s.partialResponse||l)&&b.forEach(t=>{var e;t in w||null==(e=y)||delete e[t]}),_=l?e({},n,Object.fromEntries(Object.entries(l).filter(t=>{return!(t[1].failed&&(e=t[0],{}.hasOwnProperty.call(i,e)&&!f(i[e])));var e}))):Ks(n,b)}return e({[bi]:Object.keys(Ys(m)),[Ai]:m||{},[Ri]:y||{},[wi]:_||{},[Ei]:!0===t.minimalFlagCalledEvents},v?{[ki]:v}:{},d?{[Si]:d}:{})}}(t,s,a?this.zv("$feature_flag_payloads")||{}:this.getFlagPayloads(),a?this.zv("$feature_flag_details")||{}:this.getFlagsWithDetails(),r,this.R);if(o)if(!1===(null==r?void 0:r.persist)){var l=!f(this.Wl.kv.get(Ai));this.Hv=o,l||this.$t(o)}else this.Ov(),this.Vv(o,t,!(null==r||!r.partialResponse)),this.$t(o);else i&&this.Uv();i||(this.vv=!1),this.Lv(i)}}override(t,e){void 0===e&&(e=!1),this.R.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.lf(t)}lf(t){if(this.Wl){if(!1===t)return this.Ft([Oi,Mi]),this.Lv(),void Us.info("All overrides cleared");if(h(t))return this.$t({[Oi]:Xs(t)}),this.Lv(),void Us.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.Kd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Oi]=h(n)?Xs(n):n),s&&(r[Mi]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Ft([Oi,Mi]):!1===n?this.Ft(Oi):!1===s&&this.Ft(Mi),this.Lv(),!1===n?Us.info("Flag overrides cleared"):n&&Us.info("Flag overrides set",{flags:n}),void(!1===s?Us.info("Payload overrides cleared"):s&&Us.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Oi]:t}),this.Lv(),void Us.info("Flag overrides set",{flags:t});this.R.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.R.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.nv){var e=this.af(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.R.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var n,s,a=(this.zv("$early_access_features")||[]).find(e=>e.flagKey===t),o={["$feature_enrollment/"+t]:i},l={$feature_flag:t,$feature_enrollment:i,$set:o};a&&(l.$early_access_feature_name=a.name),r&&(l.$feature_enrollment_stage=r);var u=e({},this.getFlagVariants(),{[t]:i}),h=e({},this.zv(wi)),c=null==(n=h[t])?void 0:n.failed,v=e({},this.zv(Ri));c&&(delete h[t],delete v[t]),null==(s=this.Cv)||s.markCrossTabFeatureFlagChanges(e({[bi]:[t],[Ai]:[t]},c?{[wi]:[t],[Ri]:[t]}:{},{[Fi]:Object.keys(o)})),this.$t(e({[bi]:Object.keys(Ys(u)),[Ai]:u},c?{[wi]:h,[Ri]:v}:{},{[Fi]:e({},this.zv("$stored_person_properties")||{},o)})),this.Lv();try{var d;null==(d=this.Wl)||d.capture("$feature_enrollment_update",l)}catch(t){this.R.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.zv(_i);!r||e?this.uf(t,i):t(r)}uf(t,e){var i=this;return r(function*(){var r=i.Wl;if(r){var n,s=e?"&"+e.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+s,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;n=a.json.earlyAccessFeatures,i.$t({[_i]:n})}catch(t){return void i.R.error("Early access feature request failed",t)}try{t(n)}catch(t){i.R.error("Early access feature callback failed",t)}}})()}af(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(t=>e[t]),flagVariants:Object.keys(e).filter(t=>e[t]).reduce((t,i)=>(t[i]=e[i],t),{})}}Lv(t){this.Fv();var e=this.af(),i=e.flags,r=e.flagVariants,n=this.av;this.av=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.av=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.cf(t,e)}cf(t,i){void 0===i&&(i=!0);var r=this.zv("$stored_person_properties")||{},n=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,a={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in r||(a[o]=s[o]));this.$t({[Fi]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.zv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Fi]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Ft(Fi),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.zv("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[Ti]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.zv("$stored_group_properties")||{};this.$t({[Ti]:e({},i,{[t]:{}})})}else this.Ft(Ti)}reset(){this.rv++,this.qv(this.ev,"cancelled"),this.qv(this.iv,"cancelled"),this.lv=!1,this.Yd={},this.Xd={},this.Hv=void 0,this.nv=!1,this.ov=!1,this.dv=!1,this.$anon_distinct_id=void 0,this.Bv(),this.Kd=!1,this.fv=0,this.uv=/* @__PURE__ */new Map}},ea=/* @__PURE__ */ci("[FeatureFlags]"),ia=class{constructor(t,e){void 0===e&&(e=!1),this.hf=!1,this.update(t,e)}update(t,e){this.df=((t,e)=>{var i,r,n,s,a,o,l,u;return{bootstrap:{featureFlags:null!==(i=null==(r=t.bootstrap)?void 0:r.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(n=null==(s=t.bootstrap)?void 0:s.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:e,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,idleRefreshBackoff:f(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(o=t.feature_flag_request_max_retries)&&void 0!==o?o:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(u=t.evaluation_contexts)&&void 0!==u?u:t.evaluation_environments)&&void 0!==l?l:[],flagKeys:h(t.flag_keys)?t.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.hf||(ea.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.hf=!0),f(t.flag_keys)||h(t.flag_keys)||ea.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.df}},ra=class extends ta{constructor(t){var e=new ia(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.Kf=e}get Cv(){return this._instance.persistence}updateConfig(t,e){this.Kf.update(t,e),this.Tv()}},na=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),sa=/* @__PURE__ */ci("[Error tracking]"),aa="webkit-masked-url:",oa=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],la=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",aa],ua=["__firefox__","__gCrWeb"],ha=class{constructor(t){var i,r;this.eg=[],this.ig=new it([new St,new Mt,new Et,new kt,new Rt,new Ct,new Tt,new Ot],function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return function(i,n){void 0===n&&(n=0);for(var s=[],a=i.split("\n"),o=Math.min(a.length,n+1e3),l=[],u=n;o>u;u++){var h=a[u];if(1024>=h.length){var c=pt.test(h)?h.replace(pt,"$1"):h;if(!c.match(/\S*Error: /)){for(var v of r){var d=v(c,t);if(d){s.push(d);var f=mt(s);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(wt(s,l)>=50)break}}}var m=[...l].sort((t,e)=>e.start-t.start),y=m[m.length-1];if(y){var _=_t(s,y);for(var b of(s.splice(y.start-_,_),m))b.start-=_}for(var w of m)yt(s,w);return l.some(t=>0===t.start&&s.length===t.length)&&function(t){for(var e=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),i=0,r=1;e.length>r;r++)xt(e,r,i)&&(i=r);t.push(...t.splice(0,i))}(s),function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return e({},t,{filename:t.filename||(r=i,r[r.length-1]||{}).filename,function:t.function||"?"});var r})}(s)}}("web:javascript",ct,ft)),this._instance=t,this.eg=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.ng=Lt(this.sg()),this.rg=new Nt(this.ng)}onConfigChange(){this.ng=Lt(this.sg()),this.rg.setConfig(this.ng)}onRemoteConfig(t){var e,i,r;if(t.ok){var n=t.config;if("errorTracking"in n){var s=null!==(e=null==(i=n.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],a=null==(r=n.errorTracking)?void 0:r.captureExtensionExceptions;this.eg=s,this._instance.persistence&&this._instance.persistence.register({[Kr]:this.eg,[Jr]:a})}}}get og(){var t,e,i=!!this._instance.get_property(Jr);return null!==(t=null!==(e=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==e?e:i)&&void 0!==t&&t}buildProperties(t,e){return this.ig.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.ng.enabled)try{if(!p(t)||0===t.trim().length)return void sa.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce((i,r)=>Dt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.lg(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&sa.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.rg.add(e({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){sa.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.ag(e)){if(this.ug(e))return this.cg("Exception dropped: matched a suppression rule"),void sa.info("Skipping exception capture because a suppression rule matched");if(!this.og&&this.hg(e))return this.cg("Exception dropped: thrown by a browser extension"),void sa.info("Skipping exception capture because it was thrown by an extension");if(!this.og&&this.dg(e))return this.cg("Exception dropped: thrown by an injected browser script"),void sa.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.vg(e))return this.cg("Exception dropped: thrown by the PostHog SDK"),void sa.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.ng.enabled&&y(t.$exception_steps)?this.fg(t):t,r=function(){if("u">typeof process){var t,e=null==(t=process.env.POSTHOG_RELEASE_ID)?void 0:t.trim();if(e)return e}var i=globalThis._posthogReleaseId;return"string"==typeof i&&i.length>0?i:void 0}();r&&(i.$release_id=r);try{var n=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return n&&this.rg.clear(),n}catch(t){return na(t)||sa.error("Failed to capture exception event. Dropping this exception.",t),void this.rg.clear()}}catch(t){return void(na(t)||sa.error("Failed to process exception event. Ignoring this exception.",t))}}fg(t){try{var i=this.rg.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return sa.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}cg(t){this.ng.enabled&&this.rg.add({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}lg(t){return v(t)?e({},t):{}}sg(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}ug(t){if(0===t.length)return!1;try{var e=t.reduce((t,e)=>{var i=e.type,r=e.value;return p(i)&&i.length>0&&t.$exception_types.push(i),p(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.eg.some(t=>{var i=t.values.map(t=>{var i=ys[t.operator],r=e[t.key];if(!i||!r)return!1;var n=h(t.value)?t.value:[t.value];return n.length>0&&i(n,r)});return"OR"===t.type?i.some(Boolean):i.every(Boolean)})}catch(t){return sa.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}hg(t){var e=t.flatMap(t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]}),i=e.filter(t=>{var e=t.filename;return!!e&&la.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(aa)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&oa.some(t=>{var i=t.value;return t.exact?e===i:e.includes(i)})})&&!e.some(t=>{var e=t.filename;return t.in_app&&!(null!=e&&e.startsWith(aa))}))}dg(t){return t.some(t=>{var e=t.value;return p(e)&&ua.some(t=>e.includes(t))})}vg(t){if(t.length>0){var e,i,r,n,s=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[];return null!==(r=null==(n=s[s.length-1])||null==(n=n.filename)?void 0:n.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ag(t){return!y(t)&&h(t)}},ca=/*#__PURE__*/function(){function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);e>i;i++)r[i]=t[i];return r}function e(e,i){return function(t){if(Array.isArray(t))return t}(e)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r,n,s,a,o=[],l=!0,u=!1;try{if(s=(i=i.call(t)).next,0===e);else for(;!(l=(r=s.call(i)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(t){u=!0,n=t}finally{try{if(!l&&null!=i.return&&(a=i.return(),Object(a)!==a))return}finally{if(u)throw n}}return o}}(e,i)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,i):void 0}}(e,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=Object.entries,r=Object.setPrototypeOf,n=Object.isFrozen,s=Object.getPrototypeOf,a=Object.getOwnPropertyDescriptor,o=Object.freeze,l=Object.seal,u=Object.create,h="undefined"!=typeof Reflect&&Reflect,c=h.apply,v=h.construct;o||(o=function(t){return t}),l||(l=function(t){return t}),c||(c=function(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;i>n;n++)r[n-2]=arguments[n];return t.apply(e,r)}),v||(v=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];return new t(...i)});var d,f=I([].forEach),p=I([].lastIndexOf),g=I([].pop),m=I([].push),y=I([].splice),_=Array.isArray,b=I("".toLowerCase),w=I("".toString),x=I("".match),S=I("".replace),k=I("".indexOf),E=I("".trim),A=I((0).toString),T=I(Boolean.prototype.toString),F="undefined"==typeof BigInt?null:I(BigInt.prototype.toString),P="undefined"==typeof Symbol?null:I(Symbol.prototype.toString),C=I({}.hasOwnProperty),R=I({}.toString),O=I(/t/.test),M=(d=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return v(d,e)});function I(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return c(t,e,r)}}function D(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b;if(r&&r(t,null),!_(e))return t;for(var s=e.length;s--;){var a=e[s];if("string"==typeof a){var o=i(a);o!==a&&(n(e)||(e[s]=o),a=o)}t[a]=!0}return t}function j(t){for(var e=0;t.length>e;e++)C(t,e)||(t[e]=null);return t}function L(t){var r=u(null);for(var n of i(t)){var s=e(n,2),a=s[0],o=s[1];C(t,a)&&(r[a]=_(o)?j(o):o&&"object"==typeof o&&o.constructor===Object?L(o):o)}return r}function N(t,e){for(;null!==t;){var i=a(t,e);if(i){if(i.get)return I(i.get);if("function"==typeof i.value)return I(i.value)}t=s(t)}return function(){return null}}var z=o(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),B=o(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),U=o(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),H=o(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),q=o(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),V=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),W=o(["#text"]),G=o(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),K=o(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),J=o(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),X=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y=l(/{{[\w\W]*|^[\w\W]*}}/g),Z=l(/<%[\w\W]*|^[\w\W]*%>/g),Q=l(/\${[\w\W]*/g),tt=l(/^data-[\-\w.\u00B7-\uFFFF]+$/),et=l(/^aria-[\-\w]+$/),it=l(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rt=l(/^(?:\w+script|data):/i),nt=l(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),st=l(/^html$/i),at=l(/^[a-z][.\w]*(-[.\w]+)+$/i),ot=l(/<[/\w!]/g),lt=l(/<[/\w]/g),ut=l(/<\/no(script|embed|frames)/i),ht=l(/\/>/i),ct=function(){return"undefined"==typeof window?null:window},vt=function(t,e,i,r){return C(t,e)&&_(t[e])?D(r.base?L(r.base):{},t[e],r.transform):i};return function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ct(),r=e=>t(e);if(r.version="3.4.13",r.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return r.isSupported=!1,r;var n,s=e.document,a=s,h=a.currentScript,c=e.HTMLTemplateElement,v=e.Node,d=e.NodeFilter,I=e.DOMParser,j=e.trustedTypes,dt=e.Element.prototype,ft=N(dt,"cloneNode"),pt=N(dt,"remove"),gt=N(dt,"nextSibling"),mt=N(dt,"childNodes"),yt=N(dt,"parentNode"),_t=N(dt,"shadowRoot"),bt=N(dt,"attributes"),wt=v&&v.prototype?N(v.prototype,"nodeType"):null,xt=v&&v.prototype?N(v.prototype,"nodeName"):null,St=v&&v.prototype?N(v.prototype,"ownerDocument"):null;if("function"==typeof c){var kt=s.createElement("template");kt.content&&kt.content.ownerDocument&&(s=kt.content.ownerDocument)}var Et,At="",Tt=!1,Ft=0,Pt=function(){if(Ft>0)throw M('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ct=function(t){Pt(),Ft++;try{return n.createHTML(t)}finally{Ft--}},Rt=s.implementation,Ot=s.createNodeIterator,Mt=s.createDocumentFragment,$t=s.getElementsByTagName,It=a.importNode,Dt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof i&&"function"==typeof yt&&Rt&&void 0!==Rt.createHTMLDocument;var jt=Y,Lt=Z,Nt=Q,zt=tt,Bt=et,Ut=rt,Ht=nt,qt=at,Vt=it,Wt=null,Gt=D({},[...z,...B,...U,...q,...W]),Kt=null,Jt=D({},[...G,...K,...J,...X]),Xt=Object.seal(u(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Yt=null,Zt=null,Qt=Object.seal(u(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),te=!0,ee=!0,ie=!1,re=!0,ne=!1,se=!0,ae=!1,oe=!1,le=null,ue=null,he=!1,ce=!1,ve=!1,de=!1,fe=!0,pe=!1,ge="user-content-",me=!0,ye=!1,_e={},be=null,we=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),xe=null,Se=D({},["audio","video","img","source","image","track"]),ke=null,Ee=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ae="http://www.w3.org/1998/Math/MathML",Te="http://www.w3.org/2000/svg",Fe="http://www.w3.org/1999/xhtml",Pe=Fe,Ce=!1,Re=null,Oe=D({},[Ae,Te,Fe],w),Me=o(["mi","mo","mn","ms","mtext"]),$e=D({},Me),Ie=o(["annotation-xml"]),De=D({},Ie),je=D({},["title","style","font","a","script"]),Le=null,Ne=["application/xhtml+xml","text/html"],ze=null,Be=null,Ue=s.createElement("form"),He=function(t){return t instanceof RegExp||t instanceof Function},qe=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Be||Be!==t){t&&"object"==typeof t||(t={}),t=L(t),Le=-1===Ne.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Wt=vt(t,"ALLOWED_TAGS",Gt,{transform:ze="application/xhtml+xml"===Le?w:b}),Kt=vt(t,"ALLOWED_ATTR",Jt,{transform:ze}),Re=vt(t,"ALLOWED_NAMESPACES",Oe,{transform:w}),ke=vt(t,"ADD_URI_SAFE_ATTR",Ee,{transform:ze,base:Ee}),xe=vt(t,"ADD_DATA_URI_TAGS",Se,{transform:ze,base:Se}),be=vt(t,"FORBID_CONTENTS",we,{transform:ze}),Yt=vt(t,"FORBID_TAGS",L({}),{transform:ze}),Zt=vt(t,"FORBID_ATTR",L({}),{transform:ze}),_e=!!C(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?L(t.USE_PROFILES):t.USE_PROFILES),te=!1!==t.ALLOW_ARIA_ATTR,ee=!1!==t.ALLOW_DATA_ATTR,ie=t.ALLOW_UNKNOWN_PROTOCOLS||!1,re=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,ne=t.SAFE_FOR_TEMPLATES||!1,se=!1!==t.SAFE_FOR_XML,ae=t.WHOLE_DOCUMENT||!1,ce=t.RETURN_DOM||!1,ve=t.RETURN_DOM_FRAGMENT||!1,de=t.RETURN_TRUSTED_TYPE||!1,he=t.FORCE_BODY||!1,fe=!1!==t.SANITIZE_DOM,pe=t.SANITIZE_NAMED_PROPS||!1,me=!1!==t.KEEP_CONTENT,ye=t.IN_PLACE||!1,Vt=function(t){try{return O(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:it,Pe="string"==typeof t.NAMESPACE?t.NAMESPACE:Fe,$e=C(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?L(t.MATHML_TEXT_INTEGRATION_POINTS):D({},Me),De=C(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?L(t.HTML_INTEGRATION_POINTS):D({},Ie);var e=C(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?L(t.CUSTOM_ELEMENT_HANDLING):u(null);if(Xt=u(null),C(e,"tagNameCheck")&&He(e.tagNameCheck)&&(Xt.tagNameCheck=e.tagNameCheck),C(e,"attributeNameCheck")&&He(e.attributeNameCheck)&&(Xt.attributeNameCheck=e.attributeNameCheck),C(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(Xt.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),l(Xt),ne&&(ee=!1),ve&&(ce=!0),_e&&(Wt=D({},W),Kt=u(null),!0===_e.html&&(D(Wt,z),D(Kt,G)),!0===_e.svg&&(D(Wt,B),D(Kt,K),D(Kt,X)),!0===_e.svgFilters&&(D(Wt,U),D(Kt,K),D(Kt,X)),!0===_e.mathMl&&(D(Wt,q),D(Kt,J),D(Kt,X))),Qt.tagCheck=null,Qt.attributeCheck=null,C(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Qt.tagCheck=t.ADD_TAGS:_(t.ADD_TAGS)&&(Wt===Gt&&(Wt=L(Wt)),D(Wt,t.ADD_TAGS,ze))),C(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Qt.attributeCheck=t.ADD_ATTR:_(t.ADD_ATTR)&&(Kt===Jt&&(Kt=L(Kt)),D(Kt,t.ADD_ATTR,ze))),C(t,"ADD_URI_SAFE_ATTR")&&_(t.ADD_URI_SAFE_ATTR)&&D(ke,t.ADD_URI_SAFE_ATTR,ze),C(t,"FORBID_CONTENTS")&&_(t.FORBID_CONTENTS)&&(be===we&&(be=L(be)),D(be,t.FORBID_CONTENTS,ze)),C(t,"ADD_FORBID_CONTENTS")&&_(t.ADD_FORBID_CONTENTS)&&(be===we&&(be=L(be)),D(be,t.ADD_FORBID_CONTENTS,ze)),me&&(Wt["#text"]=!0),ae&&D(Wt,["html","head","body"]),Wt.table&&(D(Wt,["tbody"]),delete Yt.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');var i=n;n=t.TRUSTED_TYPES_POLICY;try{At=Ct("")}catch(t){throw n=i,t}}else null===t.TRUSTED_TYPES_POLICY?(n=void 0,At=""):(void 0===n&&(Tt||(Et=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;var i=null,r="data-tt-policy-suffix";e&&e.hasAttribute(r)&&(i=e.getAttribute(r));var n="dompurify"+(i?"#"+i:"");try{return t.createPolicy(n,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(j,h),Tt=!0),n=Et),n&&"string"==typeof At&&(At=Ct("")));o&&o(t),Be=t}},Ve=D({},[...B,...U,...H]),We=D({},[...q,...V]),Ge=function(t){m(r.removed,{element:t});try{yt(t).removeChild(t)}catch(e){if(pt(t),!yt(t))throw M("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ke=function(t){Ye(t);var e=mt(t);if(e){var i=[];f(e,t=>{m(i,t)}),f(i,t=>{try{pt(t)}catch(t){}})}var r=bt(t);if(r)for(var n=r.length-1;n>=0;--n){var s=r[n],a=s&&s.name;if("string"==typeof a)try{t.removeAttribute(a)}catch(t){}}},Je=function(t,e){try{m(r.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){m(r.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(ce||ve)try{Ge(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Xe=function(t){var e=bt(t);if(e)for(var i=e.length-1;i>=0;--i){var r=e[i],n=r&&r.name;if("string"==typeof n&&!Kt[ze(n)])try{t.removeAttribute(n)}catch(t){}}},Ye=function(t){for(var e=[t];e.length>0;){var i=e.pop();1===(wt?wt(i):i.nodeType)&&Xe(i);var r=mt(i);if(r)for(var n=r.length-1;n>=0;--n)e.push(r[n])}},Ze=function(t){var e=null,i=null;if(he)t="<remove></remove>"+t;else{var r=x(t,/^[\r\n\t ]+/);i=r&&r[0]}"application/xhtml+xml"===Le&&Pe===Fe&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var a=n?Ct(t):t;if(Pe===Fe)try{e=(new I).parseFromString(a,Le)}catch(t){}if(!e||!e.documentElement){e=Rt.createDocument(Pe,"template",null);try{e.documentElement.innerHTML=Ce?At:a}catch(t){}}var o=e.body||e.documentElement;return t&&i&&o.insertBefore(s.createTextNode(i),o.childNodes[0]||null),Pe===Fe?$t.call(e,ae?"html":"body")[0]:ae?e.documentElement:o},Qe=function(t){var e=St?St(t):t.ownerDocument;return Ot.call(e||t,t,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},ti=function(t){return t=S(t,jt," "),t=S(t,Lt," "),S(t,Nt," ")},ei=function(t){var e;t.normalize();for(var i=St?St(t):t.ownerDocument,r=Ot.call(i||t,t,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null),n=r.nextNode();n;)n.data=ti(n.data),n=r.nextNode();var s=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");s&&f(s,t=>{ri(t.content)&&ei(t.content)})},ii=function(t){var e=xt?xt(t):null;return"string"==typeof e&&"form"===ze(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==bt(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==wt(t)||t.childNodes!==mt(t))},ri=function(t){if(!wt||"object"!=typeof t||null===t)return!1;try{return 11===wt(t)}catch(t){return!1}},ni=function(t){if(!wt||"object"!=typeof t||null===t)return!1;try{return"number"==typeof wt(t)}catch(t){return!1}};function si(t,e,i){0!==t.length&&f(t,t=>{t.call(r,e,i,Be)})}var ai=function(t,e,i,r){return 0===t.length?e:e===i||e===r?L(e):e},oi=function(t,e){if(si(Dt.beforeSanitizeElements,t,null),t!==e&&null===yt(t))return ye&&Ye(t),!0;if(ii(t))return Ge(t),!0;var i=ze(xt?xt(t):t.nodeName);if(Wt=ai(Dt.uponSanitizeElement,Wt,Gt,le),si(Dt.uponSanitizeElement,t,{tagName:i,allowedTags:Wt}),t!==e&&null===yt(t))return ye&&Ye(t),!0;if(function(t,e){return!!(se&&t.hasChildNodes()&&!ni(t.firstElementChild)&&O(ot,t.textContent)&&O(ot,t.innerHTML))||!(!se||t.namespaceURI!==Fe||"style"!==e||!ni(t.firstElementChild))||7===t.nodeType||!(!se||8!==t.nodeType||!O(lt,t.data))}(t,i))return Ge(t),!0;if(Yt[i]||!(Qt.tagCheck instanceof Function&&Qt.tagCheck(i))&&!Wt[i]){var n=function(t,e,i){if(!Yt[e]&&hi(e)){if(Xt.tagNameCheck instanceof RegExp&&O(Xt.tagNameCheck,e))return!1;if(Xt.tagNameCheck instanceof Function&&Xt.tagNameCheck(e))return!1}if(me&&!be[e]){var r=yt(t),n=mt(t);if(n&&r)for(var s=n.length-1;s>=0;--s){var a=t===i?ft(n[s],!0):n[s];r.insertBefore(a,gt(t))}}return Ge(t),!0}(t,i,e);return!1===n&&si(Dt.afterSanitizeElements,t,null),n}if(1===(wt?wt(t):t.nodeType)&&!function(t){var e=yt(t);e&&e.tagName||(e={namespaceURI:Pe,tagName:"template"});var i=b(t.tagName),r=b(e.tagName);return!!Re[t.namespaceURI]&&(t.namespaceURI===Te?function(t,e,i){return e.namespaceURI===Fe?"svg"===t:e.namespaceURI===Ae?"svg"===t&&("annotation-xml"===i||$e[i]):Boolean(Ve[t])}(i,e,r):t.namespaceURI===Ae?function(t,e,i){return e.namespaceURI===Fe?"math"===t:e.namespaceURI===Te?"math"===t&&De[i]:Boolean(We[t])}(i,e,r):t.namespaceURI===Fe?function(t,e,i){return!(e.namespaceURI===Te&&!De[i])&&!(e.namespaceURI===Ae&&!$e[i])&&!We[t]&&(je[t]||!Ve[t])}(i,e,r):!("application/xhtml+xml"!==Le||!Re[t.namespaceURI]))}(t))return Ge(t),!0;if(("noscript"===i||"noembed"===i||"noframes"===i)&&O(ut,t.innerHTML))return Ge(t),!0;if(ne&&3===t.nodeType){var s=ti(t.textContent);t.textContent!==s&&(m(r.removed,{element:t.cloneNode()}),t.textContent=s)}return si(Dt.afterSanitizeElements,t,null),!1},li=function(t,e,i){if(Zt[e])return!1;if(se&&"patchsrc"===e)return!1;if(se&&"for"===e&&"label"!==t&&"output"!==t)return!1;if(fe&&("id"===e||"name"===e)&&(i in s||i in Ue))return!1;var r=Kt[e]||Qt.attributeCheck instanceof Function&&Qt.attributeCheck(e,t);if(ee&&O(zt,e));else if(te&&O(Bt,e));else if(r){if(ke[e]);else if(O(Vt,S(i,Ht,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==k(i,"data:")||!xe[t])if(ie&&!O(Ut,S(i,Ht,"")));else if(i)return!1}else if(!(hi(t)&&(Xt.tagNameCheck instanceof RegExp&&O(Xt.tagNameCheck,t)||Xt.tagNameCheck instanceof Function&&Xt.tagNameCheck(t))&&(Xt.attributeNameCheck instanceof RegExp&&O(Xt.attributeNameCheck,e)||Xt.attributeNameCheck instanceof Function&&Xt.attributeNameCheck(e,t))||"is"===e&&Xt.allowCustomizedBuiltInElements&&(Xt.tagNameCheck instanceof RegExp&&O(Xt.tagNameCheck,i)||Xt.tagNameCheck instanceof Function&&Xt.tagNameCheck(i))))return!1;return!0},ui=D({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),hi=function(t){return!ui[b(t)]&&O(qt,t)},ci=function(t,e,i,r){if(n&&"object"==typeof j&&"function"==typeof j.getAttributeType&&!i)switch(j.getAttributeType(t,e)){case"TrustedHTML":return Ct(r);case"TrustedScriptURL":return function(t){Pt(),Ft++;try{return n.createScriptURL(t)}finally{Ft--}}(r)}return r},vi=function(t,e,i,n){try{i?t.setAttributeNS(i,e,n):t.setAttribute(e,n),ii(t)?Ge(t):g(r.removed)}catch(i){Je(e,t)}},di=function(t){si(Dt.beforeSanitizeAttributes,t,null);var e=t.attributes;if(e&&!ii(t)){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Kt=ai(Dt.uponSanitizeAttribute,Kt,Jt,ue),forceKeepAttr:void 0},r=e.length,n=ze(t.nodeName);r--;){var s=e[r],a=s.name,o=s.namespaceURI,l=s.value,u=ze(a),h=l,c="value"===a?h:E(h);i.attrName=u,i.attrValue=c,i.keepAttr=!0,i.forceKeepAttr=void 0,si(Dt.uponSanitizeAttribute,t,i),c=i.attrValue,!pe||"id"!==u&&"name"!==u||0===k(c,ge)||(Je(a,t),c=ge+c),se&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,c)||"attributename"===u&&x(c,"href")?Je(a,t):i.forceKeepAttr||(!i.keepAttr||!re&&O(ht,c)?Je(a,t):(ne&&(c=ti(c)),li(n,u,c)?(c=ci(n,u,o,c))!==h&&vi(t,a,o,c):Je(a,t)))}si(Dt.afterSanitizeAttributes,t,null)}},fi=function(t){var e=null,i=Qe(t);for(si(Dt.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if(si(Dt.uponSanitizeShadowNode,e,null),oi(e,t),di(e),ri(e.content)&&fi(e.content),1===(wt?wt(e):e.nodeType)){var r=_t(e);ri(r)&&(pi(r),fi(r))}si(Dt.afterSanitizeShadowDOM,t,null)},pi=function(t){for(var e=[{node:t,shadow:null}];e.length>0;){var i=e.pop();if(i.shadow)fi(i.shadow);else{var r=i.node,n=1===(wt?wt(r):r.nodeType),s=mt(r);if(s)for(var a=s.length-1;a>=0;--a)e.push({node:s[a],shadow:null});if(n){var o=xt?xt(r):null;if("string"==typeof o&&"template"===ze(o)){var l=r.content;ri(l)&&e.push({node:l,shadow:null})}}if(n){var u=_t(r);ri(u)&&e.push({node:null,shadow:u},{node:u,shadow:null})}}}};return r.sanitize=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,s=null,o=null,l=null;if((Ce=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ni(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return A(t);case"boolean":return T(t);case"bigint":return F?F(t):"0";case"symbol":return P?P(t):"Symbol()";case"undefined":default:return R(t);case"function":case"object":if(null===t)return R(t);var e=t,i=N(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:R(r)}return R(t)}}(t)))throw M("dirty is not a string, aborting");if(!r.isSupported)return t;oe?(Wt=le,Kt=ue):qe(e),(Dt.uponSanitizeElement.length>0||Dt.uponSanitizeAttribute.length>0)&&(Wt=L(Wt)),Dt.uponSanitizeAttribute.length>0&&(Kt=L(Kt)),r.removed=[];var u=ye&&"string"!=typeof t&&ni(t);if(u){!function(t){if(se)for(var e=[t];e.length>0;){var i=e.pop(),r=wt?wt(i):i.nodeType;if(7===r||8===r&&O(lt,i.data))try{pt(i)}catch(t){}else{if(1===r){var n=i,s=ze(xt?xt(i):i.nodeName);try{n.hasAttribute&&n.hasAttribute("patchsrc")&&n.removeAttribute("patchsrc"),n.hasAttribute&&n.hasAttribute("for")&&"label"!==s&&"output"!==s&&n.removeAttribute("for")}catch(t){}}var a=mt(i);if(a)for(var o=a.length-1;o>=0;--o)e.push(a[o])}}}(t);var h=xt?xt(t):t.nodeName;if("string"==typeof h){var c=ze(h);if(!Wt[c]||Yt[c])throw Ke(t),M("root node is forbidden and cannot be sanitized in-place")}if(ii(t))throw Ke(t),M("root node is clobbered and cannot be sanitized in-place");try{pi(t)}catch(e){throw Ke(t),e}}else if(ni(t))1===(s=(i=Ze("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s),pi(s);else{if(!ce&&!ne&&!ae&&-1===t.indexOf("<"))return n&&de?Ct(t):t;if(!(i=Ze(t)))return ce?null:de?At:""}i&&he&&Ge(i.firstChild);var v=u?t:i;try{for(var d=Qe(v);o=d.nextNode();)oi(o,v),di(o),ri(o.content)&&fi(o.content)}catch(e){throw u&&(Ke(t),f(r.removed,t=>{t.element&&Ye(t.element)})),e}if(u)return f(r.removed,t=>{t.element&&Ye(t.element)}),ne&&ei(t),t;if(ce){if(ne&&ei(i),ve)for(l=Mt.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(Kt.shadowroot||Kt.shadowrootmode)&&(l=It.call(a,l,!0)),l}var p=ae?i.outerHTML:i.innerHTML;return ae&&Wt["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&O(st,i.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+p),ne&&(p=ti(p)),n&&de?Ct(p):p},r.setConfig=function(){qe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,le=Wt,ue=Kt},r.clearConfig=function(){Be=null,oe=!1,le=null,ue=null,n=Et,At=""},r.isValidAttribute=function(t,e,i){return Be||qe({}),li(ze(t),ze(e),i)},r.addHook=function(t,e){"function"==typeof e&&C(Dt,t)&&m(Dt[t],e)},r.removeHook=function(t,e){if(C(Dt,t)){if(void 0!==e){var i=p(Dt[t],e);return-1===i?void 0:y(Dt[t],i,1)[0]}return g(Dt[t])}},r.removeHooks=function(t){C(Dt,t)&&(Dt[t]=[])},r.removeAllHooks=function(){Dt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}()}(),va="Refusing to render web experiment since the viewer is a likely bot",da={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},fa={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>gs(e,t),not_regex:(t,e)=>!gs(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},pa=class t{get Br(){return this._instance.config}constructor(e){var i=this;this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),i.getWebExperiments(e=>{t.zg("retrieved web experiments from the server"),i.Hg=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.Hg&&(t.zg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.Hg)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.Ug(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.Wg(a,i._instance)&&i.Vg(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.zg(va);else if(!this.Br.disable_web_experiments){if(y(this.Hg))return this.Hg=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.zg("applying feature flags",e),e.forEach(t=>{var e;if(this.Hg&&null!=(e=this.Hg)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.Hg)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.Ug(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=En(null==e?void 0:e.search,"__experiment_id"),r=En(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.zg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.Gg(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Br.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Br.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Br.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Gg(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.zg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.Vg(n[0].name,i,n[0].variants[i].transforms))}Ug(e,i){var r=e.variants[i];t.Qg(r,this._instance)?this.Vg(e.name,i,r.transforms):t.zg("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static Wg(e,i){return!y(e.conditions)&&t.Qg(e,i)&&t.Jg(e)}static Qg(e,i){var r;if(y(e.conditions)||y(null==(r=e.conditions)?void 0:r.url))return!0;var n=t.getWindowLocation();if(n){var s,a,o,l=yi(i,n.href);return null==(s=e.conditions)||!s.url||fa[null!==(a=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return null==un?void 0:un.location}static Jg(t){var e;if(y(t.conditions)||y(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!vn)return{};var r,n,s,a=e?[...In,...i||[]]:[],o=(r=An(vn.URL,a,jn),n=Dn.concat(t||[]),s={},di(n,function(t){var e=En(r,t);s[t]=e||null}),s);return fi(function(){var t={};return di(Ln,function(e){var i=(t=>{if(vn){try{for(var e=t+"=",i=vn.cookie.split(";").filter(t=>t.length),r=0;i.length>r;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}})(e);t[e]=i||null}),t}(),o)}();if(i.utm_source){var r,n,s,a,o,l,u,h,c=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(n=t.conditions)||null==(n=n.utm)?void 0:n.utm_campaign)==i.utm_campaign,v=null==(s=t.conditions)||null==(s=s.utm)||!s.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,d=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return c&&d&&f&&v}return!1}static zg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.info("[WebExperiments] "+t,i)}static Zg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.warn("[WebExperiments] "+t,i)}static Kg(e){("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"template"===e.localName?e.content:e).querySelectorAll("a[target], template").forEach(e=>{var i;if("template"!==e.localName)if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"_blank"===(null==(i=e.getAttribute("target"))?void 0:i.toLowerCase())){var r=(e.getAttribute("rel")||"").split(/\s+/).filter(t=>t&&!/^(opener|noopener)$/i.test(t));r.push("noopener"),e.setAttribute("rel",r.join(" "))}else e.removeAttribute("target");else"http://www.w3.org/1999/xhtml"===e.namespaceURI&&t.Kg(e)})}Vg(i,r,n){this._is_bot()?t.zg(va):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.zg("applying transform of variant "+r+" for experiment "+i+" ",n);var a=null==(s=document)?void 0:s.querySelectorAll(n.selector);if(null==a||!a.length)return void t.Zg("no element on this page matches selector "+n.selector+" of variant "+r+" for experiment "+i);var o=/* @__PURE__ */new Map;null==a||a.forEach(i=>{if("script"!==i.localName.toLowerCase()){var r=i;if(n.html){var s,a="http://www.w3.org/1998/Math/MathML"===i.namespaceURI&&"annotation-xml"===i.localName&&(null==(s=i.getAttribute("encoding"))?void 0:s.toLowerCase())||"",l=JSON.stringify([i.namespaceURI,i.localName,a]),u=o.get(l);if(y(u)){var h=null!=Rs?Rs:Rs=ca(),c=i.ownerDocument.implementation.createHTMLDocument(""),v=c.createElementNS(i.namespaceURI,i.localName);a&&v.setAttribute("encoding",a);var d=c.createRange();d.selectNodeContents(v);var f="http://www.w3.org/2000/svg"===i.namespaceURI&&/^(foreignObject|desc|title)$/.test(i.localName)||/^(text\/html|application\/xhtml\+xml)$/.test(a)?"http://www.w3.org/1999/xhtml":i.namespaceURI,p=d.createContextualFragment(n.html);"http://www.w3.org/1998/Math/MathML"===i.namespaceURI&&/^(mi|mo|mn|ms|mtext)$/.test(i.localName)?(v.appendChild(p),h.sanitize(v,e({},da,{NAMESPACE:f||void 0,IN_PLACE:!0}))):("http://www.w3.org/1999/xhtml"===v.namespaceURI&&"template"===v.localName?v.content:v).appendChild(h.sanitize(p,e({},da,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.Kg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.zg("Control variants leave the page unmodified.")}_is_bot(){return cn&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&F(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>F(null==t?void 0:t.brand,e)))return!0}catch(t){}return!!t.webdriver}(cn,this.Br.custom_blocked_useragents):void 0}},ga=/* @__PURE__ */ci("[Conversations]"),ma="Conversations not available yet.",ya=class{constructor(t){this._instance=t,this.Yg=void 0,this._conversationsManager=null,this.Xg=!1,this.ie=null,this.tm=!1,this.im=0,this.nm=null,this.sm=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.nm=null;else if(this.rm=t.ok,t.ok){var e=t.config.conversations;y(e)?this.nm=null:(b(e)?this.Yg=e:(this.Yg=e.enabled,this.ie=e),this.Yg||(this.nm=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.im++,this.Yg=void 0,this.ie=null,this.rm=void 0,this.tm=!1,this.nm=null}loadIfEnabled(){if(!(this._conversationsManager||this.Xg||this._instance.config.disable_conversations||mi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&!f(this.Yg)&&this.Yg)if(this.ie&&this.ie.token){this.Xg=!0;try{var e=t.initConversations;if(e)return this.om(e),void(this.Xg=!1);var i=gn(this._instance);if(!i)return void this.lm(Ur);var r=this.im;i(this._instance,"conversations",e=>{if(r!==this.im)return this.Xg=!1,void this.loadIfEnabled();e||!t.initConversations?this.lm("Could not load conversations script",e):this.om(t.initConversations),this.Xg=!1})}catch(t){this.lm("Error initializing conversations",t),this.Xg=!1}}else ga.error("Conversations enabled but missing token in remote config.")}}om(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.tm=!1,ga.info("Conversations loaded successfully")}catch(t){return void this.lm("Error completing conversations initialization",t)}this.sm&&this._conversationsManager.setTheme(this.sm),this.am()}else ga.error("Cannot complete initialization: remote config is null")}am(){var t=this.nm;this.nm=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}lm(t,e){ga.error(t,e),this._conversationsManager=null,this.Xg=!1,this.tm=!0}show(){this._conversationsManager?this._conversationsManager.show():ga.warn("Conversations not loaded yet.")}hide(){"open"===this.nm&&(this.nm=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.nm=null,this._conversationsManager.open()):this.nm="open"}close(){this._conversationsManager?(this.nm=null,this._conversationsManager.close()):this.nm="close"}setTheme(t){var i,r;this.sm=e({},this.sm,t,{dark:e({},null==(i=this.sm)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.Yg&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":mi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.rm?"remote_config_failed":f(this.Yg)?this.rm?"disabled_in_project":"remote_config_pending":this.Yg?y(this.ie)||!this.ie.token?"missing_token":null!=pn&&pn.__PosthogExtensions__?this.Xg?"initializing":this.tm?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,e,i){var n=this;return r(function*(){return n._conversationsManager?n._conversationsManager.sendMessage(t,e,i):(ga.warn(ma),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(ga.warn(ma),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(ga.warn(ma),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(ga.warn(ma),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(ga.warn(ma),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(ga.warn(ma),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(ga.warn(ma),null)})()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}};function _a(){var t="",i="";try{var r,n=null==(r="u">typeof globalThis?globalThis:"u">typeof window?window:void 0)||null==(r=r.navigator)?void 0:r.userAgent;if(n){var s=function(t){for(var e=0;L.length>e;e++){var i=L[e],r=i[1],n=i[0].exec(t),s=n&&(c(r)?r(n,t):r);if(s)return s}return["",""]}(n);t=s[0],i=s[1]}}catch(t){}return function(t,i){var r=function(t){if(t)return{}.hasOwnProperty.call(Ne,t)?Ne[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function ba(t,i){var r,n,s,a,o,l,u,h=null!==(r=null==t?void 0:t.flushIntervalMs)&&void 0!==r?r:3e3,c=null!==(n=null==t?void 0:t.maxBufferSize)&&void 0!==n?n:100,v=null!=i&&i.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,d=f(v)?Math.max(c,2048):Math.max(c,v),p=e({},_a(),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==i?void 0:i.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:c,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var wa=["debug","log","warn","error","info"],xa="console",Sa="__posthogHandledLogsRequestError",ka=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[Sa]=!0,i},Ea=t=>!!t&&"object"==typeof t&&!0===t[Sa],Aa=class{get vf(){var t=this;return e({},this.R,{error(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];i.some(Ea)||t.R.error(...i)}})}constructor(t,e){var i;this.Ql=t,this.ff=e,this.name="logs",this.pf=!1,this.gf=!1,this.mf=!1,this.R=ci("[logs]"),this.Cc=[],this.yf=[],this.fv=0,this.bf=!1,this.Ai=!1,this._f=[],this.wf=[],this.kf=!1,this.Sf=!1,this.xf=!1,this.$f=()=>{var t,e;this.Ai||(this.fv=0,null==(t=this.Cf)||t.onReconnect(),null==(e=this.Tf)||e.onReconnect())},this.pf=!(null==(i=t.get())||!i.captureConsoleLogs)}get Mf(){return!0}If(){}Ef(){if(!this.xf){try{this.Iv=typeof window>"u"?void 0:window}catch(t){this.Iv=void 0}this.Iv&&(gi(this.Iv,"online",this.$f),this.xf=!0)}}Af(t,e,i,r){this.Ef();var n=ba(this.Ql.get(),i);return[new Je(this.Rf(t,e),n,this.vf,()=>this.ff(),t=>t(),void 0,r),n]}Pf(){var t=this.Ql.get();if(!this.Cf||this.Of!==t){var e;null==(e=this.Cf)||e.reset(),this.Of=t;var i=this.Af(()=>this.Cc,t=>{this.Cc=t});this.Cf=i[0],this.Ff=i[1]}return this.Cf}Lf(){var t=this.Ql.get();if(!this.Tf||this.Df!==t){var e;null==(e=this.Tf)||e.reset(),this.Df=t;var i=this.Af(()=>this.yf,t=>{this.yf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},xa);this.Tf=i[0],this.Nf=i[1]}return this.Tf}setup(t){if(!this.Ai&&!this.bf)return this.bf=!0,this.Wl=t,this.R=t.logger.createLogger("[logs]"),Ts(t.kv.initialize(),()=>{this.Ai||this.Ev(t)})}Ev(t){var e;this.Ef(),null!=(e=this.Ql.get())&&e.captureConsoleLogs&&(this.pf=!0),(this.pf||this.Ql.remoteConfigWillArrive&&t.kv.get(this.Ql.captureHintKey))&&this.jf();var i=!1,r=t.onRemoteConfig(t=>{var e;i=t.ok&&!0===(null==(e=t.config.logs)?void 0:e.captureConsoleLogs),this.onRemoteConfig(t)});this.Ai?r.dispose():(this.oa=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Ai||(this.Ai=!0,this.qf(),null==(t=this.oa)||t.dispose(),this.oa=void 0,this.Wl=void 0,this.mf=!1,null==(e=this.Iv)||e.removeEventListener("online",this.$f),null==(i=this.Bf)||i.call(this),this.Bf=void 0,null==(r=this.Cf)||r.clearQueue(),null==(n=this.Tf)||n.clearQueue(),null==(s=this.Cf)||s.reset(),null==(a=this.Tf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Ai){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.zf():(null==(i=this.Wl)||i.kv.set(this.Ql.captureHintKey,!!r),r?(this.pf=!0,this.gf||this.jf(),this.loadIfEnabled()):this.zf())}}reset(){var t,e,i,r;this.qf(),null==(t=this.Cf)||t.clearQueue(),this.Cc=[],null==(e=this.Cf)||e.reset(),null==(i=this.Tf)||i.clearQueue(),this.yf=[],null==(r=this.Tf)||r.reset(),this.fv=0}captureLog(t){!this.Ai&&this.Wl&&this.Pf().captureLog(t)}captureConsoleLog(t){!this.Ai&&this.Wl&&this.Lf().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Ai&&this.Wl&&this.Lf().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.qf(),null==(t=this.Tf)||t.clearQueue(),this.yf=[]}zf(){this.pf||this.qf()}jf(){var t,e=this;if(!this.kf&&null!=(t=this.Iv)&&t.console){var i=ba(this.Ql.get()).maxBufferSize,r=!0;this.wf.push(()=>{r=!1});var n=function(t){var n;try{n=(t=>{for(;null!=(e=t)&&e.__rrweb_original__;){var e;t=t.__rrweb_original__}return t})(e.Iv.console[t])}catch(t){return 1}n&&e.wf.push(Cn(e.Iv.console,t,s=>{var a=function(){for(var n=arguments.length,a=new Array(n),o=0;n>o;o++)a[o]=arguments[o];try{r&&e.Hf(t,a,i)}catch(t){}return s.apply(e.Iv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of wa)if(n(s))continue;this.kf=!0,this.Uf=setTimeout(()=>{this.qf()},3e4)}}Hf(t,e,i){var r;if(this.kf&&!this.Sf&&0!==e.length)if(null!=(r=this.Wl)&&r.canCapture){if(i>this._f.length){this.Sf=!0;try{this._f.push({level:t,args:e,occurredAtMs:Date.now(),context:this.ff()})}finally{this.Sf=!1}}}else this.qf()}qf(){if(this._f=[],this.kf){for(var t of(this.kf=!1,this.Uf&&(clearTimeout(this.Uf),this.Uf=void 0),this.wf))t();this.wf=[]}}Wf(){var t=this._f;return this.qf(),t}get logger(){return this.Vf||(this.Vf={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Vf}flushLogs(t){this.Wl&&(t?this.Gf(t):(this.Cf&&this.Cf.flush().catch(t=>this.Qf(t)),this.Tf&&this.Tf.flush().catch(t=>this.Qf(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Cf)?void 0:e.flush().catch(e=>t.Qf(e)),n=null==(i=t.Tf)?void 0:i.flush().catch(e=>t.Qf(e));yield r,yield n})()}Qf(t){Ea(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Ai&&this.pf&&!this.gf&&!this.mf){var t=this.If();if(t){this.mf=!0;try{t((t,e)=>{if(this.mf=!1,!this.Ai&&this.pf)if(t||!e)this.R.error("Could not load logs script",t),this.qf();else{var i=this.Wf();this.Bf=e.initialize(this.Wl),this.gf=!0,i.length>0&&e.replay(this.Wl,i)}})}catch(t){throw this.mf=!1,t}}else this.qf()}}Rf(t,e){var i=this.Wl;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:e=>e===n.LogsQueue?t():void 0,setPersistedProperty(t,i){t===n.LogsQueue&&e(null!=i?i:[])},Hs:t=>this.Hs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}Hs(t){return new Promise(e=>{if(Sn(this.fv,3))e({kind:"fatal",error:ka(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(n),e(t))},n=setTimeout(()=>{this.R.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:ka(void 0,"logs request timed out")})},9e4),s=this.Mf;this.Wl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Wl.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.Jf(i,s),i>=200&&300>i?r({kind:"ok"}):413===i?r({kind:"too-large"}):0!==i&&408!==i&&429!==i&&500>i?r({kind:"fatal",error:/* @__PURE__ */new Error("logs request failed with status "+i)}):0===i?(t.error||this.R.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:ka(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:/* @__PURE__ */new Error("logs request failed with status "+i)})},t=>{r({kind:"retry-later",error:t})})}})}Jf(t,e){(0!==t||e)&&(this.fv=kn(t,this.fv,3,()=>this.R.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.")))}Gf(t){this.Cc.length>0&&this.Zf(t,this.Cc,this.Ff,this.Wl.library.name,t=>{this.Cc=t}),this.yf.length>0&&this.Zf(t,this.yf,this.Nf,xa,t=>{this.yf=t})}Zf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ve(s,qe(i,this.Wl.library.name,this.Wl.library.version),r,this.Wl.library.version);this.Wl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Wl.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Qf(t))}}},Ta=class extends Aa{constructor(t){super({get(){var e;return null==t||null==(e=t.config)?void 0:e.logs},captureHintKey:"$logs_capture_enabled_server_side",get remoteConfigWillArrive(){var e;return!(null!=t._shouldDisableFlags&&t._shouldDisableFlags()&&(null==(e=pn._POSTHOG_REMOTE_CONFIG)||null==(e=e[t.config.token])||!e.config))}},()=>function(t){var e,i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){var r=t.sessionManager.checkAndGetSessionAndWindowId(!0),n=r.windowId,s=r.sessionStartTimestamp,a=r.lastActivityTimestamp;i.sessionId=r.sessionId,i.windowId=n,y(s)||(i.sessionStartTimestamp=s),y(a)||(i.lastActivityTimestamp=a)}if(null!=pn&&null!=(e=pn.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(pn.location.href):pn.location.href),t.featureFlags){var o=t.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}(t)),this._instance=t,this.name="logs",this.Ef()}get Mf(){return this._instance.__loaded}If(){var t=ci("[logs]"),e=null==pn?void 0:pn.__PosthogExtensions__;if(e){var i=gn(this._instance);if(i)return t=>{i(this._instance,"logs",i=>{var r=e.logs;t(i,null!=r&&r.initializeLogs?{initialize:t=>r.initializeLogs(t),replay:(t,e)=>null==r.replayConsoleBuffer?void 0:r.replayConsoleBuffer(t,e)}:void 0)})};t.error(Ur)}else t.error("PostHog Extensions not found.")}},Fa=/* @__PURE__ */ci("[NetworkMetrics]"),Pa={"http:":80,"https:":443},Ca=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Ra=t=>p(t)&&0===t.toLowerCase().indexOf("text/event-stream"),Oa=t=>{try{return t()}catch(t){return}},Ma=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Tr(r))?void 0:i.href)||r}},$a=function(t,i,r,n,s,a,o){void 0===o&&(o=!1);try{var l,u=s();if(!u)return;var h=r||void 0,v=$s()-n,d=Tr(i.url);if(d&&"http:"!==d.protocol&&"https:"!==d.protocol)return;var f={url:(null==d?void 0:d.href)||i.url,method:i.method},g=c(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var m=o&&!h?void 0:((t,e)=>t?400>t?void 0:String(t):(null==e?void 0:e.name)||"_OTHER")(h,a),y=e({},e({"http.request.method":b=Ca.has(_=f.method)?_:"_OTHER"},"_OTHER"===b&&_!==b?{"http.request.method_original":_}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Pa[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(e=t.pathname,e.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var e})(d):{},h?{"http.response.status_code":h}:{},m?{"error.type":m}:{},null==u.attributes?void 0:u.attributes(f,{status:h,durationMs:v}));null==(l=t.metrics)||l.histogram(g,v,{unit:"ms",attributes:y})}catch(t){Fa.error("Failed to record network metric",t)}var _,b},Ia=()=>{},Da=(t,e)=>c(null==un?void 0:un.fetch)?Cn(un,"fetch",i=>function(){for(var r=$s(),n=arguments.length,s=new Array(n),a=0;n>a;a++)s[a]=arguments[a];var o=i.apply(this,s);if(!e())return o;try{var l,u,h,c=s[0],v=s[1],d=Ma(null!==(l=null!==(u=null==v?void 0:v.method)&&void 0!==u?u:null==c?void 0:c.method)&&void 0!==l?l:"GET",null!==(h=null==c?void 0:c.url)&&void 0!==h?h:c);return o.then(i=>(Ra(Oa(()=>{var t;return null==i||null==(t=i.headers)?void 0:t.get("content-type")}))||$a(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw $a(t,d,void 0,r,e,i),i})}catch(t){return Fa.error("Failed to observe fetch",t),o}}):Ia,ja=(t,e)=>{var i,r=null==un||null==(i=un.XMLHttpRequest)?void 0:i.prototype;if(!r)return Ia;var n=/* @__PURE__ */new WeakMap,s=Cn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{Ms.has(this)||n.set(this,Ma(i[0],i[1]))}catch(t){Fa.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=Cn(r,"send",i=>function(){var r,s;try{var a=n.get(this);if(a&&e()){var o=$s(),l=()=>Ra(Oa(()=>this.getResponseHeader("content-type"))),u=!1;r=()=>{this.removeEventListener("loadend",r),this.removeEventListener("readystatechange",s),u||l()||$a(t,a,this.status,o,e)},gi(this,"readystatechange",s=()=>{2===this.readyState&&(u=l())}),gi(this,"loadend",r)}}catch(t){Fa.error("Failed to observe XHR send",t)}try{for(var h=arguments.length,c=new Array(h),v=0;h>v;v++)c[v]=arguments[v];return i.apply(this,c)}catch(t){throw r&&this.removeEventListener("loadend",r),s&&this.removeEventListener("readystatechange",s),t}});return()=>{s(),a()}},La=class{constructor(t){this._instance=t,this.R=ci("[metrics]"),this.Ai=!1,this.um=!1,this.un=()=>{"hidden"===(null==vn?void 0:vn.visibilityState)&&this.flush()}}initialize(){this.onConfigChange(),this.Ai||this.um||null==vn||!vn.addEventListener||(gi(vn,"visibilitychange",this.un),this.um=!0)}onConfigChange(){var t;if(!this.Ai){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.hm?this.hm=(t=>{var e=!0,i=()=>e?(t=>{var e,i=null==(e=t.config.metrics)?void 0:e.network;return!0===i?{}:i||void 0})(t):void 0,r=Da(t,i),n=ja(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.hm&&(this.hm(),this.hm=void 0)}}Pf(){var t;if(!this.Ai){var e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;if(!this.Cf||this.Of!==e){var i;null==(i=this.Cf)||i.reset(),this.Of=e;var r=function(t){var e,i,r,n,s,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==a?void 0:a["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==a?void 0:a["service.version"])&&void 0!==i?i: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!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(s=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==s?s:1e3}}(e);f(null==e?void 0:e.flushIntervalMs)&&(r.flushIntervalMs=6e4),this.Cf=new ri(this.Rf(),r,this.R)}return this.Cf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.Pf())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.Pf())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.Pf())||r.histogram(t,e,i)}flush(t){if(!this.Cf)return Promise.resolve();if(t){var e=this.Cf.drainWindow();return e&&this.Lo(e,t),Promise.resolve()}return this.Cf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Cf)||t.reset()}dispose(){var t,e;this.Ai=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.un),this.um=!1,null==(t=this.hm)||t.call(this),this.hm=void 0,null==(e=this.Cf)||e.reset()}Rf(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Lo:t=>e.Lo(t),getLibraryId:()=>Os.LIB_NAME,getLibraryVersion:()=>Os.LIB_VERSION}}Lo(t,i){return new Promise(r=>{var n=!1,s=t=>{n||(n=!0,clearTimeout(a),r(t))},a=setTimeout(()=>s({kind:"retry-later",error:/* @__PURE__ */new Error("metrics request timed out")}),9e4);this._instance._send_request(e({method:"POST",url:this.dm(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},"hidden"===(null==vn?void 0:vn.visibilityState)&&{preferSyncCompression:!0},{fireCallbackOnDrop:!0,callback(t){var e,i=t.statusCode;s(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:/* @__PURE__ */new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:/* @__PURE__ */new Error("metrics request failed with status "+i)})}}))})}dm(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}},Na=/* @__PURE__ */new WeakMap,za=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),Ba={maxStringLength:2048,truncationSuffix:"..."},Ua={maxStringLength:2048,truncationSuffix:"..."};function Ha(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function qa(t,e){return{}.hasOwnProperty.call(t,e)}function Va(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function Wa(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?ke(r,Ba):r).slice(0,e)}}function Ga(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function Ka(t){return ke(t||"Unknown error",Ua).slice(0,2048)}function Ja(t,e){try{return Ka(e?function(t){try{if(!v(t)||!h(t.content))return;return t.content.filter(t=>v(t)&&"text"===t.type&&p(t.text)).map(t=>t.text).join(" ").trim()||void 0}catch(t){return}}(t):v(t)&&p(t.message)?t.message:p(t)?t:String(t))}catch(t){return"Unknown error"}}function Xa(t,i,r){return i.errorResult?[{type:"Error",value:r,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:t.buildProperties(i.error,{handled:!0}).$exception_list.map(t=>e({},t,{value:Ka(t.value)}))}function Ya(t,e){if(e)return"Error";try{if(!v(t))return"Error";var i=p(t.name)?t.name.trim():"",r=t.constructor;return i&&"Error"!==i||!c(r)||"Error"===r.name||(i=r.name),(i||"Error").slice(0,256)}catch(t){return"Error"}}function Za(t,e){return{message:Ja(t,e),type:Ya(t,e)}}var Qa=class{constructor(t){this._instance=t,this.vm=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.vm){var t=null==vn?void 0:vn.modelContext;if(t&&c(t.registerTool)){var e=Na.get(t);if(e)return e.instances.add(this._instance),void(this.vm=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;Cn(t,"registerTool",t=>{var e=t;return function(t){for(var r=t,s=arguments.length,a=new Array(s>1?s-1:0),o=1;s>o;o++)a[o-1]=arguments[o];try{r=n.fm(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(Na.set(t,i),this.vm=!0)}}}fm(t,i){if(!t||!c(t.execute))return t;var r=t.execute,n=this,s=function(t,i){var r={intent:!1,model:!1},n=t.inputSchema;if(!function(t){return!!f(t)||v(t)&&Object.keys(t).every(t=>za.has(t)||t.startsWith("x-"))&&!0!==t.additionalProperties&&!v(t.additionalProperties)&&(!t.type||"object"===t.type)&&(!t.properties||v(t.properties))&&(!t.required||h(t.required))}(n))return{tool:Va(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>qa(s,t)||h(null==n?void 0:n.required)&&n.required.includes(t);if(r.intent=i.intent&&!a("context"),r.model=i.model&&!a("llm_model"),!r.intent&&!r.model)return{tool:Va(t),injected:r};var o=e({},s),l=h(null==n?void 0:n.required)?[...n.required]:[];return r.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},l.includes("context")||l.push("context")),r.model&&(o.llm_model={type:"string",description:'The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the site developer\'s analytics.'},l.includes("llm_model")||l.push("llm_model")),{tool:Va(t,e({},n,{type:(null==n?void 0:n.type)||"object",properties:o,required:l})),injected:r}}(t,function(t){var e={intent:!1,model:!1};for(var i of t.instances){var r=Ha(i.config.capture_webmcp);e.intent||(e.intent=!0===(null==r?void 0:r.intent)),e.model||(e.model=!0===(null==r?void 0:r.model))}return e}(i)),a=s.tool,o=s.injected;return Object.defineProperty(a,"execute",{configurable:!0,enumerable:!0,writable:!0,value(){for(var s=/* @__PURE__ */new Date,l=arguments.length,u=new Array(l),h=0;l>h;h++)u[h]=arguments[h];var c,d,f=function(t,i){if(!v(t))return{};try{var r=i.intent?Wa(t.context,2048,!0):void 0,n=i.model?Wa(t.llm_model,256):void 0;return e({},r&&"{}"!==r?{intent:r}:{},n&&"unknown"!==n.toLowerCase()?{model:n}:{})}catch(t){return{}}}(u[0],o),p=function(t,i){var r=t[0];if(!v(r))return t;try{var n=i.intent&&qa(r,"context"),s=i.model&&qa(r,"llm_model");if(!n&&!s)return t;var a=e({},r);return n&&delete a.context,s&&delete a.llm_model,[a,...t.slice(1)]}catch(e){return t}}(u,o);try{c=r.apply(this===a?t:this,p)}catch(t){throw n.pm(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=Ga(t)?{error:t,errorResult:!0}:void 0;return n.pm(i,a,s,e,f),t},t=>{throw n.pm(i,a,s,{error:t,errorResult:!1},f),t});var g=Ga(c)?{error:c,errorResult:!0}:void 0;return n.pm(i,a,s,g,f),c}}),a}pm(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=Ha(l.config.capture_webmcp);if(h){n&&!a&&(a=Za(n.error,n.errorResult));try{l.capture("$mcp_tool_call",e({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{},h.intent&&s.intent?{$mcp_intent:s.intent,$mcp_intent_source:"context_parameter"}:{},h.model&&s.model?{$mcp_llm_model:s.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:r})}catch(t){continue}if(n&&a&&l.exceptions&&null!=(u=l.exceptionObserver)&&u.isEnabled)try{var c={$exception_list:Xa(l.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}},to={featureFlags:ra,sessionRecording:ts,autocapture:Nr,historyAutocapture:Rn,heatmaps:rs,deadClicksAutocapture:_n,webVitalsAutocapture:qn,exceptionObserver:wn,exceptions:ha,productTours:as,siteApps:us,surveys:Ds,tracingHeaders:Mn,toolbar:zs,experiments:pa,conversations:ya,logs:Ta,metrics:La,webMCP:Qa},eo={featureFlags:ra},io={sessionRecording:ts},ro={autocapture:Nr,historyAutocapture:Rn,heatmaps:rs,deadClicksAutocapture:_n,webVitalsAutocapture:qn},no={exceptionObserver:wn,exceptions:ha},so={productTours:as,featureFlags:ra},ao={siteApps:us},oo={surveys:Ds,featureFlags:ra},lo={tracingHeaders:Mn},uo={toolbar:zs},ho={experiments:pa,featureFlags:ra},co={conversations:ya},vo={logs:Ta},fo={metrics:La},po={webMCP:Qa};export{to as AllExtensions,ro as AnalyticsExtensions,co as ConversationsExtensions,no as ErrorTrackingExtensions,ho as ExperimentsExtensions,eo as FeatureFlagsExtensions,vo as LogsExtensions,fo as MetricsExtensions,so as ProductToursExtensions,io as SessionReplayExtensions,ao as SiteAppsExtensions,oo as SurveysExtensions,uo as ToolbarExtensions,lo as TracingExtensions,po as WebMCPExtensions};
|
|
1
|
+
var t=["$set_once","$set"];function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},e.apply(null,arguments)}function i(t,e,i,r,n,s,a){try{var o=t[s](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,n)}function r(t){return function(){var e=this,r=arguments;return new Promise(function(n,s){var a=t.apply(e,r);function o(t){i(a,n,s,o,l,"next",t)}function l(t){i(a,n,s,o,l,"throw",t)}o(void 0)})}}var n=/*#__PURE__*/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.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function s(t,e){return-1!==t.indexOf(e)}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)},c=t=>"function"==typeof t,v=t=>t===Object(t)&&!h(t),d=t=>{if(v(t)){for(var e in t)if(l.call(t,e))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,m=t=>null===t,y=t=>f(t)||m(t),_=t=>"[object Number]"==u.call(t)&&t==t,b=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function x(t,e){return{}.toString.call(t)==="[object "+e+"]"}function S(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,e){try{return t instanceof e}catch(t){return!1}}var A=["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","lightpanda","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"],T=/* @__PURE__ */new Map,F=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=function(t,e){for(var i="",r=0;e.length>r;r++){var n=e[r];i+=n.length+":"+n}return t.length+":"+t+"|"+e.length+":"+i}(t,e),r=T.get(i);if(void 0!==r)return r;var n=t.toLowerCase(),s=A.concat(e).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>T.size||T.clear(),T.set(i,s),s};function P(t,e,i,r,n){return e>i&&(r.warn("min cannot be greater than max."),e=i),_(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),P(null!=n?n:i,e,i,r))}var C=class{constructor(t){this.C={},this.I=t.I,this.A=P(t.bucketSize,0,100,t.R),this.O=P(t.refillRate,0,this.A,t.R),this.$=P(t.refillInterval,0,864e5,t.R)}F(t,e){var i=Math.floor((e-t.lastAccess)/this.$);i>0&&(t.tokens=Math.min(t.tokens+i*this.O,this.A),t.lastAccess=t.lastAccess+i*this.$)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),n=this.C[r];return n?this.F(n,i):this.C[r]=n={tokens:this.A,lastAccess:i},0===n.tokens||(n.tokens--,0===n.tokens&&(null==(e=this.I)||e.call(this,t)),0===n.tokens)}stop(){this.C={}}},R="Android",O="Nintendo",M="PlayStation",I="Windows",D=/* @__PURE__ */new RegExp("BlackBerry|PlayBook|BB10","i"),j={"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"},L=[[/* @__PURE__ */new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>["Xbox",t&&t[1]||""]],[/* @__PURE__ */new RegExp(O,"i"),[O,""]],[/* @__PURE__ */new RegExp(M,"i"),[M,""]],[D,["BlackBerry",""]],[/* @__PURE__ */new RegExp(I,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return["Windows Phone",""];if(new RegExp("Mobile").test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=j[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[I,r]}return[I,""]}],[/((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 e="";return t&&t.length>=3&&(e=f(t[2])?t[3]:t[2]),["watchOS",e]}],[/* @__PURE__ */new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[R,[t[2],t[3],t[4]||"0"].join(".")]:[R,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],N="[Truncated]",z="[Unserializable]";function B(t){for(var e="",i=0;t.length>i;i++){var r=t.charCodeAt(i);if(55296>r||r>56319)e+=56320>r||r>57343?t[i]:"�";else{var n=t.charCodeAt(i+1);56320>n||n>57343?e+="�":(e+=t[i]+t[i+1],i++)}}return e}function U(t,e){if(!e)return t;var i=[];try{i=Object.keys(e)}catch(t){i=[]}for(var r of i){var n=void 0;try{n=e[r]}catch(t){n=z}Object.defineProperty(t,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;var H,q,V,W,G=3e5,K=class{record(t){if("too-large"!==t.kind)if("retry-later"===t.kind){if(t.retryAfterMs){var e=this.isOpen(),i=Date.now(),r=Math.min(t.retryAfterMs,G);if(!e)return this.ts=i,void(this.es=i+r);this.es=Math.max(this.es,Math.min(i+r,this.ts+G))}}else this.reset()}remainingMs(){var t=Date.now();if(this.ts-5e3>t)return this.reset(),0;var e=Math.min(G,Math.max(0,this.es-t));return 0===e&&this.reset(),e}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};function J(t){return t?t.split("#")[0]:t}function X(t){try{return t()}catch(t){return}}function Y(t,e){var i=setTimeout(t,e);return null!=i&&i.unref&&(null==i||i.unref()),i}function Z(t,e,i){return Q.apply(this,arguments)}function Q(){return(Q=r(function*(t,e,i){var r;try{return yield Promise.race([t,new Promise((t,n)=>{r=Y(()=>{try{null==i||i(),t()}catch(t){n(t)}},e)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function tt(t){var i=globalThis._posthogChunkIds,r=globalThis._debugIds;if(i||r){var n=i?Object.keys(i):[],s=r?Object.keys(r):[];if(W&&et(i,n,q)&&et(r,s,V))return W;q=i?e({},i):void 0,V=r?e({},r):void 0,W={},null!=H||(H={});var a=(e,i)=>{for(var r of e){var n,s=i[r];if(s){var a=null==(n=H)?void 0:n[r];if(a)W[a]=s;else for(var o=t(r),l=o.length-1;l>=0;l--){var u,h=null==(u=o[l])?void 0:u.filename;if(h){W[h]=s,H[r]=h;break}}}}};return r&&a(s,r),i&&a(n,i),W}}function et(t,e,i){return t&&i?e.length===Object.keys(i).length&&e.every(e=>t[e]===i[e]):t===i}var it=class{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),n=this.buildParsingContext(e),s=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(s,i),$exception_level:"error"}}modifyFrames(t){var e=this;return r(function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&h(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t})()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,i){var r,n,s;if(null!=t.cause&&(n=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack)try{s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)}catch(t){}return e({},t,{cause:n,stack:s,errors:null==(r=t.errors)?void 0:r.map(t=>this.parseStacktrace(t,i))})}applyChunkIds(t,e){return t.map(t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return r(function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i})()}convertToExceptionList(t,i){var r=[],n=(t,s,a)=>{var o=r.length,l=void 0===s?e({type:"string"==typeof i.type&&i.type.length>0?i.type:"generic"},"boolean"==typeof i.handled?{handled:i.handled}:void 0===i.handled?{handled:!0}:{},{synthetic:"boolean"==typeof i.synthetic?i.synthetic:t.synthetic,exception_id:o}):{type:"chained",source:a,synthetic:t.synthetic,exception_id:o,parent_id:s},u={type:t.type,value:t.value,mechanism:l};for(var h of(t.stack&&(u.stacktrace={type:"raw",frames:t.stack}),r.push(u),t.cause&&n(t.cause,o,"cause"),null!==(c=t.errors)&&void 0!==c?c:[])){var c;n(h,o,"member")}};return n(t),r}buildParsingContext(t){var e;return{chunkIdMap:tt(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}getAggregateErrors(t){try{if(S(t))for(var e=Object.getPrototypeOf(t),i=0;e&&100>i;i++){var r,n=null==(r=Object.getOwnPropertyDescriptor(e,"constructor"))?void 0:r.value;if("function"==typeof n&&"AggregateError"===n.name){var s=t.errors;return h(s)?s:void 0}e=Object.getPrototypeOf(e)}}catch(t){}}buildCoercingContext(t,i,r){var n=this;void 0===r&&(r=0);var s=0,a=0,o=!1,l=/* @__PURE__ */new Set,u=[],h={},c=function(t,i,r){void 0===r&&(r=0);var c=v(i,r),d=c.apply;if(c.apply=e=>{u.push(t);try{return d(e)}finally{u.pop()}},r>4||r>0&&-1!==u.indexOf(t))return n.coerceFallback(c);var f="object"==typeof t&&null!==t||"function"==typeof t;if(!(0===r&&s>=50||f&&l.has(t))){f&&l.add(t),0===r&&s++;var p,g,m=n.getAggregateErrors(t);o||(o=!!m);try{if(!(p=n.applyCoercers(t,c)))throw h}catch(t){if(t===h)return void(0===r&&s--);if(!o)throw t;p=n.coerceFallback(c)}if(!m||s>=50)return p;try{g=m.length}catch(t){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;for(var y=[],_=0;50>s&&1e3>a&&g>_;_++){a++;var b=void 0;try{b=c.next(m[_])}catch(t){s++,b=n.coerceFallback(v(i+1))}b&&y.push(b)}return e({},p,{errors:y})}},v=function(r,n){return void 0===n&&(n=0),e({},i,{syntheticException:0==r?i.syntheticException:void 0,mechanism:0==r?t:{},apply(t){var e=c(t,r,n+1);if(!e)throw h;return e},next:t=>c(t,r+1)})},d=v(r);return e({},d,{apply:t=>{var e;return null!==(e=c(t,r))&&void 0!==e?e:this.coerceFallback(d)}})}},rt=/^([a-z][a-z0-9.+-]+):/i,nt=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function st(t){if(!t||"<anonymous>"===t)return!1;var e=rt.exec(t);return!e||nt.includes(e[1].toLowerCase())}function at(t,e,i,r,n){var s={platform:t,filename:e,function:"<anonymous>"===i?"?":i,in_app:st(e)};return f(r)||(s.lineno=r),f(n)||(s.colno=n),s}var ot=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:"?",i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},lt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ut=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ht=/\((\S*)(?::(\d+))(?::(\d+))\)/,ct=(t,e)=>{var i=lt.exec(t);if(i)return at(e,i[1],"?",+i[2],+i[3]);var r=ut.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var n=ht.exec(r[2]);n&&(r[2]=n[1],r[3]=n[2],r[4]=n[3])}var s=ot(r[1]||"?",r[2]);return at(e,s[1],s[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},vt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,dt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ft=(t,e)=>{var i=vt.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=dt.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var n=i[3],s=i[1]||"?",a=ot(s,n);return at(e,n=a[1],s=a[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},pt=/\(error: (.*)\)/;function gt(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function mt(t){for(var e=1;10>=e;e++){var i=t.length-2*e;if(0>i)break;for(var r=!0,n=0;e>n;n++)if(!gt(t[i+n],t[i+e+n])){r=!1;break}if(r){for(var s=0;e>s;s++)t[i+s]=t[i+e+s];return t.length=i+e,{start:i,length:e}}}}function yt(t,e){var i=e.start+e.length,r=bt(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function _t(t,e){for(var i=e.start;i>0&>(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function bt(t,e){for(var i=e.start+e.length,r=i;t.length>r&>(t[r],t[r-e.length]);)r++;return r-i}function wt(t,e){var i=e[0],r=t.length-(i?_t(t,i):0);for(var n of e)r-=bt(t,n);return r}function xt(t,e,i){for(var r=0;t.length>r;r++){var n=t[(e+r)%t.length],s=t[(i+r)%t.length];if(n!==s)return s>n}return!1}var St=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=p(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return x(t,"DOMException")}isDOMError(t){return x(t,"DOMError")}},kt=class{match(t){return S(t)}coerce(t,e){var i,r=this.getStack(t),n=void 0===r?null==(i=e.syntheticException)?void 0:i.stack:void 0,s=!!n;return{type:this.getType(t),value:this.getMessage(t,e),stack:null!=r?r:n,cause:t.cause?e.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){try{var e=t.stacktrace;if("string"==typeof e&&e.length>0)return e;var i=t.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(t){return}}},Et=class{match(t){return!!x(t,"ErrorEvent")&&(null!=t.error||this.Sr(t))}coerce(t,i){var r;if(null!=t.error)return i.apply(t.error);var n=i.apply(t.message);return e({},n,{stack:null!==(r=this._r(t))&&void 0!==r?r:n.stack,synthetic:!0})}Sr(t){return p(t.message)&&t.message.length>0}_r(t){var e,i,r=t,n=null!==(e=r.lineno)&&void 0!==e?e:0,s=null!==(i=r.colno)&&void 0!==i?i:0;if(p(r.filename)&&0!==r.filename.length&&0!==n)return"Error\n at "+r.filename+":"+n+":"+s}},At=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Tt=class{match(t){return"string"==typeof t}coerce(t,e){var i,r=this.getInfos(t),n=r[0],s=r[1];return{type:null!=n?n:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(At);return r&&(e=r[1],i=r[2]),[e,i]}},Ft=["fatal","error","warning","log","info","debug"];function Pt(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";var r="";for(var n of i){var s=r?r+", "+n:n;if(s.length>e)break;r=s}return r}var Ct=class{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,n=this.getErrorPropertyFromObject(t);return n?e.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.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 e="name"in t?t.name:void 0;return p(e)&&!g(e)?e:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+Pt(t)}isSeverityLevel(t){return p(t)&&!g(t)&&Ft.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 e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(S(i))return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}},Rt=class{match(t){return k(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Pt(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}},Ot=class{match(t){return w(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}},Mt=class{match(t){return x(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return w(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}},$t="$message",It="$timestamp",Dt=/* @__PURE__ */new Set([$t,It]),jt={enabled:!0,max_bytes:32768};function Lt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:jt.enabled,max_bytes:zt(t.max_bytes,jt.max_bytes)}:e({},jt)}var Nt=class{constructor(t){this.ns=[],this.ss=0,this.Br=Lt(t)}setConfig(t){this.Br=Lt(t),this.rs()}add(t){var e=function(t){var e,i,r;try{r=[],e=null!==(i=JSON.stringify(t,function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(e))return"[Circular]";r.push(e)}return e}}))&&void 0!==i?i:"null"}catch(t){return}try{var n=JSON.parse(e);if(!v(n))return;var s=n,a=s[$t],o=s[It];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!_(o))return;return{step:s,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Br.max_bytes||(this.ns.push({step:e.step,bytes:i}),this.ss+=i,this.rs())}}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Br.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function zt(t,e){if(!_(t)||1/0===t||-1/0===t)return e;var i=Math.floor(t);return 0>i?e:i}var Bt=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function Ut(t){return"string"==typeof t||t}function Ht(t){return"string"==typeof t?t:void 0}var qt="[redacted]",Vt=/^[A-Za-z0-9+/\n\r]+=*$/,Wt=/^[A-Za-z0-9_-]+={0,2}$/,Gt=/[-_]/,Kt=/^data:[^,\s]*;base64,/i,Jt=/^[A-Za-z0-9+/_-]+={0,2}$/,Xt=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Yt=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Zt=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Qt=/[\s<>"]/,te=/* @__PURE__ */(()=>new RegExp(Zt.source,"i"))(),ee=/[a-z][a-z0-9+.-]{0,63}:\/\//i,ie=/* @__PURE__ */(()=>new RegExp("^"+ee.source,"i"))(),re=/* @__PURE__ */(()=>new RegExp(ee.source,"gi"))(),ne=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,se=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ae=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,oe=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,le=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,ue=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,he=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,ce=/\d+/g,ve=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,de=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function fe(t){return function(t){return Yt.test(t)}(t)||ne.test(t)||se.test(t)}function pe(t){return t.split("&",129).length>128}function ge(t,e,i){return fe(t)||e.includes(";")&&function(t){return t.split(";").some(t=>fe(t.split("=",1)[0]))}(e)?qt:te.test(e)?i?xe(e,{allowNestedUrls:!1,stripPunctuation:!0}):qt:e}function me(t,e){var i=new URLSearchParams,r=!1,n=!1;for(var s of new URLSearchParams(t)){var a=s[0],o=s[1],l=Se(a),u=Se(o);r||(r=l!==a||u!==o);var h=ge(l,u,e);r||(r=h!==u),n=fe(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function ye(t,e){if(!t.includes("="))return{value:_e(t,e),lastFieldSensitive:!1};var i=me(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function _e(t,e){return e?xe(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function be(t,e,i){return"#"===t?!e.fragment&&(e.fragment=!0):"?"===t&&(e.fragment?"="!==i&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function we(t,e){var i;if(t.length>8192&&ie.test(t))return qt;var r,n=e.stripPunctuation?function(t){for(var e=t.length;e>0&&".,;:!?)]}'".includes(t[e-1]);)e--;return{address:t.slice(0,e),suffix:t.slice(e)}}(t):{address:t,suffix:""},s=n.address,a=n.suffix;try{r=new URL(s)}catch(t){return qt+a}var o=r.search.slice(1),l=""!==r.hash,u=function(t){var e=t.slice(1),i=e.indexOf("?");return 0>i?{head:e,tail:null}:{head:e.slice(0,i),tail:e.slice(i+1)}}(r.hash);if(pe(o)||pe(u.head)||pe(null!==(i=u.tail)&&void 0!==i?i:""))return qt+a;var h=!1;(r.username||r.password)&&(r.username=qt,r.password="",h=!0);var c=me(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=ye(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":qt,lastFieldSensitive:!0}:ye(v,e.allowNestedUrls)),p=null===f?d.value:d.value+"?"+f.value;p!==r.hash.slice(1)&&(r.hash=p,h=!0);var g=l?null!=f?f:d:c;return(h?Se(r.toString()):s)+(g.lastFieldSensitive?"":a)}function xe(t,i){return t.replace(Zt,r=>function(t,i){var r=function(t){if(!t.includes("://"))return[];for(var e=[...t.matchAll(re)].map(t=>t.index),i=[],r={query:!1,fragment:!1,fragmentQuery:!1},n=0,s=!1,a="",o=0;t.length>o&&e.length>n;o++){e[n]===o&&(o>0&&"="!==a&&i.push(o),n++);var l=t[o];be(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return we(t,i);var n="",s=0;for(var a of r)n+=we(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+we(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function Se(t){return t.replace(Xt,qt)}function ke(t,e){return function(t){return t.length>=10240&&(Vt.test(t)||function(t){var e,i=Kt.exec(t);if(!i)return!1;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Jt.test(e.replace(/[\r\n]/g,""))}(t)||Gt.test(t)&&Wt.test(t))}(t)?"[binary data redacted - not supported by PostHog MCP analytics]":function(t,e,i){var r=4*i.maxStringLength;if(t.length>r){var n=e(t.slice(0,function(t,e){for(var i=e;i>0&&!Qt.test(t[i-1]);)i--;return i}(t,r)));if(n.length>=2*i.maxStringLength)return n+i.truncationSuffix}return e(t)}(t,t=>function(t){return xe(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(ae," ");return(e=(e=(e=function(t){for(var e="",i=0,r=Pe(t,0);null!==r;r=Pe(t,r[1]))e+=t.slice(i,r[0])+Ce(t.slice(r[0],r[1])),i=r[1];return e+t.slice(i)}(e=(e=(e=e.replace(oe,qt)).replace(le,qt)).replace(ue,"$1"+qt))).replace(he,qt)).replace(ve,"$1"+qt)).replace(de,"$1"+qt)}(Se(t))),e)}function Ee(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;if(0>n||n>9)return!1;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function Ae(t,e){var i=t.charCodeAt(e);return i>=48&&57>=i}function Te(t,e){var i=t.charCodeAt(e);return Ae(t,e)||95===i||i>=65&&90>=i||i>=97&&122>=i}function Fe(t,e){for(var i=e;Ae(t,i);)i++;return i}function Pe(t,e){for(var i=e;t.length>i;i++)if(Ae(t,i)&&!Te(t,i-1)){for(var r=0,n=-1,s=i;;){var a=Fe(t,s);if(13>(r+=a-s)||Te(t,a)||(n=a),s=a+1,!" ./-".includes(t.charAt(a))||!Ae(t,s))break}if(n>=0)return[i,n];i=s-1}return null}function Ce(t){for(var e=[],i=ce.exec(t);null!==i;i=ce.exec(t))e.push({digits:i[0],start:i.index,end:i.index+i[0].length});for(var r="",n=0,s=0;e.length>s;){for(var a="",o=-1,l=s;e.length>l&&19>=(a+=e[l].digits).length;l++)a.length>=13&&Ee(a)&&(o=l);0>o?s++:(r+=t.slice(n,e[s].start)+qt,n=e[o].end,s=o+1)}return r+t.slice(n)}var Re={}.propertyIsEnumerable;function Oe(t,e){try{return Ie(t,e,{ancestors:/* @__PURE__ */new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Me(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:N};if(i.remainingNodes--,b(t))return{boolValue:t};if("bigint"==typeof t)return function(t,e){var i=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==e||e.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(t,e);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 n=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==e||e.debug("Attribute "+n+" is outside the int64 range; encoding it as a string"),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:B(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(i.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:N};if(t instanceof Date){var s=t.getTime(),a=Number.isFinite(s)?t.toISOString():String(t);return{stringValue:"string"==typeof a?B(a):String(a)}}i.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Me(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:$e(t,e,i,r+1)}}:{kvlistValue:{values:Ie(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:B(String(t))}}function $e(t,e,i,r){for(var n=[],s=Math.min(t.length,1e3),a=0;s>a&&i.remainingNodes>0;a++)try{var o=a in t?t[a]:void 0;if(y(o))continue;n.push(Me(o,e,i,r))}catch(t){n.push({stringValue:z})}return t.length>a&&n.push({stringValue:N}),n}function Ie(t,e,i,r){var n=[];for(var s in t)if(Re.call(t,s)){if(!s){null==e||e.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[s];if(m(a)||f(a))continue;n.push({key:B(s),value:Me(a,e,i,r)})}catch(t){n.push({key:B(s),value:{stringValue:z}})}}return n}function De(t,i,r){return e({},U({},t.resourceAttributes),{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":r})}var je=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Le(t,e){var i=U({},t),r={};for(var n of je)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Oe(i,e),...Oe(r,e)]}var Ne={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};var ze={text:"INFO",number:9},Be={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:ze,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function Ue(t){try{return B(String(t))}catch(t){return z}}function He(t,i,r,n){var s,a=Be[t.level||"info"]||ze,o=a.text,l=a.number,u=(void 0===(s=_(n)?n:void 0)&&(s=Date.now()),String(s)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),y(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),y(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var c=e({},h),v=t.attributes;if(v){var d=[];try{d=Object.keys(v)}catch(t){d=[]}for(var p of d){var g=void 0;try{g=v[p]}catch(t){g=z}Object.defineProperty(c,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Ue(t.body)},attributes:Oe(c,r)};return t.trace_id&&(m.traceId=t.trace_id),t.span_id&&(m.spanId=t.span_id),f(t.trace_flags)||(m.flags=t.trace_flags),m}function qe(t,e,i){return De(t,e,i)}function Ve(t,e,i,r){return{resourceLogs:[{resource:{attributes:Le(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var We=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=Y(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Ge(){return.75+.5*Math.random()}function Ke(t,e,i,r){var n=t*Math.pow(2,Math.min(Math.max(0,e-1),6));return Math.round((void 0===r?n:Math.min(n,Math.max(r,t)))*i)}var Je=class{constructor(t,e,i,r,n,s,a,o){var l;void 0===s&&(s=()=>Promise.resolve()),void 0===o&&(o=()=>!1),this._instance=t,this.Br=e,this.R=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=o,this.gs=new We(()=>this.ys()),this.bs=null,this._s=0,this.ws=0,this.ks=null,this.Ss=new K,this.xs=0,this.$s=1,this.Cs=0,this.Ts=0,this.Ms=!1,this.Is=e.maxBufferSize,this.Es=Math.max(null!==(l=e.maxQueueSize)&&void 0!==l?l:e.maxBufferSize,e.maxBufferSize),this.As=e.flushIntervalMs,this.Rs=e.maxBatchRecordsPerPost,this.Ps=e.rateCapWindowMs,this.Os=e.maxLogsPerInterval}clearQueue(){this.ws++,this._instance.setPersistedProperty(n.LogsQueue,[])}get throttled(){return this.Ss.isOpen()}reset(){this.gs.clear(),this.Cs=0,this.Ts=0,this.Ms=!1,this.xs=0,this.$s=1,this.Ss.reset(),this.Rs=this.Br.maxBatchRecordsPerPost}onReconnect(){this.xs=0,this.$s=1,this.Ss.isOpen()?this.Fs()&&this.Ls():this.ys()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ds(t);if(null!==r)if(r.body){if(this.Ns()){var n={record:He(r,null!==(i=null==e?void 0:e.context)&&void 0!==i?i:this.hs(),this.R,null==e?void 0:e.occurredAtMs)};this.ds(()=>this.js(n))}}else this.R.info("Log was rejected in beforeSend function")}}Ds(t){var e=this.Br.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Log was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for log:",t),null}return r}Ns(){if(void 0===this.Os)return!0;var t=Date.now(),e=t-this.Cs;return this.Ps>e&&e>=0||(this.Cs=t,this.Ts=0,this.Ms=!1),this.Os>this.Ts?(this.Ts++,!0):(this.Ms||(this.R.warn("captureLog dropping logs: exceeded "+this.Os+" logs per "+this.Ps+"ms"),this.Ms=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.bs||(t.bs=t.qs().finally(()=>{t.bs=null})),t.bs})()}qs(){var t=this;return r(function*(){var e;if(t.gs.clear(),!t.Bs()){var i=null!==(e=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var a,o;if(t.Bs())return;var l=t.ws;t._s=0;var u=Math.min(i.length,t.Rs),h=i.slice(0,u),c=Ve(h.map(t=>t.record),t.zs(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.Hs(c);if(t.ws!==l)return;if("too-large"===v.kind&&h.length>1)t.Rs=Math.max(1,Math.floor(h.length/2)),t.R.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Rs);else{if(t.Ss.record(v),t.gs.pending&&t.gs.arm(Math.max(t.As,t.Ss.remainingMs())),"retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.R.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===v.kind&&t.Br.maxBatchRecordsPerPost>t.Rs&&(t.Rs=Math.min(t.Br.maxBatchRecordsPerPost,t.Rs+1)),yield t.Us(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}}})()}Bs(){return!!this.ps()&&(this.Fs()&&this.clearQueue(),!0)}Us(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e._s),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}zs(){return qe(this.Br,this._instance.getLibraryId(),this._instance.getLibraryVersion())}js(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Es>i.length||(i.shift(),this._s++,this.R.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Is>i.length||this.Ss.isOpen()?this.Ls():this.ys()}}Ls(){this.gs.pending||this.gs.arm(Math.max(this.As,this.Ss.remainingMs()))}Ws(){return Math.max(Ke(this.As,this.xs,this.$s,3e4),this.Ss.remainingMs())}Fs(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.gs.clear();var i=e.flush().catch(()=>{});void 0!==t?yield Z(i,t):yield i})()}flushWithTimeout(t){var e=this;return r(function*(){var i=e.flush();yield Z(i,t,()=>{i.catch(()=>{})})})()}flushInBackground(){if(this.ks)return this.ks;var t=this.flush().then(()=>{this.xs=0,this.$s=1},t=>{this.xs++,this.$s=Ge(),this.R.error("PostHog logs flush failed:",t)}).finally(()=>{this.ks===t&&(this.ks=null),!this._instance.isDisabled&&this.Fs()&&this.gs.armNoEarlierThan(this.Ws())});return this.ks=t,t}ys(){this.flushInBackground()}},Xe=/^[0-9a-f]+$/;function Ye(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Xe.test(t)}var Ze=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Qe="00",ti=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ei(t){return String(t)+"000000"}function ii(t,e,i,r){var n="";return r&&(n=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+n}var ri=class{constructor(t,e,i){this._instance=t,this.Br=e,this.R=i,this.Vs=/* @__PURE__ */new Map,this.gs=new We(()=>this.flush().catch(t=>{this.R.error("Metrics flush failed:",t)})),this.bs=null,this.Gs=null,this.Qs=!1,this.Js=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ks=/* @__PURE__ */new Map,this.Ys=/* @__PURE__ */new Set,this.Xs=!1,this.Ss=new K,this.xs=0,this.$s=1,this.$o=0}count(t,e,i){void 0===e&&(e=1),this.Co({name:t,type:"count",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(t,e,i){this.Co({name:t,type:"gauge",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(t,e,i){this.Co({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:h(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var t=this,e=this.bs,i=/* @__PURE__ */function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.To()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.bs===i&&(this.bs=null)});return this.bs=i,i}flushCoalesced(){var t,e;return this.Mo()?null!==(t=this.bs)&&void 0!==t?t:Promise.resolve():(this.Gs||(this.Gs=(null!==(e=this.bs)&&void 0!==e?e:Promise.resolve()).catch(()=>{}).then(()=>(this.Gs=null,this.Mo()?void 0:this.flush()))),this.Gs)}Mo(){return this.xs>0||this.Ss.remainingMs()>0}drainWindow(){if(0===this.Vs.size)return null;var t=this.Vs;return this.Io(),this.Eo(t)}reset(){this.$o++,this.Ss.reset(),this.xs=0,this.$s=1,this.gs.clear(),this.bs=null,this.Gs=null,this.Io(),this.Ks=/* @__PURE__ */new Map,this.Xs=!1}Io(){this.Vs=/* @__PURE__ */new Map,this.Qs=!1,this.Js=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ys=/* @__PURE__ */new Set}Co(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ds(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type||"gauge"===i.type||"histogram"===i.type)if("count"===i.type&&0>i.value)this.R.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,n;try{r=i.attributes?e({},i.attributes):void 0,n=ii(i.type,i.name,i.unit,r)}catch(t){return void this.R.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s,a=this.Vs.get(n);if((a||this.Ao())&&("histogram"!==i.type||(s=this.Ro(i.name,i.unit,i.bounds)))){a||(a={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now(),hist:s&&si(s)},this.Vs.set(n,a));var o=this.Js.get(i.name);void 0===o?this.Js.set(i.name,i.type):o===i.type||this.Zs.has(i.name)||(this.Zs.add(i.name),this.R.warn("Metric name '"+i.name+"' is already used as a "+o+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Po(a,i.value);var l=this.Oo();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Ls()}}else this.R.warn("Dropping metric '"+i.name+"': unknown type '"+String(i.type)+"'");else this.R.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.R.warn("Dropping metric with empty name")}}Oo(){try{var t,e,i=(r=null==(t=(e=this._instance).getActiveSpan)||null==(t=t.call(e))?void 0:t.traceparent(),s=function(t){if("string"==typeof t){var e=Ze.exec(t.trim());if(e){var i=e[1],r=e[2],n=e[3],s=e[4];if("ff"!==i&&("00"!==i||!e[5])&&function(t){return Ye(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Ye(t,16,"0000000000000000")}(n))return{version:i,traceId:r,spanId:n,flags:s}}}}(r),s&&{traceId:s.traceId,spanId:s.spanId,flags:(n=s.flags,1&parseInt(n,16)?"01":Qe)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}Ao(){return this.Br.maxSeriesPerFlush>this.Vs.size||(this.Qs||(this.Qs=!0,this.R.warn("Metric series cap reached ("+this.Br.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ro(t,e,i){if(void 0===i||function(t){if(!h(t)||0===t.length)return!1;for(var e=0;t.length>e;e++)if(!Number.isFinite(t[e])||e>0&&t[e-1]>=t[e])return!1;return!0}(i)){var r=ii("histogram",t,e,void 0),n=this.Ks.get(r);if(n)return this.Fo(t,r,n,i),n;if(this.Ks.size>=this.Br.maxSeriesPerFlush){if(this.Xs||(this.Xs=!0,this.R.warn("Histogram bounds limit reached ("+this.Br.maxSeriesPerFlush+" distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.")),i&&!ni(i,ti))return;return ti}var s=i?i.slice():ti;return this.Ks.set(r,s),s}this.R.warn("Dropping histogram '"+t+"': bounds must be a non-empty array of finite, strictly increasing numbers")}Fo(t,e,i,r){ni(i,null!=r?r:ti)||this.Ys.has(e)||(this.Ys.add(e),this.R.warn("Histogram '"+t+"' already uses the bounds ["+i.join(", ")+"]; samples that pass different bounds are recorded in those buckets."))}Po(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,r.bounds)]+=1}}Ds(t){var e=this.Br.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Metric was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for metric:",t),null}return r}Ls(){this.gs.pending||this.gs.arm(this.Ws())}Ws(){return Math.max(Ke(this.Br.flushIntervalMs,this.xs,this.$s,3e4),this.Ss.remainingMs())}To(){var t=this;return r(function*(){if(t.gs.clear(),0!==t.Vs.size){var e=t.Vs;t.Io();var i=t.$o,r=yield t._instance.Lo(t.Eo(e));if(i===t.$o)switch(t.Ss.record(r),"retry-later"===r.kind?(t.xs++,t.$s=Ge()):(t.xs=0,t.$s=1),t.gs.pending&&t.gs.arm(t.Ws()),r.kind){case"ok":return;case"retry-later":return t.Do(e),void t.gs.armNoEarlierThan(t.Ws());case"too-large":return void t.R.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.R.error("Failed to send metrics batch:",r.error)}}})()}Eo(t){return e=this.No(t),i=function(t,e,i){return De(t,e,i)}(this.Br,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Le(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}No(t){var i=ei(Date.now()),r=/* @__PURE__ */new Map;for(var n of t.values()){var s,a=ii(n.type,n.name,n.unit,void 0),o=r.get(a);o||(o=e({name:n.name},n.unit&&{unit:n.unit}),"count"===n.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===n.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Oe(null!==(s=n.attributes)&&void 0!==s?s:{},this.R),u=ei(n.windowStartMs),h=ai(n.exemplar);if("count"===n.type){var c,v=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(c=n.total)&&void 0!==c?c:0},h);o.sum.dataPoints.push(v)}else if("gauge"===n.type){var d,f=e({attributes:l,timeUnixNano:i,asDouble:null!==(d=n.last)&&void 0!==d?d:0},h);o.gauge.dataPoints.push(f)}else{var p=n.hist,g=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,count:p.count,sum:p.sum,min:p.min,max:p.max,bucketCounts:p.bucketCounts,explicitBounds:p.bounds},h);o.histogram.dataPoints.push(g)}}return Array.from(r.values())}Do(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Vs.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,a.windowStartMs),o.exemplar=null!==(n=o.exemplar)&&void 0!==n?n:a.exemplar,o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=a.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":var l=o.hist,u=a.hist;l.count+=u.count,l.sum+=u.sum,l.min=Math.min(l.min,u.min),l.max=Math.max(l.max,u.max);for(var h=0;l.bucketCounts.length>h;h++)l.bucketCounts[h]+=u.bucketCounts[h]}else this.Ao()&&this.Vs.set(s,a)}}};function ni(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(var i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}function si(t){return{bounds:t,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(t.length+1).fill(0)}}function ai(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:ei(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var oi="0.12.2",li={DEBUG:!1,LIB_VERSION:oi,LIB_NAME:"browser-common",JS_SDK_VERSION:oi},ui=function(t,e){var i=(void 0===e?{}:e).debugEnabled,r={N(e){var r;try{r=typeof window>"u"?void 0:window}catch(t){return}for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;n>a;a++)s[a-1]=arguments[a];r&&(li.DEBUG||r.POSTHOG_DEBUG||i)&&!f(r.console)&&r.console&&("__rrweb_original__"in r.console[e]?r.console[e].__rrweb_original__:r.console[e])(t,...s)},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>ui(t+" "+e,i)};return r},hi=/* @__PURE__ */ui("[PostHog.js]"),ci=(t,e)=>hi.createLogger(t,e);function vi(t,e){h(t)&&t.forEach(e)}function di(t,e){if(!y(t))if(h(t))t.forEach(e);else if(t instanceof FormData)t.forEach((t,i)=>e(t,i));else for(var i in t)l.call(t,i)&&e(t[i],i)}var fi=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var n of i)for(var s in n)void 0!==n[s]&&(t[s]=n[s]);return t};function pi(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}function gi(t,e,i,r){var n=null!=r?r:{},s=n.capture,a=n.passive;null==t||t.addEventListener(e,i,{capture:void 0!==s&&s,passive:void 0===a||a})}function mi(t){return"ph_toolbar_internal"===t.name}function yi(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!c(r))return e;try{var n=r(e);return p(n)&&n?n:e}catch(t){return hi.error("Error in get_current_url, falling back to window.location.href",t),e}}var _i="$early_access_features",bi="$active_feature_flags",wi="$feature_flag_details",xi="$feature_flag_errors",Si="$feature_flag_evaluated_at",ki="$feature_flag_request_id",Ei="$minimal_flag_called_events",Ai="$enabled_feature_flags",Ti="$stored_group_properties",Fi="$stored_person_properties",Pi="$flag_call_reported",Ci="$flag_call_reported_session_id",Ri="$feature_flag_payloads",Oi="$override_feature_flags",Mi="$override_feature_flag_payloads",$i="visibilitychange",Ii="$autocapture_disabled_server_side";function Di(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ji(t){return!!t&&1===t.nodeType}function Li(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Ni(t){return!!t&&3===t.nodeType}function zi(t){return!!t&&11===t.nodeType&&ji(t.host)}function Bi(t){return t?a(t).split(/\s+/):[]}function Ui(t,e){var i=function(t){var e,i=null==(e=typeof window>"u"?void 0:window)||null==(e=e.location)?void 0:e.href;return f(i)?void 0:yi(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function Hi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Bi(e)}function qi(t){return y(t)?null:a(t).split(/(\s+)/).filter(t=>wr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Vi(t){var e="";return vr(t)&&!dr(t)&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;Ni(t)&&t.textContent&&(e+=null!==(i=qi(t.textContent))&&void 0!==i?i:"")}),a(e)}function Wi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var Gi=["a","button","form","input","select","textarea","label"];function Ki(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}function Ji(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Ki(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Xi(t){var e=t.parentNode;return!(!e||!ji(e))&&e}var Yi=[".ph-no-autocapture","[data-ph-no-autocapture]"],Zi=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Qi=/* @__PURE__ */(()=>[...Zi,"+","-","−","–"])(),tr=/* @__PURE__ */(()=>Qi.length+10)(),er=["button","a","input","select","textarea","label"],ir=["button","link","tab","menuitem","option"],rr=(t,e)=>/[a-z0-9]/i.test(e)?s(Qi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,nr=t=>s(er,t.tagName.toLowerCase())||s(ir,(t.getAttribute("role")||"").toLowerCase());function sr(t){var e="",i="",r=t=>{ji(t)&&vr(t)&&!dr(t)&&(e+=" "+Vi(t),i=i||t.getAttribute("aria-label")||"",di(t.childNodes,r))};r(t);var n=(wr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var ar=[".ph-no-rageclick",".ph-no-capture"],or=["","text","search","email","password","url","tel","number"];function lr(t,e){if(!(typeof window>"u"?void 0:window)||ur(t))return!1;var i,r,n,a,o;if(b(e)?(i=!!e&&ar,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:ar,r=null==e?void 0:e.content_ignorelist,n=null!==(o=null==e?void 0:e.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(t){return!(!t||!ji(t))&&(!!Li(t,"textarea")||(Li(t,"input")?s(or,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var l=hr(t,!1),u=l.targetElementList;return!(!l.isComplete||r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Zi;else{if(!h(t))return!1;if(t.length>tr)return hi.error("[PostHog] content_ignorelist array cannot exceed "+tr+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>rr(r,t)||rr(n,t))}(r,function(t,e){for(var i of e)if(nr(i))return sr(i);for(var r of e){try{var n;if("pointer"!==(null==(n=window)?void 0:n.getComputedStyle(r).getPropertyValue("cursor")))break}catch(t){break}var s=sr(r);if(s.safeText||s.ariaLabel)return s}return sr(t)}(t,u))||Ji(u,i))}var ur=t=>!t||Li(t,"html")||!ji(t),hr=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ur(t))return{parentIsUsefulElement:!1,targetElementList:[],isComplete:!1};for(var r=!1,n=[t],s=t,a=/* @__PURE__ */new Set([t]);!Li(s,"body");){var o=s.assignedSlot||s.parentNode,l=zi(o)?o.host:o&&ji(o)?o:null;if(!l)break;if(a.has(l)||a.size>=1e3)return{parentIsUsefulElement:r,targetElementList:n,isComplete:!1};if(a.add(l),zi(o))n.push(l),s=l;else{if(e||Gi.indexOf(l.tagName.toLowerCase())>-1)r=!0;else try{var u=i.getComputedStyle(l);u&&"pointer"===u.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(l),s=l}}return{parentIsUsefulElement:r,targetElementList:n,isComplete:!0}};function cr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r;){if(i++>=1e3||e.has(r))return!0;e.add(r);var n=Hi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!0;var a=r.assignedSlot||r.parentNode;r=zi(a)?a.host:a&&ji(a)?a:null}return!1}function vr(t){if(cr(t))return!1;if(s(Hi(t),"ph-include"))return!0;var e=t.type||"";if(p(e))switch(e.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";return!p(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,""))}function dr(t){return!!(Li(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Li(t,"select")||Li(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var fr=/* @__PURE__ */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}))$"),pr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,gr=[16,15,14,13],mr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),yr=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),_r=/[0-9A-Za-z_]/;function br(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function wr(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?fr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(pr.lastIndex=0;e=pr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of gr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(fr.test(o)&&br(o))return!0}}}return!1}(t))return!1;if(e?mr.test(t):function(t){var e;for(yr.lastIndex=0;e=yr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&_r.test(i)&&_r.test(r)))return!0}return!1}(t))return!1}return!0}function xr(t){var e=Vi(t);return wr(e=(e+" "+Sr(t)).trim())?e:""}function Sr(t){var e="";return t&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Vi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Sr(t)).trim())}catch(t){hi.error("[AutoCapture]",t)}}),e}function kr(t){return t.replace(/"|\\"/g,'\\"')}function Er(t){var e=t.attr__class;if(e)return h(e)?e:Bi(e)}var Ar=class{constructor(t){this.disabled=!1===t;var e=v(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}},Tr=t=>{var e,i=null==(e=typeof document>"u"?void 0:document)?void 0:e.createElement("a");return f(i)?null:(i.href=t,i)},Fr=()=>typeof window>"u"?void 0:window,Pr=()=>typeof document>"u"?void 0:document,Cr="$copy_autocapture",Rr=["password","hidden","file","checkbox","button","submit","reset","image"],Or=/* @__PURE__ */ci("[AutoCapture]");function Mr(t,e){return e.length>t?e.slice(0,t)+"...":e}function $r(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ji(e));return e}function Ir(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!ji(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;!Li(g,"body")&&1e3>d.length;){var m=g.assignedSlot||g.parentNode,y=zi(m)?m.host:m&&ji(m)?m:null;if(!y||f.has(y))break;f.add(y),d.push(y),g=y}var _="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Li(t,"button")||Li(t,"a")):-1;_>0&&(l=l||d.slice(0,_+1).some(t=>!vr(t)||dr(t)));var b,w,x,S=[],k={},E=!1,A=!1;if(di(d,t=>{var e=vr(t);if(e&&Li(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");E=!!(e&&i&&wr(i))&&(v?J(i):i)}s(Hi(t),"ph-no-capture")&&(A=!0),S.push(function(t,e,i,r,n){void 0===n&&(n=!1);var s=t.tagName.toLowerCase(),a={tag_name:s};Gi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Mr(1024,xr(t)):Mr(1024,Vi(t)));var o=Hi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),di(cr(t)?[]:t.attributes,function(i){var s;if((!dr(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&wr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Bi(o).join(" ")),a["attr__"+i.name]=Mr(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=$r(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),di(function(t){if(!vr(t))return{};var e={};return di(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&wr(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(k,e)||(k[e]=t)})}),A)return{props:{},explicitNoCapture:A};if(_>0&&(t=d[_],S.splice(0,_)),l||(S[0].$el_text=Li(t,"a")||Li(t,"button")?xr(t):Vi(t)),E){var T,F;S[0].attr__href=E;var P=null==(T=Tr(E))?void 0:T.host,C=null==(F=Fr())||null==(F=F.location)?void 0:F.host;P&&C&&P!==C&&(b=E)}return{props:fi((w=a.type,{$event_type:w,$ce_version:1}),c?{}:{$elements:S},{$elements_chain:(x=S,h(x)?function(t){return t.map(t=>{var i,r,n="";if(t.tag_name&&(n+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))n+="."+s.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return pi(a).sort((t,e)=>{return(r=e[0])>(i=t[0])?-1:i>r?1:0;var i,r}).forEach(t=>{var e=t[1];return o[kr(t[0].toString())]=kr(e.toString())}),(n+=":")+pi(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Er(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return pi(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(x)):"")},null!=(r=S[0])&&r.$el_text?{$el_text:null==(n=S[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},k),target:t}}var Dr=class{ka(){this.Sa=void 0,clearTimeout(this.xa),this.xa=void 0}$a(t){var e;if(!vr(t))return!0;for(var i,r=null!==(e=this.Ca().css_selector_ignorelist)&&void 0!==e?e:Yi,n=/* @__PURE__ */new Set,a=t,o=function(){if(n.size>=1e3||n.has(a))return{v:!0};n.add(a);var t=a,e=Hi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||dr(t)||r.some(e=>Ki(t,e)))return{v:!0};var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(i=o())return i.v;return!1}Ta(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.Sa;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.ka():"pointerup"===t.type&&(e.released=!0,this.xa=setTimeout(()=>this.ka(),0)))}else{var i;this.ka();var r=Wi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&ji(r)&&(this.Sa={target:r,excluded:this.$a(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.Wl)?void 0:i.distinctId})}else this.ka()}Ma(t){var e,i=this.Sa;this.ka();var r=Wi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.Wl)?void 0:e.distinctId)&&t.pointerId===i.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-i.x)&&5>=Math.abs(t.clientY-i.y)&&r&&(Li(r,"html")||Li(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.Ca().css_selector_ignorelist)&&void 0!==n?n:Yi;return[r,null==(a=Pr())?void 0:a.documentElement,null==(o=Pr())?void 0:o.body].some(t=>{if(!t)return!1;var e=Hi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!vr(t)||dr(t)||l.some(e=>Ki(t,e))})?null:i.target}}constructor(t){this.Ql=t,this.name="autocapture",this.Ia=!1,this.Ea=null,this.Aa=!1,this.Ra=/* @__PURE__ */new Map,this.Pa=!1,this.Br={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ai=!1,this.Ql.refresh(this.Br),this.rageclicks=new Ar(this.Br.rageclick),this.Oa=null}setup(t){this.Fa(),this.Wl=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ai?e.dispose():(this.oa=e,this.startIfEnabled())}dispose(){var t;this.Ai||(this.Ai=!0,this.Wl=void 0,null==(t=this.oa)||t.dispose(),this.oa=void 0,this.Ra.clear(),this.Oa=null,this.La())}Ca(){return this.Ql.refresh(this.Br),this.Br}Fa(){var t,e;return this.Ca(),this.Br.url_allowlist=null==(t=this.Br.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Br.url_ignorelist=null==(e=this.Br.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Br}Da(){var t=Fr(),e=Pr();if(this.isBrowserSupported()){if(t&&e){this.Na=t,this.ja=e;var i=this.qa=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.ka();if(0===e.type.indexOf("pointer"))return void this.Ta(e);var i="click"===e.type?this.Ma(e):void 0;if(m(i))return;this.Ba(e,"$autocapture",i)}catch(t){Or.error("Failed to capture event",t)}};if(gi(t,"blur",i),gi(e,"submit",i,{capture:!0}),gi(e,"change",i,{capture:!0}),gi(e,"click",i,{capture:!0}),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{gi(e,t,i,{capture:!0})}),this.Ca().capture_copied_text){var r=this.za=e=>{e=e||(null==t?void 0:t.event);try{this.Ba(e,Cr)}catch(t){Or.error("Failed to capture clipboard event",t)}};gi(e,"copy",r,{capture:!0}),gi(e,"cut",r,{capture:!0}),gi(e,"paste",r,{capture:!0})}}}else Or.info("Disabling Automatic Event Collection because this browser is not supported")}La(){var t=this.Na,e=this.ja;this.ka(),this.qa&&(null==t||t.removeEventListener("blur",this.qa),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.qa,!0)}),null==e||e.removeEventListener("submit",this.qa,!0),null==e||e.removeEventListener("change",this.qa,!0),null==e||e.removeEventListener("click",this.qa,!0),this.qa=void 0),this.za&&(null==e||e.removeEventListener("copy",this.za,!0),null==e||e.removeEventListener("cut",this.za,!0),null==e||e.removeEventListener("paste",this.za,!0),this.za=void 0),this.Na=void 0,this.ja=void 0,this.Ia=!1}startIfEnabled(){this.isEnabled||this.ka(),!this.Ai&&this.Wl&&this.isEnabled&&!this.Ia&&(this.Da(),this.Ia=!0)}onRemoteConfig(t){if(!this.Ai)if(this.Aa=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.Pa=e.elementsChainAsString);var i,r=e.autocapture_opt_out;b(r)&&(null==(i=this.Wl)||i.kv.set(Ii,r),this.Ea=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Ai){t.size?this.Ra.set(e,new Set(t)):this.Ra.delete(e);var i=/* @__PURE__ */new Set;this.Ra.forEach(t=>{t.forEach(t=>i.add(t))}),this.Oa=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.Oa)||i.forEach(i=>{var n;null==(n=Pr())||null==(n=n.querySelectorAll(i))||n.forEach(n=>{t!==n&&e!==n||s(r,i)||r.push(i)})}),r}get isEnabled(){var t,e;if(this.Ai)return!1;var i=null==(t=this.Wl)?void 0:t.kv.get(Ii),r=this.Ea,n=this.Ca();if(!n.remoteRequestsDisabled&&!this.Aa)return!1;var s=n.remoteRequestsDisabled&&!this.Aa;if(m(r)&&!b(i)&&!s)return!1;var a=null!==(e=this.Ea)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Ba(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Wi(t);Ni(n)&&(n=n.parentNode||null);var a,o=this.Fa();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(a=this.rageclicks)&&a.isRageClick(t.clientX,t.clientY,t.timeStamp||/* @__PURE__ */(new Date).getTime())&&lr(n,o.rageclick)&&this.Ba(t,"$rageclick",r);var l,u=i===Cr,v=u?e({},o,{dom_event_allowlist:void 0}):o;if(n&&function(t,e,i,r,n,s){var a,o=typeof window>"u"?void 0:window;if(!o||ur(t))return!1;if(null!=i&&i.url_allowlist&&!Ui(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ui(i.url_ignorelist,s))return!1;if(null!=i&&i.dom_event_allowlist){var l=i.dom_event_allowlist;if(l&&!l.some(t=>e.type===t))return!1}var u=hr(t,r),h=u.parentIsUsefulElement,c=u.targetElementList;if(!u.isComplete)return!1;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(f(i))return!0;var r,n=function(t){if(i.some(e=>t.tagName.toLowerCase()===e))return{v:!0}};for(var s of t)if(r=n(s))return r.v;return!1}(c,i))return!1;if(!Ji(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Ji(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Yi))return!1;try{var v=o.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return h?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(Gi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,v,u,u?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var d,p=Ir(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.Pa,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),g=p.props;if(p.explicitNoCapture)return!1;var m=this.getElementSelectors(n,p.target);if(m&&m.length>0&&(g.$element_selectors=m),i===Cr){var y=t.type||"clipboard";if("paste"!==y){var _,b,w=null==(_=Fr())||null==(_=_.getSelection())?void 0:_.toString(),x=qi(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(b=null==w?void 0:w.length)&&void 0!==b?b:0}g.$copy_type=y}if("$autocapture"===i&&"change"===t.type&&o.capture_value_css_selector_allowlist&&!o.maskAllText&&(Li(l=n,"input")?!s(Rr,l.type):Li(l,"textarea")||Li(l,"select")&&!l.multiple)&&function(t,e){var i;if(!vr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Yi,n=/* @__PURE__ */new Set,a=t;Li(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=Hi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Ki(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(o=l())return o.v;return!0}(n,o)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){var S=o.capture_value_css_selector_allowlist,k=!1;try{k=c(S)?!!S(n):h(S)&&S.some(t=>Ki(n,t))}catch(t){Or.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.Wl)||d.capture(i,g),!0}}else this.ka()}isBrowserSupported(){var t;return c(null==(t=Pr())?void 0:t.querySelectorAll)}},jr=["[data-ph-capture-value]"],Lr=class{constructor(t){this._instance=t}refresh(t){var e,i=this._instance.config,r=v(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==r?void 0:r.url_allowlist,t.url_ignorelist=null==r?void 0:r.url_ignorelist,t.dom_event_allowlist=null==r?void 0:r.dom_event_allowlist,t.element_allowlist=null==r?void 0:r.element_allowlist,t.css_selector_allowlist=null==r?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=null==r?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=null==r?void 0:r.element_attribute_ignorelist,t.capture_copied_text=null==r?void 0:r.capture_copied_text,t.capture_value_css_selector_allowlist=null!==(e=null==r?void 0:r.capture_value_css_selector_allowlist)&&void 0!==e?e:jr}},Nr=class extends Dr{constructor(t){super(new Lr(t)),this.instance=t}},zr="$surveys",Br="$surveys_loaded_at",Ur="PostHog loadExternalDependency extension not found.",Hr="$surveys_activated",qr="$surveys_activated_session",Vr="$surveys_activated_timestamps",Wr="$heatmaps_enabled_server_side",Gr="$exception_capture_enabled_server_side",Kr="$error_tracking_suppression_rules",Jr="$error_tracking_capture_extension_exceptions",Xr="$web_vitals_enabled_server_side",Yr="$dead_clicks_enabled_server_side",Zr="$product_tours_enabled_server_side",Qr="$web_vitals_allowed_metrics",tn="$session_recording_remote_config",en="$replay_override_sampling",rn="$replay_override_linked_flag",nn="$session_is_sampled",sn="ph_product_tours",an="$sdk_debug_recording_script_not_loaded",on="$sdk_debug_replay_stale_config",ln="beforeunload",un="u">typeof window?window:void 0,hn="u">typeof globalThis?globalThis:un,cn=null==hn?void 0:hn.navigator,vn=null==hn?void 0:hn.document,dn=null==hn?void 0:hn.location;null!=hn&&hn.XMLHttpRequest&&new hn.XMLHttpRequest;var fn="undefined"!=typeof globalThis?globalThis:un;fn&&"undefined"==typeof self&&(fn.self=fn),fn&&"undefined"==typeof File&&(fn.File=function(){});var pn=null!=un?un:{},gn=t=>{var e;return null!=t&&t.config.require_subresource_integrity?t.__loadExternalDependency:null==(e=pn.__PosthogExtensions__)?void 0:e.loadExternalDependency},mn=/* @__PURE__ */ci("[Dead Clicks]"),yn=()=>!0,_n=class{get lazyLoadedDeadClicksAutocapture(){return this.Ja}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Yr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Za(()=>{this.Ka()}):this.stop()}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=gn(this.instance))||i(this.instance,"dead-clicks-autocapture",e=>{e?mn.error("failed to load script",e):t()})}Ka(){var t;if(vn){if(!this.Ja&&null!=(t=pn.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=v(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Ja=pn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Ja.start(vn),mn.info("starting...")}}else mn.error("`document` not found. Cannot start.")}stop(){this.Ja&&(this.Ja.stop(),this.Ja=void 0,mn.info("stopping..."))}},bn=/* @__PURE__ */ci("[ExceptionAutocapture]"),wn=class{constructor(t){var i;this.Vp=()=>{var t;if(un&&this.isEnabled&&null!=(t=pn.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=pn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=pn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=pn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Jp&&this.Br.capture_unhandled_errors&&(this.Jp=e(this.captureException.bind(this))),!this.Zp&&this.Br.capture_unhandled_rejections&&(this.Zp=i(this.captureException.bind(this))),!this.Kp&&this.Br.capture_console_errors&&(this.Kp=r(this.captureException.bind(this)))}catch(t){bn.error("failed to start",t),this.Yp()}}},this._instance=t,this.Xp=!(null==(i=this._instance.persistence)||!i.props[Gr]),this.kt=new C(e({},function(t){var e,i,r,n;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,R:bn})),this.Br=this.tg(),this.startIfEnabledOrStop()}tg(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return v(t)?i=e({},i,t):(f(t)?this.Xp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Br.capture_console_errors||this.Br.capture_unhandled_errors||this.Br.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(bn.info("enabled"),this.Yp(),this.Za(this.Vp)):this.Yp()}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=gn(this._instance))||i(this._instance,"exception-autocapture",e=>{if(e)return bn.error("failed to load script",e);t()})}Yp(){var t,e,i;null==(t=this.Jp)||t.call(this),this.Jp=void 0,null==(e=this.Zp)||e.call(this),this.Zp=void 0,null==(i=this.Kp)||i.call(this),this.Kp=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Xp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Gr]:this.Xp}),this.Br=this.tg(),this.startIfEnabledOrStop())}}onConfigChange(){this.Br=this.tg()}captureException(t){try{var e,i,r,n=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";if(this.kt.consumeRateLimit(n))return void bn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},xn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},Sn=(t,e)=>t>=e&&xn(),kn=(t,e,i,r)=>{if(0===t){if(xn()){var n=e+1;return n===i&&r(),n}return e}return 0},En=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;r.length>n;n++){var s=r[n].split(/=(.*)/);if(s[0]===e){i=s;break}}if(!h(i)||2>i.length)return"";var a=i[1].replace(/\+/g," ");try{a=decodeURIComponent(a)}catch(t){hi.error("Skipping decoding for malformed query param: "+a)}return a},An=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split(/#(.*)/),n=r[1],s=(r[0]||"").split(/\?(.*)/),a=s[1],o=s[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){for(var c=l[h].split("?"),v=0;c.length>v&&!e.includes(c[v].split("=")[0]);)v++;u.push(c.length>v?c.slice(0,v).concat(c[v].split("=")[0]+"="+i).join("?"):l[h])}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=n&&(d+="#"+n),d},Tn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Fn=()=>{},Pn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function Cn(t,e,i){try{if(!(e in t))return Fn;var r={next:t[e]},n=i(function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)});return c(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=n,()=>{if(t[e]!==n)for(var i=t[e],s=Pn(i);s;){if(s.next===n)return void(s.next=r.next);s=Pn(i=s.next)}else t[e]=r.next}}catch(t){return Fn}}var Rn=class{constructor(t){this.vp=!1,this._instance=t,this.fp=this.pp()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.gp();return!!(t.path||t.search||this.mp(t))}startIfEnabled(){this.isEnabled&&(hi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.fp=this.pp(),this.startIfEnabled()}stop(){this.yp&&this.yp(),this.yp=void 0,this.bp&&this.bp(),this.bp=void 0,hi.info("History API monitoring stopped")}monitorHistoryChanges(){un&&un.history&&(this._p("pushState"),this._p("replaceState"),this.wp(),this.mp()&&this.kp())}_p(t){var e;if(un&&(null==(e=un.history[t])||!e.__posthog_wrapped__)){var i=this;Cn(un.history,t,e=>function(r,n,s){var a;i.Sp(s)&&i.xp(),e.call(this,r,n,s),i.$p(t,!i.vp&&"popstate"!==(null==un||null==(a=un.event)?void 0:a.type))})}}pp(){var t=null==un?void 0:un.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}gp(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}mp(t){return void 0===t&&(t=this.gp()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Cp(t){var e=this.gp(),i=this.fp;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.mp(e)&&t.hash!==i.hash))}$p(t,e){void 0===e&&(e=!1);try{e||this.xp();var i=this.pp();if(!i)return;if(this.Cp(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.Tp=r,Promise.resolve().then(()=>this.xp())):r()}this.fp=i}catch(e){hi.error("Error capturing "+t+" pageview",e)}}Sp(t){var e,i;return!(y(t)||!un)&&(null==(e=Tr(String(t)))?void 0:e.href)!==(null==(i=un.location)?void 0:i.href)}xp(){var t=this.Tp;if(t){this.Tp=void 0,this.vp=!0;try{t()}catch(t){hi.error("Error capturing deferred pageview",t)}finally{this.vp=!1}this.fp=this.pp()}}wp(){if(!this.yp){var t=()=>{this.$p("popstate")};gi(un,"popstate",t),this.yp=()=>{un&&un.removeEventListener("popstate",t)}}}kp(){if(!this.bp){var t=()=>{this.$p("hashchange")};gi(un,"hashchange",t),this.bp=()=>{un&&un.removeEventListener("hashchange",t)}}}},On=/* @__PURE__ */ci("[TracingHeaders]"),Mn=class{constructor(t){this._instance=t,this.Ig=void 0,this.Eg=void 0,this.Ag=void 0,this.Rg=void 0,this.Pg=[],this.Vp=()=>{var t,e,i=this.Og(),r=i.hostnames;r||i.traceparentTargets?(r||h(this.Ag)||(this.Ag=[]),this.Rg!==this.Ag&&(this.Yp(),this.Rg=this.Ag),f(this.Ig)&&(this.Ig=null==(t=pn.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(this.Ag,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.Pg)),f(this.Eg)&&(this.Eg=null==(e=pn.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(this.Ag,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.Pg))):this.Yp()}}initialize(){this.startIfEnabledOrStop()}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=gn(this._instance))||i(this._instance,"tracing-headers",e=>{if(e)return On.error("failed to load script",e);t()})}Fg(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Lg(){var t=this.Fg();return h(t)?(h(this.Ag)?this.Ag.splice(0,this.Ag.length,...t):this.Ag=[...t],t.length>0?this.Ag:void 0):!h(this.Ag)||(this.Ag.splice(0),t)?(this.Ag=t||void 0,this.Ag):void 0}Dg(){var t=this._instance.config.trace_propagation_targets,e=h(t)?t.filter(t=>p(t)&&!!t):[];return this.Pg.splice(0,this.Pg.length,...e),e.length>0?this.Pg:void 0}Og(){return{hostnames:this.Lg(),traceparentTargets:this.Dg()}}Yp(){var t,e;null==(t=this.Ig)||t.call(this),null==(e=this.Eg)||e.call(this),this.Ig=void 0,this.Eg=void 0}startIfEnabledOrStop(){var t=this.Og();t.hostnames||t.traceparentTargets?this.Za(this.Vp):this.Yp()}};function $n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var In=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Dn=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...In])(),jn="<masked>",Ln=["li_fat_id"];var Nn=/* @__PURE__ */ci("[Web Vitals]"),zn=9e5,Bn=["CLS","FCP","INP","LCP"],Un=["INP","LCP"],Hn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],qn=class{constructor(t){var i,r=this;this._instance=t,this.Mp=!1,this.Ia=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Bp=function(t){void 0===t&&(t=!1),clearTimeout(r.zp),r.zp=void 0,0!==r.Rt.metrics.length&&(r._instance.capture("$web_vitals",e({$current_url:r.Rt.url},r.Rt.metrics.reduce((t,i)=>e({},t,{["$web_vitals_"+i.name+"_event"]:e({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{})),t?{transport:"sendBeacon",send_instantly:!0}:void 0),r.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Hp=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},y(null==t?void 0:t.name)||y(null==t?void 0:t.value))Nn.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.Up(r);if(!f(n)){var s=_(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.Wp||this.Wp>t.value){this.Rt.navigationKey!==s&&(this.Bp(),this.zp=setTimeout(this.Bp,this.flushToCaptureTimeoutMs)),f(this.Rt.navigationKey)&&(this.Rt.navigationKey=s,this.Rt.url=n),this.Rt.firstMetricTimestamp=f(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});if(delete o.entries,v(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of Hn){var h="url"===u&&"string"==typeof t.attribution[u]?this.Up(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.Bp()}else Nn.error("Ignoring metric with value >= "+this.Wp,t)}}},this.Vp=()=>{if(!this.Ia){var t,i,r,n,s=!1,a=pn.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Gp])||("web-vitals"===this.Gp&&f(o)?null==a?void 0:a.postHogWebVitalsCallbacks:void 0);if(!f(l)){var u=l.withoutAttribution,h=this.attributionMetrics;s=!f(u),t=h.indexOf("LCP")>-1?l.onLCP:(null==u?void 0:u.onLCP)||l.onLCP,i=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,n=h.indexOf("INP")>-1?l.onINP:(null==u?void 0:u.onINP)||l.onINP}if(t&&i&&r&&n){var c={reportSoftNavs:this.useSoftNavs},v=s&&this.attributionMetrics.indexOf("INP")>-1?e({},c,{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&t(this.Hp.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Hp.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Hp.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.Hp.bind(this),v);var d=null==un?void 0:un.document;gi(d,$i,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.Bp(!0)}),gi(un,"pagehide",()=>this.Bp(!0)),this.Ia=!0}else Nn.error("web vitals callbacks not loaded - not starting")}},this.Mp=!(null==(i=this._instance.persistence)||!i.props[Xr]),this.startIfEnabled()}get Qp(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.Qp)?null==(t=this.Qp)?void 0:t.web_vitals_allowed_metrics:void 0;return y(i)?(null==(e=this._instance.persistence)?void 0:e.props.$web_vitals_allowed_metrics)||Bn:i}get flushToCaptureTimeoutMs(){return(v(this.Qp)?this.Qp.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.Qp)?this.Qp.web_vitals_attribution:void 0;return b(t)?t?Bn:[]:h(t)?t:Un}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.Qp)?this.Qp.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get Wp(){var t=v(this.Qp)&&_(this.Qp.__web_vitals_max_value)?this.Qp.__web_vitals_max_value:zn;return t>0&&6e4>=t?zn:t}get isEnabled(){var t=null==dn?void 0:dn.protocol;if("http:"!==t&&"https:"!==t)return Nn.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.Qp)?this.Qp.web_vitals:b(this.Qp)?this.Qp:void 0;return b(e)?e:this.Mp}startIfEnabled(){this.isEnabled&&!this.Ia&&(Nn.info("enabled, starting..."),this.Za(this.Vp))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=v(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=v(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xr]:i}),this._instance.persistence.register({[Qr]:r})),this.Mp=i,this.startIfEnabled()}}}get Gp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Za(t){var e,i=pn.__PosthogExtensions__,r=this.Gp,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=n&&n[r]||"web-vitals"===r&&f(n)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==(e=gn(this._instance))||e(this._instance,r,e=>{e?Nn.error("failed to load script",e):t()})}Up(t){var e=t||(null==un?void 0:un.location.href);if(e){var i=this._instance.config.disable_capture_url_hashes?J(e):e,r=this._instance.config.custom_personal_data_properties;return An(i,this._instance.config.mask_personal_data_properties?[...In,...r||[]]:[],jn)}Nn.error("Could not determine current URL")}},Vn=/* @__PURE__ */ci("[RemoteConfig]"),Wn=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}wc(t){var e=gn(this._instance);e?e(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}kc(t){var e=this._instance.__pending_remote_config_callbacks;if(e)e.push(t);else{var i=[t];this._instance.__pending_remote_config_callbacks=i;try{this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),batchKey:"remote_config",fireCallbackOnDrop:!0,callback:t=>{this._instance.__pending_remote_config_callbacks=void 0,i.forEach(e=>e(t))}})}catch(t){throw this._instance.__pending_remote_config_callbacks=void 0,t}}}load(){try{if(this.remoteConfig)return Vn.info("Using preloaded remote config",this.remoteConfig),void this.Sc(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Vn.warn("Remote config is disabled. Falling back to local config.");if(!this._instance.config.opt_in_site_apps)return void this.kc(t=>{this.Sc(t.json,t)});this.wc(t=>{if(!t)return Vn.info("No config found after loading remote JS config. Falling back to JSON."),void this.kc(t=>{this.Sc(t.json,t)});this.Sc(t)})}catch(t){Vn.error("Error loading remote config",t),this.Sc()}}Sc(t,e){!t&&e&&(0===e.statusCode?e.error||Vn.warn("Failed to fetch remote config from PostHog."):Vn.error("Failed to fetch remote config from PostHog."));try{this._instance.Sc(t?{ok:!0,config:t}:{ok:!1})}catch(t){Vn.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 i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){Vn.error("Error loading feature flags",t)}}},Gn="disabled",Kn="lazy_loading",Jn=null,Xn={Ot(){if(!m(Jn))return Jn;if(Jn=!0,f(un))Jn=!1;else try{var t="__support__";Xn.$t(t,"xyz"),'"xyz"'!==Xn.Lt(t)&&(Jn=!1),Xn.Ft(t)}catch(t){Jn=!1}return Jn},Dt(t){hi.error("sessionStorage error: ",t)},Lt(t){try{return null==un?void 0:un.sessionStorage.getItem(t)}catch(t){Xn.Dt(t)}return null},Pt(t){try{return JSON.parse(Xn.Lt(t))||null}catch(t){}return null},$t(t,e){try{return null==un||un.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(t){Xn.Dt(t)}return!1},Ft(t){try{null==un||un.sessionStorage.removeItem(t)}catch(t){Xn.Dt(t)}}};function Yn(t){return"ph_replay_pending_buffer_"+JSON.stringify([t.persistence_name||t.token,t.token])}var Zn=/* @__PURE__ */ci("[SessionRecording]"),Qn=[an,on,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],ts=class{get Br(){return this._instance.config}get Qc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Yf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this.Xf||"missing_config"===this.Xf?this.Xf:null!==(t=null==(e=this.Yf)?void 0:e.status)&&void 0!==t?t:this.Xf}constructor(t){var e;if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Xf=Gn,this.tp=void 0,this.ep=!1,this.Yn=void 0,this.Xe=(()=>{var t;if(null==vn||!vn.visibilityState||"visible"===vn.visibilityState)return!0;var e=null==un||null==(t=un.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.un=()=>{var t;"visible"===(null==vn?void 0:vn.visibilityState)&&(this.Xe=!0,null==(t=this.Yf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Zn.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Br.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');var i=this._instance.get_property(nn);p(i)&&"!"===i[0]&&(null==(e=this.Qc)||e.unregister(nn)),null!=vn&&vn.addEventListener&&gi(vn,"visibilitychange",this.un)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.ep=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.un),i?this.np(!0):this.stopRecording()}get sp(){var t,e=!(null==(t=this._instance.get_property(tn))||!t.enabled),i=!this.Br.disable_session_recording,r=this.Br.disable_session_recording||this._instance.consent.isOptedOut();return un&&e&&i&&!r}startIfEnabledOrStop(t){if(!this.ep){var e;if(this.Yf)if(this.Yn!==(null==(e=this.Br.session_recording)?void 0:e.selectMaskingFn))Xn.Ft(Yn(this.Br)),this.Yf.discard({discardProducerEvents:!0}),this.Yn=void 0;else if(this.Yf.isStarted&&this.sp)return void(this.rp()||this.np(!0));var i=!f(Object.assign)&&!f(Array.from);this.sp&&i?(this.op(t),Zn.info("starting")):(this.Xf=Gn,this.stopRecording())}}op(t){var e,i;if(this.sp)if("awaiting_config"!==this.Xf&&"missing_config"!==this.Xf&&(this.Xf=Kn),null!=pn&&null!=(e=pn.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=pn.__PosthogExtensions__)&&i.initSessionRecording)this.lp(t);else{var r,n=this._instance.sessionManager;null==(r=gn(this._instance))||r(this._instance,this.ap,e=>{if(!this.ep&&this.sp&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[an]:!0}),Zn.error("could not load recorder",e)):void this.lp(t);this.Xf=Gn})}}stopRecording(){var t,e;null==(t=this.tp)||t.call(this),this.tp=void 0,null==(e=this.Yf)||e.stop()}np(t){var e,i,r;void 0===t&&(t=!1),t&&(this.Yn||null!=(e=this.Br.session_recording)&&e.selectMaskingFn)&&Xn.Ft(Yn(this.Br)),null==(i=this.tp)||i.call(this),this.tp=void 0,null==(r=this.Yf)||r.discard({discardProducerEvents:t}),this.Yn=void 0}up(){var t,e;null==(t=this.Qc)||t.unregister(nn),null==(e=this.Qc)||e.unregister("$replay_sample_rate")}cp(t,e){if(y(t))return null;var i,r=_(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Zn.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}hp(t){if(this.Qc){var i,r,n=this.Qc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.cp(null==(i=this.Br.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.cp(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.up();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[tn]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds: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})})};s(),null==(i=this.tp)||i.call(this),this.tp=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?!1===e.sessionRecording?(this.hp(e),void this.np()):(this.hp(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.Xf&&(this.Xf="missing_config",this._instance.register_for_session({[on]:!0}),Zn.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Yf)&&i.log?this.Yf.log(t,e):Zn.warn("log called before recorder was ready")}get ap(){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"}dp(){var t,e=this._instance.get_property(tn);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Zn.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!y(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}rp(){var t,e,i;return null==(t=this.Br.session_recording)||!t.selectMaskingFn||!(!0!==(null==(e=pn.__PosthogExtensions__)||null==(e=e.rrweb)||null==(e=e.record)?void 0:e.supportsSelectMasking)||!0!==(null==(i=pn.__PosthogExtensions__)||null==(i=i.initSessionRecording)?void 0:i.supportsSelectMasking)||this.Yf&&!0!==this.Yf.supportsSelectMasking)||(this.Xf=Gn,Zn.error("Session recording has not started: the recorder does not support selectMaskingFn."),!1)}lp(t){var e,i,r,n,s;if(!this.ep&&this.sp&&this._instance.sessionManager){if(null==(e=pn.__PosthogExtensions__)||!e.initSessionRecording)return Zn.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[an]:!0});var a;if(this.rp())if(this.Yf||(this.Yf=null==(a=pn.__PosthogExtensions__)?void 0:a.initSessionRecording(this._instance,this.Xe),this.Yf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.rp()){if(!this.dp()){if("missing_config"===this.Xf||"awaiting_config"===this.Xf)return;return this.Xf="awaiting_config",Zn.info("persisted remote config is stale, requesting fresh config before starting"),void new Wn(this._instance).load()}this.Xf=Kn,null==(i=(r=this.Yf).setDocumentWasEverVisible)||i.call(r,this.Xe);var o=null==(n=this.Br.session_recording)?void 0:n.selectMaskingFn;this.Yf.start(t),this.Yn=o,this.Yf.isStarted&&o!==(null==(s=this.Br.session_recording)?void 0:s.selectMaskingFn)&&this.startIfEnabledOrStop()}else this.np(!0)}else this.Xf=Gn}onRRwebEmit(t){var e;null==(e=this.Yf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Yf||null==(t=this.Qc)||t.register({[rn]:!0}),null==(e=this.Yf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.Yf||null==(t=this.Qc)||t.register({[en]:!0}),null==(e=this.Yf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.Yf||null==(e=this.Qc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Yf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Qn){var n,s=null==(n=this._instance.sessionPersistence)?void 0:n.get_property(r);f(s)||(i[r]=s)}return e({},i,(null==(t=this.Yf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Yf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.Yf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}},es=/* @__PURE__ */ci("[Heatmaps]");function is(t){return v(t)&&"clientX"in t&&"clientY"in t&&_(t.clientX)&&_(t.clientY)}var rs=class{get Br(){return this.instance.config}constructor(t){var e;this.Mp=!1,this.Ia=!1,this.Ip=null,this.instance=t,this.Mp=!(null==(e=this.instance.persistence)||!e.props[Wr]),this.rageclicks=new Ar(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Br.capture_heatmaps)&&this.Br.capture_heatmaps.flush_interval_milliseconds&&(t=this.Br.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Br.capture_heatmaps)?y(this.Br.enable_heatmaps)?this.Mp:this.Br.enable_heatmaps:!1!==this.Br.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ia)return;es.info("starting..."),this.Ep(),this.un()}else{var t;clearInterval(null!==(t=this.Ip)&&void 0!==t?t:void 0),this.Ap(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Wr]:i}),this.Mp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}Rp(t){is(t.originalEvent)&&this.jr(t.originalEvent,"deadclick")}un(){this.Ip&&clearInterval(this.Ip),this.Ip="visible"===(null==vn?void 0:vn.visibilityState)?setInterval(this.Oc.bind(this),this.flushIntervalMilliseconds):null}Ep(){un&&vn&&(this.Pp=this.Oc.bind(this),gi(un,ln,this.Pp),this.Op=t=>this.jr(t||(null==un?void 0:un.event)),gi(vn,"click",this.Op,{capture:!0}),this.Fp=t=>this.Lp(t||(null==un?void 0:un.event)),gi(vn,"mousemove",this.Fp,{capture:!0}),this.Dp=new _n(this.instance,yn,this.Rp.bind(this)),this.Dp.startIfEnabledOrStop(),this.Np=this.un.bind(this),gi(vn,$i,this.Np),this.Ia=!0)}Ap(){var t;un&&vn&&(this.Pp&&un.removeEventListener(ln,this.Pp),this.Op&&vn.removeEventListener("click",this.Op,{capture:!0}),this.Fp&&vn.removeEventListener("mousemove",this.Fp,{capture:!0}),this.Np&&vn.removeEventListener($i,this.Np),clearTimeout(this.jp),null==(t=this.Dp)||t.stop(),this.Ia=!1)}qp(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(t,e,i){for(var r=t;r&&ji(r)&&!Li(r,"body");){if(r===i)return!1;var n=void 0;try{var a,o,l;n=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:un)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Xi(r)}return!1}(Wi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}jr(t,i){var r;if(void 0===i&&(i="click"),!Di(t.target)&&is(t)){var n=this.qp(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&lr(Wi(t),this.instance.config.rageclick)&&this.Co(e({},n,{type:"rageclick"})),this.Co(n)}}Lp(t){!Di(t.target)&&is(t)&&(clearTimeout(this.jp),this.jp=setTimeout(()=>{this.Co(this.qp(t,"mousemove"))},500))}Co(t){if(un){var e=this.Br.disable_capture_url_hashes?J(un.location.href):un.location.href,i=this.Br.custom_personal_data_properties,r=An(e,this.Br.mask_personal_data_properties?[...In,...i||[]]:[],jn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}Oc(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},ns=/* @__PURE__ */ci("[Product Tours]"),ss=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Zr))},as=class{get Qc(){return this._instance.persistence}constructor(t){this.pg=null,this.gg=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var i,r;if(this.Qc&&this.Qc.register({[Zr]:!!e.productTours}),!ss(this._instance))return!this.pg&&y(null==(i=this.Qc)?void 0:i.props.ph_product_tours)||ns.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.pg)||r.stop(),this.pg=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.pg&&ss(this._instance)&&this.Za(()=>this.mg())}Za(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=gn(this._instance))||i(this._instance,"product-tours",e=>{e?ns.error("Could not load product tours script",e):t()})}mg(){var t;!this.pg&&null!=(t=pn.__PosthogExtensions__)&&t.generateProductTours&&(this.pg=pn.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.gg)||e){var i=this.Qc;if(i){var r=i.props[sn];if(h(r)&&!e)return this.gg=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:e=>{if(ss(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var n="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||ns.warn(n):ns.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.gg=s,i&&i.register({[sn]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.gg,{isLoaded:!0})}getActiveProductTours(t){y(this.pg)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.pg.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.pg)||e.showTourById(t)}previewTour(t){this.pg?this.pg.previewTour(t):this.Za(()=>{var e;this.mg(),null==(e=this.pg)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.pg)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.pg)||t.nextStep()}previousStep(){var t;null==(t=this.pg)||t.previousStep()}clearCache(){var t;this.gg=null,null==(t=this.Qc)||t.unregister(sn)}resetTour(t){var e;null==(e=this.pg)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.pg)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.pg)||e.cancelPendingTour(t)}},os=/* @__PURE__ */ci("[SiteApps]"),ls="Error while initializing PostHog app with config id ",us=class{constructor(t){this._instance=t,this.yg=0,this.bg=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps&&!this._instance.config.require_subresource_integrity}_g(t,e){if(e){var i=this.globalsForEvent(e);this.bg.push(i),this.bg.length>1e3&&(this.bg=this.bg.slice(10))}}get siteAppLoaders(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this._instance.config.opt_in_site_apps&&!this.isEnabled&&os.critical("opt_in_site_apps is ignored: require_subresource_integrity disables site apps"),this.isEnabled){var t=this._instance._addCaptureHook(this._g.bind(this));this.wg=()=>{t(),this.bg=[],this.wg=void 0}}}globalsForEvent(i){var r,n,s,a,o,l,u;if(!i)throw new Error("Event payload is required");var h={},c=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(v)){var f=d[0];h[f]={id:c[f],type:f,properties:d[1]}}var p=i.$set_once,g=i.$set;return{event:e({},function(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}(i,t),{properties:e({},i.properties,g?{$set:e({},null!==(r=null==(n=i.properties)?void 0:n.$set)&&void 0!==r?r:{},g)}:{},p?{$set_once:e({},null!==(s=null==(a=i.properties)?void 0:a.$set_once)&&void 0!==s?s:{},p)}:{}),elements_chain:null!==(o=null==(l=i.properties)?void 0:l.$elements_chain)&&void 0!==o?o:"",distinct_id:null==(u=i.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:h}}kg(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(os.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(os.error("prepare_external_dependency_script returned null"),null):t}Sg(){var t,e,i,r,n,s,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==vn?void 0:vn.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.yg++,this.xg)return this.$g();var h=[],c=this,v=/* @__PURE__ */new WeakSet,d=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),h.push(()=>{t[e]=r})}},f=t=>{if(v.has(t))return t;var e=c.kg(t);return e&&v.add(e),e},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!m(t));return d(u,"appendChild",t=>function(e){var i=f(e);return i?t.call(this,i):e}),d(u,"insertBefore",t=>function(e,i){var r=f(e);return r?t.call(this,r,i):e}),d(u,"replaceChild",t=>function(e,i){var r=f(e);return r?t.call(this,r,i):i}),[null==(e=l.Element)?void 0:e.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{d(t,"append",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}),d(t,"prepend",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})}),[null==(n=l.Element)?void 0:n.prototype,null==(s=l.CharacterData)?void 0:s.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach(t=>{d(t,"before",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}),d(t,"after",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}),d(t,"replaceWith",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var n=p(i);return i.length&&!n.length?void 0:t.apply(this,n)})}),d(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",t=>function(e,i){var r=f(i);return r?t.call(this,e,r):null}),this.xg=()=>{h.forEach(t=>t()),this.xg=void 0},this.$g()}$g(){var t=!1;return()=>{var e;t||(t=!0,this.yg--,0===this.yg&&(null==(e=this.xg)||e.call(this)))}}Cg(t,e){void 0===e&&(e=!0);var i=this.Sg();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.bg.length&&(os.info("Processing "+this.bg.length+" events for site app with id "+t.id),this.bg.forEach(t=>this.Cg(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.wg)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,os.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.Cg(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){os.error(ls+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){os.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Tg(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Mg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Cg(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){os.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var n of Object.values(this.apps))r(n)}}onRemoteConfig(t){var e,i,r,n=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Tg(),void this._instance.on("eventCaptured",t=>this.Mg(t))):void os.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.wg)||i.call(this),t.ok){var s=t.config;if(null!=(r=s.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,e=o.id,i=o.url;pn["__$$ph_site_app_"+e]=n._instance,null==(t=pn.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return os.error(ls+e,t)})};for(var o of s.siteApps)a()}else os.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},hs="events",cs="cancelEvents",vs="survey shown",ds="survey dismissed",fs="survey sent";function ps(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var gs=(t,e)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},ms=t=>t.toLowerCase(),ys={exact:(t,e)=>e.some(e=>t.some(t=>e===t)),is_not:(t,e)=>e.every(e=>t.every(t=>e!==t)),regex:(t,e)=>e.some(e=>t.some(t=>gs(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!gs(e,t))),icontains:(t,e)=>e.map(ms).some(e=>t.map(ms).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(ms).every(e=>t.map(ms).every(t=>!e.includes(t))),gt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i>parseFloat(t))}),lt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i<parseFloat(t))})};function _s(t,e){return!t||Object.entries(t).every(t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(null==r)return!1;var n=ys[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var bs=/* @__PURE__ */ci("[Surveys]"),ws=["popover","widget","api"],xs=class{on(t,e){return this.jo[t]||(this.jo[t]=[]),this.jo[t].push(e),()=>{this.jo[t]=this.jo[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.jo[t]||[])i(e);for(var r of this.jo["*"]||[])r(t,e)}constructor(){this.jo={}}};function Ss(t,e,i){if(y(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}var ks=class{constructor(t){this.Di=t,this.qo=/* @__PURE__ */new Set,this.Bo=/* @__PURE__ */new Set,this.zo=new xs,this.Ho=(t,e)=>this.Uo(t,e)&&this.Wo(t,e)&&this.Vo(t,e)&&this.Go(t,e),this.Uo=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event)}init(){var t,e;f(null==(t=this.Di)?void 0:t.subscribeCapture)||(this.Qo=null==(e=this.Di)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.Qo)||t.call(this),this.Qo=void 0,null==(e=this.Di)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.zo=new xs}register(t){var e,i;if(!f(null==(e=this.Di)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.qo.add(t),null==(e=t.steps)||e.forEach(t=>{this.Bo.add((null==t?void 0:t.event)||"")})}),null!=(i=this.Di)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.qo.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.Di.setElementSelectors(r,this)}}replace(t){this.qo.clear(),this.Bo.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.Bo.has(t)||this.Bo.has(e.event))&&this.qo.forEach(t=>{this.Jo(e,t)&&this.zo.emit("actionCaptured",t.name)})}Zo(t){this.onAction("actionCaptured",e=>t(e))}Jo(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Ho(t,i))return!0;return!1}onAction(t,e){return this.zo.on(t,e)}Wo(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(null==t||!t.properties||!("$current_url"in t.properties))try{var n;r=null==(n=this.Di)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!Ss(r,e.url,e.url_matching||"contains"))return!1}return!0}Vo(t,e){return!!this.Ko(t,e)&&!!this.Yo(t,e)&&!!this.Xo(t,e)}Ko(t,e){var i;if(null==e||!e.href)return!0;var r=this.tl(t);if(r.length>0)return r.some(t=>Ss(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&Ss((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Yo(t,e){var i;if(null==e||!e.text)return!0;var r=this.tl(t);if(r.length>0)return r.some(t=>Ss(t.text,e.text,e.text_matching||"exact")||Ss(t.$el_text,e.text,e.text_matching||"exact"));var n,s,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(n=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!y(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),s=e.text,a=e.text_matching||"exact",n.some(t=>Ss(t,s,a)))}Xo(t,e){var i,r;if(null==e||!e.selector)return!0;if(null!=t&&null!=(i=t.properties)&&null!=(i=i.$element_selectors)&&i.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){}return!1}tl(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Go(t,e){return null==e||!e.properties||0===e.properties.length||_s(e.properties.reduce((t,e)=>{var i=h(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t},{}),null==t?void 0:t.properties)}},Es=class{constructor(t,e){this.el=e,this.il=[],this.Di=t,this.nl=/* @__PURE__ */new Map,this.sl=/* @__PURE__ */new Map,this.rl=/* @__PURE__ */new Map}ll(){var t,e;this.al=null==(t=(e=this.Di).subscribeSession)?void 0:t.call(e,t=>this.ul(t))}cl(t){return!1}hl(){return null}dl(t){}vl(){}fl(t,e){return!!t&&_s(t.propertyFilters,null==e?void 0:e.properties)}pl(t,e){var i=/* @__PURE__ */new Map;return t.forEach(t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach(e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}})}),i}gl(t,e,i){var r=(i===hs?this.nl:this.sl).get(t),n=[];return this.ml(t=>{n=t.filter(t=>null==r?void 0:r.includes(t.id))}),n.filter(r=>{var n,s=null==(n=r.conditions)||null==(n=n[i])||null==(n=n.values)?void 0:n.find(e=>e.name===t);return this.fl(s,e)})}register(t){this.yl(t,!1)}replace(t){this.yl(t,!0)}yl(t,e){f(this.Di.subscribeCapture)||(this.bl(t,e),this._l(t,e))}_l(t,e){var i=t.filter(t=>{var e;return null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length});if(e&&this.rl.clear(),0!==i.length){this.wl||(this.wl=new ks(this.Di),this.wl.init(),this.wl.Zo(t=>this.onAction(t)));var r=[];i.forEach(t=>{var e;null==(e=t.conditions)||null==(e=e.actions)||e.values.forEach(e=>{if(r.push(e),e.name){var i,n=null!==(i=this.rl.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.rl.set(e.name,n)}})}),e?this.wl.replace(r):this.wl.register(r)}else{var n;e&&(null==(n=this.wl)||n.replace([]))}}kl(t,e){e.forEach((e,i)=>{var r,n=null!==(r=t.get(i))&&void 0!==r?r:[];e.forEach(t=>{n.includes(t)||n.push(t)}),t.set(i,n)})}bl(t,e){var i,r,n,s=t.filter(t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),a=t.filter(t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}),o=this.pl(t,hs),l=this.pl(t,cs);e?(this.nl=o,this.sl=l):(this.kl(this.nl,o),this.kl(this.sl,l)),(0!==s.length||0!==a.length||t.some(t=>{var e;return null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length}))&&(null!==(i=this.Qo)&&void 0!==i||(this.Qo=null==(r=(n=this.Di).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.Sl(),s=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(s&&this.getActivatedIds().includes(s)){var a=this.xl(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.$l([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.Cl(s),void this.Tl([s])}if(this.sl.has(t)){var o=this.gl(t,e,cs);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.$l(o.map(t=>t.id)),o.forEach(t=>this.Ml(t.id)))}if(this.nl.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.nl.get(t)});var l=this.gl(t,e,hs);this.Il(l.map(t=>t.id))}}onAction(t){this.rl.has(t)&&this.Il(this.rl.get(t)||[])}Il(t){if(0!==t.length){var e=!!this.Di.getSessionId(),i=[];for(var r of t)e&&this.cl(r)?this.Cl(r)&&this.El(r):i.push(r);i.length>0&&(this.il=[.../* @__PURE__ */new Set([...this.il,...i])]),this.Sl().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Al()}}Cl(t){this.il=this.il.filter(e=>e!==t);var e=this.Rl();return!e.includes(t)&&(this.Pl([...e,t]),this.Ol(),!0)}$l(t){var e=new Set(t);this.il=this.il.filter(t=>!e.has(t));var i=this.Fl(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.Pl(r),0===r.length&&this.Ll()),this.Tl(t),this.Al()}Al(){try{var t;null==(t=this.el)||t.call(this)}catch(t){this.Sl().error("Error while handling activated items change",t)}}Dl(){var t=this.hl();if(!t)return{};var e=this.Di.getProperty(t);return e&&"object"==typeof e?e:{}}El(t){if(this.hl()){var i=this.Dl();this.dl(e({},i,{[t]:Date.now()}))}}Tl(t){if(this.hl()){var e=this.Dl(),i={},r=!1;for(var n of Object.entries(e)){var s=n[0],a=n[1];t.includes(s)?r=!0:i[s]=a}r&&(d(i)?this.vl():this.dl(i))}}Nl(){this.hl()&&this.vl()}getActivationTimestamp(t){if(this.Rl().includes(t)){var e=this.Dl()[t];return _(e)?e:void 0}}Fl(){var t=this.jl();return this.Di.getProperty(t)||[]}Rl(){var t=this.Fl();if(0===t.length)return[];var e=this.Di.getProperty(this.ql()),i=this.Di.getSessionId();return i&&e===i?t:[]}Ol(){var t=this.Di.getSessionId();t&&this.Bl(t)}Ll(){this.zl()}ul(t){var e=this.Di.getProperty(this.ql());if(e&&e!==t){var i=this.Fl(),r=this.Dl();i.length>0&&(this.Pl([]),i.filter(t=>_(r[t])).forEach(t=>this.Ml(t))),this.Ll(),this.Nl(),i.length>0&&this.Al()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.Rl(),...this.il])].filter(t=>!this.Hl(t))}dispose(){var t,e,i;null==(t=this.al)||t.call(this),this.al=void 0,null==(e=this.Qo)||e.call(this),this.Qo=void 0,null==(i=this.wl)||i.dispose(),this.wl=void 0}reset(){this.il=[],this.Fl().length>0&&this.Pl([]),this.Ll(),this.Nl(),this.Al()}getEventToItemsMap(){return this.nl}Ul(){return this.wl}},As=class extends Es{constructor(t,e,i,r){var n;super({subscribeCapture(e){var i=t.onEvent(t=>e(t.event,t));return()=>i.dispose()},subscribeSession(e){var i=t.onSession(e);return()=>i.dispose()},getSessionId(){var e;return null==(e=t.session)?void 0:e.sessionId},getProperty:e=>t.kv.get(e),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(n=null==i?void 0:i.setElementSelectors)&&void 0!==n?n:(e,i)=>{var r;return null==(r=t.getExtension("autocapture"))?void 0:r.setElementSelectors(e,i)}},r),this.Wl=t,this.Vl=e,this.ll()}jl(){return Hr}ql(){return qr}hl(){return Vr}dl(t){this.Wl.kv.set({[Vr]:t})}vl(){this.Wl.kv.remove(Vr)}cl(t){var e,i;this.ml(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return _(r)&&r>0}Gl(){return vs}ml(t){this.Vl.getSurveys(t)}Ml(t){this.Vl.cancelPendingSurvey(t)}Sl(){return bs}Pl(t){this.Wl.kv.set({[Hr]:t})}Bl(t){this.Wl.kv.set({[qr]:t})}zl(){this.Wl.kv.remove(qr)}Hl(){return!1}xl(t,e,i){var r,n;return t===fs&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.ml(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return ps(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===vs?"consume":"ignore":t===vs?"persist":t===ds||t===fs?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ts=(t,e)=>null!=t&&t.then?t.then(e):e(t),Fs="SDK is not enabled or survey functionality is not yet loaded",Ps="Disabled. Not loading surveys.",Cs=class{constructor(t){this.Ql=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Jl=!1,this.Zl=!1,this.Kl=[],this.Yl=[],this.Xl=null,this.ta=null,this.Ai=!1,this.ea=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.Ai&&!this.Br.disableSurveys){if(!t.ok)return this.Zl=!0,this.ia({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),bs.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return bs.warn("Flags not loaded yet. Not loading surveys.");this.na=b(e)?e:e.length>0,bs.info("flags response received, isSurveysEnabled: "+this.na),this.loadIfEnabled()}},this.ia=t=>{this.Yl.slice().forEach(e=>this.sa(e,t))}}setup(t){if(!this.Ai)return this.ra=t,Ts(t.kv.initialize(),()=>{if(this.ra===t&&!this.Ai){this.ra=void 0,this.Wl=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Ai?e.dispose():(this.oa=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Ai||(this.Ai=!0,this.ra=void 0,this.Wl=void 0,null==(t=this.oa)||t.dispose(),this.oa=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Kl=[],this.Yl.forEach(t=>{t.active=!1}),this.Yl=[],null==(r=this.la)||r.call(this),this.la=void 0,this.Xl=null,this.ea.forEach(t=>clearTimeout(t)),this.ea.clear())}get Br(){return this.Ql.get()}getRenderContext(){if(this.Wl){var t=this;return{client:this.Wl,get config(){return t.Br},surveys:t}}}initialize(){this.loadIfEnabled()}reset(){var t;null==(t=this._surveyManager)||null==t.clearInMemoryInProgressSurveyState||t.clearInMemoryInProgressSurveyState();try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],r=0;r<localStorage.length;r++){var n=localStorage.key(r);(null!=n&&n.startsWith("seenSurvey_")||null!=n&&n.startsWith("inProgressSurvey_"))&&i.push(n)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}this.ia()}loadIfEnabled(){if(!this.Ai&&this.Wl){var t=this.Br;if(!this._surveyManager)if(this.Jl)bs.info("Already initializing surveys, skipping...");else if(t.disableSurveys)bs.info(Ps);else if(t.cookielessMode&&this.Wl.isOptedOut)bs.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Ql.getExtensions();if(e){if(!f(this.na)||t.advancedEnableSurveys){var i=this.na||t.advancedEnableSurveys;this.Jl=!0,this.Zl=!1;try{var r=e.generateSurveys;if(r)return this.ua(r,i),void(this.Jl=!1);var n=e.loadExternalDependency;if(!n)return this.aa(Ur),void(this.Jl=!1);n(t=>{try{if(this.Ai)return;var e=this.Ql.getExtensions();t||null==e||!e.generateSurveys?this.aa("Could not load surveys script",t):this.ua(e.generateSurveys,i)}finally{this.Jl=!1}})}catch(t){throw this.Jl=!1,this.aa("Error initializing surveys",t),t}}}else this.aa("PostHog Extensions not found.")}}}ua(t,e){var i;if(!this.Ai){this._surveyManager=t(e),this._surveyEventReceiver=this.ca(this.Wl,this.ia);var r=null==(i=this.Wl)?void 0:i.kv.get(zr);r&&this.ha(r),bs.info("Surveys loaded successfully"),this.da(),this.ia(),this.va({isLoaded:!0})}}ca(t,e){return new As(t,this,void 0,e)}aa(t,e){this.Zl=!0,bs.error(t,e),this.ia({isLoaded:!1,error:t}),this.va({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Kl.push(t),this._surveyManager&&this.va({isLoaded:!0}),()=>{this.Kl=this.Kl.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Ai){var i=this.Wl;if(!i)return t([],{isLoaded:!1,error:Fs});if(this.Br.disableSurveys)return bs.info(Ps),t([]);var r=i.kv.get(zr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.fa()&&this.getSurveys(()=>{},!0));if(this.Xl)this.Xl.then(e=>{this.Ai||t(e.surveys,e.context)}).catch(t=>bs.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Br.requestTimeoutMs}).then(t=>{try{return this.pa(i,t)}catch(t){return bs.error("Error processing surveys response",t),this.pa(i,{statusCode:0,error:t})}},t=>this.pa(i,{statusCode:0,error:t}));this.Xl=n;var s=()=>{this.Xl===n&&(this.Xl=null)};n.then(e=>{s(),this.Ai||(this.ia(e.context),t(e.surveys,e.context))},s).catch(t=>bs.error("Error in survey callback",t))}}}pa(t,e){if(this.Ai)return{surveys:[],context:{isLoaded:!1,error:Fs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?bs.error(r):e.error||bs.warn(r),this.ta=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.ta=null;var n=e.json.surveys||[];return t.kv.set({[zr]:n,[Br]:Date.now()}),this.ha(n),{surveys:n,context:{isLoaded:!0}}}ha(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(ps(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.ga(e)}ga(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}fa(){return this.ma()&&!this.Xl&&!this.ya()}ma(){var t,e=null==(t=this.Wl)?void 0:t.kv.get(Br);return _(e)&&Date.now()-e>3e5}ya(){return _(this.ta)&&3e5>Date.now()-this.ta}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){bs.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",/* @__PURE__ */(new Date).toISOString())}catch(t){}this.ia()}va(t){for(var e of this.Kl){if(this.Ai)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){bs.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);bs.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Ai)return()=>{};var i={callback:t,active:!0,revision:0};this.Yl.push(i),this.da();var r=null==(e=this.Wl)?void 0:e.kv.get(zr);return this.Br.disableSurveys||!this._surveyManager&&this.Zl&&!this.Jl||!r&&!y(this.ta)&&!this.Xl?this.sa(i,{isLoaded:!1}):this._surveyManager&&this.sa(i),()=>{var t;i.active=!1,this.Yl=this.Yl.filter(t=>t!==i),0===this.Yl.length&&(null==(t=this.la)||t.call(this),this.la=void 0)}}da(){var t,e,i;this._surveyManager&&this.Yl.length>0&&(null!==(t=this.la)&&void 0!==t||(this.la=null==(e=(i=this.Ql).onMatchingConditionsChanged)?void 0:e.call(i,this.ia)))}sa(t,e){if(!this.Ai&&t.active){var i=++t.revision,r=r=>{if(!this.Ai&&t.active&&i===t.revision)try{var n=null!=e?e:{isLoaded:!0},s=JSON.stringify([r,n]);if(s===t.lastResult)return;t.lastResult=s,t.callback(r,n)}catch(t){bs.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){bs.error("Error in active matching surveys callback",t)}}}ba(t){var e=null;return this.getSurveys(i=>{var r;e=null!==(r=i.find(e=>e.id===t))&&void 0!==r?r:null}),e}_a(t){if(y(this._surveyManager))return{eligible:!1,reason:Fs};var e="string"==typeof t?this.ba(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}wa(t){var e;if(null==(e=this.Wl)||!e.canCapture)return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(y(this._surveyManager))return{eligible:!1,reason:Fs};var i="string"==typeof t?this.ba(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return bs.warn("init was not called"),{visible:!1,disabledReason:Fs};var e=this.wa(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(bs.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Fs})):new Promise(i=>{this.getSurveys(e=>{var r,n=null!==(r=e.find(e=>e.id===t))&&void 0!==r?r:null;if(n){var s=this.wa(n);i({visible:s.eligible,disabledReason:s.reason})}else i({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,i){var r,n,s;if(null!=(r=this.Wl)&&r.canCapture)if(y(this._surveyManager))bs.warn("init was not called");else{var a="string"==typeof t?this.ba(t):t;if(null!=a&&a.id)if(ws.includes(a.type)){var o=null==(n=typeof document>"u"?void 0:document)?void 0:n.querySelector(e);if(o)if(null!=(s=a.appearance)&&s.surveyPopupDelaySeconds){bs.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.ea.delete(l),!this.Ai&&null!=(t=this.Wl)&&t.canCapture&&(bs.info("Rendering survey "+a.id+" with delay of "+(null==(e=a.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(r=this._surveyManager)||r.renderSurvey(a,o,i),bs.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.ea.add(l)}else this._surveyManager.renderSurvey(a,o,i);else bs.warn("Survey element not found")}else bs.warn("Surveys of type "+a.type+" cannot be rendered in the app");else bs.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.Wl)&&r.canCapture)if(y(this._surveyManager))bs.warn("init was not called");else{var s=this.ba(t);if(s){var a=s;if(null!=(n=s.appearance)&&n.surveyPopupDelaySeconds&&i.ignoreDelay&&(a=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&bs.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this._a(s);if(!o.eligible)return void bs.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(a,i):this.renderSurvey(a,i.selector,i.properties)}else bs.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?bs.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};li.DEBUG=!1,li.LIB_VERSION="1.453.2",li.LIB_NAME="web";var Rs,Os=li,Ms=/* @__PURE__ */new WeakMap,$s=()=>{var t;return null!=un&&null!=(t=un.performance)&&t.now?un.performance.now():Date.now()},Is=class{constructor(t){this._instance=t}get(){var t,e,i,r,n=null==(t=this._instance)?void 0:t.config;return{disableSurveys:!(null==n||!n.disable_surveys),cookielessMode:!(null==n||!n.cookieless_mode),advancedEnableSurveys:!(null==n||!n.advanced_enable_surveys),requestTimeoutMs:null!==(e=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==e?e:1e4,prefillFromUrl:!(null==n||null==(i=n.surveys)||!i.prefillFromUrl),automaticDisplay:!(null!=n&&n.disable_surveys_automatic_display),featureFlagEvaluation:!(null!=n&&n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null==(r=this._instance)||null==(r=r.requestRouter)?void 0:r.endpointFor("ui","")}}getExtensions(){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=gn(e);return{generateSurveys:i?t=>i(e,t):void 0,loadExternalDependency:r?t=>r(e,"surveys",t):void 0}}}onMatchingConditionsChanged(t){var e,i,r=null==(e=this._instance)?void 0:e._addCaptureHook(e=>{"$pageview"!==e&&e!==vs&&e!==ds&&e!==fs||t()}),n=()=>t();gi(un,"PHSurveyShown",n);var s=!1,a=null==(i=this._instance)?void 0:i.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,null==r||r(),null==a||a(),null==un||un.removeEventListener("PHSurveyShown",n)}}},Ds=class extends Cs{constructor(t){super(new Is(t))}},js=/* @__PURE__ */(()=>null!=un&&un.location?Tn(un.location.hash,"__posthog")||Tn(location.hash,"state"):null)(),Ls="_postHogToolbarParams",Ns=/* @__PURE__ */ci("[Toolbar]"),zs=class{constructor(t){this.instance=t}Ng(t){pn.ph_toolbar_state=t}jg(){var t;return null!==(t=pn.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),mi(this.instance.config))return!1;if(!un||!vn)return!1;t=null!=t?t:un.location,i=null!=i?i:un.history;try{if(!e){try{un.localStorage.setItem("test","test"),un.localStorage.removeItem("test")}catch(t){return!1}e=null==un?void 0:un.localStorage}var r,n=js||Tn(t.hash,"__posthog")||Tn(t.hash,"state"),s=n?X(()=>JSON.parse(atob(decodeURIComponent(n))))||X(()=>JSON.parse(decodeURIComponent(n))):null;return s&&"ph_authorize"===s.action?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?t.hash=s.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(Ls)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}qg(t){var e=pn.ph_load_toolbar||pn.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):Ns.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==vn||!vn.getElementById("__POSTHOG_TOOLBAR__"));if(!un||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(un.localStorage.setItem(Ls,JSON.stringify(e({},n,{source:void 0}))),2===this.jg())this.qg(n);else if(0===this.jg()){var s;this.Ng(1),null==(s=gn(this.instance))||s(this.instance,"toolbar",t=>{if(t)return Ns.error("[Toolbar] Failed to load",t),void this.Ng(0);this.Ng(2),this.qg(n)}),gi(un,"turbolinks:load",()=>{this.Ng(0),this.loadToolbar(n)})}return!0}Bg(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}},Bs=/* @__PURE__ */ci("[FeatureFlags]"),Us=/* @__PURE__ */ci("[FeatureFlags]",{debugEnabled:!0}),Hs="\" failed. Feature flags didn't load in time.",qs=[502,504],Vs=["click","keydown","wheel","touchstart","pointerdown"],Ws="connection_error",Gs=(t,i)=>{var r=Object.keys(i||{}).filter(t=>{var e;return null==i||null==(e=i[t])?void 0:e.failed});if(!r.length)return t||{};var n=e({},t);return r.forEach(t=>delete n[t]),n},Ks=(t,i)=>{var r=e({},t);return i.forEach(t=>{var e;null!=(e=r[t])&&e.failed&&delete r[t]}),r},Js=(t,e)=>!(null==e||!e.partialResponse)||!!t.errorsWhileComputingFlags,Xs=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Ys=t=>{var e={};for(var i of pi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Zs=(t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed).map(t=>{var e;return[t,null!==(e=r[t].variant)&&void 0!==e?e:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed&&r[t].enabled).filter(t=>{var e;return!f(null==(e=r[t].metadata)?void 0:e.payload)}).map(t=>{var e;return[t,null==(e=r[t].metadata)?void 0:e.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)},Qs=(t,e)=>t.distinctId===e.distinctId&&t.sessionId===e.sessionId&&((t,e)=>{var i=Object.keys(t);return i.length===Object.keys(e).length&&i.every(i=>t[i]===e[i])})(t.groups,e.groups),ta=class{constructor(t){this.name="featureFlags",this.Kd=!1,this.featureFlagEventHandlers=[],this.R=Bs,this.Yd={},this.Xd={},this.tv=[],this.ev=/* @__PURE__ */new Set,this.iv=/* @__PURE__ */new Set,this.nv=!1,this.sv=!1,this.rv=0,this.ov=!1,this.lv=!1,this.av=!1,this.uv=/* @__PURE__ */new Map,this.hv=!1,this.dv=!1,this.vv=!1,this.fv=0,this.pv=!1,this.ln=()=>{var t=this.gv();this.fv=0,t&&this.reloadFeatureFlags()},this.mv=()=>{var t,e,i=this.yv,r=null!==(t=this.bv)&&void 0!==t?t:i;f(i)||f(r)||this.Br.remoteRequestsDisabled||!this._v||"hidden"===this._v.visibilityState||Date.now()-(null!==(e=this.wv)&&void 0!==e?e:0)<r||(this.bv=this.pv||!this.Br.idleRefreshBackoff?i:Math.min(2*r,36e5),this.pv=!1,this.reloadFeatureFlags(),this.Sv())},this.xv=()=>{this.pv&&this.bv===this.yv||this.$v()},this.un=()=>{var t;"visible"===(null==(t=this._v)?void 0:t.visibilityState)&&this.$v()},this.Ql=t}get Cv(){}Tv(){this.Wl&&this.Mv()}setup(t){try{this.Iv=typeof window>"u"?void 0:window,this._v=typeof document>"u"?void 0:document}catch(t){this.Iv=void 0,this._v=void 0}return this.ra=t,this.R=t.logger.createLogger("[FeatureFlags]"),Ts(t.kv.initialize(),()=>{this.ra===t&&(this.ra=void 0,this.Wl=t,this.Ev(t))})}Ev(t){var e;if(this.Wl===t)return this.Iv&&gi(this.Iv,"online",this.ln),this.Mv(),this.Av=t.registerDynamicEventProperties(()=>this.Rv()?this.Yd:this.Xd),this.Pv=null==(e=this.Cv)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Ov(),this.Fv(),this.Lv()}),this.Fv(),this.initialize()}$v(){this.pv=!0,this.bv=this.yv,this.mv()}Mv(){var t,e=this.Br.refreshIntervalMs,i=!this.Br.remoteRequestsDisabled&&this._v&&!f(e)&&e>0?e:void 0;this.Br.idleRefreshBackoff||(this.bv=i),i!==this.yv&&(this.Dv(),f(i)||(this.yv=i,this.bv=i,this.Sv(),null!=(t=this._v)&&t.addEventListener&&(gi(this._v,$i,this.un),vi(Vs,t=>{gi(this._v,t,this.xv,{capture:!0})}))))}Sv(){f(this.yv)||(f(this.Nv)||clearInterval(this.Nv),this.wv=Date.now(),this.Nv=setInterval(this.mv,this.yv))}Dv(){var t;f(this.Nv)||(clearInterval(this.Nv),this.Nv=void 0,null==(t=this._v)||null==t.removeEventListener||t.removeEventListener($i,this.un),vi(Vs,t=>{var e;null==(e=this._v)||null==e.removeEventListener||e.removeEventListener(t,this.xv,{capture:!0})})),this.yv=void 0,this.bv=void 0,this.pv=!1,this.wv=void 0}destroy(){this.jv()}dispose(){this.jv()}jv(){var t,e,i;this.Dv(),this.rv++,this.lv=!1,this.ra=void 0,this.qv(this.ev,"cancelled"),this.qv(this.iv,"cancelled"),this.Wl&&(this.Bv(),null==(t=this.Av)||t.dispose(),this.Av=void 0,null==(e=this.Pv)||e.call(this),this.Pv=void 0,this.tv=[],null==(i=this.Iv)||i.removeEventListener("online",this.ln),this.Wl=void 0)}get Br(){return this.Ql.get()}zv(t){var e;return this.Hv&&t in this.Hv?this.Hv[t]:null==(e=this.Wl)?void 0:e.kv.get(t)}Ov(){return!!this.Hv&&(this.Hv=void 0,!0)}Uv(){var t;return!f(null==(t=this.Wl)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Ov()}$t(t){this.Wv(()=>{var e;return null==(e=this.Wl)?void 0:e.kv.set(t)})}Vv(t,e,i){if(this.Cv&&t.$enabled_feature_flags){var r=this.zv("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(t=>{var e=t[1];return!(null!=e&&e.failed)}).map(t=>t[0]):[],o=!!e.errorsWhileComputingFlags&&!!e.flags,l=o||i&&e.flags?a:i&&!h(s)?Object.keys(s||{}):Array.from(/* @__PURE__ */new Set([...Object.keys(r),...Object.keys(n)])),u=this.zv("$feature_flag_payloads")||{},c=t.$feature_flag_payloads||{},v=o||i?l:Array.from(/* @__PURE__ */new Set([...Object.keys(u),...Object.keys(c)])),d=!o&&!i,p=!!d||l,g=!!d||v,m={[bi]:p,[Ai]:p,[Ri]:g};for(var y of(t.$feature_flag_details&&(m[wi]=p),[ki,Si,Ei]))f(t[y])||(m[y]=!0);this.Cv.markCrossTabFeatureFlagChanges(m)}}Ft(t){this.Wv(()=>{var e;return null==(e=this.Wl)?void 0:e.kv.remove(t)})}Wv(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}Fv(){var t={},i=this.zv(wi);for(var r of[ki,Oi]){var n=this.zv(r);f(n)||(t[r]=n)}var s=this.zv(bi);s&&(t[bi]=s.filter(t=>{var e;return!(null!=i&&null!=(e=i[t])&&e.failed)}));var a=this.zv(Ri);a&&(t[Ri]=Gs(a,i)),this.Yd=t;var o=e({},t),l=Gs(this.zv(Ai),i);if(l)for(var u of Object.entries(l))o["$feature/"+u[0]]=u[1];this.Xd=o}Rv(){var t=this.Br.cacheTtlMs;if(!t||0>=t)return!1;var e=this.zv(Si);return"number"!=typeof e||Date.now()-e>t}Gv(){return!!this.Rv()&&(this.vv||this.sv||(this.vv=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Qv(){var t=this.Br.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.R.error("Invalid evaluation context found:",t,"Expected non-empty string"),e}):[]}Jv(){var t=this.Br.flagKeys;if(!f(t))return t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.R.error("Invalid flag key found:",t,"Expected non-empty string"),e})}initialize(){var t,e,i=this.Br,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var n,s,a=null!==(n=null==(s=i.bootstrap)?void 0:s.featureFlagPayloads)&&void 0!==n?n:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,e)=>(t[e]=r[e],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,e)=>(t[e]=a[e],t),{});return this.Zv({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n=null!=r&&r.merge?Gs(this.zv(Ai),this.zv(wi)):{},s=null!=r&&r.merge?Gs(this.zv(Ri),this.zv(wi)):{},a=e({},n,t),o=e({},s,i),l={};for(var u of Object.entries(a)){var h=u[0],c=u[1];l[h]={key:h,enabled:Ut(c),variant:Ht(c),reason:void 0,metadata:f(null==o?void 0:o[h])?void 0:{id:0,version:void 0,description:void 0,payload:o[h]}}}this.Zv({flags:l})}get hasLoadedFlags(){return this.nv}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.zv(wi),i=this.zv(Oi),r=this.zv(Mi);if(!r&&!i)return t||{};var n=fi({},t||{});for(var s of[.../* @__PURE__ */new Set([...Object.keys(r||{}),...Object.keys(i||{})])]){var a,o,l=n[s],u=null==i?void 0:i[s],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,c=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,v=null==r?void 0:r[s],d=e({},l,{enabled:h,variant:h?null!=c?c:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(d.original_enabled=null==l?void 0:l.enabled),c!==(null==l?void 0:l.variant)&&(d.original_variant=null==l?void 0:l.variant),v&&(d.metadata=e({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),n[s]=d}return this.Kd||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.Kd=!0),n}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(i=>{var r=t[i];return{key:i,enabled:Ut(r),variant:Ht(r),payload:Bt(e[i])}})}getFlagVariants(){var t=Gs(this.zv(Ai),this.zv(wi)),e=this.zv(Oi);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Kd||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Kd=!0),i}getFlagPayloads(){var t=Gs(this.zv(Ri),this.zv(wi)),e=this.zv(Mi);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Kd||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Kd=!0),i}reloadFeatureFlags(){this.ov||this.Br.featureFlagsDisabled||this.gv()||(this.av&&this.R.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this.sv&&(this.lv=!0),this.Kv||(this.tv.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}}),this.Kv=setTimeout(()=>{this.Yv()},5)))}reloadFeatureFlagsAsync(){return!this.Wl||this.ov||this.Br.featureFlagsDisabled||this.Br.remoteRequestsDisabled||this.gv()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.ev.add(t),this.reloadFeatureFlags()})}qv(t,e){t.forEach(t=>t({status:e})),t.clear()}Bv(){clearTimeout(this.Kv),this.Kv=void 0}onReloading(t){return this.tv.push(t),()=>{this.tv=this.tv.filter(e=>e!==t)}}ensureFlagsLoaded(){this.nv||this.sv||this.Kv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ov=t}resetFlagCallReported(){this.Ft(Pi),this.uv=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.uv.size&&!this.hv&&null!=(t=this.Wl)&&t.canCapture&&!this.Wl.isRateLimited){this.hv=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.uv.keys())){var r=this.uv.get(i);if(r){if(r.value!==String(e[i])||!Qs(r.context,this.Xv())){this.uv.delete(i);continue}if(this.getFeatureFlagResult(i),this.uv.has(i))break}}}finally{this.hv=!1}}}Yv(t){var i;this.Bv();var r=this.Wl;if(!r||this.Br.remoteRequestsDisabled||this.gv())this.qv(this.ev,"skipped");else if(this.sv)this.lv=!0;else{var n={token:r.projectToken,distinct_id:r.distinctId,groups:r.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:e({},r.initialPersonProperties,this.zv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.zv(Ti),timezone:$n()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Br.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.Qv();s.length&&(n.evaluation_contexts=s);var a=this.Jv();f(a)||(n.flag_keys=a);var o=this.Br.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.rv,h=this.ev;this.ev=/* @__PURE__ */new Set,this.iv=h,this.sv=!0;var c=()=>{this.lv&&(this.lv=!1,this.Yv())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.sv=!1,u===this.rv)if(this.tf(t.statusCode),s||this.lv||(this.$anon_distinct_id=void 0),!n.disable_flags||this.lv){this.dv=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ws:"unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),r.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l=!(null==(i=r.quotaLimited)||!i.includes("feature_flags"));l&&a.push("quota_limited"),this.$t({[xi]:a}),l?this.R.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."):n.disable_flags||this.Zv(r,s,{partialResponse:o}),this.qv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.qv(h,"skipped");else c()},d=t=>{this.sv=!1,u===this.rv?(this.$t({[xi]:[Ws]}),this.R.error("Feature flag request failed",t),this.Uv()&&this.Lv(!0),this.qv(h,"error"),c()):c()},p=null!==(i=this.Br.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.rv,m=()=>{if(u!==this.rv||!this.Wl||this.Br.remoteRequestsDisabled)return this.sv=!1,this.qv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Br.compression,sentAt:"body",timeoutMs:this.Br.requestTimeoutMs}).then(t=>{if((t=>qs.includes(t.statusCode)||(t=>0===t.statusCode&&t.error instanceof Error&&"AbortError"===t.error.name)(t))(t)&&g())return p--,void setTimeout(m,500);v(t)}).catch(d)}catch(t){d(t)}};m()}}gv(){return Sn(this.fv,3)}tf(t){this.fv=kn(t,this.fv,3,()=>this.R.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."))}ef(t){var e;return!(this.nv||this.getFlags().length||null!=(e=this.getFeatureFlagDetails(t))&&e.failed)}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.dv)if(this.ef(t))this.R.warn('getFeatureFlag for key "'+t+Hs);else if(!this.Gv()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e;return null==(e=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:e.payload}getFeatureFlagResult(t,i){var r;if(void 0===i&&(i={}),!i.fresh||this.dv)if(this.ef(t))this.R.warn('getFeatureFlagResult for key "'+t+Hs);else if(!this.Gv()){var n,s=null==(r=this.zv(wi))||null==(r=r[t])?void 0:r.failed,a=s?void 0:this.zv(Ai),o=s?void 0:this.zv(Ri),l=this.zv(Oi),u=!!l&&{}.hasOwnProperty.call(l,t),c=u||!!a&&t in a,v=u?l[t]:null==a?void 0:a[t],d=this.zv(Mi),p=d&&{}.hasOwnProperty.call(d,t)?d[t]:null==o?void 0:o[t],g=String(v),m=this.zv("$feature_flag_request_id")||void 0,y=this.zv("$feature_flag_evaluated_at")||void 0,_=this.zv("$flag_call_reported")||{};if(this.Br.deduplicateCallsPerSession){var b,w=null==(b=this.Wl)||null==(b=b.session)?void 0:b.sessionId,x=this.zv(Ci);w&&w!==x&&(_={},n=w)}if(!i.send_event&&"send_event"in i)n&&this.$t({[Pi]:_,[Ci]:n});else{var S,k,E,A,T=!(null!=(S=this.Wl)&&S.canCapture),F=!(T||null!=(k=this.Wl)&&k.isRateLimited);if(F?this.uv.delete(t):(T&&Object.keys(_).length>0&&(_={},this.$t({[Pi]:_})),null!=(A=_[t])&&A.includes(g)||this.if(t,g)),!F||null!=(E=_[t])&&E.includes(g))n&&this.$t({[Pi]:_,[Ci]:n});else{var P,C,R,O,M,I,D,j,L,N,z,B,U;h(_[t])?_[t].push(g):_[t]=[g],this.$t(e({[Pi]:_},n?{[Ci]:n}:{}));var H=this.getFeatureFlagDetails(t),q=[...null!==(P=this.zv("$feature_flag_errors"))&&void 0!==P?P:[]];f(v)&&q.push(null!=H&&H.failed?"evaluation_failed":"flag_missing");var V={$feature_flag:t,$feature_flag_response:v,$feature_flag_payload:null!=p?p:null,$feature_flag_request_id:m,$feature_flag_evaluated_at:y,$feature_flag_bootstrapped_response:null!==(C=null==(R=this.Br.bootstrap)||null==(R=R.featureFlags)?void 0:R[t])&&void 0!==C?C:null,$feature_flag_bootstrapped_payload:null!==(O=null==(M=this.Br.bootstrap)||null==(M=M.featureFlagPayloads)?void 0:M[t])&&void 0!==O?O:null,$used_bootstrap_value:!this.dv};f(null==H||null==(I=H.metadata)?void 0:I.has_experiment)||(V.$feature_flag_has_experiment=H.metadata.has_experiment),f(null==H||null==(D=H.metadata)?void 0:D.version)||(V.$feature_flag_version=H.metadata.version);var W=null!==(j=null==H||null==(L=H.reason)?void 0:L.description)&&void 0!==j?j:null==H||null==(N=H.reason)?void 0:N.code;W&&(V.$feature_flag_reason=W),null!=H&&null!=(z=H.metadata)&&z.id&&(V.$feature_flag_id=H.metadata.id),f(null==H?void 0:H.original_variant)&&f(null==H?void 0:H.original_enabled)||(V.$feature_flag_original_response=f(H.original_variant)?H.original_enabled:H.original_variant),null!=H&&null!=(B=H.metadata)&&B.original_payload&&(V.$feature_flag_original_payload=null==H||null==(U=H.metadata)?void 0:U.original_payload),q.length&&(V.$feature_flag_error=q.join(",")),this.nf(V)||(this.sf(t,g),this.if(t,g))}}if(c)return{key:t,enabled:!!v,variant:"string"==typeof v?v:void 0,payload:Bt(p)}}}nf(t){try{var e;return!1!==(null==(e=this.Wl)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}if(t,e){this.uv.set(t,{value:e,context:this.Xv()})}Xv(){var t,i,r;return{distinctId:null==(t=this.Wl)?void 0:t.distinctId,groups:e({},null==(i=this.Wl)?void 0:i.groups),sessionId:this.Br.deduplicateCallsPerSession?null==(r=this.Wl)||null==(r=r.session)?void 0:r.sessionId:void 0}}sf(t,e){var i=this.zv("$flag_call_reported")||{},r=i[t];h(r)&&r.includes(e)&&(i[t]=r.filter(t=>t!==e),this.$t({[Pi]:i}))}getRemoteConfigPayload(t,e){this.rf(t,e)}rf(t,e){var i=this;return r(function*(){var r=i.Wl;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.Qv();s.length&&(n.evaluation_contexts=s);var a,o=i.Jv();f(o)||(n.flag_keys=o);try{var l;a=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i.Br.compression,sentAt:"body",timeoutMs:i.Br.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void i.R.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){i.R.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.dv)return e.defaultValue;if(this.ef(t))return this.R.warn('isFeatureEnabled for key "'+t+Hs),e.defaultValue;var i=this.getFeatureFlag(t,e);return f(i)?e.defaultValue:!!i}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e,i){this.Zv(t,e,i)}Zv(t,i,r){if(this.Wl){var n;this.nv=!0,!1!==(null==r?void 0:r.persist)&&Js(t,r)&&null!=(n=this.Cv)&&null!=n.reconcileFeatureFlagsBeforeMerge&&n.reconcileFeatureFlagsBeforeMerge()&&this.Ov();var s=this.getFlagVariants(),a=!t.flags&&h(t.featureFlags),o=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=Bs);var o=Zs(t,a),l=o.flags,u=o.featureFlags,c=o.featureFlagPayloads;if(u){var v=t.requestId,d=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{[bi]:u,[Ai]:p,[wi]:Ks(n,u),[Ri]:Gs(r,n),[Ei]:!1}}var m=u,y=c,_=l;if(Js(t,s)){var b=Object.keys(m),w=y||{};m=e({},i,m),y=e({},r,w),(null!=s&&s.partialResponse||l)&&b.forEach(t=>{var e;t in w||null==(e=y)||delete e[t]}),_=l?e({},n,Object.fromEntries(Object.entries(l).filter(t=>{return!(t[1].failed&&(e=t[0],{}.hasOwnProperty.call(i,e)&&!f(i[e])));var e}))):Ks(n,b)}return e({[bi]:Object.keys(Ys(m)),[Ai]:m||{},[Ri]:y||{},[wi]:_||{},[Ei]:!0===t.minimalFlagCalledEvents},v?{[ki]:v}:{},d?{[Si]:d}:{})}}(t,s,a?this.zv("$feature_flag_payloads")||{}:this.getFlagPayloads(),a?this.zv("$feature_flag_details")||{}:this.getFlagsWithDetails(),r,this.R);if(o)if(!1===(null==r?void 0:r.persist)){var l=!f(this.Wl.kv.get(Ai));this.Hv=o,l||this.$t(o)}else this.Ov(),this.Vv(o,t,!(null==r||!r.partialResponse)),this.$t(o);else i&&this.Uv();i||(this.vv=!1),this.Lv(i)}}override(t,e){void 0===e&&(e=!1),this.R.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.lf(t)}lf(t){if(this.Wl){if(!1===t)return this.Ft([Oi,Mi]),this.Lv(),void Us.info("All overrides cleared");if(h(t))return this.$t({[Oi]:Xs(t)}),this.Lv(),void Us.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.Kd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Oi]=h(n)?Xs(n):n),s&&(r[Mi]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Ft([Oi,Mi]):!1===n?this.Ft(Oi):!1===s&&this.Ft(Mi),this.Lv(),!1===n?Us.info("Flag overrides cleared"):n&&Us.info("Flag overrides set",{flags:n}),void(!1===s?Us.info("Payload overrides cleared"):s&&Us.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Oi]:t}),this.Lv(),void Us.info("Flag overrides set",{flags:t});this.R.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.R.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.nv){var e=this.af(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.R.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var n,s,a=(this.zv("$early_access_features")||[]).find(e=>e.flagKey===t),o={["$feature_enrollment/"+t]:i},l={$feature_flag:t,$feature_enrollment:i,$set:o};a&&(l.$early_access_feature_name=a.name),r&&(l.$feature_enrollment_stage=r);var u=e({},this.getFlagVariants(),{[t]:i}),h=e({},this.zv(wi)),c=null==(n=h[t])?void 0:n.failed,v=e({},this.zv(Ri));c&&(delete h[t],delete v[t]),null==(s=this.Cv)||s.markCrossTabFeatureFlagChanges(e({[bi]:[t],[Ai]:[t]},c?{[wi]:[t],[Ri]:[t]}:{},{[Fi]:Object.keys(o)})),this.$t(e({[bi]:Object.keys(Ys(u)),[Ai]:u},c?{[wi]:h,[Ri]:v}:{},{[Fi]:e({},this.zv("$stored_person_properties")||{},o)})),this.Lv();try{var d;null==(d=this.Wl)||d.capture("$feature_enrollment_update",l)}catch(t){this.R.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.zv(_i);!r||e?this.uf(t,i):t(r)}uf(t,e){var i=this;return r(function*(){var r=i.Wl;if(r){var n,s=e?"&"+e.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+s,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;n=a.json.earlyAccessFeatures,i.$t({[_i]:n})}catch(t){return void i.R.error("Early access feature request failed",t)}try{t(n)}catch(t){i.R.error("Early access feature callback failed",t)}}})()}af(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(t=>e[t]),flagVariants:Object.keys(e).filter(t=>e[t]).reduce((t,i)=>(t[i]=e[i],t),{})}}Lv(t){this.Fv();var e=this.af(),i=e.flags,r=e.flagVariants,n=this.av;this.av=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.av=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.cf(t,e)}cf(t,i){void 0===i&&(i=!0);var r=this.zv("$stored_person_properties")||{},n=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,a={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in r||(a[o]=s[o]));this.$t({[Fi]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.zv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Fi]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Ft(Fi),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.zv("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[Ti]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.zv("$stored_group_properties")||{};this.$t({[Ti]:e({},i,{[t]:{}})})}else this.Ft(Ti)}reset(){this.rv++,this.qv(this.ev,"cancelled"),this.qv(this.iv,"cancelled"),this.lv=!1,this.Yd={},this.Xd={},this.Hv=void 0,this.nv=!1,this.ov=!1,this.dv=!1,this.$anon_distinct_id=void 0,this.Bv(),this.Kd=!1,this.fv=0,this.uv=/* @__PURE__ */new Map}},ea=/* @__PURE__ */ci("[FeatureFlags]"),ia=class{constructor(t,e){void 0===e&&(e=!1),this.hf=!1,this.update(t,e)}update(t,e){this.df=((t,e)=>{var i,r,n,s,a,o,l,u;return{bootstrap:{featureFlags:null!==(i=null==(r=t.bootstrap)?void 0:r.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(n=null==(s=t.bootstrap)?void 0:s.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:e,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,idleRefreshBackoff:f(t.remote_config_refresh_interval_ms),requestTimeoutMs:t.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(o=t.feature_flag_request_max_retries)&&void 0!==o?o:1),compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(u=t.evaluation_contexts)&&void 0!==u?u:t.evaluation_environments)&&void 0!==l?l:[],flagKeys:h(t.flag_keys)?t.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.hf||(ea.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.hf=!0),f(t.flag_keys)||h(t.flag_keys)||ea.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.df}},ra=class extends ta{constructor(t){var e=new ia(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.Kf=e}get Cv(){return this._instance.persistence}updateConfig(t,e){this.Kf.update(t,e),this.Tv()}},na=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),sa=/* @__PURE__ */ci("[Error tracking]"),aa="webkit-masked-url:",oa=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],la=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",aa],ua=["__firefox__","__gCrWeb"],ha=class{constructor(t){var i,r;this.eg=[],this.ig=new it([new St,new Mt,new Et,new kt,new Rt,new Ct,new Tt,new Ot],function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return function(i,n){void 0===n&&(n=0);for(var s=[],a=i.split("\n"),o=Math.min(a.length,n+1e3),l=[],u=n;o>u;u++){var h=a[u];if(1024>=h.length){var c=pt.test(h)?h.replace(pt,"$1"):h;if(!c.match(/\S*Error: /)){for(var v of r){var d=v(c,t);if(d){s.push(d);var f=mt(s);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(wt(s,l)>=50)break}}}var m=[...l].sort((t,e)=>e.start-t.start),y=m[m.length-1];if(y){var _=_t(s,y);for(var b of(s.splice(y.start-_,_),m))b.start-=_}for(var w of m)yt(s,w);return l.some(t=>0===t.start&&s.length===t.length)&&function(t){for(var e=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),i=0,r=1;e.length>r;r++)xt(e,r,i)&&(i=r);t.push(...t.splice(0,i))}(s),function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return e({},t,{filename:t.filename||(r=i,r[r.length-1]||{}).filename,function:t.function||"?"});var r})}(s)}}("web:javascript",ct,ft)),this._instance=t,this.eg=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.ng=Lt(this.sg()),this.rg=new Nt(this.ng)}onConfigChange(){this.ng=Lt(this.sg()),this.rg.setConfig(this.ng)}onRemoteConfig(t){var e,i,r;if(t.ok){var n=t.config;if("errorTracking"in n){var s=null!==(e=null==(i=n.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],a=null==(r=n.errorTracking)?void 0:r.captureExtensionExceptions;this.eg=s,this._instance.persistence&&this._instance.persistence.register({[Kr]:this.eg,[Jr]:a})}}}get og(){var t,e,i=!!this._instance.get_property(Jr);return null!==(t=null!==(e=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==e?e:i)&&void 0!==t&&t}buildProperties(t,e){return this.ig.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.ng.enabled)try{if(!p(t)||0===t.trim().length)return void sa.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce((i,r)=>Dt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.lg(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&sa.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.rg.add(e({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){sa.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.ag(e)){if(this.ug(e))return this.cg("Exception dropped: matched a suppression rule"),void sa.info("Skipping exception capture because a suppression rule matched");if(!this.og&&this.hg(e))return this.cg("Exception dropped: thrown by a browser extension"),void sa.info("Skipping exception capture because it was thrown by an extension");if(!this.og&&this.dg(e))return this.cg("Exception dropped: thrown by an injected browser script"),void sa.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.vg(e))return this.cg("Exception dropped: thrown by the PostHog SDK"),void sa.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.ng.enabled&&y(t.$exception_steps)?this.fg(t):t,r=function(){if("u">typeof process){var t,e=null==(t=process.env.POSTHOG_RELEASE_ID)?void 0:t.trim();if(e)return e}var i=globalThis._posthogReleaseId;return"string"==typeof i&&i.length>0?i:void 0}();r&&(i.$release_id=r);try{var n=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return n&&this.rg.clear(),n}catch(t){return na(t)||sa.error("Failed to capture exception event. Dropping this exception.",t),void this.rg.clear()}}catch(t){return void(na(t)||sa.error("Failed to process exception event. Ignoring this exception.",t))}}fg(t){try{var i=this.rg.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return sa.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}cg(t){this.ng.enabled&&this.rg.add({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}lg(t){return v(t)?e({},t):{}}sg(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}ug(t){if(0===t.length)return!1;try{var e=t.reduce((t,e)=>{var i=e.type,r=e.value;return p(i)&&i.length>0&&t.$exception_types.push(i),p(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.eg.some(t=>{var i=t.values.map(t=>{var i=ys[t.operator],r=e[t.key];if(!i||!r)return!1;var n=h(t.value)?t.value:[t.value];return n.length>0&&i(n,r)});return"OR"===t.type?i.some(Boolean):i.every(Boolean)})}catch(t){return sa.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}hg(t){var e=t.flatMap(t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]}),i=e.filter(t=>{var e=t.filename;return!!e&&la.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(aa)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&oa.some(t=>{var i=t.value;return t.exact?e===i:e.includes(i)})})&&!e.some(t=>{var e=t.filename;return t.in_app&&!(null!=e&&e.startsWith(aa))}))}dg(t){return t.some(t=>{var e=t.value;return p(e)&&ua.some(t=>e.includes(t))})}vg(t){if(t.length>0){var e,i,r,n,s=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[];return null!==(r=null==(n=s[s.length-1])||null==(n=n.filename)?void 0:n.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ag(t){return!y(t)&&h(t)}},ca=/*#__PURE__*/function(){function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);e>i;i++)r[i]=t[i];return r}function e(e,i){return function(t){if(Array.isArray(t))return t}(e)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var r,n,s,a,o=[],l=!0,u=!1;try{if(s=(i=i.call(t)).next,0===e);else for(;!(l=(r=s.call(i)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(t){u=!0,n=t}finally{try{if(!l&&null!=i.return&&(a=i.return(),Object(a)!==a))return}finally{if(u)throw n}}return o}}(e,i)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,i):void 0}}(e,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=Object.entries,r=Object.setPrototypeOf,n=Object.isFrozen,s=Object.getPrototypeOf,a=Object.getOwnPropertyDescriptor,o=Object.freeze,l=Object.seal,u=Object.create,h="undefined"!=typeof Reflect&&Reflect,c=h.apply,v=h.construct;o||(o=function(t){return t}),l||(l=function(t){return t}),c||(c=function(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;i>n;n++)r[n-2]=arguments[n];return t.apply(e,r)}),v||(v=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];return new t(...i)});var d,f=I([].forEach),p=I([].lastIndexOf),g=I([].pop),m=I([].push),y=I([].splice),_=Array.isArray,b=I("".toLowerCase),w=I("".toString),x=I("".match),S=I("".replace),k=I("".indexOf),E=I("".trim),A=I((0).toString),T=I(Boolean.prototype.toString),F="undefined"==typeof BigInt?null:I(BigInt.prototype.toString),P="undefined"==typeof Symbol?null:I(Symbol.prototype.toString),C=I({}.hasOwnProperty),R=I({}.toString),O=I(/t/.test),M=(d=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return v(d,e)});function I(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return c(t,e,r)}}function D(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b;if(r&&r(t,null),!_(e))return t;for(var s=e.length;s--;){var a=e[s];if("string"==typeof a){var o=i(a);o!==a&&(n(e)||(e[s]=o),a=o)}t[a]=!0}return t}function j(t){for(var e=0;t.length>e;e++)C(t,e)||(t[e]=null);return t}function L(t){var r=u(null);for(var n of i(t)){var s=e(n,2),a=s[0],o=s[1];C(t,a)&&(r[a]=_(o)?j(o):o&&"object"==typeof o&&o.constructor===Object?L(o):o)}return r}function N(t,e){for(;null!==t;){var i=a(t,e);if(i){if(i.get)return I(i.get);if("function"==typeof i.value)return I(i.value)}t=s(t)}return function(){return null}}var z=o(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),B=o(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),U=o(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),H=o(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),q=o(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),V=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),W=o(["#text"]),G=o(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),K=o(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),J=o(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),X=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y=l(/{{[\w\W]*|^[\w\W]*}}/g),Z=l(/<%[\w\W]*|^[\w\W]*%>/g),Q=l(/\${[\w\W]*/g),tt=l(/^data-[\-\w.\u00B7-\uFFFF]+$/),et=l(/^aria-[\-\w]+$/),it=l(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rt=l(/^(?:\w+script|data):/i),nt=l(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),st=l(/^html$/i),at=l(/^[a-z][.\w]*(-[.\w]+)+$/i),ot=l(/<[/\w!]/g),lt=l(/<[/\w]/g),ut=l(/<\/no(script|embed|frames)/i),ht=l(/\/>/i),ct=function(){return"undefined"==typeof window?null:window},vt=function(t,e,i,r){return C(t,e)&&_(t[e])?D(r.base?L(r.base):{},t[e],r.transform):i};return function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ct(),r=e=>t(e);if(r.version="3.4.13",r.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return r.isSupported=!1,r;var n,s=e.document,a=s,h=a.currentScript,c=e.HTMLTemplateElement,v=e.Node,d=e.NodeFilter,I=e.DOMParser,j=e.trustedTypes,dt=e.Element.prototype,ft=N(dt,"cloneNode"),pt=N(dt,"remove"),gt=N(dt,"nextSibling"),mt=N(dt,"childNodes"),yt=N(dt,"parentNode"),_t=N(dt,"shadowRoot"),bt=N(dt,"attributes"),wt=v&&v.prototype?N(v.prototype,"nodeType"):null,xt=v&&v.prototype?N(v.prototype,"nodeName"):null,St=v&&v.prototype?N(v.prototype,"ownerDocument"):null;if("function"==typeof c){var kt=s.createElement("template");kt.content&&kt.content.ownerDocument&&(s=kt.content.ownerDocument)}var Et,At="",Tt=!1,Ft=0,Pt=function(){if(Ft>0)throw M('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Ct=function(t){Pt(),Ft++;try{return n.createHTML(t)}finally{Ft--}},Rt=s.implementation,Ot=s.createNodeIterator,Mt=s.createDocumentFragment,$t=s.getElementsByTagName,It=a.importNode,Dt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof i&&"function"==typeof yt&&Rt&&void 0!==Rt.createHTMLDocument;var jt=Y,Lt=Z,Nt=Q,zt=tt,Bt=et,Ut=rt,Ht=nt,qt=at,Vt=it,Wt=null,Gt=D({},[...z,...B,...U,...q,...W]),Kt=null,Jt=D({},[...G,...K,...J,...X]),Xt=Object.seal(u(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Yt=null,Zt=null,Qt=Object.seal(u(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),te=!0,ee=!0,ie=!1,re=!0,ne=!1,se=!0,ae=!1,oe=!1,le=null,ue=null,he=!1,ce=!1,ve=!1,de=!1,fe=!0,pe=!1,ge="user-content-",me=!0,ye=!1,_e={},be=null,we=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),xe=null,Se=D({},["audio","video","img","source","image","track"]),ke=null,Ee=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ae="http://www.w3.org/1998/Math/MathML",Te="http://www.w3.org/2000/svg",Fe="http://www.w3.org/1999/xhtml",Pe=Fe,Ce=!1,Re=null,Oe=D({},[Ae,Te,Fe],w),Me=o(["mi","mo","mn","ms","mtext"]),$e=D({},Me),Ie=o(["annotation-xml"]),De=D({},Ie),je=D({},["title","style","font","a","script"]),Le=null,Ne=["application/xhtml+xml","text/html"],ze=null,Be=null,Ue=s.createElement("form"),He=function(t){return t instanceof RegExp||t instanceof Function},qe=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Be||Be!==t){t&&"object"==typeof t||(t={}),t=L(t),Le=-1===Ne.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Wt=vt(t,"ALLOWED_TAGS",Gt,{transform:ze="application/xhtml+xml"===Le?w:b}),Kt=vt(t,"ALLOWED_ATTR",Jt,{transform:ze}),Re=vt(t,"ALLOWED_NAMESPACES",Oe,{transform:w}),ke=vt(t,"ADD_URI_SAFE_ATTR",Ee,{transform:ze,base:Ee}),xe=vt(t,"ADD_DATA_URI_TAGS",Se,{transform:ze,base:Se}),be=vt(t,"FORBID_CONTENTS",we,{transform:ze}),Yt=vt(t,"FORBID_TAGS",L({}),{transform:ze}),Zt=vt(t,"FORBID_ATTR",L({}),{transform:ze}),_e=!!C(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?L(t.USE_PROFILES):t.USE_PROFILES),te=!1!==t.ALLOW_ARIA_ATTR,ee=!1!==t.ALLOW_DATA_ATTR,ie=t.ALLOW_UNKNOWN_PROTOCOLS||!1,re=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,ne=t.SAFE_FOR_TEMPLATES||!1,se=!1!==t.SAFE_FOR_XML,ae=t.WHOLE_DOCUMENT||!1,ce=t.RETURN_DOM||!1,ve=t.RETURN_DOM_FRAGMENT||!1,de=t.RETURN_TRUSTED_TYPE||!1,he=t.FORCE_BODY||!1,fe=!1!==t.SANITIZE_DOM,pe=t.SANITIZE_NAMED_PROPS||!1,me=!1!==t.KEEP_CONTENT,ye=t.IN_PLACE||!1,Vt=function(t){try{return O(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:it,Pe="string"==typeof t.NAMESPACE?t.NAMESPACE:Fe,$e=C(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?L(t.MATHML_TEXT_INTEGRATION_POINTS):D({},Me),De=C(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?L(t.HTML_INTEGRATION_POINTS):D({},Ie);var e=C(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?L(t.CUSTOM_ELEMENT_HANDLING):u(null);if(Xt=u(null),C(e,"tagNameCheck")&&He(e.tagNameCheck)&&(Xt.tagNameCheck=e.tagNameCheck),C(e,"attributeNameCheck")&&He(e.attributeNameCheck)&&(Xt.attributeNameCheck=e.attributeNameCheck),C(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(Xt.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),l(Xt),ne&&(ee=!1),ve&&(ce=!0),_e&&(Wt=D({},W),Kt=u(null),!0===_e.html&&(D(Wt,z),D(Kt,G)),!0===_e.svg&&(D(Wt,B),D(Kt,K),D(Kt,X)),!0===_e.svgFilters&&(D(Wt,U),D(Kt,K),D(Kt,X)),!0===_e.mathMl&&(D(Wt,q),D(Kt,J),D(Kt,X))),Qt.tagCheck=null,Qt.attributeCheck=null,C(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Qt.tagCheck=t.ADD_TAGS:_(t.ADD_TAGS)&&(Wt===Gt&&(Wt=L(Wt)),D(Wt,t.ADD_TAGS,ze))),C(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Qt.attributeCheck=t.ADD_ATTR:_(t.ADD_ATTR)&&(Kt===Jt&&(Kt=L(Kt)),D(Kt,t.ADD_ATTR,ze))),C(t,"ADD_URI_SAFE_ATTR")&&_(t.ADD_URI_SAFE_ATTR)&&D(ke,t.ADD_URI_SAFE_ATTR,ze),C(t,"FORBID_CONTENTS")&&_(t.FORBID_CONTENTS)&&(be===we&&(be=L(be)),D(be,t.FORBID_CONTENTS,ze)),C(t,"ADD_FORBID_CONTENTS")&&_(t.ADD_FORBID_CONTENTS)&&(be===we&&(be=L(be)),D(be,t.ADD_FORBID_CONTENTS,ze)),me&&(Wt["#text"]=!0),ae&&D(Wt,["html","head","body"]),Wt.table&&(D(Wt,["tbody"]),delete Yt.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw M('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');var i=n;n=t.TRUSTED_TYPES_POLICY;try{At=Ct("")}catch(t){throw n=i,t}}else null===t.TRUSTED_TYPES_POLICY?(n=void 0,At=""):(void 0===n&&(Tt||(Et=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;var i=null,r="data-tt-policy-suffix";e&&e.hasAttribute(r)&&(i=e.getAttribute(r));var n="dompurify"+(i?"#"+i:"");try{return t.createPolicy(n,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(j,h),Tt=!0),n=Et),n&&"string"==typeof At&&(At=Ct("")));o&&o(t),Be=t}},Ve=D({},[...B,...U,...H]),We=D({},[...q,...V]),Ge=function(t){m(r.removed,{element:t});try{yt(t).removeChild(t)}catch(e){if(pt(t),!yt(t))throw M("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ke=function(t){Ye(t);var e=mt(t);if(e){var i=[];f(e,t=>{m(i,t)}),f(i,t=>{try{pt(t)}catch(t){}})}var r=bt(t);if(r)for(var n=r.length-1;n>=0;--n){var s=r[n],a=s&&s.name;if("string"==typeof a)try{t.removeAttribute(a)}catch(t){}}},Je=function(t,e){try{m(r.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){m(r.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(ce||ve)try{Ge(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Xe=function(t){var e=bt(t);if(e)for(var i=e.length-1;i>=0;--i){var r=e[i],n=r&&r.name;if("string"==typeof n&&!Kt[ze(n)])try{t.removeAttribute(n)}catch(t){}}},Ye=function(t){for(var e=[t];e.length>0;){var i=e.pop();1===(wt?wt(i):i.nodeType)&&Xe(i);var r=mt(i);if(r)for(var n=r.length-1;n>=0;--n)e.push(r[n])}},Ze=function(t){var e=null,i=null;if(he)t="<remove></remove>"+t;else{var r=x(t,/^[\r\n\t ]+/);i=r&&r[0]}"application/xhtml+xml"===Le&&Pe===Fe&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var a=n?Ct(t):t;if(Pe===Fe)try{e=(new I).parseFromString(a,Le)}catch(t){}if(!e||!e.documentElement){e=Rt.createDocument(Pe,"template",null);try{e.documentElement.innerHTML=Ce?At:a}catch(t){}}var o=e.body||e.documentElement;return t&&i&&o.insertBefore(s.createTextNode(i),o.childNodes[0]||null),Pe===Fe?$t.call(e,ae?"html":"body")[0]:ae?e.documentElement:o},Qe=function(t){var e=St?St(t):t.ownerDocument;return Ot.call(e||t,t,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},ti=function(t){return t=S(t,jt," "),t=S(t,Lt," "),S(t,Nt," ")},ei=function(t){var e;t.normalize();for(var i=St?St(t):t.ownerDocument,r=Ot.call(i||t,t,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null),n=r.nextNode();n;)n.data=ti(n.data),n=r.nextNode();var s=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");s&&f(s,t=>{ri(t.content)&&ei(t.content)})},ii=function(t){var e=xt?xt(t):null;return"string"==typeof e&&"form"===ze(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==bt(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==wt(t)||t.childNodes!==mt(t))},ri=function(t){if(!wt||"object"!=typeof t||null===t)return!1;try{return 11===wt(t)}catch(t){return!1}},ni=function(t){if(!wt||"object"!=typeof t||null===t)return!1;try{return"number"==typeof wt(t)}catch(t){return!1}};function si(t,e,i){0!==t.length&&f(t,t=>{t.call(r,e,i,Be)})}var ai=function(t,e,i,r){return 0===t.length?e:e===i||e===r?L(e):e},oi=function(t,e){if(si(Dt.beforeSanitizeElements,t,null),t!==e&&null===yt(t))return ye&&Ye(t),!0;if(ii(t))return Ge(t),!0;var i=ze(xt?xt(t):t.nodeName);if(Wt=ai(Dt.uponSanitizeElement,Wt,Gt,le),si(Dt.uponSanitizeElement,t,{tagName:i,allowedTags:Wt}),t!==e&&null===yt(t))return ye&&Ye(t),!0;if(function(t,e){return!!(se&&t.hasChildNodes()&&!ni(t.firstElementChild)&&O(ot,t.textContent)&&O(ot,t.innerHTML))||!(!se||t.namespaceURI!==Fe||"style"!==e||!ni(t.firstElementChild))||7===t.nodeType||!(!se||8!==t.nodeType||!O(lt,t.data))}(t,i))return Ge(t),!0;if(Yt[i]||!(Qt.tagCheck instanceof Function&&Qt.tagCheck(i))&&!Wt[i]){var n=function(t,e,i){if(!Yt[e]&&hi(e)){if(Xt.tagNameCheck instanceof RegExp&&O(Xt.tagNameCheck,e))return!1;if(Xt.tagNameCheck instanceof Function&&Xt.tagNameCheck(e))return!1}if(me&&!be[e]){var r=yt(t),n=mt(t);if(n&&r)for(var s=n.length-1;s>=0;--s){var a=t===i?ft(n[s],!0):n[s];r.insertBefore(a,gt(t))}}return Ge(t),!0}(t,i,e);return!1===n&&si(Dt.afterSanitizeElements,t,null),n}if(1===(wt?wt(t):t.nodeType)&&!function(t){var e=yt(t);e&&e.tagName||(e={namespaceURI:Pe,tagName:"template"});var i=b(t.tagName),r=b(e.tagName);return!!Re[t.namespaceURI]&&(t.namespaceURI===Te?function(t,e,i){return e.namespaceURI===Fe?"svg"===t:e.namespaceURI===Ae?"svg"===t&&("annotation-xml"===i||$e[i]):Boolean(Ve[t])}(i,e,r):t.namespaceURI===Ae?function(t,e,i){return e.namespaceURI===Fe?"math"===t:e.namespaceURI===Te?"math"===t&&De[i]:Boolean(We[t])}(i,e,r):t.namespaceURI===Fe?function(t,e,i){return!(e.namespaceURI===Te&&!De[i])&&!(e.namespaceURI===Ae&&!$e[i])&&!We[t]&&(je[t]||!Ve[t])}(i,e,r):!("application/xhtml+xml"!==Le||!Re[t.namespaceURI]))}(t))return Ge(t),!0;if(("noscript"===i||"noembed"===i||"noframes"===i)&&O(ut,t.innerHTML))return Ge(t),!0;if(ne&&3===t.nodeType){var s=ti(t.textContent);t.textContent!==s&&(m(r.removed,{element:t.cloneNode()}),t.textContent=s)}return si(Dt.afterSanitizeElements,t,null),!1},li=function(t,e,i){if(Zt[e])return!1;if(se&&"patchsrc"===e)return!1;if(se&&"for"===e&&"label"!==t&&"output"!==t)return!1;if(fe&&("id"===e||"name"===e)&&(i in s||i in Ue))return!1;var r=Kt[e]||Qt.attributeCheck instanceof Function&&Qt.attributeCheck(e,t);if(ee&&O(zt,e));else if(te&&O(Bt,e));else if(r){if(ke[e]);else if(O(Vt,S(i,Ht,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==k(i,"data:")||!xe[t])if(ie&&!O(Ut,S(i,Ht,"")));else if(i)return!1}else if(!(hi(t)&&(Xt.tagNameCheck instanceof RegExp&&O(Xt.tagNameCheck,t)||Xt.tagNameCheck instanceof Function&&Xt.tagNameCheck(t))&&(Xt.attributeNameCheck instanceof RegExp&&O(Xt.attributeNameCheck,e)||Xt.attributeNameCheck instanceof Function&&Xt.attributeNameCheck(e,t))||"is"===e&&Xt.allowCustomizedBuiltInElements&&(Xt.tagNameCheck instanceof RegExp&&O(Xt.tagNameCheck,i)||Xt.tagNameCheck instanceof Function&&Xt.tagNameCheck(i))))return!1;return!0},ui=D({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),hi=function(t){return!ui[b(t)]&&O(qt,t)},ci=function(t,e,i,r){if(n&&"object"==typeof j&&"function"==typeof j.getAttributeType&&!i)switch(j.getAttributeType(t,e)){case"TrustedHTML":return Ct(r);case"TrustedScriptURL":return function(t){Pt(),Ft++;try{return n.createScriptURL(t)}finally{Ft--}}(r)}return r},vi=function(t,e,i,n){try{i?t.setAttributeNS(i,e,n):t.setAttribute(e,n),ii(t)?Ge(t):g(r.removed)}catch(i){Je(e,t)}},di=function(t){si(Dt.beforeSanitizeAttributes,t,null);var e=t.attributes;if(e&&!ii(t)){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Kt=ai(Dt.uponSanitizeAttribute,Kt,Jt,ue),forceKeepAttr:void 0},r=e.length,n=ze(t.nodeName);r--;){var s=e[r],a=s.name,o=s.namespaceURI,l=s.value,u=ze(a),h=l,c="value"===a?h:E(h);i.attrName=u,i.attrValue=c,i.keepAttr=!0,i.forceKeepAttr=void 0,si(Dt.uponSanitizeAttribute,t,i),c=i.attrValue,!pe||"id"!==u&&"name"!==u||0===k(c,ge)||(Je(a,t),c=ge+c),se&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,c)||"attributename"===u&&x(c,"href")?Je(a,t):i.forceKeepAttr||(!i.keepAttr||!re&&O(ht,c)?Je(a,t):(ne&&(c=ti(c)),li(n,u,c)?(c=ci(n,u,o,c))!==h&&vi(t,a,o,c):Je(a,t)))}si(Dt.afterSanitizeAttributes,t,null)}},fi=function(t){var e=null,i=Qe(t);for(si(Dt.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if(si(Dt.uponSanitizeShadowNode,e,null),oi(e,t),di(e),ri(e.content)&&fi(e.content),1===(wt?wt(e):e.nodeType)){var r=_t(e);ri(r)&&(pi(r),fi(r))}si(Dt.afterSanitizeShadowDOM,t,null)},pi=function(t){for(var e=[{node:t,shadow:null}];e.length>0;){var i=e.pop();if(i.shadow)fi(i.shadow);else{var r=i.node,n=1===(wt?wt(r):r.nodeType),s=mt(r);if(s)for(var a=s.length-1;a>=0;--a)e.push({node:s[a],shadow:null});if(n){var o=xt?xt(r):null;if("string"==typeof o&&"template"===ze(o)){var l=r.content;ri(l)&&e.push({node:l,shadow:null})}}if(n){var u=_t(r);ri(u)&&e.push({node:null,shadow:u},{node:u,shadow:null})}}}};return r.sanitize=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,s=null,o=null,l=null;if((Ce=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ni(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return A(t);case"boolean":return T(t);case"bigint":return F?F(t):"0";case"symbol":return P?P(t):"Symbol()";case"undefined":default:return R(t);case"function":case"object":if(null===t)return R(t);var e=t,i=N(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:R(r)}return R(t)}}(t)))throw M("dirty is not a string, aborting");if(!r.isSupported)return t;oe?(Wt=le,Kt=ue):qe(e),(Dt.uponSanitizeElement.length>0||Dt.uponSanitizeAttribute.length>0)&&(Wt=L(Wt)),Dt.uponSanitizeAttribute.length>0&&(Kt=L(Kt)),r.removed=[];var u=ye&&"string"!=typeof t&&ni(t);if(u){!function(t){if(se)for(var e=[t];e.length>0;){var i=e.pop(),r=wt?wt(i):i.nodeType;if(7===r||8===r&&O(lt,i.data))try{pt(i)}catch(t){}else{if(1===r){var n=i,s=ze(xt?xt(i):i.nodeName);try{n.hasAttribute&&n.hasAttribute("patchsrc")&&n.removeAttribute("patchsrc"),n.hasAttribute&&n.hasAttribute("for")&&"label"!==s&&"output"!==s&&n.removeAttribute("for")}catch(t){}}var a=mt(i);if(a)for(var o=a.length-1;o>=0;--o)e.push(a[o])}}}(t);var h=xt?xt(t):t.nodeName;if("string"==typeof h){var c=ze(h);if(!Wt[c]||Yt[c])throw Ke(t),M("root node is forbidden and cannot be sanitized in-place")}if(ii(t))throw Ke(t),M("root node is clobbered and cannot be sanitized in-place");try{pi(t)}catch(e){throw Ke(t),e}}else if(ni(t))1===(s=(i=Ze("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s),pi(s);else{if(!ce&&!ne&&!ae&&-1===t.indexOf("<"))return n&&de?Ct(t):t;if(!(i=Ze(t)))return ce?null:de?At:""}i&&he&&Ge(i.firstChild);var v=u?t:i;try{for(var d=Qe(v);o=d.nextNode();)oi(o,v),di(o),ri(o.content)&&fi(o.content)}catch(e){throw u&&(Ke(t),f(r.removed,t=>{t.element&&Ye(t.element)})),e}if(u)return f(r.removed,t=>{t.element&&Ye(t.element)}),ne&&ei(t),t;if(ce){if(ne&&ei(i),ve)for(l=Mt.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(Kt.shadowroot||Kt.shadowrootmode)&&(l=It.call(a,l,!0)),l}var p=ae?i.outerHTML:i.innerHTML;return ae&&Wt["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&O(st,i.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+p),ne&&(p=ti(p)),n&&de?Ct(p):p},r.setConfig=function(){qe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,le=Wt,ue=Kt},r.clearConfig=function(){Be=null,oe=!1,le=null,ue=null,n=Et,At=""},r.isValidAttribute=function(t,e,i){return Be||qe({}),li(ze(t),ze(e),i)},r.addHook=function(t,e){"function"==typeof e&&C(Dt,t)&&m(Dt[t],e)},r.removeHook=function(t,e){if(C(Dt,t)){if(void 0!==e){var i=p(Dt[t],e);return-1===i?void 0:y(Dt[t],i,1)[0]}return g(Dt[t])}},r.removeHooks=function(t){C(Dt,t)&&(Dt[t]=[])},r.removeAllHooks=function(){Dt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}()}(),va="Refusing to render web experiment since the viewer is a likely bot",da={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},fa={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>gs(e,t),not_regex:(t,e)=>!gs(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},pa=class t{get Br(){return this._instance.config}constructor(e){var i=this;this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),i.getWebExperiments(e=>{t.zg("retrieved web experiments from the server"),i.Hg=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.Hg&&(t.zg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.Hg)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.Ug(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.Wg(a,i._instance)&&i.Vg(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.zg(va);else if(!this.Br.disable_web_experiments){if(y(this.Hg))return this.Hg=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.zg("applying feature flags",e),e.forEach(t=>{var e;if(this.Hg&&null!=(e=this.Hg)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.Hg)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.Ug(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=En(null==e?void 0:e.search,"__experiment_id"),r=En(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.zg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.Gg(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Br.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Br.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Br.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Gg(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.zg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.Vg(n[0].name,i,n[0].variants[i].transforms))}Ug(e,i){var r=e.variants[i];t.Qg(r,this._instance)?this.Vg(e.name,i,r.transforms):t.zg("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static Wg(e,i){return!y(e.conditions)&&t.Qg(e,i)&&t.Jg(e)}static Qg(e,i){var r;if(y(e.conditions)||y(null==(r=e.conditions)?void 0:r.url))return!0;var n=t.getWindowLocation();if(n){var s,a,o,l=yi(i,n.href);return null==(s=e.conditions)||!s.url||fa[null!==(a=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return null==un?void 0:un.location}static Jg(t){var e;if(y(t.conditions)||y(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!vn)return{};var r,n,s,a=e?[...In,...i||[]]:[],o=(r=An(vn.URL,a,jn),n=Dn.concat(t||[]),s={},di(n,function(t){var e=En(r,t);s[t]=e||null}),s);return fi(function(){var t={};return di(Ln,function(e){var i=(t=>{if(vn){try{for(var e=t+"=",i=vn.cookie.split(";").filter(t=>t.length),r=0;i.length>r;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}})(e);t[e]=i||null}),t}(),o)}();if(i.utm_source){var r,n,s,a,o,l,u,h,c=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(n=t.conditions)||null==(n=n.utm)?void 0:n.utm_campaign)==i.utm_campaign,v=null==(s=t.conditions)||null==(s=s.utm)||!s.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,d=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return c&&d&&f&&v}return!1}static zg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.info("[WebExperiments] "+t,i)}static Zg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.warn("[WebExperiments] "+t,i)}static Kg(e){("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"template"===e.localName?e.content:e).querySelectorAll("a[target], template").forEach(e=>{var i;if("template"!==e.localName)if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"_blank"===(null==(i=e.getAttribute("target"))?void 0:i.toLowerCase())){var r=(e.getAttribute("rel")||"").split(/\s+/).filter(t=>t&&!/^(opener|noopener)$/i.test(t));r.push("noopener"),e.setAttribute("rel",r.join(" "))}else e.removeAttribute("target");else"http://www.w3.org/1999/xhtml"===e.namespaceURI&&t.Kg(e)})}Vg(i,r,n){this._is_bot()?t.zg(va):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.zg("applying transform of variant "+r+" for experiment "+i+" ",n);var a=null==(s=document)?void 0:s.querySelectorAll(n.selector);if(null==a||!a.length)return void t.Zg("no element on this page matches selector "+n.selector+" of variant "+r+" for experiment "+i);var o=/* @__PURE__ */new Map;null==a||a.forEach(i=>{if("script"!==i.localName.toLowerCase()){var r=i;if(n.html){var s,a="http://www.w3.org/1998/Math/MathML"===i.namespaceURI&&"annotation-xml"===i.localName&&(null==(s=i.getAttribute("encoding"))?void 0:s.toLowerCase())||"",l=JSON.stringify([i.namespaceURI,i.localName,a]),u=o.get(l);if(y(u)){var h=null!=Rs?Rs:Rs=ca(),c=i.ownerDocument.implementation.createHTMLDocument(""),v=c.createElementNS(i.namespaceURI,i.localName);a&&v.setAttribute("encoding",a);var d=c.createRange();d.selectNodeContents(v);var f="http://www.w3.org/2000/svg"===i.namespaceURI&&/^(foreignObject|desc|title)$/.test(i.localName)||/^(text\/html|application\/xhtml\+xml)$/.test(a)?"http://www.w3.org/1999/xhtml":i.namespaceURI,p=d.createContextualFragment(n.html);"http://www.w3.org/1998/Math/MathML"===i.namespaceURI&&/^(mi|mo|mn|ms|mtext)$/.test(i.localName)?(v.appendChild(p),h.sanitize(v,e({},da,{NAMESPACE:f||void 0,IN_PLACE:!0}))):("http://www.w3.org/1999/xhtml"===v.namespaceURI&&"template"===v.localName?v.content:v).appendChild(h.sanitize(p,e({},da,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.Kg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.zg("Control variants leave the page unmodified.")}_is_bot(){return cn&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&F(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>F(null==t?void 0:t.brand,e)))return!0}catch(t){}return!!t.webdriver}(cn,this.Br.custom_blocked_useragents):void 0}},ga=/* @__PURE__ */ci("[Conversations]"),ma="Conversations not available yet.",ya=class{constructor(t){this._instance=t,this.Yg=void 0,this._conversationsManager=null,this.Xg=!1,this.ie=null,this.tm=!1,this.im=0,this.nm=null,this.sm=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.nm=null;else if(this.rm=t.ok,t.ok){var e=t.config.conversations;y(e)?this.nm=null:(b(e)?this.Yg=e:(this.Yg=e.enabled,this.ie=e),this.Yg||(this.nm=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.im++,this.Yg=void 0,this.ie=null,this.rm=void 0,this.tm=!1,this.nm=null}loadIfEnabled(){if(!(this._conversationsManager||this.Xg||this._instance.config.disable_conversations||mi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&!f(this.Yg)&&this.Yg)if(this.ie&&this.ie.token){this.Xg=!0;try{var e=t.initConversations;if(e)return this.om(e),void(this.Xg=!1);var i=gn(this._instance);if(!i)return void this.lm(Ur);var r=this.im;i(this._instance,"conversations",e=>{if(r!==this.im)return this.Xg=!1,void this.loadIfEnabled();e||!t.initConversations?this.lm("Could not load conversations script",e):this.om(t.initConversations),this.Xg=!1})}catch(t){this.lm("Error initializing conversations",t),this.Xg=!1}}else ga.error("Conversations enabled but missing token in remote config.")}}om(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.tm=!1,ga.info("Conversations loaded successfully")}catch(t){return void this.lm("Error completing conversations initialization",t)}this.sm&&this._conversationsManager.setTheme(this.sm),this.am()}else ga.error("Cannot complete initialization: remote config is null")}am(){var t=this.nm;this.nm=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}lm(t,e){ga.error(t,e),this._conversationsManager=null,this.Xg=!1,this.tm=!0}show(){this._conversationsManager?this._conversationsManager.show():ga.warn("Conversations not loaded yet.")}hide(){"open"===this.nm&&(this.nm=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.nm=null,this._conversationsManager.open()):this.nm="open"}close(){this._conversationsManager?(this.nm=null,this._conversationsManager.close()):this.nm="close"}setTheme(t){var i,r;this.sm=e({},this.sm,t,{dark:e({},null==(i=this.sm)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.Yg&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":mi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.rm?"remote_config_failed":f(this.Yg)?this.rm?"disabled_in_project":"remote_config_pending":this.Yg?y(this.ie)||!this.ie.token?"missing_token":null!=pn&&pn.__PosthogExtensions__?this.Xg?"initializing":this.tm?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,e,i){var n=this;return r(function*(){return n._conversationsManager?n._conversationsManager.sendMessage(t,e,i):(ga.warn(ma),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(ga.warn(ma),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(ga.warn(ma),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(ga.warn(ma),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(ga.warn(ma),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(ga.warn(ma),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(ga.warn(ma),null)})()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}};function _a(){var t="",i="";try{var r,n=null==(r="u">typeof globalThis?globalThis:"u">typeof window?window:void 0)||null==(r=r.navigator)?void 0:r.userAgent;if(n){var s=function(t){for(var e=0;L.length>e;e++){var i=L[e],r=i[1],n=i[0].exec(t),s=n&&(c(r)?r(n,t):r);if(s)return s}return["",""]}(n);t=s[0],i=s[1]}}catch(t){}return function(t,i){var r=function(t){if(t)return{}.hasOwnProperty.call(Ne,t)?Ne[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function ba(t,i){var r,n,s,a,o,l,u,h=null!==(r=null==t?void 0:t.flushIntervalMs)&&void 0!==r?r:3e3,c=null!==(n=null==t?void 0:t.maxBufferSize)&&void 0!==n?n:100,v=null!=i&&i.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,d=f(v)?Math.max(c,2048):Math.max(c,v),p=e({},_a(),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==i?void 0:i.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:c,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var wa=["debug","log","warn","error","info"],xa="console",Sa="__posthogHandledLogsRequestError",ka=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[Sa]=!0,i},Ea=t=>!!t&&"object"==typeof t&&!0===t[Sa],Aa=class{get vf(){var t=this;return e({},this.R,{error(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];i.some(Ea)||t.R.error(...i)}})}constructor(t,e){var i;this.Ql=t,this.ff=e,this.name="logs",this.pf=!1,this.gf=!1,this.mf=!1,this.R=ci("[logs]"),this.Cc=[],this.yf=[],this.fv=0,this.bf=!1,this.Ai=!1,this._f=[],this.wf=[],this.kf=!1,this.Sf=!1,this.xf=!1,this.$f=()=>{var t,e;this.Ai||(this.fv=0,null==(t=this.Cf)||t.onReconnect(),null==(e=this.Tf)||e.onReconnect())},this.pf=!(null==(i=t.get())||!i.captureConsoleLogs)}get Mf(){return!0}If(){}Ef(){if(!this.xf){try{this.Iv=typeof window>"u"?void 0:window}catch(t){this.Iv=void 0}this.Iv&&(gi(this.Iv,"online",this.$f),this.xf=!0)}}Af(t,e,i,r){this.Ef();var n=ba(this.Ql.get(),i);return[new Je(this.Rf(t,e),n,this.vf,()=>this.ff(),t=>t(),void 0,r),n]}Pf(){var t=this.Ql.get();if(!this.Cf||this.Of!==t){var e;null==(e=this.Cf)||e.reset(),this.Of=t;var i=this.Af(()=>this.Cc,t=>{this.Cc=t});this.Cf=i[0],this.Ff=i[1]}return this.Cf}Lf(){var t=this.Ql.get();if(!this.Tf||this.Df!==t){var e;null==(e=this.Tf)||e.reset(),this.Df=t;var i=this.Af(()=>this.yf,t=>{this.yf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},xa);this.Tf=i[0],this.Nf=i[1]}return this.Tf}setup(t){if(!this.Ai&&!this.bf)return this.bf=!0,this.Wl=t,this.R=t.logger.createLogger("[logs]"),Ts(t.kv.initialize(),()=>{this.Ai||this.Ev(t)})}Ev(t){var e;this.Ef(),null!=(e=this.Ql.get())&&e.captureConsoleLogs&&(this.pf=!0),(this.pf||this.Ql.remoteConfigWillArrive&&t.kv.get(this.Ql.captureHintKey))&&this.jf();var i=!1,r=t.onRemoteConfig(t=>{var e;i=t.ok&&!0===(null==(e=t.config.logs)?void 0:e.captureConsoleLogs),this.onRemoteConfig(t)});this.Ai?r.dispose():(this.oa=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Ai||(this.Ai=!0,this.qf(),null==(t=this.oa)||t.dispose(),this.oa=void 0,this.Wl=void 0,this.mf=!1,null==(e=this.Iv)||e.removeEventListener("online",this.$f),null==(i=this.Bf)||i.call(this),this.Bf=void 0,null==(r=this.Cf)||r.clearQueue(),null==(n=this.Tf)||n.clearQueue(),null==(s=this.Cf)||s.reset(),null==(a=this.Tf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Ai){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.zf():(null==(i=this.Wl)||i.kv.set(this.Ql.captureHintKey,!!r),r?(this.pf=!0,this.gf||this.jf(),this.loadIfEnabled()):this.zf())}}reset(){var t,e,i,r;this.qf(),null==(t=this.Cf)||t.clearQueue(),this.Cc=[],null==(e=this.Cf)||e.reset(),null==(i=this.Tf)||i.clearQueue(),this.yf=[],null==(r=this.Tf)||r.reset(),this.fv=0}captureLog(t){!this.Ai&&this.Wl&&this.Pf().captureLog(t)}captureConsoleLog(t){!this.Ai&&this.Wl&&this.Lf().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Ai&&this.Wl&&this.Lf().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.qf(),null==(t=this.Tf)||t.clearQueue(),this.yf=[]}zf(){this.pf||this.qf()}jf(){var t,e=this;if(!this.kf&&null!=(t=this.Iv)&&t.console){var i=ba(this.Ql.get()).maxBufferSize,r=!0;this.wf.push(()=>{r=!1});var n=function(t){var n;try{n=(t=>{for(;null!=(e=t)&&e.__rrweb_original__;){var e;t=t.__rrweb_original__}return t})(e.Iv.console[t])}catch(t){return 1}n&&e.wf.push(Cn(e.Iv.console,t,s=>{var a=function(){for(var n=arguments.length,a=new Array(n),o=0;n>o;o++)a[o]=arguments[o];try{r&&e.Hf(t,a,i)}catch(t){}return s.apply(e.Iv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of wa)if(n(s))continue;this.kf=!0,this.Uf=setTimeout(()=>{this.qf()},3e4)}}Hf(t,e,i){var r;if(this.kf&&!this.Sf&&0!==e.length)if(null!=(r=this.Wl)&&r.canCapture){if(i>this._f.length){this.Sf=!0;try{this._f.push({level:t,args:e,occurredAtMs:Date.now(),context:this.ff()})}finally{this.Sf=!1}}}else this.qf()}qf(){if(this._f=[],this.kf){for(var t of(this.kf=!1,this.Uf&&(clearTimeout(this.Uf),this.Uf=void 0),this.wf))t();this.wf=[]}}Wf(){var t=this._f;return this.qf(),t}get logger(){return this.Vf||(this.Vf={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Vf}flushLogs(t){this.Wl&&(t?this.Gf(t):(this.Cf&&this.Cf.flush().catch(t=>this.Qf(t)),this.Tf&&this.Tf.flush().catch(t=>this.Qf(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Cf)?void 0:e.flush().catch(e=>t.Qf(e)),n=null==(i=t.Tf)?void 0:i.flush().catch(e=>t.Qf(e));yield r,yield n})()}Qf(t){Ea(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Ai&&this.pf&&!this.gf&&!this.mf){var t=this.If();if(t){this.mf=!0;try{t((t,e)=>{if(this.mf=!1,!this.Ai&&this.pf)if(t||!e)this.R.error("Could not load logs script",t),this.qf();else{var i=this.Wf();this.Bf=e.initialize(this.Wl),this.gf=!0,i.length>0&&e.replay(this.Wl,i)}})}catch(t){throw this.mf=!1,t}}else this.qf()}}Rf(t,e){var i=this.Wl;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:e=>e===n.LogsQueue?t():void 0,setPersistedProperty(t,i){t===n.LogsQueue&&e(null!=i?i:[])},Hs:t=>this.Hs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}Hs(t){return new Promise(e=>{if(Sn(this.fv,3))e({kind:"fatal",error:ka(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(n),e(t))},n=setTimeout(()=>{this.R.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:ka(void 0,"logs request timed out")})},9e4),s=this.Mf;this.Wl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Wl.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.Jf(i,s),i>=200&&300>i?r({kind:"ok"}):413===i?r({kind:"too-large"}):0!==i&&408!==i&&429!==i&&500>i?r({kind:"fatal",error:/* @__PURE__ */new Error("logs request failed with status "+i)}):0===i?(t.error||this.R.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:ka(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:/* @__PURE__ */new Error("logs request failed with status "+i)})},t=>{r({kind:"retry-later",error:t})})}})}Jf(t,e){(0!==t||e)&&(this.fv=kn(t,this.fv,3,()=>this.R.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.")))}Gf(t){this.Cc.length>0&&this.Zf(t,this.Cc,this.Ff,this.Wl.library.name,t=>{this.Cc=t}),this.yf.length>0&&this.Zf(t,this.yf,this.Nf,xa,t=>{this.yf=t})}Zf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ve(s,qe(i,this.Wl.library.name,this.Wl.library.version),r,this.Wl.library.version);this.Wl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Wl.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Qf(t))}}},Ta=class extends Aa{constructor(t){super({get(){var e;return null==t||null==(e=t.config)?void 0:e.logs},captureHintKey:"$logs_capture_enabled_server_side",get remoteConfigWillArrive(){var e;return!(null!=t._shouldDisableFlags&&t._shouldDisableFlags()&&(null==(e=pn._POSTHOG_REMOTE_CONFIG)||null==(e=e[t.config.token])||!e.config))}},()=>function(t){var e,i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){var r=t.sessionManager.checkAndGetSessionAndWindowId(!0),n=r.windowId,s=r.sessionStartTimestamp,a=r.lastActivityTimestamp;i.sessionId=r.sessionId,i.windowId=n,y(s)||(i.sessionStartTimestamp=s),y(a)||(i.lastActivityTimestamp=a)}if(null!=pn&&null!=(e=pn.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(pn.location.href):pn.location.href),t.featureFlags){var o=t.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}(t)),this._instance=t,this.name="logs",this.Ef()}get Mf(){return this._instance.__loaded}If(){var t=ci("[logs]"),e=null==pn?void 0:pn.__PosthogExtensions__;if(e){var i=gn(this._instance);if(i)return t=>{i(this._instance,"logs",i=>{var r=e.logs;t(i,null!=r&&r.initializeLogs?{initialize:t=>r.initializeLogs(t),replay:(t,e)=>null==r.replayConsoleBuffer?void 0:r.replayConsoleBuffer(t,e)}:void 0)})};t.error(Ur)}else t.error("PostHog Extensions not found.")}},Fa=/* @__PURE__ */ci("[NetworkMetrics]"),Pa={"http:":80,"https:":443},Ca=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),Ra=t=>p(t)&&0===t.toLowerCase().indexOf("text/event-stream"),Oa=t=>{try{return t()}catch(t){return}},Ma=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Tr(r))?void 0:i.href)||r}},$a=function(t,i,r,n,s,a,o){void 0===o&&(o=!1);try{var l,u=s();if(!u)return;var h=r||void 0,v=$s()-n,d=Tr(i.url);if(d&&"http:"!==d.protocol&&"https:"!==d.protocol)return;var f={url:(null==d?void 0:d.href)||i.url,method:i.method},g=c(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var m=o&&!h?void 0:((t,e)=>t?400>t?void 0:String(t):(null==e?void 0:e.name)||"_OTHER")(h,a),y=e({},e({"http.request.method":b=Ca.has(_=f.method)?_:"_OTHER"},"_OTHER"===b&&_!==b?{"http.request.method_original":_}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||Pa[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(e=t.pathname,e.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var e})(d):{},h?{"http.response.status_code":h}:{},m?{"error.type":m}:{},null==u.attributes?void 0:u.attributes(f,{status:h,durationMs:v}));null==(l=t.metrics)||l.histogram(g,v,{unit:"ms",attributes:y})}catch(t){Fa.error("Failed to record network metric",t)}var _,b},Ia=()=>{},Da=(t,e)=>c(null==un?void 0:un.fetch)?Cn(un,"fetch",i=>function(){for(var r=$s(),n=arguments.length,s=new Array(n),a=0;n>a;a++)s[a]=arguments[a];var o=i.apply(this,s);if(!e())return o;try{var l,u,h,c=s[0],v=s[1],d=Ma(null!==(l=null!==(u=null==v?void 0:v.method)&&void 0!==u?u:null==c?void 0:c.method)&&void 0!==l?l:"GET",null!==(h=null==c?void 0:c.url)&&void 0!==h?h:c);return o.then(i=>(Ra(Oa(()=>{var t;return null==i||null==(t=i.headers)?void 0:t.get("content-type")}))||$a(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw $a(t,d,void 0,r,e,i),i})}catch(t){return Fa.error("Failed to observe fetch",t),o}}):Ia,ja=(t,e)=>{var i,r=null==un||null==(i=un.XMLHttpRequest)?void 0:i.prototype;if(!r)return Ia;var n=/* @__PURE__ */new WeakMap,s=Cn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{Ms.has(this)||n.set(this,Ma(i[0],i[1]))}catch(t){Fa.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=Cn(r,"send",i=>function(){var r,s;try{var a=n.get(this);if(a&&e()){var o=$s(),l=()=>Ra(Oa(()=>this.getResponseHeader("content-type"))),u=!1;r=()=>{this.removeEventListener("loadend",r),this.removeEventListener("readystatechange",s),u||l()||$a(t,a,this.status,o,e)},gi(this,"readystatechange",s=()=>{2===this.readyState&&(u=l())}),gi(this,"loadend",r)}}catch(t){Fa.error("Failed to observe XHR send",t)}try{for(var h=arguments.length,c=new Array(h),v=0;h>v;v++)c[v]=arguments[v];return i.apply(this,c)}catch(t){throw r&&this.removeEventListener("loadend",r),s&&this.removeEventListener("readystatechange",s),t}});return()=>{s(),a()}},La=class{constructor(t){this._instance=t,this.R=ci("[metrics]"),this.Ai=!1,this.um=!1,this.un=()=>{"hidden"===(null==vn?void 0:vn.visibilityState)&&this.flush()}}initialize(){this.onConfigChange(),this.Ai||this.um||null==vn||!vn.addEventListener||(gi(vn,"visibilitychange",this.un),this.um=!0)}onConfigChange(){var t;if(!this.Ai){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.hm?this.hm=(t=>{var e=!0,i=()=>e?(t=>{var e,i=null==(e=t.config.metrics)?void 0:e.network;return!0===i?{}:i||void 0})(t):void 0,r=Da(t,i),n=ja(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.hm&&(this.hm(),this.hm=void 0)}}Pf(){var t;if(!this.Ai){var e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;if(!this.Cf||this.Of!==e){var i;null==(i=this.Cf)||i.reset(),this.Of=e;var r=function(t){var e,i,r,n,s,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==a?void 0:a["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==a?void 0:a["service.version"])&&void 0!==i?i: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!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(s=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==s?s:1e3}}(e);f(null==e?void 0:e.flushIntervalMs)&&(r.flushIntervalMs=6e4),this.Cf=new ri(this.Rf(),r,this.R)}return this.Cf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.Pf())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.Pf())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.Pf())||r.histogram(t,e,i)}flush(t){if(!this.Cf)return Promise.resolve();if(t){var e=this.Cf.drainWindow();return e&&this.Lo(e,t),Promise.resolve()}return this.Cf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Cf)||t.reset()}dispose(){var t,e;this.Ai=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.un),this.um=!1,null==(t=this.hm)||t.call(this),this.hm=void 0,null==(e=this.Cf)||e.reset()}Rf(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Lo:t=>e.Lo(t),getLibraryId:()=>Os.LIB_NAME,getLibraryVersion:()=>Os.LIB_VERSION}}Lo(t,i){return new Promise(r=>{var n=!1,s=t=>{n||(n=!0,clearTimeout(a),r(t))},a=setTimeout(()=>s({kind:"retry-later",error:/* @__PURE__ */new Error("metrics request timed out")}),9e4);this._instance._send_request(e({method:"POST",url:this.dm(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},"hidden"===(null==vn?void 0:vn.visibilityState)&&{preferSyncCompression:!0},{fireCallbackOnDrop:!0,callback(t){var e,i=t.statusCode;s(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:/* @__PURE__ */new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:/* @__PURE__ */new Error("metrics request failed with status "+i)})}}))})}dm(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}},Na=/* @__PURE__ */new WeakMap,za=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),Ba={maxStringLength:2048,truncationSuffix:"..."},Ua={maxStringLength:2048,truncationSuffix:"..."};function Ha(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function qa(t,e){return{}.hasOwnProperty.call(t,e)}function Va(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function Wa(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?ke(r,Ba):r).slice(0,e)}}function Ga(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function Ka(t){return ke(t||"Unknown error",Ua).slice(0,2048)}function Ja(t,e){try{return Ka(e?function(t){try{if(!v(t)||!h(t.content))return;return t.content.filter(t=>v(t)&&"text"===t.type&&p(t.text)).map(t=>t.text).join(" ").trim()||void 0}catch(t){return}}(t):v(t)&&p(t.message)?t.message:p(t)?t:String(t))}catch(t){return"Unknown error"}}function Xa(t,i,r){return i.errorResult?[{type:"Error",value:r,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:t.buildProperties(i.error,{handled:!0}).$exception_list.map(t=>e({},t,{value:Ka(t.value)}))}function Ya(t,e){if(e)return"Error";try{if(!v(t))return"Error";var i=p(t.name)?t.name.trim():"",r=t.constructor;return i&&"Error"!==i||!c(r)||"Error"===r.name||(i=r.name),(i||"Error").slice(0,256)}catch(t){return"Error"}}function Za(t,e){return{message:Ja(t,e),type:Ya(t,e)}}var Qa=class{constructor(t){this._instance=t,this.vm=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.vm){var t=null==vn?void 0:vn.modelContext;if(t&&c(t.registerTool)){var e=Na.get(t);if(e)return e.instances.add(this._instance),void(this.vm=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;Cn(t,"registerTool",t=>{var e=t;return function(t){for(var r=t,s=arguments.length,a=new Array(s>1?s-1:0),o=1;s>o;o++)a[o-1]=arguments[o];try{r=n.fm(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(Na.set(t,i),this.vm=!0)}}}fm(t,i){if(!t||!c(t.execute))return t;var r=t.execute,n=this,s=function(t,i){var r={intent:!1,model:!1},n=t.inputSchema;if(!function(t){return!!f(t)||v(t)&&Object.keys(t).every(t=>za.has(t)||t.startsWith("x-"))&&!0!==t.additionalProperties&&!v(t.additionalProperties)&&(!t.type||"object"===t.type)&&(!t.properties||v(t.properties))&&(!t.required||h(t.required))}(n))return{tool:Va(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>qa(s,t)||h(null==n?void 0:n.required)&&n.required.includes(t);if(r.intent=i.intent&&!a("context"),r.model=i.model&&!a("llm_model"),!r.intent&&!r.model)return{tool:Va(t),injected:r};var o=e({},s),l=h(null==n?void 0:n.required)?[...n.required]:[];return r.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},l.includes("context")||l.push("context")),r.model&&(o.llm_model={type:"string",description:'The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the site developer\'s analytics.'},l.includes("llm_model")||l.push("llm_model")),{tool:Va(t,e({},n,{type:(null==n?void 0:n.type)||"object",properties:o,required:l})),injected:r}}(t,function(t){var e={intent:!1,model:!1};for(var i of t.instances){var r=Ha(i.config.capture_webmcp);e.intent||(e.intent=!0===(null==r?void 0:r.intent)),e.model||(e.model=!0===(null==r?void 0:r.model))}return e}(i)),a=s.tool,o=s.injected;return Object.defineProperty(a,"execute",{configurable:!0,enumerable:!0,writable:!0,value(){for(var s=/* @__PURE__ */new Date,l=arguments.length,u=new Array(l),h=0;l>h;h++)u[h]=arguments[h];var c,d,f=function(t,i){if(!v(t))return{};try{var r=i.intent?Wa(t.context,2048,!0):void 0,n=i.model?Wa(t.llm_model,256):void 0;return e({},r&&"{}"!==r?{intent:r}:{},n&&"unknown"!==n.toLowerCase()?{model:n}:{})}catch(t){return{}}}(u[0],o),p=function(t,i){var r=t[0];if(!v(r))return t;try{var n=i.intent&&qa(r,"context"),s=i.model&&qa(r,"llm_model");if(!n&&!s)return t;var a=e({},r);return n&&delete a.context,s&&delete a.llm_model,[a,...t.slice(1)]}catch(e){return t}}(u,o);try{c=r.apply(this===a?t:this,p)}catch(t){throw n.pm(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=Ga(t)?{error:t,errorResult:!0}:void 0;return n.pm(i,a,s,e,f),t},t=>{throw n.pm(i,a,s,{error:t,errorResult:!1},f),t});var g=Ga(c)?{error:c,errorResult:!0}:void 0;return n.pm(i,a,s,g,f),c}}),a}pm(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=Ha(l.config.capture_webmcp);if(h){n&&!a&&(a=Za(n.error,n.errorResult));try{l.capture("$mcp_tool_call",e({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{},h.intent&&s.intent?{$mcp_intent:s.intent,$mcp_intent_source:"context_parameter"}:{},h.model&&s.model?{$mcp_llm_model:s.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:r})}catch(t){continue}if(n&&a&&l.exceptions&&null!=(u=l.exceptionObserver)&&u.isEnabled)try{var c={$exception_list:Xa(l.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}},to={featureFlags:ra,sessionRecording:ts,autocapture:Nr,historyAutocapture:Rn,heatmaps:rs,deadClicksAutocapture:_n,webVitalsAutocapture:qn,exceptionObserver:wn,exceptions:ha,productTours:as,siteApps:us,surveys:Ds,tracingHeaders:Mn,toolbar:zs,experiments:pa,conversations:ya,logs:Ta,metrics:La,webMCP:Qa},eo={featureFlags:ra},io={sessionRecording:ts},ro={autocapture:Nr,historyAutocapture:Rn,heatmaps:rs,deadClicksAutocapture:_n,webVitalsAutocapture:qn},no={exceptionObserver:wn,exceptions:ha},so={productTours:as,featureFlags:ra},ao={siteApps:us},oo={surveys:Ds,featureFlags:ra},lo={tracingHeaders:Mn},uo={toolbar:zs},ho={experiments:pa,featureFlags:ra},co={conversations:ya},vo={logs:Ta},fo={metrics:La},po={webMCP:Qa};export{to as AllExtensions,ro as AnalyticsExtensions,co as ConversationsExtensions,no as ErrorTrackingExtensions,ho as ExperimentsExtensions,eo as FeatureFlagsExtensions,vo as LogsExtensions,fo as MetricsExtensions,so as ProductToursExtensions,io as SessionReplayExtensions,ao as SiteAppsExtensions,oo as SurveysExtensions,uo as ToolbarExtensions,lo as TracingExtensions,po as WebMCPExtensions};
|
|
2
2
|
//# sourceMappingURL=extension-bundles.js.map
|