posthog-js 1.447.10 → 1.447.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- 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),b=t=>"[object Number]"==u.call(t)&&t==t,_=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),b(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 R=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={}}},C="Android",O="Nintendo",M="PlayStation",I="Windows",j=/* @__PURE__ */new RegExp("BlackBerry|PlayBook|BB10","i"),D={"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,""]],[j,["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=D[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]?[C,[t[2],t[3],t[4]||"0"].join(".")]:[C,""]],[/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=[],b=0;50>s&&1e3>a&&g>b;b++){a++;var _=void 0;try{_=c.next(m[b])}catch(t){s++,_=n.coerceFallback(v(i+1))}_&&y.push(_)}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=_t(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function bt(t,e){for(var i=e.start;i>0&&gt(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function _t(t,e){for(var i=e.start+e.length,r=i;t.length>r&&gt(t[r],t[r-e.length]);)r++;return r-i}function wt(t,e){var i=e[0],r=t.length-(i?bt(t,i):0);for(var n of e)r-=_t(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.br(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.wr(t))&&void 0!==r?r:n.stack,synthetic:!0})}br(t){return p(t.message)&&t.message.length>0}wr(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]";for(var r=i.length;r>0;r--){var n=i.slice(0,r).join(", ");if(e>=n.length)return r===i.length?n:n.length>e?n.slice(0,e)+"...":n}return""}var Rt=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}}},Ct=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",jt=/* @__PURE__ */new Set([$t,It]),Dt={enabled:!0,max_bytes:32768};function Lt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Dt.enabled,max_bytes:zt(t.max_bytes,Dt.max_bytes)}:e({},Dt)}var Nt=class{constructor(t){this.ns=[],this.ss=0,this.Nr=Lt(t)}setConfig(t){this.Nr=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)&&!b(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.Nr.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.Nr.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function zt(t,e){if(!b(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:be(t,e),lastFieldSensitive:!1};var i=me(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function be(t,e){return e?xe(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function _e(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];_e(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])+Re(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 Re(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 Ce={}.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--,_(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(Ce.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 je(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 De=["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 De)({}).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=b(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 je(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.Nr=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.Is=!1,this.Ms=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.Is=!1,this.xs=0,this.$s=1,this.Ss.reset(),this.Rs=this.Nr.maxBatchRecordsPerPost}onReconnect(){this.xs=0,this.$s=1,this.Ss.isOpen()?this.Fs()&&this.Ds():this.ys()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ls(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")}}Ls(t){var e=this.Nr.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.Is=!1),this.Os>this.Ts?(this.Ts++,!0):(this.Is||(this.R.warn("captureLog dropping logs: exceeded "+this.Os+" logs per "+this.Ps+"ms"),this.Is=!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.Nr.maxBatchRecordsPerPost>t.Rs&&(t.Rs=Math.min(t.Nr.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.Nr,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.Ms>i.length||this.Ss.isOpen()?this.Ds():this.ys()}}Ds(){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.Nr=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.So({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.So({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.So({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.xo()});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.$o()?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.$o()?void 0:this.flush()))),this.Gs)}$o(){return this.xs>0||this.Ss.remainingMs()>0}drainWindow(){if(0===this.Vs.size)return null;var t=this.Vs;return this.Co(),this.To(t)}reset(){this._o++,this.Ss.reset(),this.xs=0,this.$s=1,this.gs.clear(),this.bs=null,this.Gs=null,this.Co(),this.Ks=/* @__PURE__ */new Map,this.Xs=!1}Co(){this.Vs=/* @__PURE__ */new Map,this.Qs=!1,this.Js=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ys=/* @__PURE__ */new Set}So(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ls(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.Io())&&("histogram"!==i.type||(s=this.Mo(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.Eo(a,i.value);var l=this.Ao();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Ds()}}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")}}Ao(){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}Io(){return this.Nr.maxSeriesPerFlush>this.Vs.size||(this.Qs||(this.Qs=!0,this.R.warn("Metric series cap reached ("+this.Nr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Mo(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.Ro(t,r,n,i),n;if(this.Ks.size>=this.Nr.maxSeriesPerFlush){if(this.Xs||(this.Xs=!0,this.R.warn("Histogram bounds limit reached ("+this.Nr.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")}Ro(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."))}Eo(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}}Ls(t){var e=this.Nr.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}Ds(){this.gs.pending||this.gs.arm(this.Ws())}Ws(){return Math.max(Ke(this.Nr.flushIntervalMs,this.xs,this.$s,3e4),this.Ss.remainingMs())}xo(){var t=this;return r(function*(){if(t.gs.clear(),0!==t.Vs.size){var e=t.Vs;t.Co();var i=t._o,r=yield t._instance.Po(t.To(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.Oo(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)}}})()}To(t){return e=this.Fo(t),i=function(t,e,i){return je(t,e,i)}(this.Nr,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}Fo(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())}Oo(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.Io()&&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.10.8",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 bi="$early_access_features",_i="$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",Ri="$flag_call_reported_session_id",Ci="$feature_flag_payloads",Oi="$override_feature_flags",Mi="$override_feature_flag_payloads",$i="visibilitychange",Ii="$autocapture_disabled_server_side";function ji(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Di(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&&Di(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=>_r(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Vi(t){var e="";return cr(t)&&!vr(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||!Di(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=>{Di(t)&&cr(t)&&!vr(t)&&(e+=" "+Vi(t),i=i||t.getAttribute("aria-label")||"",di(t.childNodes,r))};r(t);var n=(_r(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(_(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||!Di(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).targetElementList;return!(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,l))||Ji(l,i))}var ur=t=>!t||Li(t,"html")||!Di(t),hr=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ur(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,n=[t],s=t;s.parentNode&&!Li(s,"body");)if(zi(s.parentNode))n.push(s.parentNode.host),s=s.parentNode.host;else{var a=Xi(s);if(!a)break;if(e||Gi.indexOf(a.tagName.toLowerCase())>-1)r=!0;else try{var o=i.getComputedStyle(a);o&&"pointer"===o.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(a),s=a}return{parentIsUsefulElement:r,targetElementList:n}};function cr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r.parentNode&&!Li(r,"body");r=r.parentNode){if(i++>=1e3||e.has(r))return!1;e.add(r);var n=Hi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!1}if(s(Hi(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function vr(t){return!!(Li(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Li(t,"select")||Li(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var dr=/* @__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}))$"),fr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,pr=[16,15,14,13],gr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),mr=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),yr=/[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 _r(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?dr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(fr.lastIndex=0;e=fr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of pr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(dr.test(o)&&br(o))return!0}}}return!1}(t))return!1;if(e?gr.test(t):function(t){var e;for(mr.lastIndex=0;e=mr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&yr.test(i)&&yr.test(r)))return!0}return!1}(t))return!1}return!0}function wr(t){var e=Vi(t);return _r(e=(e+" "+xr(t)).trim())?e:""}function xr(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+" "+xr(t)).trim())}catch(t){hi.error("[AutoCapture]",t)}}),e}function Sr(t){return t.replace(/"|\\"/g,'\\"')}function kr(t){var e=t.attr__class;if(e)return h(e)?e:Bi(e)}var Er=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}},Ar=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)},Tr=()=>typeof window>"u"?void 0:window,Fr=()=>typeof document>"u"?void 0:document,Pr="$copy_autocapture",Rr=["password","hidden","file","checkbox","button","submit","reset","image"],Cr=/* @__PURE__ */ci("[AutoCapture]");function Or(t,e){return e.length>t?e.slice(0,t)+"...":e}function Mr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!Di(e));return e}function $r(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!Di(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;g.parentNode&&!Li(g,"body")&&1e3>d.length;)if(zi(g.parentNode)){var m=g.parentNode.host;if(f.has(m))break;f.add(m),d.push(m),g=m}else{if(!Di(g.parentNode))break;if(f.has(g.parentNode))break;f.add(g.parentNode),d.push(g.parentNode),g=g.parentNode}var y="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Li(t,"button")||Li(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!cr(t)||vr(t)));var b,_,w,x=[],S={},k=!1,E=!1;if(di(d,t=>{var e=cr(t);if(Li(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");k=!!(e&&i&&_r(i))&&(v?J(i):i)}s(Hi(t),"ph-no-capture")&&(E=!0),x.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()?Or(1024,wr(t)):Or(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(t.attributes,function(i){var s;if((!vr(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&_r(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]=Or(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=Mr(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(!cr(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&&_r(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(S,e)||(S[e]=t)})}),E)return{props:{},explicitNoCapture:E};if(y>0&&(t=d[y],x.splice(0,y)),l||(x[0].$el_text=Li(t,"a")||Li(t,"button")?wr(t):Vi(t)),k){var A,T;x[0].attr__href=k;var F=null==(A=Ar(k))?void 0:A.host,P=null==(T=Tr())||null==(T=T.location)?void 0:T.host;F&&P&&F!==P&&(b=k)}return{props:fi((_=a.type,{$event_type:_,$ce_version:1}),c?{}:{$elements:x},{$elements_chain:(w=x,h(w)?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[Sr(t[0].toString())]=Sr(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:kr(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})}(w)):"")},null!=(r=x[0])&&r.$el_text?{$el_text:null==(n=x[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},S),target:t}}var Ir=class{ba(){this._a=void 0,clearTimeout(this.wa),this.wa=void 0}ka(t){var e;if(!cr(t))return!0;for(var i,r=null!==(e=this.Sa().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")||vr(t)||r.some(e=>Ki(t,e)))return{v:!0};var i=a.parentNode;a=zi(i)?i.host:i&&Di(i)?i:null};a;)if(i=o())return i.v;return!1}xa(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this._a;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.ba():"pointerup"===t.type&&(e.released=!0,this.wa=setTimeout(()=>this.ba(),0)))}else{var i;this.ba();var r=Wi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&Di(r)&&(this._a={target:r,excluded:this.ka(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.zl)?void 0:i.distinctId})}else this.ba()}$a(t){var e,i=this._a;this.ba();var r=Wi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.zl)?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.Sa().css_selector_ignorelist)&&void 0!==n?n:Yi;return[r,null==(a=Fr())?void 0:a.documentElement,null==(o=Fr())?void 0:o.body].some(t=>{if(!t)return!1;var e=Hi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!cr(t)||vr(t)||l.some(e=>Ki(t,e))})?null:i.target}}constructor(t){this.Wl=t,this.name="autocapture",this.Ca=!1,this.Ta=null,this.Ia=!1,this.Ma=/* @__PURE__ */new Map,this.Ea=!1,this.Nr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Mi=!1,this.Wl.refresh(this.Nr),this.rageclicks=new Er(this.Nr.rageclick),this.Aa=null}setup(t){this.Ra(),this.zl=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Mi?e.dispose():(this.na=e,this.startIfEnabled())}dispose(){var t;this.Mi||(this.Mi=!0,this.zl=void 0,null==(t=this.na)||t.dispose(),this.na=void 0,this.Ma.clear(),this.Aa=null,this.Pa())}Sa(){return this.Wl.refresh(this.Nr),this.Nr}Ra(){var t,e;return this.Sa(),this.Nr.url_allowlist=null==(t=this.Nr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Nr.url_ignorelist=null==(e=this.Nr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Nr}Oa(){var t=Tr(),e=Fr();if(this.isBrowserSupported()){if(t&&e){this.Fa=t,this.Da=e;var i=this.La=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.ba();if(0===e.type.indexOf("pointer"))return void this.xa(e);var i="click"===e.type?this.$a(e):void 0;if(m(i))return;this.Na(e,"$autocapture",i)}catch(t){Cr.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.Sa().capture_copied_text){var r=this.ja=e=>{e=e||(null==t?void 0:t.event);try{this.Na(e,Pr)}catch(t){Cr.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 Cr.info("Disabling Automatic Event Collection because this browser is not supported")}Pa(){var t=this.Fa,e=this.Da;this.ba(),this.La&&(null==t||t.removeEventListener("blur",this.La),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.La,!0)}),null==e||e.removeEventListener("submit",this.La,!0),null==e||e.removeEventListener("change",this.La,!0),null==e||e.removeEventListener("click",this.La,!0),this.La=void 0),this.ja&&(null==e||e.removeEventListener("copy",this.ja,!0),null==e||e.removeEventListener("cut",this.ja,!0),null==e||e.removeEventListener("paste",this.ja,!0),this.ja=void 0),this.Fa=void 0,this.Da=void 0,this.Ca=!1}startIfEnabled(){this.isEnabled||this.ba(),!this.Mi&&this.zl&&this.isEnabled&&!this.Ca&&(this.Oa(),this.Ca=!0)}onRemoteConfig(t){if(!this.Mi)if(this.Ia=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.Ea=e.elementsChainAsString);var i,r=e.autocapture_opt_out;_(r)&&(null==(i=this.zl)||i.kv.set(Ii,r),this.Ta=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Mi){t.size?this.Ma.set(e,new Set(t)):this.Ma.delete(e);var i=/* @__PURE__ */new Set;this.Ma.forEach(t=>{t.forEach(t=>i.add(t))}),this.Aa=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.Aa)||i.forEach(i=>{var n;null==(n=Fr())||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.Mi)return!1;var i=null==(t=this.zl)?void 0:t.kv.get(Ii),r=this.Ta,n=this.Sa();if(!n.remoteRequestsDisabled&&!this.Ia)return!1;var s=n.remoteRequestsDisabled&&!this.Ia;if(m(r)&&!_(i)&&!s)return!1;var a=null!==(e=this.Ta)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Na(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.Ra();"$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.Na(t,"$rageclick",r);var l,u=i===Pr,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(!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=$r(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.Ea,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===Pr){var y=t.type||"clipboard";if("paste"!==y){var b,_,w=null==(b=Tr())||null==(b=b.getSelection())?void 0:b.toString(),x=qi(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(_=null==w?void 0:w.length)&&void 0!==_?_: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(!cr(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&&Di(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){Cr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.zl)||d.capture(i,g),!0}}else this.ba()}isBrowserSupported(){var t;return c(null==(t=Fr())?void 0:t.querySelectorAll)}},jr=["[data-ph-capture-value]"],Dr=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}},Lr="$surveys",Nr="$surveys_loaded_at",zr="PostHog loadExternalDependency extension not found.",Br="$surveys_activated",Ur="$surveys_activated_session",Hr="$surveys_activated_timestamps",qr="$heatmaps_enabled_server_side",Vr="$exception_capture_enabled_server_side",Wr="$error_tracking_suppression_rules",Gr="$error_tracking_capture_extension_exceptions",Kr="$web_vitals_enabled_server_side",Jr="$dead_clicks_enabled_server_side",Xr="$product_tours_enabled_server_side",Yr="$web_vitals_allowed_metrics",Zr="$session_recording_remote_config",Qr="$replay_override_sampling",tn="$replay_override_linked_flag",en="ph_product_tours",rn="$sdk_debug_recording_script_not_loaded",nn="$sdk_debug_replay_stale_config",sn="beforeunload",an="u">typeof window?window:void 0,on="u">typeof globalThis?globalThis:an,ln=null==on?void 0:on.navigator,un=null==on?void 0:on.document,hn=null==on?void 0:on.location;null!=on&&on.XMLHttpRequest&&new on.XMLHttpRequest;var cn="undefined"!=typeof globalThis?globalThis:an;cn&&"undefined"==typeof self&&(cn.self=cn),cn&&"undefined"==typeof File&&(cn.File=function(){});var vn=null!=an?an:{},dn=/* @__PURE__ */ci("[Dead Clicks]"),fn=()=>!0,pn=class{get lazyLoadedDeadClicksAutocapture(){return this.Va}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({[Jr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ga(()=>{this.Qa()}):this.stop()}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",e=>{e?dn.error("failed to load script",e):t()})}Qa(){var t;if(un){if(!this.Va&&null!=(t=vn.__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.Va=vn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Va.start(un),dn.info("starting...")}}else dn.error("`document` not found. Cannot start.")}stop(){this.Va&&(this.Va.stop(),this.Va=void 0,dn.info("stopping..."))}},gn=/* @__PURE__ */ci("[ExceptionAutocapture]"),mn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},yn=(t,e)=>t>=e&&mn(),bn=(t,e,i,r)=>{if(0===t){if(mn()){var n=e+1;return n===i&&r(),n}return e}return 0},_n=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},wn=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},xn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Sn=()=>{},kn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function En(t,e,i){try{if(!(e in t))return Sn;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=kn(i);s;){if(s.next===n)return void(s.next=r.next);s=kn(i=s.next)}else t[e]=r.next}}catch(t){return Sn}}var An=/* @__PURE__ */ci("[TracingHeaders]");function Tn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Fn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Pn=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Fn])(),Rn="<masked>",Cn=["li_fat_id"];var On=/* @__PURE__ */ci("[Web Vitals]"),Mn=9e5,$n=["CLS","FCP","INP","LCP"],In=["INP","LCP"],jn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Dn=/* @__PURE__ */ci("[RemoteConfig]"),Ln=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=vn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}yc(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}bc(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Dn.info("Using preloaded remote config",this.remoteConfig),void this._c(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Dn.warn("Remote config is disabled. Falling back to local config.");this.yc(t=>{if(!t)return Dn.info("No config found after loading remote JS config. Falling back to JSON."),void this.bc(t=>{this._c(t.json,t)});this._c(t)})}catch(t){Dn.error("Error loading remote config",t),this._c()}}_c(t,e){!t&&e&&(0===e.statusCode?e.error||Dn.warn("Failed to fetch remote config from PostHog."):Dn.error("Failed to fetch remote config from PostHog."));try{this._instance._c(t?{ok:!0,config:t}:{ok:!1})}catch(t){Dn.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){Dn.error("Error loading feature flags",t)}}},Nn="disabled",zn="lazy_loading",Bn=/* @__PURE__ */ci("[SessionRecording]"),Un=[rn,nn,"$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"],Hn=/* @__PURE__ */ci("[Heatmaps]");function qn(t){return v(t)&&"clientX"in t&&"clientY"in t&&b(t.clientX)&&b(t.clientY)}var Vn=/* @__PURE__ */ci("[Product Tours]"),Wn=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Xr))},Gn=/* @__PURE__ */ci("[SiteApps]"),Kn="Error while initializing PostHog app with config id ",Jn="events",Xn="cancelEvents",Yn="survey shown",Zn="survey dismissed",Qn="survey sent";function ts(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var es=(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}},is=t=>t.toLowerCase(),rs={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=>es(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!es(e,t))),icontains:(t,e)=>e.map(is).some(e=>t.map(is).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(is).every(e=>t.map(is).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 ns(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=rs[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var ss=/* @__PURE__ */ci("[Surveys]"),as=["popover","widget","api"],os=class{on(t,e){return this.Do[t]||(this.Do[t]=[]),this.Do[t].push(e),()=>{this.Do[t]=this.Do[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.Do[t]||[])i(e);for(var r of this.Do["*"]||[])r(t,e)}constructor(){this.Do={}}};function ls(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 us=class{constructor(t){this.Li=t,this.Lo=/* @__PURE__ */new Set,this.No=/* @__PURE__ */new Set,this.jo=new os,this.qo=(t,e)=>this.Bo(t,e)&&this.zo(t,e)&&this.Ho(t,e)&&this.Uo(t,e),this.Bo=(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.Li)?void 0:t.subscribeCapture)||(this.Wo=null==(e=this.Li)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.Wo)||t.call(this),this.Wo=void 0,null==(e=this.Li)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.jo=new os}register(t){var e,i;if(!f(null==(e=this.Li)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.Lo.add(t),null==(e=t.steps)||e.forEach(t=>{this.No.add((null==t?void 0:t.event)||"")})}),null!=(i=this.Li)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.Lo.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.Li.setElementSelectors(r,this)}}replace(t){this.Lo.clear(),this.No.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.No.has(t)||this.No.has(e.event))&&this.Lo.forEach(t=>{this.Vo(e,t)&&this.jo.emit("actionCaptured",t.name)})}Go(t){this.onAction("actionCaptured",e=>t(e))}Vo(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.qo(t,i))return!0;return!1}onAction(t,e){return this.jo.on(t,e)}zo(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.Li)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!ls(r,e.url,e.url_matching||"contains"))return!1}return!0}Ho(t,e){return!!this.Qo(t,e)&&!!this.Jo(t,e)&&!!this.Zo(t,e)}Qo(t,e){var i;if(null==e||!e.href)return!0;var r=this.Ko(t);if(r.length>0)return r.some(t=>ls(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&ls((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Jo(t,e){var i;if(null==e||!e.text)return!0;var r=this.Ko(t);if(r.length>0)return r.some(t=>ls(t.text,e.text,e.text_matching||"exact")||ls(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=>ls(t,s,a)))}Zo(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}Ko(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Uo(t,e){return null==e||!e.properties||0===e.properties.length||ns(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)}},hs=class{constructor(t,e){this.Yo=e,this.Xo=[],this.Li=t,this.tl=/* @__PURE__ */new Map,this.el=/* @__PURE__ */new Map,this.il=/* @__PURE__ */new Map}nl(){var t,e;this.sl=null==(t=(e=this.Li).subscribeSession)?void 0:t.call(e,t=>this.rl(t))}ll(t){return!1}al(){return null}ul(t){}cl(){}hl(t,e){return!!t&&ns(t.propertyFilters,null==e?void 0:e.properties)}dl(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}vl(t,e,i){var r=(i===Jn?this.tl:this.el).get(t),n=[];return this.fl(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.hl(s,e)})}register(t){this.pl(t,!1)}replace(t){this.pl(t,!0)}pl(t,e){f(this.Li.subscribeCapture)||(this.gl(t,e),this.ml(t,e))}ml(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.il.clear(),0!==i.length){this.yl||(this.yl=new us(this.Li),this.yl.init(),this.yl.Go(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.il.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.il.set(e.name,n)}})}),e?this.yl.replace(r):this.yl.register(r)}else{var n;e&&(null==(n=this.yl)||n.replace([]))}}bl(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)})}gl(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.dl(t,Jn),l=this.dl(t,Xn);e?(this.tl=o,this.el=l):(this.bl(this.tl,o),this.bl(this.el,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.Wo)&&void 0!==i||(this.Wo=null==(r=(n=this.Li).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this._l(),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.wl(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.kl([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.Sl(s),void this.xl([s])}if(this.el.has(t)){var o=this.vl(t,e,Xn);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.kl(o.map(t=>t.id)),o.forEach(t=>this.$l(t.id)))}if(this.tl.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.tl.get(t)});var l=this.vl(t,e,Jn);this.Cl(l.map(t=>t.id))}}onAction(t){this.il.has(t)&&this.Cl(this.il.get(t)||[])}Cl(t){if(0!==t.length){var e=!!this.Li.getSessionId(),i=[];for(var r of t)e&&this.ll(r)?this.Sl(r)&&this.Tl(r):i.push(r);i.length>0&&(this.Xo=[.../* @__PURE__ */new Set([...this.Xo,...i])]),this._l().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Il()}}Sl(t){this.Xo=this.Xo.filter(e=>e!==t);var e=this.Ml();return!e.includes(t)&&(this.El([...e,t]),this.Al(),!0)}kl(t){var e=new Set(t);this.Xo=this.Xo.filter(t=>!e.has(t));var i=this.Rl(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.El(r),0===r.length&&this.Pl()),this.xl(t),this.Il()}Il(){try{var t;null==(t=this.Yo)||t.call(this)}catch(t){this._l().error("Error while handling activated items change",t)}}Ol(){var t=this.al();if(!t)return{};var e=this.Li.getProperty(t);return e&&"object"==typeof e?e:{}}Tl(t){if(this.al()){var i=this.Ol();this.ul(e({},i,{[t]:Date.now()}))}}xl(t){if(this.al()){var e=this.Ol(),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.cl():this.ul(i))}}Fl(){this.al()&&this.cl()}getActivationTimestamp(t){if(this.Ml().includes(t)){var e=this.Ol()[t];return b(e)?e:void 0}}Rl(){var t=this.Dl();return this.Li.getProperty(t)||[]}Ml(){var t=this.Rl();if(0===t.length)return[];var e=this.Li.getProperty(this.Ll()),i=this.Li.getSessionId();return i&&e===i?t:[]}Al(){var t=this.Li.getSessionId();t&&this.Nl(t)}Pl(){this.jl()}rl(t){var e=this.Li.getProperty(this.Ll());if(e&&e!==t){var i=this.Rl(),r=this.Ol();i.length>0&&(this.El([]),i.filter(t=>b(r[t])).forEach(t=>this.$l(t))),this.Pl(),this.Fl(),i.length>0&&this.Il()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.Ml(),...this.Xo])].filter(t=>!this.ql(t))}dispose(){var t,e,i;null==(t=this.sl)||t.call(this),this.sl=void 0,null==(e=this.Wo)||e.call(this),this.Wo=void 0,null==(i=this.yl)||i.dispose(),this.yl=void 0}reset(){this.Xo=[],this.Rl().length>0&&this.El([]),this.Pl(),this.Fl(),this.Il()}getEventToItemsMap(){return this.tl}Bl(){return this.yl}},cs=class extends hs{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.zl=t,this.Hl=e,this.nl()}Dl(){return Br}Ll(){return Ur}al(){return Hr}ul(t){this.zl.kv.set({[Hr]:t})}cl(){this.zl.kv.remove(Hr)}ll(t){var e,i;this.fl(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return b(r)&&r>0}Ul(){return Yn}fl(t){this.Hl.getSurveys(t)}$l(t){this.Hl.cancelPendingSurvey(t)}_l(){return ss}El(t){this.zl.kv.set({[Br]:t})}Nl(t){this.zl.kv.set({[Ur]:t})}jl(){this.zl.kv.remove(Ur)}ql(){return!1}wl(t,e,i){var r,n;return t===Qn&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.fl(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return ts(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===Yn?"consume":"ignore":t===Yn?"persist":t===Zn||t===Qn?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},vs=(t,e)=>null!=t&&t.then?t.then(e):e(t),ds="SDK is not enabled or survey functionality is not yet loaded",fs="Disabled. Not loading surveys.",ps=class{constructor(t){this.Wl=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Vl=!1,this.Gl=!1,this.Ql=[],this.Jl=[],this.Zl=null,this.Kl=null,this.Mi=!1,this.Yl=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.Mi&&!this.Nr.disableSurveys){if(!t.ok)return this.Gl=!0,this.Xl({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),ss.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return ss.warn("Flags not loaded yet. Not loading surveys.");this.ta=_(e)?e:e.length>0,ss.info("flags response received, isSurveysEnabled: "+this.ta),this.loadIfEnabled()}},this.Xl=t=>{this.Jl.slice().forEach(e=>this.ea(e,t))}}setup(t){if(!this.Mi)return this.ia=t,vs(t.kv.initialize(),()=>{if(this.ia===t&&!this.Mi){this.ia=void 0,this.zl=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Mi?e.dispose():(this.na=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Mi||(this.Mi=!0,this.ia=void 0,this.zl=void 0,null==(t=this.na)||t.dispose(),this.na=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Ql=[],this.Jl.forEach(t=>{t.active=!1}),this.Jl=[],null==(r=this.sa)||r.call(this),this.sa=void 0,this.Zl=null,this.Yl.forEach(t=>clearTimeout(t)),this.Yl.clear())}get Nr(){return this.Wl.get()}getRenderContext(){if(this.zl){var t=this;return{client:this.zl,get config(){return t.Nr},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.Xl()}loadIfEnabled(){if(!this.Mi&&this.zl){var t=this.Nr;if(!this._surveyManager)if(this.Vl)ss.info("Already initializing surveys, skipping...");else if(t.disableSurveys)ss.info(fs);else if(t.cookielessMode&&this.zl.isOptedOut)ss.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Wl.getExtensions();if(e){if(!f(this.ta)||t.advancedEnableSurveys){var i=this.ta||t.advancedEnableSurveys;this.Vl=!0,this.Gl=!1;try{var r=e.generateSurveys;if(r)return this.oa(r,i),void(this.Vl=!1);var n=e.loadExternalDependency;if(!n)return this.ra(zr),void(this.Vl=!1);n(t=>{try{if(this.Mi)return;var e=this.Wl.getExtensions();t||null==e||!e.generateSurveys?this.ra("Could not load surveys script",t):this.oa(e.generateSurveys,i)}finally{this.Vl=!1}})}catch(t){throw this.Vl=!1,this.ra("Error initializing surveys",t),t}}}else this.ra("PostHog Extensions not found.")}}}oa(t,e){var i;if(!this.Mi){this._surveyManager=t(e),this._surveyEventReceiver=this.la(this.zl,this.Xl);var r=null==(i=this.zl)?void 0:i.kv.get(Lr);r&&this.aa(r),ss.info("Surveys loaded successfully"),this.ua(),this.Xl(),this.ca({isLoaded:!0})}}la(t,e){return new cs(t,this,void 0,e)}ra(t,e){this.Gl=!0,ss.error(t,e),this.Xl({isLoaded:!1,error:t}),this.ca({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ql.push(t),this._surveyManager&&this.ca({isLoaded:!0}),()=>{this.Ql=this.Ql.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Mi){var i=this.zl;if(!i)return t([],{isLoaded:!1,error:ds});if(this.Nr.disableSurveys)return ss.info(fs),t([]);var r=i.kv.get(Lr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.ha()&&this.getSurveys(()=>{},!0));if(this.Zl)this.Zl.then(e=>{this.Mi||t(e.surveys,e.context)}).catch(t=>ss.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Nr.requestTimeoutMs}).then(t=>{try{return this.da(i,t)}catch(t){return ss.error("Error processing surveys response",t),this.da(i,{statusCode:0,error:t})}},t=>this.da(i,{statusCode:0,error:t}));this.Zl=n;var s=()=>{this.Zl===n&&(this.Zl=null)};n.then(e=>{s(),this.Mi||(this.Xl(e.context),t(e.surveys,e.context))},s).catch(t=>ss.error("Error in survey callback",t))}}}da(t,e){if(this.Mi)return{surveys:[],context:{isLoaded:!1,error:ds}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?ss.error(r):e.error||ss.warn(r),this.Kl=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Kl=null;var n=e.json.surveys||[];return t.kv.set({[Lr]:n,[Nr]:Date.now()}),this.aa(n),{surveys:n,context:{isLoaded:!0}}}aa(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(ts(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.va(e)}va(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}ha(){return this.fa()&&!this.Zl&&!this.pa()}fa(){var t,e=null==(t=this.zl)?void 0:t.kv.get(Nr);return b(e)&&Date.now()-e>3e5}pa(){return b(this.Kl)&&3e5>Date.now()-this.Kl}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){ss.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.Xl()}ca(t){for(var e of this.Ql){if(this.Mi)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){ss.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ss.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Mi)return()=>{};var i={callback:t,active:!0,revision:0};this.Jl.push(i),this.ua();var r=null==(e=this.zl)?void 0:e.kv.get(Lr);return this.Nr.disableSurveys||!this._surveyManager&&this.Gl&&!this.Vl||!r&&!y(this.Kl)&&!this.Zl?this.ea(i,{isLoaded:!1}):this._surveyManager&&this.ea(i),()=>{var t;i.active=!1,this.Jl=this.Jl.filter(t=>t!==i),0===this.Jl.length&&(null==(t=this.sa)||t.call(this),this.sa=void 0)}}ua(){var t,e,i;this._surveyManager&&this.Jl.length>0&&(null!==(t=this.sa)&&void 0!==t||(this.sa=null==(e=(i=this.Wl).onMatchingConditionsChanged)?void 0:e.call(i,this.Xl)))}ea(t,e){if(!this.Mi&&t.active){var i=++t.revision,r=r=>{if(!this.Mi&&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){ss.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){ss.error("Error in active matching surveys callback",t)}}}ga(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}ma(t){if(y(this._surveyManager))return{eligible:!1,reason:ds};var e="string"==typeof t?this.ga(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}ya(t){var e;if(null==(e=this.zl)||!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:ds};var i="string"==typeof t?this.ga(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return ss.warn("init was not called"),{visible:!1,disabledReason:ds};var e=this.ya(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(ss.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ds})):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.ya(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.zl)&&r.canCapture)if(y(this._surveyManager))ss.warn("init was not called");else{var a="string"==typeof t?this.ga(t):t;if(null!=a&&a.id)if(as.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){ss.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.Yl.delete(l),!this.Mi&&null!=(t=this.zl)&&t.canCapture&&(ss.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),ss.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.Yl.add(l)}else this._surveyManager.renderSurvey(a,o,i);else ss.warn("Survey element not found")}else ss.warn("Surveys of type "+a.type+" cannot be rendered in the app");else ss.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.zl)&&r.canCapture)if(y(this._surveyManager))ss.warn("init was not called");else{var s=this.ga(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&&ss.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.ma(s);if(!o.eligible)return void ss.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 ss.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?ss.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.447.10",li.LIB_NAME="web";var gs,ms=li,ys=/* @__PURE__ */new WeakMap,bs=()=>{var t;return null!=an&&null!=(t=an.performance)&&t.now?an.performance.now():Date.now()},_s=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==vn?void 0:vn.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=t.loadExternalDependency;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!==Yn&&e!==Zn&&e!==Qn||t()}),n=()=>t();gi(an,"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==an||an.removeEventListener("PHSurveyShown",n)}}},ws=/* @__PURE__ */(()=>null!=an&&an.location?xn(an.location.hash,"__posthog")||xn(location.hash,"state"):null)(),xs="_postHogToolbarParams",Ss=/* @__PURE__ */ci("[Toolbar]"),ks=/* @__PURE__ */ci("[FeatureFlags]"),Es=/* @__PURE__ */ci("[FeatureFlags]",{debugEnabled:!0}),As="\" failed. Feature flags didn't load in time.",Ts=[502,504],Fs=["click","keydown","wheel","touchstart","pointerdown"],Ps="connection_error",Rs=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Cs=t=>{var e={};for(var i of pi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Os=(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),Ms=class{constructor(t){this.name="featureFlags",this.Qd=!1,this.featureFlagEventHandlers=[],this.R=ks,this.Jd={},this.Zd={},this.Kd=[],this.Yd=/* @__PURE__ */new Set,this.Xd=/* @__PURE__ */new Set,this.tv=!1,this.ev=!1,this.iv=0,this.nv=!1,this.sv=!1,this.rv=!1,this.ov=/* @__PURE__ */new Map,this.lv=!1,this.av=!1,this.uv=!1,this.hv=0,this.dv=!1,this.an=()=>{var t=this.vv();this.hv=0,t&&this.reloadFeatureFlags()},this.fv=()=>{var t,e,i=this.pv,r=null!==(t=this.gv)&&void 0!==t?t:i;f(i)||f(r)||this.Nr.remoteRequestsDisabled||!this.mv||"hidden"===this.mv.visibilityState||Date.now()-(null!==(e=this.yv)&&void 0!==e?e:0)<r||(this.gv=this.dv||!this.Nr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.dv=!1,this.reloadFeatureFlags(),this.bv())},this._v=()=>{this.dv&&this.gv===this.pv||this.wv()},this.ln=()=>{var t;"visible"===(null==(t=this.mv)?void 0:t.visibilityState)&&this.wv()},this.Wl=t}get Sv(){}xv(){this.zl&&this.$v()}setup(t){try{this.Cv=typeof window>"u"?void 0:window,this.mv=typeof document>"u"?void 0:document}catch(t){this.Cv=void 0,this.mv=void 0}return this.ia=t,this.R=t.logger.createLogger("[FeatureFlags]"),vs(t.kv.initialize(),()=>{this.ia===t&&(this.ia=void 0,this.zl=t,this.Tv(t))})}Tv(t){var e;if(this.zl===t)return this.Cv&&gi(this.Cv,"online",this.an),this.$v(),this.Iv=t.registerDynamicEventProperties(()=>this.Mv()?this.Jd:this.Zd),this.Ev=null==(e=this.Sv)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Av(),this.Rv(),this.Pv()}),this.Rv(),this.initialize()}wv(){this.dv=!0,this.gv=this.pv,this.fv()}$v(){var t,e=this.Nr.refreshIntervalMs,i=!this.Nr.remoteRequestsDisabled&&this.mv&&!f(e)&&e>0?e:void 0;this.Nr.idleRefreshBackoff||(this.gv=i),i!==this.pv&&(this.Ov(),f(i)||(this.pv=i,this.gv=i,this.bv(),null!=(t=this.mv)&&t.addEventListener&&(gi(this.mv,$i,this.ln),vi(Fs,t=>{gi(this.mv,t,this._v,{capture:!0})}))))}bv(){f(this.pv)||(f(this.Fv)||clearInterval(this.Fv),this.yv=Date.now(),this.Fv=setInterval(this.fv,this.pv))}Ov(){var t;f(this.Fv)||(clearInterval(this.Fv),this.Fv=void 0,null==(t=this.mv)||null==t.removeEventListener||t.removeEventListener($i,this.ln),vi(Fs,t=>{var e;null==(e=this.mv)||null==e.removeEventListener||e.removeEventListener(t,this._v,{capture:!0})})),this.pv=void 0,this.gv=void 0,this.dv=!1,this.yv=void 0}destroy(){this.Dv()}dispose(){this.Dv()}Dv(){var t,e,i;this.Ov(),this.iv++,this.sv=!1,this.ia=void 0,this.Lv(this.Yd,"cancelled"),this.Lv(this.Xd,"cancelled"),this.zl&&(this.Nv(),null==(t=this.Iv)||t.dispose(),this.Iv=void 0,null==(e=this.Ev)||e.call(this),this.Ev=void 0,this.Kd=[],null==(i=this.Cv)||i.removeEventListener("online",this.an),this.zl=void 0)}get Nr(){return this.Wl.get()}jv(t){var e;return this.qv&&t in this.qv?this.qv[t]:null==(e=this.zl)?void 0:e.kv.get(t)}Av(){return!!this.qv&&(this.qv=void 0,!0)}Bv(){var t;return!f(null==(t=this.zl)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Av()}$t(t){this.zv(()=>{var e;return null==(e=this.zl)?void 0:e.kv.set(t)})}Hv(t,e,i){if(this.Sv&&t.$enabled_feature_flags){var r=this.jv("$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?a:i&&!h(s)?Object.keys(s||{}):Array.from(/* @__PURE__ */new Set([...Object.keys(r),...Object.keys(n)])),u=this.jv("$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={[_i]:p,[Ai]:p,[Ci]:g};for(var y of(t.$feature_flag_details&&(m[wi]=p),[ki,Si,Ei]))f(t[y])||(m[y]=!0);this.Sv.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.zv(()=>{var e;return null==(e=this.zl)?void 0:e.kv.remove(t)})}zv(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}Rv(){var t={};for(var i of[_i,Ci,ki,Oi]){var r=this.jv(i);f(r)||(t[i]=r)}this.Jd=t;var n=e({},t),s=this.jv(Ai);if(s)for(var a of Object.entries(s))n["$feature/"+a[0]]=a[1];this.Zd=n}Mv(){var t=this.Nr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.jv(Si);return"number"!=typeof e||Date.now()-e>t}Uv(){return!!this.Mv()&&(this.uv||this.ev||(this.uv=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Wv(){var t=this.Nr.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}):[]}Vv(){var t=this.Nr.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.Nr,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.Gv({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n,s,a=null!=r&&r.merge&&null!==(n=this.jv("$enabled_feature_flags"))&&void 0!==n?n:{},o=null!=r&&r.merge&&null!==(s=this.jv("$feature_flag_payloads"))&&void 0!==s?s:{},l=e({},a,t),u=e({},o,i),h={};for(var c of Object.entries(l)){var v=c[0],d=c[1];h[v]={key:v,enabled:Ut(d),variant:Ht(d),reason:void 0,metadata:f(null==u?void 0:u[v])?void 0:{id:0,version:void 0,description:void 0,payload:u[v]}}}this.Gv({flags:h})}get hasLoadedFlags(){return this.tv}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.jv(wi),i=this.jv(Oi),r=this.jv(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.Qd||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.Qd=!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=this.jv(Ai),e=this.jv(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.Qd||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Qd=!0),i}getFlagPayloads(){var t=this.jv(Ci),e=this.jv(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.Qd||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Qd=!0),i}reloadFeatureFlags(){this.nv||this.Nr.featureFlagsDisabled||this.vv()||(this.rv&&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.ev&&(this.sv=!0),this.Qv||(this.Kd.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}}),this.Qv=setTimeout(()=>{this.Jv()},5)))}reloadFeatureFlagsAsync(){return!this.zl||this.nv||this.Nr.featureFlagsDisabled||this.Nr.remoteRequestsDisabled||this.vv()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.Yd.add(t),this.reloadFeatureFlags()})}Lv(t,e){t.forEach(t=>t({status:e})),t.clear()}Nv(){clearTimeout(this.Qv),this.Qv=void 0}onReloading(t){return this.Kd.push(t),()=>{this.Kd=this.Kd.filter(e=>e!==t)}}ensureFlagsLoaded(){this.tv||this.ev||this.Qv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.nv=t}resetFlagCallReported(){this.Dt(Pi),this.ov=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.ov.size&&!this.lv&&null!=(t=this.zl)&&t.canCapture&&!this.zl.isRateLimited){this.lv=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.ov.keys())){var r=this.ov.get(i);if(r){if(r.value!==String(e[i])||!Os(r.context,this.Zv())){this.ov.delete(i);continue}if(this.getFeatureFlagResult(i),this.ov.has(i))break}}}finally{this.lv=!1}}}Jv(t){var i;this.Nv();var r=this.zl;if(!r||this.Nr.remoteRequestsDisabled||this.vv())this.Lv(this.Yd,"skipped");else if(this.ev)this.sv=!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.jv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.jv(Ti),timezone:Tn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Nr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.Wv();s.length&&(n.evaluation_contexts=s);var a=this.Vv();f(a)||(n.flag_keys=a);var o=this.Nr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.iv,h=this.Yd;this.Yd=/* @__PURE__ */new Set,this.Xd=h,this.ev=!0;var c=()=>{this.sv&&(this.sv=!1,this.Jv())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.ev=!1,u===this.iv)if(this.Kv(t.statusCode),s||this.sv||(this.$anon_distinct_id=void 0),!n.disable_flags||this.sv){this.av=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ps:"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.Gv(r,s,{partialResponse:o}),this.Lv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.Lv(h,"skipped");else c()},d=t=>{this.ev=!1,u===this.iv?(this.$t({[xi]:[Ps]}),this.R.error("Feature flag request failed",t),this.Bv()&&this.Pv(!0),this.Lv(h,"error"),c()):c()},p=null!==(i=this.Nr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.iv,m=()=>{if(u!==this.iv||!this.zl||this.Nr.remoteRequestsDisabled)return this.ev=!1,this.Lv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Nr.compression,sentAt:"body",timeoutMs:this.Nr.requestTimeoutMs}).then(t=>{if((t=>Ts.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()}}vv(){return yn(this.hv,3)}Kv(t){this.hv=bn(t,this.hv,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."))}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.av)if(this.tv||this.getFlags()&&this.getFlags().length>0){if(!this.Uv()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else this.R.warn('getFeatureFlag for key "'+t+As)}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){if(void 0===i&&(i={}),!i.fresh||this.av)if(this.tv||this.getFlags()&&this.getFlags().length>0){if(!this.Uv()){var r,n=this.getFlagVariants(),s=t in n,a=n[t],o=this.getFlagPayloads()[t],l=String(a),u=this.jv("$feature_flag_request_id")||void 0,c=this.jv("$feature_flag_evaluated_at")||void 0,v=this.jv("$flag_call_reported")||{};if(this.Nr.deduplicateCallsPerSession){var d,p=null==(d=this.zl)||null==(d=d.session)?void 0:d.sessionId,g=this.jv(Ri);p&&p!==g&&(v={},r=p)}if(!i.send_event&&"send_event"in i)r&&this.$t({[Pi]:v,[Ri]:r});else{var m,y,b,_,w=!(null!=(m=this.zl)&&m.canCapture),x=!(w||null!=(y=this.zl)&&y.isRateLimited);if(x?this.ov.delete(t):(w&&Object.keys(v).length>0&&(v={},this.$t({[Pi]:v})),null!=(_=v[t])&&_.includes(l)||this.Yv(t,l)),!x||null!=(b=v[t])&&b.includes(l))r&&this.$t({[Pi]:v,[Ri]:r});else{var S,k,E,A,T,F,P,R,C,O,M,I,j;h(v[t])?v[t].push(l):v[t]=[l],this.$t(e({[Pi]:v},r?{[Ri]:r}:{}));var D=this.getFeatureFlagDetails(t),L=[...null!==(S=this.jv("$feature_flag_errors"))&&void 0!==S?S:[]];f(a)&&L.push("flag_missing");var N={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:null!==(k=null==(E=this.Nr.bootstrap)||null==(E=E.featureFlags)?void 0:E[t])&&void 0!==k?k:null,$feature_flag_bootstrapped_payload:null!==(A=null==(T=this.Nr.bootstrap)||null==(T=T.featureFlagPayloads)?void 0:T[t])&&void 0!==A?A:null,$used_bootstrap_value:!this.av};f(null==D||null==(F=D.metadata)?void 0:F.has_experiment)||(N.$feature_flag_has_experiment=D.metadata.has_experiment),f(null==D||null==(P=D.metadata)?void 0:P.version)||(N.$feature_flag_version=D.metadata.version);var z=null!==(R=null==D||null==(C=D.reason)?void 0:C.description)&&void 0!==R?R:null==D||null==(O=D.reason)?void 0:O.code;z&&(N.$feature_flag_reason=z),null!=D&&null!=(M=D.metadata)&&M.id&&(N.$feature_flag_id=D.metadata.id),f(null==D?void 0:D.original_variant)&&f(null==D?void 0:D.original_enabled)||(N.$feature_flag_original_response=f(D.original_variant)?D.original_enabled:D.original_variant),null!=D&&null!=(I=D.metadata)&&I.original_payload&&(N.$feature_flag_original_payload=null==D||null==(j=D.metadata)?void 0:j.original_payload),L.length&&(N.$feature_flag_error=L.join(",")),this.Xv(N)||(this.tf(t,l),this.Yv(t,l))}}if(s)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:Bt(o)}}}else this.R.warn('getFeatureFlagResult for key "'+t+As)}Xv(t){try{var e;return!1!==(null==(e=this.zl)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}Yv(t,e){this.ov.set(t,{value:e,context:this.Zv()})}Zv(){var t,i,r;return{distinctId:null==(t=this.zl)?void 0:t.distinctId,groups:e({},null==(i=this.zl)?void 0:i.groups),sessionId:this.Nr.deduplicateCallsPerSession?null==(r=this.zl)||null==(r=r.session)?void 0:r.sessionId:void 0}}tf(t,e){var i=this.jv("$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.ef(t,e)}ef(t,e){var i=this;return r(function*(){var r=i.zl;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.Wv();s.length&&(n.evaluation_contexts=s);var a,o=i.Vv();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.Nr.compression,sentAt:"body",timeoutMs:i.Nr.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.av)return e.defaultValue;if(!(this.tv||this.getFlags()&&this.getFlags().length>0))return this.R.warn('isFeatureEnabled for key "'+t+As),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.Gv(t,e,i)}Gv(t,i,r){if(this.zl){this.tv=!0;var n=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=ks);var o=((t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).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].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)})(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{[_i]:u,[Ai]:p,[Ei]:!1}}var m=u,y=c,b=l;if(null!=s&&s.partialResponse){var _=Object.keys(m),w=y||{};m=e({},i,m),y=e({},r,w),_.forEach(t=>{var e;t in w||null==(e=y)||delete e[t]}),b=e({},n,b)}else if(t.errorsWhileComputingFlags)if(l){var x=new Set(Object.keys(l).filter(t=>{var e;return!(null!=(e=l[t])&&e.failed)}));m=e({},i,Object.fromEntries(Object.entries(m).filter(t=>x.has(t[0]))));var S=Object.fromEntries(Object.entries(y||{}).filter(t=>x.has(t[0])));y=e({},r,S),x.forEach(t=>{var e;t in S||null==(e=y)||delete e[t]}),b=e({},n,Object.fromEntries(Object.entries(b||{}).filter(t=>x.has(t[0]))))}else m=e({},i,m),y=e({},r,y),b=e({},n,b);return e({[_i]:Object.keys(Cs(m)),[Ai]:m||{},[Ci]:y||{},[wi]:b||{},[Ei]:!0===t.minimalFlagCalledEvents},v?{[ki]:v}:{},d?{[Si]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.R);if(n)if(!1===(null==r?void 0:r.persist)){var s=!f(this.zl.kv.get(Ai));this.qv=n,s||this.$t(n)}else this.Av(),this.Hv(n,t,!(null==r||!r.partialResponse)),this.$t(n);else i&&this.Bv();i||(this.uv=!1),this.Pv(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.if(t)}if(t){if(this.zl){if(!1===t)return this.Dt([Oi,Mi]),this.Pv(),void Es.info("All overrides cleared");if(h(t))return this.$t({[Oi]:Rs(t)}),this.Pv(),void Es.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.Qd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Oi]=h(n)?Rs(n):n),s&&(r[Mi]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Oi,Mi]):!1===n?this.Dt(Oi):!1===s&&this.Dt(Mi),this.Pv(),!1===n?Es.info("Flag overrides cleared"):n&&Es.info("Flag overrides set",{flags:n}),void(!1===s?Es.info("Payload overrides cleared"):s&&Es.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Oi]:t}),this.Pv(),void Es.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.tv){var e=this.nf(),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=(this.jv("$early_access_features")||[]).find(e=>e.flagKey===t),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};s&&(o.$early_access_feature_name=s.name),r&&(o.$feature_enrollment_stage=r);var l=e({},this.getFlagVariants(),{[t]:i});null==(n=this.Sv)||n.markCrossTabFeatureFlagChanges({[_i]:[t],[Ai]:[t],[Fi]:Object.keys(a)}),this.$t({[_i]:Object.keys(Cs(l)),[Ai]:l,[Fi]:e({},this.jv("$stored_person_properties")||{},a)}),this.Pv();try{var u;null==(u=this.zl)||u.capture("$feature_enrollment_update",o)}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.jv(bi);!r||e?this.sf(t,i):t(r)}sf(t,e){var i=this;return r(function*(){var r=i.zl;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({[bi]: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)}}})()}nf(){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),{})}}Pv(t){this.Rv();var e=this.nf(),i=e.flags,r=e.flagVariants,n=this.rv;this.rv=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.rv=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.rf(t,e)}rf(t,i){void 0===i&&(i=!0);var r=this.jv("$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.jv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Fi]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Fi),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.jv("$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.jv("$stored_group_properties")||{};this.$t({[Ti]:e({},i,{[t]:{}})})}else this.Dt(Ti)}reset(){this.iv++,this.Lv(this.Yd,"cancelled"),this.Lv(this.Xd,"cancelled"),this.sv=!1,this.Jd={},this.Zd={},this.qv=void 0,this.tv=!1,this.nv=!1,this.av=!1,this.$anon_distinct_id=void 0,this.Nv(),this.Qd=!1,this.hv=0,this.ov=/* @__PURE__ */new Map}},$s=/* @__PURE__ */ci("[FeatureFlags]"),Is=class{constructor(t,e){void 0===e&&(e=!1),this.lf=!1,this.update(t,e)}update(t,e){this.af=((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.lf||($s.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.lf=!0),f(t.flag_keys)||h(t.flag_keys)||$s.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.af}},js=class extends Ms{constructor(t){var e=new Is(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.uf=e}get Sv(){return this._instance.persistence}updateConfig(t,e){this.uf.update(t,e),this.xv()}},Ds=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Ls=/* @__PURE__ */ci("[Error tracking]"),Ns="webkit-masked-url:",zs=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Bs=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ns],Us=["__firefox__","__gCrWeb"],Hs=/*#__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),b=Array.isArray,_=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),R=I({}.hasOwnProperty),C=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 j(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_;if(r&&r(t,null),!b(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 D(t){for(var e=0;t.length>e;e++)R(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];R(t,a)&&(r[a]=b(o)?D(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 R(t,e)&&b(t[e])?j(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,D=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"),bt=N(dt,"shadowRoot"),_t=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.')},Rt=function(t){Pt(),Ft++;try{return n.createHTML(t)}finally{Ft--}},Ct=s.implementation,Ot=s.createNodeIterator,Mt=s.createDocumentFragment,$t=s.getElementsByTagName,It=a.importNode,jt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof i&&"function"==typeof yt&&Ct&&void 0!==Ct.createHTMLDocument;var Dt=Y,Lt=Z,Nt=Q,zt=tt,Bt=et,Ut=rt,Ht=nt,qt=at,Vt=it,Wt=null,Gt=j({},[...z,...B,...U,...q,...W]),Kt=null,Jt=j({},[...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,be={},_e=null,we=j({},["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=j({},["audio","video","img","source","image","track"]),ke=null,Ee=j({},["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,Re=!1,Ce=null,Oe=j({},[Ae,Te,Fe],w),Me=o(["mi","mo","mn","ms","mtext"]),$e=j({},Me),Ie=o(["annotation-xml"]),je=j({},Ie),De=j({},["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:_}),Kt=vt(t,"ALLOWED_ATTR",Jt,{transform:ze}),Ce=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}),_e=vt(t,"FORBID_CONTENTS",we,{transform:ze}),Yt=vt(t,"FORBID_TAGS",L({}),{transform:ze}),Zt=vt(t,"FORBID_ATTR",L({}),{transform:ze}),be=!!R(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=R(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?L(t.MATHML_TEXT_INTEGRATION_POINTS):j({},Me),je=R(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?L(t.HTML_INTEGRATION_POINTS):j({},Ie);var e=R(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),R(e,"tagNameCheck")&&He(e.tagNameCheck)&&(Xt.tagNameCheck=e.tagNameCheck),R(e,"attributeNameCheck")&&He(e.attributeNameCheck)&&(Xt.attributeNameCheck=e.attributeNameCheck),R(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(Xt.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),l(Xt),ne&&(ee=!1),ve&&(ce=!0),be&&(Wt=j({},W),Kt=u(null),!0===be.html&&(j(Wt,z),j(Kt,G)),!0===be.svg&&(j(Wt,B),j(Kt,K),j(Kt,X)),!0===be.svgFilters&&(j(Wt,U),j(Kt,K),j(Kt,X)),!0===be.mathMl&&(j(Wt,q),j(Kt,J),j(Kt,X))),Qt.tagCheck=null,Qt.attributeCheck=null,R(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Qt.tagCheck=t.ADD_TAGS:b(t.ADD_TAGS)&&(Wt===Gt&&(Wt=L(Wt)),j(Wt,t.ADD_TAGS,ze))),R(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Qt.attributeCheck=t.ADD_ATTR:b(t.ADD_ATTR)&&(Kt===Jt&&(Kt=L(Kt)),j(Kt,t.ADD_ATTR,ze))),R(t,"ADD_URI_SAFE_ATTR")&&b(t.ADD_URI_SAFE_ATTR)&&j(ke,t.ADD_URI_SAFE_ATTR,ze),R(t,"FORBID_CONTENTS")&&b(t.FORBID_CONTENTS)&&(_e===we&&(_e=L(_e)),j(_e,t.FORBID_CONTENTS,ze)),R(t,"ADD_FORBID_CONTENTS")&&b(t.ADD_FORBID_CONTENTS)&&(_e===we&&(_e=L(_e)),j(_e,t.ADD_FORBID_CONTENTS,ze)),me&&(Wt["#text"]=!0),ae&&j(Wt,["html","head","body"]),Wt.table&&(j(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=Rt("")}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}}(D,h),Tt=!0),n=Et),n&&"string"==typeof At&&(At=Rt("")));o&&o(t),Be=t}},Ve=j({},[...B,...U,...H]),We=j({},[...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=_t(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=_t(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?Rt(t):t;if(Pe===Fe)try{e=(new I).parseFromString(a,Le)}catch(t){}if(!e||!e.documentElement){e=Ct.createDocument(Pe,"template",null);try{e.documentElement.innerHTML=Re?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,Dt," "),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!==_t(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(jt.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(jt.uponSanitizeElement,Wt,Gt,le),si(jt.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&&!_e[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(jt.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=_(t.tagName),r=_(e.tagName);return!!Ce[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&&je[i]:Boolean(We[t])}(i,e,r):t.namespaceURI===Fe?function(t,e,i){return!(e.namespaceURI===Te&&!je[i])&&!(e.namespaceURI===Ae&&!$e[i])&&!We[t]&&(De[t]||!Ve[t])}(i,e,r):!("application/xhtml+xml"!==Le||!Ce[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(jt.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=j({},["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[_(t)]&&O(qt,t)},ci=function(t,e,i,r){if(n&&"object"==typeof D&&"function"==typeof D.getAttributeType&&!i)switch(D.getAttributeType(t,e)){case"TrustedHTML":return Rt(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(jt.beforeSanitizeAttributes,t,null);var e=t.attributes;if(e&&!ii(t)){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Kt=ai(jt.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(jt.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(jt.afterSanitizeAttributes,t,null)}},fi=function(t){var e=null,i=Qe(t);for(si(jt.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if(si(jt.uponSanitizeShadowNode,e,null),oi(e,t),di(e),ri(e.content)&&fi(e.content),1===(wt?wt(e):e.nodeType)){var r=bt(e);ri(r)&&(pi(r),fi(r))}si(jt.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=bt(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((Re=!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 C(t);case"function":case"object":if(null===t)return C(t);var e=t,i=N(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:C(r)}return C(t)}}(t)))throw M("dirty is not a string, aborting");if(!r.isSupported)return t;oe?(Wt=le,Kt=ue):qe(e),(jt.uponSanitizeElement.length>0||jt.uponSanitizeAttribute.length>0)&&(Wt=L(Wt)),jt.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?Rt(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?Rt(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&&R(jt,t)&&m(jt[t],e)},r.removeHook=function(t,e){if(R(jt,t)){if(void 0!==e){var i=p(jt[t],e);return-1===i?void 0:y(jt[t],i,1)[0]}return g(jt[t])}},r.removeHooks=function(t){R(jt,t)&&(jt[t]=[])},r.removeAllHooks=function(){jt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}()}(),qs="Refusing to render web experiment since the viewer is a likely bot",Vs={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Ws={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>es(e,t),not_regex:(t,e)=>!es(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},Gs=/* @__PURE__ */ci("[Conversations]"),Ks="Conversations not available yet.";function Js(){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 Xs(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({},Js(),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 Ys=["debug","log","warn","error","info"],Zs="console",Qs="__posthogHandledLogsRequestError",ta=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[Qs]=!0,i},ea=t=>!!t&&"object"==typeof t&&!0===t[Qs],ia=class{get cf(){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.Wl=t,this.hf=e,this.name="logs",this.df=!1,this.vf=!1,this.ff=!1,this.R=ci("[logs]"),this.Sc=[],this.pf=[],this.hv=0,this.gf=!1,this.Mi=!1,this.mf=[],this.yf=[],this.bf=!1,this._f=!1,this.wf=!1,this.kf=()=>{var t,e;this.Mi||(this.hv=0,null==(t=this.Sf)||t.onReconnect(),null==(e=this.xf)||e.onReconnect())},this.df=!(null==(i=t.get())||!i.captureConsoleLogs)}get $f(){return!0}Cf(){}Tf(){if(!this.wf){try{this.Cv=typeof window>"u"?void 0:window}catch(t){this.Cv=void 0}this.Cv&&(gi(this.Cv,"online",this.kf),this.wf=!0)}}If(t,e,i,r){this.Tf();var n=Xs(this.Wl.get(),i);return[new Je(this.Mf(t,e),n,this.cf,()=>this.hf(),t=>t(),void 0,r),n]}Ef(){var t=this.Wl.get();if(!this.Sf||this.Af!==t){var e;null==(e=this.Sf)||e.reset(),this.Af=t;var i=this.If(()=>this.Sc,t=>{this.Sc=t});this.Sf=i[0],this.Rf=i[1]}return this.Sf}Pf(){var t=this.Wl.get();if(!this.xf||this.Of!==t){var e;null==(e=this.xf)||e.reset(),this.Of=t;var i=this.If(()=>this.pf,t=>{this.pf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Zs);this.xf=i[0],this.Ff=i[1]}return this.xf}setup(t){if(!this.Mi&&!this.gf)return this.gf=!0,this.zl=t,this.R=t.logger.createLogger("[logs]"),vs(t.kv.initialize(),()=>{this.Mi||this.Tv(t)})}Tv(t){var e;this.Tf(),null!=(e=this.Wl.get())&&e.captureConsoleLogs&&(this.df=!0),(this.df||this.Wl.remoteConfigWillArrive&&t.kv.get(this.Wl.captureHintKey))&&this.Df();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.Mi?r.dispose():(this.na=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Mi||(this.Mi=!0,this.Lf(),null==(t=this.na)||t.dispose(),this.na=void 0,this.zl=void 0,this.ff=!1,null==(e=this.Cv)||e.removeEventListener("online",this.kf),null==(i=this.Nf)||i.call(this),this.Nf=void 0,null==(r=this.Sf)||r.clearQueue(),null==(n=this.xf)||n.clearQueue(),null==(s=this.Sf)||s.reset(),null==(a=this.xf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Mi){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.jf():(null==(i=this.zl)||i.kv.set(this.Wl.captureHintKey,!!r),r?(this.df=!0,this.vf||this.Df(),this.loadIfEnabled()):this.jf())}}reset(){var t,e,i,r;this.Lf(),null==(t=this.Sf)||t.clearQueue(),this.Sc=[],null==(e=this.Sf)||e.reset(),null==(i=this.xf)||i.clearQueue(),this.pf=[],null==(r=this.xf)||r.reset(),this.hv=0}captureLog(t){!this.Mi&&this.zl&&this.Ef().captureLog(t)}captureConsoleLog(t){!this.Mi&&this.zl&&this.Pf().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Mi&&this.zl&&this.Pf().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.Lf(),null==(t=this.xf)||t.clearQueue(),this.pf=[]}jf(){this.df||this.Lf()}Df(){var t,e=this;if(!this.bf&&null!=(t=this.Cv)&&t.console){var i=Xs(this.Wl.get()).maxBufferSize,r=!0;this.yf.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.Cv.console[t])}catch(t){return 1}n&&e.yf.push(En(e.Cv.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.qf(t,a,i)}catch(t){}return s.apply(e.Cv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of Ys)if(n(s))continue;this.bf=!0,this.Bf=setTimeout(()=>{this.Lf()},3e4)}}qf(t,e,i){var r;if(this.bf&&!this._f&&0!==e.length)if(null!=(r=this.zl)&&r.canCapture){if(i>this.mf.length){this._f=!0;try{this.mf.push({level:t,args:e,occurredAtMs:Date.now(),context:this.hf()})}finally{this._f=!1}}}else this.Lf()}Lf(){if(this.mf=[],this.bf){for(var t of(this.bf=!1,this.Bf&&(clearTimeout(this.Bf),this.Bf=void 0),this.yf))t();this.yf=[]}}zf(){var t=this.mf;return this.Lf(),t}get logger(){return this.Hf||(this.Hf={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.Hf}flushLogs(t){this.zl&&(t?this.Uf(t):(this.Sf&&this.Sf.flush().catch(t=>this.Wf(t)),this.xf&&this.xf.flush().catch(t=>this.Wf(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Sf)?void 0:e.flush().catch(e=>t.Wf(e)),n=null==(i=t.xf)?void 0:i.flush().catch(e=>t.Wf(e));yield r,yield n})()}Wf(t){ea(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Mi&&this.df&&!this.vf&&!this.ff){var t=this.Cf();if(t){this.ff=!0;try{t((t,e)=>{if(this.ff=!1,!this.Mi&&this.df)if(t||!e)this.R.error("Could not load logs script",t),this.Lf();else{var i=this.zf();this.Nf=e.initialize(this.zl),this.vf=!0,i.length>0&&e.replay(this.zl,i)}})}catch(t){throw this.ff=!1,t}}else this.Lf()}}Mf(t,e){var i=this.zl;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(yn(this.hv,3))e({kind:"fatal",error:ta(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:ta(void 0,"logs request timed out")})},9e4),s=this.$f;this.zl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.zl.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.Vf(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:ta(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})})}})}Vf(t,e){(0!==t||e)&&(this.hv=bn(t,this.hv,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.")))}Uf(t){this.Sc.length>0&&this.Gf(t,this.Sc,this.Rf,this.zl.library.name,t=>{this.Sc=t}),this.pf.length>0&&this.Gf(t,this.pf,this.Ff,Zs,t=>{this.pf=t})}Gf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ve(s,qe(i,this.zl.library.name,this.zl.library.version),r,this.zl.library.version);this.zl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.zl.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Wf(t))}}},ra=/* @__PURE__ */ci("[NetworkMetrics]"),na={"http:":80,"https:":443},sa=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),aa=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Ar(r))?void 0:i.href)||r}},oa=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=bs()-n,d=Ar(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":_=sa.has(b=f.method)?b:"_OTHER"},"_OTHER"===_&&b!==_?{"http.request.method_original":b}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||na[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){ra.error("Failed to record network metric",t)}var b,_},la=()=>{},ua=(t,e)=>c(null==an?void 0:an.fetch)?En(an,"fetch",i=>function(){for(var r=bs(),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=aa(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=>(oa(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw oa(t,d,void 0,r,e,i),i})}catch(t){return ra.error("Failed to observe fetch",t),o}}):la,ha=(t,e)=>{var i,r=null==an||null==(i=an.XMLHttpRequest)?void 0:i.prototype;if(!r)return la;var n=/* @__PURE__ */new WeakMap,s=En(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{ys.has(this)||n.set(this,aa(i[0],i[1]))}catch(t){ra.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=En(r,"send",i=>function(){var r;try{var s=n.get(this);if(s&&e()){var a=bs();gi(this,"loadend",r=()=>{this.removeEventListener("loadend",r),oa(t,s,this.status,a,e)})}}catch(t){ra.error("Failed to observe XHR send",t)}try{for(var o=arguments.length,l=new Array(o),u=0;o>u;u++)l[u]=arguments[u];return i.apply(this,l)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{s(),a()}},ca=/* @__PURE__ */new WeakMap,va=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),da={maxStringLength:2048,truncationSuffix:"..."},fa={maxStringLength:2048,truncationSuffix:"..."};function pa(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function ga(t,e){return{}.hasOwnProperty.call(t,e)}function ma(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function ya(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?ke(r,da):r).slice(0,e)}}function ba(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function _a(t){return ke(t||"Unknown error",fa).slice(0,2048)}function wa(t,e){try{return _a(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:_a(t.value)}))}function Sa(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 ka(t,e){return{message:wa(t,e),type:Sa(t,e)}}var Ea=function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return fi({},...e)},Aa={featureFlags:js},Ta={sessionRecording:class{get Nr(){return this._instance.config}get Wc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Qf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this.Jf||"missing_config"===this.Jf?this.Jf:null!==(t=null==(e=this.Qf)?void 0:e.status)&&void 0!==t?t:this.Jf}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Jf=Nn,this.Zf=void 0,this.Kf=!1,this.Ke=(()=>{var t;if(null==un||!un.visibilityState||"visible"===un.visibilityState)return!0;var e=null==an||null==(t=an.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.ln=()=>{var t;"visible"===(null==un?void 0:un.visibilityState)&&(this.Ke=!0,null==(t=this.Qf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Bn.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Nr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=un&&un.addEventListener&&gi(un,"visibilitychange",this.ln)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.Kf=!0,null==un||null==un.removeEventListener||un.removeEventListener("visibilitychange",this.ln),i?this.Yf(!0):this.stopRecording()}get Xf(){var t,e=!(null==(t=this._instance.get_property(Zr))||!t.enabled),i=!this.Nr.disable_session_recording,r=this.Nr.disable_session_recording||this._instance.consent.isOptedOut();return an&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!(this.Kf||this.Xf&&null!=(e=this.Qf)&&e.isStarted)){var i=!f(Object.assign)&&!f(Array.from);this.Xf&&i?(this.tp(t),Bn.info("starting")):(this.Jf=Nn,this.stopRecording())}}tp(t){var e,i;if(this.Xf)if("awaiting_config"!==this.Jf&&"missing_config"!==this.Jf&&(this.Jf=zn),null!=vn&&null!=(e=vn.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=vn.__PosthogExtensions__)&&i.initSessionRecording)this.ep(t);else{var r,n=this._instance.sessionManager;null==(r=vn.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.np,e=>{if(!this.Kf&&this.Xf&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[rn]:!0}),Bn.error("could not load recorder",e)):void this.ep(t);this.Jf=Nn})}}stopRecording(){var t,e;null==(t=this.Zf)||t.call(this),this.Zf=void 0,null==(e=this.Qf)||e.stop()}Yf(t){var e,i;void 0===t&&(t=!1),null==(e=this.Zf)||e.call(this),this.Zf=void 0,null==(i=this.Qf)||i.discard({discardProducerEvents:t})}sp(){var t,e;null==(t=this.Wc)||t.unregister("$session_is_sampled"),null==(e=this.Wc)||e.unregister("$replay_sample_rate")}rp(t,e){if(y(t))return null;var i,r=b(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Bn.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}op(t){if(this.Wc){var i,r,n=this.Wc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.rp(null==(i=this.Nr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.rp(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.sp();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[Zr]: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.Zf)||i.call(this),this.Zf=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.op(e),void this.Yf()):(this.op(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.Jf&&(this.Jf="missing_config",this._instance.register_for_session({[nn]:!0}),Bn.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.Qf)&&i.log?this.Qf.log(t,e):Bn.warn("log called before recorder was ready")}get np(){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"}lp(){var t,e=this._instance.get_property(Zr);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Bn.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}ep(t){var e,i,r;if(!this.Kf&&this.Xf&&this._instance.sessionManager){if(null==(e=vn.__PosthogExtensions__)||!e.initSessionRecording)return Bn.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[rn]:!0});var n;if(this.Qf||(this.Qf=null==(n=vn.__PosthogExtensions__)?void 0:n.initSessionRecording(this._instance,this.Ke),this.Qf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.lp()){if("missing_config"===this.Jf||"awaiting_config"===this.Jf)return;return this.Jf="awaiting_config",Bn.info("persisted remote config is stale, requesting fresh config before starting"),void new Ln(this._instance).load()}this.Jf=zn,null==(i=(r=this.Qf).setDocumentWasEverVisible)||i.call(r,this.Ke),this.Qf.start(t)}else this.Jf=Nn}onRRwebEmit(t){var e;null==(e=this.Qf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Qf||null==(t=this.Wc)||t.register({[tn]:!0}),null==(e=this.Qf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.Qf||null==(t=this.Wc)||t.register({[Qr]:!0}),null==(e=this.Qf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.Qf||null==(e=this.Wc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Qf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Un){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.Qf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Qf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.Qf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Fa={autocapture:class extends Ir{constructor(t){super(new Dr(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.ap=!1,this._instance=t,this.up=this.cp()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.hp();return!!(t.path||t.search||this.dp(t))}startIfEnabled(){this.isEnabled&&(hi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.up=this.cp(),this.startIfEnabled()}stop(){this.vp&&this.vp(),this.vp=void 0,this.fp&&this.fp(),this.fp=void 0,hi.info("History API monitoring stopped")}monitorHistoryChanges(){an&&an.history&&(this.pp("pushState"),this.pp("replaceState"),this.gp(),this.dp()&&this.mp())}pp(t){var e;if(an&&(null==(e=an.history[t])||!e.__posthog_wrapped__)){var i=this;En(an.history,t,e=>function(r,n,s){var a;i.yp(s)&&i.bp(),e.call(this,r,n,s),i._p(t,!i.ap&&"popstate"!==(null==an||null==(a=an.event)?void 0:a.type))})}}cp(){var t=null==an?void 0:an.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}hp(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}dp(t){return void 0===t&&(t=this.hp()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}wp(t){var e=this.hp(),i=this.up;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.dp(e)&&t.hash!==i.hash))}_p(t,e){void 0===e&&(e=!1);try{e||this.bp();var i=this.cp();if(!i)return;if(this.wp(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.kp=r,Promise.resolve().then(()=>this.bp())):r()}this.up=i}catch(e){hi.error("Error capturing "+t+" pageview",e)}}yp(t){var e,i;return!(y(t)||!an)&&(null==(e=Ar(String(t)))?void 0:e.href)!==(null==(i=an.location)?void 0:i.href)}bp(){var t=this.kp;if(t){this.kp=void 0,this.ap=!0;try{t()}catch(t){hi.error("Error capturing deferred pageview",t)}finally{this.ap=!1}this.up=this.cp()}}gp(){if(!this.vp){var t=()=>{this._p("popstate")};gi(an,"popstate",t),this.vp=()=>{an&&an.removeEventListener("popstate",t)}}}mp(){if(!this.fp){var t=()=>{this._p("hashchange")};gi(an,"hashchange",t),this.fp=()=>{an&&an.removeEventListener("hashchange",t)}}}},heatmaps:class{get Nr(){return this.instance.config}constructor(t){var e;this.Sp=!1,this.Ca=!1,this.xp=null,this.instance=t,this.Sp=!(null==(e=this.instance.persistence)||!e.props[qr]),this.rageclicks=new Er(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Nr.capture_heatmaps)&&this.Nr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Nr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Nr.capture_heatmaps)?y(this.Nr.enable_heatmaps)?this.Sp:this.Nr.enable_heatmaps:!1!==this.Nr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ca)return;Hn.info("starting..."),this.$p(),this.ln()}else{var t;clearInterval(null!==(t=this.xp)&&void 0!==t?t:void 0),this.Cp(),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({[qr]:i}),this.Sp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}Tp(t){qn(t.originalEvent)&&this.Fr(t.originalEvent,"deadclick")}ln(){this.xp&&clearInterval(this.xp),this.xp="visible"===(null==un?void 0:un.visibilityState)?setInterval(this.Ac.bind(this),this.flushIntervalMilliseconds):null}$p(){an&&un&&(this.Ip=this.Ac.bind(this),gi(an,sn,this.Ip),this.Mp=t=>this.Fr(t||(null==an?void 0:an.event)),gi(un,"click",this.Mp,{capture:!0}),this.Ep=t=>this.Ap(t||(null==an?void 0:an.event)),gi(un,"mousemove",this.Ep,{capture:!0}),this.Rp=new pn(this.instance,fn,this.Tp.bind(this)),this.Rp.startIfEnabledOrStop(),this.Pp=this.ln.bind(this),gi(un,$i,this.Pp),this.Ca=!0)}Cp(){var t;an&&un&&(this.Ip&&an.removeEventListener(sn,this.Ip),this.Mp&&un.removeEventListener("click",this.Mp,{capture:!0}),this.Ep&&un.removeEventListener("mousemove",this.Ep,{capture:!0}),this.Pp&&un.removeEventListener($i,this.Pp),clearTimeout(this.Op),null==(t=this.Rp)||t.stop(),this.Ca=!1)}Fp(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&&Di(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:an)?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}}Fr(t,i){var r;if(void 0===i&&(i="click"),!ji(t.target)&&qn(t)){var n=this.Fp(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&lr(Wi(t),this.instance.config.rageclick)&&this.So(e({},n,{type:"rageclick"})),this.So(n)}}Ap(t){!ji(t.target)&&qn(t)&&(clearTimeout(this.Op),this.Op=setTimeout(()=>{this.So(this.Fp(t,"mousemove"))},500))}So(t){if(an){var e=this.Nr.disable_capture_url_hashes?J(an.location.href):an.location.href,i=this.Nr.custom_personal_data_properties,r=wn(e,this.Nr.mask_personal_data_properties?[...Fn,...i||[]]:[],Rn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}Ac(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:pn,webVitalsAutocapture:class{constructor(t){var i,r=this;this._instance=t,this.Sp=!1,this.Ca=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Dp=function(t){void 0===t&&(t=!1),clearTimeout(r.Lp),r.Lp=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.Np=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))On.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.jp(r);if(!f(n)){var s=b(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.qp||this.qp>t.value){this.Rt.navigationKey!==s&&(this.Dp(),this.Lp=setTimeout(this.Dp,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 jn){var h="url"===u&&"string"==typeof t.attribution[u]?this.jp(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.Dp()}else On.error("Ignoring metric with value >= "+this.qp,t)}}},this.Bp=()=>{if(!this.Ca){var t,i,r,n,s=!1,a=vn.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.zp])||("web-vitals"===this.zp&&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.Np.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Np.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Np.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.Np.bind(this),v);var d=null==an?void 0:an.document;gi(d,$i,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.Dp(!0)}),gi(an,"pagehide",()=>this.Dp(!0)),this.Ca=!0}else On.error("web vitals callbacks not loaded - not starting")}},this.Sp=!(null==(i=this._instance.persistence)||!i.props[Kr]),this.startIfEnabled()}get Hp(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.Hp)?null==(t=this.Hp)?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)||$n:i}get flushToCaptureTimeoutMs(){return(v(this.Hp)?this.Hp.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.Hp)?this.Hp.web_vitals_attribution:void 0;return _(t)?t?$n:[]:h(t)?t:In}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.Hp)?this.Hp.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get qp(){var t=v(this.Hp)&&b(this.Hp.__web_vitals_max_value)?this.Hp.__web_vitals_max_value:Mn;return t>0&&6e4>=t?Mn:t}get isEnabled(){var t=null==hn?void 0:hn.protocol;if("http:"!==t&&"https:"!==t)return On.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.Hp)?this.Hp.web_vitals:_(this.Hp)?this.Hp:void 0;return _(e)?e:this.Sp}startIfEnabled(){this.isEnabled&&!this.Ca&&(On.info("enabled, starting..."),this.Ga(this.Bp))}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({[Kr]:i}),this._instance.persistence.register({[Yr]:r})),this.Sp=i,this.startIfEnabled()}}}get zp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ga(t){var e=vn.__PosthogExtensions__,i=this.zp,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&f(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,e=>{e?On.error("failed to load script",e):t()})}jp(t){var e=t||(null==an?void 0:an.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 wn(i,this._instance.config.mask_personal_data_properties?[...Fn,...r||[]]:[],Rn)}On.error("Could not determine current URL")}}},Pa={exceptionObserver:class{constructor(t){var i;this.Bp=()=>{var t;if(an&&this.isEnabled&&null!=(t=vn.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=vn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=vn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=vn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Up&&this.Nr.capture_unhandled_errors&&(this.Up=e(this.captureException.bind(this))),!this.Wp&&this.Nr.capture_unhandled_rejections&&(this.Wp=i(this.captureException.bind(this))),!this.Vp&&this.Nr.capture_console_errors&&(this.Vp=r(this.captureException.bind(this)))}catch(t){gn.error("failed to start",t),this.Gp()}}},this._instance=t,this.Qp=!(null==(i=this._instance.persistence)||!i.props[Vr]),this.kt=new R(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:gn})),this.Nr=this.Jp(),this.startIfEnabledOrStop()}Jp(){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.Qp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Nr.capture_console_errors||this.Nr.capture_unhandled_errors||this.Nr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(gn.info("enabled"),this.Gp(),this.Ga(this.Bp)):this.Gp()}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",e=>{if(e)return gn.error("failed to load script",e);t()})}Gp(){var t,e,i;null==(t=this.Up)||t.call(this),this.Up=void 0,null==(e=this.Wp)||e.call(this),this.Wp=void 0,null==(i=this.Vp)||i.call(this),this.Vp=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Qp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Vr]:this.Qp}),this.Nr=this.Jp(),this.startIfEnabledOrStop())}}onConfigChange(){this.Nr=this.Jp()}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 gn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,r;this.Zp=[],this.Kp=new it([new St,new Mt,new Et,new kt,new Ct,new Rt,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 b=bt(s,y);for(var _ of(s.splice(y.start-b,b),m))_.start-=b}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.Zp=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Yp=Lt(this.Xp()),this.tg=new Nt(this.Yp)}onConfigChange(){this.Yp=Lt(this.Xp()),this.tg.setConfig(this.Yp)}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.Zp=s,this._instance.persistence&&this._instance.persistence.register({[Wr]:this.Zp,[Gr]:a})}}}get eg(){var t,e,i=!!this._instance.get_property(Gr);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.Kp.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Yp.enabled)try{if(!p(t)||0===t.trim().length)return void Ls.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)=>jt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.ig(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&Ls.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.tg.add(e({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){Ls.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.ng(e)){if(this.sg(e))return this.rg("Exception dropped: matched a suppression rule"),void Ls.info("Skipping exception capture because a suppression rule matched");if(!this.eg&&this.og(e))return this.rg("Exception dropped: thrown by a browser extension"),void Ls.info("Skipping exception capture because it was thrown by an extension");if(!this.eg&&this.lg(e))return this.rg("Exception dropped: thrown by an injected browser script"),void Ls.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ag(e))return this.rg("Exception dropped: thrown by the PostHog SDK"),void Ls.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Yp.enabled&&y(t.$exception_steps)?this.ug(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.tg.clear(),n}catch(t){return Ds(t)||Ls.error("Failed to capture exception event. Dropping this exception.",t),void this.tg.clear()}}catch(t){return void(Ds(t)||Ls.error("Failed to process exception event. Ignoring this exception.",t))}}ug(t){try{var i=this.tg.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return Ls.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}rg(t){this.Yp.enabled&&this.tg.add({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}ig(t){return v(t)?e({},t):{}}Xp(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}sg(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.Zp.some(t=>{var i=t.values.map(t=>{var i=rs[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 Ls.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}og(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&&Bs.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(Ns)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&zs.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(Ns))}))}lg(t){return t.some(t=>{var e=t.value;return p(e)&&Us.some(t=>e.includes(t))})}ag(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}ng(t){return!y(t)&&h(t)}}},Ra={productTours:class{get Wc(){return this._instance.persistence}constructor(t){this.cg=null,this.hg=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.Wc&&this.Wc.register({[Xr]:!!e.productTours}),!Wn(this._instance))return!this.cg&&y(null==(i=this.Wc)?void 0:i.props.ph_product_tours)||Vn.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.cg)||r.stop(),this.cg=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.cg&&Wn(this._instance)&&this.Ga(()=>this.dg())}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",e=>{e?Vn.error("Could not load product tours script",e):t()})}dg(){var t;!this.cg&&null!=(t=vn.__PosthogExtensions__)&&t.generateProductTours&&(this.cg=vn.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.hg)||e){var i=this.Wc;if(i){var r=i.props[en];if(h(r)&&!e)return this.hg=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(Wn(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||Vn.warn(n):Vn.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.hg=s,i&&i.register({[en]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.hg,{isLoaded:!0})}getActiveProductTours(t){y(this.cg)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.cg.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.cg)||e.showTourById(t)}previewTour(t){this.cg?this.cg.previewTour(t):this.Ga(()=>{var e;this.dg(),null==(e=this.cg)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.cg)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.cg)||t.nextStep()}previousStep(){var t;null==(t=this.cg)||t.previousStep()}clearCache(){var t;this.hg=null,null==(t=this.Wc)||t.unregister(en)}resetTour(t){var e;null==(e=this.cg)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.cg)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.cg)||e.cancelPendingTour(t)}},featureFlags:js},Ca={siteApps:class{constructor(t){this._instance=t,this.vg=0,this.fg=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}pg(t,e){if(e){var i=this.globalsForEvent(e);this.fg.push(i),this.fg.length>1e3&&(this.fg=this.fg.slice(10))}}get siteAppLoaders(){var t;return null==(t=vn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.pg.bind(this));this.gg=()=>{t(),this.fg=[],this.gg=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}}mg(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)||(Gn.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)||(Gn.error("prepare_external_dependency_script returned null"),null):t}yg(){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==un?void 0:un.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.vg++,this.bg)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.mg(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.bg=()=>{h.forEach(t=>t()),this.bg=void 0},this._g()}_g(){var t=!1;return()=>{var e;t||(t=!0,this.vg--,0===this.vg&&(null==(e=this.bg)||e.call(this)))}}wg(t,e){void 0===e&&(e=!0);var i=this.yg();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.fg.length&&(Gn.info("Processing "+this.fg.length+" events for site app with id "+t.id),this.fg.forEach(t=>this.wg(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.gg)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,Gn.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.wg(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){Gn.error(Kn+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){Gn.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}kg(){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)}Sg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.wg(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){Gn.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.kg(),void this._instance.on("eventCaptured",t=>this.Sg(t))):void Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.gg)||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;vn["__$$ph_site_app_"+e]=n._instance,null==(t=vn.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return Gn.error(Kn+e,t)})};for(var o of s.siteApps)a()}else Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Oa={tracingHeaders:class{constructor(t){this._instance=t,this.xg=void 0,this.$g=void 0,this.Cg=void 0,this.Bp=()=>{var t,e,i=this.Tg();i?(f(this.xg)&&(this.xg=null==(t=vn.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.$g)&&(this.$g=null==(e=vn.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Gp()}}initialize(){this.startIfEnabledOrStop()}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",e=>{if(e)return An.error("failed to load script",e);t()})}Ig(){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}Tg(){var t=this.Ig();return h(t)?(h(this.Cg)?this.Cg.splice(0,this.Cg.length,...t):this.Cg=[...t],t.length>0?this.Cg:void 0):(h(this.Cg)&&this.Cg.splice(0),this.Cg=t||void 0,this.Cg)}Gp(){var t,e;null==(t=this.xg)||t.call(this),null==(e=this.$g)||e.call(this),this.xg=void 0,this.$g=void 0}startIfEnabledOrStop(){this.Tg()?this.Ga(this.Bp):this.Gp()}}},Ma={surveys:class extends ps{constructor(t){super(new _s(t))}},featureFlags:js},$a={toolbar:class{constructor(t){this.instance=t}Mg(t){vn.ph_toolbar_state=t}Eg(){var t;return null!==(t=vn.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(!an||!un)return!1;t=null!=t?t:an.location,i=null!=i?i:an.history;try{if(!e){try{an.localStorage.setItem("test","test"),an.localStorage.removeItem("test")}catch(t){return!1}e=null==an?void 0:an.localStorage}var r,n=ws||xn(t.hash,"__posthog")||xn(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(xs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Ag(t){var e=vn.ph_load_toolbar||vn.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):Ss.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==un||!un.getElementById("__POSTHOG_TOOLBAR__"));if(!an||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(an.localStorage.setItem(xs,JSON.stringify(e({},n,{source:void 0}))),2===this.Eg())this.Ag(n);else if(0===this.Eg()){var s;this.Mg(1),null==(s=vn.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return Ss.error("[Toolbar] Failed to load",t),void this.Mg(0);this.Mg(2),this.Ag(n)}),gi(an,"turbolinks:load",()=>{this.Mg(0),this.loadToolbar(n)})}return!0}Rg(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)}}},Ia={experiments:class t{get Nr(){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.Pg("retrieved web experiments from the server"),i.Og=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.Og&&(t.Pg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.Og)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.Fg(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.Dg(a,i._instance)&&i.Lg(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.Pg(qs);else if(!this.Nr.disable_web_experiments){if(y(this.Og))return this.Og=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.Pg("applying feature flags",e),e.forEach(t=>{var e;if(this.Og&&null!=(e=this.Og)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.Og)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.Fg(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=_n(null==e?void 0:e.search,"__experiment_id"),r=_n(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.Pg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.Ng(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Nr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Nr.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.Nr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Ng(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.Pg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.Lg(n[0].name,i,n[0].variants[i].transforms))}Fg(e,i){var r=e.variants[i];t.jg(r,this._instance)?this.Lg(e.name,i,r.transforms):t.Pg("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static Dg(e,i){return!y(e.conditions)&&t.jg(e,i)&&t.qg(e)}static jg(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||Ws[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==an?void 0:an.location}static qg(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(!un)return{};var r,n,s,a=e?[...Fn,...i||[]]:[],o=(r=wn(un.URL,a,Rn),n=Pn.concat(t||[]),s={},di(n,function(t){var e=_n(r,t);s[t]=e||null}),s);return fi(function(){var t={};return di(Cn,function(e){var i=(t=>{if(un){try{for(var e=t+"=",i=un.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 Pg(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 Bg(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 zg(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.zg(e)})}Lg(i,r,n){this._is_bot()?t.Pg(qs):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.Pg("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.Bg("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!=gs?gs:gs=Hs(),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({},Vs,{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({},Vs,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.zg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.Pg("Control variants leave the page unmodified.")}_is_bot(){return ln&&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}(ln,this.Nr.custom_blocked_useragents):void 0}},featureFlags:js},ja={conversations:class{constructor(t){this._instance=t,this.Hg=void 0,this._conversationsManager=null,this.Ug=!1,this.ie=null,this.Wg=!1,this.Vg=0,this.Gg=null,this.Qg=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.Gg=null;else if(this.Jg=t.ok,t.ok){var e=t.config.conversations;y(e)?this.Gg=null:(_(e)?this.Hg=e:(this.Hg=e.enabled,this.ie=e),this.Hg||(this.Gg=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Vg++,this.Hg=void 0,this.ie=null,this.Jg=void 0,this.Wg=!1,this.Gg=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ug||this._instance.config.disable_conversations||mi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==vn?void 0:vn.__PosthogExtensions__;if(t&&!f(this.Hg)&&this.Hg)if(this.ie&&this.ie.token){this.Ug=!0;try{var e=t.initConversations;if(e)return this.Zg(e),void(this.Ug=!1);var i=t.loadExternalDependency;if(!i)return void this.Kg(zr);var r=this.Vg;i(this._instance,"conversations",e=>{if(r!==this.Vg)return this.Ug=!1,void this.loadIfEnabled();e||!t.initConversations?this.Kg("Could not load conversations script",e):this.Zg(t.initConversations),this.Ug=!1})}catch(t){this.Kg("Error initializing conversations",t),this.Ug=!1}}else Gs.error("Conversations enabled but missing token in remote config.")}}Zg(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.Wg=!1,Gs.info("Conversations loaded successfully")}catch(t){return void this.Kg("Error completing conversations initialization",t)}this.Qg&&this._conversationsManager.setTheme(this.Qg),this.Yg()}else Gs.error("Cannot complete initialization: remote config is null")}Yg(){var t=this.Gg;this.Gg=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}Kg(t,e){Gs.error(t,e),this._conversationsManager=null,this.Ug=!1,this.Wg=!0}show(){this._conversationsManager?this._conversationsManager.show():Gs.warn("Conversations not loaded yet.")}hide(){"open"===this.Gg&&(this.Gg=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.Gg=null,this._conversationsManager.open()):this.Gg="open"}close(){this._conversationsManager?(this.Gg=null,this._conversationsManager.close()):this.Gg="close"}setTheme(t){var i,r;this.Qg=e({},this.Qg,t,{dark:e({},null==(i=this.Qg)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.Hg&&!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.Jg?"remote_config_failed":f(this.Hg)?this.Jg?"disabled_in_project":"remote_config_pending":this.Hg?y(this.ie)||!this.ie.token?"missing_token":null!=vn&&vn.__PosthogExtensions__?this.Ug?"initializing":this.Wg?"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):(Gs.warn(Ks),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Gs.warn(Ks),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Gs.warn(Ks),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Gs.warn(Ks),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Gs.warn(Ks),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Gs.warn(Ks),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Gs.warn(Ks),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()}}},Da={logs:class extends ia{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=vn._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!=vn&&null!=(e=vn.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(vn.location.href):vn.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.Tf()}get $f(){return this._instance.__loaded}Cf(){var t=ci("[logs]"),e=null==vn?void 0:vn.__PosthogExtensions__;if(e){var i=e.loadExternalDependency;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(zr)}else t.error("PostHog Extensions not found.")}}},La={metrics:class{constructor(t){this._instance=t,this.R=ci("[metrics]"),this.Mi=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.Mi){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.Xg?this.Xg=(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=ua(t,i),n=ha(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.Xg&&(this.Xg(),this.Xg=void 0)}}Ef(){var t;if(!this.Mi){var e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Sf&&this.Af===i||(null==(e=this.Sf)||e.reset(),this.Af=i,this.Sf=new ri(this.Mf(),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}}(i),this.R)),this.Sf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.Ef())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.Ef())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.Ef())||r.histogram(t,e,i)}flush(t){if(!this.Sf)return Promise.resolve();if(t){var e=this.Sf.drainWindow();return e&&this.Po(e,t),Promise.resolve()}return this.Sf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Sf)||t.reset()}dispose(){var t,e;this.Mi=!0,null==(t=this.Xg)||t.call(this),this.Xg=void 0,null==(e=this.Sf)||e.reset()}Mf(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Po:t=>e.Po(t),getLibraryId:()=>ms.LIB_NAME,getLibraryVersion:()=>ms.LIB_VERSION}}Po(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.tm(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{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)})}}))})}tm(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Na={webMCP:class{constructor(t){this._instance=t,this.im=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.im){var t=null==un?void 0:un.modelContext;if(t&&c(t.registerTool)){var e=ca.get(t);if(e)return e.instances.add(this._instance),void(this.im=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;En(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.nm(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(ca.set(t,i),this.im=!0)}}}nm(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=>va.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:ma(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>ga(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:ma(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:ma(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=pa(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?ya(t.context,2048,!0):void 0,n=i.model?ya(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&&ga(r,"context"),s=i.model&&ga(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.sm(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=ba(t)?{error:t,errorResult:!0}:void 0;return n.sm(i,a,s,e,f),t},t=>{throw n.sm(i,a,s,{error:t,errorResult:!1},f),t});var g=ba(c)?{error:c,errorResult:!0}:void 0;return n.sm(i,a,s,g,f),c}}),a}sm(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=pa(l.config.capture_webmcp);if(h){n&&!a&&(a=ka(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==hn?void 0:hn.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==hn?void 0:hn.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}}},za=/* @__PURE__ */Ea(Aa,Ta,Fa,Pa,Ra,Ca,Ma,Oa,$a,Ia,ja,Da,La,Na),Ba=Aa,Ua=Ta,Ha=Fa,qa=Pa,Va=Ra,Wa=Ca,Ga=Ma,Ka=Oa,Ja=$a,Xa=Ia,Ya=ja,Za=Da,Qa=La,to=Na;export{za as AllExtensions,Ha as AnalyticsExtensions,Ya as ConversationsExtensions,qa as ErrorTrackingExtensions,Xa as ExperimentsExtensions,Ba as FeatureFlagsExtensions,Za as LogsExtensions,Qa as MetricsExtensions,Va as ProductToursExtensions,Ua as SessionReplayExtensions,Wa as SiteAppsExtensions,Ga as SurveysExtensions,Ja as ToolbarExtensions,Ka as TracingExtensions,to 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),b=t=>"[object Number]"==u.call(t)&&t==t,_=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),b(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 R=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={}}},C="Android",O="Nintendo",M="PlayStation",I="Windows",j=/* @__PURE__ */new RegExp("BlackBerry|PlayBook|BB10","i"),D={"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,""]],[j,["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=D[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]?[C,[t[2],t[3],t[4]||"0"].join(".")]:[C,""]],[/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=[],b=0;50>s&&1e3>a&&g>b;b++){a++;var _=void 0;try{_=c.next(m[b])}catch(t){s++,_=n.coerceFallback(v(i+1))}_&&y.push(_)}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=_t(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function bt(t,e){for(var i=e.start;i>0&&gt(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function _t(t,e){for(var i=e.start+e.length,r=i;t.length>r&&gt(t[r],t[r-e.length]);)r++;return r-i}function wt(t,e){var i=e[0],r=t.length-(i?bt(t,i):0);for(var n of e)r-=_t(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.br(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.wr(t))&&void 0!==r?r:n.stack,synthetic:!0})}br(t){return p(t.message)&&t.message.length>0}wr(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]";for(var r=i.length;r>0;r--){var n=i.slice(0,r).join(", ");if(e>=n.length)return r===i.length?n:n.length>e?n.slice(0,e)+"...":n}return""}var Rt=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}}},Ct=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",jt=/* @__PURE__ */new Set([$t,It]),Dt={enabled:!0,max_bytes:32768};function Lt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Dt.enabled,max_bytes:zt(t.max_bytes,Dt.max_bytes)}:e({},Dt)}var Nt=class{constructor(t){this.ns=[],this.ss=0,this.Nr=Lt(t)}setConfig(t){this.Nr=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)&&!b(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.Nr.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.Nr.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function zt(t,e){if(!b(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:be(t,e),lastFieldSensitive:!1};var i=me(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function be(t,e){return e?xe(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function _e(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];_e(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])+Re(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 Re(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 Ce={}.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--,_(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(Ce.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 je(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 De=["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 De)({}).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=b(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 je(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.Nr=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.Is=!1,this.Ms=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.Is=!1,this.xs=0,this.$s=1,this.Ss.reset(),this.Rs=this.Nr.maxBatchRecordsPerPost}onReconnect(){this.xs=0,this.$s=1,this.Ss.isOpen()?this.Fs()&&this.Ds():this.ys()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ls(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")}}Ls(t){var e=this.Nr.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.Is=!1),this.Os>this.Ts?(this.Ts++,!0):(this.Is||(this.R.warn("captureLog dropping logs: exceeded "+this.Os+" logs per "+this.Ps+"ms"),this.Is=!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.Nr.maxBatchRecordsPerPost>t.Rs&&(t.Rs=Math.min(t.Nr.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.Nr,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.Ms>i.length||this.Ss.isOpen()?this.Ds():this.ys()}}Ds(){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.Nr=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.So({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.So({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.So({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.xo()});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.$o()?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.$o()?void 0:this.flush()))),this.Gs)}$o(){return this.xs>0||this.Ss.remainingMs()>0}drainWindow(){if(0===this.Vs.size)return null;var t=this.Vs;return this.Co(),this.To(t)}reset(){this._o++,this.Ss.reset(),this.xs=0,this.$s=1,this.gs.clear(),this.bs=null,this.Gs=null,this.Co(),this.Ks=/* @__PURE__ */new Map,this.Xs=!1}Co(){this.Vs=/* @__PURE__ */new Map,this.Qs=!1,this.Js=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ys=/* @__PURE__ */new Set}So(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ls(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.Io())&&("histogram"!==i.type||(s=this.Mo(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.Eo(a,i.value);var l=this.Ao();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Ds()}}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")}}Ao(){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}Io(){return this.Nr.maxSeriesPerFlush>this.Vs.size||(this.Qs||(this.Qs=!0,this.R.warn("Metric series cap reached ("+this.Nr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Mo(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.Ro(t,r,n,i),n;if(this.Ks.size>=this.Nr.maxSeriesPerFlush){if(this.Xs||(this.Xs=!0,this.R.warn("Histogram bounds limit reached ("+this.Nr.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")}Ro(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."))}Eo(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}}Ls(t){var e=this.Nr.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}Ds(){this.gs.pending||this.gs.arm(this.Ws())}Ws(){return Math.max(Ke(this.Nr.flushIntervalMs,this.xs,this.$s,3e4),this.Ss.remainingMs())}xo(){var t=this;return r(function*(){if(t.gs.clear(),0!==t.Vs.size){var e=t.Vs;t.Co();var i=t._o,r=yield t._instance.Po(t.To(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.Oo(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)}}})()}To(t){return e=this.Fo(t),i=function(t,e,i){return je(t,e,i)}(this.Nr,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}Fo(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())}Oo(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.Io()&&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.10.8",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 bi="$early_access_features",_i="$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",Ri="$flag_call_reported_session_id",Ci="$feature_flag_payloads",Oi="$override_feature_flags",Mi="$override_feature_flag_payloads",$i="visibilitychange",Ii="$autocapture_disabled_server_side";function ji(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function Di(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&&Di(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=>_r(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Vi(t){var e="";return cr(t)&&!vr(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||!Di(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=>{Di(t)&&cr(t)&&!vr(t)&&(e+=" "+Vi(t),i=i||t.getAttribute("aria-label")||"",di(t.childNodes,r))};r(t);var n=(_r(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(_(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||!Di(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).targetElementList;return!(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,l))||Ji(l,i))}var ur=t=>!t||Li(t,"html")||!Di(t),hr=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ur(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,n=[t],s=t;s.parentNode&&!Li(s,"body");)if(zi(s.parentNode))n.push(s.parentNode.host),s=s.parentNode.host;else{var a=Xi(s);if(!a)break;if(e||Gi.indexOf(a.tagName.toLowerCase())>-1)r=!0;else try{var o=i.getComputedStyle(a);o&&"pointer"===o.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(a),s=a}return{parentIsUsefulElement:r,targetElementList:n}};function cr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r.parentNode&&!Li(r,"body");r=r.parentNode){if(i++>=1e3||e.has(r))return!1;e.add(r);var n=Hi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!1}if(s(Hi(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function vr(t){return!!(Li(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Li(t,"select")||Li(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var dr=/* @__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}))$"),fr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,pr=[16,15,14,13],gr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),mr=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),yr=/[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 _r(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?dr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(fr.lastIndex=0;e=fr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of pr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(dr.test(o)&&br(o))return!0}}}return!1}(t))return!1;if(e?gr.test(t):function(t){var e;for(mr.lastIndex=0;e=mr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&yr.test(i)&&yr.test(r)))return!0}return!1}(t))return!1}return!0}function wr(t){var e=Vi(t);return _r(e=(e+" "+xr(t)).trim())?e:""}function xr(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+" "+xr(t)).trim())}catch(t){hi.error("[AutoCapture]",t)}}),e}function Sr(t){return t.replace(/"|\\"/g,'\\"')}function kr(t){var e=t.attr__class;if(e)return h(e)?e:Bi(e)}var Er=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}},Ar=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)},Tr=()=>typeof window>"u"?void 0:window,Fr=()=>typeof document>"u"?void 0:document,Pr="$copy_autocapture",Rr=["password","hidden","file","checkbox","button","submit","reset","image"],Cr=/* @__PURE__ */ci("[AutoCapture]");function Or(t,e){return e.length>t?e.slice(0,t)+"...":e}function Mr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!Di(e));return e}function $r(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!Di(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;g.parentNode&&!Li(g,"body")&&1e3>d.length;)if(zi(g.parentNode)){var m=g.parentNode.host;if(f.has(m))break;f.add(m),d.push(m),g=m}else{if(!Di(g.parentNode))break;if(f.has(g.parentNode))break;f.add(g.parentNode),d.push(g.parentNode),g=g.parentNode}var y="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Li(t,"button")||Li(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!cr(t)||vr(t)));var b,_,w,x=[],S={},k=!1,E=!1;if(di(d,t=>{var e=cr(t);if(Li(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");k=!!(e&&i&&_r(i))&&(v?J(i):i)}s(Hi(t),"ph-no-capture")&&(E=!0),x.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()?Or(1024,wr(t)):Or(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(t.attributes,function(i){var s;if((!vr(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&_r(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]=Or(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=Mr(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(!cr(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&&_r(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(S,e)||(S[e]=t)})}),E)return{props:{},explicitNoCapture:E};if(y>0&&(t=d[y],x.splice(0,y)),l||(x[0].$el_text=Li(t,"a")||Li(t,"button")?wr(t):Vi(t)),k){var A,T;x[0].attr__href=k;var F=null==(A=Ar(k))?void 0:A.host,P=null==(T=Tr())||null==(T=T.location)?void 0:T.host;F&&P&&F!==P&&(b=k)}return{props:fi((_=a.type,{$event_type:_,$ce_version:1}),c?{}:{$elements:x},{$elements_chain:(w=x,h(w)?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[Sr(t[0].toString())]=Sr(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:kr(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})}(w)):"")},null!=(r=x[0])&&r.$el_text?{$el_text:null==(n=x[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},S),target:t}}var Ir=class{ba(){this._a=void 0,clearTimeout(this.wa),this.wa=void 0}ka(t){var e;if(!cr(t))return!0;for(var i,r=null!==(e=this.Sa().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")||vr(t)||r.some(e=>Ki(t,e)))return{v:!0};var i=a.parentNode;a=zi(i)?i.host:i&&Di(i)?i:null};a;)if(i=o())return i.v;return!1}xa(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this._a;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.ba():"pointerup"===t.type&&(e.released=!0,this.wa=setTimeout(()=>this.ba(),0)))}else{var i;this.ba();var r=Wi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&Di(r)&&(this._a={target:r,excluded:this.ka(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.zl)?void 0:i.distinctId})}else this.ba()}$a(t){var e,i=this._a;this.ba();var r=Wi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.zl)?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.Sa().css_selector_ignorelist)&&void 0!==n?n:Yi;return[r,null==(a=Fr())?void 0:a.documentElement,null==(o=Fr())?void 0:o.body].some(t=>{if(!t)return!1;var e=Hi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!cr(t)||vr(t)||l.some(e=>Ki(t,e))})?null:i.target}}constructor(t){this.Wl=t,this.name="autocapture",this.Ca=!1,this.Ta=null,this.Ia=!1,this.Ma=/* @__PURE__ */new Map,this.Ea=!1,this.Nr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Mi=!1,this.Wl.refresh(this.Nr),this.rageclicks=new Er(this.Nr.rageclick),this.Aa=null}setup(t){this.Ra(),this.zl=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Mi?e.dispose():(this.na=e,this.startIfEnabled())}dispose(){var t;this.Mi||(this.Mi=!0,this.zl=void 0,null==(t=this.na)||t.dispose(),this.na=void 0,this.Ma.clear(),this.Aa=null,this.Pa())}Sa(){return this.Wl.refresh(this.Nr),this.Nr}Ra(){var t,e;return this.Sa(),this.Nr.url_allowlist=null==(t=this.Nr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Nr.url_ignorelist=null==(e=this.Nr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Nr}Oa(){var t=Tr(),e=Fr();if(this.isBrowserSupported()){if(t&&e){this.Fa=t,this.Da=e;var i=this.La=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.ba();if(0===e.type.indexOf("pointer"))return void this.xa(e);var i="click"===e.type?this.$a(e):void 0;if(m(i))return;this.Na(e,"$autocapture",i)}catch(t){Cr.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.Sa().capture_copied_text){var r=this.ja=e=>{e=e||(null==t?void 0:t.event);try{this.Na(e,Pr)}catch(t){Cr.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 Cr.info("Disabling Automatic Event Collection because this browser is not supported")}Pa(){var t=this.Fa,e=this.Da;this.ba(),this.La&&(null==t||t.removeEventListener("blur",this.La),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.La,!0)}),null==e||e.removeEventListener("submit",this.La,!0),null==e||e.removeEventListener("change",this.La,!0),null==e||e.removeEventListener("click",this.La,!0),this.La=void 0),this.ja&&(null==e||e.removeEventListener("copy",this.ja,!0),null==e||e.removeEventListener("cut",this.ja,!0),null==e||e.removeEventListener("paste",this.ja,!0),this.ja=void 0),this.Fa=void 0,this.Da=void 0,this.Ca=!1}startIfEnabled(){this.isEnabled||this.ba(),!this.Mi&&this.zl&&this.isEnabled&&!this.Ca&&(this.Oa(),this.Ca=!0)}onRemoteConfig(t){if(!this.Mi)if(this.Ia=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.Ea=e.elementsChainAsString);var i,r=e.autocapture_opt_out;_(r)&&(null==(i=this.zl)||i.kv.set(Ii,r),this.Ta=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Mi){t.size?this.Ma.set(e,new Set(t)):this.Ma.delete(e);var i=/* @__PURE__ */new Set;this.Ma.forEach(t=>{t.forEach(t=>i.add(t))}),this.Aa=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.Aa)||i.forEach(i=>{var n;null==(n=Fr())||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.Mi)return!1;var i=null==(t=this.zl)?void 0:t.kv.get(Ii),r=this.Ta,n=this.Sa();if(!n.remoteRequestsDisabled&&!this.Ia)return!1;var s=n.remoteRequestsDisabled&&!this.Ia;if(m(r)&&!_(i)&&!s)return!1;var a=null!==(e=this.Ta)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Na(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.Ra();"$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.Na(t,"$rageclick",r);var l,u=i===Pr,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(!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=$r(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.Ea,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===Pr){var y=t.type||"clipboard";if("paste"!==y){var b,_,w=null==(b=Tr())||null==(b=b.getSelection())?void 0:b.toString(),x=qi(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(_=null==w?void 0:w.length)&&void 0!==_?_: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(!cr(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&&Di(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){Cr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.zl)||d.capture(i,g),!0}}else this.ba()}isBrowserSupported(){var t;return c(null==(t=Fr())?void 0:t.querySelectorAll)}},jr=["[data-ph-capture-value]"],Dr=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}},Lr="$surveys",Nr="$surveys_loaded_at",zr="PostHog loadExternalDependency extension not found.",Br="$surveys_activated",Ur="$surveys_activated_session",Hr="$surveys_activated_timestamps",qr="$heatmaps_enabled_server_side",Vr="$exception_capture_enabled_server_side",Wr="$error_tracking_suppression_rules",Gr="$error_tracking_capture_extension_exceptions",Kr="$web_vitals_enabled_server_side",Jr="$dead_clicks_enabled_server_side",Xr="$product_tours_enabled_server_side",Yr="$web_vitals_allowed_metrics",Zr="$session_recording_remote_config",Qr="$replay_override_sampling",tn="$replay_override_linked_flag",en="ph_product_tours",rn="$sdk_debug_recording_script_not_loaded",nn="$sdk_debug_replay_stale_config",sn="beforeunload",an="u">typeof window?window:void 0,on="u">typeof globalThis?globalThis:an,ln=null==on?void 0:on.navigator,un=null==on?void 0:on.document,hn=null==on?void 0:on.location;null!=on&&on.XMLHttpRequest&&new on.XMLHttpRequest;var cn="undefined"!=typeof globalThis?globalThis:an;cn&&"undefined"==typeof self&&(cn.self=cn),cn&&"undefined"==typeof File&&(cn.File=function(){});var vn=null!=an?an:{},dn=/* @__PURE__ */ci("[Dead Clicks]"),fn=()=>!0,pn=class{get lazyLoadedDeadClicksAutocapture(){return this.Va}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({[Jr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ga(()=>{this.Qa()}):this.stop()}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",e=>{e?dn.error("failed to load script",e):t()})}Qa(){var t;if(un){if(!this.Va&&null!=(t=vn.__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.Va=vn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Va.start(un),dn.info("starting...")}}else dn.error("`document` not found. Cannot start.")}stop(){this.Va&&(this.Va.stop(),this.Va=void 0,dn.info("stopping..."))}},gn=/* @__PURE__ */ci("[ExceptionAutocapture]"),mn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},yn=(t,e)=>t>=e&&mn(),bn=(t,e,i,r)=>{if(0===t){if(mn()){var n=e+1;return n===i&&r(),n}return e}return 0},_n=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},wn=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},xn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Sn=()=>{},kn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function En(t,e,i){try{if(!(e in t))return Sn;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=kn(i);s;){if(s.next===n)return void(s.next=r.next);s=kn(i=s.next)}else t[e]=r.next}}catch(t){return Sn}}var An=/* @__PURE__ */ci("[TracingHeaders]");function Tn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Fn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Pn=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Fn])(),Rn="<masked>",Cn=["li_fat_id"];var On=/* @__PURE__ */ci("[Web Vitals]"),Mn=9e5,$n=["CLS","FCP","INP","LCP"],In=["INP","LCP"],jn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Dn=/* @__PURE__ */ci("[RemoteConfig]"),Ln=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=vn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}yc(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}bc(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Dn.info("Using preloaded remote config",this.remoteConfig),void this._c(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Dn.warn("Remote config is disabled. Falling back to local config.");this.yc(t=>{if(!t)return Dn.info("No config found after loading remote JS config. Falling back to JSON."),void this.bc(t=>{this._c(t.json,t)});this._c(t)})}catch(t){Dn.error("Error loading remote config",t),this._c()}}_c(t,e){!t&&e&&(0===e.statusCode?e.error||Dn.warn("Failed to fetch remote config from PostHog."):Dn.error("Failed to fetch remote config from PostHog."));try{this._instance._c(t?{ok:!0,config:t}:{ok:!1})}catch(t){Dn.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){Dn.error("Error loading feature flags",t)}}},Nn="disabled",zn="lazy_loading",Bn=/* @__PURE__ */ci("[SessionRecording]"),Un=[rn,nn,"$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"],Hn=/* @__PURE__ */ci("[Heatmaps]");function qn(t){return v(t)&&"clientX"in t&&"clientY"in t&&b(t.clientX)&&b(t.clientY)}var Vn=/* @__PURE__ */ci("[Product Tours]"),Wn=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Xr))},Gn=/* @__PURE__ */ci("[SiteApps]"),Kn="Error while initializing PostHog app with config id ",Jn="events",Xn="cancelEvents",Yn="survey shown",Zn="survey dismissed",Qn="survey sent";function ts(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var es=(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}},is=t=>t.toLowerCase(),rs={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=>es(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!es(e,t))),icontains:(t,e)=>e.map(is).some(e=>t.map(is).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(is).every(e=>t.map(is).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 ns(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=rs[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var ss=/* @__PURE__ */ci("[Surveys]"),as=["popover","widget","api"],os=class{on(t,e){return this.Do[t]||(this.Do[t]=[]),this.Do[t].push(e),()=>{this.Do[t]=this.Do[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.Do[t]||[])i(e);for(var r of this.Do["*"]||[])r(t,e)}constructor(){this.Do={}}};function ls(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 us=class{constructor(t){this.Li=t,this.Lo=/* @__PURE__ */new Set,this.No=/* @__PURE__ */new Set,this.jo=new os,this.qo=(t,e)=>this.Bo(t,e)&&this.zo(t,e)&&this.Ho(t,e)&&this.Uo(t,e),this.Bo=(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.Li)?void 0:t.subscribeCapture)||(this.Wo=null==(e=this.Li)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.Wo)||t.call(this),this.Wo=void 0,null==(e=this.Li)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.jo=new os}register(t){var e,i;if(!f(null==(e=this.Li)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.Lo.add(t),null==(e=t.steps)||e.forEach(t=>{this.No.add((null==t?void 0:t.event)||"")})}),null!=(i=this.Li)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.Lo.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.Li.setElementSelectors(r,this)}}replace(t){this.Lo.clear(),this.No.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.No.has(t)||this.No.has(e.event))&&this.Lo.forEach(t=>{this.Vo(e,t)&&this.jo.emit("actionCaptured",t.name)})}Go(t){this.onAction("actionCaptured",e=>t(e))}Vo(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.qo(t,i))return!0;return!1}onAction(t,e){return this.jo.on(t,e)}zo(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.Li)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!ls(r,e.url,e.url_matching||"contains"))return!1}return!0}Ho(t,e){return!!this.Qo(t,e)&&!!this.Jo(t,e)&&!!this.Zo(t,e)}Qo(t,e){var i;if(null==e||!e.href)return!0;var r=this.Ko(t);if(r.length>0)return r.some(t=>ls(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&ls((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Jo(t,e){var i;if(null==e||!e.text)return!0;var r=this.Ko(t);if(r.length>0)return r.some(t=>ls(t.text,e.text,e.text_matching||"exact")||ls(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=>ls(t,s,a)))}Zo(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}Ko(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Uo(t,e){return null==e||!e.properties||0===e.properties.length||ns(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)}},hs=class{constructor(t,e){this.Yo=e,this.Xo=[],this.Li=t,this.tl=/* @__PURE__ */new Map,this.el=/* @__PURE__ */new Map,this.il=/* @__PURE__ */new Map}nl(){var t,e;this.sl=null==(t=(e=this.Li).subscribeSession)?void 0:t.call(e,t=>this.rl(t))}ll(t){return!1}al(){return null}ul(t){}cl(){}hl(t,e){return!!t&&ns(t.propertyFilters,null==e?void 0:e.properties)}dl(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}vl(t,e,i){var r=(i===Jn?this.tl:this.el).get(t),n=[];return this.fl(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.hl(s,e)})}register(t){this.pl(t,!1)}replace(t){this.pl(t,!0)}pl(t,e){f(this.Li.subscribeCapture)||(this.gl(t,e),this.ml(t,e))}ml(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.il.clear(),0!==i.length){this.yl||(this.yl=new us(this.Li),this.yl.init(),this.yl.Go(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.il.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.il.set(e.name,n)}})}),e?this.yl.replace(r):this.yl.register(r)}else{var n;e&&(null==(n=this.yl)||n.replace([]))}}bl(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)})}gl(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.dl(t,Jn),l=this.dl(t,Xn);e?(this.tl=o,this.el=l):(this.bl(this.tl,o),this.bl(this.el,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.Wo)&&void 0!==i||(this.Wo=null==(r=(n=this.Li).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this._l(),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.wl(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.kl([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.Sl(s),void this.xl([s])}if(this.el.has(t)){var o=this.vl(t,e,Xn);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.kl(o.map(t=>t.id)),o.forEach(t=>this.$l(t.id)))}if(this.tl.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.tl.get(t)});var l=this.vl(t,e,Jn);this.Cl(l.map(t=>t.id))}}onAction(t){this.il.has(t)&&this.Cl(this.il.get(t)||[])}Cl(t){if(0!==t.length){var e=!!this.Li.getSessionId(),i=[];for(var r of t)e&&this.ll(r)?this.Sl(r)&&this.Tl(r):i.push(r);i.length>0&&(this.Xo=[.../* @__PURE__ */new Set([...this.Xo,...i])]),this._l().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Il()}}Sl(t){this.Xo=this.Xo.filter(e=>e!==t);var e=this.Ml();return!e.includes(t)&&(this.El([...e,t]),this.Al(),!0)}kl(t){var e=new Set(t);this.Xo=this.Xo.filter(t=>!e.has(t));var i=this.Rl(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.El(r),0===r.length&&this.Pl()),this.xl(t),this.Il()}Il(){try{var t;null==(t=this.Yo)||t.call(this)}catch(t){this._l().error("Error while handling activated items change",t)}}Ol(){var t=this.al();if(!t)return{};var e=this.Li.getProperty(t);return e&&"object"==typeof e?e:{}}Tl(t){if(this.al()){var i=this.Ol();this.ul(e({},i,{[t]:Date.now()}))}}xl(t){if(this.al()){var e=this.Ol(),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.cl():this.ul(i))}}Fl(){this.al()&&this.cl()}getActivationTimestamp(t){if(this.Ml().includes(t)){var e=this.Ol()[t];return b(e)?e:void 0}}Rl(){var t=this.Dl();return this.Li.getProperty(t)||[]}Ml(){var t=this.Rl();if(0===t.length)return[];var e=this.Li.getProperty(this.Ll()),i=this.Li.getSessionId();return i&&e===i?t:[]}Al(){var t=this.Li.getSessionId();t&&this.Nl(t)}Pl(){this.jl()}rl(t){var e=this.Li.getProperty(this.Ll());if(e&&e!==t){var i=this.Rl(),r=this.Ol();i.length>0&&(this.El([]),i.filter(t=>b(r[t])).forEach(t=>this.$l(t))),this.Pl(),this.Fl(),i.length>0&&this.Il()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.Ml(),...this.Xo])].filter(t=>!this.ql(t))}dispose(){var t,e,i;null==(t=this.sl)||t.call(this),this.sl=void 0,null==(e=this.Wo)||e.call(this),this.Wo=void 0,null==(i=this.yl)||i.dispose(),this.yl=void 0}reset(){this.Xo=[],this.Rl().length>0&&this.El([]),this.Pl(),this.Fl(),this.Il()}getEventToItemsMap(){return this.tl}Bl(){return this.yl}},cs=class extends hs{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.zl=t,this.Hl=e,this.nl()}Dl(){return Br}Ll(){return Ur}al(){return Hr}ul(t){this.zl.kv.set({[Hr]:t})}cl(){this.zl.kv.remove(Hr)}ll(t){var e,i;this.fl(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return b(r)&&r>0}Ul(){return Yn}fl(t){this.Hl.getSurveys(t)}$l(t){this.Hl.cancelPendingSurvey(t)}_l(){return ss}El(t){this.zl.kv.set({[Br]:t})}Nl(t){this.zl.kv.set({[Ur]:t})}jl(){this.zl.kv.remove(Ur)}ql(){return!1}wl(t,e,i){var r,n;return t===Qn&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.fl(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return ts(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===Yn?"consume":"ignore":t===Yn?"persist":t===Zn||t===Qn?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},vs=(t,e)=>null!=t&&t.then?t.then(e):e(t),ds="SDK is not enabled or survey functionality is not yet loaded",fs="Disabled. Not loading surveys.",ps=class{constructor(t){this.Wl=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Vl=!1,this.Gl=!1,this.Ql=[],this.Jl=[],this.Zl=null,this.Kl=null,this.Mi=!1,this.Yl=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.Mi&&!this.Nr.disableSurveys){if(!t.ok)return this.Gl=!0,this.Xl({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),ss.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return ss.warn("Flags not loaded yet. Not loading surveys.");this.ta=_(e)?e:e.length>0,ss.info("flags response received, isSurveysEnabled: "+this.ta),this.loadIfEnabled()}},this.Xl=t=>{this.Jl.slice().forEach(e=>this.ea(e,t))}}setup(t){if(!this.Mi)return this.ia=t,vs(t.kv.initialize(),()=>{if(this.ia===t&&!this.Mi){this.ia=void 0,this.zl=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Mi?e.dispose():(this.na=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Mi||(this.Mi=!0,this.ia=void 0,this.zl=void 0,null==(t=this.na)||t.dispose(),this.na=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Ql=[],this.Jl.forEach(t=>{t.active=!1}),this.Jl=[],null==(r=this.sa)||r.call(this),this.sa=void 0,this.Zl=null,this.Yl.forEach(t=>clearTimeout(t)),this.Yl.clear())}get Nr(){return this.Wl.get()}getRenderContext(){if(this.zl){var t=this;return{client:this.zl,get config(){return t.Nr},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.Xl()}loadIfEnabled(){if(!this.Mi&&this.zl){var t=this.Nr;if(!this._surveyManager)if(this.Vl)ss.info("Already initializing surveys, skipping...");else if(t.disableSurveys)ss.info(fs);else if(t.cookielessMode&&this.zl.isOptedOut)ss.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Wl.getExtensions();if(e){if(!f(this.ta)||t.advancedEnableSurveys){var i=this.ta||t.advancedEnableSurveys;this.Vl=!0,this.Gl=!1;try{var r=e.generateSurveys;if(r)return this.oa(r,i),void(this.Vl=!1);var n=e.loadExternalDependency;if(!n)return this.ra(zr),void(this.Vl=!1);n(t=>{try{if(this.Mi)return;var e=this.Wl.getExtensions();t||null==e||!e.generateSurveys?this.ra("Could not load surveys script",t):this.oa(e.generateSurveys,i)}finally{this.Vl=!1}})}catch(t){throw this.Vl=!1,this.ra("Error initializing surveys",t),t}}}else this.ra("PostHog Extensions not found.")}}}oa(t,e){var i;if(!this.Mi){this._surveyManager=t(e),this._surveyEventReceiver=this.la(this.zl,this.Xl);var r=null==(i=this.zl)?void 0:i.kv.get(Lr);r&&this.aa(r),ss.info("Surveys loaded successfully"),this.ua(),this.Xl(),this.ca({isLoaded:!0})}}la(t,e){return new cs(t,this,void 0,e)}ra(t,e){this.Gl=!0,ss.error(t,e),this.Xl({isLoaded:!1,error:t}),this.ca({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ql.push(t),this._surveyManager&&this.ca({isLoaded:!0}),()=>{this.Ql=this.Ql.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Mi){var i=this.zl;if(!i)return t([],{isLoaded:!1,error:ds});if(this.Nr.disableSurveys)return ss.info(fs),t([]);var r=i.kv.get(Lr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.ha()&&this.getSurveys(()=>{},!0));if(this.Zl)this.Zl.then(e=>{this.Mi||t(e.surveys,e.context)}).catch(t=>ss.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Nr.requestTimeoutMs}).then(t=>{try{return this.da(i,t)}catch(t){return ss.error("Error processing surveys response",t),this.da(i,{statusCode:0,error:t})}},t=>this.da(i,{statusCode:0,error:t}));this.Zl=n;var s=()=>{this.Zl===n&&(this.Zl=null)};n.then(e=>{s(),this.Mi||(this.Xl(e.context),t(e.surveys,e.context))},s).catch(t=>ss.error("Error in survey callback",t))}}}da(t,e){if(this.Mi)return{surveys:[],context:{isLoaded:!1,error:ds}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?ss.error(r):e.error||ss.warn(r),this.Kl=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Kl=null;var n=e.json.surveys||[];return t.kv.set({[Lr]:n,[Nr]:Date.now()}),this.aa(n),{surveys:n,context:{isLoaded:!0}}}aa(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(ts(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.va(e)}va(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}ha(){return this.fa()&&!this.Zl&&!this.pa()}fa(){var t,e=null==(t=this.zl)?void 0:t.kv.get(Nr);return b(e)&&Date.now()-e>3e5}pa(){return b(this.Kl)&&3e5>Date.now()-this.Kl}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){ss.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.Xl()}ca(t){for(var e of this.Ql){if(this.Mi)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){ss.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ss.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Mi)return()=>{};var i={callback:t,active:!0,revision:0};this.Jl.push(i),this.ua();var r=null==(e=this.zl)?void 0:e.kv.get(Lr);return this.Nr.disableSurveys||!this._surveyManager&&this.Gl&&!this.Vl||!r&&!y(this.Kl)&&!this.Zl?this.ea(i,{isLoaded:!1}):this._surveyManager&&this.ea(i),()=>{var t;i.active=!1,this.Jl=this.Jl.filter(t=>t!==i),0===this.Jl.length&&(null==(t=this.sa)||t.call(this),this.sa=void 0)}}ua(){var t,e,i;this._surveyManager&&this.Jl.length>0&&(null!==(t=this.sa)&&void 0!==t||(this.sa=null==(e=(i=this.Wl).onMatchingConditionsChanged)?void 0:e.call(i,this.Xl)))}ea(t,e){if(!this.Mi&&t.active){var i=++t.revision,r=r=>{if(!this.Mi&&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){ss.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){ss.error("Error in active matching surveys callback",t)}}}ga(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}ma(t){if(y(this._surveyManager))return{eligible:!1,reason:ds};var e="string"==typeof t?this.ga(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}ya(t){var e;if(null==(e=this.zl)||!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:ds};var i="string"==typeof t?this.ga(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return ss.warn("init was not called"),{visible:!1,disabledReason:ds};var e=this.ya(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(ss.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ds})):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.ya(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.zl)&&r.canCapture)if(y(this._surveyManager))ss.warn("init was not called");else{var a="string"==typeof t?this.ga(t):t;if(null!=a&&a.id)if(as.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){ss.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.Yl.delete(l),!this.Mi&&null!=(t=this.zl)&&t.canCapture&&(ss.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),ss.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.Yl.add(l)}else this._surveyManager.renderSurvey(a,o,i);else ss.warn("Survey element not found")}else ss.warn("Surveys of type "+a.type+" cannot be rendered in the app");else ss.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.zl)&&r.canCapture)if(y(this._surveyManager))ss.warn("init was not called");else{var s=this.ga(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&&ss.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.ma(s);if(!o.eligible)return void ss.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 ss.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?ss.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.447.11",li.LIB_NAME="web";var gs,ms=li,ys=/* @__PURE__ */new WeakMap,bs=()=>{var t;return null!=an&&null!=(t=an.performance)&&t.now?an.performance.now():Date.now()},_s=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==vn?void 0:vn.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=t.loadExternalDependency;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!==Yn&&e!==Zn&&e!==Qn||t()}),n=()=>t();gi(an,"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==an||an.removeEventListener("PHSurveyShown",n)}}},ws=/* @__PURE__ */(()=>null!=an&&an.location?xn(an.location.hash,"__posthog")||xn(location.hash,"state"):null)(),xs="_postHogToolbarParams",Ss=/* @__PURE__ */ci("[Toolbar]"),ks=/* @__PURE__ */ci("[FeatureFlags]"),Es=/* @__PURE__ */ci("[FeatureFlags]",{debugEnabled:!0}),As="\" failed. Feature flags didn't load in time.",Ts=[502,504],Fs=["click","keydown","wheel","touchstart","pointerdown"],Ps="connection_error",Rs=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Cs=t=>{var e={};for(var i of pi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Os=(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),Ms=class{constructor(t){this.name="featureFlags",this.Qd=!1,this.featureFlagEventHandlers=[],this.R=ks,this.Jd={},this.Zd={},this.Kd=[],this.Yd=/* @__PURE__ */new Set,this.Xd=/* @__PURE__ */new Set,this.tv=!1,this.ev=!1,this.iv=0,this.nv=!1,this.sv=!1,this.rv=!1,this.ov=/* @__PURE__ */new Map,this.lv=!1,this.av=!1,this.uv=!1,this.hv=0,this.dv=!1,this.an=()=>{var t=this.vv();this.hv=0,t&&this.reloadFeatureFlags()},this.fv=()=>{var t,e,i=this.pv,r=null!==(t=this.gv)&&void 0!==t?t:i;f(i)||f(r)||this.Nr.remoteRequestsDisabled||!this.mv||"hidden"===this.mv.visibilityState||Date.now()-(null!==(e=this.yv)&&void 0!==e?e:0)<r||(this.gv=this.dv||!this.Nr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.dv=!1,this.reloadFeatureFlags(),this.bv())},this._v=()=>{this.dv&&this.gv===this.pv||this.wv()},this.ln=()=>{var t;"visible"===(null==(t=this.mv)?void 0:t.visibilityState)&&this.wv()},this.Wl=t}get Sv(){}xv(){this.zl&&this.$v()}setup(t){try{this.Cv=typeof window>"u"?void 0:window,this.mv=typeof document>"u"?void 0:document}catch(t){this.Cv=void 0,this.mv=void 0}return this.ia=t,this.R=t.logger.createLogger("[FeatureFlags]"),vs(t.kv.initialize(),()=>{this.ia===t&&(this.ia=void 0,this.zl=t,this.Tv(t))})}Tv(t){var e;if(this.zl===t)return this.Cv&&gi(this.Cv,"online",this.an),this.$v(),this.Iv=t.registerDynamicEventProperties(()=>this.Mv()?this.Jd:this.Zd),this.Ev=null==(e=this.Sv)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Av(),this.Rv(),this.Pv()}),this.Rv(),this.initialize()}wv(){this.dv=!0,this.gv=this.pv,this.fv()}$v(){var t,e=this.Nr.refreshIntervalMs,i=!this.Nr.remoteRequestsDisabled&&this.mv&&!f(e)&&e>0?e:void 0;this.Nr.idleRefreshBackoff||(this.gv=i),i!==this.pv&&(this.Ov(),f(i)||(this.pv=i,this.gv=i,this.bv(),null!=(t=this.mv)&&t.addEventListener&&(gi(this.mv,$i,this.ln),vi(Fs,t=>{gi(this.mv,t,this._v,{capture:!0})}))))}bv(){f(this.pv)||(f(this.Fv)||clearInterval(this.Fv),this.yv=Date.now(),this.Fv=setInterval(this.fv,this.pv))}Ov(){var t;f(this.Fv)||(clearInterval(this.Fv),this.Fv=void 0,null==(t=this.mv)||null==t.removeEventListener||t.removeEventListener($i,this.ln),vi(Fs,t=>{var e;null==(e=this.mv)||null==e.removeEventListener||e.removeEventListener(t,this._v,{capture:!0})})),this.pv=void 0,this.gv=void 0,this.dv=!1,this.yv=void 0}destroy(){this.Dv()}dispose(){this.Dv()}Dv(){var t,e,i;this.Ov(),this.iv++,this.sv=!1,this.ia=void 0,this.Lv(this.Yd,"cancelled"),this.Lv(this.Xd,"cancelled"),this.zl&&(this.Nv(),null==(t=this.Iv)||t.dispose(),this.Iv=void 0,null==(e=this.Ev)||e.call(this),this.Ev=void 0,this.Kd=[],null==(i=this.Cv)||i.removeEventListener("online",this.an),this.zl=void 0)}get Nr(){return this.Wl.get()}jv(t){var e;return this.qv&&t in this.qv?this.qv[t]:null==(e=this.zl)?void 0:e.kv.get(t)}Av(){return!!this.qv&&(this.qv=void 0,!0)}Bv(){var t;return!f(null==(t=this.zl)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Av()}$t(t){this.zv(()=>{var e;return null==(e=this.zl)?void 0:e.kv.set(t)})}Hv(t,e,i){if(this.Sv&&t.$enabled_feature_flags){var r=this.jv("$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?a:i&&!h(s)?Object.keys(s||{}):Array.from(/* @__PURE__ */new Set([...Object.keys(r),...Object.keys(n)])),u=this.jv("$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={[_i]:p,[Ai]:p,[Ci]:g};for(var y of(t.$feature_flag_details&&(m[wi]=p),[ki,Si,Ei]))f(t[y])||(m[y]=!0);this.Sv.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.zv(()=>{var e;return null==(e=this.zl)?void 0:e.kv.remove(t)})}zv(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}Rv(){var t={};for(var i of[_i,Ci,ki,Oi]){var r=this.jv(i);f(r)||(t[i]=r)}this.Jd=t;var n=e({},t),s=this.jv(Ai);if(s)for(var a of Object.entries(s))n["$feature/"+a[0]]=a[1];this.Zd=n}Mv(){var t=this.Nr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.jv(Si);return"number"!=typeof e||Date.now()-e>t}Uv(){return!!this.Mv()&&(this.uv||this.ev||(this.uv=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Wv(){var t=this.Nr.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}):[]}Vv(){var t=this.Nr.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.Nr,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.Gv({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n,s,a=null!=r&&r.merge&&null!==(n=this.jv("$enabled_feature_flags"))&&void 0!==n?n:{},o=null!=r&&r.merge&&null!==(s=this.jv("$feature_flag_payloads"))&&void 0!==s?s:{},l=e({},a,t),u=e({},o,i),h={};for(var c of Object.entries(l)){var v=c[0],d=c[1];h[v]={key:v,enabled:Ut(d),variant:Ht(d),reason:void 0,metadata:f(null==u?void 0:u[v])?void 0:{id:0,version:void 0,description:void 0,payload:u[v]}}}this.Gv({flags:h})}get hasLoadedFlags(){return this.tv}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.jv(wi),i=this.jv(Oi),r=this.jv(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.Qd||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.Qd=!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=this.jv(Ai),e=this.jv(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.Qd||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Qd=!0),i}getFlagPayloads(){var t=this.jv(Ci),e=this.jv(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.Qd||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Qd=!0),i}reloadFeatureFlags(){this.nv||this.Nr.featureFlagsDisabled||this.vv()||(this.rv&&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.ev&&(this.sv=!0),this.Qv||(this.Kd.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}}),this.Qv=setTimeout(()=>{this.Jv()},5)))}reloadFeatureFlagsAsync(){return!this.zl||this.nv||this.Nr.featureFlagsDisabled||this.Nr.remoteRequestsDisabled||this.vv()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.Yd.add(t),this.reloadFeatureFlags()})}Lv(t,e){t.forEach(t=>t({status:e})),t.clear()}Nv(){clearTimeout(this.Qv),this.Qv=void 0}onReloading(t){return this.Kd.push(t),()=>{this.Kd=this.Kd.filter(e=>e!==t)}}ensureFlagsLoaded(){this.tv||this.ev||this.Qv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.nv=t}resetFlagCallReported(){this.Dt(Pi),this.ov=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.ov.size&&!this.lv&&null!=(t=this.zl)&&t.canCapture&&!this.zl.isRateLimited){this.lv=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.ov.keys())){var r=this.ov.get(i);if(r){if(r.value!==String(e[i])||!Os(r.context,this.Zv())){this.ov.delete(i);continue}if(this.getFeatureFlagResult(i),this.ov.has(i))break}}}finally{this.lv=!1}}}Jv(t){var i;this.Nv();var r=this.zl;if(!r||this.Nr.remoteRequestsDisabled||this.vv())this.Lv(this.Yd,"skipped");else if(this.ev)this.sv=!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.jv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.jv(Ti),timezone:Tn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Nr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.Wv();s.length&&(n.evaluation_contexts=s);var a=this.Vv();f(a)||(n.flag_keys=a);var o=this.Nr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.iv,h=this.Yd;this.Yd=/* @__PURE__ */new Set,this.Xd=h,this.ev=!0;var c=()=>{this.sv&&(this.sv=!1,this.Jv())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.ev=!1,u===this.iv)if(this.Kv(t.statusCode),s||this.sv||(this.$anon_distinct_id=void 0),!n.disable_flags||this.sv){this.av=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ps:"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.Gv(r,s,{partialResponse:o}),this.Lv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.Lv(h,"skipped");else c()},d=t=>{this.ev=!1,u===this.iv?(this.$t({[xi]:[Ps]}),this.R.error("Feature flag request failed",t),this.Bv()&&this.Pv(!0),this.Lv(h,"error"),c()):c()},p=null!==(i=this.Nr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.iv,m=()=>{if(u!==this.iv||!this.zl||this.Nr.remoteRequestsDisabled)return this.ev=!1,this.Lv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Nr.compression,sentAt:"body",timeoutMs:this.Nr.requestTimeoutMs}).then(t=>{if((t=>Ts.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()}}vv(){return yn(this.hv,3)}Kv(t){this.hv=bn(t,this.hv,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."))}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.av)if(this.tv||this.getFlags()&&this.getFlags().length>0){if(!this.Uv()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else this.R.warn('getFeatureFlag for key "'+t+As)}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){if(void 0===i&&(i={}),!i.fresh||this.av)if(this.tv||this.getFlags()&&this.getFlags().length>0){if(!this.Uv()){var r,n=this.getFlagVariants(),s=t in n,a=n[t],o=this.getFlagPayloads()[t],l=String(a),u=this.jv("$feature_flag_request_id")||void 0,c=this.jv("$feature_flag_evaluated_at")||void 0,v=this.jv("$flag_call_reported")||{};if(this.Nr.deduplicateCallsPerSession){var d,p=null==(d=this.zl)||null==(d=d.session)?void 0:d.sessionId,g=this.jv(Ri);p&&p!==g&&(v={},r=p)}if(!i.send_event&&"send_event"in i)r&&this.$t({[Pi]:v,[Ri]:r});else{var m,y,b,_,w=!(null!=(m=this.zl)&&m.canCapture),x=!(w||null!=(y=this.zl)&&y.isRateLimited);if(x?this.ov.delete(t):(w&&Object.keys(v).length>0&&(v={},this.$t({[Pi]:v})),null!=(_=v[t])&&_.includes(l)||this.Yv(t,l)),!x||null!=(b=v[t])&&b.includes(l))r&&this.$t({[Pi]:v,[Ri]:r});else{var S,k,E,A,T,F,P,R,C,O,M,I,j;h(v[t])?v[t].push(l):v[t]=[l],this.$t(e({[Pi]:v},r?{[Ri]:r}:{}));var D=this.getFeatureFlagDetails(t),L=[...null!==(S=this.jv("$feature_flag_errors"))&&void 0!==S?S:[]];f(a)&&L.push("flag_missing");var N={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:null!==(k=null==(E=this.Nr.bootstrap)||null==(E=E.featureFlags)?void 0:E[t])&&void 0!==k?k:null,$feature_flag_bootstrapped_payload:null!==(A=null==(T=this.Nr.bootstrap)||null==(T=T.featureFlagPayloads)?void 0:T[t])&&void 0!==A?A:null,$used_bootstrap_value:!this.av};f(null==D||null==(F=D.metadata)?void 0:F.has_experiment)||(N.$feature_flag_has_experiment=D.metadata.has_experiment),f(null==D||null==(P=D.metadata)?void 0:P.version)||(N.$feature_flag_version=D.metadata.version);var z=null!==(R=null==D||null==(C=D.reason)?void 0:C.description)&&void 0!==R?R:null==D||null==(O=D.reason)?void 0:O.code;z&&(N.$feature_flag_reason=z),null!=D&&null!=(M=D.metadata)&&M.id&&(N.$feature_flag_id=D.metadata.id),f(null==D?void 0:D.original_variant)&&f(null==D?void 0:D.original_enabled)||(N.$feature_flag_original_response=f(D.original_variant)?D.original_enabled:D.original_variant),null!=D&&null!=(I=D.metadata)&&I.original_payload&&(N.$feature_flag_original_payload=null==D||null==(j=D.metadata)?void 0:j.original_payload),L.length&&(N.$feature_flag_error=L.join(",")),this.Xv(N)||(this.tf(t,l),this.Yv(t,l))}}if(s)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:Bt(o)}}}else this.R.warn('getFeatureFlagResult for key "'+t+As)}Xv(t){try{var e;return!1!==(null==(e=this.zl)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}Yv(t,e){this.ov.set(t,{value:e,context:this.Zv()})}Zv(){var t,i,r;return{distinctId:null==(t=this.zl)?void 0:t.distinctId,groups:e({},null==(i=this.zl)?void 0:i.groups),sessionId:this.Nr.deduplicateCallsPerSession?null==(r=this.zl)||null==(r=r.session)?void 0:r.sessionId:void 0}}tf(t,e){var i=this.jv("$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.ef(t,e)}ef(t,e){var i=this;return r(function*(){var r=i.zl;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.Wv();s.length&&(n.evaluation_contexts=s);var a,o=i.Vv();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.Nr.compression,sentAt:"body",timeoutMs:i.Nr.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.av)return e.defaultValue;if(!(this.tv||this.getFlags()&&this.getFlags().length>0))return this.R.warn('isFeatureEnabled for key "'+t+As),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.Gv(t,e,i)}Gv(t,i,r){if(this.zl){this.tv=!0;var n=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=ks);var o=((t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).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].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)})(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{[_i]:u,[Ai]:p,[Ei]:!1}}var m=u,y=c,b=l;if(null!=s&&s.partialResponse){var _=Object.keys(m),w=y||{};m=e({},i,m),y=e({},r,w),_.forEach(t=>{var e;t in w||null==(e=y)||delete e[t]}),b=e({},n,b)}else if(t.errorsWhileComputingFlags)if(l){var x=new Set(Object.keys(l).filter(t=>{var e;return!(null!=(e=l[t])&&e.failed)}));m=e({},i,Object.fromEntries(Object.entries(m).filter(t=>x.has(t[0]))));var S=Object.fromEntries(Object.entries(y||{}).filter(t=>x.has(t[0])));y=e({},r,S),x.forEach(t=>{var e;t in S||null==(e=y)||delete e[t]}),b=e({},n,Object.fromEntries(Object.entries(b||{}).filter(t=>x.has(t[0]))))}else m=e({},i,m),y=e({},r,y),b=e({},n,b);return e({[_i]:Object.keys(Cs(m)),[Ai]:m||{},[Ci]:y||{},[wi]:b||{},[Ei]:!0===t.minimalFlagCalledEvents},v?{[ki]:v}:{},d?{[Si]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.R);if(n)if(!1===(null==r?void 0:r.persist)){var s=!f(this.zl.kv.get(Ai));this.qv=n,s||this.$t(n)}else this.Av(),this.Hv(n,t,!(null==r||!r.partialResponse)),this.$t(n);else i&&this.Bv();i||(this.uv=!1),this.Pv(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.if(t)}if(t){if(this.zl){if(!1===t)return this.Dt([Oi,Mi]),this.Pv(),void Es.info("All overrides cleared");if(h(t))return this.$t({[Oi]:Rs(t)}),this.Pv(),void Es.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.Qd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Oi]=h(n)?Rs(n):n),s&&(r[Mi]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Oi,Mi]):!1===n?this.Dt(Oi):!1===s&&this.Dt(Mi),this.Pv(),!1===n?Es.info("Flag overrides cleared"):n&&Es.info("Flag overrides set",{flags:n}),void(!1===s?Es.info("Payload overrides cleared"):s&&Es.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Oi]:t}),this.Pv(),void Es.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.tv){var e=this.nf(),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=(this.jv("$early_access_features")||[]).find(e=>e.flagKey===t),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};s&&(o.$early_access_feature_name=s.name),r&&(o.$feature_enrollment_stage=r);var l=e({},this.getFlagVariants(),{[t]:i});null==(n=this.Sv)||n.markCrossTabFeatureFlagChanges({[_i]:[t],[Ai]:[t],[Fi]:Object.keys(a)}),this.$t({[_i]:Object.keys(Cs(l)),[Ai]:l,[Fi]:e({},this.jv("$stored_person_properties")||{},a)}),this.Pv();try{var u;null==(u=this.zl)||u.capture("$feature_enrollment_update",o)}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.jv(bi);!r||e?this.sf(t,i):t(r)}sf(t,e){var i=this;return r(function*(){var r=i.zl;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({[bi]: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)}}})()}nf(){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),{})}}Pv(t){this.Rv();var e=this.nf(),i=e.flags,r=e.flagVariants,n=this.rv;this.rv=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.rv=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.rf(t,e)}rf(t,i){void 0===i&&(i=!0);var r=this.jv("$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.jv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Fi]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Fi),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.jv("$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.jv("$stored_group_properties")||{};this.$t({[Ti]:e({},i,{[t]:{}})})}else this.Dt(Ti)}reset(){this.iv++,this.Lv(this.Yd,"cancelled"),this.Lv(this.Xd,"cancelled"),this.sv=!1,this.Jd={},this.Zd={},this.qv=void 0,this.tv=!1,this.nv=!1,this.av=!1,this.$anon_distinct_id=void 0,this.Nv(),this.Qd=!1,this.hv=0,this.ov=/* @__PURE__ */new Map}},$s=/* @__PURE__ */ci("[FeatureFlags]"),Is=class{constructor(t,e){void 0===e&&(e=!1),this.lf=!1,this.update(t,e)}update(t,e){this.af=((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.lf||($s.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.lf=!0),f(t.flag_keys)||h(t.flag_keys)||$s.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.af}},js=class extends Ms{constructor(t){var e=new Is(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.uf=e}get Sv(){return this._instance.persistence}updateConfig(t,e){this.uf.update(t,e),this.xv()}},Ds=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Ls=/* @__PURE__ */ci("[Error tracking]"),Ns="webkit-masked-url:",zs=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Bs=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ns],Us=["__firefox__","__gCrWeb"],Hs=/*#__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),b=Array.isArray,_=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),R=I({}.hasOwnProperty),C=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 j(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_;if(r&&r(t,null),!b(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 D(t){for(var e=0;t.length>e;e++)R(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];R(t,a)&&(r[a]=b(o)?D(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 R(t,e)&&b(t[e])?j(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,D=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"),bt=N(dt,"shadowRoot"),_t=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.')},Rt=function(t){Pt(),Ft++;try{return n.createHTML(t)}finally{Ft--}},Ct=s.implementation,Ot=s.createNodeIterator,Mt=s.createDocumentFragment,$t=s.getElementsByTagName,It=a.importNode,jt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof i&&"function"==typeof yt&&Ct&&void 0!==Ct.createHTMLDocument;var Dt=Y,Lt=Z,Nt=Q,zt=tt,Bt=et,Ut=rt,Ht=nt,qt=at,Vt=it,Wt=null,Gt=j({},[...z,...B,...U,...q,...W]),Kt=null,Jt=j({},[...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,be={},_e=null,we=j({},["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=j({},["audio","video","img","source","image","track"]),ke=null,Ee=j({},["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,Re=!1,Ce=null,Oe=j({},[Ae,Te,Fe],w),Me=o(["mi","mo","mn","ms","mtext"]),$e=j({},Me),Ie=o(["annotation-xml"]),je=j({},Ie),De=j({},["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:_}),Kt=vt(t,"ALLOWED_ATTR",Jt,{transform:ze}),Ce=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}),_e=vt(t,"FORBID_CONTENTS",we,{transform:ze}),Yt=vt(t,"FORBID_TAGS",L({}),{transform:ze}),Zt=vt(t,"FORBID_ATTR",L({}),{transform:ze}),be=!!R(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=R(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?L(t.MATHML_TEXT_INTEGRATION_POINTS):j({},Me),je=R(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?L(t.HTML_INTEGRATION_POINTS):j({},Ie);var e=R(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),R(e,"tagNameCheck")&&He(e.tagNameCheck)&&(Xt.tagNameCheck=e.tagNameCheck),R(e,"attributeNameCheck")&&He(e.attributeNameCheck)&&(Xt.attributeNameCheck=e.attributeNameCheck),R(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(Xt.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),l(Xt),ne&&(ee=!1),ve&&(ce=!0),be&&(Wt=j({},W),Kt=u(null),!0===be.html&&(j(Wt,z),j(Kt,G)),!0===be.svg&&(j(Wt,B),j(Kt,K),j(Kt,X)),!0===be.svgFilters&&(j(Wt,U),j(Kt,K),j(Kt,X)),!0===be.mathMl&&(j(Wt,q),j(Kt,J),j(Kt,X))),Qt.tagCheck=null,Qt.attributeCheck=null,R(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Qt.tagCheck=t.ADD_TAGS:b(t.ADD_TAGS)&&(Wt===Gt&&(Wt=L(Wt)),j(Wt,t.ADD_TAGS,ze))),R(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Qt.attributeCheck=t.ADD_ATTR:b(t.ADD_ATTR)&&(Kt===Jt&&(Kt=L(Kt)),j(Kt,t.ADD_ATTR,ze))),R(t,"ADD_URI_SAFE_ATTR")&&b(t.ADD_URI_SAFE_ATTR)&&j(ke,t.ADD_URI_SAFE_ATTR,ze),R(t,"FORBID_CONTENTS")&&b(t.FORBID_CONTENTS)&&(_e===we&&(_e=L(_e)),j(_e,t.FORBID_CONTENTS,ze)),R(t,"ADD_FORBID_CONTENTS")&&b(t.ADD_FORBID_CONTENTS)&&(_e===we&&(_e=L(_e)),j(_e,t.ADD_FORBID_CONTENTS,ze)),me&&(Wt["#text"]=!0),ae&&j(Wt,["html","head","body"]),Wt.table&&(j(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=Rt("")}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}}(D,h),Tt=!0),n=Et),n&&"string"==typeof At&&(At=Rt("")));o&&o(t),Be=t}},Ve=j({},[...B,...U,...H]),We=j({},[...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=_t(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=_t(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?Rt(t):t;if(Pe===Fe)try{e=(new I).parseFromString(a,Le)}catch(t){}if(!e||!e.documentElement){e=Ct.createDocument(Pe,"template",null);try{e.documentElement.innerHTML=Re?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,Dt," "),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!==_t(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(jt.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(jt.uponSanitizeElement,Wt,Gt,le),si(jt.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&&!_e[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(jt.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=_(t.tagName),r=_(e.tagName);return!!Ce[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&&je[i]:Boolean(We[t])}(i,e,r):t.namespaceURI===Fe?function(t,e,i){return!(e.namespaceURI===Te&&!je[i])&&!(e.namespaceURI===Ae&&!$e[i])&&!We[t]&&(De[t]||!Ve[t])}(i,e,r):!("application/xhtml+xml"!==Le||!Ce[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(jt.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=j({},["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[_(t)]&&O(qt,t)},ci=function(t,e,i,r){if(n&&"object"==typeof D&&"function"==typeof D.getAttributeType&&!i)switch(D.getAttributeType(t,e)){case"TrustedHTML":return Rt(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(jt.beforeSanitizeAttributes,t,null);var e=t.attributes;if(e&&!ii(t)){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Kt=ai(jt.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(jt.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(jt.afterSanitizeAttributes,t,null)}},fi=function(t){var e=null,i=Qe(t);for(si(jt.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if(si(jt.uponSanitizeShadowNode,e,null),oi(e,t),di(e),ri(e.content)&&fi(e.content),1===(wt?wt(e):e.nodeType)){var r=bt(e);ri(r)&&(pi(r),fi(r))}si(jt.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=bt(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((Re=!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 C(t);case"function":case"object":if(null===t)return C(t);var e=t,i=N(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:C(r)}return C(t)}}(t)))throw M("dirty is not a string, aborting");if(!r.isSupported)return t;oe?(Wt=le,Kt=ue):qe(e),(jt.uponSanitizeElement.length>0||jt.uponSanitizeAttribute.length>0)&&(Wt=L(Wt)),jt.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?Rt(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?Rt(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&&R(jt,t)&&m(jt[t],e)},r.removeHook=function(t,e){if(R(jt,t)){if(void 0!==e){var i=p(jt[t],e);return-1===i?void 0:y(jt[t],i,1)[0]}return g(jt[t])}},r.removeHooks=function(t){R(jt,t)&&(jt[t]=[])},r.removeAllHooks=function(){jt={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}()}(),qs="Refusing to render web experiment since the viewer is a likely bot",Vs={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Ws={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>es(e,t),not_regex:(t,e)=>!es(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},Gs=/* @__PURE__ */ci("[Conversations]"),Ks="Conversations not available yet.";function Js(){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 Xs(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({},Js(),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 Ys=["debug","log","warn","error","info"],Zs="console",Qs="__posthogHandledLogsRequestError",ta=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[Qs]=!0,i},ea=t=>!!t&&"object"==typeof t&&!0===t[Qs],ia=class{get cf(){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.Wl=t,this.hf=e,this.name="logs",this.df=!1,this.vf=!1,this.ff=!1,this.R=ci("[logs]"),this.Sc=[],this.pf=[],this.hv=0,this.gf=!1,this.Mi=!1,this.mf=[],this.yf=[],this.bf=!1,this._f=!1,this.wf=!1,this.kf=()=>{var t,e;this.Mi||(this.hv=0,null==(t=this.Sf)||t.onReconnect(),null==(e=this.xf)||e.onReconnect())},this.df=!(null==(i=t.get())||!i.captureConsoleLogs)}get $f(){return!0}Cf(){}Tf(){if(!this.wf){try{this.Cv=typeof window>"u"?void 0:window}catch(t){this.Cv=void 0}this.Cv&&(gi(this.Cv,"online",this.kf),this.wf=!0)}}If(t,e,i,r){this.Tf();var n=Xs(this.Wl.get(),i);return[new Je(this.Mf(t,e),n,this.cf,()=>this.hf(),t=>t(),void 0,r),n]}Ef(){var t=this.Wl.get();if(!this.Sf||this.Af!==t){var e;null==(e=this.Sf)||e.reset(),this.Af=t;var i=this.If(()=>this.Sc,t=>{this.Sc=t});this.Sf=i[0],this.Rf=i[1]}return this.Sf}Pf(){var t=this.Wl.get();if(!this.xf||this.Of!==t){var e;null==(e=this.xf)||e.reset(),this.Of=t;var i=this.If(()=>this.pf,t=>{this.pf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Zs);this.xf=i[0],this.Ff=i[1]}return this.xf}setup(t){if(!this.Mi&&!this.gf)return this.gf=!0,this.zl=t,this.R=t.logger.createLogger("[logs]"),vs(t.kv.initialize(),()=>{this.Mi||this.Tv(t)})}Tv(t){var e;this.Tf(),null!=(e=this.Wl.get())&&e.captureConsoleLogs&&(this.df=!0),(this.df||this.Wl.remoteConfigWillArrive&&t.kv.get(this.Wl.captureHintKey))&&this.Df();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.Mi?r.dispose():(this.na=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Mi||(this.Mi=!0,this.Lf(),null==(t=this.na)||t.dispose(),this.na=void 0,this.zl=void 0,this.ff=!1,null==(e=this.Cv)||e.removeEventListener("online",this.kf),null==(i=this.Nf)||i.call(this),this.Nf=void 0,null==(r=this.Sf)||r.clearQueue(),null==(n=this.xf)||n.clearQueue(),null==(s=this.Sf)||s.reset(),null==(a=this.xf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Mi){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.jf():(null==(i=this.zl)||i.kv.set(this.Wl.captureHintKey,!!r),r?(this.df=!0,this.vf||this.Df(),this.loadIfEnabled()):this.jf())}}reset(){var t,e,i,r;this.Lf(),null==(t=this.Sf)||t.clearQueue(),this.Sc=[],null==(e=this.Sf)||e.reset(),null==(i=this.xf)||i.clearQueue(),this.pf=[],null==(r=this.xf)||r.reset(),this.hv=0}captureLog(t){!this.Mi&&this.zl&&this.Ef().captureLog(t)}captureConsoleLog(t){!this.Mi&&this.zl&&this.Pf().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Mi&&this.zl&&this.Pf().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.Lf(),null==(t=this.xf)||t.clearQueue(),this.pf=[]}jf(){this.df||this.Lf()}Df(){var t,e=this;if(!this.bf&&null!=(t=this.Cv)&&t.console){var i=Xs(this.Wl.get()).maxBufferSize,r=!0;this.yf.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.Cv.console[t])}catch(t){return 1}n&&e.yf.push(En(e.Cv.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.qf(t,a,i)}catch(t){}return s.apply(e.Cv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of Ys)if(n(s))continue;this.bf=!0,this.Bf=setTimeout(()=>{this.Lf()},3e4)}}qf(t,e,i){var r;if(this.bf&&!this._f&&0!==e.length)if(null!=(r=this.zl)&&r.canCapture){if(i>this.mf.length){this._f=!0;try{this.mf.push({level:t,args:e,occurredAtMs:Date.now(),context:this.hf()})}finally{this._f=!1}}}else this.Lf()}Lf(){if(this.mf=[],this.bf){for(var t of(this.bf=!1,this.Bf&&(clearTimeout(this.Bf),this.Bf=void 0),this.yf))t();this.yf=[]}}zf(){var t=this.mf;return this.Lf(),t}get logger(){return this.Hf||(this.Hf={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.Hf}flushLogs(t){this.zl&&(t?this.Uf(t):(this.Sf&&this.Sf.flush().catch(t=>this.Wf(t)),this.xf&&this.xf.flush().catch(t=>this.Wf(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Sf)?void 0:e.flush().catch(e=>t.Wf(e)),n=null==(i=t.xf)?void 0:i.flush().catch(e=>t.Wf(e));yield r,yield n})()}Wf(t){ea(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Mi&&this.df&&!this.vf&&!this.ff){var t=this.Cf();if(t){this.ff=!0;try{t((t,e)=>{if(this.ff=!1,!this.Mi&&this.df)if(t||!e)this.R.error("Could not load logs script",t),this.Lf();else{var i=this.zf();this.Nf=e.initialize(this.zl),this.vf=!0,i.length>0&&e.replay(this.zl,i)}})}catch(t){throw this.ff=!1,t}}else this.Lf()}}Mf(t,e){var i=this.zl;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(yn(this.hv,3))e({kind:"fatal",error:ta(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:ta(void 0,"logs request timed out")})},9e4),s=this.$f;this.zl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.zl.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.Vf(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:ta(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})})}})}Vf(t,e){(0!==t||e)&&(this.hv=bn(t,this.hv,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.")))}Uf(t){this.Sc.length>0&&this.Gf(t,this.Sc,this.Rf,this.zl.library.name,t=>{this.Sc=t}),this.pf.length>0&&this.Gf(t,this.pf,this.Ff,Zs,t=>{this.pf=t})}Gf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ve(s,qe(i,this.zl.library.name,this.zl.library.version),r,this.zl.library.version);this.zl.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.zl.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Wf(t))}}},ra=/* @__PURE__ */ci("[NetworkMetrics]"),na={"http:":80,"https:":443},sa=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),aa=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Ar(r))?void 0:i.href)||r}},oa=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=bs()-n,d=Ar(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":_=sa.has(b=f.method)?b:"_OTHER"},"_OTHER"===_&&b!==_?{"http.request.method_original":b}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||na[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){ra.error("Failed to record network metric",t)}var b,_},la=()=>{},ua=(t,e)=>c(null==an?void 0:an.fetch)?En(an,"fetch",i=>function(){for(var r=bs(),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=aa(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=>(oa(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw oa(t,d,void 0,r,e,i),i})}catch(t){return ra.error("Failed to observe fetch",t),o}}):la,ha=(t,e)=>{var i,r=null==an||null==(i=an.XMLHttpRequest)?void 0:i.prototype;if(!r)return la;var n=/* @__PURE__ */new WeakMap,s=En(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{ys.has(this)||n.set(this,aa(i[0],i[1]))}catch(t){ra.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=En(r,"send",i=>function(){var r;try{var s=n.get(this);if(s&&e()){var a=bs();gi(this,"loadend",r=()=>{this.removeEventListener("loadend",r),oa(t,s,this.status,a,e)})}}catch(t){ra.error("Failed to observe XHR send",t)}try{for(var o=arguments.length,l=new Array(o),u=0;o>u;u++)l[u]=arguments[u];return i.apply(this,l)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{s(),a()}},ca=/* @__PURE__ */new WeakMap,va=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),da={maxStringLength:2048,truncationSuffix:"..."},fa={maxStringLength:2048,truncationSuffix:"..."};function pa(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function ga(t,e){return{}.hasOwnProperty.call(t,e)}function ma(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function ya(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?ke(r,da):r).slice(0,e)}}function ba(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function _a(t){return ke(t||"Unknown error",fa).slice(0,2048)}function wa(t,e){try{return _a(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:_a(t.value)}))}function Sa(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 ka(t,e){return{message:wa(t,e),type:Sa(t,e)}}var Ea=function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return fi({},...e)},Aa={featureFlags:js},Ta={sessionRecording:class{get Nr(){return this._instance.config}get Wc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Qf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this.Jf||"missing_config"===this.Jf?this.Jf:null!==(t=null==(e=this.Qf)?void 0:e.status)&&void 0!==t?t:this.Jf}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Jf=Nn,this.Zf=void 0,this.Kf=!1,this.Ke=(()=>{var t;if(null==un||!un.visibilityState||"visible"===un.visibilityState)return!0;var e=null==an||null==(t=an.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.ln=()=>{var t;"visible"===(null==un?void 0:un.visibilityState)&&(this.Ke=!0,null==(t=this.Qf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Bn.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Nr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=un&&un.addEventListener&&gi(un,"visibilitychange",this.ln)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.Kf=!0,null==un||null==un.removeEventListener||un.removeEventListener("visibilitychange",this.ln),i?this.Yf(!0):this.stopRecording()}get Xf(){var t,e=!(null==(t=this._instance.get_property(Zr))||!t.enabled),i=!this.Nr.disable_session_recording,r=this.Nr.disable_session_recording||this._instance.consent.isOptedOut();return an&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!(this.Kf||this.Xf&&null!=(e=this.Qf)&&e.isStarted)){var i=!f(Object.assign)&&!f(Array.from);this.Xf&&i?(this.tp(t),Bn.info("starting")):(this.Jf=Nn,this.stopRecording())}}tp(t){var e,i;if(this.Xf)if("awaiting_config"!==this.Jf&&"missing_config"!==this.Jf&&(this.Jf=zn),null!=vn&&null!=(e=vn.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=vn.__PosthogExtensions__)&&i.initSessionRecording)this.ep(t);else{var r,n=this._instance.sessionManager;null==(r=vn.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.np,e=>{if(!this.Kf&&this.Xf&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[rn]:!0}),Bn.error("could not load recorder",e)):void this.ep(t);this.Jf=Nn})}}stopRecording(){var t,e;null==(t=this.Zf)||t.call(this),this.Zf=void 0,null==(e=this.Qf)||e.stop()}Yf(t){var e,i;void 0===t&&(t=!1),null==(e=this.Zf)||e.call(this),this.Zf=void 0,null==(i=this.Qf)||i.discard({discardProducerEvents:t})}sp(){var t,e;null==(t=this.Wc)||t.unregister("$session_is_sampled"),null==(e=this.Wc)||e.unregister("$replay_sample_rate")}rp(t,e){if(y(t))return null;var i,r=b(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Bn.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}op(t){if(this.Wc){var i,r,n=this.Wc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.rp(null==(i=this.Nr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.rp(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.sp();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[Zr]: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.Zf)||i.call(this),this.Zf=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.op(e),void this.Yf()):(this.op(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.Jf&&(this.Jf="missing_config",this._instance.register_for_session({[nn]:!0}),Bn.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.Qf)&&i.log?this.Qf.log(t,e):Bn.warn("log called before recorder was ready")}get np(){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"}lp(){var t,e=this._instance.get_property(Zr);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Bn.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}ep(t){var e,i,r;if(!this.Kf&&this.Xf&&this._instance.sessionManager){if(null==(e=vn.__PosthogExtensions__)||!e.initSessionRecording)return Bn.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[rn]:!0});var n;if(this.Qf||(this.Qf=null==(n=vn.__PosthogExtensions__)?void 0:n.initSessionRecording(this._instance,this.Ke),this.Qf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.lp()){if("missing_config"===this.Jf||"awaiting_config"===this.Jf)return;return this.Jf="awaiting_config",Bn.info("persisted remote config is stale, requesting fresh config before starting"),void new Ln(this._instance).load()}this.Jf=zn,null==(i=(r=this.Qf).setDocumentWasEverVisible)||i.call(r,this.Ke),this.Qf.start(t)}else this.Jf=Nn}onRRwebEmit(t){var e;null==(e=this.Qf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Qf||null==(t=this.Wc)||t.register({[tn]:!0}),null==(e=this.Qf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.Qf||null==(t=this.Wc)||t.register({[Qr]:!0}),null==(e=this.Qf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.Qf||null==(e=this.Wc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Qf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Un){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.Qf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Qf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.Qf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Fa={autocapture:class extends Ir{constructor(t){super(new Dr(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.ap=!1,this._instance=t,this.up=this.cp()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.hp();return!!(t.path||t.search||this.dp(t))}startIfEnabled(){this.isEnabled&&(hi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.up=this.cp(),this.startIfEnabled()}stop(){this.vp&&this.vp(),this.vp=void 0,this.fp&&this.fp(),this.fp=void 0,hi.info("History API monitoring stopped")}monitorHistoryChanges(){an&&an.history&&(this.pp("pushState"),this.pp("replaceState"),this.gp(),this.dp()&&this.mp())}pp(t){var e;if(an&&(null==(e=an.history[t])||!e.__posthog_wrapped__)){var i=this;En(an.history,t,e=>function(r,n,s){var a;i.yp(s)&&i.bp(),e.call(this,r,n,s),i._p(t,!i.ap&&"popstate"!==(null==an||null==(a=an.event)?void 0:a.type))})}}cp(){var t=null==an?void 0:an.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}hp(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}dp(t){return void 0===t&&(t=this.hp()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}wp(t){var e=this.hp(),i=this.up;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.dp(e)&&t.hash!==i.hash))}_p(t,e){void 0===e&&(e=!1);try{e||this.bp();var i=this.cp();if(!i)return;if(this.wp(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.kp=r,Promise.resolve().then(()=>this.bp())):r()}this.up=i}catch(e){hi.error("Error capturing "+t+" pageview",e)}}yp(t){var e,i;return!(y(t)||!an)&&(null==(e=Ar(String(t)))?void 0:e.href)!==(null==(i=an.location)?void 0:i.href)}bp(){var t=this.kp;if(t){this.kp=void 0,this.ap=!0;try{t()}catch(t){hi.error("Error capturing deferred pageview",t)}finally{this.ap=!1}this.up=this.cp()}}gp(){if(!this.vp){var t=()=>{this._p("popstate")};gi(an,"popstate",t),this.vp=()=>{an&&an.removeEventListener("popstate",t)}}}mp(){if(!this.fp){var t=()=>{this._p("hashchange")};gi(an,"hashchange",t),this.fp=()=>{an&&an.removeEventListener("hashchange",t)}}}},heatmaps:class{get Nr(){return this.instance.config}constructor(t){var e;this.Sp=!1,this.Ca=!1,this.xp=null,this.instance=t,this.Sp=!(null==(e=this.instance.persistence)||!e.props[qr]),this.rageclicks=new Er(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Nr.capture_heatmaps)&&this.Nr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Nr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Nr.capture_heatmaps)?y(this.Nr.enable_heatmaps)?this.Sp:this.Nr.enable_heatmaps:!1!==this.Nr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ca)return;Hn.info("starting..."),this.$p(),this.ln()}else{var t;clearInterval(null!==(t=this.xp)&&void 0!==t?t:void 0),this.Cp(),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({[qr]:i}),this.Sp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}Tp(t){qn(t.originalEvent)&&this.Fr(t.originalEvent,"deadclick")}ln(){this.xp&&clearInterval(this.xp),this.xp="visible"===(null==un?void 0:un.visibilityState)?setInterval(this.Ac.bind(this),this.flushIntervalMilliseconds):null}$p(){an&&un&&(this.Ip=this.Ac.bind(this),gi(an,sn,this.Ip),this.Mp=t=>this.Fr(t||(null==an?void 0:an.event)),gi(un,"click",this.Mp,{capture:!0}),this.Ep=t=>this.Ap(t||(null==an?void 0:an.event)),gi(un,"mousemove",this.Ep,{capture:!0}),this.Rp=new pn(this.instance,fn,this.Tp.bind(this)),this.Rp.startIfEnabledOrStop(),this.Pp=this.ln.bind(this),gi(un,$i,this.Pp),this.Ca=!0)}Cp(){var t;an&&un&&(this.Ip&&an.removeEventListener(sn,this.Ip),this.Mp&&un.removeEventListener("click",this.Mp,{capture:!0}),this.Ep&&un.removeEventListener("mousemove",this.Ep,{capture:!0}),this.Pp&&un.removeEventListener($i,this.Pp),clearTimeout(this.Op),null==(t=this.Rp)||t.stop(),this.Ca=!1)}Fp(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&&Di(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:an)?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}}Fr(t,i){var r;if(void 0===i&&(i="click"),!ji(t.target)&&qn(t)){var n=this.Fp(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&lr(Wi(t),this.instance.config.rageclick)&&this.So(e({},n,{type:"rageclick"})),this.So(n)}}Ap(t){!ji(t.target)&&qn(t)&&(clearTimeout(this.Op),this.Op=setTimeout(()=>{this.So(this.Fp(t,"mousemove"))},500))}So(t){if(an){var e=this.Nr.disable_capture_url_hashes?J(an.location.href):an.location.href,i=this.Nr.custom_personal_data_properties,r=wn(e,this.Nr.mask_personal_data_properties?[...Fn,...i||[]]:[],Rn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}Ac(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:pn,webVitalsAutocapture:class{constructor(t){var i,r=this;this._instance=t,this.Sp=!1,this.Ca=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Dp=function(t){void 0===t&&(t=!1),clearTimeout(r.Lp),r.Lp=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.Np=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))On.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.jp(r);if(!f(n)){var s=b(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.qp||this.qp>t.value){this.Rt.navigationKey!==s&&(this.Dp(),this.Lp=setTimeout(this.Dp,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 jn){var h="url"===u&&"string"==typeof t.attribution[u]?this.jp(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.Dp()}else On.error("Ignoring metric with value >= "+this.qp,t)}}},this.Bp=()=>{if(!this.Ca){var t,i,r,n,s=!1,a=vn.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.zp])||("web-vitals"===this.zp&&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.Np.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Np.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Np.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.Np.bind(this),v);var d=null==an?void 0:an.document;gi(d,$i,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.Dp(!0)}),gi(an,"pagehide",()=>this.Dp(!0)),this.Ca=!0}else On.error("web vitals callbacks not loaded - not starting")}},this.Sp=!(null==(i=this._instance.persistence)||!i.props[Kr]),this.startIfEnabled()}get Hp(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.Hp)?null==(t=this.Hp)?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)||$n:i}get flushToCaptureTimeoutMs(){return(v(this.Hp)?this.Hp.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.Hp)?this.Hp.web_vitals_attribution:void 0;return _(t)?t?$n:[]:h(t)?t:In}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.Hp)?this.Hp.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get qp(){var t=v(this.Hp)&&b(this.Hp.__web_vitals_max_value)?this.Hp.__web_vitals_max_value:Mn;return t>0&&6e4>=t?Mn:t}get isEnabled(){var t=null==hn?void 0:hn.protocol;if("http:"!==t&&"https:"!==t)return On.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.Hp)?this.Hp.web_vitals:_(this.Hp)?this.Hp:void 0;return _(e)?e:this.Sp}startIfEnabled(){this.isEnabled&&!this.Ca&&(On.info("enabled, starting..."),this.Ga(this.Bp))}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({[Kr]:i}),this._instance.persistence.register({[Yr]:r})),this.Sp=i,this.startIfEnabled()}}}get zp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ga(t){var e=vn.__PosthogExtensions__,i=this.zp,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&f(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,e=>{e?On.error("failed to load script",e):t()})}jp(t){var e=t||(null==an?void 0:an.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 wn(i,this._instance.config.mask_personal_data_properties?[...Fn,...r||[]]:[],Rn)}On.error("Could not determine current URL")}}},Pa={exceptionObserver:class{constructor(t){var i;this.Bp=()=>{var t;if(an&&this.isEnabled&&null!=(t=vn.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=vn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=vn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=vn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Up&&this.Nr.capture_unhandled_errors&&(this.Up=e(this.captureException.bind(this))),!this.Wp&&this.Nr.capture_unhandled_rejections&&(this.Wp=i(this.captureException.bind(this))),!this.Vp&&this.Nr.capture_console_errors&&(this.Vp=r(this.captureException.bind(this)))}catch(t){gn.error("failed to start",t),this.Gp()}}},this._instance=t,this.Qp=!(null==(i=this._instance.persistence)||!i.props[Vr]),this.kt=new R(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:gn})),this.Nr=this.Jp(),this.startIfEnabledOrStop()}Jp(){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.Qp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Nr.capture_console_errors||this.Nr.capture_unhandled_errors||this.Nr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(gn.info("enabled"),this.Gp(),this.Ga(this.Bp)):this.Gp()}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",e=>{if(e)return gn.error("failed to load script",e);t()})}Gp(){var t,e,i;null==(t=this.Up)||t.call(this),this.Up=void 0,null==(e=this.Wp)||e.call(this),this.Wp=void 0,null==(i=this.Vp)||i.call(this),this.Vp=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Qp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Vr]:this.Qp}),this.Nr=this.Jp(),this.startIfEnabledOrStop())}}onConfigChange(){this.Nr=this.Jp()}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 gn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,r;this.Zp=[],this.Kp=new it([new St,new Mt,new Et,new kt,new Ct,new Rt,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 b=bt(s,y);for(var _ of(s.splice(y.start-b,b),m))_.start-=b}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.Zp=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Yp=Lt(this.Xp()),this.tg=new Nt(this.Yp)}onConfigChange(){this.Yp=Lt(this.Xp()),this.tg.setConfig(this.Yp)}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.Zp=s,this._instance.persistence&&this._instance.persistence.register({[Wr]:this.Zp,[Gr]:a})}}}get eg(){var t,e,i=!!this._instance.get_property(Gr);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.Kp.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Yp.enabled)try{if(!p(t)||0===t.trim().length)return void Ls.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)=>jt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.ig(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&Ls.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.tg.add(e({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){Ls.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.ng(e)){if(this.sg(e))return this.rg("Exception dropped: matched a suppression rule"),void Ls.info("Skipping exception capture because a suppression rule matched");if(!this.eg&&this.og(e))return this.rg("Exception dropped: thrown by a browser extension"),void Ls.info("Skipping exception capture because it was thrown by an extension");if(!this.eg&&this.lg(e))return this.rg("Exception dropped: thrown by an injected browser script"),void Ls.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ag(e))return this.rg("Exception dropped: thrown by the PostHog SDK"),void Ls.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Yp.enabled&&y(t.$exception_steps)?this.ug(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.tg.clear(),n}catch(t){return Ds(t)||Ls.error("Failed to capture exception event. Dropping this exception.",t),void this.tg.clear()}}catch(t){return void(Ds(t)||Ls.error("Failed to process exception event. Ignoring this exception.",t))}}ug(t){try{var i=this.tg.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return Ls.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}rg(t){this.Yp.enabled&&this.tg.add({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}ig(t){return v(t)?e({},t):{}}Xp(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}sg(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.Zp.some(t=>{var i=t.values.map(t=>{var i=rs[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 Ls.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}og(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&&Bs.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(Ns)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&zs.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(Ns))}))}lg(t){return t.some(t=>{var e=t.value;return p(e)&&Us.some(t=>e.includes(t))})}ag(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}ng(t){return!y(t)&&h(t)}}},Ra={productTours:class{get Wc(){return this._instance.persistence}constructor(t){this.cg=null,this.hg=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.Wc&&this.Wc.register({[Xr]:!!e.productTours}),!Wn(this._instance))return!this.cg&&y(null==(i=this.Wc)?void 0:i.props.ph_product_tours)||Vn.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.cg)||r.stop(),this.cg=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.cg&&Wn(this._instance)&&this.Ga(()=>this.dg())}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",e=>{e?Vn.error("Could not load product tours script",e):t()})}dg(){var t;!this.cg&&null!=(t=vn.__PosthogExtensions__)&&t.generateProductTours&&(this.cg=vn.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.hg)||e){var i=this.Wc;if(i){var r=i.props[en];if(h(r)&&!e)return this.hg=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(Wn(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||Vn.warn(n):Vn.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.hg=s,i&&i.register({[en]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.hg,{isLoaded:!0})}getActiveProductTours(t){y(this.cg)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.cg.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.cg)||e.showTourById(t)}previewTour(t){this.cg?this.cg.previewTour(t):this.Ga(()=>{var e;this.dg(),null==(e=this.cg)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.cg)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.cg)||t.nextStep()}previousStep(){var t;null==(t=this.cg)||t.previousStep()}clearCache(){var t;this.hg=null,null==(t=this.Wc)||t.unregister(en)}resetTour(t){var e;null==(e=this.cg)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.cg)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.cg)||e.cancelPendingTour(t)}},featureFlags:js},Ca={siteApps:class{constructor(t){this._instance=t,this.vg=0,this.fg=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}pg(t,e){if(e){var i=this.globalsForEvent(e);this.fg.push(i),this.fg.length>1e3&&(this.fg=this.fg.slice(10))}}get siteAppLoaders(){var t;return null==(t=vn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.pg.bind(this));this.gg=()=>{t(),this.fg=[],this.gg=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}}mg(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)||(Gn.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)||(Gn.error("prepare_external_dependency_script returned null"),null):t}yg(){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==un?void 0:un.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.vg++,this.bg)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.mg(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.bg=()=>{h.forEach(t=>t()),this.bg=void 0},this._g()}_g(){var t=!1;return()=>{var e;t||(t=!0,this.vg--,0===this.vg&&(null==(e=this.bg)||e.call(this)))}}wg(t,e){void 0===e&&(e=!0);var i=this.yg();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.fg.length&&(Gn.info("Processing "+this.fg.length+" events for site app with id "+t.id),this.fg.forEach(t=>this.wg(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.gg)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,Gn.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.wg(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){Gn.error(Kn+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){Gn.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}kg(){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)}Sg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.wg(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){Gn.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.kg(),void this._instance.on("eventCaptured",t=>this.Sg(t))):void Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.gg)||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;vn["__$$ph_site_app_"+e]=n._instance,null==(t=vn.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return Gn.error(Kn+e,t)})};for(var o of s.siteApps)a()}else Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Oa={tracingHeaders:class{constructor(t){this._instance=t,this.xg=void 0,this.$g=void 0,this.Cg=void 0,this.Bp=()=>{var t,e,i=this.Tg();i?(f(this.xg)&&(this.xg=null==(t=vn.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.$g)&&(this.$g=null==(e=vn.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Gp()}}initialize(){this.startIfEnabledOrStop()}Ga(t){var e,i;null!=(e=vn.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=vn.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",e=>{if(e)return An.error("failed to load script",e);t()})}Ig(){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}Tg(){var t=this.Ig();return h(t)?(h(this.Cg)?this.Cg.splice(0,this.Cg.length,...t):this.Cg=[...t],t.length>0?this.Cg:void 0):(h(this.Cg)&&this.Cg.splice(0),this.Cg=t||void 0,this.Cg)}Gp(){var t,e;null==(t=this.xg)||t.call(this),null==(e=this.$g)||e.call(this),this.xg=void 0,this.$g=void 0}startIfEnabledOrStop(){this.Tg()?this.Ga(this.Bp):this.Gp()}}},Ma={surveys:class extends ps{constructor(t){super(new _s(t))}},featureFlags:js},$a={toolbar:class{constructor(t){this.instance=t}Mg(t){vn.ph_toolbar_state=t}Eg(){var t;return null!==(t=vn.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(!an||!un)return!1;t=null!=t?t:an.location,i=null!=i?i:an.history;try{if(!e){try{an.localStorage.setItem("test","test"),an.localStorage.removeItem("test")}catch(t){return!1}e=null==an?void 0:an.localStorage}var r,n=ws||xn(t.hash,"__posthog")||xn(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(xs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Ag(t){var e=vn.ph_load_toolbar||vn.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):Ss.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==un||!un.getElementById("__POSTHOG_TOOLBAR__"));if(!an||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(an.localStorage.setItem(xs,JSON.stringify(e({},n,{source:void 0}))),2===this.Eg())this.Ag(n);else if(0===this.Eg()){var s;this.Mg(1),null==(s=vn.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return Ss.error("[Toolbar] Failed to load",t),void this.Mg(0);this.Mg(2),this.Ag(n)}),gi(an,"turbolinks:load",()=>{this.Mg(0),this.loadToolbar(n)})}return!0}Rg(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)}}},Ia={experiments:class t{get Nr(){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.Pg("retrieved web experiments from the server"),i.Og=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.Og&&(t.Pg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.Og)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.Fg(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.Dg(a,i._instance)&&i.Lg(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.Pg(qs);else if(!this.Nr.disable_web_experiments){if(y(this.Og))return this.Og=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.Pg("applying feature flags",e),e.forEach(t=>{var e;if(this.Og&&null!=(e=this.Og)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.Og)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.Fg(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=_n(null==e?void 0:e.search,"__experiment_id"),r=_n(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.Pg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.Ng(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Nr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Nr.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.Nr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Ng(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.Pg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.Lg(n[0].name,i,n[0].variants[i].transforms))}Fg(e,i){var r=e.variants[i];t.jg(r,this._instance)?this.Lg(e.name,i,r.transforms):t.Pg("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static Dg(e,i){return!y(e.conditions)&&t.jg(e,i)&&t.qg(e)}static jg(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||Ws[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==an?void 0:an.location}static qg(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(!un)return{};var r,n,s,a=e?[...Fn,...i||[]]:[],o=(r=wn(un.URL,a,Rn),n=Pn.concat(t||[]),s={},di(n,function(t){var e=_n(r,t);s[t]=e||null}),s);return fi(function(){var t={};return di(Cn,function(e){var i=(t=>{if(un){try{for(var e=t+"=",i=un.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 Pg(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 Bg(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 zg(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.zg(e)})}Lg(i,r,n){this._is_bot()?t.Pg(qs):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.Pg("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.Bg("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!=gs?gs:gs=Hs(),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({},Vs,{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({},Vs,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.zg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.Pg("Control variants leave the page unmodified.")}_is_bot(){return ln&&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}(ln,this.Nr.custom_blocked_useragents):void 0}},featureFlags:js},ja={conversations:class{constructor(t){this._instance=t,this.Hg=void 0,this._conversationsManager=null,this.Ug=!1,this.ie=null,this.Wg=!1,this.Vg=0,this.Gg=null,this.Qg=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.Gg=null;else if(this.Jg=t.ok,t.ok){var e=t.config.conversations;y(e)?this.Gg=null:(_(e)?this.Hg=e:(this.Hg=e.enabled,this.ie=e),this.Hg||(this.Gg=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Vg++,this.Hg=void 0,this.ie=null,this.Jg=void 0,this.Wg=!1,this.Gg=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ug||this._instance.config.disable_conversations||mi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==vn?void 0:vn.__PosthogExtensions__;if(t&&!f(this.Hg)&&this.Hg)if(this.ie&&this.ie.token){this.Ug=!0;try{var e=t.initConversations;if(e)return this.Zg(e),void(this.Ug=!1);var i=t.loadExternalDependency;if(!i)return void this.Kg(zr);var r=this.Vg;i(this._instance,"conversations",e=>{if(r!==this.Vg)return this.Ug=!1,void this.loadIfEnabled();e||!t.initConversations?this.Kg("Could not load conversations script",e):this.Zg(t.initConversations),this.Ug=!1})}catch(t){this.Kg("Error initializing conversations",t),this.Ug=!1}}else Gs.error("Conversations enabled but missing token in remote config.")}}Zg(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.Wg=!1,Gs.info("Conversations loaded successfully")}catch(t){return void this.Kg("Error completing conversations initialization",t)}this.Qg&&this._conversationsManager.setTheme(this.Qg),this.Yg()}else Gs.error("Cannot complete initialization: remote config is null")}Yg(){var t=this.Gg;this.Gg=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}Kg(t,e){Gs.error(t,e),this._conversationsManager=null,this.Ug=!1,this.Wg=!0}show(){this._conversationsManager?this._conversationsManager.show():Gs.warn("Conversations not loaded yet.")}hide(){"open"===this.Gg&&(this.Gg=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.Gg=null,this._conversationsManager.open()):this.Gg="open"}close(){this._conversationsManager?(this.Gg=null,this._conversationsManager.close()):this.Gg="close"}setTheme(t){var i,r;this.Qg=e({},this.Qg,t,{dark:e({},null==(i=this.Qg)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.Hg&&!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.Jg?"remote_config_failed":f(this.Hg)?this.Jg?"disabled_in_project":"remote_config_pending":this.Hg?y(this.ie)||!this.ie.token?"missing_token":null!=vn&&vn.__PosthogExtensions__?this.Ug?"initializing":this.Wg?"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):(Gs.warn(Ks),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Gs.warn(Ks),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Gs.warn(Ks),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Gs.warn(Ks),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Gs.warn(Ks),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Gs.warn(Ks),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Gs.warn(Ks),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()}}},Da={logs:class extends ia{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=vn._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!=vn&&null!=(e=vn.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(vn.location.href):vn.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.Tf()}get $f(){return this._instance.__loaded}Cf(){var t=ci("[logs]"),e=null==vn?void 0:vn.__PosthogExtensions__;if(e){var i=e.loadExternalDependency;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(zr)}else t.error("PostHog Extensions not found.")}}},La={metrics:class{constructor(t){this._instance=t,this.R=ci("[metrics]"),this.Mi=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.Mi){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.Xg?this.Xg=(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=ua(t,i),n=ha(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.Xg&&(this.Xg(),this.Xg=void 0)}}Ef(){var t;if(!this.Mi){var e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Sf&&this.Af===i||(null==(e=this.Sf)||e.reset(),this.Af=i,this.Sf=new ri(this.Mf(),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}}(i),this.R)),this.Sf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.Ef())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.Ef())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.Ef())||r.histogram(t,e,i)}flush(t){if(!this.Sf)return Promise.resolve();if(t){var e=this.Sf.drainWindow();return e&&this.Po(e,t),Promise.resolve()}return this.Sf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Sf)||t.reset()}dispose(){var t,e;this.Mi=!0,null==(t=this.Xg)||t.call(this),this.Xg=void 0,null==(e=this.Sf)||e.reset()}Mf(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Po:t=>e.Po(t),getLibraryId:()=>ms.LIB_NAME,getLibraryVersion:()=>ms.LIB_VERSION}}Po(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.tm(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{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)})}}))})}tm(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Na={webMCP:class{constructor(t){this._instance=t,this.im=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.im){var t=null==un?void 0:un.modelContext;if(t&&c(t.registerTool)){var e=ca.get(t);if(e)return e.instances.add(this._instance),void(this.im=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;En(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.nm(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(ca.set(t,i),this.im=!0)}}}nm(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=>va.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:ma(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>ga(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:ma(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:ma(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=pa(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?ya(t.context,2048,!0):void 0,n=i.model?ya(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&&ga(r,"context"),s=i.model&&ga(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.sm(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=ba(t)?{error:t,errorResult:!0}:void 0;return n.sm(i,a,s,e,f),t},t=>{throw n.sm(i,a,s,{error:t,errorResult:!1},f),t});var g=ba(c)?{error:c,errorResult:!0}:void 0;return n.sm(i,a,s,g,f),c}}),a}sm(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=pa(l.config.capture_webmcp);if(h){n&&!a&&(a=ka(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==hn?void 0:hn.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==hn?void 0:hn.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}}},za=/* @__PURE__ */Ea(Aa,Ta,Fa,Pa,Ra,Ca,Ma,Oa,$a,Ia,ja,Da,La,Na),Ba=Aa,Ua=Ta,Ha=Fa,qa=Pa,Va=Ra,Wa=Ca,Ga=Ma,Ka=Oa,Ja=$a,Xa=Ia,Ya=ja,Za=Da,Qa=La,to=Na;export{za as AllExtensions,Ha as AnalyticsExtensions,Ya as ConversationsExtensions,qa as ErrorTrackingExtensions,Xa as ExperimentsExtensions,Ba as FeatureFlagsExtensions,Za as LogsExtensions,Qa as MetricsExtensions,Va as ProductToursExtensions,Ua as SessionReplayExtensions,Wa as SiteAppsExtensions,Ga as SurveysExtensions,Ja as ToolbarExtensions,Ka as TracingExtensions,to as WebMCPExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map