posthog-js 1.455.0 → 1.455.1

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 (42) 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.es5.js.map +1 -1
  5. package/dist/array.full.js +1 -1
  6. package/dist/array.full.js.map +1 -1
  7. package/dist/array.full.no-external.js +1 -1
  8. package/dist/array.full.no-external.js.map +1 -1
  9. package/dist/array.js +1 -1
  10. package/dist/array.no-external.js +1 -1
  11. package/dist/customizations.full.js +1 -1
  12. package/dist/customizations.js +1 -1
  13. package/dist/default-extensions.js +1 -1
  14. package/dist/exception-autocapture.d.ts +4 -3
  15. package/dist/exception-autocapture.js +1 -1
  16. package/dist/exception-autocapture.js.map +1 -1
  17. package/dist/extension-bundles.js +1 -1
  18. package/dist/external-scripts-loader.js +1 -1
  19. package/dist/integrity.json +28 -28
  20. package/dist/lazy-recorder.js +1 -1
  21. package/dist/main.js +1 -1
  22. package/dist/module.full.cjs +1 -1
  23. package/dist/module.full.js +1 -1
  24. package/dist/module.full.js.map +1 -1
  25. package/dist/module.full.no-external.cjs +1 -1
  26. package/dist/module.full.no-external.js +1 -1
  27. package/dist/module.full.no-external.js.map +1 -1
  28. package/dist/module.js +1 -1
  29. package/dist/module.mjs +1 -1
  30. package/dist/module.no-external.cjs +1 -1
  31. package/dist/module.no-external.js +1 -1
  32. package/dist/module.slim.js +1 -1
  33. package/dist/module.slim.no-external.js +1 -1
  34. package/dist/posthog-recorder.js +1 -1
  35. package/dist/src/entrypoints/exception-autocapture.d.ts +4 -3
  36. package/dist/surveys-preview.js +1 -1
  37. package/dist/surveys.js +1 -1
  38. package/lib/package.json +1 -1
  39. package/lib/src/entrypoints/exception-autocapture.d.ts +4 -3
  40. package/lib/src/entrypoints/exception-autocapture.js +92 -42
  41. package/lib/src/entrypoints/exception-autocapture.js.map +1 -1
  42. package/package.json +4 -4
@@ -1,2 +1,2 @@
1
- var t=["$set_once","$set"];function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},e.apply(null,arguments)}function i(t,e,i,r,n,s,a){try{var o=t[s](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,n)}function r(t){return function(){var e=this,r=arguments;return new Promise(function(n,s){var a=t.apply(e,r);function o(t){i(a,n,s,o,l,"next",t)}function l(t){i(a,n,s,o,l,"throw",t)}o(void 0)})}}var n=/*#__PURE__*/function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function s(t,e){return-1!==t.indexOf(e)}var a=function(t){return t.trim()},o=Object.prototype,l=o.hasOwnProperty,u=o.toString,h=Array.isArray||function(t){return"[object Array]"===u.call(t)},c=t=>"function"==typeof t,v=t=>t===Object(t)&&!h(t),d=t=>{if(v(t)){for(var e in t)if(l.call(t,e))return!1;return!0}return!1},f=t=>void 0===t,p=t=>"[object String]"==u.call(t),g=t=>p(t)&&0===t.trim().length,m=t=>null===t,_=t=>f(t)||m(t),y=t=>"[object Number]"==u.call(t)&&t==t,b=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function x(t,e){return{}.toString.call(t)==="[object "+e+"]"}function S(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return E(t,Error)}}function k(t){return"u">typeof Event&&E(t,Event)}function E(t,e){try{return t instanceof e}catch(t){return!1}}var A=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","lightpanda","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],T=/* @__PURE__ */new Map,F=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=function(t,e){for(var i="",r=0;e.length>r;r++){var n=e[r];i+=n.length+":"+n}return t.length+":"+t+"|"+e.length+":"+i}(t,e),r=T.get(i);if(void 0!==r)return r;var n=t.toLowerCase(),s=A.concat(e).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>T.size||T.clear(),T.set(i,s),s};function O(t,e,i,r,n){return e>i&&(r.warn("min cannot be greater than max."),e=i),y(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),O(null!=n?n:i,e,i,r))}var P=class{constructor(t){this.C={},this.I=t.I,this.A=O(t.bucketSize,0,100,t.R),this.O=O(t.refillRate,0,this.A,t.R),this.$=O(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",R="Nintendo",M="PlayStation",I="Windows",D=/* @__PURE__ */new RegExp("BlackBerry|PlayBook|BB10","i"),j={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},L=[[/* @__PURE__ */new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>["Xbox",t&&t[1]||""]],[/* @__PURE__ */new RegExp(R,"i"),[R,""]],[/* @__PURE__ */new RegExp(M,"i"),[M,""]],[D,["BlackBerry",""]],[/* @__PURE__ */new RegExp(I,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return["Windows Phone",""];if(new RegExp("Mobile").test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=j[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[I,r]}return[I,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=f(t[2])?t[3]:t[2]),["watchOS",e]}],[/* @__PURE__ */new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[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=0;50>s&&1e3>a&&g>y;y++){a++;var b=void 0;try{b=c.next(m[y])}catch(t){s++,b=n.coerceFallback(v(i+1))}b&&_.push(b)}return e({},p,{errors:_})}},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 _t(t,e){var i=e.start+e.length,r=bt(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function yt(t,e){for(var i=e.start;i>0&&gt(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function bt(t,e){for(var i=e.start+e.length,r=i;t.length>r&&gt(t[r],t[r-e.length]);)r++;return r-i}function wt(t,e){var i=e[0],r=t.length-(i?yt(t,i):0);for(var n of e)r-=bt(t,n);return r}function xt(t,e,i){for(var r=0;t.length>r;r++){var n=t[(e+r)%t.length],s=t[(i+r)%t.length];if(n!==s)return s>n}return!1}var St=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=p(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return x(t,"DOMException")}isDOMError(t){return x(t,"DOMError")}},kt=class{match(t){return S(t)}coerce(t,e){var i,r=this.getStack(t),n=void 0===r?null==(i=e.syntheticException)?void 0:i.stack:void 0,s=!!n;return{type:this.getType(t),value:this.getMessage(t,e),stack:null!=r?r:n,cause:t.cause?e.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){try{var e=t.stacktrace;if("string"==typeof e&&e.length>0)return e;var i=t.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(t){return}}},Et=class{match(t){return!!x(t,"ErrorEvent")&&(null!=t.error||this.$r(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.Lr(t))&&void 0!==r?r:n.stack,synthetic:!0})}$r(t){return p(t.message)&&t.message.length>0}Lr(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 Ot(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";var r="";for(var n of i){var s=r?r+", "+n:n;if(s.length>e)break;r=s}return r}var Pt=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: "+Ot(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: "+Ot(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}},Rt=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}}},$t=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}},Mt="$message",It="$timestamp",Dt=/* @__PURE__ */new Set([Mt,It]),jt={enabled:!0,max_bytes:32768};function Lt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:jt.enabled,max_bytes:zt(t.max_bytes,jt.max_bytes)}:e({},jt)}var Nt=class{constructor(t){this.ns=[],this.ss=0,this.Yr=Lt(t)}setConfig(t){this.Yr=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[Mt],o=s[It];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!y(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.Yr.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.Yr.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function zt(t,e){if(!y(t)||1/0===t||-1/0===t)return e;var i=Math.floor(t);return 0>i?e:i}var Bt=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function Ut(t){return"string"==typeof t||t}function Ht(t){return"string"==typeof t?t:void 0}var qt="[redacted]",Vt=/^[A-Za-z0-9+/\n\r]+=*$/,Wt=/^[A-Za-z0-9_-]+={0,2}$/,Gt=/[-_]/,Kt=/^data:[^,\s]*;base64,/i,Jt=/^[A-Za-z0-9+/_-]+={0,2}$/,Xt=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Yt=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Zt=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Qt=/[\s<>"]/,te=/* @__PURE__ */(()=>new RegExp(Zt.source,"i"))(),ee=/[a-z][a-z0-9+.-]{0,63}:\/\//i,ie=/* @__PURE__ */(()=>new RegExp("^"+ee.source,"i"))(),re=/* @__PURE__ */(()=>new RegExp(ee.source,"gi"))(),ne=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,se=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ae=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,oe=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,le=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,ue=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,he=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,ce=/\d+/g,ve=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,de=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function fe(t){return function(t){return Yt.test(t)}(t)||ne.test(t)||se.test(t)}function pe(t){return t.split("&",129).length>128}function ge(t,e,i){return fe(t)||e.includes(";")&&function(t){return t.split(";").some(t=>fe(t.split("=",1)[0]))}(e)?qt:te.test(e)?i?xe(e,{allowNestedUrls:!1,stripPunctuation:!0}):qt:e}function me(t,e){var i=new URLSearchParams,r=!1,n=!1;for(var s of new URLSearchParams(t)){var a=s[0],o=s[1],l=Se(a),u=Se(o);r||(r=l!==a||u!==o);var h=ge(l,u,e);r||(r=h!==u),n=fe(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function _e(t,e){if(!t.includes("="))return{value:ye(t,e),lastFieldSensitive:!1};var i=me(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function ye(t,e){return e?xe(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function be(t,e,i){return"#"===t?!e.fragment&&(e.fragment=!0):"?"===t&&(e.fragment?"="!==i&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function we(t,e){var i;if(t.length>8192&&ie.test(t))return qt;var r,n=e.stripPunctuation?function(t){for(var e=t.length;e>0&&".,;:!?)]}'".includes(t[e-1]);)e--;return{address:t.slice(0,e),suffix:t.slice(e)}}(t):{address:t,suffix:""},s=n.address,a=n.suffix;try{r=new URL(s)}catch(t){return qt+a}var o=r.search.slice(1),l=""!==r.hash,u=function(t){var e=t.slice(1),i=e.indexOf("?");return 0>i?{head:e,tail:null}:{head:e.slice(0,i),tail:e.slice(i+1)}}(r.hash);if(pe(o)||pe(u.head)||pe(null!==(i=u.tail)&&void 0!==i?i:""))return qt+a;var h=!1;(r.username||r.password)&&(r.username=qt,r.password="",h=!0);var c=me(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=_e(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":qt,lastFieldSensitive:!0}:_e(v,e.allowNestedUrls)),p=null===f?d.value:d.value+"?"+f.value;p!==r.hash.slice(1)&&(r.hash=p,h=!0);var g=l?null!=f?f:d:c;return(h?Se(r.toString()):s)+(g.lastFieldSensitive?"":a)}function xe(t,i){return t.replace(Zt,r=>function(t,i){var r=function(t){if(!t.includes("://"))return[];for(var e=[...t.matchAll(re)].map(t=>t.index),i=[],r={query:!1,fragment:!1,fragmentQuery:!1},n=0,s=!1,a="",o=0;t.length>o&&e.length>n;o++){e[n]===o&&(o>0&&"="!==a&&i.push(o),n++);var l=t[o];be(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return we(t,i);var n="",s=0;for(var a of r)n+=we(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+we(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function Se(t){return t.replace(Xt,qt)}function ke(t,e){return function(t){return t.length>=10240&&(Vt.test(t)||function(t){var e,i=Kt.exec(t);if(!i)return!1;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Jt.test(e.replace(/[\r\n]/g,""))}(t)||Gt.test(t)&&Wt.test(t))}(t)?"[binary data redacted - not supported by PostHog MCP analytics]":function(t,e,i){var r=4*i.maxStringLength;if(t.length>r){var n=e(t.slice(0,function(t,e){for(var i=e;i>0&&!Qt.test(t[i-1]);)i--;return i}(t,r)));if(n.length>=2*i.maxStringLength)return n+i.truncationSuffix}return e(t)}(t,t=>function(t){return xe(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(ae," ");return(e=(e=(e=function(t){for(var e="",i=0,r=Oe(t,0);null!==r;r=Oe(t,r[1]))e+=t.slice(i,r[0])+Pe(t.slice(r[0],r[1])),i=r[1];return e+t.slice(i)}(e=(e=(e=e.replace(oe,qt)).replace(le,qt)).replace(ue,"$1"+qt))).replace(he,qt)).replace(ve,"$1"+qt)).replace(de,"$1"+qt)}(Se(t))),e)}function Ee(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;if(0>n||n>9)return!1;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function Ae(t,e){var i=t.charCodeAt(e);return i>=48&&57>=i}function Te(t,e){var i=t.charCodeAt(e);return Ae(t,e)||95===i||i>=65&&90>=i||i>=97&&122>=i}function Fe(t,e){for(var i=e;Ae(t,i);)i++;return i}function Oe(t,e){for(var i=e;t.length>i;i++)if(Ae(t,i)&&!Te(t,i-1)){for(var r=0,n=-1,s=i;;){var a=Fe(t,s);if(13>(r+=a-s)||Te(t,a)||(n=a),s=a+1,!" ./-".includes(t.charAt(a))||!Ae(t,s))break}if(n>=0)return[i,n];i=s-1}return null}function Pe(t){for(var e=[],i=ce.exec(t);null!==i;i=ce.exec(t))e.push({digits:i[0],start:i.index,end:i.index+i[0].length});for(var r="",n=0,s=0;e.length>s;){for(var a="",o=-1,l=s;e.length>l&&19>=(a+=e[l].digits).length;l++)a.length>=13&&Ee(a)&&(o=l);0>o?s++:(r+=t.slice(n,e[s].start)+qt,n=e[o].end,s=o+1)}return r+t.slice(n)}var Ce={}.propertyIsEnumerable;function Re(t,e){try{return Ie(t,e,{ancestors:/* @__PURE__ */new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function $e(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:N};if(i.remainingNodes--,b(t))return{boolValue:t};if("bigint"==typeof t)return function(t,e){var i=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==e||e.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(t,e);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var n=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==e||e.debug("Attribute "+n+" is outside the int64 range; encoding it as a string"),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:B(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(i.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:N};if(t instanceof Date){var s=t.getTime(),a=Number.isFinite(s)?t.toISOString():String(t);return{stringValue:"string"==typeof a?B(a):String(a)}}i.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return $e(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:Me(t,e,i,r+1)}}:{kvlistValue:{values:Ie(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:B(String(t))}}function Me(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(_(o))continue;n.push($e(o,e,i,r))}catch(t){n.push({stringValue:z})}return t.length>a&&n.push({stringValue:N}),n}function Ie(t,e,i,r){var n=[];for(var s in t)if(Ce.call(t,s)){if(!s){null==e||e.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[s];if(m(a)||f(a))continue;n.push({key:B(s),value:$e(a,e,i,r)})}catch(t){n.push({key:B(s),value:{stringValue:z}})}}return n}function De(t,i,r){return e({},U({},t.resourceAttributes),{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":r})}var je=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Le(t,e){var i=U({},t),r={};for(var n of je)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Re(i,e),...Re(r,e)]}var Ne={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};var ze={text:"INFO",number:9},Be={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:ze,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function Ue(t){try{return B(String(t))}catch(t){return z}}function He(t,i,r,n){var s,a=Be[t.level||"info"]||ze,o=a.text,l=a.number,u=(void 0===(s=y(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),_(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),_(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var c=e({},h),v=t.attributes;if(v){var d=[];try{d=Object.keys(v)}catch(t){d=[]}for(var p of d){var g=void 0;try{g=v[p]}catch(t){g=z}Object.defineProperty(c,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Ue(t.body)},attributes:Re(c,r)};return t.trace_id&&(m.traceId=t.trace_id),t.span_id&&(m.spanId=t.span_id),f(t.trace_flags)||(m.flags=t.trace_flags),m}function qe(t,e,i){return De(t,e,i)}function Ve(t,e,i,r){return{resourceLogs:[{resource:{attributes:Le(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var We=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=Y(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Ge(){return.75+.5*Math.random()}function Ke(t,e,i,r){var n=t*Math.pow(2,Math.min(Math.max(0,e-1),6));return Math.round((void 0===r?n:Math.min(n,Math.max(r,t)))*i)}var Je=class{constructor(t,e,i,r,n,s,a,o){var l;void 0===s&&(s=()=>Promise.resolve()),void 0===o&&(o=()=>!1),this._instance=t,this.Yr=e,this.R=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=o,this.gs=new We(()=>this.ys()),this.bs=null,this._s=0,this.ws=0,this.ks=null,this.Ss=new K,this.xs=0,this.$s=1,this.Cs=0,this.Ts=0,this.Ms=!1,this.Is=e.maxBufferSize,this.Es=Math.max(null!==(l=e.maxQueueSize)&&void 0!==l?l:e.maxBufferSize,e.maxBufferSize),this.As=e.flushIntervalMs,this.Rs=e.maxBatchRecordsPerPost,this.Ps=e.rateCapWindowMs,this.Os=e.maxLogsPerInterval}clearQueue(){this.ws++,this._instance.setPersistedProperty(n.LogsQueue,[])}get throttled(){return this.Ss.isOpen()}reset(){this.gs.clear(),this.Cs=0,this.Ts=0,this.Ms=!1,this.xs=0,this.$s=1,this.Ss.reset(),this.Rs=this.Yr.maxBatchRecordsPerPost}onReconnect(){this.xs=0,this.$s=1,this.Ss.isOpen()?this.Fs()&&this.Ls():this.ys()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ds(t);if(null!==r)if(r.body){if(this.Ns()){var n={record:He(r,null!==(i=null==e?void 0:e.context)&&void 0!==i?i:this.hs(),this.R,null==e?void 0:e.occurredAtMs)};this.ds(()=>this.js(n))}}else this.R.info("Log was rejected in beforeSend function")}}Ds(t){var e=this.Yr.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Log was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for log:",t),null}return r}Ns(){if(void 0===this.Os)return!0;var t=Date.now(),e=t-this.Cs;return this.Ps>e&&e>=0||(this.Cs=t,this.Ts=0,this.Ms=!1),this.Os>this.Ts?(this.Ts++,!0):(this.Ms||(this.R.warn("captureLog dropping logs: exceeded "+this.Os+" logs per "+this.Ps+"ms"),this.Ms=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.bs||(t.bs=t.qs().finally(()=>{t.bs=null})),t.bs})()}qs(){var t=this;return r(function*(){var e;if(t.gs.clear(),!t.Bs()){var i=null!==(e=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var a,o;if(t.Bs())return;var l=t.ws;t._s=0;var u=Math.min(i.length,t.Rs),h=i.slice(0,u),c=Ve(h.map(t=>t.record),t.zs(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.Hs(c);if(t.ws!==l)return;if("too-large"===v.kind&&h.length>1)t.Rs=Math.max(1,Math.floor(h.length/2)),t.R.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Rs);else{if(t.Ss.record(v),t.gs.pending&&t.gs.arm(Math.max(t.As,t.Ss.remainingMs())),"retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.R.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===v.kind&&t.Yr.maxBatchRecordsPerPost>t.Rs&&(t.Rs=Math.min(t.Yr.maxBatchRecordsPerPost,t.Rs+1)),yield t.Us(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}}})()}Bs(){return!!this.ps()&&(this.Fs()&&this.clearQueue(),!0)}Us(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e._s),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}zs(){return qe(this.Yr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}js(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Es>i.length||(i.shift(),this._s++,this.R.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Is>i.length||this.Ss.isOpen()?this.Ls():this.ys()}}Ls(){this.gs.pending||this.gs.arm(Math.max(this.As,this.Ss.remainingMs()))}Ws(){return Math.max(Ke(this.As,this.xs,this.$s,3e4),this.Ss.remainingMs())}Fs(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.gs.clear();var i=e.flush().catch(()=>{});void 0!==t?yield Z(i,t):yield i})()}flushWithTimeout(t){var e=this;return r(function*(){var i=e.flush();yield Z(i,t,()=>{i.catch(()=>{})})})()}flushInBackground(){if(this.ks)return this.ks;var t=this.flush().then(()=>{this.xs=0,this.$s=1},t=>{this.xs++,this.$s=Ge(),this.R.error("PostHog logs flush failed:",t)}).finally(()=>{this.ks===t&&(this.ks=null),!this._instance.isDisabled&&this.Fs()&&this.gs.armNoEarlierThan(this.Ws())});return this.ks=t,t}ys(){this.flushInBackground()}},Xe=/^[0-9a-f]+$/;function Ye(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Xe.test(t)}var Ze=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Qe="00",ti=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ei(t){return String(t)+"000000"}function ii(t,e,i,r){var n="";return r&&(n=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+n}var ri=class{constructor(t,e,i){this._instance=t,this.Yr=e,this.R=i,this.Vs=/* @__PURE__ */new Map,this.gs=new We(()=>this.flush().catch(t=>{this.R.error("Metrics flush failed:",t)})),this.bs=null,this.Gs=null,this.Js=!1,this.Qs=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ks=/* @__PURE__ */new Map,this.Ys=/* @__PURE__ */new Set,this.Xs=!1,this.Ss=new K,this.xs=0,this.$s=1,this.Po=0}count(t,e,i){void 0===e&&(e=1),this.Fo({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.Fo({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.Fo({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:h(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var t=this,e=this.bs,i=/* @__PURE__ */function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.No()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.bs===i&&(this.bs=null)});return this.bs=i,i}flushCoalesced(){var t,e;return this.jo()?null!==(t=this.bs)&&void 0!==t?t:Promise.resolve():(this.Gs||(this.Gs=(null!==(e=this.bs)&&void 0!==e?e:Promise.resolve()).catch(()=>{}).then(()=>(this.Gs=null,this.jo()?void 0:this.flush()))),this.Gs)}jo(){return this.xs>0||this.Ss.remainingMs()>0}drainWindow(){if(0===this.Vs.size)return null;var t=this.Vs;return this.qo(),this.Bo(t)}reset(){this.Po++,this.Ss.reset(),this.xs=0,this.$s=1,this.gs.clear(),this.bs=null,this.Gs=null,this.qo(),this.Ks=/* @__PURE__ */new Map,this.Xs=!1}qo(){this.Vs=/* @__PURE__ */new Map,this.Js=!1,this.Qs=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ys=/* @__PURE__ */new Set}Fo(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ds(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type||"gauge"===i.type||"histogram"===i.type)if("count"===i.type&&0>i.value)this.R.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,n;try{r=i.attributes?e({},i.attributes):void 0,n=ii(i.type,i.name,i.unit,r)}catch(t){return void this.R.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s,a=this.Vs.get(n);if((a||this.zo())&&("histogram"!==i.type||(s=this.Ho(i.name,i.unit,i.bounds)))){a||(a={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now(),hist:s&&si(s)},this.Vs.set(n,a));var o=this.Qs.get(i.name);void 0===o?this.Qs.set(i.name,i.type):o===i.type||this.Zs.has(i.name)||(this.Zs.add(i.name),this.R.warn("Metric name '"+i.name+"' is already used as a "+o+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Uo(a,i.value);var l=this.Wo();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Ls()}}else this.R.warn("Dropping metric '"+i.name+"': unknown type '"+String(i.type)+"'");else this.R.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.R.warn("Dropping metric with empty name")}}Wo(){try{var t,e,i=(r=null==(t=(e=this._instance).getActiveSpan)||null==(t=t.call(e))?void 0:t.traceparent(),s=function(t){if("string"==typeof t){var e=Ze.exec(t.trim());if(e){var i=e[1],r=e[2],n=e[3],s=e[4];if("ff"!==i&&("00"!==i||!e[5])&&function(t){return Ye(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Ye(t,16,"0000000000000000")}(n))return{version:i,traceId:r,spanId:n,flags:s}}}}(r),s&&{traceId:s.traceId,spanId:s.spanId,flags:(n=s.flags,1&parseInt(n,16)?"01":Qe)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}zo(){return this.Yr.maxSeriesPerFlush>this.Vs.size||(this.Js||(this.Js=!0,this.R.warn("Metric series cap reached ("+this.Yr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ho(t,e,i){if(void 0===i||function(t){if(!h(t)||0===t.length)return!1;for(var e=0;t.length>e;e++)if(!Number.isFinite(t[e])||e>0&&t[e-1]>=t[e])return!1;return!0}(i)){var r=ii("histogram",t,e,void 0),n=this.Ks.get(r);if(n)return this.Vo(t,r,n,i),n;if(this.Ks.size>=this.Yr.maxSeriesPerFlush){if(this.Xs||(this.Xs=!0,this.R.warn("Histogram bounds limit reached ("+this.Yr.maxSeriesPerFlush+" distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.")),i&&!ni(i,ti))return;return ti}var s=i?i.slice():ti;return this.Ks.set(r,s),s}this.R.warn("Dropping histogram '"+t+"': bounds must be a non-empty array of finite, strictly increasing numbers")}Vo(t,e,i,r){ni(i,null!=r?r:ti)||this.Ys.has(e)||(this.Ys.add(e),this.R.warn("Histogram '"+t+"' already uses the bounds ["+i.join(", ")+"]; samples that pass different bounds are recorded in those buckets."))}Uo(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,r.bounds)]+=1}}Ds(t){var e=this.Yr.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Metric was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for metric:",t),null}return r}Ls(){this.gs.pending||this.gs.arm(this.Ws())}Ws(){return Math.max(Ke(this.Yr.flushIntervalMs,this.xs,this.$s,3e4),this.Ss.remainingMs())}No(){var t=this;return r(function*(){if(t.gs.clear(),0!==t.Vs.size){var e=t.Vs;t.qo();var i=t.Po,r=yield t._instance.Go(t.Bo(e));if(i===t.Po)switch(t.Ss.record(r),"retry-later"===r.kind?(t.xs++,t.$s=Ge()):(t.xs=0,t.$s=1),t.gs.pending&&t.gs.arm(t.Ws()),r.kind){case"ok":return;case"retry-later":return t.Jo(e),void t.gs.armNoEarlierThan(t.Ws());case"too-large":return void t.R.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.R.error("Failed to send metrics batch:",r.error)}}})()}Bo(t){return e=this.Qo(t),i=function(t,e,i){return De(t,e,i)}(this.Yr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Le(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}Qo(t){var i=ei(Date.now()),r=/* @__PURE__ */new Map;for(var n of t.values()){var s,a=ii(n.type,n.name,n.unit,void 0),o=r.get(a);o||(o=e({name:n.name},n.unit&&{unit:n.unit}),"count"===n.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===n.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Re(null!==(s=n.attributes)&&void 0!==s?s:{},this.R),u=ei(n.windowStartMs),h=ai(n.exemplar);if("count"===n.type){var c,v=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(c=n.total)&&void 0!==c?c:0},h);o.sum.dataPoints.push(v)}else if("gauge"===n.type){var d,f=e({attributes:l,timeUnixNano:i,asDouble:null!==(d=n.last)&&void 0!==d?d:0},h);o.gauge.dataPoints.push(f)}else{var p=n.hist,g=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,count:p.count,sum:p.sum,min:p.min,max:p.max,bucketCounts:p.bucketCounts,explicitBounds:p.bounds},h);o.histogram.dataPoints.push(g)}}return Array.from(r.values())}Jo(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Vs.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,a.windowStartMs),o.exemplar=null!==(n=o.exemplar)&&void 0!==n?n:a.exemplar,o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=a.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":var l=o.hist,u=a.hist;l.count+=u.count,l.sum+=u.sum,l.min=Math.min(l.min,u.min),l.max=Math.max(l.max,u.max);for(var h=0;l.bucketCounts.length>h;h++)l.bucketCounts[h]+=u.bucketCounts[h]}else this.zo()&&this.Vs.set(s,a)}}};function ni(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(var i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}function si(t){return{bounds:t,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(t.length+1).fill(0)}}function ai(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:ei(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var oi="0.14.1",li={DEBUG:!1,LIB_VERSION:oi,LIB_NAME:"browser-common",JS_SDK_VERSION:oi},ui=function(t,e){var i=(void 0===e?{}:e).debugEnabled,r={N(e){var r;try{r=typeof window>"u"?void 0:window}catch(t){return}for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;n>a;a++)s[a-1]=arguments[a];r&&(li.DEBUG||r.POSTHOG_DEBUG||i)&&!f(r.console)&&r.console&&("__rrweb_original__"in r.console[e]?r.console[e].__rrweb_original__:r.console[e])(t,...s)},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>ui(t+" "+e,i)};return r},hi=/* @__PURE__ */ui("[PostHog.js]"),ci=(t,e)=>hi.createLogger(t,e);function vi(t,e){h(t)&&t.forEach(e)}function di(t,e){if(!_(t))if(h(t))t.forEach(e);else if(t instanceof FormData)t.forEach((t,i)=>e(t,i));else for(var i in t)l.call(t,i)&&e(t[i],i)}var fi=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var n of i)for(var s in n)void 0!==n[s]&&(t[s]=n[s]);return t};function pi(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}function gi(t,e,i,r){var n=null!=r?r:{},s=n.capture,a=n.passive;null==t||t.addEventListener(e,i,{capture:void 0!==s&&s,passive:void 0===a||a})}function mi(t){return"ph_toolbar_internal"===t.name}function _i(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!c(r))return e;try{var n=r(e);return p(n)&&n?n:e}catch(t){return hi.error("Error in get_current_url, falling back to window.location.href",t),e}}var yi="$early_access_features",bi="$active_feature_flags",wi="$feature_flag_details",xi="$feature_flag_errors",Si="$feature_flag_evaluated_at",ki="$feature_flag_request_id",Ei="$minimal_flag_called_events",Ai="$enabled_feature_flags",Ti="$stored_group_properties",Fi="$stored_person_properties",Oi="$flag_call_reported",Pi="$flag_call_reported_session_id",Ci="$feature_flag_payloads",Ri="$override_feature_flags",$i="$override_feature_flag_payloads",Mi="visibilitychange",Ii="$autocapture_disabled_server_side";function Di(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ji(t){return!!t&&1===t.nodeType}function Li(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Ni(t){return!!t&&3===t.nodeType}function zi(t){return!!t&&11===t.nodeType&&ji(t.host)}function Bi(t){return t?a(t).split(/\s+/):[]}function Ui(t,e){var i=function(t){var e,i=null==(e=typeof window>"u"?void 0:window)||null==(e=e.location)?void 0:e.href;return f(i)?void 0:_i(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function Hi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Bi(e)}function qi(t){return _(t)?null:a(t).split(/(\s+)/).filter(t=>wr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Vi(t){var e="";return vr(t)&&!dr(t)&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;Ni(t)&&t.textContent&&(e+=null!==(i=qi(t.textContent))&&void 0!==i?i:"")}),a(e)}function Wi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var Gi=["a","button","form","input","select","textarea","label"];function Ki(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}function Ji(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Ki(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Xi(t){var e=t.parentNode;return!(!e||!ji(e))&&e}var Yi=[".ph-no-autocapture","[data-ph-no-autocapture]"],Zi=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Qi=/* @__PURE__ */(()=>[...Zi,"+","-","−","–"])(),tr=/* @__PURE__ */(()=>Qi.length+10)(),er=["button","a","input","select","textarea","label"],ir=["button","link","tab","menuitem","option"],rr=(t,e)=>/[a-z0-9]/i.test(e)?s(Qi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,nr=t=>s(er,t.tagName.toLowerCase())||s(ir,(t.getAttribute("role")||"").toLowerCase());function sr(t){var e="",i="",r=t=>{ji(t)&&vr(t)&&!dr(t)&&(e+=" "+Vi(t),i=i||t.getAttribute("aria-label")||"",di(t.childNodes,r))};r(t);var n=(wr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var ar=[".ph-no-rageclick",".ph-no-capture"],or=["","text","search","email","password","url","tel","number"];function lr(t,e){if(!(typeof window>"u"?void 0:window)||ur(t))return!1;var i,r,n,a,o;if(b(e)?(i=!!e&&ar,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:ar,r=null==e?void 0:e.content_ignorelist,n=null!==(o=null==e?void 0:e.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(t){return!(!t||!ji(t))&&(!!Li(t,"textarea")||(Li(t,"input")?s(or,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var l=hr(t,!1),u=l.targetElementList;return!(!l.isComplete||r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Zi;else{if(!h(t))return!1;if(t.length>tr)return hi.error("[PostHog] content_ignorelist array cannot exceed "+tr+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>rr(r,t)||rr(n,t))}(r,function(t,e){for(var i of e)if(nr(i))return sr(i);for(var r of e){try{var n;if("pointer"!==(null==(n=window)?void 0:n.getComputedStyle(r).getPropertyValue("cursor")))break}catch(t){break}var s=sr(r);if(s.safeText||s.ariaLabel)return s}return sr(t)}(t,u))||Ji(u,i))}var ur=t=>!t||Li(t,"html")||!ji(t),hr=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ur(t))return{parentIsUsefulElement:!1,targetElementList:[],isComplete:!1};for(var r=!1,n=[t],s=t,a=/* @__PURE__ */new Set([t]);!Li(s,"body");){var o=s.assignedSlot||s.parentNode,l=zi(o)?o.host:o&&ji(o)?o:null;if(!l)break;if(a.has(l)||a.size>=1e3)return{parentIsUsefulElement:r,targetElementList:n,isComplete:!1};if(a.add(l),zi(o))n.push(l),s=l;else{if(e||Gi.indexOf(l.tagName.toLowerCase())>-1)r=!0;else try{var u=i.getComputedStyle(l);u&&"pointer"===u.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(l),s=l}}return{parentIsUsefulElement:r,targetElementList:n,isComplete:!0}};function cr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r;){if(i++>=1e3||e.has(r))return!0;e.add(r);var n=Hi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!0;var a=r.assignedSlot||r.parentNode;r=zi(a)?a.host:a&&ji(a)?a:null}return!1}function vr(t){if(cr(t))return!1;if(s(Hi(t),"ph-include"))return!0;var e=t.type||"";if(p(e))switch(e.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";return!p(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,""))}function dr(t){return!!(Li(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Li(t,"select")||Li(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var fr=/* @__PURE__ */new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),pr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,gr=[16,15,14,13],mr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),_r=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),yr=/[0-9A-Za-z_]/;function br(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function wr(t,e){if(void 0===e&&(e=!0),_(t))return!1;if(p(t)){if(t=a(t),e?fr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(pr.lastIndex=0;e=pr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of gr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(fr.test(o)&&br(o))return!0}}}return!1}(t))return!1;if(e?mr.test(t):function(t){var e;for(_r.lastIndex=0;e=_r.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&yr.test(i)&&yr.test(r)))return!0}return!1}(t))return!1}return!0}function xr(t){var e=Vi(t);return wr(e=(e+" "+Sr(t)).trim())?e:""}function Sr(t){var e="";return t&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Vi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Sr(t)).trim())}catch(t){hi.error("[AutoCapture]",t)}}),e}function kr(t){return t.replace(/"|\\"/g,'\\"')}function Er(t){var e=t.attr__class;if(e)return h(e)?e:Bi(e)}var Ar=class{constructor(t){this.disabled=!1===t;var e=v(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}},Tr=t=>{var e,i=null==(e=typeof document>"u"?void 0:document)?void 0:e.createElement("a");return f(i)?null:(i.href=t,i)},Fr=()=>typeof window>"u"?void 0:window,Or=()=>typeof document>"u"?void 0:document,Pr="$copy_autocapture",Cr=["password","hidden","file","checkbox","button","submit","reset","image"],Rr=/* @__PURE__ */ci("[AutoCapture]");function $r(t,e){return e.length>t?e.slice(0,t)+"...":e}function Mr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ji(e));return e}function Ir(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!ji(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;!Li(g,"body")&&1e3>d.length;){var m=g.assignedSlot||g.parentNode,_=zi(m)?m.host:m&&ji(m)?m:null;if(!_||f.has(_))break;f.add(_),d.push(_),g=_}var y="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Li(t,"button")||Li(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!vr(t)||dr(t)));var b,w,x,S=[],k={},E=!1,A=!1;if(di(d,t=>{var e=vr(t);if(e&&Li(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");E=!!(e&&i&&wr(i))&&(v?J(i):i)}s(Hi(t),"ph-no-capture")&&(A=!0),S.push(function(t,e,i,r,n){void 0===n&&(n=!1);var s=t.tagName.toLowerCase(),a={tag_name:s};Gi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?$r(1024,xr(t)):$r(1024,Vi(t)));var o=Hi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),di(cr(t)?[]:t.attributes,function(i){var s;if((!dr(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&wr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Bi(o).join(" ")),a["attr__"+i.name]=$r(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=Mr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),di(function(t){if(!vr(t))return{};var e={};return di(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&wr(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(k,e)||(k[e]=t)})}),A)return{props:{},explicitNoCapture:A};if(y>0&&(t=d[y],S.splice(0,y)),l||(S[0].$el_text=Li(t,"a")||Li(t,"button")?xr(t):Vi(t)),E){var T,F;S[0].attr__href=E;var O=null==(T=Tr(E))?void 0:T.host,P=null==(F=Fr())||null==(F=F.location)?void 0:F.host;O&&P&&O!==P&&(b=E)}return{props:fi((w=a.type,{$event_type:w,$ce_version:1}),c?{}:{$elements:S},{$elements_chain:(x=S,h(x)?function(t){return t.map(t=>{var i,r,n="";if(t.tag_name&&(n+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))n+="."+s.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return pi(a).sort((t,e)=>{return(r=e[0])>(i=t[0])?-1:i>r?1:0;var i,r}).forEach(t=>{var e=t[1];return o[kr(t[0].toString())]=kr(e.toString())}),(n+=":")+pi(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Er(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return pi(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(x)):"")},null!=(r=S[0])&&r.$el_text?{$el_text:null==(n=S[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},k),target:t}}var Dr=class{Pa(){this.Oa=void 0,clearTimeout(this.Fa),this.Fa=void 0}La(t){var e;if(!vr(t))return!0;for(var i,r=null!==(e=this.Da().css_selector_ignorelist)&&void 0!==e?e:Yi,n=/* @__PURE__ */new Set,a=t,o=function(){if(n.size>=1e3||n.has(a))return{v:!0};n.add(a);var t=a,e=Hi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||dr(t)||r.some(e=>Ki(t,e)))return{v:!0};var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(i=o())return i.v;return!1}Na(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.Oa;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.Pa():"pointerup"===t.type&&(e.released=!0,this.Fa=setTimeout(()=>this.Pa(),0)))}else{var i;this.Pa();var r=Wi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&ji(r)&&(this.Oa={target:r,excluded:this.La(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.ia)?void 0:i.distinctId})}else this.Pa()}ja(t){var e,i=this.Oa;this.Pa();var r=Wi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.ia)?void 0:e.distinctId)&&t.pointerId===i.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-i.x)&&5>=Math.abs(t.clientY-i.y)&&r&&(Li(r,"html")||Li(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.Da().css_selector_ignorelist)&&void 0!==n?n:Yi;return[r,null==(a=Or())?void 0:a.documentElement,null==(o=Or())?void 0:o.body].some(t=>{if(!t)return!1;var e=Hi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!vr(t)||dr(t)||l.some(e=>Ki(t,e))})?null:i.target}}constructor(t){this.ra=t,this.name="autocapture",this.qa=!1,this.Ba=null,this.za=!1,this.Ha=/* @__PURE__ */new Map,this.Ua=!1,this.Yr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.qi=!1,this.ra.refresh(this.Yr),this.rageclicks=new Ar(this.Yr.rageclick),this.Wa=null}setup(t){this.Va(),this.ia=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.qi?e.dispose():(this.ma=e,this.startIfEnabled())}dispose(){var t;this.qi||(this.qi=!0,this.ia=void 0,null==(t=this.ma)||t.dispose(),this.ma=void 0,this.Ha.clear(),this.Wa=null,this.Ga())}Da(){return this.ra.refresh(this.Yr),this.Yr}Va(){var t,e;return this.Da(),this.Yr.url_allowlist=null==(t=this.Yr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Yr.url_ignorelist=null==(e=this.Yr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Yr}Ja(){var t=Fr(),e=Or();if(this.isBrowserSupported()){if(t&&e){this.Qa=t,this.Za=e;var i=this.Ka=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.Pa();if(0===e.type.indexOf("pointer"))return void this.Na(e);var i="click"===e.type?this.ja(e):void 0;if(m(i))return;this.Ya(e,"$autocapture",i)}catch(t){Rr.error("Failed to capture event",t)}};if(gi(t,"blur",i),gi(e,"submit",i,{capture:!0}),gi(e,"change",i,{capture:!0}),gi(e,"click",i,{capture:!0}),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{gi(e,t,i,{capture:!0})}),this.Da().capture_copied_text){var r=this.Xa=e=>{e=e||(null==t?void 0:t.event);try{this.Ya(e,Pr)}catch(t){Rr.error("Failed to capture clipboard event",t)}};gi(e,"copy",r,{capture:!0}),gi(e,"cut",r,{capture:!0}),gi(e,"paste",r,{capture:!0})}}}else Rr.info("Disabling Automatic Event Collection because this browser is not supported")}Ga(){var t=this.Qa,e=this.Za;this.Pa(),this.Ka&&(null==t||t.removeEventListener("blur",this.Ka),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.Ka,!0)}),null==e||e.removeEventListener("submit",this.Ka,!0),null==e||e.removeEventListener("change",this.Ka,!0),null==e||e.removeEventListener("click",this.Ka,!0),this.Ka=void 0),this.Xa&&(null==e||e.removeEventListener("copy",this.Xa,!0),null==e||e.removeEventListener("cut",this.Xa,!0),null==e||e.removeEventListener("paste",this.Xa,!0),this.Xa=void 0),this.Qa=void 0,this.Za=void 0,this.qa=!1}startIfEnabled(){this.isEnabled||this.Pa(),!this.qi&&this.ia&&this.isEnabled&&!this.qa&&(this.Ja(),this.qa=!0)}onRemoteConfig(t){if(!this.qi)if(this.za=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.Ua=e.elementsChainAsString);var i,r=e.autocapture_opt_out;b(r)&&(null==(i=this.ia)||i.kv.set(Ii,r),this.Ba=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.qi){t.size?this.Ha.set(e,new Set(t)):this.Ha.delete(e);var i=/* @__PURE__ */new Set;this.Ha.forEach(t=>{t.forEach(t=>i.add(t))}),this.Wa=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.Wa)||i.forEach(i=>{var n;null==(n=Or())||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.qi)return!1;var i=null==(t=this.ia)?void 0:t.kv.get(Ii),r=this.Ba,n=this.Da();if(!n.remoteRequestsDisabled&&!this.za)return!1;var s=n.remoteRequestsDisabled&&!this.za;if(m(r)&&!b(i)&&!s)return!1;var a=null!==(e=this.Ba)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Ya(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Wi(t);Ni(n)&&(n=n.parentNode||null);var a,o=this.Va();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(a=this.rageclicks)&&a.isRageClick(t.clientX,t.clientY,t.timeStamp||/* @__PURE__ */(new Date).getTime())&&lr(n,o.rageclick)&&this.Ya(t,"$rageclick",r);var l,u=i===Pr,v=u?e({},o,{dom_event_allowlist:void 0}):o;if(n&&function(t,e,i,r,n,s){var a,o=typeof window>"u"?void 0:window;if(!o||ur(t))return!1;if(null!=i&&i.url_allowlist&&!Ui(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ui(i.url_ignorelist,s))return!1;if(null!=i&&i.dom_event_allowlist){var l=i.dom_event_allowlist;if(l&&!l.some(t=>e.type===t))return!1}var u=hr(t,r),h=u.parentIsUsefulElement,c=u.targetElementList;if(!u.isComplete)return!1;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(f(i))return!0;var r,n=function(t){if(i.some(e=>t.tagName.toLowerCase()===e))return{v:!0}};for(var s of t)if(r=n(s))return r.v;return!1}(c,i))return!1;if(!Ji(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Ji(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Yi))return!1;try{var v=o.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return h?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(Gi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,v,u,u?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var d,p=Ir(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.Ua,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),g=p.props;if(p.explicitNoCapture)return!1;var m=this.getElementSelectors(n,p.target);if(m&&m.length>0&&(g.$element_selectors=m),i===Pr){var _=t.type||"clipboard";if("paste"!==_){var y,b,w=null==(y=Fr())||null==(y=y.getSelection())?void 0:y.toString(),x=qi(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(b=null==w?void 0:w.length)&&void 0!==b?b:0}g.$copy_type=_}if("$autocapture"===i&&"change"===t.type&&o.capture_value_css_selector_allowlist&&!o.maskAllText&&(Li(l=n,"input")?!s(Cr,l.type):Li(l,"textarea")||Li(l,"select")&&!l.multiple)&&function(t,e){var i;if(!vr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Yi,n=/* @__PURE__ */new Set,a=t;Li(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=Hi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Ki(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(o=l())return o.v;return!0}(n,o)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){var S=o.capture_value_css_selector_allowlist,k=!1;try{k=c(S)?!!S(n):h(S)&&S.some(t=>Ki(n,t))}catch(t){Rr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.ia)||d.capture(i,g),!0}}else this.Pa()}isBrowserSupported(){var t;return c(null==(t=Or())?void 0:t.querySelectorAll)}},jr=["[data-ph-capture-value]"],Lr=class{constructor(t){this._instance=t}refresh(t){var e,i=this._instance.config,r=v(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance._shouldDisableFlags(),t.url_allowlist=null==r?void 0:r.url_allowlist,t.url_ignorelist=null==r?void 0:r.url_ignorelist,t.dom_event_allowlist=null==r?void 0:r.dom_event_allowlist,t.element_allowlist=null==r?void 0:r.element_allowlist,t.css_selector_allowlist=null==r?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=null==r?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=null==r?void 0:r.element_attribute_ignorelist,t.capture_copied_text=null==r?void 0:r.capture_copied_text,t.capture_value_css_selector_allowlist=null!==(e=null==r?void 0:r.capture_value_css_selector_allowlist)&&void 0!==e?e:jr}},Nr=class extends Dr{constructor(t){super(new Lr(t)),this.instance=t}},zr="$surveys",Br="$surveys_loaded_at",Ur="PostHog loadExternalDependency extension not found.",Hr="$surveys_activated",qr="$surveys_activated_session",Vr="$surveys_activated_timestamps",Wr="$heatmaps_enabled_server_side",Gr="$exception_capture_enabled_server_side",Kr="$error_tracking_suppression_rules",Jr="$error_tracking_capture_extension_exceptions",Xr="$web_vitals_enabled_server_side",Yr="$dead_clicks_enabled_server_side",Zr="$product_tours_enabled_server_side",Qr="$web_vitals_allowed_metrics",tn="$session_recording_remote_config",en="$replay_override_sampling",rn="$replay_override_linked_flag",nn="$session_is_sampled",sn="ph_product_tours",an="$sdk_debug_recording_script_not_loaded",on="$sdk_debug_replay_stale_config",ln="beforeunload",un="u">typeof window?window:void 0,hn="u">typeof globalThis?globalThis:un,cn=null==hn?void 0:hn.navigator,vn=null==hn?void 0:hn.document,dn=null==hn?void 0:hn.location;null!=hn&&hn.XMLHttpRequest&&new hn.XMLHttpRequest;var fn="undefined"!=typeof globalThis?globalThis:un;fn&&"undefined"==typeof self&&(fn.self=fn),fn&&"undefined"==typeof File&&(fn.File=function(){});var pn=null!=un?un:{},gn=t=>{var e;return null!=t&&t.config.require_subresource_integrity?t.__loadExternalDependency:null==(e=pn.__PosthogExtensions__)?void 0:e.loadExternalDependency},mn=/* @__PURE__ */ci("[Dead Clicks]"),_n=()=>!0,yn=class{get lazyLoadedDeadClicksAutocapture(){return this.ou}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Yr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.lu(()=>{this.au()}):this.stop()}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=gn(this.instance))||i(this.instance,"dead-clicks-autocapture",e=>{e?mn.error("failed to load script",e):t()})}au(){var t;if(vn){if(!this.ou&&null!=(t=pn.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=v(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.ou=pn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.ou.start(vn),mn.info("starting...")}}else mn.error("`document` not found. Cannot start.")}stop(){this.ou&&(this.ou.stop(),this.ou=void 0,mn.info("stopping..."))}},bn=/* @__PURE__ */ci("[ExceptionAutocapture]"),wn=class{constructor(t){var i;this.pg=()=>{var t;if(un&&this.isEnabled&&null!=(t=pn.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=pn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=pn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=pn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.yg&&this.Yr.capture_unhandled_errors&&(this.yg=e(this.captureException.bind(this))),!this.bg&&this.Yr.capture_unhandled_rejections&&(this.bg=i(this.captureException.bind(this))),!this._g&&this.Yr.capture_console_errors&&(this._g=r(this.captureException.bind(this)))}catch(t){bn.error("failed to start",t),this.wg()}}},this._instance=t,this.kg=!(null==(i=this._instance.persistence)||!i.props[Gr]),this.kt=new P(e({},function(t){var e,i,r,n;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,R:bn})),this.Yr=this.Sg(),this.startIfEnabledOrStop()}Sg(){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.kg:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Yr.capture_console_errors||this.Yr.capture_unhandled_errors||this.Yr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(bn.info("enabled"),this.wg(),this.lu(this.pg)):this.wg()}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=gn(this._instance))||i(this._instance,"exception-autocapture",e=>{if(e)return bn.error("failed to load script",e);t()})}wg(){var t,e,i;null==(t=this.yg)||t.call(this),this.yg=void 0,null==(e=this.bg)||e.call(this),this.bg=void 0,null==(i=this._g)||i.call(this),this._g=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.kg=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Gr]:this.kg}),this.Yr=this.Sg(),this.startIfEnabledOrStop())}}onConfigChange(){this.Yr=this.Sg()}captureException(t){try{var e,i,r,n=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";if(this.kt.consumeRateLimit(n))return void bn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},xn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},Sn=(t,e)=>t>=e&&xn(),kn=(t,e,i,r)=>{if(0===t){if(xn()){var n=e+1;return n===i&&r(),n}return e}return 0},En=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;r.length>n;n++){var s=r[n].split(/=(.*)/);if(s[0]===e){i=s;break}}if(!h(i)||2>i.length)return"";var a=i[1].replace(/\+/g," ");try{a=decodeURIComponent(a)}catch(t){hi.error("Skipping decoding for malformed query param: "+a)}return a},An=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split(/#(.*)/),n=r[1],s=(r[0]||"").split(/\?(.*)/),a=s[1],o=s[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){for(var c=l[h].split("?"),v=0;c.length>v&&!e.includes(c[v].split("=")[0]);)v++;u.push(c.length>v?c.slice(0,v).concat(c[v].split("=")[0]+"="+i).join("?"):l[h])}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=n&&(d+="#"+n),d},Tn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Fn=()=>{},On=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function Pn(t,e,i){try{if(!(e in t))return Fn;var r={next:t[e]},n=i(function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)});return c(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=n,()=>{if(t[e]!==n)for(var i=t[e],s=On(i);s;){if(s.next===n)return void(s.next=r.next);s=On(i=s.next)}else t[e]=r.next}}catch(t){return Fn}}var Cn=class{constructor(t){this.Op=!1,this._instance=t,this.Fp=this.Lp()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Dp();return!!(t.path||t.search||this.Np(t))}startIfEnabled(){this.isEnabled&&(hi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Fp=this.Lp(),this.startIfEnabled()}stop(){this.jp&&this.jp(),this.jp=void 0,this.qp&&this.qp(),this.qp=void 0,hi.info("History API monitoring stopped")}monitorHistoryChanges(){un&&un.history&&(this.Bp("pushState"),this.Bp("replaceState"),this.zp(),this.Np()&&this.Hp())}Bp(t){var e;if(un&&(null==(e=un.history[t])||!e.__posthog_wrapped__)){var i=this;Pn(un.history,t,e=>function(r,n,s){var a;i.Up(s)&&i.Wp(),e.call(this,r,n,s),i.Vp(t,!i.Op&&"popstate"!==(null==un||null==(a=un.event)?void 0:a.type))})}}Lp(){var t=null==un?void 0:un.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Dp(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}Np(t){return void 0===t&&(t=this.Dp()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Gp(t){var e=this.Dp(),i=this.Fp;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.Np(e)&&t.hash!==i.hash))}Vp(t,e){void 0===e&&(e=!1);try{e||this.Wp();var i=this.Lp();if(!i)return;if(this.Gp(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.Jp=r,Promise.resolve().then(()=>this.Wp())):r()}this.Fp=i}catch(e){hi.error("Error capturing "+t+" pageview",e)}}Up(t){var e,i;return!(_(t)||!un)&&(null==(e=Tr(String(t)))?void 0:e.href)!==(null==(i=un.location)?void 0:i.href)}Wp(){var t=this.Jp;if(t){this.Jp=void 0,this.Op=!0;try{t()}catch(t){hi.error("Error capturing deferred pageview",t)}finally{this.Op=!1}this.Fp=this.Lp()}}zp(){if(!this.jp){var t=()=>{this.Vp("popstate")};gi(un,"popstate",t),this.jp=()=>{un&&un.removeEventListener("popstate",t)}}}Hp(){if(!this.qp){var t=()=>{this.Vp("hashchange")};gi(un,"hashchange",t),this.qp=()=>{un&&un.removeEventListener("hashchange",t)}}}},Rn=/* @__PURE__ */ci("[TracingHeaders]"),$n=class{constructor(t){this._instance=t,this.Yg=void 0,this.Xg=void 0,this.tm=void 0,this.im=void 0,this.nm=[],this.pg=()=>{var t,e,i=this.sm(),r=i.hostnames;r||i.traceparentTargets?(r||h(this.tm)||(this.tm=[]),this.im!==this.tm&&(this.wg(),this.im=this.tm),f(this.Yg)&&(this.Yg=null==(t=pn.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(this.tm,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.nm)),f(this.Xg)&&(this.Xg=null==(e=pn.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(this.tm,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.nm))):this.wg()}}initialize(){this.startIfEnabledOrStop()}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=gn(this._instance))||i(this._instance,"tracing-headers",e=>{if(e)return Rn.error("failed to load script",e);t()})}rm(){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}om(){var t=this.rm();return h(t)?(h(this.tm)?this.tm.splice(0,this.tm.length,...t):this.tm=[...t],t.length>0?this.tm:void 0):!h(this.tm)||(this.tm.splice(0),t)?(this.tm=t||void 0,this.tm):void 0}lm(){var t=this._instance.config.trace_propagation_targets,e=h(t)?t.filter(t=>p(t)&&!!t):[];return this.nm.splice(0,this.nm.length,...e),e.length>0?this.nm:void 0}sm(){return{hostnames:this.om(),traceparentTargets:this.lm()}}wg(){var t,e;null==(t=this.Yg)||t.call(this),null==(e=this.Xg)||e.call(this),this.Yg=void 0,this.Xg=void 0}startIfEnabledOrStop(){var t=this.sm();t.hostnames||t.traceparentTargets?this.lu(this.pg):this.wg()}};function Mn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var In=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Dn=["ScCid","SsCid"],jn={sccid:Dn},Ln=/* @__PURE__ */(()=>[...In,...Dn,"sscid"])(),Nn=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...In])(),zn="<masked>",Bn=["li_fat_id"];var Un=/* @__PURE__ */ci("[Web Vitals]"),Hn=9e5,qn=["CLS","FCP","INP","LCP"],Vn=["INP","LCP"],Wn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Gn=class{constructor(t){var i,r=this;this._instance=t,this.Qp=!1,this.qa=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.cg=function(t){void 0===t&&(t=!1),clearTimeout(r.hg),r.hg=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.dg=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},_(null==t?void 0:t.name)||_(null==t?void 0:t.value))Un.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.vg(r);if(!f(n)){var s=y(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.fg||this.fg>t.value){this.Rt.navigationKey!==s&&(this.cg(),this.hg=setTimeout(this.cg,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 Wn){var h="url"===u&&"string"==typeof t.attribution[u]?this.vg(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.cg()}else Un.error("Ignoring metric with value >= "+this.fg,t)}}},this.pg=()=>{if(!this.qa){var t,i,r,n,s=!1,a=pn.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.gg])||("web-vitals"===this.gg&&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.dg.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.dg.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.dg.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.dg.bind(this),v);var d=null==un?void 0:un.document;gi(d,Mi,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.cg(!0)}),gi(un,"pagehide",()=>this.cg(!0)),this.qa=!0}else Un.error("web vitals callbacks not loaded - not starting")}},this.Qp=!(null==(i=this._instance.persistence)||!i.props[Xr]),this.startIfEnabled()}get mg(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.mg)?null==(t=this.mg)?void 0:t.web_vitals_allowed_metrics:void 0;return _(i)?(null==(e=this._instance.persistence)?void 0:e.props.$web_vitals_allowed_metrics)||qn:i}get flushToCaptureTimeoutMs(){return(v(this.mg)?this.mg.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.mg)?this.mg.web_vitals_attribution:void 0;return b(t)?t?qn:[]:h(t)?t:Vn}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.mg)?this.mg.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get fg(){var t=v(this.mg)&&y(this.mg.__web_vitals_max_value)?this.mg.__web_vitals_max_value:Hn;return t>0&&6e4>=t?Hn:t}get isEnabled(){var t=null==dn?void 0:dn.protocol;if("http:"!==t&&"https:"!==t)return Un.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.mg)?this.mg.web_vitals:b(this.mg)?this.mg:void 0;return b(e)?e:this.Qp}startIfEnabled(){this.isEnabled&&!this.qa&&(Un.info("enabled, starting..."),this.lu(this.pg))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=v(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=v(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xr]:i}),this._instance.persistence.register({[Qr]:r})),this.Qp=i,this.startIfEnabled()}}}get gg(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}lu(t){var e,i=pn.__PosthogExtensions__,r=this.gg,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=n&&n[r]||"web-vitals"===r&&f(n)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==(e=gn(this._instance))||e(this._instance,r,e=>{e?Un.error("failed to load script",e):t()})}vg(t){var e=t||(null==un?void 0:un.location.href);if(e){var i=this._instance.config.disable_capture_url_hashes?J(e):e,r=this._instance.config.custom_personal_data_properties;return An(i,this._instance.config.mask_personal_data_properties?[...Ln,...r||[]]:[],zn)}Un.error("Could not determine current URL")}},Kn=/* @__PURE__ */ci("[RemoteConfig]"),Jn=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Rc(t){var e=gn(this._instance);e?e(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Pc(t){var e=this._instance.__pending_remote_config_callbacks;if(e)e.push(t);else{var i=[t];this._instance.__pending_remote_config_callbacks=i;try{this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),batchKey:"remote_config",fireCallbackOnDrop:!0,callback:t=>{this._instance.__pending_remote_config_callbacks=void 0,i.forEach(e=>e(t))}})}catch(t){throw this._instance.__pending_remote_config_callbacks=void 0,t}}}load(){try{if(this.remoteConfig)return Kn.info("Using preloaded remote config",this.remoteConfig),void this.Oc(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Kn.warn("Remote config is disabled. Falling back to local config.");if(!this._instance.config.opt_in_site_apps)return void this.Pc(t=>{this.Oc(t.json,t)});this.Rc(t=>{if(!t)return Kn.info("No config found after loading remote JS config. Falling back to JSON."),void this.Pc(t=>{this.Oc(t.json,t)});this.Oc(t)})}catch(t){Kn.error("Error loading remote config",t),this.Oc()}}Oc(t,e){!t&&e&&(0===e.statusCode?e.error||Kn.warn("Failed to fetch remote config from PostHog."):Kn.error("Failed to fetch remote config from PostHog."));try{this._instance.Oc(t?{ok:!0,config:t}:{ok:!1})}catch(t){Kn.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){Kn.error("Error loading feature flags",t)}}},Xn="disabled",Yn="lazy_loading",Zn=null,Qn={Ot(){if(!m(Zn))return Zn;if(Zn=!0,f(un))Zn=!1;else try{var t="__support__";Qn.$t(t,"xyz"),'"xyz"'!==Qn.Lt(t)&&(Zn=!1),Qn.Dt(t)}catch(t){Zn=!1}return Zn},Ft(t){hi.error("sessionStorage error: ",t)},Lt(t){try{return null==un?void 0:un.sessionStorage.getItem(t)}catch(t){Qn.Ft(t)}return null},Pt(t){try{return JSON.parse(Qn.Lt(t))||null}catch(t){}return null},$t(t,e){try{return null==un||un.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(t){Qn.Ft(t)}return!1},Dt(t){try{null==un||un.sessionStorage.removeItem(t)}catch(t){Qn.Ft(t)}}};function ts(t){return"ph_replay_pending_buffer_"+JSON.stringify([t.persistence_name||t.token,t.token])}var es=/* @__PURE__ */ci("[SessionRecording]"),is=[an,on,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],rs=class{get Yr(){return this._instance.config}get oh(){return this._instance.persistence}get started(){var t;return!(null==(t=this._p)||!t.isStarted)}get status(){var t,e;return this.isReplayOff?Xn:"awaiting_config"===this.wp||"missing_config"===this.wp?this.wp:null!==(t=null==(e=this._p)?void 0:e.status)&&void 0!==t?t:this.wp}constructor(t){var e;if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.wp=Xn,this.kp=void 0,this.Sp=!1,this.li=void 0,this.un=(()=>{var t;if(null==vn||!vn.visibilityState||"visible"===vn.visibilityState)return!0;var e=null==un||null==(t=un.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.gn=()=>{var t;"visible"===(null==vn?void 0:vn.visibilityState)&&(this.un=!0,null==(t=this._p)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw es.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Yr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');var i=this._instance.get_property(nn);p(i)&&"!"===i[0]&&(null==(e=this.oh)||e.unregister(nn)),null!=vn&&vn.addEventListener&&gi(vn,"visibilitychange",this.gn)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.Sp=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.gn),i?this.xp(!0):this.stopRecording()}get $p(){var t,e=!(null==(t=this._instance.get_property(tn))||!t.enabled),i=!this.Yr.disable_session_recording,r=this.Yr.disable_session_recording||this._instance.consent.isOptedOut();return un&&e&&i&&!r}get isReplayOff(){var t;return!!this.Yr.disable_session_recording||this._instance.consent.isOptedOut()||!1===(null==(t=this._instance.get_property("$session_recording_remote_config"))?void 0:t.enabled)}startIfEnabledOrStop(t){if(!this.Sp){var e;if(this._p)if(this.li!==(null==(e=this.Yr.session_recording)?void 0:e.selectMaskingFn))Qn.Dt(ts(this.Yr)),this._p.discard({discardProducerEvents:!0}),this.li=void 0;else if(this._p.isStarted&&this.$p)return void(this.Cp()||this.xp(!0));var i=!f(Object.assign)&&!f(Array.from);this.$p&&i?(this.Tp(t),es.info("starting")):(this.wp=Xn,this.stopRecording())}}Tp(t){var e,i;if(this.$p)if("awaiting_config"!==this.wp&&"missing_config"!==this.wp&&(this.wp=Yn),null!=pn&&null!=(e=pn.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=pn.__PosthogExtensions__)&&i.initSessionRecording)this.Mp(t);else{var r,n=this._instance.sessionManager;null==(r=gn(this._instance))||r(this._instance,this.Ip,e=>{if(!this.Sp&&this.$p&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[an]:!0}),es.error("could not load recorder",e)):void this.Mp(t);this.wp=Xn})}}stopRecording(){var t,e;null==(t=this.kp)||t.call(this),this.kp=void 0,null==(e=this._p)||e.stop()}xp(t){var e,i,r;void 0===t&&(t=!1),t&&(this.li||null!=(e=this.Yr.session_recording)&&e.selectMaskingFn)&&Qn.Dt(ts(this.Yr)),null==(i=this.kp)||i.call(this),this.kp=void 0,null==(r=this._p)||r.discard({discardProducerEvents:t}),this.li=void 0}Ep(){var t,e;null==(t=this.oh)||t.unregister(nn),null==(e=this.oh)||e.unregister("$replay_sample_rate")}Ap(t,e){if(_(t))return null;var i,r=y(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(es.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Rp(t){if(this.oh){var i,r,n=this.oh,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Ap(null==(i=this.Yr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Ap(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;_(o)&&this.Ep();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[tn]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};s(),null==(i=this.kp)||i.call(this),this.kp=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.Rp(e),void this.xp()):(this.Rp(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.wp&&(this.wp="missing_config",this._instance.register_for_session({[on]:!0}),es.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._p)&&i.log?this._p.log(t,e):es.warn("log called before recorder was ready")}get Ip(){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"}Pp(){var t,e=this._instance.get_property(tn);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return es.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!_(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Cp(){var t,e,i;return null==(t=this.Yr.session_recording)||!t.selectMaskingFn||!(!0!==(null==(e=pn.__PosthogExtensions__)||null==(e=e.rrweb)||null==(e=e.record)?void 0:e.supportsSelectMasking)||!0!==(null==(i=pn.__PosthogExtensions__)||null==(i=i.initSessionRecording)?void 0:i.supportsSelectMasking)||this._p&&!0!==this._p.supportsSelectMasking)||(this.wp=Xn,es.error("Session recording has not started: the recorder does not support selectMaskingFn."),!1)}Mp(t){var e,i,r,n,s;if(!this.Sp&&this.$p&&this._instance.sessionManager){if(null==(e=pn.__PosthogExtensions__)||!e.initSessionRecording)return es.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[an]:!0});var a;if(this.Cp())if(this._p||(this._p=null==(a=pn.__PosthogExtensions__)?void 0:a.initSessionRecording(this._instance,this.un),this._p._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Cp()){if(!this.Pp()){if("missing_config"===this.wp||"awaiting_config"===this.wp)return;return this.wp="awaiting_config",es.info("persisted remote config is stale, requesting fresh config before starting"),void new Jn(this._instance).load()}this.wp=Yn,null==(i=(r=this._p).setDocumentWasEverVisible)||i.call(r,this.un);var o=null==(n=this.Yr.session_recording)?void 0:n.selectMaskingFn;this._p.start(t),this.li=o,this._p.isStarted&&o!==(null==(s=this.Yr.session_recording)?void 0:s.selectMaskingFn)&&this.startIfEnabledOrStop()}else this.xp(!0)}else this.wp=Xn}onRRwebEmit(t){var e;null==(e=this._p)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this._p||null==(t=this.oh)||t.register({[rn]:!0}),null==(e=this._p)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this._p||null==(t=this.oh)||t.register({[en]:!0}),null==(e=this._p)||e.overrideSampling()}overrideTrigger(t){var e,i;this._p||null==(e=this.oh)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this._p)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;if(this.isReplayOff)return{$recording_status:Xn};var i={};for(var r of is){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._p)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this._p)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this._p)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}},ns=/* @__PURE__ */ci("[Heatmaps]");function ss(t){return v(t)&&"clientX"in t&&"clientY"in t&&y(t.clientX)&&y(t.clientY)}var as=class{get Yr(){return this.instance.config}constructor(t){var e;this.Qp=!1,this.qa=!1,this.Zp=!1,this.Kp=0,this.Yp=null,this.instance=t,this.Qp=!(null==(e=this.instance.persistence)||!e.props[Wr]),this.rageclicks=new Ar(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Yr.capture_heatmaps)&&this.Yr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Yr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return _(this.Yr.capture_heatmaps)?_(this.Yr.enable_heatmaps)?this.Qp:this.Yr.enable_heatmaps:!1!==this.Yr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.qa)return;ns.info("starting..."),this.Xp(),this.gn()}else{var t;clearInterval(null!==(t=this.Yp)&&void 0!==t?t:void 0),this.tg(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Wr]:i}),this.Qp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}discardPending(){this.Kp=Date.now(),clearTimeout(this.eg),this.eg=void 0,this.getAndClearBuffer()}ig(t){ss(t.originalEvent)&&t.timestamp>this.Kp&&this.Jr(t.originalEvent,"deadclick")}gn(){this.Yp&&clearInterval(this.Yp),this.Yp="visible"===(null==vn?void 0:vn.visibilityState)?setInterval(this.Wc.bind(this),this.flushIntervalMilliseconds):null}Xp(){un&&vn&&(this.ng=this.Wc.bind(this),gi(un,ln,this.ng),this.sg=t=>this.Jr(t||(null==un?void 0:un.event)),gi(vn,"click",this.sg,{capture:!0}),this.rg=t=>this.og(t||(null==un?void 0:un.event)),gi(vn,"mousemove",this.rg,{capture:!0}),this.lg=new yn(this.instance,_n,this.ig.bind(this)),this.lg.startIfEnabledOrStop(),this.ag=this.gn.bind(this),gi(vn,Mi,this.ag),this.qa=!0)}tg(){var t;un&&vn&&(this.ng&&un.removeEventListener(ln,this.ng),this.sg&&vn.removeEventListener("click",this.sg,{capture:!0}),this.rg&&vn.removeEventListener("mousemove",this.rg,{capture:!0}),this.ag&&vn.removeEventListener(Mi,this.ag),clearTimeout(this.eg),this.eg=void 0,null==(t=this.lg)||t.stop(),this.qa=!1)}ug(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(t,e,i){for(var r=t;r&&ji(r)&&!Li(r,"body");){if(r===i)return!1;var n=void 0;try{var a,o,l;n=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:un)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Xi(r)}return!1}(Wi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}Jr(t,i){var r;if(void 0===i&&(i="click"),!Di(t.target)&&ss(t)&&this.instance.is_capturing()){var n=this.ug(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&lr(Wi(t),this.instance.config.rageclick)&&this.Fo(e({},n,{type:"rageclick"})),this.Fo(n)}}og(t){!Di(t.target)&&ss(t)&&(f(this.eg)&&(this.Zp=this.instance.is_capturing()),clearTimeout(this.eg),this.eg=setTimeout(()=>{this.eg=void 0,this.Zp&&this.instance.is_capturing()&&this.Fo(this.ug(t,"mousemove"))},500))}Fo(t){if(un){var e=this.Yr.disable_capture_url_hashes?J(un.location.href):un.location.href,i=this.Yr.custom_personal_data_properties,r=An(e,this.Yr.mask_personal_data_properties?[...Ln,...i||[]]:[],zn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}Wc(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},os=/* @__PURE__ */ci("[Product Tours]"),ls=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Zr))},us=class{get oh(){return this._instance.persistence}constructor(t){this.Ng=null,this.jg=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.oh&&this.oh.register({[Zr]:!!e.productTours}),!ls(this._instance))return!this.Ng&&_(null==(i=this.oh)?void 0:i.props.ph_product_tours)||os.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Ng)||r.stop(),this.Ng=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Ng&&ls(this._instance)&&this.lu(()=>this.qg())}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=gn(this._instance))||i(this._instance,"product-tours",e=>{e?os.error("Could not load product tours script",e):t()})}qg(){var t;!this.Ng&&null!=(t=pn.__PosthogExtensions__)&&t.generateProductTours&&(this.Ng=pn.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.jg)||e){var i=this.oh;if(i){var r=i.props[sn];if(h(r)&&!e)return this.jg=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(ls(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||os.warn(n):os.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.jg=s,i&&i.register({[sn]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.jg,{isLoaded:!0})}getActiveProductTours(t){_(this.Ng)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ng.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Ng)||e.showTourById(t)}previewTour(t){this.Ng?this.Ng.previewTour(t):this.lu(()=>{var e;this.qg(),null==(e=this.Ng)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Ng)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Ng)||t.nextStep()}previousStep(){var t;null==(t=this.Ng)||t.previousStep()}clearCache(){var t;this.jg=null,null==(t=this.oh)||t.unregister(sn)}resetTour(t){var e;null==(e=this.Ng)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Ng)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Ng)||e.cancelPendingTour(t)}},hs=/* @__PURE__ */ci("[SiteApps]"),cs="Error while initializing PostHog app with config id ",vs=class{constructor(t){this._instance=t,this.Bg=0,this.zg=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps&&!this._instance.config.require_subresource_integrity}Hg(t,e){if(e){var i=this.globalsForEvent(e);this.zg.push(i),this.zg.length>1e3&&(this.zg=this.zg.slice(10))}}get siteAppLoaders(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this._instance.config.opt_in_site_apps&&!this.isEnabled&&hs.critical("opt_in_site_apps is ignored: require_subresource_integrity disables site apps"),this.isEnabled){var t=this._instance._addCaptureHook(this.Hg.bind(this));this.Ug=()=>{t(),this.zg=[],this.Ug=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}}Wg(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)||(hs.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)||(hs.error("prepare_external_dependency_script returned null"),null):t}Vg(){var t,e,i,r,n,s,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==vn?void 0:vn.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Bg++,this.Gg)return this.Jg();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.Wg(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.Gg=()=>{h.forEach(t=>t()),this.Gg=void 0},this.Jg()}Jg(){var t=!1;return()=>{var e;t||(t=!0,this.Bg--,0===this.Bg&&(null==(e=this.Gg)||e.call(this)))}}Qg(t,e){void 0===e&&(e=!0);var i=this.Vg();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.zg.length&&(hs.info("Processing "+this.zg.length+" events for site app with id "+t.id),this.zg.forEach(t=>this.Qg(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.Ug)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,hs.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.Qg(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){hs.error(cs+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){hs.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Zg(){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)}Kg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Qg(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){hs.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.Zg(),void this._instance.on("eventCaptured",t=>this.Kg(t))):void hs.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Ug)||i.call(this),t.ok){var s=t.config;if(null!=(r=s.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,e=o.id,i=o.url;pn["__$$ph_site_app_"+e]=n._instance,null==(t=pn.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return hs.error(cs+e,t)})};for(var o of s.siteApps)a()}else hs.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ds="events",fs="cancelEvents",ps="survey shown",gs="survey dismissed",ms="survey sent";function _s(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var ys=(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}},bs=t=>t.toLowerCase(),ws={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=>ys(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!ys(e,t))),icontains:(t,e)=>e.map(bs).some(e=>t.map(bs).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(bs).every(e=>t.map(bs).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 xs(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=ws[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var Ss=/* @__PURE__ */ci("[Surveys]"),ks=["popover","widget","api"],Es=class{on(t,e){return this.Zo[t]||(this.Zo[t]=[]),this.Zo[t].push(e),()=>{this.Zo[t]=this.Zo[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.Zo[t]||[])i(e);for(var r of this.Zo["*"]||[])r(t,e)}constructor(){this.Zo={}}};function As(t,e,i){if(_(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 Ts=class{constructor(t){this.Gi=t,this.Ko=/* @__PURE__ */new Set,this.Yo=/* @__PURE__ */new Set,this.Xo=new Es,this.tl=(t,e)=>this.el(t,e)&&this.il(t,e)&&this.nl(t,e)&&this.sl(t,e),this.el=(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.Gi)?void 0:t.subscribeCapture)||(this.rl=null==(e=this.Gi)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.rl)||t.call(this),this.rl=void 0,null==(e=this.Gi)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.Xo=new Es}register(t){var e,i;if(!f(null==(e=this.Gi)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.Ko.add(t),null==(e=t.steps)||e.forEach(t=>{this.Yo.add((null==t?void 0:t.event)||"")})}),null!=(i=this.Gi)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.Ko.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.Gi.setElementSelectors(r,this)}}replace(t){this.Ko.clear(),this.Yo.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.Yo.has(t)||this.Yo.has(e.event))&&this.Ko.forEach(t=>{this.ll(e,t)&&this.Xo.emit("actionCaptured",t.name)})}al(t){this.onAction("actionCaptured",e=>t(e))}ll(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.tl(t,i))return!0;return!1}onAction(t,e){return this.Xo.on(t,e)}il(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.Gi)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!As(r,e.url,e.url_matching||"contains"))return!1}return!0}nl(t,e){return!!this.ul(t,e)&&!!this.cl(t,e)&&!!this.hl(t,e)}ul(t,e){var i;if(null==e||!e.href)return!0;var r=this.dl(t);if(r.length>0)return r.some(t=>As(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&As((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}cl(t,e){var i;if(null==e||!e.text)return!0;var r=this.dl(t);if(r.length>0)return r.some(t=>As(t.text,e.text,e.text_matching||"exact")||As(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;!_(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=>As(t,s,a)))}hl(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}dl(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}sl(t,e){return null==e||!e.properties||0===e.properties.length||xs(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)}},Fs=class{constructor(t,e){this.vl=e,this.fl=[],this.Gi=t,this.pl=/* @__PURE__ */new Map,this.gl=/* @__PURE__ */new Map,this.ml=/* @__PURE__ */new Map}yl(){var t,e;this.bl=null==(t=(e=this.Gi).subscribeSession)?void 0:t.call(e,t=>this._l(t))}wl(t){return!1}kl(){return null}Sl(t){}xl(){}$l(t,e){return!!t&&xs(t.propertyFilters,null==e?void 0:e.properties)}Cl(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}Tl(t,e,i){var r=(i===ds?this.pl:this.gl).get(t),n=[];return this.Ml(t=>{n=t.filter(t=>null==r?void 0:r.includes(t.id))}),n.filter(r=>{var n,s=null==(n=r.conditions)||null==(n=n[i])||null==(n=n.values)?void 0:n.find(e=>e.name===t);return this.$l(s,e)})}register(t){this.Il(t,!1)}replace(t){this.Il(t,!0)}Il(t,e){f(this.Gi.subscribeCapture)||(this.El(t,e),this.Al(t,e))}Al(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.ml.clear(),0!==i.length){this.Rl||(this.Rl=new Ts(this.Gi),this.Rl.init(),this.Rl.al(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.ml.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.ml.set(e.name,n)}})}),e?this.Rl.replace(r):this.Rl.register(r)}else{var n;e&&(null==(n=this.Rl)||n.replace([]))}}Pl(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)})}El(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.Cl(t,ds),l=this.Cl(t,fs);e?(this.pl=o,this.gl=l):(this.Pl(this.pl,o),this.Pl(this.gl,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.rl)&&void 0!==i||(this.rl=null==(r=(n=this.Gi).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.Ol(),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.Fl(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.Ll([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.Dl(s),void this.Nl([s])}if(this.gl.has(t)){var o=this.Tl(t,e,fs);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.Ll(o.map(t=>t.id)),o.forEach(t=>this.jl(t.id)))}if(this.pl.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.pl.get(t)});var l=this.Tl(t,e,ds);this.ql(l.map(t=>t.id))}}onAction(t){this.ml.has(t)&&this.ql(this.ml.get(t)||[])}ql(t){if(0!==t.length){var e=!!this.Gi.getSessionId(),i=[];for(var r of t)e&&this.wl(r)?this.Dl(r)&&this.Bl(r):i.push(r);i.length>0&&(this.fl=[.../* @__PURE__ */new Set([...this.fl,...i])]),this.Ol().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.zl()}}Dl(t){this.fl=this.fl.filter(e=>e!==t);var e=this.Hl();return!e.includes(t)&&(this.Ul([...e,t]),this.Wl(),!0)}Ll(t){var e=new Set(t);this.fl=this.fl.filter(t=>!e.has(t));var i=this.Vl(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.Ul(r),0===r.length&&this.Gl()),this.Nl(t),this.zl()}zl(){try{var t;null==(t=this.vl)||t.call(this)}catch(t){this.Ol().error("Error while handling activated items change",t)}}Jl(){var t=this.kl();if(!t)return{};var e=this.Gi.getProperty(t);return e&&"object"==typeof e?e:{}}Bl(t){if(this.kl()){var i=this.Jl();this.Sl(e({},i,{[t]:Date.now()}))}}Nl(t){if(this.kl()){var e=this.Jl(),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.xl():this.Sl(i))}}Ql(){this.kl()&&this.xl()}getActivationTimestamp(t){if(this.Hl().includes(t)){var e=this.Jl()[t];return y(e)?e:void 0}}Vl(){var t=this.Zl();return this.Gi.getProperty(t)||[]}Hl(){var t=this.Vl();if(0===t.length)return[];var e=this.Gi.getProperty(this.Kl()),i=this.Gi.getSessionId();return i&&e===i?t:[]}Wl(){var t=this.Gi.getSessionId();t&&this.Yl(t)}Gl(){this.Xl()}_l(t){var e=this.Gi.getProperty(this.Kl());if(e&&e!==t){var i=this.Vl(),r=this.Jl();i.length>0&&(this.Ul([]),i.filter(t=>y(r[t])).forEach(t=>this.jl(t))),this.Gl(),this.Ql(),i.length>0&&this.zl()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.Hl(),...this.fl])].filter(t=>!this.ta(t))}dispose(){var t,e,i;null==(t=this.bl)||t.call(this),this.bl=void 0,null==(e=this.rl)||e.call(this),this.rl=void 0,null==(i=this.Rl)||i.dispose(),this.Rl=void 0}reset(){this.fl=[],this.Vl().length>0&&this.Ul([]),this.Gl(),this.Ql(),this.zl()}getEventToItemsMap(){return this.pl}ea(){return this.Rl}},Os=class extends Fs{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.ia=t,this.na=e,this.yl()}Zl(){return Hr}Kl(){return qr}kl(){return Vr}Sl(t){this.ia.kv.set({[Vr]:t})}xl(){this.ia.kv.remove(Vr)}wl(t){var e,i;this.Ml(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return y(r)&&r>0}sa(){return ps}Ml(t){this.na.getSurveys(t)}jl(t){this.na.cancelPendingSurvey(t)}Ol(){return Ss}Ul(t){this.ia.kv.set({[Hr]:t})}Yl(t){this.ia.kv.set({[qr]:t})}Xl(){this.ia.kv.remove(qr)}ta(){return!1}Fl(t,e,i){var r,n;return t===ms&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.Ml(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return _s(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===ps?"consume":"ignore":t===ps?"persist":t===gs||t===ms?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ps=(t,e)=>null!=t&&t.then?t.then(e):e(t),Cs="SDK is not enabled or survey functionality is not yet loaded",Rs="Disabled. Not loading surveys.",$s=class{constructor(t){this.ra=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.oa=!1,this.la=!1,this.aa=[],this.ua=[],this.ca=null,this.ha=null,this.qi=!1,this.da=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.qi&&!this.Yr.disableSurveys){if(!t.ok)return this.la=!0,this.va({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),Ss.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(_(e))return Ss.warn("Flags not loaded yet. Not loading surveys.");this.fa=b(e)?e:e.length>0,Ss.info("flags response received, isSurveysEnabled: "+this.fa),this.loadIfEnabled()}},this.va=t=>{this.ua.slice().forEach(e=>this.pa(e,t))}}setup(t){if(!this.qi)return this.ga=t,Ps(t.kv.initialize(),()=>{if(this.ga===t&&!this.qi){this.ga=void 0,this.ia=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.qi?e.dispose():(this.ma=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.qi||(this.qi=!0,this.ga=void 0,this.ia=void 0,null==(t=this.ma)||t.dispose(),this.ma=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.aa=[],this.ua.forEach(t=>{t.active=!1}),this.ua=[],null==(r=this.ya)||r.call(this),this.ya=void 0,this.ca=null,this.da.forEach(t=>clearTimeout(t)),this.da.clear())}get Yr(){return this.ra.get()}getRenderContext(){if(this.ia){var t=this;return{client:this.ia,get config(){return t.Yr},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.qi&&this.ia){var t=this.Yr;if(!this._surveyManager)if(this.oa)Ss.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Ss.info(Rs);else if(t.cookielessMode&&this.ia.isOptedOut)Ss.info("Not loading surveys in cookieless mode without consent.");else{var e=this.ra.getExtensions();if(e){if(!f(this.fa)||t.advancedEnableSurveys){var i=this.fa||t.advancedEnableSurveys;this.oa=!0,this.la=!1;try{var r=e.generateSurveys;if(r)return this._a(r,i),void(this.oa=!1);var n=e.loadExternalDependency;if(!n)return this.ba(Ur),void(this.oa=!1);n(t=>{try{if(this.qi)return;var e=this.ra.getExtensions();t||null==e||!e.generateSurveys?this.ba("Could not load surveys script",t):this._a(e.generateSurveys,i)}finally{this.oa=!1}})}catch(t){throw this.oa=!1,this.ba("Error initializing surveys",t),t}}}else this.ba("PostHog Extensions not found.")}}}_a(t,e){var i;if(!this.qi){this._surveyManager=t(e),this._surveyEventReceiver=this.wa(this.ia,this.va);var r=null==(i=this.ia)?void 0:i.kv.get(zr);r&&this.ka(r),Ss.info("Surveys loaded successfully"),this.Sa(),this.va(),this.xa({isLoaded:!0})}}wa(t,e){return new Os(t,this,void 0,e)}ba(t,e){this.la=!0,Ss.error(t,e),this.va({isLoaded:!1,error:t}),this.xa({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.aa.push(t),this._surveyManager&&this.xa({isLoaded:!0}),()=>{this.aa=this.aa.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.qi){var i=this.ia;if(!i)return t([],{isLoaded:!1,error:Cs});if(this.Yr.disableSurveys)return Ss.info(Rs),t([]);var r=i.kv.get(zr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.$a()&&this.getSurveys(()=>{},!0));if(this.ca)this.ca.then(e=>{this.qi||t(e.surveys,e.context)}).catch(t=>Ss.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Yr.requestTimeoutMs}).then(t=>{try{return this.Ca(i,t)}catch(t){return Ss.error("Error processing surveys response",t),this.Ca(i,{statusCode:0,error:t})}},t=>this.Ca(i,{statusCode:0,error:t}));this.ca=n;var s=()=>{this.ca===n&&(this.ca=null)};n.then(e=>{s(),this.qi||(this.va(e.context),t(e.surveys,e.context))},s).catch(t=>Ss.error("Error in survey callback",t))}}}Ca(t,e){if(this.qi)return{surveys:[],context:{isLoaded:!1,error:Cs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?Ss.error(r):e.error||Ss.warn(r),this.ha=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.ha=null;var n=e.json.surveys||[];return t.kv.set({[zr]:n,[Br]:Date.now()}),this.ka(n),{surveys:n,context:{isLoaded:!0}}}ka(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(_s(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.Ta(e)}Ta(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}$a(){return this.Ma()&&!this.ca&&!this.Ia()}Ma(){var t,e=null==(t=this.ia)?void 0:t.kv.get(Br);return y(e)&&Date.now()-e>3e5}Ia(){return y(this.ha)&&3e5>Date.now()-this.ha}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){Ss.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",/* @__PURE__ */(new Date).toISOString())}catch(t){}this.va()}xa(t){for(var e of this.aa){if(this.qi)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){Ss.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!_(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Ss.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.qi)return()=>{};var i={callback:t,active:!0,revision:0};this.ua.push(i),this.Sa();var r=null==(e=this.ia)?void 0:e.kv.get(zr);return this.Yr.disableSurveys||!this._surveyManager&&this.la&&!this.oa||!r&&!_(this.ha)&&!this.ca?this.pa(i,{isLoaded:!1}):this._surveyManager&&this.pa(i),()=>{var t;i.active=!1,this.ua=this.ua.filter(t=>t!==i),0===this.ua.length&&(null==(t=this.ya)||t.call(this),this.ya=void 0)}}Sa(){var t,e,i;this._surveyManager&&this.ua.length>0&&(null!==(t=this.ya)&&void 0!==t||(this.ya=null==(e=(i=this.ra).onMatchingConditionsChanged)?void 0:e.call(i,this.va)))}pa(t,e){if(!this.qi&&t.active){var i=++t.revision,r=r=>{if(!this.qi&&t.active&&i===t.revision)try{var n=null!=e?e:{isLoaded:!0},s=JSON.stringify([r,n]);if(s===t.lastResult)return;t.lastResult=s,t.callback(r,n)}catch(t){Ss.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){Ss.error("Error in active matching surveys callback",t)}}}Ea(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}Aa(t){if(_(this._surveyManager))return{eligible:!1,reason:Cs};var e="string"==typeof t?this.Ea(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Ra(t){var e;if(null==(e=this.ia)||!e.canCapture)return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(_(this._surveyManager))return{eligible:!1,reason:Cs};var i="string"==typeof t?this.Ea(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(_(this._surveyManager))return Ss.warn("init was not called"),{visible:!1,disabledReason:Cs};var e=this.Ra(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return _(this._surveyManager)?(Ss.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Cs})):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.Ra(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.ia)&&r.canCapture)if(_(this._surveyManager))Ss.warn("init was not called");else{var a="string"==typeof t?this.Ea(t):t;if(null!=a&&a.id)if(ks.includes(a.type)){var o=null==(n=typeof document>"u"?void 0:document)?void 0:n.querySelector(e);if(o)if(null!=(s=a.appearance)&&s.surveyPopupDelaySeconds){Ss.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.da.delete(l),!this.qi&&null!=(t=this.ia)&&t.canCapture&&(Ss.info("Rendering survey "+a.id+" with delay of "+(null==(e=a.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(r=this._surveyManager)||r.renderSurvey(a,o,i),Ss.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.da.add(l)}else this._surveyManager.renderSurvey(a,o,i);else Ss.warn("Survey element not found")}else Ss.warn("Surveys of type "+a.type+" cannot be rendered in the app");else Ss.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.ia)&&r.canCapture)if(_(this._surveyManager))Ss.warn("init was not called");else{var s=this.Ea(t);if(s){var a=s;if(null!=(n=s.appearance)&&n.surveyPopupDelaySeconds&&i.ignoreDelay&&(a=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&Ss.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.Aa(s);if(!o.eligible)return void Ss.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(a,i):this.renderSurvey(a,i.selector,i.properties)}else Ss.warn("Survey not found")}}cancelPendingSurvey(t){_(this._surveyManager)?Ss.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};li.DEBUG=!1,li.LIB_VERSION="1.455.0",li.LIB_NAME="web";var Ms,Is=li,Ds=/* @__PURE__ */new WeakMap,js=()=>{var t;return null!=un&&null!=(t=un.performance)&&t.now?un.performance.now():Date.now()},Ls=class{constructor(t){this._instance=t}get(){var t,e,i,r,n=null==(t=this._instance)?void 0:t.config;return{disableSurveys:!(null==n||!n.disable_surveys),cookielessMode:!(null==n||!n.cookieless_mode),advancedEnableSurveys:!(null==n||!n.advanced_enable_surveys),requestTimeoutMs:null!==(e=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==e?e:1e4,prefillFromUrl:!(null==n||null==(i=n.surveys)||!i.prefillFromUrl),automaticDisplay:!(null!=n&&n.disable_surveys_automatic_display),featureFlagEvaluation:!(null!=n&&n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null==(r=this._instance)||null==(r=r.requestRouter)?void 0:r.endpointFor("ui","")}}getExtensions(){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=gn(e);return{generateSurveys:i?t=>i(e,t):void 0,loadExternalDependency:r?t=>r(e,"surveys",t):void 0}}}onMatchingConditionsChanged(t){var e,i,r=null==(e=this._instance)?void 0:e._addCaptureHook(e=>{"$pageview"!==e&&e!==ps&&e!==gs&&e!==ms||t()}),n=()=>t();gi(un,"PHSurveyShown",n);var s=!1,a=null==(i=this._instance)?void 0:i.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,null==r||r(),null==a||a(),null==un||un.removeEventListener("PHSurveyShown",n)}}},Ns=class extends $s{constructor(t){super(new Ls(t))}},zs=/* @__PURE__ */(()=>null!=un&&un.location?Tn(un.location.hash,"__posthog")||Tn(location.hash,"state"):null)(),Bs="_postHogToolbarParams",Us=/* @__PURE__ */ci("[Toolbar]"),Hs=class{constructor(t){this.instance=t}am(t){pn.ph_toolbar_state=t}um(){var t;return null!==(t=pn.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),mi(this.instance.config))return!1;if(!un||!vn)return!1;t=null!=t?t:un.location,i=null!=i?i:un.history;try{if(!e){try{un.localStorage.setItem("test","test"),un.localStorage.removeItem("test")}catch(t){return!1}e=null==un?void 0:un.localStorage}var r,n=zs||Tn(t.hash,"__posthog")||Tn(t.hash,"state"),s=n?X(()=>JSON.parse(atob(decodeURIComponent(n))))||X(()=>JSON.parse(decodeURIComponent(n))):null;return s&&"ph_authorize"===s.action?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?t.hash=s.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(Bs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}hm(t){var e=pn.ph_load_toolbar||pn.ph_load_editor;!_(e)&&c(e)?e(t,this.instance):Us.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==vn||!vn.getElementById("__POSTHOG_TOOLBAR__"));if(!un||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(un.localStorage.setItem(Bs,JSON.stringify(e({},n,{source:void 0}))),2===this.um())this.hm(n);else if(0===this.um()){var s;this.am(1),null==(s=gn(this.instance))||s(this.instance,"toolbar",t=>{if(t)return Us.error("[Toolbar] Failed to load",t),void this.am(0);this.am(2),this.hm(n)}),gi(un,"turbolinks:load",()=>{this.am(0),this.loadToolbar(n)})}return!0}dm(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)}},qs=/* @__PURE__ */ci("[FeatureFlags]"),Vs=/* @__PURE__ */ci("[FeatureFlags]",{debugEnabled:!0}),Ws="\" failed. Feature flags didn't load in time.",Gs=[502,504],Ks=["click","keydown","wheel","touchstart","pointerdown"],Js="connection_error",Xs=(t,i)=>{var r=Object.keys(i||{}).filter(t=>{var e;return null==i||null==(e=i[t])?void 0:e.failed});if(!r.length)return t||{};var n=e({},t);return r.forEach(t=>delete n[t]),n},Ys=(t,i)=>{var r=e({},t);return i.forEach(t=>{var e;null!=(e=r[t])&&e.failed&&delete r[t]}),r},Zs=(t,e)=>!(null==e||!e.partialResponse)||!!t.errorsWhileComputingFlags,Qs=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},ta=t=>{var e={};for(var i of pi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},ea=(t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed).map(t=>{var e;return[t,null!==(e=r[t].variant)&&void 0!==e?e:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed&&r[t].enabled).filter(t=>{var e;return!f(null==(e=r[t].metadata)?void 0:e.payload)}).map(t=>{var e;return[t,null==(e=r[t].metadata)?void 0:e.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)},ia={version:2},ra=(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),na=class{constructor(t){this.name="featureFlags",this.uv=!1,this.featureFlagEventHandlers=[],this.R=qs,this.hv={},this.dv={},this.vv=[],this.fv=/* @__PURE__ */new Set,this.pv=/* @__PURE__ */new Set,this.gv=!1,this.mv=!1,this.yv=0,this.bv=!1,this._v=!1,this.wv=!1,this.Sv=/* @__PURE__ */new Map,this.xv=!1,this.$v=!1,this.Cv=!1,this.Tv=0,this.Mv=!1,this.Iv=!1,this.Ev=/* @__PURE__ */new WeakMap,this.Av=/* @__PURE__ */new Map,this.mn=()=>{var t=this.Rv();this.Tv=0,t&&this.reloadFeatureFlags()},this.Pv=()=>{var t,e,i=this.Ov,r=null!==(t=this.Fv)&&void 0!==t?t:i;f(i)||f(r)||this.Yr.remoteRequestsDisabled||!this.Lv||"hidden"===this.Lv.visibilityState||Date.now()-(null!==(e=this.Dv)&&void 0!==e?e:0)<r||(this.Fv=this.Mv||!this.Yr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Mv=!1,this.reloadFeatureFlags(),this.Nv())},this.jv=()=>{this.Mv&&this.Fv===this.Ov||this.qv()},this.gn=()=>{var t;"visible"===(null==(t=this.Lv)?void 0:t.visibilityState)&&this.qv()},this.ra=t}get Bv(){return ia}get zv(){}Hv(){this.ia&&this.Uv()}setup(t){try{this.Wv=typeof window>"u"?void 0:window,this.Lv=typeof document>"u"?void 0:document}catch(t){this.Wv=void 0,this.Lv=void 0}return this.ga=t,this.R=t.logger.createLogger("[FeatureFlags]"),Ps(t.kv.initialize(),()=>{this.ga===t&&(this.ga=void 0,this.ia=t,this.Vv(t))})}Vv(t){var e;if(this.ia===t)return this.Wv&&gi(this.Wv,"online",this.mn),this.Uv(),this.Gv=t.registerDynamicEventProperties(()=>this.Jv()?this.hv:this.dv),this.Qv=null==(e=this.zv)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Zv(),this.Kv(),this.Yv()}),this.Kv(),this.initialize()}qv(){this.Mv=!0,this.Fv=this.Ov,this.Pv()}Uv(){var t,e=this.Yr.refreshIntervalMs,i=!this.Yr.remoteRequestsDisabled&&this.Lv&&!f(e)&&e>0?e:void 0;this.Yr.idleRefreshBackoff||(this.Fv=i),i!==this.Ov&&(this.Xv(),f(i)||(this.Ov=i,this.Fv=i,this.Nv(),null!=(t=this.Lv)&&t.addEventListener&&(gi(this.Lv,Mi,this.gn),vi(Ks,t=>{gi(this.Lv,t,this.jv,{capture:!0})}))))}Nv(){f(this.Ov)||(f(this.tf)||clearInterval(this.tf),this.Dv=Date.now(),this.tf=setInterval(this.Pv,this.Ov))}Xv(){var t;f(this.tf)||(clearInterval(this.tf),this.tf=void 0,null==(t=this.Lv)||null==t.removeEventListener||t.removeEventListener(Mi,this.gn),vi(Ks,t=>{var e;null==(e=this.Lv)||null==e.removeEventListener||e.removeEventListener(t,this.jv,{capture:!0})})),this.Ov=void 0,this.Fv=void 0,this.Mv=!1,this.Dv=void 0}destroy(){this.ef()}dispose(){this.ef()}ef(){var t,e,i;this.Xv(),this.yv++,this._v=!1,this.ga=void 0,this.if(this.fv,"cancelled"),this.if(this.pv,"cancelled"),this.ia&&(this.nf(),null==(t=this.Gv)||t.dispose(),this.Gv=void 0,null==(e=this.Qv)||e.call(this),this.Qv=void 0,this.vv=[],null==(i=this.Wv)||i.removeEventListener("online",this.mn),this.ia=void 0)}get Yr(){return this.ra.get()}sf(t){var e;return this.rf&&t in this.rf?this.rf[t]:null==(e=this.ia)?void 0:e.kv.get(t)}Zv(){return!!this.rf&&(this.rf=void 0,!0)}lf(){var t;return!f(null==(t=this.ia)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Zv()}$t(t){this.af(()=>{var e;return null==(e=this.ia)?void 0:e.kv.set(t)})}uf(t,e,i){if(this.zv&&t.$enabled_feature_flags){var r=this.sf("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(t=>{var e=t[1];return!(null!=e&&e.failed)}).map(t=>t[0]):[],o=!!e.errorsWhileComputingFlags&&!!e.flags,l=o||i&&e.flags?a:i&&!h(s)?Object.keys(s||{}):Array.from(/* @__PURE__ */new Set([...Object.keys(r),...Object.keys(n)])),u=this.sf("$feature_flag_payloads")||{},c=t.$feature_flag_payloads||{},v=o||i?l:Array.from(/* @__PURE__ */new Set([...Object.keys(u),...Object.keys(c)])),d=!o&&!i,p=!!d||l,g=!!d||v,m={[bi]:p,[Ai]:p,[Ci]:g};for(var _ of(t.$feature_flag_details&&(m[wi]=p),[ki,Si,Ei]))f(t[_])||(m[_]=!0);this.zv.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.af(()=>{var e;return null==(e=this.ia)?void 0:e.kv.remove(t)})}af(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}Kv(){var t={},i=this.sf(wi);for(var r of[ki,Ri]){var n=this.sf(r);f(n)||(t[r]=n)}var s=this.sf(bi);s&&(t[bi]=s.filter(t=>{var e;return!(null!=i&&null!=(e=i[t])&&e.failed)}));var a=this.sf(Ci);a&&(t[Ci]=Xs(a,i)),this.hv=t;var o=e({},t),l=Xs(this.sf(Ai),i);if(l)for(var u of Object.entries(l))o["$feature/"+u[0]]=u[1];this.dv=o}Jv(){var t=this.Yr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.sf(Si);return"number"!=typeof e||Date.now()-e>t}cf(){return!!this.Jv()&&(this.Cv||this.mv||(this.Cv=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}hf(){var t=this.Yr.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}):[]}df(){var t=this.Yr.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.Yr,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]=i.encodeBootstrapPayloads?JSON.stringify(a[e]):a[e],t),{});return this.vf({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n=null!=r&&r.merge?Xs(this.sf(Ai),this.sf(wi)):{},s=null!=r&&r.merge?Xs(this.sf(Ci),this.sf(wi)):{},a=e({},n,t),o=e({},s,i),l={};for(var u of Object.entries(a)){var h=u[0],c=u[1];l[h]={key:h,enabled:Ut(c),variant:Ht(c),reason:void 0,metadata:f(null==o?void 0:o[h])?void 0:{id:0,version:void 0,description:void 0,payload:o[h]}}}this.vf({flags:l})}get hasLoadedFlags(){return this.gv}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.ff(),e=this.Bv.publicDetail;return e?Object.fromEntries(Object.entries(t).map(t=>[t[0],e(t[1])])):t}ff(){var t=this.sf(wi),i=this.sf(Ri),r=this.sf($i);if(!r&&!i)return t||{};var n=fi({},t||{});for(var s of[.../* @__PURE__ */new Set([...Object.keys(r||{}),...Object.keys(i||{})])]){var a,o,l=n[s],u=null==i?void 0:i[s],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,c=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,v=null==r?void 0:r[s],d=e({},l,{enabled:h,variant:h?null!=c?c:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(d.original_enabled=null==l?void 0:l.enabled),c!==(null==l?void 0:l.variant)&&(d.original_variant=null==l?void 0:l.variant),v&&(d.metadata=e({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),n[s]=d}return this.uv||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.uv=!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=Xs(this.sf(Ai),this.sf(wi)),e=this.sf(Ri);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.uv||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.uv=!0),i}getFlagPayloads(){var t=Xs(this.sf(Ci),this.sf(wi)),e=this.sf($i);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.uv||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.uv=!0),i}reloadFeatureFlags(){this.bv||this.Yr.featureFlagsDisabled||this.Rv()||(this.wv&&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.mv&&(this._v=!0),this.pf||(this.pf=setTimeout(()=>{this.gf()},5),this.vv.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}})))}reloadFeatureFlagsAsync(){return!this.ia||this.bv||this.Yr.featureFlagsDisabled||this.Yr.remoteRequestsDisabled||this.Rv()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.fv.add(t),this.reloadFeatureFlags()})}if(t,e){t.forEach(t=>t({status:e})),t.clear()}nf(){clearTimeout(this.pf),this.pf=void 0}onReloading(t){return this.vv.push(t),()=>{this.vv=this.vv.filter(e=>e!==t)}}ensureFlagsLoaded(){this.gv||this.mv||this.pf||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.bv=t}resetFlagCallReported(){this.Dt(Oi),this.Sv=/* @__PURE__ */new Map,this.Av=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.Sv.size&&!this.xv&&null!=(t=this.ia)&&t.canCapture&&!this.ia.isRateLimited){this.xv=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.Sv.keys())){var r,n=this.Sv.get(i);if(n){var s=null==(r=this.mf(i,e[i]))?void 0:r.calledKey;if(n.value!==String(e[i])||n.calledKey&&n.calledKey!==s||!ra(n.context,this.yf()))this.Sv.delete(i);else if(this.getFeatureFlagResult(i),this.Sv.has(i))break}}}finally{this.xv=!1}}}gf(t){var i;this.nf();var r=this.ia;if(!r||this.Yr.remoteRequestsDisabled||this.Rv())this.if(this.fv,"skipped");else if(this.mv)this._v=!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.sf("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.sf(Ti),timezone:Mn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Yr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.hf();s.length&&(n.evaluation_contexts=s);var a=this.df();f(a)||(n.flag_keys=a);var o=this.Yr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v="+this.Bv.version+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.yv,h=this.fv;this.fv=/* @__PURE__ */new Set,this.pv=h,this.mv=!0;var c=()=>{this._v&&(this._v=!1,this.gf())},v=t=>{var e,i=this.bf(t.json),r=200!==t.statusCode;if(this.mv=!1,u===this.yv)if(this._f(t.statusCode),r||this._v||(this.$anon_distinct_id=void 0),!n.disable_flags||this._v){this.$v=!r;var s=[];t.error?s.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Js:"unknown_error"):200!==t.statusCode&&s.push("api_error_"+t.statusCode),i.errorsWhileComputingFlags&&s.push("errors_while_computing_flags");var a=!(null==(e=i.quotaLimited)||!e.includes("feature_flags"));a&&s.push("quota_limited"),this.$t({[xi]:s}),a?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.vf(i,r,{partialResponse:o}),this.if(h,n.disable_flags?"skipped":s.length||!i.flags&&!i.featureFlags?"error":"loaded"),c()}else this.if(h,"skipped");else c()},d=t=>{this.mv=!1,u===this.yv?(this.$t({[xi]:[Js]}),this.R.error("Feature flag request failed",t),this.lf()&&this.Yv(!0),this.if(h,"error"),c()):c()},p=null!==(i=this.Yr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.yv,m=()=>{if(u!==this.yv||!this.ia||this.Yr.remoteRequestsDisabled)return this.mv=!1,this.if(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Yr.compression,sentAt:"body",timeoutMs:this.Yr.requestTimeoutMs}).then(t=>{if((t=>Gs.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()}}bf(t){var e=null!=t?t:{},i=this.Bv.read;if(!i)return e;var r=i(e),n=r.body;return r.withoutTypedValues&&!this.Iv&&(this.Iv=!0,this.R.info("The /flags response has no typed flag values. Its flags are read as before.")),n}Rv(){return Sn(this.Tv,3)}_f(t){this.Tv=kn(t,this.Tv,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."))}wf(t){var e;return!(this.gv||this.getFlags().length||null!=(e=this.getFeatureFlagDetails(t))&&e.failed)}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.$v)if(this.wf(t))this.R.warn('getFeatureFlag for key "'+t+Ws);else if(!this.cf()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}getFeatureFlagDetails(t){var e=this.ff()[t],i=this.Bv.publicDetail;return e&&i?i(e):e}getFeatureFlagPayload(t){var e;return null==(e=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:e.payload}getFeatureFlagResult(t,i){var r;if(void 0===i&&(i={}),!i.fresh||this.$v)if(this.wf(t))this.R.warn('getFeatureFlagResult for key "'+t+Ws);else if(!this.cf()){var n,s=null==(r=this.sf(wi))||null==(r=r[t])?void 0:r.failed,a=s?void 0:this.sf(Ai),o=s?void 0:this.sf(Ci),l=this.sf(Ri),u=!!l&&{}.hasOwnProperty.call(l,t),c=u||!!a&&t in a,v=u?l[t]:null==a?void 0:a[t],d=this.sf($i),f=d&&{}.hasOwnProperty.call(d,t)?d[t]:null==o?void 0:o[t],p=String(v),g=this.sf("$feature_flag_request_id")||void 0,m=this.sf("$feature_flag_evaluated_at")||void 0,_=this.sf("$flag_call_reported")||{};if(this.Yr.deduplicateCallsPerSession){var y,b=null==(y=this.ia)||null==(y=y.session)?void 0:y.sessionId,w=this.sf(Pi);b&&b!==w&&(_={},n=b)}if(!i.send_event&&"send_event"in i)n&&this.$t({[Oi]:_,[Pi]:n});else{var x,S,k,E,A,T,F=!(null!=(x=this.ia)&&x.canCapture),O=!(F||null!=(S=this.ia)&&S.isRateLimited),P=this.mf(t,v),C=P?P.calledKey:p,R=null==P?void 0:P.exposureKey,M=()=>this.kf(t,p,null==P?void 0:P.calledKey);O?this.Sv.delete(t):(F&&Object.keys(_).length>0&&(_={},this.$t({[Oi]:_})),null!=(A=_[t])&&A.includes(C)&&(!R||null!=(T=_[t])&&T.includes(R))||M());var I=!(null!=(k=_[t])&&k.includes(C)),D=!(!R||null!=(E=_[t])&&E.includes(R));if(O&&P&&(I||D)){n&&this.$t({[Oi]:_,[Pi]:n});var j=P.build(this.Sf(t,v,f,g,m)),L=I?this.xf(t,C,j.called,M):void 0;D&&j.exposure&&this.xf(t,R,j.exposure,M,L)}else if(O&&I){h(_[t])?_[t].push(p):_[t]=[p],this.$t(e({[Oi]:_},n?{[Pi]:n}:{}));var N=this.Sf(t,v,f,g,m);this.$f(N)||(this.Cf(t,p),M())}else n&&this.$t({[Oi]:_,[Pi]:n})}if(c)return{key:t,enabled:!!v,variant:"string"==typeof v?v:void 0,payload:Bt(f)}}}Sf(t,e,i,r,n){var s,a,o,l,u,h,c,v,d,p,g,m,_,y=this.ff()[t],b=[...null!==(s=this.sf("$feature_flag_errors"))&&void 0!==s?s:[]];f(e)&&b.push(null!=y&&y.failed?"evaluation_failed":"flag_missing");var w={$feature_flag:t,$feature_flag_response:e,$feature_flag_payload:null!=i?i:null,$feature_flag_request_id:r,$feature_flag_evaluated_at:n,$feature_flag_bootstrapped_response:null!==(a=null==(o=this.Yr.bootstrap)||null==(o=o.featureFlags)?void 0:o[t])&&void 0!==a?a:null,$feature_flag_bootstrapped_payload:null!==(l=null==(u=this.Yr.bootstrap)||null==(u=u.featureFlagPayloads)?void 0:u[t])&&void 0!==l?l:null,$used_bootstrap_value:!this.$v};f(null==y||null==(h=y.metadata)?void 0:h.has_experiment)||(w.$feature_flag_has_experiment=y.metadata.has_experiment),f(null==y||null==(c=y.metadata)?void 0:c.version)||(w.$feature_flag_version=y.metadata.version);var x=null!==(v=null==y||null==(d=y.reason)?void 0:d.description)&&void 0!==v?v:null==y||null==(p=y.reason)?void 0:p.code;return x&&(w.$feature_flag_reason=x),null!=y&&null!=(g=y.metadata)&&g.id&&(w.$feature_flag_id=y.metadata.id),f(null==y?void 0:y.original_variant)&&f(null==y?void 0:y.original_enabled)||(w.$feature_flag_original_response=f(y.original_variant)?y.original_enabled:y.original_variant),null!=y&&null!=(m=y.metadata)&&m.original_payload&&(w.$feature_flag_original_payload=null==y||null==(_=y.metadata)?void 0:_.original_payload),b.length&&(w.$feature_flag_error=b.join(",")),w}mf(t,e){var i,r,n,s=this.Bv.flagEvents,a=this.sf(Ri);if(!(!s||v(a)&&l.call(a,t)))return s({key:t,response:e,groups:null!==(i=null==(r=this.ia)?void 0:r.groups)&&void 0!==i?i:{},record:null==(n=this.sf(wi))?void 0:n[t]})}xf(t,i,r,n,s){var a,o=this.sf("$flag_call_reported")||{},l=t+i,u=this.Av.get(l)||0;if(!(null!=(a=o[t])&&a.includes(i)||u>1)){this.$t({[Oi]:e({},o,{[t]:[...o[t]||[],i].slice(-10)})});var h,c,v=!1,d=!1;this.Ev.set(r.properties,e({},r.capture,{failed(){v=!0},resolved:t=>(c=t.$session_id,h=JSON.stringify([t.distinct_id,t.$groups,c,t.$process_person_profile]),!(d=!!s&&h!==s))}));var f=!1;try{var p,g;(f=!1!==(null==(p=this.ia)?void 0:p.capture(r.event,r.properties))&&!(null==(g=this.ia)||!g.canCapture))||n()}catch(t){v=!0,this.R.error("Failed to capture "+r.event,t)}v&&this.Av.set(l,u+1);var m=f&&!v&&!d;return m||this.Cf(t,i),this.Yr.deduplicateCallsPerSession&&c&&c!==this.sf("$flag_call_reported_session_id")&&this.$t({[Oi]:m?{[t]:[i]}:{},[Pi]:c}),h}}flagEventCapture(t){return t?this.Ev.get(t):void 0}$f(t){try{var e;return!1!==(null==(e=this.ia)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}kf(t,e,i){this.Sv.set(t,{value:e,calledKey:i,context:this.yf()})}yf(){var t,i,r;return{distinctId:null==(t=this.ia)?void 0:t.distinctId,groups:e({},null==(i=this.ia)?void 0:i.groups),sessionId:this.Yr.deduplicateCallsPerSession?null==(r=this.ia)||null==(r=r.session)?void 0:r.sessionId:void 0}}Cf(t,e){var i=this.sf("$flag_call_reported")||{},r=i[t];h(r)&&r.includes(e)&&(i[t]=r.filter(t=>t!==e),this.$t({[Oi]:i}))}getRemoteConfigPayload(t,e){this.Tf(t,e)}Tf(t,e){var i=this;return r(function*(){var r=i.ia;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.hf();s.length&&(n.evaluation_contexts=s);var a,o=i.df();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.Yr.compression,sentAt:"body",timeoutMs:i.Yr.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.$v)return e.defaultValue;if(this.wf(t))return this.R.warn('isFeatureEnabled for key "'+t+Ws),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.vf(t,e,i)}vf(t,i,r){if(this.ia){var n;this.gv=!0,!1!==(null==r?void 0:r.persist)&&Zs(t,r)&&null!=(n=this.zv)&&null!=n.reconcileFeatureFlagsBeforeMerge&&n.reconcileFeatureFlagsBeforeMerge()&&this.Zv();var s=this.getFlagVariants(),a=!t.flags&&h(t.featureFlags),o=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=qs);var o=ea(t,a),l=o.flags,u=o.featureFlags,c=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[bi]:u,[Ai]:p,[wi]:Ys(n,u),[Ci]:Xs(r,n),[Ei]:!1}}var m=u,_=c,y=l;if(Zs(t,s)){var b=Object.keys(m),w=_||{};m=e({},i,m),_=e({},r,w),(null!=s&&s.partialResponse||l)&&b.forEach(t=>{var e;t in w||null==(e=_)||delete e[t]}),y=l?e({},n,Object.fromEntries(Object.entries(l).filter(t=>{return!(t[1].failed&&(e=t[0],{}.hasOwnProperty.call(i,e)&&!f(i[e])));var e}))):Ys(n,b)}return e({[bi]:Object.keys(ta(m)),[Ai]:m||{},[Ci]:_||{},[wi]:y||{},[Ei]:!0===t.minimalFlagCalledEvents},v?{[ki]:v}:{},d?{[Si]:d}:{})}}(t,s,a?this.sf("$feature_flag_payloads")||{}:this.getFlagPayloads(),a?this.sf("$feature_flag_details")||{}:this.ff(),r,this.R);if(o)if(!1===(null==r?void 0:r.persist)){var l=!f(this.ia.kv.get(Ai));this.rf=o,l||this.$t(o)}else this.Zv(),this.uf(o,t,!(null==r||!r.partialResponse)),this.$t(o);else i&&this.lf();i||(this.Cv=!1),this.Yv(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.Mf(t)}Mf(t){if(this.ia){if(!1===t)return this.Dt([Ri,$i]),this.Yv(),void Vs.info("All overrides cleared");if(h(t))return this.$t({[Ri]:Qs(t)}),this.Yv(),void Vs.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.uv=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Ri]=h(n)?Qs(n):n),s&&(r[$i]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Ri,$i]):!1===n?this.Dt(Ri):!1===s&&this.Dt($i),this.Yv(),!1===n?Vs.info("Flag overrides cleared"):n&&Vs.info("Flag overrides set",{flags:n}),void(!1===s?Vs.info("Payload overrides cleared"):s&&Vs.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Ri]:t}),this.Yv(),void Vs.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.gv){var e=this.If(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.R.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var n,s,a=(this.sf("$early_access_features")||[]).find(e=>e.flagKey===t),o={["$feature_enrollment/"+t]:i},l={$feature_flag:t,$feature_enrollment:i,$set:o};a&&(l.$early_access_feature_name=a.name),r&&(l.$feature_enrollment_stage=r);var u=e({},this.getFlagVariants(),{[t]:i}),h=e({},this.sf(wi)),c=null==(n=h[t])?void 0:n.failed,v=e({},this.sf(Ci));c&&(delete h[t],delete v[t]),null==(s=this.zv)||s.markCrossTabFeatureFlagChanges(e({[bi]:[t],[Ai]:[t]},c?{[wi]:[t],[Ci]:[t]}:{},{[Fi]:Object.keys(o)})),this.$t(e({[bi]:Object.keys(ta(u)),[Ai]:u},c?{[wi]:h,[Ci]:v}:{},{[Fi]:e({},this.sf("$stored_person_properties")||{},o)})),this.Yv();try{var d;null==(d=this.ia)||d.capture("$feature_enrollment_update",l)}catch(t){this.R.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.sf(yi);!r||e?this.Ef(t,i):t(r)}Ef(t,e){var i=this;return r(function*(){var r=i.ia;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({[yi]: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)}}})()}If(){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),{})}}Yv(t){this.Kv();var e=this.If(),i=e.flags,r=e.flagVariants,n=this.wv;this.wv=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.wv=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Af(t,e)}Af(t,i){void 0===i&&(i=!0);var r=this.sf("$stored_person_properties")||{},n=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,a={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in r||(a[o]=s[o]));this.$t({[Fi]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.sf("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Fi]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Fi),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.sf("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[Ti]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.sf("$stored_group_properties")||{};this.$t({[Ti]:e({},i,{[t]:{}})})}else this.Dt(Ti)}reset(){this.yv++,this.if(this.fv,"cancelled"),this.if(this.pv,"cancelled"),this._v=!1,this.hv={},this.dv={},this.rf=void 0,this.gv=!1,this.bv=!1,this.$v=!1,this.$anon_distinct_id=void 0,this.nf(),this.uv=!1,this.Tv=0,this.Sv=/* @__PURE__ */new Map,this.Av=/* @__PURE__ */new Map}},sa=t=>v(t)&&"value"in t?t:void 0,aa=t=>p(t)?t:y(t)||v(t)||!0===t,oa="$experiment_exposure",la="experiment_split",ua="experiment",ha={targeting_match:["targeted_release","percentage_rollout"],[la]:[ua],rollout_miss:["percentage_rollout",ua],experiment_paused:[ua],holdout:[ua]},ca="$feature_flag_config_version",va="$feature_flag_reason_code",da="$feature_flag_rule_id",fa="$feature_flag_rule_type",pa="$feature_flag_variant_key",ga="$feature_flag_experiment_id",ma="$feature_flag_forced_variant",_a=[ca,va,da,fa,pa],ya=[..._a,"$feature_flag_reason",ma,ga],ba=[ca,va,fa,"$experiment_exposure_source",ga,ma],wa=["$feature_flag_id","$feature_flag_version","$feature_flag_request_id","$feature_flag_evaluated_at"],xa=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Sa=t=>p(t)?t:void 0,ka={},Ea=t=>y(t)&&t%1==0,Aa=[["key",p],["failed",b]],Ta=[["code",p],["condition_index",Ea],["description",p]],Fa=[["id",Ea],["version",Ea],["description",p],["has_experiment",b],["config_version",Ea],["rule_type",p],["rule_id",p],["variant_key",p],["forced_variant",b],["experiment_id",Ea]],Oa=(t,e)=>{if(!_(t)){if(!v(t))throw ka;var i={};for(var r of e){var n=r[0],s=r[1],a=t[n];if(!_(a)){if(!s(a))throw ka;i[n]=a}}return i}},Pa=(t,i)=>{var r=Oa(i,Aa),n=null==i?void 0:i.value;if(!r||!(m(n)||b(n)||p(n)||v(n)||y(n)&&isFinite(n)))throw ka;var s=i.metadata,a=Oa(s,Fa),o=!0===r.failed,l=o?null:n,u=y(l)||v(l),h=aa(l);return{key:t,enabled:!1!==h,variant:p(h)?h:null,value:l,reason:Oa(i.reason,Ta),metadata:a||u?e({},a,{payload:o?null:u?JSON.stringify(l):null==s?void 0:s.payload,experiment_id:void 0}):void 0,failed:o||void 0}},Ca=["config_version","rule_type","rule_id","variant_key","forced_variant"],Ra={version:4,read(t){var i=v(t)?t.flags:void 0,r=!1;if(!v(i)){var n=v(t)?t.featureFlags:void 0;return{body:t,withoutTypedValues:v(n)&&Object.keys(n).length>0}}return{body:e({},t,{flags:Object.fromEntries(Object.keys(i).map(t=>{var e=i[t];if(v(e)&&!("value"in e))return r=!0,[t,e];try{return[t,Pa(t,e)]}catch(e){return[t,{key:t,enabled:!1}]}}))}),withoutTypedValues:r}},publicDetail(t){if(!sa(t))return t;var i=e({},t);if(delete i.value,v(i.metadata)){var r=i.metadata=e({},i.metadata);for(var n of Ca)delete r[n]}return i},flagEvents(t){var i=t.key,r=t.response,n=t.record,s=(t=>{var e,i=sa(t),r=null==i?void 0:i.metadata;if(i&&2===(null==r?void 0:r.config_version)){var n,s,a,o=Sa(null==(e=i.reason)?void 0:e.code)||void 0,u=o&&l.call(ha,o)?ha[o]:void 0,h=Sa(r.rule_id),c=Sa(r.rule_type);return!i.failed&&u&&h&&xa.test(h)&&c&&-1!==u.indexOf(c)&&(o!==la?(n=h,s=c):p(r.variant_key)&&(n=h,s=c,a=r.variant_key)),{reasonCode:o,ruleId:n,ruleType:s,variantKey:a}}})(n),a=sa(n);if(s&&a&&(a.failed?f(r):aa(a.value)===r)){var o=s.reasonCode,u=s.ruleId,h=s.ruleType,c=s.variantKey,v=Object.keys(t.groups).sort().map(e=>[e,t.groups[e]]),d={[ca]:2};o&&(d[va]=o),u&&(d[da]=u,d[fa]=h);var g=p(c);return g&&(d[pa]=c),{calledKey:JSON.stringify([r,v,2,o||null,u||null,h||null,g?c:null]),exposureKey:g?JSON.stringify([oa,v,2,u,c]):void 0,build(t){var n=e({},t,d);delete n.$feature_flag_reason;var s={event:"$feature_flag_called",properties:n,capture:{omit:ya.filter(t=>!(t in n)),keep:_a}};if(!g)return{called:s,exposure:void 0};var a={};for(var o of wa)f(n[o])||(a[o]=n[o]);return a.$feature_flag=i,a.$feature_flag_response=r,a[pa]=c,a[da]=u,a.locally_evaluated=!1,{called:s,exposure:{event:oa,properties:a,capture:{omit:ba,keep:[]}}}}}}}},$a=/* @__PURE__ */ci("[FeatureFlags]"),Ma=class{constructor(t,e){void 0===e&&(e=!1),this.Rf=!1,this.update(t,e)}update(t,e){this.Pf=((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.Rf||($a.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Rf=!0),f(t.flag_keys)||h(t.flag_keys)||$a.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Pf}},Ia=class extends na{constructor(t){var e=new Ma(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.bp=e}get zv(){return this._instance.persistence}get Bv(){return Ra}updateConfig(t,e){this.bp.update(t,e),this.Hv()}},Da=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),ja=/* @__PURE__ */ci("[Error tracking]"),La="webkit-masked-url:",Na=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],za=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",La],Ba=["__firefox__","__gCrWeb"],Ua=class{constructor(t){var i,r;this.xg=[],this.$g=new it([new St,new $t,new Et,new kt,new Ct,new Pt,new Tt,new Rt],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),_=m[m.length-1];if(_){var y=yt(s,_);for(var b of(s.splice(_.start-y,y),m))b.start-=y}for(var w of m)_t(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.xg=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Cg=Lt(this.Tg()),this.Mg=new Nt(this.Cg)}onConfigChange(){this.Cg=Lt(this.Tg()),this.Mg.setConfig(this.Cg)}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.xg=s,this._instance.persistence&&this._instance.persistence.register({[Kr]:this.xg,[Jr]:a})}}}get Ig(){var t,e,i=!!this._instance.get_property(Jr);return null!==(t=null!==(e=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==e?e:i)&&void 0!==t&&t}buildProperties(t,e){return this.$g.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Cg.enabled)try{if(!p(t)||0===t.trim().length)return void ja.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce((i,r)=>Dt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.Eg(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&ja.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.Mg.add(e({[Mt]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){ja.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Ag(e)){if(this.Rg(e))return this.Pg("Exception dropped: matched a suppression rule"),void ja.info("Skipping exception capture because a suppression rule matched");if(!this.Ig&&this.Og(e))return this.Pg("Exception dropped: thrown by a browser extension"),void ja.info("Skipping exception capture because it was thrown by an extension");if(!this.Ig&&this.Fg(e))return this.Pg("Exception dropped: thrown by an injected browser script"),void ja.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Lg(e))return this.Pg("Exception dropped: thrown by the PostHog SDK"),void ja.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Cg.enabled&&_(t.$exception_steps)?this.Dg(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.Mg.clear(),n}catch(t){return Da(t)||ja.error("Failed to capture exception event. Dropping this exception.",t),void this.Mg.clear()}}catch(t){return void(Da(t)||ja.error("Failed to process exception event. Ignoring this exception.",t))}}Dg(t){try{var i=this.Mg.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return ja.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Pg(t){this.Cg.enabled&&this.Mg.add({[Mt]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}Eg(t){return v(t)?e({},t):{}}Tg(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Rg(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.xg.some(t=>{var i=t.values.map(t=>{var i=ws[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 ja.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Og(t){var e=t.flatMap(t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]}),i=e.filter(t=>{var e=t.filename;return!!e&&za.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(La)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&Na.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(La))}))}Fg(t){return t.some(t=>{var e=t.value;return p(e)&&Ba.some(t=>e.includes(t))})}Lg(t){if(t.length>0){var e,i,r,n,s=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[];return null!==(r=null==(n=s[s.length-1])||null==(n=n.filename)?void 0:n.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Ag(t){return!_(t)&&h(t)}},Ha=/*#__PURE__*/function(){function t(t,e){this.v=t,this.k=e}function e(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 i(t,i){return function(t){if(Array.isArray(t))return t}(t)||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){if(Object(i)!==i)return;l=!1}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}}(t,i)||function(t,i){if(t){if("string"==typeof t)return e(t,i);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,i):void 0}}(t,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.")}()}function r(e){var i,r;function n(i,r){try{var a=e[i](r),o=a.value,l=o instanceof t;Promise.resolve(l?o.v:o).then(function(t){if(l){var r="return"===i&&o.k?i:"next";if(!o.k||t.done)return n(r,t);t=e[r](t).value}s(!!a.done,t)},function(t){n("throw",t)})}catch(t){s(2,t)}}function s(t,e){2===t?i.reject(e):i.resolve({value:e,done:t}),(i=i.next)?n(i.key,i.arg):r=null}this._invoke=function(t,e){return new Promise(function(s,a){var o={key:t,arg:e,resolve:s,reject:a,next:null};r?r=r.next=o:(i=r=o,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}r.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},r.prototype.next=function(t){return this._invoke("next",t)},r.prototype.throw=function(t){return this._invoke("throw",t)},r.prototype.return=function(t){return this._invoke("return",t)};var n=Object.entries,s=Object.keys,a=Object.setPrototypeOf,o=Object.isFrozen,l=Object.getPrototypeOf,u=Object.getOwnPropertyDescriptor,h=Object.freeze,c=Object.seal,v=Object.create,d="undefined"!=typeof Reflect&&Reflect,f=d.apply,p=d.construct;h||(h=function(t){return t}),c||(c=function(t){return t}),f||(f=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)}),p||(p=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 g=U([].forEach),m=U([].lastIndexOf),_=U([].pop),y=U([].push),b=U([].slice),w=U([].splice),x=Array.isArray,S=H(Set),k=U(Set.prototype.add),E=U(Set.prototype.has),A=U("".toLowerCase),T=U("".toString),F=U("".match),O=U("".replace),P=U("".indexOf),C=U("".trim),R=U((0).toString),M=U(Boolean.prototype.toString),I="undefined"==typeof BigInt?null:U(BigInt.prototype.toString),D="undefined"==typeof Symbol?null:U(Symbol.prototype.toString),j=U({}.hasOwnProperty),L=U({}.toString),N=/t/.test,z=function(t,e){return t instanceof RegExp&&(t.lastIndex=0),f(N,t,[e])},B=H(TypeError);function U(t){return function(e){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return f(t,e,r)}}function H(t){return function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return p(t,i)}}function q(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:A;if(a&&a(t,null),!x(e))return t;for(var r=e.length;r--;){var n=e[r];if("string"==typeof n){var s=i(n);s!==n&&(o(e)||(e[r]=s),n=s)}t[n]=!0}return t}function V(t){for(var e=0;t.length>e;e++)j(t,e)||(t[e]=null);return t}function W(t){var e=v(null);for(var r of n(t)){var s=i(r,2),a=s[0],o=s[1];j(t,a)&&(e[a]=x(o)?V(o):o&&"object"==typeof o&&o.constructor===Object?W(o):o)}return e}function G(t){for(var e=v(null),i=s(t),r=i.length;r--;)e[i[r]]=t[i[r]];return e}function K(t,e){for(;null!==t;){var i=u(t,e);if(i){if(i.get)return U(i.get);if("function"==typeof i.value)return U(i.value)}t=l(t)}return function(){return null}}var J=h(["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"]),X=h(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Y=h(["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"]),Z=h(["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=h(["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"]),tt=h(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),et=h(["#text"]),it=h(["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"]),rt=h(["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","pointer-events","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","vector-effect","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"]),nt=h(["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"]),st=h(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),at=c(/{{[\w\W]*|^[\w\W]*}}/g),ot=c(/<%[\w\W]*|^[\w\W]*%>/g),lt=c(/\${[\w\W]*/g),ut=c(/{{|}}|\${|<%|%>|&lt;%|%&gt;/),ht=c(/^data-[\-\w.\u00B7-\uFFFF]+$/),ct=c(/^aria-[\-\w]+$/),vt=c(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dt=c(/^(?:\w+script|data):/i),ft=c(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pt=c(/^html$/i),gt=c(/^[a-z][.\w]*(-[.\w]+)+$/i),mt=c(/<[/\w!]/g),_t=c(/<[/\w]/g),yt=c(/<\/no(script|embed|frames)/i),bt=c(/\/>/i),wt=c(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),xt=c(/^[\r\n\t ]+/),St=h(q({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),kt=function(){return"undefined"==typeof window?null:window},Et=function(t,e,i,r){return j(t,e)&&x(t[e])?q(r.base?G(r.base):{},t[e],r.transform):i},At=function(t,e,i){var r=j(t,e)?t[e]:void 0;return r&&"object"==typeof r?W(r):i};return function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kt(),i=e=>t(e);if(i.version="3.4.18",i.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return i.isSupported=!1,i;var r,s=e.document,a=s,o=a.currentScript,d=e.HTMLTemplateElement,f=e.Node,p=e.NodeFilter,N=e.DOMParser,H=e.trustedTypes,V=e.Element.prototype,Tt=K(V,"cloneNode"),Ft=K(V,"remove"),Ot=K(V,"removeAttributeNode"),Pt=K(V,"nextSibling"),Ct=K(V,"childNodes"),Rt=K(V,"parentNode"),$t=K(V,"shadowRoot"),Mt=K(V,"attributes"),It=f&&f.prototype?K(f.prototype,"nodeType"):null,Dt=f&&f.prototype?K(f.prototype,"nodeName"):null,jt=f&&f.prototype?K(f.prototype,"ownerDocument"):null,Lt=function(t){return It?It(t):t.nodeType},Nt=function(t){return Dt?Dt(t):t.nodeName},zt=function(t){for(;null!==t;){var e=u(t,"namespaceURI");if(e)return e.get?U(e.get):null;t=l(t)}return null}(V),Bt=function(t){return zt?zt(t):t.namespaceURI};if("function"==typeof d){var Ut=s.createElement("template");Ut.content&&Ut.content.ownerDocument&&(s=Ut.content.ownerDocument)}var Ht,qt="",Vt=!1,Wt=0,Gt=function(){if(Wt>0)throw B('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.')},Kt=function(t){Gt(),Wt++;try{return r.createHTML(t)}finally{Wt--}},Jt=function(t){return r&&Re?Kt(t):t},Xt=s.implementation,Yt=s.createNodeIterator,Zt=s.createDocumentFragment,Qt=s.getElementsByTagName,te=a.importNode,ee={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof n&&"function"==typeof Rt&&Xt&&void 0!==Xt.createHTMLDocument;var ie=at,re=ot,ne=lt,se=ht,ae=ct,oe=dt,le=ft,ue=gt,he=vt,ce=null,ve=q({},[...J,...X,...Y,...Q,...et]),de=null,fe=q({},[...it,...rt,...nt,...st]),pe=null,ge=null,me=null,_e=Object.seal(v(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ye=!0,be=!0,we=!1,xe=!0,Se=!1,ke=!0,Ee=!1,Ae=!1,Te=null,Fe=null,Oe=!1,Pe=!1,Ce=!1,Re=!1,$e=!0,Me=!1,Ie="user-content-",De=!0,je=!1,Le=null,Ne=!1,ze=null,Be=q({},["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"]),Ue=null,He=q({},["audio","video","img","source","image","track"]),qe=null,Ve=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),We="http://www.w3.org/1998/Math/MathML",Ge="http://www.w3.org/2000/svg",Ke="http://www.w3.org/1999/xhtml",Je=Ke,Xe=!1,Ye=null,Ze=q({},[We,Ge,Ke],T),Qe=h(q({},["mi","mo","mn","ms","mtext"])),ti=null,ei=h(q({},["annotation-xml"])),ii=null,ri=h(v(null)),ni=q({},["title","style","font","a","script"]),si=null,ai=["application/xhtml+xml","text/html"],oi=null,li=null,ui=s.createElement("form"),hi=function(t){return t instanceof RegExp||t instanceof Function},ci=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t&&"object"==typeof t||(t={}),t=W(t),si=-1===ai.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,ce=Et(t,"ALLOWED_TAGS",ve,{transform:oi="application/xhtml+xml"===si?T:A}),de=Et(t,"ALLOWED_ATTR",fe,{transform:oi}),Ye=Et(t,"ALLOWED_NAMESPACES",Ze,{transform:T}),qe=Et(t,"ADD_URI_SAFE_ATTR",Ve,{transform:oi,base:Ve}),Ue=Et(t,"ADD_DATA_URI_TAGS",He,{transform:oi,base:He}),ze=Et(t,"FORBID_CONTENTS",Be,{transform:oi}),ge=Et(t,"FORBID_TAGS",v(null),{transform:oi}),me=Et(t,"FORBID_ATTR",v(null),{transform:oi}),Ne=!!j(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?W(t.USE_PROFILES):t.USE_PROFILES),ye=!1!==t.ALLOW_ARIA_ATTR,be=!1!==t.ALLOW_DATA_ATTR,we=t.ALLOW_UNKNOWN_PROTOCOLS||!1,xe=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Se=t.SAFE_FOR_TEMPLATES||!1,ke=!1!==t.SAFE_FOR_XML,Ee=t.WHOLE_DOCUMENT||!1,Pe=t.RETURN_DOM||!1,Ce=t.RETURN_DOM_FRAGMENT||!1,Re=t.RETURN_TRUSTED_TYPE||!1,Oe=t.FORCE_BODY||!1,$e=!1!==t.SANITIZE_DOM,Me=t.SANITIZE_NAMED_PROPS||!1,De=!1!==t.KEEP_CONTENT,je=t.IN_PLACE||!1,he=function(t){if(!t)return!1;try{return z(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:vt,Je="string"==typeof t.NAMESPACE?t.NAMESPACE:Ke,ti=At(t,"MATHML_TEXT_INTEGRATION_POINTS",Qe),ii=At(t,"HTML_INTEGRATION_POINTS",ei);var e=At(t,"CUSTOM_ELEMENT_HANDLING",ri);if(pe=v(null),j(e,"tagNameCheck")&&hi(e.tagNameCheck)&&(pe.tagNameCheck=e.tagNameCheck),j(e,"attributeNameCheck")&&hi(e.attributeNameCheck)&&(pe.attributeNameCheck=e.attributeNameCheck),j(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(pe.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),c(pe),Se&&(be=!1),Ce&&(Pe=!0),Ne&&((j(t,"ALLOWED_TAGS")||j(t,"ALLOWED_ATTR"))&&"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together."),ce=q({},et),de=v(null),!0===Ne.html&&(q(ce,J),q(de,it)),!0===Ne.svg&&(q(ce,X),q(de,rt),q(de,st)),!0===Ne.svgFilters&&(q(ce,Y),q(de,rt),q(de,st)),!0===Ne.mathMl&&(q(ce,Q),q(de,nt),q(de,st))),_e.tagCheck=null,_e.attributeCheck=null,j(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?_e.tagCheck=t.ADD_TAGS:x(t.ADD_TAGS)&&(ce===ve&&(ce=G(ce)),q(ce,t.ADD_TAGS,oi))),j(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?_e.attributeCheck=t.ADD_ATTR:x(t.ADD_ATTR)&&(de===fe&&(de=G(de)),q(de,t.ADD_ATTR,oi))),j(t,"ADD_FORBID_CONTENTS")&&x(t.ADD_FORBID_CONTENTS)&&(ze===Be&&(ze=G(ze)),q(ze,t.ADD_FORBID_CONTENTS,oi)),De&&(ce["#text"]=!0),Ee&&q(ce,["html","head","body"]),ce.table&&(ce.tbody=!0,delete ge.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw B('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw B('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');var i=r;r=t.TRUSTED_TYPES_POLICY;try{qt=Kt("")}catch(t){throw r=i,t}}else null===t.TRUSTED_TYPES_POLICY?(r=void 0,qt=""):(void 0===r&&(Vt||(Ht=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}}(H,o),Vt=!0),r=Ht),r&&"string"==typeof qt&&(qt=Kt("")));li=h(t)},vi=q({},[...X,...Y,...Z]),di=q({},[...Q,...tt]),fi=function(t){y(i.removed,{element:t});try{Rt(t).removeChild(t)}catch(e){if(Ft(t),!Rt(t))throw B("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},pi=function(t,e,i){try{Ot(t,e)}catch(e){try{t.removeAttribute(i)}catch(t){}}},gi=function(t){bi(t);var e=Ct(t);e&&g(b(e),t=>{try{Ft(t)}catch(t){}}),1===Lt(t)&&_i(t,!1)},mi=function(t,e,r){if(!r)try{r=e.getAttributeNode(t)}catch(t){r=null}if(y(i.removed,{attribute:r||null,from:e}),r)pi(e,r,t);else try{e.removeAttribute(t)}catch(t){}if("is"===t)if(Pe||Ce)try{fi(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},_i=function(t,e){var i=Mt(t);if(i)for(var r=i.length-1;r>=0;--r){var n=i[r],s=n&&n.name;"string"!=typeof s||e&&de[oi(s)]||pi(t,n,s)}},yi=function(t,e){for(var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[t];r.length>0;){var n=r.pop();if(!1!==e(n)){if(i&&1===Lt(n)){var s=$t(n);Ci(s)&&r.push(s)}var a=Ct(n);if(a)for(var o=a.length-1;o>=0;--o)r.push(a[o])}}},bi=function(t){yi(t,t=>{1===Lt(t)&&_i(t,!0)})},wi=function(t){var e=[];return yi(t,t=>{e.push(t)},!0),e},xi=function(t,e){var r=!1;return g(i.removed,e=>{e.element&&(r=r||e.element===t,bi(e.element))}),function(t,e){var i=S();g(wi(t),t=>{1===Lt(t)&&k(i,t)}),g(e,t=>{1!==Lt(t)||E(i,t)||_i(t,!0)})}(t,e),r},Si=function(t,e){return!!ke&&("patchsrc"===t||"for"===t&&"label"!==e&&"output"!==e)},ki=function(t){var e=null,i=null;if(Oe)t="<remove></remove>"+t;else{var n=F(t,xt);i=n&&n[0]}"application/xhtml+xml"===si&&Je===Ke&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var a=r?Kt(t):t;if(Je===Ke)try{e=(new N).parseFromString(a,si)}catch(t){}if(!e||!e.documentElement){e=Xt.createDocument(Je,"template",null);try{e.documentElement.innerHTML=Xe?qt:a}catch(t){}}var o=e.body||e.documentElement;return t&&i&&o.insertBefore(s.createTextNode(i),o.childNodes[0]||null),Je===Ke?Qt.call(e,Ee?"html":"body")[0]:Ee?e.documentElement:o},Ei=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=jt?jt(t):t.ownerDocument;return Yt.call(i||t,t,(e?0:p.SHOW_ELEMENT)|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Ai=function(t){return t=O(t,ie," "),t=O(t,re," "),O(t,ne," ")},Ti=function(t){var e;Fi(t);var i=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");i&&g(i,t=>{Ci(t.content)&&Ti(t.content)})},Fi=function(t){t.normalize();for(var e=Ei(t,!0),i=e.nextNode();i;)i.data=Ai(i.data),i=e.nextNode()},Oi=function(t){var e=Dt?Dt(t):null;return"string"==typeof e&&"form"===oi(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==Mt(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.removeAttributeNode||"function"!=typeof t.getAttributeNode||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==It(t)||t.childNodes!==Ct(t))},Pi=function(t){if(!It||"object"!=typeof t||null===t)return null;try{var e=It(t);return"number"==typeof e?e:null}catch(t){return null}},Ci=function(t){return 11===Pi(t)},Ri=function(t){return null!==Pi(t)};function $i(t,e,r){0!==t.length&&g(t,t=>{t.call(i,e,r,li)})}var Mi=function(t,e){if(t instanceof RegExp)return z(t,e);if(t instanceof Function){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;i>n;n++)r[n-2]=arguments[n];return Boolean(t(e,...r))}return!1},Ii=function(t,e,i,r){return 0===t.length?e:e===i||e===r?G(e):e},Di=function(t,e){return t!==e&&null===Rt(t)&&(je&&bi(t),!0)},ji=function(t,e){if(Le&&k(Le,t),$i(ee.beforeSanitizeElements,t,null),Di(t,e))return!0;if(Oi(t))return fi(t),!0;var r=oi(Nt(t)),n=Lt(t);if(ce=Ii(ee.uponSanitizeElement,ce,ve,Te),$i(ee.uponSanitizeElement,t,{tagName:r,allowedTags:ce}),Di(t,e))return!0;if(function(t,e,i){return!!(ke&&1===i&&t.hasChildNodes()&&!Ri(t.firstElementChild)&&z(mt,t.textContent)&&z(mt,t.innerHTML))||!!(ke&&St[e]&&1===i&&Bt(t)===Ke&&(Ri(t.firstElementChild)||"string"==typeof t.textContent&&z(mt,t.textContent)))||7===i||!(!ke||8!==i||!z(_t,t.data))}(t,r,n))return fi(t),!0;if(ge[r]||!(_e.tagCheck instanceof Function&&_e.tagCheck(r))&&!ce[r]){var s=function(t,e,i){if(!ge[e]&&zi(e)&&Mi(pe.tagNameCheck,e))return!1;if(De&&!ze[e]&&!ze[A(e)]){var r=Rt(t),n=Ct(t);if(n&&r)for(var s=n.length-1;s>=0;--s){var a=t===i?Tt(n[s],!0):n[s];r.insertBefore(a,Pt(t))}}return fi(t),!0}(t,r,e);return!(!1!==s||($i(ee.afterSanitizeElements,t,null),!Di(t,e)))||s}if(1===n&&!function(t){var e=Bt(t),i=A(Nt(t)),r=Rt(t),n=Je,s="template";return r&&1===Lt(r)&&(n=Bt(r),s=A(Nt(r))),!!Ye[e]&&(e===Ge?function(t,e,i){return e===Ke?"svg"===t:e===We?"svg"===t&&("annotation-xml"===i||ti[i]):Boolean(vi[t])}(i,n,s):e===We?function(t,e,i){return e===Ke?"math"===t:e===Ge?"math"===t&&ii[i]:Boolean(di[t])}(i,n,s):e===Ke?function(t,e,i){return!(e===Ge&&!ii[i])&&!(e===We&&!ti[i])&&!di[t]&&(ni[t]||!vi[t])}(i,n,s):"application/xhtml+xml"===si)}(t))return fi(t),!0;if(("noscript"===r||"noembed"===r||"noframes"===r)&&z(yt,t.innerHTML))return fi(t),!0;if(Se&&3===n){var a=t.textContent,o=Ai(a);a!==o&&(y(i.removed,{element:t.cloneNode()}),t.textContent=o)}return $i(ee.afterSanitizeElements,t,null),Di(t,e)},Li=function(t,e,i){if(me[e])return!1;if(Si(e,t))return!1;if($e&&("id"===e||"name"===e)&&(i in s||i in ui))return!1;var r=de[e]||_e.attributeCheck instanceof Function&&_e.attributeCheck(e,t);if(be&&z(se,e))return!0;if(ye&&z(ae,e))return!0;if(!r)return zi(t)&&Mi(pe.tagNameCheck,t)&&Mi(pe.attributeNameCheck,e,t)||"is"===e&&pe.allowCustomizedBuiltInElements&&Mi(pe.tagNameCheck,i);if(qe[e])return!0;var n=O(i,le,"");return!(!z(he,n)&&("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==P(i,"data:")||!Ue[t])&&(!we||z(oe,n))&&i)},Ni=q({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),zi=function(t){return!Ni[A(t)]&&z(ue,t)},Bi=function(t,e,i,n){if(r&&"object"==typeof H&&"function"==typeof H.getAttributeType&&!i)switch(H.getAttributeType(t,e)){case"TrustedHTML":return Kt(n);case"TrustedScriptURL":return function(t){Gt(),Wt++;try{return r.createScriptURL(t)}finally{Wt--}}(n)}return n},Ui=function(t,e,i,r){try{return i?t.setAttributeNS(i,e,r):t.setAttribute(e,r),!Oi(t)||(fi(t),!1)}catch(i){return mi(e,t),!1}},Hi=function(t,e){return!(!ke||!z(wt,e))||"attributename"===A(t)&&-1!==P(e,"href")},qi=function(t,e){ji(t,e),function(t,e){if($i(ee.beforeSanitizeAttributes,t,null),!Di(t,e)){var r=t.attributes;if(r&&!Oi(t)){for(var n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:de=Ii(ee.uponSanitizeAttribute,de,fe,Fe),forceKeepAttr:void 0},s=r.length,a=oi(Nt(t));s--;){var o=r[s],l=o.name,u=o.namespaceURI,h=o.value,c=oi(l),v=h,d="value"===l?v:C(v),f=!1;n.attrName=c,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,$i(ee.uponSanitizeAttribute,t,n),d=n.attrValue,!Me||"id"!==c&&"name"!==c||0===P(d,Ie)||(mi(l,t,o),d=Ie+d,f=!0),Hi(l,d)?mi(l,t,o):n.forceKeepAttr||(!n.keepAttr||!xe&&z(bt,d)?mi(l,t,o):(Se&&(d=Ai(d)),Li(a,c,d)?(d=Bi(a,c,u,d))!==v&&Ui(t,l,u,d)&&f&&_(i.removed):mi(l,t,o)))}$i(ee.afterSanitizeAttributes,t,null),Di(t,e)}}}(t,e),Ci(t.content)&&Vi(t.content)},Vi=function(t){var e=null,i=Ei(t);for($i(ee.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if($i(ee.uponSanitizeShadowNode,e,null),qi(e,t),1===Lt(e)){var r=$t(e);Ci(r)&&(Wi(r),Vi(r))}Se&&Fi(t),$i(ee.afterSanitizeShadowDOM,t,null)},Wi=function(t){for(var e=[{node:t,shadow:null}];e.length>0;){var i=e.pop();if(i.shadow)Vi(i.shadow);else{var r=i.node,n=1===Lt(r),s=Ct(r);if(s)for(var a=s.length-1;a>=0;--a)e.push({node:s[a],shadow:null});if(n){var o=Dt?Dt(r):null;if("string"==typeof o&&"template"===oi(o)){var l=r.content;Ci(l)&&e.push({node:l,shadow:null})}}if(n){var u=$t(r);Ci(u)&&e.push({node:null,shadow:u},{node:u,shadow:null})}}}};return i.sanitize=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,n=null,s=null,o=null;if((Xe=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Ri(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return R(t);case"boolean":return M(t);case"bigint":return I?I(t):"0";case"symbol":return D?D(t):"Symbol()";case"undefined":default:return L(t);case"function":case"object":if(null===t)return L(t);var e=t,i=K(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:L(r)}return L(t)}}(t)))throw B("dirty is not a string, aborting");if(!i.isSupported)return t;Ae?(ce=Te,de=Fe):ci(e),i.removed=[];var l=je&&"string"!=typeof t&&Ri(t),u=[],h=Le;if(l){ke&&yi(t,t=>{var e=Lt(t);if(7===e||8===e&&z(_t,t.data)){try{Ft(t)}catch(t){}return!1}if(1===e){var i=t,r=oi(Nt(t));try{i.hasAttribute&&i.hasAttribute("patchsrc")&&i.removeAttribute("patchsrc"),i.hasAttribute&&i.hasAttribute("for")&&Si("for",r)&&i.removeAttribute("for")}catch(t){}}return!0});var c=Nt(t);if("string"==typeof c){var v=oi(c);if(!ce[v]||ge[v])throw gi(t),B("root node is forbidden and cannot be sanitized in-place")}if(Oi(t))throw gi(t),B("root node is clobbered and cannot be sanitized in-place");u=wi(t),Le=S()}else if(Ri(t))1===(n=(r=ki("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===n.nodeName||"HTML"===n.nodeName?r=n:r.appendChild(n),Wi(r);else{if(!Pe&&!Se&&!Ee&&-1===t.indexOf("<"))return Jt(t);if(!(r=ki(t)))return Pe?null:Re?qt:""}r&&Oe&&fi(r.firstChild);var d=l?t:r;try{l&&Wi(t);for(var f=Ei(d);s=f.nextNode();)qi(s,d);l&&function(t,e){for(var i,r=Le,n=null,s=()=>(n||(n=S(),g(e,t=>{k(n,t)})),n),a=function(){var e=wi(t),i=[t],n=!1;if(g(e,t=>{11===Lt(t)?y(i,t):n||E(r,t)||(n=E(s(),t))}),!n)return{v:void 0};if(o>=8)throw B("the tree kept changing during in-place sanitization; refusing to return it");g(i,(e,i)=>{!function(t,e,i,r){for(var n,s=Ei(t);n=s.nextNode();)E(r,n)&&!E(Le,n)&&(e&&$i(ee.uponSanitizeShadowNode,n,null),qi(n,i))}(e,i>0,t,s())})},o=0;;o++)if(i=a())return i.v}(t,u)}catch(e){throw l&&(gi(t),xi(t,u)),e}finally{Le=h}if(l){if(xi(t,u))throw B("a node selected for removal could not be safely returned; refusing to sanitize in place");return Se&&Ti(t),t}if(Pe){if(Se&&Ti(r),Ce)for(o=Zt.call(r.ownerDocument);r.firstChild;)o.appendChild(r.firstChild);else o=r;return(de.shadowroot||de.shadowrootmode)&&(o=te.call(a,o,!0)),o}var p=()=>Ee?r.outerHTML:r.innerHTML,m=p();return Se&&z(ut,m)&&(Fi(r),m=p()),Ee&&ce["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&z(pt,r.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+m),Jt(m)},i.setConfig=function(){ci(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Ae=!0,Te=ce,Fe=de},i.clearConfig=function(){li=null,Ae=!1,Te=null,Fe=null,r=Ht,qt=""},i.isValidAttribute=function(t,e,i){li||ci({});var r=oi(t),n=oi(e);return("string"!=typeof i||!(Hi(e,i)||!xe&&z(bt,i)))&&Li(r,n,i)},i.addHook=function(t,e){"function"==typeof e&&j(ee,t)&&y(ee[t],e)},i.removeHook=function(t,e){if(j(ee,t)){if(void 0!==e){var i=m(ee[t],e);return-1===i?void 0:w(ee[t],i,1)[0]}return _(ee[t])}},i.removeHooks=function(t){j(ee,t)&&(ee[t]=[])},i.removeAllHooks=function(){ee={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}()}(),qa="Refusing to render web experiment since the viewer is a likely bot",Va={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Wa={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>ys(e,t),not_regex:(t,e)=>!ys(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},Ga=class t{get Yr(){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.vm("retrieved web experiments from the server"),i.fm=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.fm&&(t.vm("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.fm)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.pm(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.gm(a,i._instance)&&i.ym(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.vm(qa);else if(!this.Yr.disable_web_experiments){if(_(this.fm))return this.fm=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.vm("applying feature flags",e),e.forEach(t=>{var e;if(this.fm&&null!=(e=this.fm)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.fm)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.pm(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=En(null==e?void 0:e.search,"__experiment_id"),r=En(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.vm("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.bm(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Yr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Yr.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.Yr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}bm(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.vm("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.ym(n[0].name,i,n[0].variants[i].transforms))}pm(e,i){var r=e.variants[i];t._m(r,this._instance)?this.ym(e.name,i,r.transforms):t.vm("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static gm(e,i){return!_(e.conditions)&&t._m(e,i)&&t.wm(e)}static _m(e,i){var r;if(_(e.conditions)||_(null==(r=e.conditions)?void 0:r.url))return!0;var n=t.getWindowLocation();if(n){var s,a,o,l=_i(i,n.href);return null==(s=e.conditions)||!s.url||Wa[null!==(a=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return null==un?void 0:un.location}static wm(t){var e;if(_(t.conditions)||_(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!vn)return{};var r,n,s,a=e?[...Ln,...i||[]]:[],o=(r=An(vn.URL,a,zn),n=Nn.concat(t||[]),s={},di(n,function(t){var e=En(r,t);!e&&l.call(jn,t)&&vi(jn[t],function(t){e=e||En(r,t)}),s[t]=e||null}),s);return fi(function(){var t={};return di(Bn,function(e){var i=(t=>{if(vn){try{for(var e=t+"=",i=vn.cookie.split(";").filter(t=>t.length),r=0;i.length>r;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}})(e);t[e]=i||null}),t}(),o)}();if(i.utm_source){var r,n,s,a,o,u,h,c,v=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,d=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,f=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(u=t.conditions)||null==(u=u.utm)?void 0:u.utm_medium)==i.utm_medium,p=null==(h=t.conditions)||null==(h=h.utm)||!h.utm_term||(null==(c=t.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return v&&f&&p&&d}return!1}static vm(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.info("[WebExperiments] "+t,i)}static km(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.warn("[WebExperiments] "+t,i)}static Sm(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.Sm(e)})}ym(i,r,n){this._is_bot()?t.vm(qa):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.vm("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.km("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(_(u)){var h=null!=Ms?Ms:Ms=Ha(),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({},Va,{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({},Va,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.Sm(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.vm("Control variants leave the page unmodified.")}_is_bot(){return cn&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&F(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>F(null==t?void 0:t.brand,e)))return!0}catch(t){}return!!t.webdriver}(cn,this.Yr.custom_blocked_useragents):void 0}},Ka=/* @__PURE__ */ci("[Conversations]"),Ja="Conversations not available yet.",Xa=class{constructor(t){this._instance=t,this.xm=void 0,this._conversationsManager=null,this.$m=!1,this.ie=null,this.Cm=!1,this.Tm=0,this.Mm=null,this.Im=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.Mm=null;else if(this.Em=t.ok,t.ok){var e=t.config.conversations;_(e)?this.Mm=null:(b(e)?this.xm=e:(this.xm=e.enabled,this.ie=e),this.xm||(this.Mm=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Tm++,this.xm=void 0,this.ie=null,this.Em=void 0,this.Cm=!1,this.Mm=null}loadIfEnabled(){if(!(this._conversationsManager||this.$m||this._instance.config.disable_conversations||mi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&!f(this.xm)&&this.xm)if(this.ie&&this.ie.token){this.$m=!0;try{var e=t.initConversations;if(e)return this.Am(e),void(this.$m=!1);var i=gn(this._instance);if(!i)return void this.Rm(Ur);var r=this.Tm;i(this._instance,"conversations",e=>{if(r!==this.Tm)return this.$m=!1,void this.loadIfEnabled();e||!t.initConversations?this.Rm("Could not load conversations script",e):this.Am(t.initConversations),this.$m=!1})}catch(t){this.Rm("Error initializing conversations",t),this.$m=!1}}else Ka.error("Conversations enabled but missing token in remote config.")}}Am(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.Cm=!1,Ka.info("Conversations loaded successfully")}catch(t){return void this.Rm("Error completing conversations initialization",t)}this.Im&&this._conversationsManager.setTheme(this.Im),this.Pm()}else Ka.error("Cannot complete initialization: remote config is null")}Pm(){var t=this.Mm;this.Mm=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}Rm(t,e){Ka.error(t,e),this._conversationsManager=null,this.$m=!1,this.Cm=!0}show(){this._conversationsManager?this._conversationsManager.show():Ka.warn("Conversations not loaded yet.")}hide(){"open"===this.Mm&&(this.Mm=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.Mm=null,this._conversationsManager.open()):this.Mm="open"}close(){this._conversationsManager?(this.Mm=null,this._conversationsManager.close()):this.Mm="close"}setTheme(t){var i,r;this.Im=e({},this.Im,t,{dark:e({},null==(i=this.Im)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.xm&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":mi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Em?"remote_config_failed":f(this.xm)?this.Em?"disabled_in_project":"remote_config_pending":this.xm?_(this.ie)||!this.ie.token?"missing_token":null!=pn&&pn.__PosthogExtensions__?this.$m?"initializing":this.Cm?"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):(Ka.warn(Ja),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Ka.warn(Ja),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Ka.warn(Ja),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Ka.warn(Ja),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Ka.warn(Ja),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Ka.warn(Ja),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ka.warn(Ja),null)})()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}};function Ya(){var t="",i="";try{var r,n=null==(r="u">typeof globalThis?globalThis:"u">typeof window?window:void 0)||null==(r=r.navigator)?void 0:r.userAgent;if(n){var s=function(t){for(var e=0;L.length>e;e++){var i=L[e],r=i[1],n=i[0].exec(t),s=n&&(c(r)?r(n,t):r);if(s)return s}return["",""]}(n);t=s[0],i=s[1]}}catch(t){}return function(t,i){var r=function(t){if(t)return{}.hasOwnProperty.call(Ne,t)?Ne[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function Za(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({},Ya(),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 Qa=["debug","log","warn","error","info"],to="console",eo="__posthogHandledLogsRequestError",io=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[eo]=!0,i},ro=t=>!!t&&"object"==typeof t&&!0===t[eo],no=class{get Of(){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(ro)||t.R.error(...i)}})}constructor(t,e){var i;this.ra=t,this.Ff=e,this.name="logs",this.Lf=!1,this.Df=!1,this.Nf=!1,this.R=ci("[logs]"),this.Dc=[],this.jf=[],this.Tv=0,this.qf=!1,this.qi=!1,this.Bf=[],this.zf=[],this.Hf=!1,this.Uf=!1,this.Wf=!1,this.Vf=()=>{var t,e;this.qi||(this.Tv=0,null==(t=this.Gf)||t.onReconnect(),null==(e=this.Jf)||e.onReconnect())},this.Lf=!(null==(i=t.get())||!i.captureConsoleLogs)}get Qf(){return!0}Zf(){}Kf(){if(!this.Wf){try{this.Wv=typeof window>"u"?void 0:window}catch(t){this.Wv=void 0}this.Wv&&(gi(this.Wv,"online",this.Vf),this.Wf=!0)}}Yf(t,e,i,r){this.Kf();var n=Za(this.ra.get(),i);return[new Je(this.Xf(t,e),n,this.Of,()=>this.Ff(),t=>t(),void 0,r),n]}tp(){var t=this.ra.get();if(!this.Gf||this.ep!==t){var e;null==(e=this.Gf)||e.reset(),this.ep=t;var i=this.Yf(()=>this.Dc,t=>{this.Dc=t});this.Gf=i[0],this.np=i[1]}return this.Gf}sp(){var t=this.ra.get();if(!this.Jf||this.rp!==t){var e;null==(e=this.Jf)||e.reset(),this.rp=t;var i=this.Yf(()=>this.jf,t=>{this.jf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},to);this.Jf=i[0],this.op=i[1]}return this.Jf}setup(t){if(!this.qi&&!this.qf)return this.qf=!0,this.ia=t,this.R=t.logger.createLogger("[logs]"),Ps(t.kv.initialize(),()=>{this.qi||this.Vv(t)})}Vv(t){var e;this.Kf(),null!=(e=this.ra.get())&&e.captureConsoleLogs&&(this.Lf=!0),(this.Lf||this.ra.remoteConfigWillArrive&&t.kv.get(this.ra.captureHintKey))&&this.lp();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.qi?r.dispose():(this.ma=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.qi||(this.qi=!0,this.ap(),null==(t=this.ma)||t.dispose(),this.ma=void 0,this.ia=void 0,this.Nf=!1,null==(e=this.Wv)||e.removeEventListener("online",this.Vf),null==(i=this.up)||i.call(this),this.up=void 0,null==(r=this.Gf)||r.clearQueue(),null==(n=this.Jf)||n.clearQueue(),null==(s=this.Gf)||s.reset(),null==(a=this.Jf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.qi){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;_(r)?this.cp():(null==(i=this.ia)||i.kv.set(this.ra.captureHintKey,!!r),r?(this.Lf=!0,this.Df||this.lp(),this.loadIfEnabled()):this.cp())}}reset(){var t,e,i,r;this.ap(),null==(t=this.Gf)||t.clearQueue(),this.Dc=[],null==(e=this.Gf)||e.reset(),null==(i=this.Jf)||i.clearQueue(),this.jf=[],null==(r=this.Jf)||r.reset(),this.Tv=0}captureLog(t){!this.qi&&this.ia&&this.tp().captureLog(t)}captureConsoleLog(t){!this.qi&&this.ia&&this.sp().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.qi&&this.ia&&this.sp().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.ap(),null==(t=this.Jf)||t.clearQueue(),this.jf=[]}cp(){this.Lf||this.ap()}lp(){var t,e=this;if(!this.Hf&&null!=(t=this.Wv)&&t.console){var i=Za(this.ra.get()).maxBufferSize,r=!0;this.zf.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.Wv.console[t])}catch(t){return 1}n&&e.zf.push(Pn(e.Wv.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.hp(t,a,i)}catch(t){}return s.apply(e.Wv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of Qa)if(n(s))continue;this.Hf=!0,this.dp=setTimeout(()=>{this.ap()},3e4)}}hp(t,e,i){var r;if(this.Hf&&!this.Uf&&0!==e.length)if(null!=(r=this.ia)&&r.canCapture){if(i>this.Bf.length){this.Uf=!0;try{this.Bf.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Ff()})}finally{this.Uf=!1}}}else this.ap()}ap(){if(this.Bf=[],this.Hf){for(var t of(this.Hf=!1,this.dp&&(clearTimeout(this.dp),this.dp=void 0),this.zf))t();this.zf=[]}}vp(){var t=this.Bf;return this.ap(),t}get logger(){return this.fp||(this.fp={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.fp}flushLogs(t){this.ia&&(t?this.pp(t):(this.Gf&&this.Gf.flush().catch(t=>this.gp(t)),this.Jf&&this.Jf.flush().catch(t=>this.gp(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Gf)?void 0:e.flush().catch(e=>t.gp(e)),n=null==(i=t.Jf)?void 0:i.flush().catch(e=>t.gp(e));yield r,yield n})()}gp(t){ro(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.qi&&this.Lf&&!this.Df&&!this.Nf){var t=this.Zf();if(t){this.Nf=!0;try{t((t,e)=>{if(this.Nf=!1,!this.qi&&this.Lf)if(t||!e)this.R.error("Could not load logs script",t),this.ap();else{var i=this.vp();this.up=e.initialize(this.ia),this.Df=!0,i.length>0&&e.replay(this.ia,i)}})}catch(t){throw this.Nf=!1,t}}else this.ap()}}Xf(t,e){var i=this.ia;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:e=>e===n.LogsQueue?t():void 0,setPersistedProperty(t,i){t===n.LogsQueue&&e(null!=i?i:[])},Hs:t=>this.Hs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}Hs(t){return new Promise(e=>{if(Sn(this.Tv,3))e({kind:"fatal",error:io(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:io(void 0,"logs request timed out")})},9e4),s=this.Qf;this.ia.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.ia.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.mp(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:io(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})})}})}mp(t,e){(0!==t||e)&&(this.Tv=kn(t,this.Tv,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.")))}pp(t){this.Dc.length>0&&this.yp(t,this.Dc,this.np,this.ia.library.name,t=>{this.Dc=t}),this.jf.length>0&&this.yp(t,this.jf,this.op,to,t=>{this.jf=t})}yp(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ve(s,qe(i,this.ia.library.name,this.ia.library.version),r,this.ia.library.version);this.ia.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.ia.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.gp(t))}}},so=class extends no{constructor(t){super({get(){var e;return null==t||null==(e=t.config)?void 0:e.logs},captureHintKey:"$logs_capture_enabled_server_side",get remoteConfigWillArrive(){var e;return!(null!=t._shouldDisableFlags&&t._shouldDisableFlags()&&(null==(e=pn._POSTHOG_REMOTE_CONFIG)||null==(e=e[t.config.token])||!e.config))}},()=>function(t){var e,i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){var r=t.sessionManager.checkAndGetSessionAndWindowId(!0),n=r.windowId,s=r.sessionStartTimestamp,a=r.lastActivityTimestamp;i.sessionId=r.sessionId,i.windowId=n,_(s)||(i.sessionStartTimestamp=s),_(a)||(i.lastActivityTimestamp=a)}if(null!=pn&&null!=(e=pn.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(pn.location.href):pn.location.href),t.featureFlags){var o=t.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}(t)),this._instance=t,this.name="logs",this.Kf()}get Qf(){return this._instance.__loaded}Zf(){var t=ci("[logs]"),e=null==pn?void 0:pn.__PosthogExtensions__;if(e){var i=gn(this._instance);if(i)return t=>{i(this._instance,"logs",i=>{var r=e.logs;t(i,null!=r&&r.initializeLogs?{initialize:t=>r.initializeLogs(t),replay:(t,e)=>null==r.replayConsoleBuffer?void 0:r.replayConsoleBuffer(t,e)}:void 0)})};t.error(Ur)}else t.error("PostHog Extensions not found.")}},ao=/* @__PURE__ */ci("[NetworkMetrics]"),oo={"http:":80,"https:":443},lo=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),uo=t=>p(t)&&0===t.toLowerCase().indexOf("text/event-stream"),ho=t=>{try{return t()}catch(t){return}},co=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Tr(r))?void 0:i.href)||r}},vo=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=js()-n,d=Tr(i.url);if(d&&"http:"!==d.protocol&&"https:"!==d.protocol)return;var f={url:(null==d?void 0:d.href)||i.url,method:i.method},g=c(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var m=o&&!h?void 0:((t,e)=>t?400>t?void 0:String(t):(null==e?void 0:e.name)||"_OTHER")(h,a),_=e({},e({"http.request.method":b=lo.has(y=f.method)?y:"_OTHER"},"_OTHER"===b&&y!==b?{"http.request.method_original":y}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||oo[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:_})}catch(t){ao.error("Failed to record network metric",t)}var y,b},fo=()=>{},po=(t,e)=>c(null==un?void 0:un.fetch)?Pn(un,"fetch",i=>function(){for(var r=js(),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=co(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=>(uo(ho(()=>{var t;return null==i||null==(t=i.headers)?void 0:t.get("content-type")}))||vo(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw vo(t,d,void 0,r,e,i),i})}catch(t){return ao.error("Failed to observe fetch",t),o}}):fo,go=(t,e)=>{var i,r=null==un||null==(i=un.XMLHttpRequest)?void 0:i.prototype;if(!r)return fo;var n=/* @__PURE__ */new WeakMap,s=Pn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{Ds.has(this)||n.set(this,co(i[0],i[1]))}catch(t){ao.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=Pn(r,"send",i=>function(){var r,s;try{var a=n.get(this);if(a&&e()){var o=js(),l=()=>uo(ho(()=>this.getResponseHeader("content-type"))),u=!1;r=()=>{this.removeEventListener("loadend",r),this.removeEventListener("readystatechange",s),u||l()||vo(t,a,this.status,o,e)},gi(this,"readystatechange",s=()=>{2===this.readyState&&(u=l())}),gi(this,"loadend",r)}}catch(t){ao.error("Failed to observe XHR send",t)}try{for(var h=arguments.length,c=new Array(h),v=0;h>v;v++)c[v]=arguments[v];return i.apply(this,c)}catch(t){throw r&&this.removeEventListener("loadend",r),s&&this.removeEventListener("readystatechange",s),t}});return()=>{s(),a()}},mo=class{constructor(t){this._instance=t,this.R=ci("[metrics]"),this.qi=!1,this.Om=!1,this.gn=()=>{"hidden"===(null==vn?void 0:vn.visibilityState)&&this.flush()}}initialize(){this.onConfigChange(),this.qi||this.Om||null==vn||!vn.addEventListener||(gi(vn,"visibilitychange",this.gn),this.Om=!0)}onConfigChange(){var t;if(!this.qi){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.Fm?this.Fm=(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=po(t,i),n=go(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.Fm&&(this.Fm(),this.Fm=void 0)}}tp(){var t;if(!this.qi){var e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;if(!this.Gf||this.ep!==e){var i;null==(i=this.Gf)||i.reset(),this.ep=e;var r=function(t){var e,i,r,n,s,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==a?void 0:a["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==a?void 0:a["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(s=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==s?s:1e3}}(e);f(null==e?void 0:e.flushIntervalMs)&&(r.flushIntervalMs=6e4),this.Gf=new ri(this.Xf(),r,this.R)}return this.Gf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.tp())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.tp())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.tp())||r.histogram(t,e,i)}flush(t){if(!this.Gf)return Promise.resolve();if(t){var e=this.Gf.drainWindow();return e&&this.Go(e,t),Promise.resolve()}return this.Gf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Gf)||t.reset()}dispose(){var t,e;this.qi=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.gn),this.Om=!1,null==(t=this.Fm)||t.call(this),this.Fm=void 0,null==(e=this.Gf)||e.reset()}Xf(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Go:t=>e.Go(t),getLibraryId:()=>Is.LIB_NAME,getLibraryVersion:()=>Is.LIB_VERSION}}Go(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.Lm(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},"hidden"===(null==vn?void 0:vn.visibilityState)&&{preferSyncCompression:!0},{fireCallbackOnDrop:!0,callback(t){var e,i=t.statusCode;s(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:/* @__PURE__ */new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:/* @__PURE__ */new Error("metrics request failed with status "+i)})}}))})}Lm(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}},_o=/* @__PURE__ */new WeakMap,yo=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),bo={maxStringLength:2048,truncationSuffix:"..."},wo={maxStringLength:2048,truncationSuffix:"..."};function xo(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function So(t,e){return{}.hasOwnProperty.call(t,e)}function ko(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function Eo(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?ke(r,bo):r).slice(0,e)}}function Ao(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function To(t){return ke(t||"Unknown error",wo).slice(0,2048)}function Fo(t,e){try{return To(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 Oo(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:To(t.value)}))}function Po(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 Co(t,e){return{message:Fo(t,e),type:Po(t,e)}}var Ro=class{constructor(t){this._instance=t,this.Dm=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.Dm){var t=null==vn?void 0:vn.modelContext;if(t&&c(t.registerTool)){var e=_o.get(t);if(e)return e.instances.add(this._instance),void(this.Dm=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;Pn(t,"registerTool",t=>{var e=t;return function(t){for(var r=t,s=arguments.length,a=new Array(s>1?s-1:0),o=1;s>o;o++)a[o-1]=arguments[o];try{r=n.Nm(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(_o.set(t,i),this.Dm=!0)}}}Nm(t,i){if(!t||!c(t.execute))return t;var r=t.execute,n=this,s=function(t,i){var r={intent:!1,model:!1},n=t.inputSchema;if(!function(t){return!!f(t)||v(t)&&Object.keys(t).every(t=>yo.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:ko(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>So(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:ko(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:ko(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=xo(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?Eo(t.context,2048,!0):void 0,n=i.model?Eo(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&&So(r,"context"),s=i.model&&So(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.jm(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=Ao(t)?{error:t,errorResult:!0}:void 0;return n.jm(i,a,s,e,f),t},t=>{throw n.jm(i,a,s,{error:t,errorResult:!1},f),t});var g=Ao(c)?{error:c,errorResult:!0}:void 0;return n.jm(i,a,s,g,f),c}}),a}jm(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=xo(l.config.capture_webmcp);if(h){n&&!a&&(a=Co(n.error,n.errorResult));try{l.capture("$mcp_tool_call",e({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{},h.intent&&s.intent?{$mcp_intent:s.intent,$mcp_intent_source:"context_parameter"}:{},h.model&&s.model?{$mcp_llm_model:s.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:r})}catch(t){continue}if(n&&a&&l.exceptions&&null!=(u=l.exceptionObserver)&&u.isEnabled)try{var c={$exception_list:Oo(l.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}},$o={featureFlags:Ia,sessionRecording:rs,autocapture:Nr,historyAutocapture:Cn,heatmaps:as,deadClicksAutocapture:yn,webVitalsAutocapture:Gn,exceptionObserver:wn,exceptions:Ua,productTours:us,siteApps:vs,surveys:Ns,tracingHeaders:$n,toolbar:Hs,experiments:Ga,conversations:Xa,logs:so,metrics:mo,webMCP:Ro},Mo={featureFlags:Ia},Io={sessionRecording:rs},Do={autocapture:Nr,historyAutocapture:Cn,heatmaps:as,deadClicksAutocapture:yn,webVitalsAutocapture:Gn},jo={exceptionObserver:wn,exceptions:Ua},Lo={productTours:us,featureFlags:Ia},No={siteApps:vs},zo={surveys:Ns,featureFlags:Ia},Bo={tracingHeaders:$n},Uo={toolbar:Hs},Ho={experiments:Ga,featureFlags:Ia},qo={conversations:Xa},Vo={logs:so},Wo={metrics:mo},Go={webMCP:Ro};export{$o as AllExtensions,Do as AnalyticsExtensions,qo as ConversationsExtensions,jo as ErrorTrackingExtensions,Ho as ExperimentsExtensions,Mo as FeatureFlagsExtensions,Vo as LogsExtensions,Wo as MetricsExtensions,Lo as ProductToursExtensions,Io as SessionReplayExtensions,No as SiteAppsExtensions,zo as SurveysExtensions,Uo as ToolbarExtensions,Bo as TracingExtensions,Go 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,_=t=>f(t)||m(t),y=t=>"[object Number]"==u.call(t)&&t==t,b=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function x(t,e){return{}.toString.call(t)==="[object "+e+"]"}function S(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return E(t,Error)}}function k(t){return"u">typeof Event&&E(t,Event)}function E(t,e){try{return t instanceof e}catch(t){return!1}}var A=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","lightpanda","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],T=/* @__PURE__ */new Map,F=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=function(t,e){for(var i="",r=0;e.length>r;r++){var n=e[r];i+=n.length+":"+n}return t.length+":"+t+"|"+e.length+":"+i}(t,e),r=T.get(i);if(void 0!==r)return r;var n=t.toLowerCase(),s=A.concat(e).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>T.size||T.clear(),T.set(i,s),s};function O(t,e,i,r,n){return e>i&&(r.warn("min cannot be greater than max."),e=i),y(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),O(null!=n?n:i,e,i,r))}var P=class{constructor(t){this.C={},this.I=t.I,this.A=O(t.bucketSize,0,100,t.R),this.O=O(t.refillRate,0,this.A,t.R),this.$=O(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",R="Nintendo",M="PlayStation",I="Windows",D=/* @__PURE__ */new RegExp("BlackBerry|PlayBook|BB10","i"),j={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},L=[[/* @__PURE__ */new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>["Xbox",t&&t[1]||""]],[/* @__PURE__ */new RegExp(R,"i"),[R,""]],[/* @__PURE__ */new RegExp(M,"i"),[M,""]],[D,["BlackBerry",""]],[/* @__PURE__ */new RegExp(I,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return["Windows Phone",""];if(new RegExp("Mobile").test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=j[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[I,r]}return[I,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=f(t[2])?t[3]:t[2]),["watchOS",e]}],[/* @__PURE__ */new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[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=0;50>s&&1e3>a&&g>y;y++){a++;var b=void 0;try{b=c.next(m[y])}catch(t){s++,b=n.coerceFallback(v(i+1))}b&&_.push(b)}return e({},p,{errors:_})}},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 _t(t,e){var i=e.start+e.length,r=bt(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function yt(t,e){for(var i=e.start;i>0&&gt(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function bt(t,e){for(var i=e.start+e.length,r=i;t.length>r&&gt(t[r],t[r-e.length]);)r++;return r-i}function wt(t,e){var i=e[0],r=t.length-(i?yt(t,i):0);for(var n of e)r-=bt(t,n);return r}function xt(t,e,i){for(var r=0;t.length>r;r++){var n=t[(e+r)%t.length],s=t[(i+r)%t.length];if(n!==s)return s>n}return!1}var St=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=p(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return x(t,"DOMException")}isDOMError(t){return x(t,"DOMError")}},kt=class{match(t){return S(t)}coerce(t,e){var i,r=this.getStack(t),n=void 0===r?null==(i=e.syntheticException)?void 0:i.stack:void 0,s=!!n;return{type:this.getType(t),value:this.getMessage(t,e),stack:null!=r?r:n,cause:t.cause?e.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){try{var e=t.stacktrace;if("string"==typeof e&&e.length>0)return e;var i=t.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(t){return}}},Et=class{match(t){return!!x(t,"ErrorEvent")&&(null!=t.error||this.$r(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.Lr(t))&&void 0!==r?r:n.stack,synthetic:!0})}$r(t){return p(t.message)&&t.message.length>0}Lr(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 Ot(t,e){void 0===e&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";var r="";for(var n of i){var s=r?r+", "+n:n;if(s.length>e)break;r=s}return r}var Pt=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: "+Ot(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: "+Ot(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}},Rt=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}}},$t=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}},Mt="$message",It="$timestamp",Dt=/* @__PURE__ */new Set([Mt,It]),jt={enabled:!0,max_bytes:32768};function Lt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:jt.enabled,max_bytes:zt(t.max_bytes,jt.max_bytes)}:e({},jt)}var Nt=class{constructor(t){this.ns=[],this.ss=0,this.Yr=Lt(t)}setConfig(t){this.Yr=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[Mt],o=s[It];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!y(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.Yr.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.Yr.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function zt(t,e){if(!y(t)||1/0===t||-1/0===t)return e;var i=Math.floor(t);return 0>i?e:i}var Bt=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function Ut(t){return"string"==typeof t||t}function Ht(t){return"string"==typeof t?t:void 0}var qt="[redacted]",Vt=/^[A-Za-z0-9+/\n\r]+=*$/,Wt=/^[A-Za-z0-9_-]+={0,2}$/,Gt=/[-_]/,Kt=/^data:[^,\s]*;base64,/i,Jt=/^[A-Za-z0-9+/_-]+={0,2}$/,Xt=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Yt=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Zt=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Qt=/[\s<>"]/,te=/* @__PURE__ */(()=>new RegExp(Zt.source,"i"))(),ee=/[a-z][a-z0-9+.-]{0,63}:\/\//i,ie=/* @__PURE__ */(()=>new RegExp("^"+ee.source,"i"))(),re=/* @__PURE__ */(()=>new RegExp(ee.source,"gi"))(),ne=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,se=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ae=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,oe=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,le=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,ue=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,he=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,ce=/\d+/g,ve=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,de=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function fe(t){return function(t){return Yt.test(t)}(t)||ne.test(t)||se.test(t)}function pe(t){return t.split("&",129).length>128}function ge(t,e,i){return fe(t)||e.includes(";")&&function(t){return t.split(";").some(t=>fe(t.split("=",1)[0]))}(e)?qt:te.test(e)?i?xe(e,{allowNestedUrls:!1,stripPunctuation:!0}):qt:e}function me(t,e){var i=new URLSearchParams,r=!1,n=!1;for(var s of new URLSearchParams(t)){var a=s[0],o=s[1],l=Se(a),u=Se(o);r||(r=l!==a||u!==o);var h=ge(l,u,e);r||(r=h!==u),n=fe(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function _e(t,e){if(!t.includes("="))return{value:ye(t,e),lastFieldSensitive:!1};var i=me(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function ye(t,e){return e?xe(t,{allowNestedUrls:!1,stripPunctuation:!0}):te.test(t)?qt:t}function be(t,e,i){return"#"===t?!e.fragment&&(e.fragment=!0):"?"===t&&(e.fragment?"="!==i&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function we(t,e){var i;if(t.length>8192&&ie.test(t))return qt;var r,n=e.stripPunctuation?function(t){for(var e=t.length;e>0&&".,;:!?)]}'".includes(t[e-1]);)e--;return{address:t.slice(0,e),suffix:t.slice(e)}}(t):{address:t,suffix:""},s=n.address,a=n.suffix;try{r=new URL(s)}catch(t){return qt+a}var o=r.search.slice(1),l=""!==r.hash,u=function(t){var e=t.slice(1),i=e.indexOf("?");return 0>i?{head:e,tail:null}:{head:e.slice(0,i),tail:e.slice(i+1)}}(r.hash);if(pe(o)||pe(u.head)||pe(null!==(i=u.tail)&&void 0!==i?i:""))return qt+a;var h=!1;(r.username||r.password)&&(r.username=qt,r.password="",h=!0);var c=me(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=_e(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":qt,lastFieldSensitive:!0}:_e(v,e.allowNestedUrls)),p=null===f?d.value:d.value+"?"+f.value;p!==r.hash.slice(1)&&(r.hash=p,h=!0);var g=l?null!=f?f:d:c;return(h?Se(r.toString()):s)+(g.lastFieldSensitive?"":a)}function xe(t,i){return t.replace(Zt,r=>function(t,i){var r=function(t){if(!t.includes("://"))return[];for(var e=[...t.matchAll(re)].map(t=>t.index),i=[],r={query:!1,fragment:!1,fragmentQuery:!1},n=0,s=!1,a="",o=0;t.length>o&&e.length>n;o++){e[n]===o&&(o>0&&"="!==a&&i.push(o),n++);var l=t[o];be(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return we(t,i);var n="",s=0;for(var a of r)n+=we(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+we(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function Se(t){return t.replace(Xt,qt)}function ke(t,e){return function(t){return t.length>=10240&&(Vt.test(t)||function(t){var e,i=Kt.exec(t);if(!i)return!1;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Jt.test(e.replace(/[\r\n]/g,""))}(t)||Gt.test(t)&&Wt.test(t))}(t)?"[binary data redacted - not supported by PostHog MCP analytics]":function(t,e,i){var r=4*i.maxStringLength;if(t.length>r){var n=e(t.slice(0,function(t,e){for(var i=e;i>0&&!Qt.test(t[i-1]);)i--;return i}(t,r)));if(n.length>=2*i.maxStringLength)return n+i.truncationSuffix}return e(t)}(t,t=>function(t){return xe(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(ae," ");return(e=(e=(e=function(t){for(var e="",i=0,r=Oe(t,0);null!==r;r=Oe(t,r[1]))e+=t.slice(i,r[0])+Pe(t.slice(r[0],r[1])),i=r[1];return e+t.slice(i)}(e=(e=(e=e.replace(oe,qt)).replace(le,qt)).replace(ue,"$1"+qt))).replace(he,qt)).replace(ve,"$1"+qt)).replace(de,"$1"+qt)}(Se(t))),e)}function Ee(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;if(0>n||n>9)return!1;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function Ae(t,e){var i=t.charCodeAt(e);return i>=48&&57>=i}function Te(t,e){var i=t.charCodeAt(e);return Ae(t,e)||95===i||i>=65&&90>=i||i>=97&&122>=i}function Fe(t,e){for(var i=e;Ae(t,i);)i++;return i}function Oe(t,e){for(var i=e;t.length>i;i++)if(Ae(t,i)&&!Te(t,i-1)){for(var r=0,n=-1,s=i;;){var a=Fe(t,s);if(13>(r+=a-s)||Te(t,a)||(n=a),s=a+1,!" ./-".includes(t.charAt(a))||!Ae(t,s))break}if(n>=0)return[i,n];i=s-1}return null}function Pe(t){for(var e=[],i=ce.exec(t);null!==i;i=ce.exec(t))e.push({digits:i[0],start:i.index,end:i.index+i[0].length});for(var r="",n=0,s=0;e.length>s;){for(var a="",o=-1,l=s;e.length>l&&19>=(a+=e[l].digits).length;l++)a.length>=13&&Ee(a)&&(o=l);0>o?s++:(r+=t.slice(n,e[s].start)+qt,n=e[o].end,s=o+1)}return r+t.slice(n)}var Ce={}.propertyIsEnumerable;function Re(t,e){try{return Ie(t,e,{ancestors:/* @__PURE__ */new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function $e(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:N};if(i.remainingNodes--,b(t))return{boolValue:t};if("bigint"==typeof t)return function(t,e){var i=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==e||e.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(t,e);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var n=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==e||e.debug("Attribute "+n+" is outside the int64 range; encoding it as a string"),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:B(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(i.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:N};if(t instanceof Date){var s=t.getTime(),a=Number.isFinite(s)?t.toISOString():String(t);return{stringValue:"string"==typeof a?B(a):String(a)}}i.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return $e(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:Me(t,e,i,r+1)}}:{kvlistValue:{values:Ie(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:B(String(t))}}function Me(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(_(o))continue;n.push($e(o,e,i,r))}catch(t){n.push({stringValue:z})}return t.length>a&&n.push({stringValue:N}),n}function Ie(t,e,i,r){var n=[];for(var s in t)if(Ce.call(t,s)){if(!s){null==e||e.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[s];if(m(a)||f(a))continue;n.push({key:B(s),value:$e(a,e,i,r)})}catch(t){n.push({key:B(s),value:{stringValue:z}})}}return n}function De(t,i,r){return e({},U({},t.resourceAttributes),{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":r})}var je=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Le(t,e){var i=U({},t),r={};for(var n of je)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Re(i,e),...Re(r,e)]}var Ne={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};var ze={text:"INFO",number:9},Be={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:ze,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function Ue(t){try{return B(String(t))}catch(t){return z}}function He(t,i,r,n){var s,a=Be[t.level||"info"]||ze,o=a.text,l=a.number,u=(void 0===(s=y(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),_(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),_(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var c=e({},h),v=t.attributes;if(v){var d=[];try{d=Object.keys(v)}catch(t){d=[]}for(var p of d){var g=void 0;try{g=v[p]}catch(t){g=z}Object.defineProperty(c,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Ue(t.body)},attributes:Re(c,r)};return t.trace_id&&(m.traceId=t.trace_id),t.span_id&&(m.spanId=t.span_id),f(t.trace_flags)||(m.flags=t.trace_flags),m}function qe(t,e,i){return De(t,e,i)}function Ve(t,e,i,r){return{resourceLogs:[{resource:{attributes:Le(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var We=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=Y(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Ge(){return.75+.5*Math.random()}function Ke(t,e,i,r){var n=t*Math.pow(2,Math.min(Math.max(0,e-1),6));return Math.round((void 0===r?n:Math.min(n,Math.max(r,t)))*i)}var Je=class{constructor(t,e,i,r,n,s,a,o){var l;void 0===s&&(s=()=>Promise.resolve()),void 0===o&&(o=()=>!1),this._instance=t,this.Yr=e,this.R=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=o,this.gs=new We(()=>this.ys()),this.bs=null,this._s=0,this.ws=0,this.ks=null,this.Ss=new K,this.xs=0,this.$s=1,this.Cs=0,this.Ts=0,this.Ms=!1,this.Is=e.maxBufferSize,this.Es=Math.max(null!==(l=e.maxQueueSize)&&void 0!==l?l:e.maxBufferSize,e.maxBufferSize),this.As=e.flushIntervalMs,this.Rs=e.maxBatchRecordsPerPost,this.Ps=e.rateCapWindowMs,this.Os=e.maxLogsPerInterval}clearQueue(){this.ws++,this._instance.setPersistedProperty(n.LogsQueue,[])}get throttled(){return this.Ss.isOpen()}reset(){this.gs.clear(),this.Cs=0,this.Ts=0,this.Ms=!1,this.xs=0,this.$s=1,this.Ss.reset(),this.Rs=this.Yr.maxBatchRecordsPerPost}onReconnect(){this.xs=0,this.$s=1,this.Ss.isOpen()?this.Fs()&&this.Ls():this.ys()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ds(t);if(null!==r)if(r.body){if(this.Ns()){var n={record:He(r,null!==(i=null==e?void 0:e.context)&&void 0!==i?i:this.hs(),this.R,null==e?void 0:e.occurredAtMs)};this.ds(()=>this.js(n))}}else this.R.info("Log was rejected in beforeSend function")}}Ds(t){var e=this.Yr.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Log was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for log:",t),null}return r}Ns(){if(void 0===this.Os)return!0;var t=Date.now(),e=t-this.Cs;return this.Ps>e&&e>=0||(this.Cs=t,this.Ts=0,this.Ms=!1),this.Os>this.Ts?(this.Ts++,!0):(this.Ms||(this.R.warn("captureLog dropping logs: exceeded "+this.Os+" logs per "+this.Ps+"ms"),this.Ms=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.bs||(t.bs=t.qs().finally(()=>{t.bs=null})),t.bs})()}qs(){var t=this;return r(function*(){var e;if(t.gs.clear(),!t.Bs()){var i=null!==(e=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var a,o;if(t.Bs())return;var l=t.ws;t._s=0;var u=Math.min(i.length,t.Rs),h=i.slice(0,u),c=Ve(h.map(t=>t.record),t.zs(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.Hs(c);if(t.ws!==l)return;if("too-large"===v.kind&&h.length>1)t.Rs=Math.max(1,Math.floor(h.length/2)),t.R.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Rs);else{if(t.Ss.record(v),t.gs.pending&&t.gs.arm(Math.max(t.As,t.Ss.remainingMs())),"retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.R.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===v.kind&&t.Yr.maxBatchRecordsPerPost>t.Rs&&(t.Rs=Math.min(t.Yr.maxBatchRecordsPerPost,t.Rs+1)),yield t.Us(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}}})()}Bs(){return!!this.ps()&&(this.Fs()&&this.clearQueue(),!0)}Us(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e._s),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}zs(){return qe(this.Yr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}js(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Es>i.length||(i.shift(),this._s++,this.R.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Is>i.length||this.Ss.isOpen()?this.Ls():this.ys()}}Ls(){this.gs.pending||this.gs.arm(Math.max(this.As,this.Ss.remainingMs()))}Ws(){return Math.max(Ke(this.As,this.xs,this.$s,3e4),this.Ss.remainingMs())}Fs(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.gs.clear();var i=e.flush().catch(()=>{});void 0!==t?yield Z(i,t):yield i})()}flushWithTimeout(t){var e=this;return r(function*(){var i=e.flush();yield Z(i,t,()=>{i.catch(()=>{})})})()}flushInBackground(){if(this.ks)return this.ks;var t=this.flush().then(()=>{this.xs=0,this.$s=1},t=>{this.xs++,this.$s=Ge(),this.R.error("PostHog logs flush failed:",t)}).finally(()=>{this.ks===t&&(this.ks=null),!this._instance.isDisabled&&this.Fs()&&this.gs.armNoEarlierThan(this.Ws())});return this.ks=t,t}ys(){this.flushInBackground()}},Xe=/^[0-9a-f]+$/;function Ye(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Xe.test(t)}var Ze=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Qe="00",ti=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ei(t){return String(t)+"000000"}function ii(t,e,i,r){var n="";return r&&(n=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+n}var ri=class{constructor(t,e,i){this._instance=t,this.Yr=e,this.R=i,this.Vs=/* @__PURE__ */new Map,this.gs=new We(()=>this.flush().catch(t=>{this.R.error("Metrics flush failed:",t)})),this.bs=null,this.Gs=null,this.Js=!1,this.Qs=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ks=/* @__PURE__ */new Map,this.Ys=/* @__PURE__ */new Set,this.Xs=!1,this.Ss=new K,this.xs=0,this.$s=1,this.Po=0}count(t,e,i){void 0===e&&(e=1),this.Fo({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.Fo({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.Fo({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:h(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var t=this,e=this.bs,i=/* @__PURE__ */function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.No()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.bs===i&&(this.bs=null)});return this.bs=i,i}flushCoalesced(){var t,e;return this.jo()?null!==(t=this.bs)&&void 0!==t?t:Promise.resolve():(this.Gs||(this.Gs=(null!==(e=this.bs)&&void 0!==e?e:Promise.resolve()).catch(()=>{}).then(()=>(this.Gs=null,this.jo()?void 0:this.flush()))),this.Gs)}jo(){return this.xs>0||this.Ss.remainingMs()>0}drainWindow(){if(0===this.Vs.size)return null;var t=this.Vs;return this.qo(),this.Bo(t)}reset(){this.Po++,this.Ss.reset(),this.xs=0,this.$s=1,this.gs.clear(),this.bs=null,this.Gs=null,this.qo(),this.Ks=/* @__PURE__ */new Map,this.Xs=!1}qo(){this.Vs=/* @__PURE__ */new Map,this.Js=!1,this.Qs=/* @__PURE__ */new Map,this.Zs=/* @__PURE__ */new Set,this.Ys=/* @__PURE__ */new Set}Fo(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ds(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type||"gauge"===i.type||"histogram"===i.type)if("count"===i.type&&0>i.value)this.R.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var r,n;try{r=i.attributes?e({},i.attributes):void 0,n=ii(i.type,i.name,i.unit,r)}catch(t){return void this.R.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s,a=this.Vs.get(n);if((a||this.zo())&&("histogram"!==i.type||(s=this.Ho(i.name,i.unit,i.bounds)))){a||(a={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now(),hist:s&&si(s)},this.Vs.set(n,a));var o=this.Qs.get(i.name);void 0===o?this.Qs.set(i.name,i.type):o===i.type||this.Zs.has(i.name)||(this.Zs.add(i.name),this.R.warn("Metric name '"+i.name+"' is already used as a "+o+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Uo(a,i.value);var l=this.Wo();l&&(a.exemplar=e({},l,{value:i.value,timeMs:Date.now()})),this.Ls()}}else this.R.warn("Dropping metric '"+i.name+"': unknown type '"+String(i.type)+"'");else this.R.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.R.warn("Dropping metric with empty name")}}Wo(){try{var t,e,i=(r=null==(t=(e=this._instance).getActiveSpan)||null==(t=t.call(e))?void 0:t.traceparent(),s=function(t){if("string"==typeof t){var e=Ze.exec(t.trim());if(e){var i=e[1],r=e[2],n=e[3],s=e[4];if("ff"!==i&&("00"!==i||!e[5])&&function(t){return Ye(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Ye(t,16,"0000000000000000")}(n))return{version:i,traceId:r,spanId:n,flags:s}}}}(r),s&&{traceId:s.traceId,spanId:s.spanId,flags:(n=s.flags,1&parseInt(n,16)?"01":Qe)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}zo(){return this.Yr.maxSeriesPerFlush>this.Vs.size||(this.Js||(this.Js=!0,this.R.warn("Metric series cap reached ("+this.Yr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ho(t,e,i){if(void 0===i||function(t){if(!h(t)||0===t.length)return!1;for(var e=0;t.length>e;e++)if(!Number.isFinite(t[e])||e>0&&t[e-1]>=t[e])return!1;return!0}(i)){var r=ii("histogram",t,e,void 0),n=this.Ks.get(r);if(n)return this.Vo(t,r,n,i),n;if(this.Ks.size>=this.Yr.maxSeriesPerFlush){if(this.Xs||(this.Xs=!0,this.R.warn("Histogram bounds limit reached ("+this.Yr.maxSeriesPerFlush+" distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.")),i&&!ni(i,ti))return;return ti}var s=i?i.slice():ti;return this.Ks.set(r,s),s}this.R.warn("Dropping histogram '"+t+"': bounds must be a non-empty array of finite, strictly increasing numbers")}Vo(t,e,i,r){ni(i,null!=r?r:ti)||this.Ys.has(e)||(this.Ys.add(e),this.R.warn("Histogram '"+t+"' already uses the bounds ["+i.join(", ")+"]; samples that pass different bounds are recorded in those buckets."))}Uo(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,r.bounds)]+=1}}Ds(t){var e=this.Yr.beforeSend;if(!e)return t;var i=h(e)?e:[e],r=t;for(var n of i)try{var s=n(r);if(!s)return this.R.info("Metric was rejected in beforeSend function"),null;r=s}catch(t){return this.R.error("Error in beforeSend function for metric:",t),null}return r}Ls(){this.gs.pending||this.gs.arm(this.Ws())}Ws(){return Math.max(Ke(this.Yr.flushIntervalMs,this.xs,this.$s,3e4),this.Ss.remainingMs())}No(){var t=this;return r(function*(){if(t.gs.clear(),0!==t.Vs.size){var e=t.Vs;t.qo();var i=t.Po,r=yield t._instance.Go(t.Bo(e));if(i===t.Po)switch(t.Ss.record(r),"retry-later"===r.kind?(t.xs++,t.$s=Ge()):(t.xs=0,t.$s=1),t.gs.pending&&t.gs.arm(t.Ws()),r.kind){case"ok":return;case"retry-later":return t.Jo(e),void t.gs.armNoEarlierThan(t.Ws());case"too-large":return void t.R.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.R.error("Failed to send metrics batch:",r.error)}}})()}Bo(t){return e=this.Qo(t),i=function(t,e,i){return De(t,e,i)}(this.Yr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Le(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}Qo(t){var i=ei(Date.now()),r=/* @__PURE__ */new Map;for(var n of t.values()){var s,a=ii(n.type,n.name,n.unit,void 0),o=r.get(a);o||(o=e({name:n.name},n.unit&&{unit:n.unit}),"count"===n.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===n.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Re(null!==(s=n.attributes)&&void 0!==s?s:{},this.R),u=ei(n.windowStartMs),h=ai(n.exemplar);if("count"===n.type){var c,v=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(c=n.total)&&void 0!==c?c:0},h);o.sum.dataPoints.push(v)}else if("gauge"===n.type){var d,f=e({attributes:l,timeUnixNano:i,asDouble:null!==(d=n.last)&&void 0!==d?d:0},h);o.gauge.dataPoints.push(f)}else{var p=n.hist,g=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,count:p.count,sum:p.sum,min:p.min,max:p.max,bucketCounts:p.bucketCounts,explicitBounds:p.bounds},h);o.histogram.dataPoints.push(g)}}return Array.from(r.values())}Jo(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Vs.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,a.windowStartMs),o.exemplar=null!==(n=o.exemplar)&&void 0!==n?n:a.exemplar,o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=a.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":var l=o.hist,u=a.hist;l.count+=u.count,l.sum+=u.sum,l.min=Math.min(l.min,u.min),l.max=Math.max(l.max,u.max);for(var h=0;l.bucketCounts.length>h;h++)l.bucketCounts[h]+=u.bucketCounts[h]}else this.zo()&&this.Vs.set(s,a)}}};function ni(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(var i=0;t.length>i;i++)if(t[i]!==e[i])return!1;return!0}function si(t){return{bounds:t,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(t.length+1).fill(0)}}function ai(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:ei(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var oi="0.14.1",li={DEBUG:!1,LIB_VERSION:oi,LIB_NAME:"browser-common",JS_SDK_VERSION:oi},ui=function(t,e){var i=(void 0===e?{}:e).debugEnabled,r={N(e){var r;try{r=typeof window>"u"?void 0:window}catch(t){return}for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;n>a;a++)s[a-1]=arguments[a];r&&(li.DEBUG||r.POSTHOG_DEBUG||i)&&!f(r.console)&&r.console&&("__rrweb_original__"in r.console[e]?r.console[e].__rrweb_original__:r.console[e])(t,...s)},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>ui(t+" "+e,i)};return r},hi=/* @__PURE__ */ui("[PostHog.js]"),ci=(t,e)=>hi.createLogger(t,e);function vi(t,e){h(t)&&t.forEach(e)}function di(t,e){if(!_(t))if(h(t))t.forEach(e);else if(t instanceof FormData)t.forEach((t,i)=>e(t,i));else for(var i in t)l.call(t,i)&&e(t[i],i)}var fi=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var n of i)for(var s in n)void 0!==n[s]&&(t[s]=n[s]);return t};function pi(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}function gi(t,e,i,r){var n=null!=r?r:{},s=n.capture,a=n.passive;null==t||t.addEventListener(e,i,{capture:void 0!==s&&s,passive:void 0===a||a})}function mi(t){return"ph_toolbar_internal"===t.name}function _i(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!c(r))return e;try{var n=r(e);return p(n)&&n?n:e}catch(t){return hi.error("Error in get_current_url, falling back to window.location.href",t),e}}var yi="$early_access_features",bi="$active_feature_flags",wi="$feature_flag_details",xi="$feature_flag_errors",Si="$feature_flag_evaluated_at",ki="$feature_flag_request_id",Ei="$minimal_flag_called_events",Ai="$enabled_feature_flags",Ti="$stored_group_properties",Fi="$stored_person_properties",Oi="$flag_call_reported",Pi="$flag_call_reported_session_id",Ci="$feature_flag_payloads",Ri="$override_feature_flags",$i="$override_feature_flag_payloads",Mi="visibilitychange",Ii="$autocapture_disabled_server_side";function Di(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ji(t){return!!t&&1===t.nodeType}function Li(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Ni(t){return!!t&&3===t.nodeType}function zi(t){return!!t&&11===t.nodeType&&ji(t.host)}function Bi(t){return t?a(t).split(/\s+/):[]}function Ui(t,e){var i=function(t){var e,i=null==(e=typeof window>"u"?void 0:window)||null==(e=e.location)?void 0:e.href;return f(i)?void 0:_i(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function Hi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Bi(e)}function qi(t){return _(t)?null:a(t).split(/(\s+)/).filter(t=>wr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Vi(t){var e="";return vr(t)&&!dr(t)&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;Ni(t)&&t.textContent&&(e+=null!==(i=qi(t.textContent))&&void 0!==i?i:"")}),a(e)}function Wi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var Gi=["a","button","form","input","select","textarea","label"];function Ki(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}function Ji(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Ki(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Xi(t){var e=t.parentNode;return!(!e||!ji(e))&&e}var Yi=[".ph-no-autocapture","[data-ph-no-autocapture]"],Zi=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Qi=/* @__PURE__ */(()=>[...Zi,"+","-","−","–"])(),tr=/* @__PURE__ */(()=>Qi.length+10)(),er=["button","a","input","select","textarea","label"],ir=["button","link","tab","menuitem","option"],rr=(t,e)=>/[a-z0-9]/i.test(e)?s(Qi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,nr=t=>s(er,t.tagName.toLowerCase())||s(ir,(t.getAttribute("role")||"").toLowerCase());function sr(t){var e="",i="",r=t=>{ji(t)&&vr(t)&&!dr(t)&&(e+=" "+Vi(t),i=i||t.getAttribute("aria-label")||"",di(t.childNodes,r))};r(t);var n=(wr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var ar=[".ph-no-rageclick",".ph-no-capture"],or=["","text","search","email","password","url","tel","number"];function lr(t,e){if(!(typeof window>"u"?void 0:window)||ur(t))return!1;var i,r,n,a,o;if(b(e)?(i=!!e&&ar,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:ar,r=null==e?void 0:e.content_ignorelist,n=null!==(o=null==e?void 0:e.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(t){return!(!t||!ji(t))&&(!!Li(t,"textarea")||(Li(t,"input")?s(or,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var l=hr(t,!1),u=l.targetElementList;return!(!l.isComplete||r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Zi;else{if(!h(t))return!1;if(t.length>tr)return hi.error("[PostHog] content_ignorelist array cannot exceed "+tr+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>rr(r,t)||rr(n,t))}(r,function(t,e){for(var i of e)if(nr(i))return sr(i);for(var r of e){try{var n;if("pointer"!==(null==(n=window)?void 0:n.getComputedStyle(r).getPropertyValue("cursor")))break}catch(t){break}var s=sr(r);if(s.safeText||s.ariaLabel)return s}return sr(t)}(t,u))||Ji(u,i))}var ur=t=>!t||Li(t,"html")||!ji(t),hr=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ur(t))return{parentIsUsefulElement:!1,targetElementList:[],isComplete:!1};for(var r=!1,n=[t],s=t,a=/* @__PURE__ */new Set([t]);!Li(s,"body");){var o=s.assignedSlot||s.parentNode,l=zi(o)?o.host:o&&ji(o)?o:null;if(!l)break;if(a.has(l)||a.size>=1e3)return{parentIsUsefulElement:r,targetElementList:n,isComplete:!1};if(a.add(l),zi(o))n.push(l),s=l;else{if(e||Gi.indexOf(l.tagName.toLowerCase())>-1)r=!0;else try{var u=i.getComputedStyle(l);u&&"pointer"===u.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(l),s=l}}return{parentIsUsefulElement:r,targetElementList:n,isComplete:!0}};function cr(t){for(var e=/* @__PURE__ */new Set,i=0,r=t;r;){if(i++>=1e3||e.has(r))return!0;e.add(r);var n=Hi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!0;var a=r.assignedSlot||r.parentNode;r=zi(a)?a.host:a&&ji(a)?a:null}return!1}function vr(t){if(cr(t))return!1;if(s(Hi(t),"ph-include"))return!0;var e=t.type||"";if(p(e))switch(e.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";return!p(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,""))}function dr(t){return!!(Li(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Li(t,"select")||Li(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var fr=/* @__PURE__ */new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),pr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,gr=[16,15,14,13],mr=/* @__PURE__ */new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),_r=/* @__PURE__ */new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),yr=/[0-9A-Za-z_]/;function br(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function wr(t,e){if(void 0===e&&(e=!0),_(t))return!1;if(p(t)){if(t=a(t),e?fr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(pr.lastIndex=0;e=pr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of gr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(fr.test(o)&&br(o))return!0}}}return!1}(t))return!1;if(e?mr.test(t):function(t){var e;for(_r.lastIndex=0;e=_r.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&yr.test(i)&&yr.test(r)))return!0}return!1}(t))return!1}return!0}function xr(t){var e=Vi(t);return wr(e=(e+" "+Sr(t)).trim())?e:""}function Sr(t){var e="";return t&&t.childNodes&&t.childNodes.length&&di(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Vi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Sr(t)).trim())}catch(t){hi.error("[AutoCapture]",t)}}),e}function kr(t){return t.replace(/"|\\"/g,'\\"')}function Er(t){var e=t.attr__class;if(e)return h(e)?e:Bi(e)}var Ar=class{constructor(t){this.disabled=!1===t;var e=v(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}},Tr=t=>{var e,i=null==(e=typeof document>"u"?void 0:document)?void 0:e.createElement("a");return f(i)?null:(i.href=t,i)},Fr=()=>typeof window>"u"?void 0:window,Or=()=>typeof document>"u"?void 0:document,Pr="$copy_autocapture",Cr=["password","hidden","file","checkbox","button","submit","reset","image"],Rr=/* @__PURE__ */ci("[AutoCapture]");function $r(t,e){return e.length>t?e.slice(0,t)+"...":e}function Mr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ji(e));return e}function Ir(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!ji(t))return{props:{}};for(var d=[t],f=/* @__PURE__ */new Set([t]),g=t;!Li(g,"body")&&1e3>d.length;){var m=g.assignedSlot||g.parentNode,_=zi(m)?m.host:m&&ji(m)?m:null;if(!_||f.has(_))break;f.add(_),d.push(_),g=_}var y="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Li(t,"button")||Li(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!vr(t)||dr(t)));var b,w,x,S=[],k={},E=!1,A=!1;if(di(d,t=>{var e=vr(t);if(e&&Li(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");E=!!(e&&i&&wr(i))&&(v?J(i):i)}s(Hi(t),"ph-no-capture")&&(A=!0),S.push(function(t,e,i,r,n){void 0===n&&(n=!1);var s=t.tagName.toLowerCase(),a={tag_name:s};Gi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?$r(1024,xr(t)):$r(1024,Vi(t)));var o=Hi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),di(cr(t)?[]:t.attributes,function(i){var s;if((!dr(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&wr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Bi(o).join(" ")),a["attr__"+i.name]=$r(1024,"href"===i.name&&n?J(o):o)}});for(var l=1,u=1,h=t;h=Mr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),di(function(t){if(!vr(t))return{};var e={};return di(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&wr(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(k,e)||(k[e]=t)})}),A)return{props:{},explicitNoCapture:A};if(y>0&&(t=d[y],S.splice(0,y)),l||(S[0].$el_text=Li(t,"a")||Li(t,"button")?xr(t):Vi(t)),E){var T,F;S[0].attr__href=E;var O=null==(T=Tr(E))?void 0:T.host,P=null==(F=Fr())||null==(F=F.location)?void 0:F.host;O&&P&&O!==P&&(b=E)}return{props:fi((w=a.type,{$event_type:w,$ce_version:1}),c?{}:{$elements:S},{$elements_chain:(x=S,h(x)?function(t){return t.map(t=>{var i,r,n="";if(t.tag_name&&(n+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))n+="."+s.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return pi(a).sort((t,e)=>{return(r=e[0])>(i=t[0])?-1:i>r?1:0;var i,r}).forEach(t=>{var e=t[1];return o[kr(t[0].toString())]=kr(e.toString())}),(n+=":")+pi(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Er(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return pi(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(x)):"")},null!=(r=S[0])&&r.$el_text?{$el_text:null==(n=S[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},k),target:t}}var Dr=class{Pa(){this.Oa=void 0,clearTimeout(this.Fa),this.Fa=void 0}La(t){var e;if(!vr(t))return!0;for(var i,r=null!==(e=this.Da().css_selector_ignorelist)&&void 0!==e?e:Yi,n=/* @__PURE__ */new Set,a=t,o=function(){if(n.size>=1e3||n.has(a))return{v:!0};n.add(a);var t=a,e=Hi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||dr(t)||r.some(e=>Ki(t,e)))return{v:!0};var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(i=o())return i.v;return!1}Na(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.Oa;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.Pa():"pointerup"===t.type&&(e.released=!0,this.Fa=setTimeout(()=>this.Pa(),0)))}else{var i;this.Pa();var r=Wi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&ji(r)&&(this.Oa={target:r,excluded:this.La(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.ia)?void 0:i.distinctId})}else this.Pa()}ja(t){var e,i=this.Oa;this.Pa();var r=Wi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.ia)?void 0:e.distinctId)&&t.pointerId===i.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-i.x)&&5>=Math.abs(t.clientY-i.y)&&r&&(Li(r,"html")||Li(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.Da().css_selector_ignorelist)&&void 0!==n?n:Yi;return[r,null==(a=Or())?void 0:a.documentElement,null==(o=Or())?void 0:o.body].some(t=>{if(!t)return!1;var e=Hi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!vr(t)||dr(t)||l.some(e=>Ki(t,e))})?null:i.target}}constructor(t){this.ra=t,this.name="autocapture",this.qa=!1,this.Ba=null,this.za=!1,this.Ha=/* @__PURE__ */new Map,this.Ua=!1,this.Yr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.qi=!1,this.ra.refresh(this.Yr),this.rageclicks=new Ar(this.Yr.rageclick),this.Wa=null}setup(t){this.Va(),this.ia=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.qi?e.dispose():(this.ma=e,this.startIfEnabled())}dispose(){var t;this.qi||(this.qi=!0,this.ia=void 0,null==(t=this.ma)||t.dispose(),this.ma=void 0,this.Ha.clear(),this.Wa=null,this.Ga())}Da(){return this.ra.refresh(this.Yr),this.Yr}Va(){var t,e;return this.Da(),this.Yr.url_allowlist=null==(t=this.Yr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Yr.url_ignorelist=null==(e=this.Yr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Yr}Ja(){var t=Fr(),e=Or();if(this.isBrowserSupported()){if(t&&e){this.Qa=t,this.Za=e;var i=this.Ka=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.Pa();if(0===e.type.indexOf("pointer"))return void this.Na(e);var i="click"===e.type?this.ja(e):void 0;if(m(i))return;this.Ya(e,"$autocapture",i)}catch(t){Rr.error("Failed to capture event",t)}};if(gi(t,"blur",i),gi(e,"submit",i,{capture:!0}),gi(e,"change",i,{capture:!0}),gi(e,"click",i,{capture:!0}),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{gi(e,t,i,{capture:!0})}),this.Da().capture_copied_text){var r=this.Xa=e=>{e=e||(null==t?void 0:t.event);try{this.Ya(e,Pr)}catch(t){Rr.error("Failed to capture clipboard event",t)}};gi(e,"copy",r,{capture:!0}),gi(e,"cut",r,{capture:!0}),gi(e,"paste",r,{capture:!0})}}}else Rr.info("Disabling Automatic Event Collection because this browser is not supported")}Ga(){var t=this.Qa,e=this.Za;this.Pa(),this.Ka&&(null==t||t.removeEventListener("blur",this.Ka),di(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.Ka,!0)}),null==e||e.removeEventListener("submit",this.Ka,!0),null==e||e.removeEventListener("change",this.Ka,!0),null==e||e.removeEventListener("click",this.Ka,!0),this.Ka=void 0),this.Xa&&(null==e||e.removeEventListener("copy",this.Xa,!0),null==e||e.removeEventListener("cut",this.Xa,!0),null==e||e.removeEventListener("paste",this.Xa,!0),this.Xa=void 0),this.Qa=void 0,this.Za=void 0,this.qa=!1}startIfEnabled(){this.isEnabled||this.Pa(),!this.qi&&this.ia&&this.isEnabled&&!this.qa&&(this.Ja(),this.qa=!0)}onRemoteConfig(t){if(!this.qi)if(this.za=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.Ua=e.elementsChainAsString);var i,r=e.autocapture_opt_out;b(r)&&(null==(i=this.ia)||i.kv.set(Ii,r),this.Ba=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.qi){t.size?this.Ha.set(e,new Set(t)):this.Ha.delete(e);var i=/* @__PURE__ */new Set;this.Ha.forEach(t=>{t.forEach(t=>i.add(t))}),this.Wa=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.Wa)||i.forEach(i=>{var n;null==(n=Or())||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.qi)return!1;var i=null==(t=this.ia)?void 0:t.kv.get(Ii),r=this.Ba,n=this.Da();if(!n.remoteRequestsDisabled&&!this.za)return!1;var s=n.remoteRequestsDisabled&&!this.za;if(m(r)&&!b(i)&&!s)return!1;var a=null!==(e=this.Ba)&&void 0!==e?e:!!i;return!!n.enabled&&!a}Ya(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Wi(t);Ni(n)&&(n=n.parentNode||null);var a,o=this.Va();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(a=this.rageclicks)&&a.isRageClick(t.clientX,t.clientY,t.timeStamp||/* @__PURE__ */(new Date).getTime())&&lr(n,o.rageclick)&&this.Ya(t,"$rageclick",r);var l,u=i===Pr,v=u?e({},o,{dom_event_allowlist:void 0}):o;if(n&&function(t,e,i,r,n,s){var a,o=typeof window>"u"?void 0:window;if(!o||ur(t))return!1;if(null!=i&&i.url_allowlist&&!Ui(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ui(i.url_ignorelist,s))return!1;if(null!=i&&i.dom_event_allowlist){var l=i.dom_event_allowlist;if(l&&!l.some(t=>e.type===t))return!1}var u=hr(t,r),h=u.parentIsUsefulElement,c=u.targetElementList;if(!u.isComplete)return!1;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(f(i))return!0;var r,n=function(t){if(i.some(e=>t.tagName.toLowerCase()===e))return{v:!0}};for(var s of t)if(r=n(s))return r.v;return!1}(c,i))return!1;if(!Ji(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Ji(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Yi))return!1;try{var v=o.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return h?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(Gi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,v,u,u?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var d,p=Ir(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.Ua,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),g=p.props;if(p.explicitNoCapture)return!1;var m=this.getElementSelectors(n,p.target);if(m&&m.length>0&&(g.$element_selectors=m),i===Pr){var _=t.type||"clipboard";if("paste"!==_){var y,b,w=null==(y=Fr())||null==(y=y.getSelection())?void 0:y.toString(),x=qi(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(b=null==w?void 0:w.length)&&void 0!==b?b:0}g.$copy_type=_}if("$autocapture"===i&&"change"===t.type&&o.capture_value_css_selector_allowlist&&!o.maskAllText&&(Li(l=n,"input")?!s(Cr,l.type):Li(l,"textarea")||Li(l,"select")&&!l.multiple)&&function(t,e){var i;if(!vr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Yi,n=/* @__PURE__ */new Set,a=t;Li(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=Hi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Ki(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=zi(i)?i.host:i&&ji(i)?i:null};a;)if(o=l())return o.v;return!0}(n,o)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){var S=o.capture_value_css_selector_allowlist,k=!1;try{k=c(S)?!!S(n):h(S)&&S.some(t=>Ki(n,t))}catch(t){Rr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.ia)||d.capture(i,g),!0}}else this.Pa()}isBrowserSupported(){var t;return c(null==(t=Or())?void 0:t.querySelectorAll)}},jr=["[data-ph-capture-value]"],Lr=class{constructor(t){this._instance=t}refresh(t){var e,i=this._instance.config,r=v(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance._shouldDisableFlags(),t.url_allowlist=null==r?void 0:r.url_allowlist,t.url_ignorelist=null==r?void 0:r.url_ignorelist,t.dom_event_allowlist=null==r?void 0:r.dom_event_allowlist,t.element_allowlist=null==r?void 0:r.element_allowlist,t.css_selector_allowlist=null==r?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=null==r?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=null==r?void 0:r.element_attribute_ignorelist,t.capture_copied_text=null==r?void 0:r.capture_copied_text,t.capture_value_css_selector_allowlist=null!==(e=null==r?void 0:r.capture_value_css_selector_allowlist)&&void 0!==e?e:jr}},Nr=class extends Dr{constructor(t){super(new Lr(t)),this.instance=t}},zr="$surveys",Br="$surveys_loaded_at",Ur="PostHog loadExternalDependency extension not found.",Hr="$surveys_activated",qr="$surveys_activated_session",Vr="$surveys_activated_timestamps",Wr="$heatmaps_enabled_server_side",Gr="$exception_capture_enabled_server_side",Kr="$error_tracking_suppression_rules",Jr="$error_tracking_capture_extension_exceptions",Xr="$web_vitals_enabled_server_side",Yr="$dead_clicks_enabled_server_side",Zr="$product_tours_enabled_server_side",Qr="$web_vitals_allowed_metrics",tn="$session_recording_remote_config",en="$replay_override_sampling",rn="$replay_override_linked_flag",nn="$session_is_sampled",sn="ph_product_tours",an="$sdk_debug_recording_script_not_loaded",on="$sdk_debug_replay_stale_config",ln="beforeunload",un="u">typeof window?window:void 0,hn="u">typeof globalThis?globalThis:un,cn=null==hn?void 0:hn.navigator,vn=null==hn?void 0:hn.document,dn=null==hn?void 0:hn.location;null!=hn&&hn.XMLHttpRequest&&new hn.XMLHttpRequest;var fn="undefined"!=typeof globalThis?globalThis:un;fn&&"undefined"==typeof self&&(fn.self=fn),fn&&"undefined"==typeof File&&(fn.File=function(){});var pn=null!=un?un:{},gn=t=>{var e;return null!=t&&t.config.require_subresource_integrity?t.__loadExternalDependency:null==(e=pn.__PosthogExtensions__)?void 0:e.loadExternalDependency},mn=/* @__PURE__ */ci("[Dead Clicks]"),_n=()=>!0,yn=class{get lazyLoadedDeadClicksAutocapture(){return this.ou}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Yr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.lu(()=>{this.au()}):this.stop()}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=gn(this.instance))||i(this.instance,"dead-clicks-autocapture",e=>{e?mn.error("failed to load script",e):t()})}au(){var t;if(vn){if(!this.ou&&null!=(t=pn.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=v(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.ou=pn.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.ou.start(vn),mn.info("starting...")}}else mn.error("`document` not found. Cannot start.")}stop(){this.ou&&(this.ou.stop(),this.ou=void 0,mn.info("stopping..."))}},bn=/* @__PURE__ */ci("[ExceptionAutocapture]"),wn=class{constructor(t){var i;this.pg=()=>{var t;if(un&&this.isEnabled&&null!=(t=pn.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=pn.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=pn.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=pn.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.yg&&this.Yr.capture_unhandled_errors&&(this.yg=e(this.captureException.bind(this))),!this.bg&&this.Yr.capture_unhandled_rejections&&(this.bg=i(this.captureException.bind(this))),!this._g&&this.Yr.capture_console_errors&&(this._g=r(this.captureException.bind(this)))}catch(t){bn.error("failed to start",t),this.wg()}}},this._instance=t,this.kg=!(null==(i=this._instance.persistence)||!i.props[Gr]),this.kt=new P(e({},function(t){var e,i,r,n;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,R:bn})),this.Yr=this.Sg(),this.startIfEnabledOrStop()}Sg(){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.kg:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Yr.capture_console_errors||this.Yr.capture_unhandled_errors||this.Yr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(bn.info("enabled"),this.wg(),this.lu(this.pg)):this.wg()}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=gn(this._instance))||i(this._instance,"exception-autocapture",e=>{if(e)return bn.error("failed to load script",e);t()})}wg(){var t,e,i;null==(t=this.yg)||t.call(this),this.yg=void 0,null==(e=this.bg)||e.call(this),this.bg=void 0,null==(i=this._g)||i.call(this),this._g=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.kg=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Gr]:this.kg}),this.Yr=this.Sg(),this.startIfEnabledOrStop())}}onConfigChange(){this.Yr=this.Sg()}captureException(t){try{var e,i,r,n=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";if(this.kt.consumeRateLimit(n))return void bn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},xn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},Sn=(t,e)=>t>=e&&xn(),kn=(t,e,i,r)=>{if(0===t){if(xn()){var n=e+1;return n===i&&r(),n}return e}return 0},En=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;r.length>n;n++){var s=r[n].split(/=(.*)/);if(s[0]===e){i=s;break}}if(!h(i)||2>i.length)return"";var a=i[1].replace(/\+/g," ");try{a=decodeURIComponent(a)}catch(t){hi.error("Skipping decoding for malformed query param: "+a)}return a},An=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split(/#(.*)/),n=r[1],s=(r[0]||"").split(/\?(.*)/),a=s[1],o=s[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){for(var c=l[h].split("?"),v=0;c.length>v&&!e.includes(c[v].split("=")[0]);)v++;u.push(c.length>v?c.slice(0,v).concat(c[v].split("=")[0]+"="+i).join("?"):l[h])}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=n&&(d+="#"+n),d},Tn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Fn=()=>{},On=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function Pn(t,e,i){try{if(!(e in t))return Fn;var r={next:t[e]},n=i(function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)});return c(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=n,()=>{if(t[e]!==n)for(var i=t[e],s=On(i);s;){if(s.next===n)return void(s.next=r.next);s=On(i=s.next)}else t[e]=r.next}}catch(t){return Fn}}var Cn=class{constructor(t){this.Op=!1,this._instance=t,this.Fp=this.Lp()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Dp();return!!(t.path||t.search||this.Np(t))}startIfEnabled(){this.isEnabled&&(hi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Fp=this.Lp(),this.startIfEnabled()}stop(){this.jp&&this.jp(),this.jp=void 0,this.qp&&this.qp(),this.qp=void 0,hi.info("History API monitoring stopped")}monitorHistoryChanges(){un&&un.history&&(this.Bp("pushState"),this.Bp("replaceState"),this.zp(),this.Np()&&this.Hp())}Bp(t){var e;if(un&&(null==(e=un.history[t])||!e.__posthog_wrapped__)){var i=this;Pn(un.history,t,e=>function(r,n,s){var a;i.Up(s)&&i.Wp(),e.call(this,r,n,s),i.Vp(t,!i.Op&&"popstate"!==(null==un||null==(a=un.event)?void 0:a.type))})}}Lp(){var t=null==un?void 0:un.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Dp(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}Np(t){return void 0===t&&(t=this.Dp()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Gp(t){var e=this.Dp(),i=this.Fp;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.Np(e)&&t.hash!==i.hash))}Vp(t,e){void 0===e&&(e=!1);try{e||this.Wp();var i=this.Lp();if(!i)return;if(this.Gp(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.Jp=r,Promise.resolve().then(()=>this.Wp())):r()}this.Fp=i}catch(e){hi.error("Error capturing "+t+" pageview",e)}}Up(t){var e,i;return!(_(t)||!un)&&(null==(e=Tr(String(t)))?void 0:e.href)!==(null==(i=un.location)?void 0:i.href)}Wp(){var t=this.Jp;if(t){this.Jp=void 0,this.Op=!0;try{t()}catch(t){hi.error("Error capturing deferred pageview",t)}finally{this.Op=!1}this.Fp=this.Lp()}}zp(){if(!this.jp){var t=()=>{this.Vp("popstate")};gi(un,"popstate",t),this.jp=()=>{un&&un.removeEventListener("popstate",t)}}}Hp(){if(!this.qp){var t=()=>{this.Vp("hashchange")};gi(un,"hashchange",t),this.qp=()=>{un&&un.removeEventListener("hashchange",t)}}}},Rn=/* @__PURE__ */ci("[TracingHeaders]"),$n=class{constructor(t){this._instance=t,this.Yg=void 0,this.Xg=void 0,this.tm=void 0,this.im=void 0,this.nm=[],this.pg=()=>{var t,e,i=this.sm(),r=i.hostnames;r||i.traceparentTargets?(r||h(this.tm)||(this.tm=[]),this.im!==this.tm&&(this.wg(),this.im=this.tm),f(this.Yg)&&(this.Yg=null==(t=pn.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(this.tm,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.nm)),f(this.Xg)&&(this.Xg=null==(e=pn.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(this.tm,()=>this._instance.get_distinct_id(),this._instance.sessionManager,this.nm))):this.wg()}}initialize(){this.startIfEnabledOrStop()}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=gn(this._instance))||i(this._instance,"tracing-headers",e=>{if(e)return Rn.error("failed to load script",e);t()})}rm(){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}om(){var t=this.rm();return h(t)?(h(this.tm)?this.tm.splice(0,this.tm.length,...t):this.tm=[...t],t.length>0?this.tm:void 0):!h(this.tm)||(this.tm.splice(0),t)?(this.tm=t||void 0,this.tm):void 0}lm(){var t=this._instance.config.trace_propagation_targets,e=h(t)?t.filter(t=>p(t)&&!!t):[];return this.nm.splice(0,this.nm.length,...e),e.length>0?this.nm:void 0}sm(){return{hostnames:this.om(),traceparentTargets:this.lm()}}wg(){var t,e;null==(t=this.Yg)||t.call(this),null==(e=this.Xg)||e.call(this),this.Yg=void 0,this.Xg=void 0}startIfEnabledOrStop(){var t=this.sm();t.hostnames||t.traceparentTargets?this.lu(this.pg):this.wg()}};function Mn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var In=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Dn=["ScCid","SsCid"],jn={sccid:Dn},Ln=/* @__PURE__ */(()=>[...In,...Dn,"sscid"])(),Nn=/* @__PURE__ */(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...In])(),zn="<masked>",Bn=["li_fat_id"];var Un=/* @__PURE__ */ci("[Web Vitals]"),Hn=9e5,qn=["CLS","FCP","INP","LCP"],Vn=["INP","LCP"],Wn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Gn=class{constructor(t){var i,r=this;this._instance=t,this.Qp=!1,this.qa=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.cg=function(t){void 0===t&&(t=!1),clearTimeout(r.hg),r.hg=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.dg=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},_(null==t?void 0:t.name)||_(null==t?void 0:t.value))Un.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.vg(r);if(!f(n)){var s=y(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.fg||this.fg>t.value){this.Rt.navigationKey!==s&&(this.cg(),this.hg=setTimeout(this.cg,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 Wn){var h="url"===u&&"string"==typeof t.attribution[u]?this.vg(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.cg()}else Un.error("Ignoring metric with value >= "+this.fg,t)}}},this.pg=()=>{if(!this.qa){var t,i,r,n,s=!1,a=pn.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.gg])||("web-vitals"===this.gg&&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.dg.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.dg.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.dg.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.dg.bind(this),v);var d=null==un?void 0:un.document;gi(d,Mi,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.cg(!0)}),gi(un,"pagehide",()=>this.cg(!0)),this.qa=!0}else Un.error("web vitals callbacks not loaded - not starting")}},this.Qp=!(null==(i=this._instance.persistence)||!i.props[Xr]),this.startIfEnabled()}get mg(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.mg)?null==(t=this.mg)?void 0:t.web_vitals_allowed_metrics:void 0;return _(i)?(null==(e=this._instance.persistence)?void 0:e.props.$web_vitals_allowed_metrics)||qn:i}get flushToCaptureTimeoutMs(){return(v(this.mg)?this.mg.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.mg)?this.mg.web_vitals_attribution:void 0;return b(t)?t?qn:[]:h(t)?t:Vn}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.mg)?this.mg.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get fg(){var t=v(this.mg)&&y(this.mg.__web_vitals_max_value)?this.mg.__web_vitals_max_value:Hn;return t>0&&6e4>=t?Hn:t}get isEnabled(){var t=null==dn?void 0:dn.protocol;if("http:"!==t&&"https:"!==t)return Un.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.mg)?this.mg.web_vitals:b(this.mg)?this.mg:void 0;return b(e)?e:this.Qp}startIfEnabled(){this.isEnabled&&!this.qa&&(Un.info("enabled, starting..."),this.lu(this.pg))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=v(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=v(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xr]:i}),this._instance.persistence.register({[Qr]:r})),this.Qp=i,this.startIfEnabled()}}}get gg(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}lu(t){var e,i=pn.__PosthogExtensions__,r=this.gg,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=n&&n[r]||"web-vitals"===r&&f(n)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==(e=gn(this._instance))||e(this._instance,r,e=>{e?Un.error("failed to load script",e):t()})}vg(t){var e=t||(null==un?void 0:un.location.href);if(e){var i=this._instance.config.disable_capture_url_hashes?J(e):e,r=this._instance.config.custom_personal_data_properties;return An(i,this._instance.config.mask_personal_data_properties?[...Ln,...r||[]]:[],zn)}Un.error("Could not determine current URL")}},Kn=/* @__PURE__ */ci("[RemoteConfig]"),Jn=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Rc(t){var e=gn(this._instance);e?e(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Pc(t){var e=this._instance.__pending_remote_config_callbacks;if(e)e.push(t);else{var i=[t];this._instance.__pending_remote_config_callbacks=i;try{this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),batchKey:"remote_config",fireCallbackOnDrop:!0,callback:t=>{this._instance.__pending_remote_config_callbacks=void 0,i.forEach(e=>e(t))}})}catch(t){throw this._instance.__pending_remote_config_callbacks=void 0,t}}}load(){try{if(this.remoteConfig)return Kn.info("Using preloaded remote config",this.remoteConfig),void this.Oc(this.remoteConfig);if(this._instance._shouldDisableFlags())return void Kn.warn("Remote config is disabled. Falling back to local config.");if(!this._instance.config.opt_in_site_apps)return void this.Pc(t=>{this.Oc(t.json,t)});this.Rc(t=>{if(!t)return Kn.info("No config found after loading remote JS config. Falling back to JSON."),void this.Pc(t=>{this.Oc(t.json,t)});this.Oc(t)})}catch(t){Kn.error("Error loading remote config",t),this.Oc()}}Oc(t,e){!t&&e&&(0===e.statusCode?e.error||Kn.warn("Failed to fetch remote config from PostHog."):Kn.error("Failed to fetch remote config from PostHog."));try{this._instance.Oc(t?{ok:!0,config:t}:{ok:!1})}catch(t){Kn.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){Kn.error("Error loading feature flags",t)}}},Xn="disabled",Yn="lazy_loading",Zn=null,Qn={Ot(){if(!m(Zn))return Zn;if(Zn=!0,f(un))Zn=!1;else try{var t="__support__";Qn.$t(t,"xyz"),'"xyz"'!==Qn.Lt(t)&&(Zn=!1),Qn.Dt(t)}catch(t){Zn=!1}return Zn},Ft(t){hi.error("sessionStorage error: ",t)},Lt(t){try{return null==un?void 0:un.sessionStorage.getItem(t)}catch(t){Qn.Ft(t)}return null},Pt(t){try{return JSON.parse(Qn.Lt(t))||null}catch(t){}return null},$t(t,e){try{return null==un||un.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(t){Qn.Ft(t)}return!1},Dt(t){try{null==un||un.sessionStorage.removeItem(t)}catch(t){Qn.Ft(t)}}};function ts(t){return"ph_replay_pending_buffer_"+JSON.stringify([t.persistence_name||t.token,t.token])}var es=/* @__PURE__ */ci("[SessionRecording]"),is=[an,on,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],rs=class{get Yr(){return this._instance.config}get oh(){return this._instance.persistence}get started(){var t;return!(null==(t=this._p)||!t.isStarted)}get status(){var t,e;return this.isReplayOff?Xn:"awaiting_config"===this.wp||"missing_config"===this.wp?this.wp:null!==(t=null==(e=this._p)?void 0:e.status)&&void 0!==t?t:this.wp}constructor(t){var e;if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.wp=Xn,this.kp=void 0,this.Sp=!1,this.li=void 0,this.un=(()=>{var t;if(null==vn||!vn.visibilityState||"visible"===vn.visibilityState)return!0;var e=null==un||null==(t=un.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.gn=()=>{var t;"visible"===(null==vn?void 0:vn.visibilityState)&&(this.un=!0,null==(t=this._p)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw es.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Yr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');var i=this._instance.get_property(nn);p(i)&&"!"===i[0]&&(null==(e=this.oh)||e.unregister(nn)),null!=vn&&vn.addEventListener&&gi(vn,"visibilitychange",this.gn)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.Sp=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.gn),i?this.xp(!0):this.stopRecording()}get $p(){var t,e=!(null==(t=this._instance.get_property(tn))||!t.enabled),i=!this.Yr.disable_session_recording,r=this.Yr.disable_session_recording||this._instance.consent.isOptedOut();return un&&e&&i&&!r}get isReplayOff(){var t;return!!this.Yr.disable_session_recording||this._instance.consent.isOptedOut()||!1===(null==(t=this._instance.get_property("$session_recording_remote_config"))?void 0:t.enabled)}startIfEnabledOrStop(t){if(!this.Sp){var e;if(this._p)if(this.li!==(null==(e=this.Yr.session_recording)?void 0:e.selectMaskingFn))Qn.Dt(ts(this.Yr)),this._p.discard({discardProducerEvents:!0}),this.li=void 0;else if(this._p.isStarted&&this.$p)return void(this.Cp()||this.xp(!0));var i=!f(Object.assign)&&!f(Array.from);this.$p&&i?(this.Tp(t),es.info("starting")):(this.wp=Xn,this.stopRecording())}}Tp(t){var e,i;if(this.$p)if("awaiting_config"!==this.wp&&"missing_config"!==this.wp&&(this.wp=Yn),null!=pn&&null!=(e=pn.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=pn.__PosthogExtensions__)&&i.initSessionRecording)this.Mp(t);else{var r,n=this._instance.sessionManager;null==(r=gn(this._instance))||r(this._instance,this.Ip,e=>{if(!this.Sp&&this.$p&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[an]:!0}),es.error("could not load recorder",e)):void this.Mp(t);this.wp=Xn})}}stopRecording(){var t,e;null==(t=this.kp)||t.call(this),this.kp=void 0,null==(e=this._p)||e.stop()}xp(t){var e,i,r;void 0===t&&(t=!1),t&&(this.li||null!=(e=this.Yr.session_recording)&&e.selectMaskingFn)&&Qn.Dt(ts(this.Yr)),null==(i=this.kp)||i.call(this),this.kp=void 0,null==(r=this._p)||r.discard({discardProducerEvents:t}),this.li=void 0}Ep(){var t,e;null==(t=this.oh)||t.unregister(nn),null==(e=this.oh)||e.unregister("$replay_sample_rate")}Ap(t,e){if(_(t))return null;var i,r=y(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(es.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Rp(t){if(this.oh){var i,r,n=this.oh,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Ap(null==(i=this.Yr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Ap(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;_(o)&&this.Ep();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[tn]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};s(),null==(i=this.kp)||i.call(this),this.kp=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.Rp(e),void this.xp()):(this.Rp(e),void this.startIfEnabledOrStop()):("awaiting_config"===this.wp&&(this.wp="missing_config",this._instance.register_for_session({[on]:!0}),es.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._p)&&i.log?this._p.log(t,e):es.warn("log called before recorder was ready")}get Ip(){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"}Pp(){var t,e=this._instance.get_property(tn);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return es.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!_(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Cp(){var t,e,i;return null==(t=this.Yr.session_recording)||!t.selectMaskingFn||!(!0!==(null==(e=pn.__PosthogExtensions__)||null==(e=e.rrweb)||null==(e=e.record)?void 0:e.supportsSelectMasking)||!0!==(null==(i=pn.__PosthogExtensions__)||null==(i=i.initSessionRecording)?void 0:i.supportsSelectMasking)||this._p&&!0!==this._p.supportsSelectMasking)||(this.wp=Xn,es.error("Session recording has not started: the recorder does not support selectMaskingFn."),!1)}Mp(t){var e,i,r,n,s;if(!this.Sp&&this.$p&&this._instance.sessionManager){if(null==(e=pn.__PosthogExtensions__)||!e.initSessionRecording)return es.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[an]:!0});var a;if(this.Cp())if(this._p||(this._p=null==(a=pn.__PosthogExtensions__)?void 0:a.initSessionRecording(this._instance,this.un),this._p._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Cp()){if(!this.Pp()){if("missing_config"===this.wp||"awaiting_config"===this.wp)return;return this.wp="awaiting_config",es.info("persisted remote config is stale, requesting fresh config before starting"),void new Jn(this._instance).load()}this.wp=Yn,null==(i=(r=this._p).setDocumentWasEverVisible)||i.call(r,this.un);var o=null==(n=this.Yr.session_recording)?void 0:n.selectMaskingFn;this._p.start(t),this.li=o,this._p.isStarted&&o!==(null==(s=this.Yr.session_recording)?void 0:s.selectMaskingFn)&&this.startIfEnabledOrStop()}else this.xp(!0)}else this.wp=Xn}onRRwebEmit(t){var e;null==(e=this._p)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this._p||null==(t=this.oh)||t.register({[rn]:!0}),null==(e=this._p)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this._p||null==(t=this.oh)||t.register({[en]:!0}),null==(e=this._p)||e.overrideSampling()}overrideTrigger(t){var e,i;this._p||null==(e=this.oh)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this._p)||i.overrideTrigger(t)}get sdkDebugProperties(){var t;if(this.isReplayOff)return{$recording_status:Xn};var i={};for(var r of is){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._p)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this._p)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this._p)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}},ns=/* @__PURE__ */ci("[Heatmaps]");function ss(t){return v(t)&&"clientX"in t&&"clientY"in t&&y(t.clientX)&&y(t.clientY)}var as=class{get Yr(){return this.instance.config}constructor(t){var e;this.Qp=!1,this.qa=!1,this.Zp=!1,this.Kp=0,this.Yp=null,this.instance=t,this.Qp=!(null==(e=this.instance.persistence)||!e.props[Wr]),this.rageclicks=new Ar(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Yr.capture_heatmaps)&&this.Yr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Yr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return _(this.Yr.capture_heatmaps)?_(this.Yr.enable_heatmaps)?this.Qp:this.Yr.enable_heatmaps:!1!==this.Yr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.qa)return;ns.info("starting..."),this.Xp(),this.gn()}else{var t;clearInterval(null!==(t=this.Yp)&&void 0!==t?t:void 0),this.tg(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Wr]:i}),this.Qp=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}discardPending(){this.Kp=Date.now(),clearTimeout(this.eg),this.eg=void 0,this.getAndClearBuffer()}ig(t){ss(t.originalEvent)&&t.timestamp>this.Kp&&this.Jr(t.originalEvent,"deadclick")}gn(){this.Yp&&clearInterval(this.Yp),this.Yp="visible"===(null==vn?void 0:vn.visibilityState)?setInterval(this.Wc.bind(this),this.flushIntervalMilliseconds):null}Xp(){un&&vn&&(this.ng=this.Wc.bind(this),gi(un,ln,this.ng),this.sg=t=>this.Jr(t||(null==un?void 0:un.event)),gi(vn,"click",this.sg,{capture:!0}),this.rg=t=>this.og(t||(null==un?void 0:un.event)),gi(vn,"mousemove",this.rg,{capture:!0}),this.lg=new yn(this.instance,_n,this.ig.bind(this)),this.lg.startIfEnabledOrStop(),this.ag=this.gn.bind(this),gi(vn,Mi,this.ag),this.qa=!0)}tg(){var t;un&&vn&&(this.ng&&un.removeEventListener(ln,this.ng),this.sg&&vn.removeEventListener("click",this.sg,{capture:!0}),this.rg&&vn.removeEventListener("mousemove",this.rg,{capture:!0}),this.ag&&vn.removeEventListener(Mi,this.ag),clearTimeout(this.eg),this.eg=void 0,null==(t=this.lg)||t.stop(),this.qa=!1)}ug(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(t,e,i){for(var r=t;r&&ji(r)&&!Li(r,"body");){if(r===i)return!1;var n=void 0;try{var a,o,l;n=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:un)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Xi(r)}return!1}(Wi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}Jr(t,i){var r;if(void 0===i&&(i="click"),!Di(t.target)&&ss(t)&&this.instance.is_capturing()){var n=this.ug(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,/* @__PURE__ */(new Date).getTime())&&lr(Wi(t),this.instance.config.rageclick)&&this.Fo(e({},n,{type:"rageclick"})),this.Fo(n)}}og(t){!Di(t.target)&&ss(t)&&(f(this.eg)&&(this.Zp=this.instance.is_capturing()),clearTimeout(this.eg),this.eg=setTimeout(()=>{this.eg=void 0,this.Zp&&this.instance.is_capturing()&&this.Fo(this.ug(t,"mousemove"))},500))}Fo(t){if(un){var e=this.Yr.disable_capture_url_hashes?J(un.location.href):un.location.href,i=this.Yr.custom_personal_data_properties,r=An(e,this.Yr.mask_personal_data_properties?[...Ln,...i||[]]:[],zn);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}Wc(){this.Rt&&!d(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},os=/* @__PURE__ */ci("[Product Tours]"),ls=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Zr))},us=class{get oh(){return this._instance.persistence}constructor(t){this.Ng=null,this.jg=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.oh&&this.oh.register({[Zr]:!!e.productTours}),!ls(this._instance))return!this.Ng&&_(null==(i=this.oh)?void 0:i.props.ph_product_tours)||os.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Ng)||r.stop(),this.Ng=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Ng&&ls(this._instance)&&this.lu(()=>this.qg())}lu(t){var e,i;null!=(e=pn.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=gn(this._instance))||i(this._instance,"product-tours",e=>{e?os.error("Could not load product tours script",e):t()})}qg(){var t;!this.Ng&&null!=(t=pn.__PosthogExtensions__)&&t.generateProductTours&&(this.Ng=pn.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.jg)||e){var i=this.oh;if(i){var r=i.props[sn];if(h(r)&&!e)return this.jg=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(ls(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||os.warn(n):os.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.jg=s,i&&i.register({[sn]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.jg,{isLoaded:!0})}getActiveProductTours(t){_(this.Ng)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ng.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Ng)||e.showTourById(t)}previewTour(t){this.Ng?this.Ng.previewTour(t):this.lu(()=>{var e;this.qg(),null==(e=this.Ng)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Ng)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Ng)||t.nextStep()}previousStep(){var t;null==(t=this.Ng)||t.previousStep()}clearCache(){var t;this.jg=null,null==(t=this.oh)||t.unregister(sn)}resetTour(t){var e;null==(e=this.Ng)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Ng)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Ng)||e.cancelPendingTour(t)}},hs=/* @__PURE__ */ci("[SiteApps]"),cs="Error while initializing PostHog app with config id ",vs=class{constructor(t){this._instance=t,this.Bg=0,this.zg=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps&&!this._instance.config.require_subresource_integrity}Hg(t,e){if(e){var i=this.globalsForEvent(e);this.zg.push(i),this.zg.length>1e3&&(this.zg=this.zg.slice(10))}}get siteAppLoaders(){var t;return null==(t=pn._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this._instance.config.opt_in_site_apps&&!this.isEnabled&&hs.critical("opt_in_site_apps is ignored: require_subresource_integrity disables site apps"),this.isEnabled){var t=this._instance._addCaptureHook(this.Hg.bind(this));this.Ug=()=>{t(),this.zg=[],this.Ug=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}}Wg(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)||(hs.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)||(hs.error("prepare_external_dependency_script returned null"),null):t}Vg(){var t,e,i,r,n,s,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==vn?void 0:vn.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Bg++,this.Gg)return this.Jg();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.Wg(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.Gg=()=>{h.forEach(t=>t()),this.Gg=void 0},this.Jg()}Jg(){var t=!1;return()=>{var e;t||(t=!0,this.Bg--,0===this.Bg&&(null==(e=this.Gg)||e.call(this)))}}Qg(t,e){void 0===e&&(e=!0);var i=this.Vg();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.zg.length&&(hs.info("Processing "+this.zg.length+" events for site app with id "+t.id),this.zg.forEach(t=>this.Qg(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.Ug)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,hs.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.Qg(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){hs.error(cs+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){hs.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Zg(){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)}Kg(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Qg(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){hs.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.Zg(),void this._instance.on("eventCaptured",t=>this.Kg(t))):void hs.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Ug)||i.call(this),t.ok){var s=t.config;if(null!=(r=s.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,e=o.id,i=o.url;pn["__$$ph_site_app_"+e]=n._instance,null==(t=pn.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return hs.error(cs+e,t)})};for(var o of s.siteApps)a()}else hs.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ds="events",fs="cancelEvents",ps="survey shown",gs="survey dismissed",ms="survey sent";function _s(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var ys=(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}},bs=t=>t.toLowerCase(),ws={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=>ys(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!ys(e,t))),icontains:(t,e)=>e.map(bs).some(e=>t.map(bs).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(bs).every(e=>t.map(bs).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 xs(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=ws[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var Ss=/* @__PURE__ */ci("[Surveys]"),ks=["popover","widget","api"],Es=class{on(t,e){return this.Zo[t]||(this.Zo[t]=[]),this.Zo[t].push(e),()=>{this.Zo[t]=this.Zo[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.Zo[t]||[])i(e);for(var r of this.Zo["*"]||[])r(t,e)}constructor(){this.Zo={}}};function As(t,e,i){if(_(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 Ts=class{constructor(t){this.Gi=t,this.Ko=/* @__PURE__ */new Set,this.Yo=/* @__PURE__ */new Set,this.Xo=new Es,this.tl=(t,e)=>this.el(t,e)&&this.il(t,e)&&this.nl(t,e)&&this.sl(t,e),this.el=(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.Gi)?void 0:t.subscribeCapture)||(this.rl=null==(e=this.Gi)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.rl)||t.call(this),this.rl=void 0,null==(e=this.Gi)||null==e.setElementSelectors||e.setElementSelectors(/* @__PURE__ */new Set,this),this.Xo=new Es}register(t){var e,i;if(!f(null==(e=this.Gi)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.Ko.add(t),null==(e=t.steps)||e.forEach(t=>{this.Yo.add((null==t?void 0:t.event)||"")})}),null!=(i=this.Gi)&&i.setElementSelectors)){var r=/* @__PURE__ */new Set;this.Ko.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.Gi.setElementSelectors(r,this)}}replace(t){this.Ko.clear(),this.Yo.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.Yo.has(t)||this.Yo.has(e.event))&&this.Ko.forEach(t=>{this.ll(e,t)&&this.Xo.emit("actionCaptured",t.name)})}al(t){this.onAction("actionCaptured",e=>t(e))}ll(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.tl(t,i))return!0;return!1}onAction(t,e){return this.Xo.on(t,e)}il(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.Gi)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!As(r,e.url,e.url_matching||"contains"))return!1}return!0}nl(t,e){return!!this.ul(t,e)&&!!this.cl(t,e)&&!!this.hl(t,e)}ul(t,e){var i;if(null==e||!e.href)return!0;var r=this.dl(t);if(r.length>0)return r.some(t=>As(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&As((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}cl(t,e){var i;if(null==e||!e.text)return!0;var r=this.dl(t);if(r.length>0)return r.some(t=>As(t.text,e.text,e.text_matching||"exact")||As(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;!_(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=>As(t,s,a)))}hl(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}dl(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}sl(t,e){return null==e||!e.properties||0===e.properties.length||xs(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)}},Fs=class{constructor(t,e){this.vl=e,this.fl=[],this.Gi=t,this.pl=/* @__PURE__ */new Map,this.gl=/* @__PURE__ */new Map,this.ml=/* @__PURE__ */new Map}yl(){var t,e;this.bl=null==(t=(e=this.Gi).subscribeSession)?void 0:t.call(e,t=>this._l(t))}wl(t){return!1}kl(){return null}Sl(t){}xl(){}$l(t,e){return!!t&&xs(t.propertyFilters,null==e?void 0:e.properties)}Cl(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}Tl(t,e,i){var r=(i===ds?this.pl:this.gl).get(t),n=[];return this.Ml(t=>{n=t.filter(t=>null==r?void 0:r.includes(t.id))}),n.filter(r=>{var n,s=null==(n=r.conditions)||null==(n=n[i])||null==(n=n.values)?void 0:n.find(e=>e.name===t);return this.$l(s,e)})}register(t){this.Il(t,!1)}replace(t){this.Il(t,!0)}Il(t,e){f(this.Gi.subscribeCapture)||(this.El(t,e),this.Al(t,e))}Al(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.ml.clear(),0!==i.length){this.Rl||(this.Rl=new Ts(this.Gi),this.Rl.init(),this.Rl.al(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.ml.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.ml.set(e.name,n)}})}),e?this.Rl.replace(r):this.Rl.register(r)}else{var n;e&&(null==(n=this.Rl)||n.replace([]))}}Pl(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)})}El(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.Cl(t,ds),l=this.Cl(t,fs);e?(this.pl=o,this.gl=l):(this.Pl(this.pl,o),this.Pl(this.gl,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.rl)&&void 0!==i||(this.rl=null==(r=(n=this.Gi).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.Ol(),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.Fl(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.Ll([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.Dl(s),void this.Nl([s])}if(this.gl.has(t)){var o=this.Tl(t,e,fs);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.Ll(o.map(t=>t.id)),o.forEach(t=>this.jl(t.id)))}if(this.pl.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.pl.get(t)});var l=this.Tl(t,e,ds);this.ql(l.map(t=>t.id))}}onAction(t){this.ml.has(t)&&this.ql(this.ml.get(t)||[])}ql(t){if(0!==t.length){var e=!!this.Gi.getSessionId(),i=[];for(var r of t)e&&this.wl(r)?this.Dl(r)&&this.Bl(r):i.push(r);i.length>0&&(this.fl=[.../* @__PURE__ */new Set([...this.fl,...i])]),this.Ol().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.zl()}}Dl(t){this.fl=this.fl.filter(e=>e!==t);var e=this.Hl();return!e.includes(t)&&(this.Ul([...e,t]),this.Wl(),!0)}Ll(t){var e=new Set(t);this.fl=this.fl.filter(t=>!e.has(t));var i=this.Vl(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.Ul(r),0===r.length&&this.Gl()),this.Nl(t),this.zl()}zl(){try{var t;null==(t=this.vl)||t.call(this)}catch(t){this.Ol().error("Error while handling activated items change",t)}}Jl(){var t=this.kl();if(!t)return{};var e=this.Gi.getProperty(t);return e&&"object"==typeof e?e:{}}Bl(t){if(this.kl()){var i=this.Jl();this.Sl(e({},i,{[t]:Date.now()}))}}Nl(t){if(this.kl()){var e=this.Jl(),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.xl():this.Sl(i))}}Ql(){this.kl()&&this.xl()}getActivationTimestamp(t){if(this.Hl().includes(t)){var e=this.Jl()[t];return y(e)?e:void 0}}Vl(){var t=this.Zl();return this.Gi.getProperty(t)||[]}Hl(){var t=this.Vl();if(0===t.length)return[];var e=this.Gi.getProperty(this.Kl()),i=this.Gi.getSessionId();return i&&e===i?t:[]}Wl(){var t=this.Gi.getSessionId();t&&this.Yl(t)}Gl(){this.Xl()}_l(t){var e=this.Gi.getProperty(this.Kl());if(e&&e!==t){var i=this.Vl(),r=this.Jl();i.length>0&&(this.Ul([]),i.filter(t=>y(r[t])).forEach(t=>this.jl(t))),this.Gl(),this.Ql(),i.length>0&&this.zl()}}getActivatedIds(){return[.../* @__PURE__ */new Set([...this.Hl(),...this.fl])].filter(t=>!this.ta(t))}dispose(){var t,e,i;null==(t=this.bl)||t.call(this),this.bl=void 0,null==(e=this.rl)||e.call(this),this.rl=void 0,null==(i=this.Rl)||i.dispose(),this.Rl=void 0}reset(){this.fl=[],this.Vl().length>0&&this.Ul([]),this.Gl(),this.Ql(),this.zl()}getEventToItemsMap(){return this.pl}ea(){return this.Rl}},Os=class extends Fs{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.ia=t,this.na=e,this.yl()}Zl(){return Hr}Kl(){return qr}kl(){return Vr}Sl(t){this.ia.kv.set({[Vr]:t})}xl(){this.ia.kv.remove(Vr)}wl(t){var e,i;this.Ml(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return y(r)&&r>0}sa(){return ps}Ml(t){this.na.getSurveys(t)}jl(t){this.na.cancelPendingSurvey(t)}Ol(){return Ss}Ul(t){this.ia.kv.set({[Hr]:t})}Yl(t){this.ia.kv.set({[qr]:t})}Xl(){this.ia.kv.remove(qr)}ta(){return!1}Fl(t,e,i){var r,n;return t===ms&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.Ml(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return _s(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===ps?"consume":"ignore":t===ps?"persist":t===gs||t===ms?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ps=(t,e)=>null!=t&&t.then?t.then(e):e(t),Cs="SDK is not enabled or survey functionality is not yet loaded",Rs="Disabled. Not loading surveys.",$s=class{constructor(t){this.ra=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.oa=!1,this.la=!1,this.aa=[],this.ua=[],this.ca=null,this.ha=null,this.qi=!1,this.da=/* @__PURE__ */new Set,this.onRemoteConfig=t=>{if(!this.qi&&!this.Yr.disableSurveys){if(!t.ok)return this.la=!0,this.va({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),Ss.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(_(e))return Ss.warn("Flags not loaded yet. Not loading surveys.");this.fa=b(e)?e:e.length>0,Ss.info("flags response received, isSurveysEnabled: "+this.fa),this.loadIfEnabled()}},this.va=t=>{this.ua.slice().forEach(e=>this.pa(e,t))}}setup(t){if(!this.qi)return this.ga=t,Ps(t.kv.initialize(),()=>{if(this.ga===t&&!this.qi){this.ga=void 0,this.ia=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.qi?e.dispose():(this.ma=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.qi||(this.qi=!0,this.ga=void 0,this.ia=void 0,null==(t=this.ma)||t.dispose(),this.ma=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.aa=[],this.ua.forEach(t=>{t.active=!1}),this.ua=[],null==(r=this.ya)||r.call(this),this.ya=void 0,this.ca=null,this.da.forEach(t=>clearTimeout(t)),this.da.clear())}get Yr(){return this.ra.get()}getRenderContext(){if(this.ia){var t=this;return{client:this.ia,get config(){return t.Yr},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.qi&&this.ia){var t=this.Yr;if(!this._surveyManager)if(this.oa)Ss.info("Already initializing surveys, skipping...");else if(t.disableSurveys)Ss.info(Rs);else if(t.cookielessMode&&this.ia.isOptedOut)Ss.info("Not loading surveys in cookieless mode without consent.");else{var e=this.ra.getExtensions();if(e){if(!f(this.fa)||t.advancedEnableSurveys){var i=this.fa||t.advancedEnableSurveys;this.oa=!0,this.la=!1;try{var r=e.generateSurveys;if(r)return this._a(r,i),void(this.oa=!1);var n=e.loadExternalDependency;if(!n)return this.ba(Ur),void(this.oa=!1);n(t=>{try{if(this.qi)return;var e=this.ra.getExtensions();t||null==e||!e.generateSurveys?this.ba("Could not load surveys script",t):this._a(e.generateSurveys,i)}finally{this.oa=!1}})}catch(t){throw this.oa=!1,this.ba("Error initializing surveys",t),t}}}else this.ba("PostHog Extensions not found.")}}}_a(t,e){var i;if(!this.qi){this._surveyManager=t(e),this._surveyEventReceiver=this.wa(this.ia,this.va);var r=null==(i=this.ia)?void 0:i.kv.get(zr);r&&this.ka(r),Ss.info("Surveys loaded successfully"),this.Sa(),this.va(),this.xa({isLoaded:!0})}}wa(t,e){return new Os(t,this,void 0,e)}ba(t,e){this.la=!0,Ss.error(t,e),this.va({isLoaded:!1,error:t}),this.xa({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.aa.push(t),this._surveyManager&&this.xa({isLoaded:!0}),()=>{this.aa=this.aa.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.qi){var i=this.ia;if(!i)return t([],{isLoaded:!1,error:Cs});if(this.Yr.disableSurveys)return Ss.info(Rs),t([]);var r=i.kv.get(zr);if(r&&!e)return t(r,{isLoaded:!0}),void(this.$a()&&this.getSurveys(()=>{},!0));if(this.ca)this.ca.then(e=>{this.qi||t(e.surveys,e.context)}).catch(t=>Ss.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Yr.requestTimeoutMs}).then(t=>{try{return this.Ca(i,t)}catch(t){return Ss.error("Error processing surveys response",t),this.Ca(i,{statusCode:0,error:t})}},t=>this.Ca(i,{statusCode:0,error:t}));this.ca=n;var s=()=>{this.ca===n&&(this.ca=null)};n.then(e=>{s(),this.qi||(this.va(e.context),t(e.surveys,e.context))},s).catch(t=>Ss.error("Error in survey callback",t))}}}Ca(t,e){if(this.qi)return{surveys:[],context:{isLoaded:!1,error:Cs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?Ss.error(r):e.error||Ss.warn(r),this.ha=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.ha=null;var n=e.json.surveys||[];return t.kv.set({[zr]:n,[Br]:Date.now()}),this.ka(n),{surveys:n,context:{isLoaded:!0}}}ka(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(_s(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.Ta(e)}Ta(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}$a(){return this.Ma()&&!this.ca&&!this.Ia()}Ma(){var t,e=null==(t=this.ia)?void 0:t.kv.get(Br);return y(e)&&Date.now()-e>3e5}Ia(){return y(this.ha)&&3e5>Date.now()-this.ha}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){Ss.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",/* @__PURE__ */(new Date).toISOString())}catch(t){}this.va()}xa(t){for(var e of this.aa){if(this.qi)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){Ss.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!_(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Ss.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.qi)return()=>{};var i={callback:t,active:!0,revision:0};this.ua.push(i),this.Sa();var r=null==(e=this.ia)?void 0:e.kv.get(zr);return this.Yr.disableSurveys||!this._surveyManager&&this.la&&!this.oa||!r&&!_(this.ha)&&!this.ca?this.pa(i,{isLoaded:!1}):this._surveyManager&&this.pa(i),()=>{var t;i.active=!1,this.ua=this.ua.filter(t=>t!==i),0===this.ua.length&&(null==(t=this.ya)||t.call(this),this.ya=void 0)}}Sa(){var t,e,i;this._surveyManager&&this.ua.length>0&&(null!==(t=this.ya)&&void 0!==t||(this.ya=null==(e=(i=this.ra).onMatchingConditionsChanged)?void 0:e.call(i,this.va)))}pa(t,e){if(!this.qi&&t.active){var i=++t.revision,r=r=>{if(!this.qi&&t.active&&i===t.revision)try{var n=null!=e?e:{isLoaded:!0},s=JSON.stringify([r,n]);if(s===t.lastResult)return;t.lastResult=s,t.callback(r,n)}catch(t){Ss.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){Ss.error("Error in active matching surveys callback",t)}}}Ea(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}Aa(t){if(_(this._surveyManager))return{eligible:!1,reason:Cs};var e="string"==typeof t?this.Ea(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Ra(t){var e;if(null==(e=this.ia)||!e.canCapture)return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(_(this._surveyManager))return{eligible:!1,reason:Cs};var i="string"==typeof t?this.Ea(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(_(this._surveyManager))return Ss.warn("init was not called"),{visible:!1,disabledReason:Cs};var e=this.Ra(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return _(this._surveyManager)?(Ss.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Cs})):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.Ra(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.ia)&&r.canCapture)if(_(this._surveyManager))Ss.warn("init was not called");else{var a="string"==typeof t?this.Ea(t):t;if(null!=a&&a.id)if(ks.includes(a.type)){var o=null==(n=typeof document>"u"?void 0:document)?void 0:n.querySelector(e);if(o)if(null!=(s=a.appearance)&&s.surveyPopupDelaySeconds){Ss.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.da.delete(l),!this.qi&&null!=(t=this.ia)&&t.canCapture&&(Ss.info("Rendering survey "+a.id+" with delay of "+(null==(e=a.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(r=this._surveyManager)||r.renderSurvey(a,o,i),Ss.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.da.add(l)}else this._surveyManager.renderSurvey(a,o,i);else Ss.warn("Survey element not found")}else Ss.warn("Surveys of type "+a.type+" cannot be rendered in the app");else Ss.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.ia)&&r.canCapture)if(_(this._surveyManager))Ss.warn("init was not called");else{var s=this.Ea(t);if(s){var a=s;if(null!=(n=s.appearance)&&n.surveyPopupDelaySeconds&&i.ignoreDelay&&(a=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&Ss.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.Aa(s);if(!o.eligible)return void Ss.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(a,i):this.renderSurvey(a,i.selector,i.properties)}else Ss.warn("Survey not found")}}cancelPendingSurvey(t){_(this._surveyManager)?Ss.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};li.DEBUG=!1,li.LIB_VERSION="1.455.1",li.LIB_NAME="web";var Ms,Is=li,Ds=/* @__PURE__ */new WeakMap,js=()=>{var t;return null!=un&&null!=(t=un.performance)&&t.now?un.performance.now():Date.now()},Ls=class{constructor(t){this._instance=t}get(){var t,e,i,r,n=null==(t=this._instance)?void 0:t.config;return{disableSurveys:!(null==n||!n.disable_surveys),cookielessMode:!(null==n||!n.cookieless_mode),advancedEnableSurveys:!(null==n||!n.advanced_enable_surveys),requestTimeoutMs:null!==(e=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==e?e:1e4,prefillFromUrl:!(null==n||null==(i=n.surveys)||!i.prefillFromUrl),automaticDisplay:!(null!=n&&n.disable_surveys_automatic_display),featureFlagEvaluation:!(null!=n&&n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null==(r=this._instance)||null==(r=r.requestRouter)?void 0:r.endpointFor("ui","")}}getExtensions(){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=gn(e);return{generateSurveys:i?t=>i(e,t):void 0,loadExternalDependency:r?t=>r(e,"surveys",t):void 0}}}onMatchingConditionsChanged(t){var e,i,r=null==(e=this._instance)?void 0:e._addCaptureHook(e=>{"$pageview"!==e&&e!==ps&&e!==gs&&e!==ms||t()}),n=()=>t();gi(un,"PHSurveyShown",n);var s=!1,a=null==(i=this._instance)?void 0:i.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,null==r||r(),null==a||a(),null==un||un.removeEventListener("PHSurveyShown",n)}}},Ns=class extends $s{constructor(t){super(new Ls(t))}},zs=/* @__PURE__ */(()=>null!=un&&un.location?Tn(un.location.hash,"__posthog")||Tn(location.hash,"state"):null)(),Bs="_postHogToolbarParams",Us=/* @__PURE__ */ci("[Toolbar]"),Hs=class{constructor(t){this.instance=t}am(t){pn.ph_toolbar_state=t}um(){var t;return null!==(t=pn.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),mi(this.instance.config))return!1;if(!un||!vn)return!1;t=null!=t?t:un.location,i=null!=i?i:un.history;try{if(!e){try{un.localStorage.setItem("test","test"),un.localStorage.removeItem("test")}catch(t){return!1}e=null==un?void 0:un.localStorage}var r,n=zs||Tn(t.hash,"__posthog")||Tn(t.hash,"state"),s=n?X(()=>JSON.parse(atob(decodeURIComponent(n))))||X(()=>JSON.parse(decodeURIComponent(n))):null;return s&&"ph_authorize"===s.action?((r=s).source="url",r&&Object.keys(r).length>0&&(s.desiredHash?t.hash=s.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(Bs)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}hm(t){var e=pn.ph_load_toolbar||pn.ph_load_editor;!_(e)&&c(e)?e(t,this.instance):Us.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==vn||!vn.getElementById("__POSTHOG_TOOLBAR__"));if(!un||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(un.localStorage.setItem(Bs,JSON.stringify(e({},n,{source:void 0}))),2===this.um())this.hm(n);else if(0===this.um()){var s;this.am(1),null==(s=gn(this.instance))||s(this.instance,"toolbar",t=>{if(t)return Us.error("[Toolbar] Failed to load",t),void this.am(0);this.am(2),this.hm(n)}),gi(un,"turbolinks:load",()=>{this.am(0),this.loadToolbar(n)})}return!0}dm(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)}},qs=/* @__PURE__ */ci("[FeatureFlags]"),Vs=/* @__PURE__ */ci("[FeatureFlags]",{debugEnabled:!0}),Ws="\" failed. Feature flags didn't load in time.",Gs=[502,504],Ks=["click","keydown","wheel","touchstart","pointerdown"],Js="connection_error",Xs=(t,i)=>{var r=Object.keys(i||{}).filter(t=>{var e;return null==i||null==(e=i[t])?void 0:e.failed});if(!r.length)return t||{};var n=e({},t);return r.forEach(t=>delete n[t]),n},Ys=(t,i)=>{var r=e({},t);return i.forEach(t=>{var e;null!=(e=r[t])&&e.failed&&delete r[t]}),r},Zs=(t,e)=>!(null==e||!e.partialResponse)||!!t.errorsWhileComputingFlags,Qs=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},ta=t=>{var e={};for(var i of pi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},ea=(t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed).map(t=>{var e;return[t,null!==(e=r[t].variant)&&void 0!==e?e:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>!r[t].failed&&r[t].enabled).filter(t=>{var e;return!f(null==(e=r[t].metadata)?void 0:e.payload)}).map(t=>{var e;return[t,null==(e=r[t].metadata)?void 0:e.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)},ia={version:2},ra=(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),na=class{constructor(t){this.name="featureFlags",this.uv=!1,this.featureFlagEventHandlers=[],this.R=qs,this.hv={},this.dv={},this.vv=[],this.fv=/* @__PURE__ */new Set,this.pv=/* @__PURE__ */new Set,this.gv=!1,this.mv=!1,this.yv=0,this.bv=!1,this._v=!1,this.wv=!1,this.Sv=/* @__PURE__ */new Map,this.xv=!1,this.$v=!1,this.Cv=!1,this.Tv=0,this.Mv=!1,this.Iv=!1,this.Ev=/* @__PURE__ */new WeakMap,this.Av=/* @__PURE__ */new Map,this.mn=()=>{var t=this.Rv();this.Tv=0,t&&this.reloadFeatureFlags()},this.Pv=()=>{var t,e,i=this.Ov,r=null!==(t=this.Fv)&&void 0!==t?t:i;f(i)||f(r)||this.Yr.remoteRequestsDisabled||!this.Lv||"hidden"===this.Lv.visibilityState||Date.now()-(null!==(e=this.Dv)&&void 0!==e?e:0)<r||(this.Fv=this.Mv||!this.Yr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Mv=!1,this.reloadFeatureFlags(),this.Nv())},this.jv=()=>{this.Mv&&this.Fv===this.Ov||this.qv()},this.gn=()=>{var t;"visible"===(null==(t=this.Lv)?void 0:t.visibilityState)&&this.qv()},this.ra=t}get Bv(){return ia}get zv(){}Hv(){this.ia&&this.Uv()}setup(t){try{this.Wv=typeof window>"u"?void 0:window,this.Lv=typeof document>"u"?void 0:document}catch(t){this.Wv=void 0,this.Lv=void 0}return this.ga=t,this.R=t.logger.createLogger("[FeatureFlags]"),Ps(t.kv.initialize(),()=>{this.ga===t&&(this.ga=void 0,this.ia=t,this.Vv(t))})}Vv(t){var e;if(this.ia===t)return this.Wv&&gi(this.Wv,"online",this.mn),this.Uv(),this.Gv=t.registerDynamicEventProperties(()=>this.Jv()?this.hv:this.dv),this.Qv=null==(e=this.zv)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Zv(),this.Kv(),this.Yv()}),this.Kv(),this.initialize()}qv(){this.Mv=!0,this.Fv=this.Ov,this.Pv()}Uv(){var t,e=this.Yr.refreshIntervalMs,i=!this.Yr.remoteRequestsDisabled&&this.Lv&&!f(e)&&e>0?e:void 0;this.Yr.idleRefreshBackoff||(this.Fv=i),i!==this.Ov&&(this.Xv(),f(i)||(this.Ov=i,this.Fv=i,this.Nv(),null!=(t=this.Lv)&&t.addEventListener&&(gi(this.Lv,Mi,this.gn),vi(Ks,t=>{gi(this.Lv,t,this.jv,{capture:!0})}))))}Nv(){f(this.Ov)||(f(this.tf)||clearInterval(this.tf),this.Dv=Date.now(),this.tf=setInterval(this.Pv,this.Ov))}Xv(){var t;f(this.tf)||(clearInterval(this.tf),this.tf=void 0,null==(t=this.Lv)||null==t.removeEventListener||t.removeEventListener(Mi,this.gn),vi(Ks,t=>{var e;null==(e=this.Lv)||null==e.removeEventListener||e.removeEventListener(t,this.jv,{capture:!0})})),this.Ov=void 0,this.Fv=void 0,this.Mv=!1,this.Dv=void 0}destroy(){this.ef()}dispose(){this.ef()}ef(){var t,e,i;this.Xv(),this.yv++,this._v=!1,this.ga=void 0,this.if(this.fv,"cancelled"),this.if(this.pv,"cancelled"),this.ia&&(this.nf(),null==(t=this.Gv)||t.dispose(),this.Gv=void 0,null==(e=this.Qv)||e.call(this),this.Qv=void 0,this.vv=[],null==(i=this.Wv)||i.removeEventListener("online",this.mn),this.ia=void 0)}get Yr(){return this.ra.get()}sf(t){var e;return this.rf&&t in this.rf?this.rf[t]:null==(e=this.ia)?void 0:e.kv.get(t)}Zv(){return!!this.rf&&(this.rf=void 0,!0)}lf(){var t;return!f(null==(t=this.ia)?void 0:t.kv.get("$enabled_feature_flags"))&&this.Zv()}$t(t){this.af(()=>{var e;return null==(e=this.ia)?void 0:e.kv.set(t)})}uf(t,e,i){if(this.zv&&t.$enabled_feature_flags){var r=this.sf("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(t=>{var e=t[1];return!(null!=e&&e.failed)}).map(t=>t[0]):[],o=!!e.errorsWhileComputingFlags&&!!e.flags,l=o||i&&e.flags?a:i&&!h(s)?Object.keys(s||{}):Array.from(/* @__PURE__ */new Set([...Object.keys(r),...Object.keys(n)])),u=this.sf("$feature_flag_payloads")||{},c=t.$feature_flag_payloads||{},v=o||i?l:Array.from(/* @__PURE__ */new Set([...Object.keys(u),...Object.keys(c)])),d=!o&&!i,p=!!d||l,g=!!d||v,m={[bi]:p,[Ai]:p,[Ci]:g};for(var _ of(t.$feature_flag_details&&(m[wi]=p),[ki,Si,Ei]))f(t[_])||(m[_]=!0);this.zv.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.af(()=>{var e;return null==(e=this.ia)?void 0:e.kv.remove(t)})}af(t){try{t()}catch(t){this.R.error("Failed to update feature flag persistence",t)}}Kv(){var t={},i=this.sf(wi);for(var r of[ki,Ri]){var n=this.sf(r);f(n)||(t[r]=n)}var s=this.sf(bi);s&&(t[bi]=s.filter(t=>{var e;return!(null!=i&&null!=(e=i[t])&&e.failed)}));var a=this.sf(Ci);a&&(t[Ci]=Xs(a,i)),this.hv=t;var o=e({},t),l=Xs(this.sf(Ai),i);if(l)for(var u of Object.entries(l))o["$feature/"+u[0]]=u[1];this.dv=o}Jv(){var t=this.Yr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.sf(Si);return"number"!=typeof e||Date.now()-e>t}cf(){return!!this.Jv()&&(this.Cv||this.mv||(this.Cv=!0,this.R.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}hf(){var t=this.Yr.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}):[]}df(){var t=this.Yr.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.Yr,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]=i.encodeBootstrapPayloads?JSON.stringify(a[e]):a[e],t),{});return this.vf({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n=null!=r&&r.merge?Xs(this.sf(Ai),this.sf(wi)):{},s=null!=r&&r.merge?Xs(this.sf(Ci),this.sf(wi)):{},a=e({},n,t),o=e({},s,i),l={};for(var u of Object.entries(a)){var h=u[0],c=u[1];l[h]={key:h,enabled:Ut(c),variant:Ht(c),reason:void 0,metadata:f(null==o?void 0:o[h])?void 0:{id:0,version:void 0,description:void 0,payload:o[h]}}}this.vf({flags:l})}get hasLoadedFlags(){return this.gv}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.ff(),e=this.Bv.publicDetail;return e?Object.fromEntries(Object.entries(t).map(t=>[t[0],e(t[1])])):t}ff(){var t=this.sf(wi),i=this.sf(Ri),r=this.sf($i);if(!r&&!i)return t||{};var n=fi({},t||{});for(var s of[.../* @__PURE__ */new Set([...Object.keys(r||{}),...Object.keys(i||{})])]){var a,o,l=n[s],u=null==i?void 0:i[s],h=f(u)?null!==(a=null==l?void 0:l.enabled)&&void 0!==a&&a:!!u,c=f(u)?null==l?void 0:l.variant:"string"==typeof u?u:void 0,v=null==r?void 0:r[s],d=e({},l,{enabled:h,variant:h?null!=c?c:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(d.original_enabled=null==l?void 0:l.enabled),c!==(null==l?void 0:l.variant)&&(d.original_variant=null==l?void 0:l.variant),v&&(d.metadata=e({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(o=l.metadata)?void 0:o.payload})),n[s]=d}return this.uv||(this.R.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.uv=!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=Xs(this.sf(Ai),this.sf(wi)),e=this.sf(Ri);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.uv||(this.R.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.uv=!0),i}getFlagPayloads(){var t=Xs(this.sf(Ci),this.sf(wi)),e=this.sf($i);if(!e)return t||{};for(var i=fi({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.uv||(this.R.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.uv=!0),i}reloadFeatureFlags(){this.bv||this.Yr.featureFlagsDisabled||this.Rv()||(this.wv&&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.mv&&(this._v=!0),this.pf||(this.pf=setTimeout(()=>{this.gf()},5),this.vv.slice().forEach(t=>{try{t()}catch(t){this.R.error("Error while running feature flags reloading callback",t)}})))}reloadFeatureFlagsAsync(){return!this.ia||this.bv||this.Yr.featureFlagsDisabled||this.Yr.remoteRequestsDisabled||this.Rv()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.fv.add(t),this.reloadFeatureFlags()})}if(t,e){t.forEach(t=>t({status:e})),t.clear()}nf(){clearTimeout(this.pf),this.pf=void 0}onReloading(t){return this.vv.push(t),()=>{this.vv=this.vv.filter(e=>e!==t)}}ensureFlagsLoaded(){this.gv||this.mv||this.pf||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.bv=t}resetFlagCallReported(){this.Dt(Oi),this.Sv=/* @__PURE__ */new Map,this.Av=/* @__PURE__ */new Map}sendFlagCallsPendingCapture(){var t;if(0!==this.Sv.size&&!this.xv&&null!=(t=this.ia)&&t.canCapture&&!this.ia.isRateLimited){this.xv=!0;try{var e=this.getFlagVariants();for(var i of Array.from(this.Sv.keys())){var r,n=this.Sv.get(i);if(n){var s=null==(r=this.mf(i,e[i]))?void 0:r.calledKey;if(n.value!==String(e[i])||n.calledKey&&n.calledKey!==s||!ra(n.context,this.yf()))this.Sv.delete(i);else if(this.getFeatureFlagResult(i),this.Sv.has(i))break}}}finally{this.xv=!1}}}gf(t){var i;this.nf();var r=this.ia;if(!r||this.Yr.remoteRequestsDisabled||this.Rv())this.if(this.fv,"skipped");else if(this.mv)this._v=!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.sf("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.sf(Ti),timezone:Mn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Yr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.hf();s.length&&(n.evaluation_contexts=s);var a=this.df();f(a)||(n.flag_keys=a);var o=this.Yr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v="+this.Bv.version+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.yv,h=this.fv;this.fv=/* @__PURE__ */new Set,this.pv=h,this.mv=!0;var c=()=>{this._v&&(this._v=!1,this.gf())},v=t=>{var e,i=this.bf(t.json),r=200!==t.statusCode;if(this.mv=!1,u===this.yv)if(this._f(t.statusCode),r||this._v||(this.$anon_distinct_id=void 0),!n.disable_flags||this._v){this.$v=!r;var s=[];t.error?s.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Js:"unknown_error"):200!==t.statusCode&&s.push("api_error_"+t.statusCode),i.errorsWhileComputingFlags&&s.push("errors_while_computing_flags");var a=!(null==(e=i.quotaLimited)||!e.includes("feature_flags"));a&&s.push("quota_limited"),this.$t({[xi]:s}),a?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.vf(i,r,{partialResponse:o}),this.if(h,n.disable_flags?"skipped":s.length||!i.flags&&!i.featureFlags?"error":"loaded"),c()}else this.if(h,"skipped");else c()},d=t=>{this.mv=!1,u===this.yv?(this.$t({[xi]:[Js]}),this.R.error("Feature flag request failed",t),this.lf()&&this.Yv(!0),this.if(h,"error"),c()):c()},p=null!==(i=this.Yr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.yv,m=()=>{if(u!==this.yv||!this.ia||this.Yr.remoteRequestsDisabled)return this.mv=!1,this.if(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Yr.compression,sentAt:"body",timeoutMs:this.Yr.requestTimeoutMs}).then(t=>{if((t=>Gs.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()}}bf(t){var e=null!=t?t:{},i=this.Bv.read;if(!i)return e;var r=i(e),n=r.body;return r.withoutTypedValues&&!this.Iv&&(this.Iv=!0,this.R.info("The /flags response has no typed flag values. Its flags are read as before.")),n}Rv(){return Sn(this.Tv,3)}_f(t){this.Tv=kn(t,this.Tv,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."))}wf(t){var e;return!(this.gv||this.getFlags().length||null!=(e=this.getFeatureFlagDetails(t))&&e.failed)}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.$v)if(this.wf(t))this.R.warn('getFeatureFlag for key "'+t+Ws);else if(!this.cf()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}getFeatureFlagDetails(t){var e=this.ff()[t],i=this.Bv.publicDetail;return e&&i?i(e):e}getFeatureFlagPayload(t){var e;return null==(e=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:e.payload}getFeatureFlagResult(t,i){var r;if(void 0===i&&(i={}),!i.fresh||this.$v)if(this.wf(t))this.R.warn('getFeatureFlagResult for key "'+t+Ws);else if(!this.cf()){var n,s=null==(r=this.sf(wi))||null==(r=r[t])?void 0:r.failed,a=s?void 0:this.sf(Ai),o=s?void 0:this.sf(Ci),l=this.sf(Ri),u=!!l&&{}.hasOwnProperty.call(l,t),c=u||!!a&&t in a,v=u?l[t]:null==a?void 0:a[t],d=this.sf($i),f=d&&{}.hasOwnProperty.call(d,t)?d[t]:null==o?void 0:o[t],p=String(v),g=this.sf("$feature_flag_request_id")||void 0,m=this.sf("$feature_flag_evaluated_at")||void 0,_=this.sf("$flag_call_reported")||{};if(this.Yr.deduplicateCallsPerSession){var y,b=null==(y=this.ia)||null==(y=y.session)?void 0:y.sessionId,w=this.sf(Pi);b&&b!==w&&(_={},n=b)}if(!i.send_event&&"send_event"in i)n&&this.$t({[Oi]:_,[Pi]:n});else{var x,S,k,E,A,T,F=!(null!=(x=this.ia)&&x.canCapture),O=!(F||null!=(S=this.ia)&&S.isRateLimited),P=this.mf(t,v),C=P?P.calledKey:p,R=null==P?void 0:P.exposureKey,M=()=>this.kf(t,p,null==P?void 0:P.calledKey);O?this.Sv.delete(t):(F&&Object.keys(_).length>0&&(_={},this.$t({[Oi]:_})),null!=(A=_[t])&&A.includes(C)&&(!R||null!=(T=_[t])&&T.includes(R))||M());var I=!(null!=(k=_[t])&&k.includes(C)),D=!(!R||null!=(E=_[t])&&E.includes(R));if(O&&P&&(I||D)){n&&this.$t({[Oi]:_,[Pi]:n});var j=P.build(this.Sf(t,v,f,g,m)),L=I?this.xf(t,C,j.called,M):void 0;D&&j.exposure&&this.xf(t,R,j.exposure,M,L)}else if(O&&I){h(_[t])?_[t].push(p):_[t]=[p],this.$t(e({[Oi]:_},n?{[Pi]:n}:{}));var N=this.Sf(t,v,f,g,m);this.$f(N)||(this.Cf(t,p),M())}else n&&this.$t({[Oi]:_,[Pi]:n})}if(c)return{key:t,enabled:!!v,variant:"string"==typeof v?v:void 0,payload:Bt(f)}}}Sf(t,e,i,r,n){var s,a,o,l,u,h,c,v,d,p,g,m,_,y=this.ff()[t],b=[...null!==(s=this.sf("$feature_flag_errors"))&&void 0!==s?s:[]];f(e)&&b.push(null!=y&&y.failed?"evaluation_failed":"flag_missing");var w={$feature_flag:t,$feature_flag_response:e,$feature_flag_payload:null!=i?i:null,$feature_flag_request_id:r,$feature_flag_evaluated_at:n,$feature_flag_bootstrapped_response:null!==(a=null==(o=this.Yr.bootstrap)||null==(o=o.featureFlags)?void 0:o[t])&&void 0!==a?a:null,$feature_flag_bootstrapped_payload:null!==(l=null==(u=this.Yr.bootstrap)||null==(u=u.featureFlagPayloads)?void 0:u[t])&&void 0!==l?l:null,$used_bootstrap_value:!this.$v};f(null==y||null==(h=y.metadata)?void 0:h.has_experiment)||(w.$feature_flag_has_experiment=y.metadata.has_experiment),f(null==y||null==(c=y.metadata)?void 0:c.version)||(w.$feature_flag_version=y.metadata.version);var x=null!==(v=null==y||null==(d=y.reason)?void 0:d.description)&&void 0!==v?v:null==y||null==(p=y.reason)?void 0:p.code;return x&&(w.$feature_flag_reason=x),null!=y&&null!=(g=y.metadata)&&g.id&&(w.$feature_flag_id=y.metadata.id),f(null==y?void 0:y.original_variant)&&f(null==y?void 0:y.original_enabled)||(w.$feature_flag_original_response=f(y.original_variant)?y.original_enabled:y.original_variant),null!=y&&null!=(m=y.metadata)&&m.original_payload&&(w.$feature_flag_original_payload=null==y||null==(_=y.metadata)?void 0:_.original_payload),b.length&&(w.$feature_flag_error=b.join(",")),w}mf(t,e){var i,r,n,s=this.Bv.flagEvents,a=this.sf(Ri);if(!(!s||v(a)&&l.call(a,t)))return s({key:t,response:e,groups:null!==(i=null==(r=this.ia)?void 0:r.groups)&&void 0!==i?i:{},record:null==(n=this.sf(wi))?void 0:n[t]})}xf(t,i,r,n,s){var a,o=this.sf("$flag_call_reported")||{},l=t+i,u=this.Av.get(l)||0;if(!(null!=(a=o[t])&&a.includes(i)||u>1)){this.$t({[Oi]:e({},o,{[t]:[...o[t]||[],i].slice(-10)})});var h,c,v=!1,d=!1;this.Ev.set(r.properties,e({},r.capture,{failed(){v=!0},resolved:t=>(c=t.$session_id,h=JSON.stringify([t.distinct_id,t.$groups,c,t.$process_person_profile]),!(d=!!s&&h!==s))}));var f=!1;try{var p,g;(f=!1!==(null==(p=this.ia)?void 0:p.capture(r.event,r.properties))&&!(null==(g=this.ia)||!g.canCapture))||n()}catch(t){v=!0,this.R.error("Failed to capture "+r.event,t)}v&&this.Av.set(l,u+1);var m=f&&!v&&!d;return m||this.Cf(t,i),this.Yr.deduplicateCallsPerSession&&c&&c!==this.sf("$flag_call_reported_session_id")&&this.$t({[Oi]:m?{[t]:[i]}:{},[Pi]:c}),h}}flagEventCapture(t){return t?this.Ev.get(t):void 0}$f(t){try{var e;return!1!==(null==(e=this.ia)?void 0:e.capture("$feature_flag_called",t))}catch(t){return this.R.error("Failed to capture feature flag call",t),!0}}kf(t,e,i){this.Sv.set(t,{value:e,calledKey:i,context:this.yf()})}yf(){var t,i,r;return{distinctId:null==(t=this.ia)?void 0:t.distinctId,groups:e({},null==(i=this.ia)?void 0:i.groups),sessionId:this.Yr.deduplicateCallsPerSession?null==(r=this.ia)||null==(r=r.session)?void 0:r.sessionId:void 0}}Cf(t,e){var i=this.sf("$flag_call_reported")||{},r=i[t];h(r)&&r.includes(e)&&(i[t]=r.filter(t=>t!==e),this.$t({[Oi]:i}))}getRemoteConfigPayload(t,e){this.Tf(t,e)}Tf(t,e){var i=this;return r(function*(){var r=i.ia;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.hf();s.length&&(n.evaluation_contexts=s);var a,o=i.df();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.Yr.compression,sentAt:"body",timeoutMs:i.Yr.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.$v)return e.defaultValue;if(this.wf(t))return this.R.warn('isFeatureEnabled for key "'+t+Ws),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.vf(t,e,i)}vf(t,i,r){if(this.ia){var n;this.gv=!0,!1!==(null==r?void 0:r.persist)&&Zs(t,r)&&null!=(n=this.zv)&&null!=n.reconcileFeatureFlagsBeforeMerge&&n.reconcileFeatureFlagsBeforeMerge()&&this.Zv();var s=this.getFlagVariants(),a=!t.flags&&h(t.featureFlags),o=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=qs);var o=ea(t,a),l=o.flags,u=o.featureFlags,c=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[bi]:u,[Ai]:p,[wi]:Ys(n,u),[Ci]:Xs(r,n),[Ei]:!1}}var m=u,_=c,y=l;if(Zs(t,s)){var b=Object.keys(m),w=_||{};m=e({},i,m),_=e({},r,w),(null!=s&&s.partialResponse||l)&&b.forEach(t=>{var e;t in w||null==(e=_)||delete e[t]}),y=l?e({},n,Object.fromEntries(Object.entries(l).filter(t=>{return!(t[1].failed&&(e=t[0],{}.hasOwnProperty.call(i,e)&&!f(i[e])));var e}))):Ys(n,b)}return e({[bi]:Object.keys(ta(m)),[Ai]:m||{},[Ci]:_||{},[wi]:y||{},[Ei]:!0===t.minimalFlagCalledEvents},v?{[ki]:v}:{},d?{[Si]:d}:{})}}(t,s,a?this.sf("$feature_flag_payloads")||{}:this.getFlagPayloads(),a?this.sf("$feature_flag_details")||{}:this.ff(),r,this.R);if(o)if(!1===(null==r?void 0:r.persist)){var l=!f(this.ia.kv.get(Ai));this.rf=o,l||this.$t(o)}else this.Zv(),this.uf(o,t,!(null==r||!r.partialResponse)),this.$t(o);else i&&this.lf();i||(this.Cv=!1),this.Yv(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.Mf(t)}Mf(t){if(this.ia){if(!1===t)return this.Dt([Ri,$i]),this.Yv(),void Vs.info("All overrides cleared");if(h(t))return this.$t({[Ri]:Qs(t)}),this.Yv(),void Vs.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.uv=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Ri]=h(n)?Qs(n):n),s&&(r[$i]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Ri,$i]):!1===n?this.Dt(Ri):!1===s&&this.Dt($i),this.Yv(),!1===n?Vs.info("Flag overrides cleared"):n&&Vs.info("Flag overrides set",{flags:n}),void(!1===s?Vs.info("Payload overrides cleared"):s&&Vs.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Ri]:t}),this.Yv(),void Vs.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.gv){var e=this.If(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.R.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var n,s,a=(this.sf("$early_access_features")||[]).find(e=>e.flagKey===t),o={["$feature_enrollment/"+t]:i},l={$feature_flag:t,$feature_enrollment:i,$set:o};a&&(l.$early_access_feature_name=a.name),r&&(l.$feature_enrollment_stage=r);var u=e({},this.getFlagVariants(),{[t]:i}),h=e({},this.sf(wi)),c=null==(n=h[t])?void 0:n.failed,v=e({},this.sf(Ci));c&&(delete h[t],delete v[t]),null==(s=this.zv)||s.markCrossTabFeatureFlagChanges(e({[bi]:[t],[Ai]:[t]},c?{[wi]:[t],[Ci]:[t]}:{},{[Fi]:Object.keys(o)})),this.$t(e({[bi]:Object.keys(ta(u)),[Ai]:u},c?{[wi]:h,[Ci]:v}:{},{[Fi]:e({},this.sf("$stored_person_properties")||{},o)})),this.Yv();try{var d;null==(d=this.ia)||d.capture("$feature_enrollment_update",l)}catch(t){this.R.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.sf(yi);!r||e?this.Ef(t,i):t(r)}Ef(t,e){var i=this;return r(function*(){var r=i.ia;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({[yi]: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)}}})()}If(){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),{})}}Yv(t){this.Kv();var e=this.If(),i=e.flags,r=e.flagVariants,n=this.wv;this.wv=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.R.error("Error while running feature flags callback",t)}}),this.wv=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Af(t,e)}Af(t,i){void 0===i&&(i=!0);var r=this.sf("$stored_person_properties")||{},n=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,a={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in r||(a[o]=s[o]));this.$t({[Fi]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.sf("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Fi]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Fi),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.sf("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[Ti]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.sf("$stored_group_properties")||{};this.$t({[Ti]:e({},i,{[t]:{}})})}else this.Dt(Ti)}reset(){this.yv++,this.if(this.fv,"cancelled"),this.if(this.pv,"cancelled"),this._v=!1,this.hv={},this.dv={},this.rf=void 0,this.gv=!1,this.bv=!1,this.$v=!1,this.$anon_distinct_id=void 0,this.nf(),this.uv=!1,this.Tv=0,this.Sv=/* @__PURE__ */new Map,this.Av=/* @__PURE__ */new Map}},sa=t=>v(t)&&"value"in t?t:void 0,aa=t=>p(t)?t:y(t)||v(t)||!0===t,oa="$experiment_exposure",la="experiment_split",ua="experiment",ha={targeting_match:["targeted_release","percentage_rollout"],[la]:[ua],rollout_miss:["percentage_rollout",ua],experiment_paused:[ua],holdout:[ua]},ca="$feature_flag_config_version",va="$feature_flag_reason_code",da="$feature_flag_rule_id",fa="$feature_flag_rule_type",pa="$feature_flag_variant_key",ga="$feature_flag_experiment_id",ma="$feature_flag_forced_variant",_a=[ca,va,da,fa,pa],ya=[..._a,"$feature_flag_reason",ma,ga],ba=[ca,va,fa,"$experiment_exposure_source",ga,ma],wa=["$feature_flag_id","$feature_flag_version","$feature_flag_request_id","$feature_flag_evaluated_at"],xa=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Sa=t=>p(t)?t:void 0,ka={},Ea=t=>y(t)&&t%1==0,Aa=[["key",p],["failed",b]],Ta=[["code",p],["condition_index",Ea],["description",p]],Fa=[["id",Ea],["version",Ea],["description",p],["has_experiment",b],["config_version",Ea],["rule_type",p],["rule_id",p],["variant_key",p],["forced_variant",b],["experiment_id",Ea]],Oa=(t,e)=>{if(!_(t)){if(!v(t))throw ka;var i={};for(var r of e){var n=r[0],s=r[1],a=t[n];if(!_(a)){if(!s(a))throw ka;i[n]=a}}return i}},Pa=(t,i)=>{var r=Oa(i,Aa),n=null==i?void 0:i.value;if(!r||!(m(n)||b(n)||p(n)||v(n)||y(n)&&isFinite(n)))throw ka;var s=i.metadata,a=Oa(s,Fa),o=!0===r.failed,l=o?null:n,u=y(l)||v(l),h=aa(l);return{key:t,enabled:!1!==h,variant:p(h)?h:null,value:l,reason:Oa(i.reason,Ta),metadata:a||u?e({},a,{payload:o?null:u?JSON.stringify(l):null==s?void 0:s.payload,experiment_id:void 0}):void 0,failed:o||void 0}},Ca=["config_version","rule_type","rule_id","variant_key","forced_variant"],Ra={version:4,read(t){var i=v(t)?t.flags:void 0,r=!1;if(!v(i)){var n=v(t)?t.featureFlags:void 0;return{body:t,withoutTypedValues:v(n)&&Object.keys(n).length>0}}return{body:e({},t,{flags:Object.fromEntries(Object.keys(i).map(t=>{var e=i[t];if(v(e)&&!("value"in e))return r=!0,[t,e];try{return[t,Pa(t,e)]}catch(e){return[t,{key:t,enabled:!1}]}}))}),withoutTypedValues:r}},publicDetail(t){if(!sa(t))return t;var i=e({},t);if(delete i.value,v(i.metadata)){var r=i.metadata=e({},i.metadata);for(var n of Ca)delete r[n]}return i},flagEvents(t){var i=t.key,r=t.response,n=t.record,s=(t=>{var e,i=sa(t),r=null==i?void 0:i.metadata;if(i&&2===(null==r?void 0:r.config_version)){var n,s,a,o=Sa(null==(e=i.reason)?void 0:e.code)||void 0,u=o&&l.call(ha,o)?ha[o]:void 0,h=Sa(r.rule_id),c=Sa(r.rule_type);return!i.failed&&u&&h&&xa.test(h)&&c&&-1!==u.indexOf(c)&&(o!==la?(n=h,s=c):p(r.variant_key)&&(n=h,s=c,a=r.variant_key)),{reasonCode:o,ruleId:n,ruleType:s,variantKey:a}}})(n),a=sa(n);if(s&&a&&(a.failed?f(r):aa(a.value)===r)){var o=s.reasonCode,u=s.ruleId,h=s.ruleType,c=s.variantKey,v=Object.keys(t.groups).sort().map(e=>[e,t.groups[e]]),d={[ca]:2};o&&(d[va]=o),u&&(d[da]=u,d[fa]=h);var g=p(c);return g&&(d[pa]=c),{calledKey:JSON.stringify([r,v,2,o||null,u||null,h||null,g?c:null]),exposureKey:g?JSON.stringify([oa,v,2,u,c]):void 0,build(t){var n=e({},t,d);delete n.$feature_flag_reason;var s={event:"$feature_flag_called",properties:n,capture:{omit:ya.filter(t=>!(t in n)),keep:_a}};if(!g)return{called:s,exposure:void 0};var a={};for(var o of wa)f(n[o])||(a[o]=n[o]);return a.$feature_flag=i,a.$feature_flag_response=r,a[pa]=c,a[da]=u,a.locally_evaluated=!1,{called:s,exposure:{event:oa,properties:a,capture:{omit:ba,keep:[]}}}}}}}},$a=/* @__PURE__ */ci("[FeatureFlags]"),Ma=class{constructor(t,e){void 0===e&&(e=!1),this.Rf=!1,this.update(t,e)}update(t,e){this.Pf=((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.Rf||($a.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Rf=!0),f(t.flag_keys)||h(t.flag_keys)||$a.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Pf}},Ia=class extends na{constructor(t){var e=new Ma(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.bp=e}get zv(){return this._instance.persistence}get Bv(){return Ra}updateConfig(t,e){this.bp.update(t,e),this.Hv()}},Da=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),ja=/* @__PURE__ */ci("[Error tracking]"),La="webkit-masked-url:",Na=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],za=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",La],Ba=["__firefox__","__gCrWeb"],Ua=class{constructor(t){var i,r;this.xg=[],this.$g=new it([new St,new $t,new Et,new kt,new Ct,new Pt,new Tt,new Rt],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),_=m[m.length-1];if(_){var y=yt(s,_);for(var b of(s.splice(_.start-y,y),m))b.start-=y}for(var w of m)_t(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.xg=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Cg=Lt(this.Tg()),this.Mg=new Nt(this.Cg)}onConfigChange(){this.Cg=Lt(this.Tg()),this.Mg.setConfig(this.Cg)}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.xg=s,this._instance.persistence&&this._instance.persistence.register({[Kr]:this.xg,[Jr]:a})}}}get Ig(){var t,e,i=!!this._instance.get_property(Jr);return null!==(t=null!==(e=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==e?e:i)&&void 0!==t&&t}buildProperties(t,e){return this.$g.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Cg.enabled)try{if(!p(t)||0===t.trim().length)return void ja.warn("Ignoring exception step because message must be a non-empty string");var r=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce((i,r)=>Dt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.Eg(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&ja.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.Mg.add(e({[Mt]:t,[It]:/* @__PURE__ */(new Date).toISOString()},n))}catch(t){ja.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Ag(e)){if(this.Rg(e))return this.Pg("Exception dropped: matched a suppression rule"),void ja.info("Skipping exception capture because a suppression rule matched");if(!this.Ig&&this.Og(e))return this.Pg("Exception dropped: thrown by a browser extension"),void ja.info("Skipping exception capture because it was thrown by an extension");if(!this.Ig&&this.Fg(e))return this.Pg("Exception dropped: thrown by an injected browser script"),void ja.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Lg(e))return this.Pg("Exception dropped: thrown by the PostHog SDK"),void ja.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Cg.enabled&&_(t.$exception_steps)?this.Dg(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.Mg.clear(),n}catch(t){return Da(t)||ja.error("Failed to capture exception event. Dropping this exception.",t),void this.Mg.clear()}}catch(t){return void(Da(t)||ja.error("Failed to process exception event. Ignoring this exception.",t))}}Dg(t){try{var i=this.Mg.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return ja.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Pg(t){this.Cg.enabled&&this.Mg.add({[Mt]:t,[It]:/* @__PURE__ */(new Date).toISOString()})}Eg(t){return v(t)?e({},t):{}}Tg(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Rg(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.xg.some(t=>{var i=t.values.map(t=>{var i=ws[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 ja.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Og(t){var e=t.flatMap(t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]}),i=e.filter(t=>{var e=t.filename;return!!e&&za.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(La)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&Na.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(La))}))}Fg(t){return t.some(t=>{var e=t.value;return p(e)&&Ba.some(t=>e.includes(t))})}Lg(t){if(t.length>0){var e,i,r,n,s=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[];return null!==(r=null==(n=s[s.length-1])||null==(n=n.filename)?void 0:n.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Ag(t){return!_(t)&&h(t)}},Ha=/*#__PURE__*/function(){function t(t,e){this.v=t,this.k=e}function e(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 i(t,i){return function(t){if(Array.isArray(t))return t}(t)||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){if(Object(i)!==i)return;l=!1}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}}(t,i)||function(t,i){if(t){if("string"==typeof t)return e(t,i);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,i):void 0}}(t,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.")}()}function r(e){var i,r;function n(i,r){try{var a=e[i](r),o=a.value,l=o instanceof t;Promise.resolve(l?o.v:o).then(function(t){if(l){var r="return"===i&&o.k?i:"next";if(!o.k||t.done)return n(r,t);t=e[r](t).value}s(!!a.done,t)},function(t){n("throw",t)})}catch(t){s(2,t)}}function s(t,e){2===t?i.reject(e):i.resolve({value:e,done:t}),(i=i.next)?n(i.key,i.arg):r=null}this._invoke=function(t,e){return new Promise(function(s,a){var o={key:t,arg:e,resolve:s,reject:a,next:null};r?r=r.next=o:(i=r=o,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}r.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},r.prototype.next=function(t){return this._invoke("next",t)},r.prototype.throw=function(t){return this._invoke("throw",t)},r.prototype.return=function(t){return this._invoke("return",t)};var n=Object.entries,s=Object.keys,a=Object.setPrototypeOf,o=Object.isFrozen,l=Object.getPrototypeOf,u=Object.getOwnPropertyDescriptor,h=Object.freeze,c=Object.seal,v=Object.create,d="undefined"!=typeof Reflect&&Reflect,f=d.apply,p=d.construct;h||(h=function(t){return t}),c||(c=function(t){return t}),f||(f=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)}),p||(p=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 g=U([].forEach),m=U([].lastIndexOf),_=U([].pop),y=U([].push),b=U([].slice),w=U([].splice),x=Array.isArray,S=H(Set),k=U(Set.prototype.add),E=U(Set.prototype.has),A=U("".toLowerCase),T=U("".toString),F=U("".match),O=U("".replace),P=U("".indexOf),C=U("".trim),R=U((0).toString),M=U(Boolean.prototype.toString),I="undefined"==typeof BigInt?null:U(BigInt.prototype.toString),D="undefined"==typeof Symbol?null:U(Symbol.prototype.toString),j=U({}.hasOwnProperty),L=U({}.toString),N=/t/.test,z=function(t,e){return t instanceof RegExp&&(t.lastIndex=0),f(N,t,[e])},B=H(TypeError);function U(t){return function(e){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return f(t,e,r)}}function H(t){return function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return p(t,i)}}function q(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:A;if(a&&a(t,null),!x(e))return t;for(var r=e.length;r--;){var n=e[r];if("string"==typeof n){var s=i(n);s!==n&&(o(e)||(e[r]=s),n=s)}t[n]=!0}return t}function V(t){for(var e=0;t.length>e;e++)j(t,e)||(t[e]=null);return t}function W(t){var e=v(null);for(var r of n(t)){var s=i(r,2),a=s[0],o=s[1];j(t,a)&&(e[a]=x(o)?V(o):o&&"object"==typeof o&&o.constructor===Object?W(o):o)}return e}function G(t){for(var e=v(null),i=s(t),r=i.length;r--;)e[i[r]]=t[i[r]];return e}function K(t,e){for(;null!==t;){var i=u(t,e);if(i){if(i.get)return U(i.get);if("function"==typeof i.value)return U(i.value)}t=l(t)}return function(){return null}}var J=h(["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"]),X=h(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Y=h(["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"]),Z=h(["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=h(["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"]),tt=h(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),et=h(["#text"]),it=h(["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"]),rt=h(["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","pointer-events","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","vector-effect","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"]),nt=h(["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"]),st=h(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),at=c(/{{[\w\W]*|^[\w\W]*}}/g),ot=c(/<%[\w\W]*|^[\w\W]*%>/g),lt=c(/\${[\w\W]*/g),ut=c(/{{|}}|\${|<%|%>|&lt;%|%&gt;/),ht=c(/^data-[\-\w.\u00B7-\uFFFF]+$/),ct=c(/^aria-[\-\w]+$/),vt=c(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dt=c(/^(?:\w+script|data):/i),ft=c(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pt=c(/^html$/i),gt=c(/^[a-z][.\w]*(-[.\w]+)+$/i),mt=c(/<[/\w!]/g),_t=c(/<[/\w]/g),yt=c(/<\/no(script|embed|frames)/i),bt=c(/\/>/i),wt=c(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),xt=c(/^[\r\n\t ]+/),St=h(q({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),kt=function(){return"undefined"==typeof window?null:window},Et=function(t,e,i,r){return j(t,e)&&x(t[e])?q(r.base?G(r.base):{},t[e],r.transform):i},At=function(t,e,i){var r=j(t,e)?t[e]:void 0;return r&&"object"==typeof r?W(r):i};return function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kt(),i=e=>t(e);if(i.version="3.4.18",i.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return i.isSupported=!1,i;var r,s=e.document,a=s,o=a.currentScript,d=e.HTMLTemplateElement,f=e.Node,p=e.NodeFilter,N=e.DOMParser,H=e.trustedTypes,V=e.Element.prototype,Tt=K(V,"cloneNode"),Ft=K(V,"remove"),Ot=K(V,"removeAttributeNode"),Pt=K(V,"nextSibling"),Ct=K(V,"childNodes"),Rt=K(V,"parentNode"),$t=K(V,"shadowRoot"),Mt=K(V,"attributes"),It=f&&f.prototype?K(f.prototype,"nodeType"):null,Dt=f&&f.prototype?K(f.prototype,"nodeName"):null,jt=f&&f.prototype?K(f.prototype,"ownerDocument"):null,Lt=function(t){return It?It(t):t.nodeType},Nt=function(t){return Dt?Dt(t):t.nodeName},zt=function(t){for(;null!==t;){var e=u(t,"namespaceURI");if(e)return e.get?U(e.get):null;t=l(t)}return null}(V),Bt=function(t){return zt?zt(t):t.namespaceURI};if("function"==typeof d){var Ut=s.createElement("template");Ut.content&&Ut.content.ownerDocument&&(s=Ut.content.ownerDocument)}var Ht,qt="",Vt=!1,Wt=0,Gt=function(){if(Wt>0)throw B('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.')},Kt=function(t){Gt(),Wt++;try{return r.createHTML(t)}finally{Wt--}},Jt=function(t){return r&&Re?Kt(t):t},Xt=s.implementation,Yt=s.createNodeIterator,Zt=s.createDocumentFragment,Qt=s.getElementsByTagName,te=a.importNode,ee={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof n&&"function"==typeof Rt&&Xt&&void 0!==Xt.createHTMLDocument;var ie=at,re=ot,ne=lt,se=ht,ae=ct,oe=dt,le=ft,ue=gt,he=vt,ce=null,ve=q({},[...J,...X,...Y,...Q,...et]),de=null,fe=q({},[...it,...rt,...nt,...st]),pe=null,ge=null,me=null,_e=Object.seal(v(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ye=!0,be=!0,we=!1,xe=!0,Se=!1,ke=!0,Ee=!1,Ae=!1,Te=null,Fe=null,Oe=!1,Pe=!1,Ce=!1,Re=!1,$e=!0,Me=!1,Ie="user-content-",De=!0,je=!1,Le=null,Ne=!1,ze=null,Be=q({},["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"]),Ue=null,He=q({},["audio","video","img","source","image","track"]),qe=null,Ve=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),We="http://www.w3.org/1998/Math/MathML",Ge="http://www.w3.org/2000/svg",Ke="http://www.w3.org/1999/xhtml",Je=Ke,Xe=!1,Ye=null,Ze=q({},[We,Ge,Ke],T),Qe=h(q({},["mi","mo","mn","ms","mtext"])),ti=null,ei=h(q({},["annotation-xml"])),ii=null,ri=h(v(null)),ni=q({},["title","style","font","a","script"]),si=null,ai=["application/xhtml+xml","text/html"],oi=null,li=null,ui=s.createElement("form"),hi=function(t){return t instanceof RegExp||t instanceof Function},ci=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t&&"object"==typeof t||(t={}),t=W(t),si=-1===ai.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,ce=Et(t,"ALLOWED_TAGS",ve,{transform:oi="application/xhtml+xml"===si?T:A}),de=Et(t,"ALLOWED_ATTR",fe,{transform:oi}),Ye=Et(t,"ALLOWED_NAMESPACES",Ze,{transform:T}),qe=Et(t,"ADD_URI_SAFE_ATTR",Ve,{transform:oi,base:Ve}),Ue=Et(t,"ADD_DATA_URI_TAGS",He,{transform:oi,base:He}),ze=Et(t,"FORBID_CONTENTS",Be,{transform:oi}),ge=Et(t,"FORBID_TAGS",v(null),{transform:oi}),me=Et(t,"FORBID_ATTR",v(null),{transform:oi}),Ne=!!j(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?W(t.USE_PROFILES):t.USE_PROFILES),ye=!1!==t.ALLOW_ARIA_ATTR,be=!1!==t.ALLOW_DATA_ATTR,we=t.ALLOW_UNKNOWN_PROTOCOLS||!1,xe=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Se=t.SAFE_FOR_TEMPLATES||!1,ke=!1!==t.SAFE_FOR_XML,Ee=t.WHOLE_DOCUMENT||!1,Pe=t.RETURN_DOM||!1,Ce=t.RETURN_DOM_FRAGMENT||!1,Re=t.RETURN_TRUSTED_TYPE||!1,Oe=t.FORCE_BODY||!1,$e=!1!==t.SANITIZE_DOM,Me=t.SANITIZE_NAMED_PROPS||!1,De=!1!==t.KEEP_CONTENT,je=t.IN_PLACE||!1,he=function(t){if(!t)return!1;try{return z(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:vt,Je="string"==typeof t.NAMESPACE?t.NAMESPACE:Ke,ti=At(t,"MATHML_TEXT_INTEGRATION_POINTS",Qe),ii=At(t,"HTML_INTEGRATION_POINTS",ei);var e=At(t,"CUSTOM_ELEMENT_HANDLING",ri);if(pe=v(null),j(e,"tagNameCheck")&&hi(e.tagNameCheck)&&(pe.tagNameCheck=e.tagNameCheck),j(e,"attributeNameCheck")&&hi(e.attributeNameCheck)&&(pe.attributeNameCheck=e.attributeNameCheck),j(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(pe.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),c(pe),Se&&(be=!1),Ce&&(Pe=!0),Ne&&((j(t,"ALLOWED_TAGS")||j(t,"ALLOWED_ATTR"))&&"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together."),ce=q({},et),de=v(null),!0===Ne.html&&(q(ce,J),q(de,it)),!0===Ne.svg&&(q(ce,X),q(de,rt),q(de,st)),!0===Ne.svgFilters&&(q(ce,Y),q(de,rt),q(de,st)),!0===Ne.mathMl&&(q(ce,Q),q(de,nt),q(de,st))),_e.tagCheck=null,_e.attributeCheck=null,j(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?_e.tagCheck=t.ADD_TAGS:x(t.ADD_TAGS)&&(ce===ve&&(ce=G(ce)),q(ce,t.ADD_TAGS,oi))),j(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?_e.attributeCheck=t.ADD_ATTR:x(t.ADD_ATTR)&&(de===fe&&(de=G(de)),q(de,t.ADD_ATTR,oi))),j(t,"ADD_FORBID_CONTENTS")&&x(t.ADD_FORBID_CONTENTS)&&(ze===Be&&(ze=G(ze)),q(ze,t.ADD_FORBID_CONTENTS,oi)),De&&(ce["#text"]=!0),Ee&&q(ce,["html","head","body"]),ce.table&&(ce.tbody=!0,delete ge.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw B('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw B('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');var i=r;r=t.TRUSTED_TYPES_POLICY;try{qt=Kt("")}catch(t){throw r=i,t}}else null===t.TRUSTED_TYPES_POLICY?(r=void 0,qt=""):(void 0===r&&(Vt||(Ht=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}}(H,o),Vt=!0),r=Ht),r&&"string"==typeof qt&&(qt=Kt("")));li=h(t)},vi=q({},[...X,...Y,...Z]),di=q({},[...Q,...tt]),fi=function(t){y(i.removed,{element:t});try{Rt(t).removeChild(t)}catch(e){if(Ft(t),!Rt(t))throw B("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},pi=function(t,e,i){try{Ot(t,e)}catch(e){try{t.removeAttribute(i)}catch(t){}}},gi=function(t){bi(t);var e=Ct(t);e&&g(b(e),t=>{try{Ft(t)}catch(t){}}),1===Lt(t)&&_i(t,!1)},mi=function(t,e,r){if(!r)try{r=e.getAttributeNode(t)}catch(t){r=null}if(y(i.removed,{attribute:r||null,from:e}),r)pi(e,r,t);else try{e.removeAttribute(t)}catch(t){}if("is"===t)if(Pe||Ce)try{fi(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},_i=function(t,e){var i=Mt(t);if(i)for(var r=i.length-1;r>=0;--r){var n=i[r],s=n&&n.name;"string"!=typeof s||e&&de[oi(s)]||pi(t,n,s)}},yi=function(t,e){for(var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[t];r.length>0;){var n=r.pop();if(!1!==e(n)){if(i&&1===Lt(n)){var s=$t(n);Ci(s)&&r.push(s)}var a=Ct(n);if(a)for(var o=a.length-1;o>=0;--o)r.push(a[o])}}},bi=function(t){yi(t,t=>{1===Lt(t)&&_i(t,!0)})},wi=function(t){var e=[];return yi(t,t=>{e.push(t)},!0),e},xi=function(t,e){var r=!1;return g(i.removed,e=>{e.element&&(r=r||e.element===t,bi(e.element))}),function(t,e){var i=S();g(wi(t),t=>{1===Lt(t)&&k(i,t)}),g(e,t=>{1!==Lt(t)||E(i,t)||_i(t,!0)})}(t,e),r},Si=function(t,e){return!!ke&&("patchsrc"===t||"for"===t&&"label"!==e&&"output"!==e)},ki=function(t){var e=null,i=null;if(Oe)t="<remove></remove>"+t;else{var n=F(t,xt);i=n&&n[0]}"application/xhtml+xml"===si&&Je===Ke&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var a=r?Kt(t):t;if(Je===Ke)try{e=(new N).parseFromString(a,si)}catch(t){}if(!e||!e.documentElement){e=Xt.createDocument(Je,"template",null);try{e.documentElement.innerHTML=Xe?qt:a}catch(t){}}var o=e.body||e.documentElement;return t&&i&&o.insertBefore(s.createTextNode(i),o.childNodes[0]||null),Je===Ke?Qt.call(e,Ee?"html":"body")[0]:Ee?e.documentElement:o},Ei=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=jt?jt(t):t.ownerDocument;return Yt.call(i||t,t,(e?0:p.SHOW_ELEMENT)|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Ai=function(t){return t=O(t,ie," "),t=O(t,re," "),O(t,ne," ")},Ti=function(t){var e;Fi(t);var i=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");i&&g(i,t=>{Ci(t.content)&&Ti(t.content)})},Fi=function(t){t.normalize();for(var e=Ei(t,!0),i=e.nextNode();i;)i.data=Ai(i.data),i=e.nextNode()},Oi=function(t){var e=Dt?Dt(t):null;return"string"==typeof e&&"form"===oi(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==Mt(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.removeAttributeNode||"function"!=typeof t.getAttributeNode||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==It(t)||t.childNodes!==Ct(t))},Pi=function(t){if(!It||"object"!=typeof t||null===t)return null;try{var e=It(t);return"number"==typeof e?e:null}catch(t){return null}},Ci=function(t){return 11===Pi(t)},Ri=function(t){return null!==Pi(t)};function $i(t,e,r){0!==t.length&&g(t,t=>{t.call(i,e,r,li)})}var Mi=function(t,e){if(t instanceof RegExp)return z(t,e);if(t instanceof Function){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;i>n;n++)r[n-2]=arguments[n];return Boolean(t(e,...r))}return!1},Ii=function(t,e,i,r){return 0===t.length?e:e===i||e===r?G(e):e},Di=function(t,e){return t!==e&&null===Rt(t)&&(je&&bi(t),!0)},ji=function(t,e){if(Le&&k(Le,t),$i(ee.beforeSanitizeElements,t,null),Di(t,e))return!0;if(Oi(t))return fi(t),!0;var r=oi(Nt(t)),n=Lt(t);if(ce=Ii(ee.uponSanitizeElement,ce,ve,Te),$i(ee.uponSanitizeElement,t,{tagName:r,allowedTags:ce}),Di(t,e))return!0;if(function(t,e,i){return!!(ke&&1===i&&t.hasChildNodes()&&!Ri(t.firstElementChild)&&z(mt,t.textContent)&&z(mt,t.innerHTML))||!!(ke&&St[e]&&1===i&&Bt(t)===Ke&&(Ri(t.firstElementChild)||"string"==typeof t.textContent&&z(mt,t.textContent)))||7===i||!(!ke||8!==i||!z(_t,t.data))}(t,r,n))return fi(t),!0;if(ge[r]||!(_e.tagCheck instanceof Function&&_e.tagCheck(r))&&!ce[r]){var s=function(t,e,i){if(!ge[e]&&zi(e)&&Mi(pe.tagNameCheck,e))return!1;if(De&&!ze[e]&&!ze[A(e)]){var r=Rt(t),n=Ct(t);if(n&&r)for(var s=n.length-1;s>=0;--s){var a=t===i?Tt(n[s],!0):n[s];r.insertBefore(a,Pt(t))}}return fi(t),!0}(t,r,e);return!(!1!==s||($i(ee.afterSanitizeElements,t,null),!Di(t,e)))||s}if(1===n&&!function(t){var e=Bt(t),i=A(Nt(t)),r=Rt(t),n=Je,s="template";return r&&1===Lt(r)&&(n=Bt(r),s=A(Nt(r))),!!Ye[e]&&(e===Ge?function(t,e,i){return e===Ke?"svg"===t:e===We?"svg"===t&&("annotation-xml"===i||ti[i]):Boolean(vi[t])}(i,n,s):e===We?function(t,e,i){return e===Ke?"math"===t:e===Ge?"math"===t&&ii[i]:Boolean(di[t])}(i,n,s):e===Ke?function(t,e,i){return!(e===Ge&&!ii[i])&&!(e===We&&!ti[i])&&!di[t]&&(ni[t]||!vi[t])}(i,n,s):"application/xhtml+xml"===si)}(t))return fi(t),!0;if(("noscript"===r||"noembed"===r||"noframes"===r)&&z(yt,t.innerHTML))return fi(t),!0;if(Se&&3===n){var a=t.textContent,o=Ai(a);a!==o&&(y(i.removed,{element:t.cloneNode()}),t.textContent=o)}return $i(ee.afterSanitizeElements,t,null),Di(t,e)},Li=function(t,e,i){if(me[e])return!1;if(Si(e,t))return!1;if($e&&("id"===e||"name"===e)&&(i in s||i in ui))return!1;var r=de[e]||_e.attributeCheck instanceof Function&&_e.attributeCheck(e,t);if(be&&z(se,e))return!0;if(ye&&z(ae,e))return!0;if(!r)return zi(t)&&Mi(pe.tagNameCheck,t)&&Mi(pe.attributeNameCheck,e,t)||"is"===e&&pe.allowCustomizedBuiltInElements&&Mi(pe.tagNameCheck,i);if(qe[e])return!0;var n=O(i,le,"");return!(!z(he,n)&&("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==P(i,"data:")||!Ue[t])&&(!we||z(oe,n))&&i)},Ni=q({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),zi=function(t){return!Ni[A(t)]&&z(ue,t)},Bi=function(t,e,i,n){if(r&&"object"==typeof H&&"function"==typeof H.getAttributeType&&!i)switch(H.getAttributeType(t,e)){case"TrustedHTML":return Kt(n);case"TrustedScriptURL":return function(t){Gt(),Wt++;try{return r.createScriptURL(t)}finally{Wt--}}(n)}return n},Ui=function(t,e,i,r){try{return i?t.setAttributeNS(i,e,r):t.setAttribute(e,r),!Oi(t)||(fi(t),!1)}catch(i){return mi(e,t),!1}},Hi=function(t,e){return!(!ke||!z(wt,e))||"attributename"===A(t)&&-1!==P(e,"href")},qi=function(t,e){ji(t,e),function(t,e){if($i(ee.beforeSanitizeAttributes,t,null),!Di(t,e)){var r=t.attributes;if(r&&!Oi(t)){for(var n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:de=Ii(ee.uponSanitizeAttribute,de,fe,Fe),forceKeepAttr:void 0},s=r.length,a=oi(Nt(t));s--;){var o=r[s],l=o.name,u=o.namespaceURI,h=o.value,c=oi(l),v=h,d="value"===l?v:C(v),f=!1;n.attrName=c,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,$i(ee.uponSanitizeAttribute,t,n),d=n.attrValue,!Me||"id"!==c&&"name"!==c||0===P(d,Ie)||(mi(l,t,o),d=Ie+d,f=!0),Hi(l,d)?mi(l,t,o):n.forceKeepAttr||(!n.keepAttr||!xe&&z(bt,d)?mi(l,t,o):(Se&&(d=Ai(d)),Li(a,c,d)?(d=Bi(a,c,u,d))!==v&&Ui(t,l,u,d)&&f&&_(i.removed):mi(l,t,o)))}$i(ee.afterSanitizeAttributes,t,null),Di(t,e)}}}(t,e),Ci(t.content)&&Vi(t.content)},Vi=function(t){var e=null,i=Ei(t);for($i(ee.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if($i(ee.uponSanitizeShadowNode,e,null),qi(e,t),1===Lt(e)){var r=$t(e);Ci(r)&&(Wi(r),Vi(r))}Se&&Fi(t),$i(ee.afterSanitizeShadowDOM,t,null)},Wi=function(t){for(var e=[{node:t,shadow:null}];e.length>0;){var i=e.pop();if(i.shadow)Vi(i.shadow);else{var r=i.node,n=1===Lt(r),s=Ct(r);if(s)for(var a=s.length-1;a>=0;--a)e.push({node:s[a],shadow:null});if(n){var o=Dt?Dt(r):null;if("string"==typeof o&&"template"===oi(o)){var l=r.content;Ci(l)&&e.push({node:l,shadow:null})}}if(n){var u=$t(r);Ci(u)&&e.push({node:null,shadow:u},{node:u,shadow:null})}}}};return i.sanitize=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,n=null,s=null,o=null;if((Xe=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Ri(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return R(t);case"boolean":return M(t);case"bigint":return I?I(t):"0";case"symbol":return D?D(t):"Symbol()";case"undefined":default:return L(t);case"function":case"object":if(null===t)return L(t);var e=t,i=K(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:L(r)}return L(t)}}(t)))throw B("dirty is not a string, aborting");if(!i.isSupported)return t;Ae?(ce=Te,de=Fe):ci(e),i.removed=[];var l=je&&"string"!=typeof t&&Ri(t),u=[],h=Le;if(l){ke&&yi(t,t=>{var e=Lt(t);if(7===e||8===e&&z(_t,t.data)){try{Ft(t)}catch(t){}return!1}if(1===e){var i=t,r=oi(Nt(t));try{i.hasAttribute&&i.hasAttribute("patchsrc")&&i.removeAttribute("patchsrc"),i.hasAttribute&&i.hasAttribute("for")&&Si("for",r)&&i.removeAttribute("for")}catch(t){}}return!0});var c=Nt(t);if("string"==typeof c){var v=oi(c);if(!ce[v]||ge[v])throw gi(t),B("root node is forbidden and cannot be sanitized in-place")}if(Oi(t))throw gi(t),B("root node is clobbered and cannot be sanitized in-place");u=wi(t),Le=S()}else if(Ri(t))1===(n=(r=ki("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===n.nodeName||"HTML"===n.nodeName?r=n:r.appendChild(n),Wi(r);else{if(!Pe&&!Se&&!Ee&&-1===t.indexOf("<"))return Jt(t);if(!(r=ki(t)))return Pe?null:Re?qt:""}r&&Oe&&fi(r.firstChild);var d=l?t:r;try{l&&Wi(t);for(var f=Ei(d);s=f.nextNode();)qi(s,d);l&&function(t,e){for(var i,r=Le,n=null,s=()=>(n||(n=S(),g(e,t=>{k(n,t)})),n),a=function(){var e=wi(t),i=[t],n=!1;if(g(e,t=>{11===Lt(t)?y(i,t):n||E(r,t)||(n=E(s(),t))}),!n)return{v:void 0};if(o>=8)throw B("the tree kept changing during in-place sanitization; refusing to return it");g(i,(e,i)=>{!function(t,e,i,r){for(var n,s=Ei(t);n=s.nextNode();)E(r,n)&&!E(Le,n)&&(e&&$i(ee.uponSanitizeShadowNode,n,null),qi(n,i))}(e,i>0,t,s())})},o=0;;o++)if(i=a())return i.v}(t,u)}catch(e){throw l&&(gi(t),xi(t,u)),e}finally{Le=h}if(l){if(xi(t,u))throw B("a node selected for removal could not be safely returned; refusing to sanitize in place");return Se&&Ti(t),t}if(Pe){if(Se&&Ti(r),Ce)for(o=Zt.call(r.ownerDocument);r.firstChild;)o.appendChild(r.firstChild);else o=r;return(de.shadowroot||de.shadowrootmode)&&(o=te.call(a,o,!0)),o}var p=()=>Ee?r.outerHTML:r.innerHTML,m=p();return Se&&z(ut,m)&&(Fi(r),m=p()),Ee&&ce["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&z(pt,r.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+m),Jt(m)},i.setConfig=function(){ci(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Ae=!0,Te=ce,Fe=de},i.clearConfig=function(){li=null,Ae=!1,Te=null,Fe=null,r=Ht,qt=""},i.isValidAttribute=function(t,e,i){li||ci({});var r=oi(t),n=oi(e);return("string"!=typeof i||!(Hi(e,i)||!xe&&z(bt,i)))&&Li(r,n,i)},i.addHook=function(t,e){"function"==typeof e&&j(ee,t)&&y(ee[t],e)},i.removeHook=function(t,e){if(j(ee,t)){if(void 0!==e){var i=m(ee[t],e);return-1===i?void 0:w(ee[t],i,1)[0]}return _(ee[t])}},i.removeHooks=function(t){j(ee,t)&&(ee[t]=[])},i.removeAllHooks=function(){ee={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}()}(),qa="Refusing to render web experiment since the viewer is a likely bot",Va={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Wa={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>ys(e,t),not_regex:(t,e)=>!ys(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},Ga=class t{get Yr(){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.vm("retrieved web experiments from the server"),i.fm=/* @__PURE__ */new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.fm&&(t.vm("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.fm)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.pm(e,n)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.gm(a,i._instance)&&i.ym(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.vm(qa);else if(!this.Yr.disable_web_experiments){if(_(this.fm))return this.fm=/* @__PURE__ */new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.vm("applying feature flags",e),e.forEach(t=>{var e;if(this.fm&&null!=(e=this.fm)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.fm)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.pm(n,r)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=En(null==e?void 0:e.search,"__experiment_id"),r=En(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.vm("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.bm(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Yr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Yr.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.Yr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}bm(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.vm("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.ym(n[0].name,i,n[0].variants[i].transforms))}pm(e,i){var r=e.variants[i];t._m(r,this._instance)?this.ym(e.name,i,r.transforms):t.vm("skipping variant "+i+" of experiment "+e.name+" because this page does not match its url conditions")}static gm(e,i){return!_(e.conditions)&&t._m(e,i)&&t.wm(e)}static _m(e,i){var r;if(_(e.conditions)||_(null==(r=e.conditions)?void 0:r.url))return!0;var n=t.getWindowLocation();if(n){var s,a,o,l=_i(i,n.href);return null==(s=e.conditions)||!s.url||Wa[null!==(a=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return null==un?void 0:un.location}static wm(t){var e;if(_(t.conditions)||_(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!vn)return{};var r,n,s,a=e?[...Ln,...i||[]]:[],o=(r=An(vn.URL,a,zn),n=Nn.concat(t||[]),s={},di(n,function(t){var e=En(r,t);!e&&l.call(jn,t)&&vi(jn[t],function(t){e=e||En(r,t)}),s[t]=e||null}),s);return fi(function(){var t={};return di(Bn,function(e){var i=(t=>{if(vn){try{for(var e=t+"=",i=vn.cookie.split(";").filter(t=>t.length),r=0;i.length>r;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}})(e);t[e]=i||null}),t}(),o)}();if(i.utm_source){var r,n,s,a,o,u,h,c,v=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,d=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,f=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(u=t.conditions)||null==(u=u.utm)?void 0:u.utm_medium)==i.utm_medium,p=null==(h=t.conditions)||null==(h=h.utm)||!h.utm_term||(null==(c=t.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return v&&f&&p&&d}return!1}static vm(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.info("[WebExperiments] "+t,i)}static km(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];hi.warn("[WebExperiments] "+t,i)}static Sm(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.Sm(e)})}ym(i,r,n){this._is_bot()?t.vm(qa):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.vm("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.km("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(_(u)){var h=null!=Ms?Ms:Ms=Ha(),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({},Va,{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({},Va,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.Sm(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.vm("Control variants leave the page unmodified.")}_is_bot(){return cn&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&F(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>F(null==t?void 0:t.brand,e)))return!0}catch(t){}return!!t.webdriver}(cn,this.Yr.custom_blocked_useragents):void 0}},Ka=/* @__PURE__ */ci("[Conversations]"),Ja="Conversations not available yet.",Xa=class{constructor(t){this._instance=t,this.xm=void 0,this._conversationsManager=null,this.$m=!1,this.ie=null,this.Cm=!1,this.Tm=0,this.Mm=null,this.Im=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.Mm=null;else if(this.Em=t.ok,t.ok){var e=t.config.conversations;_(e)?this.Mm=null:(b(e)?this.xm=e:(this.xm=e.enabled,this.ie=e),this.xm||(this.Mm=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Tm++,this.xm=void 0,this.ie=null,this.Em=void 0,this.Cm=!1,this.Mm=null}loadIfEnabled(){if(!(this._conversationsManager||this.$m||this._instance.config.disable_conversations||mi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==pn?void 0:pn.__PosthogExtensions__;if(t&&!f(this.xm)&&this.xm)if(this.ie&&this.ie.token){this.$m=!0;try{var e=t.initConversations;if(e)return this.Am(e),void(this.$m=!1);var i=gn(this._instance);if(!i)return void this.Rm(Ur);var r=this.Tm;i(this._instance,"conversations",e=>{if(r!==this.Tm)return this.$m=!1,void this.loadIfEnabled();e||!t.initConversations?this.Rm("Could not load conversations script",e):this.Am(t.initConversations),this.$m=!1})}catch(t){this.Rm("Error initializing conversations",t),this.$m=!1}}else Ka.error("Conversations enabled but missing token in remote config.")}}Am(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.Cm=!1,Ka.info("Conversations loaded successfully")}catch(t){return void this.Rm("Error completing conversations initialization",t)}this.Im&&this._conversationsManager.setTheme(this.Im),this.Pm()}else Ka.error("Cannot complete initialization: remote config is null")}Pm(){var t=this.Mm;this.Mm=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}Rm(t,e){Ka.error(t,e),this._conversationsManager=null,this.$m=!1,this.Cm=!0}show(){this._conversationsManager?this._conversationsManager.show():Ka.warn("Conversations not loaded yet.")}hide(){"open"===this.Mm&&(this.Mm=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.Mm=null,this._conversationsManager.open()):this.Mm="open"}close(){this._conversationsManager?(this.Mm=null,this._conversationsManager.close()):this.Mm="close"}setTheme(t){var i,r;this.Im=e({},this.Im,t,{dark:e({},null==(i=this.Im)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.xm&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":mi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Em?"remote_config_failed":f(this.xm)?this.Em?"disabled_in_project":"remote_config_pending":this.xm?_(this.ie)||!this.ie.token?"missing_token":null!=pn&&pn.__PosthogExtensions__?this.$m?"initializing":this.Cm?"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):(Ka.warn(Ja),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Ka.warn(Ja),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Ka.warn(Ja),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Ka.warn(Ja),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Ka.warn(Ja),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Ka.warn(Ja),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Ka.warn(Ja),null)})()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}_onIdentityChanged(){var t;null==(t=this._conversationsManager)||t.setIdentity()}_onIdentityCleared(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}};function Ya(){var t="",i="";try{var r,n=null==(r="u">typeof globalThis?globalThis:"u">typeof window?window:void 0)||null==(r=r.navigator)?void 0:r.userAgent;if(n){var s=function(t){for(var e=0;L.length>e;e++){var i=L[e],r=i[1],n=i[0].exec(t),s=n&&(c(r)?r(n,t):r);if(s)return s}return["",""]}(n);t=s[0],i=s[1]}}catch(t){}return function(t,i){var r=function(t){if(t)return{}.hasOwnProperty.call(Ne,t)?Ne[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function Za(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({},Ya(),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 Qa=["debug","log","warn","error","info"],to="console",eo="__posthogHandledLogsRequestError",io=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[eo]=!0,i},ro=t=>!!t&&"object"==typeof t&&!0===t[eo],no=class{get Of(){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(ro)||t.R.error(...i)}})}constructor(t,e){var i;this.ra=t,this.Ff=e,this.name="logs",this.Lf=!1,this.Df=!1,this.Nf=!1,this.R=ci("[logs]"),this.Dc=[],this.jf=[],this.Tv=0,this.qf=!1,this.qi=!1,this.Bf=[],this.zf=[],this.Hf=!1,this.Uf=!1,this.Wf=!1,this.Vf=()=>{var t,e;this.qi||(this.Tv=0,null==(t=this.Gf)||t.onReconnect(),null==(e=this.Jf)||e.onReconnect())},this.Lf=!(null==(i=t.get())||!i.captureConsoleLogs)}get Qf(){return!0}Zf(){}Kf(){if(!this.Wf){try{this.Wv=typeof window>"u"?void 0:window}catch(t){this.Wv=void 0}this.Wv&&(gi(this.Wv,"online",this.Vf),this.Wf=!0)}}Yf(t,e,i,r){this.Kf();var n=Za(this.ra.get(),i);return[new Je(this.Xf(t,e),n,this.Of,()=>this.Ff(),t=>t(),void 0,r),n]}tp(){var t=this.ra.get();if(!this.Gf||this.ep!==t){var e;null==(e=this.Gf)||e.reset(),this.ep=t;var i=this.Yf(()=>this.Dc,t=>{this.Dc=t});this.Gf=i[0],this.np=i[1]}return this.Gf}sp(){var t=this.ra.get();if(!this.Jf||this.rp!==t){var e;null==(e=this.Jf)||e.reset(),this.rp=t;var i=this.Yf(()=>this.jf,t=>{this.jf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},to);this.Jf=i[0],this.op=i[1]}return this.Jf}setup(t){if(!this.qi&&!this.qf)return this.qf=!0,this.ia=t,this.R=t.logger.createLogger("[logs]"),Ps(t.kv.initialize(),()=>{this.qi||this.Vv(t)})}Vv(t){var e;this.Kf(),null!=(e=this.ra.get())&&e.captureConsoleLogs&&(this.Lf=!0),(this.Lf||this.ra.remoteConfigWillArrive&&t.kv.get(this.ra.captureHintKey))&&this.lp();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.qi?r.dispose():(this.ma=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.qi||(this.qi=!0,this.ap(),null==(t=this.ma)||t.dispose(),this.ma=void 0,this.ia=void 0,this.Nf=!1,null==(e=this.Wv)||e.removeEventListener("online",this.Vf),null==(i=this.up)||i.call(this),this.up=void 0,null==(r=this.Gf)||r.clearQueue(),null==(n=this.Jf)||n.clearQueue(),null==(s=this.Gf)||s.reset(),null==(a=this.Jf)||a.reset())}onRemoteConfig(t){var e,i;if(!this.qi){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;_(r)?this.cp():(null==(i=this.ia)||i.kv.set(this.ra.captureHintKey,!!r),r?(this.Lf=!0,this.Df||this.lp(),this.loadIfEnabled()):this.cp())}}reset(){var t,e,i,r;this.ap(),null==(t=this.Gf)||t.clearQueue(),this.Dc=[],null==(e=this.Gf)||e.reset(),null==(i=this.Jf)||i.clearQueue(),this.jf=[],null==(r=this.Jf)||r.reset(),this.Tv=0}captureLog(t){!this.qi&&this.ia&&this.tp().captureLog(t)}captureConsoleLog(t){!this.qi&&this.ia&&this.sp().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.qi&&this.ia&&this.sp().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.ap(),null==(t=this.Jf)||t.clearQueue(),this.jf=[]}cp(){this.Lf||this.ap()}lp(){var t,e=this;if(!this.Hf&&null!=(t=this.Wv)&&t.console){var i=Za(this.ra.get()).maxBufferSize,r=!0;this.zf.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.Wv.console[t])}catch(t){return 1}n&&e.zf.push(Pn(e.Wv.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.hp(t,a,i)}catch(t){}return s.apply(e.Wv.console,a)};return a.__rrweb_original__=n,a}))};for(var s of Qa)if(n(s))continue;this.Hf=!0,this.dp=setTimeout(()=>{this.ap()},3e4)}}hp(t,e,i){var r;if(this.Hf&&!this.Uf&&0!==e.length)if(null!=(r=this.ia)&&r.canCapture){if(i>this.Bf.length){this.Uf=!0;try{this.Bf.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Ff()})}finally{this.Uf=!1}}}else this.ap()}ap(){if(this.Bf=[],this.Hf){for(var t of(this.Hf=!1,this.dp&&(clearTimeout(this.dp),this.dp=void 0),this.zf))t();this.zf=[]}}vp(){var t=this.Bf;return this.ap(),t}get logger(){return this.fp||(this.fp={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.fp}flushLogs(t){this.ia&&(t?this.pp(t):(this.Gf&&this.Gf.flush().catch(t=>this.gp(t)),this.Jf&&this.Jf.flush().catch(t=>this.gp(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Gf)?void 0:e.flush().catch(e=>t.gp(e)),n=null==(i=t.Jf)?void 0:i.flush().catch(e=>t.gp(e));yield r,yield n})()}gp(t){ro(t)||this.R.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.qi&&this.Lf&&!this.Df&&!this.Nf){var t=this.Zf();if(t){this.Nf=!0;try{t((t,e)=>{if(this.Nf=!1,!this.qi&&this.Lf)if(t||!e)this.R.error("Could not load logs script",t),this.ap();else{var i=this.vp();this.up=e.initialize(this.ia),this.Df=!0,i.length>0&&e.replay(this.ia,i)}})}catch(t){throw this.Nf=!1,t}}else this.ap()}}Xf(t,e){var i=this.ia;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:e=>e===n.LogsQueue?t():void 0,setPersistedProperty(t,i){t===n.LogsQueue&&e(null!=i?i:[])},Hs:t=>this.Hs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}Hs(t){return new Promise(e=>{if(Sn(this.Tv,3))e({kind:"fatal",error:io(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:io(void 0,"logs request timed out")})},9e4),s=this.Qf;this.ia.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.ia.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.mp(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:io(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})})}})}mp(t,e){(0!==t||e)&&(this.Tv=kn(t,this.Tv,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.")))}pp(t){this.Dc.length>0&&this.yp(t,this.Dc,this.np,this.ia.library.name,t=>{this.Dc=t}),this.jf.length>0&&this.yp(t,this.jf,this.op,to,t=>{this.jf=t})}yp(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=Ve(s,qe(i,this.ia.library.name,this.ia.library.version),r,this.ia.library.version);this.ia.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.ia.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.gp(t))}}},so=class extends no{constructor(t){super({get(){var e;return null==t||null==(e=t.config)?void 0:e.logs},captureHintKey:"$logs_capture_enabled_server_side",get remoteConfigWillArrive(){var e;return!(null!=t._shouldDisableFlags&&t._shouldDisableFlags()&&(null==(e=pn._POSTHOG_REMOTE_CONFIG)||null==(e=e[t.config.token])||!e.config))}},()=>function(t){var e,i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){var r=t.sessionManager.checkAndGetSessionAndWindowId(!0),n=r.windowId,s=r.sessionStartTimestamp,a=r.lastActivityTimestamp;i.sessionId=r.sessionId,i.windowId=n,_(s)||(i.sessionStartTimestamp=s),_(a)||(i.lastActivityTimestamp=a)}if(null!=pn&&null!=(e=pn.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?J(pn.location.href):pn.location.href),t.featureFlags){var o=t.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}(t)),this._instance=t,this.name="logs",this.Kf()}get Qf(){return this._instance.__loaded}Zf(){var t=ci("[logs]"),e=null==pn?void 0:pn.__PosthogExtensions__;if(e){var i=gn(this._instance);if(i)return t=>{i(this._instance,"logs",i=>{var r=e.logs;t(i,null!=r&&r.initializeLogs?{initialize:t=>r.initializeLogs(t),replay:(t,e)=>null==r.replayConsoleBuffer?void 0:r.replayConsoleBuffer(t,e)}:void 0)})};t.error(Ur)}else t.error("PostHog Extensions not found.")}},ao=/* @__PURE__ */ci("[NetworkMetrics]"),oo={"http:":80,"https:":443},lo=/* @__PURE__ */new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),uo=t=>p(t)&&0===t.toLowerCase().indexOf("text/event-stream"),ho=t=>{try{return t()}catch(t){return}},co=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Tr(r))?void 0:i.href)||r}},vo=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=js()-n,d=Tr(i.url);if(d&&"http:"!==d.protocol&&"https:"!==d.protocol)return;var f={url:(null==d?void 0:d.href)||i.url,method:i.method},g=c(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var m=o&&!h?void 0:((t,e)=>t?400>t?void 0:String(t):(null==e?void 0:e.name)||"_OTHER")(h,a),_=e({},e({"http.request.method":b=lo.has(y=f.method)?y:"_OTHER"},"_OTHER"===b&&y!==b?{"http.request.method_original":y}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||oo[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:_})}catch(t){ao.error("Failed to record network metric",t)}var y,b},fo=()=>{},po=(t,e)=>c(null==un?void 0:un.fetch)?Pn(un,"fetch",i=>function(){for(var r=js(),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=co(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=>(uo(ho(()=>{var t;return null==i||null==(t=i.headers)?void 0:t.get("content-type")}))||vo(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw vo(t,d,void 0,r,e,i),i})}catch(t){return ao.error("Failed to observe fetch",t),o}}):fo,go=(t,e)=>{var i,r=null==un||null==(i=un.XMLHttpRequest)?void 0:i.prototype;if(!r)return fo;var n=/* @__PURE__ */new WeakMap,s=Pn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{Ds.has(this)||n.set(this,co(i[0],i[1]))}catch(t){ao.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=Pn(r,"send",i=>function(){var r,s;try{var a=n.get(this);if(a&&e()){var o=js(),l=()=>uo(ho(()=>this.getResponseHeader("content-type"))),u=!1;r=()=>{this.removeEventListener("loadend",r),this.removeEventListener("readystatechange",s),u||l()||vo(t,a,this.status,o,e)},gi(this,"readystatechange",s=()=>{2===this.readyState&&(u=l())}),gi(this,"loadend",r)}}catch(t){ao.error("Failed to observe XHR send",t)}try{for(var h=arguments.length,c=new Array(h),v=0;h>v;v++)c[v]=arguments[v];return i.apply(this,c)}catch(t){throw r&&this.removeEventListener("loadend",r),s&&this.removeEventListener("readystatechange",s),t}});return()=>{s(),a()}},mo=class{constructor(t){this._instance=t,this.R=ci("[metrics]"),this.qi=!1,this.Om=!1,this.gn=()=>{"hidden"===(null==vn?void 0:vn.visibilityState)&&this.flush()}}initialize(){this.onConfigChange(),this.qi||this.Om||null==vn||!vn.addEventListener||(gi(vn,"visibilitychange",this.gn),this.Om=!0)}onConfigChange(){var t;if(!this.qi){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.Fm?this.Fm=(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=po(t,i),n=go(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.Fm&&(this.Fm(),this.Fm=void 0)}}tp(){var t;if(!this.qi){var e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;if(!this.Gf||this.ep!==e){var i;null==(i=this.Gf)||i.reset(),this.ep=e;var r=function(t){var e,i,r,n,s,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==a?void 0:a["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==a?void 0:a["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(s=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==s?s:1e3}}(e);f(null==e?void 0:e.flushIntervalMs)&&(r.flushIntervalMs=6e4),this.Gf=new ri(this.Xf(),r,this.R)}return this.Gf}}count(t,e,i){var r;void 0===e&&(e=1),null==(r=this.tp())||r.count(t,e,i)}gauge(t,e,i){var r;null==(r=this.tp())||r.gauge(t,e,i)}histogram(t,e,i){var r;null==(r=this.tp())||r.histogram(t,e,i)}flush(t){if(!this.Gf)return Promise.resolve();if(t){var e=this.Gf.drainWindow();return e&&this.Go(e,t),Promise.resolve()}return this.Gf.flush().catch(t=>this.R.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Gf)||t.reset()}dispose(){var t,e;this.qi=!0,null==vn||null==vn.removeEventListener||vn.removeEventListener("visibilitychange",this.gn),this.Om=!1,null==(t=this.Fm)||t.call(this),this.Fm=void 0,null==(e=this.Gf)||e.reset()}Xf(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Go:t=>e.Go(t),getLibraryId:()=>Is.LIB_NAME,getLibraryVersion:()=>Is.LIB_VERSION}}Go(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.Lm(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},"hidden"===(null==vn?void 0:vn.visibilityState)&&{preferSyncCompression:!0},{fireCallbackOnDrop:!0,callback(t){var e,i=t.statusCode;s(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:/* @__PURE__ */new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:/* @__PURE__ */new Error("metrics request failed with status "+i)})}}))})}Lm(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}},_o=/* @__PURE__ */new WeakMap,yo=/* @__PURE__ */new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),bo={maxStringLength:2048,truncationSuffix:"..."},wo={maxStringLength:2048,truncationSuffix:"..."};function xo(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function So(t,e){return{}.hasOwnProperty.call(t,e)}function ko(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function Eo(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?ke(r,bo):r).slice(0,e)}}function Ao(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function To(t){return ke(t||"Unknown error",wo).slice(0,2048)}function Fo(t,e){try{return To(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 Oo(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:To(t.value)}))}function Po(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 Co(t,e){return{message:Fo(t,e),type:Po(t,e)}}var Ro=class{constructor(t){this._instance=t,this.Dm=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.Dm){var t=null==vn?void 0:vn.modelContext;if(t&&c(t.registerTool)){var e=_o.get(t);if(e)return e.instances.add(this._instance),void(this.Dm=!0);var i={instances:/* @__PURE__ */new Set([this._instance])},r=t.registerTool,n=this;Pn(t,"registerTool",t=>{var e=t;return function(t){for(var r=t,s=arguments.length,a=new Array(s>1?s-1:0),o=1;s>o;o++)a[o-1]=arguments[o];try{r=n.Nm(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(_o.set(t,i),this.Dm=!0)}}}Nm(t,i){if(!t||!c(t.execute))return t;var r=t.execute,n=this,s=function(t,i){var r={intent:!1,model:!1},n=t.inputSchema;if(!function(t){return!!f(t)||v(t)&&Object.keys(t).every(t=>yo.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:ko(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>So(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:ko(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:ko(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=xo(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?Eo(t.context,2048,!0):void 0,n=i.model?Eo(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&&So(r,"context"),s=i.model&&So(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.jm(i,a,s,{error:t,errorResult:!1},f),t}if((d=c)&&"function"==typeof d.then)return Promise.resolve(c).then(t=>{var e=Ao(t)?{error:t,errorResult:!0}:void 0;return n.jm(i,a,s,e,f),t},t=>{throw n.jm(i,a,s,{error:t,errorResult:!1},f),t});var g=Ao(c)?{error:c,errorResult:!0}:void 0;return n.jm(i,a,s,g,f),c}}),a}jm(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=xo(l.config.capture_webmcp);if(h){n&&!a&&(a=Co(n.error,n.errorResult));try{l.capture("$mcp_tool_call",e({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{},h.intent&&s.intent?{$mcp_intent:s.intent,$mcp_intent_source:"context_parameter"}:{},h.model&&s.model?{$mcp_llm_model:s.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:r})}catch(t){continue}if(n&&a&&l.exceptions&&null!=(u=l.exceptionObserver)&&u.isEnabled)try{var c={$exception_list:Oo(l.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==dn?void 0:dn.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}},$o={featureFlags:Ia,sessionRecording:rs,autocapture:Nr,historyAutocapture:Cn,heatmaps:as,deadClicksAutocapture:yn,webVitalsAutocapture:Gn,exceptionObserver:wn,exceptions:Ua,productTours:us,siteApps:vs,surveys:Ns,tracingHeaders:$n,toolbar:Hs,experiments:Ga,conversations:Xa,logs:so,metrics:mo,webMCP:Ro},Mo={featureFlags:Ia},Io={sessionRecording:rs},Do={autocapture:Nr,historyAutocapture:Cn,heatmaps:as,deadClicksAutocapture:yn,webVitalsAutocapture:Gn},jo={exceptionObserver:wn,exceptions:Ua},Lo={productTours:us,featureFlags:Ia},No={siteApps:vs},zo={surveys:Ns,featureFlags:Ia},Bo={tracingHeaders:$n},Uo={toolbar:Hs},Ho={experiments:Ga,featureFlags:Ia},qo={conversations:Xa},Vo={logs:so},Wo={metrics:mo},Go={webMCP:Ro};export{$o as AllExtensions,Do as AnalyticsExtensions,qo as ConversationsExtensions,jo as ErrorTrackingExtensions,Ho as ExperimentsExtensions,Mo as FeatureFlagsExtensions,Vo as LogsExtensions,Wo as MetricsExtensions,Lo as ProductToursExtensions,Io as SessionReplayExtensions,No as SiteAppsExtensions,zo as SurveysExtensions,Uo as ToolbarExtensions,Bo as TracingExtensions,Go as WebMCPExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map