@entur-partner/app-shell 6.5.0 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@auth0/auth0-react`),l=require(`@entur/alert`),u=require(`@entur/loader`),d=require(`@entur/tokens`),f=require(`@entur/typography`),p=require(`@entur-partner/common`),m=require(`react`);m=s(m,1);let h=require(`react/jsx-runtime`),g=require(`@entur-partner/util`),_=require(`@entur-partner/micro-frontend`);var v=({environment:e})=>(0,h.jsx)(`div`,{className:`epp-environment-banner`,style:{position:`fixed`,zIndex:9999,top:0,left:0,right:0,width:`100vw`,height:`16px`,backgroundColor:(0,p.getColorForEnvironment)(e)}});function ee(e){let{protocol:t,hostname:n,port:r}=window.location;return e({logoutParams:{returnTo:`${t}//${n}:${r}`}})}var y=({children:e,decorateUser:t,getReturnPath:n,isPublicView:r})=>{let[i,a]=(0,m.useState)(void 0),[o,s]=(0,m.useState)(!1),[p,g]=(0,m.useState)(void 0),{user:_,getAccessTokenSilently:v,loginWithRedirect:y,logout:b,isLoading:x,isAuthenticated:S,error:C}=(0,c.useAuth0)();return(0,m.useEffect)(()=>{S&&(async()=>{s(!0);try{a(await t(_,await v()))}catch(e){g(e)}finally{s(!1)}})()},[t,v,S,_]),x||o||S&&!i&&!p?(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Authenticating`}):!S&&!r?(y({appState:{returnTo:n()}}),(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Redirecting to login page`})):p?(process.env.NODE_ENV!==`production`&&console.error(p),(0,h.jsx)(l.BannerAlertBox,{variant:`error`,title:`Authentication failed`,style:{maxWidth:`600px`,margin:`0 auto`},children:(0,h.jsxs)(f.Paragraph,{children:[`Something went wrong while trying to authenticate you. If the problem persists you should contact`,` `,(0,h.jsx)(f.Link,{href:`mailto:support@entur.org`,children:`support@entur.org`}),` to get it resolved.`]})})):C?(process.env.NODE_ENV!==`production`&&console.error(C),(0,h.jsxs)(l.BannerAlertBox,{variant:`error`,title:`Authentication failed`,style:{maxWidth:`600px`,margin:`0 auto`},children:[(0,h.jsxs)(f.Paragraph,{children:[`Something went wrong while trying to authenticate you. If the problem persists you should contact`,` `,(0,h.jsx)(f.Link,{href:`mailto:support@entur.org`,children:`support@entur.org`}),` to get it resolved.`]}),(0,h.jsxs)(f.Paragraph,{children:[`Authentication failed with: `,(0,h.jsx)(f.CodeText,{children:C?.toString()})]})]})):(0,h.jsx)(h.Fragment,{children:e({user:i,logout:()=>ee(b),loginWithRedirect:y,getToken:v})})},b=({children:e,audience:t,domain:n,clientId:r,decorateUser:i,environment:a,redirectUri:o,navigate:s,isPublicView:l=!1})=>(0,h.jsx)(c.Auth0Provider,{domain:n,clientId:r,authorizationParams:{redirect_uri:o??window.location.origin,audience:t},onRedirectCallback:e=>{let t=e?.returnTo,n=o||t||`/`;s?s(n,{replace:!0}):window.history.replaceState({},``,n)},children:(0,h.jsx)(y,{decorateUser:i,getReturnPath:()=>`${window.location.pathname}${window.location.search}${window.location.hash}`,isPublicView:l,children:t=>(0,h.jsxs)(h.Fragment,{children:[a&&a!==p.Environment.Production&&(0,h.jsx)(v,{environment:a}),e(t)]})})}),x=`EP::activeOrgId`,S={get:()=>localStorage.getItem(x),set:e=>localStorage.setItem(x,e)},C=`EP::locale`,te={get:()=>localStorage.getItem(C),set:e=>localStorage.setItem(C,e)},w=`ucData`,ne={get:()=>localStorage.getItem(w)},T={Usercentrics:`Usercentrics Consent Management Platform`,PostHog:`PostHog.com`,Sentry:`Sentry`},re={Usercentrics:{consentGiven:!1},PostHog:{consentGiven:!1},Sentry:{consentGiven:!1}},E=e=>e.map(e=>{let t=Object.entries(T).find(t=>t[1]===e.name)?.[0];if((0,g.assertIsDefined)(t,`Service name ${e.name} not found in SERVICE_NAMES`),typeof e.consent==`boolean`){let n=e.consent;return{[t]:{consentGiven:n}}}else if(typeof e.consent==`object`&&`given`in e.consent){let n=e.consent.given;return{[t]:{consentGiven:n}}}return{[t]:{consentGiven:!1}}}).reduce((e,t)=>({...e,...t}),re),ie=(0,m.createContext)(re),ae=()=>(0,m.useContext)(ie),D=({children:e})=>{let[t,n]=(0,m.useState)(re);return(0,m.useEffect)(()=>{if(typeof window>`u`)return;let e=ne.get();if(e){let t=JSON.parse(e);n(E(Object.values(t.consent.services)))}},[]),(0,m.useEffect)(()=>{let e=async e=>{typeof window>`u`||n(E(Object.values(e.detail.services)))};return window.addEventListener(`UC_CONSENT`,e),()=>window.removeEventListener(`UC_CONSENT`,e)},[]),(0,h.jsx)(ie.Provider,{value:t,children:e})},oe=(0,m.createContext)(void 0),se=e=>{let[t,n]=(0,m.useState)(e);return(0,m.useEffect)(()=>{te.set(t)},[t]),[t,n]},ce=()=>{let e=(0,m.useContext)(oe);return(0,g.assertIsDefined)(e),e},le=({children:e,language:t})=>{let[n,r]=se(t);return(0,h.jsx)(oe.Provider,{value:{language:n,setLanguage:r},children:e})},ue=(0,m.createContext)({addItems:()=>{},getItemsForPath:()=>[],getMFNavigate:()=>void 0,setMFNavigate:()=>{},getItemGroupsPerPath:()=>({})}),de=e=>(0,m.useContext)(ue).getItemsForPath(e),fe=()=>(0,m.useContext)(ue),O=e=>{let{getMFNavigate:t}=fe();return t(e)},pe=({children:e})=>{let[t,n]=(0,m.useState)({}),[r,i]=(0,m.useState)({}),a=(0,m.useCallback)((e,t)=>{n(n=>({...n,[t]:e})),window.dispatchEvent((0,_.createMenuItemsEvent)({path:t,items:e}))},[]);return(0,h.jsx)(ue.Provider,{value:{addItems:a,getItemGroupsPerPath:()=>t,getItemsForPath:e=>t[e]??[],getMFNavigate:e=>r[e],setMFNavigate:(e,t)=>i(n=>({...n,[e]:t}))},children:e})};function me(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var he=({navigate:e,children:t,onClick:n,target:r,...i})=>(0,h.jsx)(`a`,{onClick:t=>{try{n&&n(t)}catch(e){throw t.preventDefault(),e}!t.defaultPrevented&&t.button===0&&(!r||r===`_self`)&&!me(t)&&(t.preventDefault(),e())},target:r,...i,children:t}),ge=(0,m.createContext)(void 0),_e=()=>{let e=(0,m.useContext)(ge);return(0,g.assertIsDefined)(e),e},ve=()=>{let e=(0,m.useContext)(ge);return(0,g.assertIsDefined)(e),e.organisationId},ye=e=>{let[t,n]=(0,m.useState)(Number(e));return(0,m.useEffect)(()=>{S.set(t.toString())},[t]),[t,n]},be=({children:e,organisationId:t})=>{let[n,r]=ye(t);return(0,h.jsx)(ge.Provider,{value:{organisationId:n,setOrganisationId:r},children:e})},xe=class extends Error{constructor(...e){super(...e),this.message=`Failed fetching organisations`}},Se=({getToken:e,getOrganisations:t,selectedOrganisationId:n,onChange:r,...i})=>{let[a,o]=(0,m.useState)([]),{language:s}=ce(),[c,l]=(0,m.useState)(`LOADING`);switch((0,m.useEffect)(()=>{(async()=>{let n=await e(),r;r=typeof t==`string`?await fetch(t,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`}}).then(e=>e.json()):await t(n),o(r),l(`SUCCESS`)})().catch(e=>{process.env.NODE_ENV===`development`&&console.error(e),l(`ERROR`)})},[t,e]),c){case`LOADING`:return(0,h.jsx)(`div`,{className:`eds-contrast`,children:(0,h.jsx)(u.SkeletonRectangle,{style:{height:`2.4rem`}})});case`SUCCESS`:return(0,h.jsx)(p.OrganisationDropDown,{label:s===`nb`||s===`nb-NO`?`Organisasjon`:`Organisation`,selectedOrganisationId:n,organisations:a,onChange:r,...i});case`ERROR`:throw new xe;default:return null}},k=typeof window<`u`?window:void 0,A=typeof globalThis<`u`?globalThis:k;typeof self>`u`&&(A.self=A),typeof File>`u`&&(A.File=function(){});var Ce=A?.navigator,j=A?.document,we=A?.location,Te=A?.fetch,Ee=A!=null&&A.XMLHttpRequest&&`withCredentials`in new A.XMLHttpRequest?A.XMLHttpRequest:void 0,De=A?.AbortController,Oe=A?.CompressionStream,ke=Ce?.userAgent,M=k??{},Ae=`1.372.6`,N={DEBUG:!1,LIB_VERSION:Ae,LIB_NAME:`web`,JS_SDK_VERSION:Ae};function je(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Me(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){je(a,r,i,o,s,`next`,e)}function s(e){je(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function P(){return P=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},P.apply(null,arguments)}function Ne(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Pe(){return Pe=Me((function*(e,t,n){t===void 0&&(t=!0);try{var r=new CompressionStream(`gzip`),i=r.writable.getWriter(),a=i.write(new TextEncoder().encode(e)).then((()=>i.close())).catch(function(){var e=Me((function*(e){try{yield i.abort(e)}catch{}throw e}));return function(t){return e.apply(this,arguments)}}()),o=new Response(r.readable).blob(),[s]=yield Promise.all([o,a]);return s}catch(e){if(n!=null&&n.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}})),Pe.apply(this,arguments)}var Fe=`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,pinterest,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,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`.split(`,`),Ie=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return Fe.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))},Le=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`];function F(e,t){return e.indexOf(t)!==-1}var Re=function(e){return e.trim()},ze=function(e){return e.replace(/^\$/,``)},Be=Object.prototype,Ve=Be.hasOwnProperty,He=Be.toString,I=Array.isArray||function(e){return He.call(e)===`[object Array]`},Ue=e=>typeof e==`function`,L=e=>e===Object(e)&&!I(e),We=e=>{if(L(e)){for(var t in e)if(Ve.call(e,t))return!1;return!0}return!1},R=e=>e===void 0,z=e=>He.call(e)==`[object String]`,Ge=e=>z(e)&&e.trim().length===0,Ke=e=>e===null,B=e=>R(e)||Ke(e),qe=e=>He.call(e)==`[object Number]`&&e==e,Je=e=>qe(e)&&e>0,Ye=e=>He.call(e)===`[object Boolean]`,Xe=e=>e instanceof FormData,Ze=e=>F(Le,e);function Qe(e){return typeof e!=`object`||!e}function $e(e,t){return{}.toString.call(e)===`[object `+t+`]`}function et(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var tt=[!0,`true`,1,`1`,`yes`],nt=e=>F(tt,e),rt=[!1,`false`,0,`0`,`no`];function it(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),qe(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),it(i||n,t,n,r))}var at=class{constructor(e){this.$t={},this.zt=e.zt,this.Ut=it(e.bucketSize,0,100,e.Gt),this.Wt=it(e.refillRate,0,this.Ut,e.Gt),this.Xt=it(e.refillInterval,0,864e5,e.Gt)}Jt(e,t){var n=Math.floor((t-e.lastAccess)/this.Xt);n>0&&(e.tokens=Math.min(e.tokens+n*this.Wt,this.Ut),e.lastAccess+=n*this.Xt)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.$t[r];return i?this.Jt(i,n):this.$t[r]=i={tokens:this.Ut,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.zt)==null||t.call(this,e)),i.tokens===0)}stop(){this.$t={}}},ot,st,ct,lt=(e,t,n)=>{function r(r){for(var i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];t((()=>{(0,n[r])(e,...a)}))}return{debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`error`,...t)},critical(){for(var t=arguments.length,r=Array(t),i=0;t>i;i++)r[i]=arguments[i];n.error(e,...r)},createLogger:r=>lt(e+` `+r,t,n)}},V=`Mobile`,ut=`iOS`,dt=`Android`,ft=`Tablet`,pt=dt+` `+ft,mt=`iPad`,ht=`Apple`,gt=ht+` Watch`,_t=`Safari`,vt=`BlackBerry`,yt=`Samsung`,bt=yt+`Browser`,xt=yt+` Internet`,St=`Chrome`,Ct=St+` OS`,wt=St+` `+ut,Tt=`Internet Explorer`,Et=Tt+` `+V,Dt=`Opera`,Ot=Dt+` Mini`,kt=`Edge`,At=`Microsoft `+kt,jt=`Firefox`,Mt=jt+` `+ut,Nt=`Nintendo`,Pt=`PlayStation`,Ft=`Xbox`,It=dt+` `+V,Lt=V+` `+_t,Rt=`Windows`,zt=Rt+` Phone`,Bt=`Nokia`,Vt=`Ouya`,Ht=`Generic`,Ut=Ht+` `+V.toLowerCase(),Wt=Ht+` `+ft.toLowerCase(),Gt=`Konqueror`,H=`(\\d+(\\.\\d+)?)`,Kt=RegExp(`Version/`+H),qt=new RegExp(Ft,`i`),Jt=RegExp(Pt+` \\w+`,`i`),Yt=RegExp(Nt+` \\w+`,`i`),Xt=RegExp(vt+`|PlayBook|BB10`,`i`),Zt={"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`},Qt=function(e,t){return t||=``,F(e,` OPR/`)&&F(e,`Mini`)?Ot:F(e,` OPR/`)?Dt:Xt.test(e)?vt:F(e,`IE`+V)||F(e,`WPDesktop`)?Et:F(e,bt)?xt:F(e,kt)||F(e,`Edg/`)?At:F(e,`FBIOS`)?`Facebook `+V:F(e,`UCWEB`)||F(e,`UCBrowser`)?`UC Browser`:F(e,`CriOS`)?wt:F(e,`CrMo`)||F(e,St)?St:F(e,dt)&&F(e,_t)?It:F(e,`FxiOS`)?Mt:F(e.toLowerCase(),Gt.toLowerCase())?Gt:((e,t)=>t&&F(t,ht)||function(e){return F(e,_t)&&!F(e,St)&&!F(e,dt)}(e))(e,t)?F(e,V)?Lt:_t:F(e,jt)?jt:F(e,`MSIE`)||F(e,`Trident/`)?Tt:F(e,`Gecko`)?jt:``},$t={[Et]:[RegExp(`rv:`+H)],[At]:[RegExp(kt+`?\\/`+H)],[St]:[RegExp(`(`+St+`|CrMo)\\/`+H)],[wt]:[RegExp(`CriOS\\/`+H)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+H)],[_t]:[Kt],[Lt]:[Kt],[Dt]:[RegExp(`(Opera|OPR)\\/`+H)],[jt]:[RegExp(jt+`\\/`+H)],[Mt]:[RegExp(`FxiOS\\/`+H)],[Gt]:[RegExp(`Konqueror[:/]?`+H,`i`)],[vt]:[RegExp(vt+` `+H),Kt],[It]:[RegExp(`android\\s`+H,`i`)],[xt]:[RegExp(bt+`\\/`+H)],[Tt]:[RegExp(`(rv:|MSIE )`+H)],Mozilla:[RegExp(`rv:`+H)]},en=function(e,t){var n=$t[Qt(e,t)];if(R(n))return null;for(var r=0;n.length>r;r++){var i=e.match(n[r]);if(i)return parseFloat(i[i.length-2])}return null},tn=[[RegExp(Ft+`; `+Ft+` (.*?)[);]`,`i`),e=>[Ft,e&&e[1]||``]],[new RegExp(Nt,`i`),[Nt,``]],[new RegExp(Pt,`i`),[Pt,``]],[Xt,[vt,``]],[new RegExp(Rt,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[zt,``];if(new RegExp(V).test(t)&&!/IEMobile\b/.test(t))return[Rt+` `+V,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=Zt[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[Rt,r]}return[Rt,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[ut,[e[3],e[4],e[5]||`0`].join(`.`)]:[ut,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=R(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+dt+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+dt+`)`,`i`),e=>e&&e[2]?[dt,[e[2],e[3],e[4]||`0`].join(`.`)]:[dt,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[Ct,``]],[/Linux|debian/i,[`Linux`,``]]],nn=function(e){return Yt.test(e)?Nt:Jt.test(e)?Pt:qt.test(e)?Ft:new RegExp(Vt,`i`).test(e)?Vt:RegExp(`(`+zt+`|WPDesktop)`,`i`).test(e)?zt:/iPad/.test(e)?mt:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?gt:Xt.test(e)?vt:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Bt,`i`).test(e)?Bt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(V).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?dt:pt:RegExp(`(pda|`+V+`)`,`i`).test(e)?Ut:new RegExp(ft,`i`).test(e)&&!RegExp(ft+` pc`,`i`).test(e)?Wt:``},rn=e=>e instanceof Error,an={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}},on=an.info;function sn(e){if(Ye(e))return{boolValue:e};if(typeof e==`number`)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if(typeof e==`string`)return{stringValue:e};if(I(e))return{arrayValue:{values:e.map((e=>sn(e)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function cn(e){var t=[];for(var n in e){var r=e[n];Ke(r)||R(r)||t.push({key:n,value:sn(r)})}return t}function ln(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return ct&&n.length===st||(st=n.length,ct=n.reduce(((n,r)=>{ot||={};var i=ot[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,ot[r]=[s,c];break}}return n}),{})),ct}}var un=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return Me((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&I(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),P({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Me((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,P({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:ln(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return P({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},dn=`?`;function fn(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?dn:n,in_app:!0};return R(r)||(a.lineno=r),R(i)||(a.colno=i),a}var pn=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?dn:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},mn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,hn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,gn=/\((\S*)(?::(\d+))(?::(\d+))\)/,_n=(e,t)=>{var n=mn.exec(e);if(n){var[,r,i,a]=n;return fn(t,r,dn,+i,+a)}var o=hn.exec(e);if(o){if(o[2]&&o[2].indexOf(`eval`)===0){var s=gn.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}var[c,l]=pn(o[1]||dn,o[2]);return fn(t,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},vn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,yn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,bn=(e,t)=>{var n=vn.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=yn.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||dn;return[a,i]=pn(a,i),fn(t,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},xn=/\(error: (.*)\)/,Sn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=z(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){var t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?t+`: `+e.message:t}isDOMException(e){return $e(e,`DOMException`)}isDOMError(e){return $e(e,`DOMError`)}},Cn=class{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},wn=class{constructor(){}match(e){return $e(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},Tn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,En=class{match(e){return typeof e==`string`}coerce(e,t){var[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(Tn);return r&&(t=r[1],n=r[2]),[t,n]}},Dn=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function On(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var kn=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return et(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+On(e)}isSeverityLevel(e){return z(e)&&!Ge(e)&&Dn.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(rn(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},An=class{match(e){return et(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+On(e),stack:t.syntheticException?.stack,synthetic:!0}}},jn=class{match(e){return Qe(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},Mn=class{match(e){return $e(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!et(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return Qe(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},Nn=`$message`,Pn=`$timestamp`,Fn=new Set([Nn,Pn]),In={enabled:!0,max_bytes:32768};function Ln(e){return e?{enabled:e.enabled??In.enabled,max_bytes:zn(e.max_bytes,In.max_bytes)}:P({},In)}var Rn=class{constructor(e){this.Kt=[],this.Qt=0,this.Bt=Ln(e)}setConfig(e){this.Bt=Ln(e),this.er()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Date)return n.toISOString();if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){if(t.has(n))return`[Circular]`;t.add(n)}return n}}))}catch{return}}(e);if(t)try{var n=JSON.parse(t);if(!L(n))return;var r=n,i=r[Nn],a=r[Pn];return!z(i)||i.trim().length===0||!z(a)&&!qe(a)?void 0:{step:r,json:t}}catch{return}}(e);if(t){var n=function(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e).length;for(var t=encodeURIComponent(e),n=0,r=0;t.length>r;r++)t[r]===`%`?(n+=1,r+=2):n+=1;return n}(t.json);n>this.Bt.max_bytes||(this.Kt.push({step:t.step,bytes:n}),this.Qt+=n,this.er())}}getAttachable(){return this.Kt.map((e=>e.step))}clear(){this.Kt=[],this.Qt=0}size(){return this.Kt.length}er(){for(;this.Qt>this.Bt.max_bytes&&this.Kt.length>0;){var e=this.Kt.shift();e&&(this.Qt-=e.bytes)}}};function zn(e,t){if(!qe(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var Bn=function(e,t){var{debugEnabled:n}=t===void 0?{}:t,r={C(t){if(k&&(N.DEBUG||M.POSTHOG_DEBUG||n)&&!R(k.console)&&k.console){for(var r=(`__rrweb_original__`in k.console[t])?k.console[t].__rrweb_original__:k.console[t],i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];r(e,...a)}},debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`error`,...t)},critical(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];console.error(e,...n)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling `+e)},createLogger:(t,n)=>Bn(e+` `+t,n)};return r},U=Bn(`[PostHog.js]`),W=U.createLogger,Vn=W(`[ExternalScriptsLoader]`),Hn=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Vn.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var r=j?.querySelectorAll(`script`);if(r){for(var i,a=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener(`load`,(t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)})),e.onerror=e=>n(e),{v:void 0})}},o=0;r.length>o;o++)if(i=a())return i.v}var s=()=>{if(!j)return n(`document not found`);var r=j.createElement(`script`);if(r.type=`text/javascript`,r.crossOrigin=`anonymous`,r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)},r.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)j.head.appendChild(r);else{var i,a=j.querySelectorAll(`body > script`);a.length>0?(i=a[0].parentNode)==null||i.insertBefore(r,a[0]):j.body.appendChild(r)}};j!=null&&j.body?s():j?.addEventListener(`DOMContentLoaded`,s)};M.__PosthogExtensions__=M.__PosthogExtensions__||{},M.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r;if(e.config.__preview_external_dependency_versioned_paths)r=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`);else{var i=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var a=3e5;i=i+`&t=`+Math.floor(Date.now()/a)*a}r=e.requestRouter.endpointFor(`assets`,i)}Hn(e,r,n)}else Hn(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},M.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{Hn(e,e.requestRouter.endpointFor(`api`,t),n)};var Un=`$people_distinct_id`,Wn=`$device_id`,Gn=`__alias`,Kn=`__timers`,qn=`$autocapture_disabled_server_side`,Jn=`$heatmaps_enabled_server_side`,Yn=`$exception_capture_enabled_server_side`,Xn=`$error_tracking_suppression_rules`,Zn=`$error_tracking_capture_extension_exceptions`,Qn=`$web_vitals_enabled_server_side`,$n=`$dead_clicks_enabled_server_side`,er=`$product_tours_enabled_server_side`,tr=`$web_vitals_allowed_metrics`,nr=`$session_recording_remote_config`,rr=`$replay_override_sampling`,ir=`$replay_override_linked_flag`,ar=`$replay_override_url_trigger`,or=`$replay_override_event_trigger`,sr=`$sesid`,cr=`$session_is_sampled`,lr=`$enabled_feature_flags`,ur=`$active_feature_flags`,dr=`$early_access_features`,fr=`$feature_flag_details`,pr=`$feature_flag_payloads`,mr=`$feature_flag_request_id`,hr=`$override_feature_flags`,gr=`$override_feature_flag_payloads`,_r=`$stored_person_properties`,vr=`$stored_group_properties`,yr=`$surveys`,br=`$surveys_activated`,xr=`ph_product_tours`,Sr=`$flag_call_reported`,Cr=`$flag_call_reported_session_id`,wr=`$feature_flag_errors`,Tr=`$feature_flag_evaluated_at`,Er=`$user_state`,Dr=`$client_session_props`,Or=`$capture_rate_limit`,kr=`$initial_campaign_params`,Ar=`$initial_referrer_info`,jr=`$initial_person_info`,Mr=`$epp`,Nr=`__POSTHOG_TOOLBAR__`,Pr=`$posthog_cookieless`,Fr=`$sdk_debug_extensions_init_method`,Ir=`$sdk_debug_extensions_init_time_ms`,Lr=`$sdk_debug_recording_script_not_loaded`,Rr=`PostHog loadExternalDependency extension not found.`,zr=`on_reject`,Br=`always`,Vr=`anonymous`,Hr=`identified`,Ur=`identified_only`,Wr=`visibilitychange`,Gr=`beforeunload`,Kr=`$pageview`,qr=`$pageleave`,Jr=`$identify`,Yr=`$groupidentify`;function Xr(e,t){I(e)&&e.forEach(t)}function G(e,t){if(!B(e))if(I(e))e.forEach(t);else if(Xe(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)Ve.call(e,n)&&t(e[n],n)}var K=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function Zr(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Qr=function(e){try{return e()}catch{return}},$r=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){U.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),U.critical(e)}}},ei=function(e){var t={};return G(e,(function(e,n){(z(e)&&e.length>0||qe(e))&&(t[n]=e)})),t},ti=[`herokuapp.com`,`vercel.app`,`netlify.app`];function ni(e){var t=e?.hostname;if(!z(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of ti)if(n===r)return!1;return!0}function q(e,t,n,r){var{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function ri(e){return e.name===`ph_toolbar_internal`}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return qe(e)&&isFinite(e)&&Math.floor(e)===e});var ii=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},ai=class{constructor(){this.I=0,this.S=0,this.k=new ci}generate(){var e=this.generateOrAbort();if(R(e)){this.I=0;var t=this.generateOrAbort();if(R(t))throw Error(`Could not generate UUID after timestamp reset`);return t}return e}generateOrAbort(){var e=Date.now();if(e>this.I)this.I=e,this.A();else{if(this.I>=e+1e4)return;this.S++,this.S>4398046511103&&(this.I++,this.A())}return ii.fromFieldsV7(this.I,Math.trunc(this.S/2**30),this.S&2**30-1,this.k.nextUint32())}A(){this.S=1024*this.k.nextUint32()+(1023&this.k.nextUint32())}},oi,si=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};k&&!R(k.crypto)&&crypto.getRandomValues&&(si=e=>crypto.getRandomValues(e));var ci=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(si(this.T),this.N=0),this.T[this.N++]}},li=()=>ui().toString(),ui=()=>(oi||=new ai).generate(),di=``,fi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,pi={R:()=>!!j,B(e){U.error(`cookieStore error: `+e)},O(e){if(j){try{for(var t=e+`=`,n=j.cookie.split(`;`).filter((e=>e.length)),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==` `;)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},Z(e){var t;try{t=JSON.parse(pi.O(e))||{}}catch{}return t},M(e,t,n,r,i){if(j)try{var a=``,o=``,s=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=j),di)return di;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+li();!di&&r--;){var a=n.slice(r).join(`.`),o=i+`=1;domain=.`+a+`;path=/`;t.cookie=o+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=o+`;max-age=0`,di=a)}return di}(e);if(!n){var r=(e=>{var t=e.match(fi);return t?t[0]:``})(e);r!==n&&U.info(`Warning: cookie subdomain discovery mismatch`,r,n),n=r}return n?`; domain=.`+n:``}return``}(j.location.hostname,r);if(n){var c=new Date;c.setTime(c.getTime()+864e5*n),a=`; expires=`+c.toUTCString()}i&&(o=`; secure`);var l=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return l.length>3686.4&&U.warn(`cookieStore warning: large cookie, len=`+l.length),j.cookie=l,l}catch{return}},F(e,t){if(j!=null&&j.cookie)try{pi.M(e,``,-1,t)}catch{return}}},mi=null,J={R(){if(!Ke(mi))return mi;var e=!0;if(R(k))e=!1;else try{var t=`__mplssupport__`;J.M(t,`xyz`),J.O(t)!==`"xyz"`&&(e=!1),J.F(t)}catch{e=!1}return e||U.error(`localStorage unsupported; falling back to cookie store`),mi=e,e},B(e){U.error(`localStorage error: `+e)},O(e){try{return k?.localStorage.getItem(e)}catch(e){J.B(e)}return null},Z(e){try{return JSON.parse(J.O(e))||{}}catch{}return null},M(e,t){try{k?.localStorage.setItem(e,JSON.stringify(t))}catch(e){J.B(e)}},F(e){try{k?.localStorage.removeItem(e)}catch(e){J.B(e)}}},hi=[Wn,`distinct_id`,sr,cr,Mr,jr,Er],gi={},_i={R:()=>!0,B(e){U.error(`memoryStorage error: `+e)},O:e=>gi[e]||null,Z:e=>gi[e]||null,M(e,t){gi[e]=t},F(e){delete gi[e]}},vi=null,Y={R(){if(!Ke(vi))return vi;if(vi=!0,R(k))vi=!1;else try{var e=`__support__`;Y.M(e,`xyz`),Y.O(e)!==`"xyz"`&&(vi=!1),Y.F(e)}catch{vi=!1}return vi},B(e){U.error(`sessionStorage error: `,e)},O(e){try{return k?.sessionStorage.getItem(e)}catch(e){Y.B(e)}return null},Z(e){try{return JSON.parse(Y.O(e))||null}catch{}return null},M(e,t){try{k?.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Y.B(e)}},F(e){try{k?.sessionStorage.removeItem(e)}catch(e){Y.B(e)}}},yi=class{constructor(e){this._instance=e}get Bt(){return this._instance.config}get consent(){return this.rr()?0:this.ir}isOptedOut(){return this.Bt.cookieless_mode===Br||this.isRejected()||this.consent===-1&&this.Bt.cookieless_mode===zr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Bt.opt_out_capturing_by_default}optInOut(e){this.nr.M(this.sr,+!!e,this.Bt.cookie_expiration,this.Bt.cross_subdomain_cookie,this.Bt.secure_cookie)}reset(){this.nr.F(this.sr,this.Bt.cross_subdomain_cookie)}get sr(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get ir(){var e=this.nr.O(this.sr);return nt(e)?1:F(rt,e)?0:-1}get nr(){var e=this.Bt.opt_out_capturing_persistence_type,t=e===`localStorage`?J:pi;if(!this.ar||this.ar!==t){this.ar=t;var n=e===`localStorage`?pi:J;n.O(this.sr)&&(this.ar.O(this.sr)||this.optInOut(nt(n.O(this.sr))),n.F(this.sr,this.Bt.cross_subdomain_cookie))}return this.ar}rr(){return!!this.Bt.respect_dnt&&[Ce?.doNotTrack,Ce?.msDoNotTrack,M.doNotTrack].some((e=>nt(e)))}},bi=W(`[Dead Clicks]`),xi=()=>!0,Si=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property($n)),r=e.instance.config.capture_dead_clicks;return Ye(r)?r:!!L(r)||n},Ci=class{get lazyLoadedDeadClicksAutocapture(){return this.lr}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){`captureDeadClicks`in e&&(this.instance.persistence&&this.instance.persistence.register({[$n]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.ur((()=>{this.hr()})):this.stop()}ur(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?bi.error(`failed to load script`,t):e()}))}hr(){var e;if(j){if(!this.lr&&(e=M.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=L(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.lr=M.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.lr.start(j),bi.info(`starting...`)}}else bi.error("`document` not found. Cannot start.")}stop(){this.lr&&(this.lr.stop(),this.lr=void 0,bi.info(`stopping...`))}},wi=W(`[SegmentIntegration]`),Ti=`posthog-js`;function Ei(e,t){var{organization:n,projectId:r,prefix:i,severityAllowList:a=[`error`],sendExceptionsToPostHog:o=!0}=t===void 0?{}:t;return t=>{if(a!==`*`&&!a.includes(t.level)||!e.__loaded)return t;t.tags||={};var s=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var c,l=t.exception?.values||[],u=l.map((e=>P({},e,{stacktrace:e.stacktrace?P({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>P({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:l[0]?.value||t.message,$exception_type:l[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:l[0]?.value||t.message,$sentry_exception_type:l[0]?.type,$sentry_tags:t.tags};return n&&r&&(d.$sentry_url=(i||`https://sentry.io/organizations/`)+n+`/issues/?project=`+r+`&query=`+t.event_id),o&&((c=e.exceptions)==null||c.sendExceptionEvent(d)),t}}var Di=class{constructor(e,t,n,r,i,a){this.name=Ti,this.setupOnce=function(o){o(Ei(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},Oi=class{constructor(e){this.cr=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(U.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.dr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.vr()}vr(){this.pr=this._instance.sessionManager?.onSessionId(this.cr)}destroy(){var e;(e=this.pr)==null||e.call(this),this.pr=void 0}doPageView(e,t){var n=this.gr(e,t);return this.dr={pathname:k?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.gr(e,this.dr?.pageViewId)}doEvent(){return{$pageview_id:this.dr?.pageViewId}}gr(e,t){var n=this.dr;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:s,maxContentHeight:c,lastContentY:l,maxContentY:u}=i;if(!(R(a)||R(o)||R(s)||R(c)||R(l)||R(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?it(o/a,0,1,U):1,f=a>1?it(s/a,0,1,U):1,p=c>1?it(l/c,0,1,U):1,m=c>1?it(u/c,0,1,U):1;r=K(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},ki={[Un]:{exposure:`hidden`},[Gn]:{exposure:`hidden`},__cmpns:{exposure:`hidden`},[Kn]:{exposure:`hidden`},[qn]:{exposure:`event`},[Jn]:{exposure:`hidden`},[Yn]:{exposure:`event`},[Xn]:{exposure:`hidden`},[Zn]:{exposure:`event`},[Qn]:{exposure:`event`},[$n]:{exposure:`event`},[er]:{exposure:`hidden`},[tr]:{exposure:`event`},[nr]:{exposure:`hidden`},$session_recording_enabled_server_side:{exposure:`hidden`},[sr]:{exposure:`hidden`},[cr]:{exposure:`event`},$session_past_minimum_duration:{exposure:`event`},$session_recording_url_trigger_activated_session:{exposure:`event`},$session_recording_event_trigger_activated_session:{exposure:`event`},$debug_first_full_snapshot_timestamp:{exposure:`event`},[lr]:{exposure:`derived`,shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!L(e))return{};for(var t={},n=Object.keys(e),r=0;n.length>r;r++)t[`$feature/`+n[r]]=e[n[r]];return t}},[ur]:{exposure:`event`},[dr]:{exposure:`hidden`},[fr]:{exposure:`hidden`},[pr]:{exposure:`event`},[mr]:{exposure:`event`},[hr]:{exposure:`event`},[gr]:{exposure:`hidden`},[_r]:{exposure:`hidden`},[vr]:{exposure:`hidden`},[yr]:{exposure:`hidden`},[br]:{exposure:`event`},[xr]:{exposure:`hidden`},$product_tours_activated:{exposure:`hidden`},$conversations_widget_session_id:{exposure:`event`},$conversations_ticket_id:{exposure:`event`},$conversations_widget_state:{exposure:`event`},$conversations_user_traits:{exposure:`event`},[Sr]:{exposure:`hidden`},[Cr]:{exposure:`hidden`},[wr]:{exposure:`hidden`},[Tr]:{exposure:`hidden`},[Er]:{exposure:`hidden`},[Dr]:{exposure:`hidden`},[Or]:{exposure:`hidden`},[kr]:{exposure:`hidden`},[Ar]:{exposure:`hidden`},[jr]:{exposure:`hidden`},[Mr]:{exposure:`hidden`},[rr]:{exposure:`event`},[ir]:{exposure:`event`},[ar]:{exposure:`event`},[or]:{exposure:`event`},[Fr]:{exposure:`event`},[Ir]:{exposure:`event`},[Lr]:{exposure:`event`},$sdk_debug_replay_event_trigger_status:{exposure:`event`},$sdk_debug_replay_linked_flag_trigger_status:{exposure:`event`},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:`event`},$sdk_debug_replay_remote_trigger_matching_config:{exposure:`event`},$sdk_debug_replay_trigger_groups_count:{exposure:`event`},$sdk_debug_replay_url_trigger_status:{exposure:`event`},$session_recording_start_reason:{exposure:`event`}},Ai=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],ji=e=>{var t=j?.createElement(`a`);return R(t)?null:(t.href=e,t)},Mi=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);if(a[0]===t){n=a;break}}if(!I(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{U.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},Ni=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);I(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},Pi=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},Fi=`https?://(.*)`,Ii=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],Li=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Ii],Ri=`<masked>`,zi=[`li_fat_id`];function Bi(e,t,n){if(!j)return{};var r,i=t?[...Ii,...n||[]]:[],a=Vi(Ni(j.URL,i,Ri),e);return K((r={},G(zi,(function(e){var t=pi.O(e);r[e]=t||null})),r),a)}function Vi(e,t){var n=Li.concat(t||[]),r={};return G(n,(function(t){r[t]=Mi(e,t)||null})),r}function Hi(e){var t=function(e){return e?e.search(Fi+`google.([^/?]*)`)===0?`google`:e.search(Fi+`bing.com`)===0?`bing`:e.search(Fi+`yahoo.com`)===0?`yahoo`:e.search(Fi+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!Ke(t)){r.$search_engine=t;var i=j?Mi(j.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function Ui(){return navigator.language||navigator.userLanguage}var Wi=`$direct`;function Gi(){return j?.referrer||Wi}function Ki(e,t){var n=e?[...Ii,...t||[]]:[],r=we?.href.substring(0,1e3);return{r:Gi().substring(0,1e3),u:r?Ni(r,n,Ri):void 0}}function qi(e){var{r:t,u:n}=e,r={$referrer:t,$referring_domain:t==null?void 0:t==Wi?Wi:ji(t)?.host};if(n){r.$current_url=n;var i=ji(n);r.$host=i?.host,r.$pathname=i?.pathname,K(r,Vi(n))}return t&&K(r,Hi(t)),r}function Ji(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Yi(){try{return new Date().getTimezoneOffset()}catch{return}}var Xi=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Zi=class{constructor(e,t){this.Bt=e,this.props={},this.mr=!1,this.yr=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(e),this.nr=this.br(e),this.load(),e.debug&&U.info(`Persistence loaded`,e.persistence,P({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.wr}br(e){Xi.indexOf(e.persistence.toLowerCase())===-1&&(U.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);var t=function(e){e===void 0&&(e=[]);var t=[...hi,...e];return P({},J,{Z(e){try{var t={};try{t=pi.Z(e)||{}}catch{}var n=K(t,JSON.parse(J.O(e)||`{}`));return J.M(e,n),n}catch{}return null},M(e,n,r,i,a,o){try{J.M(e,n,void 0,void 0,o);var s={};t.forEach((e=>{n[e]&&(s[e]=n[e])})),Object.keys(s).length&&pi.M(e,s,r,i,a,o)}catch(e){J.B(e)}},F(e,t){try{k?.localStorage.removeItem(e),pi.F(e,t)}catch(e){J.B(e)}}})}(e.cookie_persisted_properties||[]),n=e.persistence.toLowerCase();return n===`localstorage`&&J.R()?J:n===`localstorage+cookie`&&t.R()?t:n===`sessionstorage`&&Y.R()?Y:n===`memory`?_i:n===`cookie`?pi:t.R()?t:pi}_r(e){var t=e??this.Bt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[Tr];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return G(this.props,((t,n)=>{var r=(e=>{var t=ki[e];if(t)return t;for(var[n,r]of Ai)if(e.indexOf(n)===0)return r})(n);if(r?.exposure===`derived`){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t,n===lr?()=>this._r():()=>!1))return;r.transformToEventProperties&&K(e,r.transformToEventProperties(t))}else r&&r.exposure!==`event`||(e[n]=t)})),e}load(){if(!this.wr){var e=this.nr.Z(this.yr);e&&(this.props=K({},e))}}save(){this.wr||this.nr.M(this.yr,this.props,this.Ir,this.Cr,this.Sr,this.Bt.debug)}remove(){this.nr.F(this.yr,!1),this.nr.F(this.yr,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(L(e)){R(t)&&(t=`None`),this.Ir=R(n)?this.kr:n;var r=!1;if(G(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.Tr(n,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(L(e)){this.Ir=R(t)?this.kr:t;var n=!1;if(G(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.Tr(r,t),n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Ar(e),this.save())}update_campaign_params(){if(!this.mr){var e=Bi(this.Bt.custom_campaign_params,this.Bt.mask_personal_data_properties,this.Bt.custom_personal_data_properties);We(ei(e))||this.register(e),this.mr=!0}}update_search_keyword(){var e;this.register((e=j?.referrer)?Hi(e):{})}update_referrer_info(){this.register_once({$referrer:Gi(),$referring_domain:j!=null&&j.referrer&&ji(j.referrer)?.host||Wi},void 0)}set_initial_person_info(){this.props[kr]||this.props[Ar]||this.register_once({[jr]:Ki(this.Bt.mask_personal_data_properties,this.Bt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};G([Ar,kr],(t=>{var n=this.props[t];n&&G(n,(function(t,n){e[`$initial_`+ze(n)]=t}))}));var t,n,r=this.props[jr];return r&&K(e,(t=qi(r),n={},G(t,(function(e,t){n[`$initial_`+ze(t)]=e})),n)),e}safe_merge(e){return G(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){if(this.kr=this.Ir=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.br(e),i=this.props;this.clear(),this.nr=r,this.props=i,this.save()}}set_disabled(e){this.wr=e,this.wr?this.remove():this.save()}set_cross_subdomain(e){e!==this.Cr&&(this.Cr=e,this.remove(),this.save())}set_secure(e){e!==this.Sr&&(this.Sr=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[Kn]||{};n[e]=t,this.Tr(Kn,n),this.save()}remove_event_timer(e){var t=this.props[Kn]||{},n=t[e];return R(n)||(delete t[e],this.Tr(Kn,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.Tr(e,t),this.save()}Tr(e,t){this.props[e]=t}Ar(e){delete this.props[e]}},Qi={Activation:`events`,Cancellation:`cancelEvents`},$i={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},ea={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},ta={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},na={Popover:`popover`,Inline:`inline`},ra={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},ia={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},aa=W(`[RateLimiter]`),oa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{aa.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){aa.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(Or)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;return o||e||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(Or,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},sa=W(`[RemoteConfig]`),ca=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Er(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Rr(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/`+this._instance.config.token+`/config`),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return sa.info(`Using preloaded remote config`,this.remoteConfig),this.Nr(this.remoteConfig),void this.Mr();if(this._instance.Fr())return void sa.warn(`Remote config is disabled. Falling back to local config.`);this.Er((e=>{if(!e)return sa.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Rr((e=>{this.Nr(e),this.Mr()}));this.Nr(e),this.Mr()}))}catch(e){sa.error(`Error loading remote config`,e)}}stop(){this.Or&&=(clearInterval(this.Or),void 0)}refresh(){this._instance.Fr()||j?.visibilityState===`hidden`||this._instance.reloadFeatureFlags()}Mr(){if(!this.Or){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.Or=setInterval((()=>{this.refresh()}),e))}}Nr(e){var t;e||sa.error(`Failed to fetch remote config from PostHog.`),this._instance.Nr(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},la={GZipJS:`gzip-js`,Base64:`base64`},ua=Uint8Array,X=Uint16Array,da=Uint32Array,fa=new ua([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),pa=new ua([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ma=new ua([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ha=function(e,t){for(var n=new X(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new da(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},ga=ha(fa,2),_a=ga[1];ga[0][28]=258,_a[258]=28;for(var va=ha(pa,0)[1],ya=new X(32768),Z=0;32768>Z;++Z){var ba=(43690&Z)>>>1|(21845&Z)<<1;ya[Z]=((65280&(ba=(61680&(ba=(52428&ba)>>>2|(13107&ba)<<2))>>>4|(3855&ba)<<4))>>>8|(255&ba)<<8)>>>1}var xa=function(e,t,n){for(var r=e.length,i=0,a=new X(t);r>i;++i)++a[e[i]-1];var o,s=new X(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new X(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[ya[d]>>>c]=l}else for(o=new X(r),i=0;r>i;++i)o[i]=ya[s[e[i]-1]++]>>>15-e[i];return o},Sa=new ua(288);for(Z=0;144>Z;++Z)Sa[Z]=8;for(Z=144;256>Z;++Z)Sa[Z]=9;for(Z=256;280>Z;++Z)Sa[Z]=7;for(Z=280;288>Z;++Z)Sa[Z]=8;var Ca=new ua(32);for(Z=0;32>Z;++Z)Ca[Z]=5;var wa=xa(Sa,9,0),Ta=xa(Ca,5,0),Ea=function(e){return(e/8>>0)+(7&e&&1)},Da=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof X?X:e instanceof da?da:ua)(n-t);return r.set(e.subarray(t,n)),r},Oa=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},ka=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Aa=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new ua(0),0];if(i==1){var o=new ua(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new X(f+1),m=ja(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var ee=a[r].s;t>p[ee]?h-=1<<t-p[ee]++-1:++r}for(;r>=0&&h;--r){var y=a[r].s;p[y]==t&&(--p[y],++h)}m=t}return[new ua(p),m]},ja=function(e,t,n){return e.s==-1?Math.max(ja(e.l,t,n+1),ja(e.r,t,n+1)):t[e.s]=n},Ma=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new X(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},Na=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Pa=function(e,t,n){var r=n.length,i=Ea(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},Fa=function(e,t,n,r,i,a,o,s,c,l,u){Oa(t,u++,n),++i[256];for(var d=Aa(i,15),f=d[0],p=d[1],m=Aa(a,15),h=m[0],g=m[1],_=Ma(f),v=_[0],ee=_[1],y=Ma(h),b=y[0],x=y[1],S=new X(19),C=0;v.length>C;++C)S[31&v[C]]++;for(C=0;b.length>C;++C)S[31&b[C]]++;for(var te=Aa(S,7),w=te[0],ne=te[1],T=19;T>4&&!w[ma[T-1]];--T);var re,E,ie,ae,D=l+5<<3,oe=Na(i,Sa)+Na(a,Ca)+o,se=Na(i,f)+Na(a,h)+o+14+3*T+Na(S,w)+(2*S[16]+3*S[17]+7*S[18]);if(oe>=D&&se>=D)return Pa(t,u,e.subarray(c,c+l));if(Oa(t,u,1+(oe>se)),u+=2,oe>se){re=xa(f,p,0),E=f,ie=xa(h,g,0),ae=h;var ce=xa(w,ne,0);for(Oa(t,u,ee-257),Oa(t,u+5,x-1),Oa(t,u+10,T-4),u+=14,C=0;T>C;++C)Oa(t,u+3*C,w[ma[C]]);u+=3*T;for(var le=[v,b],ue=0;2>ue;++ue){var de=le[ue];for(C=0;de.length>C;++C)Oa(t,u,ce[fe=31&de[C]]),u+=w[fe],fe>15&&(Oa(t,u,de[C]>>>5&127),u+=de[C]>>>12)}}else re=wa,E=Sa,ie=Ta,ae=Ca;for(C=0;s>C;++C)if(r[C]>255){var fe;ka(t,u,re[257+(fe=r[C]>>>18&31)]),u+=E[fe+257],fe>7&&(Oa(t,u,r[C]>>>23&31),u+=fa[fe]);var O=31&r[C];ka(t,u,ie[O]),u+=ae[O],O>3&&(ka(t,u,r[C]>>>5&8191),u+=pa[O])}else ka(t,u,re[r[C]]),u+=E[r[C]];return ka(t,u,re[256]),u+E[256]},Ia=new da([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),La=function(){for(var e=new da(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Ra=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function za(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=La[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new ua(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=Pa(c,l,e.subarray(u,d)):(c[u]=!0,l=Pa(c,l,e.subarray(u,o)))}else{for(var f=Ia[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new X(32768),_=new X(h+1),v=Math.ceil(n/3),ee=2*v,y=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<ee)&h},b=new da(25e3),x=new X(288),S=new X(32),C=0,te=0,w=(u=0,0),ne=0,T=0;o>u;++u){var re=y(u),E=32767&u,ie=_[re];if(g[E]=ie,_[re]=E,u>=ne){var ae=o-u;if((C>7e3||w>24576)&&ae>423){l=Fa(e,c,0,b,x,S,te,w,T,u-T,l),w=C=te=0,T=u;for(var D=0;286>D;++D)x[D]=0;for(D=0;30>D;++D)S[D]=0}var oe=2,se=0,ce=m,le=E-ie&32767;if(ae>2&&re==y(u-le))for(var ue=Math.min(p,ae)-1,de=Math.min(32767,u),fe=Math.min(258,ae);de>=le&&--ce&&E!=ie;){if(e[u+oe]==e[u+oe-le]){for(var O=0;fe>O&&e[u+O]==e[u+O-le];++O);if(O>oe){if(oe=O,se=le,O>ue)break;var pe=Math.min(le,O-2),me=0;for(D=0;pe>D;++D){var he=u-le+D+32768&32767,ge=he-g[he]+32768&32767;ge>me&&(me=ge,ie=he)}}}le+=(E=ie)-(ie=g[E])+32768&32767}if(se){b[w++]=268435456|_a[oe]<<18|va[se];var _e=31&_a[oe],ve=31&va[se];te+=fa[_e]+pa[ve],++x[257+_e],++S[ve],ne=u+oe,++C}else b[w++]=e[u],++x[e[u]]}}l=Fa(e,c,!0,b,x,S,te,w,T,u-T,l)}return Da(s,0,r+Ea(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Ra(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),Ra(l,u-8,n.d()),Ra(l,u-4,r),l}var Ba=!!Ee||!!Te,Va=`text/plain`,Ha=!1,Ua=function(e,t,n){n===void 0&&(n=!0);var[r,i]=e.split(`?`),a=P({},t),o=i?.split(`&`).map((e=>{var t,[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],r+`=`+o}))??[],s=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return G(e,(function(e,t){R(e)||R(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(a);return s&&o.push(s),r+`?`+o.join(`&`)},Wa=(e,t)=>JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t),Ga=e=>{if(e.tr)return e.tr;var{data:t,compression:n}=e;if(t){if(n===la.GZipJS){var r=za(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new ua(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new ua(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return Da(r,0,i)}(Wa(t)),{mtime:0});return{contentType:Va,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===la.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Wa(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(Wa(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=Wa(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},Ka=function(){var e=Me((function*(e){var t=yield function(e,t,n){return Pe.apply(this,arguments)}(Wa(e.data),N.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return P({},e,{tr:{contentType:Va,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),qa=(e,t)=>Ua(e,{_:new Date().getTime().toString(),ver:N.JS_SDK_VERSION,compression:t}),Ja=[];Te&&Ja.push({transport:`fetch`,method(e){var{contentType:t,body:n,estimatedSize:r}=Ga(e)??{},i=new Headers;G(e.headers,(function(e,t){i.append(t,e)})),t&&i.append(`Content-Type`,t);var a=e.url,o=null;if(De){var s=new De;o={signal:s.signal,timeout:setTimeout((()=>s.abort()),e.timeout)}}Te(a,P({method:e?.method||`GET`,headers:i,keepalive:e.method===`POST`&&52428.8>(r||0),body:n,signal:o?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){U.error(e)}e.callback==null||e.callback(r)})))).catch((t=>{U.error(t),e.callback==null||e.callback({statusCode:0,error:t})})).finally((()=>o?clearTimeout(o.timeout):null))}}),Ee&&Ja.push({transport:`XHR`,method(e){var t=new Ee;t.open(e.method||`GET`,e.url,!0);var{contentType:n,body:r}=Ga(e)??{};G(e.headers,(function(e,n){t.setRequestHeader(n,e)})),n&&t.setRequestHeader(`Content-Type`,n),e.timeout&&(t.timeout=e.timeout),e.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}e.callback==null||e.callback(n)}},t.send(r)}}),Ce!=null&&Ce.sendBeacon&&Ja.push({transport:`sendBeacon`,method(e){var t=Ua(e.url,{beacon:`1`});try{var{contentType:n,body:r}=Ga(e)??{};if(!r)return;var i=r instanceof Blob?r:new Blob([r],{type:n});Ce.sendBeacon(t,i)}catch{}}});var Ya=3e3,Xa=class{constructor(e,t){this.Pr=!0,this.Lr=[],this.Dr=it(t?.flush_interval_ms||Ya,250,5e3,U.createLogger(`flush interval`),Ya),this.Br=e}enqueue(e){this.Lr.push(e),this.jr||this.$r()}unload(){this.qr();var e=this.Lr.length>0?this.Zr():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Br(P({},e,{transport:`sendBeacon`}))}))}enable(){this.Pr=!1,this.$r()}$r(){var e=this;this.Pr||(this.jr=setTimeout((()=>{if(this.qr(),this.Lr.length>0){var t=this.Zr(),n=function(){var n=t[r],i=new Date().getTime();n.data&&I(n.data)&&G(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.Br(n)};for(var r in t)n()}}),this.Dr))}qr(){clearTimeout(this.jr),this.jr=void 0}Zr(){var e={};return G(this.Lr,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;R(e[i])&&(e[i]=P({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Lr=[],e}},Za=[`retriesPerformedSoFar`],Qa=class{constructor(e){this.Hr=!1,this.Vr=3e3,this.Lr=[],this._instance=e,this.Lr=[],this.zr=!0,!R(k)&&`onLine`in k.navigator&&(this.zr=k.navigator.onLine,this.Ur=()=>{this.zr=!0,this.Yr()},this.Gr=()=>{this.zr=!1},q(k,`online`,this.Ur),q(k,`offline`,this.Gr))}get length(){return this.Lr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=Ne(e,Za);Je(t)&&(n.url=Ua(n.url,{retry_count:t})),this._instance._send_request(P({},n,{callback:e=>{e.statusCode===200||e.statusCode>=400&&500>e.statusCode||(t??0)>=10?n.callback==null||n.callback(e):this.Wr(P({retriesPerformedSoFar:t},n))}}))}Wr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.Lr.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),U.warn(i),this.Hr||(this.Hr=!0,this.Xr())}Xr(){if(this.Jr&&clearTimeout(this.Jr),this.Lr.length===0)return this.Hr=!1,void(this.Jr=void 0);this.Jr=setTimeout((()=>{this.zr&&this.Lr.length>0&&this.Yr(),this.Xr()}),this.Vr)}Yr(){var e=Date.now(),t=[],n=this.Lr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Lr=t,n.length>0)for(var{requestOptions:r}of n)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Jr&&=(clearTimeout(this.Jr),void 0),this.Hr=!1,R(k)||(this.Ur&&=(k.removeEventListener(`online`,this.Ur),void 0),this.Gr&&=(k.removeEventListener(`offline`,this.Gr),void 0)),this.Lr))try{this._instance._send_request(P({},e,{transport:`sendBeacon`}))}catch(e){U.error(e)}this.Lr=[]}},$a=class{constructor(e){this.Kr=()=>{this.Qr||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.Qr.lastScrollY=Math.ceil(t),this.Qr.maxScrollY=Math.max(t,this.Qr.maxScrollY??0),this.Qr.maxScrollHeight=Math.max(n,this.Qr.maxScrollHeight??0),this.Qr.lastContentY=r,this.Qr.maxContentY=Math.max(r,this.Qr.maxContentY??0),this.Qr.maxContentHeight=Math.max(i,this.Qr.maxContentHeight??0)},this._instance=e}get ei(){return this._instance.config.scroll_root_selector}getContext(){return this.Qr}resetContext(){var e=this.Qr;return setTimeout(this.Kr,0),e}startMeasuringScrollPosition(){q(k,`scroll`,this.Kr,{capture:!0}),q(k,`scrollend`,this.Kr,{capture:!0}),q(k,`resize`,this.Kr)}scrollElement(){if(!this.ei)return k?.document.documentElement;for(var e of I(this.ei)?this.ei:[this.ei]){var t=k?.document.querySelector(e);if(t)return t}}scrollY(){if(this.ei){var e=this.scrollElement();return e&&e.scrollTop||0}return k&&(k.scrollY||k.pageYOffset||k.document.documentElement.scrollTop)||0}scrollX(){if(this.ei){var e=this.scrollElement();return e&&e.scrollLeft||0}return k&&(k.scrollX||k.pageXOffset||k.document.documentElement.scrollLeft)||0}},eo=e=>Ki(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties),to=class{constructor(e,t,n,r){this.ti=e=>{var t=this.ri();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.ii(this._instance)};this.ni.register({[Dr]:n})}},this._instance=e,this.si=t,this.ni=n,this.ii=r||eo,this.si.onSessionId(this.ti)}ri(){return this.ni.props[Dr]}getSetOnceProps(){var e=this.ri()?.props;return e?`r`in e?qi(e):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return G(ei(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+ze(n)]=t})),e}},no=class{constructor(){this.oi={}}on(e,t){return this.oi[e]||(this.oi[e]=[]),this.oi[e].push(t),()=>{this.oi[e]=this.oi[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.oi[e]||[])n(t);for(var r of this.oi[`*`]||[])r(e,t)}},ro=W(`[SessionId]`),io=class{on(e,t){return this.ai.on(e,t)}constructor(e,t,n){var r;if(this.li=[],this.ui=void 0,this.ai=new no,this.hi=(e,t)=>!(!Je(e)||!Je(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===Br)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Bt=e.config,this.ni=e.persistence,this.ci=void 0,this.di=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=t||li,this.fi=n||li;var i=this.Bt.persistence_name||this.Bt.token;if(this._sessionTimeoutMs=1e3*it(this.Bt.session_idle_timeout_seconds||1800,60,36e3,ro.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi=`ph_`+i+`_window_id`,this.mi=`ph_`+i+`_primary_window_exists`,this.yi()){var a=Y.Z(this.gi),o=Y.Z(this.mi);a&&!o?this.ci=a:Y.F(this.gi),Y.M(this.mi,!0)}if((r=this.Bt.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Bt.bootstrap.sessionID.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})();this.bi(this.Bt.bootstrap.sessionID,new Date().getTime(),s)}catch(e){ro.error(`Invalid sessionID in bootstrap`,e)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return R(this.li)&&(this.li=[]),this.li.push(e),this.di&&e(this.di,this.ci),()=>{this.li=this.li.filter((t=>t!==e))}}yi(){return this.Bt.persistence!==`memory`&&!this.ni.wr&&Y.R()}Ii(e){e!==this.ci&&(this.ci=e,this.yi()&&Y.M(this.gi,e))}Ci(){return this.ci?this.ci:this.yi()?Y.Z(this.gi):null}bi(e,t,n){e===this.di&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.di=e,this.ni.register({[sr]:[t,e,n]}))}Si(){var e=this.ni.props[sr];return I(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.bi(null,null,null)}destroy(){clearTimeout(this.xi),this.xi=void 0,this.ui&&k&&(k.removeEventListener(Gr,this.ui,{capture:!1}),this.ui=void 0),this.li=[]}wi(){this.ui=()=>{this.yi()&&Y.F(this.mi)},q(k,Gr,this.ui,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Bt.cookieless_mode===Br)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),[r,i,a]=this.Si(),o=this.Ci(),s=Je(a)&&Math.abs(n-a)>864e5,c=!1,l=!i,u=!l&&!e&&this.hi(n,r);l||u||s?(i=this.vi(),o=this.fi(),ro.info(`new session ID generated`,{sessionId:i,windowId:o,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}}),a=n,c=!0):o||(o=this.fi(),c=!0);var d=Je(r)&&e&&!s?r:n,f=Je(a)?a:new Date().getTime();return this.Ii(o),this.bi(i,d,f),e||this.pi(),c&&this.li.forEach((e=>e(i,o,c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0))),{sessionId:i,windowId:o,sessionStartTimestamp:f,changeReason:c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0,lastActivityTimestamp:r}}pi(){clearTimeout(this.xi),this.xi=setTimeout((()=>{var[e]=this.Si();if(this.hi(new Date().getTime(),e)){var t=this.di;this.resetSessionId(),this.ai.emit(`forcedIdleReset`,{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},ao=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Ie(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>Ie(e?.brand,t))))return!0}catch{}return!!e.webdriver},oo=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function so(e,t,n){return Wa({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var co={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>oo(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!oo(t,e))))),icontains:(e,t)=>t.map(lo).some((t=>e.map(lo).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(lo).every((t=>e.map(lo).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},lo=e=>e.toLowerCase();function uo(e,t){return!e||Object.entries(e).every((e=>{var[n,r]=e,i=t?.[n];if(R(i)||Ke(i))return!1;var a=[String(i)],o=co[r.operator];return!!o&&o(r.values,a)}))}var fo,po,mo=`custom`,ho=`i.posthog.com`,go=/^\/static\//,_o=class{constructor(e){this.ki={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+ho,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.ki[this.apiHost]||(this.ki[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:mo),this.ki[this.apiHost]}Ti(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof t==`string`&&go.test(e))return t.trim().replace(/\/$/,``)||void 0}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.uiHost+t;if(e===`flags`)return this.flagsApiHost+t;if(e===`assets`){var n=this.Ti(t);if(n)return``+n+t}if(this.region===mo)return this.apiHost+t;var r=ho+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+r;case`api`:return`https://`+this.region+`.`+r}}};fo===void 0&&(fo=e=>e()),po===void 0&&(po=console),po.log.bind(po),po.warn.bind(po),po.error.bind(po),po.debug.bind(po);var Q=W(`[Surveys]`),vo=`seenSurvey_`,yo=[$i.Popover,$i.Widget,$i.API],bo={ignoreConditions:!1,ignoreDelay:!1,displayType:na.Popover},xo=W(`[PostHog ExternalIntegrations]`),So={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},Co=class{constructor(e){this._instance=e}ur(e,t){var n;(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return xo.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var n,i,a;!r||(n=M.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[t]||e.ur(So[t],(()=>{var n;(n=M.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[t])==null||n.start(e._instance)})),!r&&(i=M.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[t]&&((a=M.__PosthogExtensions__)==null||(a=a.integrations)==null||(a=a[t])==null||a.stop())};for(var[n,r]of Object.entries((i=this._instance.config.integrations)??{})){var i;t(n)}}},wo,To={},Eo=0,Do=()=>{},Oo=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,ko=`Surveys module not available`,Ao=`sanitize_properties is deprecated. Use before_send instead`,jo=`Invalid value for property_denylist config: `,Mo=`posthog`,No=!Ba&&ke?.indexOf(`MSIE`)===-1&&ke?.indexOf(`Mozilla`)===-1,Po=e=>{var t;return P({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,token:``,autocapture:!0,cross_subdomain_cookie:ni(j?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:Do,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:we&&z(we?.search)&&we.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(k==null||(t=k.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){U.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ur,before_send:void 0,request_queue_config:{flush_interval_ms:Ya},error_tracking:{},_onCapture:Do,__preview_eager_load_replay:!1},(e=>({rageclick:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2025-11-30`?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},Fo=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],Io=e=>{var t={};for(var[n,r]of Fo)R(e[n])||(t[r]=e[n]);var i=K({},t,e);return I(e.property_blacklist)&&(R(e.property_denylist)?i.property_denylist=e.property_blacklist:I(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:U.error(jo+e.property_denylist)),i},Lo=class{constructor(){this.__forceAllowLocalhost=!1}get Ai(){return this.__forceAllowLocalhost}set Ai(e){U.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Ro=class e{Ei(e,t){if(e){var n=this.Ri.indexOf(e);n!==-1&&this.Ri.splice(n,1)}return this.Ri.push(t),t.initialize==null||t.initialize(),t}Ni(){return this.config.cookieless_mode===Br||this.config.cookieless_mode===zr&&this.consent.isRejected()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new Lo,this.Mi=!1,this.version=N.LIB_VERSION,this.Fi=new no,this.Ri=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Po(),this.SentryIntegration=Di,this.sentryIntegration=e=>function(e,t){var n=Ei(e,t);return{name:Ti,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Oi=!1,this.Pi=null,this.Li=null,this.Di=null,this.scrollManager=new $a(this),this.pageViewManager=new Oi(this),this.rateLimiter=new oa(this),this.requestRouter=new _o(this),this.consent=new yi(this),this.externalIntegrations=new Co(this);var t=e.__defaultExtensionClasses??{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,n)=>{var r=z(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=z(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>U.info(`send "`+e?.event+`"`,e)))}init(t,n,r){if(r&&r!==Mo){var i=To[r]??new e;return i._init(t,n,r),To[r]=i,To[Mo][r]=i,i}return this._init(t,n,r)}_init(e,t,n){var r;if(t===void 0&&(t={}),R(e)||Ge(e))return U.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`),this;this.__loaded=!0,this.config={},t.debug=this.Bi(t.debug),this.ji=t,this.$i=[],t.person_profiles?this.Li=t.person_profiles:t.process_person&&(this.Li=t.process_person),this.set_config(K({},Po(t.defaults),Io(t),{name:n,token:e})),this.config.on_xhr_error&&U.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:la.GZipJS;var i=this.qi();this.persistence=new Zi(this.config,i),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Zi(P({},this.config,{persistence:`sessionStorage`}),i);var a=P({},this.persistence.props),o=P({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zi=new Xa((e=>this.Hi(e)),this.config.request_queue_config),this.Vi=new Qa(this),this.__request_queue=[];var s=this.Ni();if(s||(this.sessionManager=new io(this),this.sessionPropsManager=new to(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(U.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.zi(s)}),0)):(U.info(`Initializing extensions synchronously`),this.zi(s)),N.DEBUG=N.DEBUG||this.config.debug,N.DEBUG&&U.info(`Starting in debug mode`,{this:this,config:t,thisC:P({},this.config),p:a,s:o}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=P({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),t.bootstrap?.distinctID!==void 0){var c=t.bootstrap.distinctID,l=this.get_distinct_id(),u=this.persistence.get_property(Er);if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===Vr)this.identify(c);else if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===Hr)U.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var d=this.config.get_device_id(li()),f=t.bootstrap.isIdentifiedID?d:c;this.persistence.set_property(Er,t.bootstrap.isIdentifiedID?Hr:Vr),this.register({distinct_id:c,$device_id:f})}}if(s)this.register_once({distinct_id:Pr,$device_id:null},``);else if(!this.get_distinct_id()){var p=this.config.get_device_id(li());this.register_once({distinct_id:p,$device_id:p},``),this.persistence.set_property(Er,Vr)}return q(k,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||li();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(Er,Hr)),t()},i=n.user();`then`in i&&Ue(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{Promise&&Promise.resolve||wi.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(wi.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(wi.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,Kr),identify:e=>t(e,Jr),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.Ui())):this.Ui(),Ue(this.config._onCapture)&&this.config._onCapture!==Do&&(U.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&U.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}zi(t){var n=performance.now(),r=P({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Ri.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Ri.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Ri.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Ri.push(new r.tracingHeaders(this)),r.siteApps&&this.Ri.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Ri.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Ri.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Ri.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Ri.push(this.logs=this.logs??new r.logs(this)),r.conversations&&this.Ri.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Ri.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Ri.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Ri.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Ri.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Ri.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,Si)),r.toolbar&&this.Ri.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Ri.push(this.experiments=this.experiments??new r.experiments(this)),this.Ri.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.Yi){var e=this.Yi;this.Yi=void 0,this.Nr(e)}})),this.Gi(i,n)}Gi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Gi(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){U.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({[Fr]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Ir]:r}),this.config.__preview_deferred_init_extensions&&U.info(`PostHog extensions initialized (`+r+`ms)`)}Nr(e){var t;if(!j||!j.body)return U.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Nr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Yi=e),this.Wi=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=F(e.supportedCompression,la.GZipJS)?la.GZipJS:F(e.supportedCompression,la.Base64)?la.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Li?this.Li:Ur}),this.Ri.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}Ui(){try{this.config.loaded(this)}catch(e){U.critical("`loaded` function failed",e)}if(this.Xi(),this.config.internal_or_test_user_hostname&&we!=null&&we.hostname){var e=we.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ni())&&this.Ji()}),1),this.Ki=new ca(this),this.Ki.load()}Xi(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Xr(this.__request_queue,(e=>this.Hi(e))),this.__request_queue=[],this.Xi()}_handle_unload(){var e,t,n,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Qi()&&this.capture(qr),(t=this.logs)==null||t.flushLogs(`sendBeacon`),(n=this.Zi)==null||n.unload(),(r=this.Vi)==null||r.unload()):this.Qi()&&this.capture(qr,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded&&(No?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ua(e.url,{ip:+!!this.config.ip}),e.headers=P({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=P({},e);t.timeout=t.timeout||6e4,t.url=qa(t.url,t.compression);var n=t.transport??`fetch`,r=Ja.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),i=function(e,t){for(var r=0;e.length>r;r++)if(e[r].transport===n)return e[r]}(r)?.method??r[0].method;if(!i)throw Error(`No available transport method`);n!==`sendBeacon`&&t.data&&t.compression===la.GZipJS&&Oe&&!Ha?Ka(t).then((e=>{i(e)})).catch((n=>{if((e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`)(n))return Ha=!0,void i(P({},t,{compression:void 0,url:qa(e.url,void 0)}));i(t)})):i(t)})(P({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))))}Hi(e){this.Vi?this.Vi.retriableRequest(e):this._send_request(e)}_execute_array(e){Eo++;try{var t,n=[],r=[],i=[];Xr(e,(e=>{e&&(I(t=e[0])?i.push(e):Ue(e)?e.call(this):I(e)&&t===`alias`?n.push(e):I(e)&&t.indexOf(`capture`)!==-1&&Ue(this[t])?i.push(e):r.push(e))}));var a=function(e,t){Xr(e,(function(e){if(I(e[0])){var n=t;G(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}))};a(n,this),a(r,this),a(i,this)}finally{Eo--}}push(t){if(Eo>0&&I(t)&&z(t[0])){var n=e.prototype[t[0]];Ue(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(e,t,n){var r,i,a,o;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zi){if(this.is_capturing())if(!R(e)&&z(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){t!=null&&t.$current_url&&!z(t?.$current_url)&&(U.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.en||U.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var l=new Date,u=n?.timestamp||l,d=li(),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===Kr&&this.config.__preview_capture_bot_pageviews&&s&&(f.event=`$bot_pageview`,f.properties.$browser_type=`bot`),c&&(f.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),n!=null&&n.$set&&(f.$set=n?.$set);var p,m,h,g=this.tn(n?.$set_once,e!==Yr,e===Jr);if(g&&(f.$set_once=g),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>z(e)?e.slice(0,r):e,o=new Set,f=function e(t,n){return t===Object(t)?o.has(t)?void 0:(o.add(t),I(t)?(r=[],Xr(t,(t=>{r.push(e(t))}))):(r={},G(t,((t,n)=>{o.has(t)||(r[n]=e(t,n))}))),r):a?a(t):t;var r}(i)),f.timestamp=u,R(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),e===ea.DISMISSED||e===ea.SENT){var _=t?.[ta.SURVEY_ID],v=t?.[ta.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>{var n=``+vo+t.id;return t.current_iteration&&t.current_iteration>0&&(n=``+vo+t.id+`_`+t.current_iteration),n})(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){Q.error(`Failed to persist survey seen state`,e)}})({id:_,current_iteration:v}),f.$set=P({},f.$set,{[(p={id:_,current_iteration:v},m=e===ea.SENT?`responded`:`dismissed`,h=`$survey_`+m+`/`+p.id,p.current_iteration&&p.current_iteration>0&&(h=`$survey_`+m+`/`+p.id+`/`+p.current_iteration),h)]:!0})}else e===ea.SHOWN&&(f.$set=P({},f.$set,{[ta.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===ra.SHOWN){var ee=t?.[ia.TOUR_TYPE];ee&&(f.$set=P({},f.$set,{[ia.TOUR_LAST_SEEN_DATE+`/`+ee]:new Date().toISOString()}))}var y=P({},f.properties.$set,f.$set);if(We(y)||this.setPersonPropertiesForFlags(y),!B(this.config.before_send)){var b=this.rn(f);if(!b)return;f=b}this.Fi.emit(`eventCaptured`,f);var x={method:`POST`,url:n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),data:f,compression:`best-available`,batchKey:n?._batchKey};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Hi(x):this.Zi.enqueue(x),f}U.critical(`This capture call is ignored due to client rate limiting.`)}}else U.error(`No event name provided to posthog.capture`)}else U.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}calculateEventProperties(e,t,n,r,i){if(n||=new Date,!this.persistence||!this.sessionPersistence)return t;var a=i?void 0:this.persistence.remove_event_timer(e),o=P({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.Ni()&&(o.$cookieless_mode=!0),e===`$snapshot`){var s=P({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=s.distinct_id,(!z(o.distinct_id)&&!qe(o.distinct_id)||Ge(o.distinct_id))&&U.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),o}var c,l=function(e,t){var n,r,i;if(!ke)return{};var a,o,s,c,l=e?[...Ii,...t||[]]:[],[u,d]=function(e){for(var t=0;tn.length>t;t++){var[n,r]=tn[t],i=n.exec(e),a=i&&(Ue(r)?r(i,e):r);if(a)return a}return[``,``]}(ke);return K(ei({$os:u,$os_version:d,$browser:Qt(ke,navigator.vendor),$device:nn(ke),$device_type:(o=ke,s={userAgentDataPlatform:(n=navigator)==null||(n=n.userAgentData)==null?void 0:n.platform,maxTouchPoints:navigator?.maxTouchPoints,screenWidth:k==null||(r=k.screen)==null?void 0:r.width,screenHeight:k==null||(i=k.screen)==null?void 0:i.height,devicePixelRatio:k?.devicePixelRatio},c=nn(o),c===mt||c===pt||c===`Kobo`||c===`Kindle Fire`||c===Wt?ft:c===Nt||c===Ft||c===Pt||c===Vt?`Console`:c===gt?`Wearable`:c?V:s?.userAgentDataPlatform===`Android`&&(s?.maxTouchPoints??0)>0?600>Math.min(s?.screenWidth??0,s?.screenHeight??0)/(s?.devicePixelRatio??1)?V:ft:`Desktop`),$timezone:Ji(),$timezone_offset:Yi()}),{$current_url:Ni(we?.href,l,Ri),$host:we?.host,$pathname:we?.pathname,$raw_user_agent:ke.length>1e3?ke.substring(0,997)+`...`:ke,$browser_version:en(ke,navigator.vendor),$browser_language:Ui(),$browser_language_prefix:(a=Ui(),typeof a==`string`?a.split(`-`)[0]:void 0),$screen_height:k?.screen.height,$screen_width:k?.screen.width,$viewport_height:k?.innerHeight,$viewport_width:k?.innerWidth,$lib:N.LIB_NAME,$lib_version:N.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:u,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime());o.$session_id=u,o.$window_id=d}this.sessionPropsManager&&K(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&K(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.Vi?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===mo&&(o.$lib_custom_api_host=this.config.api_host),c=e!==Kr||i?e!==qr||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=K(o,c),e===Kr&&j&&(o.title=j.title),!R(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}ke&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`),(o=K({},l,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),I(this.config.property_denylist)?G(this.config.property_denylist,(function(e){delete o[e]})):U.error(jo+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(U.error(Ao),o=p(o,e));var m=this.nn();return o.$process_person_profile=m,m&&!i&&this.sn(`_calculate_event_properties`),o}tn(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.nn()||this.Mi&&!n)return e;var r=K({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(U.error(Ao),r=i(r,`$set_once`)),t&&(this.Mi=!0),We(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}an(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.Fi.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:ko}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:ko})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:ko})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=bo),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:ko}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:ko})}ln(e){return!e||Ge(e)?(U.critical(`Unique user id has not been set in posthog.identify`),!1):e===Pr?(U.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(U.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return U.uninitializedWarning(`posthog.identify`);if(qe(e)&&(e=e.toString(),U.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.ln(e)&&this.sn(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Wn)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Gn)&&(this.unregister(Gn),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(Er)||Vr)===Vr;e!==r&&a?(this.persistence.set_property(Er,Hr),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(Jr,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.Di=so(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister(Sr))}}setPersonProperties(e,t){if((e||t)&&this.sn(`posthog.setPersonProperties`)){var n=so(this.get_distinct_id(),e,t);this.Di===n?U.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.Di=n)}}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:P({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(Yr,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else U.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.sn(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,n,r,i,a,o,s,c;if(U.info(`reset`),!this.__loaded)return U.uninitializedWarning(`posthog.reset`);var l=this.get_property(Wn);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),(r=this.surveys)==null||r.reset(),(i=this.Ki)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.conversations)==null||o.reset(),(s=this.persistence)==null||s.set_property(Er,Vr),(c=this.sessionManager)==null||c.resetSessionId(),this.Di=null,this.config.cookieless_mode===Br)this.register_once({distinct_id:Pr,$device_id:null},``);else{var u=this.config.get_device_id(li());this.register_once({distinct_id:u,$device_id:e?u:l},``)}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.un()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.hn()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(Un)?(U.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.sn(`posthog.alias`)?(R(t)&&(t=this.get_distinct_id()),e===t?(U.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.an(Gn,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=P({},this.config);if(L(e)){var n,r,i,a,o,s,c,l,u,d;K(this.config,Io(e));var f=this.qi();(n=this.persistence)==null||n.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Zi(P({},this.config,{persistence:`sessionStorage`}),f);var p=this.Bi(this.config.debug);Ye(p)&&(this.config.debug=p),Ye(this.config.debug)&&(this.config.debug?(N.DEBUG=!0,J.R()&&J.M(`ph_debug`,!0),U.info(`set_config`,{config:e,oldConfig:t,newConfig:P({},this.config)})):(N.DEBUG=!1,J.R()&&J.F(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.exceptions)==null||i.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(s=this.heatmaps)==null||s.startIfEnabled(),(c=this.exceptionObserver)==null||c.startIfEnabledOrStop(),(l=this.deadClicksAutocapture)==null||l.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.cn(),(d=this.externalIntegrations)==null||d.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){N.LIB_NAME=e,N.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(P({},r,t))}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??e.dn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??Mo;return e!==Mo&&(e=Mo+`.`+e),e}_isIdentified(){return this.persistence?.get_property(Er)===Hr||this.sessionPersistence?.get_property(Er)===Hr}nn(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===Ur&&!this._isIdentified()&&We(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Gn])&&((t=this.persistence)==null||(t=t.props)==null||!t[Mr]))}Qi(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.nn()||this.sn(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.sn(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}sn(e){return this.config.person_profiles===`never`?(U.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.an(Mr,!0),!0)}qi(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==zr)}cn(){var e,t,n=this.qi();return this.persistence?.wr!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.wr!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==Br){if(this.Ni()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new io(this),this.pageViewManager=new Oi(this),this.persistence&&(this.sessionPropsManager=new to(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.Ei(this.sessionRecording,new o(this)),this.Wi&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.Wi)))}var s;this.consent.optInOut(!0),this.cn(),this.Xi(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==zr&&((s=this.surveys)==null||s.loadIfEnabled()),(R(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ji()}else U.warn(Oo)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===Br?U.warn(Oo):(this.config.cookieless_mode===zr&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.cn(),this.config.cookieless_mode===zr&&(this.register({distinct_id:Pr,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.Ji()))}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===Br||(this.config.cookieless_mode===zr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.cn()}_is_bot(){return Ce?ao(Ce,this.config.custom_blocked_useragents):void 0}Ji(){j&&(j.visibilityState===`visible`?this.Oi||(this.Oi=!0,this.capture(Kr,{title:j.title},{send_instantly:!0}),this.Pi&&=(j.removeEventListener(Wr,this.Pi),null)):this.Pi||(this.Pi=this.Ji.bind(this),q(j,Wr,this.Pi)))}debug(e){!1===e?(k?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(k?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Fr(){var e,t,n,r,i,a,o=this.ji||{};return`advanced_disable_flags`in o?!!o.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(U.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):(n=`advanced_disable_decide`,r=U,i=(t=`advanced_disable_flags`)in(e=o)&&!B(e[t]),a=n in e&&!B(e[n]),i?e[t]:!!a&&(r&&r.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])):!!this.config.advanced_disable_flags}rn(e){if(B(this.config.before_send))return e;var t=I(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var r of t){if(n=r(n),B(n)){var i=`Event '`+e.event+`' was rejected in beforeSend function`;return Ze(e.event)?U.warn(i+`. This can cause unexpected behavior.`):U.info(i),null}n.properties&&!We(n.properties)||U.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}return n}getPageViewId(){return this.pageViewManager.dr?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Bi(e){var t=Ye(e)&&!e,n=J.R()&&J.O(`ph_debug`)===`true`;return!t&&(!!n||e)}};Ro.__defaultExtensionClasses={},Ro.dn={trace:wo=()=>{},debug:wo,info:wo,warn:wo,error:wo,fatal:wo},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=$r(e.prototype[t[n]])}(Ro,[`identify`]);var zo=1,Bo=3,Vo=11;function Ho(e){return e instanceof Element&&(e.id===Nr||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function Uo(e){return!!e&&e.nodeType===zo}function Wo(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Go(e){return!!e&&e.nodeType===Bo}function Ko(e){return!!e&&e.nodeType===Vo&&Uo(e.host)}function qo(e){return e?Re(e).split(/\s+/):[]}function Jo(e){var t=k?.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Yo(e){var t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return qo(t)}function Xo(e){return B(e)?null:Re(e).split(/(\s+)/).filter((e=>ms(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Zo(e){var t=``;return os(e)&&!ss(e)&&e.childNodes&&e.childNodes.length&&G(e.childNodes,(function(e){Go(e)&&e.textContent&&(t+=Xo(e.textContent)??``)})),Re(t)}function Qo(e){return R(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var $o=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function es(e,t){if(R(t))return!0;var n,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function ts(e){var t=e.parentNode;return!(!t||!Uo(t))&&t}var ns=[`next`,`previous`,`prev`,`>`,`<`],rs=[`.ph-no-rageclick`,`.ph-no-capture`],is=e=>!e||Wo(e,`html`)||!Uo(e),as=(e,t)=>{if(!k||is(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!Wo(i,`body`);)if(Ko(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=ts(i);if(!a)break;if(t||$o.indexOf(a.tagName.toLowerCase())>-1)n=!0;else{var o=k.getComputedStyle(a);o&&o.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}r.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:r}};function os(e){for(var t=e;t.parentNode&&!Wo(t,`body`);t=t.parentNode){var n=Yo(t);if(F(n,`ph-sensitive`)||F(n,`ph-no-capture`))return!1}if(F(Yo(e),`ph-include`))return!0;var r=e.type||``;if(z(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}var i=e.name||e.id||``;return!z(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function ss(e){return!!(Wo(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Wo(e,`select`)||Wo(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var cs=`(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})`,ls=RegExp(`^(?:`+cs+`)$`),us=new RegExp(cs),ds=`\\d{3}-?\\d{2}-?\\d{4}`,fs=RegExp(`^(`+ds+`)$`),ps=RegExp(`(`+ds+`)`);function ms(e,t){return t===void 0&&(t=!0),!(B(e)||z(e)&&(e=Re(e),(t?ls:us).test((e||``).replace(/[- ]/g,``))||(t?fs:ps).test(e)))}function hs(e){var t=Zo(e);return ms(t=(t+` `+gs(e)).trim())?t:``}function gs(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&G(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=Zo(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+gs(e)).trim())}catch(e){U.error(`[AutoCapture]`,e)}})),t}function _s(e){return e.replace(/"|\\"/g,`\\"`)}function vs(e){var t=e.attr__class;return t?I(t)?t:qo(t):void 0}var ys=class{constructor(e){this.disabled=!1===e;var t=L(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},bs=`$copy_autocapture`,xs=W(`[AutoCapture]`);function Ss(e,t){return t.length>e?t.slice(0,e)+`...`:t}function Cs(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!Uo(t));return t}function ws(e,t){var n,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:s}=t;if(!Uo(e))return{props:{}};for(var c=[e],l=e;l.parentNode&&!Wo(l,`body`);)if(Ko(l.parentNode))c.push(l.parentNode.host),l=l.parentNode.host;else{if(!Uo(l.parentNode))break;c.push(l.parentNode),l=l.parentNode}var u,d,f=[],p={},m=!1,h=!1;if(G(c,(e=>{var t=os(e);if(Wo(e,`a`)){var n=e.getAttribute(`href`);m=t&&!!n&&ms(n)&&n}F(Yo(e),`ph-no-capture`)&&(h=!0),f.push(function(e,t,n,r){var i=e.tagName.toLowerCase(),a={tag_name:i};$o.indexOf(i)>-1&&!n&&(a.$el_text=i.toLowerCase()===`a`||i.toLowerCase()===`button`?Ss(1024,hs(e)):Ss(1024,Zo(e)));var o=Yo(e);o.length>0&&(a.classes=o.filter((function(e){return e!==``}))),G(e.attributes,(function(n){var i;if((!ss(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&ms(n.value)&&(!z(i=n.name)||i.substring(0,10)!==`_ngcontent`&&i.substring(0,7)!==`_nghost`)){var o=n.value;n.name===`class`&&(o=qo(o).join(` `)),a[`attr__`+n.name]=Ss(1024,o)}}));for(var s=1,c=1,l=e;l=Cs(l);)s++,l.tagName===e.tagName&&c++;return a.nth_child=s,a.nth_of_type=c,a}(e,i,a,o)),K(p,function(e){if(!os(e))return{};var t={};return G(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&ms(r)&&(t[n]=r)}})),t}(e))})),h)return{props:{},explicitNoCapture:h};if(a||(f[0].$el_text=Wo(e,`a`)||Wo(e,`button`)?hs(e):Zo(e)),m){var g;f[0].attr__href=m;var _=ji(m)?.host,v=k==null||(g=k.location)==null?void 0:g.host;_&&v&&_!==v&&(u=m)}return{props:K({$event_type:r.type,$ce_version:1},s?{}:{$elements:f},{$elements_chain:(d=f,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=P({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return Zr(r).sort(((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)})).forEach((e=>{var[t,n]=e;return i[_s(t.toString())]=_s(n.toString())})),(t+=`:`)+Zr(i).map((e=>{var[t,n]=e;return t+`="`+n+`"`})).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:vs(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Zr(e).filter((e=>{var[t]=e;return t.indexOf(`attr__`)===0})).forEach((e=>{var[n,r]=e;return t.attributes[n]=r})),t}))}(d)))},(n=f[0])!=null&&n.$el_text?{$el_text:f[0]?.$el_text}:{},u&&r.type===`click`?{$external_click_url:u}:{},p)}}var Ts=W(`[ExceptionAutocapture]`);function Es(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return Ue(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var Ds=W(`[TracingHeaders]`),Os=W(`[Web Vitals]`),ks=9e5,As=`disabled`,js=`lazy_loading`,Ms=`awaiting_config`,Ns=`missing_config`;W(`[SessionRecording]`),W(`[SessionRecording]`);var Ps=`[SessionRecording]`,Fs=W(Ps),Is=W(`[Heatmaps]`);function Ls(e){return L(e)&&`clientX`in e&&`clientY`in e&&qe(e.clientX)&&qe(e.clientY)}var Rs=W(`[Product Tours]`),zs=[`$set_once`,`$set`],Bs=W(`[SiteApps]`),Vs=`Error while initializing PostHog app with config id `;function Hs(e,t,n){if(B(e))return!1;switch(n){case`exact`:return e===t;case`contains`:var r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(r,`i`).test(e);case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Us=class{constructor(e){this.vn=new no,this.fn=(e,t)=>this.pn(e,t)&&this.gn(e,t)&&this.mn(e,t)&&this.yn(e,t),this.pn=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.bn=new Set,this.wn=new Set}init(){var e;R(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!R(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.wn)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.bn)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.bn.has(e)||this.bn.has(t?.event))&&this.wn&&this.wn?.size>0&&this.wn.forEach((e=>{this._n(t,e)&&this.vn.emit(`actionCaptured`,e.name)}))}In(e){this.onAction(`actionCaptured`,(t=>e(t)))}_n(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.fn(e,n))return!0;return!1}onAction(e,t){return this.vn.on(e,t)}gn(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!Hs(r,t.url,t.url_matching||`contains`))return!1}return!0}mn(e,t){return!!this.Cn(e,t)&&!!this.Sn(e,t)&&!!this.xn(e,t)}Cn(e,t){var n;if(t==null||!t.href)return!0;var r=this.kn(e);if(r.length>0)return r.some((e=>Hs(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&Hs((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}Sn(e,t){var n;if(t==null||!t.text)return!0;var r=this.kn(e);if(r.length>0)return r.some((e=>Hs(e.text,t.text,t.text_matching||`exact`)||Hs(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!B(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>Hs(e,a,o))))}xn(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}kn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}yn(e,t){return t==null||!t.properties||t.properties.length===0||uo(t.properties.reduce(((e,t)=>{var n=I(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},Ws=class{constructor(e){this._instance=e,this.Tn=new Map,this.An=new Map,this.En=new Map}Rn(e,t){return!!e&&uo(e.propertyFilters,t?.properties)}Nn(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}Mn(e,t,n){var r=(n===Qi.Activation?this.Tn:this.An).get(e),i=[];return this.Fn((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.Rn(a,t)}))}register(e){R(this._instance?._addCaptureHook)||(this.On(e),this.Pn(e))}Pn(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.Ln??(this.Ln=new Us(this._instance),this.Ln.init(),this.Ln.In((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.Ln)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.En.get(t.name);n&&n.push(e.id),this.En.set(t.name,n||[e.id])}})))})))}On(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this.Tn=this.Nn(e,Qi.Activation),this.An=this.Nn(e,Qi.Cancellation))}onEvent(e,t){var n,r=this.le(),i=this.Dn(),a=this.Bn(),o=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[i])||[];if(a===e&&t&&o.length>0){var s,c;r.info(`event matched, removing item from activated items`,{event:e,eventPayload:t,existingActivatedItems:o});var l=(t==null||(s=t.properties)==null?void 0:s.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(l){var u=o.indexOf(l);0>u||(o.splice(u,1),this.jn(o))}}else{if(this.An.has(e)){var d=this.Mn(e,t,Qi.Cancellation);d.length>0&&(r.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:d.map((e=>e.id))}),d.forEach((e=>{var t=o.indexOf(e.id);0>t||o.splice(t,1),this.$n(e.id)})),this.jn(o))}if(this.Tn.has(e)){r.info(`event name matched`,{event:e,eventPayload:t,items:this.Tn.get(e)});var f=this.Mn(e,t,Qi.Activation);this.jn(o.concat(f.map((e=>e.id))||[]))}}}onAction(e){var t,n=this.Dn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[];this.En.has(e)&&this.jn(r.concat(this.En.get(e)||[]))}jn(e){var t=this.le(),n=[...new Set(e)].filter((e=>!this.qn(e)));t.info(`updating activated items`,{activatedItems:n}),this.Zn(n)}getActivatedIds(){var e,t=this.Dn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.Tn}Hn(){return this.Ln}},Gs=class extends Ws{constructor(e){super(e)}Dn(){return br}Bn(){return ea.SHOWN}Fn(e){var t;(t=this._instance)==null||t.getSurveys(e)}$n(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}le(){return Q}Zn(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[br]:e})}qn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ks=`SDK is not enabled or survey functionality is not yet loaded`,qs=`Disabled. Not loading surveys.`,Js=k!=null&&k.location?Pi(k.location.hash,`__posthog`)||Pi(location.hash,`state`):null,Ys=`_postHogToolbarParams`,Xs=W(`[Toolbar]`),$=W(`[FeatureFlags]`),Zs=W(`[FeatureFlags]`,{debugEnabled:!0}),Qs=`" failed. Feature flags didn't load in time.`,$s=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},ec=e=>{var t={};for(var[n,r]of Zr(e||{}))r&&(t[n]=r);return t},tc=W(`[Error tracking]`),nc=`Refusing to render web experiment since the viewer is a likely bot`,rc={icontains:(e,t)=>!!k&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!k&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!k&&oo(t.href,e),not_regex:(e,t)=>!!k&&!oo(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e},ic=class e{get Bt(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.Vn(`retrieved web experiments from the server`),n.zn=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.zn&&(e.Vn(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.zn)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);z(i)&&t.variants[i]&&n.Un(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.Yn(o)&&n.Un(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Vn(nc);else if(!this.Bt.disable_web_experiments){if(B(this.zn))return this.zn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Vn(`applying feature flags`,t),t.forEach((e=>{var t;if(this.zn&&(t=this.zn)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.zn?.get(e);n&&r!=null&&r.variants[n]&&this.Un(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=Mi(t?.search,`__experiment_id`),r=Mi(t?.search,`__experiment_variant`);n&&r&&(e.Vn(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.Gn(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Bt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Bt.disable_web_experiments&&!n)return e([]);var r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=`+this.Bt.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Gn(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.Vn(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.Un(i[0].name,n,i[0].variants[n].transforms))}static Yn(t){return!B(t.conditions)&&e.Wn(t)&&e.Xn(t)}static Wn(t){if(B(t.conditions)||B(t.conditions?.url))return!0;var n,r=e.getWindowLocation();return!!r&&((n=t.conditions)==null||!n.url||rc[t.conditions?.urlMatchType??`icontains`](t.conditions.url,r))}static getWindowLocation(){return k?.location}static Xn(e){if(B(e.conditions)||B(e.conditions?.utm))return!0;var t=Bi();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static Vn(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];U.info(`[WebExperiments] `+e,n)}Un(t,n,r){this._is_bot()?e.Vn(nc):n===`control`?e.Vn(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.Vn(`applying transform of variant `+n+` for experiment `+t+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return Ce&&this._instance?ao(Ce,this.Bt.custom_blocked_useragents):void 0}},ac=W(`[Conversations]`),oc=`Conversations not available yet.`,sc={featureFlags:class{constructor(e){this.Jn=!1,this.Kn=!1,this.Qn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=e,this.featureFlagEventHandlers=[]}get Bt(){return this._instance.config}get ni(){return this._instance.persistence}os(e){return this._instance.get_property(e)}ls(){var e;return(e=this.ni?._r(this.Bt.feature_flag_cache_ttl_ms))!=null&&e}us(){return!!this.ls()&&(this.ss||this.Qn||(this.ss=!0,$.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}hs(){var e=this.Bt.evaluation_contexts??this.Bt.evaluation_environments;return!this.Bt.evaluation_environments||this.Bt.evaluation_contexts||this.ns||($.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.ns=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||$.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}cs(){return this.hs().length>0}initialize(){var{config:e}=this._instance,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(n[t]&&(e[t]=n[t]),e)),{});this.receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r=n!=null&&n.merge?this.getFlagVariants():{},i=n!=null&&n.merge?this.getFlagPayloads():{},a=P({},r,e),o=P({},i,t),s={};for(var[c,l]of Object.entries(a)){var u=typeof l==`string`;s[c]={key:c,enabled:!!u||!!l,variant:u?l:void 0,reason:void 0,metadata:R(o?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:o[c]}}}this.receivedFeatureFlags({flags:s})}get hasLoadedFlags(){return this.Kn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.os(fr),t=this.os(hr),n=this.os(gr);if(!n&&!t)return e||{};var r=K({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=R(c)?(a=s?.enabled)!=null&&a:!!c,u=R(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=P({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=P({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.Jn||=($.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getFlagVariants(){var e=this.os(lr),t=this.os(hr);if(!t)return e||{};for(var n=K({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Jn||=($.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.os(pr),t=this.os(gr);if(!t)return e||{};for(var n=K({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Jn||=($.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.es||this.Bt.advanced_disable_feature_flags||this.ds||(this._instance.Fi.emit(`featureFlagsReloading`,!0),this.ds=setTimeout((()=>{this.vs()}),5))}fs(){clearTimeout(this.ds),this.ds=void 0}ensureFlagsLoaded(){this.Kn||this.Qn||this.ds||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.es=e}vs(e){if(this.fs(),!this._instance.Fr())if(this.Qn)this.ts=!0;else{var t=this.Bt.token,n=this.os(Wn),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:P({},this.ni?.get_initial_props()||{},this.os(_r)||{}),group_properties:this.os(vr),timezone:Ji()};Ke(n)||R(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Bt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.cs()&&(r.evaluation_contexts=this.hs());var i=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Bt.advanced_only_evaluate_survey_feature_flags?`&only_evaluate_survey_feature_flags=true`:``));this.Qn=!0,this._instance._send_request({method:`POST`,url:i,data:r,compression:this.Bt.disable_compression?void 0:la.Base64,timeout:this.Bt.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,a=!0;if(e.statusCode===200&&(this.ts||(this.$anon_distinct_id=void 0),a=!1),this.Qn=!1,!r.disable_flags||this.ts){this.rs=!a;var o=[];e.error?e.error instanceof Error?o.push(e.error.name===`AbortError`?`timeout`:`connection_error`):o.push(`unknown_error`):e.statusCode!==200&&o.push(`api_error_`+e.statusCode),(t=e.json)!=null&&t.errorsWhileComputingFlags&&o.push(`errors_while_computing_flags`);var s=!((n=e.json)==null||(n=n.quotaLimited)==null||!n.includes(`feature_flags`));s&&o.push(`quota_limited`),(i=this.ni)==null||i.register({[wr]:o}),s?$.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.`):(r.disable_flags||this.receivedFeatureFlags(e.json??{},a,{partialResponse:!!this.Bt.advanced_only_evaluate_survey_feature_flags}),this.ts&&(this.ts=!1,this.vs()))}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs)if(this.Kn||this.getFlags()&&this.getFlags().length>0){if(!this.us()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else $.warn(`getFeatureFlag for key "`+e+Qs)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs)if(this.Kn||this.getFlags()&&this.getFlags().length>0){if(!this.us()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.os(mr)||void 0,c=this.os(Tr)||void 0,l=this.os(Sr)||{};if(this.Bt.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.os(Cr);d&&d!==f&&(l={},(u=this.ni)==null||u.register({[Sr]:l,[Cr]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,ee,y;I(l[e])?l[e].push(o):l[e]=[o],(p=this.ni)==null||p.register({[Sr]:l});var b=this.getFeatureFlagDetails(e),x=[...this.os(wr)??[]];R(i)&&x.push(`flag_missing`);var S={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((m=this.Bt.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Bt.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.rs};R(b==null||(g=b.metadata)==null?void 0:g.version)||(S.$feature_flag_version=b.metadata.version);var C,te=(b==null||(_=b.reason)==null?void 0:_.description)??(b==null||(v=b.reason)==null?void 0:v.code);te&&(S.$feature_flag_reason=te),b!=null&&(ee=b.metadata)!=null&&ee.id&&(S.$feature_flag_id=b.metadata.id),R(b?.original_variant)&&R(b?.original_enabled)||(S.$feature_flag_original_response=R(b.original_variant)?b.original_enabled:b.original_variant),b!=null&&(y=b.metadata)!=null&&y.original_payload&&(S.$feature_flag_original_payload=b==null||(C=b.metadata)==null?void 0:C.original_payload),x.length&&(S.$feature_flag_error=x.join(`,`)),this._instance.capture(`$feature_flag_called`,S)}if(r){var w=a;if(!R(a))try{w=JSON.parse(a)}catch{}return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:w}}}}else $.warn(`getFeatureFlagResult for key "`+e+Qs)}getRemoteConfigPayload(e,t){var n=this.Bt.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.cs()&&(r.evaluation_contexts=this.hs()),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Bt.disable_compression?void 0:la.Base64,timeout:this.Bt.feature_flag_request_timeout_ms,callback(n){var r=n.json?.featureFlagPayloads;t(r?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs){if(this.Kn||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return R(n)?void 0:!!n}$.warn(`isFeatureEnabled for key "`+e+Qs)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.ni){this.Kn=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),a=this.getFlagsWithDetails();(function(e,t,n,r,i,a){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var o=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>[e,t[e].variant??t[e].enabled]))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>t[e].metadata?.payload)).map((e=>[e,t[e].metadata?.payload])))):$.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(I(c)){$.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;t&&t.register({[ur]:c,[lr]:f})}else{var m=c,h=l,g=s;if(a!=null&&a.partialResponse)m=P({},n,m),h=P({},r,h),g=P({},i,g);else if(e.errorsWhileComputingFlags)if(s){var _=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=P({},n,Object.fromEntries(Object.entries(m).filter((e=>{var[t]=e;return _.has(t)})))),h=P({},r,Object.fromEntries(Object.entries(h||{}).filter((e=>{var[t]=e;return _.has(t)})))),g=P({},i,Object.fromEntries(Object.entries(g||{}).filter((e=>{var[t]=e;return _.has(t)}))))}else m=P({},n,m),h=P({},r,h),g=P({},i,g);t&&t.register(P({[ur]:Object.keys(ec(m)),[lr]:m||{},[pr]:h||{},[fr]:g||{}},u?{[mr]:u}:{},d?{[Tr]:d}:{}))}}})(e,this.ni,r,i,a,n),t||(this.ss=!1),this.ps(t)}}override(e,t){t===void 0&&(t=!1),$.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.ni)return $.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.ni.unregister(hr),this.ni.unregister(gr),this.ps(),Zs.info(`All overrides cleared`);if(I(e)){var t=$s(e);return this.ni.register({[hr]:t}),this.ps(),Zs.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Jn=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.ni.unregister(hr),Zs.info(`Flag overrides cleared`);else if(r.flags){if(I(r.flags)){var i=$s(r.flags);this.ni.register({[hr]:i})}else this.ni.register({[hr]:r.flags});Zs.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.ni.unregister(gr),Zs.info(`Payload overrides cleared`)):r.payloads&&(this.ni.register({[gr]:r.payloads}),Zs.info(`Payload overrides set`,{payloads:r.payloads}))),this.ps();return}if(e&&typeof e==`object`)return this.ni.register({[hr]:e}),this.ps(),Zs.info(`Flag overrides set`,{flags:e});$.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Kn){var{flags:t,flagVariants:n}=this.gs();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.os(dr)||[]).find((t=>t.flagKey===e)),a={[`$feature_enrollment/`+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture(`$feature_enrollment_update`,o),this.setPersonPropertiesForFlags(a,!1);var s=P({},this.getFlagVariants(),{[e]:t});(r=this.ni)==null||r.register({[ur]:Object.keys(ec(s)),[lr]:s}),this.ps()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.os(dr),i=n?`&`+n.map((e=>`stage=`+e)).join(`&`):``;if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/early_access_features/?token=`+this.Bt.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.ni)==null||n.unregister(dr),(r=this.ni)==null||r.register({[dr]:i}),e(i)}}})}gs(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}ps(e){var{flags:t,flagVariants:n}=this.gs();this.featureFlagEventHandlers.forEach((r=>r(t,n,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.os(_r)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this._instance.register({[_r]:P({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(_r)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.os(vr)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=P({},n[t],e[t]),delete e[t]})),this._instance.register({[vr]:P({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.os(vr)||{};this._instance.register({[vr]:P({},t,{[e]:{}})})}else this._instance.unregister(vr)}reset(){this.Kn=!1,this.Qn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.fs(),this.Jn=!1}}},cc={sessionRecording:class{get Bt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var e;return!((e=this.ys)==null||!e.isStarted)}get status(){return this.bs===Ms||this.bs===Ns?this.bs:this.ys?.status??this.bs}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.bs=As,this.ws=void 0,this._instance=e,!this._instance.sessionManager)throw Fs.error(`started without valid sessionManager`),Error(Ps+` started without valid sessionManager. This is a bug.`);if(this.Bt.cookieless_mode===Br)throw Error(Ps+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get _s(){var e,t=!((e=this._instance.get_property(nr))==null||!e.enabled),n=!this.Bt.disable_session_recording,r=this.Bt.disable_session_recording||this._instance.consent.isOptedOut();return k&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this._s||(t=this.ys)==null||!t.isStarted){var n=!R(Object.assign)&&!R(Array.from);this._s&&n?(this.Is(e),Fs.info(`starting`)):(this.bs=As,this.stopRecording())}}Is(e){var t,n,r;this._s&&(this.bs!==Ms&&this.bs!==Ns&&(this.bs=js),M!=null&&(t=M.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=M.__PosthogExtensions__)!=null&&n.initSessionRecording?this.Cs(e):(r=M.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.Ss,(t=>{if(t)return Fs.error(`could not load recorder`,t);this.Cs(e)})))}stopRecording(){var e,t;(e=this.ws)==null||e.call(this),this.ws=void 0,(t=this.ys)==null||t.stop()}xs(){var e,t;(e=this.ws)==null||e.call(this),this.ws=void 0,(t=this.ys)==null||t.discard()}ks(){var e;(e=this.ni)==null||e.unregister(cr)}Ts(e,t){if(B(e))return null;var n,r=qe(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(Fs.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}As(e){if(this.ni){var t,n=this.ni,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.Ts(this.Bt.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.Ts(t?.sampleRate,`remote config sampleRate`),a=r??i;B(a)&&this.ks();var o=t?.minimumDurationMilliseconds;n.register({[nr]:P({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:P({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:R(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.ws)==null||t.call(this),this.ws=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this.As(e),this.xs()):(this.As(e),this.startIfEnabledOrStop()):(this.bs===Ms&&(this.bs=Ns,Fs.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.ys)!=null&&n.log?this.ys.log(e,t):Fs.warn(`log called before recorder was ready`)}get Ss(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(nr);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}Es(){var e=this._instance.get_property(nr);if(!e)return!1;var t=(typeof e==`object`?e:JSON.parse(e)).cache_timestamp??Date.now();return 36e5>=Date.now()-t}Cs(e){var t;if((t=M.__PosthogExtensions__)==null||!t.initSessionRecording)return Fs.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Lr]:!0});if(this.ys||(this.ys=M.__PosthogExtensions__?.initSessionRecording(this._instance),this.ys._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Es()){if(this.bs===Ns||this.bs===Ms)return;this.bs=Ms,Fs.info(`persisted remote config is stale, requesting fresh config before starting`),new ca(this._instance).load();return}this.bs=js,this.ys.start(e)}onRRwebEmit(e){var t;(t=this.ys)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.ys||(t=this.ni)==null||t.register({[ir]:!0}),(e=this.ys)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.ys||(t=this.ni)==null||t.register({[rr]:!0}),(e=this.ys)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.ys||(n=this.ni)==null||n.register({[e===`url`?ar:or]:!0}),(t=this.ys)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.ys?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.ys)==null||!n.tryAddCustomEvent(e,t))}}},lc={autocapture:class{constructor(e){this.Rs=!1,this.Ns=null,this.Ms=!1,this.instance=e,this.rageclicks=new ys(e.config.rageclick),this.Fs=null}initialize(){this.startIfEnabled()}get Bt(){var e=L(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}Os(){if(this.isBrowserSupported()){if(k&&j){var e=e=>{e||=k?.event;try{this.Ps(e)}catch(e){xs.error(`Failed to capture event`,e)}};if(q(j,`submit`,e,{capture:!0}),q(j,`change`,e,{capture:!0}),q(j,`click`,e,{capture:!0}),this.Bt.capture_copied_text){var t=e=>{e||=k?.event;try{this.Ps(e,bs)}catch(e){xs.error(`Failed to capture copy/cut event`,e)}};q(j,`copy`,t,{capture:!0}),q(j,`cut`,t,{capture:!0})}}}else xs.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.Rs&&(this.Os(),this.Rs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.Ms=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[qn]:!!e.autocapture_opt_out}),this.Ns=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.Fs=e}getElementSelectors(e){var t,n=[];return(t=this.Fs)==null||t.forEach((t=>{(j?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[qn];if(Ke(this.Ns)&&!Ye(e)&&!this.instance.Fr())return!1;var t=this.Ns??!!e;return!!this.instance.config.autocapture&&!t}Ps(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=Qo(e);Go(r)&&(r=r.parentNode||null),t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&function(e,t){if(!k||is(e))return!1;var n,r;if(Ye(t)?(n=!!t&&rs,r=void 0):(n=t?.css_selector_ignorelist??rs,r=t?.content_ignorelist),!1===n)return!1;var{targetElementList:i}=as(e,!1);return!function(e,t){if(!1===e||R(e))return!1;var n;if(!0===e)n=ns;else{if(!I(e))return!1;if(e.length>10)return U.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:r}=e;return n.some((e=>t.includes(e)||r.includes(e)))}))}(r,i.map((e=>({safeText:Zo(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!es(i,n)}(r,this.instance.config.rageclick)&&this.Ps(e,`$rageclick`);var i=t===bs;if(r&&function(e,t,n,r,i){var a,o,s;if(n===void 0&&(n=void 0),!k||is(e)||(a=n)!=null&&a.url_allowlist&&!Jo(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&Jo(n.url_ignorelist))return!1;if((s=n)!=null&&s.dom_event_allowlist){var c=n.dom_event_allowlist;if(c&&!c.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:l,targetElementList:u}=as(e,r);if(!function(e,t){var n=t?.element_allowlist;if(R(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(u,n)||!es(u,n?.css_selector_allowlist))return!1;var d=k.getComputedStyle(e);if(d&&d.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0;var f=e.tagName.toLowerCase();switch(f){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return l?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&($o.indexOf(f)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.Bt,i,i?[`copy`,`cut`]:void 0)){var{props:a,explicitNoCapture:o}=ws(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Bt.element_attribute_ignorelist,elementsChainAsString:this.Ms});if(o)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(a.$element_selectors=s),t===bs){var c,l=Xo(k==null||(c=k.getSelection())==null?void 0:c.toString()),u=e.type||`clipboard`;if(!l)return!1;a.$selected_content=l,a.$copy_type=u}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return Ue(j?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.Ls=(k==null||(t=k.location)==null?void 0:t.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(U.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.Ds&&this.Ds(),this.Ds=void 0,U.info(`History API monitoring stopped`)}monitorHistoryChanges(){var e,t;if(k&&k.history){var n=this;(e=k.history.pushState)!=null&&e.__posthog_wrapped__||Es(k.history,`pushState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Bs(`pushState`)})),(t=k.history.replaceState)!=null&&t.__posthog_wrapped__||Es(k.history,`replaceState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Bs(`replaceState`)})),this.js()}}Bs(e){try{var t,n=k==null||(t=k.location)==null?void 0:t.pathname;if(!n)return;n!==this.Ls&&this.isEnabled&&this._instance.capture(Kr,{navigation_type:e}),this.Ls=n}catch(t){U.error(`Error capturing `+e+` pageview`,t)}}js(){if(!this.Ds){var e=()=>{this.Bs(`popstate`)};q(k,`popstate`,e),this.Ds=()=>{k&&k.removeEventListener(`popstate`,e)}}}},heatmaps:class{get Bt(){return this.instance.config}constructor(e){var t;this.$s=!1,this.Rs=!1,this.qs=null,this.instance=e,this.$s=!((t=this.instance.persistence)==null||!t.props[Jn]),this.rageclicks=new ys(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return L(this.Bt.capture_heatmaps)&&this.Bt.capture_heatmaps.flush_interval_milliseconds&&(e=this.Bt.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return B(this.Bt.capture_heatmaps)?B(this.Bt.enable_heatmaps)?this.$s:this.Bt.enable_heatmaps:!1!==this.Bt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Rs)return;Is.info(`starting...`),this.Zs(),this.Lt()}else clearInterval(this.qs??void 0),this.Hs(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Jn]:t}),this.$s=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.T;return this.T=void 0,e}Vs(e){this.Tt(e.originalEvent,`deadclick`)}Lt(){this.qs&&clearInterval(this.qs),this.qs=j?.visibilityState===`visible`?setInterval(this.Yr.bind(this),this.flushIntervalMilliseconds):null}Zs(){k&&j&&(this.zs=this.Yr.bind(this),q(k,Gr,this.zs),this.Us=e=>this.Tt(e||k?.event),q(j,`click`,this.Us,{capture:!0}),this.Ys=e=>this.Gs(e||k?.event),q(j,`mousemove`,this.Ys,{capture:!0}),this.Ws=new Ci(this.instance,xi,this.Vs.bind(this)),this.Ws.startIfEnabledOrStop(),this.Xs=this.Lt.bind(this),q(j,Wr,this.Xs),this.Rs=!0)}Hs(){var e;k&&j&&(this.zs&&k.removeEventListener(Gr,this.zs),this.Us&&j.removeEventListener(`click`,this.Us,{capture:!0}),this.Ys&&j.removeEventListener(`mousemove`,this.Ys,{capture:!0}),this.Xs&&j.removeEventListener(Wr,this.Xs),clearTimeout(this.Js),(e=this.Ws)==null||e.stop(),this.Rs=!1)}Ks(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){for(var r=e;r&&Uo(r)&&!Wo(r,`body`);){if(r===n)return!1;if(F(t,k?.getComputedStyle(r).position))return!0;r=ts(r)}return!1}(Qo(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}Tt(e,t){var n;if(t===void 0&&(t=`click`),!Ho(e.target)&&Ls(e)){var r=this.Ks(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Qs(P({},r,{type:`rageclick`})),this.Qs(r)}}Gs(e){!Ho(e.target)&&Ls(e)&&(clearTimeout(this.Js),this.Js=setTimeout((()=>{this.Qs(this.Ks(e,`mousemove`))}),500))}Qs(e){if(k){var t=k.location.href,n=this.Bt.custom_personal_data_properties,r=Ni(t,this.Bt.mask_personal_data_properties?[...Ii,...n||[]]:[],Ri);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(e)}}Yr(){this.T&&!We(this.T)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Ci,webVitalsAutocapture:class{constructor(e){var t;this.$s=!1,this.Rs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.eo=()=>{clearTimeout(this.ro),this.T.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.T.metrics.reduce(((e,t)=>P({},e,{[`$web_vitals_`+t.name+`_event`]:P({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=e=>{var t=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0);if(R(t))Os.error(`Could not read session ID. Dropping metrics!`);else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.io();R(n)||(B(e?.name)||B(e?.value)?Os.error(`Invalid metric received`,e):!this.no||this.no>e.value?(this.T.url!==n&&(this.eo(),this.ro=setTimeout(this.eo,this.flushToCaptureTimeoutMs)),R(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=R(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.T.metrics.push(P({},e,{$current_url:n,$session_id:t.sessionId,$window_id:t.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.eo()):Os.error(`Ignoring metric with value >= `+this.no,e))}},this.so=()=>{if(!this.Rs){var e,t,n,r,i=M.__PosthogExtensions__;R(i)||R(i.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:n,onINP:r}=i.postHogWebVitalsCallbacks),e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.ht.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.ht.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.ht.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.ht.bind(this)),this.Rs=!0):Os.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.$s=!((t=this._instance.persistence)==null||!t.props[Qn]),this.startIfEnabled()}get oo(){return this._instance.config.capture_performance}get allowedMetrics(){var e=L(this.oo)?this.oo?.web_vitals_allowed_metrics:void 0;return B(e)?this._instance.persistence?.props[tr]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(L(this.oo)?this.oo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=L(this.oo)?this.oo.web_vitals_attribution:void 0;return e!=null&&e}get no(){var e=L(this.oo)&&qe(this.oo.__web_vitals_max_value)?this.oo.__web_vitals_max_value:ks;return e>0&&6e4>=e?ks:e}get isEnabled(){var e=we?.protocol;if(e!==`http:`&&e!==`https:`)return Os.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=L(this.oo)?this.oo.web_vitals:Ye(this.oo)?this.oo:void 0;return Ye(t)?t:this.$s}startIfEnabled(){this.isEnabled&&!this.Rs&&(Os.info(`enabled, starting...`),this.ur(this.so))}onRemoteConfig(e){if(`capturePerformance`in e){var t=L(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=L(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Qn]:t}),this._instance.persistence.register({[tr]:n})),this.$s=t,this.startIfEnabled()}}ur(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?Os.error(`failed to load script`,t):e()}))}io(){var e=k?k.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return Ni(e,this._instance.config.mask_personal_data_properties?[...Ii,...t||[]]:[],Ri)}Os.error(`Could not determine current URL`)}}},uc={exceptionObserver:class{constructor(e){var t;this.so=()=>{var e;if(k&&this.isEnabled&&(e=M.__PosthogExtensions__)!=null&&e.errorWrappingFunctions){var t=M.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=M.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=M.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ao&&this.Bt.capture_unhandled_errors&&(this.ao=t(this.captureException.bind(this))),!this.lo&&this.Bt.capture_unhandled_rejections&&(this.lo=n(this.captureException.bind(this))),!this.uo&&this.Bt.capture_console_errors&&(this.uo=r(this.captureException.bind(this)))}catch(e){Ts.error(`failed to start`,e),this.ho()}}},this._instance=e,this.co=!((t=this._instance.persistence)==null||!t.props[Yn]),this.do=new at({refillRate:this._instance.config.error_tracking.__exceptionRateLimiterRefillRate??1,bucketSize:this._instance.config.error_tracking.__exceptionRateLimiterBucketSize??10,refillInterval:1e4,Gt:Ts}),this.Bt=this.vo(),this.startIfEnabledOrStop()}vo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return L(e)?t=P({},t,e):(R(e)?this.co:e)&&(t=P({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Bt.capture_console_errors||this.Bt.capture_unhandled_errors||this.Bt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ts.info(`enabled`),this.ho(),this.ur(this.so)):this.ho()}ur(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return Ts.error(`failed to load script`,t);e()}))}ho(){var e,t,n;(e=this.ao)==null||e.call(this),this.ao=void 0,(t=this.lo)==null||t.call(this),this.lo=void 0,(n=this.uo)==null||n.call(this),this.uo=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.co=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Yn]:this.co}),this.Bt=this.vo(),this.startIfEnabledOrStop())}onConfigChange(){this.Bt=this.vo()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.do.consumeRateLimit(r)?Ts.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.fo=[],this.po=new un([new Sn,new Mn,new wn,new Cn,new An,new kn,new En,new jn],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(`
2
- `),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=xn.test(s)?s.replace(xn,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return P({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||dn});var n}))}(i)}}(`web:javascript`,_n,bn)),this._instance=e,this.fo=this._instance.persistence?.get_property(Xn)??[],this.mo=Ln(this.yo()),this.bo=new Rn(this.mo)}onConfigChange(){this.mo=Ln(this.yo()),this.bo.setConfig(this.mo)}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.fo=t,this._instance.persistence&&this._instance.persistence.register({[Xn]:this.fo,[Zn]:n})}}get wo(){var e,t=!!this._instance.get_property(Zn);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.po.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.mo.enabled)try{if(!z(e)||e.trim().length===0)return void tc.warn(`Ignoring exception step because message must be a non-empty string`);var{sanitizedProperties:n,droppedKeys:r}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((n,r)=>Fn.has(r)?(t.push(r),n):(n[r]=e[r],n)),{}),droppedKeys:t}}(this._o(t));r.length>0&&tc.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this.bo.add(P({[Nn]:e,[Pn]:new Date().toISOString()},n))}catch(e){tc.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.Io(t)){if(this.Co(t))return this.So(`Exception dropped: matched a suppression rule`),void tc.info(`Skipping exception capture because a suppression rule matched`);if(!this.wo&&this.xo(t))return this.So(`Exception dropped: thrown by a browser extension`),void tc.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ko(t))return this.So(`Exception dropped: thrown by the PostHog SDK`),void tc.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}var n=this.mo.enabled&&B(e.$exception_steps)?this.To(e):e;try{var r=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,en:!0});return r&&this.bo.clear(),r}catch(e){tc.error(`Failed to capture exception event. Dropping this exception.`,e),this.bo.clear();return}}catch(e){tc.error(`Failed to process exception event. Ignoring this exception.`,e);return}}To(e){try{var t=this.bo.getAttachable();return t.length===0?e:P({},e,{$exception_steps:t})}catch(t){return tc.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}So(e){this.mo.enabled&&this.bo.add({[Nn]:e,[Pn]:new Date().toISOString()})}_o(e){return L(e)?P({},e):{}}yo(){return this._instance.config.error_tracking?.exception_steps??{}}Co(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var{type:n,value:r}=t;return z(n)&&n.length>0&&e.$exception_types.push(n),z(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.fo.some((e=>{var n=e.values.map((e=>{var n=co[e.operator],r=I(e.value)?e.value:[e.value],i=t[e.key]??[];return r.length>0&&n(r,i)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}xo(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}ko(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}Io(e){return!B(e)&&I(e)}}},dc=P({productTours:class{get ni(){return this._instance.persistence}constructor(e){this.Ao=null,this.Eo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.ni&&this.ni.register({[er]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.Ao||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(er)||this.ur((()=>this.Ro()))}ur(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?Rs.error(`Could not load product tours script`,t):e()}))}Ro(){var e;!this.Ao&&(e=M.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ao=M.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!I(this.Eo)||t){var n=this.ni;if(n){var r=n.props[xr];if(I(r)&&!t)return this.Eo=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,callback:t=>{var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;Rs.error(i),e([],{isLoaded:!1,error:i});return}var a=I(t.json.product_tours)?t.json.product_tours:[];this.Eo=a,n&&n.register({[xr]:a}),e(a,{isLoaded:!0})}})}else e(this.Eo,{isLoaded:!0})}getActiveProductTours(e){B(this.Ao)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.Ao.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ao)==null||t.showTourById(e)}previewTour(e){this.Ao?this.Ao.previewTour(e):this.ur((()=>{var t;this.Ro(),(t=this.Ao)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ao)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.Ao)==null||e.nextStep()}previousStep(){var e;(e=this.Ao)==null||e.previousStep()}clearCache(){var e;this.Eo=null,(e=this.ni)==null||e.unregister(xr)}resetTour(e){var t;(t=this.Ao)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ao)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ao)==null||t.cancelPendingTour(e)}}},sc),fc={siteApps:class{constructor(e){this._instance=e,this.No=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Mo(e,t){if(t){var n=this.globalsForEvent(t);this.No.push(n),this.No.length>1e3&&(this.No=this.No.slice(10))}}get siteAppLoaders(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Mo.bind(this));this.Fo=()=>{e(),this.No=[],this.Fo=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var[i,a]of Object.entries(r))t[i]={id:n[i],type:i,properties:a};var{$set_once:o,$set:s}=e;return{event:P({},Ne(e,zs),{properties:P({},e.properties,s?{$set:P({},e.properties?.$set??{},s)}:{},o?{$set_once:P({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.No.length&&(Bs.info(`Processing `+this.No.length+` events for site app with id `+e.id),this.No.forEach((e=>t.processEvent==null?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.Fo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Bs.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback(e){i(e)}});a&&(t.processEvent=a),r=!0}catch(t){Bs.error(Vs+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Bs.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}Oo(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}Po(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(t){Bs.error(`Error while processing event `+e.event+` for site app `+n.id,t)}}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Oo(),void this._instance.on(`eventCaptured`,(e=>this.Po(e)))):void Bs.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.Fo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(e){var t;M[`__$$ph_site_app_`+e]=i._instance,(t=M.__PosthogExtensions__)==null||t.loadSiteApp==null||t.loadSiteApp(i._instance,s,(t=>{if(t)return Bs.error(Vs+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else Bs.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},pc={tracingHeaders:class{constructor(e){this.Lo=void 0,this.Do=void 0,this.so=()=>{var e,t,n=this.Bo()||[];R(this.Lo)&&((e=M.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(n,this._instance.get_distinct_id(),this._instance.sessionManager)),R(this.Do)&&((t=M.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(n,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}ur(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return Ds.error(`failed to load script`,t);e()}))}Bo(){return this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var e,t;this.Bo()?this.ur(this.so):((e=this.Lo)==null||e.call(this),(t=this.Do)==null||t.call(this),this.Lo=void 0,this.Do=void 0)}}},mc=P({surveys:class{get Bt(){return this._instance.config}constructor(e){this.jo=void 0,this._surveyManager=null,this.$o=!1,this.qo=[],this.Zo=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Bt.disable_surveys){var t=e.surveys;if(B(t))return Q.warn(`Flags not loaded yet. Not loading surveys.`);var n=I(t);this.jo=n?t.length>0:t,Q.info(`flags response received, isSurveysEnabled: `+this.jo),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(vo)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.$o)Q.info(`Already initializing surveys, skipping...`);else if(this.Bt.disable_surveys)Q.info(qs);else if(this.Bt.cookieless_mode&&this._instance.consent.isOptedOut())Q.info(`Not loading surveys in cookieless mode without consent.`);else{var e=M?.__PosthogExtensions__;if(e){if(!R(this.jo)||this.Bt.advanced_enable_surveys){var t=this.jo||this.Bt.advanced_enable_surveys;this.$o=!0;try{var n=e.generateSurveys;if(n)return void this.Ho(n,t);var r=e.loadExternalDependency;if(!r)return void this.Vo(Rr);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Vo(`Could not load surveys script`,n):this.Ho(e.generateSurveys,t)}))}catch(e){throw this.Vo(`Error initializing surveys`,e),e}finally{this.$o=!1}}}else Q.error(`PostHog Extensions not found.`)}}Ho(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Gs(this._instance),Q.info(`Surveys loaded successfully`),this.zo({isLoaded:!0})}Vo(e,t){Q.error(e,t),this.zo({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.qo.push(e),this._surveyManager&&this.zo({isLoaded:!0}),()=>{this.qo=this.qo.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Bt.disable_surveys)return Q.info(qs),e([]);var n,r=this._instance.get_property(yr);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Zo?this.Zo.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Zo=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Bt.token),method:`GET`,timeout:this.Bt.surveys_request_timeout_ms,callback:t=>{var r;this.Zo=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;Q.error(a);var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[yr]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}zo(e){for(var t of this.qo)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Q.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!B(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Q.warn(`init was not called`)}Uo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}Yo(e){if(B(this._surveyManager))return{eligible:!1,reason:Ks};var t=typeof e==`string`?this.Uo(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(B(this._surveyManager))return Q.warn(`init was not called`),{visible:!1,disabledReason:Ks};var t=this.Yo(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return B(this._surveyManager)?(Q.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Ks})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Yo(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(B(this._surveyManager))Q.warn(`init was not called`);else{var i=typeof e==`string`?this.Uo(e):e;if(i!=null&&i.id)if(yo.includes(i.type)){var a=j?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(Q.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;Q.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),Q.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);Q.warn(`Survey element not found`)}else Q.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else Q.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(B(this._surveyManager))Q.warn(`init was not called`);else{var r=this.Uo(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=P({},r,{appearance:P({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==na.Popover&&t.initialResponses&&Q.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.canRenderSurvey(r);if(!a.visible)return void Q.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===na.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else Q.warn(`Survey not found`)}}cancelPendingSurvey(e){B(this._surveyManager)?Q.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}},sc),hc={toolbar:class{constructor(e){this.instance=e}Go(e){M.ph_toolbar_state=e}Wo(){return M.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),ri(this.instance.config)||!k||!j)return!1;e??=k.location,n??=k.history;try{if(!t){try{k.localStorage.setItem(`test`,`test`),k.localStorage.removeItem(`test`)}catch{return!1}t=k?.localStorage}var r,i=Js||Pi(e.hash,`__posthog`)||Pi(e.hash,`state`),a=i?Qr((()=>JSON.parse(atob(decodeURIComponent(i)))))||Qr((()=>JSON.parse(decodeURIComponent(i)))):null;return a&&a.action===`ph_authorize`?((r=a).source=`url`,r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):((r=JSON.parse(t.getItem(Ys)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Xo(e){var t=M.ph_load_toolbar||M.ph_load_editor;!B(t)&&Ue(t)?t(e,this.instance):Xs.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(j==null||!j.getElementById(Nr));if(!k||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=P({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(k.localStorage.setItem(Ys,JSON.stringify(P({},r,{source:void 0}))),this.Wo()===2)this.Xo(r);else if(this.Wo()===0){var i;this.Go(1),(i=M.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return Xs.error(`[Toolbar] Failed to load`,e),void this.Go(0);this.Go(2),this.Xo(r)})),q(k,`turbolinks:load`,(()=>{this.Go(0),this.loadToolbar(r)}))}return!0}Jo(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},gc=P({experiments:ic},sc),_c=P({},sc,cc,lc,uc,dc,fc,mc,pc,hc,gc,{conversations:class{constructor(e){this.Ko=void 0,this._conversationsManager=null,this.Qo=!1,this.ea=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;B(t)||(Ye(t)?this.Ko=t:(this.Ko=t.enabled,this.ea=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Ko=void 0,this.ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Qo||this._instance.config.disable_conversations||ri(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=M?.__PosthogExtensions__;if(e&&!R(this.Ko)&&this.Ko)if(this.ea&&this.ea.token){this.Qo=!0;try{var t=e.initConversations;if(t)return this.ta(t),void(this.Qo=!1);var n=e.loadExternalDependency;if(!n)return void this.ra(Rr);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.ra(`Could not load conversations script`,t):this.ta(e.initConversations),this.Qo=!1}))}catch(e){this.ra(`Error initializing conversations`,e),this.Qo=!1}}else ac.error(`Conversations enabled but missing token in remote config.`)}}ta(e){if(this.ea)try{this._conversationsManager=e(this.ea,this._instance),ac.info(`Conversations loaded successfully`)}catch(e){this.ra(`Error completing conversations initialization`,e)}else ac.error(`Cannot complete initialization: remote config is null`)}ra(e,t){ac.error(e,t),this._conversationsManager=null,this.Qo=!1}show(){this._conversationsManager?this._conversationsManager.show():ac.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Ko&&!Ke(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return Me((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(ac.warn(oc),null)}))()}getMessages(e,t){var n=this;return Me((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(ac.warn(oc),null)}))()}markAsRead(e){var t=this;return Me((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(ac.warn(oc),null)}))()}getTickets(e){var t=this;return Me((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(ac.warn(oc),null)}))()}requestRestoreLink(e){var t=this;return Me((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(ac.warn(oc),null)}))()}restoreFromToken(e){var t=this;return Me((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(ac.warn(oc),null)}))()}restoreFromUrlToken(){var e=this;return Me((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(ac.warn(oc),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}un(){var e;(e=this._conversationsManager)==null||e.setIdentity()}hn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t;this.ia=!1,this.na=!1,this.Gt=W(`[logs]`),this.sa=[],this.oa=0,this.aa=0,this.la=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ia=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!B(t)&&t&&(this.ia=!0,this.loadIfEnabled())}reset(){this.sa=[],this.jr&&=(clearTimeout(this.jr),void 0),this.oa=0,this.aa=0,this.la=!1}loadIfEnabled(){if(this.ia&&!this.na){var e=M?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.Gt.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.na=!0)})):this.Gt.error(Rr)}else this.Gt.error(`PostHog Extensions not found.`)}}captureLog(e){if(this._instance.is_capturing())if(e&&e.body){var t=this._instance.config.logs?.flushIntervalMs??3e3,n=this._instance.config.logs?.maxLogsPerInterval??1e3,r=Date.now();if(t>r-this.aa||(this.aa=r,this.oa=0,this.la=!1),n>this.oa){this.oa++;var i=function(e,t){var{text:n,number:r}=an[e.level||`info`]||on,i=String(Date.now())+`000000`,a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a[`url.full`]=t.currentUrl),t.screenName&&(a[`screen.name`]=t.screenName),t.appState&&(a[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var o=P({},a,e.attributes||{}),s={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:r,severityText:n,body:{stringValue:e.body},attributes:cn(o)};return e.trace_id&&(s.traceId=e.trace_id),e.span_id&&(s.spanId=e.span_id),R(e.trace_flags)||(s.flags=e.trace_flags),s}(e,this.ua());this.sa.push({record:i}),(this._instance.config.logs?.maxBufferSize??100)>this.sa.length?this.ha():this.flushLogs()}else this.la||=(this.Gt.warn(`captureLog dropping logs: exceeded `+n+` logs per `+t+`ms`),!0)}else this.Gt.warn(`captureLog requires a body`)}get logger(){return this.ca||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.ca}flushLogs(e){if(this.jr&&=(clearTimeout(this.jr),void 0),this.sa.length!==0){var t=this.sa;this.sa=[];var n=this._instance.config.logs,r=P({"service.name":n?.serviceName||`unknown_service`},n?.environment&&{"deployment.environment":n.environment},n?.serviceVersion&&{"service.version":n.serviceVersion},n?.resourceAttributes),i=function(e,t,n,r){return{resourceLogs:[{resource:{attributes:cn(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}(t.map((e=>e.record)),r,N.LIB_NAME,N.LIB_VERSION),a=this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token);this._instance.Hi({method:`POST`,url:a,data:i,compression:`best-available`,batchKey:`logs`,transport:e})}}ha(){this.jr||=setTimeout((()=>{this.jr=void 0,this.flushLogs()}),this._instance.config.logs?.flushIntervalMs??3e3)}ua(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=n}if(M!=null&&(e=M.location)!=null&&e.href&&(t.currentUrl=M.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});Ro.__defaultExtensionClasses=P({},_c);var vc,yc=(vc=To[Mo]=new Ro,function(){function e(){e.done||(e.done=!0,No=!1,G(To,(function(e){e._dom_loaded()})))}j!=null&&j.addEventListener?j.readyState===`complete`?e():q(j,`DOMContentLoaded`,e,{capture:!1}):k&&U.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),vc),bc;function xc(e){bc=e}function Sc(){return bc}var Cc=(0,m.createContext)({get client(){return Sc()},bootstrap:void 0});function wc(e,t,n){if(n===void 0&&(n=new WeakMap),e===t)return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e)&&n.get(e)===t)return!0;n.set(e,t);var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(var a=0,o=r;a<o.length;a++){var s=o[a];if(!i.includes(s)||!wc(e[s],t[s],n))return!1}return!0}function Tc(e){var t=e.children,n=e.client,r=e.apiKey,i=e.options,a=(0,m.useRef)(null),o=(0,m.useMemo)(function(){if(n)return r&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),i&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n;var e=Sc();return r||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),e},[n,r,JSON.stringify(i)]);return(0,m.useEffect)(function(){if(!n){var e=Sc(),t=a.current;t?(r!==t.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),i&&!wc(i,t.options)&&e.set_config(i),a.current={apiKey:r,options:i??{}}):(e.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),e.init(r,i),a.current={apiKey:r,options:i??{}})}},[n,r,JSON.stringify(i)]),m.default.createElement(Cc.Provider,{value:{client:o,bootstrap:i?.bootstrap??n?.config?.bootstrap}},t)}var Ec=function(e){return typeof e==`function`},Dc=function(e,t){return Dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Dc(e,t)};function Oc(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Dc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var kc={componentStack:null,exceptionEvent:null,error:null},Ac={INVALID_FALLBACK:`[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.`};(function(e){Oc(t,e);function t(t){var n=e.call(this,t)||this;return n.state=kc,n}return t.prototype.componentDidCatch=function(e,t){var n=this.props.additionalProperties,r;Ec(n)?r=n(e):typeof n==`object`&&(r=n);var i=this.context.client.captureException(e,r),a=t.componentStack;this.setState({error:e,componentStack:a??null,exceptionEvent:i})},t.prototype.render=function(){var e=this.props,t=e.children,n=e.fallback,r=this.state;if(r.componentStack==null)return Ec(t)?t():t;var i=Ec(n)?m.default.createElement(n,{error:r.error,componentStack:r.componentStack,exceptionEvent:r.exceptionEvent}):n;return m.default.isValidElement(i)?i:(console.warn(Ac.INVALID_FALLBACK),m.default.createElement(m.default.Fragment,null))},t.contextType=Cc,t})(m.default.Component),xc(yc);var jc=({debug:e=!1,postHogApiKey:t,isStandalone:n,project:r,forceDisablePostHog:i=!1,children:a})=>{let o=ae();return(0,m.useEffect)(()=>{!t||i||(o?.PostHog.consentGiven?yc.opt_in_capturing():yc.opt_out_capturing())},[o.PostHog.consentGiven,i,t]),!t||i?(console.warn(i?`AppShellStandalone Warning: PostHog tracking is disabled by force. PostHog will not be initialized.`:`AppShellStandalone Warning: PostHog API key is not provided. PostHog will not be initialized.`),(0,h.jsx)(h.Fragment,{children:a})):(yc.init(t,{debug:e,api_host:n?`https://eu.posthog.com`:`/ingest`,ui_host:`https://eu.posthog.com`,opt_out_capturing_by_default:!0,autocapture:n},r),(0,h.jsx)(Tc,{client:yc,children:a}))};exports.AppShell=b,exports.ConsentManagerProvider=D,exports.LanguageProvider=le,exports.MenuProvider=pe,exports.MicroFrontendLink=he,exports.OrganisationProvider=be,exports.OrganisationSelector=Se,exports.OrganisationsError=xe,exports.PostHogProviderWrapper=jc,exports.languageStorage=te,exports.organisationStorage=S,exports.useConsentManager=ae,exports.useLanguage=ce,exports.useMFNavigation=O,exports.useMenu=fe,exports.useMenuGroupItems=de,exports.useOrganisation=_e,exports.useOrganisationId=ve;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@auth0/auth0-react`),l=require(`@entur/alert`),u=require(`@entur/loader`),d=require(`@entur/tokens`),f=require(`@entur/typography`),p=require(`@entur-partner/common`),m=require(`react`);m=s(m,1);let h=require(`react/jsx-runtime`),g=require(`@entur-partner/util`),_=require(`@entur-partner/micro-frontend`);var v=({environment:e})=>(0,h.jsx)(`div`,{className:`epp-environment-banner`,style:{position:`fixed`,zIndex:9999,top:0,left:0,right:0,width:`100vw`,height:`16px`,backgroundColor:(0,p.getColorForEnvironment)(e)}});function ee(e){let{protocol:t,hostname:n,port:r}=window.location;return e({logoutParams:{returnTo:`${t}//${n}:${r}`}})}var te=({children:e,decorateUser:t,getReturnPath:n,isPublicView:r})=>{let[i,a]=(0,m.useState)(void 0),[o,s]=(0,m.useState)(void 0),{user:p,getAccessTokenSilently:g,loginWithRedirect:_,logout:v,isLoading:te,isAuthenticated:y,error:b}=(0,c.useAuth0)();return(0,m.useEffect)(()=>{y&&(async()=>{try{a(await t(p,await g()))}catch(e){s(e)}})()},[t,g,y,p]),te||y&&!i&&!o?(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Authenticating`}):!y&&!r?(_({appState:{returnTo:n()}}),(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Redirecting to login page`})):o?(process.env.NODE_ENV!==`production`&&console.error(o),(0,h.jsx)(l.BannerAlertBox,{variant:`error`,title:`Authentication failed`,style:{maxWidth:`600px`,margin:`0 auto`},children:(0,h.jsxs)(f.Paragraph,{children:[`Something went wrong while trying to authenticate you. If the problem persists you should contact`,` `,(0,h.jsx)(f.Link,{href:`mailto:support@entur.org`,children:`support@entur.org`}),` to get it resolved.`]})})):b?(process.env.NODE_ENV!==`production`&&console.error(b),(0,h.jsxs)(l.BannerAlertBox,{variant:`error`,title:`Authentication failed`,style:{maxWidth:`600px`,margin:`0 auto`},children:[(0,h.jsxs)(f.Paragraph,{children:[`Something went wrong while trying to authenticate you. If the problem persists you should contact`,` `,(0,h.jsx)(f.Link,{href:`mailto:support@entur.org`,children:`support@entur.org`}),` to get it resolved.`]}),(0,h.jsxs)(f.Paragraph,{children:[`Authentication failed with: `,(0,h.jsx)(f.CodeText,{children:b?.toString()})]})]})):(0,h.jsx)(h.Fragment,{children:e({user:i,logout:()=>ee(v),loginWithRedirect:_,getToken:g})})},y=({children:e,audience:t,domain:n,clientId:r,decorateUser:i,environment:a,redirectUri:o,navigate:s,isPublicView:l=!1})=>(0,h.jsx)(c.Auth0Provider,{domain:n,clientId:r,authorizationParams:{redirect_uri:o??window.location.origin,audience:t},onRedirectCallback:e=>{let t=e?.returnTo,n=o||t||`/`;s?s(n,{replace:!0}):window.history.replaceState({},``,n)},children:(0,h.jsx)(te,{decorateUser:i,getReturnPath:()=>`${window.location.pathname}${window.location.search}${window.location.hash}`,isPublicView:l,children:t=>(0,h.jsxs)(h.Fragment,{children:[a&&a!==p.Environment.Production&&(0,h.jsx)(v,{environment:a}),e(t)]})})}),b=`EP::activeOrgId`,x={get:()=>localStorage.getItem(b),set:e=>localStorage.setItem(b,e)},S=`EP::locale`,ne={get:()=>localStorage.getItem(S),set:e=>localStorage.setItem(S,e)},C=`ucData`,re={get:()=>localStorage.getItem(C)},w={Usercentrics:`Usercentrics Consent Management Platform`,PostHog:`PostHog.com`,Sentry:`Sentry`},ie={Usercentrics:{consentGiven:!1},PostHog:{consentGiven:!1},Sentry:{consentGiven:!1}},T=e=>e.map(e=>{let t=Object.entries(w).find(t=>t[1]===e.name)?.[0];if((0,g.assertIsDefined)(t,`Service name ${e.name} not found in SERVICE_NAMES`),typeof e.consent==`boolean`){let n=e.consent;return{[t]:{consentGiven:n}}}else if(typeof e.consent==`object`&&`given`in e.consent){let n=e.consent.given;return{[t]:{consentGiven:n}}}return{[t]:{consentGiven:!1}}}).reduce((e,t)=>({...e,...t}),ie),ae=(0,m.createContext)(ie),oe=()=>(0,m.useContext)(ae),E=({children:e})=>{let[t,n]=(0,m.useState)(ie);return(0,m.useEffect)(()=>{if(typeof window>`u`)return;let e=re.get();if(e){let t=JSON.parse(e);n(T(Object.values(t.consent.services)))}},[]),(0,m.useEffect)(()=>{let e=async e=>{typeof window>`u`||n(T(Object.values(e.detail.services)))};return window.addEventListener(`UC_CONSENT`,e),()=>window.removeEventListener(`UC_CONSENT`,e)},[]),(0,h.jsx)(ae.Provider,{value:t,children:e})},se=(0,m.createContext)(void 0),ce=e=>{let[t,n]=(0,m.useState)(e);return(0,m.useEffect)(()=>{ne.set(t)},[t]),[t,n]},le=()=>{let e=(0,m.useContext)(se);return(0,g.assertIsDefined)(e),e},ue=({children:e,language:t})=>{let[n,r]=ce(t);return(0,h.jsx)(se.Provider,{value:{language:n,setLanguage:r},children:e})},de=(0,m.createContext)({addItems:()=>{},getItemsForPath:()=>[],getMFNavigate:()=>void 0,setMFNavigate:()=>{},getItemGroupsPerPath:()=>({})}),fe=e=>(0,m.useContext)(de).getItemsForPath(e),pe=()=>(0,m.useContext)(de),D=e=>{let{getMFNavigate:t}=pe();return t(e)},me=({children:e})=>{let[t,n]=(0,m.useState)({}),[r,i]=(0,m.useState)({}),a=(0,m.useCallback)((e,t)=>{n(n=>({...n,[t]:e})),window.dispatchEvent((0,_.createMenuItemsEvent)({path:t,items:e}))},[]);return(0,h.jsx)(de.Provider,{value:{addItems:a,getItemGroupsPerPath:()=>t,getItemsForPath:e=>t[e]??[],getMFNavigate:e=>r[e],setMFNavigate:(e,t)=>i(n=>({...n,[e]:t}))},children:e})};function he(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var ge=({navigate:e,children:t,onClick:n,target:r,...i})=>(0,h.jsx)(`a`,{onClick:t=>{try{n&&n(t)}catch(e){throw t.preventDefault(),e}!t.defaultPrevented&&t.button===0&&(!r||r===`_self`)&&!he(t)&&(t.preventDefault(),e())},target:r,...i,children:t}),_e=(0,m.createContext)(void 0),ve=()=>{let e=(0,m.useContext)(_e);return(0,g.assertIsDefined)(e),e},ye=()=>{let e=(0,m.useContext)(_e);return(0,g.assertIsDefined)(e),e.organisationId},be=e=>{let[t,n]=(0,m.useState)(Number(e));return(0,m.useEffect)(()=>{x.set(t.toString())},[t]),[t,n]},xe=({children:e,organisationId:t})=>{let[n,r]=be(t);return(0,h.jsx)(_e.Provider,{value:{organisationId:n,setOrganisationId:r},children:e})},Se=class extends Error{constructor(...e){super(...e),this.message=`Failed fetching organisations`}},Ce=({getToken:e,getOrganisations:t,selectedOrganisationId:n,onChange:r,...i})=>{let[a,o]=(0,m.useState)([]),{language:s}=le(),[c,l]=(0,m.useState)(`LOADING`);switch((0,m.useEffect)(()=>{(async()=>{let n=await e(),r;r=typeof t==`string`?await fetch(t,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`}}).then(e=>e.json()):await t(n),o(r),l(`SUCCESS`)})().catch(e=>{process.env.NODE_ENV===`development`&&console.error(e),l(`ERROR`)})},[t,e]),c){case`LOADING`:return(0,h.jsx)(`div`,{className:`eds-contrast`,children:(0,h.jsx)(u.SkeletonRectangle,{style:{height:`2.4rem`}})});case`SUCCESS`:return(0,h.jsx)(p.OrganisationDropDown,{label:s===`nb`||s===`nb-NO`?`Organisasjon`:`Organisation`,selectedOrganisationId:n,organisations:a,onChange:r,...i});case`ERROR`:throw new Se;default:return null}},O=typeof window<`u`?window:void 0,k=typeof globalThis<`u`?globalThis:O;typeof self>`u`&&(k.self=k),typeof File>`u`&&(k.File=function(){});var we=k?.navigator,A=k?.document,Te=k?.location,Ee=k?.fetch,De=k!=null&&k.XMLHttpRequest&&`withCredentials`in new k.XMLHttpRequest?k.XMLHttpRequest:void 0,Oe=k?.AbortController,ke=k?.CompressionStream,Ae=we?.userAgent,j=O??{},je=`1.372.6`,M={DEBUG:!1,LIB_VERSION:je,LIB_NAME:`web`,JS_SDK_VERSION:je};function Me(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function Ne(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Me(a,r,i,o,s,`next`,e)}function s(e){Me(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},N.apply(null,arguments)}function Pe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Fe(){return Fe=Ne((function*(e,t,n){t===void 0&&(t=!0);try{var r=new CompressionStream(`gzip`),i=r.writable.getWriter(),a=i.write(new TextEncoder().encode(e)).then((()=>i.close())).catch(function(){var e=Ne((function*(e){try{yield i.abort(e)}catch{}throw e}));return function(t){return e.apply(this,arguments)}}()),o=new Response(r.readable).blob(),[s]=yield Promise.all([o,a]);return s}catch(e){if(n!=null&&n.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}})),Fe.apply(this,arguments)}var Ie=`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,pinterest,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,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`.split(`,`),Le=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return Ie.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))},Re=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`];function P(e,t){return e.indexOf(t)!==-1}var ze=function(e){return e.trim()},Be=function(e){return e.replace(/^\$/,``)},Ve=Object.prototype,He=Ve.hasOwnProperty,Ue=Ve.toString,F=Array.isArray||function(e){return Ue.call(e)===`[object Array]`},We=e=>typeof e==`function`,I=e=>e===Object(e)&&!F(e),Ge=e=>{if(I(e)){for(var t in e)if(He.call(e,t))return!1;return!0}return!1},L=e=>e===void 0,R=e=>Ue.call(e)==`[object String]`,Ke=e=>R(e)&&e.trim().length===0,qe=e=>e===null,z=e=>L(e)||qe(e),Je=e=>Ue.call(e)==`[object Number]`&&e==e,Ye=e=>Je(e)&&e>0,Xe=e=>Ue.call(e)===`[object Boolean]`,Ze=e=>e instanceof FormData,Qe=e=>P(Re,e);function $e(e){return typeof e!=`object`||!e}function et(e,t){return{}.toString.call(e)===`[object `+t+`]`}function tt(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var nt=[!0,`true`,1,`1`,`yes`],rt=e=>P(nt,e),it=[!1,`false`,0,`0`,`no`];function at(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Je(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),at(i||n,t,n,r))}var ot=class{constructor(e){this.$t={},this.zt=e.zt,this.Ut=at(e.bucketSize,0,100,e.Gt),this.Wt=at(e.refillRate,0,this.Ut,e.Gt),this.Xt=at(e.refillInterval,0,864e5,e.Gt)}Jt(e,t){var n=Math.floor((t-e.lastAccess)/this.Xt);n>0&&(e.tokens=Math.min(e.tokens+n*this.Wt,this.Ut),e.lastAccess+=n*this.Xt)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.$t[r];return i?this.Jt(i,n):this.$t[r]=i={tokens:this.Ut,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.zt)==null||t.call(this,e)),i.tokens===0)}stop(){this.$t={}}},st,ct,lt,ut=(e,t,n)=>{function r(r){for(var i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];t((()=>{(0,n[r])(e,...a)}))}return{debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r(`error`,...t)},critical(){for(var t=arguments.length,r=Array(t),i=0;t>i;i++)r[i]=arguments[i];n.error(e,...r)},createLogger:r=>ut(e+` `+r,t,n)}},B=`Mobile`,dt=`iOS`,ft=`Android`,pt=`Tablet`,mt=ft+` `+pt,ht=`iPad`,gt=`Apple`,_t=gt+` Watch`,vt=`Safari`,yt=`BlackBerry`,bt=`Samsung`,xt=bt+`Browser`,St=bt+` Internet`,Ct=`Chrome`,wt=Ct+` OS`,Tt=Ct+` `+dt,Et=`Internet Explorer`,Dt=Et+` `+B,Ot=`Opera`,kt=Ot+` Mini`,At=`Edge`,jt=`Microsoft `+At,Mt=`Firefox`,Nt=Mt+` `+dt,Pt=`Nintendo`,Ft=`PlayStation`,It=`Xbox`,Lt=ft+` `+B,Rt=B+` `+vt,zt=`Windows`,Bt=zt+` Phone`,Vt=`Nokia`,Ht=`Ouya`,Ut=`Generic`,Wt=Ut+` `+B.toLowerCase(),Gt=Ut+` `+pt.toLowerCase(),Kt=`Konqueror`,V=`(\\d+(\\.\\d+)?)`,qt=RegExp(`Version/`+V),Jt=new RegExp(It,`i`),Yt=RegExp(Ft+` \\w+`,`i`),Xt=RegExp(Pt+` \\w+`,`i`),Zt=RegExp(yt+`|PlayBook|BB10`,`i`),Qt={"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`},$t=function(e,t){return t||=``,P(e,` OPR/`)&&P(e,`Mini`)?kt:P(e,` OPR/`)?Ot:Zt.test(e)?yt:P(e,`IE`+B)||P(e,`WPDesktop`)?Dt:P(e,xt)?St:P(e,At)||P(e,`Edg/`)?jt:P(e,`FBIOS`)?`Facebook `+B:P(e,`UCWEB`)||P(e,`UCBrowser`)?`UC Browser`:P(e,`CriOS`)?Tt:P(e,`CrMo`)||P(e,Ct)?Ct:P(e,ft)&&P(e,vt)?Lt:P(e,`FxiOS`)?Nt:P(e.toLowerCase(),Kt.toLowerCase())?Kt:((e,t)=>t&&P(t,gt)||function(e){return P(e,vt)&&!P(e,Ct)&&!P(e,ft)}(e))(e,t)?P(e,B)?Rt:vt:P(e,Mt)?Mt:P(e,`MSIE`)||P(e,`Trident/`)?Et:P(e,`Gecko`)?Mt:``},en={[Dt]:[RegExp(`rv:`+V)],[jt]:[RegExp(At+`?\\/`+V)],[Ct]:[RegExp(`(`+Ct+`|CrMo)\\/`+V)],[Tt]:[RegExp(`CriOS\\/`+V)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+V)],[vt]:[qt],[Rt]:[qt],[Ot]:[RegExp(`(Opera|OPR)\\/`+V)],[Mt]:[RegExp(Mt+`\\/`+V)],[Nt]:[RegExp(`FxiOS\\/`+V)],[Kt]:[RegExp(`Konqueror[:/]?`+V,`i`)],[yt]:[RegExp(yt+` `+V),qt],[Lt]:[RegExp(`android\\s`+V,`i`)],[St]:[RegExp(xt+`\\/`+V)],[Et]:[RegExp(`(rv:|MSIE )`+V)],Mozilla:[RegExp(`rv:`+V)]},tn=function(e,t){var n=en[$t(e,t)];if(L(n))return null;for(var r=0;n.length>r;r++){var i=e.match(n[r]);if(i)return parseFloat(i[i.length-2])}return null},nn=[[RegExp(It+`; `+It+` (.*?)[);]`,`i`),e=>[It,e&&e[1]||``]],[new RegExp(Pt,`i`),[Pt,``]],[new RegExp(Ft,`i`),[Ft,``]],[Zt,[yt,``]],[new RegExp(zt,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Bt,``];if(new RegExp(B).test(t)&&!/IEMobile\b/.test(t))return[zt+` `+B,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=Qt[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[zt,r]}return[zt,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[dt,[e[3],e[4],e[5]||`0`].join(`.`)]:[dt,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+ft+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+ft+`)`,`i`),e=>e&&e[2]?[ft,[e[2],e[3],e[4]||`0`].join(`.`)]:[ft,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[wt,``]],[/Linux|debian/i,[`Linux`,``]]],rn=function(e){return Xt.test(e)?Pt:Yt.test(e)?Ft:Jt.test(e)?It:new RegExp(Ht,`i`).test(e)?Ht:RegExp(`(`+Bt+`|WPDesktop)`,`i`).test(e)?Bt:/iPad/.test(e)?ht:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?_t:Zt.test(e)?yt:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Vt,`i`).test(e)?Vt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(B).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?ft:mt:RegExp(`(pda|`+B+`)`,`i`).test(e)?Wt:new RegExp(pt,`i`).test(e)&&!RegExp(pt+` pc`,`i`).test(e)?Gt:``},an=e=>e instanceof Error,on={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}},sn=on.info;function cn(e){if(Xe(e))return{boolValue:e};if(typeof e==`number`)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if(typeof e==`string`)return{stringValue:e};if(F(e))return{arrayValue:{values:e.map((e=>cn(e)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function ln(e){var t=[];for(var n in e){var r=e[n];qe(r)||L(r)||t.push({key:n,value:cn(r)})}return t}function un(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return lt&&n.length===ct||(ct=n.length,lt=n.reduce(((n,r)=>{st||={};var i=st[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,st[r]=[s,c];break}}return n}),{})),lt}}var dn=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return Ne((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&F(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),N({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Ne((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,N({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:un(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return N({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},fn=`?`;function pn(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?fn:n,in_app:!0};return L(r)||(a.lineno=r),L(i)||(a.colno=i),a}var mn=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?fn:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},hn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,gn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,_n=/\((\S*)(?::(\d+))(?::(\d+))\)/,vn=(e,t)=>{var n=hn.exec(e);if(n){var[,r,i,a]=n;return pn(t,r,fn,+i,+a)}var o=gn.exec(e);if(o){if(o[2]&&o[2].indexOf(`eval`)===0){var s=_n.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}var[c,l]=mn(o[1]||fn,o[2]);return pn(t,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},yn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,bn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,xn=(e,t)=>{var n=yn.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=bn.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||fn;return[a,i]=mn(a,i),pn(t,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Sn=/\(error: (.*)\)/,Cn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=R(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){var t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?t+`: `+e.message:t}isDOMException(e){return et(e,`DOMException`)}isDOMError(e){return et(e,`DOMError`)}},wn=class{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},Tn=class{constructor(){}match(e){return et(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},En=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Dn=class{match(e){return typeof e==`string`}coerce(e,t){var[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(En);return r&&(t=r[1],n=r[2]),[t,n]}},On=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function kn(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var An=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return tt(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+kn(e)}isSeverityLevel(e){return R(e)&&!Ke(e)&&On.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(an(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},jn=class{match(e){return tt(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+kn(e),stack:t.syntheticException?.stack,synthetic:!0}}},Mn=class{match(e){return $e(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},Nn=class{match(e){return et(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!tt(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return $e(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},Pn=`$message`,Fn=`$timestamp`,In=new Set([Pn,Fn]),Ln={enabled:!0,max_bytes:32768};function Rn(e){return e?{enabled:e.enabled??Ln.enabled,max_bytes:Bn(e.max_bytes,Ln.max_bytes)}:N({},Ln)}var zn=class{constructor(e){this.Kt=[],this.Qt=0,this.Bt=Rn(e)}setConfig(e){this.Bt=Rn(e),this.er()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Date)return n.toISOString();if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){if(t.has(n))return`[Circular]`;t.add(n)}return n}}))}catch{return}}(e);if(t)try{var n=JSON.parse(t);if(!I(n))return;var r=n,i=r[Pn],a=r[Fn];return!R(i)||i.trim().length===0||!R(a)&&!Je(a)?void 0:{step:r,json:t}}catch{return}}(e);if(t){var n=function(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e).length;for(var t=encodeURIComponent(e),n=0,r=0;t.length>r;r++)t[r]===`%`?(n+=1,r+=2):n+=1;return n}(t.json);n>this.Bt.max_bytes||(this.Kt.push({step:t.step,bytes:n}),this.Qt+=n,this.er())}}getAttachable(){return this.Kt.map((e=>e.step))}clear(){this.Kt=[],this.Qt=0}size(){return this.Kt.length}er(){for(;this.Qt>this.Bt.max_bytes&&this.Kt.length>0;){var e=this.Kt.shift();e&&(this.Qt-=e.bytes)}}};function Bn(e,t){if(!Je(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var Vn=function(e,t){var{debugEnabled:n}=t===void 0?{}:t,r={C(t){if(O&&(M.DEBUG||j.POSTHOG_DEBUG||n)&&!L(O.console)&&O.console){for(var r=(`__rrweb_original__`in O.console[t])?O.console[t].__rrweb_original__:O.console[t],i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];r(e,...a)}},debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.C(`error`,...t)},critical(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];console.error(e,...n)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling `+e)},createLogger:(t,n)=>Vn(e+` `+t,n)};return r},H=Vn(`[PostHog.js]`),U=H.createLogger,Hn=U(`[ExternalScriptsLoader]`),Un=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Hn.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var r=A?.querySelectorAll(`script`);if(r){for(var i,a=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener(`load`,(t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)})),e.onerror=e=>n(e),{v:void 0})}},o=0;r.length>o;o++)if(i=a())return i.v}var s=()=>{if(!A)return n(`document not found`);var r=A.createElement(`script`);if(r.type=`text/javascript`,r.crossOrigin=`anonymous`,r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)},r.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)A.head.appendChild(r);else{var i,a=A.querySelectorAll(`body > script`);a.length>0?(i=a[0].parentNode)==null||i.insertBefore(r,a[0]):A.body.appendChild(r)}};A!=null&&A.body?s():A?.addEventListener(`DOMContentLoaded`,s)};j.__PosthogExtensions__=j.__PosthogExtensions__||{},j.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r;if(e.config.__preview_external_dependency_versioned_paths)r=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`);else{var i=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var a=3e5;i=i+`&t=`+Math.floor(Date.now()/a)*a}r=e.requestRouter.endpointFor(`assets`,i)}Un(e,r,n)}else Un(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},j.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{Un(e,e.requestRouter.endpointFor(`api`,t),n)};var Wn=`$people_distinct_id`,Gn=`$device_id`,Kn=`__alias`,qn=`__timers`,Jn=`$autocapture_disabled_server_side`,Yn=`$heatmaps_enabled_server_side`,Xn=`$exception_capture_enabled_server_side`,Zn=`$error_tracking_suppression_rules`,Qn=`$error_tracking_capture_extension_exceptions`,$n=`$web_vitals_enabled_server_side`,er=`$dead_clicks_enabled_server_side`,tr=`$product_tours_enabled_server_side`,nr=`$web_vitals_allowed_metrics`,rr=`$session_recording_remote_config`,ir=`$replay_override_sampling`,ar=`$replay_override_linked_flag`,or=`$replay_override_url_trigger`,sr=`$replay_override_event_trigger`,cr=`$sesid`,lr=`$session_is_sampled`,ur=`$enabled_feature_flags`,dr=`$active_feature_flags`,fr=`$early_access_features`,pr=`$feature_flag_details`,mr=`$feature_flag_payloads`,hr=`$feature_flag_request_id`,gr=`$override_feature_flags`,_r=`$override_feature_flag_payloads`,vr=`$stored_person_properties`,yr=`$stored_group_properties`,br=`$surveys`,xr=`$surveys_activated`,Sr=`ph_product_tours`,Cr=`$flag_call_reported`,wr=`$flag_call_reported_session_id`,Tr=`$feature_flag_errors`,Er=`$feature_flag_evaluated_at`,Dr=`$user_state`,Or=`$client_session_props`,kr=`$capture_rate_limit`,Ar=`$initial_campaign_params`,jr=`$initial_referrer_info`,Mr=`$initial_person_info`,Nr=`$epp`,Pr=`__POSTHOG_TOOLBAR__`,Fr=`$posthog_cookieless`,Ir=`$sdk_debug_extensions_init_method`,Lr=`$sdk_debug_extensions_init_time_ms`,Rr=`$sdk_debug_recording_script_not_loaded`,zr=`PostHog loadExternalDependency extension not found.`,Br=`on_reject`,Vr=`always`,Hr=`anonymous`,Ur=`identified`,Wr=`identified_only`,Gr=`visibilitychange`,Kr=`beforeunload`,qr=`$pageview`,Jr=`$pageleave`,Yr=`$identify`,Xr=`$groupidentify`;function Zr(e,t){F(e)&&e.forEach(t)}function W(e,t){if(!z(e))if(F(e))e.forEach(t);else if(Ze(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)He.call(e,n)&&t(e[n],n)}var G=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function Qr(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var $r=function(e){try{return e()}catch{return}},ei=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){H.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),H.critical(e)}}},ti=function(e){var t={};return W(e,(function(e,n){(R(e)&&e.length>0||Je(e))&&(t[n]=e)})),t},ni=[`herokuapp.com`,`vercel.app`,`netlify.app`];function ri(e){var t=e?.hostname;if(!R(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of ni)if(n===r)return!1;return!0}function K(e,t,n,r){var{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function ii(e){return e.name===`ph_toolbar_internal`}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Je(e)&&isFinite(e)&&Math.floor(e)===e});var ai=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},oi=class{constructor(){this.I=0,this.S=0,this.k=new li}generate(){var e=this.generateOrAbort();if(L(e)){this.I=0;var t=this.generateOrAbort();if(L(t))throw Error(`Could not generate UUID after timestamp reset`);return t}return e}generateOrAbort(){var e=Date.now();if(e>this.I)this.I=e,this.A();else{if(this.I>=e+1e4)return;this.S++,this.S>4398046511103&&(this.I++,this.A())}return ai.fromFieldsV7(this.I,Math.trunc(this.S/2**30),this.S&2**30-1,this.k.nextUint32())}A(){this.S=1024*this.k.nextUint32()+(1023&this.k.nextUint32())}},si,ci=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};O&&!L(O.crypto)&&crypto.getRandomValues&&(ci=e=>crypto.getRandomValues(e));var li=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(ci(this.T),this.N=0),this.T[this.N++]}},ui=()=>di().toString(),di=()=>(si||=new oi).generate(),fi=``,pi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,mi={R:()=>!!A,B(e){H.error(`cookieStore error: `+e)},O(e){if(A){try{for(var t=e+`=`,n=A.cookie.split(`;`).filter((e=>e.length)),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==` `;)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},Z(e){var t;try{t=JSON.parse(mi.O(e))||{}}catch{}return t},M(e,t,n,r,i){if(A)try{var a=``,o=``,s=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=A),fi)return fi;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+ui();!fi&&r--;){var a=n.slice(r).join(`.`),o=i+`=1;domain=.`+a+`;path=/`;t.cookie=o+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=o+`;max-age=0`,fi=a)}return fi}(e);if(!n){var r=(e=>{var t=e.match(pi);return t?t[0]:``})(e);r!==n&&H.info(`Warning: cookie subdomain discovery mismatch`,r,n),n=r}return n?`; domain=.`+n:``}return``}(A.location.hostname,r);if(n){var c=new Date;c.setTime(c.getTime()+864e5*n),a=`; expires=`+c.toUTCString()}i&&(o=`; secure`);var l=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return l.length>3686.4&&H.warn(`cookieStore warning: large cookie, len=`+l.length),A.cookie=l,l}catch{return}},F(e,t){if(A!=null&&A.cookie)try{mi.M(e,``,-1,t)}catch{return}}},hi=null,q={R(){if(!qe(hi))return hi;var e=!0;if(L(O))e=!1;else try{var t=`__mplssupport__`;q.M(t,`xyz`),q.O(t)!==`"xyz"`&&(e=!1),q.F(t)}catch{e=!1}return e||H.error(`localStorage unsupported; falling back to cookie store`),hi=e,e},B(e){H.error(`localStorage error: `+e)},O(e){try{return O?.localStorage.getItem(e)}catch(e){q.B(e)}return null},Z(e){try{return JSON.parse(q.O(e))||{}}catch{}return null},M(e,t){try{O?.localStorage.setItem(e,JSON.stringify(t))}catch(e){q.B(e)}},F(e){try{O?.localStorage.removeItem(e)}catch(e){q.B(e)}}},gi=[Gn,`distinct_id`,cr,lr,Nr,Mr,Dr],_i={},vi={R:()=>!0,B(e){H.error(`memoryStorage error: `+e)},O:e=>_i[e]||null,Z:e=>_i[e]||null,M(e,t){_i[e]=t},F(e){delete _i[e]}},yi=null,J={R(){if(!qe(yi))return yi;if(yi=!0,L(O))yi=!1;else try{var e=`__support__`;J.M(e,`xyz`),J.O(e)!==`"xyz"`&&(yi=!1),J.F(e)}catch{yi=!1}return yi},B(e){H.error(`sessionStorage error: `,e)},O(e){try{return O?.sessionStorage.getItem(e)}catch(e){J.B(e)}return null},Z(e){try{return JSON.parse(J.O(e))||null}catch{}return null},M(e,t){try{O?.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){J.B(e)}},F(e){try{O?.sessionStorage.removeItem(e)}catch(e){J.B(e)}}},bi=class{constructor(e){this._instance=e}get Bt(){return this._instance.config}get consent(){return this.rr()?0:this.ir}isOptedOut(){return this.Bt.cookieless_mode===Vr||this.isRejected()||this.consent===-1&&this.Bt.cookieless_mode===Br}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Bt.opt_out_capturing_by_default}optInOut(e){this.nr.M(this.sr,+!!e,this.Bt.cookie_expiration,this.Bt.cross_subdomain_cookie,this.Bt.secure_cookie)}reset(){this.nr.F(this.sr,this.Bt.cross_subdomain_cookie)}get sr(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get ir(){var e=this.nr.O(this.sr);return rt(e)?1:P(it,e)?0:-1}get nr(){var e=this.Bt.opt_out_capturing_persistence_type,t=e===`localStorage`?q:mi;if(!this.ar||this.ar!==t){this.ar=t;var n=e===`localStorage`?mi:q;n.O(this.sr)&&(this.ar.O(this.sr)||this.optInOut(rt(n.O(this.sr))),n.F(this.sr,this.Bt.cross_subdomain_cookie))}return this.ar}rr(){return!!this.Bt.respect_dnt&&[we?.doNotTrack,we?.msDoNotTrack,j.doNotTrack].some((e=>rt(e)))}},xi=U(`[Dead Clicks]`),Si=()=>!0,Ci=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(er)),r=e.instance.config.capture_dead_clicks;return Xe(r)?r:!!I(r)||n},wi=class{get lazyLoadedDeadClicksAutocapture(){return this.lr}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){`captureDeadClicks`in e&&(this.instance.persistence&&this.instance.persistence.register({[er]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.ur((()=>{this.hr()})):this.stop()}ur(e){var t,n;(t=j.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(n=j.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?xi.error(`failed to load script`,t):e()}))}hr(){var e;if(A){if(!this.lr&&(e=j.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=I(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.lr=j.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.lr.start(A),xi.info(`starting...`)}}else xi.error("`document` not found. Cannot start.")}stop(){this.lr&&(this.lr.stop(),this.lr=void 0,xi.info(`stopping...`))}},Ti=U(`[SegmentIntegration]`),Ei=`posthog-js`;function Di(e,t){var{organization:n,projectId:r,prefix:i,severityAllowList:a=[`error`],sendExceptionsToPostHog:o=!0}=t===void 0?{}:t;return t=>{if(a!==`*`&&!a.includes(t.level)||!e.__loaded)return t;t.tags||={};var s=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var c,l=t.exception?.values||[],u=l.map((e=>N({},e,{stacktrace:e.stacktrace?N({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>N({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:l[0]?.value||t.message,$exception_type:l[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:l[0]?.value||t.message,$sentry_exception_type:l[0]?.type,$sentry_tags:t.tags};return n&&r&&(d.$sentry_url=(i||`https://sentry.io/organizations/`)+n+`/issues/?project=`+r+`&query=`+t.event_id),o&&((c=e.exceptions)==null||c.sendExceptionEvent(d)),t}}var Oi=class{constructor(e,t,n,r,i,a){this.name=Ei,this.setupOnce=function(o){o(Di(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},ki=class{constructor(e){this.cr=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(H.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.dr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.vr()}vr(){this.pr=this._instance.sessionManager?.onSessionId(this.cr)}destroy(){var e;(e=this.pr)==null||e.call(this),this.pr=void 0}doPageView(e,t){var n=this.gr(e,t);return this.dr={pathname:O?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.gr(e,this.dr?.pageViewId)}doEvent(){return{$pageview_id:this.dr?.pageViewId}}gr(e,t){var n=this.dr;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:s,maxContentHeight:c,lastContentY:l,maxContentY:u}=i;if(!(L(a)||L(o)||L(s)||L(c)||L(l)||L(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?at(o/a,0,1,H):1,f=a>1?at(s/a,0,1,H):1,p=c>1?at(l/c,0,1,H):1,m=c>1?at(u/c,0,1,H):1;r=G(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},Ai={[Wn]:{exposure:`hidden`},[Kn]:{exposure:`hidden`},__cmpns:{exposure:`hidden`},[qn]:{exposure:`hidden`},[Jn]:{exposure:`event`},[Yn]:{exposure:`hidden`},[Xn]:{exposure:`event`},[Zn]:{exposure:`hidden`},[Qn]:{exposure:`event`},[$n]:{exposure:`event`},[er]:{exposure:`event`},[tr]:{exposure:`hidden`},[nr]:{exposure:`event`},[rr]:{exposure:`hidden`},$session_recording_enabled_server_side:{exposure:`hidden`},[cr]:{exposure:`hidden`},[lr]:{exposure:`event`},$session_past_minimum_duration:{exposure:`event`},$session_recording_url_trigger_activated_session:{exposure:`event`},$session_recording_event_trigger_activated_session:{exposure:`event`},$debug_first_full_snapshot_timestamp:{exposure:`event`},[ur]:{exposure:`derived`,shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!I(e))return{};for(var t={},n=Object.keys(e),r=0;n.length>r;r++)t[`$feature/`+n[r]]=e[n[r]];return t}},[dr]:{exposure:`event`},[fr]:{exposure:`hidden`},[pr]:{exposure:`hidden`},[mr]:{exposure:`event`},[hr]:{exposure:`event`},[gr]:{exposure:`event`},[_r]:{exposure:`hidden`},[vr]:{exposure:`hidden`},[yr]:{exposure:`hidden`},[br]:{exposure:`hidden`},[xr]:{exposure:`event`},[Sr]:{exposure:`hidden`},$product_tours_activated:{exposure:`hidden`},$conversations_widget_session_id:{exposure:`event`},$conversations_ticket_id:{exposure:`event`},$conversations_widget_state:{exposure:`event`},$conversations_user_traits:{exposure:`event`},[Cr]:{exposure:`hidden`},[wr]:{exposure:`hidden`},[Tr]:{exposure:`hidden`},[Er]:{exposure:`hidden`},[Dr]:{exposure:`hidden`},[Or]:{exposure:`hidden`},[kr]:{exposure:`hidden`},[Ar]:{exposure:`hidden`},[jr]:{exposure:`hidden`},[Mr]:{exposure:`hidden`},[Nr]:{exposure:`hidden`},[ir]:{exposure:`event`},[ar]:{exposure:`event`},[or]:{exposure:`event`},[sr]:{exposure:`event`},[Ir]:{exposure:`event`},[Lr]:{exposure:`event`},[Rr]:{exposure:`event`},$sdk_debug_replay_event_trigger_status:{exposure:`event`},$sdk_debug_replay_linked_flag_trigger_status:{exposure:`event`},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:`event`},$sdk_debug_replay_remote_trigger_matching_config:{exposure:`event`},$sdk_debug_replay_trigger_groups_count:{exposure:`event`},$sdk_debug_replay_url_trigger_status:{exposure:`event`},$session_recording_start_reason:{exposure:`event`}},ji=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],Mi=e=>{var t=A?.createElement(`a`);return L(t)?null:(t.href=e,t)},Ni=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);if(a[0]===t){n=a;break}}if(!F(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{H.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},Pi=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);F(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},Fi=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},Ii=`https?://(.*)`,Li=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],Ri=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Li],zi=`<masked>`,Bi=[`li_fat_id`];function Vi(e,t,n){if(!A)return{};var r,i=t?[...Li,...n||[]]:[],a=Hi(Pi(A.URL,i,zi),e);return G((r={},W(Bi,(function(e){var t=mi.O(e);r[e]=t||null})),r),a)}function Hi(e,t){var n=Ri.concat(t||[]),r={};return W(n,(function(t){r[t]=Ni(e,t)||null})),r}function Ui(e){var t=function(e){return e?e.search(Ii+`google.([^/?]*)`)===0?`google`:e.search(Ii+`bing.com`)===0?`bing`:e.search(Ii+`yahoo.com`)===0?`yahoo`:e.search(Ii+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!qe(t)){r.$search_engine=t;var i=A?Ni(A.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function Wi(){return navigator.language||navigator.userLanguage}var Gi=`$direct`;function Ki(){return A?.referrer||Gi}function qi(e,t){var n=e?[...Li,...t||[]]:[],r=Te?.href.substring(0,1e3);return{r:Ki().substring(0,1e3),u:r?Pi(r,n,zi):void 0}}function Ji(e){var{r:t,u:n}=e,r={$referrer:t,$referring_domain:t==null?void 0:t==Gi?Gi:Mi(t)?.host};if(n){r.$current_url=n;var i=Mi(n);r.$host=i?.host,r.$pathname=i?.pathname,G(r,Hi(n))}return t&&G(r,Ui(t)),r}function Yi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Xi(){try{return new Date().getTimezoneOffset()}catch{return}}var Zi=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Qi=class{constructor(e,t){this.Bt=e,this.props={},this.mr=!1,this.yr=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(e),this.nr=this.br(e),this.load(),e.debug&&H.info(`Persistence loaded`,e.persistence,N({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.wr}br(e){Zi.indexOf(e.persistence.toLowerCase())===-1&&(H.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);var t=function(e){e===void 0&&(e=[]);var t=[...gi,...e];return N({},q,{Z(e){try{var t={};try{t=mi.Z(e)||{}}catch{}var n=G(t,JSON.parse(q.O(e)||`{}`));return q.M(e,n),n}catch{}return null},M(e,n,r,i,a,o){try{q.M(e,n,void 0,void 0,o);var s={};t.forEach((e=>{n[e]&&(s[e]=n[e])})),Object.keys(s).length&&mi.M(e,s,r,i,a,o)}catch(e){q.B(e)}},F(e,t){try{O?.localStorage.removeItem(e),mi.F(e,t)}catch(e){q.B(e)}}})}(e.cookie_persisted_properties||[]),n=e.persistence.toLowerCase();return n===`localstorage`&&q.R()?q:n===`localstorage+cookie`&&t.R()?t:n===`sessionstorage`&&J.R()?J:n===`memory`?vi:n===`cookie`?mi:t.R()?t:mi}_r(e){var t=e??this.Bt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[Er];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return W(this.props,((t,n)=>{var r=(e=>{var t=Ai[e];if(t)return t;for(var[n,r]of ji)if(e.indexOf(n)===0)return r})(n);if(r?.exposure===`derived`){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t,n===ur?()=>this._r():()=>!1))return;r.transformToEventProperties&&G(e,r.transformToEventProperties(t))}else r&&r.exposure!==`event`||(e[n]=t)})),e}load(){if(!this.wr){var e=this.nr.Z(this.yr);e&&(this.props=G({},e))}}save(){this.wr||this.nr.M(this.yr,this.props,this.Ir,this.Cr,this.Sr,this.Bt.debug)}remove(){this.nr.F(this.yr,!1),this.nr.F(this.yr,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(I(e)){L(t)&&(t=`None`),this.Ir=L(n)?this.kr:n;var r=!1;if(W(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.Tr(n,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(I(e)){this.Ir=L(t)?this.kr:t;var n=!1;if(W(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.Tr(r,t),n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Ar(e),this.save())}update_campaign_params(){if(!this.mr){var e=Vi(this.Bt.custom_campaign_params,this.Bt.mask_personal_data_properties,this.Bt.custom_personal_data_properties);Ge(ti(e))||this.register(e),this.mr=!0}}update_search_keyword(){var e;this.register((e=A?.referrer)?Ui(e):{})}update_referrer_info(){this.register_once({$referrer:Ki(),$referring_domain:A!=null&&A.referrer&&Mi(A.referrer)?.host||Gi},void 0)}set_initial_person_info(){this.props[Ar]||this.props[jr]||this.register_once({[Mr]:qi(this.Bt.mask_personal_data_properties,this.Bt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};W([jr,Ar],(t=>{var n=this.props[t];n&&W(n,(function(t,n){e[`$initial_`+Be(n)]=t}))}));var t,n,r=this.props[Mr];return r&&G(e,(t=Ji(r),n={},W(t,(function(e,t){n[`$initial_`+Be(t)]=e})),n)),e}safe_merge(e){return W(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){if(this.kr=this.Ir=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.br(e),i=this.props;this.clear(),this.nr=r,this.props=i,this.save()}}set_disabled(e){this.wr=e,this.wr?this.remove():this.save()}set_cross_subdomain(e){e!==this.Cr&&(this.Cr=e,this.remove(),this.save())}set_secure(e){e!==this.Sr&&(this.Sr=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[qn]||{};n[e]=t,this.Tr(qn,n),this.save()}remove_event_timer(e){var t=this.props[qn]||{},n=t[e];return L(n)||(delete t[e],this.Tr(qn,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.Tr(e,t),this.save()}Tr(e,t){this.props[e]=t}Ar(e){delete this.props[e]}},$i={Activation:`events`,Cancellation:`cancelEvents`},ea={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},ta={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},na={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},ra={Popover:`popover`,Inline:`inline`},ia={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},aa={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},oa=U(`[RateLimiter]`),sa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{oa.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){oa.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(kr)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;return o||e||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(kr,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},ca=U(`[RemoteConfig]`),la=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=j._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Er(e){var t,n;(t=j.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=j.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Rr(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/`+this._instance.config.token+`/config`),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return ca.info(`Using preloaded remote config`,this.remoteConfig),this.Nr(this.remoteConfig),void this.Mr();if(this._instance.Fr())return void ca.warn(`Remote config is disabled. Falling back to local config.`);this.Er((e=>{if(!e)return ca.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Rr((e=>{this.Nr(e),this.Mr()}));this.Nr(e),this.Mr()}))}catch(e){ca.error(`Error loading remote config`,e)}}stop(){this.Or&&=(clearInterval(this.Or),void 0)}refresh(){this._instance.Fr()||A?.visibilityState===`hidden`||this._instance.reloadFeatureFlags()}Mr(){if(!this.Or){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.Or=setInterval((()=>{this.refresh()}),e))}}Nr(e){var t;e||ca.error(`Failed to fetch remote config from PostHog.`),this._instance.Nr(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},ua={GZipJS:`gzip-js`,Base64:`base64`},da=Uint8Array,Y=Uint16Array,fa=Uint32Array,pa=new da([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ma=new da([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ha=new da([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ga=function(e,t){for(var n=new Y(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new fa(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},_a=ga(pa,2),va=_a[1];_a[0][28]=258,va[258]=28;for(var ya=ga(ma,0)[1],ba=new Y(32768),X=0;32768>X;++X){var xa=(43690&X)>>>1|(21845&X)<<1;ba[X]=((65280&(xa=(61680&(xa=(52428&xa)>>>2|(13107&xa)<<2))>>>4|(3855&xa)<<4))>>>8|(255&xa)<<8)>>>1}var Sa=function(e,t,n){for(var r=e.length,i=0,a=new Y(t);r>i;++i)++a[e[i]-1];var o,s=new Y(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new Y(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[ba[d]>>>c]=l}else for(o=new Y(r),i=0;r>i;++i)o[i]=ba[s[e[i]-1]++]>>>15-e[i];return o},Ca=new da(288);for(X=0;144>X;++X)Ca[X]=8;for(X=144;256>X;++X)Ca[X]=9;for(X=256;280>X;++X)Ca[X]=7;for(X=280;288>X;++X)Ca[X]=8;var wa=new da(32);for(X=0;32>X;++X)wa[X]=5;var Ta=Sa(Ca,9,0),Ea=Sa(wa,5,0),Da=function(e){return(e/8>>0)+(7&e&&1)},Oa=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Y?Y:e instanceof fa?fa:da)(n-t);return r.set(e.subarray(t,n)),r},ka=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Aa=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},ja=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new da(0),0];if(i==1){var o=new da(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new Y(f+1),m=Ma(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var ee=a[r].s;t>p[ee]?h-=1<<t-p[ee]++-1:++r}for(;r>=0&&h;--r){var te=a[r].s;p[te]==t&&(--p[te],++h)}m=t}return[new da(p),m]},Ma=function(e,t,n){return e.s==-1?Math.max(Ma(e.l,t,n+1),Ma(e.r,t,n+1)):t[e.s]=n},Na=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Y(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},Pa=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Fa=function(e,t,n){var r=n.length,i=Da(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},Ia=function(e,t,n,r,i,a,o,s,c,l,u){ka(t,u++,n),++i[256];for(var d=ja(i,15),f=d[0],p=d[1],m=ja(a,15),h=m[0],g=m[1],_=Na(f),v=_[0],ee=_[1],te=Na(h),y=te[0],b=te[1],x=new Y(19),S=0;v.length>S;++S)x[31&v[S]]++;for(S=0;y.length>S;++S)x[31&y[S]]++;for(var ne=ja(x,7),C=ne[0],re=ne[1],w=19;w>4&&!C[ha[w-1]];--w);var ie,T,ae,oe,E=l+5<<3,se=Pa(i,Ca)+Pa(a,wa)+o,ce=Pa(i,f)+Pa(a,h)+o+14+3*w+Pa(x,C)+(2*x[16]+3*x[17]+7*x[18]);if(se>=E&&ce>=E)return Fa(t,u,e.subarray(c,c+l));if(ka(t,u,1+(se>ce)),u+=2,se>ce){ie=Sa(f,p,0),T=f,ae=Sa(h,g,0),oe=h;var le=Sa(C,re,0);for(ka(t,u,ee-257),ka(t,u+5,b-1),ka(t,u+10,w-4),u+=14,S=0;w>S;++S)ka(t,u+3*S,C[ha[S]]);u+=3*w;for(var ue=[v,y],de=0;2>de;++de){var fe=ue[de];for(S=0;fe.length>S;++S)ka(t,u,le[pe=31&fe[S]]),u+=C[pe],pe>15&&(ka(t,u,fe[S]>>>5&127),u+=fe[S]>>>12)}}else ie=Ta,T=Ca,ae=Ea,oe=wa;for(S=0;s>S;++S)if(r[S]>255){var pe;Aa(t,u,ie[257+(pe=r[S]>>>18&31)]),u+=T[pe+257],pe>7&&(ka(t,u,r[S]>>>23&31),u+=pa[pe]);var D=31&r[S];Aa(t,u,ae[D]),u+=oe[D],D>3&&(Aa(t,u,r[S]>>>5&8191),u+=ma[D])}else Aa(t,u,ie[r[S]]),u+=T[r[S]];return Aa(t,u,ie[256]),u+T[256]},La=new fa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ra=function(){for(var e=new fa(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),za=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Ba(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=Ra[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new da(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=Fa(c,l,e.subarray(u,d)):(c[u]=!0,l=Fa(c,l,e.subarray(u,o)))}else{for(var f=La[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new Y(32768),_=new Y(h+1),v=Math.ceil(n/3),ee=2*v,te=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<ee)&h},y=new fa(25e3),b=new Y(288),x=new Y(32),S=0,ne=0,C=(u=0,0),re=0,w=0;o>u;++u){var ie=te(u),T=32767&u,ae=_[ie];if(g[T]=ae,_[ie]=T,u>=re){var oe=o-u;if((S>7e3||C>24576)&&oe>423){l=Ia(e,c,0,y,b,x,ne,C,w,u-w,l),C=S=ne=0,w=u;for(var E=0;286>E;++E)b[E]=0;for(E=0;30>E;++E)x[E]=0}var se=2,ce=0,le=m,ue=T-ae&32767;if(oe>2&&ie==te(u-ue))for(var de=Math.min(p,oe)-1,fe=Math.min(32767,u),pe=Math.min(258,oe);fe>=ue&&--le&&T!=ae;){if(e[u+se]==e[u+se-ue]){for(var D=0;pe>D&&e[u+D]==e[u+D-ue];++D);if(D>se){if(se=D,ce=ue,D>de)break;var me=Math.min(ue,D-2),he=0;for(E=0;me>E;++E){var ge=u-ue+E+32768&32767,_e=ge-g[ge]+32768&32767;_e>he&&(he=_e,ae=ge)}}}ue+=(T=ae)-(ae=g[T])+32768&32767}if(ce){y[C++]=268435456|va[se]<<18|ya[ce];var ve=31&va[se],ye=31&ya[ce];ne+=pa[ve]+ma[ye],++b[257+ve],++x[ye],re=u+se,++S}else y[C++]=e[u],++b[e[u]]}}l=Ia(e,c,!0,y,b,x,ne,C,w,u-w,l)}return Oa(s,0,r+Da(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&za(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),za(l,u-8,n.d()),za(l,u-4,r),l}var Va=!!De||!!Ee,Ha=`text/plain`,Ua=!1,Wa=function(e,t,n){n===void 0&&(n=!0);var[r,i]=e.split(`?`),a=N({},t),o=i?.split(`&`).map((e=>{var t,[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],r+`=`+o}))??[],s=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return W(e,(function(e,t){L(e)||L(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(a);return s&&o.push(s),r+`?`+o.join(`&`)},Ga=(e,t)=>JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t),Ka=e=>{if(e.tr)return e.tr;var{data:t,compression:n}=e;if(t){if(n===ua.GZipJS){var r=Ba(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new da(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new da(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return Oa(r,0,i)}(Ga(t)),{mtime:0});return{contentType:Ha,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===ua.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Ga(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(Ga(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=Ga(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},qa=function(){var e=Ne((function*(e){var t=yield function(e,t,n){return Fe.apply(this,arguments)}(Ga(e.data),M.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return N({},e,{tr:{contentType:Ha,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Ja=(e,t)=>Wa(e,{_:new Date().getTime().toString(),ver:M.JS_SDK_VERSION,compression:t}),Ya=[];Ee&&Ya.push({transport:`fetch`,method(e){var{contentType:t,body:n,estimatedSize:r}=Ka(e)??{},i=new Headers;W(e.headers,(function(e,t){i.append(t,e)})),t&&i.append(`Content-Type`,t);var a=e.url,o=null;if(Oe){var s=new Oe;o={signal:s.signal,timeout:setTimeout((()=>s.abort()),e.timeout)}}Ee(a,N({method:e?.method||`GET`,headers:i,keepalive:e.method===`POST`&&52428.8>(r||0),body:n,signal:o?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){H.error(e)}e.callback==null||e.callback(r)})))).catch((t=>{H.error(t),e.callback==null||e.callback({statusCode:0,error:t})})).finally((()=>o?clearTimeout(o.timeout):null))}}),De&&Ya.push({transport:`XHR`,method(e){var t=new De;t.open(e.method||`GET`,e.url,!0);var{contentType:n,body:r}=Ka(e)??{};W(e.headers,(function(e,n){t.setRequestHeader(n,e)})),n&&t.setRequestHeader(`Content-Type`,n),e.timeout&&(t.timeout=e.timeout),e.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}e.callback==null||e.callback(n)}},t.send(r)}}),we!=null&&we.sendBeacon&&Ya.push({transport:`sendBeacon`,method(e){var t=Wa(e.url,{beacon:`1`});try{var{contentType:n,body:r}=Ka(e)??{};if(!r)return;var i=r instanceof Blob?r:new Blob([r],{type:n});we.sendBeacon(t,i)}catch{}}});var Xa=3e3,Za=class{constructor(e,t){this.Pr=!0,this.Lr=[],this.Dr=at(t?.flush_interval_ms||Xa,250,5e3,H.createLogger(`flush interval`),Xa),this.Br=e}enqueue(e){this.Lr.push(e),this.jr||this.$r()}unload(){this.qr();var e=this.Lr.length>0?this.Zr():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Br(N({},e,{transport:`sendBeacon`}))}))}enable(){this.Pr=!1,this.$r()}$r(){var e=this;this.Pr||(this.jr=setTimeout((()=>{if(this.qr(),this.Lr.length>0){var t=this.Zr(),n=function(){var n=t[r],i=new Date().getTime();n.data&&F(n.data)&&W(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.Br(n)};for(var r in t)n()}}),this.Dr))}qr(){clearTimeout(this.jr),this.jr=void 0}Zr(){var e={};return W(this.Lr,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;L(e[i])&&(e[i]=N({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Lr=[],e}},Qa=[`retriesPerformedSoFar`],$a=class{constructor(e){this.Hr=!1,this.Vr=3e3,this.Lr=[],this._instance=e,this.Lr=[],this.zr=!0,!L(O)&&`onLine`in O.navigator&&(this.zr=O.navigator.onLine,this.Ur=()=>{this.zr=!0,this.Yr()},this.Gr=()=>{this.zr=!1},K(O,`online`,this.Ur),K(O,`offline`,this.Gr))}get length(){return this.Lr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=Pe(e,Qa);Ye(t)&&(n.url=Wa(n.url,{retry_count:t})),this._instance._send_request(N({},n,{callback:e=>{e.statusCode===200||e.statusCode>=400&&500>e.statusCode||(t??0)>=10?n.callback==null||n.callback(e):this.Wr(N({retriesPerformedSoFar:t},n))}}))}Wr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.Lr.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),H.warn(i),this.Hr||(this.Hr=!0,this.Xr())}Xr(){if(this.Jr&&clearTimeout(this.Jr),this.Lr.length===0)return this.Hr=!1,void(this.Jr=void 0);this.Jr=setTimeout((()=>{this.zr&&this.Lr.length>0&&this.Yr(),this.Xr()}),this.Vr)}Yr(){var e=Date.now(),t=[],n=this.Lr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Lr=t,n.length>0)for(var{requestOptions:r}of n)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Jr&&=(clearTimeout(this.Jr),void 0),this.Hr=!1,L(O)||(this.Ur&&=(O.removeEventListener(`online`,this.Ur),void 0),this.Gr&&=(O.removeEventListener(`offline`,this.Gr),void 0)),this.Lr))try{this._instance._send_request(N({},e,{transport:`sendBeacon`}))}catch(e){H.error(e)}this.Lr=[]}},eo=class{constructor(e){this.Kr=()=>{this.Qr||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.Qr.lastScrollY=Math.ceil(t),this.Qr.maxScrollY=Math.max(t,this.Qr.maxScrollY??0),this.Qr.maxScrollHeight=Math.max(n,this.Qr.maxScrollHeight??0),this.Qr.lastContentY=r,this.Qr.maxContentY=Math.max(r,this.Qr.maxContentY??0),this.Qr.maxContentHeight=Math.max(i,this.Qr.maxContentHeight??0)},this._instance=e}get ei(){return this._instance.config.scroll_root_selector}getContext(){return this.Qr}resetContext(){var e=this.Qr;return setTimeout(this.Kr,0),e}startMeasuringScrollPosition(){K(O,`scroll`,this.Kr,{capture:!0}),K(O,`scrollend`,this.Kr,{capture:!0}),K(O,`resize`,this.Kr)}scrollElement(){if(!this.ei)return O?.document.documentElement;for(var e of F(this.ei)?this.ei:[this.ei]){var t=O?.document.querySelector(e);if(t)return t}}scrollY(){if(this.ei){var e=this.scrollElement();return e&&e.scrollTop||0}return O&&(O.scrollY||O.pageYOffset||O.document.documentElement.scrollTop)||0}scrollX(){if(this.ei){var e=this.scrollElement();return e&&e.scrollLeft||0}return O&&(O.scrollX||O.pageXOffset||O.document.documentElement.scrollLeft)||0}},to=e=>qi(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties),no=class{constructor(e,t,n,r){this.ti=e=>{var t=this.ri();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.ii(this._instance)};this.ni.register({[Or]:n})}},this._instance=e,this.si=t,this.ni=n,this.ii=r||to,this.si.onSessionId(this.ti)}ri(){return this.ni.props[Or]}getSetOnceProps(){var e=this.ri()?.props;return e?`r`in e?Ji(e):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return W(ti(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+Be(n)]=t})),e}},ro=class{constructor(){this.oi={}}on(e,t){return this.oi[e]||(this.oi[e]=[]),this.oi[e].push(t),()=>{this.oi[e]=this.oi[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.oi[e]||[])n(t);for(var r of this.oi[`*`]||[])r(e,t)}},io=U(`[SessionId]`),ao=class{on(e,t){return this.ai.on(e,t)}constructor(e,t,n){var r;if(this.li=[],this.ui=void 0,this.ai=new ro,this.hi=(e,t)=>!(!Ye(e)||!Ye(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===Vr)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Bt=e.config,this.ni=e.persistence,this.ci=void 0,this.di=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=t||ui,this.fi=n||ui;var i=this.Bt.persistence_name||this.Bt.token;if(this._sessionTimeoutMs=1e3*at(this.Bt.session_idle_timeout_seconds||1800,60,36e3,io.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi=`ph_`+i+`_window_id`,this.mi=`ph_`+i+`_primary_window_exists`,this.yi()){var a=J.Z(this.gi),o=J.Z(this.mi);a&&!o?this.ci=a:J.F(this.gi),J.M(this.mi,!0)}if((r=this.Bt.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Bt.bootstrap.sessionID.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})();this.bi(this.Bt.bootstrap.sessionID,new Date().getTime(),s)}catch(e){io.error(`Invalid sessionID in bootstrap`,e)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(this.li)&&(this.li=[]),this.li.push(e),this.di&&e(this.di,this.ci),()=>{this.li=this.li.filter((t=>t!==e))}}yi(){return this.Bt.persistence!==`memory`&&!this.ni.wr&&J.R()}Ii(e){e!==this.ci&&(this.ci=e,this.yi()&&J.M(this.gi,e))}Ci(){return this.ci?this.ci:this.yi()?J.Z(this.gi):null}bi(e,t,n){e===this.di&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.di=e,this.ni.register({[cr]:[t,e,n]}))}Si(){var e=this.ni.props[cr];return F(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.bi(null,null,null)}destroy(){clearTimeout(this.xi),this.xi=void 0,this.ui&&O&&(O.removeEventListener(Kr,this.ui,{capture:!1}),this.ui=void 0),this.li=[]}wi(){this.ui=()=>{this.yi()&&J.F(this.mi)},K(O,Kr,this.ui,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Bt.cookieless_mode===Vr)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),[r,i,a]=this.Si(),o=this.Ci(),s=Ye(a)&&Math.abs(n-a)>864e5,c=!1,l=!i,u=!l&&!e&&this.hi(n,r);l||u||s?(i=this.vi(),o=this.fi(),io.info(`new session ID generated`,{sessionId:i,windowId:o,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}}),a=n,c=!0):o||(o=this.fi(),c=!0);var d=Ye(r)&&e&&!s?r:n,f=Ye(a)?a:new Date().getTime();return this.Ii(o),this.bi(i,d,f),e||this.pi(),c&&this.li.forEach((e=>e(i,o,c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0))),{sessionId:i,windowId:o,sessionStartTimestamp:f,changeReason:c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0,lastActivityTimestamp:r}}pi(){clearTimeout(this.xi),this.xi=setTimeout((()=>{var[e]=this.Si();if(this.hi(new Date().getTime(),e)){var t=this.di;this.resetSessionId(),this.ai.emit(`forcedIdleReset`,{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},oo=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Le(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>Le(e?.brand,t))))return!0}catch{}return!!e.webdriver},so=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function co(e,t,n){return Ga({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var lo={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>so(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!so(t,e))))),icontains:(e,t)=>t.map(uo).some((t=>e.map(uo).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(uo).every((t=>e.map(uo).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},uo=e=>e.toLowerCase();function fo(e,t){return!e||Object.entries(e).every((e=>{var[n,r]=e,i=t?.[n];if(L(i)||qe(i))return!1;var a=[String(i)],o=lo[r.operator];return!!o&&o(r.values,a)}))}var po,mo,ho=`custom`,go=`i.posthog.com`,_o=/^\/static\//,vo=class{constructor(e){this.ki={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+go,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.ki[this.apiHost]||(this.ki[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:ho),this.ki[this.apiHost]}Ti(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof t==`string`&&_o.test(e))return t.trim().replace(/\/$/,``)||void 0}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.uiHost+t;if(e===`flags`)return this.flagsApiHost+t;if(e===`assets`){var n=this.Ti(t);if(n)return``+n+t}if(this.region===ho)return this.apiHost+t;var r=go+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+r;case`api`:return`https://`+this.region+`.`+r}}};po===void 0&&(po=e=>e()),mo===void 0&&(mo=console),mo.log.bind(mo),mo.warn.bind(mo),mo.error.bind(mo),mo.debug.bind(mo);var Z=U(`[Surveys]`),yo=`seenSurvey_`,bo=[ea.Popover,ea.Widget,ea.API],xo={ignoreConditions:!1,ignoreDelay:!1,displayType:ra.Popover},So=U(`[PostHog ExternalIntegrations]`),Co={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},wo=class{constructor(e){this._instance=e}ur(e,t){var n;(n=j.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return So.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var n,i,a;!r||(n=j.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[t]||e.ur(Co[t],(()=>{var n;(n=j.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[t])==null||n.start(e._instance)})),!r&&(i=j.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[t]&&((a=j.__PosthogExtensions__)==null||(a=a.integrations)==null||(a=a[t])==null||a.stop())};for(var[n,r]of Object.entries((i=this._instance.config.integrations)??{})){var i;t(n)}}},To,Eo={},Do=0,Oo=()=>{},ko=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,Ao=`Surveys module not available`,jo=`sanitize_properties is deprecated. Use before_send instead`,Mo=`Invalid value for property_denylist config: `,No=`posthog`,Po=!Va&&Ae?.indexOf(`MSIE`)===-1&&Ae?.indexOf(`Mozilla`)===-1,Fo=e=>{var t;return N({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,token:``,autocapture:!0,cross_subdomain_cookie:ri(A?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:Oo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:Te&&R(Te?.search)&&Te.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(O==null||(t=O.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){H.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Wr,before_send:void 0,request_queue_config:{flush_interval_ms:Xa},error_tracking:{},_onCapture:Oo,__preview_eager_load_replay:!1},(e=>({rageclick:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2025-11-30`?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},Io=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],Lo=e=>{var t={};for(var[n,r]of Io)L(e[n])||(t[r]=e[n]);var i=G({},t,e);return F(e.property_blacklist)&&(L(e.property_denylist)?i.property_denylist=e.property_blacklist:F(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:H.error(Mo+e.property_denylist)),i},Ro=class{constructor(){this.__forceAllowLocalhost=!1}get Ai(){return this.__forceAllowLocalhost}set Ai(e){H.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},zo=class e{Ei(e,t){if(e){var n=this.Ri.indexOf(e);n!==-1&&this.Ri.splice(n,1)}return this.Ri.push(t),t.initialize==null||t.initialize(),t}Ni(){return this.config.cookieless_mode===Vr||this.config.cookieless_mode===Br&&this.consent.isRejected()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new Ro,this.Mi=!1,this.version=M.LIB_VERSION,this.Fi=new ro,this.Ri=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Fo(),this.SentryIntegration=Oi,this.sentryIntegration=e=>function(e,t){var n=Di(e,t);return{name:Ei,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Oi=!1,this.Pi=null,this.Li=null,this.Di=null,this.scrollManager=new eo(this),this.pageViewManager=new ki(this),this.rateLimiter=new sa(this),this.requestRouter=new vo(this),this.consent=new bi(this),this.externalIntegrations=new wo(this);var t=e.__defaultExtensionClasses??{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,n)=>{var r=R(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=R(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>H.info(`send "`+e?.event+`"`,e)))}init(t,n,r){if(r&&r!==No){var i=Eo[r]??new e;return i._init(t,n,r),Eo[r]=i,Eo[No][r]=i,i}return this._init(t,n,r)}_init(e,t,n){var r;if(t===void 0&&(t={}),L(e)||Ke(e))return H.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`),this;this.__loaded=!0,this.config={},t.debug=this.Bi(t.debug),this.ji=t,this.$i=[],t.person_profiles?this.Li=t.person_profiles:t.process_person&&(this.Li=t.process_person),this.set_config(G({},Fo(t.defaults),Lo(t),{name:n,token:e})),this.config.on_xhr_error&&H.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:ua.GZipJS;var i=this.qi();this.persistence=new Qi(this.config,i),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Qi(N({},this.config,{persistence:`sessionStorage`}),i);var a=N({},this.persistence.props),o=N({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zi=new Za((e=>this.Hi(e)),this.config.request_queue_config),this.Vi=new $a(this),this.__request_queue=[];var s=this.Ni();if(s||(this.sessionManager=new ao(this),this.sessionPropsManager=new no(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(H.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.zi(s)}),0)):(H.info(`Initializing extensions synchronously`),this.zi(s)),M.DEBUG=M.DEBUG||this.config.debug,M.DEBUG&&H.info(`Starting in debug mode`,{this:this,config:t,thisC:N({},this.config),p:a,s:o}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=N({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),t.bootstrap?.distinctID!==void 0){var c=t.bootstrap.distinctID,l=this.get_distinct_id(),u=this.persistence.get_property(Dr);if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===Hr)this.identify(c);else if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===Ur)H.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var d=this.config.get_device_id(ui()),f=t.bootstrap.isIdentifiedID?d:c;this.persistence.set_property(Dr,t.bootstrap.isIdentifiedID?Ur:Hr),this.register({distinct_id:c,$device_id:f})}}if(s)this.register_once({distinct_id:Fr,$device_id:null},``);else if(!this.get_distinct_id()){var p=this.config.get_device_id(ui());this.register_once({distinct_id:p,$device_id:p},``),this.persistence.set_property(Dr,Hr)}return K(O,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||ui();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(Dr,Ur)),t()},i=n.user();`then`in i&&We(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{Promise&&Promise.resolve||Ti.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Ti.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Ti.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,qr),identify:e=>t(e,Yr),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.Ui())):this.Ui(),We(this.config._onCapture)&&this.config._onCapture!==Oo&&(H.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&H.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}zi(t){var n=performance.now(),r=N({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Ri.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Ri.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Ri.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Ri.push(new r.tracingHeaders(this)),r.siteApps&&this.Ri.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Ri.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Ri.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Ri.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Ri.push(this.logs=this.logs??new r.logs(this)),r.conversations&&this.Ri.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Ri.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Ri.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Ri.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Ri.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Ri.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,Ci)),r.toolbar&&this.Ri.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Ri.push(this.experiments=this.experiments??new r.experiments(this)),this.Ri.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.Yi){var e=this.Yi;this.Yi=void 0,this.Nr(e)}})),this.Gi(i,n)}Gi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Gi(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){H.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({[Ir]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Lr]:r}),this.config.__preview_deferred_init_extensions&&H.info(`PostHog extensions initialized (`+r+`ms)`)}Nr(e){var t;if(!A||!A.body)return H.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Nr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Yi=e),this.Wi=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=P(e.supportedCompression,ua.GZipJS)?ua.GZipJS:P(e.supportedCompression,ua.Base64)?ua.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Li?this.Li:Wr}),this.Ri.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}Ui(){try{this.config.loaded(this)}catch(e){H.critical("`loaded` function failed",e)}if(this.Xi(),this.config.internal_or_test_user_hostname&&Te!=null&&Te.hostname){var e=Te.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ni())&&this.Ji()}),1),this.Ki=new la(this),this.Ki.load()}Xi(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Zr(this.__request_queue,(e=>this.Hi(e))),this.__request_queue=[],this.Xi()}_handle_unload(){var e,t,n,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Qi()&&this.capture(Jr),(t=this.logs)==null||t.flushLogs(`sendBeacon`),(n=this.Zi)==null||n.unload(),(r=this.Vi)==null||r.unload()):this.Qi()&&this.capture(Jr,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded&&(Po?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Wa(e.url,{ip:+!!this.config.ip}),e.headers=N({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=N({},e);t.timeout=t.timeout||6e4,t.url=Ja(t.url,t.compression);var n=t.transport??`fetch`,r=Ya.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),i=function(e,t){for(var r=0;e.length>r;r++)if(e[r].transport===n)return e[r]}(r)?.method??r[0].method;if(!i)throw Error(`No available transport method`);n!==`sendBeacon`&&t.data&&t.compression===ua.GZipJS&&ke&&!Ua?qa(t).then((e=>{i(e)})).catch((n=>{if((e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`)(n))return Ua=!0,void i(N({},t,{compression:void 0,url:Ja(e.url,void 0)}));i(t)})):i(t)})(N({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))))}Hi(e){this.Vi?this.Vi.retriableRequest(e):this._send_request(e)}_execute_array(e){Do++;try{var t,n=[],r=[],i=[];Zr(e,(e=>{e&&(F(t=e[0])?i.push(e):We(e)?e.call(this):F(e)&&t===`alias`?n.push(e):F(e)&&t.indexOf(`capture`)!==-1&&We(this[t])?i.push(e):r.push(e))}));var a=function(e,t){Zr(e,(function(e){if(F(e[0])){var n=t;W(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}))};a(n,this),a(r,this),a(i,this)}finally{Do--}}push(t){if(Do>0&&F(t)&&R(t[0])){var n=e.prototype[t[0]];We(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(e,t,n){var r,i,a,o;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zi){if(this.is_capturing())if(!L(e)&&R(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){t!=null&&t.$current_url&&!R(t?.$current_url)&&(H.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.en||H.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var l=new Date,u=n?.timestamp||l,d=ui(),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===qr&&this.config.__preview_capture_bot_pageviews&&s&&(f.event=`$bot_pageview`,f.properties.$browser_type=`bot`),c&&(f.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),n!=null&&n.$set&&(f.$set=n?.$set);var p,m,h,g=this.tn(n?.$set_once,e!==Xr,e===Yr);if(g&&(f.$set_once=g),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>R(e)?e.slice(0,r):e,o=new Set,f=function e(t,n){return t===Object(t)?o.has(t)?void 0:(o.add(t),F(t)?(r=[],Zr(t,(t=>{r.push(e(t))}))):(r={},W(t,((t,n)=>{o.has(t)||(r[n]=e(t,n))}))),r):a?a(t):t;var r}(i)),f.timestamp=u,L(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),e===ta.DISMISSED||e===ta.SENT){var _=t?.[na.SURVEY_ID],v=t?.[na.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>{var n=``+yo+t.id;return t.current_iteration&&t.current_iteration>0&&(n=``+yo+t.id+`_`+t.current_iteration),n})(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){Z.error(`Failed to persist survey seen state`,e)}})({id:_,current_iteration:v}),f.$set=N({},f.$set,{[(p={id:_,current_iteration:v},m=e===ta.SENT?`responded`:`dismissed`,h=`$survey_`+m+`/`+p.id,p.current_iteration&&p.current_iteration>0&&(h=`$survey_`+m+`/`+p.id+`/`+p.current_iteration),h)]:!0})}else e===ta.SHOWN&&(f.$set=N({},f.$set,{[na.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===ia.SHOWN){var ee=t?.[aa.TOUR_TYPE];ee&&(f.$set=N({},f.$set,{[aa.TOUR_LAST_SEEN_DATE+`/`+ee]:new Date().toISOString()}))}var te=N({},f.properties.$set,f.$set);if(Ge(te)||this.setPersonPropertiesForFlags(te),!z(this.config.before_send)){var y=this.rn(f);if(!y)return;f=y}this.Fi.emit(`eventCaptured`,f);var b={method:`POST`,url:n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),data:f,compression:`best-available`,batchKey:n?._batchKey};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Hi(b):this.Zi.enqueue(b),f}H.critical(`This capture call is ignored due to client rate limiting.`)}}else H.error(`No event name provided to posthog.capture`)}else H.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}calculateEventProperties(e,t,n,r,i){if(n||=new Date,!this.persistence||!this.sessionPersistence)return t;var a=i?void 0:this.persistence.remove_event_timer(e),o=N({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.Ni()&&(o.$cookieless_mode=!0),e===`$snapshot`){var s=N({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=s.distinct_id,(!R(o.distinct_id)&&!Je(o.distinct_id)||Ke(o.distinct_id))&&H.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),o}var c,l=function(e,t){var n,r,i;if(!Ae)return{};var a,o,s,c,l=e?[...Li,...t||[]]:[],[u,d]=function(e){for(var t=0;nn.length>t;t++){var[n,r]=nn[t],i=n.exec(e),a=i&&(We(r)?r(i,e):r);if(a)return a}return[``,``]}(Ae);return G(ti({$os:u,$os_version:d,$browser:$t(Ae,navigator.vendor),$device:rn(Ae),$device_type:(o=Ae,s={userAgentDataPlatform:(n=navigator)==null||(n=n.userAgentData)==null?void 0:n.platform,maxTouchPoints:navigator?.maxTouchPoints,screenWidth:O==null||(r=O.screen)==null?void 0:r.width,screenHeight:O==null||(i=O.screen)==null?void 0:i.height,devicePixelRatio:O?.devicePixelRatio},c=rn(o),c===ht||c===mt||c===`Kobo`||c===`Kindle Fire`||c===Gt?pt:c===Pt||c===It||c===Ft||c===Ht?`Console`:c===_t?`Wearable`:c?B:s?.userAgentDataPlatform===`Android`&&(s?.maxTouchPoints??0)>0?600>Math.min(s?.screenWidth??0,s?.screenHeight??0)/(s?.devicePixelRatio??1)?B:pt:`Desktop`),$timezone:Yi(),$timezone_offset:Xi()}),{$current_url:Pi(Te?.href,l,zi),$host:Te?.host,$pathname:Te?.pathname,$raw_user_agent:Ae.length>1e3?Ae.substring(0,997)+`...`:Ae,$browser_version:tn(Ae,navigator.vendor),$browser_language:Wi(),$browser_language_prefix:(a=Wi(),typeof a==`string`?a.split(`-`)[0]:void 0),$screen_height:O?.screen.height,$screen_width:O?.screen.width,$viewport_height:O?.innerHeight,$viewport_width:O?.innerWidth,$lib:M.LIB_NAME,$lib_version:M.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:u,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime());o.$session_id=u,o.$window_id=d}this.sessionPropsManager&&G(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&G(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.Vi?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===ho&&(o.$lib_custom_api_host=this.config.api_host),c=e!==qr||i?e!==Jr||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=G(o,c),e===qr&&A&&(o.title=A.title),!L(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}Ae&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`),(o=G({},l,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),F(this.config.property_denylist)?W(this.config.property_denylist,(function(e){delete o[e]})):H.error(Mo+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(H.error(jo),o=p(o,e));var m=this.nn();return o.$process_person_profile=m,m&&!i&&this.sn(`_calculate_event_properties`),o}tn(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.nn()||this.Mi&&!n)return e;var r=G({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(H.error(jo),r=i(r,`$set_once`)),t&&(this.Mi=!0),Ge(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}an(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.Fi.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Ao}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Ao})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Ao})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=xo),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:Ao}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:Ao})}ln(e){return!e||Ke(e)?(H.critical(`Unique user id has not been set in posthog.identify`),!1):e===Fr?(H.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(H.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return H.uninitializedWarning(`posthog.identify`);if(Je(e)&&(e=e.toString(),H.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.ln(e)&&this.sn(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Gn)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Kn)&&(this.unregister(Kn),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(Dr)||Hr)===Hr;e!==r&&a?(this.persistence.set_property(Dr,Ur),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(Yr,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.Di=co(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister(Cr))}}setPersonProperties(e,t){if((e||t)&&this.sn(`posthog.setPersonProperties`)){var n=co(this.get_distinct_id(),e,t);this.Di===n?H.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.Di=n)}}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:N({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(Xr,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else H.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.sn(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,n,r,i,a,o,s,c;if(H.info(`reset`),!this.__loaded)return H.uninitializedWarning(`posthog.reset`);var l=this.get_property(Gn);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),(r=this.surveys)==null||r.reset(),(i=this.Ki)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.conversations)==null||o.reset(),(s=this.persistence)==null||s.set_property(Dr,Hr),(c=this.sessionManager)==null||c.resetSessionId(),this.Di=null,this.config.cookieless_mode===Vr)this.register_once({distinct_id:Fr,$device_id:null},``);else{var u=this.config.get_device_id(ui());this.register_once({distinct_id:u,$device_id:e?u:l},``)}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.un()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.hn()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(Wn)?(H.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.sn(`posthog.alias`)?(L(t)&&(t=this.get_distinct_id()),e===t?(H.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.an(Kn,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=N({},this.config);if(I(e)){var n,r,i,a,o,s,c,l,u,d;G(this.config,Lo(e));var f=this.qi();(n=this.persistence)==null||n.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Qi(N({},this.config,{persistence:`sessionStorage`}),f);var p=this.Bi(this.config.debug);Xe(p)&&(this.config.debug=p),Xe(this.config.debug)&&(this.config.debug?(M.DEBUG=!0,q.R()&&q.M(`ph_debug`,!0),H.info(`set_config`,{config:e,oldConfig:t,newConfig:N({},this.config)})):(M.DEBUG=!1,q.R()&&q.F(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.exceptions)==null||i.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(s=this.heatmaps)==null||s.startIfEnabled(),(c=this.exceptionObserver)==null||c.startIfEnabledOrStop(),(l=this.deadClicksAutocapture)==null||l.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.cn(),(d=this.externalIntegrations)==null||d.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){M.LIB_NAME=e,M.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(N({},r,t))}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??e.dn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??No;return e!==No&&(e=No+`.`+e),e}_isIdentified(){return this.persistence?.get_property(Dr)===Ur||this.sessionPersistence?.get_property(Dr)===Ur}nn(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===Wr&&!this._isIdentified()&&Ge(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Kn])&&((t=this.persistence)==null||(t=t.props)==null||!t[Nr]))}Qi(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.nn()||this.sn(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.sn(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}sn(e){return this.config.person_profiles===`never`?(H.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.an(Nr,!0),!0)}qi(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Br)}cn(){var e,t,n=this.qi();return this.persistence?.wr!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.wr!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==Vr){if(this.Ni()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new ao(this),this.pageViewManager=new ki(this),this.persistence&&(this.sessionPropsManager=new no(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.Ei(this.sessionRecording,new o(this)),this.Wi&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.Wi)))}var s;this.consent.optInOut(!0),this.cn(),this.Xi(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Br&&((s=this.surveys)==null||s.loadIfEnabled()),(L(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ji()}else H.warn(ko)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===Vr?H.warn(ko):(this.config.cookieless_mode===Br&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.cn(),this.config.cookieless_mode===Br&&(this.register({distinct_id:Fr,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.Ji()))}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===Vr||(this.config.cookieless_mode===Br?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.cn()}_is_bot(){return we?oo(we,this.config.custom_blocked_useragents):void 0}Ji(){A&&(A.visibilityState===`visible`?this.Oi||(this.Oi=!0,this.capture(qr,{title:A.title},{send_instantly:!0}),this.Pi&&=(A.removeEventListener(Gr,this.Pi),null)):this.Pi||(this.Pi=this.Ji.bind(this),K(A,Gr,this.Pi)))}debug(e){!1===e?(O?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(O?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Fr(){var e,t,n,r,i,a,o=this.ji||{};return`advanced_disable_flags`in o?!!o.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(H.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):(n=`advanced_disable_decide`,r=H,i=(t=`advanced_disable_flags`)in(e=o)&&!z(e[t]),a=n in e&&!z(e[n]),i?e[t]:!!a&&(r&&r.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])):!!this.config.advanced_disable_flags}rn(e){if(z(this.config.before_send))return e;var t=F(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var r of t){if(n=r(n),z(n)){var i=`Event '`+e.event+`' was rejected in beforeSend function`;return Qe(e.event)?H.warn(i+`. This can cause unexpected behavior.`):H.info(i),null}n.properties&&!Ge(n.properties)||H.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}return n}getPageViewId(){return this.pageViewManager.dr?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Bi(e){var t=Xe(e)&&!e,n=q.R()&&q.O(`ph_debug`)===`true`;return!t&&(!!n||e)}};zo.__defaultExtensionClasses={},zo.dn={trace:To=()=>{},debug:To,info:To,warn:To,error:To,fatal:To},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=ei(e.prototype[t[n]])}(zo,[`identify`]);var Bo=1,Vo=3,Ho=11;function Uo(e){return e instanceof Element&&(e.id===Pr||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function Wo(e){return!!e&&e.nodeType===Bo}function Go(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Ko(e){return!!e&&e.nodeType===Vo}function qo(e){return!!e&&e.nodeType===Ho&&Wo(e.host)}function Jo(e){return e?ze(e).split(/\s+/):[]}function Yo(e){var t=O?.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Xo(e){var t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return Jo(t)}function Zo(e){return z(e)?null:ze(e).split(/(\s+)/).filter((e=>hs(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Qo(e){var t=``;return ss(e)&&!cs(e)&&e.childNodes&&e.childNodes.length&&W(e.childNodes,(function(e){Ko(e)&&e.textContent&&(t+=Zo(e.textContent)??``)})),ze(t)}function $o(e){return L(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var es=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function ts(e,t){if(L(t))return!0;var n,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function ns(e){var t=e.parentNode;return!(!t||!Wo(t))&&t}var rs=[`next`,`previous`,`prev`,`>`,`<`],is=[`.ph-no-rageclick`,`.ph-no-capture`],as=e=>!e||Go(e,`html`)||!Wo(e),os=(e,t)=>{if(!O||as(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!Go(i,`body`);)if(qo(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=ns(i);if(!a)break;if(t||es.indexOf(a.tagName.toLowerCase())>-1)n=!0;else{var o=O.getComputedStyle(a);o&&o.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}r.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:r}};function ss(e){for(var t=e;t.parentNode&&!Go(t,`body`);t=t.parentNode){var n=Xo(t);if(P(n,`ph-sensitive`)||P(n,`ph-no-capture`))return!1}if(P(Xo(e),`ph-include`))return!0;var r=e.type||``;if(R(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}var i=e.name||e.id||``;return!R(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function cs(e){return!!(Go(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Go(e,`select`)||Go(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var ls=`(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})`,us=RegExp(`^(?:`+ls+`)$`),ds=new RegExp(ls),fs=`\\d{3}-?\\d{2}-?\\d{4}`,ps=RegExp(`^(`+fs+`)$`),ms=RegExp(`(`+fs+`)`);function hs(e,t){return t===void 0&&(t=!0),!(z(e)||R(e)&&(e=ze(e),(t?us:ds).test((e||``).replace(/[- ]/g,``))||(t?ps:ms).test(e)))}function gs(e){var t=Qo(e);return hs(t=(t+` `+_s(e)).trim())?t:``}function _s(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&W(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=Qo(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+_s(e)).trim())}catch(e){H.error(`[AutoCapture]`,e)}})),t}function vs(e){return e.replace(/"|\\"/g,`\\"`)}function ys(e){var t=e.attr__class;return t?F(t)?t:Jo(t):void 0}var bs=class{constructor(e){this.disabled=!1===e;var t=I(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},xs=`$copy_autocapture`,Ss=U(`[AutoCapture]`);function Cs(e,t){return t.length>e?t.slice(0,e)+`...`:t}function ws(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!Wo(t));return t}function Ts(e,t){var n,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:s}=t;if(!Wo(e))return{props:{}};for(var c=[e],l=e;l.parentNode&&!Go(l,`body`);)if(qo(l.parentNode))c.push(l.parentNode.host),l=l.parentNode.host;else{if(!Wo(l.parentNode))break;c.push(l.parentNode),l=l.parentNode}var u,d,f=[],p={},m=!1,h=!1;if(W(c,(e=>{var t=ss(e);if(Go(e,`a`)){var n=e.getAttribute(`href`);m=t&&!!n&&hs(n)&&n}P(Xo(e),`ph-no-capture`)&&(h=!0),f.push(function(e,t,n,r){var i=e.tagName.toLowerCase(),a={tag_name:i};es.indexOf(i)>-1&&!n&&(a.$el_text=i.toLowerCase()===`a`||i.toLowerCase()===`button`?Cs(1024,gs(e)):Cs(1024,Qo(e)));var o=Xo(e);o.length>0&&(a.classes=o.filter((function(e){return e!==``}))),W(e.attributes,(function(n){var i;if((!cs(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&hs(n.value)&&(!R(i=n.name)||i.substring(0,10)!==`_ngcontent`&&i.substring(0,7)!==`_nghost`)){var o=n.value;n.name===`class`&&(o=Jo(o).join(` `)),a[`attr__`+n.name]=Cs(1024,o)}}));for(var s=1,c=1,l=e;l=ws(l);)s++,l.tagName===e.tagName&&c++;return a.nth_child=s,a.nth_of_type=c,a}(e,i,a,o)),G(p,function(e){if(!ss(e))return{};var t={};return W(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&hs(r)&&(t[n]=r)}})),t}(e))})),h)return{props:{},explicitNoCapture:h};if(a||(f[0].$el_text=Go(e,`a`)||Go(e,`button`)?gs(e):Qo(e)),m){var g;f[0].attr__href=m;var _=Mi(m)?.host,v=O==null||(g=O.location)==null?void 0:g.host;_&&v&&_!==v&&(u=m)}return{props:G({$event_type:r.type,$ce_version:1},s?{}:{$elements:f},{$elements_chain:(d=f,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=N({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return Qr(r).sort(((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)})).forEach((e=>{var[t,n]=e;return i[vs(t.toString())]=vs(n.toString())})),(t+=`:`)+Qr(i).map((e=>{var[t,n]=e;return t+`="`+n+`"`})).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:ys(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Qr(e).filter((e=>{var[t]=e;return t.indexOf(`attr__`)===0})).forEach((e=>{var[n,r]=e;return t.attributes[n]=r})),t}))}(d)))},(n=f[0])!=null&&n.$el_text?{$el_text:f[0]?.$el_text}:{},u&&r.type===`click`?{$external_click_url:u}:{},p)}}var Es=U(`[ExceptionAutocapture]`);function Ds(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return We(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var Os=U(`[TracingHeaders]`),ks=U(`[Web Vitals]`),As=9e5,js=`disabled`,Ms=`lazy_loading`,Ns=`awaiting_config`,Ps=`missing_config`;U(`[SessionRecording]`),U(`[SessionRecording]`);var Fs=`[SessionRecording]`,Is=U(Fs),Ls=U(`[Heatmaps]`);function Rs(e){return I(e)&&`clientX`in e&&`clientY`in e&&Je(e.clientX)&&Je(e.clientY)}var zs=U(`[Product Tours]`),Bs=[`$set_once`,`$set`],Vs=U(`[SiteApps]`),Hs=`Error while initializing PostHog app with config id `;function Us(e,t,n){if(z(e))return!1;switch(n){case`exact`:return e===t;case`contains`:var r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(r,`i`).test(e);case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Ws=class{constructor(e){this.vn=new ro,this.fn=(e,t)=>this.pn(e,t)&&this.gn(e,t)&&this.mn(e,t)&&this.yn(e,t),this.pn=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.bn=new Set,this.wn=new Set}init(){var e;L(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!L(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.wn)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.bn)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.bn.has(e)||this.bn.has(t?.event))&&this.wn&&this.wn?.size>0&&this.wn.forEach((e=>{this._n(t,e)&&this.vn.emit(`actionCaptured`,e.name)}))}In(e){this.onAction(`actionCaptured`,(t=>e(t)))}_n(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.fn(e,n))return!0;return!1}onAction(e,t){return this.vn.on(e,t)}gn(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!Us(r,t.url,t.url_matching||`contains`))return!1}return!0}mn(e,t){return!!this.Cn(e,t)&&!!this.Sn(e,t)&&!!this.xn(e,t)}Cn(e,t){var n;if(t==null||!t.href)return!0;var r=this.kn(e);if(r.length>0)return r.some((e=>Us(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&Us((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}Sn(e,t){var n;if(t==null||!t.text)return!0;var r=this.kn(e);if(r.length>0)return r.some((e=>Us(e.text,t.text,t.text_matching||`exact`)||Us(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!z(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>Us(e,a,o))))}xn(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}kn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}yn(e,t){return t==null||!t.properties||t.properties.length===0||fo(t.properties.reduce(((e,t)=>{var n=F(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},Gs=class{constructor(e){this._instance=e,this.Tn=new Map,this.An=new Map,this.En=new Map}Rn(e,t){return!!e&&fo(e.propertyFilters,t?.properties)}Nn(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}Mn(e,t,n){var r=(n===$i.Activation?this.Tn:this.An).get(e),i=[];return this.Fn((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.Rn(a,t)}))}register(e){L(this._instance?._addCaptureHook)||(this.On(e),this.Pn(e))}Pn(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.Ln??(this.Ln=new Ws(this._instance),this.Ln.init(),this.Ln.In((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.Ln)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.En.get(t.name);n&&n.push(e.id),this.En.set(t.name,n||[e.id])}})))})))}On(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this.Tn=this.Nn(e,$i.Activation),this.An=this.Nn(e,$i.Cancellation))}onEvent(e,t){var n,r=this.le(),i=this.Dn(),a=this.Bn(),o=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[i])||[];if(a===e&&t&&o.length>0){var s,c;r.info(`event matched, removing item from activated items`,{event:e,eventPayload:t,existingActivatedItems:o});var l=(t==null||(s=t.properties)==null?void 0:s.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(l){var u=o.indexOf(l);0>u||(o.splice(u,1),this.jn(o))}}else{if(this.An.has(e)){var d=this.Mn(e,t,$i.Cancellation);d.length>0&&(r.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:d.map((e=>e.id))}),d.forEach((e=>{var t=o.indexOf(e.id);0>t||o.splice(t,1),this.$n(e.id)})),this.jn(o))}if(this.Tn.has(e)){r.info(`event name matched`,{event:e,eventPayload:t,items:this.Tn.get(e)});var f=this.Mn(e,t,$i.Activation);this.jn(o.concat(f.map((e=>e.id))||[]))}}}onAction(e){var t,n=this.Dn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[];this.En.has(e)&&this.jn(r.concat(this.En.get(e)||[]))}jn(e){var t=this.le(),n=[...new Set(e)].filter((e=>!this.qn(e)));t.info(`updating activated items`,{activatedItems:n}),this.Zn(n)}getActivatedIds(){var e,t=this.Dn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.Tn}Hn(){return this.Ln}},Ks=class extends Gs{constructor(e){super(e)}Dn(){return xr}Bn(){return ta.SHOWN}Fn(e){var t;(t=this._instance)==null||t.getSurveys(e)}$n(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}le(){return Z}Zn(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[xr]:e})}qn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},qs=`SDK is not enabled or survey functionality is not yet loaded`,Js=`Disabled. Not loading surveys.`,Ys=O!=null&&O.location?Fi(O.location.hash,`__posthog`)||Fi(location.hash,`state`):null,Xs=`_postHogToolbarParams`,Zs=U(`[Toolbar]`),Q=U(`[FeatureFlags]`),Qs=U(`[FeatureFlags]`,{debugEnabled:!0}),$s=`" failed. Feature flags didn't load in time.`,ec=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},tc=e=>{var t={};for(var[n,r]of Qr(e||{}))r&&(t[n]=r);return t},nc=U(`[Error tracking]`),rc=`Refusing to render web experiment since the viewer is a likely bot`,ic={icontains:(e,t)=>!!O&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!O&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!O&&so(t.href,e),not_regex:(e,t)=>!!O&&!so(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e},ac=class e{get Bt(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.Vn(`retrieved web experiments from the server`),n.zn=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.zn&&(e.Vn(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.zn)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);R(i)&&t.variants[i]&&n.Un(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.Yn(o)&&n.Un(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Vn(rc);else if(!this.Bt.disable_web_experiments){if(z(this.zn))return this.zn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Vn(`applying feature flags`,t),t.forEach((e=>{var t;if(this.zn&&(t=this.zn)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.zn?.get(e);n&&r!=null&&r.variants[n]&&this.Un(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=Ni(t?.search,`__experiment_id`),r=Ni(t?.search,`__experiment_variant`);n&&r&&(e.Vn(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.Gn(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Bt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Bt.disable_web_experiments&&!n)return e([]);var r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=`+this.Bt.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Gn(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.Vn(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.Un(i[0].name,n,i[0].variants[n].transforms))}static Yn(t){return!z(t.conditions)&&e.Wn(t)&&e.Xn(t)}static Wn(t){if(z(t.conditions)||z(t.conditions?.url))return!0;var n,r=e.getWindowLocation();return!!r&&((n=t.conditions)==null||!n.url||ic[t.conditions?.urlMatchType??`icontains`](t.conditions.url,r))}static getWindowLocation(){return O?.location}static Xn(e){if(z(e.conditions)||z(e.conditions?.utm))return!0;var t=Vi();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static Vn(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];H.info(`[WebExperiments] `+e,n)}Un(t,n,r){this._is_bot()?e.Vn(rc):n===`control`?e.Vn(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.Vn(`applying transform of variant `+n+` for experiment `+t+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return we&&this._instance?oo(we,this.Bt.custom_blocked_useragents):void 0}},$=U(`[Conversations]`),oc=`Conversations not available yet.`,sc={featureFlags:class{constructor(e){this.Jn=!1,this.Kn=!1,this.Qn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=e,this.featureFlagEventHandlers=[]}get Bt(){return this._instance.config}get ni(){return this._instance.persistence}os(e){return this._instance.get_property(e)}ls(){var e;return(e=this.ni?._r(this.Bt.feature_flag_cache_ttl_ms))!=null&&e}us(){return!!this.ls()&&(this.ss||this.Qn||(this.ss=!0,Q.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}hs(){var e=this.Bt.evaluation_contexts??this.Bt.evaluation_environments;return!this.Bt.evaluation_environments||this.Bt.evaluation_contexts||this.ns||(Q.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.ns=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||Q.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}cs(){return this.hs().length>0}initialize(){var{config:e}=this._instance,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(n[t]&&(e[t]=n[t]),e)),{});this.receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r=n!=null&&n.merge?this.getFlagVariants():{},i=n!=null&&n.merge?this.getFlagPayloads():{},a=N({},r,e),o=N({},i,t),s={};for(var[c,l]of Object.entries(a)){var u=typeof l==`string`;s[c]={key:c,enabled:!!u||!!l,variant:u?l:void 0,reason:void 0,metadata:L(o?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:o[c]}}}this.receivedFeatureFlags({flags:s})}get hasLoadedFlags(){return this.Kn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.os(pr),t=this.os(gr),n=this.os(_r);if(!n&&!t)return e||{};var r=G({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=L(c)?(a=s?.enabled)!=null&&a:!!c,u=L(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=N({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=N({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.Jn||=(Q.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getFlagVariants(){var e=this.os(ur),t=this.os(gr);if(!t)return e||{};for(var n=G({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Jn||=(Q.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.os(mr),t=this.os(_r);if(!t)return e||{};for(var n=G({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Jn||=(Q.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.es||this.Bt.advanced_disable_feature_flags||this.ds||(this._instance.Fi.emit(`featureFlagsReloading`,!0),this.ds=setTimeout((()=>{this.vs()}),5))}fs(){clearTimeout(this.ds),this.ds=void 0}ensureFlagsLoaded(){this.Kn||this.Qn||this.ds||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.es=e}vs(e){if(this.fs(),!this._instance.Fr())if(this.Qn)this.ts=!0;else{var t=this.Bt.token,n=this.os(Gn),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:N({},this.ni?.get_initial_props()||{},this.os(vr)||{}),group_properties:this.os(yr),timezone:Yi()};qe(n)||L(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Bt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.cs()&&(r.evaluation_contexts=this.hs());var i=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Bt.advanced_only_evaluate_survey_feature_flags?`&only_evaluate_survey_feature_flags=true`:``));this.Qn=!0,this._instance._send_request({method:`POST`,url:i,data:r,compression:this.Bt.disable_compression?void 0:ua.Base64,timeout:this.Bt.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,a=!0;if(e.statusCode===200&&(this.ts||(this.$anon_distinct_id=void 0),a=!1),this.Qn=!1,!r.disable_flags||this.ts){this.rs=!a;var o=[];e.error?e.error instanceof Error?o.push(e.error.name===`AbortError`?`timeout`:`connection_error`):o.push(`unknown_error`):e.statusCode!==200&&o.push(`api_error_`+e.statusCode),(t=e.json)!=null&&t.errorsWhileComputingFlags&&o.push(`errors_while_computing_flags`);var s=!((n=e.json)==null||(n=n.quotaLimited)==null||!n.includes(`feature_flags`));s&&o.push(`quota_limited`),(i=this.ni)==null||i.register({[Tr]:o}),s?Q.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.`):(r.disable_flags||this.receivedFeatureFlags(e.json??{},a,{partialResponse:!!this.Bt.advanced_only_evaluate_survey_feature_flags}),this.ts&&(this.ts=!1,this.vs()))}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs)if(this.Kn||this.getFlags()&&this.getFlags().length>0){if(!this.us()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else Q.warn(`getFeatureFlag for key "`+e+$s)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs)if(this.Kn||this.getFlags()&&this.getFlags().length>0){if(!this.us()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.os(hr)||void 0,c=this.os(Er)||void 0,l=this.os(Cr)||{};if(this.Bt.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.os(wr);d&&d!==f&&(l={},(u=this.ni)==null||u.register({[Cr]:l,[wr]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,ee,te;F(l[e])?l[e].push(o):l[e]=[o],(p=this.ni)==null||p.register({[Cr]:l});var y=this.getFeatureFlagDetails(e),b=[...this.os(Tr)??[]];L(i)&&b.push(`flag_missing`);var x={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((m=this.Bt.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Bt.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.rs};L(y==null||(g=y.metadata)==null?void 0:g.version)||(x.$feature_flag_version=y.metadata.version);var S,ne=(y==null||(_=y.reason)==null?void 0:_.description)??(y==null||(v=y.reason)==null?void 0:v.code);ne&&(x.$feature_flag_reason=ne),y!=null&&(ee=y.metadata)!=null&&ee.id&&(x.$feature_flag_id=y.metadata.id),L(y?.original_variant)&&L(y?.original_enabled)||(x.$feature_flag_original_response=L(y.original_variant)?y.original_enabled:y.original_variant),y!=null&&(te=y.metadata)!=null&&te.original_payload&&(x.$feature_flag_original_payload=y==null||(S=y.metadata)==null?void 0:S.original_payload),b.length&&(x.$feature_flag_error=b.join(`,`)),this._instance.capture(`$feature_flag_called`,x)}if(r){var C=a;if(!L(a))try{C=JSON.parse(a)}catch{}return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:C}}}}else Q.warn(`getFeatureFlagResult for key "`+e+$s)}getRemoteConfigPayload(e,t){var n=this.Bt.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.cs()&&(r.evaluation_contexts=this.hs()),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Bt.disable_compression?void 0:ua.Base64,timeout:this.Bt.feature_flag_request_timeout_ms,callback(n){var r=n.json?.featureFlagPayloads;t(r?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs){if(this.Kn||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return L(n)?void 0:!!n}Q.warn(`isFeatureEnabled for key "`+e+$s)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.ni){this.Kn=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),a=this.getFlagsWithDetails();(function(e,t,n,r,i,a){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var o=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>[e,t[e].variant??t[e].enabled]))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>t[e].metadata?.payload)).map((e=>[e,t[e].metadata?.payload])))):Q.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(F(c)){Q.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;t&&t.register({[dr]:c,[ur]:f})}else{var m=c,h=l,g=s;if(a!=null&&a.partialResponse)m=N({},n,m),h=N({},r,h),g=N({},i,g);else if(e.errorsWhileComputingFlags)if(s){var _=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=N({},n,Object.fromEntries(Object.entries(m).filter((e=>{var[t]=e;return _.has(t)})))),h=N({},r,Object.fromEntries(Object.entries(h||{}).filter((e=>{var[t]=e;return _.has(t)})))),g=N({},i,Object.fromEntries(Object.entries(g||{}).filter((e=>{var[t]=e;return _.has(t)}))))}else m=N({},n,m),h=N({},r,h),g=N({},i,g);t&&t.register(N({[dr]:Object.keys(tc(m)),[ur]:m||{},[mr]:h||{},[pr]:g||{}},u?{[hr]:u}:{},d?{[Er]:d}:{}))}}})(e,this.ni,r,i,a,n),t||(this.ss=!1),this.ps(t)}}override(e,t){t===void 0&&(t=!1),Q.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.ni)return Q.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.ni.unregister(gr),this.ni.unregister(_r),this.ps(),Qs.info(`All overrides cleared`);if(F(e)){var t=ec(e);return this.ni.register({[gr]:t}),this.ps(),Qs.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Jn=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.ni.unregister(gr),Qs.info(`Flag overrides cleared`);else if(r.flags){if(F(r.flags)){var i=ec(r.flags);this.ni.register({[gr]:i})}else this.ni.register({[gr]:r.flags});Qs.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.ni.unregister(_r),Qs.info(`Payload overrides cleared`)):r.payloads&&(this.ni.register({[_r]:r.payloads}),Qs.info(`Payload overrides set`,{payloads:r.payloads}))),this.ps();return}if(e&&typeof e==`object`)return this.ni.register({[gr]:e}),this.ps(),Qs.info(`Flag overrides set`,{flags:e});Q.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Kn){var{flags:t,flagVariants:n}=this.gs();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.os(fr)||[]).find((t=>t.flagKey===e)),a={[`$feature_enrollment/`+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture(`$feature_enrollment_update`,o),this.setPersonPropertiesForFlags(a,!1);var s=N({},this.getFlagVariants(),{[e]:t});(r=this.ni)==null||r.register({[dr]:Object.keys(tc(s)),[ur]:s}),this.ps()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.os(fr),i=n?`&`+n.map((e=>`stage=`+e)).join(`&`):``;if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/early_access_features/?token=`+this.Bt.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.ni)==null||n.unregister(fr),(r=this.ni)==null||r.register({[fr]:i}),e(i)}}})}gs(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}ps(e){var{flags:t,flagVariants:n}=this.gs();this.featureFlagEventHandlers.forEach((r=>r(t,n,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.os(vr)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this._instance.register({[vr]:N({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(vr)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.os(yr)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=N({},n[t],e[t]),delete e[t]})),this._instance.register({[yr]:N({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.os(yr)||{};this._instance.register({[yr]:N({},t,{[e]:{}})})}else this._instance.unregister(yr)}reset(){this.Kn=!1,this.Qn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.fs(),this.Jn=!1}}},cc={sessionRecording:class{get Bt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var e;return!((e=this.ys)==null||!e.isStarted)}get status(){return this.bs===Ns||this.bs===Ps?this.bs:this.ys?.status??this.bs}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.bs=js,this.ws=void 0,this._instance=e,!this._instance.sessionManager)throw Is.error(`started without valid sessionManager`),Error(Fs+` started without valid sessionManager. This is a bug.`);if(this.Bt.cookieless_mode===Vr)throw Error(Fs+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get _s(){var e,t=!((e=this._instance.get_property(rr))==null||!e.enabled),n=!this.Bt.disable_session_recording,r=this.Bt.disable_session_recording||this._instance.consent.isOptedOut();return O&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this._s||(t=this.ys)==null||!t.isStarted){var n=!L(Object.assign)&&!L(Array.from);this._s&&n?(this.Is(e),Is.info(`starting`)):(this.bs=js,this.stopRecording())}}Is(e){var t,n,r;this._s&&(this.bs!==Ns&&this.bs!==Ps&&(this.bs=Ms),j!=null&&(t=j.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=j.__PosthogExtensions__)!=null&&n.initSessionRecording?this.Cs(e):(r=j.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.Ss,(t=>{if(t)return Is.error(`could not load recorder`,t);this.Cs(e)})))}stopRecording(){var e,t;(e=this.ws)==null||e.call(this),this.ws=void 0,(t=this.ys)==null||t.stop()}xs(){var e,t;(e=this.ws)==null||e.call(this),this.ws=void 0,(t=this.ys)==null||t.discard()}ks(){var e;(e=this.ni)==null||e.unregister(lr)}Ts(e,t){if(z(e))return null;var n,r=Je(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(Is.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}As(e){if(this.ni){var t,n=this.ni,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.Ts(this.Bt.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.Ts(t?.sampleRate,`remote config sampleRate`),a=r??i;z(a)&&this.ks();var o=t?.minimumDurationMilliseconds;n.register({[rr]:N({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:N({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:L(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.ws)==null||t.call(this),this.ws=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this.As(e),this.xs()):(this.As(e),this.startIfEnabledOrStop()):(this.bs===Ns&&(this.bs=Ps,Is.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.ys)!=null&&n.log?this.ys.log(e,t):Is.warn(`log called before recorder was ready`)}get Ss(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(rr);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}Es(){var e=this._instance.get_property(rr);if(!e)return!1;var t=(typeof e==`object`?e:JSON.parse(e)).cache_timestamp??Date.now();return 36e5>=Date.now()-t}Cs(e){var t;if((t=j.__PosthogExtensions__)==null||!t.initSessionRecording)return Is.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Rr]:!0});if(this.ys||(this.ys=j.__PosthogExtensions__?.initSessionRecording(this._instance),this.ys._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Es()){if(this.bs===Ps||this.bs===Ns)return;this.bs=Ns,Is.info(`persisted remote config is stale, requesting fresh config before starting`),new la(this._instance).load();return}this.bs=Ms,this.ys.start(e)}onRRwebEmit(e){var t;(t=this.ys)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.ys||(t=this.ni)==null||t.register({[ar]:!0}),(e=this.ys)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.ys||(t=this.ni)==null||t.register({[ir]:!0}),(e=this.ys)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.ys||(n=this.ni)==null||n.register({[e===`url`?or:sr]:!0}),(t=this.ys)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.ys?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.ys)==null||!n.tryAddCustomEvent(e,t))}}},lc={autocapture:class{constructor(e){this.Rs=!1,this.Ns=null,this.Ms=!1,this.instance=e,this.rageclicks=new bs(e.config.rageclick),this.Fs=null}initialize(){this.startIfEnabled()}get Bt(){var e=I(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}Os(){if(this.isBrowserSupported()){if(O&&A){var e=e=>{e||=O?.event;try{this.Ps(e)}catch(e){Ss.error(`Failed to capture event`,e)}};if(K(A,`submit`,e,{capture:!0}),K(A,`change`,e,{capture:!0}),K(A,`click`,e,{capture:!0}),this.Bt.capture_copied_text){var t=e=>{e||=O?.event;try{this.Ps(e,xs)}catch(e){Ss.error(`Failed to capture copy/cut event`,e)}};K(A,`copy`,t,{capture:!0}),K(A,`cut`,t,{capture:!0})}}}else Ss.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.Rs&&(this.Os(),this.Rs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.Ms=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Jn]:!!e.autocapture_opt_out}),this.Ns=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.Fs=e}getElementSelectors(e){var t,n=[];return(t=this.Fs)==null||t.forEach((t=>{(A?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[Jn];if(qe(this.Ns)&&!Xe(e)&&!this.instance.Fr())return!1;var t=this.Ns??!!e;return!!this.instance.config.autocapture&&!t}Ps(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=$o(e);Ko(r)&&(r=r.parentNode||null),t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&function(e,t){if(!O||as(e))return!1;var n,r;if(Xe(t)?(n=!!t&&is,r=void 0):(n=t?.css_selector_ignorelist??is,r=t?.content_ignorelist),!1===n)return!1;var{targetElementList:i}=os(e,!1);return!function(e,t){if(!1===e||L(e))return!1;var n;if(!0===e)n=rs;else{if(!F(e))return!1;if(e.length>10)return H.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:r}=e;return n.some((e=>t.includes(e)||r.includes(e)))}))}(r,i.map((e=>({safeText:Qo(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!ts(i,n)}(r,this.instance.config.rageclick)&&this.Ps(e,`$rageclick`);var i=t===xs;if(r&&function(e,t,n,r,i){var a,o,s;if(n===void 0&&(n=void 0),!O||as(e)||(a=n)!=null&&a.url_allowlist&&!Yo(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&Yo(n.url_ignorelist))return!1;if((s=n)!=null&&s.dom_event_allowlist){var c=n.dom_event_allowlist;if(c&&!c.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:l,targetElementList:u}=os(e,r);if(!function(e,t){var n=t?.element_allowlist;if(L(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(u,n)||!ts(u,n?.css_selector_allowlist))return!1;var d=O.getComputedStyle(e);if(d&&d.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0;var f=e.tagName.toLowerCase();switch(f){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return l?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&(es.indexOf(f)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.Bt,i,i?[`copy`,`cut`]:void 0)){var{props:a,explicitNoCapture:o}=Ts(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Bt.element_attribute_ignorelist,elementsChainAsString:this.Ms});if(o)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(a.$element_selectors=s),t===xs){var c,l=Zo(O==null||(c=O.getSelection())==null?void 0:c.toString()),u=e.type||`clipboard`;if(!l)return!1;a.$selected_content=l,a.$copy_type=u}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return We(A?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.Ls=(O==null||(t=O.location)==null?void 0:t.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(H.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.Ds&&this.Ds(),this.Ds=void 0,H.info(`History API monitoring stopped`)}monitorHistoryChanges(){var e,t;if(O&&O.history){var n=this;(e=O.history.pushState)!=null&&e.__posthog_wrapped__||Ds(O.history,`pushState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Bs(`pushState`)})),(t=O.history.replaceState)!=null&&t.__posthog_wrapped__||Ds(O.history,`replaceState`,(e=>function(t,r,i){e.call(this,t,r,i),n.Bs(`replaceState`)})),this.js()}}Bs(e){try{var t,n=O==null||(t=O.location)==null?void 0:t.pathname;if(!n)return;n!==this.Ls&&this.isEnabled&&this._instance.capture(qr,{navigation_type:e}),this.Ls=n}catch(t){H.error(`Error capturing `+e+` pageview`,t)}}js(){if(!this.Ds){var e=()=>{this.Bs(`popstate`)};K(O,`popstate`,e),this.Ds=()=>{O&&O.removeEventListener(`popstate`,e)}}}},heatmaps:class{get Bt(){return this.instance.config}constructor(e){var t;this.$s=!1,this.Rs=!1,this.qs=null,this.instance=e,this.$s=!((t=this.instance.persistence)==null||!t.props[Yn]),this.rageclicks=new bs(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return I(this.Bt.capture_heatmaps)&&this.Bt.capture_heatmaps.flush_interval_milliseconds&&(e=this.Bt.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return z(this.Bt.capture_heatmaps)?z(this.Bt.enable_heatmaps)?this.$s:this.Bt.enable_heatmaps:!1!==this.Bt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Rs)return;Ls.info(`starting...`),this.Zs(),this.Lt()}else clearInterval(this.qs??void 0),this.Hs(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Yn]:t}),this.$s=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.T;return this.T=void 0,e}Vs(e){this.Tt(e.originalEvent,`deadclick`)}Lt(){this.qs&&clearInterval(this.qs),this.qs=A?.visibilityState===`visible`?setInterval(this.Yr.bind(this),this.flushIntervalMilliseconds):null}Zs(){O&&A&&(this.zs=this.Yr.bind(this),K(O,Kr,this.zs),this.Us=e=>this.Tt(e||O?.event),K(A,`click`,this.Us,{capture:!0}),this.Ys=e=>this.Gs(e||O?.event),K(A,`mousemove`,this.Ys,{capture:!0}),this.Ws=new wi(this.instance,Si,this.Vs.bind(this)),this.Ws.startIfEnabledOrStop(),this.Xs=this.Lt.bind(this),K(A,Gr,this.Xs),this.Rs=!0)}Hs(){var e;O&&A&&(this.zs&&O.removeEventListener(Kr,this.zs),this.Us&&A.removeEventListener(`click`,this.Us,{capture:!0}),this.Ys&&A.removeEventListener(`mousemove`,this.Ys,{capture:!0}),this.Xs&&A.removeEventListener(Gr,this.Xs),clearTimeout(this.Js),(e=this.Ws)==null||e.stop(),this.Rs=!1)}Ks(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){for(var r=e;r&&Wo(r)&&!Go(r,`body`);){if(r===n)return!1;if(P(t,O?.getComputedStyle(r).position))return!0;r=ns(r)}return!1}($o(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}Tt(e,t){var n;if(t===void 0&&(t=`click`),!Uo(e.target)&&Rs(e)){var r=this.Ks(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Qs(N({},r,{type:`rageclick`})),this.Qs(r)}}Gs(e){!Uo(e.target)&&Rs(e)&&(clearTimeout(this.Js),this.Js=setTimeout((()=>{this.Qs(this.Ks(e,`mousemove`))}),500))}Qs(e){if(O){var t=O.location.href,n=this.Bt.custom_personal_data_properties,r=Pi(t,this.Bt.mask_personal_data_properties?[...Li,...n||[]]:[],zi);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(e)}}Yr(){this.T&&!Ge(this.T)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:wi,webVitalsAutocapture:class{constructor(e){var t;this.$s=!1,this.Rs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.eo=()=>{clearTimeout(this.ro),this.T.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.T.metrics.reduce(((e,t)=>N({},e,{[`$web_vitals_`+t.name+`_event`]:N({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=e=>{var t=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0);if(L(t))ks.error(`Could not read session ID. Dropping metrics!`);else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.io();L(n)||(z(e?.name)||z(e?.value)?ks.error(`Invalid metric received`,e):!this.no||this.no>e.value?(this.T.url!==n&&(this.eo(),this.ro=setTimeout(this.eo,this.flushToCaptureTimeoutMs)),L(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=L(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.T.metrics.push(N({},e,{$current_url:n,$session_id:t.sessionId,$window_id:t.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.eo()):ks.error(`Ignoring metric with value >= `+this.no,e))}},this.so=()=>{if(!this.Rs){var e,t,n,r,i=j.__PosthogExtensions__;L(i)||L(i.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:n,onINP:r}=i.postHogWebVitalsCallbacks),e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.ht.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.ht.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.ht.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.ht.bind(this)),this.Rs=!0):ks.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.$s=!((t=this._instance.persistence)==null||!t.props[$n]),this.startIfEnabled()}get oo(){return this._instance.config.capture_performance}get allowedMetrics(){var e=I(this.oo)?this.oo?.web_vitals_allowed_metrics:void 0;return z(e)?this._instance.persistence?.props[nr]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(I(this.oo)?this.oo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=I(this.oo)?this.oo.web_vitals_attribution:void 0;return e!=null&&e}get no(){var e=I(this.oo)&&Je(this.oo.__web_vitals_max_value)?this.oo.__web_vitals_max_value:As;return e>0&&6e4>=e?As:e}get isEnabled(){var e=Te?.protocol;if(e!==`http:`&&e!==`https:`)return ks.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=I(this.oo)?this.oo.web_vitals:Xe(this.oo)?this.oo:void 0;return Xe(t)?t:this.$s}startIfEnabled(){this.isEnabled&&!this.Rs&&(ks.info(`enabled, starting...`),this.ur(this.so))}onRemoteConfig(e){if(`capturePerformance`in e){var t=I(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=I(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[$n]:t}),this._instance.persistence.register({[nr]:n})),this.$s=t,this.startIfEnabled()}}ur(e){var t,n;(t=j.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=j.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?ks.error(`failed to load script`,t):e()}))}io(){var e=O?O.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return Pi(e,this._instance.config.mask_personal_data_properties?[...Li,...t||[]]:[],zi)}ks.error(`Could not determine current URL`)}}},uc={exceptionObserver:class{constructor(e){var t;this.so=()=>{var e;if(O&&this.isEnabled&&(e=j.__PosthogExtensions__)!=null&&e.errorWrappingFunctions){var t=j.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=j.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=j.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ao&&this.Bt.capture_unhandled_errors&&(this.ao=t(this.captureException.bind(this))),!this.lo&&this.Bt.capture_unhandled_rejections&&(this.lo=n(this.captureException.bind(this))),!this.uo&&this.Bt.capture_console_errors&&(this.uo=r(this.captureException.bind(this)))}catch(e){Es.error(`failed to start`,e),this.ho()}}},this._instance=e,this.co=!((t=this._instance.persistence)==null||!t.props[Xn]),this.do=new ot({refillRate:this._instance.config.error_tracking.__exceptionRateLimiterRefillRate??1,bucketSize:this._instance.config.error_tracking.__exceptionRateLimiterBucketSize??10,refillInterval:1e4,Gt:Es}),this.Bt=this.vo(),this.startIfEnabledOrStop()}vo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return I(e)?t=N({},t,e):(L(e)?this.co:e)&&(t=N({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Bt.capture_console_errors||this.Bt.capture_unhandled_errors||this.Bt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Es.info(`enabled`),this.ho(),this.ur(this.so)):this.ho()}ur(e){var t,n;(t=j.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(n=j.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return Es.error(`failed to load script`,t);e()}))}ho(){var e,t,n;(e=this.ao)==null||e.call(this),this.ao=void 0,(t=this.lo)==null||t.call(this),this.lo=void 0,(n=this.uo)==null||n.call(this),this.uo=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.co=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Xn]:this.co}),this.Bt=this.vo(),this.startIfEnabledOrStop())}onConfigChange(){this.Bt=this.vo()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.do.consumeRateLimit(r)?Es.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.fo=[],this.po=new dn([new Cn,new Nn,new Tn,new wn,new jn,new An,new Dn,new Mn],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(`
2
+ `),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=Sn.test(s)?s.replace(Sn,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return N({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||fn});var n}))}(i)}}(`web:javascript`,vn,xn)),this._instance=e,this.fo=this._instance.persistence?.get_property(Zn)??[],this.mo=Rn(this.yo()),this.bo=new zn(this.mo)}onConfigChange(){this.mo=Rn(this.yo()),this.bo.setConfig(this.mo)}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.fo=t,this._instance.persistence&&this._instance.persistence.register({[Zn]:this.fo,[Qn]:n})}}get wo(){var e,t=!!this._instance.get_property(Qn);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.po.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.mo.enabled)try{if(!R(e)||e.trim().length===0)return void nc.warn(`Ignoring exception step because message must be a non-empty string`);var{sanitizedProperties:n,droppedKeys:r}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((n,r)=>In.has(r)?(t.push(r),n):(n[r]=e[r],n)),{}),droppedKeys:t}}(this._o(t));r.length>0&&nc.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this.bo.add(N({[Pn]:e,[Fn]:new Date().toISOString()},n))}catch(e){nc.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.Io(t)){if(this.Co(t))return this.So(`Exception dropped: matched a suppression rule`),void nc.info(`Skipping exception capture because a suppression rule matched`);if(!this.wo&&this.xo(t))return this.So(`Exception dropped: thrown by a browser extension`),void nc.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ko(t))return this.So(`Exception dropped: thrown by the PostHog SDK`),void nc.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}var n=this.mo.enabled&&z(e.$exception_steps)?this.To(e):e;try{var r=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,en:!0});return r&&this.bo.clear(),r}catch(e){nc.error(`Failed to capture exception event. Dropping this exception.`,e),this.bo.clear();return}}catch(e){nc.error(`Failed to process exception event. Ignoring this exception.`,e);return}}To(e){try{var t=this.bo.getAttachable();return t.length===0?e:N({},e,{$exception_steps:t})}catch(t){return nc.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}So(e){this.mo.enabled&&this.bo.add({[Pn]:e,[Fn]:new Date().toISOString()})}_o(e){return I(e)?N({},e):{}}yo(){return this._instance.config.error_tracking?.exception_steps??{}}Co(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var{type:n,value:r}=t;return R(n)&&n.length>0&&e.$exception_types.push(n),R(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.fo.some((e=>{var n=e.values.map((e=>{var n=lo[e.operator],r=F(e.value)?e.value:[e.value],i=t[e.key]??[];return r.length>0&&n(r,i)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}xo(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}ko(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}Io(e){return!z(e)&&F(e)}}},dc=N({productTours:class{get ni(){return this._instance.persistence}constructor(e){this.Ao=null,this.Eo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.ni&&this.ni.register({[tr]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.Ao||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(tr)||this.ur((()=>this.Ro()))}ur(e){var t,n;(t=j.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=j.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?zs.error(`Could not load product tours script`,t):e()}))}Ro(){var e;!this.Ao&&(e=j.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ao=j.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!F(this.Eo)||t){var n=this.ni;if(n){var r=n.props[Sr];if(F(r)&&!t)return this.Eo=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,callback:t=>{var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;zs.error(i),e([],{isLoaded:!1,error:i});return}var a=F(t.json.product_tours)?t.json.product_tours:[];this.Eo=a,n&&n.register({[Sr]:a}),e(a,{isLoaded:!0})}})}else e(this.Eo,{isLoaded:!0})}getActiveProductTours(e){z(this.Ao)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.Ao.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ao)==null||t.showTourById(e)}previewTour(e){this.Ao?this.Ao.previewTour(e):this.ur((()=>{var t;this.Ro(),(t=this.Ao)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ao)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.Ao)==null||e.nextStep()}previousStep(){var e;(e=this.Ao)==null||e.previousStep()}clearCache(){var e;this.Eo=null,(e=this.ni)==null||e.unregister(Sr)}resetTour(e){var t;(t=this.Ao)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ao)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ao)==null||t.cancelPendingTour(e)}}},sc),fc={siteApps:class{constructor(e){this._instance=e,this.No=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Mo(e,t){if(t){var n=this.globalsForEvent(t);this.No.push(n),this.No.length>1e3&&(this.No=this.No.slice(10))}}get siteAppLoaders(){var e;return(e=j._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Mo.bind(this));this.Fo=()=>{e(),this.No=[],this.Fo=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var[i,a]of Object.entries(r))t[i]={id:n[i],type:i,properties:a};var{$set_once:o,$set:s}=e;return{event:N({},Pe(e,Bs),{properties:N({},e.properties,s?{$set:N({},e.properties?.$set??{},s)}:{},o?{$set_once:N({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.No.length&&(Vs.info(`Processing `+this.No.length+` events for site app with id `+e.id),this.No.forEach((e=>t.processEvent==null?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.Fo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Vs.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback(e){i(e)}});a&&(t.processEvent=a),r=!0}catch(t){Vs.error(Hs+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Vs.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}Oo(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}Po(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(t){Vs.error(`Error while processing event `+e.event+` for site app `+n.id,t)}}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Oo(),void this._instance.on(`eventCaptured`,(e=>this.Po(e)))):void Vs.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.Fo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(e){var t;j[`__$$ph_site_app_`+e]=i._instance,(t=j.__PosthogExtensions__)==null||t.loadSiteApp==null||t.loadSiteApp(i._instance,s,(t=>{if(t)return Vs.error(Hs+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else Vs.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},pc={tracingHeaders:class{constructor(e){this.Lo=void 0,this.Do=void 0,this.so=()=>{var e,t,n=this.Bo()||[];L(this.Lo)&&((e=j.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(n,this._instance.get_distinct_id(),this._instance.sessionManager)),L(this.Do)&&((t=j.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(n,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}ur(e){var t,n;(t=j.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=j.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return Os.error(`failed to load script`,t);e()}))}Bo(){return this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var e,t;this.Bo()?this.ur(this.so):((e=this.Lo)==null||e.call(this),(t=this.Do)==null||t.call(this),this.Lo=void 0,this.Do=void 0)}}},mc=N({surveys:class{get Bt(){return this._instance.config}constructor(e){this.jo=void 0,this._surveyManager=null,this.$o=!1,this.qo=[],this.Zo=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Bt.disable_surveys){var t=e.surveys;if(z(t))return Z.warn(`Flags not loaded yet. Not loading surveys.`);var n=F(t);this.jo=n?t.length>0:t,Z.info(`flags response received, isSurveysEnabled: `+this.jo),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(yo)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.$o)Z.info(`Already initializing surveys, skipping...`);else if(this.Bt.disable_surveys)Z.info(Js);else if(this.Bt.cookieless_mode&&this._instance.consent.isOptedOut())Z.info(`Not loading surveys in cookieless mode without consent.`);else{var e=j?.__PosthogExtensions__;if(e){if(!L(this.jo)||this.Bt.advanced_enable_surveys){var t=this.jo||this.Bt.advanced_enable_surveys;this.$o=!0;try{var n=e.generateSurveys;if(n)return void this.Ho(n,t);var r=e.loadExternalDependency;if(!r)return void this.Vo(zr);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Vo(`Could not load surveys script`,n):this.Ho(e.generateSurveys,t)}))}catch(e){throw this.Vo(`Error initializing surveys`,e),e}finally{this.$o=!1}}}else Z.error(`PostHog Extensions not found.`)}}Ho(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ks(this._instance),Z.info(`Surveys loaded successfully`),this.zo({isLoaded:!0})}Vo(e,t){Z.error(e,t),this.zo({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.qo.push(e),this._surveyManager&&this.zo({isLoaded:!0}),()=>{this.qo=this.qo.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Bt.disable_surveys)return Z.info(Js),e([]);var n,r=this._instance.get_property(br);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Zo?this.Zo.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Zo=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Bt.token),method:`GET`,timeout:this.Bt.surveys_request_timeout_ms,callback:t=>{var r;this.Zo=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;Z.error(a);var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[br]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}zo(e){for(var t of this.qo)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Z.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!z(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Z.warn(`init was not called`)}Uo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}Yo(e){if(z(this._surveyManager))return{eligible:!1,reason:qs};var t=typeof e==`string`?this.Uo(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(z(this._surveyManager))return Z.warn(`init was not called`),{visible:!1,disabledReason:qs};var t=this.Yo(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return z(this._surveyManager)?(Z.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:qs})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Yo(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(z(this._surveyManager))Z.warn(`init was not called`);else{var i=typeof e==`string`?this.Uo(e):e;if(i!=null&&i.id)if(bo.includes(i.type)){var a=A?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(Z.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;Z.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),Z.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);Z.warn(`Survey element not found`)}else Z.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else Z.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(z(this._surveyManager))Z.warn(`init was not called`);else{var r=this.Uo(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=N({},r,{appearance:N({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==ra.Popover&&t.initialResponses&&Z.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.canRenderSurvey(r);if(!a.visible)return void Z.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===ra.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else Z.warn(`Survey not found`)}}cancelPendingSurvey(e){z(this._surveyManager)?Z.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}},sc),hc={toolbar:class{constructor(e){this.instance=e}Go(e){j.ph_toolbar_state=e}Wo(){return j.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),ii(this.instance.config)||!O||!A)return!1;e??=O.location,n??=O.history;try{if(!t){try{O.localStorage.setItem(`test`,`test`),O.localStorage.removeItem(`test`)}catch{return!1}t=O?.localStorage}var r,i=Ys||Fi(e.hash,`__posthog`)||Fi(e.hash,`state`),a=i?$r((()=>JSON.parse(atob(decodeURIComponent(i)))))||$r((()=>JSON.parse(decodeURIComponent(i)))):null;return a&&a.action===`ph_authorize`?((r=a).source=`url`,r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):((r=JSON.parse(t.getItem(Xs)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Xo(e){var t=j.ph_load_toolbar||j.ph_load_editor;!z(t)&&We(t)?t(e,this.instance):Zs.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(A==null||!A.getElementById(Pr));if(!O||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=N({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(O.localStorage.setItem(Xs,JSON.stringify(N({},r,{source:void 0}))),this.Wo()===2)this.Xo(r);else if(this.Wo()===0){var i;this.Go(1),(i=j.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return Zs.error(`[Toolbar] Failed to load`,e),void this.Go(0);this.Go(2),this.Xo(r)})),K(O,`turbolinks:load`,(()=>{this.Go(0),this.loadToolbar(r)}))}return!0}Jo(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},gc=N({experiments:ac},sc),_c=N({},sc,cc,lc,uc,dc,fc,mc,pc,hc,gc,{conversations:class{constructor(e){this.Ko=void 0,this._conversationsManager=null,this.Qo=!1,this.ea=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;z(t)||(Xe(t)?this.Ko=t:(this.Ko=t.enabled,this.ea=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Ko=void 0,this.ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Qo||this._instance.config.disable_conversations||ii(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=j?.__PosthogExtensions__;if(e&&!L(this.Ko)&&this.Ko)if(this.ea&&this.ea.token){this.Qo=!0;try{var t=e.initConversations;if(t)return this.ta(t),void(this.Qo=!1);var n=e.loadExternalDependency;if(!n)return void this.ra(zr);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.ra(`Could not load conversations script`,t):this.ta(e.initConversations),this.Qo=!1}))}catch(e){this.ra(`Error initializing conversations`,e),this.Qo=!1}}else $.error(`Conversations enabled but missing token in remote config.`)}}ta(e){if(this.ea)try{this._conversationsManager=e(this.ea,this._instance),$.info(`Conversations loaded successfully`)}catch(e){this.ra(`Error completing conversations initialization`,e)}else $.error(`Cannot complete initialization: remote config is null`)}ra(e,t){$.error(e,t),this._conversationsManager=null,this.Qo=!1}show(){this._conversationsManager?this._conversationsManager.show():$.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Ko&&!qe(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return Ne((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):($.warn(oc),null)}))()}getMessages(e,t){var n=this;return Ne((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):($.warn(oc),null)}))()}markAsRead(e){var t=this;return Ne((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):($.warn(oc),null)}))()}getTickets(e){var t=this;return Ne((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):($.warn(oc),null)}))()}requestRestoreLink(e){var t=this;return Ne((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):($.warn(oc),null)}))()}restoreFromToken(e){var t=this;return Ne((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):($.warn(oc),null)}))()}restoreFromUrlToken(){var e=this;return Ne((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():($.warn(oc),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}un(){var e;(e=this._conversationsManager)==null||e.setIdentity()}hn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t;this.ia=!1,this.na=!1,this.Gt=U(`[logs]`),this.sa=[],this.oa=0,this.aa=0,this.la=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ia=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!z(t)&&t&&(this.ia=!0,this.loadIfEnabled())}reset(){this.sa=[],this.jr&&=(clearTimeout(this.jr),void 0),this.oa=0,this.aa=0,this.la=!1}loadIfEnabled(){if(this.ia&&!this.na){var e=j?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.Gt.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.na=!0)})):this.Gt.error(zr)}else this.Gt.error(`PostHog Extensions not found.`)}}captureLog(e){if(this._instance.is_capturing())if(e&&e.body){var t=this._instance.config.logs?.flushIntervalMs??3e3,n=this._instance.config.logs?.maxLogsPerInterval??1e3,r=Date.now();if(t>r-this.aa||(this.aa=r,this.oa=0,this.la=!1),n>this.oa){this.oa++;var i=function(e,t){var{text:n,number:r}=on[e.level||`info`]||sn,i=String(Date.now())+`000000`,a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a[`url.full`]=t.currentUrl),t.screenName&&(a[`screen.name`]=t.screenName),t.appState&&(a[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var o=N({},a,e.attributes||{}),s={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:r,severityText:n,body:{stringValue:e.body},attributes:ln(o)};return e.trace_id&&(s.traceId=e.trace_id),e.span_id&&(s.spanId=e.span_id),L(e.trace_flags)||(s.flags=e.trace_flags),s}(e,this.ua());this.sa.push({record:i}),(this._instance.config.logs?.maxBufferSize??100)>this.sa.length?this.ha():this.flushLogs()}else this.la||=(this.Gt.warn(`captureLog dropping logs: exceeded `+n+` logs per `+t+`ms`),!0)}else this.Gt.warn(`captureLog requires a body`)}get logger(){return this.ca||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.ca}flushLogs(e){if(this.jr&&=(clearTimeout(this.jr),void 0),this.sa.length!==0){var t=this.sa;this.sa=[];var n=this._instance.config.logs,r=N({"service.name":n?.serviceName||`unknown_service`},n?.environment&&{"deployment.environment":n.environment},n?.serviceVersion&&{"service.version":n.serviceVersion},n?.resourceAttributes),i=function(e,t,n,r){return{resourceLogs:[{resource:{attributes:ln(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}(t.map((e=>e.record)),r,M.LIB_NAME,M.LIB_VERSION),a=this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token);this._instance.Hi({method:`POST`,url:a,data:i,compression:`best-available`,batchKey:`logs`,transport:e})}}ha(){this.jr||=setTimeout((()=>{this.jr=void 0,this.flushLogs()}),this._instance.config.logs?.flushIntervalMs??3e3)}ua(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=n}if(j!=null&&(e=j.location)!=null&&e.href&&(t.currentUrl=j.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});zo.__defaultExtensionClasses=N({},_c);var vc,yc=(vc=Eo[No]=new zo,function(){function e(){e.done||(e.done=!0,Po=!1,W(Eo,(function(e){e._dom_loaded()})))}A!=null&&A.addEventListener?A.readyState===`complete`?e():K(A,`DOMContentLoaded`,e,{capture:!1}):O&&H.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),vc),bc;function xc(e){bc=e}function Sc(){return bc}var Cc=(0,m.createContext)({get client(){return Sc()},bootstrap:void 0});function wc(e,t,n){if(n===void 0&&(n=new WeakMap),e===t)return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(n.has(e)&&n.get(e)===t)return!0;n.set(e,t);var r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(var a=0,o=r;a<o.length;a++){var s=o[a];if(!i.includes(s)||!wc(e[s],t[s],n))return!1}return!0}function Tc(e){var t=e.children,n=e.client,r=e.apiKey,i=e.options,a=(0,m.useRef)(null),o=(0,m.useMemo)(function(){if(n)return r&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),i&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n;var e=Sc();return r||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),e},[n,r,JSON.stringify(i)]);return(0,m.useEffect)(function(){if(!n){var e=Sc(),t=a.current;t?(r!==t.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),i&&!wc(i,t.options)&&e.set_config(i),a.current={apiKey:r,options:i??{}}):(e.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),e.init(r,i),a.current={apiKey:r,options:i??{}})}},[n,r,JSON.stringify(i)]),m.default.createElement(Cc.Provider,{value:{client:o,bootstrap:i?.bootstrap??n?.config?.bootstrap}},t)}var Ec=function(e){return typeof e==`function`},Dc=function(e,t){return Dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Dc(e,t)};function Oc(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Dc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var kc={componentStack:null,exceptionEvent:null,error:null},Ac={INVALID_FALLBACK:`[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.`};(function(e){Oc(t,e);function t(t){var n=e.call(this,t)||this;return n.state=kc,n}return t.prototype.componentDidCatch=function(e,t){var n=this.props.additionalProperties,r;Ec(n)?r=n(e):typeof n==`object`&&(r=n);var i=this.context.client.captureException(e,r),a=t.componentStack;this.setState({error:e,componentStack:a??null,exceptionEvent:i})},t.prototype.render=function(){var e=this.props,t=e.children,n=e.fallback,r=this.state;if(r.componentStack==null)return Ec(t)?t():t;var i=Ec(n)?m.default.createElement(n,{error:r.error,componentStack:r.componentStack,exceptionEvent:r.exceptionEvent}):n;return m.default.isValidElement(i)?i:(console.warn(Ac.INVALID_FALLBACK),m.default.createElement(m.default.Fragment,null))},t.contextType=Cc,t})(m.default.Component),xc(yc);var jc=({debug:e=!1,postHogApiKey:t,isStandalone:n,project:r,forceDisablePostHog:i=!1,children:a})=>{let o=oe();return(0,m.useEffect)(()=>{!t||i||(o?.PostHog.consentGiven?yc.opt_in_capturing():yc.opt_out_capturing())},[o.PostHog.consentGiven,i,t]),!t||i?(console.warn(i?`AppShellStandalone Warning: PostHog tracking is disabled by force. PostHog will not be initialized.`:`AppShellStandalone Warning: PostHog API key is not provided. PostHog will not be initialized.`),(0,h.jsx)(h.Fragment,{children:a})):(yc.init(t,{debug:e,api_host:n?`https://eu.posthog.com`:`/ingest`,ui_host:`https://eu.posthog.com`,opt_out_capturing_by_default:!0,autocapture:n},r),(0,h.jsx)(Tc,{client:yc,children:a}))};exports.AppShell=y,exports.ConsentManagerProvider=E,exports.LanguageProvider=ue,exports.MenuProvider=me,exports.MicroFrontendLink=ge,exports.OrganisationProvider=xe,exports.OrganisationSelector=Ce,exports.OrganisationsError=Se,exports.PostHogProviderWrapper=jc,exports.languageStorage=ne,exports.organisationStorage=x,exports.useConsentManager=oe,exports.useLanguage=le,exports.useMFNavigation=D,exports.useMenu=pe,exports.useMenuGroupItems=fe,exports.useOrganisation=ve,exports.useOrganisationId=ye;
3
3
  //# sourceMappingURL=index.cjs.map