posthog-js 1.444.4 → 1.445.0

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 (40) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/array.full.es5.js +1 -1
  3. package/dist/array.full.js +1 -1
  4. package/dist/array.full.no-external.js +1 -1
  5. package/dist/array.js +1 -1
  6. package/dist/array.no-external.js +1 -1
  7. package/dist/customizations.full.js +1 -1
  8. package/dist/customizations.js +1 -1
  9. package/dist/default-extensions.js +1 -1
  10. package/dist/extension-bundles.js +1 -1
  11. package/dist/integrity.json +52 -0
  12. package/dist/lazy-recorder.js +1 -1
  13. package/dist/loader-bootstrap.js +1 -1
  14. package/dist/loader-bootstrap.js.map +1 -1
  15. package/dist/loader.js +1 -1
  16. package/dist/loader.js.map +1 -1
  17. package/dist/main.js +1 -1
  18. package/dist/module.full.cjs +1 -1
  19. package/dist/module.full.js +1 -1
  20. package/dist/module.full.no-external.cjs +1 -1
  21. package/dist/module.full.no-external.js +1 -1
  22. package/dist/module.js +1 -1
  23. package/dist/module.mjs +1 -1
  24. package/dist/module.no-external.cjs +1 -1
  25. package/dist/module.no-external.js +1 -1
  26. package/dist/module.slim.js +1 -1
  27. package/dist/module.slim.no-external.js +1 -1
  28. package/dist/posthog-recorder.js +1 -1
  29. package/dist/src/utils/loader-script.d.ts +1 -0
  30. package/dist/surveys-preview.js +1 -1
  31. package/dist/surveys.js +1 -1
  32. package/lib/package.json +2 -2
  33. package/lib/src/entrypoints/loader-bootstrap.js +9 -0
  34. package/lib/src/entrypoints/loader-bootstrap.js.map +1 -1
  35. package/lib/src/entrypoints/loader.js +8 -0
  36. package/lib/src/entrypoints/loader.js.map +1 -1
  37. package/lib/src/utils/loader-script.d.ts +1 -0
  38. package/lib/src/utils/loader-script.js +10 -0
  39. package/lib/src/utils/loader-script.js.map +1 -1
  40. package/package.json +6 -6
@@ -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=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function s(t,e){return-1!==t.indexOf(e)}var a=function(t){return t.trim()},o=Object.prototype,l=o.hasOwnProperty,u=o.toString,h=Array.isArray||function(t){return"[object Array]"===u.call(t)},c=t=>"function"==typeof t,v=t=>t===Object(t)&&!h(t),d=t=>{if(v(t)){for(var e in t)if(l.call(t,e))return!1;return!0}return!1},f=t=>void 0===t,p=t=>"[object String]"==u.call(t),g=t=>p(t)&&0===t.trim().length,m=t=>null===t,y=t=>f(t)||m(t),b=t=>"[object Number]"==u.call(t)&&t==t,_=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function x(t,e){return{}.toString.call(t)==="[object "+e+"]"}function S(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return E(t,Error)}}function k(t){return"u">typeof Event&&E(t,Event)}function E(t,e){try{return t instanceof e}catch(t){return!1}}var T=["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"],A=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=A.get(i);if(void 0!==r)return r;var n=t.toLowerCase(),s=T.concat(e).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>A.size||A.clear(),A.set(i,s),s};function P(t,e,i,r,n){return e>i&&(r.warn("min cannot be greater than max."),e=i),b(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),P(null!=n?n:i,e,i,r))}var R=class{constructor(t){this.C={},this.I=t.I,this.R=P(t.bucketSize,0,100,t.A),this.O=P(t.refillRate,0,this.R,t.A),this.$=P(t.refillInterval,0,864e5,t.A)}F(t,e){var i=Math.floor((e-t.lastAccess)/this.$);i>0&&(t.tokens=Math.min(t.tokens+i*this.O,this.R),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.R,lastAccess:i},0===n.tokens||(n.tokens--,0===n.tokens&&(null==(e=this.I)||e.call(this,t)),0===n.tokens)}stop(){this.C={}}},O="Mobile",C="Android",M="Nintendo",I="PlayStation",j="Xbox",D="Windows";O.toLowerCase(),"Tablet".toLowerCase(),new RegExp(j,"i");var L=new RegExp("BlackBerry|PlayBook|BB10","i"),N={"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"},z=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[j,t&&t[1]||""]],[new RegExp(M,"i"),[M,""]],[new RegExp(I,"i"),[I,""]],[L,["BlackBerry",""]],[new RegExp(D,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return["Windows Phone",""];if(new RegExp(O).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=N[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[D,r]}return[D,""]}],[/((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]}],[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",""]]],U="[Truncated]",B="[Unserializable]";function H(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 q(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=B}Object.defineProperty(t,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;var V,W,G,K,J=3e5,X=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,J);if(!e)return this.ts=i,void(this.es=i+r);this.es=Math.max(this.es,Math.min(i+r,this.ts+J))}}else this.reset()}remainingMs(){var t=Date.now();if(this.ts-5e3>t)return this.reset(),0;var e=Math.min(J,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 Y(t){return t?t.split("#")[0]:t}function Z(t){try{return t()}catch(t){return}}function Q(t,e){var i=setTimeout(t,e);return null!=i&&i.unref&&(null==i||i.unref()),i}function tt(t,e,i){return et.apply(this,arguments)}function et(){return(et=r(function*(t,e,i){var r;try{return yield Promise.race([t,new Promise((t,n)=>{r=Q(()=>{try{null==i||i(),t()}catch(t){n(t)}},e)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function it(t){var i=globalThis._posthogChunkIds,r=globalThis._debugIds;if(i||r){var n=i?Object.keys(i):[],s=r?Object.keys(r):[];if(K&&rt(i,n,W)&&rt(r,s,G))return K;W=i?e({},i):void 0,G=r?e({},r):void 0,K={},null!=V||(V={});var a=(e,i)=>{for(var r of e){var n,s=i[r];if(s){var a=null==(n=V)?void 0:n[r];if(a)K[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){K[h]=s,V[r]=h;break}}}}};return r&&a(s,r),i&&a(n,i),K}}function rt(t,e,i){return t&&i?e.length===Object.keys(i).length&&e.every(e=>t[e]===i[e]):t===i}var nt=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:it(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=new Set,u=[],h={},c=function(t,i,r){void 0===r&&(r=0);var c=v(i,r),d=c.apply;if(c.apply=e=>{u.push(t);try{return d(e)}finally{u.pop()}},r>4||r>0&&-1!==u.indexOf(t))return n.coerceFallback(c);var f="object"==typeof t&&null!==t||"function"==typeof t;if(!(0===r&&s>=50||f&&l.has(t))){f&&l.add(t),0===r&&s++;var p,g,m=n.getAggregateErrors(t);o||(o=!!m);try{if(!(p=n.applyCoercers(t,c)))throw h}catch(t){if(t===h)return void(0===r&&s--);if(!o)throw t;p=n.coerceFallback(c)}if(!m||s>=50)return p;try{g=m.length}catch(t){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;for(var y=[],b=0;50>s&&1e3>a&&g>b;b++){a++;var _=void 0;try{_=c.next(m[b])}catch(t){s++,_=n.coerceFallback(v(i+1))}_&&y.push(_)}return e({},p,{errors:y})}},v=function(r,n){return void 0===n&&(n=0),e({},i,{syntheticException:0==r?i.syntheticException:void 0,mechanism:0==r?t:{},apply(t){var e=c(t,r,n+1);if(!e)throw h;return e},next:t=>c(t,r+1)})},d=v(r);return e({},d,{apply:t=>{var e;return null!==(e=c(t,r))&&void 0!==e?e:this.coerceFallback(d)}})}},st=/^([a-z][a-z0-9.+-]+):/i,at=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function ot(t){if(!t||"<anonymous>"===t)return!1;var e=st.exec(t);return!e||at.includes(e[1].toLowerCase())}function lt(t,e,i,r,n){var s={platform:t,filename:e,function:"<anonymous>"===i?"?":i,in_app:ot(e)};return f(r)||(s.lineno=r),f(n)||(s.colno=n),s}var ut=(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]},ht=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ct=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,vt=/\((\S*)(?::(\d+))(?::(\d+))\)/,dt=(t,e)=>{var i=ht.exec(t);if(i)return lt(e,i[1],"?",+i[2],+i[3]);var r=ct.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var n=vt.exec(r[2]);n&&(r[2]=n[1],r[3]=n[2],r[4]=n[3])}var s=ut(r[1]||"?",r[2]);return lt(e,s[1],s[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},ft=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,gt=(t,e)=>{var i=ft.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=pt.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=ut(s,n);return lt(e,n=a[1],s=a[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},mt=/\(error: (.*)\)/;function yt(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function bt(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(!yt(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=xt(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function wt(t,e){for(var i=e.start;i>0&&yt(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function xt(t,e){for(var i=e.start+e.length,r=i;t.length>r&&yt(t[r],t[r-e.length]);)r++;return r-i}function St(t,e){var i=e[0],r=t.length-(i?wt(t,i):0);for(var n of e)r-=xt(t,n);return r}function kt(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 Et=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")}},Tt=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}}},At=class{match(t){return!!x(t,"ErrorEvent")&&(null!=t.error||this.mr(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.gr(t))&&void 0!==r?r:n.stack,synthetic:!0})}mr(t){return p(t.message)&&t.message.length>0}gr(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}},Ft=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Pt=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(Ft);return r&&(e=r[1],i=r[2]),[e,i]}},Rt=["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]";for(var r=i.length;r>0;r--){var n=i.slice(0,r).join(", ");if(e>=n.length)return r===i.length?n:n.length>e?n.slice(0,e)+"...":n}return""}var Ct=class{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,n=this.getErrorPropertyFromObject(t);return n?e.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(k(t))return t.constructor.name;var e="name"in t?t.name:void 0;return p(e)&&!g(e)?e:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+Ot(t)}isSeverityLevel(t){return p(t)&&!g(t)&&Rt.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}}},Mt=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}}},$t=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}}},It=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}},jt="$message",Dt="$timestamp",Lt=new Set([jt,Dt]),Nt={enabled:!0,max_bytes:32768};function zt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Nt.enabled,max_bytes:Bt(t.max_bytes,Nt.max_bytes)}:e({},Nt)}var Ut=class{constructor(t){this.ns=[],this.ss=0,this.Dr=zt(t)}setConfig(t){this.Dr=zt(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[jt],o=s[Dt];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!b(o))return;return{step:s,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Dr.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.Dr.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function Bt(t,e){if(!b(t)||1/0===t||-1/0===t)return e;var i=Math.floor(t);return 0>i?e:i}var Ht=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function qt(t){return"string"==typeof t||t}function Vt(t){return"string"==typeof t?t:void 0}var Wt="[redacted]",Gt=/^[A-Za-z0-9+/\n\r]+=*$/,Kt=/^[A-Za-z0-9_-]+={0,2}$/,Jt=/[-_]/,Xt=/^data:[^,\s]*;base64,/i,Yt=/^[A-Za-z0-9+/_-]+={0,2}$/,Zt=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Qt=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,te=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,ee=/[\s<>"]/,ie=new RegExp(te.source,"i"),re=/[a-z][a-z0-9+.-]{0,63}:\/\//i,ne=new RegExp("^"+re.source,"i"),se=new RegExp(re.source,"gi"),ae=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,oe=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,le=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,ue=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,he=/\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,ce=/(^|[^\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,ve=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,de=/\b\d(?:[ ./-]?\d){12,}\b/g,fe=/\d+/g,pe=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,ge=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function me(t){return function(t){return Qt.test(t)}(t)||ae.test(t)||oe.test(t)}function ye(t){return t.split("&",129).length>128}function be(t,e,i){return me(t)||e.includes(";")&&function(t){return t.split(";").some(t=>me(t.split("=",1)[0]))}(e)?Wt:ie.test(e)?i?Ee(e,{allowNestedUrls:!1,stripPunctuation:!0}):Wt:e}function _e(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=Te(a),u=Te(o);r||(r=l!==a||u!==o);var h=be(l,u,e);r||(r=h!==u),n=me(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function we(t,e){if(!t.includes("="))return{value:xe(t,e),lastFieldSensitive:!1};var i=_e(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function xe(t,e){return e?Ee(t,{allowNestedUrls:!1,stripPunctuation:!0}):ie.test(t)?Wt:t}function Se(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 ke(t,e){var i;if(t.length>8192&&ne.test(t))return Wt;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 Wt+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(ye(o)||ye(u.head)||ye(null!==(i=u.tail)&&void 0!==i?i:""))return Wt+a;var h=!1;(r.username||r.password)&&(r.username=Wt,r.password="",h=!0);var c=_e(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=we(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":Wt,lastFieldSensitive:!0}:we(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?Te(r.toString()):s)+(g.lastFieldSensitive?"":a)}function Ee(t,i){return t.replace(te,r=>function(t,i){var r=function(t){if(!t.includes("://"))return[];for(var e=[...t.matchAll(se)].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];Se(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return ke(t,i);var n="",s=0;for(var a of r)n+=ke(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+ke(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function Te(t){return t.replace(Zt,Wt)}function Ae(t,e){return function(t){return t.length>=10240&&(Gt.test(t)||function(t){var e,i=Xt.exec(t);if(!i)return!1;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Yt.test(e.replace(/[\r\n]/g,""))}(t)||Jt.test(t)&&Kt.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&&!ee.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 Ee(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(le," ");return(e=(e=(e=(e=(e=(e=e.replace(ue,Wt)).replace(he,Wt)).replace(ce,"$1"+Wt)).replace(de,Pe)).replace(ve,Wt)).replace(pe,"$1"+Wt)).replace(ge,"$1"+Wt)}(Te(t))),e)}function Fe(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 Pe(t){for(var e=[],i=fe.exec(t);null!==i;i=fe.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&&Fe(a)&&(o=l);0>o?s++:(r+=t.slice(n,e[s].start)+Wt,n=e[o].end,s=o+1)}return r+t.slice(n)}var Re={}.propertyIsEnumerable;function Oe(t,e){try{return $e(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Ce(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:U};if(i.remainingNodes--,_(t))return{boolValue:t};if("bigint"==typeof t)return function(t,e){var i=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==e||e.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(t,e);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var n=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==e||e.debug("Attribute "+n+" is outside the int64 range; encoding it as a string"),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:H(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:U};if(t instanceof Date){var s=t.getTime(),a=Number.isFinite(s)?t.toISOString():String(t);return{stringValue:"string"==typeof a?H(a):String(a)}}i.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Ce(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:Me(t,e,i,r+1)}}:{kvlistValue:{values:$e(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:H(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(y(o))continue;n.push(Ce(o,e,i,r))}catch(t){n.push({stringValue:B})}return t.length>a&&n.push({stringValue:U}),n}function $e(t,e,i,r){var n=[];for(var s in t)if(Re.call(t,s)){if(!s){null==e||e.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[s];if(m(a)||f(a))continue;n.push({key:H(s),value:Ce(a,e,i,r)})}catch(t){n.push({key:H(s),value:{stringValue:B}})}}return n}function Ie(t,i,r){return e({},q({},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 De(t,e){var i=q({},t),r={};for(var n of je)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Oe(i,e),...Oe(r,e)]}var Le={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 Ne={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},ze=Ne.info;function Ue(t){try{return H(String(t))}catch(t){return B}}function Be(t,i,r,n){var s,a=Ne[t.level||"info"]||ze,o=a.text,l=a.number,u=(void 0===(s=b(n)?n:void 0)&&(s=Date.now()),String(s)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),y(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),y(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var c=e({},h),v=t.attributes;if(v){var d=[];try{d=Object.keys(v)}catch(t){d=[]}for(var p of d){var g=void 0;try{g=v[p]}catch(t){g=B}Object.defineProperty(c,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Ue(t.body)},attributes:Oe(c,r)};return t.trace_id&&(m.traceId=t.trace_id),t.span_id&&(m.spanId=t.span_id),f(t.trace_flags)||(m.flags=t.trace_flags),m}function He(t,e,i){return Ie(t,e,i)}function qe(t,e,i,r){return{resourceLogs:[{resource:{attributes:De(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var Ve=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=Q(()=>{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 We(){return.75+.5*Math.random()}function Ge(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 Ke=class{constructor(t,e,i,r,n,s,a){var o;void 0===s&&(s=()=>Promise.resolve()),this._instance=t,this.Dr=e,this.A=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=new Ve(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new X,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=e.maxBufferSize,this.Is=Math.max(null!==(o=e.maxQueueSize)&&void 0!==o?o:e.maxBufferSize,e.maxBufferSize),this.Es=e.flushIntervalMs,this.Ms=e.maxBatchRecordsPerPost,this.As=e.rateCapWindowMs,this.Rs=e.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(n.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Ms=this.Dr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.Ps()&&this.Os():this.gs()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Fs(t);if(null!==r)if(r.body){if(this.Ds()){var n={record:Be(r,null!==(i=null==e?void 0:e.context)&&void 0!==i?i:this.hs(),this.A,null==e?void 0:e.occurredAtMs)};this.ds(()=>this.Ls(n))}}else this.A.info("Log was rejected in beforeSend function")}}Fs(t){var e=this.Dr.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.A.info("Log was rejected in beforeSend function"),null;r=s}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return r}Ds(){if(void 0===this.Rs)return!0;var t=Date.now(),e=t-this.xs;return this.As>e&&e>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn("captureLog dropping logs: exceeded "+this.Rs+" logs per "+this.As+"ms"),this.Cs=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return r(function*(){var e;t.ps.clear();var i=null!==(e=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var a,o,l=t._s;t.bs=0;var u=Math.min(i.length,t.Ms),h=i.slice(0,u),c=qe(h.map(t=>t.record),t.js(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.qs(c);if(t._s!==l)return;if("too-large"===v.kind&&h.length>1)t.Ms=Math.max(1,Math.floor(h.length/2)),t.A.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Ms);else{if(t.ws.record(v),t.ps.pending&&t.ps.arm(Math.max(t.Es,t.ws.remainingMs())),"retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.A.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.Dr.maxBatchRecordsPerPost>t.Ms&&(t.Ms=Math.min(t.Dr.maxBatchRecordsPerPost,t.Ms+1)),yield t.Bs(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}})()}Bs(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e.bs),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}js(){return He(this.Dr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Is>i.length||(i.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Ts>i.length||this.ws.isOpen()?this.Os():this.gs()}}Os(){this.ps.pending||this.ps.arm(Math.max(this.Es,this.ws.remainingMs()))}zs(){return Math.max(Ge(this.Es,this.ks,this.Ss,3e4),this.ws.remainingMs())}Ps(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.ps.clear();var i=e.flush().catch(()=>{});void 0!==t?yield tt(i,t):yield i})()}flushWithTimeout(t){var e=this;return r(function*(){var i=e.flush();yield tt(i,t,()=>{i.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=We(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ps()&&this.ps.armNoEarlierThan(this.zs())})}},Je=/^[0-9a-f]+$/;function Xe(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Je.test(t)}var Ye=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Ze="00",Qe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ti(t){return String(t)+"000000"}function ei(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 ii=class{constructor(t,e,i){this._instance=t,this.Dr=e,this.A=i,this.Hs=new Map,this.ps=new Ve(()=>this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new X,this.ks=0,this.Ss=1,this.Gs=0}count(t,e,i){void 0===e&&(e=1),this.Qs({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.Qs({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.Qs({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var t=this,e=this.ys,i=function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.Js()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.ys===i&&(this.ys=null)});return this.ys=i,i}drainWindow(){if(0===this.Hs.size)return null;var t=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Zs(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Fs(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.A.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=ei(i.type,i.name,i.unit,r)}catch(t){return void this.A.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s=this.Hs.get(n);if(!s){if(!this.Ks())return;s={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.Hs.set(n,s)}var a=this.Ws.get(i.name);void 0===a?this.Ws.set(i.name,i.type):a===i.type||this.Vs.has(i.name)||(this.Vs.add(i.name),this.A.warn("Metric name '"+i.name+"' is already used as a "+a+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Ys(s,i.value);var o=this.Xs();o&&(s.exemplar=e({},o,{value:i.value,timeMs:Date.now()})),this.Os()}else this.A.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Xs(){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=Ye.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 Xe(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Xe(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":Ze)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}Ks(){return this.Dr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.A.warn("Metric series cap reached ("+this.Dr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ys(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":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(Qe.length+1).fill(0)});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,Qe)]+=1}}Fs(t){var e=this.Dr.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.A.info("Metric was rejected in beforeSend function"),null;r=s}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return r}Os(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Ge(this.Dr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Js(){var t=this;return r(function*(){if(t.ps.clear(),0!==t.Hs.size){var e=t.Hs;t.Hs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;var i=t.Gs,r=yield t._instance.bo(t.Zs(e));if(i===t.Gs)switch(t.ws.record(r),"retry-later"===r.kind?(t.ks++,t.Ss=We()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),r.kind){case"ok":return;case"retry-later":return t._o(e),void t.ps.armNoEarlierThan(t.zs());case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",r.error)}}})()}Zs(t){return e=this.wo(t),i=function(t,e,i){return Ie(t,e,i)}(this.Dr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:De(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}wo(t){var i=ti(Date.now()),r=new Map;for(var n of t.values()){var s,a=ei(n.type,n.name,n.unit,void 0),o=r.get(a);o||(o=e({name:n.name},n.unit&&{unit:n.unit}),"count"===n.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===n.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Oe(null!==(s=n.attributes)&&void 0!==s?s:{},this.A),u=ti(n.windowStartMs),h=ri(n.exemplar);if("count"===n.type){var c,v=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(c=n.total)&&void 0!==c?c:0},h);o.sum.dataPoints.push(v)}else if("gauge"===n.type){var d,f=e({attributes:l,timeUnixNano:i,asDouble:null!==(d=n.last)&&void 0!==d?d:0},h);o.gauge.dataPoints.push(f)}else if(n.hist){var p=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,count:n.hist.count,sum:n.hist.sum,min:n.hist.min,max:n.hist.max,bucketCounts:n.hist.bucketCounts,explicitBounds:Qe},h);o.histogram.dataPoints.push(p)}}return Array.from(r.values())}_o(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Hs.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,a.windowStartMs),o.exemplar=null!==(n=o.exemplar)&&void 0!==n?n:a.exemplar,o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=a.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(a.hist)if(o.hist){o.hist.count+=a.hist.count,o.hist.sum+=a.hist.sum,o.hist.min=Math.min(o.hist.min,a.hist.min),o.hist.max=Math.max(o.hist.max,a.hist.max);for(var l=0;o.hist.bucketCounts.length>l;l++)o.hist.bucketCounts[l]+=a.hist.bucketCounts[l]}else o.hist=a.hist}else this.Ks()&&this.Hs.set(s,a)}}};function ri(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:ti(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var ni="0.10.4",si={DEBUG:!1,LIB_VERSION:ni,LIB_NAME:"browser-common",JS_SDK_VERSION:ni},ai=function(t,e){var i=(void 0===e?{}:e).debugEnabled,r={N(e){var r;try{r=typeof window>"u"?void 0:window}catch(t){return}for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;n>a;a++)s[a-1]=arguments[a];r&&(si.DEBUG||r.POSTHOG_DEBUG||i)&&!f(r.console)&&r.console&&("__rrweb_original__"in r.console[e]?r.console[e].__rrweb_original__:r.console[e])(t,...s)},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>ai(t+" "+e,i)};return r},oi=ai("[PostHog.js]"),li=oi.createLogger;function ui(t,e){h(t)&&t.forEach(e)}function hi(t,e){if(!y(t))if(h(t))t.forEach(e);else if(t instanceof FormData)t.forEach((t,i)=>e(t,i));else for(var i in t)l.call(t,i)&&e(t[i],i)}var ci=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var n of i)for(var s in n)void 0!==n[s]&&(t[s]=n[s]);return t};function vi(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}function di(t,e,i,r){var n=null!=r?r:{},s=n.capture,a=n.passive;null==t||t.addEventListener(e,i,{capture:void 0!==s&&s,passive:void 0===a||a})}function fi(t){return"ph_toolbar_internal"===t.name}function pi(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!c(r))return e;try{var n=r(e);return p(n)&&n?n:e}catch(t){return oi.error("Error in get_current_url, falling back to window.location.href",t),e}}var gi="$early_access_features",mi="$active_feature_flags",yi="$feature_flag_details",bi="$feature_flag_errors",_i="$feature_flag_evaluated_at",wi="$feature_flag_request_id",xi="$minimal_flag_called_events",Si="$enabled_feature_flags",ki="$stored_group_properties",Ei="$stored_person_properties",Ti="$flag_call_reported",Ai="$flag_call_reported_session_id",Fi="$feature_flag_payloads",Pi="$override_feature_flags",Ri="$override_feature_flag_payloads",Oi="visibilitychange",Ci="$autocapture_disabled_server_side";function Mi(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function $i(t){return!!t&&1===t.nodeType}function Ii(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ji(t){return!!t&&3===t.nodeType}function Di(t){return!!t&&11===t.nodeType&&$i(t.host)}function Li(t){return t?a(t).split(/\s+/):[]}function Ni(t,e){var i=function(t){var e,i=null==(e=typeof window>"u"?void 0:window)||null==(e=e.location)?void 0:e.href;return f(i)?void 0:pi(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function zi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Li(e)}function Ui(t){return y(t)?null:a(t).split(/(\s+)/).filter(t=>mr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Bi(t){var e="";return lr(t)&&!ur(t)&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;ji(t)&&t.textContent&&(e+=null!==(i=Ui(t.textContent))&&void 0!==i?i:"")}),a(e)}function Hi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var qi=["a","button","form","input","select","textarea","label"];function Vi(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}function Wi(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Vi(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Gi(t){var e=t.parentNode;return!(!e||!$i(e))&&e}var Ki=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ji=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Xi=[...Ji,"+","-","−","–"],Yi=Xi.length+10,Zi=["button","a","input","select","textarea","label"],Qi=["button","link","tab","menuitem","option"],tr=(t,e)=>/[a-z0-9]/i.test(e)?s(Xi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,er=t=>s(Zi,t.tagName.toLowerCase())||s(Qi,(t.getAttribute("role")||"").toLowerCase());function ir(t){var e="",i="",r=t=>{$i(t)&&lr(t)&&!ur(t)&&(e+=" "+Bi(t),i=i||t.getAttribute("aria-label")||"",hi(t.childNodes,r))};r(t);var n=(mr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var rr=[".ph-no-rageclick",".ph-no-capture"],nr=["","text","search","email","password","url","tel","number"];function sr(t,e){if(!(typeof window>"u"?void 0:window)||ar(t))return!1;var i,r,n,a,o;if(_(e)?(i=!!e&&rr,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:rr,r=null==e?void 0:e.content_ignorelist,n=null!==(o=null==e?void 0:e.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(t){return!(!t||!$i(t))&&(!!Ii(t,"textarea")||(Ii(t,"input")?s(nr,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var l=or(t,!1).targetElementList;return!(r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Ji;else{if(!h(t))return!1;if(t.length>Yi)return oi.error("[PostHog] content_ignorelist array cannot exceed "+Yi+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>tr(r,t)||tr(n,t))}(r,function(t,e){for(var i of e)if(er(i))return ir(i);for(var r of e){try{var n;if("pointer"!==(null==(n=window)?void 0:n.getComputedStyle(r).getPropertyValue("cursor")))break}catch(t){break}var s=ir(r);if(s.safeText||s.ariaLabel)return s}return ir(t)}(t,l))||Wi(l,i))}var ar=t=>!t||Ii(t,"html")||!$i(t),or=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ar(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,n=[t],s=t;s.parentNode&&!Ii(s,"body");)if(Di(s.parentNode))n.push(s.parentNode.host),s=s.parentNode.host;else{var a=Gi(s);if(!a)break;if(e||qi.indexOf(a.tagName.toLowerCase())>-1)r=!0;else try{var o=i.getComputedStyle(a);o&&"pointer"===o.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(a),s=a}return{parentIsUsefulElement:r,targetElementList:n}};function lr(t){for(var e=new Set,i=0,r=t;r.parentNode&&!Ii(r,"body");r=r.parentNode){if(i++>=1e3||e.has(r))return!1;e.add(r);var n=zi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!1}if(s(zi(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function ur(t){return!!(Ii(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ii(t,"select")||Ii(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var hr=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),cr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,vr=[16,15,14,13],dr=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),fr=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),pr=/[0-9A-Za-z_]/;function gr(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function mr(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?hr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(cr.lastIndex=0;e=cr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of vr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(hr.test(o)&&gr(o))return!0}}}return!1}(t))return!1;if(e?dr.test(t):function(t){var e;for(fr.lastIndex=0;e=fr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&pr.test(i)&&pr.test(r)))return!0}return!1}(t))return!1}return!0}function yr(t){var e=Bi(t);return mr(e=(e+" "+br(t)).trim())?e:""}function br(t){var e="";return t&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Bi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+br(t)).trim())}catch(t){oi.error("[AutoCapture]",t)}}),e}function _r(t){return t.replace(/"|\\"/g,'\\"')}function wr(t){var e=t.attr__class;if(e)return h(e)?e:Li(e)}var xr=class{constructor(t){this.disabled=!1===t;var e=v(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}},Sr=t=>{var e,i=null==(e=typeof document>"u"?void 0:document)?void 0:e.createElement("a");return f(i)?null:(i.href=t,i)},kr=()=>typeof window>"u"?void 0:window,Er=()=>typeof document>"u"?void 0:document,Tr="$copy_autocapture",Ar=["password","hidden","file","checkbox","button","submit","reset","image"],Fr=li("[AutoCapture]");function Pr(t,e){return e.length>t?e.slice(0,t)+"...":e}function Rr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!$i(e));return e}function Or(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!$i(t))return{props:{}};for(var d=[t],f=new Set([t]),g=t;g.parentNode&&!Ii(g,"body")&&1e3>d.length;)if(Di(g.parentNode)){var m=g.parentNode.host;if(f.has(m))break;f.add(m),d.push(m),g=m}else{if(!$i(g.parentNode))break;if(f.has(g.parentNode))break;f.add(g.parentNode),d.push(g.parentNode),g=g.parentNode}var y="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Ii(t,"button")||Ii(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!lr(t)||ur(t)));var b,_,w,x=[],S={},k=!1,E=!1;if(hi(d,t=>{var e=lr(t);if(Ii(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");k=!!(e&&i&&mr(i))&&(v?Y(i):i)}s(zi(t),"ph-no-capture")&&(E=!0),x.push(function(t,e,i,r,n){void 0===n&&(n=!1);var s=t.tagName.toLowerCase(),a={tag_name:s};qi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Pr(1024,yr(t)):Pr(1024,Bi(t)));var o=zi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),hi(t.attributes,function(i){var s;if((!ur(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&mr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Li(o).join(" ")),a["attr__"+i.name]=Pr(1024,"href"===i.name&&n?Y(o):o)}});for(var l=1,u=1,h=t;h=Rr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),hi(function(t){if(!lr(t))return{};var e={};return hi(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&mr(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(S,e)||(S[e]=t)})}),E)return{props:{},explicitNoCapture:E};if(y>0&&(t=d[y],x.splice(0,y)),l||(x[0].$el_text=Ii(t,"a")||Ii(t,"button")?yr(t):Bi(t)),k){var T,A;x[0].attr__href=k;var F=null==(T=Sr(k))?void 0:T.host,P=null==(A=kr())||null==(A=A.location)?void 0:A.host;F&&P&&F!==P&&(b=k)}return{props:ci((_=a.type,{$event_type:_,$ce_version:1}),c?{}:{$elements:x},{$elements_chain:(w=x,h(w)?function(t){return t.map(t=>{var i,r,n="";if(t.tag_name&&(n+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))n+="."+s.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return vi(a).sort((t,e)=>{return(r=e[0])>(i=t[0])?-1:i>r?1:0;var i,r}).forEach(t=>{var e=t[1];return o[_r(t[0].toString())]=_r(e.toString())}),(n+=":")+vi(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:wr(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return vi(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(w)):"")},null!=(r=x[0])&&r.$el_text?{$el_text:null==(n=x[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},S),target:t}}var Cr=class{sl(){this.rl=void 0,clearTimeout(this.al),this.al=void 0}ll(t){var e;if(!lr(t))return!0;for(var i,r=null!==(e=this.ul().css_selector_ignorelist)&&void 0!==e?e:Ki,n=new Set,a=t,o=function(){if(n.size>=1e3||n.has(a))return{v:!0};n.add(a);var t=a,e=zi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||ur(t)||r.some(e=>Vi(t,e)))return{v:!0};var i=a.parentNode;a=Di(i)?i.host:i&&$i(i)?i:null};a;)if(i=o())return i.v;return!1}cl(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.rl;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.sl():"pointerup"===t.type&&(e.released=!0,this.al=setTimeout(()=>this.sl(),0)))}else{var i;this.sl();var r=Hi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&$i(r)&&(this.rl={target:r,excluded:this.ll(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.Ta)?void 0:i.distinctId})}else this.sl()}hl(t){var e,i=this.rl;this.sl();var r=Hi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.Ta)?void 0:e.distinctId)&&t.pointerId===i.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-i.x)&&5>=Math.abs(t.clientY-i.y)&&r&&(Ii(r,"html")||Ii(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.ul().css_selector_ignorelist)&&void 0!==n?n:Ki;return[r,null==(a=Er())?void 0:a.documentElement,null==(o=Er())?void 0:o.body].some(t=>{if(!t)return!1;var e=zi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!lr(t)||ur(t)||l.some(e=>Vi(t,e))})?null:i.target}}constructor(t){this.Ma=t,this.name="autocapture",this.dl=!1,this.vl=null,this.fl=!1,this.pl=new Map,this.gl=!1,this.Dr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ti=!1,this.Ma.refresh(this.Dr),this.rageclicks=new xr(this.Dr.rageclick),this.ml=null}setup(t){this.yl(),this.Ta=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ti?e.dispose():(this.za=e,this.startIfEnabled())}dispose(){var t;this.Ti||(this.Ti=!0,this.Ta=void 0,null==(t=this.za)||t.dispose(),this.za=void 0,this.pl.clear(),this.ml=null,this.bl())}ul(){return this.Ma.refresh(this.Dr),this.Dr}yl(){var t,e;return this.ul(),this.Dr.url_allowlist=null==(t=this.Dr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Dr.url_ignorelist=null==(e=this.Dr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Dr}_l(){var t=kr(),e=Er();if(this.isBrowserSupported()){if(t&&e){this.wl=t,this.kl=e;var i=this.Sl=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.sl();if(0===e.type.indexOf("pointer"))return void this.cl(e);var i="click"===e.type?this.hl(e):void 0;if(m(i))return;this.xl(e,"$autocapture",i)}catch(t){Fr.error("Failed to capture event",t)}};if(di(t,"blur",i),di(e,"submit",i,{capture:!0}),di(e,"change",i,{capture:!0}),di(e,"click",i,{capture:!0}),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{di(e,t,i,{capture:!0})}),this.ul().capture_copied_text){var r=this.$l=e=>{e=e||(null==t?void 0:t.event);try{this.xl(e,Tr)}catch(t){Fr.error("Failed to capture clipboard event",t)}};di(e,"copy",r,{capture:!0}),di(e,"cut",r,{capture:!0}),di(e,"paste",r,{capture:!0})}}}else Fr.info("Disabling Automatic Event Collection because this browser is not supported")}bl(){var t=this.wl,e=this.kl;this.sl(),this.Sl&&(null==t||t.removeEventListener("blur",this.Sl),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.Sl,!0)}),null==e||e.removeEventListener("submit",this.Sl,!0),null==e||e.removeEventListener("change",this.Sl,!0),null==e||e.removeEventListener("click",this.Sl,!0),this.Sl=void 0),this.$l&&(null==e||e.removeEventListener("copy",this.$l,!0),null==e||e.removeEventListener("cut",this.$l,!0),null==e||e.removeEventListener("paste",this.$l,!0),this.$l=void 0),this.wl=void 0,this.kl=void 0,this.dl=!1}startIfEnabled(){this.isEnabled||this.sl(),!this.Ti&&this.Ta&&this.isEnabled&&!this.dl&&(this._l(),this.dl=!0)}onRemoteConfig(t){if(!this.Ti)if(this.fl=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.gl=e.elementsChainAsString);var i,r=e.autocapture_opt_out;_(r)&&(null==(i=this.Ta)||i.kv.set(Ci,r),this.vl=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Ti){t.size?this.pl.set(e,new Set(t)):this.pl.delete(e);var i=new Set;this.pl.forEach(t=>{t.forEach(t=>i.add(t))}),this.ml=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.ml)||i.forEach(i=>{var n;null==(n=Er())||null==(n=n.querySelectorAll(i))||n.forEach(n=>{t!==n&&e!==n||s(r,i)||r.push(i)})}),r}get isEnabled(){var t,e;if(this.Ti)return!1;var i=null==(t=this.Ta)?void 0:t.kv.get(Ci),r=this.vl,n=this.ul();if(!n.remoteRequestsDisabled&&!this.fl)return!1;var s=n.remoteRequestsDisabled&&!this.fl;if(m(r)&&!_(i)&&!s)return!1;var a=null!==(e=this.vl)&&void 0!==e?e:!!i;return!!n.enabled&&!a}xl(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Hi(t);ji(n)&&(n=n.parentNode||null);var a,o=this.yl();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(a=this.rageclicks)&&a.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&sr(n,o.rageclick)&&this.xl(t,"$rageclick",r);var l,u=i===Tr,v=u?e({},o,{dom_event_allowlist:void 0}):o;if(n&&function(t,e,i,r,n,s){var a,o=typeof window>"u"?void 0:window;if(!o||ar(t))return!1;if(null!=i&&i.url_allowlist&&!Ni(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ni(i.url_ignorelist,s))return!1;if(null!=i&&i.dom_event_allowlist){var l=i.dom_event_allowlist;if(l&&!l.some(t=>e.type===t))return!1}var u=or(t,r),h=u.parentIsUsefulElement,c=u.targetElementList;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(f(i))return!0;var r,n=function(t){if(i.some(e=>t.tagName.toLowerCase()===e))return{v:!0}};for(var s of t)if(r=n(s))return r.v;return!1}(c,i))return!1;if(!Wi(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Wi(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Ki))return!1;try{var v=o.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return h?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(qi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,v,u,u?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var d,p=Or(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.gl,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===Tr){var y=t.type||"clipboard";if("paste"!==y){var b,_,w=null==(b=kr())||null==(b=b.getSelection())?void 0:b.toString(),x=Ui(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(_=null==w?void 0:w.length)&&void 0!==_?_:0}g.$copy_type=y}if("$autocapture"===i&&"change"===t.type&&o.capture_value_css_selector_allowlist&&!o.maskAllText&&(Ii(l=n,"input")?!s(Ar,l.type):Ii(l,"textarea")||Ii(l,"select")&&!l.multiple)&&function(t,e){var i;if(!lr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Ki,n=new Set,a=t;Ii(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=zi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Vi(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=Di(i)?i.host:i&&$i(i)?i:null};a;)if(o=l())return o.v;return!0}(n,o)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){var S=o.capture_value_css_selector_allowlist,k=!1;try{k=c(S)?!!S(n):h(S)&&S.some(t=>Vi(n,t))}catch(t){Fr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.Ta)||d.capture(i,g),!0}}else this.sl()}isBrowserSupported(){var t;return c(null==(t=Er())?void 0:t.querySelectorAll)}},Mr=["[data-ph-capture-value]"],$r=class{constructor(t){this._instance=t}refresh(t){var e,i=this._instance.config,r=v(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance._shouldDisableFlags(),t.url_allowlist=null==r?void 0:r.url_allowlist,t.url_ignorelist=null==r?void 0:r.url_ignorelist,t.dom_event_allowlist=null==r?void 0:r.dom_event_allowlist,t.element_allowlist=null==r?void 0:r.element_allowlist,t.css_selector_allowlist=null==r?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=null==r?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=null==r?void 0:r.element_attribute_ignorelist,t.capture_copied_text=null==r?void 0:r.capture_copied_text,t.capture_value_css_selector_allowlist=null!==(e=null==r?void 0:r.capture_value_css_selector_allowlist)&&void 0!==e?e:Mr}},Ir="$surveys",jr="$surveys_loaded_at",Dr="PostHog loadExternalDependency extension not found.",Lr="$surveys_activated",Nr="$surveys_activated_session",zr="$surveys_activated_timestamps",Ur="$heatmaps_enabled_server_side",Br="$exception_capture_enabled_server_side",Hr="$error_tracking_suppression_rules",qr="$error_tracking_capture_extension_exceptions",Vr="$web_vitals_enabled_server_side",Wr="$dead_clicks_enabled_server_side",Gr="$product_tours_enabled_server_side",Kr="$web_vitals_allowed_metrics",Jr="$session_recording_remote_config",Xr="$replay_override_sampling",Yr="$replay_override_linked_flag",Zr="ph_product_tours",Qr="$sdk_debug_recording_script_not_loaded",tn="$sdk_debug_replay_stale_config",en="beforeunload",rn="u">typeof window?window:void 0,nn="u">typeof globalThis?globalThis:rn,sn=null==nn?void 0:nn.navigator,an=null==nn?void 0:nn.document,on=null==nn?void 0:nn.location;null!=nn&&nn.XMLHttpRequest&&new nn.XMLHttpRequest;var ln="undefined"!=typeof globalThis?globalThis:rn;ln&&"undefined"==typeof self&&(ln.self=ln),ln&&"undefined"==typeof File&&(ln.File=function(){});var un=null!=rn?rn:{},hn=li("[Dead Clicks]"),cn=()=>!0,vn=class{get lazyLoadedDeadClicksAutocapture(){return this.Rl}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Wr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Pl(()=>{this.Ol()}):this.stop()}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",e=>{e?hn.error("failed to load script",e):t()})}Ol(){var t;if(an){if(!this.Rl&&null!=(t=un.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=v(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Rl=un.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Rl.start(an),hn.info("starting...")}}else hn.error("`document` not found. Cannot start.")}stop(){this.Rl&&(this.Rl.stop(),this.Rl=void 0,hn.info("stopping..."))}},dn=li("[ExceptionAutocapture]"),fn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},pn=(t,e)=>t>=e&&fn(),gn=(t,e,i,r)=>{if(0===t){if(fn()){var n=e+1;return n===i&&r(),n}return e}return 0},mn=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;r.length>n;n++){var s=r[n].split(/=(.*)/);if(s[0]===e){i=s;break}}if(!h(i)||2>i.length)return"";var a=i[1].replace(/\+/g," ");try{a=decodeURIComponent(a)}catch(t){oi.error("Skipping decoding for malformed query param: "+a)}return a},yn=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split(/#(.*)/),n=r[1],s=(r[0]||"").split(/\?(.*)/),a=s[1],o=s[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){for(var c=l[h].split("?"),v=0;c.length>v&&!e.includes(c[v].split("=")[0]);)v++;u.push(c.length>v?c.slice(0,v).concat(c[v].split("=")[0]+"="+i).join("?"):l[h])}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=n&&(d+="#"+n),d},bn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},_n=()=>{},wn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function xn(t,e,i){try{if(!(e in t))return _n;var r={next:t[e]},n=i(function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)});return c(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=n,()=>{if(t[e]!==n)for(var i=t[e],s=wn(i);s;){if(s.next===n)return void(s.next=r.next);s=wn(i=s.next)}else t[e]=r.next}}catch(t){return _n}}var Sn=li("[TracingHeaders]");function kn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var En=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Tn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...En],An="<masked>",Fn=["li_fat_id"];var Pn=li("[Web Vitals]"),Rn=9e5,On=["CLS","FCP","INP","LCP"],Cn=["INP","LCP"],Mn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],$n=li("[RemoteConfig]"),In=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Ju(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Zu(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return $n.info("Using preloaded remote config",this.remoteConfig),void this.Ku(this.remoteConfig);if(this._instance._shouldDisableFlags())return void $n.warn("Remote config is disabled. Falling back to local config.");this.Ju(t=>{if(!t)return $n.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zu(t=>{this.Ku(t.json,t)});this.Ku(t)})}catch(t){$n.error("Error loading remote config",t),this.Ku()}}Ku(t,e){!t&&e&&(0===e.statusCode?e.error||$n.warn("Failed to fetch remote config from PostHog."):$n.error("Failed to fetch remote config from PostHog."));try{this._instance.Ku(t?{ok:!0,config:t}:{ok:!1})}catch(t){$n.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){$n.error("Error loading feature flags",t)}}},jn="disabled",Dn="lazy_loading",Ln=li("[SessionRecording]"),Nn=[Qr,tn,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],zn=li("[Heatmaps]");function Un(t){return v(t)&&"clientX"in t&&"clientY"in t&&b(t.clientX)&&b(t.clientY)}var Bn=li("[Product Tours]"),Hn=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Gr))},qn=li("[SiteApps]"),Vn="Error while initializing PostHog app with config id ",Wn="events",Gn="cancelEvents",Kn="survey shown",Jn="survey dismissed",Xn="survey sent";function Yn(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var Zn=(t,e)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},Qn=t=>t.toLowerCase(),ts={exact:(t,e)=>e.some(e=>t.some(t=>e===t)),is_not:(t,e)=>e.every(e=>t.every(t=>e!==t)),regex:(t,e)=>e.some(e=>t.some(t=>Zn(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!Zn(e,t))),icontains:(t,e)=>e.map(Qn).some(e=>t.map(Qn).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(Qn).every(e=>t.map(Qn).every(t=>!e.includes(t))),gt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i>parseFloat(t))}),lt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i<parseFloat(t))})};function es(t,e){return!t||Object.entries(t).every(t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(null==r)return!1;var n=ts[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var is=li("[Surveys]"),rs=["popover","widget","api"],ns=class{on(t,e){return this.ko[t]||(this.ko[t]=[]),this.ko[t].push(e),()=>{this.ko[t]=this.ko[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.ko[t]||[])i(e);for(var r of this.ko["*"]||[])r(t,e)}constructor(){this.ko={}}};function ss(t,e,i){if(y(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}var as=class{constructor(t){this.$i=t,this.So=new Set,this.xo=new Set,this.$o=new ns,this.Co=(t,e)=>this.To(t,e)&&this.Io(t,e)&&this.Eo(t,e)&&this.Mo(t,e),this.To=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event)}init(){var t,e;f(null==(t=this.$i)?void 0:t.subscribeCapture)||(this.Ao=null==(e=this.$i)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.Ao)||t.call(this),this.Ao=void 0,null==(e=this.$i)||null==e.setElementSelectors||e.setElementSelectors(new Set,this),this.$o=new ns}register(t){var e,i;if(!f(null==(e=this.$i)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.So.add(t),null==(e=t.steps)||e.forEach(t=>{this.xo.add((null==t?void 0:t.event)||"")})}),null!=(i=this.$i)&&i.setElementSelectors)){var r=new Set;this.So.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.$i.setElementSelectors(r,this)}}replace(t){this.So.clear(),this.xo.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.xo.has(t)||this.xo.has(e.event))&&this.So.forEach(t=>{this.Ro(e,t)&&this.$o.emit("actionCaptured",t.name)})}Po(t){this.onAction("actionCaptured",e=>t(e))}Ro(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Co(t,i))return!0;return!1}onAction(t,e){return this.$o.on(t,e)}Io(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(null==t||!t.properties||!("$current_url"in t.properties))try{var n;r=null==(n=this.$i)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!ss(r,e.url,e.url_matching||"contains"))return!1}return!0}Eo(t,e){return!!this.Oo(t,e)&&!!this.Fo(t,e)&&!!this.Do(t,e)}Oo(t,e){var i;if(null==e||!e.href)return!0;var r=this.Lo(t);if(r.length>0)return r.some(t=>ss(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&ss((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Fo(t,e){var i;if(null==e||!e.text)return!0;var r=this.Lo(t);if(r.length>0)return r.some(t=>ss(t.text,e.text,e.text_matching||"exact")||ss(t.$el_text,e.text,e.text_matching||"exact"));var n,s,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(n=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!y(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),s=e.text,a=e.text_matching||"exact",n.some(t=>ss(t,s,a)))}Do(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}Lo(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Mo(t,e){return null==e||!e.properties||0===e.properties.length||es(e.properties.reduce((t,e)=>{var i=h(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t},{}),null==t?void 0:t.properties)}},os=class{constructor(t,e){this.No=e,this.jo=[],this.$i=t,this.qo=new Map,this.Bo=new Map,this.zo=new Map}Ho(){var t,e;this.Uo=null==(t=(e=this.$i).subscribeSession)?void 0:t.call(e,t=>this.Wo(t))}Vo(t){return!1}Go(){return null}Qo(t){}Jo(){}Zo(t,e){return!!t&&es(t.propertyFilters,null==e?void 0:e.properties)}Ko(t,e){var i=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}Yo(t,e,i){var r=(i===Wn?this.qo:this.Bo).get(t),n=[];return this.Xo(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.Zo(s,e)})}register(t){this.ta(t,!1)}replace(t){this.ta(t,!0)}ta(t,e){f(this.$i.subscribeCapture)||(this.ea(t,e),this.ia(t,e))}ia(t,e){var i=t.filter(t=>{var e;return null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length});if(e&&this.zo.clear(),0!==i.length){this.na||(this.na=new as(this.$i),this.na.init(),this.na.Po(t=>this.onAction(t)));var r=[];i.forEach(t=>{var e;null==(e=t.conditions)||null==(e=e.actions)||e.values.forEach(e=>{if(r.push(e),e.name){var i,n=null!==(i=this.zo.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.zo.set(e.name,n)}})}),e?this.na.replace(r):this.na.register(r)}else{var n;e&&(null==(n=this.na)||n.replace([]))}}sa(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)})}ea(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.Ko(t,Wn),l=this.Ko(t,Gn);e?(this.qo=o,this.Bo=l):(this.sa(this.qo,o),this.sa(this.Bo,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.Ao)&&void 0!==i||(this.Ao=null==(r=(n=this.$i).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.ra(),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.oa(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.aa([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.la(s),void this.ua([s])}if(this.Bo.has(t)){var o=this.Yo(t,e,Gn);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.aa(o.map(t=>t.id)),o.forEach(t=>this.ca(t.id)))}if(this.qo.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.qo.get(t)});var l=this.Yo(t,e,Wn);this.ha(l.map(t=>t.id))}}onAction(t){this.zo.has(t)&&this.ha(this.zo.get(t)||[])}ha(t){if(0!==t.length){var e=!!this.$i.getSessionId(),i=[];for(var r of t)e&&this.Vo(r)?this.la(r)&&this.da(r):i.push(r);i.length>0&&(this.jo=[...new Set([...this.jo,...i])]),this.ra().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.va()}}la(t){this.jo=this.jo.filter(e=>e!==t);var e=this.fa();return!e.includes(t)&&(this.pa([...e,t]),this.ga(),!0)}aa(t){var e=new Set(t);this.jo=this.jo.filter(t=>!e.has(t));var i=this.ma(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.pa(r),0===r.length&&this.ya()),this.ua(t),this.va()}va(){try{var t;null==(t=this.No)||t.call(this)}catch(t){this.ra().error("Error while handling activated items change",t)}}ba(){var t=this.Go();if(!t)return{};var e=this.$i.getProperty(t);return e&&"object"==typeof e?e:{}}da(t){if(this.Go()){var i=this.ba();this.Qo(e({},i,{[t]:Date.now()}))}}ua(t){if(this.Go()){var e=this.ba(),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.Jo():this.Qo(i))}}_a(){this.Go()&&this.Jo()}getActivationTimestamp(t){if(this.fa().includes(t)){var e=this.ba()[t];return b(e)?e:void 0}}ma(){var t=this.wa();return this.$i.getProperty(t)||[]}fa(){var t=this.ma();if(0===t.length)return[];var e=this.$i.getProperty(this.ka()),i=this.$i.getSessionId();return i&&e===i?t:[]}ga(){var t=this.$i.getSessionId();t&&this.Sa(t)}ya(){this.xa()}Wo(t){var e=this.$i.getProperty(this.ka());if(e&&e!==t){var i=this.ma(),r=this.ba();i.length>0&&(this.pa([]),i.filter(t=>b(r[t])).forEach(t=>this.ca(t))),this.ya(),this._a(),i.length>0&&this.va()}}getActivatedIds(){return[...new Set([...this.fa(),...this.jo])].filter(t=>!this.$a(t))}dispose(){var t,e,i;null==(t=this.Uo)||t.call(this),this.Uo=void 0,null==(e=this.Ao)||e.call(this),this.Ao=void 0,null==(i=this.na)||i.dispose(),this.na=void 0}reset(){this.jo=[],this.ma().length>0&&this.pa([]),this.ya(),this._a(),this.va()}getEventToItemsMap(){return this.qo}Ca(){return this.na}},ls=class extends os{constructor(t,e,i,r){var n;super({subscribeCapture(e){var i=t.onEvent(t=>e(t.event,t));return()=>i.dispose()},subscribeSession(e){var i=t.onSession(e);return()=>i.dispose()},getSessionId(){var e;return null==(e=t.session)?void 0:e.sessionId},getProperty:e=>t.kv.get(e),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(n=null==i?void 0:i.setElementSelectors)&&void 0!==n?n:(e,i)=>{var r;return null==(r=t.getExtension("autocapture"))?void 0:r.setElementSelectors(e,i)}},r),this.Ta=t,this.Ia=e,this.Ho()}wa(){return Lr}ka(){return Nr}Go(){return zr}Qo(t){this.Ta.kv.set({[zr]:t})}Jo(){this.Ta.kv.remove(zr)}Vo(t){var e,i;this.Xo(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return b(r)&&r>0}Ea(){return Kn}Xo(t){this.Ia.getSurveys(t)}ca(t){this.Ia.cancelPendingSurvey(t)}ra(){return is}pa(t){this.Ta.kv.set({[Lr]:t})}Sa(t){this.Ta.kv.set({[Nr]:t})}xa(){this.Ta.kv.remove(Nr)}$a(){return!1}oa(t,e,i){var r,n;return t===Xn&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.Xo(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return Yn(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===Kn?"consume":"ignore":t===Kn?"persist":t===Jn||t===Xn?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},us=(t,e)=>null!=t&&t.then?t.then(e):e(t),hs="SDK is not enabled or survey functionality is not yet loaded",cs="Disabled. Not loading surveys.",vs=class{constructor(t){this.Ma=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Aa=!1,this.Ra=!1,this.Pa=[],this.Oa=[],this.Fa=null,this.Da=null,this.Ti=!1,this.La=new Set,this.onRemoteConfig=t=>{if(!this.Ti&&!this.Dr.disableSurveys){if(!t.ok)return this.Ra=!0,this.Na({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),is.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return is.warn("Flags not loaded yet. Not loading surveys.");this.ja=_(e)?e:e.length>0,is.info("flags response received, isSurveysEnabled: "+this.ja),this.loadIfEnabled()}},this.Na=t=>{this.Oa.slice().forEach(e=>this.qa(e,t))}}setup(t){if(!this.Ti)return this.Ba=t,us(t.kv.initialize(),()=>{if(this.Ba===t&&!this.Ti){this.Ba=void 0,this.Ta=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Ti?e.dispose():(this.za=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Ti||(this.Ti=!0,this.Ba=void 0,this.Ta=void 0,null==(t=this.za)||t.dispose(),this.za=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Pa=[],this.Oa.forEach(t=>{t.active=!1}),this.Oa=[],null==(r=this.Ha)||r.call(this),this.Ha=void 0,this.Fa=null,this.La.forEach(t=>clearTimeout(t)),this.La.clear())}get Dr(){return this.Ma.get()}getRenderContext(){if(this.Ta){var t=this;return{client:this.Ta,get config(){return t.Dr},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.Na()}loadIfEnabled(){if(!this.Ti&&this.Ta){var t=this.Dr;if(!this._surveyManager)if(this.Aa)is.info("Already initializing surveys, skipping...");else if(t.disableSurveys)is.info(cs);else if(t.cookielessMode&&this.Ta.isOptedOut)is.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Ma.getExtensions();if(e){if(!f(this.ja)||t.advancedEnableSurveys){var i=this.ja||t.advancedEnableSurveys;this.Aa=!0,this.Ra=!1;try{var r=e.generateSurveys;if(r)return this.Wa(r,i),void(this.Aa=!1);var n=e.loadExternalDependency;if(!n)return this.Ua(Dr),void(this.Aa=!1);n(t=>{try{if(this.Ti)return;var e=this.Ma.getExtensions();t||null==e||!e.generateSurveys?this.Ua("Could not load surveys script",t):this.Wa(e.generateSurveys,i)}finally{this.Aa=!1}})}catch(t){throw this.Aa=!1,this.Ua("Error initializing surveys",t),t}}}else this.Ua("PostHog Extensions not found.")}}}Wa(t,e){var i;if(!this.Ti){this._surveyManager=t(e),this._surveyEventReceiver=this.Va(this.Ta,this.Na);var r=null==(i=this.Ta)?void 0:i.kv.get(Ir);r&&this.Ga(r),is.info("Surveys loaded successfully"),this.Qa(),this.Na(),this.Ja({isLoaded:!0})}}Va(t,e){return new ls(t,this,void 0,e)}Ua(t,e){this.Ra=!0,is.error(t,e),this.Na({isLoaded:!1,error:t}),this.Ja({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Pa.push(t),this._surveyManager&&this.Ja({isLoaded:!0}),()=>{this.Pa=this.Pa.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Ti){var i=this.Ta;if(!i)return t([],{isLoaded:!1,error:hs});if(this.Dr.disableSurveys)return is.info(cs),t([]);var r=i.kv.get(Ir);if(r&&!e)return t(r,{isLoaded:!0}),void(this.Za()&&this.getSurveys(()=>{},!0));if(this.Fa)this.Fa.then(e=>{this.Ti||t(e.surveys,e.context)}).catch(t=>is.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Dr.requestTimeoutMs}).then(t=>{try{return this.Ka(i,t)}catch(t){return is.error("Error processing surveys response",t),this.Ka(i,{statusCode:0,error:t})}},t=>this.Ka(i,{statusCode:0,error:t}));this.Fa=n;var s=()=>{this.Fa===n&&(this.Fa=null)};n.then(e=>{s(),this.Ti||(this.Na(e.context),t(e.surveys,e.context))},s).catch(t=>is.error("Error in survey callback",t))}}}Ka(t,e){if(this.Ti)return{surveys:[],context:{isLoaded:!1,error:hs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?is.error(r):e.error||is.warn(r),this.Da=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Da=null;var n=e.json.surveys||[];return t.kv.set({[Ir]:n,[jr]:Date.now()}),this.Ga(n),{surveys:n,context:{isLoaded:!0}}}Ga(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Yn(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.Ya(e)}Ya(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}Za(){return this.Xa()&&!this.Fa&&!this.tl()}Xa(){var t,e=null==(t=this.Ta)?void 0:t.kv.get(jr);return b(e)&&Date.now()-e>3e5}tl(){return b(this.Da)&&3e5>Date.now()-this.Da}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){is.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Na()}Ja(t){for(var e of this.Pa){if(this.Ti)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){is.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);is.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Ti)return()=>{};var i={callback:t,active:!0,revision:0};this.Oa.push(i),this.Qa();var r=null==(e=this.Ta)?void 0:e.kv.get(Ir);return this.Dr.disableSurveys||!this._surveyManager&&this.Ra&&!this.Aa||!r&&!y(this.Da)&&!this.Fa?this.qa(i,{isLoaded:!1}):this._surveyManager&&this.qa(i),()=>{var t;i.active=!1,this.Oa=this.Oa.filter(t=>t!==i),0===this.Oa.length&&(null==(t=this.Ha)||t.call(this),this.Ha=void 0)}}Qa(){var t,e,i;this._surveyManager&&this.Oa.length>0&&(null!==(t=this.Ha)&&void 0!==t||(this.Ha=null==(e=(i=this.Ma).onMatchingConditionsChanged)?void 0:e.call(i,this.Na)))}qa(t,e){if(!this.Ti&&t.active){var i=++t.revision,r=r=>{if(!this.Ti&&t.active&&i===t.revision)try{var n=null!=e?e:{isLoaded:!0},s=JSON.stringify([r,n]);if(s===t.lastResult)return;t.lastResult=s,t.callback(r,n)}catch(t){is.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){is.error("Error in active matching surveys callback",t)}}}el(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}il(t){if(y(this._surveyManager))return{eligible:!1,reason:hs};var e="string"==typeof t?this.el(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}nl(t){var e;if(null==(e=this.Ta)||!e.canCapture)return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(y(this._surveyManager))return{eligible:!1,reason:hs};var i="string"==typeof t?this.el(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return is.warn("init was not called"),{visible:!1,disabledReason:hs};var e=this.nl(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:hs})):new Promise(i=>{this.getSurveys(e=>{var r,n=null!==(r=e.find(e=>e.id===t))&&void 0!==r?r:null;if(n){var s=this.nl(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.Ta)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var a="string"==typeof t?this.el(t):t;if(null!=a&&a.id)if(rs.includes(a.type)){var o=null==(n=typeof document>"u"?void 0:document)?void 0:n.querySelector(e);if(o)if(null!=(s=a.appearance)&&s.surveyPopupDelaySeconds){is.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.La.delete(l),!this.Ti&&null!=(t=this.Ta)&&t.canCapture&&(is.info("Rendering survey "+a.id+" with delay of "+(null==(e=a.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(r=this._surveyManager)||r.renderSurvey(a,o,i),is.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.La.add(l)}else this._surveyManager.renderSurvey(a,o,i);else is.warn("Survey element not found")}else is.warn("Surveys of type "+a.type+" cannot be rendered in the app");else is.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.Ta)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var s=this.el(t);if(s){var a=s;if(null!=(n=s.appearance)&&n.surveyPopupDelaySeconds&&i.ignoreDelay&&(a=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.il(s);if(!o.eligible)return void is.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(a,i):this.renderSurvey(a,i.selector,i.properties)}else is.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?is.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};si.DEBUG=!1,si.LIB_VERSION="1.444.4",si.LIB_NAME="web";var ds=si,fs=new WeakMap,ps=class{constructor(t){this._instance=t}get(){var t,e,i,r,n=null==(t=this._instance)?void 0:t.config;return{disableSurveys:!(null==n||!n.disable_surveys),cookielessMode:!(null==n||!n.cookieless_mode),advancedEnableSurveys:!(null==n||!n.advanced_enable_surveys),requestTimeoutMs:null!==(e=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==e?e:1e4,prefillFromUrl:!(null==n||null==(i=n.surveys)||!i.prefillFromUrl),automaticDisplay:!(null!=n&&n.disable_surveys_automatic_display),featureFlagEvaluation:!(null!=n&&n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null==(r=this._instance)||null==(r=r.requestRouter)?void 0:r.endpointFor("ui","")}}getExtensions(){var t=null==un?void 0:un.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=t.loadExternalDependency;return{generateSurveys:i?t=>i(e,t):void 0,loadExternalDependency:r?t=>r(e,"surveys",t):void 0}}}onMatchingConditionsChanged(t){var e,i,r=null==(e=this._instance)?void 0:e._addCaptureHook(e=>{"$pageview"!==e&&e!==Kn&&e!==Jn&&e!==Xn||t()}),n=()=>t();di(rn,"PHSurveyShown",n);var s=!1,a=null==(i=this._instance)?void 0:i.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,null==r||r(),null==a||a(),null==rn||rn.removeEventListener("PHSurveyShown",n)}}},gs=null!=rn&&rn.location?bn(rn.location.hash,"__posthog")||bn(location.hash,"state"):null,ms="_postHogToolbarParams",ys=li("[Toolbar]"),bs=li("[FeatureFlags]"),_s=li("[FeatureFlags]",{debugEnabled:!0}),ws="\" failed. Feature flags didn't load in time.",xs=[502,504],Ss=["click","keydown","wheel","touchstart","pointerdown"],ks="connection_error",Es=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Ts=t=>{var e={};for(var i of vi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},As=class{constructor(t){this.name="featureFlags",this.xd=!1,this.featureFlagEventHandlers=[],this.A=bs,this.$d={},this.Cd={},this.Td=[],this.Id=new Set,this.Ed=new Set,this.Md=!1,this.Ad=!1,this.Rd=0,this.Pd=!1,this.Od=!1,this.Fd=!1,this.Dd=!1,this.Ld=!1,this.Nd=0,this.jd=!1,this.sn=()=>{var t=this.qd();this.Nd=0,t&&this.reloadFeatureFlags()},this.Bd=()=>{var t,e,i=this.zd,r=null!==(t=this.Hd)&&void 0!==t?t:i;f(i)||f(r)||this.Dr.remoteRequestsDisabled||!this.Ud||"hidden"===this.Ud.visibilityState||Date.now()-(null!==(e=this.Wd)&&void 0!==e?e:0)<r||(this.Hd=this.jd||!this.Dr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.jd=!1,this.reloadFeatureFlags(),this.Vd())},this.Gd=()=>{this.jd&&this.Hd===this.zd||this.Qd()},this.an=()=>{var t;"visible"===(null==(t=this.Ud)?void 0:t.visibilityState)&&this.Qd()},this.Ma=t}get Jd(){}Zd(){this.Ta&&this.Kd()}setup(t){try{this.Yd=typeof window>"u"?void 0:window,this.Ud=typeof document>"u"?void 0:document}catch(t){this.Yd=void 0,this.Ud=void 0}return this.Ba=t,this.A=t.logger.createLogger("[FeatureFlags]"),us(t.kv.initialize(),()=>{this.Ba===t&&(this.Ba=void 0,this.Ta=t,this.Xd(t))})}Xd(t){var e;if(this.Ta===t)return this.Yd&&di(this.Yd,"online",this.sn),this.Kd(),this.tv=t.registerDynamicEventProperties(()=>this.ev()?this.$d:this.Cd),this.iv=null==(e=this.Jd)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.nv(),this.sv(),this.rv()}),this.sv(),this.initialize()}Qd(){this.jd=!0,this.Hd=this.zd,this.Bd()}Kd(){var t,e=this.Dr.refreshIntervalMs,i=!this.Dr.remoteRequestsDisabled&&this.Ud&&!f(e)&&e>0?e:void 0;this.Dr.idleRefreshBackoff||(this.Hd=i),i!==this.zd&&(this.ov(),f(i)||(this.zd=i,this.Hd=i,this.Vd(),null!=(t=this.Ud)&&t.addEventListener&&(di(this.Ud,Oi,this.an),ui(Ss,t=>{di(this.Ud,t,this.Gd,{capture:!0})}))))}Vd(){f(this.zd)||(f(this.av)||clearInterval(this.av),this.Wd=Date.now(),this.av=setInterval(this.Bd,this.zd))}ov(){var t;f(this.av)||(clearInterval(this.av),this.av=void 0,null==(t=this.Ud)||null==t.removeEventListener||t.removeEventListener(Oi,this.an),ui(Ss,t=>{var e;null==(e=this.Ud)||null==e.removeEventListener||e.removeEventListener(t,this.Gd,{capture:!0})})),this.zd=void 0,this.Hd=void 0,this.jd=!1,this.Wd=void 0}destroy(){this.lv()}dispose(){this.lv()}lv(){var t,e,i;this.ov(),this.Rd++,this.Od=!1,this.Ba=void 0,this.uv(this.Id,"cancelled"),this.uv(this.Ed,"cancelled"),this.Ta&&(this.hv(),null==(t=this.tv)||t.dispose(),this.tv=void 0,null==(e=this.iv)||e.call(this),this.iv=void 0,this.Td=[],null==(i=this.Yd)||i.removeEventListener("online",this.sn),this.Ta=void 0)}get Dr(){return this.Ma.get()}dv(t){var e;return this.vv&&t in this.vv?this.vv[t]:null==(e=this.Ta)?void 0:e.kv.get(t)}nv(){return!!this.vv&&(this.vv=void 0,!0)}fv(){var t;return!f(null==(t=this.Ta)?void 0:t.kv.get("$enabled_feature_flags"))&&this.nv()}$t(t){this.pv(()=>{var e;return null==(e=this.Ta)?void 0:e.kv.set(t)})}gv(t,e,i){if(this.Jd&&t.$enabled_feature_flags){var r=this.dv("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(t=>{var e=t[1];return!(null!=e&&e.failed)}).map(t=>t[0]):[],o=!!e.errorsWhileComputingFlags&&!!e.flags,l=o?a:i&&!h(s)?Object.keys(s||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),u=this.dv("$feature_flag_payloads")||{},c=t.$feature_flag_payloads||{},v=o||i?l:Array.from(new Set([...Object.keys(u),...Object.keys(c)])),d=!o&&!i,p=!!d||l,g=!!d||v,m={[mi]:p,[Si]:p,[Fi]:g};for(var y of(t.$feature_flag_details&&(m[yi]=p),[wi,_i,xi]))f(t[y])||(m[y]=!0);this.Jd.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.pv(()=>{var e;return null==(e=this.Ta)?void 0:e.kv.remove(t)})}pv(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}sv(){var t={};for(var i of[mi,Fi,wi,Pi]){var r=this.dv(i);f(r)||(t[i]=r)}this.$d=t;var n=e({},t),s=this.dv(Si);if(s)for(var a of Object.entries(s))n["$feature/"+a[0]]=a[1];this.Cd=n}ev(){var t=this.Dr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.dv(_i);return"number"!=typeof e||Date.now()-e>t}mv(){return!!this.ev()&&(this.Ld||this.Ad||(this.Ld=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}yv(){var t=this.Dr.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),e}):[]}bv(){var t=this.Dr.flagKeys;if(!f(t))return t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),e})}initialize(){var t,e,i=this.Dr,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var n,s,a=null!==(n=null==(s=i.bootstrap)?void 0:s.featureFlagPayloads)&&void 0!==n?n:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,e)=>(t[e]=r[e],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,e)=>(t[e]=a[e],t),{});return this._v({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n,s,a=null!=r&&r.merge&&null!==(n=this.dv("$enabled_feature_flags"))&&void 0!==n?n:{},o=null!=r&&r.merge&&null!==(s=this.dv("$feature_flag_payloads"))&&void 0!==s?s:{},l=e({},a,t),u=e({},o,i),h={};for(var c of Object.entries(l)){var v=c[0],d=c[1];h[v]={key:v,enabled:qt(d),variant:Vt(d),reason:void 0,metadata:f(null==u?void 0:u[v])?void 0:{id:0,version:void 0,description:void 0,payload:u[v]}}}this._v({flags:h})}get hasLoadedFlags(){return this.Md}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.dv(yi),i=this.dv(Pi),r=this.dv(Ri);if(!r&&!i)return t||{};var n=ci({},t||{});for(var s of[...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.xd||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.xd=!0),n}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(i=>{var r=t[i];return{key:i,enabled:qt(r),variant:Vt(r),payload:Ht(e[i])}})}getFlagVariants(){var t=this.dv(Si),e=this.dv(Pi);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.xd||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.xd=!0),i}getFlagPayloads(){var t=this.dv(Fi),e=this.dv(Ri);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.xd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.xd=!0),i}reloadFeatureFlags(){this.Pd||this.Dr.featureFlagsDisabled||this.qd()||(this.Fd&&this.A.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.Ad&&(this.Od=!0),this.wv||(this.Td.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.wv=setTimeout(()=>{this.Sv()},5)))}reloadFeatureFlagsAsync(){return!this.Ta||this.Pd||this.Dr.featureFlagsDisabled||this.Dr.remoteRequestsDisabled||this.qd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.Id.add(t),this.reloadFeatureFlags()})}uv(t,e){t.forEach(t=>t({status:e})),t.clear()}hv(){clearTimeout(this.wv),this.wv=void 0}onReloading(t){return this.Td.push(t),()=>{this.Td=this.Td.filter(e=>e!==t)}}ensureFlagsLoaded(){this.Md||this.Ad||this.wv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Pd=t}resetFlagCallReported(){this.Dt(Ti)}Sv(t){var i;this.hv();var r=this.Ta;if(!r||this.Dr.remoteRequestsDisabled||this.qd())this.uv(this.Id,"skipped");else if(this.Ad)this.Od=!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.dv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.dv(ki),timezone:kn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Dr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.yv();s.length&&(n.evaluation_contexts=s);var a=this.bv();f(a)||(n.flag_keys=a);var o=this.Dr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.Rd,h=this.Id;this.Id=new Set,this.Ed=h,this.Ad=!0;var c=()=>{this.Od&&(this.Od=!1,this.Sv())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.Ad=!1,u===this.Rd)if(this.xv(t.statusCode),s||this.Od||(this.$anon_distinct_id=void 0),!n.disable_flags||this.Od){this.Dd=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?ks:"unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),r.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l=!(null==(i=r.quotaLimited)||!i.includes("feature_flags"));l&&a.push("quota_limited"),this.$t({[bi]:a}),l?this.A.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._v(r,s,{partialResponse:o}),this.uv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.uv(h,"skipped");else c()},d=t=>{this.Ad=!1,u===this.Rd?(this.$t({[bi]:[ks]}),this.A.error("Feature flag request failed",t),this.fv()&&this.rv(!0),this.uv(h,"error"),c()):c()},p=null!==(i=this.Dr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.Rd,m=()=>{if(u!==this.Rd||!this.Ta||this.Dr.remoteRequestsDisabled)return this.Ad=!1,this.uv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Dr.compression,sentAt:"body",timeoutMs:this.Dr.requestTimeoutMs}).then(t=>{if((t=>xs.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()}}qd(){return pn(this.Nd,3)}xv(t){this.Nd=gn(t,this.Nd,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.Dd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.mv()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else this.A.warn('getFeatureFlag for key "'+t+ws)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e;return null==(e=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:e.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.Dd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.mv()){var r,n=this.getFlagVariants(),s=t in n,a=n[t],o=this.getFlagPayloads()[t],l=String(a),u=this.dv("$feature_flag_request_id")||void 0,c=this.dv("$feature_flag_evaluated_at")||void 0,v=this.dv("$flag_call_reported")||{};if(this.Dr.deduplicateCallsPerSession){var d,p=null==(d=this.Ta)||null==(d=d.session)?void 0:d.sessionId,g=this.dv(Ai);p&&p!==g&&(v={},r=p)}if(!i.send_event&&"send_event"in i)r&&this.$t({[Ti]:v,[Ai]:r});else{var m,y,b=null==(m=this.Ta)?void 0:m.canCapture;if(!b&&Object.keys(v).length>0&&(v={},this.$t({[Ti]:v})),!b||null!=(y=v[t])&&y.includes(l))r&&this.$t({[Ti]:v,[Ai]:r});else{var _,w,x,S,k,E,T,A,F,P,R,O,C;h(v[t])?v[t].push(l):v[t]=[l],this.$t(e({[Ti]:v},r?{[Ai]:r}:{}));var M=this.getFeatureFlagDetails(t),I=[...null!==(_=this.dv("$feature_flag_errors"))&&void 0!==_?_:[]];f(a)&&I.push("flag_missing");var j={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:null!==(w=null==(x=this.Dr.bootstrap)||null==(x=x.featureFlags)?void 0:x[t])&&void 0!==w?w:null,$feature_flag_bootstrapped_payload:null!==(S=null==(k=this.Dr.bootstrap)||null==(k=k.featureFlagPayloads)?void 0:k[t])&&void 0!==S?S:null,$used_bootstrap_value:!this.Dd};f(null==M||null==(E=M.metadata)?void 0:E.has_experiment)||(j.$feature_flag_has_experiment=M.metadata.has_experiment),f(null==M||null==(T=M.metadata)?void 0:T.version)||(j.$feature_flag_version=M.metadata.version);var D=null!==(A=null==M||null==(F=M.reason)?void 0:F.description)&&void 0!==A?A:null==M||null==(P=M.reason)?void 0:P.code;D&&(j.$feature_flag_reason=D),null!=M&&null!=(R=M.metadata)&&R.id&&(j.$feature_flag_id=M.metadata.id),f(null==M?void 0:M.original_variant)&&f(null==M?void 0:M.original_enabled)||(j.$feature_flag_original_response=f(M.original_variant)?M.original_enabled:M.original_variant),null!=M&&null!=(O=M.metadata)&&O.original_payload&&(j.$feature_flag_original_payload=null==M||null==(C=M.metadata)?void 0:C.original_payload),I.length&&(j.$feature_flag_error=I.join(",")),this.$v(j)}}if(s)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:Ht(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+ws)}$v(t){try{var e;null==(e=this.Ta)||e.capture("$feature_flag_called",t)}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,e){this.Cv(t,e)}Cv(t,e){var i=this;return r(function*(){var r=i.Ta;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.yv();s.length&&(n.evaluation_contexts=s);var a,o=i.bv();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.Dr.compression,sentAt:"body",timeoutMs:i.Dr.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void i.A.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){i.A.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.Dd)return e.defaultValue;if(!(this.Md||this.getFlags()&&this.getFlags().length>0))return this.A.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._v(t,e,i)}_v(t,i,r){if(this.Ta){this.Md=!0;var n=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=bs);var o=((t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).map(t=>{var e;return[t,null!==(e=r[t].variant)&&void 0!==e?e:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>r[t].enabled).filter(t=>{var e;return!f(null==(e=r[t].metadata)?void 0:e.payload)}).map(t=>{var e;return[t,null==(e=r[t].metadata)?void 0:e.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,a),l=o.flags,u=o.featureFlags,c=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[mi]:u,[Si]:p,[xi]:!1}}var m=u,y=c,b=l;if(null!=s&&s.partialResponse){var _=Object.keys(m),w=y||{};m=e({},i,m),y=e({},r,w),_.forEach(t=>{var e;t in w||null==(e=y)||delete e[t]}),b=e({},n,b)}else if(t.errorsWhileComputingFlags)if(l){var x=new Set(Object.keys(l).filter(t=>{var e;return!(null!=(e=l[t])&&e.failed)}));m=e({},i,Object.fromEntries(Object.entries(m).filter(t=>x.has(t[0]))));var S=Object.fromEntries(Object.entries(y||{}).filter(t=>x.has(t[0])));y=e({},r,S),x.forEach(t=>{var e;t in S||null==(e=y)||delete e[t]}),b=e({},n,Object.fromEntries(Object.entries(b||{}).filter(t=>x.has(t[0]))))}else m=e({},i,m),y=e({},r,y),b=e({},n,b);return e({[mi]:Object.keys(Ts(m)),[Si]:m||{},[Fi]:y||{},[yi]:b||{},[xi]:!0===t.minimalFlagCalledEvents},v?{[wi]:v}:{},d?{[_i]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.A);if(n)if(!1===(null==r?void 0:r.persist)){var s=!f(this.Ta.kv.get(Si));this.vv=n,s||this.$t(n)}else this.nv(),this.gv(n,t,!(null==r||!r.partialResponse)),this.$t(n);else i&&this.fv();i||(this.Ld=!1),this.rv(i)}}override(t,e){void 0===e&&(e=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.Tv(t)}Tv(t){if(this.Ta){if(!1===t)return this.Dt([Pi,Ri]),this.rv(),void _s.info("All overrides cleared");if(h(t))return this.$t({[Pi]:Es(t)}),this.rv(),void _s.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.xd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Pi]=h(n)?Es(n):n),s&&(r[Ri]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Pi,Ri]):!1===n?this.Dt(Pi):!1===s&&this.Dt(Ri),this.rv(),!1===n?_s.info("Flag overrides cleared"):n&&_s.info("Flag overrides set",{flags:n}),void(!1===s?_s.info("Payload overrides cleared"):s&&_s.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Pi]:t}),this.rv(),void _s.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Md){var e=this.Iv(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var n,s=(this.dv("$early_access_features")||[]).find(e=>e.flagKey===t),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};s&&(o.$early_access_feature_name=s.name),r&&(o.$feature_enrollment_stage=r);var l=e({},this.getFlagVariants(),{[t]:i});null==(n=this.Jd)||n.markCrossTabFeatureFlagChanges({[mi]:[t],[Si]:[t],[Ei]:Object.keys(a)}),this.$t({[mi]:Object.keys(Ts(l)),[Si]:l,[Ei]:e({},this.dv("$stored_person_properties")||{},a)}),this.rv();try{var u;null==(u=this.Ta)||u.capture("$feature_enrollment_update",o)}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.dv(gi);!r||e?this.Ev(t,i):t(r)}Ev(t,e){var i=this;return r(function*(){var r=i.Ta;if(r){var n,s=e?"&"+e.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+s,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;n=a.json.earlyAccessFeatures,i.$t({[gi]:n})}catch(t){return void i.A.error("Early access feature request failed",t)}try{t(n)}catch(t){i.A.error("Early access feature callback failed",t)}}})()}Iv(){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),{})}}rv(t){this.sv();var e=this.Iv(),i=e.flags,r=e.flagVariants,n=this.Fd;this.Fd=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}}),this.Fd=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Mv(t,e)}Mv(t,i){void 0===i&&(i=!0);var r=this.dv("$stored_person_properties")||{},n=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,a={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in r||(a[o]=s[o]));this.$t({[Ei]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.dv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Ei]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Ei),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.dv("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[ki]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.dv("$stored_group_properties")||{};this.$t({[ki]:e({},i,{[t]:{}})})}else this.Dt(ki)}reset(){this.Rd++,this.uv(this.Id,"cancelled"),this.uv(this.Ed,"cancelled"),this.Od=!1,this.$d={},this.Cd={},this.vv=void 0,this.Md=!1,this.Pd=!1,this.Dd=!1,this.$anon_distinct_id=void 0,this.hv(),this.xd=!1,this.Nd=0}},Fs=li("[FeatureFlags]"),Ps=class{constructor(t,e){void 0===e&&(e=!1),this.Av=!1,this.update(t,e)}update(t,e){this.Rv=((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.Av||(Fs.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Av=!0),f(t.flag_keys)||h(t.flag_keys)||Fs.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Rv}},Rs=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Os=li("[Error tracking]"),Cs="webkit-masked-url:",Ms=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],$s=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Cs],Is=["__firefox__","__gCrWeb"];function js(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 Ds(t,e){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);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,e)||function(t,e){if(t){if("string"==typeof t)return js(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?js(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Ls=Object.entries,Ns=Object.setPrototypeOf,zs=Object.isFrozen,Us=Object.getPrototypeOf,Bs=Object.getOwnPropertyDescriptor,Hs=Object.freeze,qs=Object.seal,Vs=Object.create,Ws="undefined"!=typeof Reflect&&Reflect,Gs=Ws.apply,Ks=Ws.construct;Hs||(Hs=function(t){return t}),qs||(qs=function(t){return t}),Gs||(Gs=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)}),Ks||(Ks=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 Js,Xs=ga([].forEach),Ys=ga([].lastIndexOf),Zs=ga([].pop),Qs=ga([].push),ta=ga([].splice),ea=Array.isArray,ia=ga("".toLowerCase),ra=ga("".toString),na=ga("".match),sa=ga("".replace),aa=ga("".indexOf),oa=ga("".trim),la=ga((0).toString),ua=ga(Boolean.prototype.toString),ha="undefined"==typeof BigInt?null:ga(BigInt.prototype.toString),ca="undefined"==typeof Symbol?null:ga(Symbol.prototype.toString),va=ga({}.hasOwnProperty),da=ga({}.toString),fa=ga(/t/.test),pa=(Js=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return Ks(Js,e)});function ga(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return Gs(t,e,r)}}function ma(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ia;if(Ns&&Ns(t,null),!ea(e))return t;for(var r=e.length;r--;){var n=e[r];if("string"==typeof n){var s=i(n);s!==n&&(zs(e)||(e[r]=s),n=s)}t[n]=!0}return t}function ya(t){for(var e=0;t.length>e;e++)va(t,e)||(t[e]=null);return t}function ba(t){var e=Vs(null);for(var i of Ls(t)){var r=Ds(i,2),n=r[0],s=r[1];va(t,n)&&(e[n]=ea(s)?ya(s):s&&"object"==typeof s&&s.constructor===Object?ba(s):s)}return e}function _a(t,e){for(;null!==t;){var i=Bs(t,e);if(i){if(i.get)return ga(i.get);if("function"==typeof i.value)return ga(i.value)}t=Us(t)}return function(){return null}}var wa,xa=Hs(["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"]),Sa=Hs(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ka=Hs(["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"]),Ea=Hs(["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"]),Ta=Hs(["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"]),Aa=Hs(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fa=Hs(["#text"]),Pa=Hs(["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"]),Ra=Hs(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Oa=Hs(["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"]),Ca=Hs(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ma=qs(/{{[\w\W]*|^[\w\W]*}}/g),$a=qs(/<%[\w\W]*|^[\w\W]*%>/g),Ia=qs(/\${[\w\W]*/g),ja=qs(/^data-[\-\w.\u00B7-\uFFFF]+$/),Da=qs(/^aria-[\-\w]+$/),La=qs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Na=qs(/^(?:\w+script|data):/i),za=qs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ua=qs(/^html$/i),Ba=qs(/^[a-z][.\w]*(-[.\w]+)+$/i),Ha=qs(/<[/\w!]/g),qa=qs(/<[/\w]/g),Va=qs(/<\/no(script|embed|frames)/i),Wa=qs(/\/>/i),Ga=function(){return"undefined"==typeof window?null:window},Ka=function(t,e,i,r){return va(t,e)&&ea(t[e])?ma(r.base?ba(r.base):{},t[e],r.transform):i},Ja=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ga(),i=e=>t(e);if(i.version="3.4.13",i.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return i.isSupported=!1,i;var r,n=e.document,s=n,a=s.currentScript,o=e.HTMLTemplateElement,l=e.Node,u=e.NodeFilter,h=e.DOMParser,c=e.trustedTypes,v=e.Element.prototype,d=_a(v,"cloneNode"),f=_a(v,"remove"),p=_a(v,"nextSibling"),g=_a(v,"childNodes"),m=_a(v,"parentNode"),y=_a(v,"shadowRoot"),b=_a(v,"attributes"),_=l&&l.prototype?_a(l.prototype,"nodeType"):null,w=l&&l.prototype?_a(l.prototype,"nodeName"):null,x=l&&l.prototype?_a(l.prototype,"ownerDocument"):null;if("function"==typeof o){var S=n.createElement("template");S.content&&S.content.ownerDocument&&(n=S.content.ownerDocument)}var k,E="",T=!1,A=0,F=function(){if(A>0)throw pa('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.')},P=function(t){F(),A++;try{return r.createHTML(t)}finally{A--}},R=n.implementation,O=n.createNodeIterator,C=n.createDocumentFragment,M=n.getElementsByTagName,I=s.importNode,j={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof Ls&&"function"==typeof m&&R&&void 0!==R.createHTMLDocument;var D=Ma,L=$a,N=Ia,z=ja,U=Da,B=Na,H=za,q=Ba,V=La,W=null,G=ma({},[...xa,...Sa,...ka,...Ta,...Fa]),K=null,J=ma({},[...Pa,...Ra,...Oa,...Ca]),X=Object.seal(Vs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Y=null,Z=null,Q=Object.seal(Vs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),tt=!0,et=!0,it=!1,rt=!0,nt=!1,st=!0,at=!1,ot=!1,lt=null,ut=null,ht=!1,ct=!1,vt=!1,dt=!1,ft=!0,pt=!1,gt="user-content-",mt=!0,yt=!1,bt={},_t=null,wt=ma({},["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"]),xt=null,St=ma({},["audio","video","img","source","image","track"]),kt=null,Et=ma({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Tt="http://www.w3.org/1998/Math/MathML",At="http://www.w3.org/2000/svg",Ft="http://www.w3.org/1999/xhtml",Pt=Ft,Rt=!1,Ot=null,Ct=ma({},[Tt,At,Ft],ra),Mt=Hs(["mi","mo","mn","ms","mtext"]),$t=ma({},Mt),It=Hs(["annotation-xml"]),jt=ma({},It),Dt=ma({},["title","style","font","a","script"]),Lt=null,Nt=["application/xhtml+xml","text/html"],zt=null,Ut=null,Bt=n.createElement("form"),Ht=function(t){return t instanceof RegExp||t instanceof Function},qt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Ut||Ut!==t){t&&"object"==typeof t||(t={}),t=ba(t),Lt=-1===Nt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,W=Ka(t,"ALLOWED_TAGS",G,{transform:zt="application/xhtml+xml"===Lt?ra:ia}),K=Ka(t,"ALLOWED_ATTR",J,{transform:zt}),Ot=Ka(t,"ALLOWED_NAMESPACES",Ct,{transform:ra}),kt=Ka(t,"ADD_URI_SAFE_ATTR",Et,{transform:zt,base:Et}),xt=Ka(t,"ADD_DATA_URI_TAGS",St,{transform:zt,base:St}),_t=Ka(t,"FORBID_CONTENTS",wt,{transform:zt}),Y=Ka(t,"FORBID_TAGS",ba({}),{transform:zt}),Z=Ka(t,"FORBID_ATTR",ba({}),{transform:zt}),bt=!!va(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?ba(t.USE_PROFILES):t.USE_PROFILES),tt=!1!==t.ALLOW_ARIA_ATTR,et=!1!==t.ALLOW_DATA_ATTR,it=t.ALLOW_UNKNOWN_PROTOCOLS||!1,rt=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,nt=t.SAFE_FOR_TEMPLATES||!1,st=!1!==t.SAFE_FOR_XML,at=t.WHOLE_DOCUMENT||!1,ct=t.RETURN_DOM||!1,vt=t.RETURN_DOM_FRAGMENT||!1,dt=t.RETURN_TRUSTED_TYPE||!1,ht=t.FORCE_BODY||!1,ft=!1!==t.SANITIZE_DOM,pt=t.SANITIZE_NAMED_PROPS||!1,mt=!1!==t.KEEP_CONTENT,yt=t.IN_PLACE||!1,V=function(t){try{return fa(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:La,Pt="string"==typeof t.NAMESPACE?t.NAMESPACE:Ft,$t=va(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?ba(t.MATHML_TEXT_INTEGRATION_POINTS):ma({},Mt),jt=va(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?ba(t.HTML_INTEGRATION_POINTS):ma({},It);var e=va(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?ba(t.CUSTOM_ELEMENT_HANDLING):Vs(null);if(X=Vs(null),va(e,"tagNameCheck")&&Ht(e.tagNameCheck)&&(X.tagNameCheck=e.tagNameCheck),va(e,"attributeNameCheck")&&Ht(e.attributeNameCheck)&&(X.attributeNameCheck=e.attributeNameCheck),va(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(X.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),qs(X),nt&&(et=!1),vt&&(ct=!0),bt&&(W=ma({},Fa),K=Vs(null),!0===bt.html&&(ma(W,xa),ma(K,Pa)),!0===bt.svg&&(ma(W,Sa),ma(K,Ra),ma(K,Ca)),!0===bt.svgFilters&&(ma(W,ka),ma(K,Ra),ma(K,Ca)),!0===bt.mathMl&&(ma(W,Ta),ma(K,Oa),ma(K,Ca))),Q.tagCheck=null,Q.attributeCheck=null,va(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Q.tagCheck=t.ADD_TAGS:ea(t.ADD_TAGS)&&(W===G&&(W=ba(W)),ma(W,t.ADD_TAGS,zt))),va(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Q.attributeCheck=t.ADD_ATTR:ea(t.ADD_ATTR)&&(K===J&&(K=ba(K)),ma(K,t.ADD_ATTR,zt))),va(t,"ADD_URI_SAFE_ATTR")&&ea(t.ADD_URI_SAFE_ATTR)&&ma(kt,t.ADD_URI_SAFE_ATTR,zt),va(t,"FORBID_CONTENTS")&&ea(t.FORBID_CONTENTS)&&(_t===wt&&(_t=ba(_t)),ma(_t,t.FORBID_CONTENTS,zt)),va(t,"ADD_FORBID_CONTENTS")&&ea(t.ADD_FORBID_CONTENTS)&&(_t===wt&&(_t=ba(_t)),ma(_t,t.ADD_FORBID_CONTENTS,zt)),mt&&(W["#text"]=!0),at&&ma(W,["html","head","body"]),W.table&&(ma(W,["tbody"]),delete Y.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw pa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw pa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');var i=r;r=t.TRUSTED_TYPES_POLICY;try{E=P("")}catch(t){throw r=i,t}}else null===t.TRUSTED_TYPES_POLICY?(r=void 0,E=""):(void 0===r&&(T||(k=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}}(c,a),T=!0),r=k),r&&"string"==typeof E&&(E=P("")));Hs&&Hs(t),Ut=t}},Vt=ma({},[...Sa,...ka,...Ea]),Wt=ma({},[...Ta,...Aa]),Gt=function(t){Qs(i.removed,{element:t});try{m(t).removeChild(t)}catch(e){if(f(t),!m(t))throw pa("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Kt=function(t){Yt(t);var e=g(t);if(e){var i=[];Xs(e,t=>{Qs(i,t)}),Xs(i,t=>{try{f(t)}catch(t){}})}var r=b(t);if(r)for(var n=r.length-1;n>=0;--n){var s=r[n],a=s&&s.name;if("string"==typeof a)try{t.removeAttribute(a)}catch(t){}}},Jt=function(t,e){try{Qs(i.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Qs(i.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(ct||vt)try{Gt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Xt=function(t){var e=b(t);if(e)for(var i=e.length-1;i>=0;--i){var r=e[i],n=r&&r.name;if("string"==typeof n&&!K[zt(n)])try{t.removeAttribute(n)}catch(t){}}},Yt=function(t){for(var e=[t];e.length>0;){var i=e.pop();1===(_?_(i):i.nodeType)&&Xt(i);var r=g(i);if(r)for(var n=r.length-1;n>=0;--n)e.push(r[n])}},Zt=function(t){var e=null,i=null;if(ht)t="<remove></remove>"+t;else{var s=na(t,/^[\r\n\t ]+/);i=s&&s[0]}"application/xhtml+xml"===Lt&&Pt===Ft&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var a=r?P(t):t;if(Pt===Ft)try{e=(new h).parseFromString(a,Lt)}catch(t){}if(!e||!e.documentElement){e=R.createDocument(Pt,"template",null);try{e.documentElement.innerHTML=Rt?E:a}catch(t){}}var o=e.body||e.documentElement;return t&&i&&o.insertBefore(n.createTextNode(i),o.childNodes[0]||null),Pt===Ft?M.call(e,at?"html":"body")[0]:at?e.documentElement:o},Qt=function(t){var e=x?x(t):t.ownerDocument;return O.call(e||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},te=function(t){return t=sa(t,D," "),t=sa(t,L," "),sa(t,N," ")},ee=function(t){var e;t.normalize();for(var i=x?x(t):t.ownerDocument,r=O.call(i||t,t,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null),n=r.nextNode();n;)n.data=te(n.data),n=r.nextNode();var s=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");s&&Xs(s,t=>{re(t.content)&&ee(t.content)})},ie=function(t){var e=w?w(t):null;return"string"==typeof e&&"form"===zt(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==b(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==_(t)||t.childNodes!==g(t))},re=function(t){if(!_||"object"!=typeof t||null===t)return!1;try{return 11===_(t)}catch(t){return!1}},ne=function(t){if(!_||"object"!=typeof t||null===t)return!1;try{return"number"==typeof _(t)}catch(t){return!1}};function se(t,e,r){0!==t.length&&Xs(t,t=>{t.call(i,e,r,Ut)})}var ae=function(t,e,i,r){return 0===t.length?e:e===i||e===r?ba(e):e},oe=function(t,e){if(se(j.beforeSanitizeElements,t,null),t!==e&&null===m(t))return yt&&Yt(t),!0;if(ie(t))return Gt(t),!0;var r=zt(w?w(t):t.nodeName);if(W=ae(j.uponSanitizeElement,W,G,lt),se(j.uponSanitizeElement,t,{tagName:r,allowedTags:W}),t!==e&&null===m(t))return yt&&Yt(t),!0;if(function(t,e){return!!(st&&t.hasChildNodes()&&!ne(t.firstElementChild)&&fa(Ha,t.textContent)&&fa(Ha,t.innerHTML))||!(!st||t.namespaceURI!==Ft||"style"!==e||!ne(t.firstElementChild))||7===t.nodeType||!(!st||8!==t.nodeType||!fa(qa,t.data))}(t,r))return Gt(t),!0;if(Y[r]||!(Q.tagCheck instanceof Function&&Q.tagCheck(r))&&!W[r]){var n=function(t,e,i){if(!Y[e]&&he(e)){if(X.tagNameCheck instanceof RegExp&&fa(X.tagNameCheck,e))return!1;if(X.tagNameCheck instanceof Function&&X.tagNameCheck(e))return!1}if(mt&&!_t[e]){var r=m(t),n=g(t);if(n&&r)for(var s=n.length-1;s>=0;--s){var a=t===i?d(n[s],!0):n[s];r.insertBefore(a,p(t))}}return Gt(t),!0}(t,r,e);return!1===n&&se(j.afterSanitizeElements,t,null),n}if(1===(_?_(t):t.nodeType)&&!function(t){var e=m(t);e&&e.tagName||(e={namespaceURI:Pt,tagName:"template"});var i=ia(t.tagName),r=ia(e.tagName);return!!Ot[t.namespaceURI]&&(t.namespaceURI===At?function(t,e,i){return e.namespaceURI===Ft?"svg"===t:e.namespaceURI===Tt?"svg"===t&&("annotation-xml"===i||$t[i]):Boolean(Vt[t])}(i,e,r):t.namespaceURI===Tt?function(t,e,i){return e.namespaceURI===Ft?"math"===t:e.namespaceURI===At?"math"===t&&jt[i]:Boolean(Wt[t])}(i,e,r):t.namespaceURI===Ft?function(t,e,i){return!(e.namespaceURI===At&&!jt[i])&&!(e.namespaceURI===Tt&&!$t[i])&&!Wt[t]&&(Dt[t]||!Vt[t])}(i,e,r):!("application/xhtml+xml"!==Lt||!Ot[t.namespaceURI]))}(t))return Gt(t),!0;if(("noscript"===r||"noembed"===r||"noframes"===r)&&fa(Va,t.innerHTML))return Gt(t),!0;if(nt&&3===t.nodeType){var s=te(t.textContent);t.textContent!==s&&(Qs(i.removed,{element:t.cloneNode()}),t.textContent=s)}return se(j.afterSanitizeElements,t,null),!1},le=function(t,e,i){if(Z[e])return!1;if(st&&"patchsrc"===e)return!1;if(st&&"for"===e&&"label"!==t&&"output"!==t)return!1;if(ft&&("id"===e||"name"===e)&&(i in n||i in Bt))return!1;var r=K[e]||Q.attributeCheck instanceof Function&&Q.attributeCheck(e,t);if(et&&fa(z,e));else if(tt&&fa(U,e));else if(r){if(kt[e]);else if(fa(V,sa(i,H,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==aa(i,"data:")||!xt[t])if(it&&!fa(B,sa(i,H,"")));else if(i)return!1}else if(!(he(t)&&(X.tagNameCheck instanceof RegExp&&fa(X.tagNameCheck,t)||X.tagNameCheck instanceof Function&&X.tagNameCheck(t))&&(X.attributeNameCheck instanceof RegExp&&fa(X.attributeNameCheck,e)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(e,t))||"is"===e&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fa(X.tagNameCheck,i)||X.tagNameCheck instanceof Function&&X.tagNameCheck(i))))return!1;return!0},ue=ma({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),he=function(t){return!ue[ia(t)]&&fa(q,t)},ce=function(t,e,i,n){if(r&&"object"==typeof c&&"function"==typeof c.getAttributeType&&!i)switch(c.getAttributeType(t,e)){case"TrustedHTML":return P(n);case"TrustedScriptURL":return function(t){F(),A++;try{return r.createScriptURL(t)}finally{A--}}(n)}return n},ve=function(t,e,r,n){try{r?t.setAttributeNS(r,e,n):t.setAttribute(e,n),ie(t)?Gt(t):Zs(i.removed)}catch(i){Jt(e,t)}},de=function(t){se(j.beforeSanitizeAttributes,t,null);var e=t.attributes;if(e&&!ie(t)){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K=ae(j.uponSanitizeAttribute,K,J,ut),forceKeepAttr:void 0},r=e.length,n=zt(t.nodeName);r--;){var s=e[r],a=s.name,o=s.namespaceURI,l=s.value,u=zt(a),h=l,c="value"===a?h:oa(h);i.attrName=u,i.attrValue=c,i.keepAttr=!0,i.forceKeepAttr=void 0,se(j.uponSanitizeAttribute,t,i),c=i.attrValue,!pt||"id"!==u&&"name"!==u||0===aa(c,gt)||(Jt(a,t),c=gt+c),st&&fa(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,c)||"attributename"===u&&na(c,"href")?Jt(a,t):i.forceKeepAttr||(!i.keepAttr||!rt&&fa(Wa,c)?Jt(a,t):(nt&&(c=te(c)),le(n,u,c)?(c=ce(n,u,o,c))!==h&&ve(t,a,o,c):Jt(a,t)))}se(j.afterSanitizeAttributes,t,null)}},fe=function(t){var e=null,i=Qt(t);for(se(j.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if(se(j.uponSanitizeShadowNode,e,null),oe(e,t),de(e),re(e.content)&&fe(e.content),1===(_?_(e):e.nodeType)){var r=y(e);re(r)&&(pe(r),fe(r))}se(j.afterSanitizeShadowDOM,t,null)},pe=function(t){for(var e=[{node:t,shadow:null}];e.length>0;){var i=e.pop();if(i.shadow)fe(i.shadow);else{var r=i.node,n=1===(_?_(r):r.nodeType),s=g(r);if(s)for(var a=s.length-1;a>=0;--a)e.push({node:s[a],shadow:null});if(n){var o=w?w(r):null;if("string"==typeof o&&"template"===zt(o)){var l=r.content;re(l)&&e.push({node:l,shadow:null})}}if(n){var u=y(r);re(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]:{},n=null,a=null,o=null,l=null;if((Rt=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ne(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return la(t);case"boolean":return ua(t);case"bigint":return ha?ha(t):"0";case"symbol":return ca?ca(t):"Symbol()";case"undefined":default:return da(t);case"function":case"object":if(null===t)return da(t);var e=t,i=_a(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:da(r)}return da(t)}}(t)))throw pa("dirty is not a string, aborting");if(!i.isSupported)return t;ot?(W=lt,K=ut):qt(e),(j.uponSanitizeElement.length>0||j.uponSanitizeAttribute.length>0)&&(W=ba(W)),j.uponSanitizeAttribute.length>0&&(K=ba(K)),i.removed=[];var u=yt&&"string"!=typeof t&&ne(t);if(u){!function(t){if(st)for(var e=[t];e.length>0;){var i=e.pop(),r=_?_(i):i.nodeType;if(7===r||8===r&&fa(qa,i.data))try{f(i)}catch(t){}else{if(1===r){var n=i,s=zt(w?w(i):i.nodeName);try{n.hasAttribute&&n.hasAttribute("patchsrc")&&n.removeAttribute("patchsrc"),n.hasAttribute&&n.hasAttribute("for")&&"label"!==s&&"output"!==s&&n.removeAttribute("for")}catch(t){}}var a=g(i);if(a)for(var o=a.length-1;o>=0;--o)e.push(a[o])}}}(t);var h=w?w(t):t.nodeName;if("string"==typeof h){var c=zt(h);if(!W[c]||Y[c])throw Kt(t),pa("root node is forbidden and cannot be sanitized in-place")}if(ie(t))throw Kt(t),pa("root node is clobbered and cannot be sanitized in-place");try{pe(t)}catch(e){throw Kt(t),e}}else if(ne(t))1===(a=(n=Zt("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?n=a:n.appendChild(a),pe(a);else{if(!ct&&!nt&&!at&&-1===t.indexOf("<"))return r&&dt?P(t):t;if(!(n=Zt(t)))return ct?null:dt?E:""}n&&ht&&Gt(n.firstChild);var v=u?t:n;try{for(var d=Qt(v);o=d.nextNode();)oe(o,v),de(o),re(o.content)&&fe(o.content)}catch(e){throw u&&(Kt(t),Xs(i.removed,t=>{t.element&&Yt(t.element)})),e}if(u)return Xs(i.removed,t=>{t.element&&Yt(t.element)}),nt&&ee(t),t;if(ct){if(nt&&ee(n),vt)for(l=C.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(K.shadowroot||K.shadowrootmode)&&(l=I.call(s,l,!0)),l}var p=at?n.outerHTML:n.innerHTML;return at&&W["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&fa(Ua,n.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+p),nt&&(p=te(p)),r&&dt?P(p):p},i.setConfig=function(){qt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ot=!0,lt=W,ut=K},i.clearConfig=function(){Ut=null,ot=!1,lt=null,ut=null,r=k,E=""},i.isValidAttribute=function(t,e,i){return Ut||qt({}),le(zt(t),zt(e),i)},i.addHook=function(t,e){"function"==typeof e&&va(j,t)&&Qs(j[t],e)},i.removeHook=function(t,e){if(va(j,t)){if(void 0!==e){var i=Ys(j[t],e);return-1===i?void 0:ta(j[t],i,1)[0]}return Zs(j[t])}},i.removeHooks=function(t){va(j,t)&&(j[t]=[])},i.removeAllHooks=function(){j={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}(),Xa="Refusing to render web experiment since the viewer is a likely bot",Ya={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Za={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>Zn(e,t),not_regex:(t,e)=>!Zn(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},Qa=li("[Conversations]"),to="Conversations not available yet.";function eo(){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;z.length>e;e++){var i=z[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(Le,t)?Le[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function io(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({},eo(),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 ro=["debug","log","warn","error","info"],no="console",so="__posthogHandledLogsRequestError",ao=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[so]=!0,i},oo=t=>!!t&&"object"==typeof t&&!0===t[so],lo=class{get Pv(){var t=this;return e({},this.A,{error(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];i.some(oo)||t.A.error(...i)}})}constructor(t,e){var i;this.Ma=t,this.Ov=e,this.name="logs",this.Fv=!1,this.Dv=!1,this.Lv=!1,this.A=li("[logs]"),this.tc=[],this.Nv=[],this.Nd=0,this.jv=!1,this.Ti=!1,this.qv=[],this.Bv=[],this.zv=!1,this.Hv=!1,this.Uv=!1,this.Wv=()=>{var t,e;this.Ti||(this.Nd=0,null==(t=this.Vv)||t.onReconnect(),null==(e=this.Gv)||e.onReconnect())},this.Fv=!(null==(i=t.get())||!i.captureConsoleLogs)}get Qv(){return!0}Jv(){}Zv(){if(!this.Uv){try{this.Yd=typeof window>"u"?void 0:window}catch(t){this.Yd=void 0}this.Yd&&(di(this.Yd,"online",this.Wv),this.Uv=!0)}}Kv(t,e,i,r){this.Zv();var n=io(this.Ma.get(),i);return[new Ke(this.Yv(t,e),n,this.Pv,()=>this.Ov(),t=>t(),void 0,r),n]}Xv(){var t=this.Ma.get();if(!this.Vv||this.tf!==t){var e;null==(e=this.Vv)||e.reset(),this.tf=t;var i=this.Kv(()=>this.tc,t=>{this.tc=t});this.Vv=i[0],this.ef=i[1]}return this.Vv}if(){var t=this.Ma.get();if(!this.Gv||this.nf!==t){var e;null==(e=this.Gv)||e.reset(),this.nf=t;var i=this.Kv(()=>this.Nv,t=>{this.Nv=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},no);this.Gv=i[0],this.sf=i[1]}return this.Gv}setup(t){if(!this.Ti&&!this.jv)return this.jv=!0,this.Ta=t,this.A=t.logger.createLogger("[logs]"),us(t.kv.initialize(),()=>{this.Ti||this.Xd(t)})}Xd(t){var e;this.Zv(),null!=(e=this.Ma.get())&&e.captureConsoleLogs&&(this.Fv=!0),(this.Fv||this.Ma.remoteConfigWillArrive&&t.kv.get(this.Ma.captureHintKey))&&this.rf();var i=!1,r=t.onRemoteConfig(t=>{var e;i=t.ok&&!0===(null==(e=t.config.logs)?void 0:e.captureConsoleLogs),this.onRemoteConfig(t)});this.Ti?r.dispose():(this.za=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Ti||(this.Ti=!0,this.af(),null==(t=this.za)||t.dispose(),this.za=void 0,this.Ta=void 0,this.Lv=!1,null==(e=this.Yd)||e.removeEventListener("online",this.Wv),null==(i=this.lf)||i.call(this),this.lf=void 0,null==(r=this.Vv)||r.clearQueue(),null==(n=this.Gv)||n.clearQueue(),null==(s=this.Vv)||s.reset(),null==(a=this.Gv)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Ti){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.uf():(null==(i=this.Ta)||i.kv.set(this.Ma.captureHintKey,!!r),r?(this.Fv=!0,this.Dv||this.rf(),this.loadIfEnabled()):this.uf())}}reset(){var t,e,i,r;this.af(),null==(t=this.Vv)||t.clearQueue(),this.tc=[],null==(e=this.Vv)||e.reset(),null==(i=this.Gv)||i.clearQueue(),this.Nv=[],null==(r=this.Gv)||r.reset(),this.Nd=0}captureLog(t){!this.Ti&&this.Ta&&this.Xv().captureLog(t)}captureConsoleLog(t){!this.Ti&&this.Ta&&this.if().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Ti&&this.Ta&&this.if().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.af(),null==(t=this.Gv)||t.clearQueue(),this.Nv=[]}uf(){this.Fv||this.af()}rf(){var t,e=this;if(!this.zv&&null!=(t=this.Yd)&&t.console){var i=io(this.Ma.get()).maxBufferSize,r=!0;this.Bv.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.Yd.console[t])}catch(t){return 1}n&&e.Bv.push(xn(e.Yd.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.cf(t,a,i)}catch(t){}return s.apply(e.Yd.console,a)};return a.__rrweb_original__=n,a}))};for(var s of ro)if(n(s))continue;this.zv=!0,this.hf=setTimeout(()=>{this.af()},3e4)}}cf(t,e,i){var r;if(this.zv&&!this.Hv&&0!==e.length)if(null!=(r=this.Ta)&&r.canCapture){if(i>this.qv.length){this.Hv=!0;try{this.qv.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Ov()})}finally{this.Hv=!1}}}else this.af()}af(){if(this.qv=[],this.zv){for(var t of(this.zv=!1,this.hf&&(clearTimeout(this.hf),this.hf=void 0),this.Bv))t();this.Bv=[]}}df(){var t=this.qv;return this.af(),t}get logger(){return this.vf||(this.vf={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.vf}flushLogs(t){this.Ta&&(t?this.ff(t):(this.Vv&&this.Vv.flush().catch(t=>this.pf(t)),this.Gv&&this.Gv.flush().catch(t=>this.pf(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Vv)?void 0:e.flush().catch(e=>t.pf(e)),n=null==(i=t.Gv)?void 0:i.flush().catch(e=>t.pf(e));yield r,yield n})()}pf(t){oo(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Ti&&this.Fv&&!this.Dv&&!this.Lv){var t=this.Jv();if(t){this.Lv=!0;try{t((t,e)=>{if(this.Lv=!1,!this.Ti&&this.Fv)if(t||!e)this.A.error("Could not load logs script",t),this.af();else{var i=this.df();this.lf=e.initialize(this.Ta),this.Dv=!0,i.length>0&&e.replay(this.Ta,i)}})}catch(t){throw this.Lv=!1,t}}else this.af()}}Yv(t,e){var i=this.Ta;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:e=>e===n.LogsQueue?t():void 0,setPersistedProperty(t,i){t===n.LogsQueue&&e(null!=i?i:[])},qs:t=>this.qs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}qs(t){return new Promise(e=>{if(pn(this.Nd,3))e({kind:"fatal",error:ao(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(n),e(t))},n=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:ao(void 0,"logs request timed out")})},9e4),s=this.Qv;this.Ta.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Ta.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.gf(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:new Error("logs request failed with status "+i)}):0===i?(t.error||this.A.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:ao(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})},t=>{r({kind:"retry-later",error:t})})}})}gf(t,e){(0!==t||e)&&(this.Nd=gn(t,this.Nd,3,()=>this.A.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.")))}ff(t){this.tc.length>0&&this.mf(t,this.tc,this.ef,this.Ta.library.name,t=>{this.tc=t}),this.Nv.length>0&&this.mf(t,this.Nv,this.sf,no,t=>{this.Nv=t})}mf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=qe(s,He(i,this.Ta.library.name,this.Ta.library.version),r,this.Ta.library.version);this.Ta.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Ta.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.pf(t))}}},uo=li("[NetworkMetrics]"),ho=()=>{var t;return null!=rn&&null!=(t=rn.performance)&&t.now?rn.performance.now():Date.now()},co={"http:":80,"https:":443},vo=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),fo=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Sr(r))?void 0:i.href)||r}},po=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=ho()-n,d=Sr(i.url);if(d&&"http:"!==d.protocol&&"https:"!==d.protocol)return;var f={url:(null==d?void 0:d.href)||i.url,method:i.method},g=c(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var m=o&&!h?void 0:((t,e)=>t?400>t?void 0:String(t):(null==e?void 0:e.name)||"_OTHER")(h,a),y=e({},e({"http.request.method":_=vo.has(b=f.method)?b:"_OTHER"},"_OTHER"===_&&b!==_?{"http.request.method_original":b}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||co[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(e=t.pathname,e.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var e})(d):{},h?{"http.response.status_code":h}:{},m?{"error.type":m}:{},null==u.attributes?void 0:u.attributes(f,{status:h,durationMs:v}));null==(l=t.metrics)||l.histogram(g,v,{unit:"ms",attributes:y})}catch(t){uo.error("Failed to record network metric",t)}var b,_},go=()=>{},mo=(t,e)=>c(null==rn?void 0:rn.fetch)?xn(rn,"fetch",i=>function(){for(var r=ho(),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=fo(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=>(po(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw po(t,d,void 0,r,e,i),i})}catch(t){return uo.error("Failed to observe fetch",t),o}}):go,yo=(t,e)=>{var i,r=null==rn||null==(i=rn.XMLHttpRequest)?void 0:i.prototype;if(!r)return go;var n=new WeakMap,s=xn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{fs.has(this)||n.set(this,fo(i[0],i[1]))}catch(t){uo.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=xn(r,"send",i=>function(){var r;try{var s=n.get(this);if(s&&e()){var a=ho();di(this,"loadend",r=()=>{this.removeEventListener("loadend",r),po(t,s,this.status,a,e)})}}catch(t){uo.error("Failed to observe XHR send",t)}try{for(var o=arguments.length,l=new Array(o),u=0;o>u;u++)l[u]=arguments[u];return i.apply(this,l)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{s(),a()}},bo=new WeakMap,_o=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),wo={maxStringLength:2048,truncationSuffix:"..."},xo={maxStringLength:2048,truncationSuffix:"..."};function So(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function ko(t,e){return{}.hasOwnProperty.call(t,e)}function Eo(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function To(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?Ae(r,wo):r).slice(0,e)}}function Ao(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function Fo(t){return Ae(t||"Unknown error",xo).slice(0,2048)}function Po(t,e){try{return Fo(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 Ro(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:Fo(t.value)}))}function Oo(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:Po(t,e),type:Oo(t,e)}}var Mo={featureFlags:class extends As{constructor(t){var e=new Ps(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.yf=e}get Jd(){return this._instance.persistence}updateConfig(t,e){this.yf.update(t,e),this.Zd()}}},$o={sessionRecording:class{get Dr(){return this._instance.config}get xc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.bf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this._f||"missing_config"===this._f?this._f:null!==(t=null==(e=this.bf)?void 0:e.status)&&void 0!==t?t:this._f}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this._f=jn,this.wf=void 0,this.kf=!1,this.Ye=(()=>{var t;if(null==an||!an.visibilityState||"visible"===an.visibilityState)return!0;var e=null==rn||null==(t=rn.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.an=()=>{var t;"visible"===(null==an?void 0:an.visibilityState)&&(this.Ye=!0,null==(t=this.bf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Ln.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Dr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=an&&an.addEventListener&&di(an,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.kf=!0,null==an||null==an.removeEventListener||an.removeEventListener("visibilitychange",this.an),i?this.Sf(!0):this.stopRecording()}get xf(){var t,e=!(null==(t=this._instance.get_property(Jr))||!t.enabled),i=!this.Dr.disable_session_recording,r=this.Dr.disable_session_recording||this._instance.consent.isOptedOut();return rn&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!(this.kf||this.xf&&null!=(e=this.bf)&&e.isStarted)){var i=!f(Object.assign)&&!f(Array.from);this.xf&&i?(this.$f(t),Ln.info("starting")):(this._f=jn,this.stopRecording())}}$f(t){var e,i;if(this.xf)if("awaiting_config"!==this._f&&"missing_config"!==this._f&&(this._f=Dn),null!=un&&null!=(e=un.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=un.__PosthogExtensions__)&&i.initSessionRecording)this.Cf(t);else{var r,n=this._instance.sessionManager;null==(r=un.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Tf,e=>{if(!this.kf&&this.xf&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[Qr]:!0}),Ln.error("could not load recorder",e)):void this.Cf(t);this._f=jn})}}stopRecording(){var t,e;null==(t=this.wf)||t.call(this),this.wf=void 0,null==(e=this.bf)||e.stop()}Sf(t){var e,i;void 0===t&&(t=!1),null==(e=this.wf)||e.call(this),this.wf=void 0,null==(i=this.bf)||i.discard({discardProducerEvents:t})}If(){var t,e;null==(t=this.xc)||t.unregister("$session_is_sampled"),null==(e=this.xc)||e.unregister("$replay_sample_rate")}Ef(t,e){if(y(t))return null;var i,r=b(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ln.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Mf(t){if(this.xc){var i,r,n=this.xc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Ef(null==(i=this.Dr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Ef(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.If();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[Jr]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};s(),null==(i=this.wf)||i.call(this),this.wf=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.Mf(e),void this.Sf()):(this.Mf(e),void this.startIfEnabledOrStop()):("awaiting_config"===this._f&&(this._f="missing_config",this._instance.register_for_session({[tn]:!0}),Ln.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.bf)&&i.log?this.bf.log(t,e):Ln.warn("log called before recorder was ready")}get Tf(){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"}Af(){var t,e=this._instance.get_property(Jr);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Ln.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!y(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Cf(t){var e,i,r;if(!this.kf&&this.xf&&this._instance.sessionManager){if(null==(e=un.__PosthogExtensions__)||!e.initSessionRecording)return Ln.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Qr]:!0});var n;if(this.bf||(this.bf=null==(n=un.__PosthogExtensions__)?void 0:n.initSessionRecording(this._instance,this.Ye),this.bf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Af()){if("missing_config"===this._f||"awaiting_config"===this._f)return;return this._f="awaiting_config",Ln.info("persisted remote config is stale, requesting fresh config before starting"),void new In(this._instance).load()}this._f=Dn,null==(i=(r=this.bf).setDocumentWasEverVisible)||i.call(r,this.Ye),this.bf.start(t)}else this._f=jn}onRRwebEmit(t){var e;null==(e=this.bf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.bf||null==(t=this.xc)||t.register({[Yr]:!0}),null==(e=this.bf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.bf||null==(t=this.xc)||t.register({[Xr]:!0}),null==(e=this.bf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.bf||null==(e=this.xc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.bf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Nn){var n,s=null==(n=this._instance.sessionPersistence)?void 0:n.get_property(r);f(s)||(i[r]=s)}return e({},i,(null==(t=this.bf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.bf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.bf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Io={autocapture:class extends Cr{constructor(t){super(new $r(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.Rf=!1,this._instance=t,this.Pf=this.Of()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Ff();return!!(t.path||t.search||this.Df(t))}startIfEnabled(){this.isEnabled&&(oi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Pf=this.Of(),this.startIfEnabled()}stop(){this.Lf&&this.Lf(),this.Lf=void 0,this.Nf&&this.Nf(),this.Nf=void 0,oi.info("History API monitoring stopped")}monitorHistoryChanges(){rn&&rn.history&&(this.jf("pushState"),this.jf("replaceState"),this.qf(),this.Df()&&this.Bf())}jf(t){var e;if(rn&&(null==(e=rn.history[t])||!e.__posthog_wrapped__)){var i=this;xn(rn.history,t,e=>function(r,n,s){var a;i.zf(s)&&i.Hf(),e.call(this,r,n,s),i.Uf(t,!i.Rf&&"popstate"!==(null==rn||null==(a=rn.event)?void 0:a.type))})}}Of(){var t=null==rn?void 0:rn.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Ff(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}Df(t){return void 0===t&&(t=this.Ff()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Wf(t){var e=this.Ff(),i=this.Pf;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.Df(e)&&t.hash!==i.hash))}Uf(t,e){void 0===e&&(e=!1);try{e||this.Hf();var i=this.Of();if(!i)return;if(this.Wf(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.Vf=r,Promise.resolve().then(()=>this.Hf())):r()}this.Pf=i}catch(e){oi.error("Error capturing "+t+" pageview",e)}}zf(t){var e,i;return!(y(t)||!rn)&&(null==(e=Sr(String(t)))?void 0:e.href)!==(null==(i=rn.location)?void 0:i.href)}Hf(){var t=this.Vf;if(t){this.Vf=void 0,this.Rf=!0;try{t()}catch(t){oi.error("Error capturing deferred pageview",t)}finally{this.Rf=!1}this.Pf=this.Of()}}qf(){if(!this.Lf){var t=()=>{this.Uf("popstate")};di(rn,"popstate",t),this.Lf=()=>{rn&&rn.removeEventListener("popstate",t)}}}Bf(){if(!this.Nf){var t=()=>{this.Uf("hashchange")};di(rn,"hashchange",t),this.Nf=()=>{rn&&rn.removeEventListener("hashchange",t)}}}},heatmaps:class{get Dr(){return this.instance.config}constructor(t){var e;this.Gf=!1,this.dl=!1,this.Qf=null,this.instance=t,this.Gf=!(null==(e=this.instance.persistence)||!e.props[Ur]),this.rageclicks=new xr(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Dr.capture_heatmaps)&&this.Dr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Dr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Dr.capture_heatmaps)?y(this.Dr.enable_heatmaps)?this.Gf:this.Dr.enable_heatmaps:!1!==this.Dr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.dl)return;zn.info("starting..."),this.Jf(),this.an()}else{var t;clearInterval(null!==(t=this.Qf)&&void 0!==t?t:void 0),this.Zf(),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({[Ur]:i}),this.Gf=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.At;return this.At=void 0,t}Kf(t){Un(t.originalEvent)&&this.Lr(t.originalEvent,"deadclick")}an(){this.Qf&&clearInterval(this.Qf),this.Qf="visible"===(null==an?void 0:an.visibilityState)?setInterval(this.uc.bind(this),this.flushIntervalMilliseconds):null}Jf(){rn&&an&&(this.Yf=this.uc.bind(this),di(rn,en,this.Yf),this.Xf=t=>this.Lr(t||(null==rn?void 0:rn.event)),di(an,"click",this.Xf,{capture:!0}),this.tp=t=>this.ep(t||(null==rn?void 0:rn.event)),di(an,"mousemove",this.tp,{capture:!0}),this.np=new vn(this.instance,cn,this.Kf.bind(this)),this.np.startIfEnabledOrStop(),this.sp=this.an.bind(this),di(an,Oi,this.sp),this.dl=!0)}Zf(){var t;rn&&an&&(this.Yf&&rn.removeEventListener(en,this.Yf),this.Xf&&an.removeEventListener("click",this.Xf,{capture:!0}),this.tp&&an.removeEventListener("mousemove",this.tp,{capture:!0}),this.sp&&an.removeEventListener(Oi,this.sp),clearTimeout(this.rp),null==(t=this.np)||t.stop(),this.dl=!1)}op(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(t,e,i){for(var r=t;r&&$i(r)&&!Ii(r,"body");){if(r===i)return!1;var n=void 0;try{var a,o,l;n=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:rn)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Gi(r)}return!1}(Hi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}Lr(t,i){var r;if(void 0===i&&(i="click"),!Mi(t.target)&&Un(t)){var n=this.op(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&sr(Hi(t),this.instance.config.rageclick)&&this.Qs(e({},n,{type:"rageclick"})),this.Qs(n)}}ep(t){!Mi(t.target)&&Un(t)&&(clearTimeout(this.rp),this.rp=setTimeout(()=>{this.Qs(this.op(t,"mousemove"))},500))}Qs(t){if(rn){var e=this.Dr.disable_capture_url_hashes?Y(rn.location.href):rn.location.href,i=this.Dr.custom_personal_data_properties,r=yn(e,this.Dr.mask_personal_data_properties?[...En,...i||[]]:[],An);this.At=this.At||{},this.At[r]||(this.At[r]=[]),this.At[r].push(t)}}uc(){this.At&&!d(this.At)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:vn,webVitalsAutocapture:class{constructor(t){var i,r=this;this._instance=t,this.Gf=!1,this.dl=!1,this.At={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.ap=function(t){void 0===t&&(t=!1),clearTimeout(r.lp),r.lp=void 0,0!==r.At.metrics.length&&(r._instance.capture("$web_vitals",e({$current_url:r.At.url},r.At.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.At={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.up=t=>{var i;if(this.At=this.At||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},y(null==t?void 0:t.name)||y(null==t?void 0:t.value))Pn.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.cp(r);if(!f(n)){var s=b(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.hp||this.hp>t.value){this.At.navigationKey!==s&&(this.ap(),this.lp=setTimeout(this.ap,this.flushToCaptureTimeoutMs)),f(this.At.navigationKey)&&(this.At.navigationKey=s,this.At.url=n),this.At.firstMetricTimestamp=f(this.At.firstMetricTimestamp)?Date.now():this.At.firstMetricTimestamp;var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});if(delete o.entries,v(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of Mn){var h="url"===u&&"string"==typeof t.attribution[u]?this.cp(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.At.metrics.push(o),this.At.metrics.length===this.allowedMetrics.length&&this.ap()}else Pn.error("Ignoring metric with value >= "+this.hp,t)}}},this.dp=()=>{if(!this.dl){var t,i,r,n,s=!1,a=un.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.vp])||("web-vitals"===this.vp&&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.up.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.up.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.up.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.up.bind(this),v);var d=null==rn?void 0:rn.document;di(d,Oi,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.ap(!0)}),di(rn,"pagehide",()=>this.ap(!0)),this.dl=!0}else Pn.error("web vitals callbacks not loaded - not starting")}},this.Gf=!(null==(i=this._instance.persistence)||!i.props[Vr]),this.startIfEnabled()}get fp(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.fp)?null==(t=this.fp)?void 0:t.web_vitals_allowed_metrics:void 0;return y(i)?(null==(e=this._instance.persistence)?void 0:e.props.$web_vitals_allowed_metrics)||On:i}get flushToCaptureTimeoutMs(){return(v(this.fp)?this.fp.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.fp)?this.fp.web_vitals_attribution:void 0;return _(t)?t?On:[]:h(t)?t:Cn}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.fp)?this.fp.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get hp(){var t=v(this.fp)&&b(this.fp.__web_vitals_max_value)?this.fp.__web_vitals_max_value:Rn;return t>0&&6e4>=t?Rn:t}get isEnabled(){var t=null==on?void 0:on.protocol;if("http:"!==t&&"https:"!==t)return Pn.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.fp)?this.fp.web_vitals:_(this.fp)?this.fp:void 0;return _(e)?e:this.Gf}startIfEnabled(){this.isEnabled&&!this.dl&&(Pn.info("enabled, starting..."),this.Pl(this.dp))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=v(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=v(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Vr]:i}),this._instance.persistence.register({[Kr]:r})),this.Gf=i,this.startIfEnabled()}}}get vp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Pl(t){var e=un.__PosthogExtensions__,i=this.vp,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&f(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,e=>{e?Pn.error("failed to load script",e):t()})}cp(t){var e=t||(null==rn?void 0:rn.location.href);if(e){var i=this._instance.config.disable_capture_url_hashes?Y(e):e,r=this._instance.config.custom_personal_data_properties;return yn(i,this._instance.config.mask_personal_data_properties?[...En,...r||[]]:[],An)}Pn.error("Could not determine current URL")}}},jo={exceptionObserver:class{constructor(t){var i;this.dp=()=>{var t;if(rn&&this.isEnabled&&null!=(t=un.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=un.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=un.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=un.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.pp&&this.Dr.capture_unhandled_errors&&(this.pp=e(this.captureException.bind(this))),!this.gp&&this.Dr.capture_unhandled_rejections&&(this.gp=i(this.captureException.bind(this))),!this.mp&&this.Dr.capture_console_errors&&(this.mp=r(this.captureException.bind(this)))}catch(t){dn.error("failed to start",t),this.yp()}}},this._instance=t,this.bp=!(null==(i=this._instance.persistence)||!i.props[Br]),this.kt=new R(e({},function(t){var e,i,r,n;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,A:dn})),this.Dr=this._p(),this.startIfEnabledOrStop()}_p(){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.bp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Dr.capture_console_errors||this.Dr.capture_unhandled_errors||this.Dr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(dn.info("enabled"),this.yp(),this.Pl(this.dp)):this.yp()}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",e=>{if(e)return dn.error("failed to load script",e);t()})}yp(){var t,e,i;null==(t=this.pp)||t.call(this),this.pp=void 0,null==(e=this.gp)||e.call(this),this.gp=void 0,null==(i=this.mp)||i.call(this),this.mp=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.bp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Br]:this.bp}),this.Dr=this._p(),this.startIfEnabledOrStop())}}onConfigChange(){this.Dr=this._p()}captureException(t){try{var e,i,r,n=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";if(this.kt.consumeRateLimit(n))return void dn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,r;this.wp=[],this.kp=new nt([new Et,new It,new At,new Tt,new Mt,new Ct,new Pt,new $t],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=mt.test(h)?h.replace(mt,"$1"):h;if(!c.match(/\S*Error: /)){for(var v of r){var d=v(c,t);if(d){s.push(d);var f=bt(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(St(s,l)>=50)break}}}var m=[...l].sort((t,e)=>e.start-t.start),y=m[m.length-1];if(y){var b=wt(s,y);for(var _ of(s.splice(y.start-b,b),m))_.start-=b}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++)kt(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",dt,gt)),this._instance=t,this.wp=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Sp=zt(this.xp()),this.$p=new Ut(this.Sp)}onConfigChange(){this.Sp=zt(this.xp()),this.$p.setConfig(this.Sp)}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.wp=s,this._instance.persistence&&this._instance.persistence.register({[Hr]:this.wp,[qr]:a})}}}get Cp(){var t,e,i=!!this._instance.get_property(qr);return null!==(t=null!==(e=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==e?e:i)&&void 0!==t&&t}buildProperties(t,e){return this.kp.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Sp.enabled)try{if(!p(t)||0===t.trim().length)return void Os.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)=>Lt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.Tp(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&Os.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.$p.add(e({[jt]:t,[Dt]:(new Date).toISOString()},n))}catch(t){Os.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Ip(e)){if(this.Ep(e))return this.Mp("Exception dropped: matched a suppression rule"),void Os.info("Skipping exception capture because a suppression rule matched");if(!this.Cp&&this.Ap(e))return this.Mp("Exception dropped: thrown by a browser extension"),void Os.info("Skipping exception capture because it was thrown by an extension");if(!this.Cp&&this.Rp(e))return this.Mp("Exception dropped: thrown by an injected browser script"),void Os.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Pp(e))return this.Mp("Exception dropped: thrown by the PostHog SDK"),void Os.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Sp.enabled&&y(t.$exception_steps)?this.Op(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.$p.clear(),n}catch(t){return Rs(t)||Os.error("Failed to capture exception event. Dropping this exception.",t),void this.$p.clear()}}catch(t){return void(Rs(t)||Os.error("Failed to process exception event. Ignoring this exception.",t))}}Op(t){try{var i=this.$p.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return Os.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Mp(t){this.Sp.enabled&&this.$p.add({[jt]:t,[Dt]:(new Date).toISOString()})}Tp(t){return v(t)?e({},t):{}}xp(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Ep(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.wp.some(t=>{var i=t.values.map(t=>{var i=ts[t.operator],r=e[t.key];if(!i||!r)return!1;var n=h(t.value)?t.value:[t.value];return n.length>0&&i(n,r)});return"OR"===t.type?i.some(Boolean):i.every(Boolean)})}catch(t){return Os.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Ap(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&&$s.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(Cs)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&Ms.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(Cs))}))}Rp(t){return t.some(t=>{var e=t.value;return p(e)&&Is.some(t=>e.includes(t))})}Pp(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}Ip(t){return!y(t)&&h(t)}}},Do=e({productTours:class{get xc(){return this._instance.persistence}constructor(t){this.Fp=null,this.Dp=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.xc&&this.xc.register({[Gr]:!!e.productTours}),!Hn(this._instance))return!this.Fp&&y(null==(i=this.xc)?void 0:i.props.ph_product_tours)||Bn.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Fp)||r.stop(),this.Fp=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Fp&&Hn(this._instance)&&this.Pl(()=>this.Lp())}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",e=>{e?Bn.error("Could not load product tours script",e):t()})}Lp(){var t;!this.Fp&&null!=(t=un.__PosthogExtensions__)&&t.generateProductTours&&(this.Fp=un.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.Dp)||e){var i=this.xc;if(i){var r=i.props[Zr];if(h(r)&&!e)return this.Dp=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:e=>{if(Hn(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var n="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||Bn.warn(n):Bn.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.Dp=s,i&&i.register({[Zr]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Dp,{isLoaded:!0})}getActiveProductTours(t){y(this.Fp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fp.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Fp)||e.showTourById(t)}previewTour(t){this.Fp?this.Fp.previewTour(t):this.Pl(()=>{var e;this.Lp(),null==(e=this.Fp)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Fp)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Fp)||t.nextStep()}previousStep(){var t;null==(t=this.Fp)||t.previousStep()}clearCache(){var t;this.Dp=null,null==(t=this.xc)||t.unregister(Zr)}resetTour(t){var e;null==(e=this.Fp)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Fp)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Fp)||e.cancelPendingTour(t)}}},Mo),Lo={siteApps:class{constructor(t){this._instance=t,this.Np=0,this.jp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}qp(t,e){if(e){var i=this.globalsForEvent(e);this.jp.push(i),this.jp.length>1e3&&(this.jp=this.jp.slice(10))}}get siteAppLoaders(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.qp.bind(this));this.Bp=()=>{t(),this.jp=[],this.Bp=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}}zp(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(qn.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(qn.error("prepare_external_dependency_script returned null"),null):t}Hp(){var t,e,i,r,n,s,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==an?void 0:an.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Np++,this.Up)return this.Wp();var h=[],c=this,v=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.zp(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.Up=()=>{h.forEach(t=>t()),this.Up=void 0},this.Wp()}Wp(){var t=!1;return()=>{var e;t||(t=!0,this.Np--,0===this.Np&&(null==(e=this.Up)||e.call(this)))}}Vp(t,e){void 0===e&&(e=!0);var i=this.Hp();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.jp.length&&(qn.info("Processing "+this.jp.length+" events for site app with id "+t.id),this.jp.forEach(t=>this.Vp(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.Bp)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,qn.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.Vp(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){qn.error(Vn+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){qn.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Gp(){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)}Qp(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Vp(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){qn.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var n of Object.values(this.apps))r(n)}}onRemoteConfig(t){var e,i,r,n=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Gp(),void this._instance.on("eventCaptured",t=>this.Qp(t))):void qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Bp)||i.call(this),t.ok){var s=t.config;if(null!=(r=s.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,e=o.id,i=o.url;un["__$$ph_site_app_"+e]=n._instance,null==(t=un.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return qn.error(Vn+e,t)})};for(var o of s.siteApps)a()}else qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},No={tracingHeaders:class{constructor(t){this._instance=t,this.Jp=void 0,this.Zp=void 0,this.Kp=void 0,this.dp=()=>{var t,e,i=this.Yp();i?(f(this.Jp)&&(this.Jp=null==(t=un.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.Zp)&&(this.Zp=null==(e=un.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.yp()}}initialize(){this.startIfEnabledOrStop()}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",e=>{if(e)return Sn.error("failed to load script",e);t()})}Xp(){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}Yp(){var t=this.Xp();return h(t)?(h(this.Kp)?this.Kp.splice(0,this.Kp.length,...t):this.Kp=[...t],t.length>0?this.Kp:void 0):(h(this.Kp)&&this.Kp.splice(0),this.Kp=t||void 0,this.Kp)}yp(){var t,e;null==(t=this.Jp)||t.call(this),null==(e=this.Zp)||e.call(this),this.Jp=void 0,this.Zp=void 0}startIfEnabledOrStop(){this.Yp()?this.Pl(this.dp):this.yp()}}},zo=e({surveys:class extends vs{constructor(t){super(new ps(t))}}},Mo),Uo={toolbar:class{constructor(t){this.instance=t}tg(t){un.ph_toolbar_state=t}eg(){var t;return null!==(t=un.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),fi(this.instance.config))return!1;if(!rn||!an)return!1;t=null!=t?t:rn.location,i=null!=i?i:rn.history;try{if(!e){try{rn.localStorage.setItem("test","test"),rn.localStorage.removeItem("test")}catch(t){return!1}e=null==rn?void 0:rn.localStorage}var r,n=gs||bn(t.hash,"__posthog")||bn(t.hash,"state"),s=n?Z(()=>JSON.parse(atob(decodeURIComponent(n))))||Z(()=>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(ms)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}ig(t){var e=un.ph_load_toolbar||un.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):ys.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==an||!an.getElementById("__POSTHOG_TOOLBAR__"));if(!rn||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(rn.localStorage.setItem(ms,JSON.stringify(e({},n,{source:void 0}))),2===this.eg())this.ig(n);else if(0===this.eg()){var s;this.tg(1),null==(s=un.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return ys.error("[Toolbar] Failed to load",t),void this.tg(0);this.tg(2),this.ig(n)}),di(rn,"turbolinks:load",()=>{this.tg(0),this.loadToolbar(n)})}return!0}ng(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)}}},Bo=e({experiments:class t{get Dr(){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.sg("retrieved web experiments from the server"),i.rg=new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.rg&&(t.sg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.rg)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.og(e.name,n,e.variants[n].transforms)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.ag(a,i._instance)&&i.og(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.sg(Xa);else if(!this.Dr.disable_web_experiments){if(y(this.rg))return this.rg=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.sg("applying feature flags",e),e.forEach(t=>{var e;if(this.rg&&null!=(e=this.rg)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.rg)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.og(n.name,r,n.variants[r].transforms)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=mn(null==e?void 0:e.search,"__experiment_id"),r=mn(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.sg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.lg(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Dr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Dr.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.Dr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}lg(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.sg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.og(n[0].name,i,n[0].variants[i].transforms))}static ag(e,i){return!y(e.conditions)&&t.ug(e,i)&&t.cg(e)}static ug(e,i){var r;if(y(e.conditions)||y(null==(r=e.conditions)?void 0:r.url))return!0;var n=t.getWindowLocation();if(n){var s,a,o,l=pi(i,n.href);return null==(s=e.conditions)||!s.url||Za[null!==(a=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return null==rn?void 0:rn.location}static cg(t){var e;if(y(t.conditions)||y(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!an)return{};var r,n,s,a=e?[...En,...i||[]]:[],o=(r=yn(an.URL,a,An),n=Tn.concat(t||[]),s={},hi(n,function(t){var e=mn(r,t);s[t]=e||null}),s);return ci(function(){var t={};return hi(Fn,function(e){var i=(t=>{if(an){try{for(var e=t+"=",i=an.cookie.split(";").filter(t=>t.length),r=0;i.length>r;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}})(e);t[e]=i||null}),t}(),o)}();if(i.utm_source){var r,n,s,a,o,l,u,h,c=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(n=t.conditions)||null==(n=n.utm)?void 0:n.utm_campaign)==i.utm_campaign,v=null==(s=t.conditions)||null==(s=s.utm)||!s.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,d=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return c&&d&&f&&v}return!1}static sg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];oi.info("[WebExperiments] "+t,i)}static hg(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.hg(e)})}og(i,r,n){this._is_bot()?t.sg(Xa):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.sg("applying transform of variant "+r+" for experiment "+i+" ",n);var a=null==(s=document)?void 0:s.querySelectorAll(n.selector),o=new Map;null==a||a.forEach(i=>{if("script"!==i.localName.toLowerCase()){var r=i;if(n.html){var s,a="http://www.w3.org/1998/Math/MathML"===i.namespaceURI&&"annotation-xml"===i.localName&&(null==(s=i.getAttribute("encoding"))?void 0:s.toLowerCase())||"",l=JSON.stringify([i.namespaceURI,i.localName,a]),u=o.get(l);if(y(u)){var h=null!=wa?wa:wa=Ja(),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({},Ya,{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({},Ya,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.hg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.sg("Control variants leave the page unmodified.")}_is_bot(){return sn&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&F(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>F(null==t?void 0:t.brand,e)))return!0}catch(t){}return!!t.webdriver}(sn,this.Dr.custom_blocked_useragents):void 0}}},Mo),Ho={conversations:class{constructor(t){this._instance=t,this.dg=void 0,this._conversationsManager=null,this.vg=!1,this.ie=null,this.fg=!1,this.pg=0,this.gg=null,this.mg=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.gg=null;else if(this.yg=t.ok,t.ok){var e=t.config.conversations;y(e)?this.gg=null:(_(e)?this.dg=e:(this.dg=e.enabled,this.ie=e),this.dg||(this.gg=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.pg++,this.dg=void 0,this.ie=null,this.yg=void 0,this.fg=!1,this.gg=null}loadIfEnabled(){if(!(this._conversationsManager||this.vg||this._instance.config.disable_conversations||fi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==un?void 0:un.__PosthogExtensions__;if(t&&!f(this.dg)&&this.dg)if(this.ie&&this.ie.token){this.vg=!0;try{var e=t.initConversations;if(e)return this.bg(e),void(this.vg=!1);var i=t.loadExternalDependency;if(!i)return void this._g(Dr);var r=this.pg;i(this._instance,"conversations",e=>{if(r!==this.pg)return this.vg=!1,void this.loadIfEnabled();e||!t.initConversations?this._g("Could not load conversations script",e):this.bg(t.initConversations),this.vg=!1})}catch(t){this._g("Error initializing conversations",t),this.vg=!1}}else Qa.error("Conversations enabled but missing token in remote config.")}}bg(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.fg=!1,Qa.info("Conversations loaded successfully")}catch(t){return void this._g("Error completing conversations initialization",t)}this.mg&&this._conversationsManager.setTheme(this.mg),this.wg()}else Qa.error("Cannot complete initialization: remote config is null")}wg(){var t=this.gg;this.gg=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}_g(t,e){Qa.error(t,e),this._conversationsManager=null,this.vg=!1,this.fg=!0}show(){this._conversationsManager?this._conversationsManager.show():Qa.warn("Conversations not loaded yet.")}hide(){"open"===this.gg&&(this.gg=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.gg=null,this._conversationsManager.open()):this.gg="open"}close(){this._conversationsManager?(this.gg=null,this._conversationsManager.close()):this.gg="close"}setTheme(t){var i,r;this.mg=e({},this.mg,t,{dark:e({},null==(i=this.mg)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.dg&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":fi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.yg?"remote_config_failed":f(this.dg)?this.yg?"disabled_in_project":"remote_config_pending":this.dg?y(this.ie)||!this.ie.token?"missing_token":null!=un&&un.__PosthogExtensions__?this.vg?"initializing":this.fg?"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):(Qa.warn(to),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Qa.warn(to),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Qa.warn(to),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Qa.warn(to),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Qa.warn(to),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Qa.warn(to),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Qa.warn(to),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()}}},qo={logs:class extends lo{constructor(t){super({get(){var e;return null==t||null==(e=t.config)?void 0:e.logs},captureHintKey:"$logs_capture_enabled_server_side",get remoteConfigWillArrive(){var e;return!(null!=t._shouldDisableFlags&&t._shouldDisableFlags()&&(null==(e=un._POSTHOG_REMOTE_CONFIG)||null==(e=e[t.config.token])||!e.config))}},()=>function(t){var e,i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){var r=t.sessionManager.checkAndGetSessionAndWindowId(!0),n=r.windowId,s=r.sessionStartTimestamp,a=r.lastActivityTimestamp;i.sessionId=r.sessionId,i.windowId=n,y(s)||(i.sessionStartTimestamp=s),y(a)||(i.lastActivityTimestamp=a)}if(null!=un&&null!=(e=un.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?Y(un.location.href):un.location.href),t.featureFlags){var o=t.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}(t)),this._instance=t,this.name="logs",this.Zv()}get Qv(){return this._instance.__loaded}Jv(){var t=li("[logs]"),e=null==un?void 0:un.__PosthogExtensions__;if(e){var i=e.loadExternalDependency;if(i)return t=>{i(this._instance,"logs",i=>{var r=e.logs;t(i,null!=r&&r.initializeLogs?{initialize:t=>r.initializeLogs(t),replay:(t,e)=>null==r.replayConsoleBuffer?void 0:r.replayConsoleBuffer(t,e)}:void 0)})};t.error(Dr)}else t.error("PostHog Extensions not found.")}}},Vo={metrics:class{constructor(t){this._instance=t,this.A=li("[metrics]"),this.Ti=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.Ti){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.kg?this.kg=(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=mo(t,i),n=yo(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.kg&&(this.kg(),this.kg=void 0)}}Xv(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Vv&&this.tf===i||(null==(e=this.Vv)||e.reset(),this.tf=i,this.Vv=new ii(this.Yv(),function(t){var e,i,r,n,s,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==a?void 0:a["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==a?void 0:a["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(s=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==s?s:1e3}}(i),this.A)),this.Vv}count(t,e,i){void 0===e&&(e=1),this.Xv().count(t,e,i)}gauge(t,e,i){this.Xv().gauge(t,e,i)}histogram(t,e,i){this.Xv().histogram(t,e,i)}flush(t){if(!this.Vv)return Promise.resolve();if(t){var e=this.Vv.drainWindow();return e&&this.bo(e,t),Promise.resolve()}return this.Vv.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Vv)||t.reset()}dispose(){var t,e;this.Ti=!0,null==(t=this.kg)||t.call(this),this.kg=void 0,null==(e=this.Vv)||e.reset()}Yv(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},bo:t=>e.bo(t),getLibraryId:()=>ds.LIB_NAME,getLibraryVersion:()=>ds.LIB_VERSION}}bo(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:new Error("metrics request timed out")}),9e4);this._instance._send_request(e({method:"POST",url:this.Sg(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var e,i=t.statusCode;s(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("metrics request failed with status "+i)})}}))})}Sg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Wo={webMCP:class{constructor(t){this._instance=t,this.xg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.xg){var t=null==an?void 0:an.modelContext;if(t&&c(t.registerTool)){var e=bo.get(t);if(e)return e.instances.add(this._instance),void(this.xg=!0);var i={instances:new Set([this._instance])},r=t.registerTool,n=this;xn(t,"registerTool",t=>{var e=t;return function(t){for(var r=t,s=arguments.length,a=new Array(s>1?s-1:0),o=1;s>o;o++)a[o-1]=arguments[o];try{r=n.$g(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(bo.set(t,i),this.xg=!0)}}}$g(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=>_o.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:Eo(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>ko(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:Eo(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 exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},l.includes("llm_model")||l.push("llm_model")),{tool:Eo(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=So(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=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?To(t.context,2048,!0):void 0,n=i.model?To(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&&ko(r,"context"),s=i.model&&ko(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.Cg(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.Cg(i,a,s,e,f),t},t=>{throw n.Cg(i,a,s,{error:t,errorResult:!1},f),t});var g=Ao(c)?{error:c,errorResult:!0}:void 0;return n.Cg(i,a,s,g,f),c}}),a}Cg(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=So(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==on?void 0:on.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{},h.intent&&s.intent?{$mcp_intent:s.intent,$mcp_intent_source:"context_parameter"}:{},h.model&&s.model?{$mcp_llm_model:s.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:r})}catch(t){continue}if(n&&a&&l.exceptions&&null!=(u=l.exceptionObserver)&&u.isEnabled)try{var c={$exception_list:Ro(l.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==on?void 0:on.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}}},Go=e({},Mo,$o,Io,jo,Do,Lo,zo,No,Uo,Bo,Ho,qo,Vo,Wo),Ko=Mo,Jo=$o,Xo=Io,Yo=jo,Zo=Do,Qo=Lo,tl=zo,el=No,il=Uo,rl=Bo,nl=Ho,sl=qo,al=Vo,ol=Wo;export{Go as AllExtensions,Xo as AnalyticsExtensions,nl as ConversationsExtensions,Yo as ErrorTrackingExtensions,rl as ExperimentsExtensions,Ko as FeatureFlagsExtensions,sl as LogsExtensions,al as MetricsExtensions,Zo as ProductToursExtensions,Jo as SessionReplayExtensions,Qo as SiteAppsExtensions,tl as SurveysExtensions,il as ToolbarExtensions,el as TracingExtensions,ol 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=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({});function s(t,e){return-1!==t.indexOf(e)}var a=function(t){return t.trim()},o=Object.prototype,l=o.hasOwnProperty,u=o.toString,h=Array.isArray||function(t){return"[object Array]"===u.call(t)},c=t=>"function"==typeof t,v=t=>t===Object(t)&&!h(t),d=t=>{if(v(t)){for(var e in t)if(l.call(t,e))return!1;return!0}return!1},f=t=>void 0===t,p=t=>"[object String]"==u.call(t),g=t=>p(t)&&0===t.trim().length,m=t=>null===t,y=t=>f(t)||m(t),b=t=>"[object Number]"==u.call(t)&&t==t,_=t=>"[object Boolean]"===u.call(t);function w(t){return null===t||"object"!=typeof t}function x(t,e){return{}.toString.call(t)==="[object "+e+"]"}function S(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return E(t,Error)}}function k(t){return"u">typeof Event&&E(t,Event)}function E(t,e){try{return t instanceof e}catch(t){return!1}}var T=["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"],A=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=A.get(i);if(void 0!==r)return r;var n=t.toLowerCase(),s=T.concat(e).some(t=>-1!==n.indexOf(t.toLowerCase()));return 256>A.size||A.clear(),A.set(i,s),s};function P(t,e,i,r,n){return e>i&&(r.warn("min cannot be greater than max."),e=i),b(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),P(null!=n?n:i,e,i,r))}var R=class{constructor(t){this.C={},this.I=t.I,this.R=P(t.bucketSize,0,100,t.A),this.O=P(t.refillRate,0,this.R,t.A),this.$=P(t.refillInterval,0,864e5,t.A)}F(t,e){var i=Math.floor((e-t.lastAccess)/this.$);i>0&&(t.tokens=Math.min(t.tokens+i*this.O,this.R),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.R,lastAccess:i},0===n.tokens||(n.tokens--,0===n.tokens&&(null==(e=this.I)||e.call(this,t)),0===n.tokens)}stop(){this.C={}}},O="Mobile",C="Android",M="Nintendo",I="PlayStation",j="Xbox",D="Windows";O.toLowerCase(),"Tablet".toLowerCase(),new RegExp(j,"i");var L=new RegExp("BlackBerry|PlayBook|BB10","i"),N={"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"},z=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[j,t&&t[1]||""]],[new RegExp(M,"i"),[M,""]],[new RegExp(I,"i"),[I,""]],[L,["BlackBerry",""]],[new RegExp(D,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return["Windows Phone",""];if(new RegExp(O).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=N[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[D,r]}return[D,""]}],[/((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]}],[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",""]]],U="[Truncated]",B="[Unserializable]";function H(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 q(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=B}Object.defineProperty(t,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return t}Date,Date;var V,W,G,K,J=3e5,X=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,J);if(!e)return this.ts=i,void(this.es=i+r);this.es=Math.max(this.es,Math.min(i+r,this.ts+J))}}else this.reset()}remainingMs(){var t=Date.now();if(this.ts-5e3>t)return this.reset(),0;var e=Math.min(J,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 Y(t){return t?t.split("#")[0]:t}function Z(t){try{return t()}catch(t){return}}function Q(t,e){var i=setTimeout(t,e);return null!=i&&i.unref&&(null==i||i.unref()),i}function tt(t,e,i){return et.apply(this,arguments)}function et(){return(et=r(function*(t,e,i){var r;try{return yield Promise.race([t,new Promise((t,n)=>{r=Q(()=>{try{null==i||i(),t()}catch(t){n(t)}},e)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function it(t){var i=globalThis._posthogChunkIds,r=globalThis._debugIds;if(i||r){var n=i?Object.keys(i):[],s=r?Object.keys(r):[];if(K&&rt(i,n,W)&&rt(r,s,G))return K;W=i?e({},i):void 0,G=r?e({},r):void 0,K={},null!=V||(V={});var a=(e,i)=>{for(var r of e){var n,s=i[r];if(s){var a=null==(n=V)?void 0:n[r];if(a)K[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){K[h]=s,V[r]=h;break}}}}};return r&&a(s,r),i&&a(n,i),K}}function rt(t,e,i){return t&&i?e.length===Object.keys(i).length&&e.every(e=>t[e]===i[e]):t===i}var nt=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:it(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=new Set,u=[],h={},c=function(t,i,r){void 0===r&&(r=0);var c=v(i,r),d=c.apply;if(c.apply=e=>{u.push(t);try{return d(e)}finally{u.pop()}},r>4||r>0&&-1!==u.indexOf(t))return n.coerceFallback(c);var f="object"==typeof t&&null!==t||"function"==typeof t;if(!(0===r&&s>=50||f&&l.has(t))){f&&l.add(t),0===r&&s++;var p,g,m=n.getAggregateErrors(t);o||(o=!!m);try{if(!(p=n.applyCoercers(t,c)))throw h}catch(t){if(t===h)return void(0===r&&s--);if(!o)throw t;p=n.coerceFallback(c)}if(!m||s>=50)return p;try{g=m.length}catch(t){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;for(var y=[],b=0;50>s&&1e3>a&&g>b;b++){a++;var _=void 0;try{_=c.next(m[b])}catch(t){s++,_=n.coerceFallback(v(i+1))}_&&y.push(_)}return e({},p,{errors:y})}},v=function(r,n){return void 0===n&&(n=0),e({},i,{syntheticException:0==r?i.syntheticException:void 0,mechanism:0==r?t:{},apply(t){var e=c(t,r,n+1);if(!e)throw h;return e},next:t=>c(t,r+1)})},d=v(r);return e({},d,{apply:t=>{var e;return null!==(e=c(t,r))&&void 0!==e?e:this.coerceFallback(d)}})}},st=/^([a-z][a-z0-9.+-]+):/i,at=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function ot(t){if(!t||"<anonymous>"===t)return!1;var e=st.exec(t);return!e||at.includes(e[1].toLowerCase())}function lt(t,e,i,r,n){var s={platform:t,filename:e,function:"<anonymous>"===i?"?":i,in_app:ot(e)};return f(r)||(s.lineno=r),f(n)||(s.colno=n),s}var ut=(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]},ht=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ct=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,vt=/\((\S*)(?::(\d+))(?::(\d+))\)/,dt=(t,e)=>{var i=ht.exec(t);if(i)return lt(e,i[1],"?",+i[2],+i[3]);var r=ct.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var n=vt.exec(r[2]);n&&(r[2]=n[1],r[3]=n[2],r[4]=n[3])}var s=ut(r[1]||"?",r[2]);return lt(e,s[1],s[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},ft=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,gt=(t,e)=>{var i=ft.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=pt.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=ut(s,n);return lt(e,n=a[1],s=a[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},mt=/\(error: (.*)\)/;function yt(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function bt(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(!yt(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=xt(t,e);r&&t.splice(i+r===t.length?i:e.start,r)}function wt(t,e){for(var i=e.start;i>0&&yt(t[i-1],t[i-1+e.length]);)i--;return e.start-i}function xt(t,e){for(var i=e.start+e.length,r=i;t.length>r&&yt(t[r],t[r-e.length]);)r++;return r-i}function St(t,e){var i=e[0],r=t.length-(i?wt(t,i):0);for(var n of e)r-=xt(t,n);return r}function kt(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 Et=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")}},Tt=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}}},At=class{match(t){return!!x(t,"ErrorEvent")&&(null!=t.error||this.mr(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.gr(t))&&void 0!==r?r:n.stack,synthetic:!0})}mr(t){return p(t.message)&&t.message.length>0}gr(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}},Ft=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Pt=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(Ft);return r&&(e=r[1],i=r[2]),[e,i]}},Rt=["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]";for(var r=i.length;r>0;r--){var n=i.slice(0,r).join(", ");if(e>=n.length)return r===i.length?n:n.length>e?n.slice(0,e)+"...":n}return""}var Ct=class{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,n=this.getErrorPropertyFromObject(t);return n?e.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(k(t))return t.constructor.name;var e="name"in t?t.name:void 0;return p(e)&&!g(e)?e:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+Ot(t)}isSeverityLevel(t){return p(t)&&!g(t)&&Rt.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}}},Mt=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}}},$t=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}}},It=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}},jt="$message",Dt="$timestamp",Lt=new Set([jt,Dt]),Nt={enabled:!0,max_bytes:32768};function zt(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:Nt.enabled,max_bytes:Bt(t.max_bytes,Nt.max_bytes)}:e({},Nt)}var Ut=class{constructor(t){this.ns=[],this.ss=0,this.Dr=zt(t)}setConfig(t){this.Dr=zt(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[jt],o=s[Dt];if(!p(a)||0===a.trim().length)return;if(!p(o)&&!b(o))return;return{step:s,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Dr.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.Dr.max_bytes&&this.ns.length>0;){var t=this.ns.shift();t&&(this.ss-=t.bytes)}}};function Bt(t,e){if(!b(t)||1/0===t||-1/0===t)return e;var i=Math.floor(t);return 0>i?e:i}var Ht=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function qt(t){return"string"==typeof t||t}function Vt(t){return"string"==typeof t?t:void 0}var Wt="[redacted]",Gt=/^[A-Za-z0-9+/\n\r]+=*$/,Kt=/^[A-Za-z0-9_-]+={0,2}$/,Jt=/[-_]/,Xt=/^data:[^,\s]*;base64,/i,Yt=/^[A-Za-z0-9+/_-]+={0,2}$/,Zt=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Qt=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,te=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,ee=/[\s<>"]/,ie=new RegExp(te.source,"i"),re=/[a-z][a-z0-9+.-]{0,63}:\/\//i,ne=new RegExp("^"+re.source,"i"),se=new RegExp(re.source,"gi"),ae=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,oe=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,le=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,ue=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,he=/\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,ce=/(^|[^\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,ve=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,de=/\b\d(?:[ ./-]?\d){12,}\b/g,fe=/\d+/g,pe=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,ge=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function me(t){return function(t){return Qt.test(t)}(t)||ae.test(t)||oe.test(t)}function ye(t){return t.split("&",129).length>128}function be(t,e,i){return me(t)||e.includes(";")&&function(t){return t.split(";").some(t=>me(t.split("=",1)[0]))}(e)?Wt:ie.test(e)?i?Ee(e,{allowNestedUrls:!1,stripPunctuation:!0}):Wt:e}function _e(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=Te(a),u=Te(o);r||(r=l!==a||u!==o);var h=be(l,u,e);r||(r=h!==u),n=me(l)||h!==u,i.append(l,h)}return{changed:r,lastFieldSensitive:n,serialized:i.toString()}}function we(t,e){if(!t.includes("="))return{value:xe(t,e),lastFieldSensitive:!1};var i=_e(t,e);return{value:i.changed?i.serialized:t,lastFieldSensitive:i.lastFieldSensitive}}function xe(t,e){return e?Ee(t,{allowNestedUrls:!1,stripPunctuation:!0}):ie.test(t)?Wt:t}function Se(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 ke(t,e){var i;if(t.length>8192&&ne.test(t))return Wt;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 Wt+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(ye(o)||ye(u.head)||ye(null!==(i=u.tail)&&void 0!==i?i:""))return Wt+a;var h=!1;(r.username||r.password)&&(r.username=Wt,r.password="",h=!0);var c=_e(o,e.allowNestedUrls);c.changed&&(r.search=c.serialized,h=!0);var v,d=we(u.head,e.allowNestedUrls),f=null===u.tail?null:(v=u.tail,d.lastFieldSensitive?{value:""===v?"":Wt,lastFieldSensitive:!0}:we(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?Te(r.toString()):s)+(g.lastFieldSensitive?"":a)}function Ee(t,i){return t.replace(te,r=>function(t,i){var r=function(t){if(!t.includes("://"))return[];for(var e=[...t.matchAll(se)].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];Se(l,r,a)?(a=l,s=!0):s&&"=&".includes(l)&&(a=l)}return i}(t);if(0===r.length)return ke(t,i);var n="",s=0;for(var a of r)n+=ke(t.slice(s,a),e({},i,{stripPunctuation:!1})),s=a;return n+ke(t.slice(s),i)}(r,e({},i,{stripPunctuation:i.stripPunctuation&&r.length!==t.length})))}function Te(t){return t.replace(Zt,Wt)}function Ae(t,e){return function(t){return t.length>=10240&&(Gt.test(t)||function(t){var e,i=Xt.exec(t);if(!i)return!1;try{e=decodeURIComponent(t.slice(i[0].length))}catch(t){return!1}return Yt.test(e.replace(/[\r\n]/g,""))}(t)||Jt.test(t)&&Kt.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&&!ee.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 Ee(t,{allowNestedUrls:!0,stripPunctuation:!0})}(function(t){var e=t.replace(le," ");return(e=(e=(e=(e=(e=(e=e.replace(ue,Wt)).replace(he,Wt)).replace(ce,"$1"+Wt)).replace(de,Pe)).replace(ve,Wt)).replace(pe,"$1"+Wt)).replace(ge,"$1"+Wt)}(Te(t))),e)}function Fe(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 Pe(t){for(var e=[],i=fe.exec(t);null!==i;i=fe.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&&Fe(a)&&(o=l);0>o?s++:(r+=t.slice(n,e[s].start)+Wt,n=e[o].end,s=o+1)}return r+t.slice(n)}var Re={}.propertyIsEnumerable;function Oe(t,e){try{return $e(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function Ce(t,e,i,r){if(0>=i.remainingNodes)return{stringValue:U};if(i.remainingNodes--,_(t))return{boolValue:t};if("bigint"==typeof t)return function(t,e){var i=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==e||e.debug("Attribute "+i+" is outside the int64 range; encoding it as a string"),{stringValue:i}):{intValue:i}}(t,e);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var n=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==e||e.debug("Attribute "+n+" is outside the int64 range; encoding it as a string"),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:H(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:U};if(t instanceof Date){var s=t.getTime(),a=Number.isFinite(s)?t.toISOString():String(t);return{stringValue:"string"==typeof a?H(a):String(a)}}i.ancestors.add(t);try{try{var o=t.toJSON;if("function"==typeof o)return Ce(o.call(t),e,i,r+1)}catch(t){}return h(t)?{arrayValue:{values:Me(t,e,i,r+1)}}:{kvlistValue:{values:$e(t,e,i,r+1)}}}finally{i.ancestors.delete(t)}}return{stringValue:H(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(y(o))continue;n.push(Ce(o,e,i,r))}catch(t){n.push({stringValue:B})}return t.length>a&&n.push({stringValue:U}),n}function $e(t,e,i,r){var n=[];for(var s in t)if(Re.call(t,s)){if(!s){null==e||e.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==e||e.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=t[s];if(m(a)||f(a))continue;n.push({key:H(s),value:Ce(a,e,i,r)})}catch(t){n.push({key:H(s),value:{stringValue:B}})}}return n}function Ie(t,i,r){return e({},q({},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 De(t,e){var i=q({},t),r={};for(var n of je)({}).hasOwnProperty.call(i,n)&&(r[n]=i[n],delete i[n]);return[...Oe(i,e),...Oe(r,e)]}var Le={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 Ne={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},ze=Ne.info;function Ue(t){try{return H(String(t))}catch(t){return B}}function Be(t,i,r,n){var s,a=Ne[t.level||"info"]||ze,o=a.text,l=a.number,u=(void 0===(s=b(n)?n:void 0)&&(s=Date.now()),String(s)+"000000"),h={};i.distinctId&&(h.posthogDistinctId=i.distinctId),i.sessionId&&(h.sessionId=i.sessionId),i.windowId&&(h["window.id"]=i.windowId),y(i.sessionStartTimestamp)||(h.sessionStartTimestamp=String(i.sessionStartTimestamp)),y(i.lastActivityTimestamp)||(h.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(h["url.full"]=i.currentUrl),i.screenName&&(h["screen.name"]=i.screenName),i.appState&&(h["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(h.feature_flags=i.activeFeatureFlags);var c=e({},h),v=t.attributes;if(v){var d=[];try{d=Object.keys(v)}catch(t){d=[]}for(var p of d){var g=void 0;try{g=v[p]}catch(t){g=B}Object.defineProperty(c,p,{value:g,enumerable:!0,writable:!0,configurable:!0})}}var m={timeUnixNano:u,observedTimeUnixNano:u,severityNumber:l,severityText:o,body:{stringValue:Ue(t.body)},attributes:Oe(c,r)};return t.trace_id&&(m.traceId=t.trace_id),t.span_id&&(m.spanId=t.span_id),f(t.trace_flags)||(m.flags=t.trace_flags),m}function He(t,e,i){return Ie(t,e,i)}function qe(t,e,i,r){return{resourceLogs:[{resource:{attributes:De(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}var Ve=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=Q(()=>{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 We(){return.75+.5*Math.random()}function Ge(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 Ke=class{constructor(t,e,i,r,n,s,a){var o;void 0===s&&(s=()=>Promise.resolve()),this._instance=t,this.Dr=e,this.A=i,this.hs=r,this.ds=n,this.vs=s,this.fs=a,this.ps=new Ve(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new X,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=e.maxBufferSize,this.Is=Math.max(null!==(o=e.maxQueueSize)&&void 0!==o?o:e.maxBufferSize,e.maxBufferSize),this.Es=e.flushIntervalMs,this.Ms=e.maxBatchRecordsPerPost,this.As=e.rateCapWindowMs,this.Rs=e.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(n.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Ms=this.Dr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.Ps()&&this.Os():this.gs()}captureLog(t,e){var i;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Fs(t);if(null!==r)if(r.body){if(this.Ds()){var n={record:Be(r,null!==(i=null==e?void 0:e.context)&&void 0!==i?i:this.hs(),this.A,null==e?void 0:e.occurredAtMs)};this.ds(()=>this.Ls(n))}}else this.A.info("Log was rejected in beforeSend function")}}Fs(t){var e=this.Dr.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.A.info("Log was rejected in beforeSend function"),null;r=s}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return r}Ds(){if(void 0===this.Rs)return!0;var t=Date.now(),e=t-this.xs;return this.As>e&&e>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn("captureLog dropping logs: exceeded "+this.Rs+" logs per "+this.As+"ms"),this.Cs=!0),!1)}flush(){var t=this;return r(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return r(function*(){var e;t.ps.clear();var i=null!==(e=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var a,o,l=t._s;t.bs=0;var u=Math.min(i.length,t.Ms),h=i.slice(0,u),c=qe(h.map(t=>t.record),t.js(),null!==(a=t.fs)&&void 0!==a?a:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.qs(c);if(t._s!==l)return;if("too-large"===v.kind&&h.length>1)t.Ms=Math.max(1,Math.floor(h.length/2)),t.A.warn("Logs batch of size "+h.length+" was too large for the ingestion endpoint, reducing batch size to "+t.Ms);else{if(t.ws.record(v),t.ps.pending&&t.ps.arm(Math.max(t.Es,t.ws.remainingMs())),"retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.A.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.Dr.maxBatchRecordsPerPost>t.Ms&&(t.Ms=Math.min(t.Dr.maxBatchRecordsPerPost,t.Ms+1)),yield t.Bs(h.length),i=null!==(o=t._instance.getPersistedProperty(n.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===v.kind)throw v.error}}})()}Bs(t){var e=this;return r(function*(){var i,r=Math.max(0,t-e.bs),s=null!==(i=e._instance.getPersistedProperty(n.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(n.LogsQueue,s.slice(r)),yield e.vs()})()}js(){return He(this.Dr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(n.LogsQueue))&&void 0!==e?e:[];this.Is>i.length||(i.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(n.LogsQueue,i),this.Ts>i.length||this.ws.isOpen()?this.Os():this.gs()}}Os(){this.ps.pending||this.ps.arm(Math.max(this.Es,this.ws.remainingMs()))}zs(){return Math.max(Ge(this.Es,this.ks,this.Ss,3e4),this.ws.remainingMs())}Ps(){var t=this._instance.getPersistedProperty(n.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return r(function*(){e.ps.clear();var i=e.flush().catch(()=>{});void 0!==t?yield tt(i,t):yield i})()}flushWithTimeout(t){var e=this;return r(function*(){var i=e.flush();yield tt(i,t,()=>{i.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=We(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ps()&&this.ps.armNoEarlierThan(this.zs())})}},Je=/^[0-9a-f]+$/;function Xe(t,e,i){return"string"==typeof t&&t.length===e&&t!==i&&Je.test(t)}var Ye=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;var Ze="00",Qe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function ti(t){return String(t)+"000000"}function ei(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 ii=class{constructor(t,e,i){this._instance=t,this.Dr=e,this.A=i,this.Hs=new Map,this.ps=new Ve(()=>this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new X,this.ks=0,this.Ss=1,this.Gs=0}count(t,e,i){void 0===e&&(e=1),this.Qs({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.Qs({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.Qs({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var t=this,e=this.ys,i=function(){var i=r(function*(){e&&(yield e.catch(()=>{})),yield t.Js()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this.ys===i&&(this.ys=null)});return this.ys=i,i}drainWindow(){if(0===this.Hs.size)return null;var t=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Zs(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Fs(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.A.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=ei(i.type,i.name,i.unit,r)}catch(t){return void this.A.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var s=this.Hs.get(n);if(!s){if(!this.Ks())return;s={name:i.name,type:i.type,unit:i.unit,attributes:r,windowStartMs:Date.now()},this.Hs.set(n,s)}var a=this.Ws.get(i.name);void 0===a?this.Ws.set(i.name,i.type):a===i.type||this.Vs.has(i.name)||(this.Vs.add(i.name),this.A.warn("Metric name '"+i.name+"' is already used as a "+a+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Ys(s,i.value);var o=this.Xs();o&&(s.exemplar=e({},o,{value:i.value,timeMs:Date.now()})),this.Os()}else this.A.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Xs(){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=Ye.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 Xe(t,32,"00000000000000000000000000000000")}(r)&&function(t){return Xe(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":Ze)});if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(t){}var r,n,s}Ks(){return this.Dr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.A.warn("Metric series cap reached ("+this.Dr.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Ys(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":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(Qe.length+1).fill(0)});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,Qe)]+=1}}Fs(t){var e=this.Dr.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.A.info("Metric was rejected in beforeSend function"),null;r=s}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return r}Os(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Ge(this.Dr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Js(){var t=this;return r(function*(){if(t.ps.clear(),0!==t.Hs.size){var e=t.Hs;t.Hs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;var i=t.Gs,r=yield t._instance.bo(t.Zs(e));if(i===t.Gs)switch(t.ws.record(r),"retry-later"===r.kind?(t.ks++,t.Ss=We()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),r.kind){case"ok":return;case"retry-later":return t._o(e),void t.ps.armNoEarlierThan(t.zs());case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",r.error)}}})()}Zs(t){return e=this.wo(t),i=function(t,e,i){return Ie(t,e,i)}(this.Dr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:De(i)},scopeMetrics:[{scope:{name:r,version:n},metrics:e}]}]};var e,i,r,n}wo(t){var i=ti(Date.now()),r=new Map;for(var n of t.values()){var s,a=ei(n.type,n.name,n.unit,void 0),o=r.get(a);o||(o=e({name:n.name},n.unit&&{unit:n.unit}),"count"===n.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===n.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},r.set(a,o));var l=Oe(null!==(s=n.attributes)&&void 0!==s?s:{},this.A),u=ti(n.windowStartMs),h=ri(n.exemplar);if("count"===n.type){var c,v=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(c=n.total)&&void 0!==c?c:0},h);o.sum.dataPoints.push(v)}else if("gauge"===n.type){var d,f=e({attributes:l,timeUnixNano:i,asDouble:null!==(d=n.last)&&void 0!==d?d:0},h);o.gauge.dataPoints.push(f)}else if(n.hist){var p=e({attributes:l,startTimeUnixNano:u,timeUnixNano:i,count:n.hist.count,sum:n.hist.sum,min:n.hist.min,max:n.hist.max,bucketCounts:n.hist.bucketCounts,explicitBounds:Qe},h);o.histogram.dataPoints.push(p)}}return Array.from(r.values())}_o(t){var e,i;for(var r of t){var n,s=r[0],a=r[1],o=this.Hs.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,a.windowStartMs),o.exemplar=null!==(n=o.exemplar)&&void 0!==n?n:a.exemplar,o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=a.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(a.hist)if(o.hist){o.hist.count+=a.hist.count,o.hist.sum+=a.hist.sum,o.hist.min=Math.min(o.hist.min,a.hist.min),o.hist.max=Math.max(o.hist.max,a.hist.max);for(var l=0;o.hist.bucketCounts.length>l;l++)o.hist.bucketCounts[l]+=a.hist.bucketCounts[l]}else o.hist=a.hist}else this.Ks()&&this.Hs.set(s,a)}}};function ri(t){return t?{exemplars:[{filteredAttributes:[],timeUnixNano:ti(t.timeMs),asDouble:t.value,traceId:t.traceId,spanId:t.spanId}]}:{}}var ni="0.10.4",si={DEBUG:!1,LIB_VERSION:ni,LIB_NAME:"browser-common",JS_SDK_VERSION:ni},ai=function(t,e){var i=(void 0===e?{}:e).debugEnabled,r={N(e){var r;try{r=typeof window>"u"?void 0:window}catch(t){return}for(var n=arguments.length,s=new Array(n>1?n-1:0),a=1;n>a;a++)s[a-1]=arguments[a];r&&(si.DEBUG||r.POSTHOG_DEBUG||i)&&!f(r.console)&&r.console&&("__rrweb_original__"in r.console[e]?r.console[e].__rrweb_original__:r.console[e])(t,...s)},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.N("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>ai(t+" "+e,i)};return r},oi=ai("[PostHog.js]"),li=oi.createLogger;function ui(t,e){h(t)&&t.forEach(e)}function hi(t,e){if(!y(t))if(h(t))t.forEach(e);else if(t instanceof FormData)t.forEach((t,i)=>e(t,i));else for(var i in t)l.call(t,i)&&e(t[i],i)}var ci=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var n of i)for(var s in n)void 0!==n[s]&&(t[s]=n[s]);return t};function vi(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}function di(t,e,i,r){var n=null!=r?r:{},s=n.capture,a=n.passive;null==t||t.addEventListener(e,i,{capture:void 0!==s&&s,passive:void 0===a||a})}function fi(t){return"ph_toolbar_internal"===t.name}function pi(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!c(r))return e;try{var n=r(e);return p(n)&&n?n:e}catch(t){return oi.error("Error in get_current_url, falling back to window.location.href",t),e}}var gi="$early_access_features",mi="$active_feature_flags",yi="$feature_flag_details",bi="$feature_flag_errors",_i="$feature_flag_evaluated_at",wi="$feature_flag_request_id",xi="$minimal_flag_called_events",Si="$enabled_feature_flags",ki="$stored_group_properties",Ei="$stored_person_properties",Ti="$flag_call_reported",Ai="$flag_call_reported_session_id",Fi="$feature_flag_payloads",Pi="$override_feature_flags",Ri="$override_feature_flag_payloads",Oi="visibilitychange",Ci="$autocapture_disabled_server_side";function Mi(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function $i(t){return!!t&&1===t.nodeType}function Ii(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ji(t){return!!t&&3===t.nodeType}function Di(t){return!!t&&11===t.nodeType&&$i(t.host)}function Li(t){return t?a(t).split(/\s+/):[]}function Ni(t,e){var i=function(t){var e,i=null==(e=typeof window>"u"?void 0:window)||null==(e=e.location)?void 0:e.href;return f(i)?void 0:pi(t,i)}(e);return!!(i&&t&&t.some(t=>i.match(t)))}function zi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Li(e)}function Ui(t){return y(t)?null:a(t).split(/(\s+)/).filter(t=>mr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Bi(t){var e="";return lr(t)&&!ur(t)&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;ji(t)&&t.textContent&&(e+=null!==(i=Ui(t.textContent))&&void 0!==i?i:"")}),a(e)}function Hi(t){var e;return f(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var qi=["a","button","form","input","select","textarea","label"];function Vi(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}function Wi(t,e){if(f(e))return!0;var i,r=function(t){if(e.some(e=>Vi(t,e)))return{v:!0}};for(var n of t)if(i=r(n))return i.v;return!1}function Gi(t){var e=t.parentNode;return!(!e||!$i(e))&&e}var Ki=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ji=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Xi=[...Ji,"+","-","−","–"],Yi=Xi.length+10,Zi=["button","a","input","select","textarea","label"],Qi=["button","link","tab","menuitem","option"],tr=(t,e)=>/[a-z0-9]/i.test(e)?s(Xi,e)?new RegExp("\\b"+e+"\\b").test(t):t.includes(e):t===e,er=t=>s(Zi,t.tagName.toLowerCase())||s(Qi,(t.getAttribute("role")||"").toLowerCase());function ir(t){var e="",i="",r=t=>{$i(t)&&lr(t)&&!ur(t)&&(e+=" "+Bi(t),i=i||t.getAttribute("aria-label")||"",hi(t.childNodes,r))};r(t);var n=(mr(e=a(e.replace(/\s+/g," ")))?e:"").toLowerCase();return{safeText:n,ariaLabel:a(t.getAttribute("aria-label")||(n?"":i)).toLowerCase()}}var rr=[".ph-no-rageclick",".ph-no-capture"],nr=["","text","search","email","password","url","tel","number"];function sr(t,e){if(!(typeof window>"u"?void 0:window)||ar(t))return!1;var i,r,n,a,o;if(_(e)?(i=!!e&&rr,r=void 0,n=!1):(i=null!==(a=null==e?void 0:e.css_selector_ignorelist)&&void 0!==a?a:rr,r=null==e?void 0:e.content_ignorelist,n=null!==(o=null==e?void 0:e.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(t){return!(!t||!$i(t))&&(!!Ii(t,"textarea")||(Ii(t,"input")?s(nr,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var l=or(t,!1).targetElementList;return!(r&&function(t,e){var i,r=e.safeText,n=e.ariaLabel;if(!0===t)i=Ji;else{if(!h(t))return!1;if(t.length>Yi)return oi.error("[PostHog] content_ignorelist array cannot exceed "+Yi+" items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map(t=>t.toLowerCase())}return i.some(t=>tr(r,t)||tr(n,t))}(r,function(t,e){for(var i of e)if(er(i))return ir(i);for(var r of e){try{var n;if("pointer"!==(null==(n=window)?void 0:n.getComputedStyle(r).getPropertyValue("cursor")))break}catch(t){break}var s=ir(r);if(s.safeText||s.ariaLabel)return s}return ir(t)}(t,l))||Wi(l,i))}var ar=t=>!t||Ii(t,"html")||!$i(t),or=(t,e)=>{var i=typeof window>"u"?void 0:window;if(!i||ar(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,n=[t],s=t;s.parentNode&&!Ii(s,"body");)if(Di(s.parentNode))n.push(s.parentNode.host),s=s.parentNode.host;else{var a=Gi(s);if(!a)break;if(e||qi.indexOf(a.tagName.toLowerCase())>-1)r=!0;else try{var o=i.getComputedStyle(a);o&&"pointer"===o.getPropertyValue("cursor")&&(r=!0)}catch(t){}n.push(a),s=a}return{parentIsUsefulElement:r,targetElementList:n}};function lr(t){for(var e=new Set,i=0,r=t;r.parentNode&&!Ii(r,"body");r=r.parentNode){if(i++>=1e3||e.has(r))return!1;e.add(r);var n=zi(r);if(s(n,"ph-sensitive")||s(n,"ph-no-capture"))return!1}if(s(zi(t),"ph-include"))return!0;var a=t.type||"";if(p(a))switch(a.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!p(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function ur(t){return!!(Ii(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ii(t,"select")||Ii(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var hr=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),cr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,vr=[16,15,14,13],dr=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),fr=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),pr=/[0-9A-Za-z_]/;function gr(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var n=t.charCodeAt(r)-48;i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0}function mr(t,e){if(void 0===e&&(e=!0),y(t))return!1;if(p(t)){if(t=a(t),e?hr.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(cr.lastIndex=0;e=cr.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),n=0;r.length>n;n++)for(var s of vr){var a=n+s;if(r.length>=a){var o=r.slice(n,a);if(hr.test(o)&&gr(o))return!0}}}return!1}(t))return!1;if(e?dr.test(t):function(t){var e;for(fr.lastIndex=0;e=fr.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&pr.test(i)&&pr.test(r)))return!0}return!1}(t))return!1}return!0}function yr(t){var e=Bi(t);return mr(e=(e+" "+br(t)).trim())?e:""}function br(t){var e="";return t&&t.childNodes&&t.childNodes.length&&hi(t.childNodes,function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Bi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+br(t)).trim())}catch(t){oi.error("[AutoCapture]",t)}}),e}function _r(t){return t.replace(/"|\\"/g,'\\"')}function wr(t){var e=t.attr__class;if(e)return h(e)?e:Li(e)}var xr=class{constructor(t){this.disabled=!1===t;var e=v(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}},Sr=t=>{var e,i=null==(e=typeof document>"u"?void 0:document)?void 0:e.createElement("a");return f(i)?null:(i.href=t,i)},kr=()=>typeof window>"u"?void 0:window,Er=()=>typeof document>"u"?void 0:document,Tr="$copy_autocapture",Ar=["password","hidden","file","checkbox","button","submit","reset","image"],Fr=li("[AutoCapture]");function Pr(t,e){return e.length>t?e.slice(0,t)+"...":e}function Rr(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!$i(e));return e}function Or(t,i){var r,n,a=i.e,o=i.maskAllElementAttributes,l=i.maskAllText,u=i.elementAttributeIgnoreList,c=i.elementsChainAsString,v=i.disableCaptureUrlHashes;if(!$i(t))return{props:{}};for(var d=[t],f=new Set([t]),g=t;g.parentNode&&!Ii(g,"body")&&1e3>d.length;)if(Di(g.parentNode)){var m=g.parentNode.host;if(f.has(m))break;f.add(m),d.push(m),g=m}else{if(!$i(g.parentNode))break;if(f.has(g.parentNode))break;f.add(g.parentNode),d.push(g.parentNode),g=g.parentNode}var y="click"===a.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>Ii(t,"button")||Ii(t,"a")):-1;y>0&&(l=l||d.slice(0,y+1).some(t=>!lr(t)||ur(t)));var b,_,w,x=[],S={},k=!1,E=!1;if(hi(d,t=>{var e=lr(t);if(Ii(t,"a")&&!o&&(null==u||!u.includes("href"))){var i=t.getAttribute("href");k=!!(e&&i&&mr(i))&&(v?Y(i):i)}s(zi(t),"ph-no-capture")&&(E=!0),x.push(function(t,e,i,r,n){void 0===n&&(n=!1);var s=t.tagName.toLowerCase(),a={tag_name:s};qi.indexOf(s)>-1&&!i&&(a.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Pr(1024,yr(t)):Pr(1024,Bi(t)));var o=zi(t);e||null!=r&&r.includes("class")||0>=o.length||(a.classes=o.filter(function(t){return""!==t})),hi(t.attributes,function(i){var s;if((!ur(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&mr(i.value)&&(!p(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=Li(o).join(" ")),a["attr__"+i.name]=Pr(1024,"href"===i.name&&n?Y(o):o)}});for(var l=1,u=1,h=t;h=Rr(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,o,l,u,v)),hi(function(t){if(!lr(t))return{};var e={};return hi(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&mr(r)&&(e[i]=r)}}),e}(t),(t,e)=>{({}).hasOwnProperty.call(S,e)||(S[e]=t)})}),E)return{props:{},explicitNoCapture:E};if(y>0&&(t=d[y],x.splice(0,y)),l||(x[0].$el_text=Ii(t,"a")||Ii(t,"button")?yr(t):Bi(t)),k){var T,A;x[0].attr__href=k;var F=null==(T=Sr(k))?void 0:T.host,P=null==(A=kr())||null==(A=A.location)?void 0:A.host;F&&P&&F!==P&&(b=k)}return{props:ci((_=a.type,{$event_type:_,$ce_version:1}),c?{}:{$elements:x},{$elements_chain:(w=x,h(w)?function(t){return t.map(t=>{var i,r,n="";if(t.tag_name&&(n+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))n+="."+s.replace(/"/g,"");var a=e({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return vi(a).sort((t,e)=>{return(r=e[0])>(i=t[0])?-1:i>r?1:0;var i,r}).forEach(t=>{var e=t[1];return o[_r(t[0].toString())]=_r(e.toString())}),(n+=":")+vi(o).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:wr(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return vi(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(w)):"")},null!=(r=x[0])&&r.$el_text?{$el_text:null==(n=x[0])?void 0:n.$el_text}:{},b&&"click"===a.type?{$external_click_url:b}:{},S),target:t}}var Cr=class{sl(){this.rl=void 0,clearTimeout(this.al),this.al=void 0}ll(t){var e;if(!lr(t))return!0;for(var i,r=null!==(e=this.ul().css_selector_ignorelist)&&void 0!==e?e:Ki,n=new Set,a=t,o=function(){if(n.size>=1e3||n.has(a))return{v:!0};n.add(a);var t=a,e=zi(t);if(s(e,"ph-no-capture")||s(e,"ph-sensitive")||ur(t)||r.some(e=>Vi(t,e)))return{v:!0};var i=a.parentNode;a=Di(i)?i.host:i&&$i(i)?i:null};a;)if(i=o())return i.v;return!1}cl(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var e=this.rl;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.sl():"pointerup"===t.type&&(e.released=!0,this.al=setTimeout(()=>this.sl(),0)))}else{var i;this.sl();var r=Hi(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&$i(r)&&(this.rl={target:r,excluded:this.ll(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(i=this.Ta)?void 0:i.distinctId})}else this.sl()}hl(t){var e,i=this.rl;this.sl();var r=Hi(t);if(null!=i&&i.released&&i.target.isConnected&&i.distinctId===(null==(e=this.Ta)?void 0:e.distinctId)&&t.pointerId===i.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-i.x)&&5>=Math.abs(t.clientY-i.y)&&r&&(Ii(r,"html")||Ii(r,"body"))){var n,a,o;if(i.excluded)return null;var l=null!==(n=this.ul().css_selector_ignorelist)&&void 0!==n?n:Ki;return[r,null==(a=Er())?void 0:a.documentElement,null==(o=Er())?void 0:o.body].some(t=>{if(!t)return!1;var e=zi(t);return s(e,"ph-no-capture")||s(e,"ph-sensitive")||!lr(t)||ur(t)||l.some(e=>Vi(t,e))})?null:i.target}}constructor(t){this.Ma=t,this.name="autocapture",this.dl=!1,this.vl=null,this.fl=!1,this.pl=new Map,this.gl=!1,this.Dr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ti=!1,this.Ma.refresh(this.Dr),this.rageclicks=new xr(this.Dr.rageclick),this.ml=null}setup(t){this.yl(),this.Ta=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ti?e.dispose():(this.za=e,this.startIfEnabled())}dispose(){var t;this.Ti||(this.Ti=!0,this.Ta=void 0,null==(t=this.za)||t.dispose(),this.za=void 0,this.pl.clear(),this.ml=null,this.bl())}ul(){return this.Ma.refresh(this.Dr),this.Dr}yl(){var t,e;return this.ul(),this.Dr.url_allowlist=null==(t=this.Dr.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.Dr.url_ignorelist=null==(e=this.Dr.url_ignorelist)?void 0:e.map(t=>new RegExp(t)),this.Dr}_l(){var t=kr(),e=Er();if(this.isBrowserSupported()){if(t&&e){this.wl=t,this.kl=e;var i=this.Sl=e=>{e=e||(null==t?void 0:t.event);try{if("blur"===e.type)return void this.sl();if(0===e.type.indexOf("pointer"))return void this.cl(e);var i="click"===e.type?this.hl(e):void 0;if(m(i))return;this.xl(e,"$autocapture",i)}catch(t){Fr.error("Failed to capture event",t)}};if(di(t,"blur",i),di(e,"submit",i,{capture:!0}),di(e,"change",i,{capture:!0}),di(e,"click",i,{capture:!0}),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{di(e,t,i,{capture:!0})}),this.ul().capture_copied_text){var r=this.$l=e=>{e=e||(null==t?void 0:t.event);try{this.xl(e,Tr)}catch(t){Fr.error("Failed to capture clipboard event",t)}};di(e,"copy",r,{capture:!0}),di(e,"cut",r,{capture:!0}),di(e,"paste",r,{capture:!0})}}}else Fr.info("Disabling Automatic Event Collection because this browser is not supported")}bl(){var t=this.wl,e=this.kl;this.sl(),this.Sl&&(null==t||t.removeEventListener("blur",this.Sl),hi(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==e||e.removeEventListener(t,this.Sl,!0)}),null==e||e.removeEventListener("submit",this.Sl,!0),null==e||e.removeEventListener("change",this.Sl,!0),null==e||e.removeEventListener("click",this.Sl,!0),this.Sl=void 0),this.$l&&(null==e||e.removeEventListener("copy",this.$l,!0),null==e||e.removeEventListener("cut",this.$l,!0),null==e||e.removeEventListener("paste",this.$l,!0),this.$l=void 0),this.wl=void 0,this.kl=void 0,this.dl=!1}startIfEnabled(){this.isEnabled||this.sl(),!this.Ti&&this.Ta&&this.isEnabled&&!this.dl&&(this._l(),this.dl=!0)}onRemoteConfig(t){if(!this.Ti)if(this.fl=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.gl=e.elementsChainAsString);var i,r=e.autocapture_opt_out;_(r)&&(null==(i=this.Ta)||i.kv.set(Ci,r),this.vl=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t,e){if(void 0===e&&(e=this),!this.Ti){t.size?this.pl.set(e,new Set(t)):this.pl.delete(e);var i=new Set;this.pl.forEach(t=>{t.forEach(t=>i.add(t))}),this.ml=i}}getElementSelectors(t,e){var i,r=[];return null==(i=this.ml)||i.forEach(i=>{var n;null==(n=Er())||null==(n=n.querySelectorAll(i))||n.forEach(n=>{t!==n&&e!==n||s(r,i)||r.push(i)})}),r}get isEnabled(){var t,e;if(this.Ti)return!1;var i=null==(t=this.Ta)?void 0:t.kv.get(Ci),r=this.vl,n=this.ul();if(!n.remoteRequestsDisabled&&!this.fl)return!1;var s=n.remoteRequestsDisabled&&!this.fl;if(m(r)&&!_(i)&&!s)return!1;var a=null!==(e=this.vl)&&void 0!==e?e:!!i;return!!n.enabled&&!a}xl(t,i,r){if(void 0===i&&(i="$autocapture"),this.isEnabled){var n=r||Hi(t);ji(n)&&(n=n.parentNode||null);var a,o=this.yl();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(a=this.rageclicks)&&a.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&sr(n,o.rageclick)&&this.xl(t,"$rageclick",r);var l,u=i===Tr,v=u?e({},o,{dom_event_allowlist:void 0}):o;if(n&&function(t,e,i,r,n,s){var a,o=typeof window>"u"?void 0:window;if(!o||ar(t))return!1;if(null!=i&&i.url_allowlist&&!Ni(i.url_allowlist,s))return!1;if(null!=i&&i.url_ignorelist&&Ni(i.url_ignorelist,s))return!1;if(null!=i&&i.dom_event_allowlist){var l=i.dom_event_allowlist;if(l&&!l.some(t=>e.type===t))return!1}var u=or(t,r),h=u.parentIsUsefulElement,c=u.targetElementList;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(f(i))return!0;var r,n=function(t){if(i.some(e=>t.tagName.toLowerCase()===e))return{v:!0}};for(var s of t)if(r=n(s))return r.v;return!1}(c,i))return!1;if(!Wi(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Wi(c,null!==(a=null==i?void 0:i.css_selector_ignorelist)&&void 0!==a?a:Ki))return!1;try{var v=o.getComputedStyle(t);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var d=t.tagName.toLowerCase();switch(d){case"html":return!1;case"form":return(n||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(e.type)>=0;default:return h?(n||["click"]).indexOf(e.type)>=0:(n||["click"]).indexOf(e.type)>=0&&(qi.indexOf(d)>-1||"true"===t.getAttribute("contenteditable"))}}(n,t,v,u,u?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var d,p=Or(n,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.gl,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===Tr){var y=t.type||"clipboard";if("paste"!==y){var b,_,w=null==(b=kr())||null==(b=b.getSelection())?void 0:b.toString(),x=Ui(w);if(!x)return!1;g.$selected_content=x,g.$clipboard_text_length=null!==(_=null==w?void 0:w.length)&&void 0!==_?_:0}g.$copy_type=y}if("$autocapture"===i&&"change"===t.type&&o.capture_value_css_selector_allowlist&&!o.maskAllText&&(Ii(l=n,"input")?!s(Ar,l.type):Ii(l,"textarea")||Ii(l,"select")&&!l.multiple)&&function(t,e){var i;if(!lr(t))return!1;var r=null!==(i=e.css_selector_ignorelist)&&void 0!==i?i:Ki,n=new Set,a=t;Ii(t,"select")&&(a=t.options[t.selectedIndex]||t);for(var o,l=function(){var t=a,e=zi(t);if(n.size>=1e3||n.has(a)||s(e,"ph-sensitive")||s(e,"ph-no-capture")||r.some(e=>Vi(t,e)))return{v:!1};n.add(a);var i=a.assignedSlot||a.parentNode;a=Di(i)?i.host:i&&$i(i)?i:null};a;)if(o=l())return o.v;return!0}(n,o)&&!n.querySelector(".ph-no-capture, .ph-sensitive")){var S=o.capture_value_css_selector_allowlist,k=!1;try{k=c(S)?!!S(n):h(S)&&S.some(t=>Vi(n,t))}catch(t){Fr.error("capture_value_css_selector_allowlist threw",t)}k&&(g.$input_value=n.value)}return null==(d=this.Ta)||d.capture(i,g),!0}}else this.sl()}isBrowserSupported(){var t;return c(null==(t=Er())?void 0:t.querySelectorAll)}},Mr=["[data-ph-capture-value]"],$r=class{constructor(t){this._instance=t}refresh(t){var e,i=this._instance.config,r=v(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance._shouldDisableFlags(),t.url_allowlist=null==r?void 0:r.url_allowlist,t.url_ignorelist=null==r?void 0:r.url_ignorelist,t.dom_event_allowlist=null==r?void 0:r.dom_event_allowlist,t.element_allowlist=null==r?void 0:r.element_allowlist,t.css_selector_allowlist=null==r?void 0:r.css_selector_allowlist,t.css_selector_ignorelist=null==r?void 0:r.css_selector_ignorelist,t.element_attribute_ignorelist=null==r?void 0:r.element_attribute_ignorelist,t.capture_copied_text=null==r?void 0:r.capture_copied_text,t.capture_value_css_selector_allowlist=null!==(e=null==r?void 0:r.capture_value_css_selector_allowlist)&&void 0!==e?e:Mr}},Ir="$surveys",jr="$surveys_loaded_at",Dr="PostHog loadExternalDependency extension not found.",Lr="$surveys_activated",Nr="$surveys_activated_session",zr="$surveys_activated_timestamps",Ur="$heatmaps_enabled_server_side",Br="$exception_capture_enabled_server_side",Hr="$error_tracking_suppression_rules",qr="$error_tracking_capture_extension_exceptions",Vr="$web_vitals_enabled_server_side",Wr="$dead_clicks_enabled_server_side",Gr="$product_tours_enabled_server_side",Kr="$web_vitals_allowed_metrics",Jr="$session_recording_remote_config",Xr="$replay_override_sampling",Yr="$replay_override_linked_flag",Zr="ph_product_tours",Qr="$sdk_debug_recording_script_not_loaded",tn="$sdk_debug_replay_stale_config",en="beforeunload",rn="u">typeof window?window:void 0,nn="u">typeof globalThis?globalThis:rn,sn=null==nn?void 0:nn.navigator,an=null==nn?void 0:nn.document,on=null==nn?void 0:nn.location;null!=nn&&nn.XMLHttpRequest&&new nn.XMLHttpRequest;var ln="undefined"!=typeof globalThis?globalThis:rn;ln&&"undefined"==typeof self&&(ln.self=ln),ln&&"undefined"==typeof File&&(ln.File=function(){});var un=null!=rn?rn:{},hn=li("[Dead Clicks]"),cn=()=>!0,vn=class{get lazyLoadedDeadClicksAutocapture(){return this.Rl}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Wr]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Pl(()=>{this.Ol()}):this.stop()}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",e=>{e?hn.error("failed to load script",e):t()})}Ol(){var t;if(an){if(!this.Rl&&null!=(t=un.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=v(this.instance.config.capture_dead_clicks)?e({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Rl=un.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Rl.start(an),hn.info("starting...")}}else hn.error("`document` not found. Cannot start.")}stop(){this.Rl&&(this.Rl.stop(),this.Rl=void 0,hn.info("stopping..."))}},dn=li("[ExceptionAutocapture]"),fn=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(t){return!1}},pn=(t,e)=>t>=e&&fn(),gn=(t,e,i,r)=>{if(0===t){if(fn()){var n=e+1;return n===i&&r(),n}return e}return 0},mn=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;r.length>n;n++){var s=r[n].split(/=(.*)/);if(s[0]===e){i=s;break}}if(!h(i)||2>i.length)return"";var a=i[1].replace(/\+/g," ");try{a=decodeURIComponent(a)}catch(t){oi.error("Skipping decoding for malformed query param: "+a)}return a},yn=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split(/#(.*)/),n=r[1],s=(r[0]||"").split(/\?(.*)/),a=s[1],o=s[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){for(var c=l[h].split("?"),v=0;c.length>v&&!e.includes(c[v].split("=")[0]);)v++;u.push(c.length>v?c.slice(0,v).concat(c[v].split("=")[0]+"="+i).join("?"):l[h])}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=n&&(d+="#"+n),d},bn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},_n=()=>{},wn=t=>{var e;if(c(t))return null!==(e=t.__posthog_layer__)&&void 0!==e?e:t.__rrweb_layer__};function xn(t,e,i){try{if(!(e in t))return _n;var r={next:t[e]},n=i(function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)});return c(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=n,()=>{if(t[e]!==n)for(var i=t[e],s=wn(i);s;){if(s.next===n)return void(s.next=r.next);s=wn(i=s.next)}else t[e]=r.next}}catch(t){return _n}}var Sn=li("[TracingHeaders]");function kn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var En=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Tn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...En],An="<masked>",Fn=["li_fat_id"];var Pn=li("[Web Vitals]"),Rn=9e5,On=["CLS","FCP","INP","LCP"],Cn=["INP","LCP"],Mn=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],$n=li("[RemoteConfig]"),In=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Ju(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Zu(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return $n.info("Using preloaded remote config",this.remoteConfig),void this.Ku(this.remoteConfig);if(this._instance._shouldDisableFlags())return void $n.warn("Remote config is disabled. Falling back to local config.");this.Ju(t=>{if(!t)return $n.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zu(t=>{this.Ku(t.json,t)});this.Ku(t)})}catch(t){$n.error("Error loading remote config",t),this.Ku()}}Ku(t,e){!t&&e&&(0===e.statusCode?e.error||$n.warn("Failed to fetch remote config from PostHog."):$n.error("Failed to fetch remote config from PostHog."));try{this._instance.Ku(t?{ok:!0,config:t}:{ok:!1})}catch(t){$n.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){$n.error("Error loading feature flags",t)}}},jn="disabled",Dn="lazy_loading",Ln=li("[SessionRecording]"),Nn=[Qr,tn,"$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_matched_recording_trigger_groups","$sdk_debug_replay_pending_trigger_conditions","$sdk_debug_replay_remote_trigger_matching_config","$sdk_debug_replay_trigger_groups_count","$sdk_debug_replay_url_trigger_status"],zn=li("[Heatmaps]");function Un(t){return v(t)&&"clientX"in t&&"clientY"in t&&b(t.clientX)&&b(t.clientY)}var Bn=li("[Product Tours]"),Hn=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Gr))},qn=li("[SiteApps]"),Vn="Error while initializing PostHog app with config id ",Wn="events",Gn="cancelEvents",Kn="survey shown",Jn="survey dismissed",Xn="survey sent";function Yn(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var Zn=(t,e)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},Qn=t=>t.toLowerCase(),ts={exact:(t,e)=>e.some(e=>t.some(t=>e===t)),is_not:(t,e)=>e.every(e=>t.every(t=>e!==t)),regex:(t,e)=>e.some(e=>t.some(t=>Zn(e,t))),not_regex:(t,e)=>e.every(e=>t.every(t=>!Zn(e,t))),icontains:(t,e)=>e.map(Qn).some(e=>t.map(Qn).some(t=>e.includes(t))),not_icontains:(t,e)=>e.map(Qn).every(e=>t.map(Qn).every(t=>!e.includes(t))),gt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i>parseFloat(t))}),lt:(t,e)=>e.some(e=>{var i=parseFloat(e);return!isNaN(i)&&t.some(t=>i<parseFloat(t))})};function es(t,e){return!t||Object.entries(t).every(t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(null==r)return!1;var n=ts[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}var is=li("[Surveys]"),rs=["popover","widget","api"],ns=class{on(t,e){return this.ko[t]||(this.ko[t]=[]),this.ko[t].push(e),()=>{this.ko[t]=this.ko[t].filter(t=>t!==e)}}emit(t,e){for(var i of this.ko[t]||[])i(e);for(var r of this.ko["*"]||[])r(t,e)}constructor(){this.ko={}}};function ss(t,e,i){if(y(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}var as=class{constructor(t){this.$i=t,this.So=new Set,this.xo=new Set,this.$o=new ns,this.Co=(t,e)=>this.To(t,e)&&this.Io(t,e)&&this.Eo(t,e)&&this.Mo(t,e),this.To=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event)}init(){var t,e;f(null==(t=this.$i)?void 0:t.subscribeCapture)||(this.Ao=null==(e=this.$i)?void 0:e.subscribeCapture((t,e)=>{this.on(t,e)}))}dispose(){var t,e;null==(t=this.Ao)||t.call(this),this.Ao=void 0,null==(e=this.$i)||null==e.setElementSelectors||e.setElementSelectors(new Set,this),this.$o=new ns}register(t){var e,i;if(!f(null==(e=this.$i)?void 0:e.subscribeCapture)&&(t.forEach(t=>{var e;this.So.add(t),null==(e=t.steps)||e.forEach(t=>{this.xo.add((null==t?void 0:t.event)||"")})}),null!=(i=this.$i)&&i.setElementSelectors)){var r=new Set;this.So.forEach(t=>{var e;null==(e=t.steps)||e.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this.$i.setElementSelectors(r,this)}}replace(t){this.So.clear(),this.xo.clear(),this.register(t)}on(t,e){null!=e&&0!=t.length&&(this.xo.has(t)||this.xo.has(e.event))&&this.So.forEach(t=>{this.Ro(e,t)&&this.$o.emit("actionCaptured",t.name)})}Po(t){this.onAction("actionCaptured",e=>t(e))}Ro(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Co(t,i))return!0;return!1}onAction(t,e){return this.$o.on(t,e)}Io(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(null==t||!t.properties||!("$current_url"in t.properties))try{var n;r=null==(n=this.$i)||null==n.getActionUrl?void 0:n.getActionUrl()}catch(t){return!1}if(!r||"string"!=typeof r)return!1;if(!ss(r,e.url,e.url_matching||"contains"))return!1}return!0}Eo(t,e){return!!this.Oo(t,e)&&!!this.Fo(t,e)&&!!this.Do(t,e)}Oo(t,e){var i;if(null==e||!e.href)return!0;var r=this.Lo(t);if(r.length>0)return r.some(t=>ss(t.href,e.href,e.href_matching||"exact"));var n,s=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!s&&ss((n=s.match(/(?::|")href="(.*?)"/))?n[1]:"",e.href,e.href_matching||"exact")}Fo(t,e){var i;if(null==e||!e.text)return!0;var r=this.Lo(t);if(r.length>0)return r.some(t=>ss(t.text,e.text,e.text_matching||"exact")||ss(t.$el_text,e.text,e.text_matching||"exact"));var n,s,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(n=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!y(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),s=e.text,a=e.text_matching||"exact",n.some(t=>ss(t,s,a)))}Do(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}Lo(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}Mo(t,e){return null==e||!e.properties||0===e.properties.length||es(e.properties.reduce((t,e)=>{var i=h(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t},{}),null==t?void 0:t.properties)}},os=class{constructor(t,e){this.No=e,this.jo=[],this.$i=t,this.qo=new Map,this.Bo=new Map,this.zo=new Map}Ho(){var t,e;this.Uo=null==(t=(e=this.$i).subscribeSession)?void 0:t.call(e,t=>this.Wo(t))}Vo(t){return!1}Go(){return null}Qo(t){}Jo(){}Zo(t,e){return!!t&&es(t.propertyFilters,null==e?void 0:e.properties)}Ko(t,e){var i=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}Yo(t,e,i){var r=(i===Wn?this.qo:this.Bo).get(t),n=[];return this.Xo(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.Zo(s,e)})}register(t){this.ta(t,!1)}replace(t){this.ta(t,!0)}ta(t,e){f(this.$i.subscribeCapture)||(this.ea(t,e),this.ia(t,e))}ia(t,e){var i=t.filter(t=>{var e;return null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)?void 0:e.length});if(e&&this.zo.clear(),0!==i.length){this.na||(this.na=new as(this.$i),this.na.init(),this.na.Po(t=>this.onAction(t)));var r=[];i.forEach(t=>{var e;null==(e=t.conditions)||null==(e=e.actions)||e.values.forEach(e=>{if(r.push(e),e.name){var i,n=null!==(i=this.zo.get(e.name))&&void 0!==i?i:[];n.includes(t.id)||n.push(t.id),this.zo.set(e.name,n)}})}),e?this.na.replace(r):this.na.register(r)}else{var n;e&&(null==(n=this.na)||n.replace([]))}}sa(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)})}ea(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.Ko(t,Wn),l=this.Ko(t,Gn);e?(this.qo=o,this.Bo=l):(this.sa(this.qo,o),this.sa(this.Bo,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.Ao)&&void 0!==i||(this.Ao=null==(r=(n=this.$i).subscribeCapture)?void 0:r.call(n,(t,e)=>{this.onEvent(t,e)})))}onEvent(t,e){var i,r,n=this.ra(),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.oa(t,s,e);if("consume"===a)return n.info("event consumed activated item, removing it",{event:t,itemId:s}),void this.aa([s]);if("persist"===a)return n.info("shown item promoted to persisted activation",{event:t,itemId:s}),this.la(s),void this.ua([s])}if(this.Bo.has(t)){var o=this.Yo(t,e,Gn);o.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map(t=>t.id)}),this.aa(o.map(t=>t.id)),o.forEach(t=>this.ca(t.id)))}if(this.qo.has(t)){n.info("event name matched",{event:t,eventPayload:e,items:this.qo.get(t)});var l=this.Yo(t,e,Wn);this.ha(l.map(t=>t.id))}}onAction(t){this.zo.has(t)&&this.ha(this.zo.get(t)||[])}ha(t){if(0!==t.length){var e=!!this.$i.getSessionId(),i=[];for(var r of t)e&&this.Vo(r)?this.la(r)&&this.da(r):i.push(r);i.length>0&&(this.jo=[...new Set([...this.jo,...i])]),this.ra().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.va()}}la(t){this.jo=this.jo.filter(e=>e!==t);var e=this.fa();return!e.includes(t)&&(this.pa([...e,t]),this.ga(),!0)}aa(t){var e=new Set(t);this.jo=this.jo.filter(t=>!e.has(t));var i=this.ma(),r=i.filter(t=>!e.has(t));r.length!==i.length&&(this.pa(r),0===r.length&&this.ya()),this.ua(t),this.va()}va(){try{var t;null==(t=this.No)||t.call(this)}catch(t){this.ra().error("Error while handling activated items change",t)}}ba(){var t=this.Go();if(!t)return{};var e=this.$i.getProperty(t);return e&&"object"==typeof e?e:{}}da(t){if(this.Go()){var i=this.ba();this.Qo(e({},i,{[t]:Date.now()}))}}ua(t){if(this.Go()){var e=this.ba(),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.Jo():this.Qo(i))}}_a(){this.Go()&&this.Jo()}getActivationTimestamp(t){if(this.fa().includes(t)){var e=this.ba()[t];return b(e)?e:void 0}}ma(){var t=this.wa();return this.$i.getProperty(t)||[]}fa(){var t=this.ma();if(0===t.length)return[];var e=this.$i.getProperty(this.ka()),i=this.$i.getSessionId();return i&&e===i?t:[]}ga(){var t=this.$i.getSessionId();t&&this.Sa(t)}ya(){this.xa()}Wo(t){var e=this.$i.getProperty(this.ka());if(e&&e!==t){var i=this.ma(),r=this.ba();i.length>0&&(this.pa([]),i.filter(t=>b(r[t])).forEach(t=>this.ca(t))),this.ya(),this._a(),i.length>0&&this.va()}}getActivatedIds(){return[...new Set([...this.fa(),...this.jo])].filter(t=>!this.$a(t))}dispose(){var t,e,i;null==(t=this.Uo)||t.call(this),this.Uo=void 0,null==(e=this.Ao)||e.call(this),this.Ao=void 0,null==(i=this.na)||i.dispose(),this.na=void 0}reset(){this.jo=[],this.ma().length>0&&this.pa([]),this.ya(),this._a(),this.va()}getEventToItemsMap(){return this.qo}Ca(){return this.na}},ls=class extends os{constructor(t,e,i,r){var n;super({subscribeCapture(e){var i=t.onEvent(t=>e(t.event,t));return()=>i.dispose()},subscribeSession(e){var i=t.onSession(e);return()=>i.dispose()},getSessionId(){var e;return null==(e=t.session)?void 0:e.sessionId},getProperty:e=>t.kv.get(e),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(n=null==i?void 0:i.setElementSelectors)&&void 0!==n?n:(e,i)=>{var r;return null==(r=t.getExtension("autocapture"))?void 0:r.setElementSelectors(e,i)}},r),this.Ta=t,this.Ia=e,this.Ho()}wa(){return Lr}ka(){return Nr}Go(){return zr}Qo(t){this.Ta.kv.set({[zr]:t})}Jo(){this.Ta.kv.remove(zr)}Vo(t){var e,i;this.Xo(e=>{i=e.find(e=>e.id===t)});var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return b(r)&&r>0}Ea(){return Kn}Xo(t){this.Ia.getSurveys(t)}ca(t){this.Ia.cancelPendingSurvey(t)}ra(){return is}pa(t){this.Ta.kv.set({[Lr]:t})}Sa(t){this.Ta.kv.set({[Nr]:t})}xa(){this.Ta.kv.remove(Nr)}$a(){return!1}oa(t,e,i){var r,n;return t===Xn&&!1===(null==i||null==(r=i.properties)?void 0:r.$survey_completed)?"ignore":(this.Xo(t=>{n=t.find(t=>t.id===e)}),!n||function(t){var e;return Yn(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(n)?t===Kn?"consume":"ignore":t===Kn?"persist":t===Jn||t===Xn?"consume":"ignore")}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},us=(t,e)=>null!=t&&t.then?t.then(e):e(t),hs="SDK is not enabled or survey functionality is not yet loaded",cs="Disabled. Not loading surveys.",vs=class{constructor(t){this.Ma=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Aa=!1,this.Ra=!1,this.Pa=[],this.Oa=[],this.Fa=null,this.Da=null,this.Ti=!1,this.La=new Set,this.onRemoteConfig=t=>{if(!this.Ti&&!this.Dr.disableSurveys){if(!t.ok)return this.Ra=!0,this.Na({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),is.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(y(e))return is.warn("Flags not loaded yet. Not loading surveys.");this.ja=_(e)?e:e.length>0,is.info("flags response received, isSurveysEnabled: "+this.ja),this.loadIfEnabled()}},this.Na=t=>{this.Oa.slice().forEach(e=>this.qa(e,t))}}setup(t){if(!this.Ti)return this.Ba=t,us(t.kv.initialize(),()=>{if(this.Ba===t&&!this.Ti){this.Ba=void 0,this.Ta=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.Ti?e.dispose():(this.za=e,this.loadIfEnabled())}})}dispose(){var t,e,i,r;this.Ti||(this.Ti=!0,this.Ba=void 0,this.Ta=void 0,null==(t=this.za)||t.dispose(),this.za=void 0,null==(e=this._surveyEventReceiver)||e.dispose(),this._surveyEventReceiver=null,null==(i=this._surveyManager)||null==i.dispose||i.dispose(),this._surveyManager=null,this.Pa=[],this.Oa.forEach(t=>{t.active=!1}),this.Oa=[],null==(r=this.Ha)||r.call(this),this.Ha=void 0,this.Fa=null,this.La.forEach(t=>clearTimeout(t)),this.La.clear())}get Dr(){return this.Ma.get()}getRenderContext(){if(this.Ta){var t=this;return{client:this.Ta,get config(){return t.Dr},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.Na()}loadIfEnabled(){if(!this.Ti&&this.Ta){var t=this.Dr;if(!this._surveyManager)if(this.Aa)is.info("Already initializing surveys, skipping...");else if(t.disableSurveys)is.info(cs);else if(t.cookielessMode&&this.Ta.isOptedOut)is.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Ma.getExtensions();if(e){if(!f(this.ja)||t.advancedEnableSurveys){var i=this.ja||t.advancedEnableSurveys;this.Aa=!0,this.Ra=!1;try{var r=e.generateSurveys;if(r)return this.Wa(r,i),void(this.Aa=!1);var n=e.loadExternalDependency;if(!n)return this.Ua(Dr),void(this.Aa=!1);n(t=>{try{if(this.Ti)return;var e=this.Ma.getExtensions();t||null==e||!e.generateSurveys?this.Ua("Could not load surveys script",t):this.Wa(e.generateSurveys,i)}finally{this.Aa=!1}})}catch(t){throw this.Aa=!1,this.Ua("Error initializing surveys",t),t}}}else this.Ua("PostHog Extensions not found.")}}}Wa(t,e){var i;if(!this.Ti){this._surveyManager=t(e),this._surveyEventReceiver=this.Va(this.Ta,this.Na);var r=null==(i=this.Ta)?void 0:i.kv.get(Ir);r&&this.Ga(r),is.info("Surveys loaded successfully"),this.Qa(),this.Na(),this.Ja({isLoaded:!0})}}Va(t,e){return new ls(t,this,void 0,e)}Ua(t,e){this.Ra=!0,is.error(t,e),this.Na({isLoaded:!1,error:t}),this.Ja({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Pa.push(t),this._surveyManager&&this.Ja({isLoaded:!0}),()=>{this.Pa=this.Pa.filter(e=>e!==t)}}getSurveys(t,e){if(void 0===e&&(e=!1),!this.Ti){var i=this.Ta;if(!i)return t([],{isLoaded:!1,error:hs});if(this.Dr.disableSurveys)return is.info(cs),t([]);var r=i.kv.get(Ir);if(r&&!e)return t(r,{isLoaded:!0}),void(this.Za()&&this.getSurveys(()=>{},!0));if(this.Fa)this.Fa.then(e=>{this.Ti||t(e.surveys,e.context)}).catch(t=>is.error("Error in survey callback",t));else{var n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Dr.requestTimeoutMs}).then(t=>{try{return this.Ka(i,t)}catch(t){return is.error("Error processing surveys response",t),this.Ka(i,{statusCode:0,error:t})}},t=>this.Ka(i,{statusCode:0,error:t}));this.Fa=n;var s=()=>{this.Fa===n&&(this.Fa=null)};n.then(e=>{s(),this.Ti||(this.Na(e.context),t(e.surveys,e.context))},s).catch(t=>is.error("Error in survey callback",t))}}}Ka(t,e){if(this.Ti)return{surveys:[],context:{isLoaded:!1,error:hs}};var i=e.statusCode;if(200!==i||!e.json){var r="Surveys API could not be loaded, status: "+i;return 0!==i?is.error(r):e.error||is.warn(r),this.Da=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Da=null;var n=e.json.surveys||[];return t.kv.set({[Ir]:n,[jr]:Date.now()}),this.Ga(n),{surveys:n,context:{isLoaded:!0}}}Ga(t){var e=t.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(Yn(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t)));this.Ya(e)}Ya(t){var e;null==(e=this._surveyEventReceiver)||e.replace(t)}Za(){return this.Xa()&&!this.Fa&&!this.tl()}Xa(){var t,e=null==(t=this.Ta)?void 0:t.kv.get(jr);return b(e)&&Date.now()-e>3e5}tl(){return b(this.Da)&&3e5>Date.now()-this.Da}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){is.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}this.Na()}Ja(t){for(var e of this.Pa){if(this.Ti)return;try{t.isLoaded?this.getSurveys(e):e([],t)}catch(t){is.error("Error in survey callback",t)}}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!y(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);is.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e;if(this.Ti)return()=>{};var i={callback:t,active:!0,revision:0};this.Oa.push(i),this.Qa();var r=null==(e=this.Ta)?void 0:e.kv.get(Ir);return this.Dr.disableSurveys||!this._surveyManager&&this.Ra&&!this.Aa||!r&&!y(this.Da)&&!this.Fa?this.qa(i,{isLoaded:!1}):this._surveyManager&&this.qa(i),()=>{var t;i.active=!1,this.Oa=this.Oa.filter(t=>t!==i),0===this.Oa.length&&(null==(t=this.Ha)||t.call(this),this.Ha=void 0)}}Qa(){var t,e,i;this._surveyManager&&this.Oa.length>0&&(null!==(t=this.Ha)&&void 0!==t||(this.Ha=null==(e=(i=this.Ma).onMatchingConditionsChanged)?void 0:e.call(i,this.Na)))}qa(t,e){if(!this.Ti&&t.active){var i=++t.revision,r=r=>{if(!this.Ti&&t.active&&i===t.revision)try{var n=null!=e?e:{isLoaded:!0},s=JSON.stringify([r,n]);if(s===t.lastResult)return;t.lastResult=s,t.callback(r,n)}catch(t){is.error("Error in active matching surveys callback",t)}};try{e&&!e.isLoaded?r([]):this.getActiveMatchingSurveys(r)}catch(t){is.error("Error in active matching surveys callback",t)}}}el(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}il(t){if(y(this._surveyManager))return{eligible:!1,reason:hs};var e="string"==typeof t?this.el(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}nl(t){var e;if(null==(e=this.Ta)||!e.canCapture)return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(y(this._surveyManager))return{eligible:!1,reason:hs};var i="string"==typeof t?this.el(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(y(this._surveyManager))return is.warn("init was not called"),{visible:!1,disabledReason:hs};var e=this.nl(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return y(this._surveyManager)?(is.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:hs})):new Promise(i=>{this.getSurveys(e=>{var r,n=null!==(r=e.find(e=>e.id===t))&&void 0!==r?r:null;if(n){var s=this.nl(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.Ta)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var a="string"==typeof t?this.el(t):t;if(null!=a&&a.id)if(rs.includes(a.type)){var o=null==(n=typeof document>"u"?void 0:document)?void 0:n.querySelector(e);if(o)if(null!=(s=a.appearance)&&s.surveyPopupDelaySeconds){is.info("Rendering survey "+a.id+" with delay of "+a.appearance.surveyPopupDelaySeconds+" seconds");var l=setTimeout(()=>{var t,e,r;this.La.delete(l),!this.Ti&&null!=(t=this.Ta)&&t.canCapture&&(is.info("Rendering survey "+a.id+" with delay of "+(null==(e=a.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(r=this._surveyManager)||r.renderSurvey(a,o,i),is.info("Survey "+a.id+" rendered"))},1e3*a.appearance.surveyPopupDelaySeconds);this.La.add(l)}else this._surveyManager.renderSurvey(a,o,i);else is.warn("Survey element not found")}else is.warn("Surveys of type "+a.type+" cannot be rendered in the app");else is.warn("Survey not found")}}displaySurvey(t,i){var r,n;if(null!=(r=this.Ta)&&r.canCapture)if(y(this._surveyManager))is.warn("init was not called");else{var s=this.el(t);if(s){var a=s;if(null!=(n=s.appearance)&&n.surveyPopupDelaySeconds&&i.ignoreDelay&&(a=e({},s,{appearance:e({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==i.displayType&&i.initialResponses&&is.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.il(s);if(!o.eligible)return void is.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(a,i):this.renderSurvey(a,i.selector,i.properties)}else is.warn("Survey not found")}}cancelPendingSurvey(t){y(this._surveyManager)?is.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};si.DEBUG=!1,si.LIB_VERSION="1.445.0",si.LIB_NAME="web";var ds=si,fs=new WeakMap,ps=class{constructor(t){this._instance=t}get(){var t,e,i,r,n=null==(t=this._instance)?void 0:t.config;return{disableSurveys:!(null==n||!n.disable_surveys),cookielessMode:!(null==n||!n.cookieless_mode),advancedEnableSurveys:!(null==n||!n.advanced_enable_surveys),requestTimeoutMs:null!==(e=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==e?e:1e4,prefillFromUrl:!(null==n||null==(i=n.surveys)||!i.prefillFromUrl),automaticDisplay:!(null!=n&&n.disable_surveys_automatic_display),featureFlagEvaluation:!(null!=n&&n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null==(r=this._instance)||null==(r=r.requestRouter)?void 0:r.endpointFor("ui","")}}getExtensions(){var t=null==un?void 0:un.__PosthogExtensions__;if(t&&this._instance){var e=this._instance,i=t.generateSurveys,r=t.loadExternalDependency;return{generateSurveys:i?t=>i(e,t):void 0,loadExternalDependency:r?t=>r(e,"surveys",t):void 0}}}onMatchingConditionsChanged(t){var e,i,r=null==(e=this._instance)?void 0:e._addCaptureHook(e=>{"$pageview"!==e&&e!==Kn&&e!==Jn&&e!==Xn||t()}),n=()=>t();di(rn,"PHSurveyShown",n);var s=!1,a=null==(i=this._instance)?void 0:i.onFeatureFlags(()=>{s&&t()});return s=!0,()=>{s=!1,null==r||r(),null==a||a(),null==rn||rn.removeEventListener("PHSurveyShown",n)}}},gs=null!=rn&&rn.location?bn(rn.location.hash,"__posthog")||bn(location.hash,"state"):null,ms="_postHogToolbarParams",ys=li("[Toolbar]"),bs=li("[FeatureFlags]"),_s=li("[FeatureFlags]",{debugEnabled:!0}),ws="\" failed. Feature flags didn't load in time.",xs=[502,504],Ss=["click","keydown","wheel","touchstart","pointerdown"],ks="connection_error",Es=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Ts=t=>{var e={};for(var i of vi(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},As=class{constructor(t){this.name="featureFlags",this.xd=!1,this.featureFlagEventHandlers=[],this.A=bs,this.$d={},this.Cd={},this.Td=[],this.Id=new Set,this.Ed=new Set,this.Md=!1,this.Ad=!1,this.Rd=0,this.Pd=!1,this.Od=!1,this.Fd=!1,this.Dd=!1,this.Ld=!1,this.Nd=0,this.jd=!1,this.sn=()=>{var t=this.qd();this.Nd=0,t&&this.reloadFeatureFlags()},this.Bd=()=>{var t,e,i=this.zd,r=null!==(t=this.Hd)&&void 0!==t?t:i;f(i)||f(r)||this.Dr.remoteRequestsDisabled||!this.Ud||"hidden"===this.Ud.visibilityState||Date.now()-(null!==(e=this.Wd)&&void 0!==e?e:0)<r||(this.Hd=this.jd||!this.Dr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.jd=!1,this.reloadFeatureFlags(),this.Vd())},this.Gd=()=>{this.jd&&this.Hd===this.zd||this.Qd()},this.an=()=>{var t;"visible"===(null==(t=this.Ud)?void 0:t.visibilityState)&&this.Qd()},this.Ma=t}get Jd(){}Zd(){this.Ta&&this.Kd()}setup(t){try{this.Yd=typeof window>"u"?void 0:window,this.Ud=typeof document>"u"?void 0:document}catch(t){this.Yd=void 0,this.Ud=void 0}return this.Ba=t,this.A=t.logger.createLogger("[FeatureFlags]"),us(t.kv.initialize(),()=>{this.Ba===t&&(this.Ba=void 0,this.Ta=t,this.Xd(t))})}Xd(t){var e;if(this.Ta===t)return this.Yd&&di(this.Yd,"online",this.sn),this.Kd(),this.tv=t.registerDynamicEventProperties(()=>this.ev()?this.$d:this.Cd),this.iv=null==(e=this.Jd)?void 0:e.onCrossTabFeatureFlagChange(()=>{this.nv(),this.sv(),this.rv()}),this.sv(),this.initialize()}Qd(){this.jd=!0,this.Hd=this.zd,this.Bd()}Kd(){var t,e=this.Dr.refreshIntervalMs,i=!this.Dr.remoteRequestsDisabled&&this.Ud&&!f(e)&&e>0?e:void 0;this.Dr.idleRefreshBackoff||(this.Hd=i),i!==this.zd&&(this.ov(),f(i)||(this.zd=i,this.Hd=i,this.Vd(),null!=(t=this.Ud)&&t.addEventListener&&(di(this.Ud,Oi,this.an),ui(Ss,t=>{di(this.Ud,t,this.Gd,{capture:!0})}))))}Vd(){f(this.zd)||(f(this.av)||clearInterval(this.av),this.Wd=Date.now(),this.av=setInterval(this.Bd,this.zd))}ov(){var t;f(this.av)||(clearInterval(this.av),this.av=void 0,null==(t=this.Ud)||null==t.removeEventListener||t.removeEventListener(Oi,this.an),ui(Ss,t=>{var e;null==(e=this.Ud)||null==e.removeEventListener||e.removeEventListener(t,this.Gd,{capture:!0})})),this.zd=void 0,this.Hd=void 0,this.jd=!1,this.Wd=void 0}destroy(){this.lv()}dispose(){this.lv()}lv(){var t,e,i;this.ov(),this.Rd++,this.Od=!1,this.Ba=void 0,this.uv(this.Id,"cancelled"),this.uv(this.Ed,"cancelled"),this.Ta&&(this.hv(),null==(t=this.tv)||t.dispose(),this.tv=void 0,null==(e=this.iv)||e.call(this),this.iv=void 0,this.Td=[],null==(i=this.Yd)||i.removeEventListener("online",this.sn),this.Ta=void 0)}get Dr(){return this.Ma.get()}dv(t){var e;return this.vv&&t in this.vv?this.vv[t]:null==(e=this.Ta)?void 0:e.kv.get(t)}nv(){return!!this.vv&&(this.vv=void 0,!0)}fv(){var t;return!f(null==(t=this.Ta)?void 0:t.kv.get("$enabled_feature_flags"))&&this.nv()}$t(t){this.pv(()=>{var e;return null==(e=this.Ta)?void 0:e.kv.set(t)})}gv(t,e,i){if(this.Jd&&t.$enabled_feature_flags){var r=this.dv("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},s=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(t=>{var e=t[1];return!(null!=e&&e.failed)}).map(t=>t[0]):[],o=!!e.errorsWhileComputingFlags&&!!e.flags,l=o?a:i&&!h(s)?Object.keys(s||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),u=this.dv("$feature_flag_payloads")||{},c=t.$feature_flag_payloads||{},v=o||i?l:Array.from(new Set([...Object.keys(u),...Object.keys(c)])),d=!o&&!i,p=!!d||l,g=!!d||v,m={[mi]:p,[Si]:p,[Fi]:g};for(var y of(t.$feature_flag_details&&(m[yi]=p),[wi,_i,xi]))f(t[y])||(m[y]=!0);this.Jd.markCrossTabFeatureFlagChanges(m)}}Dt(t){this.pv(()=>{var e;return null==(e=this.Ta)?void 0:e.kv.remove(t)})}pv(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}sv(){var t={};for(var i of[mi,Fi,wi,Pi]){var r=this.dv(i);f(r)||(t[i]=r)}this.$d=t;var n=e({},t),s=this.dv(Si);if(s)for(var a of Object.entries(s))n["$feature/"+a[0]]=a[1];this.Cd=n}ev(){var t=this.Dr.cacheTtlMs;if(!t||0>=t)return!1;var e=this.dv(_i);return"number"!=typeof e||Date.now()-e>t}mv(){return!!this.ev()&&(this.Ld||this.Ad||(this.Ld=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}yv(){var t=this.Dr.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),e}):[]}bv(){var t=this.Dr.flagKeys;if(!f(t))return t.filter(t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),e})}initialize(){var t,e,i=this.Dr,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var n,s,a=null!==(n=null==(s=i.bootstrap)?void 0:s.featureFlagPayloads)&&void 0!==n?n:{},o=Object.keys(r).filter(t=>!f(r[t])).reduce((t,e)=>(t[e]=r[e],t),{}),l=Object.keys(a).filter(t=>o[t]).reduce((t,e)=>(t[e]=a[e],t),{});return this._v({featureFlags:o,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,r){var n,s,a=null!=r&&r.merge&&null!==(n=this.dv("$enabled_feature_flags"))&&void 0!==n?n:{},o=null!=r&&r.merge&&null!==(s=this.dv("$feature_flag_payloads"))&&void 0!==s?s:{},l=e({},a,t),u=e({},o,i),h={};for(var c of Object.entries(l)){var v=c[0],d=c[1];h[v]={key:v,enabled:qt(d),variant:Vt(d),reason:void 0,metadata:f(null==u?void 0:u[v])?void 0:{id:0,version:void 0,description:void 0,payload:u[v]}}}this._v({flags:h})}get hasLoadedFlags(){return this.Md}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.dv(yi),i=this.dv(Pi),r=this.dv(Ri);if(!r&&!i)return t||{};var n=ci({},t||{});for(var s of[...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.xd||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:n}),this.xd=!0),n}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(i=>{var r=t[i];return{key:i,enabled:qt(r),variant:Vt(r),payload:Ht(e[i])}})}getFlagVariants(){var t=this.dv(Si),e=this.dv(Pi);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.xd||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.xd=!0),i}getFlagPayloads(){var t=this.dv(Fi),e=this.dv(Ri);if(!e)return t||{};for(var i=ci({},t||{}),r=Object.keys(e),n=0;r.length>n;n++)i[r[n]]=e[r[n]];return this.xd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.xd=!0),i}reloadFeatureFlags(){this.Pd||this.Dr.featureFlagsDisabled||this.qd()||(this.Fd&&this.A.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.Ad&&(this.Od=!0),this.wv||(this.Td.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.wv=setTimeout(()=>{this.Sv()},5)))}reloadFeatureFlagsAsync(){return!this.Ta||this.Pd||this.Dr.featureFlagsDisabled||this.Dr.remoteRequestsDisabled||this.qd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.Id.add(t),this.reloadFeatureFlags()})}uv(t,e){t.forEach(t=>t({status:e})),t.clear()}hv(){clearTimeout(this.wv),this.wv=void 0}onReloading(t){return this.Td.push(t),()=>{this.Td=this.Td.filter(e=>e!==t)}}ensureFlagsLoaded(){this.Md||this.Ad||this.wv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Pd=t}resetFlagCallReported(){this.Dt(Ti)}Sv(t){var i;this.hv();var r=this.Ta;if(!r||this.Dr.remoteRequestsDisabled||this.qd())this.uv(this.Id,"skipped");else if(this.Ad)this.Od=!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.dv("$stored_person_properties")||{},{$lib:r.library.name,$lib_version:r.library.version}),group_properties:this.dv(ki),timezone:kn()};f(r.deviceId)||(n.$device_id=r.deviceId),(null!=t&&t.disableFlags||this.Dr.featureFlagsDisabled)&&(n.disable_flags=!0);var s=this.yv();s.length&&(n.evaluation_contexts=s);var a=this.bv();f(a)||(n.flag_keys=a);var o=this.Dr.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),u=this.Rd,h=this.Id;this.Id=new Set,this.Ed=h,this.Ad=!0;var c=()=>{this.Od&&(this.Od=!1,this.Sv())},v=t=>{var e,i,r=null!==(e=t.json)&&void 0!==e?e:{},s=200!==t.statusCode;if(this.Ad=!1,u===this.Rd)if(this.xv(t.statusCode),s||this.Od||(this.$anon_distinct_id=void 0),!n.disable_flags||this.Od){this.Dd=!s;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?ks:"unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),r.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l=!(null==(i=r.quotaLimited)||!i.includes("feature_flags"));l&&a.push("quota_limited"),this.$t({[bi]:a}),l?this.A.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._v(r,s,{partialResponse:o}),this.uv(h,n.disable_flags?"skipped":a.length||!r.flags&&!r.featureFlags?"error":"loaded"),c()}else this.uv(h,"skipped");else c()},d=t=>{this.Ad=!1,u===this.Rd?(this.$t({[bi]:[ks]}),this.A.error("Feature flag request failed",t),this.fv()&&this.rv(!0),this.uv(h,"error"),c()):c()},p=null!==(i=this.Dr.requestMaxRetries)&&void 0!==i?i:1,g=()=>p>0&&u===this.Rd,m=()=>{if(u!==this.Rd||!this.Ta||this.Dr.remoteRequestsDisabled)return this.Ad=!1,this.uv(h,"skipped"),void c();try{r.sendRequest(l,{target:"flags",method:"POST",body:n,compression:this.Dr.compression,sentAt:"body",timeoutMs:this.Dr.requestTimeoutMs}).then(t=>{if((t=>xs.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()}}qd(){return pn(this.Nd,3)}xv(t){this.Nd=gn(t,this.Nd,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.Dd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.mv()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else this.A.warn('getFeatureFlag for key "'+t+ws)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e;return null==(e=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:e.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.Dd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.mv()){var r,n=this.getFlagVariants(),s=t in n,a=n[t],o=this.getFlagPayloads()[t],l=String(a),u=this.dv("$feature_flag_request_id")||void 0,c=this.dv("$feature_flag_evaluated_at")||void 0,v=this.dv("$flag_call_reported")||{};if(this.Dr.deduplicateCallsPerSession){var d,p=null==(d=this.Ta)||null==(d=d.session)?void 0:d.sessionId,g=this.dv(Ai);p&&p!==g&&(v={},r=p)}if(!i.send_event&&"send_event"in i)r&&this.$t({[Ti]:v,[Ai]:r});else{var m,y,b=null==(m=this.Ta)?void 0:m.canCapture;if(!b&&Object.keys(v).length>0&&(v={},this.$t({[Ti]:v})),!b||null!=(y=v[t])&&y.includes(l))r&&this.$t({[Ti]:v,[Ai]:r});else{var _,w,x,S,k,E,T,A,F,P,R,O,C;h(v[t])?v[t].push(l):v[t]=[l],this.$t(e({[Ti]:v},r?{[Ai]:r}:{}));var M=this.getFeatureFlagDetails(t),I=[...null!==(_=this.dv("$feature_flag_errors"))&&void 0!==_?_:[]];f(a)&&I.push("flag_missing");var j={$feature_flag:t,$feature_flag_response:a,$feature_flag_payload:null!=o?o:null,$feature_flag_request_id:u,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:null!==(w=null==(x=this.Dr.bootstrap)||null==(x=x.featureFlags)?void 0:x[t])&&void 0!==w?w:null,$feature_flag_bootstrapped_payload:null!==(S=null==(k=this.Dr.bootstrap)||null==(k=k.featureFlagPayloads)?void 0:k[t])&&void 0!==S?S:null,$used_bootstrap_value:!this.Dd};f(null==M||null==(E=M.metadata)?void 0:E.has_experiment)||(j.$feature_flag_has_experiment=M.metadata.has_experiment),f(null==M||null==(T=M.metadata)?void 0:T.version)||(j.$feature_flag_version=M.metadata.version);var D=null!==(A=null==M||null==(F=M.reason)?void 0:F.description)&&void 0!==A?A:null==M||null==(P=M.reason)?void 0:P.code;D&&(j.$feature_flag_reason=D),null!=M&&null!=(R=M.metadata)&&R.id&&(j.$feature_flag_id=M.metadata.id),f(null==M?void 0:M.original_variant)&&f(null==M?void 0:M.original_enabled)||(j.$feature_flag_original_response=f(M.original_variant)?M.original_enabled:M.original_variant),null!=M&&null!=(O=M.metadata)&&O.original_payload&&(j.$feature_flag_original_payload=null==M||null==(C=M.metadata)?void 0:C.original_payload),I.length&&(j.$feature_flag_error=I.join(",")),this.$v(j)}}if(s)return{key:t,enabled:!!a,variant:"string"==typeof a?a:void 0,payload:Ht(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+ws)}$v(t){try{var e;null==(e=this.Ta)||e.capture("$feature_flag_called",t)}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,e){this.Cv(t,e)}Cv(t,e){var i=this;return r(function*(){var r=i.Ta;if(r){var n={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},s=i.yv();s.length&&(n.evaluation_contexts=s);var a,o=i.bv();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.Dr.compression,sentAt:"body",timeoutMs:i.Dr.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void i.A.error("Remote config feature flag request failed",t)}try{e(a)}catch(t){i.A.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.Dd)return e.defaultValue;if(!(this.Md||this.getFlags()&&this.getFlags().length>0))return this.A.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._v(t,e,i)}_v(t,i,r){if(this.Ta){this.Md=!0;var n=function(t,i,r,n,s,a){void 0===i&&(i={}),void 0===r&&(r={}),void 0===n&&(n={}),void 0===a&&(a=bs);var o=((t,i)=>{var r=t.flags;return r?e({},t,{featureFlags:Object.fromEntries(Object.keys(r).map(t=>{var e;return[t,null!==(e=r[t].variant)&&void 0!==e?e:r[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(r).filter(t=>r[t].enabled).filter(t=>{var e;return!f(null==(e=r[t].metadata)?void 0:e.payload)}).map(t=>{var e;return[t,null==(e=r[t].metadata)?void 0:e.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,a),l=o.flags,u=o.featureFlags,c=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(h(u)){a.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var p={};if(u)for(var g=0;u.length>g;g++)p[u[g]]=!0;return{[mi]:u,[Si]:p,[xi]:!1}}var m=u,y=c,b=l;if(null!=s&&s.partialResponse){var _=Object.keys(m),w=y||{};m=e({},i,m),y=e({},r,w),_.forEach(t=>{var e;t in w||null==(e=y)||delete e[t]}),b=e({},n,b)}else if(t.errorsWhileComputingFlags)if(l){var x=new Set(Object.keys(l).filter(t=>{var e;return!(null!=(e=l[t])&&e.failed)}));m=e({},i,Object.fromEntries(Object.entries(m).filter(t=>x.has(t[0]))));var S=Object.fromEntries(Object.entries(y||{}).filter(t=>x.has(t[0])));y=e({},r,S),x.forEach(t=>{var e;t in S||null==(e=y)||delete e[t]}),b=e({},n,Object.fromEntries(Object.entries(b||{}).filter(t=>x.has(t[0]))))}else m=e({},i,m),y=e({},r,y),b=e({},n,b);return e({[mi]:Object.keys(Ts(m)),[Si]:m||{},[Fi]:y||{},[yi]:b||{},[xi]:!0===t.minimalFlagCalledEvents},v?{[wi]:v}:{},d?{[_i]:d}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),r,this.A);if(n)if(!1===(null==r?void 0:r.persist)){var s=!f(this.Ta.kv.get(Si));this.vv=n,s||this.$t(n)}else this.nv(),this.gv(n,t,!(null==r||!r.partialResponse)),this.$t(n);else i&&this.fv();i||(this.Ld=!1),this.rv(i)}}override(t,e){void 0===e&&(e=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.Tv(t)}Tv(t){if(this.Ta){if(!1===t)return this.Dt([Pi,Ri]),this.rv(),void _s.info("All overrides cleared");if(h(t))return this.$t({[Pi]:Es(t)}),this.rv(),void _s.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var e,i=t;this.xd=Boolean(null!==(e=i.suppressWarning)&&void 0!==e&&e);var r={},n=i.flags,s=i.payloads;return n&&(r[Pi]=h(n)?Es(n):n),s&&(r[Ri]=s),Object.keys(r).length&&this.$t(r),!1===n&&!1===s?this.Dt([Pi,Ri]):!1===n?this.Dt(Pi):!1===s&&this.Dt(Ri),this.rv(),!1===n?_s.info("Flag overrides cleared"):n&&_s.info("Flag overrides set",{flags:n}),void(!1===s?_s.info("Payload overrides cleared"):s&&_s.info("Payload overrides set",{payloads:s}))}if(t&&"object"==typeof t)return this.$t({[Pi]:t}),this.rv(),void _s.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Md){var e=this.Iv(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,r){var n,s=(this.dv("$early_access_features")||[]).find(e=>e.flagKey===t),a={["$feature_enrollment/"+t]:i},o={$feature_flag:t,$feature_enrollment:i,$set:a};s&&(o.$early_access_feature_name=s.name),r&&(o.$feature_enrollment_stage=r);var l=e({},this.getFlagVariants(),{[t]:i});null==(n=this.Jd)||n.markCrossTabFeatureFlagChanges({[mi]:[t],[Si]:[t],[Ei]:Object.keys(a)}),this.$t({[mi]:Object.keys(Ts(l)),[Si]:l,[Ei]:e({},this.dv("$stored_person_properties")||{},a)}),this.rv();try{var u;null==(u=this.Ta)||u.capture("$feature_enrollment_update",o)}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.dv(gi);!r||e?this.Ev(t,i):t(r)}Ev(t,e){var i=this;return r(function*(){var r=i.Ta;if(r){var n,s=e?"&"+e.map(t=>"stage="+t).join("&"):"";try{var a=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+s,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;n=a.json.earlyAccessFeatures,i.$t({[gi]:n})}catch(t){return void i.A.error("Early access feature request failed",t)}try{t(n)}catch(t){i.A.error("Early access feature callback failed",t)}}})()}Iv(){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),{})}}rv(t){this.sv();var e=this.Iv(),i=e.flags,r=e.flagVariants,n=this.Fd;this.Fd=!0,this.featureFlagEventHandlers.forEach(e=>{try{e(i,r,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}}),this.Fd=n}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0),this.Mv(t,e)}Mv(t,i){void 0===i&&(i=!0);var r=this.dv("$stored_person_properties")||{},n=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,a={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in r||(a[o]=s[o]));this.$t({[Ei]:e({},r,a,n)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=e({},this.dv("$stored_person_properties")||{});t.forEach(t=>{delete r[t]}),this.$t({[Ei]:r}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Ei),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var r=this.dv("$stored_group_properties")||{},n=e({},r);for(var s of Object.keys(t))n[s]=e({},r[s],t[s]);this.$t({[ki]:n}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.dv("$stored_group_properties")||{};this.$t({[ki]:e({},i,{[t]:{}})})}else this.Dt(ki)}reset(){this.Rd++,this.uv(this.Id,"cancelled"),this.uv(this.Ed,"cancelled"),this.Od=!1,this.$d={},this.Cd={},this.vv=void 0,this.Md=!1,this.Pd=!1,this.Dd=!1,this.$anon_distinct_id=void 0,this.hv(),this.xd=!1,this.Nd=0}},Fs=li("[FeatureFlags]"),Ps=class{constructor(t,e){void 0===e&&(e=!1),this.Av=!1,this.update(t,e)}update(t,e){this.Rv=((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.Av||(Fs.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Av=!0),f(t.flag_keys)||h(t.flag_keys)||Fs.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Rv}},Rs=t=>S(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Os=li("[Error tracking]"),Cs="webkit-masked-url:",Ms=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],$s=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Cs],Is=["__firefox__","__gCrWeb"];function js(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 Ds(t,e){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);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,e)||function(t,e){if(t){if("string"==typeof t)return js(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?js(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Ls=Object.entries,Ns=Object.setPrototypeOf,zs=Object.isFrozen,Us=Object.getPrototypeOf,Bs=Object.getOwnPropertyDescriptor,Hs=Object.freeze,qs=Object.seal,Vs=Object.create,Ws="undefined"!=typeof Reflect&&Reflect,Gs=Ws.apply,Ks=Ws.construct;Hs||(Hs=function(t){return t}),qs||(qs=function(t){return t}),Gs||(Gs=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)}),Ks||(Ks=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 Js,Xs=ga([].forEach),Ys=ga([].lastIndexOf),Zs=ga([].pop),Qs=ga([].push),ta=ga([].splice),ea=Array.isArray,ia=ga("".toLowerCase),ra=ga("".toString),na=ga("".match),sa=ga("".replace),aa=ga("".indexOf),oa=ga("".trim),la=ga((0).toString),ua=ga(Boolean.prototype.toString),ha="undefined"==typeof BigInt?null:ga(BigInt.prototype.toString),ca="undefined"==typeof Symbol?null:ga(Symbol.prototype.toString),va=ga({}.hasOwnProperty),da=ga({}.toString),fa=ga(/t/.test),pa=(Js=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return Ks(Js,e)});function ga(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;i>n;n++)r[n-1]=arguments[n];return Gs(t,e,r)}}function ma(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ia;if(Ns&&Ns(t,null),!ea(e))return t;for(var r=e.length;r--;){var n=e[r];if("string"==typeof n){var s=i(n);s!==n&&(zs(e)||(e[r]=s),n=s)}t[n]=!0}return t}function ya(t){for(var e=0;t.length>e;e++)va(t,e)||(t[e]=null);return t}function ba(t){var e=Vs(null);for(var i of Ls(t)){var r=Ds(i,2),n=r[0],s=r[1];va(t,n)&&(e[n]=ea(s)?ya(s):s&&"object"==typeof s&&s.constructor===Object?ba(s):s)}return e}function _a(t,e){for(;null!==t;){var i=Bs(t,e);if(i){if(i.get)return ga(i.get);if("function"==typeof i.value)return ga(i.value)}t=Us(t)}return function(){return null}}var wa,xa=Hs(["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"]),Sa=Hs(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ka=Hs(["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"]),Ea=Hs(["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"]),Ta=Hs(["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"]),Aa=Hs(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fa=Hs(["#text"]),Pa=Hs(["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"]),Ra=Hs(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Oa=Hs(["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"]),Ca=Hs(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ma=qs(/{{[\w\W]*|^[\w\W]*}}/g),$a=qs(/<%[\w\W]*|^[\w\W]*%>/g),Ia=qs(/\${[\w\W]*/g),ja=qs(/^data-[\-\w.\u00B7-\uFFFF]+$/),Da=qs(/^aria-[\-\w]+$/),La=qs(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Na=qs(/^(?:\w+script|data):/i),za=qs(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ua=qs(/^html$/i),Ba=qs(/^[a-z][.\w]*(-[.\w]+)+$/i),Ha=qs(/<[/\w!]/g),qa=qs(/<[/\w]/g),Va=qs(/<\/no(script|embed|frames)/i),Wa=qs(/\/>/i),Ga=function(){return"undefined"==typeof window?null:window},Ka=function(t,e,i,r){return va(t,e)&&ea(t[e])?ma(r.base?ba(r.base):{},t[e],r.transform):i},Ja=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ga(),i=e=>t(e);if(i.version="3.4.13",i.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return i.isSupported=!1,i;var r,n=e.document,s=n,a=s.currentScript,o=e.HTMLTemplateElement,l=e.Node,u=e.NodeFilter,h=e.DOMParser,c=e.trustedTypes,v=e.Element.prototype,d=_a(v,"cloneNode"),f=_a(v,"remove"),p=_a(v,"nextSibling"),g=_a(v,"childNodes"),m=_a(v,"parentNode"),y=_a(v,"shadowRoot"),b=_a(v,"attributes"),_=l&&l.prototype?_a(l.prototype,"nodeType"):null,w=l&&l.prototype?_a(l.prototype,"nodeName"):null,x=l&&l.prototype?_a(l.prototype,"ownerDocument"):null;if("function"==typeof o){var S=n.createElement("template");S.content&&S.content.ownerDocument&&(n=S.content.ownerDocument)}var k,E="",T=!1,A=0,F=function(){if(A>0)throw pa('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.')},P=function(t){F(),A++;try{return r.createHTML(t)}finally{A--}},R=n.implementation,O=n.createNodeIterator,C=n.createDocumentFragment,M=n.getElementsByTagName,I=s.importNode,j={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof Ls&&"function"==typeof m&&R&&void 0!==R.createHTMLDocument;var D=Ma,L=$a,N=Ia,z=ja,U=Da,B=Na,H=za,q=Ba,V=La,W=null,G=ma({},[...xa,...Sa,...ka,...Ta,...Fa]),K=null,J=ma({},[...Pa,...Ra,...Oa,...Ca]),X=Object.seal(Vs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Y=null,Z=null,Q=Object.seal(Vs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),tt=!0,et=!0,it=!1,rt=!0,nt=!1,st=!0,at=!1,ot=!1,lt=null,ut=null,ht=!1,ct=!1,vt=!1,dt=!1,ft=!0,pt=!1,gt="user-content-",mt=!0,yt=!1,bt={},_t=null,wt=ma({},["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"]),xt=null,St=ma({},["audio","video","img","source","image","track"]),kt=null,Et=ma({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Tt="http://www.w3.org/1998/Math/MathML",At="http://www.w3.org/2000/svg",Ft="http://www.w3.org/1999/xhtml",Pt=Ft,Rt=!1,Ot=null,Ct=ma({},[Tt,At,Ft],ra),Mt=Hs(["mi","mo","mn","ms","mtext"]),$t=ma({},Mt),It=Hs(["annotation-xml"]),jt=ma({},It),Dt=ma({},["title","style","font","a","script"]),Lt=null,Nt=["application/xhtml+xml","text/html"],zt=null,Ut=null,Bt=n.createElement("form"),Ht=function(t){return t instanceof RegExp||t instanceof Function},qt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Ut||Ut!==t){t&&"object"==typeof t||(t={}),t=ba(t),Lt=-1===Nt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,W=Ka(t,"ALLOWED_TAGS",G,{transform:zt="application/xhtml+xml"===Lt?ra:ia}),K=Ka(t,"ALLOWED_ATTR",J,{transform:zt}),Ot=Ka(t,"ALLOWED_NAMESPACES",Ct,{transform:ra}),kt=Ka(t,"ADD_URI_SAFE_ATTR",Et,{transform:zt,base:Et}),xt=Ka(t,"ADD_DATA_URI_TAGS",St,{transform:zt,base:St}),_t=Ka(t,"FORBID_CONTENTS",wt,{transform:zt}),Y=Ka(t,"FORBID_TAGS",ba({}),{transform:zt}),Z=Ka(t,"FORBID_ATTR",ba({}),{transform:zt}),bt=!!va(t,"USE_PROFILES")&&(t.USE_PROFILES&&"object"==typeof t.USE_PROFILES?ba(t.USE_PROFILES):t.USE_PROFILES),tt=!1!==t.ALLOW_ARIA_ATTR,et=!1!==t.ALLOW_DATA_ATTR,it=t.ALLOW_UNKNOWN_PROTOCOLS||!1,rt=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,nt=t.SAFE_FOR_TEMPLATES||!1,st=!1!==t.SAFE_FOR_XML,at=t.WHOLE_DOCUMENT||!1,ct=t.RETURN_DOM||!1,vt=t.RETURN_DOM_FRAGMENT||!1,dt=t.RETURN_TRUSTED_TYPE||!1,ht=t.FORCE_BODY||!1,ft=!1!==t.SANITIZE_DOM,pt=t.SANITIZE_NAMED_PROPS||!1,mt=!1!==t.KEEP_CONTENT,yt=t.IN_PLACE||!1,V=function(t){try{return fa(t,""),!0}catch(t){return!1}}(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:La,Pt="string"==typeof t.NAMESPACE?t.NAMESPACE:Ft,$t=va(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof t.MATHML_TEXT_INTEGRATION_POINTS?ba(t.MATHML_TEXT_INTEGRATION_POINTS):ma({},Mt),jt=va(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&"object"==typeof t.HTML_INTEGRATION_POINTS?ba(t.HTML_INTEGRATION_POINTS):ma({},It);var e=va(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&"object"==typeof t.CUSTOM_ELEMENT_HANDLING?ba(t.CUSTOM_ELEMENT_HANDLING):Vs(null);if(X=Vs(null),va(e,"tagNameCheck")&&Ht(e.tagNameCheck)&&(X.tagNameCheck=e.tagNameCheck),va(e,"attributeNameCheck")&&Ht(e.attributeNameCheck)&&(X.attributeNameCheck=e.attributeNameCheck),va(e,"allowCustomizedBuiltInElements")&&"boolean"==typeof e.allowCustomizedBuiltInElements&&(X.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),qs(X),nt&&(et=!1),vt&&(ct=!0),bt&&(W=ma({},Fa),K=Vs(null),!0===bt.html&&(ma(W,xa),ma(K,Pa)),!0===bt.svg&&(ma(W,Sa),ma(K,Ra),ma(K,Ca)),!0===bt.svgFilters&&(ma(W,ka),ma(K,Ra),ma(K,Ca)),!0===bt.mathMl&&(ma(W,Ta),ma(K,Oa),ma(K,Ca))),Q.tagCheck=null,Q.attributeCheck=null,va(t,"ADD_TAGS")&&("function"==typeof t.ADD_TAGS?Q.tagCheck=t.ADD_TAGS:ea(t.ADD_TAGS)&&(W===G&&(W=ba(W)),ma(W,t.ADD_TAGS,zt))),va(t,"ADD_ATTR")&&("function"==typeof t.ADD_ATTR?Q.attributeCheck=t.ADD_ATTR:ea(t.ADD_ATTR)&&(K===J&&(K=ba(K)),ma(K,t.ADD_ATTR,zt))),va(t,"ADD_URI_SAFE_ATTR")&&ea(t.ADD_URI_SAFE_ATTR)&&ma(kt,t.ADD_URI_SAFE_ATTR,zt),va(t,"FORBID_CONTENTS")&&ea(t.FORBID_CONTENTS)&&(_t===wt&&(_t=ba(_t)),ma(_t,t.FORBID_CONTENTS,zt)),va(t,"ADD_FORBID_CONTENTS")&&ea(t.ADD_FORBID_CONTENTS)&&(_t===wt&&(_t=ba(_t)),ma(_t,t.ADD_FORBID_CONTENTS,zt)),mt&&(W["#text"]=!0),at&&ma(W,["html","head","body"]),W.table&&(ma(W,["tbody"]),delete Y.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw pa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw pa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');var i=r;r=t.TRUSTED_TYPES_POLICY;try{E=P("")}catch(t){throw r=i,t}}else null===t.TRUSTED_TYPES_POLICY?(r=void 0,E=""):(void 0===r&&(T||(k=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}}(c,a),T=!0),r=k),r&&"string"==typeof E&&(E=P("")));Hs&&Hs(t),Ut=t}},Vt=ma({},[...Sa,...ka,...Ea]),Wt=ma({},[...Ta,...Aa]),Gt=function(t){Qs(i.removed,{element:t});try{m(t).removeChild(t)}catch(e){if(f(t),!m(t))throw pa("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Kt=function(t){Yt(t);var e=g(t);if(e){var i=[];Xs(e,t=>{Qs(i,t)}),Xs(i,t=>{try{f(t)}catch(t){}})}var r=b(t);if(r)for(var n=r.length-1;n>=0;--n){var s=r[n],a=s&&s.name;if("string"==typeof a)try{t.removeAttribute(a)}catch(t){}}},Jt=function(t,e){try{Qs(i.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Qs(i.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(ct||vt)try{Gt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Xt=function(t){var e=b(t);if(e)for(var i=e.length-1;i>=0;--i){var r=e[i],n=r&&r.name;if("string"==typeof n&&!K[zt(n)])try{t.removeAttribute(n)}catch(t){}}},Yt=function(t){for(var e=[t];e.length>0;){var i=e.pop();1===(_?_(i):i.nodeType)&&Xt(i);var r=g(i);if(r)for(var n=r.length-1;n>=0;--n)e.push(r[n])}},Zt=function(t){var e=null,i=null;if(ht)t="<remove></remove>"+t;else{var s=na(t,/^[\r\n\t ]+/);i=s&&s[0]}"application/xhtml+xml"===Lt&&Pt===Ft&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var a=r?P(t):t;if(Pt===Ft)try{e=(new h).parseFromString(a,Lt)}catch(t){}if(!e||!e.documentElement){e=R.createDocument(Pt,"template",null);try{e.documentElement.innerHTML=Rt?E:a}catch(t){}}var o=e.body||e.documentElement;return t&&i&&o.insertBefore(n.createTextNode(i),o.childNodes[0]||null),Pt===Ft?M.call(e,at?"html":"body")[0]:at?e.documentElement:o},Qt=function(t){var e=x?x(t):t.ownerDocument;return O.call(e||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},te=function(t){return t=sa(t,D," "),t=sa(t,L," "),sa(t,N," ")},ee=function(t){var e;t.normalize();for(var i=x?x(t):t.ownerDocument,r=O.call(i||t,t,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null),n=r.nextNode();n;)n.data=te(n.data),n=r.nextNode();var s=null===(e=t.querySelectorAll)||void 0===e?void 0:e.call(t,"template");s&&Xs(s,t=>{re(t.content)&&ee(t.content)})},ie=function(t){var e=w?w(t):null;return"string"==typeof e&&"form"===zt(e)&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||t.attributes!==b(t)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes||t.nodeType!==_(t)||t.childNodes!==g(t))},re=function(t){if(!_||"object"!=typeof t||null===t)return!1;try{return 11===_(t)}catch(t){return!1}},ne=function(t){if(!_||"object"!=typeof t||null===t)return!1;try{return"number"==typeof _(t)}catch(t){return!1}};function se(t,e,r){0!==t.length&&Xs(t,t=>{t.call(i,e,r,Ut)})}var ae=function(t,e,i,r){return 0===t.length?e:e===i||e===r?ba(e):e},oe=function(t,e){if(se(j.beforeSanitizeElements,t,null),t!==e&&null===m(t))return yt&&Yt(t),!0;if(ie(t))return Gt(t),!0;var r=zt(w?w(t):t.nodeName);if(W=ae(j.uponSanitizeElement,W,G,lt),se(j.uponSanitizeElement,t,{tagName:r,allowedTags:W}),t!==e&&null===m(t))return yt&&Yt(t),!0;if(function(t,e){return!!(st&&t.hasChildNodes()&&!ne(t.firstElementChild)&&fa(Ha,t.textContent)&&fa(Ha,t.innerHTML))||!(!st||t.namespaceURI!==Ft||"style"!==e||!ne(t.firstElementChild))||7===t.nodeType||!(!st||8!==t.nodeType||!fa(qa,t.data))}(t,r))return Gt(t),!0;if(Y[r]||!(Q.tagCheck instanceof Function&&Q.tagCheck(r))&&!W[r]){var n=function(t,e,i){if(!Y[e]&&he(e)){if(X.tagNameCheck instanceof RegExp&&fa(X.tagNameCheck,e))return!1;if(X.tagNameCheck instanceof Function&&X.tagNameCheck(e))return!1}if(mt&&!_t[e]){var r=m(t),n=g(t);if(n&&r)for(var s=n.length-1;s>=0;--s){var a=t===i?d(n[s],!0):n[s];r.insertBefore(a,p(t))}}return Gt(t),!0}(t,r,e);return!1===n&&se(j.afterSanitizeElements,t,null),n}if(1===(_?_(t):t.nodeType)&&!function(t){var e=m(t);e&&e.tagName||(e={namespaceURI:Pt,tagName:"template"});var i=ia(t.tagName),r=ia(e.tagName);return!!Ot[t.namespaceURI]&&(t.namespaceURI===At?function(t,e,i){return e.namespaceURI===Ft?"svg"===t:e.namespaceURI===Tt?"svg"===t&&("annotation-xml"===i||$t[i]):Boolean(Vt[t])}(i,e,r):t.namespaceURI===Tt?function(t,e,i){return e.namespaceURI===Ft?"math"===t:e.namespaceURI===At?"math"===t&&jt[i]:Boolean(Wt[t])}(i,e,r):t.namespaceURI===Ft?function(t,e,i){return!(e.namespaceURI===At&&!jt[i])&&!(e.namespaceURI===Tt&&!$t[i])&&!Wt[t]&&(Dt[t]||!Vt[t])}(i,e,r):!("application/xhtml+xml"!==Lt||!Ot[t.namespaceURI]))}(t))return Gt(t),!0;if(("noscript"===r||"noembed"===r||"noframes"===r)&&fa(Va,t.innerHTML))return Gt(t),!0;if(nt&&3===t.nodeType){var s=te(t.textContent);t.textContent!==s&&(Qs(i.removed,{element:t.cloneNode()}),t.textContent=s)}return se(j.afterSanitizeElements,t,null),!1},le=function(t,e,i){if(Z[e])return!1;if(st&&"patchsrc"===e)return!1;if(st&&"for"===e&&"label"!==t&&"output"!==t)return!1;if(ft&&("id"===e||"name"===e)&&(i in n||i in Bt))return!1;var r=K[e]||Q.attributeCheck instanceof Function&&Q.attributeCheck(e,t);if(et&&fa(z,e));else if(tt&&fa(U,e));else if(r){if(kt[e]);else if(fa(V,sa(i,H,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==aa(i,"data:")||!xt[t])if(it&&!fa(B,sa(i,H,"")));else if(i)return!1}else if(!(he(t)&&(X.tagNameCheck instanceof RegExp&&fa(X.tagNameCheck,t)||X.tagNameCheck instanceof Function&&X.tagNameCheck(t))&&(X.attributeNameCheck instanceof RegExp&&fa(X.attributeNameCheck,e)||X.attributeNameCheck instanceof Function&&X.attributeNameCheck(e,t))||"is"===e&&X.allowCustomizedBuiltInElements&&(X.tagNameCheck instanceof RegExp&&fa(X.tagNameCheck,i)||X.tagNameCheck instanceof Function&&X.tagNameCheck(i))))return!1;return!0},ue=ma({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),he=function(t){return!ue[ia(t)]&&fa(q,t)},ce=function(t,e,i,n){if(r&&"object"==typeof c&&"function"==typeof c.getAttributeType&&!i)switch(c.getAttributeType(t,e)){case"TrustedHTML":return P(n);case"TrustedScriptURL":return function(t){F(),A++;try{return r.createScriptURL(t)}finally{A--}}(n)}return n},ve=function(t,e,r,n){try{r?t.setAttributeNS(r,e,n):t.setAttribute(e,n),ie(t)?Gt(t):Zs(i.removed)}catch(i){Jt(e,t)}},de=function(t){se(j.beforeSanitizeAttributes,t,null);var e=t.attributes;if(e&&!ie(t)){for(var i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K=ae(j.uponSanitizeAttribute,K,J,ut),forceKeepAttr:void 0},r=e.length,n=zt(t.nodeName);r--;){var s=e[r],a=s.name,o=s.namespaceURI,l=s.value,u=zt(a),h=l,c="value"===a?h:oa(h);i.attrName=u,i.attrValue=c,i.keepAttr=!0,i.forceKeepAttr=void 0,se(j.uponSanitizeAttribute,t,i),c=i.attrValue,!pt||"id"!==u&&"name"!==u||0===aa(c,gt)||(Jt(a,t),c=gt+c),st&&fa(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,c)||"attributename"===u&&na(c,"href")?Jt(a,t):i.forceKeepAttr||(!i.keepAttr||!rt&&fa(Wa,c)?Jt(a,t):(nt&&(c=te(c)),le(n,u,c)?(c=ce(n,u,o,c))!==h&&ve(t,a,o,c):Jt(a,t)))}se(j.afterSanitizeAttributes,t,null)}},fe=function(t){var e=null,i=Qt(t);for(se(j.beforeSanitizeShadowDOM,t,null);e=i.nextNode();)if(se(j.uponSanitizeShadowNode,e,null),oe(e,t),de(e),re(e.content)&&fe(e.content),1===(_?_(e):e.nodeType)){var r=y(e);re(r)&&(pe(r),fe(r))}se(j.afterSanitizeShadowDOM,t,null)},pe=function(t){for(var e=[{node:t,shadow:null}];e.length>0;){var i=e.pop();if(i.shadow)fe(i.shadow);else{var r=i.node,n=1===(_?_(r):r.nodeType),s=g(r);if(s)for(var a=s.length-1;a>=0;--a)e.push({node:s[a],shadow:null});if(n){var o=w?w(r):null;if("string"==typeof o&&"template"===zt(o)){var l=r.content;re(l)&&e.push({node:l,shadow:null})}}if(n){var u=y(r);re(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]:{},n=null,a=null,o=null,l=null;if((Rt=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ne(t)&&"string"!=typeof(t=function(t){switch(typeof t){case"string":return t;case"number":return la(t);case"boolean":return ua(t);case"bigint":return ha?ha(t):"0";case"symbol":return ca?ca(t):"Symbol()";case"undefined":default:return da(t);case"function":case"object":if(null===t)return da(t);var e=t,i=_a(e,"toString");if("function"==typeof i){var r=i(e);return"string"==typeof r?r:da(r)}return da(t)}}(t)))throw pa("dirty is not a string, aborting");if(!i.isSupported)return t;ot?(W=lt,K=ut):qt(e),(j.uponSanitizeElement.length>0||j.uponSanitizeAttribute.length>0)&&(W=ba(W)),j.uponSanitizeAttribute.length>0&&(K=ba(K)),i.removed=[];var u=yt&&"string"!=typeof t&&ne(t);if(u){!function(t){if(st)for(var e=[t];e.length>0;){var i=e.pop(),r=_?_(i):i.nodeType;if(7===r||8===r&&fa(qa,i.data))try{f(i)}catch(t){}else{if(1===r){var n=i,s=zt(w?w(i):i.nodeName);try{n.hasAttribute&&n.hasAttribute("patchsrc")&&n.removeAttribute("patchsrc"),n.hasAttribute&&n.hasAttribute("for")&&"label"!==s&&"output"!==s&&n.removeAttribute("for")}catch(t){}}var a=g(i);if(a)for(var o=a.length-1;o>=0;--o)e.push(a[o])}}}(t);var h=w?w(t):t.nodeName;if("string"==typeof h){var c=zt(h);if(!W[c]||Y[c])throw Kt(t),pa("root node is forbidden and cannot be sanitized in-place")}if(ie(t))throw Kt(t),pa("root node is clobbered and cannot be sanitized in-place");try{pe(t)}catch(e){throw Kt(t),e}}else if(ne(t))1===(a=(n=Zt("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?n=a:n.appendChild(a),pe(a);else{if(!ct&&!nt&&!at&&-1===t.indexOf("<"))return r&&dt?P(t):t;if(!(n=Zt(t)))return ct?null:dt?E:""}n&&ht&&Gt(n.firstChild);var v=u?t:n;try{for(var d=Qt(v);o=d.nextNode();)oe(o,v),de(o),re(o.content)&&fe(o.content)}catch(e){throw u&&(Kt(t),Xs(i.removed,t=>{t.element&&Yt(t.element)})),e}if(u)return Xs(i.removed,t=>{t.element&&Yt(t.element)}),nt&&ee(t),t;if(ct){if(nt&&ee(n),vt)for(l=C.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(K.shadowroot||K.shadowrootmode)&&(l=I.call(s,l,!0)),l}var p=at?n.outerHTML:n.innerHTML;return at&&W["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&fa(Ua,n.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+p),nt&&(p=te(p)),r&&dt?P(p):p},i.setConfig=function(){qt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ot=!0,lt=W,ut=K},i.clearConfig=function(){Ut=null,ot=!1,lt=null,ut=null,r=k,E=""},i.isValidAttribute=function(t,e,i){return Ut||qt({}),le(zt(t),zt(e),i)},i.addHook=function(t,e){"function"==typeof e&&va(j,t)&&Qs(j[t],e)},i.removeHook=function(t,e){if(va(j,t)){if(void 0!==e){var i=Ys(j[t],e);return-1===i?void 0:ta(j[t],i,1)[0]}return Zs(j[t])}},i.removeHooks=function(t){va(j,t)&&(j[t]=[])},i.removeAllHooks=function(){j={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}(),Xa="Refusing to render web experiment since the viewer is a likely bot",Ya={ADD_ATTR:(t,e)=>"target"===t&&"a"===e||"form"===t&&/^(button|fieldset|input|output|select|textarea)$/.test(e),ADD_URI_SAFE_ATTR:["form"]},Za={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>Zn(e,t),not_regex:(t,e)=>!Zn(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},Qa=li("[Conversations]"),to="Conversations not available yet.";function eo(){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;z.length>e;e++){var i=z[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(Le,t)?Le[t]:t}(t);return e({},r?{"os.name":r}:{},i?{"os.version":i}:{})}(t,i)}function io(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({},eo(),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 ro=["debug","log","warn","error","info"],no="console",so="__posthogHandledLogsRequestError",ao=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[so]=!0,i},oo=t=>!!t&&"object"==typeof t&&!0===t[so],lo=class{get Pv(){var t=this;return e({},this.A,{error(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];i.some(oo)||t.A.error(...i)}})}constructor(t,e){var i;this.Ma=t,this.Ov=e,this.name="logs",this.Fv=!1,this.Dv=!1,this.Lv=!1,this.A=li("[logs]"),this.tc=[],this.Nv=[],this.Nd=0,this.jv=!1,this.Ti=!1,this.qv=[],this.Bv=[],this.zv=!1,this.Hv=!1,this.Uv=!1,this.Wv=()=>{var t,e;this.Ti||(this.Nd=0,null==(t=this.Vv)||t.onReconnect(),null==(e=this.Gv)||e.onReconnect())},this.Fv=!(null==(i=t.get())||!i.captureConsoleLogs)}get Qv(){return!0}Jv(){}Zv(){if(!this.Uv){try{this.Yd=typeof window>"u"?void 0:window}catch(t){this.Yd=void 0}this.Yd&&(di(this.Yd,"online",this.Wv),this.Uv=!0)}}Kv(t,e,i,r){this.Zv();var n=io(this.Ma.get(),i);return[new Ke(this.Yv(t,e),n,this.Pv,()=>this.Ov(),t=>t(),void 0,r),n]}Xv(){var t=this.Ma.get();if(!this.Vv||this.tf!==t){var e;null==(e=this.Vv)||e.reset(),this.tf=t;var i=this.Kv(()=>this.tc,t=>{this.tc=t});this.Vv=i[0],this.ef=i[1]}return this.Vv}if(){var t=this.Ma.get();if(!this.Gv||this.nf!==t){var e;null==(e=this.Gv)||e.reset(),this.nf=t;var i=this.Kv(()=>this.Nv,t=>{this.Nv=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},no);this.Gv=i[0],this.sf=i[1]}return this.Gv}setup(t){if(!this.Ti&&!this.jv)return this.jv=!0,this.Ta=t,this.A=t.logger.createLogger("[logs]"),us(t.kv.initialize(),()=>{this.Ti||this.Xd(t)})}Xd(t){var e;this.Zv(),null!=(e=this.Ma.get())&&e.captureConsoleLogs&&(this.Fv=!0),(this.Fv||this.Ma.remoteConfigWillArrive&&t.kv.get(this.Ma.captureHintKey))&&this.rf();var i=!1,r=t.onRemoteConfig(t=>{var e;i=t.ok&&!0===(null==(e=t.config.logs)?void 0:e.captureConsoleLogs),this.onRemoteConfig(t)});this.Ti?r.dispose():(this.za=r,i||this.loadIfEnabled())}dispose(){var t,e,i,r,n,s,a;this.Ti||(this.Ti=!0,this.af(),null==(t=this.za)||t.dispose(),this.za=void 0,this.Ta=void 0,this.Lv=!1,null==(e=this.Yd)||e.removeEventListener("online",this.Wv),null==(i=this.lf)||i.call(this),this.lf=void 0,null==(r=this.Vv)||r.clearQueue(),null==(n=this.Gv)||n.clearQueue(),null==(s=this.Vv)||s.reset(),null==(a=this.Gv)||a.reset())}onRemoteConfig(t){var e,i;if(!this.Ti){var r=t.ok?null==(e=t.config.logs)?void 0:e.captureConsoleLogs:void 0;y(r)?this.uf():(null==(i=this.Ta)||i.kv.set(this.Ma.captureHintKey,!!r),r?(this.Fv=!0,this.Dv||this.rf(),this.loadIfEnabled()):this.uf())}}reset(){var t,e,i,r;this.af(),null==(t=this.Vv)||t.clearQueue(),this.tc=[],null==(e=this.Vv)||e.reset(),null==(i=this.Gv)||i.clearQueue(),this.Nv=[],null==(r=this.Gv)||r.reset(),this.Nd=0}captureLog(t){!this.Ti&&this.Ta&&this.Xv().captureLog(t)}captureConsoleLog(t){!this.Ti&&this.Ta&&this.if().captureLog(t)}captureBufferedConsoleLog(t,e,i){!this.Ti&&this.Ta&&this.if().captureLog(t,{context:e,occurredAtMs:i})}_onOptOut(){var t;this.af(),null==(t=this.Gv)||t.clearQueue(),this.Nv=[]}uf(){this.Fv||this.af()}rf(){var t,e=this;if(!this.zv&&null!=(t=this.Yd)&&t.console){var i=io(this.Ma.get()).maxBufferSize,r=!0;this.Bv.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.Yd.console[t])}catch(t){return 1}n&&e.Bv.push(xn(e.Yd.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.cf(t,a,i)}catch(t){}return s.apply(e.Yd.console,a)};return a.__rrweb_original__=n,a}))};for(var s of ro)if(n(s))continue;this.zv=!0,this.hf=setTimeout(()=>{this.af()},3e4)}}cf(t,e,i){var r;if(this.zv&&!this.Hv&&0!==e.length)if(null!=(r=this.Ta)&&r.canCapture){if(i>this.qv.length){this.Hv=!0;try{this.qv.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Ov()})}finally{this.Hv=!1}}}else this.af()}af(){if(this.qv=[],this.zv){for(var t of(this.zv=!1,this.hf&&(clearTimeout(this.hf),this.hf=void 0),this.Bv))t();this.Bv=[]}}df(){var t=this.qv;return this.af(),t}get logger(){return this.vf||(this.vf={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.vf}flushLogs(t){this.Ta&&(t?this.ff(t):(this.Vv&&this.Vv.flush().catch(t=>this.pf(t)),this.Gv&&this.Gv.flush().catch(t=>this.pf(t))))}flush(){var t=this;return r(function*(){var e,i,r=null==(e=t.Vv)?void 0:e.flush().catch(e=>t.pf(e)),n=null==(i=t.Gv)?void 0:i.flush().catch(e=>t.pf(e));yield r,yield n})()}pf(t){oo(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.Ti&&this.Fv&&!this.Dv&&!this.Lv){var t=this.Jv();if(t){this.Lv=!0;try{t((t,e)=>{if(this.Lv=!1,!this.Ti&&this.Fv)if(t||!e)this.A.error("Could not load logs script",t),this.af();else{var i=this.df();this.lf=e.initialize(this.Ta),this.Dv=!0,i.length>0&&e.replay(this.Ta,i)}})}catch(t){throw this.Lv=!1,t}}else this.af()}}Yv(t,e){var i=this.Ta;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:e=>e===n.LogsQueue?t():void 0,setPersistedProperty(t,i){t===n.LogsQueue&&e(null!=i?i:[])},qs:t=>this.qs(t),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}qs(t){return new Promise(e=>{if(pn(this.Nd,3))e({kind:"fatal",error:ao(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(n),e(t))},n=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:ao(void 0,"logs request timed out")})},9e4),s=this.Qv;this.Ta.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Ta.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(t=>{var e,i=t.statusCode;this.gf(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:new Error("logs request failed with status "+i)}):0===i?(t.error||this.A.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:ao(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})},t=>{r({kind:"retry-later",error:t})})}})}gf(t,e){(0!==t||e)&&(this.Nd=gn(t,this.Nd,3,()=>this.A.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.")))}ff(t){this.tc.length>0&&this.mf(t,this.tc,this.ef,this.Ta.library.name,t=>{this.tc=t}),this.Nv.length>0&&this.mf(t,this.Nv,this.sf,no,t=>{this.Nv=t})}mf(t,e,i,r,n){if(0!==e.length){var s=e.map(t=>t.record);n([]);var a=qe(s,He(i,this.Ta.library.name,this.Ta.library.version),r,this.Ta.library.version);this.Ta.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.Ta.projectToken},body:a,compression:"best-available",transport:t,timeoutMs:6e4}).catch(t=>this.pf(t))}}},uo=li("[NetworkMetrics]"),ho=()=>{var t;return null!=rn&&null!=(t=rn.performance)&&t.now?rn.performance.now():Date.now()},co={"http:":80,"https:":443},vo=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),fo=(t,e)=>{var i,r=String(e);return{method:String(t).toUpperCase(),url:(null==(i=Sr(r))?void 0:i.href)||r}},po=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=ho()-n,d=Sr(i.url);if(d&&"http:"!==d.protocol&&"https:"!==d.protocol)return;var f={url:(null==d?void 0:d.href)||i.url,method:i.method},g=c(u.name)?u.name(f):p(u.name)?u.name:"http.client.request.duration";if(!g)return;var m=o&&!h?void 0:((t,e)=>t?400>t?void 0:String(t):(null==e?void 0:e.name)||"_OTHER")(h,a),y=e({},e({"http.request.method":_=vo.has(b=f.method)?b:"_OTHER"},"_OTHER"===_&&b!==_?{"http.request.method_original":b}:{}),d?(t=>{return{"server.address":t.hostname.startsWith("[")&&t.hostname.endsWith("]")?t.hostname.slice(1,-1):t.hostname,"server.port":Number(t.port)||co[t.protocol],"url.scheme":t.protocol.slice(0,-1),"url.template":(e=t.pathname,e.split("/").map(t=>(t=>/^\d+$/.test(t)||t.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(t))(t)?":id":t).join("/"))};var e})(d):{},h?{"http.response.status_code":h}:{},m?{"error.type":m}:{},null==u.attributes?void 0:u.attributes(f,{status:h,durationMs:v}));null==(l=t.metrics)||l.histogram(g,v,{unit:"ms",attributes:y})}catch(t){uo.error("Failed to record network metric",t)}var b,_},go=()=>{},mo=(t,e)=>c(null==rn?void 0:rn.fetch)?xn(rn,"fetch",i=>function(){for(var r=ho(),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=fo(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=>(po(t,d,null==i?void 0:i.status,r,e,void 0,!0),i),i=>{throw po(t,d,void 0,r,e,i),i})}catch(t){return uo.error("Failed to observe fetch",t),o}}):go,yo=(t,e)=>{var i,r=null==rn||null==(i=rn.XMLHttpRequest)?void 0:i.prototype;if(!r)return go;var n=new WeakMap,s=xn(r,"open",t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];try{fs.has(this)||n.set(this,fo(i[0],i[1]))}catch(t){uo.error("Failed to observe XHR open",t)}return t.apply(this,i)}),a=xn(r,"send",i=>function(){var r;try{var s=n.get(this);if(s&&e()){var a=ho();di(this,"loadend",r=()=>{this.removeEventListener("loadend",r),po(t,s,this.status,a,e)})}}catch(t){uo.error("Failed to observe XHR send",t)}try{for(var o=arguments.length,l=new Array(o),u=0;o>u;u++)l[u]=arguments[u];return i.apply(this,l)}catch(t){throw r&&this.removeEventListener("loadend",r),t}});return()=>{s(),a()}},bo=new WeakMap,_o=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),wo={maxStringLength:2048,truncationSuffix:"..."},xo={maxStringLength:2048,truncationSuffix:"..."};function So(t){if(t)return!0===t?{intent:!0,model:!0}:{intent:!1!==t.intent,model:!1!==t.model}}function ko(t,e){return{}.hasOwnProperty.call(t,e)}function Eo(t,e){var i=Object.create(t);return e&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),i}function To(t,e,i){if(void 0===i&&(i=!1),p(t)){var r=t.trim();if(r)return(i?Ae(r,wo):r).slice(0,e)}}function Ao(t){try{return v(t)&&!0===t.isError}catch(t){return!1}}function Fo(t){return Ae(t||"Unknown error",xo).slice(0,2048)}function Po(t,e){try{return Fo(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 Ro(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:Fo(t.value)}))}function Oo(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:Po(t,e),type:Oo(t,e)}}var Mo={featureFlags:class extends As{constructor(t){var e=new Ps(t.config,t._shouldDisableFlags());super(e),this.name="featureFlags",this._instance=t,this.yf=e}get Jd(){return this._instance.persistence}updateConfig(t,e){this.yf.update(t,e),this.Zd()}}},$o={sessionRecording:class{get Dr(){return this._instance.config}get xc(){return this._instance.persistence}get started(){var t;return!(null==(t=this.bf)||!t.isStarted)}get status(){var t,e;return"awaiting_config"===this._f||"missing_config"===this._f?this._f:null!==(t=null==(e=this.bf)?void 0:e.status)&&void 0!==t?t:this._f}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this._f=jn,this.wf=void 0,this.kf=!1,this.Ye=(()=>{var t;if(null==an||!an.visibilityState||"visible"===an.visibilityState)return!0;var e=null==rn||null==(t=rn.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=e&&e.length)||e.some(t=>"visible"===t.name)})(),this.an=()=>{var t;"visible"===(null==an?void 0:an.visibilityState)&&(this.Ye=!0,null==(t=this.bf)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw Ln.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Dr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=an&&an.addEventListener&&di(an,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(void 0===t?{}:t).discardBufferedEvents,i=void 0!==e&&e;this.kf=!0,null==an||null==an.removeEventListener||an.removeEventListener("visibilitychange",this.an),i?this.Sf(!0):this.stopRecording()}get xf(){var t,e=!(null==(t=this._instance.get_property(Jr))||!t.enabled),i=!this.Dr.disable_session_recording,r=this.Dr.disable_session_recording||this._instance.consent.isOptedOut();return rn&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!(this.kf||this.xf&&null!=(e=this.bf)&&e.isStarted)){var i=!f(Object.assign)&&!f(Array.from);this.xf&&i?(this.$f(t),Ln.info("starting")):(this._f=jn,this.stopRecording())}}$f(t){var e,i;if(this.xf)if("awaiting_config"!==this._f&&"missing_config"!==this._f&&(this._f=Dn),null!=un&&null!=(e=un.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=un.__PosthogExtensions__)&&i.initSessionRecording)this.Cf(t);else{var r,n=this._instance.sessionManager;null==(r=un.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Tf,e=>{if(!this.kf&&this.xf&&this._instance.sessionManager===n)return e?(this._instance.register_for_session({[Qr]:!0}),Ln.error("could not load recorder",e)):void this.Cf(t);this._f=jn})}}stopRecording(){var t,e;null==(t=this.wf)||t.call(this),this.wf=void 0,null==(e=this.bf)||e.stop()}Sf(t){var e,i;void 0===t&&(t=!1),null==(e=this.wf)||e.call(this),this.wf=void 0,null==(i=this.bf)||i.discard({discardProducerEvents:t})}If(){var t,e;null==(t=this.xc)||t.unregister("$session_is_sampled"),null==(e=this.xc)||e.unregister("$replay_sample_rate")}Ef(t,e){if(y(t))return null;var i,r=b(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ln.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Mf(t){if(this.xc){var i,r,n=this.xc,s=()=>{var i,r=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Ef(null==(i=this.Dr.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),a=this.Ef(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=s?s:a;y(o)&&this.If();var l=null==r?void 0:r.minimumDurationMilliseconds;n.register({[Jr]:e({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:e({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:f(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};s(),null==(i=this.wf)||i.call(this),this.wf=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.Mf(e),void this.Sf()):(this.Mf(e),void this.startIfEnabledOrStop()):("awaiting_config"===this._f&&(this._f="missing_config",this._instance.register_for_session({[tn]:!0}),Ln.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.bf)&&i.log?this.bf.log(t,e):Ln.warn("log called before recorder was ready")}get Tf(){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"}Af(){var t,e=this._instance.get_property(Jr);if(!e)return!1;try{t="object"==typeof e?e:JSON.parse(e)}catch(t){return Ln.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!y(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Cf(t){var e,i,r;if(!this.kf&&this.xf&&this._instance.sessionManager){if(null==(e=un.__PosthogExtensions__)||!e.initSessionRecording)return Ln.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Qr]:!0});var n;if(this.bf||(this.bf=null==(n=un.__PosthogExtensions__)?void 0:n.initSessionRecording(this._instance,this.Ye),this.bf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Af()){if("missing_config"===this._f||"awaiting_config"===this._f)return;return this._f="awaiting_config",Ln.info("persisted remote config is stale, requesting fresh config before starting"),void new In(this._instance).load()}this._f=Dn,null==(i=(r=this.bf).setDocumentWasEverVisible)||i.call(r,this.Ye),this.bf.start(t)}else this._f=jn}onRRwebEmit(t){var e;null==(e=this.bf)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.bf||null==(t=this.xc)||t.register({[Yr]:!0}),null==(e=this.bf)||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.bf||null==(t=this.xc)||t.register({[Xr]:!0}),null==(e=this.bf)||e.overrideSampling()}overrideTrigger(t){var e,i;this.bf||null==(e=this.xc)||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(i=this.bf)||i.overrideTrigger(t)}get sdkDebugProperties(){var t,i={};for(var r of Nn){var n,s=null==(n=this._instance.sessionPersistence)?void 0:n.get_property(r);f(s)||(i[r]=s)}return e({},i,(null==(t=this.bf)?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var i;return!(null==(i=this.bf)||!i.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;null==(t=this.bf)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},Io={autocapture:class extends Cr{constructor(t){super(new $r(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.Rf=!1,this._instance=t,this.Pf=this.Of()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Ff();return!!(t.path||t.search||this.Df(t))}startIfEnabled(){this.isEnabled&&(oi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Pf=this.Of(),this.startIfEnabled()}stop(){this.Lf&&this.Lf(),this.Lf=void 0,this.Nf&&this.Nf(),this.Nf=void 0,oi.info("History API monitoring stopped")}monitorHistoryChanges(){rn&&rn.history&&(this.jf("pushState"),this.jf("replaceState"),this.qf(),this.Df()&&this.Bf())}jf(t){var e;if(rn&&(null==(e=rn.history[t])||!e.__posthog_wrapped__)){var i=this;xn(rn.history,t,e=>function(r,n,s){var a;i.zf(s)&&i.Hf(),e.call(this,r,n,s),i.Uf(t,!i.Rf&&"popstate"!==(null==rn||null==(a=rn.event)?void 0:a.type))})}}Of(){var t=null==rn?void 0:rn.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Ff(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:v(t)?t:{}}Df(t){return void 0===t&&(t=this.Ff()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Wf(t){var e=this.Ff(),i=this.Pf;return!(!i||!(e.path&&t.pathname!==i.pathname||e.search&&t.search!==i.search||this.Df(e)&&t.hash!==i.hash))}Uf(t,e){void 0===e&&(e=!1);try{e||this.Hf();var i=this.Of();if(!i)return;if(this.Wf(i)){var r=()=>this._instance.capture("$pageview",{navigation_type:t});e?(this.Vf=r,Promise.resolve().then(()=>this.Hf())):r()}this.Pf=i}catch(e){oi.error("Error capturing "+t+" pageview",e)}}zf(t){var e,i;return!(y(t)||!rn)&&(null==(e=Sr(String(t)))?void 0:e.href)!==(null==(i=rn.location)?void 0:i.href)}Hf(){var t=this.Vf;if(t){this.Vf=void 0,this.Rf=!0;try{t()}catch(t){oi.error("Error capturing deferred pageview",t)}finally{this.Rf=!1}this.Pf=this.Of()}}qf(){if(!this.Lf){var t=()=>{this.Uf("popstate")};di(rn,"popstate",t),this.Lf=()=>{rn&&rn.removeEventListener("popstate",t)}}}Bf(){if(!this.Nf){var t=()=>{this.Uf("hashchange")};di(rn,"hashchange",t),this.Nf=()=>{rn&&rn.removeEventListener("hashchange",t)}}}},heatmaps:class{get Dr(){return this.instance.config}constructor(t){var e;this.Gf=!1,this.dl=!1,this.Qf=null,this.instance=t,this.Gf=!(null==(e=this.instance.persistence)||!e.props[Ur]),this.rageclicks=new xr(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return v(this.Dr.capture_heatmaps)&&this.Dr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Dr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return y(this.Dr.capture_heatmaps)?y(this.Dr.enable_heatmaps)?this.Gf:this.Dr.enable_heatmaps:!1!==this.Dr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.dl)return;zn.info("starting..."),this.Jf(),this.an()}else{var t;clearInterval(null!==(t=this.Qf)&&void 0!==t?t:void 0),this.Zf(),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({[Ur]:i}),this.Gf=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.At;return this.At=void 0,t}Kf(t){Un(t.originalEvent)&&this.Lr(t.originalEvent,"deadclick")}an(){this.Qf&&clearInterval(this.Qf),this.Qf="visible"===(null==an?void 0:an.visibilityState)?setInterval(this.uc.bind(this),this.flushIntervalMilliseconds):null}Jf(){rn&&an&&(this.Yf=this.uc.bind(this),di(rn,en,this.Yf),this.Xf=t=>this.Lr(t||(null==rn?void 0:rn.event)),di(an,"click",this.Xf,{capture:!0}),this.tp=t=>this.ep(t||(null==rn?void 0:rn.event)),di(an,"mousemove",this.tp,{capture:!0}),this.np=new vn(this.instance,cn,this.Kf.bind(this)),this.np.startIfEnabledOrStop(),this.sp=this.an.bind(this),di(an,Oi,this.sp),this.dl=!0)}Zf(){var t;rn&&an&&(this.Yf&&rn.removeEventListener(en,this.Yf),this.Xf&&an.removeEventListener("click",this.Xf,{capture:!0}),this.tp&&an.removeEventListener("mousemove",this.tp,{capture:!0}),this.sp&&an.removeEventListener(Oi,this.sp),clearTimeout(this.rp),null==(t=this.np)||t.stop(),this.dl=!1)}op(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=function(t,e,i){for(var r=t;r&&$i(r)&&!Ii(r,"body");){if(r===i)return!1;var n=void 0;try{var a,o,l;n=null==(a=null!==(o=null==(l=r.ownerDocument)?void 0:l.defaultView)&&void 0!==o?o:rn)?void 0:a.getComputedStyle(r).position}catch(t){return!1}if(s(e,n))return!0;r=Gi(r)}return!1}(Hi(t),["fixed","sticky"],n);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:i),target_fixed:a,type:e}}Lr(t,i){var r;if(void 0===i&&(i="click"),!Mi(t.target)&&Un(t)){var n=this.op(t,i);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&sr(Hi(t),this.instance.config.rageclick)&&this.Qs(e({},n,{type:"rageclick"})),this.Qs(n)}}ep(t){!Mi(t.target)&&Un(t)&&(clearTimeout(this.rp),this.rp=setTimeout(()=>{this.Qs(this.op(t,"mousemove"))},500))}Qs(t){if(rn){var e=this.Dr.disable_capture_url_hashes?Y(rn.location.href):rn.location.href,i=this.Dr.custom_personal_data_properties,r=yn(e,this.Dr.mask_personal_data_properties?[...En,...i||[]]:[],An);this.At=this.At||{},this.At[r]||(this.At[r]=[]),this.At[r].push(t)}}uc(){this.At&&!d(this.At)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:vn,webVitalsAutocapture:class{constructor(t){var i,r=this;this._instance=t,this.Gf=!1,this.dl=!1,this.At={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.ap=function(t){void 0===t&&(t=!1),clearTimeout(r.lp),r.lp=void 0,0!==r.At.metrics.length&&(r._instance.capture("$web_vitals",e({$current_url:r.At.url},r.At.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.At={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.up=t=>{var i;if(this.At=this.At||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},y(null==t?void 0:t.name)||y(null==t?void 0:t.value))Pn.error("Invalid metric received",t);else{var r="string"==typeof t.navigationURL?t.navigationURL:void 0,n=this.cp(r);if(!f(n)){var s=b(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+n;if(!this.hp||this.hp>t.value){this.At.navigationKey!==s&&(this.ap(),this.lp=setTimeout(this.ap,this.flushToCaptureTimeoutMs)),f(this.At.navigationKey)&&(this.At.navigationKey=s,this.At.url=n),this.At.firstMetricTimestamp=f(this.At.firstMetricTimestamp)?Date.now():this.At.firstMetricTimestamp;var a=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),o=e({},t,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});if(delete o.entries,v(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var u of Mn){var h="url"===u&&"string"==typeof t.attribution[u]?this.cp(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.At.metrics.push(o),this.At.metrics.length===this.allowedMetrics.length&&this.ap()}else Pn.error("Ignoring metric with value >= "+this.hp,t)}}},this.dp=()=>{if(!this.dl){var t,i,r,n,s=!1,a=un.__PosthogExtensions__,o=null==a?void 0:a.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.vp])||("web-vitals"===this.vp&&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.up.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.up.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.up.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.up.bind(this),v);var d=null==rn?void 0:rn.document;di(d,Oi,()=>{"hidden"===(null==d?void 0:d.visibilityState)&&this.ap(!0)}),di(rn,"pagehide",()=>this.ap(!0)),this.dl=!0}else Pn.error("web vitals callbacks not loaded - not starting")}},this.Gf=!(null==(i=this._instance.persistence)||!i.props[Vr]),this.startIfEnabled()}get fp(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=v(this.fp)?null==(t=this.fp)?void 0:t.web_vitals_allowed_metrics:void 0;return y(i)?(null==(e=this._instance.persistence)?void 0:e.props.$web_vitals_allowed_metrics)||On:i}get flushToCaptureTimeoutMs(){return(v(this.fp)?this.fp.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=v(this.fp)?this.fp.web_vitals_attribution:void 0;return _(t)?t?On:[]:h(t)?t:Cn}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=v(this.fp)?this.fp.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get hp(){var t=v(this.fp)&&b(this.fp.__web_vitals_max_value)?this.fp.__web_vitals_max_value:Rn;return t>0&&6e4>=t?Rn:t}get isEnabled(){var t=null==on?void 0:on.protocol;if("http:"!==t&&"https:"!==t)return Pn.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=v(this.fp)?this.fp.web_vitals:_(this.fp)?this.fp:void 0;return _(e)?e:this.Gf}startIfEnabled(){this.isEnabled&&!this.dl&&(Pn.info("enabled, starting..."),this.Pl(this.dp))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=v(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=v(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Vr]:i}),this._instance.persistence.register({[Kr]:r})),this.Gf=i,this.startIfEnabled()}}}get vp(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Pl(t){var e=un.__PosthogExtensions__,i=this.vp,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&f(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,e=>{e?Pn.error("failed to load script",e):t()})}cp(t){var e=t||(null==rn?void 0:rn.location.href);if(e){var i=this._instance.config.disable_capture_url_hashes?Y(e):e,r=this._instance.config.custom_personal_data_properties;return yn(i,this._instance.config.mask_personal_data_properties?[...En,...r||[]]:[],An)}Pn.error("Could not determine current URL")}}},jo={exceptionObserver:class{constructor(t){var i;this.dp=()=>{var t;if(rn&&this.isEnabled&&null!=(t=un.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=un.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=un.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=un.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.pp&&this.Dr.capture_unhandled_errors&&(this.pp=e(this.captureException.bind(this))),!this.gp&&this.Dr.capture_unhandled_rejections&&(this.gp=i(this.captureException.bind(this))),!this.mp&&this.Dr.capture_console_errors&&(this.mp=r(this.captureException.bind(this)))}catch(t){dn.error("failed to start",t),this.yp()}}},this._instance=t,this.bp=!(null==(i=this._instance.persistence)||!i.props[Br]),this.kt=new R(e({},function(t){var e,i,r,n;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,A:dn})),this.Dr=this._p(),this.startIfEnabledOrStop()}_p(){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.bp:t)&&(i=e({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Dr.capture_console_errors||this.Dr.capture_unhandled_errors||this.Dr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(dn.info("enabled"),this.yp(),this.Pl(this.dp)):this.yp()}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",e=>{if(e)return dn.error("failed to load script",e);t()})}yp(){var t,e,i;null==(t=this.pp)||t.call(this),this.pp=void 0,null==(e=this.gp)||e.call(this),this.gp=void 0,null==(i=this.mp)||i.call(this),this.mp=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.bp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Br]:this.bp}),this.Dr=this._p(),this.startIfEnabledOrStop())}}onConfigChange(){this.Dr=this._p()}captureException(t){try{var e,i,r,n=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";if(this.kt.consumeRateLimit(n))return void dn.info("Skipping exception capture because of client rate limiting.",{exception:n});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,r;this.wp=[],this.kp=new nt([new Et,new It,new At,new Tt,new Mt,new Ct,new Pt,new $t],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=mt.test(h)?h.replace(mt,"$1"):h;if(!c.match(/\S*Error: /)){for(var v of r){var d=v(c,t);if(d){s.push(d);var f=bt(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(St(s,l)>=50)break}}}var m=[...l].sort((t,e)=>e.start-t.start),y=m[m.length-1];if(y){var b=wt(s,y);for(var _ of(s.splice(y.start-b,b),m))_.start-=b}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++)kt(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",dt,gt)),this._instance=t,this.wp=null!==(i=null==(r=this._instance.persistence)?void 0:r.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Sp=zt(this.xp()),this.$p=new Ut(this.Sp)}onConfigChange(){this.Sp=zt(this.xp()),this.$p.setConfig(this.Sp)}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.wp=s,this._instance.persistence&&this._instance.persistence.register({[Hr]:this.wp,[qr]:a})}}}get Cp(){var t,e,i=!!this._instance.get_property(qr);return null!==(t=null!==(e=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==e?e:i)&&void 0!==t&&t}buildProperties(t,e){return this.kp.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,i){if(this.Sp.enabled)try{if(!p(t)||0===t.trim().length)return void Os.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)=>Lt.has(r)?(e.push(r),i):(i[r]=t[r],i),{}),droppedKeys:e}}(this.Tp(i)),n=r.sanitizedProperties,s=r.droppedKeys;s.length>0&&Os.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.$p.add(e({[jt]:t,[Dt]:(new Date).toISOString()},n))}catch(t){Os.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Ip(e)){if(this.Ep(e))return this.Mp("Exception dropped: matched a suppression rule"),void Os.info("Skipping exception capture because a suppression rule matched");if(!this.Cp&&this.Ap(e))return this.Mp("Exception dropped: thrown by a browser extension"),void Os.info("Skipping exception capture because it was thrown by an extension");if(!this.Cp&&this.Rp(e))return this.Mp("Exception dropped: thrown by an injected browser script"),void Os.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Pp(e))return this.Mp("Exception dropped: thrown by the PostHog SDK"),void Os.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Sp.enabled&&y(t.$exception_steps)?this.Op(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.$p.clear(),n}catch(t){return Rs(t)||Os.error("Failed to capture exception event. Dropping this exception.",t),void this.$p.clear()}}catch(t){return void(Rs(t)||Os.error("Failed to process exception event. Ignoring this exception.",t))}}Op(t){try{var i=this.$p.getAttachable();return 0===i.length?t:e({},t,{$exception_steps:i})}catch(e){return Os.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Mp(t){this.Sp.enabled&&this.$p.add({[jt]:t,[Dt]:(new Date).toISOString()})}Tp(t){return v(t)?e({},t):{}}xp(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Ep(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.wp.some(t=>{var i=t.values.map(t=>{var i=ts[t.operator],r=e[t.key];if(!i||!r)return!1;var n=h(t.value)?t.value:[t.value];return n.length>0&&i(n,r)});return"OR"===t.type?i.some(Boolean):i.every(Boolean)})}catch(t){return Os.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Ap(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&&$s.some(t=>e.startsWith(t))});return 0!==i.length&&(!i.every(t=>{var e=t.filename;return!!e&&e.startsWith(Cs)})||t.some(t=>{var e=t.value;return"NoResponse"===t.type||p(e)&&Ms.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(Cs))}))}Rp(t){return t.some(t=>{var e=t.value;return p(e)&&Is.some(t=>e.includes(t))})}Pp(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}Ip(t){return!y(t)&&h(t)}}},Do=e({productTours:class{get xc(){return this._instance.persistence}constructor(t){this.Fp=null,this.Dp=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.xc&&this.xc.register({[Gr]:!!e.productTours}),!Hn(this._instance))return!this.Fp&&y(null==(i=this.xc)?void 0:i.props.ph_product_tours)||Bn.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Fp)||r.stop(),this.Fp=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Fp&&Hn(this._instance)&&this.Pl(()=>this.Lp())}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",e=>{e?Bn.error("Could not load product tours script",e):t()})}Lp(){var t;!this.Fp&&null!=(t=un.__PosthogExtensions__)&&t.generateProductTours&&(this.Fp=un.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!h(this.Dp)||e){var i=this.xc;if(i){var r=i.props[Zr];if(h(r)&&!e)return this.Dp=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:e=>{if(Hn(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var n="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||Bn.warn(n):Bn.error(n),void t([],{isLoaded:!1,error:n})}var s=h(e.json.product_tours)?e.json.product_tours:[];this.Dp=s,i&&i.register({[Zr]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Dp,{isLoaded:!0})}getActiveProductTours(t){y(this.Fp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fp.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Fp)||e.showTourById(t)}previewTour(t){this.Fp?this.Fp.previewTour(t):this.Pl(()=>{var e;this.Lp(),null==(e=this.Fp)||e.previewTour(t)})}dismissProductTour(){var t;null==(t=this.Fp)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Fp)||t.nextStep()}previousStep(){var t;null==(t=this.Fp)||t.previousStep()}clearCache(){var t;this.Dp=null,null==(t=this.xc)||t.unregister(Zr)}resetTour(t){var e;null==(e=this.Fp)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Fp)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Fp)||e.cancelPendingTour(t)}}},Mo),Lo={siteApps:class{constructor(t){this._instance=t,this.Np=0,this.jp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}qp(t,e){if(e){var i=this.globalsForEvent(e);this.jp.push(i),this.jp.length>1e3&&(this.jp=this.jp.slice(10))}}get siteAppLoaders(){var t;return null==(t=un._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.qp.bind(this));this.Bp=()=>{t(),this.jp=[],this.Bp=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}}zp(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(qn.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(qn.error("prepare_external_dependency_script returned null"),null):t}Hp(){var t,e,i,r,n,s,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==an?void 0:an.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Np++,this.Up)return this.Wp();var h=[],c=this,v=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.zp(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.Up=()=>{h.forEach(t=>t()),this.Up=void 0},this.Wp()}Wp(){var t=!1;return()=>{var e;t||(t=!0,this.Np--,0===this.Np&&(null==(e=this.Up)||e.call(this)))}}Vp(t,e){void 0===e&&(e=!0);var i=this.Hp();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.jp.length&&(qn.info("Processing "+this.jp.length+" events for site app with id "+t.id),this.jp.forEach(t=>this.Vp(()=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(i=this.Bp)||i.call(this))},r=!1,n=n=>{e.errored=!n,e.loaded=!0,qn.info("Site app with id "+t.id+" "+(n?"loaded":"errored")),r&&i()};try{var s=this.Vp(e=>t.init({posthog:this._instance,callback(t){e(),n(t)}}),!1).processEvent;s&&(e.processEvent=s),r=!0}catch(e){qn.error(Vn+t.id,e),n(!1)}if(r&&e.loaded)try{i()}catch(i){qn.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Gp(){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)}Qp(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Vp(()=>null==r.processEvent?void 0:r.processEvent(i))}catch(e){qn.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var n of Object.values(this.apps))r(n)}}onRemoteConfig(t){var e,i,r,n=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Gp(),void this._instance.on("eventCaptured",t=>this.Qp(t))):void qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Bp)||i.call(this),t.ok){var s=t.config;if(null!=(r=s.siteApps)&&r.length)if(this.isEnabled){var a=function(){var t,e=o.id,i=o.url;un["__$$ph_site_app_"+e]=n._instance,null==(t=un.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(n._instance,i,t=>{if(t)return qn.error(Vn+e,t)})};for(var o of s.siteApps)a()}else qn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},No={tracingHeaders:class{constructor(t){this._instance=t,this.Jp=void 0,this.Zp=void 0,this.Kp=void 0,this.dp=()=>{var t,e,i=this.Yp();i?(f(this.Jp)&&(this.Jp=null==(t=un.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),f(this.Zp)&&(this.Zp=null==(e=un.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.yp()}}initialize(){this.startIfEnabledOrStop()}Pl(t){var e,i;null!=(e=un.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=un.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",e=>{if(e)return Sn.error("failed to load script",e);t()})}Xp(){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}Yp(){var t=this.Xp();return h(t)?(h(this.Kp)?this.Kp.splice(0,this.Kp.length,...t):this.Kp=[...t],t.length>0?this.Kp:void 0):(h(this.Kp)&&this.Kp.splice(0),this.Kp=t||void 0,this.Kp)}yp(){var t,e;null==(t=this.Jp)||t.call(this),null==(e=this.Zp)||e.call(this),this.Jp=void 0,this.Zp=void 0}startIfEnabledOrStop(){this.Yp()?this.Pl(this.dp):this.yp()}}},zo=e({surveys:class extends vs{constructor(t){super(new ps(t))}}},Mo),Uo={toolbar:class{constructor(t){this.instance=t}tg(t){un.ph_toolbar_state=t}eg(){var t;return null!==(t=un.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),fi(this.instance.config))return!1;if(!rn||!an)return!1;t=null!=t?t:rn.location,i=null!=i?i:rn.history;try{if(!e){try{rn.localStorage.setItem("test","test"),rn.localStorage.removeItem("test")}catch(t){return!1}e=null==rn?void 0:rn.localStorage}var r,n=gs||bn(t.hash,"__posthog")||bn(t.hash,"state"),s=n?Z(()=>JSON.parse(atob(decodeURIComponent(n))))||Z(()=>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(ms)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}ig(t){var e=un.ph_load_toolbar||un.ph_load_editor;!y(e)&&c(e)?e(t,this.instance):ys.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==an||!an.getElementById("__POSTHOG_TOOLBAR__"));if(!rn||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=e({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(rn.localStorage.setItem(ms,JSON.stringify(e({},n,{source:void 0}))),2===this.eg())this.ig(n);else if(0===this.eg()){var s;this.tg(1),null==(s=un.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return ys.error("[Toolbar] Failed to load",t),void this.tg(0);this.tg(2),this.ig(n)}),di(rn,"turbolinks:load",()=>{this.tg(0),this.loadToolbar(n)})}return!0}ng(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)}}},Bo=e({experiments:class t{get Dr(){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.sg("retrieved web experiments from the server"),i.rg=new Map,e.forEach(e=>{if(e.feature_flag_key){var r;i.rg&&(t.sg("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(r=i.rg)||r.set(e.feature_flag_key,e));var n=i._instance.getFeatureFlag(e.feature_flag_key);p(n)&&e.variants[n]&&i.og(e.name,n,e.variants[n].transforms)}else if(e.variants)for(var s in e.variants){var a=e.variants[s];t.ag(a,i._instance)&&i.og(e.name,s,a.transforms)}})},e)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.sg(Xa);else if(!this.Dr.disable_web_experiments){if(y(this.rg))return this.rg=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.sg("applying feature flags",e),e.forEach(t=>{var e;if(this.rg&&null!=(e=this.rg)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),n=null==(i=this.rg)?void 0:i.get(t);r&&null!=n&&n.variants[r]&&this.og(n.name,r,n.variants[r].transforms)}})}}previewWebExperiment(){var e=t.getWindowLocation();if(null!=e&&e.search){var i=mn(null==e?void 0:e.search,"__experiment_id"),r=mn(null==e?void 0:e.search,"__experiment_variant");i&&r&&(t.sg("previewing web experiments "+i+" && "+r),this.getWebExperiments(t=>{this.lg(parseInt(i),r,t)},!1,!0))}}loadIfEnabled(){this.Dr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Dr.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.Dr.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}lg(e,i,r){var n=r.filter(t=>t.id===e);n&&n.length>0&&(t.sg("Previewing web experiment ["+n[0].name+"] with variant ["+i+"]"),this.og(n[0].name,i,n[0].variants[i].transforms))}static ag(e,i){return!y(e.conditions)&&t.ug(e,i)&&t.cg(e)}static ug(e,i){var r;if(y(e.conditions)||y(null==(r=e.conditions)?void 0:r.url))return!0;var n=t.getWindowLocation();if(n){var s,a,o,l=pi(i,n.href);return null==(s=e.conditions)||!s.url||Za[null!==(a=null==(o=e.conditions)?void 0:o.urlMatchType)&&void 0!==a?a:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return null==rn?void 0:rn.location}static cg(t){var e;if(y(t.conditions)||y(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!an)return{};var r,n,s,a=e?[...En,...i||[]]:[],o=(r=yn(an.URL,a,An),n=Tn.concat(t||[]),s={},hi(n,function(t){var e=mn(r,t);s[t]=e||null}),s);return ci(function(){var t={};return hi(Fn,function(e){var i=(t=>{if(an){try{for(var e=t+"=",i=an.cookie.split(";").filter(t=>t.length),r=0;i.length>r;r++){for(var n=i[r];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}})(e);t[e]=i||null}),t}(),o)}();if(i.utm_source){var r,n,s,a,o,l,u,h,c=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(n=t.conditions)||null==(n=n.utm)?void 0:n.utm_campaign)==i.utm_campaign,v=null==(s=t.conditions)||null==(s=s.utm)||!s.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,d=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return c&&d&&f&&v}return!1}static sg(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];oi.info("[WebExperiments] "+t,i)}static hg(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.hg(e)})}og(i,r,n){this._is_bot()?t.sg(Xa):"control"!==r?n.forEach(n=>{if(n.selector){var s;t.sg("applying transform of variant "+r+" for experiment "+i+" ",n);var a=null==(s=document)?void 0:s.querySelectorAll(n.selector),o=new Map;null==a||a.forEach(i=>{if("script"!==i.localName.toLowerCase()){var r=i;if(n.html){var s,a="http://www.w3.org/1998/Math/MathML"===i.namespaceURI&&"annotation-xml"===i.localName&&(null==(s=i.getAttribute("encoding"))?void 0:s.toLowerCase())||"",l=JSON.stringify([i.namespaceURI,i.localName,a]),u=o.get(l);if(y(u)){var h=null!=wa?wa:wa=Ja(),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({},Ya,{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({},Ya,{NAMESPACE:f||void 0,RETURN_DOM_FRAGMENT:!0}))),t.hg(v),o.set(l,u=v.innerHTML)}r.innerHTML=u}n.css&&r.setAttribute("style",n.css)}})}}):t.sg("Control variants leave the page unmodified.")}_is_bot(){return sn&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&F(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>F(null==t?void 0:t.brand,e)))return!0}catch(t){}return!!t.webdriver}(sn,this.Dr.custom_blocked_useragents):void 0}}},Mo),Ho={conversations:class{constructor(t){this._instance=t,this.dg=void 0,this._conversationsManager=null,this.vg=!1,this.ie=null,this.fg=!1,this.pg=0,this.gg=null,this.mg=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)this.gg=null;else if(this.yg=t.ok,t.ok){var e=t.config.conversations;y(e)?this.gg=null:(_(e)?this.dg=e:(this.dg=e.enabled,this.ie=e),this.dg||(this.gg=null),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.pg++,this.dg=void 0,this.ie=null,this.yg=void 0,this.fg=!1,this.gg=null}loadIfEnabled(){if(!(this._conversationsManager||this.vg||this._instance.config.disable_conversations||fi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==un?void 0:un.__PosthogExtensions__;if(t&&!f(this.dg)&&this.dg)if(this.ie&&this.ie.token){this.vg=!0;try{var e=t.initConversations;if(e)return this.bg(e),void(this.vg=!1);var i=t.loadExternalDependency;if(!i)return void this._g(Dr);var r=this.pg;i(this._instance,"conversations",e=>{if(r!==this.pg)return this.vg=!1,void this.loadIfEnabled();e||!t.initConversations?this._g("Could not load conversations script",e):this.bg(t.initConversations),this.vg=!1})}catch(t){this._g("Error initializing conversations",t),this.vg=!1}}else Qa.error("Conversations enabled but missing token in remote config.")}}bg(t){if(this.ie){try{this._conversationsManager=t(this.ie,this._instance),this.fg=!1,Qa.info("Conversations loaded successfully")}catch(t){return void this._g("Error completing conversations initialization",t)}this.mg&&this._conversationsManager.setTheme(this.mg),this.wg()}else Qa.error("Cannot complete initialization: remote config is null")}wg(){var t=this.gg;this.gg=null,this._conversationsManager&&t&&("open"===t?this._conversationsManager.open():this._conversationsManager.close())}_g(t,e){Qa.error(t,e),this._conversationsManager=null,this.vg=!1,this.fg=!0}show(){this._conversationsManager?this._conversationsManager.show():Qa.warn("Conversations not loaded yet.")}hide(){"open"===this.gg&&(this.gg=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.gg=null,this._conversationsManager.open()):this.gg="open"}close(){this._conversationsManager?(this.gg=null,this._conversationsManager.close()):this.gg="close"}setTheme(t){var i,r;this.mg=e({},this.mg,t,{dark:e({},null==(i=this.mg)?void 0:i.dark,null==t?void 0:t.dark)}),null==(r=this._conversationsManager)||r.setTheme(t)}isAvailable(){return!0===this.dg&&!m(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":fi(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.yg?"remote_config_failed":f(this.dg)?this.yg?"disabled_in_project":"remote_config_pending":this.dg?y(this.ie)||!this.ie.token?"missing_token":null!=un&&un.__PosthogExtensions__?this.vg?"initializing":this.fg?"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):(Qa.warn(to),null)})()}getMessages(t,e){var i=this;return r(function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Qa.warn(to),null)})()}markAsRead(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Qa.warn(to),null)})()}getTickets(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Qa.warn(to),null)})()}requestRestoreLink(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Qa.warn(to),null)})()}restoreFromToken(t){var e=this;return r(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Qa.warn(to),null)})()}restoreFromUrlToken(){var t=this;return r(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Qa.warn(to),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()}}},qo={logs:class extends lo{constructor(t){super({get(){var e;return null==t||null==(e=t.config)?void 0:e.logs},captureHintKey:"$logs_capture_enabled_server_side",get remoteConfigWillArrive(){var e;return!(null!=t._shouldDisableFlags&&t._shouldDisableFlags()&&(null==(e=un._POSTHOG_REMOTE_CONFIG)||null==(e=e[t.config.token])||!e.config))}},()=>function(t){var e,i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){var r=t.sessionManager.checkAndGetSessionAndWindowId(!0),n=r.windowId,s=r.sessionStartTimestamp,a=r.lastActivityTimestamp;i.sessionId=r.sessionId,i.windowId=n,y(s)||(i.sessionStartTimestamp=s),y(a)||(i.lastActivityTimestamp=a)}if(null!=un&&null!=(e=un.location)&&e.href&&(i.currentUrl=t.config.disable_capture_url_hashes?Y(un.location.href):un.location.href),t.featureFlags){var o=t.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}(t)),this._instance=t,this.name="logs",this.Zv()}get Qv(){return this._instance.__loaded}Jv(){var t=li("[logs]"),e=null==un?void 0:un.__PosthogExtensions__;if(e){var i=e.loadExternalDependency;if(i)return t=>{i(this._instance,"logs",i=>{var r=e.logs;t(i,null!=r&&r.initializeLogs?{initialize:t=>r.initializeLogs(t),replay:(t,e)=>null==r.replayConsoleBuffer?void 0:r.replayConsoleBuffer(t,e)}:void 0)})};t.error(Dr)}else t.error("PostHog Extensions not found.")}}},Vo={metrics:class{constructor(t){this._instance=t,this.A=li("[metrics]"),this.Ti=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(!this.Ti){var e=!(null==(t=this._instance.config.metrics)||!t.network);e&&!this.kg?this.kg=(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=mo(t,i),n=yo(t,i);return()=>{e=!1,r(),n()}})(this._instance):!e&&this.kg&&(this.kg(),this.kg=void 0)}}Xv(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Vv&&this.tf===i||(null==(e=this.Vv)||e.reset(),this.tf=i,this.Vv=new ii(this.Yv(),function(t){var e,i,r,n,s,a=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==a?void 0:a["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==a?void 0:a["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==a?void 0:a["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:a,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(s=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==s?s:1e3}}(i),this.A)),this.Vv}count(t,e,i){void 0===e&&(e=1),this.Xv().count(t,e,i)}gauge(t,e,i){this.Xv().gauge(t,e,i)}histogram(t,e,i){this.Xv().histogram(t,e,i)}flush(t){if(!this.Vv)return Promise.resolve();if(t){var e=this.Vv.drainWindow();return e&&this.bo(e,t),Promise.resolve()}return this.Vv.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Vv)||t.reset()}dispose(){var t,e;this.Ti=!0,null==(t=this.kg)||t.call(this),this.kg=void 0,null==(e=this.Vv)||e.reset()}Yv(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},bo:t=>e.bo(t),getLibraryId:()=>ds.LIB_NAME,getLibraryVersion:()=>ds.LIB_VERSION}}bo(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:new Error("metrics request timed out")}),9e4);this._instance._send_request(e({method:"POST",url:this.Sg(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var e,i=t.statusCode;s(i>=200&&300>i?{kind:"ok"}:413===i?{kind:"too-large"}:0!==i&&408!==i&&429!==i&&500>i?{kind:"fatal",error:new Error("metrics request failed with status "+i)}:{kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("metrics request failed with status "+i)})}}))})}Sg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Wo={webMCP:class{constructor(t){this._instance=t,this.xg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(this._instance.config.capture_webmcp&&!this.xg){var t=null==an?void 0:an.modelContext;if(t&&c(t.registerTool)){var e=bo.get(t);if(e)return e.instances.add(this._instance),void(this.xg=!0);var i={instances:new Set([this._instance])},r=t.registerTool,n=this;xn(t,"registerTool",t=>{var e=t;return function(t){for(var r=t,s=arguments.length,a=new Array(s>1?s-1:0),o=1;s>o;o++)a[o-1]=arguments[o];try{r=n.$g(t,i)}catch(i){return e.call(this,t,...a)}return e.call(this,r,...a)}}),t.registerTool!==r&&(bo.set(t,i),this.xg=!0)}}}$g(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=>_o.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:Eo(t),injected:r};var s=(null==n?void 0:n.properties)||{},a=t=>ko(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:Eo(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 exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},l.includes("llm_model")||l.push("llm_model")),{tool:Eo(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=So(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=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?To(t.context,2048,!0):void 0,n=i.model?To(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&&ko(r,"context"),s=i.model&&ko(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.Cg(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.Cg(i,a,s,e,f),t},t=>{throw n.Cg(i,a,s,{error:t,errorResult:!1},f),t});var g=Ao(c)?{error:c,errorResult:!0}:void 0;return n.Cg(i,a,s,g,f),c}}),a}Cg(t,i,r,n,s){var a,o=Date.now()-r.getTime();for(var l of t.instances){var u,h=So(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==on?void 0:on.hostname,$mcp_duration_ms:o,$mcp_is_error:!!n},a?{$mcp_error_type:a.type,$mcp_error_message:a.message}:{},h.intent&&s.intent?{$mcp_intent:s.intent,$mcp_intent_source:"context_parameter"}:{},h.model&&s.model?{$mcp_llm_model:s.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:r})}catch(t){continue}if(n&&a&&l.exceptions&&null!=(u=l.exceptionObserver)&&u.isEnabled)try{var c={$exception_list:Ro(l.exceptions,n,a.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:i.name,$mcp_resource_name:i.name,$mcp_tool_description:i.description,$mcp_server_name:null==on?void 0:on.hostname};l.exceptionObserver.captureException(c)}catch(t){}}}}}},Go=e({},Mo,$o,Io,jo,Do,Lo,zo,No,Uo,Bo,Ho,qo,Vo,Wo),Ko=Mo,Jo=$o,Xo=Io,Yo=jo,Zo=Do,Qo=Lo,tl=zo,el=No,il=Uo,rl=Bo,nl=Ho,sl=qo,al=Vo,ol=Wo;export{Go as AllExtensions,Xo as AnalyticsExtensions,nl as ConversationsExtensions,Yo as ErrorTrackingExtensions,rl as ExperimentsExtensions,Ko as FeatureFlagsExtensions,sl as LogsExtensions,al as MetricsExtensions,Zo as ProductToursExtensions,Jo as SessionReplayExtensions,Qo as SiteAppsExtensions,tl as SurveysExtensions,il as ToolbarExtensions,el as TracingExtensions,ol as WebMCPExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map