posthog-js 1.447.1 → 1.447.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.es5.js +1 -1
  4. package/dist/array.full.js +1 -1
  5. package/dist/array.full.js.map +1 -1
  6. package/dist/array.full.no-external.js +1 -1
  7. package/dist/array.full.no-external.js.map +1 -1
  8. package/dist/array.js +1 -1
  9. package/dist/array.no-external.js +1 -1
  10. package/dist/customizations.full.js +1 -1
  11. package/dist/customizations.js +1 -1
  12. package/dist/default-extensions.js +1 -1
  13. package/dist/extension-bundles.js +1 -1
  14. package/dist/integrity.json +29 -29
  15. package/dist/lazy-recorder.js +1 -1
  16. package/dist/lazy-recorder.js.map +1 -1
  17. package/dist/main.js +1 -1
  18. package/dist/module.full.cjs +1 -1
  19. package/dist/module.full.js +1 -1
  20. package/dist/module.full.js.map +1 -1
  21. package/dist/module.full.no-external.cjs +1 -1
  22. package/dist/module.full.no-external.js +1 -1
  23. package/dist/module.full.no-external.js.map +1 -1
  24. package/dist/module.js +1 -1
  25. package/dist/module.mjs +1 -1
  26. package/dist/module.no-external.cjs +1 -1
  27. package/dist/module.no-external.js +1 -1
  28. package/dist/module.slim.js +1 -1
  29. package/dist/module.slim.no-external.js +1 -1
  30. package/dist/posthog-recorder.d.ts +1 -0
  31. package/dist/posthog-recorder.js +1 -1
  32. package/dist/posthog-recorder.js.map +1 -1
  33. package/dist/recorder-v2.js +1 -1
  34. package/dist/recorder-v2.js.map +1 -1
  35. package/dist/recorder.d.ts +1 -0
  36. package/dist/recorder.js +1 -1
  37. package/dist/recorder.js.map +1 -1
  38. package/dist/rrweb.d.ts +1 -0
  39. package/dist/rrweb.js +1 -1
  40. package/dist/rrweb.js.map +1 -1
  41. package/dist/src/extensions/replay/types/rrweb.d.ts +1 -0
  42. package/dist/surveys-preview.js +1 -1
  43. package/dist/surveys.js +1 -1
  44. package/lib/package.json +1 -1
  45. package/lib/src/extensions/replay/types/rrweb.d.ts +1 -0
  46. package/package.json +7 -7
@@ -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.yr(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.br(t))&&void 0!==r?r:n.stack,synthetic:!0})}yr(t){return p(t.message)&&t.message.length>0}br(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.Fr=Lt(t)}setConfig(t){this.Fr=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.Fr.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.Fr.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=/\b\d(?:[ ./-]?\d){12,}\b/g,ve=/\d+/g,de=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,fe=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function pe(t){return function(t){return Yt.test(t)}(t)||ne.test(t)||se.test(t)}function ge(t){return t.split("&",129).length>128}function me(t,e,i){return pe(t)||e.includes(";")&&function(t){return t.split(";").some(t=>pe(t.split("=",1)[0]))}(e)?qt:te.test(e)?i?Se(e,{allowNestedUrls:!1,stripPunctuation:!0}):qt:e}function ye(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=ke(a),u=ke(o);r||(r=l!==a||u!==o);var h=me(l,u,e);r||(r=h!==u),n=pe(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function be(t,e){if(!t.includes("="))return{value:_e(t,e),lastFieldSensitive:!1};var i=ye(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function _e(t,e){return e?Se(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function we(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 xe(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(ge(o)||ge(u.head)||ge(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=ye(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=be(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":qt,lastFieldSensitive:!0}:be(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?ke(r.toString()):s)+(g.lastFieldSensitive?"":a)}function Se(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];we(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return xe(t,i);var n="",s=0;for(var a of r)n+=xe(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+xe(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function ke(t){return t.replace(Xt,qt)}function Ee(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 Se(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(ae," ");return(e=(e=(e=(e=(e=(e=e.replace(oe,qt)).replace(le,qt)).replace(ue,"$1"+qt)).replace(ce,Te)).replace(he,qt)).replace(de,"$1"+qt)).replace(fe,"$1"+qt)}(ke(t))),e)}function Ae(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 Te(t){for(var e=[],i=ve.exec(t);null!==i;i=ve.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&&Ae(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 Fe={}.propertyIsEnumerable;function Pe(t,e){try{return Oe(t,e,{ancestors:/* @__PURE__ */new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Re(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 Re(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:Ce(t,e,i,r+1)}}:{kvlistValue:{values:Oe(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:B(String(t))}}function Ce(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(Re(o,e,i,r))}catch(t){n.push({stringValue:z})}return t.length>a&&n.push({stringValue:N}),n}function Oe(t,e,i,r){var n=[];for(var s in t)if(Fe.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:Re(a,e,i,r)})}catch(t){n.push({key:B(s),value:{stringValue:z}})}}return n}function Me(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 $e=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Ie(t,e){var i=U({},t),r={};for(var n of $e)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Pe(i,e),...Pe(r,e)]}var je={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 De={text:"INFO",number:9},Le={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:De,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function Ne(t){try{return B(String(t))}catch(t){return z}}function ze(t,i,r,n){var s,a=Le[t.level||"info"]||De,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:Ne(t.body)},attributes:Pe(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 Be(t,e,i){return Me(t,e,i)}function Ue(t,e,i,r){return{resourceLogs:[{resource:{attributes:Ie(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var He=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 qe(){return.75+.5*Math.random()}function Ve(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 We=class{constructor(t,e,i,r,n,s,a){var o;void 0===s&&(s=()=>Promise.resolve()),this._instance=t,this.Fr=e,this.R=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=new He(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new K,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=e.maxBufferSize,this.Is=Math.max(null!==(o=e.maxQueueSize)&&void 0!==o?o:e.maxBufferSize,e.maxBufferSize),this.Ms=e.flushIntervalMs,this.Es=e.maxBatchRecordsPerPost,this.As=e.rateCapWindowMs,this.Rs=e.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(n.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Fr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.Ps()&&this.Os():this.gs()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Fs(t);if(null!==r)if(r.body){if(this.Ds()){var n={record:ze(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.Ls(n))}}else this.R.info("Log was rejected in beforeSend function")}}Fs(t){var e=this.Fr.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}Ds(){if(void 0===this.Rs)return!0;var t=Date.now(),e=t-this.xs;return this.As>e&&e>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.R.warn("captureLog dropping logs: exceeded "+this.Rs+" logs per "+this.As+"ms"),this.Cs=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return r(function*(){var e;t.ps.clear();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,l=t._s;t.bs=0;var u=Math.min(i.length,t.Es),h=i.slice(0,u),c=Ue(h.map(t=>t.record),t.js(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.qs(c);if(t._s!==l)return;if("too-large"===v.kind&&h.length>1)t.Es=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.Es);else{if(t.ws.record(v),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.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.Fr.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Fr.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}})()}Bs(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e.bs),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}js(){return Be(this.Fr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Is>i.length||(i.shift(),this.bs++,this.R.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Ts>i.length||this.ws.isOpen()?this.Os():this.gs()}}Os(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(Ve(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}Ps(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.ps.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(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=qe(),this.R.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ps()&&this.ps.armNoEarlierThan(this.zs())})}},Ge=/^[0-9a-f]+$/;function Ke(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Ge.test(t)}var Je=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Xe="00",Ye=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ze(t){return String(t)+"000000"}function Qe(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 ti=class{constructor(t,e,i){this._instance=t,this.Fr=e,this.R=i,this.Hs=/* @__PURE__ */new Map,this.ps=new He(()=>this.flush().catch(t=>{this.R.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=/* @__PURE__ */new Map,this.Vs=/* @__PURE__ */new Set,this.Gs=/* @__PURE__ */new Map,this.Qs=/* @__PURE__ */new Set,this.Js=!1,this.ws=new K,this.ks=0,this.Ss=1,this.Zs=0}count(t,e,i){void 0===e&&(e=1),this.Ks({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.Ks({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.Ks({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.ys,i=/* @__PURE__ */function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.Ys()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.ys===i&&(this.ys=null)});return this.ys=i,i}drainWindow(){if(0===this.Hs.size)return null;var t=this.Hs;return this.Xs(),this._o(t)}reset(){this.Zs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.ys=null,this.Xs(),this.Gs=/* @__PURE__ */new Map,this.Js=!1}Xs(){this.Hs=/* @__PURE__ */new Map,this.Us=!1,this.Ws=/* @__PURE__ */new Map,this.Vs=/* @__PURE__ */new Set,this.Qs=/* @__PURE__ */new Set}Ks(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Fs(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=Qe(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.Hs.get(n);if((a||this.ko())&&("histogram"!==i.type||(s=this.So(i.name,i.unit,i.bounds)))){a||(a={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now(),hist:s&&ii(s)},this.Hs.set(n,a));var o=this.Ws.get(i.name);void 0===o?this.Ws.set(i.name,i.type):o===i.type||this.Vs.has(i.name)||(this.Vs.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.xo(a,i.value);var l=this.$o();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Os()}}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")}}$o(){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=Je.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 Ke(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Ke(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":Xe)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}ko(){return this.Fr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.R.warn("Metric series cap reached ("+this.Fr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}So(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=Qe("histogram",t,e,void 0),n=this.Gs.get(r);if(n)return this.Co(t,r,n,i),n;if(this.Gs.size>=this.Fr.maxSeriesPerFlush){if(this.Js||(this.Js=!0,this.R.warn("Histogram bounds limit reached ("+this.Fr.maxSeriesPerFlush+" distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.")),i&&!ei(i,Ye))return;return Ye}var s=i?i.slice():Ye;return this.Gs.set(r,s),s}this.R.warn("Dropping histogram '"+t+"': bounds must be a non-empty array of finite, strictly increasing numbers")}Co(t,e,i,r){ei(i,null!=r?r:Ye)||this.Qs.has(e)||(this.Qs.add(e),this.R.warn("Histogram '"+t+"' already uses the bounds ["+i.join(", ")+"]; samples that pass different bounds are recorded in those buckets."))}xo(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}}Fs(t){var e=this.Fr.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}Os(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Ve(this.Fr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Ys(){var t=this;return r(function*(){if(t.ps.clear(),0!==t.Hs.size){var e=t.Hs;t.Xs();var i=t.Zs,r=yield t._instance.To(t._o(e));if(i===t.Zs)switch(t.ws.record(r),"retry-later"===r.kind?(t.ks++,t.Ss=qe()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),r.kind){case"ok":return;case"retry-later":return t.Io(e),void t.ps.armNoEarlierThan(t.zs());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)}}})()}_o(t){return e=this.Mo(t),i=function(t,e,i){return Me(t,e,i)}(this.Fr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ie(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}Mo(t){var i=Ze(Date.now()),r=/* @__PURE__ */new Map;for(var n of t.values()){var s,a=Qe(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=Pe(null!==(s=n.attributes)&&void 0!==s?s:{},this.R),u=Ze(n.windowStartMs),h=ri(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())}Io(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Hs.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.ko()&&this.Hs.set(s,a)}}};function ei(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 ii(t){return{bounds:t,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(t.length+1).fill(0)}}function ri(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:Ze(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var ni="0.10.7",si={DEBUG:!1,LIB_VERSION:ni,LIB_NAME:"browser-common",JS_SDK_VERSION:ni},ai=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&&(si.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)=>ai(t+" "+e,i)};return r},oi=/* @__PURE__ */ai("[PostHog.js]"),li=(t,e)=>oi.createLogger(t,e);function ui(t,e){h(t)&&t.forEach(e)}function hi(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 ci=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 vi(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 di(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 fi(t){return"ph_toolbar_internal"===t.name}function pi(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 oi.error("Error in get_current_url, falling back to window.location.href",t),e}}var gi="$early_access_features",mi="$active_feature_flags",yi="$feature_flag_details",bi="$feature_flag_errors",_i="$feature_flag_evaluated_at",wi="$feature_flag_request_id",xi="$minimal_flag_called_events",Si="$enabled_feature_flags",ki="$stored_group_properties",Ei="$stored_person_properties",Ai="$flag_call_reported",Ti="$flag_call_reported_session_id",Fi="$feature_flag_payloads",Pi="$override_feature_flags",Ri="$override_feature_flag_payloads",Ci="visibilitychange",Oi="$autocapture_disabled_server_side";function Mi(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function $i(t){return!!t&&1===t.nodeType}function Ii(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ji(t){return!!t&&3===t.nodeType}function Di(t){return!!t&&11===t.nodeType&&$i(t.host)}function Li(t){return t?a(t).split(/\s+/):[]}function Ni(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:pi(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function zi(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 Li(e)}function Bi(t){return y(t)?null:a(t).split(/(\s+)/).filter(t=>mr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ui(t){var e="";return lr(t)&&!ur(t)&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;ji(t)&&t.textContent&&(e+=null!==(i=Bi(t.textContent))&&void 0!==i?i:"")}),a(e)}function Hi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var qi=["a","button","form","input","select","textarea","label"];function Vi(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 Wi(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Vi(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Gi(t){var e=t.parentNode;return!(!e||!$i(e))&&e}var Ki=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ji=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Xi=/* @__PURE__ */(()=>[...Ji,"+","-","−","–"])(),Yi=/* @__PURE__ */(()=>Xi.length+10)(),Zi=["button","a","input","select","textarea","label"],Qi=["button","link","tab","menuitem","option"],tr=(t,e)=>/[a-z0-9]/i.test(e)?s(Xi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,er=t=>s(Zi,t.tagName.toLowerCase())||s(Qi,(t.getAttribute("role")||"").toLowerCase());function ir(t){var e="",i="",r=t=>{$i(t)&&lr(t)&&!ur(t)&&(e+=" "+Ui(t),i=i||t.getAttribute("aria-label")||"",hi(t.childNodes,r))};r(t);var n=(mr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var rr=[".ph-no-rageclick",".ph-no-capture"],nr=["","text","search","email","password","url","tel","number"];function sr(t,e){if(!(typeof window>"u"?void 0:window)||ar(t))return!1;var i,r,n,a,o;if(_(e)?(i=!!e&&rr,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:rr,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||!$i(t))&&(!!Ii(t,"textarea")||(Ii(t,"input")?s(nr,(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=or(t,!1).targetElementList;return!(r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Ji;else{if(!h(t))return!1;if(t.length>Yi)return oi.error("[PostHog] content_ignorelist array cannot exceed "+Yi+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>tr(r,t)||tr(n,t))}(r,function(t,e){for(var i of e)if(er(i))return ir(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=ir(r);if(s.safeText||s.ariaLabel)return s}return ir(t)}(t,l))||Wi(l,i))}var ar=t=>!t||Ii(t,"html")||!$i(t),or=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ar(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,n=[t],s=t;s.parentNode&&!Ii(s,"body");)if(Di(s.parentNode))n.push(s.parentNode.host),s=s.parentNode.host;else{var a=Gi(s);if(!a)break;if(e||qi.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 lr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r.parentNode&&!Ii(r,"body");r=r.parentNode){if(i++>=1e3||e.has(r))return!1;e.add(r);var n=zi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!1}if(s(zi(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 ur(t){return!!(Ii(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ii(t,"select")||Ii(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var hr=/* @__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}))$"),cr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,vr=[16,15,14,13],dr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),fr=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),pr=/[0-9A-Za-z_]/;function gr(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 mr(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?hr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(cr.lastIndex=0;e=cr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of vr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(hr.test(o)&&gr(o))return!0}}}return!1}(t))return!1;if(e?dr.test(t):function(t){var e;for(fr.lastIndex=0;e=fr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&pr.test(i)&&pr.test(r)))return!0}return!1}(t))return!1}return!0}function yr(t){var e=Ui(t);return mr(e=(e+" "+br(t)).trim())?e:""}function br(t){var e="";return t&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Ui(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+br(t)).trim())}catch(t){oi.error("[AutoCapture]",t)}}),e}function _r(t){return t.replace(/"|\\"/g,'\\"')}function wr(t){var e=t.attr__class;if(e)return h(e)?e:Li(e)}var xr=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}},Sr=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)},kr=()=>typeof window>"u"?void 0:window,Er=()=>typeof document>"u"?void 0:document,Ar="$copy_autocapture",Tr=["password","hidden","file","checkbox","button","submit","reset","image"],Fr=/* @__PURE__ */li("[AutoCapture]");function Pr(t,e){return e.length>t?e.slice(0,t)+"...":e}function Rr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!$i(e));return e}function Cr(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!$i(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;g.parentNode&&!Ii(g,"body")&&1e3>d.length;)if(Di(g.parentNode)){var m=g.parentNode.host;if(f.has(m))break;f.add(m),d.push(m),g=m}else{if(!$i(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=>Ii(t,"button")||Ii(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!lr(t)||ur(t)));var b,_,w,x=[],S={},k=!1,E=!1;if(hi(d,t=>{var e=lr(t);if(Ii(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");k=!!(e&&i&&mr(i))&&(v?J(i):i)}s(zi(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};qi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Pr(1024,yr(t)):Pr(1024,Ui(t)));var o=zi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),hi(t.attributes,function(i){var s;if((!ur(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&mr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Li(o).join(" ")),a["attr__"+i.name]=Pr(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=Rr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),hi(function(t){if(!lr(t))return{};var e={};return hi(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&&mr(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=Ii(t,"a")||Ii(t,"button")?yr(t):Ui(t)),k){var A,T;x[0].attr__href=k;var F=null==(A=Sr(k))?void 0:A.host,P=null==(T=kr())||null==(T=T.location)?void 0:T.host;F&&P&&F!==P&&(b=k)}return{props:ci((_=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 vi(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[_r(t[0].toString())]=_r(e.toString())}),(n+=":")+vi(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:wr(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return vi(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 Or=class{vl(){this.fl=void 0,clearTimeout(this.pl),this.pl=void 0}gl(t){var e;if(!lr(t))return!0;for(var i,r=null!==(e=this.ml().css_selector_ignorelist)&&void 0!==e?e:Ki,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=zi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||ur(t)||r.some(e=>Vi(t,e)))return{v:!0};var i=a.parentNode;a=Di(i)?i.host:i&&$i(i)?i:null};a;)if(i=o())return i.v;return!1}yl(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.fl;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.vl():"pointerup"===t.type&&(e.released=!0,this.pl=setTimeout(()=>this.vl(),0)))}else{var i;this.vl();var r=Hi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&$i(r)&&(this.fl={target:r,excluded:this.gl(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.Fa)?void 0:i.distinctId})}else this.vl()}bl(t){var e,i=this.fl;this.vl();var r=Hi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.Fa)?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&&(Ii(r,"html")||Ii(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.ml().css_selector_ignorelist)&&void 0!==n?n:Ki;return[r,null==(a=Er())?void 0:a.documentElement,null==(o=Er())?void 0:o.body].some(t=>{if(!t)return!1;var e=zi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!lr(t)||ur(t)||l.some(e=>Vi(t,e))})?null:i.target}}constructor(t){this.Na=t,this.name="autocapture",this._l=!1,this.wl=null,this.kl=!1,this.Sl=/* @__PURE__ */new Map,this.xl=!1,this.Fr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ti=!1,this.Na.refresh(this.Fr),this.rageclicks=new xr(this.Fr.rageclick),this.$l=null}setup(t){this.Cl(),this.Fa=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ti?e.dispose():(this.Za=e,this.startIfEnabled())}dispose(){var t;this.Ti||(this.Ti=!0,this.Fa=void 0,null==(t=this.Za)||t.dispose(),this.Za=void 0,this.Sl.clear(),this.$l=null,this.Tl())}ml(){return this.Na.refresh(this.Fr),this.Fr}Cl(){var t,e;return this.ml(),this.Fr.url_allowlist=null==(t=this.Fr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Fr.url_ignorelist=null==(e=this.Fr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Fr}Il(){var t=kr(),e=Er();if(this.isBrowserSupported()){if(t&&e){this.Ml=t,this.El=e;var i=this.Al=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.vl();if(0===e.type.indexOf("pointer"))return void this.yl(e);var i="click"===e.type?this.bl(e):void 0;if(m(i))return;this.Rl(e,"$autocapture",i)}catch(t){Fr.error("Failed to capture event",t)}};if(di(t,"blur",i),di(e,"submit",i,{capture:!0}),di(e,"change",i,{capture:!0}),di(e,"click",i,{capture:!0}),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{di(e,t,i,{capture:!0})}),this.ml().capture_copied_text){var r=this.Pl=e=>{e=e||(null==t?void 0:t.event);try{this.Rl(e,Ar)}catch(t){Fr.error("Failed to capture clipboard event",t)}};di(e,"copy",r,{capture:!0}),di(e,"cut",r,{capture:!0}),di(e,"paste",r,{capture:!0})}}}else Fr.info("Disabling Automatic Event Collection because this browser is not supported")}Tl(){var t=this.Ml,e=this.El;this.vl(),this.Al&&(null==t||t.removeEventListener("blur",this.Al),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.Al,!0)}),null==e||e.removeEventListener("submit",this.Al,!0),null==e||e.removeEventListener("change",this.Al,!0),null==e||e.removeEventListener("click",this.Al,!0),this.Al=void 0),this.Pl&&(null==e||e.removeEventListener("copy",this.Pl,!0),null==e||e.removeEventListener("cut",this.Pl,!0),null==e||e.removeEventListener("paste",this.Pl,!0),this.Pl=void 0),this.Ml=void 0,this.El=void 0,this._l=!1}startIfEnabled(){this.isEnabled||this.vl(),!this.Ti&&this.Fa&&this.isEnabled&&!this._l&&(this.Il(),this._l=!0)}onRemoteConfig(t){if(!this.Ti)if(this.kl=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.xl=e.elementsChainAsString);var i,r=e.autocapture_opt_out;_(r)&&(null==(i=this.Fa)||i.kv.set(Oi,r),this.wl=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Ti){t.size?this.Sl.set(e,new Set(t)):this.Sl.delete(e);var i=/* @__PURE__ */new Set;this.Sl.forEach(t=>{t.forEach(t=>i.add(t))}),this.$l=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.$l)||i.forEach(i=>{var n;null==(n=Er())||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.Ti)return!1;var i=null==(t=this.Fa)?void 0:t.kv.get(Oi),r=this.wl,n=this.ml();if(!n.remoteRequestsDisabled&&!this.kl)return!1;var s=n.remoteRequestsDisabled&&!this.kl;if(m(r)&&!_(i)&&!s)return!1;var a=null!==(e=this.wl)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Rl(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Hi(t);ji(n)&&(n=n.parentNode||null);var a,o=this.Cl();"$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())&&sr(n,o.rageclick)&&this.Rl(t,"$rageclick",r);var l,u=i===Ar,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||ar(t))return!1;if(null!=i&&i.url_allowlist&&!Ni(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ni(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=or(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(!Wi(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Wi(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Ki))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&&(qi.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=Cr(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.xl,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===Ar){var y=t.type||"clipboard";if("paste"!==y){var b,_,w=null==(b=kr())||null==(b=b.getSelection())?void 0:b.toString(),x=Bi(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&&(Ii(l=n,"input")?!s(Tr,l.type):Ii(l,"textarea")||Ii(l,"select")&&!l.multiple)&&function(t,e){var i;if(!lr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Ki,n=/* @__PURE__ */new Set,a=t;Ii(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=zi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Vi(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=Di(i)?i.host:i&&$i(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=>Vi(n,t))}catch(t){Fr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.Fa)||d.capture(i,g),!0}}else this.vl()}isBrowserSupported(){var t;return c(null==(t=Er())?void 0:t.querySelectorAll)}},Mr=["[data-ph-capture-value]"],$r=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:Mr}},Ir="$surveys",jr="$surveys_loaded_at",Dr="PostHog loadExternalDependency extension not found.",Lr="$surveys_activated",Nr="$surveys_activated_session",zr="$surveys_activated_timestamps",Br="$heatmaps_enabled_server_side",Ur="$exception_capture_enabled_server_side",Hr="$error_tracking_suppression_rules",qr="$error_tracking_capture_extension_exceptions",Vr="$web_vitals_enabled_server_side",Wr="$dead_clicks_enabled_server_side",Gr="$product_tours_enabled_server_side",Kr="$web_vitals_allowed_metrics",Jr="$session_recording_remote_config",Xr="$replay_override_sampling",Yr="$replay_override_linked_flag",Zr="ph_product_tours",Qr="$sdk_debug_recording_script_not_loaded",tn="$sdk_debug_replay_stale_config",en="beforeunload",rn="u">typeof window?window:void 0,nn="u">typeof globalThis?globalThis:rn,sn=null==nn?void 0:nn.navigator,an=null==nn?void 0:nn.document,on=null==nn?void 0:nn.location;null!=nn&&nn.XMLHttpRequest&&new nn.XMLHttpRequest;var ln="undefined"!=typeof globalThis?globalThis:rn;ln&&"undefined"==typeof self&&(ln.self=ln),ln&&"undefined"==typeof File&&(ln.File=function(){});var un=null!=rn?rn:{},hn=/* @__PURE__ */li("[Dead Clicks]"),cn=()=>!0,vn=class{get lazyLoadedDeadClicksAutocapture(){return this.ql}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({[Wr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Bl(()=>{this.zl()}):this.stop()}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",e=>{e?hn.error("failed to load script",e):t()})}zl(){var t;if(an){if(!this.ql&&null!=(t=un.__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.ql=un.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.ql.start(an),hn.info("starting...")}}else hn.error("`document` not found. Cannot start.")}stop(){this.ql&&(this.ql.stop(),this.ql=void 0,hn.info("stopping..."))}},dn=/* @__PURE__ */li("[ExceptionAutocapture]"),fn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},pn=(t,e)=>t>=e&&fn(),gn=(t,e,i,r)=>{if(0===t){if(fn()){var n=e+1;return n===i&&r(),n}return e}return 0},mn=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){oi.error("Skipping decoding for malformed query param: "+a)}return a},yn=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},bn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},_n=()=>{},wn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function xn(t,e,i){try{if(!(e in t))return _n;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=wn(i);s;){if(s.next===n)return void(s.next=r.next);s=wn(i=s.next)}else t[e]=r.next}}catch(t){return _n}}var Sn=/* @__PURE__ */li("[TracingHeaders]");function kn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var En=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],An=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...En])(),Tn="<masked>",Fn=["li_fat_id"];var Pn=/* @__PURE__ */li("[Web Vitals]"),Rn=9e5,Cn=["CLS","FCP","INP","LCP"],On=["INP","LCP"],Mn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],$n=/* @__PURE__ */li("[RemoteConfig]"),In=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}rc(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}oc(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 $n.info("Using preloaded remote config",this.remoteConfig),void this.ac(this.remoteConfig);if(this._instance._shouldDisableFlags())return void $n.warn("Remote config is disabled. Falling back to local config.");this.rc(t=>{if(!t)return $n.info("No config found after loading remote JS config. Falling back to JSON."),void this.oc(t=>{this.ac(t.json,t)});this.ac(t)})}catch(t){$n.error("Error loading remote config",t),this.ac()}}ac(t,e){!t&&e&&(0===e.statusCode?e.error||$n.warn("Failed to fetch remote config from PostHog."):$n.error("Failed to fetch remote config from PostHog."));try{this._instance.ac(t?{ok:!0,config:t}:{ok:!1})}catch(t){$n.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){$n.error("Error loading feature flags",t)}}},jn="disabled",Dn="lazy_loading",Ln=/* @__PURE__ */li("[SessionRecording]"),Nn=[Qr,tn,"$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"],zn=/* @__PURE__ */li("[Heatmaps]");function Bn(t){return v(t)&&"clientX"in t&&"clientY"in t&&b(t.clientX)&&b(t.clientY)}var Un=/* @__PURE__ */li("[Product Tours]"),Hn=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Gr))},qn=/* @__PURE__ */li("[SiteApps]"),Vn="Error while initializing PostHog app with config id ",Wn="events",Gn="cancelEvents",Kn="survey shown",Jn="survey dismissed",Xn="survey sent";function Yn(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var Zn=(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}},Qn=t=>t.toLowerCase(),ts={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=>Zn(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!Zn(e,t))),icontains:(t,e)=>e.map(Qn).some(e=>t.map(Qn).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(Qn).every(e=>t.map(Qn).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 es(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=ts[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var is=/* @__PURE__ */li("[Surveys]"),rs=["popover","widget","api"],ns=class{on(t,e){return this.Eo[t]||(this.Eo[t]=[]),this.Eo[t].push(e),()=>{this.Eo[t]=this.Eo[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.Eo[t]||[])i(e);for(var r of this.Eo["*"]||[])r(t,e)}constructor(){this.Eo={}}};function ss(t,e,i){if(y(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}var as=class{constructor(t){this.$i=t,this.Ao=/* @__PURE__ */new Set,this.Ro=/* @__PURE__ */new Set,this.Po=new ns,this.Oo=(t,e)=>this.Fo(t,e)&&this.Do(t,e)&&this.Lo(t,e)&&this.No(t,e),this.Fo=(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.$i)?void 0:t.subscribeCapture)||(this.jo=null==(e=this.$i)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.jo)||t.call(this),this.jo=void 0,null==(e=this.$i)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.Po=new ns}register(t){var e,i;if(!f(null==(e=this.$i)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.Ao.add(t),null==(e=t.steps)||e.forEach(t=>{this.Ro.add((null==t?void 0:t.event)||"")})}),null!=(i=this.$i)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.Ao.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.$i.setElementSelectors(r,this)}}replace(t){this.Ao.clear(),this.Ro.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.Ro.has(t)||this.Ro.has(e.event))&&this.Ao.forEach(t=>{this.qo(e,t)&&this.Po.emit("actionCaptured",t.name)})}Bo(t){this.onAction("actionCaptured",e=>t(e))}qo(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Oo(t,i))return!0;return!1}onAction(t,e){return this.Po.on(t,e)}Do(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.$i)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!ss(r,e.url,e.url_matching||"contains"))return!1}return!0}Lo(t,e){return!!this.zo(t,e)&&!!this.Ho(t,e)&&!!this.Uo(t,e)}zo(t,e){var i;if(null==e||!e.href)return!0;var r=this.Wo(t);if(r.length>0)return r.some(t=>ss(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&ss((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Ho(t,e){var i;if(null==e||!e.text)return!0;var r=this.Wo(t);if(r.length>0)return r.some(t=>ss(t.text,e.text,e.text_matching||"exact")||ss(t.$el_text,e.text,e.text_matching||"exact"));var n,s,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(n=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!y(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),s=e.text,a=e.text_matching||"exact",n.some(t=>ss(t,s,a)))}Uo(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}Wo(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}No(t,e){return null==e||!e.properties||0===e.properties.length||es(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)}},os=class{constructor(t,e){this.Vo=e,this.Go=[],this.$i=t,this.Qo=/* @__PURE__ */new Map,this.Jo=/* @__PURE__ */new Map,this.Zo=/* @__PURE__ */new Map}Ko(){var t,e;this.Yo=null==(t=(e=this.$i).subscribeSession)?void 0:t.call(e,t=>this.Xo(t))}ta(t){return!1}ea(){return null}ia(t){}na(){}sa(t,e){return!!t&&es(t.propertyFilters,null==e?void 0:e.properties)}ra(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}oa(t,e,i){var r=(i===Wn?this.Qo:this.Jo).get(t),n=[];return this.aa(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.sa(s,e)})}register(t){this.la(t,!1)}replace(t){this.la(t,!0)}la(t,e){f(this.$i.subscribeCapture)||(this.ua(t,e),this.ca(t,e))}ca(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.Zo.clear(),0!==i.length){this.ha||(this.ha=new as(this.$i),this.ha.init(),this.ha.Bo(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.Zo.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.Zo.set(e.name,n)}})}),e?this.ha.replace(r):this.ha.register(r)}else{var n;e&&(null==(n=this.ha)||n.replace([]))}}da(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)})}ua(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.ra(t,Wn),l=this.ra(t,Gn);e?(this.Qo=o,this.Jo=l):(this.da(this.Qo,o),this.da(this.Jo,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.jo)&&void 0!==i||(this.jo=null==(r=(n=this.$i).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.va(),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.fa(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.pa([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.ga(s),void this.ma([s])}if(this.Jo.has(t)){var o=this.oa(t,e,Gn);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.pa(o.map(t=>t.id)),o.forEach(t=>this.ya(t.id)))}if(this.Qo.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.Qo.get(t)});var l=this.oa(t,e,Wn);this.ba(l.map(t=>t.id))}}onAction(t){this.Zo.has(t)&&this.ba(this.Zo.get(t)||[])}ba(t){if(0!==t.length){var e=!!this.$i.getSessionId(),i=[];for(var r of t)e&&this.ta(r)?this.ga(r)&&this._a(r):i.push(r);i.length>0&&(this.Go=[.../* @__PURE__ */new Set([...this.Go,...i])]),this.va().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.wa()}}ga(t){this.Go=this.Go.filter(e=>e!==t);var e=this.ka();return!e.includes(t)&&(this.Sa([...e,t]),this.xa(),!0)}pa(t){var e=new Set(t);this.Go=this.Go.filter(t=>!e.has(t));var i=this.$a(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.Sa(r),0===r.length&&this.Ca()),this.ma(t),this.wa()}wa(){try{var t;null==(t=this.Vo)||t.call(this)}catch(t){this.va().error("Error while handling activated items change",t)}}Ta(){var t=this.ea();if(!t)return{};var e=this.$i.getProperty(t);return e&&"object"==typeof e?e:{}}_a(t){if(this.ea()){var i=this.Ta();this.ia(e({},i,{[t]:Date.now()}))}}ma(t){if(this.ea()){var e=this.Ta(),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.na():this.ia(i))}}Ia(){this.ea()&&this.na()}getActivationTimestamp(t){if(this.ka().includes(t)){var e=this.Ta()[t];return b(e)?e:void 0}}$a(){var t=this.Ma();return this.$i.getProperty(t)||[]}ka(){var t=this.$a();if(0===t.length)return[];var e=this.$i.getProperty(this.Ea()),i=this.$i.getSessionId();return i&&e===i?t:[]}xa(){var t=this.$i.getSessionId();t&&this.Aa(t)}Ca(){this.Ra()}Xo(t){var e=this.$i.getProperty(this.Ea());if(e&&e!==t){var i=this.$a(),r=this.Ta();i.length>0&&(this.Sa([]),i.filter(t=>b(r[t])).forEach(t=>this.ya(t))),this.Ca(),this.Ia(),i.length>0&&this.wa()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.ka(),...this.Go])].filter(t=>!this.Pa(t))}dispose(){var t,e,i;null==(t=this.Yo)||t.call(this),this.Yo=void 0,null==(e=this.jo)||e.call(this),this.jo=void 0,null==(i=this.ha)||i.dispose(),this.ha=void 0}reset(){this.Go=[],this.$a().length>0&&this.Sa([]),this.Ca(),this.Ia(),this.wa()}getEventToItemsMap(){return this.Qo}Oa(){return this.ha}},ls=class extends os{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.Fa=t,this.Da=e,this.Ko()}Ma(){return Lr}Ea(){return Nr}ea(){return zr}ia(t){this.Fa.kv.set({[zr]:t})}na(){this.Fa.kv.remove(zr)}ta(t){var e,i;this.aa(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}La(){return Kn}aa(t){this.Da.getSurveys(t)}ya(t){this.Da.cancelPendingSurvey(t)}va(){return is}Sa(t){this.Fa.kv.set({[Lr]:t})}Aa(t){this.Fa.kv.set({[Nr]:t})}Ra(){this.Fa.kv.remove(Nr)}Pa(){return!1}fa(t,e,i){var r,n;return t===Xn&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.aa(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return Yn(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===Kn?"consume":"ignore":t===Kn?"persist":t===Jn||t===Xn?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},us=(t,e)=>null!=t&&t.then?t.then(e):e(t),hs="SDK is not enabled or survey functionality is not yet loaded",cs="Disabled. Not loading surveys.",vs=class{constructor(t){this.Na=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.ja=!1,this.qa=!1,this.Ba=[],this.za=[],this.Ha=null,this.Ua=null,this.Ti=!1,this.Wa=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.Ti&&!this.Fr.disableSurveys){if(!t.ok)return this.qa=!0,this.Va({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),is.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return is.warn("Flags not loaded yet. Not loading surveys.");this.Ga=_(e)?e:e.length>0,is.info("flags response received, isSurveysEnabled: "+this.Ga),this.loadIfEnabled()}},this.Va=t=>{this.za.slice().forEach(e=>this.Qa(e,t))}}setup(t){if(!this.Ti)return this.Ja=t,us(t.kv.initialize(),()=>{if(this.Ja===t&&!this.Ti){this.Ja=void 0,this.Fa=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Ti?e.dispose():(this.Za=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Ti||(this.Ti=!0,this.Ja=void 0,this.Fa=void 0,null==(t=this.Za)||t.dispose(),this.Za=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Ba=[],this.za.forEach(t=>{t.active=!1}),this.za=[],null==(r=this.Ka)||r.call(this),this.Ka=void 0,this.Ha=null,this.Wa.forEach(t=>clearTimeout(t)),this.Wa.clear())}get Fr(){return this.Na.get()}getRenderContext(){if(this.Fa){var t=this;return{client:this.Fa,get config(){return t.Fr},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.Va()}loadIfEnabled(){if(!this.Ti&&this.Fa){var t=this.Fr;if(!this._surveyManager)if(this.ja)is.info("Already initializing surveys, skipping...");else if(t.disableSurveys)is.info(cs);else if(t.cookielessMode&&this.Fa.isOptedOut)is.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Na.getExtensions();if(e){if(!f(this.Ga)||t.advancedEnableSurveys){var i=this.Ga||t.advancedEnableSurveys;this.ja=!0,this.qa=!1;try{var r=e.generateSurveys;if(r)return this.Xa(r,i),void(this.ja=!1);var n=e.loadExternalDependency;if(!n)return this.Ya(Dr),void(this.ja=!1);n(t=>{try{if(this.Ti)return;var e=this.Na.getExtensions();t||null==e||!e.generateSurveys?this.Ya("Could not load surveys script",t):this.Xa(e.generateSurveys,i)}finally{this.ja=!1}})}catch(t){throw this.ja=!1,this.Ya("Error initializing surveys",t),t}}}else this.Ya("PostHog Extensions not found.")}}}Xa(t,e){var i;if(!this.Ti){this._surveyManager=t(e),this._surveyEventReceiver=this.tl(this.Fa,this.Va);var r=null==(i=this.Fa)?void 0:i.kv.get(Ir);r&&this.el(r),is.info("Surveys loaded successfully"),this.il(),this.Va(),this.nl({isLoaded:!0})}}tl(t,e){return new ls(t,this,void 0,e)}Ya(t,e){this.qa=!0,is.error(t,e),this.Va({isLoaded:!1,error:t}),this.nl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ba.push(t),this._surveyManager&&this.nl({isLoaded:!0}),()=>{this.Ba=this.Ba.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Ti){var i=this.Fa;if(!i)return t([],{isLoaded:!1,error:hs});if(this.Fr.disableSurveys)return is.info(cs),t([]);var r=i.kv.get(Ir);if(r&&!e)return t(r,{isLoaded:!0}),void(this.sl()&&this.getSurveys(()=>{},!0));if(this.Ha)this.Ha.then(e=>{this.Ti||t(e.surveys,e.context)}).catch(t=>is.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Fr.requestTimeoutMs}).then(t=>{try{return this.rl(i,t)}catch(t){return is.error("Error processing surveys response",t),this.rl(i,{statusCode:0,error:t})}},t=>this.rl(i,{statusCode:0,error:t}));this.Ha=n;var s=()=>{this.Ha===n&&(this.Ha=null)};n.then(e=>{s(),this.Ti||(this.Va(e.context),t(e.surveys,e.context))},s).catch(t=>is.error("Error in survey callback",t))}}}rl(t,e){if(this.Ti)return{surveys:[],context:{isLoaded:!1,error:hs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?is.error(r):e.error||is.warn(r),this.Ua=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Ua=null;var n=e.json.surveys||[];return t.kv.set({[Ir]:n,[jr]:Date.now()}),this.el(n),{surveys:n,context:{isLoaded:!0}}}el(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Yn(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.al(e)}al(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}sl(){return this.ll()&&!this.Ha&&!this.ul()}ll(){var t,e=null==(t=this.Fa)?void 0:t.kv.get(jr);return b(e)&&Date.now()-e>3e5}ul(){return b(this.Ua)&&3e5>Date.now()-this.Ua}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){is.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.Va()}nl(t){for(var e of this.Ba){if(this.Ti)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){is.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);is.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Ti)return()=>{};var i={callback:t,active:!0,revision:0};this.za.push(i),this.il();var r=null==(e=this.Fa)?void 0:e.kv.get(Ir);return this.Fr.disableSurveys||!this._surveyManager&&this.qa&&!this.ja||!r&&!y(this.Ua)&&!this.Ha?this.Qa(i,{isLoaded:!1}):this._surveyManager&&this.Qa(i),()=>{var t;i.active=!1,this.za=this.za.filter(t=>t!==i),0===this.za.length&&(null==(t=this.Ka)||t.call(this),this.Ka=void 0)}}il(){var t,e,i;this._surveyManager&&this.za.length>0&&(null!==(t=this.Ka)&&void 0!==t||(this.Ka=null==(e=(i=this.Na).onMatchingConditionsChanged)?void 0:e.call(i,this.Va)))}Qa(t,e){if(!this.Ti&&t.active){var i=++t.revision,r=r=>{if(!this.Ti&&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){is.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){is.error("Error in active matching surveys callback",t)}}}cl(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}hl(t){if(y(this._surveyManager))return{eligible:!1,reason:hs};var e="string"==typeof t?this.cl(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}dl(t){var e;if(null==(e=this.Fa)||!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:hs};var i="string"==typeof t?this.cl(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return is.warn("init was not called"),{visible:!1,disabledReason:hs};var e=this.dl(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:hs})):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.dl(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.Fa)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var a="string"==typeof t?this.cl(t):t;if(null!=a&&a.id)if(rs.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){is.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.Wa.delete(l),!this.Ti&&null!=(t=this.Fa)&&t.canCapture&&(is.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),is.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.Wa.add(l)}else this._surveyManager.renderSurvey(a,o,i);else is.warn("Survey element not found")}else is.warn("Surveys of type "+a.type+" cannot be rendered in the app");else is.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.Fa)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var s=this.cl(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&&is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.hl(s);if(!o.eligible)return void is.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 is.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?is.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};si.DEBUG=!1,si.LIB_VERSION="1.447.1",si.LIB_NAME="web";var ds,fs=si,ps=/* @__PURE__ */new WeakMap,gs=()=>{var t;return null!=rn&&null!=(t=rn.performance)&&t.now?rn.performance.now():Date.now()},ms=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==un?void 0:un.__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!==Kn&&e!==Jn&&e!==Xn||t()}),n=()=>t();di(rn,"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==rn||rn.removeEventListener("PHSurveyShown",n)}}},ys=/* @__PURE__ */(()=>null!=rn&&rn.location?bn(rn.location.hash,"__posthog")||bn(location.hash,"state"):null)(),bs="_postHogToolbarParams",_s=/* @__PURE__ */li("[Toolbar]"),ws=/* @__PURE__ */li("[FeatureFlags]"),xs=/* @__PURE__ */li("[FeatureFlags]",{debugEnabled:!0}),Ss="\" failed. Feature flags didn't load in time.",ks=[502,504],Es=["click","keydown","wheel","touchstart","pointerdown"],As="connection_error",Ts=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Fs=t=>{var e={};for(var i of vi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Ps=(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),Rs=class{constructor(t){this.name="featureFlags",this.Pd=!1,this.featureFlagEventHandlers=[],this.R=ws,this.Od={},this.Fd={},this.Dd=[],this.Ld=/* @__PURE__ */new Set,this.Nd=/* @__PURE__ */new Set,this.jd=!1,this.qd=!1,this.Bd=0,this.zd=!1,this.Hd=!1,this.Ud=!1,this.Wd=/* @__PURE__ */new Map,this.Vd=!1,this.Gd=!1,this.Qd=!1,this.Jd=0,this.Zd=!1,this.sn=()=>{var t=this.Kd();this.Jd=0,t&&this.reloadFeatureFlags()},this.Yd=()=>{var t,e,i=this.Xd,r=null!==(t=this.tv)&&void 0!==t?t:i;f(i)||f(r)||this.Fr.remoteRequestsDisabled||!this.ev||"hidden"===this.ev.visibilityState||Date.now()-(null!==(e=this.iv)&&void 0!==e?e:0)<r||(this.tv=this.Zd||!this.Fr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Zd=!1,this.reloadFeatureFlags(),this.nv())},this.sv=()=>{this.Zd&&this.tv===this.Xd||this.rv()},this.an=()=>{var t;"visible"===(null==(t=this.ev)?void 0:t.visibilityState)&&this.rv()},this.Na=t}get ov(){}av(){this.Fa&&this.lv()}setup(t){try{this.uv=typeof window>"u"?void 0:window,this.ev=typeof document>"u"?void 0:document}catch(t){this.uv=void 0,this.ev=void 0}return this.Ja=t,this.R=t.logger.createLogger("[FeatureFlags]"),us(t.kv.initialize(),()=>{this.Ja===t&&(this.Ja=void 0,this.Fa=t,this.hv(t))})}hv(t){var e;if(this.Fa===t)return this.uv&&di(this.uv,"online",this.sn),this.lv(),this.dv=t.registerDynamicEventProperties(()=>this.vv()?this.Od:this.Fd),this.fv=null==(e=this.ov)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.pv(),this.gv(),this.mv()}),this.gv(),this.initialize()}rv(){this.Zd=!0,this.tv=this.Xd,this.Yd()}lv(){var t,e=this.Fr.refreshIntervalMs,i=!this.Fr.remoteRequestsDisabled&&this.ev&&!f(e)&&e>0?e:void 0;this.Fr.idleRefreshBackoff||(this.tv=i),i!==this.Xd&&(this.yv(),f(i)||(this.Xd=i,this.tv=i,this.nv(),null!=(t=this.ev)&&t.addEventListener&&(di(this.ev,Ci,this.an),ui(Es,t=>{di(this.ev,t,this.sv,{capture:!0})}))))}nv(){f(this.Xd)||(f(this.bv)||clearInterval(this.bv),this.iv=Date.now(),this.bv=setInterval(this.Yd,this.Xd))}yv(){var t;f(this.bv)||(clearInterval(this.bv),this.bv=void 0,null==(t=this.ev)||null==t.removeEventListener||t.removeEventListener(Ci,this.an),ui(Es,t=>{var e;null==(e=this.ev)||null==e.removeEventListener||e.removeEventListener(t,this.sv,{capture:!0})})),this.Xd=void 0,this.tv=void 0,this.Zd=!1,this.iv=void 0}destroy(){this._v()}dispose(){this._v()}_v(){var t,e,i;this.yv(),this.Bd++,this.Hd=!1,this.Ja=void 0,this.wv(this.Ld,"cancelled"),this.wv(this.Nd,"cancelled"),this.Fa&&(this.Sv(),null==(t=this.dv)||t.dispose(),this.dv=void 0,null==(e=this.fv)||e.call(this),this.fv=void 0,this.Dd=[],null==(i=this.uv)||i.removeEventListener("online",this.sn),this.Fa=void 0)}get Fr(){return this.Na.get()}xv(t){var e;return this.$v&&t in this.$v?this.$v[t]:null==(e=this.Fa)?void 0:e.kv.get(t)}pv(){return!!this.$v&&(this.$v=void 0,!0)}Cv(){var t;return!f(null==(t=this.Fa)?void 0:t.kv.get("$enabled_feature_flags"))&&this.pv()}$t(t){this.Tv(()=>{var e;return null==(e=this.Fa)?void 0:e.kv.set(t)})}Iv(t,e,i){if(this.ov&&t.$enabled_feature_flags){var r=this.xv("$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.xv("$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={[mi]:p,[Si]:p,[Fi]:g};for(var y of(t.$feature_flag_details&&(m[yi]=p),[wi,_i,xi]))f(t[y])||(m[y]=!0);this.ov.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.Tv(()=>{var e;return null==(e=this.Fa)?void 0:e.kv.remove(t)})}Tv(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}gv(){var t={};for(var i of[mi,Fi,wi,Pi]){var r=this.xv(i);f(r)||(t[i]=r)}this.Od=t;var n=e({},t),s=this.xv(Si);if(s)for(var a of Object.entries(s))n["$feature/"+a[0]]=a[1];this.Fd=n}vv(){var t=this.Fr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.xv(_i);return"number"!=typeof e||Date.now()-e>t}Mv(){return!!this.vv()&&(this.Qd||this.qd||(this.Qd=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Ev(){var t=this.Fr.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}):[]}Av(){var t=this.Fr.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.Fr,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.Rv({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n,s,a=null!=r&&r.merge&&null!==(n=this.xv("$enabled_feature_flags"))&&void 0!==n?n:{},o=null!=r&&r.merge&&null!==(s=this.xv("$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.Rv({flags:h})}get hasLoadedFlags(){return this.jd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.xv(yi),i=this.xv(Pi),r=this.xv(Ri);if(!r&&!i)return t||{};var n=ci({},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.Pd||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.Pd=!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.xv(Si),e=this.xv(Pi);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Pd||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Pd=!0),i}getFlagPayloads(){var t=this.xv(Fi),e=this.xv(Ri);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Pd||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Pd=!0),i}reloadFeatureFlags(){this.zd||this.Fr.featureFlagsDisabled||this.Kd()||(this.Ud&&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.qd&&(this.Hd=!0),this.Pv||(this.Dd.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}}),this.Pv=setTimeout(()=>{this.Ov()},5)))}reloadFeatureFlagsAsync(){return!this.Fa||this.zd||this.Fr.featureFlagsDisabled||this.Fr.remoteRequestsDisabled||this.Kd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.Ld.add(t),this.reloadFeatureFlags()})}wv(t,e){t.forEach(t=>t({status:e})),t.clear()}Sv(){clearTimeout(this.Pv),this.Pv=void 0}onReloading(t){return this.Dd.push(t),()=>{this.Dd=this.Dd.filter(e=>e!==t)}}ensureFlagsLoaded(){this.jd||this.qd||this.Pv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.zd=t}resetFlagCallReported(){this.Dt(Ai),this.Wd=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.Wd.size&&!this.Vd&&null!=(t=this.Fa)&&t.canCapture&&!this.Fa.isRateLimited){this.Vd=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.Wd.keys())){var r=this.Wd.get(i);if(r){if(r.value!==String(e[i])||!Ps(r.context,this.Fv())){this.Wd.delete(i);continue}if(this.getFeatureFlagResult(i),this.Wd.has(i))break}}}finally{this.Vd=!1}}}Ov(t){var i;this.Sv();var r=this.Fa;if(!r||this.Fr.remoteRequestsDisabled||this.Kd())this.wv(this.Ld,"skipped");else if(this.qd)this.Hd=!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.xv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.xv(ki),timezone:kn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Fr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.Ev();s.length&&(n.evaluation_contexts=s);var a=this.Av();f(a)||(n.flag_keys=a);var o=this.Fr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.Bd,h=this.Ld;this.Ld=/* @__PURE__ */new Set,this.Nd=h,this.qd=!0;var c=()=>{this.Hd&&(this.Hd=!1,this.Ov())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.qd=!1,u===this.Bd)if(this.Dv(t.statusCode),s||this.Hd||(this.$anon_distinct_id=void 0),!n.disable_flags||this.Hd){this.Gd=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?As:"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({[bi]: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.Rv(r,s,{partialResponse:o}),this.wv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.wv(h,"skipped");else c()},d=t=>{this.qd=!1,u===this.Bd?(this.$t({[bi]:[As]}),this.R.error("Feature flag request failed",t),this.Cv()&&this.mv(!0),this.wv(h,"error"),c()):c()},p=null!==(i=this.Fr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.Bd,m=()=>{if(u!==this.Bd||!this.Fa||this.Fr.remoteRequestsDisabled)return this.qd=!1,this.wv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Fr.compression,sentAt:"body",timeoutMs:this.Fr.requestTimeoutMs}).then(t=>{if((t=>ks.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()}}Kd(){return pn(this.Jd,3)}Dv(t){this.Jd=gn(t,this.Jd,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.Gd)if(this.jd||this.getFlags()&&this.getFlags().length>0){if(!this.Mv()){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+Ss)}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.Gd)if(this.jd||this.getFlags()&&this.getFlags().length>0){if(!this.Mv()){var r,n=this.getFlagVariants(),s=t in n,a=n[t],o=this.getFlagPayloads()[t],l=String(a),u=this.xv("$feature_flag_request_id")||void 0,c=this.xv("$feature_flag_evaluated_at")||void 0,v=this.xv("$flag_call_reported")||{};if(this.Fr.deduplicateCallsPerSession){var d,p=null==(d=this.Fa)||null==(d=d.session)?void 0:d.sessionId,g=this.xv(Ti);p&&p!==g&&(v={},r=p)}if(!i.send_event&&"send_event"in i)r&&this.$t({[Ai]:v,[Ti]:r});else{var m,y,b,_,w=!(null!=(m=this.Fa)&&m.canCapture),x=!(w||null!=(y=this.Fa)&&y.isRateLimited);if(x?this.Wd.delete(t):(w&&Object.keys(v).length>0&&(v={},this.$t({[Ai]:v})),null!=(_=v[t])&&_.includes(l)||this.Lv(t,l)),!x||null!=(b=v[t])&&b.includes(l))r&&this.$t({[Ai]:v,[Ti]: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({[Ai]:v},r?{[Ti]:r}:{}));var D=this.getFeatureFlagDetails(t),L=[...null!==(S=this.xv("$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.Fr.bootstrap)||null==(E=E.featureFlags)?void 0:E[t])&&void 0!==k?k:null,$feature_flag_bootstrapped_payload:null!==(A=null==(T=this.Fr.bootstrap)||null==(T=T.featureFlagPayloads)?void 0:T[t])&&void 0!==A?A:null,$used_bootstrap_value:!this.Gd};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.Nv(N)||(this.jv(t,l),this.Lv(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+Ss)}Nv(t){try{var e;return!1!==(null==(e=this.Fa)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}Lv(t,e){this.Wd.set(t,{value:e,context:this.Fv()})}Fv(){var t,i,r;return{distinctId:null==(t=this.Fa)?void 0:t.distinctId,groups:e({},null==(i=this.Fa)?void 0:i.groups),sessionId:this.Fr.deduplicateCallsPerSession?null==(r=this.Fa)||null==(r=r.session)?void 0:r.sessionId:void 0}}jv(t,e){var i=this.xv("$flag_call_reported")||{},r=i[t];h(r)&&r.includes(e)&&(i[t]=r.filter(t=>t!==e),this.$t({[Ai]:i}))}getRemoteConfigPayload(t,e){this.qv(t,e)}qv(t,e){var i=this;return r(function*(){var r=i.Fa;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.Ev();s.length&&(n.evaluation_contexts=s);var a,o=i.Av();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.Fr.compression,sentAt:"body",timeoutMs:i.Fr.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.Gd)return e.defaultValue;if(!(this.jd||this.getFlags()&&this.getFlags().length>0))return this.R.warn('isFeatureEnabled for key "'+t+Ss),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.Rv(t,e,i)}Rv(t,i,r){if(this.Fa){this.jd=!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=ws);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{[mi]:u,[Si]:p,[xi]:!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({[mi]:Object.keys(Fs(m)),[Si]:m||{},[Fi]:y||{},[yi]:b||{},[xi]:!0===t.minimalFlagCalledEvents},v?{[wi]:v}:{},d?{[_i]: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.Fa.kv.get(Si));this.$v=n,s||this.$t(n)}else this.pv(),this.Iv(n,t,!(null==r||!r.partialResponse)),this.$t(n);else i&&this.Cv();i||(this.Qd=!1),this.mv(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.Bv(t)}Bv(t){if(this.Fa){if(!1===t)return this.Dt([Pi,Ri]),this.mv(),void xs.info("All overrides cleared");if(h(t))return this.$t({[Pi]:Ts(t)}),this.mv(),void xs.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.Pd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Pi]=h(n)?Ts(n):n),s&&(r[Ri]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Pi,Ri]):!1===n?this.Dt(Pi):!1===s&&this.Dt(Ri),this.mv(),!1===n?xs.info("Flag overrides cleared"):n&&xs.info("Flag overrides set",{flags:n}),void(!1===s?xs.info("Payload overrides cleared"):s&&xs.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Pi]:t}),this.mv(),void xs.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.jd){var e=this.zv(),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.xv("$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.ov)||n.markCrossTabFeatureFlagChanges({[mi]:[t],[Si]:[t],[Ei]:Object.keys(a)}),this.$t({[mi]:Object.keys(Fs(l)),[Si]:l,[Ei]:e({},this.xv("$stored_person_properties")||{},a)}),this.mv();try{var u;null==(u=this.Fa)||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.xv(gi);!r||e?this.Hv(t,i):t(r)}Hv(t,e){var i=this;return r(function*(){var r=i.Fa;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({[gi]: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)}}})()}zv(){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),{})}}mv(t){this.gv();var e=this.zv(),i=e.flags,r=e.flagVariants,n=this.Ud;this.Ud=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.Ud=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Uv(t,e)}Uv(t,i){void 0===i&&(i=!0);var r=this.xv("$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({[Ei]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.xv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Ei]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Ei),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.xv("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[ki]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.xv("$stored_group_properties")||{};this.$t({[ki]:e({},i,{[t]:{}})})}else this.Dt(ki)}reset(){this.Bd++,this.wv(this.Ld,"cancelled"),this.wv(this.Nd,"cancelled"),this.Hd=!1,this.Od={},this.Fd={},this.$v=void 0,this.jd=!1,this.zd=!1,this.Gd=!1,this.$anon_distinct_id=void 0,this.Sv(),this.Pd=!1,this.Jd=0,this.Wd=/* @__PURE__ */new Map}},Cs=/* @__PURE__ */li("[FeatureFlags]"),Os=class{constructor(t,e){void 0===e&&(e=!1),this.Wv=!1,this.update(t,e)}update(t,e){this.Vv=((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.Wv||(Cs.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Wv=!0),f(t.flag_keys)||h(t.flag_keys)||Cs.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Vv}},Ms=class extends Rs{constructor(t){var e=new Os(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.Gv=e}get ov(){return this._instance.persistence}updateConfig(t,e){this.Gv.update(t,e),this.av()}},$s=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Is=/* @__PURE__ */li("[Error tracking]"),js="webkit-masked-url:",Ds=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Ls=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",js],Ns=["__firefox__","__gCrWeb"],zs=/*#__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}()}(),Bs="Refusing to render web experiment since the viewer is a likely bot",Us={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Hs={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>Zn(e,t),not_regex:(t,e)=>!Zn(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},qs=/* @__PURE__ */li("[Conversations]"),Vs="Conversations not available yet.";function Ws(){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(je,t)?je[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function Gs(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({},Ws(),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 Ks=["debug","log","warn","error","info"],Js="console",Xs="__posthogHandledLogsRequestError",Ys=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[Xs]=!0,i},Zs=t=>!!t&&"object"==typeof t&&!0===t[Xs],Qs=class{get Qv(){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(Zs)||t.R.error(...i)}})}constructor(t,e){var i;this.Na=t,this.Jv=e,this.name="logs",this.Zv=!1,this.Kv=!1,this.Yv=!1,this.R=li("[logs]"),this.cc=[],this.Xv=[],this.Jd=0,this.tf=!1,this.Ti=!1,this.ef=[],this.if=[],this.nf=!1,this.sf=!1,this.rf=!1,this.af=()=>{var t,e;this.Ti||(this.Jd=0,null==(t=this.lf)||t.onReconnect(),null==(e=this.uf)||e.onReconnect())},this.Zv=!(null==(i=t.get())||!i.captureConsoleLogs)}get cf(){return!0}hf(){}df(){if(!this.rf){try{this.uv=typeof window>"u"?void 0:window}catch(t){this.uv=void 0}this.uv&&(di(this.uv,"online",this.af),this.rf=!0)}}vf(t,e,i,r){this.df();var n=Gs(this.Na.get(),i);return[new We(this.ff(t,e),n,this.Qv,()=>this.Jv(),t=>t(),void 0,r),n]}pf(){var t=this.Na.get();if(!this.lf||this.gf!==t){var e;null==(e=this.lf)||e.reset(),this.gf=t;var i=this.vf(()=>this.cc,t=>{this.cc=t});this.lf=i[0],this.mf=i[1]}return this.lf}yf(){var t=this.Na.get();if(!this.uf||this.bf!==t){var e;null==(e=this.uf)||e.reset(),this.bf=t;var i=this.vf(()=>this.Xv,t=>{this.Xv=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Js);this.uf=i[0],this._f=i[1]}return this.uf}setup(t){if(!this.Ti&&!this.tf)return this.tf=!0,this.Fa=t,this.R=t.logger.createLogger("[logs]"),us(t.kv.initialize(),()=>{this.Ti||this.hv(t)})}hv(t){var e;this.df(),null!=(e=this.Na.get())&&e.captureConsoleLogs&&(this.Zv=!0),(this.Zv||this.Na.remoteConfigWillArrive&&t.kv.get(this.Na.captureHintKey))&&this.wf();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.Ti?r.dispose():(this.Za=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Ti||(this.Ti=!0,this.kf(),null==(t=this.Za)||t.dispose(),this.Za=void 0,this.Fa=void 0,this.Yv=!1,null==(e=this.uv)||e.removeEventListener("online",this.af),null==(i=this.Sf)||i.call(this),this.Sf=void 0,null==(r=this.lf)||r.clearQueue(),null==(n=this.uf)||n.clearQueue(),null==(s=this.lf)||s.reset(),null==(a=this.uf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Ti){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.xf():(null==(i=this.Fa)||i.kv.set(this.Na.captureHintKey,!!r),r?(this.Zv=!0,this.Kv||this.wf(),this.loadIfEnabled()):this.xf())}}reset(){var t,e,i,r;this.kf(),null==(t=this.lf)||t.clearQueue(),this.cc=[],null==(e=this.lf)||e.reset(),null==(i=this.uf)||i.clearQueue(),this.Xv=[],null==(r=this.uf)||r.reset(),this.Jd=0}captureLog(t){!this.Ti&&this.Fa&&this.pf().captureLog(t)}captureConsoleLog(t){!this.Ti&&this.Fa&&this.yf().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Ti&&this.Fa&&this.yf().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.kf(),null==(t=this.uf)||t.clearQueue(),this.Xv=[]}xf(){this.Zv||this.kf()}wf(){var t,e=this;if(!this.nf&&null!=(t=this.uv)&&t.console){var i=Gs(this.Na.get()).maxBufferSize,r=!0;this.if.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.uv.console[t])}catch(t){return 1}n&&e.if.push(xn(e.uv.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.$f(t,a,i)}catch(t){}return s.apply(e.uv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of Ks)if(n(s))continue;this.nf=!0,this.Cf=setTimeout(()=>{this.kf()},3e4)}}$f(t,e,i){var r;if(this.nf&&!this.sf&&0!==e.length)if(null!=(r=this.Fa)&&r.canCapture){if(i>this.ef.length){this.sf=!0;try{this.ef.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Jv()})}finally{this.sf=!1}}}else this.kf()}kf(){if(this.ef=[],this.nf){for(var t of(this.nf=!1,this.Cf&&(clearTimeout(this.Cf),this.Cf=void 0),this.if))t();this.if=[]}}Tf(){var t=this.ef;return this.kf(),t}get logger(){return this.If||(this.If={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.If}flushLogs(t){this.Fa&&(t?this.Mf(t):(this.lf&&this.lf.flush().catch(t=>this.Ef(t)),this.uf&&this.uf.flush().catch(t=>this.Ef(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.lf)?void 0:e.flush().catch(e=>t.Ef(e)),n=null==(i=t.uf)?void 0:i.flush().catch(e=>t.Ef(e));yield r,yield n})()}Ef(t){Zs(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Ti&&this.Zv&&!this.Kv&&!this.Yv){var t=this.hf();if(t){this.Yv=!0;try{t((t,e)=>{if(this.Yv=!1,!this.Ti&&this.Zv)if(t||!e)this.R.error("Could not load logs script",t),this.kf();else{var i=this.Tf();this.Sf=e.initialize(this.Fa),this.Kv=!0,i.length>0&&e.replay(this.Fa,i)}})}catch(t){throw this.Yv=!1,t}}else this.kf()}}ff(t,e){var i=this.Fa;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:[])},qs:t=>this.qs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}qs(t){return new Promise(e=>{if(pn(this.Jd,3))e({kind:"fatal",error:Ys(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:Ys(void 0,"logs request timed out")})},9e4),s=this.cf;this.Fa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Fa.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.Af(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:Ys(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})})}})}Af(t,e){(0!==t||e)&&(this.Jd=gn(t,this.Jd,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.")))}Mf(t){this.cc.length>0&&this.Rf(t,this.cc,this.mf,this.Fa.library.name,t=>{this.cc=t}),this.Xv.length>0&&this.Rf(t,this.Xv,this._f,Js,t=>{this.Xv=t})}Rf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ue(s,Be(i,this.Fa.library.name,this.Fa.library.version),r,this.Fa.library.version);this.Fa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Fa.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Ef(t))}}},ta=/* @__PURE__ */li("[NetworkMetrics]"),ea={"http:":80,"https:":443},ia=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),ra=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Sr(r))?void 0:i.href)||r}},na=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=gs()-n,d=Sr(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":_=ia.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)||ea[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){ta.error("Failed to record network metric",t)}var b,_},sa=()=>{},aa=(t,e)=>c(null==rn?void 0:rn.fetch)?xn(rn,"fetch",i=>function(){for(var r=gs(),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=ra(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=>(na(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw na(t,d,void 0,r,e,i),i})}catch(t){return ta.error("Failed to observe fetch",t),o}}):sa,oa=(t,e)=>{var i,r=null==rn||null==(i=rn.XMLHttpRequest)?void 0:i.prototype;if(!r)return sa;var n=/* @__PURE__ */new WeakMap,s=xn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{ps.has(this)||n.set(this,ra(i[0],i[1]))}catch(t){ta.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=xn(r,"send",i=>function(){var r;try{var s=n.get(this);if(s&&e()){var a=gs();di(this,"loadend",r=()=>{this.removeEventListener("loadend",r),na(t,s,this.status,a,e)})}}catch(t){ta.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()}},la=/* @__PURE__ */new WeakMap,ua=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),ha={maxStringLength:2048,truncationSuffix:"..."},ca={maxStringLength:2048,truncationSuffix:"..."};function va(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function da(t,e){return{}.hasOwnProperty.call(t,e)}function fa(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function pa(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?Ee(r,ha):r).slice(0,e)}}function ga(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function ma(t){return Ee(t||"Unknown error",ca).slice(0,2048)}function ya(t,e){try{return ma(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 ba(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:ma(t.value)}))}function _a(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 wa(t,e){return{message:ya(t,e),type:_a(t,e)}}var xa=function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return ci({},...e)},Sa={featureFlags:Ms},ka={sessionRecording:class{get Fr(){return this._instance.config}get Pc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Pf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this.Of||"missing_config"===this.Of?this.Of:null!==(t=null==(e=this.Pf)?void 0:e.status)&&void 0!==t?t:this.Of}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Of=jn,this.Ff=void 0,this.Df=!1,this.Ye=(()=>{var t;if(null==an||!an.visibilityState||"visible"===an.visibilityState)return!0;var e=null==rn||null==(t=rn.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.an=()=>{var t;"visible"===(null==an?void 0:an.visibilityState)&&(this.Ye=!0,null==(t=this.Pf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Ln.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Fr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=an&&an.addEventListener&&di(an,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.Df=!0,null==an||null==an.removeEventListener||an.removeEventListener("visibilitychange",this.an),i?this.Lf(!0):this.stopRecording()}get Nf(){var t,e=!(null==(t=this._instance.get_property(Jr))||!t.enabled),i=!this.Fr.disable_session_recording,r=this.Fr.disable_session_recording||this._instance.consent.isOptedOut();return rn&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!(this.Df||this.Nf&&null!=(e=this.Pf)&&e.isStarted)){var i=!f(Object.assign)&&!f(Array.from);this.Nf&&i?(this.jf(t),Ln.info("starting")):(this.Of=jn,this.stopRecording())}}jf(t){var e,i;if(this.Nf)if("awaiting_config"!==this.Of&&"missing_config"!==this.Of&&(this.Of=Dn),null!=un&&null!=(e=un.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=un.__PosthogExtensions__)&&i.initSessionRecording)this.qf(t);else{var r,n=this._instance.sessionManager;null==(r=un.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Bf,e=>{if(!this.Df&&this.Nf&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[Qr]:!0}),Ln.error("could not load recorder",e)):void this.qf(t);this.Of=jn})}}stopRecording(){var t,e;null==(t=this.Ff)||t.call(this),this.Ff=void 0,null==(e=this.Pf)||e.stop()}Lf(t){var e,i;void 0===t&&(t=!1),null==(e=this.Ff)||e.call(this),this.Ff=void 0,null==(i=this.Pf)||i.discard({discardProducerEvents:t})}zf(){var t,e;null==(t=this.Pc)||t.unregister("$session_is_sampled"),null==(e=this.Pc)||e.unregister("$replay_sample_rate")}Hf(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?(Ln.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Uf(t){if(this.Pc){var i,r,n=this.Pc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Hf(null==(i=this.Fr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Hf(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.zf();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[Jr]: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.Ff)||i.call(this),this.Ff=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.Uf(e),void this.Lf()):(this.Uf(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.Of&&(this.Of="missing_config",this._instance.register_for_session({[tn]:!0}),Ln.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.Pf)&&i.log?this.Pf.log(t,e):Ln.warn("log called before recorder was ready")}get Bf(){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"}Wf(){var t,e=this._instance.get_property(Jr);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Ln.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}qf(t){var e,i,r;if(!this.Df&&this.Nf&&this._instance.sessionManager){if(null==(e=un.__PosthogExtensions__)||!e.initSessionRecording)return Ln.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Qr]:!0});var n;if(this.Pf||(this.Pf=null==(n=un.__PosthogExtensions__)?void 0:n.initSessionRecording(this._instance,this.Ye),this.Pf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Wf()){if("missing_config"===this.Of||"awaiting_config"===this.Of)return;return this.Of="awaiting_config",Ln.info("persisted remote config is stale, requesting fresh config before starting"),void new In(this._instance).load()}this.Of=Dn,null==(i=(r=this.Pf).setDocumentWasEverVisible)||i.call(r,this.Ye),this.Pf.start(t)}else this.Of=jn}onRRwebEmit(t){var e;null==(e=this.Pf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Pf||null==(t=this.Pc)||t.register({[Yr]:!0}),null==(e=this.Pf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.Pf||null==(t=this.Pc)||t.register({[Xr]:!0}),null==(e=this.Pf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.Pf||null==(e=this.Pc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Pf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Nn){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.Pf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Pf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.Pf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Ea={autocapture:class extends Or{constructor(t){super(new $r(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.Vf=!1,this._instance=t,this.Gf=this.Qf()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Jf();return!!(t.path||t.search||this.Zf(t))}startIfEnabled(){this.isEnabled&&(oi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Gf=this.Qf(),this.startIfEnabled()}stop(){this.Kf&&this.Kf(),this.Kf=void 0,this.Yf&&this.Yf(),this.Yf=void 0,oi.info("History API monitoring stopped")}monitorHistoryChanges(){rn&&rn.history&&(this.Xf("pushState"),this.Xf("replaceState"),this.tp(),this.Zf()&&this.ep())}Xf(t){var e;if(rn&&(null==(e=rn.history[t])||!e.__posthog_wrapped__)){var i=this;xn(rn.history,t,e=>function(r,n,s){var a;i.np(s)&&i.sp(),e.call(this,r,n,s),i.rp(t,!i.Vf&&"popstate"!==(null==rn||null==(a=rn.event)?void 0:a.type))})}}Qf(){var t=null==rn?void 0:rn.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Jf(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}Zf(t){return void 0===t&&(t=this.Jf()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}op(t){var e=this.Jf(),i=this.Gf;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.Zf(e)&&t.hash!==i.hash))}rp(t,e){void 0===e&&(e=!1);try{e||this.sp();var i=this.Qf();if(!i)return;if(this.op(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.ap=r,Promise.resolve().then(()=>this.sp())):r()}this.Gf=i}catch(e){oi.error("Error capturing "+t+" pageview",e)}}np(t){var e,i;return!(y(t)||!rn)&&(null==(e=Sr(String(t)))?void 0:e.href)!==(null==(i=rn.location)?void 0:i.href)}sp(){var t=this.ap;if(t){this.ap=void 0,this.Vf=!0;try{t()}catch(t){oi.error("Error capturing deferred pageview",t)}finally{this.Vf=!1}this.Gf=this.Qf()}}tp(){if(!this.Kf){var t=()=>{this.rp("popstate")};di(rn,"popstate",t),this.Kf=()=>{rn&&rn.removeEventListener("popstate",t)}}}ep(){if(!this.Yf){var t=()=>{this.rp("hashchange")};di(rn,"hashchange",t),this.Yf=()=>{rn&&rn.removeEventListener("hashchange",t)}}}},heatmaps:class{get Fr(){return this.instance.config}constructor(t){var e;this.lp=!1,this._l=!1,this.up=null,this.instance=t,this.lp=!(null==(e=this.instance.persistence)||!e.props[Br]),this.rageclicks=new xr(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Fr.capture_heatmaps)&&this.Fr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Fr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Fr.capture_heatmaps)?y(this.Fr.enable_heatmaps)?this.lp:this.Fr.enable_heatmaps:!1!==this.Fr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._l)return;zn.info("starting..."),this.cp(),this.an()}else{var t;clearInterval(null!==(t=this.up)&&void 0!==t?t:void 0),this.hp(),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({[Br]:i}),this.lp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}dp(t){Bn(t.originalEvent)&&this.Pr(t.originalEvent,"deadclick")}an(){this.up&&clearInterval(this.up),this.up="visible"===(null==an?void 0:an.visibilityState)?setInterval(this.bc.bind(this),this.flushIntervalMilliseconds):null}cp(){rn&&an&&(this.vp=this.bc.bind(this),di(rn,en,this.vp),this.fp=t=>this.Pr(t||(null==rn?void 0:rn.event)),di(an,"click",this.fp,{capture:!0}),this.pp=t=>this.gp(t||(null==rn?void 0:rn.event)),di(an,"mousemove",this.pp,{capture:!0}),this.mp=new vn(this.instance,cn,this.dp.bind(this)),this.mp.startIfEnabledOrStop(),this.yp=this.an.bind(this),di(an,Ci,this.yp),this._l=!0)}hp(){var t;rn&&an&&(this.vp&&rn.removeEventListener(en,this.vp),this.fp&&an.removeEventListener("click",this.fp,{capture:!0}),this.pp&&an.removeEventListener("mousemove",this.pp,{capture:!0}),this.yp&&an.removeEventListener(Ci,this.yp),clearTimeout(this.bp),null==(t=this.mp)||t.stop(),this._l=!1)}_p(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&&$i(r)&&!Ii(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:rn)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Gi(r)}return!1}(Hi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}Pr(t,i){var r;if(void 0===i&&(i="click"),!Mi(t.target)&&Bn(t)){var n=this._p(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&sr(Hi(t),this.instance.config.rageclick)&&this.Ks(e({},n,{type:"rageclick"})),this.Ks(n)}}gp(t){!Mi(t.target)&&Bn(t)&&(clearTimeout(this.bp),this.bp=setTimeout(()=>{this.Ks(this._p(t,"mousemove"))},500))}Ks(t){if(rn){var e=this.Fr.disable_capture_url_hashes?J(rn.location.href):rn.location.href,i=this.Fr.custom_personal_data_properties,r=yn(e,this.Fr.mask_personal_data_properties?[...En,...i||[]]:[],Tn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}bc(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:vn,webVitalsAutocapture:class{constructor(t){var i,r=this;this._instance=t,this.lp=!1,this._l=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.wp=function(t){void 0===t&&(t=!1),clearTimeout(r.kp),r.kp=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.Sp=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))Pn.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.xp(r);if(!f(n)){var s=b(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.$p||this.$p>t.value){this.Rt.navigationKey!==s&&(this.wp(),this.kp=setTimeout(this.wp,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 Mn){var h="url"===u&&"string"==typeof t.attribution[u]?this.xp(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.wp()}else Pn.error("Ignoring metric with value >= "+this.$p,t)}}},this.Cp=()=>{if(!this._l){var t,i,r,n,s=!1,a=un.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Tp])||("web-vitals"===this.Tp&&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.Sp.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Sp.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Sp.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.Sp.bind(this),v);var d=null==rn?void 0:rn.document;di(d,Ci,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.wp(!0)}),di(rn,"pagehide",()=>this.wp(!0)),this._l=!0}else Pn.error("web vitals callbacks not loaded - not starting")}},this.lp=!(null==(i=this._instance.persistence)||!i.props[Vr]),this.startIfEnabled()}get Ip(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.Ip)?null==(t=this.Ip)?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)||Cn:i}get flushToCaptureTimeoutMs(){return(v(this.Ip)?this.Ip.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.Ip)?this.Ip.web_vitals_attribution:void 0;return _(t)?t?Cn:[]:h(t)?t:On}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.Ip)?this.Ip.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get $p(){var t=v(this.Ip)&&b(this.Ip.__web_vitals_max_value)?this.Ip.__web_vitals_max_value:Rn;return t>0&&6e4>=t?Rn:t}get isEnabled(){var t=null==on?void 0:on.protocol;if("http:"!==t&&"https:"!==t)return Pn.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.Ip)?this.Ip.web_vitals:_(this.Ip)?this.Ip:void 0;return _(e)?e:this.lp}startIfEnabled(){this.isEnabled&&!this._l&&(Pn.info("enabled, starting..."),this.Bl(this.Cp))}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({[Vr]:i}),this._instance.persistence.register({[Kr]:r})),this.lp=i,this.startIfEnabled()}}}get Tp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Bl(t){var e=un.__PosthogExtensions__,i=this.Tp,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?Pn.error("failed to load script",e):t()})}xp(t){var e=t||(null==rn?void 0:rn.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 yn(i,this._instance.config.mask_personal_data_properties?[...En,...r||[]]:[],Tn)}Pn.error("Could not determine current URL")}}},Aa={exceptionObserver:class{constructor(t){var i;this.Cp=()=>{var t;if(rn&&this.isEnabled&&null!=(t=un.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=un.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=un.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=un.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Mp&&this.Fr.capture_unhandled_errors&&(this.Mp=e(this.captureException.bind(this))),!this.Ep&&this.Fr.capture_unhandled_rejections&&(this.Ep=i(this.captureException.bind(this))),!this.Ap&&this.Fr.capture_console_errors&&(this.Ap=r(this.captureException.bind(this)))}catch(t){dn.error("failed to start",t),this.Rp()}}},this._instance=t,this.Pp=!(null==(i=this._instance.persistence)||!i.props[Ur]),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:dn})),this.Fr=this.Op(),this.startIfEnabledOrStop()}Op(){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.Pp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Fr.capture_console_errors||this.Fr.capture_unhandled_errors||this.Fr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(dn.info("enabled"),this.Rp(),this.Bl(this.Cp)):this.Rp()}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",e=>{if(e)return dn.error("failed to load script",e);t()})}Rp(){var t,e,i;null==(t=this.Mp)||t.call(this),this.Mp=void 0,null==(e=this.Ep)||e.call(this),this.Ep=void 0,null==(i=this.Ap)||i.call(this),this.Ap=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Pp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ur]:this.Pp}),this.Fr=this.Op(),this.startIfEnabledOrStop())}}onConfigChange(){this.Fr=this.Op()}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 dn.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.Fp=[],this.Dp=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.Fp=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Lp=Lt(this.Np()),this.jp=new Nt(this.Lp)}onConfigChange(){this.Lp=Lt(this.Np()),this.jp.setConfig(this.Lp)}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.Fp=s,this._instance.persistence&&this._instance.persistence.register({[Hr]:this.Fp,[qr]:a})}}}get qp(){var t,e,i=!!this._instance.get_property(qr);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.Dp.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Lp.enabled)try{if(!p(t)||0===t.trim().length)return void Is.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.Bp(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&Is.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.jp.add(e({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){Is.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.zp(e)){if(this.Hp(e))return this.Up("Exception dropped: matched a suppression rule"),void Is.info("Skipping exception capture because a suppression rule matched");if(!this.qp&&this.Wp(e))return this.Up("Exception dropped: thrown by a browser extension"),void Is.info("Skipping exception capture because it was thrown by an extension");if(!this.qp&&this.Vp(e))return this.Up("Exception dropped: thrown by an injected browser script"),void Is.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Gp(e))return this.Up("Exception dropped: thrown by the PostHog SDK"),void Is.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Lp.enabled&&y(t.$exception_steps)?this.Qp(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.jp.clear(),n}catch(t){return $s(t)||Is.error("Failed to capture exception event. Dropping this exception.",t),void this.jp.clear()}}catch(t){return void($s(t)||Is.error("Failed to process exception event. Ignoring this exception.",t))}}Qp(t){try{var i=this.jp.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return Is.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Up(t){this.Lp.enabled&&this.jp.add({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}Bp(t){return v(t)?e({},t):{}}Np(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Hp(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.Fp.some(t=>{var i=t.values.map(t=>{var i=ts[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 Is.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Wp(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&&Ls.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(js)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&Ds.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(js))}))}Vp(t){return t.some(t=>{var e=t.value;return p(e)&&Ns.some(t=>e.includes(t))})}Gp(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}zp(t){return!y(t)&&h(t)}}},Ta={productTours:class{get Pc(){return this._instance.persistence}constructor(t){this.Jp=null,this.Zp=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.Pc&&this.Pc.register({[Gr]:!!e.productTours}),!Hn(this._instance))return!this.Jp&&y(null==(i=this.Pc)?void 0:i.props.ph_product_tours)||Un.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Jp)||r.stop(),this.Jp=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Jp&&Hn(this._instance)&&this.Bl(()=>this.Kp())}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",e=>{e?Un.error("Could not load product tours script",e):t()})}Kp(){var t;!this.Jp&&null!=(t=un.__PosthogExtensions__)&&t.generateProductTours&&(this.Jp=un.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.Zp)||e){var i=this.Pc;if(i){var r=i.props[Zr];if(h(r)&&!e)return this.Zp=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(Hn(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||Un.warn(n):Un.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.Zp=s,i&&i.register({[Zr]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Zp,{isLoaded:!0})}getActiveProductTours(t){y(this.Jp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Jp.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Jp)||e.showTourById(t)}previewTour(t){this.Jp?this.Jp.previewTour(t):this.Bl(()=>{var e;this.Kp(),null==(e=this.Jp)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Jp)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Jp)||t.nextStep()}previousStep(){var t;null==(t=this.Jp)||t.previousStep()}clearCache(){var t;this.Zp=null,null==(t=this.Pc)||t.unregister(Zr)}resetTour(t){var e;null==(e=this.Jp)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Jp)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Jp)||e.cancelPendingTour(t)}},featureFlags:Ms},Fa={siteApps:class{constructor(t){this._instance=t,this.Yp=0,this.Xp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}tg(t,e){if(e){var i=this.globalsForEvent(e);this.Xp.push(i),this.Xp.length>1e3&&(this.Xp=this.Xp.slice(10))}}get siteAppLoaders(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.tg.bind(this));this.eg=()=>{t(),this.Xp=[],this.eg=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}}ig(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)||(qn.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)||(qn.error("prepare_external_dependency_script returned null"),null):t}ng(){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==an?void 0:an.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Yp++,this.sg)return this.rg();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.ig(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.sg=()=>{h.forEach(t=>t()),this.sg=void 0},this.rg()}rg(){var t=!1;return()=>{var e;t||(t=!0,this.Yp--,0===this.Yp&&(null==(e=this.sg)||e.call(this)))}}og(t,e){void 0===e&&(e=!0);var i=this.ng();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.Xp.length&&(qn.info("Processing "+this.Xp.length+" events for site app with id "+t.id),this.Xp.forEach(t=>this.og(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.eg)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,qn.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.og(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){qn.error(Vn+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){qn.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}ag(){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)}lg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.og(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){qn.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.ag(),void this._instance.on("eventCaptured",t=>this.lg(t))):void qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.eg)||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;un["__$$ph_site_app_"+e]=n._instance,null==(t=un.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return qn.error(Vn+e,t)})};for(var o of s.siteApps)a()}else qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Pa={tracingHeaders:class{constructor(t){this._instance=t,this.ug=void 0,this.cg=void 0,this.hg=void 0,this.Cp=()=>{var t,e,i=this.dg();i?(f(this.ug)&&(this.ug=null==(t=un.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.cg)&&(this.cg=null==(e=un.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Rp()}}initialize(){this.startIfEnabledOrStop()}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",e=>{if(e)return Sn.error("failed to load script",e);t()})}vg(){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}dg(){var t=this.vg();return h(t)?(h(this.hg)?this.hg.splice(0,this.hg.length,...t):this.hg=[...t],t.length>0?this.hg:void 0):(h(this.hg)&&this.hg.splice(0),this.hg=t||void 0,this.hg)}Rp(){var t,e;null==(t=this.ug)||t.call(this),null==(e=this.cg)||e.call(this),this.ug=void 0,this.cg=void 0}startIfEnabledOrStop(){this.dg()?this.Bl(this.Cp):this.Rp()}}},Ra={surveys:class extends vs{constructor(t){super(new ms(t))}},featureFlags:Ms},Ca={toolbar:class{constructor(t){this.instance=t}fg(t){un.ph_toolbar_state=t}pg(){var t;return null!==(t=un.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),fi(this.instance.config))return!1;if(!rn||!an)return!1;t=null!=t?t:rn.location,i=null!=i?i:rn.history;try{if(!e){try{rn.localStorage.setItem("test","test"),rn.localStorage.removeItem("test")}catch(t){return!1}e=null==rn?void 0:rn.localStorage}var r,n=ys||bn(t.hash,"__posthog")||bn(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(bs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}gg(t){var e=un.ph_load_toolbar||un.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):_s.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==an||!an.getElementById("__POSTHOG_TOOLBAR__"));if(!rn||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(rn.localStorage.setItem(bs,JSON.stringify(e({},n,{source:void 0}))),2===this.pg())this.gg(n);else if(0===this.pg()){var s;this.fg(1),null==(s=un.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return _s.error("[Toolbar] Failed to load",t),void this.fg(0);this.fg(2),this.gg(n)}),di(rn,"turbolinks:load",()=>{this.fg(0),this.loadToolbar(n)})}return!0}mg(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)}}},Oa={experiments:class t{get Fr(){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.yg("retrieved web experiments from the server"),i.bg=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.bg&&(t.yg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.bg)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i._g(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.wg(a,i._instance)&&i.kg(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.yg(Bs);else if(!this.Fr.disable_web_experiments){if(y(this.bg))return this.bg=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.yg("applying feature flags",e),e.forEach(t=>{var e;if(this.bg&&null!=(e=this.bg)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.bg)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this._g(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=mn(null==e?void 0:e.search,"__experiment_id"),r=mn(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.yg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.Sg(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Fr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Fr.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.Fr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Sg(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.yg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.kg(n[0].name,i,n[0].variants[i].transforms))}_g(e,i){var r=e.variants[i];t.xg(r,this._instance)?this.kg(e.name,i,r.transforms):t.yg("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static wg(e,i){return!y(e.conditions)&&t.xg(e,i)&&t.$g(e)}static xg(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=pi(i,n.href);return null==(s=e.conditions)||!s.url||Hs[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==rn?void 0:rn.location}static $g(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(!an)return{};var r,n,s,a=e?[...En,...i||[]]:[],o=(r=yn(an.URL,a,Tn),n=An.concat(t||[]),s={},hi(n,function(t){var e=mn(r,t);s[t]=e||null}),s);return ci(function(){var t={};return hi(Fn,function(e){var i=(t=>{if(an){try{for(var e=t+"=",i=an.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 yg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];oi.info("[WebExperiments] "+t,i)}static Cg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];oi.warn("[WebExperiments] "+t,i)}static Tg(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.Tg(e)})}kg(i,r,n){this._is_bot()?t.yg(Bs):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.yg("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.Cg("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!=ds?ds:ds=zs(),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({},Us,{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({},Us,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.Tg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.yg("Control variants leave the page unmodified.")}_is_bot(){return sn&&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}(sn,this.Fr.custom_blocked_useragents):void 0}},featureFlags:Ms},Ma={conversations:class{constructor(t){this._instance=t,this.Ig=void 0,this._conversationsManager=null,this.Mg=!1,this.ie=null,this.Eg=!1,this.Ag=0,this.Rg=null,this.Pg=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.Rg=null;else if(this.Og=t.ok,t.ok){var e=t.config.conversations;y(e)?this.Rg=null:(_(e)?this.Ig=e:(this.Ig=e.enabled,this.ie=e),this.Ig||(this.Rg=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Ag++,this.Ig=void 0,this.ie=null,this.Og=void 0,this.Eg=!1,this.Rg=null}loadIfEnabled(){if(!(this._conversationsManager||this.Mg||this._instance.config.disable_conversations||fi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==un?void 0:un.__PosthogExtensions__;if(t&&!f(this.Ig)&&this.Ig)if(this.ie&&this.ie.token){this.Mg=!0;try{var e=t.initConversations;if(e)return this.Fg(e),void(this.Mg=!1);var i=t.loadExternalDependency;if(!i)return void this.Dg(Dr);var r=this.Ag;i(this._instance,"conversations",e=>{if(r!==this.Ag)return this.Mg=!1,void this.loadIfEnabled();e||!t.initConversations?this.Dg("Could not load conversations script",e):this.Fg(t.initConversations),this.Mg=!1})}catch(t){this.Dg("Error initializing conversations",t),this.Mg=!1}}else qs.error("Conversations enabled but missing token in remote config.")}}Fg(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.Eg=!1,qs.info("Conversations loaded successfully")}catch(t){return void this.Dg("Error completing conversations initialization",t)}this.Pg&&this._conversationsManager.setTheme(this.Pg),this.Lg()}else qs.error("Cannot complete initialization: remote config is null")}Lg(){var t=this.Rg;this.Rg=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}Dg(t,e){qs.error(t,e),this._conversationsManager=null,this.Mg=!1,this.Eg=!0}show(){this._conversationsManager?this._conversationsManager.show():qs.warn("Conversations not loaded yet.")}hide(){"open"===this.Rg&&(this.Rg=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.Rg=null,this._conversationsManager.open()):this.Rg="open"}close(){this._conversationsManager?(this.Rg=null,this._conversationsManager.close()):this.Rg="close"}setTheme(t){var i,r;this.Pg=e({},this.Pg,t,{dark:e({},null==(i=this.Pg)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.Ig&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":fi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Og?"remote_config_failed":f(this.Ig)?this.Og?"disabled_in_project":"remote_config_pending":this.Ig?y(this.ie)||!this.ie.token?"missing_token":null!=un&&un.__PosthogExtensions__?this.Mg?"initializing":this.Eg?"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):(qs.warn(Vs),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(qs.warn(Vs),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(qs.warn(Vs),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(qs.warn(Vs),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(qs.warn(Vs),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(qs.warn(Vs),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(qs.warn(Vs),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()}}},$a={logs:class extends Qs{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=un._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!=un&&null!=(e=un.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(un.location.href):un.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.df()}get cf(){return this._instance.__loaded}hf(){var t=li("[logs]"),e=null==un?void 0:un.__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(Dr)}else t.error("PostHog Extensions not found.")}}},Ia={metrics:class{constructor(t){this._instance=t,this.R=li("[metrics]"),this.Ti=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.Ti){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.Ng?this.Ng=(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=aa(t,i),n=oa(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.Ng&&(this.Ng(),this.Ng=void 0)}}pf(){var t;if(!this.Ti){var e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.lf&&this.gf===i||(null==(e=this.lf)||e.reset(),this.gf=i,this.lf=new ti(this.ff(),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.lf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.pf())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.pf())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.pf())||r.histogram(t,e,i)}flush(t){if(!this.lf)return Promise.resolve();if(t){var e=this.lf.drainWindow();return e&&this.To(e,t),Promise.resolve()}return this.lf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.lf)||t.reset()}dispose(){var t,e;this.Ti=!0,null==(t=this.Ng)||t.call(this),this.Ng=void 0,null==(e=this.lf)||e.reset()}ff(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},To:t=>e.To(t),getLibraryId:()=>fs.LIB_NAME,getLibraryVersion:()=>fs.LIB_VERSION}}To(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.jg(),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)})}}))})}jg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},ja={webMCP:class{constructor(t){this._instance=t,this.qg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.qg){var t=null==an?void 0:an.modelContext;if(t&&c(t.registerTool)){var e=la.get(t);if(e)return e.instances.add(this._instance),void(this.qg=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;xn(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.Bg(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(la.set(t,i),this.qg=!0)}}}Bg(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=>ua.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:fa(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>da(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:fa(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:fa(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=va(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?pa(t.context,2048,!0):void 0,n=i.model?pa(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&&da(r,"context"),s=i.model&&da(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.zg(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=ga(t)?{error:t,errorResult:!0}:void 0;return n.zg(i,a,s,e,f),t},t=>{throw n.zg(i,a,s,{error:t,errorResult:!1},f),t});var g=ga(c)?{error:c,errorResult:!0}:void 0;return n.zg(i,a,s,g,f),c}}),a}zg(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=va(l.config.capture_webmcp);if(h){n&&!a&&(a=wa(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==on?void 0:on.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:ba(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==on?void 0:on.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}}},Da=/* @__PURE__ */xa(Sa,ka,Ea,Aa,Ta,Fa,Ra,Pa,Ca,Oa,Ma,$a,Ia,ja),La=Sa,Na=ka,za=Ea,Ba=Aa,Ua=Ta,Ha=Fa,qa=Ra,Va=Pa,Wa=Ca,Ga=Oa,Ka=Ma,Ja=$a,Xa=Ia,Ya=ja;export{Da as AllExtensions,za as AnalyticsExtensions,Ka as ConversationsExtensions,Ba as ErrorTrackingExtensions,Ga as ExperimentsExtensions,La as FeatureFlagsExtensions,Ja as LogsExtensions,Xa as MetricsExtensions,Ua as ProductToursExtensions,Na as SessionReplayExtensions,Ha as SiteAppsExtensions,qa as SurveysExtensions,Wa as ToolbarExtensions,Va as TracingExtensions,Ya 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.yr(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.br(t))&&void 0!==r?r:n.stack,synthetic:!0})}yr(t){return p(t.message)&&t.message.length>0}br(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.Fr=Lt(t)}setConfig(t){this.Fr=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.Fr.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.Fr.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=/\b\d(?:[ ./-]?\d){12,}\b/g,ve=/\d+/g,de=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,fe=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function pe(t){return function(t){return Yt.test(t)}(t)||ne.test(t)||se.test(t)}function ge(t){return t.split("&",129).length>128}function me(t,e,i){return pe(t)||e.includes(";")&&function(t){return t.split(";").some(t=>pe(t.split("=",1)[0]))}(e)?qt:te.test(e)?i?Se(e,{allowNestedUrls:!1,stripPunctuation:!0}):qt:e}function ye(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=ke(a),u=ke(o);r||(r=l!==a||u!==o);var h=me(l,u,e);r||(r=h!==u),n=pe(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function be(t,e){if(!t.includes("="))return{value:_e(t,e),lastFieldSensitive:!1};var i=ye(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function _e(t,e){return e?Se(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function we(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 xe(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(ge(o)||ge(u.head)||ge(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=ye(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=be(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":qt,lastFieldSensitive:!0}:be(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?ke(r.toString()):s)+(g.lastFieldSensitive?"":a)}function Se(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];we(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return xe(t,i);var n="",s=0;for(var a of r)n+=xe(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+xe(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function ke(t){return t.replace(Xt,qt)}function Ee(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 Se(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(ae," ");return(e=(e=(e=(e=(e=(e=e.replace(oe,qt)).replace(le,qt)).replace(ue,"$1"+qt)).replace(ce,Te)).replace(he,qt)).replace(de,"$1"+qt)).replace(fe,"$1"+qt)}(ke(t))),e)}function Ae(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 Te(t){for(var e=[],i=ve.exec(t);null!==i;i=ve.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&&Ae(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 Fe={}.propertyIsEnumerable;function Pe(t,e){try{return Oe(t,e,{ancestors:/* @__PURE__ */new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Re(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 Re(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:Ce(t,e,i,r+1)}}:{kvlistValue:{values:Oe(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:B(String(t))}}function Ce(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(Re(o,e,i,r))}catch(t){n.push({stringValue:z})}return t.length>a&&n.push({stringValue:N}),n}function Oe(t,e,i,r){var n=[];for(var s in t)if(Fe.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:Re(a,e,i,r)})}catch(t){n.push({key:B(s),value:{stringValue:z}})}}return n}function Me(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 $e=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Ie(t,e){var i=U({},t),r={};for(var n of $e)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Pe(i,e),...Pe(r,e)]}var je={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 De={text:"INFO",number:9},Le={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:De,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function Ne(t){try{return B(String(t))}catch(t){return z}}function ze(t,i,r,n){var s,a=Le[t.level||"info"]||De,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:Ne(t.body)},attributes:Pe(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 Be(t,e,i){return Me(t,e,i)}function Ue(t,e,i,r){return{resourceLogs:[{resource:{attributes:Ie(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var He=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 qe(){return.75+.5*Math.random()}function Ve(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 We=class{constructor(t,e,i,r,n,s,a){var o;void 0===s&&(s=()=>Promise.resolve()),this._instance=t,this.Fr=e,this.R=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=new He(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new K,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=e.maxBufferSize,this.Is=Math.max(null!==(o=e.maxQueueSize)&&void 0!==o?o:e.maxBufferSize,e.maxBufferSize),this.Ms=e.flushIntervalMs,this.Es=e.maxBatchRecordsPerPost,this.As=e.rateCapWindowMs,this.Rs=e.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(n.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Fr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.Ps()&&this.Os():this.gs()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Fs(t);if(null!==r)if(r.body){if(this.Ds()){var n={record:ze(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.Ls(n))}}else this.R.info("Log was rejected in beforeSend function")}}Fs(t){var e=this.Fr.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}Ds(){if(void 0===this.Rs)return!0;var t=Date.now(),e=t-this.xs;return this.As>e&&e>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.R.warn("captureLog dropping logs: exceeded "+this.Rs+" logs per "+this.As+"ms"),this.Cs=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return r(function*(){var e;t.ps.clear();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,l=t._s;t.bs=0;var u=Math.min(i.length,t.Es),h=i.slice(0,u),c=Ue(h.map(t=>t.record),t.js(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.qs(c);if(t._s!==l)return;if("too-large"===v.kind&&h.length>1)t.Es=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.Es);else{if(t.ws.record(v),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.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.Fr.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Fr.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}})()}Bs(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e.bs),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}js(){return Be(this.Fr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Is>i.length||(i.shift(),this.bs++,this.R.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Ts>i.length||this.ws.isOpen()?this.Os():this.gs()}}Os(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(Ve(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}Ps(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.ps.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(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=qe(),this.R.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ps()&&this.ps.armNoEarlierThan(this.zs())})}},Ge=/^[0-9a-f]+$/;function Ke(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Ge.test(t)}var Je=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Xe="00",Ye=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ze(t){return String(t)+"000000"}function Qe(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 ti=class{constructor(t,e,i){this._instance=t,this.Fr=e,this.R=i,this.Hs=/* @__PURE__ */new Map,this.ps=new He(()=>this.flush().catch(t=>{this.R.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=/* @__PURE__ */new Map,this.Vs=/* @__PURE__ */new Set,this.Gs=/* @__PURE__ */new Map,this.Qs=/* @__PURE__ */new Set,this.Js=!1,this.ws=new K,this.ks=0,this.Ss=1,this.Zs=0}count(t,e,i){void 0===e&&(e=1),this.Ks({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.Ks({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.Ks({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.ys,i=/* @__PURE__ */function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.Ys()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.ys===i&&(this.ys=null)});return this.ys=i,i}drainWindow(){if(0===this.Hs.size)return null;var t=this.Hs;return this.Xs(),this._o(t)}reset(){this.Zs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.ys=null,this.Xs(),this.Gs=/* @__PURE__ */new Map,this.Js=!1}Xs(){this.Hs=/* @__PURE__ */new Map,this.Us=!1,this.Ws=/* @__PURE__ */new Map,this.Vs=/* @__PURE__ */new Set,this.Qs=/* @__PURE__ */new Set}Ks(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Fs(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=Qe(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.Hs.get(n);if((a||this.ko())&&("histogram"!==i.type||(s=this.So(i.name,i.unit,i.bounds)))){a||(a={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now(),hist:s&&ii(s)},this.Hs.set(n,a));var o=this.Ws.get(i.name);void 0===o?this.Ws.set(i.name,i.type):o===i.type||this.Vs.has(i.name)||(this.Vs.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.xo(a,i.value);var l=this.$o();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Os()}}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")}}$o(){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=Je.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 Ke(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Ke(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":Xe)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}ko(){return this.Fr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.R.warn("Metric series cap reached ("+this.Fr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}So(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=Qe("histogram",t,e,void 0),n=this.Gs.get(r);if(n)return this.Co(t,r,n,i),n;if(this.Gs.size>=this.Fr.maxSeriesPerFlush){if(this.Js||(this.Js=!0,this.R.warn("Histogram bounds limit reached ("+this.Fr.maxSeriesPerFlush+" distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.")),i&&!ei(i,Ye))return;return Ye}var s=i?i.slice():Ye;return this.Gs.set(r,s),s}this.R.warn("Dropping histogram '"+t+"': bounds must be a non-empty array of finite, strictly increasing numbers")}Co(t,e,i,r){ei(i,null!=r?r:Ye)||this.Qs.has(e)||(this.Qs.add(e),this.R.warn("Histogram '"+t+"' already uses the bounds ["+i.join(", ")+"]; samples that pass different bounds are recorded in those buckets."))}xo(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}}Fs(t){var e=this.Fr.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}Os(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Ve(this.Fr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Ys(){var t=this;return r(function*(){if(t.ps.clear(),0!==t.Hs.size){var e=t.Hs;t.Xs();var i=t.Zs,r=yield t._instance.To(t._o(e));if(i===t.Zs)switch(t.ws.record(r),"retry-later"===r.kind?(t.ks++,t.Ss=qe()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),r.kind){case"ok":return;case"retry-later":return t.Io(e),void t.ps.armNoEarlierThan(t.zs());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)}}})()}_o(t){return e=this.Mo(t),i=function(t,e,i){return Me(t,e,i)}(this.Fr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ie(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}Mo(t){var i=Ze(Date.now()),r=/* @__PURE__ */new Map;for(var n of t.values()){var s,a=Qe(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=Pe(null!==(s=n.attributes)&&void 0!==s?s:{},this.R),u=Ze(n.windowStartMs),h=ri(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())}Io(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Hs.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.ko()&&this.Hs.set(s,a)}}};function ei(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 ii(t){return{bounds:t,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(t.length+1).fill(0)}}function ri(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:Ze(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var ni="0.10.7",si={DEBUG:!1,LIB_VERSION:ni,LIB_NAME:"browser-common",JS_SDK_VERSION:ni},ai=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&&(si.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)=>ai(t+" "+e,i)};return r},oi=/* @__PURE__ */ai("[PostHog.js]"),li=(t,e)=>oi.createLogger(t,e);function ui(t,e){h(t)&&t.forEach(e)}function hi(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 ci=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 vi(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 di(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 fi(t){return"ph_toolbar_internal"===t.name}function pi(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 oi.error("Error in get_current_url, falling back to window.location.href",t),e}}var gi="$early_access_features",mi="$active_feature_flags",yi="$feature_flag_details",bi="$feature_flag_errors",_i="$feature_flag_evaluated_at",wi="$feature_flag_request_id",xi="$minimal_flag_called_events",Si="$enabled_feature_flags",ki="$stored_group_properties",Ei="$stored_person_properties",Ai="$flag_call_reported",Ti="$flag_call_reported_session_id",Fi="$feature_flag_payloads",Pi="$override_feature_flags",Ri="$override_feature_flag_payloads",Ci="visibilitychange",Oi="$autocapture_disabled_server_side";function Mi(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function $i(t){return!!t&&1===t.nodeType}function Ii(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ji(t){return!!t&&3===t.nodeType}function Di(t){return!!t&&11===t.nodeType&&$i(t.host)}function Li(t){return t?a(t).split(/\s+/):[]}function Ni(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:pi(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function zi(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 Li(e)}function Bi(t){return y(t)?null:a(t).split(/(\s+)/).filter(t=>mr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ui(t){var e="";return lr(t)&&!ur(t)&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;ji(t)&&t.textContent&&(e+=null!==(i=Bi(t.textContent))&&void 0!==i?i:"")}),a(e)}function Hi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var qi=["a","button","form","input","select","textarea","label"];function Vi(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 Wi(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Vi(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Gi(t){var e=t.parentNode;return!(!e||!$i(e))&&e}var Ki=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ji=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Xi=/* @__PURE__ */(()=>[...Ji,"+","-","−","–"])(),Yi=/* @__PURE__ */(()=>Xi.length+10)(),Zi=["button","a","input","select","textarea","label"],Qi=["button","link","tab","menuitem","option"],tr=(t,e)=>/[a-z0-9]/i.test(e)?s(Xi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,er=t=>s(Zi,t.tagName.toLowerCase())||s(Qi,(t.getAttribute("role")||"").toLowerCase());function ir(t){var e="",i="",r=t=>{$i(t)&&lr(t)&&!ur(t)&&(e+=" "+Ui(t),i=i||t.getAttribute("aria-label")||"",hi(t.childNodes,r))};r(t);var n=(mr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var rr=[".ph-no-rageclick",".ph-no-capture"],nr=["","text","search","email","password","url","tel","number"];function sr(t,e){if(!(typeof window>"u"?void 0:window)||ar(t))return!1;var i,r,n,a,o;if(_(e)?(i=!!e&&rr,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:rr,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||!$i(t))&&(!!Ii(t,"textarea")||(Ii(t,"input")?s(nr,(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=or(t,!1).targetElementList;return!(r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Ji;else{if(!h(t))return!1;if(t.length>Yi)return oi.error("[PostHog] content_ignorelist array cannot exceed "+Yi+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>tr(r,t)||tr(n,t))}(r,function(t,e){for(var i of e)if(er(i))return ir(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=ir(r);if(s.safeText||s.ariaLabel)return s}return ir(t)}(t,l))||Wi(l,i))}var ar=t=>!t||Ii(t,"html")||!$i(t),or=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ar(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,n=[t],s=t;s.parentNode&&!Ii(s,"body");)if(Di(s.parentNode))n.push(s.parentNode.host),s=s.parentNode.host;else{var a=Gi(s);if(!a)break;if(e||qi.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 lr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r.parentNode&&!Ii(r,"body");r=r.parentNode){if(i++>=1e3||e.has(r))return!1;e.add(r);var n=zi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!1}if(s(zi(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 ur(t){return!!(Ii(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ii(t,"select")||Ii(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var hr=/* @__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}))$"),cr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,vr=[16,15,14,13],dr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),fr=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),pr=/[0-9A-Za-z_]/;function gr(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 mr(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?hr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(cr.lastIndex=0;e=cr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of vr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(hr.test(o)&&gr(o))return!0}}}return!1}(t))return!1;if(e?dr.test(t):function(t){var e;for(fr.lastIndex=0;e=fr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&pr.test(i)&&pr.test(r)))return!0}return!1}(t))return!1}return!0}function yr(t){var e=Ui(t);return mr(e=(e+" "+br(t)).trim())?e:""}function br(t){var e="";return t&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Ui(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+br(t)).trim())}catch(t){oi.error("[AutoCapture]",t)}}),e}function _r(t){return t.replace(/"|\\"/g,'\\"')}function wr(t){var e=t.attr__class;if(e)return h(e)?e:Li(e)}var xr=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}},Sr=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)},kr=()=>typeof window>"u"?void 0:window,Er=()=>typeof document>"u"?void 0:document,Ar="$copy_autocapture",Tr=["password","hidden","file","checkbox","button","submit","reset","image"],Fr=/* @__PURE__ */li("[AutoCapture]");function Pr(t,e){return e.length>t?e.slice(0,t)+"...":e}function Rr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!$i(e));return e}function Cr(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!$i(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;g.parentNode&&!Ii(g,"body")&&1e3>d.length;)if(Di(g.parentNode)){var m=g.parentNode.host;if(f.has(m))break;f.add(m),d.push(m),g=m}else{if(!$i(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=>Ii(t,"button")||Ii(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!lr(t)||ur(t)));var b,_,w,x=[],S={},k=!1,E=!1;if(hi(d,t=>{var e=lr(t);if(Ii(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");k=!!(e&&i&&mr(i))&&(v?J(i):i)}s(zi(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};qi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Pr(1024,yr(t)):Pr(1024,Ui(t)));var o=zi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),hi(t.attributes,function(i){var s;if((!ur(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&mr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Li(o).join(" ")),a["attr__"+i.name]=Pr(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=Rr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),hi(function(t){if(!lr(t))return{};var e={};return hi(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&&mr(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=Ii(t,"a")||Ii(t,"button")?yr(t):Ui(t)),k){var A,T;x[0].attr__href=k;var F=null==(A=Sr(k))?void 0:A.host,P=null==(T=kr())||null==(T=T.location)?void 0:T.host;F&&P&&F!==P&&(b=k)}return{props:ci((_=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 vi(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[_r(t[0].toString())]=_r(e.toString())}),(n+=":")+vi(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:wr(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return vi(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 Or=class{vl(){this.fl=void 0,clearTimeout(this.pl),this.pl=void 0}gl(t){var e;if(!lr(t))return!0;for(var i,r=null!==(e=this.ml().css_selector_ignorelist)&&void 0!==e?e:Ki,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=zi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||ur(t)||r.some(e=>Vi(t,e)))return{v:!0};var i=a.parentNode;a=Di(i)?i.host:i&&$i(i)?i:null};a;)if(i=o())return i.v;return!1}yl(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.fl;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.vl():"pointerup"===t.type&&(e.released=!0,this.pl=setTimeout(()=>this.vl(),0)))}else{var i;this.vl();var r=Hi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&$i(r)&&(this.fl={target:r,excluded:this.gl(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.Fa)?void 0:i.distinctId})}else this.vl()}bl(t){var e,i=this.fl;this.vl();var r=Hi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.Fa)?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&&(Ii(r,"html")||Ii(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.ml().css_selector_ignorelist)&&void 0!==n?n:Ki;return[r,null==(a=Er())?void 0:a.documentElement,null==(o=Er())?void 0:o.body].some(t=>{if(!t)return!1;var e=zi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!lr(t)||ur(t)||l.some(e=>Vi(t,e))})?null:i.target}}constructor(t){this.Na=t,this.name="autocapture",this._l=!1,this.wl=null,this.kl=!1,this.Sl=/* @__PURE__ */new Map,this.xl=!1,this.Fr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ti=!1,this.Na.refresh(this.Fr),this.rageclicks=new xr(this.Fr.rageclick),this.$l=null}setup(t){this.Cl(),this.Fa=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ti?e.dispose():(this.Za=e,this.startIfEnabled())}dispose(){var t;this.Ti||(this.Ti=!0,this.Fa=void 0,null==(t=this.Za)||t.dispose(),this.Za=void 0,this.Sl.clear(),this.$l=null,this.Tl())}ml(){return this.Na.refresh(this.Fr),this.Fr}Cl(){var t,e;return this.ml(),this.Fr.url_allowlist=null==(t=this.Fr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Fr.url_ignorelist=null==(e=this.Fr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Fr}Il(){var t=kr(),e=Er();if(this.isBrowserSupported()){if(t&&e){this.Ml=t,this.El=e;var i=this.Al=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.vl();if(0===e.type.indexOf("pointer"))return void this.yl(e);var i="click"===e.type?this.bl(e):void 0;if(m(i))return;this.Rl(e,"$autocapture",i)}catch(t){Fr.error("Failed to capture event",t)}};if(di(t,"blur",i),di(e,"submit",i,{capture:!0}),di(e,"change",i,{capture:!0}),di(e,"click",i,{capture:!0}),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{di(e,t,i,{capture:!0})}),this.ml().capture_copied_text){var r=this.Pl=e=>{e=e||(null==t?void 0:t.event);try{this.Rl(e,Ar)}catch(t){Fr.error("Failed to capture clipboard event",t)}};di(e,"copy",r,{capture:!0}),di(e,"cut",r,{capture:!0}),di(e,"paste",r,{capture:!0})}}}else Fr.info("Disabling Automatic Event Collection because this browser is not supported")}Tl(){var t=this.Ml,e=this.El;this.vl(),this.Al&&(null==t||t.removeEventListener("blur",this.Al),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.Al,!0)}),null==e||e.removeEventListener("submit",this.Al,!0),null==e||e.removeEventListener("change",this.Al,!0),null==e||e.removeEventListener("click",this.Al,!0),this.Al=void 0),this.Pl&&(null==e||e.removeEventListener("copy",this.Pl,!0),null==e||e.removeEventListener("cut",this.Pl,!0),null==e||e.removeEventListener("paste",this.Pl,!0),this.Pl=void 0),this.Ml=void 0,this.El=void 0,this._l=!1}startIfEnabled(){this.isEnabled||this.vl(),!this.Ti&&this.Fa&&this.isEnabled&&!this._l&&(this.Il(),this._l=!0)}onRemoteConfig(t){if(!this.Ti)if(this.kl=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.xl=e.elementsChainAsString);var i,r=e.autocapture_opt_out;_(r)&&(null==(i=this.Fa)||i.kv.set(Oi,r),this.wl=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Ti){t.size?this.Sl.set(e,new Set(t)):this.Sl.delete(e);var i=/* @__PURE__ */new Set;this.Sl.forEach(t=>{t.forEach(t=>i.add(t))}),this.$l=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.$l)||i.forEach(i=>{var n;null==(n=Er())||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.Ti)return!1;var i=null==(t=this.Fa)?void 0:t.kv.get(Oi),r=this.wl,n=this.ml();if(!n.remoteRequestsDisabled&&!this.kl)return!1;var s=n.remoteRequestsDisabled&&!this.kl;if(m(r)&&!_(i)&&!s)return!1;var a=null!==(e=this.wl)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Rl(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Hi(t);ji(n)&&(n=n.parentNode||null);var a,o=this.Cl();"$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())&&sr(n,o.rageclick)&&this.Rl(t,"$rageclick",r);var l,u=i===Ar,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||ar(t))return!1;if(null!=i&&i.url_allowlist&&!Ni(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ni(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=or(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(!Wi(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Wi(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Ki))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&&(qi.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=Cr(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.xl,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===Ar){var y=t.type||"clipboard";if("paste"!==y){var b,_,w=null==(b=kr())||null==(b=b.getSelection())?void 0:b.toString(),x=Bi(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&&(Ii(l=n,"input")?!s(Tr,l.type):Ii(l,"textarea")||Ii(l,"select")&&!l.multiple)&&function(t,e){var i;if(!lr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Ki,n=/* @__PURE__ */new Set,a=t;Ii(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=zi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Vi(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=Di(i)?i.host:i&&$i(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=>Vi(n,t))}catch(t){Fr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.Fa)||d.capture(i,g),!0}}else this.vl()}isBrowserSupported(){var t;return c(null==(t=Er())?void 0:t.querySelectorAll)}},Mr=["[data-ph-capture-value]"],$r=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:Mr}},Ir="$surveys",jr="$surveys_loaded_at",Dr="PostHog loadExternalDependency extension not found.",Lr="$surveys_activated",Nr="$surveys_activated_session",zr="$surveys_activated_timestamps",Br="$heatmaps_enabled_server_side",Ur="$exception_capture_enabled_server_side",Hr="$error_tracking_suppression_rules",qr="$error_tracking_capture_extension_exceptions",Vr="$web_vitals_enabled_server_side",Wr="$dead_clicks_enabled_server_side",Gr="$product_tours_enabled_server_side",Kr="$web_vitals_allowed_metrics",Jr="$session_recording_remote_config",Xr="$replay_override_sampling",Yr="$replay_override_linked_flag",Zr="ph_product_tours",Qr="$sdk_debug_recording_script_not_loaded",tn="$sdk_debug_replay_stale_config",en="beforeunload",rn="u">typeof window?window:void 0,nn="u">typeof globalThis?globalThis:rn,sn=null==nn?void 0:nn.navigator,an=null==nn?void 0:nn.document,on=null==nn?void 0:nn.location;null!=nn&&nn.XMLHttpRequest&&new nn.XMLHttpRequest;var ln="undefined"!=typeof globalThis?globalThis:rn;ln&&"undefined"==typeof self&&(ln.self=ln),ln&&"undefined"==typeof File&&(ln.File=function(){});var un=null!=rn?rn:{},hn=/* @__PURE__ */li("[Dead Clicks]"),cn=()=>!0,vn=class{get lazyLoadedDeadClicksAutocapture(){return this.ql}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({[Wr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Bl(()=>{this.zl()}):this.stop()}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",e=>{e?hn.error("failed to load script",e):t()})}zl(){var t;if(an){if(!this.ql&&null!=(t=un.__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.ql=un.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.ql.start(an),hn.info("starting...")}}else hn.error("`document` not found. Cannot start.")}stop(){this.ql&&(this.ql.stop(),this.ql=void 0,hn.info("stopping..."))}},dn=/* @__PURE__ */li("[ExceptionAutocapture]"),fn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},pn=(t,e)=>t>=e&&fn(),gn=(t,e,i,r)=>{if(0===t){if(fn()){var n=e+1;return n===i&&r(),n}return e}return 0},mn=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){oi.error("Skipping decoding for malformed query param: "+a)}return a},yn=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},bn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},_n=()=>{},wn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function xn(t,e,i){try{if(!(e in t))return _n;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=wn(i);s;){if(s.next===n)return void(s.next=r.next);s=wn(i=s.next)}else t[e]=r.next}}catch(t){return _n}}var Sn=/* @__PURE__ */li("[TracingHeaders]");function kn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var En=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],An=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...En])(),Tn="<masked>",Fn=["li_fat_id"];var Pn=/* @__PURE__ */li("[Web Vitals]"),Rn=9e5,Cn=["CLS","FCP","INP","LCP"],On=["INP","LCP"],Mn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],$n=/* @__PURE__ */li("[RemoteConfig]"),In=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}rc(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}oc(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 $n.info("Using preloaded remote config",this.remoteConfig),void this.ac(this.remoteConfig);if(this._instance._shouldDisableFlags())return void $n.warn("Remote config is disabled. Falling back to local config.");this.rc(t=>{if(!t)return $n.info("No config found after loading remote JS config. Falling back to JSON."),void this.oc(t=>{this.ac(t.json,t)});this.ac(t)})}catch(t){$n.error("Error loading remote config",t),this.ac()}}ac(t,e){!t&&e&&(0===e.statusCode?e.error||$n.warn("Failed to fetch remote config from PostHog."):$n.error("Failed to fetch remote config from PostHog."));try{this._instance.ac(t?{ok:!0,config:t}:{ok:!1})}catch(t){$n.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){$n.error("Error loading feature flags",t)}}},jn="disabled",Dn="lazy_loading",Ln=/* @__PURE__ */li("[SessionRecording]"),Nn=[Qr,tn,"$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"],zn=/* @__PURE__ */li("[Heatmaps]");function Bn(t){return v(t)&&"clientX"in t&&"clientY"in t&&b(t.clientX)&&b(t.clientY)}var Un=/* @__PURE__ */li("[Product Tours]"),Hn=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Gr))},qn=/* @__PURE__ */li("[SiteApps]"),Vn="Error while initializing PostHog app with config id ",Wn="events",Gn="cancelEvents",Kn="survey shown",Jn="survey dismissed",Xn="survey sent";function Yn(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var Zn=(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}},Qn=t=>t.toLowerCase(),ts={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=>Zn(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!Zn(e,t))),icontains:(t,e)=>e.map(Qn).some(e=>t.map(Qn).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(Qn).every(e=>t.map(Qn).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 es(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=ts[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var is=/* @__PURE__ */li("[Surveys]"),rs=["popover","widget","api"],ns=class{on(t,e){return this.Eo[t]||(this.Eo[t]=[]),this.Eo[t].push(e),()=>{this.Eo[t]=this.Eo[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.Eo[t]||[])i(e);for(var r of this.Eo["*"]||[])r(t,e)}constructor(){this.Eo={}}};function ss(t,e,i){if(y(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}var as=class{constructor(t){this.$i=t,this.Ao=/* @__PURE__ */new Set,this.Ro=/* @__PURE__ */new Set,this.Po=new ns,this.Oo=(t,e)=>this.Fo(t,e)&&this.Do(t,e)&&this.Lo(t,e)&&this.No(t,e),this.Fo=(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.$i)?void 0:t.subscribeCapture)||(this.jo=null==(e=this.$i)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.jo)||t.call(this),this.jo=void 0,null==(e=this.$i)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.Po=new ns}register(t){var e,i;if(!f(null==(e=this.$i)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.Ao.add(t),null==(e=t.steps)||e.forEach(t=>{this.Ro.add((null==t?void 0:t.event)||"")})}),null!=(i=this.$i)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.Ao.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.$i.setElementSelectors(r,this)}}replace(t){this.Ao.clear(),this.Ro.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.Ro.has(t)||this.Ro.has(e.event))&&this.Ao.forEach(t=>{this.qo(e,t)&&this.Po.emit("actionCaptured",t.name)})}Bo(t){this.onAction("actionCaptured",e=>t(e))}qo(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Oo(t,i))return!0;return!1}onAction(t,e){return this.Po.on(t,e)}Do(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.$i)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!ss(r,e.url,e.url_matching||"contains"))return!1}return!0}Lo(t,e){return!!this.zo(t,e)&&!!this.Ho(t,e)&&!!this.Uo(t,e)}zo(t,e){var i;if(null==e||!e.href)return!0;var r=this.Wo(t);if(r.length>0)return r.some(t=>ss(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&ss((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Ho(t,e){var i;if(null==e||!e.text)return!0;var r=this.Wo(t);if(r.length>0)return r.some(t=>ss(t.text,e.text,e.text_matching||"exact")||ss(t.$el_text,e.text,e.text_matching||"exact"));var n,s,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(n=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!y(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),s=e.text,a=e.text_matching||"exact",n.some(t=>ss(t,s,a)))}Uo(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}Wo(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}No(t,e){return null==e||!e.properties||0===e.properties.length||es(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)}},os=class{constructor(t,e){this.Vo=e,this.Go=[],this.$i=t,this.Qo=/* @__PURE__ */new Map,this.Jo=/* @__PURE__ */new Map,this.Zo=/* @__PURE__ */new Map}Ko(){var t,e;this.Yo=null==(t=(e=this.$i).subscribeSession)?void 0:t.call(e,t=>this.Xo(t))}ta(t){return!1}ea(){return null}ia(t){}na(){}sa(t,e){return!!t&&es(t.propertyFilters,null==e?void 0:e.properties)}ra(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}oa(t,e,i){var r=(i===Wn?this.Qo:this.Jo).get(t),n=[];return this.aa(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.sa(s,e)})}register(t){this.la(t,!1)}replace(t){this.la(t,!0)}la(t,e){f(this.$i.subscribeCapture)||(this.ua(t,e),this.ca(t,e))}ca(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.Zo.clear(),0!==i.length){this.ha||(this.ha=new as(this.$i),this.ha.init(),this.ha.Bo(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.Zo.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.Zo.set(e.name,n)}})}),e?this.ha.replace(r):this.ha.register(r)}else{var n;e&&(null==(n=this.ha)||n.replace([]))}}da(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)})}ua(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.ra(t,Wn),l=this.ra(t,Gn);e?(this.Qo=o,this.Jo=l):(this.da(this.Qo,o),this.da(this.Jo,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.jo)&&void 0!==i||(this.jo=null==(r=(n=this.$i).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.va(),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.fa(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.pa([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.ga(s),void this.ma([s])}if(this.Jo.has(t)){var o=this.oa(t,e,Gn);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.pa(o.map(t=>t.id)),o.forEach(t=>this.ya(t.id)))}if(this.Qo.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.Qo.get(t)});var l=this.oa(t,e,Wn);this.ba(l.map(t=>t.id))}}onAction(t){this.Zo.has(t)&&this.ba(this.Zo.get(t)||[])}ba(t){if(0!==t.length){var e=!!this.$i.getSessionId(),i=[];for(var r of t)e&&this.ta(r)?this.ga(r)&&this._a(r):i.push(r);i.length>0&&(this.Go=[.../* @__PURE__ */new Set([...this.Go,...i])]),this.va().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.wa()}}ga(t){this.Go=this.Go.filter(e=>e!==t);var e=this.ka();return!e.includes(t)&&(this.Sa([...e,t]),this.xa(),!0)}pa(t){var e=new Set(t);this.Go=this.Go.filter(t=>!e.has(t));var i=this.$a(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.Sa(r),0===r.length&&this.Ca()),this.ma(t),this.wa()}wa(){try{var t;null==(t=this.Vo)||t.call(this)}catch(t){this.va().error("Error while handling activated items change",t)}}Ta(){var t=this.ea();if(!t)return{};var e=this.$i.getProperty(t);return e&&"object"==typeof e?e:{}}_a(t){if(this.ea()){var i=this.Ta();this.ia(e({},i,{[t]:Date.now()}))}}ma(t){if(this.ea()){var e=this.Ta(),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.na():this.ia(i))}}Ia(){this.ea()&&this.na()}getActivationTimestamp(t){if(this.ka().includes(t)){var e=this.Ta()[t];return b(e)?e:void 0}}$a(){var t=this.Ma();return this.$i.getProperty(t)||[]}ka(){var t=this.$a();if(0===t.length)return[];var e=this.$i.getProperty(this.Ea()),i=this.$i.getSessionId();return i&&e===i?t:[]}xa(){var t=this.$i.getSessionId();t&&this.Aa(t)}Ca(){this.Ra()}Xo(t){var e=this.$i.getProperty(this.Ea());if(e&&e!==t){var i=this.$a(),r=this.Ta();i.length>0&&(this.Sa([]),i.filter(t=>b(r[t])).forEach(t=>this.ya(t))),this.Ca(),this.Ia(),i.length>0&&this.wa()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.ka(),...this.Go])].filter(t=>!this.Pa(t))}dispose(){var t,e,i;null==(t=this.Yo)||t.call(this),this.Yo=void 0,null==(e=this.jo)||e.call(this),this.jo=void 0,null==(i=this.ha)||i.dispose(),this.ha=void 0}reset(){this.Go=[],this.$a().length>0&&this.Sa([]),this.Ca(),this.Ia(),this.wa()}getEventToItemsMap(){return this.Qo}Oa(){return this.ha}},ls=class extends os{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.Fa=t,this.Da=e,this.Ko()}Ma(){return Lr}Ea(){return Nr}ea(){return zr}ia(t){this.Fa.kv.set({[zr]:t})}na(){this.Fa.kv.remove(zr)}ta(t){var e,i;this.aa(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}La(){return Kn}aa(t){this.Da.getSurveys(t)}ya(t){this.Da.cancelPendingSurvey(t)}va(){return is}Sa(t){this.Fa.kv.set({[Lr]:t})}Aa(t){this.Fa.kv.set({[Nr]:t})}Ra(){this.Fa.kv.remove(Nr)}Pa(){return!1}fa(t,e,i){var r,n;return t===Xn&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.aa(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return Yn(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===Kn?"consume":"ignore":t===Kn?"persist":t===Jn||t===Xn?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},us=(t,e)=>null!=t&&t.then?t.then(e):e(t),hs="SDK is not enabled or survey functionality is not yet loaded",cs="Disabled. Not loading surveys.",vs=class{constructor(t){this.Na=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.ja=!1,this.qa=!1,this.Ba=[],this.za=[],this.Ha=null,this.Ua=null,this.Ti=!1,this.Wa=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.Ti&&!this.Fr.disableSurveys){if(!t.ok)return this.qa=!0,this.Va({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),is.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return is.warn("Flags not loaded yet. Not loading surveys.");this.Ga=_(e)?e:e.length>0,is.info("flags response received, isSurveysEnabled: "+this.Ga),this.loadIfEnabled()}},this.Va=t=>{this.za.slice().forEach(e=>this.Qa(e,t))}}setup(t){if(!this.Ti)return this.Ja=t,us(t.kv.initialize(),()=>{if(this.Ja===t&&!this.Ti){this.Ja=void 0,this.Fa=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Ti?e.dispose():(this.Za=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Ti||(this.Ti=!0,this.Ja=void 0,this.Fa=void 0,null==(t=this.Za)||t.dispose(),this.Za=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Ba=[],this.za.forEach(t=>{t.active=!1}),this.za=[],null==(r=this.Ka)||r.call(this),this.Ka=void 0,this.Ha=null,this.Wa.forEach(t=>clearTimeout(t)),this.Wa.clear())}get Fr(){return this.Na.get()}getRenderContext(){if(this.Fa){var t=this;return{client:this.Fa,get config(){return t.Fr},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.Va()}loadIfEnabled(){if(!this.Ti&&this.Fa){var t=this.Fr;if(!this._surveyManager)if(this.ja)is.info("Already initializing surveys, skipping...");else if(t.disableSurveys)is.info(cs);else if(t.cookielessMode&&this.Fa.isOptedOut)is.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Na.getExtensions();if(e){if(!f(this.Ga)||t.advancedEnableSurveys){var i=this.Ga||t.advancedEnableSurveys;this.ja=!0,this.qa=!1;try{var r=e.generateSurveys;if(r)return this.Xa(r,i),void(this.ja=!1);var n=e.loadExternalDependency;if(!n)return this.Ya(Dr),void(this.ja=!1);n(t=>{try{if(this.Ti)return;var e=this.Na.getExtensions();t||null==e||!e.generateSurveys?this.Ya("Could not load surveys script",t):this.Xa(e.generateSurveys,i)}finally{this.ja=!1}})}catch(t){throw this.ja=!1,this.Ya("Error initializing surveys",t),t}}}else this.Ya("PostHog Extensions not found.")}}}Xa(t,e){var i;if(!this.Ti){this._surveyManager=t(e),this._surveyEventReceiver=this.tl(this.Fa,this.Va);var r=null==(i=this.Fa)?void 0:i.kv.get(Ir);r&&this.el(r),is.info("Surveys loaded successfully"),this.il(),this.Va(),this.nl({isLoaded:!0})}}tl(t,e){return new ls(t,this,void 0,e)}Ya(t,e){this.qa=!0,is.error(t,e),this.Va({isLoaded:!1,error:t}),this.nl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ba.push(t),this._surveyManager&&this.nl({isLoaded:!0}),()=>{this.Ba=this.Ba.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Ti){var i=this.Fa;if(!i)return t([],{isLoaded:!1,error:hs});if(this.Fr.disableSurveys)return is.info(cs),t([]);var r=i.kv.get(Ir);if(r&&!e)return t(r,{isLoaded:!0}),void(this.sl()&&this.getSurveys(()=>{},!0));if(this.Ha)this.Ha.then(e=>{this.Ti||t(e.surveys,e.context)}).catch(t=>is.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Fr.requestTimeoutMs}).then(t=>{try{return this.rl(i,t)}catch(t){return is.error("Error processing surveys response",t),this.rl(i,{statusCode:0,error:t})}},t=>this.rl(i,{statusCode:0,error:t}));this.Ha=n;var s=()=>{this.Ha===n&&(this.Ha=null)};n.then(e=>{s(),this.Ti||(this.Va(e.context),t(e.surveys,e.context))},s).catch(t=>is.error("Error in survey callback",t))}}}rl(t,e){if(this.Ti)return{surveys:[],context:{isLoaded:!1,error:hs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?is.error(r):e.error||is.warn(r),this.Ua=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Ua=null;var n=e.json.surveys||[];return t.kv.set({[Ir]:n,[jr]:Date.now()}),this.el(n),{surveys:n,context:{isLoaded:!0}}}el(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Yn(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.al(e)}al(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}sl(){return this.ll()&&!this.Ha&&!this.ul()}ll(){var t,e=null==(t=this.Fa)?void 0:t.kv.get(jr);return b(e)&&Date.now()-e>3e5}ul(){return b(this.Ua)&&3e5>Date.now()-this.Ua}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){is.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.Va()}nl(t){for(var e of this.Ba){if(this.Ti)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){is.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);is.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Ti)return()=>{};var i={callback:t,active:!0,revision:0};this.za.push(i),this.il();var r=null==(e=this.Fa)?void 0:e.kv.get(Ir);return this.Fr.disableSurveys||!this._surveyManager&&this.qa&&!this.ja||!r&&!y(this.Ua)&&!this.Ha?this.Qa(i,{isLoaded:!1}):this._surveyManager&&this.Qa(i),()=>{var t;i.active=!1,this.za=this.za.filter(t=>t!==i),0===this.za.length&&(null==(t=this.Ka)||t.call(this),this.Ka=void 0)}}il(){var t,e,i;this._surveyManager&&this.za.length>0&&(null!==(t=this.Ka)&&void 0!==t||(this.Ka=null==(e=(i=this.Na).onMatchingConditionsChanged)?void 0:e.call(i,this.Va)))}Qa(t,e){if(!this.Ti&&t.active){var i=++t.revision,r=r=>{if(!this.Ti&&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){is.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){is.error("Error in active matching surveys callback",t)}}}cl(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}hl(t){if(y(this._surveyManager))return{eligible:!1,reason:hs};var e="string"==typeof t?this.cl(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}dl(t){var e;if(null==(e=this.Fa)||!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:hs};var i="string"==typeof t?this.cl(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return is.warn("init was not called"),{visible:!1,disabledReason:hs};var e=this.dl(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:hs})):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.dl(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.Fa)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var a="string"==typeof t?this.cl(t):t;if(null!=a&&a.id)if(rs.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){is.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.Wa.delete(l),!this.Ti&&null!=(t=this.Fa)&&t.canCapture&&(is.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),is.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.Wa.add(l)}else this._surveyManager.renderSurvey(a,o,i);else is.warn("Survey element not found")}else is.warn("Surveys of type "+a.type+" cannot be rendered in the app");else is.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.Fa)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var s=this.cl(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&&is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.hl(s);if(!o.eligible)return void is.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 is.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?is.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};si.DEBUG=!1,si.LIB_VERSION="1.447.2",si.LIB_NAME="web";var ds,fs=si,ps=/* @__PURE__ */new WeakMap,gs=()=>{var t;return null!=rn&&null!=(t=rn.performance)&&t.now?rn.performance.now():Date.now()},ms=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==un?void 0:un.__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!==Kn&&e!==Jn&&e!==Xn||t()}),n=()=>t();di(rn,"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==rn||rn.removeEventListener("PHSurveyShown",n)}}},ys=/* @__PURE__ */(()=>null!=rn&&rn.location?bn(rn.location.hash,"__posthog")||bn(location.hash,"state"):null)(),bs="_postHogToolbarParams",_s=/* @__PURE__ */li("[Toolbar]"),ws=/* @__PURE__ */li("[FeatureFlags]"),xs=/* @__PURE__ */li("[FeatureFlags]",{debugEnabled:!0}),Ss="\" failed. Feature flags didn't load in time.",ks=[502,504],Es=["click","keydown","wheel","touchstart","pointerdown"],As="connection_error",Ts=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Fs=t=>{var e={};for(var i of vi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Ps=(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),Rs=class{constructor(t){this.name="featureFlags",this.Pd=!1,this.featureFlagEventHandlers=[],this.R=ws,this.Od={},this.Fd={},this.Dd=[],this.Ld=/* @__PURE__ */new Set,this.Nd=/* @__PURE__ */new Set,this.jd=!1,this.qd=!1,this.Bd=0,this.zd=!1,this.Hd=!1,this.Ud=!1,this.Wd=/* @__PURE__ */new Map,this.Vd=!1,this.Gd=!1,this.Qd=!1,this.Jd=0,this.Zd=!1,this.sn=()=>{var t=this.Kd();this.Jd=0,t&&this.reloadFeatureFlags()},this.Yd=()=>{var t,e,i=this.Xd,r=null!==(t=this.tv)&&void 0!==t?t:i;f(i)||f(r)||this.Fr.remoteRequestsDisabled||!this.ev||"hidden"===this.ev.visibilityState||Date.now()-(null!==(e=this.iv)&&void 0!==e?e:0)<r||(this.tv=this.Zd||!this.Fr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Zd=!1,this.reloadFeatureFlags(),this.nv())},this.sv=()=>{this.Zd&&this.tv===this.Xd||this.rv()},this.an=()=>{var t;"visible"===(null==(t=this.ev)?void 0:t.visibilityState)&&this.rv()},this.Na=t}get ov(){}av(){this.Fa&&this.lv()}setup(t){try{this.uv=typeof window>"u"?void 0:window,this.ev=typeof document>"u"?void 0:document}catch(t){this.uv=void 0,this.ev=void 0}return this.Ja=t,this.R=t.logger.createLogger("[FeatureFlags]"),us(t.kv.initialize(),()=>{this.Ja===t&&(this.Ja=void 0,this.Fa=t,this.hv(t))})}hv(t){var e;if(this.Fa===t)return this.uv&&di(this.uv,"online",this.sn),this.lv(),this.dv=t.registerDynamicEventProperties(()=>this.vv()?this.Od:this.Fd),this.fv=null==(e=this.ov)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.pv(),this.gv(),this.mv()}),this.gv(),this.initialize()}rv(){this.Zd=!0,this.tv=this.Xd,this.Yd()}lv(){var t,e=this.Fr.refreshIntervalMs,i=!this.Fr.remoteRequestsDisabled&&this.ev&&!f(e)&&e>0?e:void 0;this.Fr.idleRefreshBackoff||(this.tv=i),i!==this.Xd&&(this.yv(),f(i)||(this.Xd=i,this.tv=i,this.nv(),null!=(t=this.ev)&&t.addEventListener&&(di(this.ev,Ci,this.an),ui(Es,t=>{di(this.ev,t,this.sv,{capture:!0})}))))}nv(){f(this.Xd)||(f(this.bv)||clearInterval(this.bv),this.iv=Date.now(),this.bv=setInterval(this.Yd,this.Xd))}yv(){var t;f(this.bv)||(clearInterval(this.bv),this.bv=void 0,null==(t=this.ev)||null==t.removeEventListener||t.removeEventListener(Ci,this.an),ui(Es,t=>{var e;null==(e=this.ev)||null==e.removeEventListener||e.removeEventListener(t,this.sv,{capture:!0})})),this.Xd=void 0,this.tv=void 0,this.Zd=!1,this.iv=void 0}destroy(){this._v()}dispose(){this._v()}_v(){var t,e,i;this.yv(),this.Bd++,this.Hd=!1,this.Ja=void 0,this.wv(this.Ld,"cancelled"),this.wv(this.Nd,"cancelled"),this.Fa&&(this.Sv(),null==(t=this.dv)||t.dispose(),this.dv=void 0,null==(e=this.fv)||e.call(this),this.fv=void 0,this.Dd=[],null==(i=this.uv)||i.removeEventListener("online",this.sn),this.Fa=void 0)}get Fr(){return this.Na.get()}xv(t){var e;return this.$v&&t in this.$v?this.$v[t]:null==(e=this.Fa)?void 0:e.kv.get(t)}pv(){return!!this.$v&&(this.$v=void 0,!0)}Cv(){var t;return!f(null==(t=this.Fa)?void 0:t.kv.get("$enabled_feature_flags"))&&this.pv()}$t(t){this.Tv(()=>{var e;return null==(e=this.Fa)?void 0:e.kv.set(t)})}Iv(t,e,i){if(this.ov&&t.$enabled_feature_flags){var r=this.xv("$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.xv("$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={[mi]:p,[Si]:p,[Fi]:g};for(var y of(t.$feature_flag_details&&(m[yi]=p),[wi,_i,xi]))f(t[y])||(m[y]=!0);this.ov.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.Tv(()=>{var e;return null==(e=this.Fa)?void 0:e.kv.remove(t)})}Tv(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}gv(){var t={};for(var i of[mi,Fi,wi,Pi]){var r=this.xv(i);f(r)||(t[i]=r)}this.Od=t;var n=e({},t),s=this.xv(Si);if(s)for(var a of Object.entries(s))n["$feature/"+a[0]]=a[1];this.Fd=n}vv(){var t=this.Fr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.xv(_i);return"number"!=typeof e||Date.now()-e>t}Mv(){return!!this.vv()&&(this.Qd||this.qd||(this.Qd=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Ev(){var t=this.Fr.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}):[]}Av(){var t=this.Fr.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.Fr,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.Rv({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n,s,a=null!=r&&r.merge&&null!==(n=this.xv("$enabled_feature_flags"))&&void 0!==n?n:{},o=null!=r&&r.merge&&null!==(s=this.xv("$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.Rv({flags:h})}get hasLoadedFlags(){return this.jd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.xv(yi),i=this.xv(Pi),r=this.xv(Ri);if(!r&&!i)return t||{};var n=ci({},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.Pd||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.Pd=!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.xv(Si),e=this.xv(Pi);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Pd||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Pd=!0),i}getFlagPayloads(){var t=this.xv(Fi),e=this.xv(Ri);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.Pd||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Pd=!0),i}reloadFeatureFlags(){this.zd||this.Fr.featureFlagsDisabled||this.Kd()||(this.Ud&&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.qd&&(this.Hd=!0),this.Pv||(this.Dd.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}}),this.Pv=setTimeout(()=>{this.Ov()},5)))}reloadFeatureFlagsAsync(){return!this.Fa||this.zd||this.Fr.featureFlagsDisabled||this.Fr.remoteRequestsDisabled||this.Kd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.Ld.add(t),this.reloadFeatureFlags()})}wv(t,e){t.forEach(t=>t({status:e})),t.clear()}Sv(){clearTimeout(this.Pv),this.Pv=void 0}onReloading(t){return this.Dd.push(t),()=>{this.Dd=this.Dd.filter(e=>e!==t)}}ensureFlagsLoaded(){this.jd||this.qd||this.Pv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.zd=t}resetFlagCallReported(){this.Dt(Ai),this.Wd=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.Wd.size&&!this.Vd&&null!=(t=this.Fa)&&t.canCapture&&!this.Fa.isRateLimited){this.Vd=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.Wd.keys())){var r=this.Wd.get(i);if(r){if(r.value!==String(e[i])||!Ps(r.context,this.Fv())){this.Wd.delete(i);continue}if(this.getFeatureFlagResult(i),this.Wd.has(i))break}}}finally{this.Vd=!1}}}Ov(t){var i;this.Sv();var r=this.Fa;if(!r||this.Fr.remoteRequestsDisabled||this.Kd())this.wv(this.Ld,"skipped");else if(this.qd)this.Hd=!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.xv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.xv(ki),timezone:kn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Fr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.Ev();s.length&&(n.evaluation_contexts=s);var a=this.Av();f(a)||(n.flag_keys=a);var o=this.Fr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.Bd,h=this.Ld;this.Ld=/* @__PURE__ */new Set,this.Nd=h,this.qd=!0;var c=()=>{this.Hd&&(this.Hd=!1,this.Ov())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.qd=!1,u===this.Bd)if(this.Dv(t.statusCode),s||this.Hd||(this.$anon_distinct_id=void 0),!n.disable_flags||this.Hd){this.Gd=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?As:"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({[bi]: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.Rv(r,s,{partialResponse:o}),this.wv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.wv(h,"skipped");else c()},d=t=>{this.qd=!1,u===this.Bd?(this.$t({[bi]:[As]}),this.R.error("Feature flag request failed",t),this.Cv()&&this.mv(!0),this.wv(h,"error"),c()):c()},p=null!==(i=this.Fr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.Bd,m=()=>{if(u!==this.Bd||!this.Fa||this.Fr.remoteRequestsDisabled)return this.qd=!1,this.wv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Fr.compression,sentAt:"body",timeoutMs:this.Fr.requestTimeoutMs}).then(t=>{if((t=>ks.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()}}Kd(){return pn(this.Jd,3)}Dv(t){this.Jd=gn(t,this.Jd,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.Gd)if(this.jd||this.getFlags()&&this.getFlags().length>0){if(!this.Mv()){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+Ss)}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.Gd)if(this.jd||this.getFlags()&&this.getFlags().length>0){if(!this.Mv()){var r,n=this.getFlagVariants(),s=t in n,a=n[t],o=this.getFlagPayloads()[t],l=String(a),u=this.xv("$feature_flag_request_id")||void 0,c=this.xv("$feature_flag_evaluated_at")||void 0,v=this.xv("$flag_call_reported")||{};if(this.Fr.deduplicateCallsPerSession){var d,p=null==(d=this.Fa)||null==(d=d.session)?void 0:d.sessionId,g=this.xv(Ti);p&&p!==g&&(v={},r=p)}if(!i.send_event&&"send_event"in i)r&&this.$t({[Ai]:v,[Ti]:r});else{var m,y,b,_,w=!(null!=(m=this.Fa)&&m.canCapture),x=!(w||null!=(y=this.Fa)&&y.isRateLimited);if(x?this.Wd.delete(t):(w&&Object.keys(v).length>0&&(v={},this.$t({[Ai]:v})),null!=(_=v[t])&&_.includes(l)||this.Lv(t,l)),!x||null!=(b=v[t])&&b.includes(l))r&&this.$t({[Ai]:v,[Ti]: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({[Ai]:v},r?{[Ti]:r}:{}));var D=this.getFeatureFlagDetails(t),L=[...null!==(S=this.xv("$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.Fr.bootstrap)||null==(E=E.featureFlags)?void 0:E[t])&&void 0!==k?k:null,$feature_flag_bootstrapped_payload:null!==(A=null==(T=this.Fr.bootstrap)||null==(T=T.featureFlagPayloads)?void 0:T[t])&&void 0!==A?A:null,$used_bootstrap_value:!this.Gd};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.Nv(N)||(this.jv(t,l),this.Lv(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+Ss)}Nv(t){try{var e;return!1!==(null==(e=this.Fa)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}Lv(t,e){this.Wd.set(t,{value:e,context:this.Fv()})}Fv(){var t,i,r;return{distinctId:null==(t=this.Fa)?void 0:t.distinctId,groups:e({},null==(i=this.Fa)?void 0:i.groups),sessionId:this.Fr.deduplicateCallsPerSession?null==(r=this.Fa)||null==(r=r.session)?void 0:r.sessionId:void 0}}jv(t,e){var i=this.xv("$flag_call_reported")||{},r=i[t];h(r)&&r.includes(e)&&(i[t]=r.filter(t=>t!==e),this.$t({[Ai]:i}))}getRemoteConfigPayload(t,e){this.qv(t,e)}qv(t,e){var i=this;return r(function*(){var r=i.Fa;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.Ev();s.length&&(n.evaluation_contexts=s);var a,o=i.Av();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.Fr.compression,sentAt:"body",timeoutMs:i.Fr.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.Gd)return e.defaultValue;if(!(this.jd||this.getFlags()&&this.getFlags().length>0))return this.R.warn('isFeatureEnabled for key "'+t+Ss),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.Rv(t,e,i)}Rv(t,i,r){if(this.Fa){this.jd=!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=ws);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{[mi]:u,[Si]:p,[xi]:!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({[mi]:Object.keys(Fs(m)),[Si]:m||{},[Fi]:y||{},[yi]:b||{},[xi]:!0===t.minimalFlagCalledEvents},v?{[wi]:v}:{},d?{[_i]: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.Fa.kv.get(Si));this.$v=n,s||this.$t(n)}else this.pv(),this.Iv(n,t,!(null==r||!r.partialResponse)),this.$t(n);else i&&this.Cv();i||(this.Qd=!1),this.mv(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.Bv(t)}Bv(t){if(this.Fa){if(!1===t)return this.Dt([Pi,Ri]),this.mv(),void xs.info("All overrides cleared");if(h(t))return this.$t({[Pi]:Ts(t)}),this.mv(),void xs.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.Pd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Pi]=h(n)?Ts(n):n),s&&(r[Ri]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Pi,Ri]):!1===n?this.Dt(Pi):!1===s&&this.Dt(Ri),this.mv(),!1===n?xs.info("Flag overrides cleared"):n&&xs.info("Flag overrides set",{flags:n}),void(!1===s?xs.info("Payload overrides cleared"):s&&xs.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Pi]:t}),this.mv(),void xs.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.jd){var e=this.zv(),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.xv("$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.ov)||n.markCrossTabFeatureFlagChanges({[mi]:[t],[Si]:[t],[Ei]:Object.keys(a)}),this.$t({[mi]:Object.keys(Fs(l)),[Si]:l,[Ei]:e({},this.xv("$stored_person_properties")||{},a)}),this.mv();try{var u;null==(u=this.Fa)||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.xv(gi);!r||e?this.Hv(t,i):t(r)}Hv(t,e){var i=this;return r(function*(){var r=i.Fa;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({[gi]: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)}}})()}zv(){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),{})}}mv(t){this.gv();var e=this.zv(),i=e.flags,r=e.flagVariants,n=this.Ud;this.Ud=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.Ud=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Uv(t,e)}Uv(t,i){void 0===i&&(i=!0);var r=this.xv("$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({[Ei]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.xv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Ei]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Ei),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.xv("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[ki]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.xv("$stored_group_properties")||{};this.$t({[ki]:e({},i,{[t]:{}})})}else this.Dt(ki)}reset(){this.Bd++,this.wv(this.Ld,"cancelled"),this.wv(this.Nd,"cancelled"),this.Hd=!1,this.Od={},this.Fd={},this.$v=void 0,this.jd=!1,this.zd=!1,this.Gd=!1,this.$anon_distinct_id=void 0,this.Sv(),this.Pd=!1,this.Jd=0,this.Wd=/* @__PURE__ */new Map}},Cs=/* @__PURE__ */li("[FeatureFlags]"),Os=class{constructor(t,e){void 0===e&&(e=!1),this.Wv=!1,this.update(t,e)}update(t,e){this.Vv=((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.Wv||(Cs.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Wv=!0),f(t.flag_keys)||h(t.flag_keys)||Cs.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Vv}},Ms=class extends Rs{constructor(t){var e=new Os(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.Gv=e}get ov(){return this._instance.persistence}updateConfig(t,e){this.Gv.update(t,e),this.av()}},$s=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Is=/* @__PURE__ */li("[Error tracking]"),js="webkit-masked-url:",Ds=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Ls=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",js],Ns=["__firefox__","__gCrWeb"],zs=/*#__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}()}(),Bs="Refusing to render web experiment since the viewer is a likely bot",Us={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Hs={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>Zn(e,t),not_regex:(t,e)=>!Zn(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},qs=/* @__PURE__ */li("[Conversations]"),Vs="Conversations not available yet.";function Ws(){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(je,t)?je[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function Gs(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({},Ws(),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 Ks=["debug","log","warn","error","info"],Js="console",Xs="__posthogHandledLogsRequestError",Ys=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[Xs]=!0,i},Zs=t=>!!t&&"object"==typeof t&&!0===t[Xs],Qs=class{get Qv(){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(Zs)||t.R.error(...i)}})}constructor(t,e){var i;this.Na=t,this.Jv=e,this.name="logs",this.Zv=!1,this.Kv=!1,this.Yv=!1,this.R=li("[logs]"),this.cc=[],this.Xv=[],this.Jd=0,this.tf=!1,this.Ti=!1,this.ef=[],this.if=[],this.nf=!1,this.sf=!1,this.rf=!1,this.af=()=>{var t,e;this.Ti||(this.Jd=0,null==(t=this.lf)||t.onReconnect(),null==(e=this.uf)||e.onReconnect())},this.Zv=!(null==(i=t.get())||!i.captureConsoleLogs)}get cf(){return!0}hf(){}df(){if(!this.rf){try{this.uv=typeof window>"u"?void 0:window}catch(t){this.uv=void 0}this.uv&&(di(this.uv,"online",this.af),this.rf=!0)}}vf(t,e,i,r){this.df();var n=Gs(this.Na.get(),i);return[new We(this.ff(t,e),n,this.Qv,()=>this.Jv(),t=>t(),void 0,r),n]}pf(){var t=this.Na.get();if(!this.lf||this.gf!==t){var e;null==(e=this.lf)||e.reset(),this.gf=t;var i=this.vf(()=>this.cc,t=>{this.cc=t});this.lf=i[0],this.mf=i[1]}return this.lf}yf(){var t=this.Na.get();if(!this.uf||this.bf!==t){var e;null==(e=this.uf)||e.reset(),this.bf=t;var i=this.vf(()=>this.Xv,t=>{this.Xv=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Js);this.uf=i[0],this._f=i[1]}return this.uf}setup(t){if(!this.Ti&&!this.tf)return this.tf=!0,this.Fa=t,this.R=t.logger.createLogger("[logs]"),us(t.kv.initialize(),()=>{this.Ti||this.hv(t)})}hv(t){var e;this.df(),null!=(e=this.Na.get())&&e.captureConsoleLogs&&(this.Zv=!0),(this.Zv||this.Na.remoteConfigWillArrive&&t.kv.get(this.Na.captureHintKey))&&this.wf();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.Ti?r.dispose():(this.Za=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Ti||(this.Ti=!0,this.kf(),null==(t=this.Za)||t.dispose(),this.Za=void 0,this.Fa=void 0,this.Yv=!1,null==(e=this.uv)||e.removeEventListener("online",this.af),null==(i=this.Sf)||i.call(this),this.Sf=void 0,null==(r=this.lf)||r.clearQueue(),null==(n=this.uf)||n.clearQueue(),null==(s=this.lf)||s.reset(),null==(a=this.uf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Ti){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.xf():(null==(i=this.Fa)||i.kv.set(this.Na.captureHintKey,!!r),r?(this.Zv=!0,this.Kv||this.wf(),this.loadIfEnabled()):this.xf())}}reset(){var t,e,i,r;this.kf(),null==(t=this.lf)||t.clearQueue(),this.cc=[],null==(e=this.lf)||e.reset(),null==(i=this.uf)||i.clearQueue(),this.Xv=[],null==(r=this.uf)||r.reset(),this.Jd=0}captureLog(t){!this.Ti&&this.Fa&&this.pf().captureLog(t)}captureConsoleLog(t){!this.Ti&&this.Fa&&this.yf().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Ti&&this.Fa&&this.yf().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.kf(),null==(t=this.uf)||t.clearQueue(),this.Xv=[]}xf(){this.Zv||this.kf()}wf(){var t,e=this;if(!this.nf&&null!=(t=this.uv)&&t.console){var i=Gs(this.Na.get()).maxBufferSize,r=!0;this.if.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.uv.console[t])}catch(t){return 1}n&&e.if.push(xn(e.uv.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.$f(t,a,i)}catch(t){}return s.apply(e.uv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of Ks)if(n(s))continue;this.nf=!0,this.Cf=setTimeout(()=>{this.kf()},3e4)}}$f(t,e,i){var r;if(this.nf&&!this.sf&&0!==e.length)if(null!=(r=this.Fa)&&r.canCapture){if(i>this.ef.length){this.sf=!0;try{this.ef.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Jv()})}finally{this.sf=!1}}}else this.kf()}kf(){if(this.ef=[],this.nf){for(var t of(this.nf=!1,this.Cf&&(clearTimeout(this.Cf),this.Cf=void 0),this.if))t();this.if=[]}}Tf(){var t=this.ef;return this.kf(),t}get logger(){return this.If||(this.If={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.If}flushLogs(t){this.Fa&&(t?this.Mf(t):(this.lf&&this.lf.flush().catch(t=>this.Ef(t)),this.uf&&this.uf.flush().catch(t=>this.Ef(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.lf)?void 0:e.flush().catch(e=>t.Ef(e)),n=null==(i=t.uf)?void 0:i.flush().catch(e=>t.Ef(e));yield r,yield n})()}Ef(t){Zs(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Ti&&this.Zv&&!this.Kv&&!this.Yv){var t=this.hf();if(t){this.Yv=!0;try{t((t,e)=>{if(this.Yv=!1,!this.Ti&&this.Zv)if(t||!e)this.R.error("Could not load logs script",t),this.kf();else{var i=this.Tf();this.Sf=e.initialize(this.Fa),this.Kv=!0,i.length>0&&e.replay(this.Fa,i)}})}catch(t){throw this.Yv=!1,t}}else this.kf()}}ff(t,e){var i=this.Fa;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:[])},qs:t=>this.qs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}qs(t){return new Promise(e=>{if(pn(this.Jd,3))e({kind:"fatal",error:Ys(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:Ys(void 0,"logs request timed out")})},9e4),s=this.cf;this.Fa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Fa.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.Af(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:Ys(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})})}})}Af(t,e){(0!==t||e)&&(this.Jd=gn(t,this.Jd,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.")))}Mf(t){this.cc.length>0&&this.Rf(t,this.cc,this.mf,this.Fa.library.name,t=>{this.cc=t}),this.Xv.length>0&&this.Rf(t,this.Xv,this._f,Js,t=>{this.Xv=t})}Rf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ue(s,Be(i,this.Fa.library.name,this.Fa.library.version),r,this.Fa.library.version);this.Fa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Fa.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.Ef(t))}}},ta=/* @__PURE__ */li("[NetworkMetrics]"),ea={"http:":80,"https:":443},ia=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),ra=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Sr(r))?void 0:i.href)||r}},na=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=gs()-n,d=Sr(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":_=ia.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)||ea[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){ta.error("Failed to record network metric",t)}var b,_},sa=()=>{},aa=(t,e)=>c(null==rn?void 0:rn.fetch)?xn(rn,"fetch",i=>function(){for(var r=gs(),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=ra(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=>(na(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw na(t,d,void 0,r,e,i),i})}catch(t){return ta.error("Failed to observe fetch",t),o}}):sa,oa=(t,e)=>{var i,r=null==rn||null==(i=rn.XMLHttpRequest)?void 0:i.prototype;if(!r)return sa;var n=/* @__PURE__ */new WeakMap,s=xn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{ps.has(this)||n.set(this,ra(i[0],i[1]))}catch(t){ta.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=xn(r,"send",i=>function(){var r;try{var s=n.get(this);if(s&&e()){var a=gs();di(this,"loadend",r=()=>{this.removeEventListener("loadend",r),na(t,s,this.status,a,e)})}}catch(t){ta.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()}},la=/* @__PURE__ */new WeakMap,ua=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),ha={maxStringLength:2048,truncationSuffix:"..."},ca={maxStringLength:2048,truncationSuffix:"..."};function va(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function da(t,e){return{}.hasOwnProperty.call(t,e)}function fa(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function pa(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?Ee(r,ha):r).slice(0,e)}}function ga(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function ma(t){return Ee(t||"Unknown error",ca).slice(0,2048)}function ya(t,e){try{return ma(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 ba(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:ma(t.value)}))}function _a(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 wa(t,e){return{message:ya(t,e),type:_a(t,e)}}var xa=function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return ci({},...e)},Sa={featureFlags:Ms},ka={sessionRecording:class{get Fr(){return this._instance.config}get Pc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Pf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this.Of||"missing_config"===this.Of?this.Of:null!==(t=null==(e=this.Pf)?void 0:e.status)&&void 0!==t?t:this.Of}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Of=jn,this.Ff=void 0,this.Df=!1,this.Ye=(()=>{var t;if(null==an||!an.visibilityState||"visible"===an.visibilityState)return!0;var e=null==rn||null==(t=rn.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.an=()=>{var t;"visible"===(null==an?void 0:an.visibilityState)&&(this.Ye=!0,null==(t=this.Pf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Ln.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Fr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=an&&an.addEventListener&&di(an,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.Df=!0,null==an||null==an.removeEventListener||an.removeEventListener("visibilitychange",this.an),i?this.Lf(!0):this.stopRecording()}get Nf(){var t,e=!(null==(t=this._instance.get_property(Jr))||!t.enabled),i=!this.Fr.disable_session_recording,r=this.Fr.disable_session_recording||this._instance.consent.isOptedOut();return rn&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!(this.Df||this.Nf&&null!=(e=this.Pf)&&e.isStarted)){var i=!f(Object.assign)&&!f(Array.from);this.Nf&&i?(this.jf(t),Ln.info("starting")):(this.Of=jn,this.stopRecording())}}jf(t){var e,i;if(this.Nf)if("awaiting_config"!==this.Of&&"missing_config"!==this.Of&&(this.Of=Dn),null!=un&&null!=(e=un.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=un.__PosthogExtensions__)&&i.initSessionRecording)this.qf(t);else{var r,n=this._instance.sessionManager;null==(r=un.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Bf,e=>{if(!this.Df&&this.Nf&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[Qr]:!0}),Ln.error("could not load recorder",e)):void this.qf(t);this.Of=jn})}}stopRecording(){var t,e;null==(t=this.Ff)||t.call(this),this.Ff=void 0,null==(e=this.Pf)||e.stop()}Lf(t){var e,i;void 0===t&&(t=!1),null==(e=this.Ff)||e.call(this),this.Ff=void 0,null==(i=this.Pf)||i.discard({discardProducerEvents:t})}zf(){var t,e;null==(t=this.Pc)||t.unregister("$session_is_sampled"),null==(e=this.Pc)||e.unregister("$replay_sample_rate")}Hf(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?(Ln.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Uf(t){if(this.Pc){var i,r,n=this.Pc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Hf(null==(i=this.Fr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Hf(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.zf();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[Jr]: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.Ff)||i.call(this),this.Ff=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.Uf(e),void this.Lf()):(this.Uf(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.Of&&(this.Of="missing_config",this._instance.register_for_session({[tn]:!0}),Ln.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.Pf)&&i.log?this.Pf.log(t,e):Ln.warn("log called before recorder was ready")}get Bf(){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"}Wf(){var t,e=this._instance.get_property(Jr);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Ln.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}qf(t){var e,i,r;if(!this.Df&&this.Nf&&this._instance.sessionManager){if(null==(e=un.__PosthogExtensions__)||!e.initSessionRecording)return Ln.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Qr]:!0});var n;if(this.Pf||(this.Pf=null==(n=un.__PosthogExtensions__)?void 0:n.initSessionRecording(this._instance,this.Ye),this.Pf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Wf()){if("missing_config"===this.Of||"awaiting_config"===this.Of)return;return this.Of="awaiting_config",Ln.info("persisted remote config is stale, requesting fresh config before starting"),void new In(this._instance).load()}this.Of=Dn,null==(i=(r=this.Pf).setDocumentWasEverVisible)||i.call(r,this.Ye),this.Pf.start(t)}else this.Of=jn}onRRwebEmit(t){var e;null==(e=this.Pf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Pf||null==(t=this.Pc)||t.register({[Yr]:!0}),null==(e=this.Pf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.Pf||null==(t=this.Pc)||t.register({[Xr]:!0}),null==(e=this.Pf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.Pf||null==(e=this.Pc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.Pf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Nn){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.Pf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Pf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.Pf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Ea={autocapture:class extends Or{constructor(t){super(new $r(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.Vf=!1,this._instance=t,this.Gf=this.Qf()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Jf();return!!(t.path||t.search||this.Zf(t))}startIfEnabled(){this.isEnabled&&(oi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Gf=this.Qf(),this.startIfEnabled()}stop(){this.Kf&&this.Kf(),this.Kf=void 0,this.Yf&&this.Yf(),this.Yf=void 0,oi.info("History API monitoring stopped")}monitorHistoryChanges(){rn&&rn.history&&(this.Xf("pushState"),this.Xf("replaceState"),this.tp(),this.Zf()&&this.ep())}Xf(t){var e;if(rn&&(null==(e=rn.history[t])||!e.__posthog_wrapped__)){var i=this;xn(rn.history,t,e=>function(r,n,s){var a;i.np(s)&&i.sp(),e.call(this,r,n,s),i.rp(t,!i.Vf&&"popstate"!==(null==rn||null==(a=rn.event)?void 0:a.type))})}}Qf(){var t=null==rn?void 0:rn.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Jf(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}Zf(t){return void 0===t&&(t=this.Jf()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}op(t){var e=this.Jf(),i=this.Gf;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.Zf(e)&&t.hash!==i.hash))}rp(t,e){void 0===e&&(e=!1);try{e||this.sp();var i=this.Qf();if(!i)return;if(this.op(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.ap=r,Promise.resolve().then(()=>this.sp())):r()}this.Gf=i}catch(e){oi.error("Error capturing "+t+" pageview",e)}}np(t){var e,i;return!(y(t)||!rn)&&(null==(e=Sr(String(t)))?void 0:e.href)!==(null==(i=rn.location)?void 0:i.href)}sp(){var t=this.ap;if(t){this.ap=void 0,this.Vf=!0;try{t()}catch(t){oi.error("Error capturing deferred pageview",t)}finally{this.Vf=!1}this.Gf=this.Qf()}}tp(){if(!this.Kf){var t=()=>{this.rp("popstate")};di(rn,"popstate",t),this.Kf=()=>{rn&&rn.removeEventListener("popstate",t)}}}ep(){if(!this.Yf){var t=()=>{this.rp("hashchange")};di(rn,"hashchange",t),this.Yf=()=>{rn&&rn.removeEventListener("hashchange",t)}}}},heatmaps:class{get Fr(){return this.instance.config}constructor(t){var e;this.lp=!1,this._l=!1,this.up=null,this.instance=t,this.lp=!(null==(e=this.instance.persistence)||!e.props[Br]),this.rageclicks=new xr(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Fr.capture_heatmaps)&&this.Fr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Fr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Fr.capture_heatmaps)?y(this.Fr.enable_heatmaps)?this.lp:this.Fr.enable_heatmaps:!1!==this.Fr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._l)return;zn.info("starting..."),this.cp(),this.an()}else{var t;clearInterval(null!==(t=this.up)&&void 0!==t?t:void 0),this.hp(),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({[Br]:i}),this.lp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}dp(t){Bn(t.originalEvent)&&this.Pr(t.originalEvent,"deadclick")}an(){this.up&&clearInterval(this.up),this.up="visible"===(null==an?void 0:an.visibilityState)?setInterval(this.bc.bind(this),this.flushIntervalMilliseconds):null}cp(){rn&&an&&(this.vp=this.bc.bind(this),di(rn,en,this.vp),this.fp=t=>this.Pr(t||(null==rn?void 0:rn.event)),di(an,"click",this.fp,{capture:!0}),this.pp=t=>this.gp(t||(null==rn?void 0:rn.event)),di(an,"mousemove",this.pp,{capture:!0}),this.mp=new vn(this.instance,cn,this.dp.bind(this)),this.mp.startIfEnabledOrStop(),this.yp=this.an.bind(this),di(an,Ci,this.yp),this._l=!0)}hp(){var t;rn&&an&&(this.vp&&rn.removeEventListener(en,this.vp),this.fp&&an.removeEventListener("click",this.fp,{capture:!0}),this.pp&&an.removeEventListener("mousemove",this.pp,{capture:!0}),this.yp&&an.removeEventListener(Ci,this.yp),clearTimeout(this.bp),null==(t=this.mp)||t.stop(),this._l=!1)}_p(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&&$i(r)&&!Ii(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:rn)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Gi(r)}return!1}(Hi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}Pr(t,i){var r;if(void 0===i&&(i="click"),!Mi(t.target)&&Bn(t)){var n=this._p(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&sr(Hi(t),this.instance.config.rageclick)&&this.Ks(e({},n,{type:"rageclick"})),this.Ks(n)}}gp(t){!Mi(t.target)&&Bn(t)&&(clearTimeout(this.bp),this.bp=setTimeout(()=>{this.Ks(this._p(t,"mousemove"))},500))}Ks(t){if(rn){var e=this.Fr.disable_capture_url_hashes?J(rn.location.href):rn.location.href,i=this.Fr.custom_personal_data_properties,r=yn(e,this.Fr.mask_personal_data_properties?[...En,...i||[]]:[],Tn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}bc(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:vn,webVitalsAutocapture:class{constructor(t){var i,r=this;this._instance=t,this.lp=!1,this._l=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.wp=function(t){void 0===t&&(t=!1),clearTimeout(r.kp),r.kp=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.Sp=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))Pn.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.xp(r);if(!f(n)){var s=b(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.$p||this.$p>t.value){this.Rt.navigationKey!==s&&(this.wp(),this.kp=setTimeout(this.wp,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 Mn){var h="url"===u&&"string"==typeof t.attribution[u]?this.xp(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.wp()}else Pn.error("Ignoring metric with value >= "+this.$p,t)}}},this.Cp=()=>{if(!this._l){var t,i,r,n,s=!1,a=un.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Tp])||("web-vitals"===this.Tp&&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.Sp.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Sp.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Sp.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.Sp.bind(this),v);var d=null==rn?void 0:rn.document;di(d,Ci,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.wp(!0)}),di(rn,"pagehide",()=>this.wp(!0)),this._l=!0}else Pn.error("web vitals callbacks not loaded - not starting")}},this.lp=!(null==(i=this._instance.persistence)||!i.props[Vr]),this.startIfEnabled()}get Ip(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.Ip)?null==(t=this.Ip)?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)||Cn:i}get flushToCaptureTimeoutMs(){return(v(this.Ip)?this.Ip.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.Ip)?this.Ip.web_vitals_attribution:void 0;return _(t)?t?Cn:[]:h(t)?t:On}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.Ip)?this.Ip.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get $p(){var t=v(this.Ip)&&b(this.Ip.__web_vitals_max_value)?this.Ip.__web_vitals_max_value:Rn;return t>0&&6e4>=t?Rn:t}get isEnabled(){var t=null==on?void 0:on.protocol;if("http:"!==t&&"https:"!==t)return Pn.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.Ip)?this.Ip.web_vitals:_(this.Ip)?this.Ip:void 0;return _(e)?e:this.lp}startIfEnabled(){this.isEnabled&&!this._l&&(Pn.info("enabled, starting..."),this.Bl(this.Cp))}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({[Vr]:i}),this._instance.persistence.register({[Kr]:r})),this.lp=i,this.startIfEnabled()}}}get Tp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Bl(t){var e=un.__PosthogExtensions__,i=this.Tp,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?Pn.error("failed to load script",e):t()})}xp(t){var e=t||(null==rn?void 0:rn.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 yn(i,this._instance.config.mask_personal_data_properties?[...En,...r||[]]:[],Tn)}Pn.error("Could not determine current URL")}}},Aa={exceptionObserver:class{constructor(t){var i;this.Cp=()=>{var t;if(rn&&this.isEnabled&&null!=(t=un.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=un.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=un.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=un.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Mp&&this.Fr.capture_unhandled_errors&&(this.Mp=e(this.captureException.bind(this))),!this.Ep&&this.Fr.capture_unhandled_rejections&&(this.Ep=i(this.captureException.bind(this))),!this.Ap&&this.Fr.capture_console_errors&&(this.Ap=r(this.captureException.bind(this)))}catch(t){dn.error("failed to start",t),this.Rp()}}},this._instance=t,this.Pp=!(null==(i=this._instance.persistence)||!i.props[Ur]),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:dn})),this.Fr=this.Op(),this.startIfEnabledOrStop()}Op(){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.Pp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Fr.capture_console_errors||this.Fr.capture_unhandled_errors||this.Fr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(dn.info("enabled"),this.Rp(),this.Bl(this.Cp)):this.Rp()}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",e=>{if(e)return dn.error("failed to load script",e);t()})}Rp(){var t,e,i;null==(t=this.Mp)||t.call(this),this.Mp=void 0,null==(e=this.Ep)||e.call(this),this.Ep=void 0,null==(i=this.Ap)||i.call(this),this.Ap=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Pp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ur]:this.Pp}),this.Fr=this.Op(),this.startIfEnabledOrStop())}}onConfigChange(){this.Fr=this.Op()}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 dn.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.Fp=[],this.Dp=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.Fp=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Lp=Lt(this.Np()),this.jp=new Nt(this.Lp)}onConfigChange(){this.Lp=Lt(this.Np()),this.jp.setConfig(this.Lp)}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.Fp=s,this._instance.persistence&&this._instance.persistence.register({[Hr]:this.Fp,[qr]:a})}}}get qp(){var t,e,i=!!this._instance.get_property(qr);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.Dp.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Lp.enabled)try{if(!p(t)||0===t.trim().length)return void Is.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.Bp(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&Is.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.jp.add(e({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){Is.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.zp(e)){if(this.Hp(e))return this.Up("Exception dropped: matched a suppression rule"),void Is.info("Skipping exception capture because a suppression rule matched");if(!this.qp&&this.Wp(e))return this.Up("Exception dropped: thrown by a browser extension"),void Is.info("Skipping exception capture because it was thrown by an extension");if(!this.qp&&this.Vp(e))return this.Up("Exception dropped: thrown by an injected browser script"),void Is.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Gp(e))return this.Up("Exception dropped: thrown by the PostHog SDK"),void Is.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Lp.enabled&&y(t.$exception_steps)?this.Qp(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.jp.clear(),n}catch(t){return $s(t)||Is.error("Failed to capture exception event. Dropping this exception.",t),void this.jp.clear()}}catch(t){return void($s(t)||Is.error("Failed to process exception event. Ignoring this exception.",t))}}Qp(t){try{var i=this.jp.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return Is.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Up(t){this.Lp.enabled&&this.jp.add({[$t]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}Bp(t){return v(t)?e({},t):{}}Np(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Hp(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.Fp.some(t=>{var i=t.values.map(t=>{var i=ts[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 Is.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Wp(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&&Ls.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(js)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&Ds.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(js))}))}Vp(t){return t.some(t=>{var e=t.value;return p(e)&&Ns.some(t=>e.includes(t))})}Gp(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}zp(t){return!y(t)&&h(t)}}},Ta={productTours:class{get Pc(){return this._instance.persistence}constructor(t){this.Jp=null,this.Zp=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.Pc&&this.Pc.register({[Gr]:!!e.productTours}),!Hn(this._instance))return!this.Jp&&y(null==(i=this.Pc)?void 0:i.props.ph_product_tours)||Un.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Jp)||r.stop(),this.Jp=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Jp&&Hn(this._instance)&&this.Bl(()=>this.Kp())}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",e=>{e?Un.error("Could not load product tours script",e):t()})}Kp(){var t;!this.Jp&&null!=(t=un.__PosthogExtensions__)&&t.generateProductTours&&(this.Jp=un.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.Zp)||e){var i=this.Pc;if(i){var r=i.props[Zr];if(h(r)&&!e)return this.Zp=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(Hn(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||Un.warn(n):Un.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.Zp=s,i&&i.register({[Zr]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Zp,{isLoaded:!0})}getActiveProductTours(t){y(this.Jp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Jp.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Jp)||e.showTourById(t)}previewTour(t){this.Jp?this.Jp.previewTour(t):this.Bl(()=>{var e;this.Kp(),null==(e=this.Jp)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Jp)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Jp)||t.nextStep()}previousStep(){var t;null==(t=this.Jp)||t.previousStep()}clearCache(){var t;this.Zp=null,null==(t=this.Pc)||t.unregister(Zr)}resetTour(t){var e;null==(e=this.Jp)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Jp)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Jp)||e.cancelPendingTour(t)}},featureFlags:Ms},Fa={siteApps:class{constructor(t){this._instance=t,this.Yp=0,this.Xp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}tg(t,e){if(e){var i=this.globalsForEvent(e);this.Xp.push(i),this.Xp.length>1e3&&(this.Xp=this.Xp.slice(10))}}get siteAppLoaders(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.tg.bind(this));this.eg=()=>{t(),this.Xp=[],this.eg=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}}ig(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)||(qn.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)||(qn.error("prepare_external_dependency_script returned null"),null):t}ng(){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==an?void 0:an.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Yp++,this.sg)return this.rg();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.ig(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.sg=()=>{h.forEach(t=>t()),this.sg=void 0},this.rg()}rg(){var t=!1;return()=>{var e;t||(t=!0,this.Yp--,0===this.Yp&&(null==(e=this.sg)||e.call(this)))}}og(t,e){void 0===e&&(e=!0);var i=this.ng();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.Xp.length&&(qn.info("Processing "+this.Xp.length+" events for site app with id "+t.id),this.Xp.forEach(t=>this.og(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.eg)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,qn.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.og(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){qn.error(Vn+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){qn.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}ag(){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)}lg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.og(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){qn.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.ag(),void this._instance.on("eventCaptured",t=>this.lg(t))):void qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.eg)||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;un["__$$ph_site_app_"+e]=n._instance,null==(t=un.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return qn.error(Vn+e,t)})};for(var o of s.siteApps)a()}else qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Pa={tracingHeaders:class{constructor(t){this._instance=t,this.ug=void 0,this.cg=void 0,this.hg=void 0,this.Cp=()=>{var t,e,i=this.dg();i?(f(this.ug)&&(this.ug=null==(t=un.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.cg)&&(this.cg=null==(e=un.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Rp()}}initialize(){this.startIfEnabledOrStop()}Bl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",e=>{if(e)return Sn.error("failed to load script",e);t()})}vg(){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}dg(){var t=this.vg();return h(t)?(h(this.hg)?this.hg.splice(0,this.hg.length,...t):this.hg=[...t],t.length>0?this.hg:void 0):(h(this.hg)&&this.hg.splice(0),this.hg=t||void 0,this.hg)}Rp(){var t,e;null==(t=this.ug)||t.call(this),null==(e=this.cg)||e.call(this),this.ug=void 0,this.cg=void 0}startIfEnabledOrStop(){this.dg()?this.Bl(this.Cp):this.Rp()}}},Ra={surveys:class extends vs{constructor(t){super(new ms(t))}},featureFlags:Ms},Ca={toolbar:class{constructor(t){this.instance=t}fg(t){un.ph_toolbar_state=t}pg(){var t;return null!==(t=un.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),fi(this.instance.config))return!1;if(!rn||!an)return!1;t=null!=t?t:rn.location,i=null!=i?i:rn.history;try{if(!e){try{rn.localStorage.setItem("test","test"),rn.localStorage.removeItem("test")}catch(t){return!1}e=null==rn?void 0:rn.localStorage}var r,n=ys||bn(t.hash,"__posthog")||bn(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(bs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}gg(t){var e=un.ph_load_toolbar||un.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):_s.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==an||!an.getElementById("__POSTHOG_TOOLBAR__"));if(!rn||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(rn.localStorage.setItem(bs,JSON.stringify(e({},n,{source:void 0}))),2===this.pg())this.gg(n);else if(0===this.pg()){var s;this.fg(1),null==(s=un.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return _s.error("[Toolbar] Failed to load",t),void this.fg(0);this.fg(2),this.gg(n)}),di(rn,"turbolinks:load",()=>{this.fg(0),this.loadToolbar(n)})}return!0}mg(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)}}},Oa={experiments:class t{get Fr(){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.yg("retrieved web experiments from the server"),i.bg=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.bg&&(t.yg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.bg)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i._g(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.wg(a,i._instance)&&i.kg(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.yg(Bs);else if(!this.Fr.disable_web_experiments){if(y(this.bg))return this.bg=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.yg("applying feature flags",e),e.forEach(t=>{var e;if(this.bg&&null!=(e=this.bg)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.bg)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this._g(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=mn(null==e?void 0:e.search,"__experiment_id"),r=mn(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.yg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.Sg(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Fr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Fr.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.Fr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Sg(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.yg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.kg(n[0].name,i,n[0].variants[i].transforms))}_g(e,i){var r=e.variants[i];t.xg(r,this._instance)?this.kg(e.name,i,r.transforms):t.yg("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static wg(e,i){return!y(e.conditions)&&t.xg(e,i)&&t.$g(e)}static xg(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=pi(i,n.href);return null==(s=e.conditions)||!s.url||Hs[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==rn?void 0:rn.location}static $g(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(!an)return{};var r,n,s,a=e?[...En,...i||[]]:[],o=(r=yn(an.URL,a,Tn),n=An.concat(t||[]),s={},hi(n,function(t){var e=mn(r,t);s[t]=e||null}),s);return ci(function(){var t={};return hi(Fn,function(e){var i=(t=>{if(an){try{for(var e=t+"=",i=an.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 yg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];oi.info("[WebExperiments] "+t,i)}static Cg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];oi.warn("[WebExperiments] "+t,i)}static Tg(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.Tg(e)})}kg(i,r,n){this._is_bot()?t.yg(Bs):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.yg("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.Cg("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!=ds?ds:ds=zs(),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({},Us,{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({},Us,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.Tg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.yg("Control variants leave the page unmodified.")}_is_bot(){return sn&&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}(sn,this.Fr.custom_blocked_useragents):void 0}},featureFlags:Ms},Ma={conversations:class{constructor(t){this._instance=t,this.Ig=void 0,this._conversationsManager=null,this.Mg=!1,this.ie=null,this.Eg=!1,this.Ag=0,this.Rg=null,this.Pg=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.Rg=null;else if(this.Og=t.ok,t.ok){var e=t.config.conversations;y(e)?this.Rg=null:(_(e)?this.Ig=e:(this.Ig=e.enabled,this.ie=e),this.Ig||(this.Rg=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Ag++,this.Ig=void 0,this.ie=null,this.Og=void 0,this.Eg=!1,this.Rg=null}loadIfEnabled(){if(!(this._conversationsManager||this.Mg||this._instance.config.disable_conversations||fi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==un?void 0:un.__PosthogExtensions__;if(t&&!f(this.Ig)&&this.Ig)if(this.ie&&this.ie.token){this.Mg=!0;try{var e=t.initConversations;if(e)return this.Fg(e),void(this.Mg=!1);var i=t.loadExternalDependency;if(!i)return void this.Dg(Dr);var r=this.Ag;i(this._instance,"conversations",e=>{if(r!==this.Ag)return this.Mg=!1,void this.loadIfEnabled();e||!t.initConversations?this.Dg("Could not load conversations script",e):this.Fg(t.initConversations),this.Mg=!1})}catch(t){this.Dg("Error initializing conversations",t),this.Mg=!1}}else qs.error("Conversations enabled but missing token in remote config.")}}Fg(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.Eg=!1,qs.info("Conversations loaded successfully")}catch(t){return void this.Dg("Error completing conversations initialization",t)}this.Pg&&this._conversationsManager.setTheme(this.Pg),this.Lg()}else qs.error("Cannot complete initialization: remote config is null")}Lg(){var t=this.Rg;this.Rg=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}Dg(t,e){qs.error(t,e),this._conversationsManager=null,this.Mg=!1,this.Eg=!0}show(){this._conversationsManager?this._conversationsManager.show():qs.warn("Conversations not loaded yet.")}hide(){"open"===this.Rg&&(this.Rg=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.Rg=null,this._conversationsManager.open()):this.Rg="open"}close(){this._conversationsManager?(this.Rg=null,this._conversationsManager.close()):this.Rg="close"}setTheme(t){var i,r;this.Pg=e({},this.Pg,t,{dark:e({},null==(i=this.Pg)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.Ig&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":fi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Og?"remote_config_failed":f(this.Ig)?this.Og?"disabled_in_project":"remote_config_pending":this.Ig?y(this.ie)||!this.ie.token?"missing_token":null!=un&&un.__PosthogExtensions__?this.Mg?"initializing":this.Eg?"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):(qs.warn(Vs),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(qs.warn(Vs),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(qs.warn(Vs),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(qs.warn(Vs),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(qs.warn(Vs),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(qs.warn(Vs),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(qs.warn(Vs),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()}}},$a={logs:class extends Qs{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=un._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!=un&&null!=(e=un.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(un.location.href):un.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.df()}get cf(){return this._instance.__loaded}hf(){var t=li("[logs]"),e=null==un?void 0:un.__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(Dr)}else t.error("PostHog Extensions not found.")}}},Ia={metrics:class{constructor(t){this._instance=t,this.R=li("[metrics]"),this.Ti=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.Ti){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.Ng?this.Ng=(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=aa(t,i),n=oa(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.Ng&&(this.Ng(),this.Ng=void 0)}}pf(){var t;if(!this.Ti){var e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.lf&&this.gf===i||(null==(e=this.lf)||e.reset(),this.gf=i,this.lf=new ti(this.ff(),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.lf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.pf())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.pf())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.pf())||r.histogram(t,e,i)}flush(t){if(!this.lf)return Promise.resolve();if(t){var e=this.lf.drainWindow();return e&&this.To(e,t),Promise.resolve()}return this.lf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.lf)||t.reset()}dispose(){var t,e;this.Ti=!0,null==(t=this.Ng)||t.call(this),this.Ng=void 0,null==(e=this.lf)||e.reset()}ff(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},To:t=>e.To(t),getLibraryId:()=>fs.LIB_NAME,getLibraryVersion:()=>fs.LIB_VERSION}}To(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.jg(),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)})}}))})}jg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},ja={webMCP:class{constructor(t){this._instance=t,this.qg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.qg){var t=null==an?void 0:an.modelContext;if(t&&c(t.registerTool)){var e=la.get(t);if(e)return e.instances.add(this._instance),void(this.qg=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;xn(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.Bg(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(la.set(t,i),this.qg=!0)}}}Bg(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=>ua.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:fa(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>da(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:fa(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:fa(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=va(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?pa(t.context,2048,!0):void 0,n=i.model?pa(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&&da(r,"context"),s=i.model&&da(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.zg(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=ga(t)?{error:t,errorResult:!0}:void 0;return n.zg(i,a,s,e,f),t},t=>{throw n.zg(i,a,s,{error:t,errorResult:!1},f),t});var g=ga(c)?{error:c,errorResult:!0}:void 0;return n.zg(i,a,s,g,f),c}}),a}zg(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=va(l.config.capture_webmcp);if(h){n&&!a&&(a=wa(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==on?void 0:on.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:ba(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==on?void 0:on.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}}},Da=/* @__PURE__ */xa(Sa,ka,Ea,Aa,Ta,Fa,Ra,Pa,Ca,Oa,Ma,$a,Ia,ja),La=Sa,Na=ka,za=Ea,Ba=Aa,Ua=Ta,Ha=Fa,qa=Ra,Va=Pa,Wa=Ca,Ga=Oa,Ka=Ma,Ja=$a,Xa=Ia,Ya=ja;export{Da as AllExtensions,za as AnalyticsExtensions,Ka as ConversationsExtensions,Ba as ErrorTrackingExtensions,Ga as ExperimentsExtensions,La as FeatureFlagsExtensions,Ja as LogsExtensions,Xa as MetricsExtensions,Ua as ProductToursExtensions,Na as SessionReplayExtensions,Ha as SiteAppsExtensions,qa as SurveysExtensions,Wa as ToolbarExtensions,Va as TracingExtensions,Ya as WebMCPExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map