@entur-partner/app-shell 6.4.3 → 6.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppShell.d.ts +4 -2
- package/dist/index.cjs +2 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1555 -6986
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,6 +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(`react`);c=s(c,1);let l=require(`@entur/alert`),u=require(`@entur/loader`),d=require(`@entur/tokens`),f=require(`@entur/typography`),p=require(`@entur-partner/common`),m=require(`@entur-partner/util`),h=require(`react/jsx-runtime`);var g=function(e,t){return g=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])},g(e,t)};function _(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);g(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},v.apply(this,arguments)};function ee(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function y(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function b(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function te(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function x(e,t){this.v=e,this.k=t}function S(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function ne(e){return new x(e,0)}function re(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function C(e,t){return e.get(S(e,t))}function w(e,t,n){re(e,t),t.set(e,n)}function T(e,t,n){return e.set(S(e,t),n),n}function E(e,t,n){return(t=function(e){var t=function(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return typeof t==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ie(Object(n),!0).forEach(function(t){E(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ie(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function O(e,t){if(e==null)return{};var n,r,i=function(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}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ae(e){return function(){return new oe(e.apply(this,arguments))}}function oe(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof x;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}oe.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},oe.prototype.next=function(e){return this._invoke(`next`,e)},oe.prototype.throw=function(e){return this._invoke(`throw`,e)},oe.prototype.return=function(e){return this._invoke(`return`,e)};var se={timeoutInSeconds:60},ce=`memory`,le={name:`auth0-spa-js`,version:`2.18.3`},ue=()=>Date.now(),k=`default`,A=class e extends Error{constructor(t,n){super(n),this.error=t,this.error_description=n,Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},de=class e extends A{constructor(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;super(t,n),this.state=r,this.appState=i,Object.setPrototypeOf(this,e.prototype)}},fe=class e extends A{constructor(t,n,r,i){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;super(t,n),this.connection=r,this.state=i,this.appState=a,Object.setPrototypeOf(this,e.prototype)}},pe=class e extends A{constructor(){super(`timeout`,`Timeout`),Object.setPrototypeOf(this,e.prototype)}},me=class e extends pe{constructor(t){super(),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},he=class e extends A{constructor(t){super(`cancelled`,`Popup closed`),this.popup=t,Object.setPrototypeOf(this,e.prototype)}},ge=class e extends A{constructor(){super(`popup_open`,"Unable to open a popup for loginWithPopup - window.open returned `null`"),Object.setPrototypeOf(this,e.prototype)}},_e=class e extends A{constructor(t,n,r,i){super(t,n),this.mfa_token=r,this.mfa_requirements=i,Object.setPrototypeOf(this,e.prototype)}},ve=class e extends A{constructor(t,n){super(`missing_refresh_token`,`Missing Refresh Token (audience: '${xe(t,[`default`])}', scope: '${xe(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},ye=class e extends A{constructor(t,n){super(`missing_scopes`,`Missing requested scopes after refresh (audience: '${xe(t,[`default`])}', missing scope: '${xe(n)}')`),this.audience=t,this.scope=n,Object.setPrototypeOf(this,e.prototype)}},be=class e extends A{constructor(t){super(`use_dpop_nonce`,`Server rejected DPoP proof: wrong nonce`),this.newDpopNonce=t,Object.setPrototypeOf(this,e.prototype)}};function xe(e){return e&&!(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).includes(e)?e:``}var Se=[`clientId`],Ce=()=>window.crypto,we=()=>{let e=``;for(;e.length<43;){let t=Ce().getRandomValues(new Uint8Array(43-e.length));for(let n of t)e.length<43&&n<198&&(e+=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.`[n%66])}return e},Te=e=>btoa(e),Ee=[{key:`name`,type:[`string`]},{key:`version`,type:[`string`,`number`]},{key:`env`,type:[`object`]}],De=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return Object.keys(e).reduce((n,r)=>{if(t&&r===`env`)return n;let i=Ee.find(e=>e.key===r);return i&&i.type.includes(typeof e[r])&&(n[r]=e[r]),n},{})},Oe=e=>{let{clientId:t}=e,n=O(e,Se);return new URLSearchParams((e=>Object.keys(e).filter(t=>e[t]!==void 0).reduce((t,n)=>D(D({},t),{},{[n]:e[n]}),{}))(D({client_id:t},n))).toString()},ke=async e=>await Ce().subtle.digest({name:`SHA-256`},new TextEncoder().encode(e)),Ae=e=>(e=>decodeURIComponent(atob(e).split(``).map(e=>`%`+(`00`+e.charCodeAt(0).toString(16)).slice(-2)).join(``)))(e.replace(/_/g,`/`).replace(/-/g,`+`)),je=e=>{let t=new Uint8Array(e);return(e=>{let t={"+":`-`,"/":`_`,"=":``};return e.replace(/[+/=]/g,e=>t[e])})(window.btoa(String.fromCharCode(...Array.from(t))))},Me=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},Ne={},Pe={};Object.defineProperty(Pe,`__esModule`,{value:!0});var Fe=function(){function e(){var e=this;this.locked=new Map,this.addToLocked=function(t,n){var r=e.locked.get(t);r===void 0?n===void 0?e.locked.set(t,[]):e.locked.set(t,[n]):n!==void 0&&(r.unshift(n),e.locked.set(t,r))},this.isLocked=function(t){return e.locked.has(t)},this.lock=function(t){return new Promise(function(n,r){e.isLocked(t)?e.addToLocked(t,n):(e.addToLocked(t),n())})},this.unlock=function(t){var n=e.locked.get(t);if(n!==void 0&&n.length!==0){var r=n.pop();e.locked.set(t,n),r!==void 0&&setTimeout(r,0)}else e.locked.delete(t)}}return e.getInstance=function(){return e.instance===void 0&&(e.instance=new e),e.instance},e}();Pe.default=function(){return Fe.getInstance()};var Ie=Me&&Me.__awaiter||function(e,t,n,r){return new(n||=Promise)(function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(o,s)}c((r=r.apply(e,t||[])).next())})},Le=Me&&Me.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw TypeError(`Generator is already executing.`);for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!((i=i.length>0&&i[i.length-1])||a[0]!==6&&a[0]!==2)){o=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(a[0]===6&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},Re=Me;Object.defineProperty(Ne,`__esModule`,{value:!0});var ze=Pe,Be=`browser-tabs-lock-key`,Ve={key:function(e){return Ie(Re,void 0,void 0,function(){return Le(this,function(e){throw Error(`Unsupported`)})})},getItem:function(e){return Ie(Re,void 0,void 0,function(){return Le(this,function(e){throw Error(`Unsupported`)})})},clear:function(){return Ie(Re,void 0,void 0,function(){return Le(this,function(e){return[2,window.localStorage.clear()]})})},removeItem:function(e){return Ie(Re,void 0,void 0,function(){return Le(this,function(e){throw Error(`Unsupported`)})})},setItem:function(e,t){return Ie(Re,void 0,void 0,function(){return Le(this,function(e){throw Error(`Unsupported`)})})},keySync:function(e){return window.localStorage.key(e)},getItemSync:function(e){return window.localStorage.getItem(e)},clearSync:function(){return window.localStorage.clear()},removeItemSync:function(e){return window.localStorage.removeItem(e)},setItemSync:function(e,t){return window.localStorage.setItem(e,t)}};function He(e){return new Promise(function(t){return setTimeout(t,e)})}function Ue(e){for(var t=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`,n=``,r=0;r<e;r++)n+=t[Math.floor(61*Math.random())];return n}var We=Ne.default=function(){function e(t){this.acquiredIatSet=new Set,this.storageHandler=void 0,this.id=Date.now().toString()+Ue(15),this.acquireLock=this.acquireLock.bind(this),this.releaseLock=this.releaseLock.bind(this),this.releaseLock__private__=this.releaseLock__private__.bind(this),this.waitForSomethingToChange=this.waitForSomethingToChange.bind(this),this.refreshLockWhileAcquired=this.refreshLockWhileAcquired.bind(this),this.storageHandler=t,e.waiters===void 0&&(e.waiters=[])}return e.prototype.acquireLock=function(t,n){return n===void 0&&(n=5e3),Ie(this,void 0,void 0,function(){var r,i,a,o,s,c,l;return Le(this,function(u){switch(u.label){case 0:r=Date.now()+Ue(4),i=Date.now()+n,a=Be+`-`+t,o=this.storageHandler===void 0?Ve:this.storageHandler,u.label=1;case 1:return Date.now()<i?[4,He(30)]:[3,8];case 2:return u.sent(),o.getItemSync(a)===null?(s=this.id+`-`+t+`-`+r,[4,He(Math.floor(25*Math.random()))]):[3,5];case 3:return u.sent(),o.setItemSync(a,JSON.stringify({id:this.id,iat:r,timeoutKey:s,timeAcquired:Date.now(),timeRefreshed:Date.now()})),[4,He(30)];case 4:return u.sent(),(c=o.getItemSync(a))!==null&&(l=JSON.parse(c)).id===this.id&&l.iat===r?(this.acquiredIatSet.add(r),this.refreshLockWhileAcquired(a,r),[2,!0]):[3,7];case 5:return e.lockCorrector(this.storageHandler===void 0?Ve:this.storageHandler),[4,this.waitForSomethingToChange(i)];case 6:u.sent(),u.label=7;case 7:return r=Date.now()+Ue(4),[3,1];case 8:return[2,!1]}})})},e.prototype.refreshLockWhileAcquired=function(e,t){return Ie(this,void 0,void 0,function(){var n=this;return Le(this,function(r){return setTimeout(function(){return Ie(n,void 0,void 0,function(){var n,r,i;return Le(this,function(a){switch(a.label){case 0:return[4,ze.default().lock(t)];case 1:return a.sent(),this.acquiredIatSet.has(t)?(n=this.storageHandler===void 0?Ve:this.storageHandler,(r=n.getItemSync(e))===null?(ze.default().unlock(t),[2]):((i=JSON.parse(r)).timeRefreshed=Date.now(),n.setItemSync(e,JSON.stringify(i)),ze.default().unlock(t),this.refreshLockWhileAcquired(e,t),[2])):(ze.default().unlock(t),[2])}})})},1e3),[2]})})},e.prototype.waitForSomethingToChange=function(t){return Ie(this,void 0,void 0,function(){return Le(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var r=!1,i=Date.now(),a=!1;function o(){if(a||=(window.removeEventListener(`storage`,o),e.removeFromWaiting(o),clearTimeout(s),!0),!r){r=!0;var t=50-(Date.now()-i);t>0?setTimeout(n,t):n(null)}}window.addEventListener(`storage`,o),e.addToWaiting(o);var s=setTimeout(o,Math.max(0,t-Date.now()))})];case 1:return n.sent(),[2]}})})},e.addToWaiting=function(t){this.removeFromWaiting(t),e.waiters!==void 0&&e.waiters.push(t)},e.removeFromWaiting=function(t){e.waiters!==void 0&&(e.waiters=e.waiters.filter(function(e){return e!==t}))},e.notifyWaiters=function(){e.waiters!==void 0&&e.waiters.slice().forEach(function(e){return e()})},e.prototype.releaseLock=function(e){return Ie(this,void 0,void 0,function(){return Le(this,function(t){switch(t.label){case 0:return[4,this.releaseLock__private__(e)];case 1:return[2,t.sent()]}})})},e.prototype.releaseLock__private__=function(t){return Ie(this,void 0,void 0,function(){var n,r,i,a;return Le(this,function(o){switch(o.label){case 0:return n=this.storageHandler===void 0?Ve:this.storageHandler,r=Be+`-`+t,(i=n.getItemSync(r))===null?[2]:(a=JSON.parse(i)).id===this.id?[4,ze.default().lock(a.iat)]:[3,2];case 1:o.sent(),this.acquiredIatSet.delete(a.iat),n.removeItemSync(r),ze.default().unlock(a.iat),e.notifyWaiters(),o.label=2;case 2:return[2]}})})},e.lockCorrector=function(t){for(var n=Date.now()-5e3,r=t,i=[],a=0;;){var o=r.keySync(a);if(o===null)break;i.push(o),a++}for(var s=!1,c=0;c<i.length;c++){var l=i[c];if(l.includes(Be)){var u=r.getItemSync(l);if(u!==null){var d=JSON.parse(u);(d.timeRefreshed===void 0&&d.timeAcquired<n||d.timeRefreshed!==void 0&&d.timeRefreshed<n)&&(r.removeItemSync(l),s=!0)}}}s&&e.notifyWaiters()},e.waiters=void 0,e}(),Ge=class{async runWithLock(e,t,n){let r=new AbortController,i=setTimeout(()=>r.abort(),t);try{return await navigator.locks.request(e,{mode:`exclusive`,signal:r.signal},async e=>{if(clearTimeout(i),!e)throw Error(`Lock not available`);return await n()})}catch(e){throw clearTimeout(i),e?.name===`AbortError`?new pe:e}}},Ke=class{constructor(){E(this,`lock`,void 0),E(this,`activeLocks`,new Set),E(this,`pagehideHandler`,void 0),this.lock=new We,this.pagehideHandler=()=>{this.activeLocks.forEach(e=>this.lock.releaseLock(e)),this.activeLocks.clear()}}async runWithLock(e,t,n){let r=!1;for(let n=0;n<10&&!r;n++)r=await this.lock.acquireLock(e,t);if(!r)throw new pe;this.activeLocks.add(e),this.activeLocks.size===1&&typeof window<`u`&&window.addEventListener(`pagehide`,this.pagehideHandler);try{return await n()}finally{this.activeLocks.delete(e),await this.lock.releaseLock(e),this.activeLocks.size===0&&typeof window<`u`&&window.removeEventListener(`pagehide`,this.pagehideHandler)}}};function qe(){return typeof navigator<`u`&&typeof(e=navigator.locks)?.request==`function`?new Ge:new Ke;var e}var Je=null,Ye=new TextEncoder,Xe=new TextDecoder;function Ze(e){return typeof e==`string`?Ye.encode(e):Xe.decode(e)}function Qe(e){if(typeof e.modulusLength!=`number`||e.modulusLength<2048)throw new rt(`${e.name} modulusLength must be at least 2048 bits`)}async function $e(e,t,n){if(!1===n.usages.includes(`sign`))throw TypeError(`private CryptoKey instances used for signing assertions must include "sign" in their "usages"`);let r=`${tt(Ze(JSON.stringify(e)))}.${tt(Ze(JSON.stringify(t)))}`;return`${r}.${tt(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:`SHA-256`};case`RSA-PSS`:return Qe(e.algorithm),{name:e.algorithm.name,saltLength:32};case`RSASSA-PKCS1-v1_5`:return Qe(e.algorithm),{name:e.algorithm.name};case`Ed25519`:return{name:e.algorithm.name}}throw new nt}(n),n,Ze(r)))}`}var et;if(Uint8Array.prototype.toBase64)et=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;et=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function tt(e){return et(e)}var nt=class extends Error{constructor(e){var t;super(e??`operation not supported`),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}},rt=class extends Error{constructor(e){var t;super(e),this.name=this.constructor.name,(t=Error.captureStackTrace)==null||t.call(Error,this,this.constructor)}};function it(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`PS256`;throw new nt(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`RSASSA-PKCS1-v1_5`:return function(e){if(e.algorithm.hash.name===`SHA-256`)return`RS256`;throw new nt(`unsupported RsaHashedKeyAlgorithm hash name`)}(e);case`ECDSA`:return function(e){if(e.algorithm.namedCurve===`P-256`)return`ES256`;throw new nt(`unsupported EcKeyAlgorithm namedCurve`)}(e);case`Ed25519`:return`Ed25519`;default:throw new nt(`unsupported CryptoKey algorithm name`)}}function at(e){return e instanceof CryptoKey}function ot(e){return at(e)&&e.type===`public`}async function st(e,t,n,r,i,a){let o=e?.privateKey,s=e?.publicKey;if(!at(c=o)||c.type!==`private`)throw TypeError(`"keypair.privateKey" must be a private CryptoKey`);var c;if(!ot(s))throw TypeError(`"keypair.publicKey" must be a public CryptoKey`);if(!0!==s.extractable)throw TypeError(`"keypair.publicKey.extractable" must be true`);if(typeof t!=`string`)throw TypeError(`"htu" must be a string`);if(typeof n!=`string`)throw TypeError(`"htm" must be a string`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`"nonce" must be a string or undefined`);if(i!==void 0&&typeof i!=`string`)throw TypeError(`"accessToken" must be a string or undefined`);if(a!==void 0&&(typeof a!=`object`||!a||Array.isArray(a)))throw TypeError(`"additional" must be an object`);return $e({alg:it(o),typ:`dpop+jwt`,jwk:await ct(s)},Object.assign(Object.assign({},a),{iat:Math.floor(Date.now()/1e3),jti:crypto.randomUUID(),htm:n,nonce:r,htu:t,ath:i?tt(await crypto.subtle.digest(`SHA-256`,Ze(i))):void 0}),o)}async function ct(e){let{kty:t,e:n,n:r,x:i,y:a,crv:o}=await crypto.subtle.exportKey(`jwk`,e);return{kty:t,crv:o,e:n,n:r,x:i,y:a}}var lt=`dpop-nonce`,ut=[`authorization_code`,`refresh_token`,`urn:ietf:params:oauth:grant-type:token-exchange`,`http://auth0.com/oauth/grant-type/mfa-oob`,`http://auth0.com/oauth/grant-type/mfa-otp`,`http://auth0.com/oauth/grant-type/mfa-recovery-code`];function dt(){return async function(e,t){var n;let r;if(typeof e!=`string`||e.length===0)throw TypeError(`"alg" must be a non-empty string`);switch(e){case`PS256`:r={name:`RSA-PSS`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`RS256`:r={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`,modulusLength:2048,publicExponent:new Uint8Array([1,0,1])};break;case`ES256`:r={name:`ECDSA`,namedCurve:`P-256`};break;case`Ed25519`:r={name:`Ed25519`};break;default:throw new nt}return crypto.subtle.generateKey(r,(n=t?.extractable)!=null&&n,[`sign`,`verify`])}(`ES256`,{extractable:!1})}function ft(e){return async function(e){if(!ot(e))throw TypeError(`"publicKey" must be a public CryptoKey`);if(!0!==e.extractable)throw TypeError(`"publicKey.extractable" must be true`);let t=await ct(e),n;switch(t.kty){case`EC`:n={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case`OKP`:n={crv:t.crv,kty:t.kty,x:t.x};break;case`RSA`:n={e:t.e,kty:t.kty,n:t.n};break;default:throw new nt(`unsupported JWK kty`)}return tt(await crypto.subtle.digest({name:`SHA-256`},Ze(JSON.stringify(n))))}(e.publicKey)}function pt(e){let{keyPair:t,url:n,method:r,nonce:i,accessToken:a}=e;return st(t,function(e){let t=new URL(e);return t.search=``,t.hash=``,t.href}(n),r,i,a)}var mt=[`error`,`error_description`],ht=async(e,t)=>{let n=await fetch(e,t);return{ok:n.ok,json:await n.json(),headers:(r=n.headers,[...r].reduce((e,t)=>{let[n,r]=t;return e[n]=r,e},{}))};var r},gt=async(e,t,n)=>{let r=new AbortController,i;return t.signal=r.signal,Promise.race([ht(e,t),new Promise((e,t)=>{i=setTimeout(()=>{r.abort(),t(Error(`Timeout when executing 'fetch'`))},n)})]).finally(()=>{clearTimeout(i)})},_t=async(e,t,n,r,i,a,o,s)=>((e,t)=>new Promise(function(n,r){let i=new MessageChannel;i.port1.onmessage=function(e){e.data.error?r(Error(e.data.error)):n(e.data),i.port1.close()},t.postMessage(e,[i.port2])}))({auth:{audience:t,scope:n},timeout:i,fetchUrl:e,fetchOptions:r,useFormData:o,useMrrt:s},a),vt=async function(e,t,n,r,i,a){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:1e4;return i?_t(e,t,n,r,o,i,a,arguments.length>7?arguments[7]:void 0):gt(e,r,o)};async function yt(e,t,n,r,i,a,o,s,c,l){if(c){let t=await c.generateProof({url:e,method:i.method||`GET`,nonce:await c.getNonce()});i.headers=D(D({},i.headers),{},{dpop:t})}let u,d=null;for(let c=0;c<3;c++)try{u=await vt(e,n,r,i,a,o,t,s),d=null;break}catch(e){d=e}if(d)throw d;let{json:{error:f,error_description:p},headers:m,ok:h}=u,g=O(u.json,mt),_;if(c&&(_=m[lt],_&&await c.setNonce(_)),!h){let u=p||`HTTP error. Unable to fetch ${e}`;if(f===`mfa_required`)throw new _e(f,u,g.mfa_token,g.mfa_requirements);if(f===`missing_refresh_token`)throw new ve(n,r);if(f===`use_dpop_nonce`){if(!c||!_||l)throw new be(_);return yt(e,t,n,r,i,a,o,s,c,!0)}throw new A(f||`request_error`,u)}return g}var bt=[`baseUrl`,`timeout`,`audience`,`scope`,`auth0Client`,`useFormData`,`useMrrt`,`dpop`];async function xt(e,t){let{baseUrl:n,timeout:r,audience:i,scope:a,auth0Client:o,useFormData:s,useMrrt:c,dpop:l}=e,u=O(e,bt),d=u.grant_type===`urn:ietf:params:oauth:grant-type:token-exchange`,f=u.grant_type===`refresh_token`&&c,p=D(D(D(D({},u),d&&i&&{audience:i}),d&&a&&{scope:a}),f&&{audience:i,scope:a}),m=s?Oe(p):JSON.stringify(p),h=(g=u.grant_type,ut.includes(g));var g;return await yt(`${n}/oauth/token`,r,i||k,a,{method:`POST`,body:m,headers:{"Content-Type":s?`application/x-www-form-urlencoded`:`application/json`,"Auth0-Client":btoa(JSON.stringify(De(o||le)))}},t,s,c,h?l:void 0)}var St=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(r=t.filter(Boolean).join(` `).trim().split(/\s+/),Array.from(new Set(r))).join(` `);var r},Ct=(e,t,n)=>{let r;return n&&(r=e[n]),r||=e[k],St(r,t)},wt=`@@auth0spajs@@`,Tt=`@@user@@`,Et=class e{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wt,n=arguments.length>2?arguments[2]:void 0;this.prefix=t,this.suffix=n,E(this,`clientId`,void 0),E(this,`scope`,void 0),E(this,`audience`,void 0),this.clientId=e.clientId,this.scope=e.scope,this.audience=e.audience}toKey(){return[this.prefix,this.clientId,this.audience,this.scope,this.suffix].filter(Boolean).join(`::`)}static fromKey(t){let[n,r,i,a]=t.split(`::`);return new e({clientId:r,scope:a,audience:i},n)}static fromCacheEntry(t){let{scope:n,audience:r,client_id:i}=t;return new e({scope:n,audience:r,clientId:i})}},Dt=class{set(e,t){localStorage.setItem(e,JSON.stringify(t))}get(e){let t=window.localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{return}}remove(e){localStorage.removeItem(e)}allKeys(){return Object.keys(window.localStorage).filter(e=>e.startsWith(wt))}},Ot=class{constructor(){E(this,`enclosedCache`,function(){let e={};return{set(t,n){e[t]=n},get(t){let n=e[t];if(n)return n},remove(t){delete e[t]},allKeys:()=>Object.keys(e)}}())}},kt=class{constructor(e,t,n){this.cache=e,this.keyManifest=t,E(this,`nowProvider`,void 0),this.nowProvider=n||ue}async setIdToken(e,t,n){let r=this.getIdTokenCacheKey(e);await this.cache.set(r,{id_token:t,decodedToken:n}),await this.keyManifest?.add(r)}async getIdToken(e){let t=await this.cache.get(this.getIdTokenCacheKey(e.clientId));if(!t&&e.scope&&e.audience){let t=await this.get(e);return!t||!t.id_token||!t.decodedToken?void 0:{id_token:t.id_token,decodedToken:t.decodedToken}}if(t)return{id_token:t.id_token,decodedToken:t.decodedToken}}async get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3?arguments[3]:void 0,i=await this.cache.get(e.toKey());if(!i){let t=await this.getCacheKeys();if(!t)return;let a=this.matchExistingCacheKey(e,t);if(a&&(i=await this.cache.get(a)),!i&&n&&r!==`cache-only`)return this.getEntryWithRefreshToken(e,t)}if(!i)return;let a=await this.nowProvider(),o=Math.floor(a/1e3);return i.expiresAt-t<o?i.body.refresh_token?this.modifiedCachedEntry(i,e):(await this.cache.remove(e.toKey()),void await this.keyManifest?.remove(e.toKey())):i.body}async modifiedCachedEntry(e,t){return e.body={refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope},await this.cache.set(t.toKey(),e),{refresh_token:e.body.refresh_token,audience:e.body.audience,scope:e.body.scope}}async set(e){let t=new Et({clientId:e.client_id,scope:e.scope,audience:e.audience}),n=await this.wrapCacheEntry(e);await this.cache.set(t.toKey(),n),await this.keyManifest?.add(t.toKey())}async remove(e,t,n){let r=new Et({clientId:e,scope:n,audience:t});await this.cache.remove(r.toKey())}async clear(e){let t=await this.getCacheKeys();t&&(await t.filter(t=>!e||t.includes(e)).reduce(async(e,t)=>{await e,await this.cache.remove(t)},Promise.resolve()),await this.keyManifest?.clear())}async wrapCacheEntry(e){let t=await this.nowProvider();return{body:e,expiresAt:Math.floor(t/1e3)+e.expires_in}}async getCacheKeys(){return this.keyManifest?(await this.keyManifest.get())?.keys:this.cache.allKeys?this.cache.allKeys():void 0}getIdTokenCacheKey(e){return new Et({clientId:e},wt,Tt).toKey()}matchExistingCacheKey(e,t){return t.filter(t=>{let n=Et.fromKey(t),r=new Set(n.scope&&n.scope.split(` `)),i=e.scope?.split(` `)||[],a=n.scope&&i.reduce((e,t)=>e&&r.has(t),!0);return n.prefix===wt&&n.clientId===e.clientId&&n.audience===e.audience&&a})[0]}async getEntryWithRefreshToken(e,t){for(let r of t){let t=Et.fromKey(r);if(t.prefix===wt&&t.clientId===e.clientId){var n;let t=await this.cache.get(r);if(t!=null&&(n=t.body)!=null&&n.refresh_token)return this.modifiedCachedEntry(t,e)}}}async updateEntry(e,t){let n=await this.getCacheKeys();if(n)for(let i of n){var r;let n=await this.cache.get(i);(n==null||(r=n.body)==null?void 0:r.refresh_token)===e&&(n.body.refresh_token=t,await this.cache.set(i,n))}}},At=class{constructor(e,t,n){this.storage=e,this.clientId=t,this.cookieDomain=n,E(this,`storageKey`,void 0),this.storageKey=`a0.spajs.txs.${this.clientId}`}create(e){this.storage.save(this.storageKey,e,{daysUntilExpire:1,cookieDomain:this.cookieDomain})}get(){return this.storage.get(this.storageKey)}remove(){this.storage.remove(this.storageKey,{cookieDomain:this.cookieDomain})}},jt=e=>typeof e==`number`,Mt=`iss.aud.exp.nbf.iat.jti.azp.nonce.auth_time.at_hash.c_hash.acr.amr.sub_jwk.cnf.sip_from_tag.sip_date.sip_callid.sip_cseq_num.sip_via_branch.orig.dest.mky.events.toe.txn.rph.sid.vot.vtm`.split(`.`),Nt=e=>{if(!e.id_token)throw Error(`ID token is required but missing`);let t=(e=>{let t=e.split(`.`),[n,r,i]=t;if(t.length!==3||!n||!r||!i)throw Error(`ID token could not be decoded`);let a=JSON.parse(Ae(r)),o={__raw:e},s={};return Object.keys(a).forEach(e=>{o[e]=a[e],Mt.includes(e)||(s[e]=a[e])}),{encoded:{header:n,payload:r,signature:i},header:JSON.parse(Ae(n)),claims:o,user:s}})(e.id_token);if(!t.claims.iss)throw Error(`Issuer (iss) claim must be a string present in the ID token`);if(t.claims.iss!==e.iss)throw Error(`Issuer (iss) claim mismatch in the ID token; expected "${e.iss}", found "${t.claims.iss}"`);if(!t.user.sub)throw Error(`Subject (sub) claim must be a string present in the ID token`);if(t.header.alg!==`RS256`)throw Error(`Signature algorithm of "${t.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);if(!t.claims.aud||typeof t.claims.aud!=`string`&&!Array.isArray(t.claims.aud))throw Error(`Audience (aud) claim must be a string or array of strings present in the ID token`);if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e.aud))throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but was not one of "${t.claims.aud.join(`, `)}"`);if(t.claims.aud.length>1){if(!t.claims.azp)throw Error(`Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values`);if(t.claims.azp!==e.aud)throw Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${e.aud}", found "${t.claims.azp}"`)}}else if(t.claims.aud!==e.aud)throw Error(`Audience (aud) claim mismatch in the ID token; expected "${e.aud}" but found "${t.claims.aud}"`);if(e.nonce){if(!t.claims.nonce)throw Error(`Nonce (nonce) claim must be a string present in the ID token`);if(t.claims.nonce!==e.nonce)throw Error(`Nonce (nonce) claim mismatch in the ID token; expected "${e.nonce}", found "${t.claims.nonce}"`)}if(e.max_age&&!jt(t.claims.auth_time))throw Error(`Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified`);if(t.claims.exp==null||!jt(t.claims.exp))throw Error(`Expiration Time (exp) claim must be a number present in the ID token`);if(!jt(t.claims.iat))throw Error(`Issued At (iat) claim must be a number present in the ID token`);let n=e.leeway||60,r=new Date(e.now||Date.now()),i=new Date(0);if(i.setUTCSeconds(t.claims.exp+n),r>i)throw Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);if(t.claims.nbf!=null&&jt(t.claims.nbf)){let e=new Date(0);if(e.setUTCSeconds(t.claims.nbf-n),r<e)throw Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${e}`)}if(t.claims.auth_time!=null&&jt(t.claims.auth_time)){let i=new Date(0);if(i.setUTCSeconds(parseInt(t.claims.auth_time)+e.max_age+n),r>i)throw Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${i}`)}if(e.organization){let n=e.organization.trim();if(n.startsWith(`org_`)){let e=n;if(!t.claims.org_id)throw Error(`Organization ID (org_id) claim must be a string present in the ID token`);if(e!==t.claims.org_id)throw Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_id}"`)}else{let e=n.toLowerCase();if(!t.claims.org_name)throw Error(`Organization Name (org_name) claim must be a string present in the ID token`);if(e!==t.claims.org_name)throw Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${e}", found "${t.claims.org_name}"`)}}return t},Pt=Me&&Me.__assign||function(){return Pt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Pt.apply(this,arguments)};function Ft(e,t){if(!t)return``;var n=`; `+e;return!0===t?n:n+`=`+t}function It(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,`%28`).replace(/\)/g,`%29`)+`=`+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if(typeof e.expires==`number`){var t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return Ft(`Expires`,e.expires?e.expires.toUTCString():``)+Ft(`Domain`,e.domain)+Ft(`Path`,e.path)+Ft(`Secure`,e.secure)+Ft(`SameSite`,e.sameSite)}(n)}function Lt(){return function(e){for(var t={},n=e?e.split(`; `):[],r=/(%[\dA-F]{2})+/gi,i=0;i<n.length;i++){var a=n[i].split(`=`),o=a.slice(1).join(`=`);o.charAt(0)===`"`&&(o=o.slice(1,-1));try{t[a[0].replace(r,decodeURIComponent)]=o.replace(r,decodeURIComponent)}catch{}}return t}(document.cookie)}var Rt=function(e){return Lt()[e]};function zt(e,t,n){document.cookie=It(e,t,Pt({path:`/`},n))}var Bt=zt,Vt=function(e,t){zt(e,``,Pt(Pt({},t),{expires:-1}))},Ht={get(e){let t=Rt(e);if(t!==void 0)return JSON.parse(t)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0,sameSite:`none`}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Bt(e,JSON.stringify(t),r)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Vt(e,n)}},Ut=`_legacy_`,Wt={get(e){return Ht.get(e)||Ht.get(`${Ut}${e}`)},save(e,t,n){let r={};window.location.protocol===`https:`&&(r={secure:!0}),n!=null&&n.daysUntilExpire&&(r.expires=n.daysUntilExpire),n!=null&&n.cookieDomain&&(r.domain=n.cookieDomain),Bt(`${Ut}${e}`,JSON.stringify(t),r),Ht.save(e,t,n)},remove(e,t){let n={};t!=null&&t.cookieDomain&&(n.domain=t.cookieDomain),Vt(e,n),Ht.remove(e,t),Ht.remove(`${Ut}${e}`,t)}},Gt={get(e){if(typeof sessionStorage>`u`)return;let t=sessionStorage.getItem(e);return t==null?void 0:JSON.parse(t)},save(e,t){sessionStorage.setItem(e,JSON.stringify(t))},remove(e){sessionStorage.removeItem(e)}},Kt=function(e){return e.Code=`code`,e.ConnectCode=`connect_code`,e}({});function qt(e,t,n){var r=t===void 0?null:t,i=function(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,a=n.length;i<a;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}(e,n!==void 0&&n),a=i.indexOf(`
|
|
2
|
-
`,10)+1,o=i.substring(a)+(r?`//# sourceMappingURL=`+r:``),s=new Blob([o],{type:`application/javascript`});return URL.createObjectURL(s)}var Jt,Yt,Xt,Zt,Qt=(Jt=`Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7ZnVuY3Rpb24gZShlLHIsdCl7cmV0dXJuKHI9ZnVuY3Rpb24oZSl7dmFyIHI9ZnVuY3Rpb24oZSxyKXtpZigib2JqZWN0IiE9dHlwZW9mIGV8fCFlKXJldHVybiBlO3ZhciB0PWVbU3ltYm9sLnRvUHJpbWl0aXZlXTtpZih2b2lkIDAhPT10KXt2YXIgbj10LmNhbGwoZSxyfHwiZGVmYXVsdCIpO2lmKCJvYmplY3QiIT10eXBlb2YgbilyZXR1cm4gbjt0aHJvdyBuZXcgVHlwZUVycm9yKCJAQHRvUHJpbWl0aXZlIG11c3QgcmV0dXJuIGEgcHJpbWl0aXZlIHZhbHVlLiIpfXJldHVybigic3RyaW5nIj09PXI/U3RyaW5nOk51bWJlcikoZSl9KGUsInN0cmluZyIpO3JldHVybiJzeW1ib2wiPT10eXBlb2Ygcj9yOnIrIiJ9KHIpKWluIGU/T2JqZWN0LmRlZmluZVByb3BlcnR5KGUscix7dmFsdWU6dCxlbnVtZXJhYmxlOiEwLGNvbmZpZ3VyYWJsZTohMCx3cml0YWJsZTohMH0pOmVbcl09dCxlfWZ1bmN0aW9uIHIoZSxyKXt2YXIgdD1PYmplY3Qua2V5cyhlKTtpZihPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbj1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO3ImJihuPW4uZmlsdGVyKGZ1bmN0aW9uKHIpe3JldHVybiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKGUscikuZW51bWVyYWJsZX0pKSx0LnB1c2guYXBwbHkodCxuKX1yZXR1cm4gdH1mdW5jdGlvbiB0KHQpe2Zvcih2YXIgbj0xO248YXJndW1lbnRzLmxlbmd0aDtuKyspe3ZhciBvPW51bGwhPWFyZ3VtZW50c1tuXT9hcmd1bWVudHNbbl06e307biUyP3IoT2JqZWN0KG8pLCEwKS5mb3JFYWNoKGZ1bmN0aW9uKHIpe2UodCxyLG9bcl0pfSk6T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnM/T2JqZWN0LmRlZmluZVByb3BlcnRpZXModCxPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyhvKSk6cihPYmplY3QobykpLmZvckVhY2goZnVuY3Rpb24oZSl7T2JqZWN0LmRlZmluZVByb3BlcnR5KHQsZSxPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKG8sZSkpfSl9cmV0dXJuIHR9Y2xhc3MgbiBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKGUscil7c3VwZXIociksdGhpcy5lcnJvcj1lLHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxuLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKGUpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOnR9PWU7cmV0dXJuIG5ldyBuKHIsdCl9fWNsYXNzIG8gZXh0ZW5kcyBue2NvbnN0cnVjdG9yKGUscil7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChzKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChzKHIpLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1yLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLG8ucHJvdG90eXBlKX19ZnVuY3Rpb24gcyhlKXtyZXR1cm4gZSYmIShhcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W10pLmluY2x1ZGVzKGUpP2U6IiJ9Y29uc3QgaT1bImNsaWVudElkIl0sYz1lPT57bGV0e2NsaWVudElkOnJ9PWUsbj1mdW5jdGlvbihlLHIpe2lmKG51bGw9PWUpcmV0dXJue307dmFyIHQsbixvPWZ1bmN0aW9uKGUscil7aWYobnVsbD09ZSlyZXR1cm57fTt2YXIgdD17fTtmb3IodmFyIG4gaW4gZSlpZih7fS5oYXNPd25Qcm9wZXJ0eS5jYWxsKGUsbikpe2lmKC0xIT09ci5pbmRleE9mKG4pKWNvbnRpbnVlO3Rbbl09ZVtuXX1yZXR1cm4gdH0oZSxyKTtpZihPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgcz1PYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKGUpO2ZvcihuPTA7bjxzLmxlbmd0aDtuKyspdD1zW25dLC0xPT09ci5pbmRleE9mKHQpJiZ7fS5wcm9wZXJ0eUlzRW51bWVyYWJsZS5jYWxsKGUsdCkmJihvW3RdPWVbdF0pfXJldHVybiBvfShlLGkpO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIocj0+dm9pZCAwIT09ZVtyXSkucmVkdWNlKChyLG4pPT50KHQoe30scikse30se1tuXTplW25dfSkse30pKSh0KHtjbGllbnRfaWQ6cn0sbikpKS50b1N0cmluZygpfTtsZXQgYT17fSxsPW51bGw7Y29uc3QgdT0oZSxyKT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQociksZj1hc3luYyBlPT57bGV0IHIsbix7ZGF0YTp7dGltZW91dDpzLGF1dGg6aSxmZXRjaFVybDpsLGZldGNoT3B0aW9uczpmLHVzZUZvcm1EYXRhOnAsdXNlTXJydDpofSxwb3J0czpbZF19PWUseT17fTtjb25zdHthdWRpZW5jZTpiLHNjb3BlOk99PWl8fHt9O3RyeXtjb25zdCBlPXA/KGU9Pntjb25zdCByPW5ldyBVUkxTZWFyY2hQYXJhbXMoZSksdD17fTtyZXR1cm4gci5mb3JFYWNoKChlLHIpPT57dFtyXT1lfSksdH0pKGYuYm9keSk6SlNPTi5wYXJzZShmLmJvZHkpO2lmKCFlLnJlZnJlc2hfdG9rZW4mJiJyZWZyZXNoX3Rva2VuIj09PWUuZ3JhbnRfdHlwZSl7aWYobj0oKGUscik9PmFbdShlLHIpXSkoYixPKSwhbiYmaCl7Y29uc3QgZT1hLmxhdGVzdF9yZWZyZXNoX3Rva2VuLHI9KChlLHIpPT57Y29uc3QgdD1PYmplY3Qua2V5cyhhKS5maW5kKHQ9PntpZigibGF0ZXN0X3JlZnJlc2hfdG9rZW4iIT09dCl7Y29uc3Qgbj0oKGUscik9PnIuc3RhcnRzV2l0aCgiIi5jb25jYXQoZSwifCIpKSkocix0KSxvPXQuc3BsaXQoInwiKVsxXS5zcGxpdCgiICIpLHM9ZS5zcGxpdCgiICIpLmV2ZXJ5KGU9Pm8uaW5jbHVkZXMoZSkpO3JldHVybiBuJiZzfX0pO3JldHVybiEhdH0pKE8sYik7ZSYmIXImJihuPWUpfWlmKCFuKXRocm93IG5ldyBvKGIsTyk7Zi5ib2R5PXA/Yyh0KHQoe30sZSkse30se3JlZnJlc2hfdG9rZW46bn0pKTpKU09OLnN0cmluZ2lmeSh0KHQoe30sZSkse30se3JlZnJlc2hfdG9rZW46bn0pKX1sZXQgaSx2OyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihpPW5ldyBBYm9ydENvbnRyb2xsZXIsZi5zaWduYWw9aS5zaWduYWwpO3RyeXt2PWF3YWl0IFByb21pc2UucmFjZShbKGo9cyxuZXcgUHJvbWlzZShlPT5zZXRUaW1lb3V0KGUsaikpKSxmZXRjaChsLHQoe30sZikpXSl9Y2F0Y2goZSl7cmV0dXJuIHZvaWQgZC5wb3N0TWVzc2FnZSh7ZXJyb3I6ZS5tZXNzYWdlfSl9aWYoIXYpcmV0dXJuIGkmJmkuYWJvcnQoKSx2b2lkIGQucG9zdE1lc3NhZ2Uoe2Vycm9yOiJUaW1lb3V0IHdoZW4gZXhlY3V0aW5nICdmZXRjaCcifSk7dz12LmhlYWRlcnMseT1bLi4ud10ucmVkdWNlKChlLHIpPT57bGV0W3Qsbl09cjtyZXR1cm4gZVt0XT1uLGV9LHt9KSxyPWF3YWl0IHYuanNvbigpLHIucmVmcmVzaF90b2tlbj8oaCYmKGEubGF0ZXN0X3JlZnJlc2hfdG9rZW49ci5yZWZyZXNoX3Rva2VuLGc9bixtPXIucmVmcmVzaF90b2tlbixPYmplY3QuZW50cmllcyhhKS5mb3JFYWNoKGU9PntsZXRbcix0XT1lO3Q9PT1nJiYoYVtyXT1tKX0pKSwoKGUscix0KT0+e2FbdShyLHQpXT1lfSkoci5yZWZyZXNoX3Rva2VuLGIsTyksZGVsZXRlIHIucmVmcmVzaF90b2tlbik6KChlLHIpPT57ZGVsZXRlIGFbdShlLHIpXX0pKGIsTyksZC5wb3N0TWVzc2FnZSh7b2s6di5vayxqc29uOnIsaGVhZGVyczp5fSl9Y2F0Y2goZSl7ZC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9LGhlYWRlcnM6eX0pfXZhciBnLG0sdyxqfTthZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixlPT57Y29uc3R7ZGF0YTpyLHBvcnRzOnR9PWUsW25dPXQ7aWYoInR5cGUiaW4gciYmImluaXQiPT09ci50eXBlKXtpZihudWxsPT09bCl0cnl7bmV3IFVSTChyLmFsbG93ZWRCYXNlVXJsKSxsPXIuYWxsb3dlZEJhc2VVcmx9Y2F0Y2goZSl7cmV0dXJufX1lbHNlImZldGNoVXJsImluIHImJihlPT57aWYoIWwpcmV0dXJuITE7dHJ5e2NvbnN0IHI9bmV3IFVSTChsKS5vcmlnaW4sdD1uZXcgVVJMKGUuZmV0Y2hVcmwpO3JldHVybiB0Lm9yaWdpbj09PXImJiIvb2F1dGgvdG9rZW4iPT09dC5wYXRobmFtZX1jYXRjaChlKXtyZXR1cm4hMX19KShyKT9mKGUpOm51bGw9PW58fG4ucG9zdE1lc3NhZ2Uoe29rOiExLGpzb246e2Vycm9yOiJpbnZhbGlkX2ZldGNoX3VybCIsZXJyb3JfZGVzY3JpcHRpb246IlVuYXV0aG9yaXplZCBmZXRjaCBVUkwifSxoZWFkZXJzOnt9fSl9KX0oKTsKCg==`,Yt=null,Xt=!1,function(e){return Zt||=qt(Jt,Yt,Xt),new Worker(Zt,e)}),$t={},en=class{constructor(e,t){this.cache=e,this.clientId=t,E(this,`manifestKey`,void 0),this.manifestKey=this.createManifestKeyFrom(this.clientId)}async add(e){let t=new Set((await this.cache.get(this.manifestKey))?.keys||[]);t.add(e),await this.cache.set(this.manifestKey,{keys:[...t]})}async remove(e){let t=await this.cache.get(this.manifestKey);if(t){let n=new Set(t.keys);return n.delete(e),n.size>0?await this.cache.set(this.manifestKey,{keys:[...n]}):await this.cache.remove(this.manifestKey)}}get(){return this.cache.get(this.manifestKey)}clear(){return this.cache.remove(this.manifestKey)}createManifestKeyFrom(e){return`${wt}::${e}`}},tn=[`openUrl`,`onRedirect`],nn=`auth0.is.authenticated`,rn={memory:()=>new Ot().enclosedCache,localstorage:()=>new Dt},an=e=>rn[e],on=e=>{let{openUrl:t,onRedirect:n}=e;return D(D({},O(e,tn)),{},{openUrl:!1===t||t?t:n})},sn=(e,t)=>{let n=t?.split(` `)||[];return(e?.split(` `)||[]).every(e=>n.includes(e))},cn={NONCE:`nonce`,KEYPAIR:`keypair`},ln=class{constructor(e){E(this,`clientId`,void 0),E(this,`dbHandle`,void 0),this.clientId=e}getVersion(){return 1}createDbHandle(){let e=window.indexedDB.open(`auth0-spa-js`,this.getVersion());return new Promise((t,n)=>{e.onupgradeneeded=()=>Object.values(cn).forEach(t=>e.result.createObjectStore(t)),e.onerror=()=>n(e.error),e.onsuccess=()=>t(e.result)})}async getDbHandle(){return this.dbHandle||=await this.createDbHandle(),this.dbHandle}async executeDbRequest(e,t,n){let r=n((await this.getDbHandle()).transaction(e,t).objectStore(e));return new Promise((e,t)=>{r.onsuccess=()=>e(r.result),r.onerror=()=>t(r.error)})}buildKey(e){let t=e?`_${e}`:`auth0`;return`${this.clientId}::${t}`}setNonce(e,t){return this.save(cn.NONCE,this.buildKey(t),e)}setKeyPair(e){return this.save(cn.KEYPAIR,this.buildKey(),e)}async save(e,t,n){await this.executeDbRequest(e,`readwrite`,e=>e.put(n,t))}findNonce(e){return this.find(cn.NONCE,this.buildKey(e))}findKeyPair(){return this.find(cn.KEYPAIR,this.buildKey())}find(e,t){return this.executeDbRequest(e,`readonly`,e=>e.get(t))}async deleteBy(e,t){(await this.executeDbRequest(e,`readonly`,e=>e.getAllKeys()))?.filter(t).map(t=>this.executeDbRequest(e,`readwrite`,e=>e.delete(t)))}deleteByClientId(e,t){return this.deleteBy(e,e=>typeof e==`string`&&e.startsWith(`${t}::`))}clearNonces(){return this.deleteByClientId(cn.NONCE,this.clientId)}clearKeyPairs(){return this.deleteByClientId(cn.KEYPAIR,this.clientId)}},un=class{constructor(e){E(this,`storage`,void 0),this.storage=new ln(e)}getNonce(e){return this.storage.findNonce(e)}setNonce(e,t){return this.storage.setNonce(e,t)}async getOrGenerateKeyPair(){let e=await this.storage.findKeyPair();return e||(e=await dt(),await this.storage.setKeyPair(e)),e}async generateProof(e){return pt(D({keyPair:await this.getOrGenerateKeyPair()},e))}async calculateThumbprint(){return ft(await this.getOrGenerateKeyPair())}async clear(){await Promise.all([this.storage.clearNonces(),this.storage.clearKeyPairs()])}},dn=function(e){return e.Bearer=`Bearer`,e.DPoP=`DPoP`,e}(dn||{}),fn=class{constructor(e,t){E(this,`config`,void 0),E(this,`hooks`,void 0),this.hooks=t,this.config=D(D({},e),{},{fetch:e.fetch||(typeof window>`u`?fetch:window.fetch.bind(window))})}isAbsoluteUrl(e){return/^(https?:)?\/\//i.test(e)}buildUrl(e,t){if(t){if(this.isAbsoluteUrl(t))return t;if(e)return`${e.replace(/\/?\/$/,``)}/${t.replace(/^\/+/,``)}`}throw TypeError("`url` must be absolute or `baseUrl` non-empty.")}getAccessToken(e){return this.config.getAccessToken?this.config.getAccessToken(e):this.hooks.getAccessToken(e)}extractUrl(e){return typeof e==`string`?e:e instanceof URL?e.href:e.url}buildBaseRequest(e,t){if(!this.config.baseUrl)return new Request(e,t);let n=this.buildUrl(this.config.baseUrl,this.extractUrl(e)),r=e instanceof Request?new Request(n,e):n;return new Request(r,t)}setAuthorizationHeader(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:dn.Bearer;e.headers.set(`authorization`,`${n} ${t}`)}async setDpopProofHeader(e,t){if(!this.config.dpopNonceId)return;let n=await this.hooks.getDpopNonce(),r=await this.hooks.generateDpopProof({accessToken:t,method:e.method,nonce:n,url:e.url});e.headers.set(`dpop`,r)}async prepareRequest(e,t){let n=await this.getAccessToken(t),r,i;typeof n==`string`?(r=this.config.dpopNonceId?dn.DPoP:dn.Bearer,i=n):(r=n.token_type,i=n.access_token),this.setAuthorizationHeader(e,i,r),r===dn.DPoP&&await this.setDpopProofHeader(e,i)}getHeader(e,t){return Array.isArray(e)?new Headers(e).get(t)||``:typeof e.get==`function`?e.get(t)||``:e[t]||``}hasUseDpopNonceError(e){if(e.status!==401)return!1;let t=this.getHeader(e.headers,`www-authenticate`);return t.includes(`invalid_dpop_nonce`)||t.includes(`use_dpop_nonce`)}async handleResponse(e,t){let n=this.getHeader(e.headers,lt);if(n&&await this.hooks.setDpopNonce(n),!this.hasUseDpopNonceError(e))return e;if(!n||!t.onUseDpopNonceError)throw new be(n);return t.onUseDpopNonceError()}async internalFetchWithAuth(e,t,n,r){let i=this.buildBaseRequest(e,t);await this.prepareRequest(i,r);let a=await this.config.fetch(i);return this.handleResponse(a,n)}fetchWithAuth(e,t,n){let r={onUseDpopNonceError:()=>this.internalFetchWithAuth(e,t,D(D({},r),{},{onUseDpopNonceError:void 0}),n)};return this.internalFetchWithAuth(e,t,r,n)}},pn=class{constructor(e,t){this.myAccountFetcher=e,this.apiBase=t}async connectAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/connect`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async completeAccount(e){let t=await this.myAccountFetcher.fetchWithAuth(`${this.apiBase}v1/connected-accounts/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return this._handleResponse(t)}async _handleResponse(e){let t;try{t=await e.text(),t=JSON.parse(t)}catch(n){throw new mn({type:`invalid_json`,status:e.status,title:`Invalid JSON response`,detail:t||String(n)})}if(e.ok)return t;throw new mn(t)}},mn=class e extends Error{constructor(t){let{type:n,status:r,title:i,detail:a,validation_errors:o}=t;super(a),E(this,`type`,void 0),E(this,`status`,void 0),E(this,`title`,void 0),E(this,`detail`,void 0),E(this,`validation_errors`,void 0),this.name=`MyAccountApiError`,this.type=n,this.status=r,this.title=i,this.detail=a,this.validation_errors=o,Object.setPrototypeOf(this,e.prototype)}},hn={otp:{authenticatorTypes:[`otp`]},sms:{authenticatorTypes:[`oob`],oobChannels:[`sms`]},email:{authenticatorTypes:[`oob`],oobChannels:[`email`]},push:{authenticatorTypes:[`oob`],oobChannels:[`auth0`]},voice:{authenticatorTypes:[`oob`],oobChannels:[`voice`]}},gn=`http://auth0.com/oauth/grant-type/mfa-otp`,_n=`http://auth0.com/oauth/grant-type/mfa-oob`,vn=`http://auth0.com/oauth/grant-type/mfa-recovery-code`,yn,bn,xn;(typeof navigator>`u`||(yn=navigator.userAgent)==null||(bn=yn.startsWith)==null||!bn.call(yn,`Mozilla/5.0 `))&&(xn=`oauth4webapi/v3.8.5`);function Sn(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var Cn=`ERR_INVALID_ARG_VALUE`,wn=`ERR_INVALID_ARG_TYPE`;function j(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var Tn=Symbol(),En=Symbol(),Dn=Symbol(),On=Symbol(),kn=Symbol(),An=Symbol(),jn=new TextEncoder,Mn=new TextDecoder;function Nn(e){return typeof e==`string`?jn.encode(e):Mn.decode(e)}var Pn,Fn;if(Uint8Array.prototype.toBase64)Pn=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:`base64url`,omitPadding:!0}));else{let e=32768;Pn=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=e)n.push(String.fromCharCode.apply(null,t.subarray(r,r+e)));return btoa(n.join(``)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}}function In(e){return typeof e==`string`?Fn(e):Pn(e)}Fn=Uint8Array.fromBase64?e=>{try{return Uint8Array.fromBase64(e,{alphabet:`base64url`})}catch(e){throw j(`The input to be decoded is not correctly encoded.`,Cn,e)}}:e=>{try{let t=atob(e.replace(/-/g,`+`).replace(/_/g,`/`).replace(/\s/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch(e){throw j(`The input to be decoded is not correctly encoded.`,Cn,e)}};var Ln=class extends Error{constructor(e,t){var n;super(e,t),E(this,`code`,void 0),this.name=this.constructor.name,this.code=Ir,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},Rn=class extends Error{constructor(e,t){var n;super(e,t),E(this,`code`,void 0),this.name=this.constructor.name,t!=null&&t.code&&(this.code=t?.code),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function M(e,t,n){return new Rn(e,{code:t,cause:n})}function zn(e,t){if(function(e,t){if(!(e instanceof CryptoKey))throw j(`${t} must be a CryptoKey`,wn)}(e,t),e.type!==`private`)throw j(`${t} must be a private CryptoKey`,Cn)}function Bn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vn(e){Sn(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(xn&&!t.has(`user-agent`)&&t.set(`user-agent`,xn),t.has(`authorization`))throw j(`"options.headers" must not include the "authorization" header name`,Cn);return t}function Hn(e,t){if(t!==void 0){if(typeof t==`function`&&(t=t(e.href)),!(t instanceof AbortSignal))throw j(`"options.signal" must return or be an instance of AbortSignal`,wn);return t}}function Un(e){return e.includes(`//`)?e.replace(`//`,`/`):e}async function Wn(e,t){return async function(e,t,n,r){if(!(e instanceof URL))throw j(`"${t}" must be an instance of URL`,wn);rr(e,!0!==r?.[Tn]);let i=n(new URL(e.href)),a=Vn(r?.headers);return a.set(`accept`,`application/json`),(r?.[On]||fetch)(i.href,{body:void 0,headers:Object.fromEntries(a.entries()),method:`GET`,redirect:`manual`,signal:Hn(i,r?.signal)})}(e,`issuerIdentifier`,e=>{switch(t?.algorithm){case void 0:case`oidc`:(function(e,t){e.pathname=Un(`${e.pathname}/${t}`)})(e,`.well-known/openid-configuration`);break;case`oauth2`:(function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2];e.pathname===`/`?e.pathname=t:e.pathname=Un(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,``)}`)})(e,`.well-known/oauth-authorization-server`);break;default:throw j(`"options.algorithm" must be "oidc" (default), or "oauth2"`,Cn)}return e},t)}function Gn(e,t,n,r,i){try{if(typeof e!=`number`||!Number.isFinite(e))throw j(`${n} must be a number`,wn,i);if(e>0)return;if(t){if(e!==0)throw j(`${n} must be a non-negative number`,Cn,i);return}throw j(`${n} must be a positive number`,Cn,i)}catch(e){throw r?M(e.message,r,i):e}}function N(e,t,n,r){try{if(typeof e!=`string`)throw j(`${t} must be a string`,wn,r);if(e.length===0)throw j(`${t} must not be empty`,Cn,r)}catch(e){throw n?M(e.message,n,r):e}}function Kn(e){(function(e,t){if(vr(e)!==t)throw function(e){let t=`"response" content-type must be `;for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(r.length>2){let e=r.pop();t+=`${r.join(`, `)}, or ${e}`}else r.length===2?t+=`${r[0]} or ${r[1]}`:t+=r[0];return M(t,zr,e)}(e,t)})(e,`application/json`)}function qn(){return In(crypto.getRandomValues(new Uint8Array(32)))}function Jn(e){switch(e.algorithm.name){case`RSA-PSS`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`PS256`;case`SHA-384`:return`PS384`;case`SHA-512`:return`PS512`;default:throw new Ln(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`RSASSA-PKCS1-v1_5`:return function(e){switch(e.algorithm.hash.name){case`SHA-256`:return`RS256`;case`SHA-384`:return`RS384`;case`SHA-512`:return`RS512`;default:throw new Ln(`unsupported RsaHashedKeyAlgorithm hash name`,{cause:e})}}(e);case`ECDSA`:return function(e){switch(e.algorithm.namedCurve){case`P-256`:return`ES256`;case`P-384`:return`ES384`;case`P-521`:return`ES512`;default:throw new Ln(`unsupported EcKeyAlgorithm namedCurve`,{cause:e})}}(e);case`Ed25519`:case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return e.algorithm.name;case`EdDSA`:return`Ed25519`;default:throw new Ln(`unsupported CryptoKey algorithm name`,{cause:e})}}function Yn(e){let t=e?.[En];return typeof t==`number`&&Number.isFinite(t)?t:0}function Xn(e){let t=e?.[Dn];return typeof t==`number`&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function Zn(){return Math.floor(Date.now()/1e3)}function Qn(e){if(typeof e!=`object`||!e)throw j(`"as" must be an object`,wn);N(e.issuer,`"as.issuer"`)}function $n(e){if(typeof e!=`object`||!e)throw j(`"client" must be an object`,wn);N(e.client_id,`"client.client_id"`)}function er(e){return N(e,`"clientSecret"`),(t,n,r,i)=>{r.set(`client_id`,n.client_id),r.set(`client_secret`,e)}}function tr(e,t){let{key:n,kid:r}=(i=e)instanceof CryptoKey?{key:i}:i?.key instanceof CryptoKey?(i.kid!==void 0&&N(i.kid,`"kid"`),{key:i.key,kid:i.kid}):{};var i;return zn(n,`"clientPrivateKey.key"`),async(e,i,a,o)=>{var s;let c={alg:Jn(n),kid:r},l=function(e,t){let n=Zn()+Yn(t);return{jti:qn(),aud:e.issuer,exp:n+60,iat:n,nbf:n,iss:t.client_id,sub:t.client_id}}(e,i);t==null||(s=t[kn])==null||s.call(t,c,l),a.set(`client_id`,i.client_id),a.set(`client_assertion_type`,`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`),a.set(`client_assertion`,await async function(e,t,n){if(!n.usages.includes(`sign`))throw j(`CryptoKey instances used for signing assertions must include "sign" in their "usages"`,Cn);let r=`${In(Nn(JSON.stringify(e)))}.${In(Nn(JSON.stringify(t)))}`;return`${r}.${In(await crypto.subtle.sign(function(e){switch(e.algorithm.name){case`ECDSA`:return{name:e.algorithm.name,hash:Xr(e)};case`RSA-PSS`:switch(Yr(e),e.algorithm.hash.name){case`SHA-256`:case`SHA-384`:case`SHA-512`:return{name:e.algorithm.name,saltLength:parseInt(e.algorithm.hash.name.slice(-3),10)>>3};default:throw new Ln(`unsupported RSA-PSS hash name`,{cause:e})}case`RSASSA-PKCS1-v1_5`:return Yr(e),e.algorithm.name;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:case`Ed25519`:return e.algorithm.name}throw new Ln(`unsupported CryptoKey algorithm name`,{cause:e})}(n),n,Nn(r)))}`}(c,l,n))}}var nr=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function rr(e,t){if(t&&e.protocol!==`https:`)throw M(`only requests to HTTPS are allowed`,Vr,e);if(e.protocol!==`https:`&&e.protocol!==`http:`)throw M(`only HTTP and HTTPS requests are allowed`,Hr,e)}function ir(e,t,n,r){let i;if(typeof e!=`string`||!(i=nr(e)))throw M(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Kr:qr,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return rr(i,r),i}function ar(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?ir(e.mtls_endpoint_aliases[t],t,n,r):ir(e[t],t,n,r)}var or=class extends Error{constructor(e,t){var n;super(e,t),E(this,`cause`,void 0),E(this,`code`,void 0),E(this,`error`,void 0),E(this,`status`,void 0),E(this,`error_description`,void 0),E(this,`response`,void 0),this.name=this.constructor.name,this.code=Fr,this.cause=t.cause,this.error=t.cause.error,this.status=t.response.status,this.error_description=t.cause.error_description,Object.defineProperty(this,`response`,{enumerable:!1,value:t.response}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},sr=class extends Error{constructor(e,t){var n;super(e,t),E(this,`cause`,void 0),E(this,`code`,void 0),E(this,`error`,void 0),E(this,`error_description`,void 0),this.name=this.constructor.name,this.code=Lr,this.cause=t.cause,this.error=t.cause.get(`error`),this.error_description=t.cause.get(`error_description`)??void 0,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},cr=class extends Error{constructor(e,t){var n;super(e,t),E(this,`cause`,void 0),E(this,`code`,void 0),E(this,`response`,void 0),E(this,`status`,void 0),this.name=this.constructor.name,this.code=Pr,this.cause=t.cause,this.status=t.response.status,this.response=t.response,Object.defineProperty(this,`response`,{enumerable:!1}),(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}},lr="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",ur=`(`+lr+`)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"`,dr=`(`+lr+")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)",fr=RegExp(`^[,\\s]*(`+lr+`)`),pr=RegExp(`^[,\\s]*`+ur+`[,\\s]*(.*)`),mr=RegExp(`^[,\\s]*`+dr+`[,\\s]*(.*)`),hr=RegExp(`^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)`);async function gr(e,t,n){if(e.status!==t){let t;throw function(e){let t;if(t=function(e){if(!Sn(e,Response))throw j(`"response" must be an instance of Response`,wn);let t=e.headers.get(`www-authenticate`);if(t===null)return;let n=[],r=t;for(;r;){let e=r.match(fr),t=e?.[1].toLowerCase();if(!t)return;let i=r.substring(e[0].length);if(i&&!i.match(/^[\s,]/))return;let a=i.match(/^\s+(.*)$/),o=!!a;r=a?a[1]:void 0;let s={},c;if(o)for(;r;){let t,n;if(e=r.match(pr)){if([,t,n,r]=e,n.includes(`\\`))try{n=JSON.parse(`"${n}"`)}catch{}s[t.toLowerCase()]=n}else{if(!(e=r.match(mr))){if(e=r.match(hr)){if(Object.keys(s).length)break;[,c,r]=e;break}return}[,t,n,r]=e,s[t.toLowerCase()]=n}}else r=i||void 0;let l={scheme:t,parameters:s};c&&(l.token68=c),n.push(l)}return n.length?n:void 0}(e))throw new cr(`server responded with a challenge in the WWW-Authenticate HTTP Header`,{cause:t,response:e})}(e),(t=await async function(e){if(e.status>399&&e.status<500){Jr(e),Kn(e);try{let t=await e.clone().json();if(Bn(t)&&typeof t.error==`string`&&t.error.length)return t}catch{}}}(e))?(await e.body?.cancel(),new or(`server responded with an error in the response body`,{cause:t,response:e})):M(`"response" is not a conform ${n} response (unexpected HTTP status code)`,Br,e)}}function _r(e){if(!Dr.has(e))throw j(`"options.DPoP" is not a valid DPoPHandle`,Cn)}function vr(e){return e.headers.get(`content-type`)?.split(`;`)[0]}async function yr(e,t,n,r,i,a,o){return await n(e,t,i,a),a.set(`content-type`,`application/x-www-form-urlencoded;charset=UTF-8`),(o?.[On]||fetch)(r.href,{body:i,headers:Object.fromEntries(a.entries()),method:`POST`,redirect:`manual`,signal:Hn(r,o?.signal)})}async function br(e,t,n,r,i,a){var o;let s=ar(e,`token_endpoint`,t.use_mtls_endpoint_aliases,!0!==a?.[Tn]);i.set(`grant_type`,r);let c=Vn(a?.headers);c.set(`accept`,`application/json`),a?.DPoP!==void 0&&(_r(a.DPoP),await a.DPoP.addProof(s,c,`POST`));let l=await yr(e,t,n,s,i,c,a);return a==null||(o=a.DPoP)==null||o.cacheNonce(l,s),l}var xr=new WeakMap,Sr=new WeakMap;function Cr(e){if(!e.id_token)return;let t=xr.get(e);if(!t)throw j(`"ref" was already garbage collected or did not resolve from the proper sources`,Cn);return t}async function wr(e,t,n,r,i,a){if(Qn(e),$n(t),!Sn(n,Response))throw j(`"response" must be an instance of Response`,wn);await gr(n,200,`Token Endpoint`),Jr(n);let o=await ri(n);if(N(o.access_token,`"response" body "access_token" property`,P,{body:o}),N(o.token_type,`"response" body "token_type" property`,P,{body:o}),o.token_type=o.token_type.toLowerCase(),o.expires_in!==void 0){let e=typeof o.expires_in==`number`?o.expires_in:parseFloat(o.expires_in);Gn(e,!0,`"response" body "expires_in" property`,P,{body:o}),o.expires_in=e}if(o.refresh_token!==void 0&&N(o.refresh_token,`"response" body "refresh_token" property`,P,{body:o}),o.scope!==void 0&&typeof o.scope!=`string`)throw M(`"response" body "scope" property must be a string`,P,{body:o});if(o.id_token!==void 0){N(o.id_token,`"response" body "id_token" property`,P,{body:o});let a=[`aud`,`exp`,`iat`,`iss`,`sub`];!0===t.require_auth_time&&a.push(`auth_time`),t.default_max_age!==void 0&&(Gn(t.default_max_age,!0,`"client.default_max_age"`),a.push(`auth_time`)),r!=null&&r.length&&a.push(...r);let{claims:s,jwt:c}=await async function(e,t,n,r,i){let a,o,{0:s,1:c,length:l}=e.split(`.`);if(l===5){if(i===void 0)throw new Ln(`JWE decryption is not configured`,{cause:e});e=await i(e),{0:s,1:c,length:l}=e.split(`.`)}if(l!==3)throw M(`Invalid JWT`,P,e);try{a=JSON.parse(Nn(In(s)))}catch(e){throw M(`failed to parse JWT Header body as base64url encoded JSON`,Rr,e)}if(!Bn(a))throw M(`JWT Header must be a top level object`,P,e);if(t(a),a.crit!==void 0)throw new Ln(`no JWT "crit" header parameter extensions are supported`,{cause:{header:a}});try{o=JSON.parse(Nn(In(c)))}catch(e){throw M(`failed to parse JWT Payload body as base64url encoded JSON`,Rr,e)}if(!Bn(o))throw M(`JWT Payload must be a top level object`,P,e);let u=Zn()+n;if(o.exp!==void 0){if(typeof o.exp!=`number`)throw M(`unexpected JWT "exp" (expiration time) claim type`,P,{claims:o});if(o.exp<=u-r)throw M(`unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp`,Ur,{claims:o,now:u,tolerance:r,claim:`exp`})}if(o.iat!==void 0&&typeof o.iat!=`number`)throw M(`unexpected JWT "iat" (issued at) claim type`,P,{claims:o});if(o.iss!==void 0&&typeof o.iss!=`string`)throw M(`unexpected JWT "iss" (issuer) claim type`,P,{claims:o});if(o.nbf!==void 0){if(typeof o.nbf!=`number`)throw M(`unexpected JWT "nbf" (not before) claim type`,P,{claims:o});if(o.nbf>u+r)throw M(`unexpected JWT "nbf" (not before) claim value`,Ur,{claims:o,now:u,tolerance:r,claim:`nbf`})}if(o.aud!==void 0&&typeof o.aud!=`string`&&!Array.isArray(o.aud))throw M(`unexpected JWT "aud" (audience) claim type`,P,{claims:o});return{header:a,claims:o,jwt:e}}(o.id_token,Qr.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,`RS256`),Yn(t),Xn(t),i).then(Ar.bind(void 0,a)).then(Er.bind(void 0,e)).then(Tr.bind(void 0,t.client_id));if(Array.isArray(s.aud)&&s.aud.length!==1){if(s.azp===void 0)throw M(`ID Token "aud" (audience) claim includes additional untrusted audiences`,Wr,{claims:s,claim:`aud`});if(s.azp!==t.client_id)throw M(`unexpected ID Token "azp" (authorized party) claim value`,Wr,{expected:t.client_id,claims:s,claim:`azp`})}s.auth_time!==void 0&&Gn(s.auth_time,!0,`ID Token "auth_time" (authentication time)`,P,{claims:s}),Sr.set(n,c),xr.set(o,s)}if(a?.[o.token_type]!==void 0)a[o.token_type](n,o);else if(o.token_type!==`dpop`&&o.token_type!==`bearer`)throw new Ln("unsupported `token_type` value",{cause:{body:o}});return o}function Tr(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw M(`unexpected JWT "aud" (audience) claim value`,Wr,{expected:e,claims:t.claims,claim:`aud`})}else if(t.claims.aud!==e)throw M(`unexpected JWT "aud" (audience) claim value`,Wr,{expected:e,claims:t.claims,claim:`aud`});return t}function Er(e,t){let n=e[ai]?.call(e,t)??e.issuer;if(t.claims.iss!==n)throw M(`unexpected JWT "iss" (issuer) claim value`,Wr,{expected:n,claims:t.claims,claim:`iss`});return t}var Dr=new WeakSet,Or=Symbol(),kr={aud:`audience`,c_hash:`code hash`,client_id:`client id`,exp:`expiration time`,iat:`issued at`,iss:`issuer`,jti:`jwt id`,nonce:`nonce`,s_hash:`state hash`,sub:`subject`,ath:`access token hash`,htm:`http method`,htu:`http uri`,cnf:`confirmation`,auth_time:`authentication time`};function Ar(e,t){for(let n of e)if(t.claims[n]===void 0)throw M(`JWT "${n}" (${kr[n]}) claim missing`,P,{claims:t.claims});return t}var jr=Symbol(),Mr=Symbol();async function Nr(e,t,n,r){return typeof r?.expectedNonce==`string`||typeof r?.maxAge==`number`||r!=null&&r.requireIdToken?async function(e,t,n,r,i,a,o){let s=[];switch(r){case void 0:r=jr;break;case jr:break;default:N(r,`"expectedNonce" argument`),s.push(`nonce`)}switch(i??=t.default_max_age,i){case void 0:i=Mr;break;case Mr:break;default:Gn(i,!0,`"maxAge" argument`),s.push(`auth_time`)}let c=await wr(e,t,n,s,a,o);N(c.id_token,`"response" body "id_token" property`,P,{body:c});let l=Cr(c);if(i!==Mr){let e=Zn()+Yn(t),n=Xn(t);if(l.auth_time+i<e-n)throw M(`too much time has elapsed since the last End-User authentication`,Ur,{claims:l,now:e,tolerance:n,claim:`auth_time`})}if(r===jr){if(l.nonce!==void 0)throw M(`unexpected ID Token "nonce" claim value`,Wr,{expected:void 0,claims:l,claim:`nonce`})}else if(l.nonce!==r)throw M(`unexpected ID Token "nonce" claim value`,Wr,{expected:r,claims:l,claim:`nonce`});return c}(e,t,n,r.expectedNonce,r.maxAge,r[An],r.recognizedTokenTypes):async function(e,t,n,r,i){let a=await wr(e,t,n,void 0,r,i),o=Cr(a);if(o){if(t.default_max_age!==void 0){Gn(t.default_max_age,!0,`"client.default_max_age"`);let e=Zn()+Yn(t),n=Xn(t);if(o.auth_time+t.default_max_age<e-n)throw M(`too much time has elapsed since the last End-User authentication`,Ur,{claims:o,now:e,tolerance:n,claim:`auth_time`})}if(o.nonce!==void 0)throw M(`unexpected ID Token "nonce" claim value`,Wr,{expected:void 0,claims:o,claim:`nonce`})}return a}(e,t,n,r?.[An],r?.recognizedTokenTypes)}var Pr=`OAUTH_WWW_AUTHENTICATE_CHALLENGE`,Fr=`OAUTH_RESPONSE_BODY_ERROR`,Ir=`OAUTH_UNSUPPORTED_OPERATION`,Lr=`OAUTH_AUTHORIZATION_RESPONSE_ERROR`,Rr=`OAUTH_PARSE_ERROR`,P=`OAUTH_INVALID_RESPONSE`,zr=`OAUTH_RESPONSE_IS_NOT_JSON`,Br=`OAUTH_RESPONSE_IS_NOT_CONFORM`,Vr=`OAUTH_HTTP_REQUEST_FORBIDDEN`,Hr=`OAUTH_REQUEST_PROTOCOL_FORBIDDEN`,Ur=`OAUTH_JWT_TIMESTAMP_CHECK_FAILED`,Wr=`OAUTH_JWT_CLAIM_COMPARISON_FAILED`,Gr=`OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED`,Kr=`OAUTH_MISSING_SERVER_METADATA`,qr=`OAUTH_INVALID_SERVER_METADATA`;function Jr(e){if(e.bodyUsed)throw j(`"response" body has been used already`,Cn)}function Yr(e){let{algorithm:t}=e;if(typeof t.modulusLength!=`number`||t.modulusLength<2048)throw new Ln(`unsupported ${t.name} modulusLength`,{cause:e})}function Xr(e){let{algorithm:t}=e;switch(t.namedCurve){case`P-256`:return`SHA-256`;case`P-384`:return`SHA-384`;case`P-521`:return`SHA-512`;default:throw new Ln(`unsupported ECDSA namedCurve`,{cause:e})}}async function Zr(e){if(e.method!==`POST`)throw j(`form_post responses are expected to use the POST method`,Cn,{cause:e});if(vr(e)!==`application/x-www-form-urlencoded`)throw j(`form_post responses are expected to use the application/x-www-form-urlencoded content-type`,Cn,{cause:e});return async function(e){if(e.bodyUsed)throw j(`form_post Request instances must contain a readable body`,Cn,{cause:e});return e.text()}(e)}function Qr(e,t,n,r){if(e===void 0)if(Array.isArray(t)){if(!t.includes(r.alg))throw M(`unexpected JWT "alg" header parameter`,P,{header:r,expected:t,reason:`authorization server metadata`})}else{if(n===void 0)throw M(`missing client or server configuration to verify used JWT "alg" header parameter`,void 0,{client:e,issuer:t,fallback:n});if(typeof n==`string`?r.alg!==n:typeof n==`function`?!n(r.alg):!n.includes(r.alg))throw M(`unexpected JWT "alg" header parameter`,P,{header:r,expected:n,reason:`default value`})}else if(typeof e==`string`?r.alg!==e:!e.includes(r.alg))throw M(`unexpected JWT "alg" header parameter`,P,{header:r,expected:e,reason:`client configuration`})}function $r(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw M(`"${t}" parameter must be provided only once`,P);return n}var ei=Symbol(),ti=Symbol();function ni(e,t,n,r){if(Qn(e),$n(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw j(`"parameters" must be an instance of URLSearchParams, or URL`,wn);if($r(n,`response`))throw M(`"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()`,P,{parameters:n});let i=$r(n,`iss`),a=$r(n,`state`);if(!i&&e.authorization_response_iss_parameter_supported)throw M(`response parameter "iss" (issuer) missing`,P,{parameters:n});if(i&&i!==e.issuer)throw M(`unexpected "iss" (issuer) response parameter value`,P,{expected:e.issuer,parameters:n});switch(r){case void 0:case ti:if(a!==void 0)throw M(`unexpected "state" response parameter encountered`,P,{expected:void 0,parameters:n});break;case ei:break;default:if(N(r,`"expectedState" argument`),a!==r)throw M(a===void 0?`response parameter "state" missing`:`unexpected "state" response parameter value`,P,{expected:r,parameters:n})}if($r(n,`error`))throw new sr(`authorization response from the server is an error`,{cause:n});let o=$r(n,`id_token`),s=$r(n,`token`);if(o!==void 0||s!==void 0)throw new Ln(`implicit and hybrid flows are not supported`);return c=new URLSearchParams(n),Dr.add(c),c;var c}async function ri(e){let t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kn;try{t=await e.json()}catch(t){throw n(e),M(`failed to parse "response" body as JSON`,Rr,t)}if(!Bn(t))throw M(`"response" body must be a top level object`,P,{body:t});return t}var ii=Symbol(),ai=Symbol(),oi=new TextEncoder,si=new TextDecoder;function ci(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>127)throw TypeError(`non-ASCII string encountered in encode()`);t[n]=r}return t}function li(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function ui(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:si.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=si.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return li(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}var di=function(e){return TypeError(`CryptoKey does not support this operation, its ${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`algorithm.name`} must be ${e}`)},fi=(e,t)=>e.name===t;function pi(e,t){var n;if((n=e.hash,parseInt(n.name.slice(4),10))!==t)throw di(`SHA-${t}`,`algorithm.hash`)}function mi(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!fi(e.algorithm,`HMAC`))throw di(`HMAC`);pi(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!fi(e.algorithm,`RSASSA-PKCS1-v1_5`))throw di(`RSASSA-PKCS1-v1_5`);pi(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!fi(e.algorithm,`RSA-PSS`))throw di(`RSA-PSS`);pi(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!fi(e.algorithm,`Ed25519`))throw di(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!fi(e.algorithm,t))throw di(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!fi(e.algorithm,`ECDSA`))throw di(`ECDSA`);let n=function(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}(t);if(e.algorithm.namedCurve!==n)throw di(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}(function(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)})(e,n)}function hi(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];if((r=r.filter(Boolean)).length>2){let t=r.pop();e+=`one of type ${r.join(`, `)}, or ${t}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;if(t==null)e+=` Received ${t}`;else if(typeof t==`function`&&t.name)e+=` Received function ${t.name}`;else if(typeof t==`object`&&t){var a;(a=t.constructor)!=null&&a.name&&(e+=` Received an instance of ${t.constructor.name}`)}return e}var gi=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return hi(`Key for the ${e} algorithm must be `,t,...r)},_i=class extends Error{constructor(e,t){var n;super(e,t),E(this,`code`,`ERR_JOSE_GENERIC`),this.name=this.constructor.name,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};E(_i,`code`,`ERR_JOSE_GENERIC`);var vi=class extends _i{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),E(this,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`),E(this,`claim`,void 0),E(this,`reason`,void 0),E(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};E(vi,`code`,`ERR_JWT_CLAIM_VALIDATION_FAILED`);var yi=class extends _i{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`unspecified`,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`unspecified`;super(e,{cause:{claim:n,reason:r,payload:t}}),E(this,`code`,`ERR_JWT_EXPIRED`),E(this,`claim`,void 0),E(this,`reason`,void 0),E(this,`payload`,void 0),this.claim=n,this.reason=r,this.payload=t}};E(yi,`code`,`ERR_JWT_EXPIRED`);var bi=class extends _i{constructor(){super(...arguments),E(this,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`)}};E(bi,`code`,`ERR_JOSE_ALG_NOT_ALLOWED`);var xi=class extends _i{constructor(){super(...arguments),E(this,`code`,`ERR_JOSE_NOT_SUPPORTED`)}};E(xi,`code`,`ERR_JOSE_NOT_SUPPORTED`),E(class extends _i{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`decryption operation failed`,arguments.length>1?arguments[1]:void 0),E(this,`code`,`ERR_JWE_DECRYPTION_FAILED`)}},`code`,`ERR_JWE_DECRYPTION_FAILED`),E(class extends _i{constructor(){super(...arguments),E(this,`code`,`ERR_JWE_INVALID`)}},`code`,`ERR_JWE_INVALID`);var Si=class extends _i{constructor(){super(...arguments),E(this,`code`,`ERR_JWS_INVALID`)}};E(Si,`code`,`ERR_JWS_INVALID`);var Ci=class extends _i{constructor(){super(...arguments),E(this,`code`,`ERR_JWT_INVALID`)}};E(Ci,`code`,`ERR_JWT_INVALID`),E(class extends _i{constructor(){super(...arguments),E(this,`code`,`ERR_JWK_INVALID`)}},`code`,`ERR_JWK_INVALID`);var wi=class extends _i{constructor(){super(...arguments),E(this,`code`,`ERR_JWKS_INVALID`)}};E(wi,`code`,`ERR_JWKS_INVALID`);var Ti=class extends _i{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`no applicable key found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),E(this,`code`,`ERR_JWKS_NO_MATCHING_KEY`)}};E(Ti,`code`,`ERR_JWKS_NO_MATCHING_KEY`);var Ei=class extends _i{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`multiple matching keys found in the JSON Web Key Set`,arguments.length>1?arguments[1]:void 0),E(this,Symbol.asyncIterator,void 0),E(this,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`)}};E(Ei,`code`,`ERR_JWKS_MULTIPLE_MATCHING_KEYS`);var Di=class extends _i{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`request timed out`,arguments.length>1?arguments[1]:void 0),E(this,`code`,`ERR_JWKS_TIMEOUT`)}};E(Di,`code`,`ERR_JWKS_TIMEOUT`);var Oi=class extends _i{constructor(){super(arguments.length>0&&arguments[0]!==void 0?arguments[0]:`signature verification failed`,arguments.length>1?arguments[1]:void 0),E(this,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`)}};E(Oi,`code`,`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`);var ki=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},Ai=e=>e?.[Symbol.toStringTag]===`KeyObject`,ji=e=>ki(e)||Ai(e);function Mi(e,t,n){try{return ui(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}function Ni(e){if(typeof(t=e)!=`object`||t===null||Object.prototype.toString.call(e)!==`[object Object]`)return!1;var t;if(Object.getPrototypeOf(e)===null)return!0;let n=e;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}var Pi=e=>Ni(e)&&typeof e.kty==`string`;async function Fi(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return hi(`Key must be `,e,...n)}(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return mi(t,e,n),t}async function Ii(e,t,n,r){let i=await Fi(e,t,`verify`);(function(e,t){if(e.startsWith(`RS`)||e.startsWith(`PS`)){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}})(e,i);let a=function(e,t){let n=`SHA-${e.slice(-3)}`;switch(e){case`HS256`:case`HS384`:case`HS512`:return{hash:n,name:`HMAC`};case`PS256`:case`PS384`:case`PS512`:return{hash:n,name:`RSA-PSS`,saltLength:parseInt(e.slice(-3),10)>>3};case`RS256`:case`RS384`:case`RS512`:return{hash:n,name:`RSASSA-PKCS1-v1_5`};case`ES256`:case`ES384`:case`ES512`:return{hash:n,name:`ECDSA`,namedCurve:t.namedCurve};case`Ed25519`:case`EdDSA`:return{name:`Ed25519`};case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return{name:e};default:throw new xi(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var Li=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;async function Ri(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=function(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new xi(Li)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new xi(Li)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new xi(Li)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new xi(Li)}break;default:throw new xi(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}(e),r=D({},e);return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??(!e.d&&!e.priv),e.key_ops??n)}var zi=`given KeyObject instance cannot be used for this algorithm`,Bi,Vi=async function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];Bi||=new WeakMap;let i=Bi.get(e);if(i!=null&&i[n])return i[n];let a=await Ri(D(D({},t),{},{alg:n}));return r&&Object.freeze(e),i?i[n]=a:Bi.set(e,{[n]:a}),a};async function Hi(e,t){if(e instanceof Uint8Array||ki(e))return e;if(Ai(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return((e,t)=>{Bi||=new WeakMap;let n=Bi.get(e);if(n!=null&&n[t])return n[t];let r=e.type===`public`,i=!!r,a;if(e.asymmetricKeyType===`x25519`){switch(t){case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:break;default:throw TypeError(zi)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(zi);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}switch(e.asymmetricKeyType){case`ml-dsa-44`:case`ml-dsa-65`:case`ml-dsa-87`:if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(zi);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`rsa`){let n;switch(t){case`RSA-OAEP`:n=`SHA-1`;break;case`RS256`:case`PS256`:case`RSA-OAEP-256`:n=`SHA-256`;break;case`RS384`:case`PS384`:case`RSA-OAEP-384`:n=`SHA-384`;break;case`RS512`:case`PS512`:case`RSA-OAEP-512`:n=`SHA-512`;break;default:throw TypeError(zi)}if(t.startsWith(`RSA-OAEP`))return e.toCryptoKey({name:`RSA-OAEP`,hash:n},i,r?[`encrypt`]:[`decrypt`]);a=e.toCryptoKey({name:t.startsWith(`PS`)?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:n},i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`ec`){let n=new Map([[`prime256v1`,`P-256`],[`secp384r1`,`P-384`],[`secp521r1`,`P-521`]]).get(e.asymmetricKeyDetails?.namedCurve);if(!n)throw TypeError(zi);let o={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};o[t]&&n===o[t]&&(a=e.toCryptoKey({name:`ECDSA`,namedCurve:n},i,[r?`verify`:`sign`])),t.startsWith(`ECDH-ES`)&&(a=e.toCryptoKey({name:`ECDH`,namedCurve:n},i,r?[]:[`deriveBits`]))}if(!a)throw TypeError(zi);return n?n[t]=a:Bi.set(e,{[t]:a}),a})(e,t)}catch(e){if(e instanceof TypeError)throw e}return Vi(e,e.export({format:`jwk`}),t)}if(Pi(e))return e.k?ui(e.k):Vi(e,e,t,!0);throw Error(`unreachable`)}var Ui=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},Wi=e=>{let t=e.data[e.pos++];if(128&t){let n=127&t,r=0;for(let t=0;t<n;t++)r=r<<8|e.data[e.pos++];return r}return t},Gi=(e,t,n)=>{if(e.data[e.pos++]!==t)throw Error(n)},Ki=(e,t)=>{let n=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,n},qi=e=>{let t=(e=>(Gi(e,6,`Expected algorithm OID`),Ki(e,Wi(e))))(e);if(Ui(t,[43,101,110]))return`X25519`;if(!Ui(t,[42,134,72,206,61,2,1]))throw Error(`Unsupported key algorithm`);Gi(e,6,`Expected curve OID`);let n=Ki(e,Wi(e));for(let{name:e,oid:t}of[{name:`P-256`,oid:[42,134,72,206,61,3,1,7]},{name:`P-384`,oid:[43,129,4,0,34]},{name:`P-521`,oid:[43,129,4,0,35]}])if(Ui(n,t))return e;throw Error(`Unsupported named curve`)},Ji=async(e,t,n,r)=>{let i,a,o=e===`spki`,s=()=>o?[`verify`]:[`sign`];switch(n){case`PS256`:case`PS384`:case`PS512`:i={name:`RSA-PSS`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RS256`:case`RS384`:case`RS512`:i={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${n.slice(-3)}`},a=s();break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:i={name:`RSA-OAEP`,hash:`SHA-${parseInt(n.slice(-3),10)||1}`},a=o?[`encrypt`,`wrapKey`]:[`decrypt`,`unwrapKey`];break;case`ES256`:case`ES384`:case`ES512`:i={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[n]},a=s();break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:try{let e=r.getNamedCurve(t);i=e===`X25519`?{name:`X25519`}:{name:`ECDH`,namedCurve:e}}catch{throw new xi(`Invalid or unsupported key format`)}a=o?[]:[`deriveBits`];break;case`Ed25519`:case`EdDSA`:i={name:`Ed25519`},a=s();break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:i={name:n},a=s();break;default:throw new xi(`Invalid or unsupported "alg" (Algorithm) value`)}return crypto.subtle.importKey(e,t,i,r?.extractable??!!o,a)},Yi=(e,t,n)=>{var r;let i=((e,t)=>li(e.replace(t,``)))(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g),a=n;return t!=null&&(r=t.startsWith)!=null&&r.call(t,`ECDH-ES`)&&(a||={},a.getNamedCurve=e=>{let t={data:e,pos:0};return function(e){Gi(e,48,`Invalid PKCS#8 structure`),Wi(e),Gi(e,2,`Expected version field`);let t=Wi(e);e.pos+=t,Gi(e,48,`Expected algorithm identifier`),Wi(e),e.pos}(t),qi(t)}),Ji(`pkcs8`,i,t,a)},Xi=e=>e?.[Symbol.toStringTag],Zi=(e,t,n)=>{if(t.use!==void 0){let e;switch(n){case`sign`:case`verify`:e=`sig`;break;case`encrypt`:case`decrypt`:e=`enc`}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){var r,i;let a;switch(!0){case n===`sign`||n===`verify`:case e===`dir`:case e.includes(`CBC-HS`):a=n;break;case e.startsWith(`PBES2`):a=`deriveBits`;break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):a=!e.includes(`GCM`)&&e.endsWith(`KW`)?n===`encrypt`?`wrapKey`:`unwrapKey`:n;break;case n===`encrypt`&&e.startsWith(`RSA`):a=`wrapKey`;break;case n===`decrypt`:a=e.startsWith(`RSA`)?`unwrapKey`:`deriveBits`}if(a&&!1===((r=t.key_ops)==null||(i=r.includes)==null?void 0:i.call(r,a)))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${a}" when present`)}return!0};function Qi(e,t,n){switch(e.substring(0,2)){case`A1`:case`A2`:case`di`:case`HS`:case`PB`:((e,t,n)=>{if(!(t instanceof Uint8Array)){if(Pi(t)){if((e=>e.kty===`oct`&&typeof e.k==`string`)(t)&&Zi(e,t,n))return;throw TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!ji(t))throw TypeError(gi(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${Xi(t)} instances for symmetric algorithms must be of type "secret"`)}})(e,t,n);break;default:((e,t,n)=>{if(Pi(t))switch(n){case`decrypt`:case`sign`:if((e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`))(t)&&Zi(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if((e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0)(t)&&Zi(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!ji(t))throw TypeError(gi(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${Xi(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${Xi(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${Xi(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${Xi(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${Xi(t)} instances for asymmetric algorithm encryption must be of type "public"`)}})(e,t,n)}}var $i,ea,ta,na;(typeof navigator>`u`||($i=navigator.userAgent)==null||(ea=$i.startsWith)==null||!ea.call($i,`Mozilla/5.0 `))&&(na=`openid-client/v6.8.2`,ta={"user-agent":na});var ra=e=>ia.get(e),ia,aa;function oa(e){return e===void 0?(aa||=new WeakMap,(e,t,n,r)=>{let i;return(i=aa.get(t))||(function(e,t){if(typeof e!=`string`)throw ua(`${t} must be a string`,la);if(e.length===0)throw ua(`${t} must not be empty`,ca)}(t.client_secret,`"metadata.client_secret"`),i=er(t.client_secret),aa.set(t,i)),i(e,t,n,r)}):er(e)}var sa=On,ca=`ERR_INVALID_ARG_VALUE`,la=`ERR_INVALID_ARG_TYPE`;function ua(e,t,n){let r=TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function da(e){return async function(e){return N(e,`codeVerifier`),In(await crypto.subtle.digest(`SHA-256`,Nn(e)))}(e)}function fa(){return qn()}var pa=class extends Error{constructor(e,t){var n;super(e,t),E(this,`code`,void 0),this.name=this.constructor.name,this.code=t?.code,(n=Error.captureStackTrace)==null||n.call(Error,this,this.constructor)}};function ma(e,t,n){return new pa(e,{cause:t,code:n})}function ha(e){if(e instanceof TypeError||e instanceof pa||e instanceof or||e instanceof sr||e instanceof cr)throw e;if(e instanceof Rn)switch(e.code){case Vr:throw ma(`only requests to HTTPS are allowed`,e,e.code);case Hr:throw ma(`only requests to HTTP or HTTPS are allowed`,e,e.code);case Br:throw ma(`unexpected HTTP response status code`,e.cause,e.code);case zr:throw ma(`unexpected response content-type`,e.cause,e.code);case Rr:throw ma(`parsing error occured`,e,e.code);case P:throw ma(`invalid response encountered`,e,e.code);case Wr:throw ma(`unexpected JWT claim value encountered`,e,e.code);case Gr:throw ma(`unexpected JSON attribute value encountered`,e,e.code);case Ur:throw ma(`JWT timestamp claim value failed validation`,e,e.code);default:throw ma(e.message,e,e.code)}if(e instanceof Ln)throw ma(`unsupported operation`,e,e.code);if(e instanceof DOMException)switch(e.name){case`OperationError`:throw ma(`runtime operation error`,e,Ir);case`NotSupportedError`:throw ma(`runtime unsupported operation`,e,Ir);case`TimeoutError`:throw ma(`operation timed out`,e,`OAUTH_TIMEOUT`);case`AbortError`:throw ma(`operation aborted`,e,`OAUTH_ABORT`)}throw new pa(`something went wrong`,{cause:e})}async function ga(e,t,n,r,i){let a=new va(await async function(e,t){var n;if(!(e instanceof URL))throw ua(`"server" must be an instance of URL`,la);let r=!e.href.includes(`/.well-known/`),i=t?.timeout??30,a=AbortSignal.timeout(1e3*i),o=await(r?Wn(e,{algorithm:t?.algorithm,[On]:t?.[sa],[Tn]:t==null||(n=t.execute)==null?void 0:n.includes(wa),signal:a,headers:new Headers(ta)}):(t?.[sa]||fetch)((rr(e,t==null||(s=t.execute)==null||!s.includes(wa)),e.href),{headers:Object.fromEntries(new Headers(D({accept:`application/json`},ta)).entries()),body:void 0,method:`GET`,redirect:`manual`,signal:a})).then(e=>async function(e,t){let n=e;if(!(n instanceof URL)&&n!==ii)throw j(`"expectedIssuerIdentifier" must be an instance of URL`,wn);if(!Sn(t,Response))throw j(`"response" must be an instance of Response`,wn);if(t.status!==200)throw M(`"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)`,Br,t);Jr(t);let r=await ri(t);if(N(r.issuer,`"response" body "issuer" property`,P,{body:r}),n!==ii&&new URL(r.issuer).href!==n.href)throw M(`"response" body "issuer" property does not match the expected value`,Gr,{expected:n.href,body:r,attribute:`issuer`});return r}(ii,e)).catch(ha);var s;return r&&new URL(o.issuer).href!==e.href&&(function(e,t,n){return!(e.origin!==`https://login.microsoftonline.com`||n!=null&&n.algorithm&&n.algorithm!==`oidc`||(t[_a]=!0,0))}(e,o,t)||function(e,t){return!(!e.hostname.endsWith(`.b2clogin.com`)||t!=null&&t.algorithm&&t.algorithm!==`oidc`)}(e,t)||(()=>{throw new pa(`discovered metadata issuer does not match the expected issuer`,{code:Gr,cause:{expected:e.href,body:o,attribute:`issuer`}})})()),o}(e,i),t,n,r),o=ra(a);if(i!=null&&i[sa]&&(o.fetch=i[sa]),i!=null&&i.timeout&&(o.timeout=i.timeout),i!=null&&i.execute)for(let e of i.execute)e(a);return a}new TextDecoder;var _a=Symbol(),va=class{constructor(e,t,n,r){if(typeof t!=`string`||!t.length)throw ua(`"clientId" must be a non-empty string`,la);if(typeof n==`string`&&(n={client_secret:n}),n?.client_id!==void 0&&t!==n.client_id)throw ua(`"clientId" and "metadata.client_id" must be the same`,ca);let i=D(D({},structuredClone(n)),{},{client_id:t}),a;i[En]=n?.[En]??0,i[Dn]=n?.[Dn]??30,a=r||(typeof i.client_secret==`string`&&i.client_secret.length?oa(i.client_secret):(e,t,n,r)=>{n.set(`client_id`,t.client_id)});let o=Object.freeze(i),s=structuredClone(e);_a in e&&(s[ai]=t=>{let{claims:{tid:n}}=t;return e.issuer.replace(`{tenantid}`,n)});let c=Object.freeze(s);ia||=new WeakMap,ia.set(this,{__proto__:null,as:c,c:o,auth:a,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let e=structuredClone(ra(this).as);return function(e){Object.defineProperties(e,function(e){return{supportsPKCE:{__proto__:null,value(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`S256`;return!0===e.code_challenge_methods_supported?.includes(t)}}}}(e))}(e),e}clientMetadata(){return structuredClone(ra(this).c)}get timeout(){return ra(this).timeout}set timeout(e){ra(this).timeout=e}get[sa](){return ra(this).fetch}set[sa](e){ra(this).fetch=e}};function ya(e){Object.defineProperties(e,function(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let e=Date.now();return t>e?Math.floor((t-e)/1e3):0}}},claims:{__proto__:null,value(){try{return Cr(this)}catch{return}}}}}(e))}async function ba(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0&&arguments[3],i=e.headers.get(`retry-after`)?.trim();if(i===void 0)return;let a;if(/^\d+$/.test(i))a=parseInt(i,10);else{let e=new Date(i);if(Number.isFinite(e.getTime())){let t=new Date,n=e.getTime()-t.getTime();n>0&&(a=Math.ceil(n/1e3))}}if(r&&!Number.isFinite(a))throw new Rn(`invalid Retry-After header value`,{cause:e});a>t&&await xa(a-t,n)}function xa(e,t){return new Promise((n,r)=>{let i=e=>{try{t.throwIfAborted()}catch(e){r(e);return}if(e<=0)return void n();let a=Math.min(e,5);setTimeout(()=>i(e-a),1e3*a)};i(e)})}async function Sa(e,t){Aa(e);let{as:n,c:r,auth:i,fetch:a,tlsOnly:o,timeout:s}=ra(e);return async function(e,t,n,r,i){Qn(e),$n(t);let a=ar(e,`backchannel_authentication_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[Tn]),o=new URLSearchParams(r);o.set(`client_id`,t.client_id);let s=Vn(i?.headers);return s.set(`accept`,`application/json`),yr(e,t,n,a,o,s,i)}(n,r,i,t,{[On]:a,[Tn]:!o,headers:new Headers(ta),signal:ja(s)}).then(e=>async function(e,t,n){if(Qn(e),$n(t),!Sn(n,Response))throw j(`"response" must be an instance of Response`,wn);await gr(n,200,`Backchannel Authentication Endpoint`),Jr(n);let r=await ri(n);N(r.auth_req_id,`"response" body "auth_req_id" property`,P,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Gn(i,!0,`"response" body "expires_in" property`,P,{body:r}),r.expires_in=i,r.interval!==void 0&&Gn(r.interval,!1,`"response" body "interval" property`,P,{body:r}),r}(n,r,e)).catch(ha)}async function Ca(e,t,n,r){Aa(e),n=new URLSearchParams(n);let i=t.interval??5,a=r?.signal??AbortSignal.timeout(1e3*t.expires_in);try{await xa(i,a)}catch(e){ha(e)}let{as:o,c:s,auth:c,fetch:l,tlsOnly:u,nonRepudiation:d,timeout:f,decrypt:p}=ra(e),m=(i,o)=>Ca(e,D(D({},t),{},{interval:i}),n,D(D({},r),{},{signal:a,flag:o})),h=await async function(e,t,n,r,i){Qn(e),$n(t),N(r,`"authReqId"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`auth_req_id`,r),br(e,t,n,`urn:openid:params:grant-type:ciba`,a,i)}(o,s,c,t.auth_req_id,{[On]:l,[Tn]:!u,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(ta),signal:a.aborted?a:ja(f)}).catch(ha);if(h.status===503&&h.headers.has(`retry-after`))return await ba(h,i,a,!0),await h.body?.cancel(),m(i);let g=async function(e,t,n,r){return wr(e,t,n,void 0,r?.[An],r?.recognizedTokenTypes)}(o,s,h,{[An]:p}),_;try{_=await g}catch(e){if(Ma(e,r))return m(i,Na);if(e instanceof or)switch(e.error){case`slow_down`:i+=5;case`authorization_pending`:return await ba(e.response,i,a),m(i)}ha(e)}return _.id_token&&await d?.(h),ya(_),_}function wa(e){ra(e).tlsOnly=!1}async function Ta(e,t,n,r,i){if(Aa(e),!(i?.flag===Na||t instanceof URL||function(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}(t,`Request`)))throw ua(`"currentUrl" must be an instance of URL, or Request`,la);let a,o,{as:s,c,auth:l,fetch:u,tlsOnly:d,jarm:f,hybrid:p,nonRepudiation:m,timeout:h,decrypt:g,implicit:_}=ra(e);if(i?.flag===Na)a=i.authResponse,o=i.redirectUri;else{if(!(t instanceof URL)){let e=t;switch(t=new URL(t.url),e.method){case`GET`:break;case`POST`:let n=new URLSearchParams(await Zr(e));if(p)t.hash=n.toString();else for(let[e,r]of n.entries())t.searchParams.append(e,r);break;default:throw ua(`unexpected Request HTTP method`,ca)}}switch(o=function(e){return(e=new URL(e)).search=``,e.hash=``,e.href}(t),!0){case!!f:a=await f(t,n?.expectedState);break;case!!p:a=await p(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!_:throw TypeError(`authorizationCodeGrant() cannot be used by response_type=id_token clients`);default:try{a=ni(s,c,t.searchParams,n?.expectedState)}catch(e){ha(e)}}}let v=await async function(e,t,n,r,i,a,o){if(Qn(e),$n(t),!Dr.has(r))throw j(`"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()`,Cn);N(i,`"redirectUri"`);let s=$r(r,`code`);if(!s)throw M(`no authorization code in "callbackParameters"`,P);let c=new URLSearchParams(o?.additionalParameters);return c.set(`redirect_uri`,i),c.set(`code`,s),a!==Or&&(N(a,`"codeVerifier"`),c.set(`code_verifier`,a)),br(e,t,n,`authorization_code`,c,o)}(s,c,l,a,o,n?.pkceCodeVerifier||Or,{additionalParameters:r,[On]:u,[Tn]:!d,DPoP:i?.DPoP,headers:new Headers(ta),signal:ja(h)}).catch(ha);typeof n?.expectedNonce!=`string`&&typeof n?.maxAge!=`number`||(n.idTokenExpected=!0);let ee=Nr(s,c,v,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[An]:g}),y;try{y=await ee}catch(t){if(Ma(t,i))return Ta(e,void 0,n,r,D(D({},i),{},{flag:Na,authResponse:a,redirectUri:o}));ha(t)}return y.id_token&&await m?.(v),ya(y),y}async function Ea(e,t,n,r){Aa(e),n=new URLSearchParams(n);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,nonRepudiation:l,timeout:u,decrypt:d}=ra(e),f=await async function(e,t,n,r,i){Qn(e),$n(t),N(r,`"refreshToken"`);let a=new URLSearchParams(i?.additionalParameters);return a.set(`refresh_token`,r),br(e,t,n,`refresh_token`,a,i)}(i,a,o,t,{[On]:s,[Tn]:!c,additionalParameters:n,DPoP:r?.DPoP,headers:new Headers(ta),signal:ja(u)}).catch(ha),p=async function(e,t,n,r){return wr(e,t,n,void 0,r?.[An],r?.recognizedTokenTypes)}(i,a,f,{[An]:d}),m;try{m=await p}catch(i){if(Ma(i,r))return Ea(e,t,n,D(D({},r),{},{flag:Na}));ha(i)}return m.id_token&&await l?.(f),ya(m),m}async function Da(e,t,n){Aa(e),t=new URLSearchParams(t);let{as:r,c:i,auth:a,fetch:o,tlsOnly:s,timeout:c}=ra(e),l=async function(e,t,n,r){return wr(e,t,n,void 0,r?.[An],r?.recognizedTokenTypes)}(r,i,await async function(e,t,n,r,i){return Qn(e),$n(t),br(e,t,n,`client_credentials`,new URLSearchParams(r),i)}(r,i,a,t,{[On]:o,[Tn]:!s,DPoP:n?.DPoP,headers:new Headers(ta),signal:ja(c)}).catch(ha)),u;try{u=await l}catch(r){if(Ma(r,n))return Da(e,t,D(D({},n),{},{flag:Na}));ha(r)}return ya(u),u}function Oa(e,t){Aa(e);let{as:n,c:r,tlsOnly:i,hybrid:a,jarm:o,implicit:s}=ra(e),c=ar(n,`authorization_endpoint`,!1,i);if((t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id),!t.has(`request_uri`)&&!t.has(`request`)){if(t.has(`response_type`)||t.set(`response_type`,a?`code id_token`:s?`id_token`:`code`),s&&!t.has(`nonce`))throw ua(`response_type=id_token clients must provide a nonce parameter in their authorization request parameters`,ca);o&&t.set(`response_mode`,`jwt`)}for(let[e,n]of t.entries())c.searchParams.append(e,n);return c}async function ka(e,t,n){Aa(e);let r=Oa(e,t),{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l}=ra(e),u=async function(e,t,n){if(Qn(e),$n(t),!Sn(n,Response))throw j(`"response" must be an instance of Response`,wn);await gr(n,201,`Pushed Authorization Request Endpoint`),Jr(n);let r=await ri(n);N(r.request_uri,`"response" body "request_uri" property`,P,{body:r});let i=typeof r.expires_in==`number`?r.expires_in:parseFloat(r.expires_in);return Gn(i,!0,`"response" body "expires_in" property`,P,{body:r}),r.expires_in=i,r}(i,a,await async function(e,t,n,r,i){var a;Qn(e),$n(t);let o=ar(e,`pushed_authorization_request_endpoint`,t.use_mtls_endpoint_aliases,!0!==i?.[Tn]),s=new URLSearchParams(r);s.set(`client_id`,t.client_id);let c=Vn(i?.headers);c.set(`accept`,`application/json`),i?.DPoP!==void 0&&(_r(i.DPoP),await i.DPoP.addProof(o,c,`POST`));let l=await yr(e,t,n,o,s,c,i);return i==null||(a=i.DPoP)==null||a.cacheNonce(l,o),l}(i,a,o,r.searchParams,{[On]:s,[Tn]:!c,DPoP:n?.DPoP,headers:new Headers(ta),signal:ja(l)}).catch(ha)),d;try{d=await u}catch(r){if(Ma(r,n))return ka(e,t,D(D({},n),{},{flag:Na}));ha(r)}return Oa(e,{request_uri:d.request_uri})}function Aa(e){if(!(e instanceof va))throw ua(`"config" must be an instance of Configuration`,la);if(Object.getPrototypeOf(e)!==va.prototype)throw ua(`subclassing Configuration is not allowed`,ca)}function ja(e){return e?AbortSignal.timeout(1e3*e):void 0}function Ma(e,t){return!(t==null||!t.DPoP||t.flag===Na)&&function(e){if(e instanceof cr){let{0:t,length:n}=e.cause;return n===1&&t.scheme===`dpop`&&t.parameters.error===`use_dpop_nonce`}return e instanceof or&&e.error===`use_dpop_nonce`}(e)}Object.freeze(va.prototype);var Na=Symbol();async function Pa(e,t,n,r){Aa(e);let{as:i,c:a,auth:o,fetch:s,tlsOnly:c,timeout:l,decrypt:u}=ra(e),d=await async function(e,t,n,r,i,a){return Qn(e),$n(t),N(r,`"grantType"`),br(e,t,n,r,new URLSearchParams(i),a)}(i,a,o,t,new URLSearchParams(n),{[On]:s,[Tn]:!c,DPoP:r?.DPoP,headers:new Headers(ta),signal:ja(l)}).then(e=>{let n;return t===`urn:ietf:params:oauth:grant-type:token-exchange`&&(n={n_a:()=>{}}),async function(e,t,n,r){return wr(e,t,n,void 0,r?.[An],r?.recognizedTokenTypes)}(i,a,e,{[An]:u,recognizedTokenTypes:n})}).catch(ha);return ya(d),d}async function Fa(e,t,n){if(!Ni(e))throw new Si(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new Si(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new Si(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new Si(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new Si(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!Ni(e.header))throw new Si(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=ui(e.protected);r=JSON.parse(si.decode(t))}catch{throw new Si(`JWS Protected Header is invalid`)}if(!function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.filter(Boolean);if(r.length===0||r.length===1)return!0;let i;for(let e of r){let t=Object.keys(e);if(i&&i.size!==0)for(let e of t){if(i.has(e))return!1;i.add(e)}else i=new Set(t)}return!0}(r,e.header))throw new Si(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i=D(D({},r),e.header),a=function(e,t,n,r,i){if(i.crit!==void 0&&r?.crit===void 0)throw new e(`"crit" (Critical) Header Parameter MUST be integrity protected`);if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(e=>typeof e!=`string`||e.length===0))throw new e(`"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present`);let a;a=n===void 0?t:new Map([...Object.entries(n),...t.entries()]);for(let t of r.crit){if(!a.has(t))throw new xi(`Extension Header Parameter "${t}" is not recognized`);if(i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&r[t]===void 0)throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(r.crit)}(Si,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new Si(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new Si(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&function(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some(e=>typeof e!=`string`)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new bi(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new Si(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new Si(`JWS Payload must be a string or an Uint8Array instance`);let l=!1;typeof t==`function`&&(t=await t(r,e),l=!0),Qi(s,t,`verify`);let u=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=t.reduce((e,t)=>{let{length:n}=t;return e+n},0),i=new Uint8Array(r),a=0;for(let e of t)i.set(e,a),a+=e.length;return i}(e.protected===void 0?new Uint8Array:ci(e.protected),ci(`.`),typeof e.payload==`string`?o?ci(e.payload):oi.encode(e.payload):e.payload),d=Mi(e.signature,`signature`,Si),f=await Hi(t,s);if(!await Ii(s,f,d,u))throw new Oi;let p;p=o?Mi(e.payload,`payload`,Si):typeof e.payload==`string`?oi.encode(e.payload):e.payload;let m={payload:p};return e.protected!==void 0&&(m.protectedHeader=r),e.header!==void 0&&(m.unprotectedHeader=e.header),l?D(D({},m),{},{key:f}):m}var Ia=86400,La=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Ra(e){let t=La.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r;switch(t[3].toLowerCase()){case`sec`:case`secs`:case`second`:case`seconds`:case`s`:r=Math.round(n);break;case`minute`:case`minutes`:case`min`:case`mins`:case`m`:r=Math.round(60*n);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:r=Math.round(3600*n);break;case`day`:case`days`:case`d`:r=Math.round(n*Ia);break;case`week`:case`weeks`:case`w`:r=Math.round(604800*n);break;default:r=Math.round(31557600*n)}return t[1]===`-`||t[4]===`ago`?-r:r}var za=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`;function Ba(e,t){let n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};try{n=JSON.parse(si.decode(t))}catch{}if(!Ni(n))throw new Ci(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=r;if(i&&(typeof e.typ!=`string`||za(e.typ)!==za(i)))throw new vi(`unexpected "typ" JWT header value`,n,`typ`,`check_failed`);let{requiredClaims:a=[],issuer:o,subject:s,audience:c,maxTokenAge:l}=r,u=[...a];l!==void 0&&u.push(`iat`),c!==void 0&&u.push(`aud`),s!==void 0&&u.push(`sub`),o!==void 0&&u.push(`iss`);for(let e of new Set(u.reverse()))if(!(e in n))throw new vi(`missing required "${e}" claim`,n,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(n.iss))throw new vi(`unexpected "iss" claim value`,n,`iss`,`check_failed`);if(s&&n.sub!==s)throw new vi(`unexpected "sub" claim value`,n,`sub`,`check_failed`);if(c&&(d=n.aud,f=typeof c==`string`?[c]:c,!(typeof d==`string`?f.includes(d):Array.isArray(d)&&f.some(Set.prototype.has.bind(new Set(d))))))throw new vi(`unexpected "aud" claim value`,n,`aud`,`check_failed`);var d,f;let p;switch(typeof r.clockTolerance){case`string`:p=Ra(r.clockTolerance);break;case`number`:p=r.clockTolerance;break;case`undefined`:p=0;break;default:throw TypeError(`Invalid clockTolerance option type`)}let{currentDate:m}=r,h=(g=m||new Date,Math.floor(g.getTime()/1e3));var g;if((n.iat!==void 0||l)&&typeof n.iat!=`number`)throw new vi(`"iat" claim must be a number`,n,`iat`,`invalid`);if(n.nbf!==void 0){if(typeof n.nbf!=`number`)throw new vi(`"nbf" claim must be a number`,n,`nbf`,`invalid`);if(n.nbf>h+p)throw new vi(`"nbf" claim timestamp check failed`,n,`nbf`,`check_failed`)}if(n.exp!==void 0){if(typeof n.exp!=`number`)throw new vi(`"exp" claim must be a number`,n,`exp`,`invalid`);if(n.exp<=h-p)throw new yi(`"exp" claim timestamp check failed`,n,`exp`,`check_failed`)}if(l){let e=h-n.iat;if(e-p>(typeof l==`number`?l:Ra(l)))throw new yi(`"iat" claim timestamp check failed (too far in the past)`,n,`iat`,`check_failed`);if(e<0-p)throw new vi(`"iat" claim timestamp check failed (it should be in the past)`,n,`iat`,`check_failed`)}return n}async function Va(e,t,n){var r;let i=await async function(e,t,n){if(e instanceof Uint8Array&&(e=si.decode(e)),typeof e!=`string`)throw new Si(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new Si(`Invalid Compact JWS`);let s=await Fa({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return typeof t==`function`?D(D({},c),{},{key:s.key}):c}(e,t,n);if((r=i.protectedHeader.crit)!=null&&r.includes(`b64`)&&!1===i.protectedHeader.b64)throw new Ci(`JWTs MUST NOT use unencoded payload`);let a={payload:Ba(i.protectedHeader,i.payload,n),protectedHeader:i.protectedHeader};return typeof t==`function`?D(D({},a),{},{key:i.key}):a}function Ha(e){return Ni(e)}var Ua,Wa,Ga=new WeakMap,Ka=new WeakMap,qa=class{constructor(e){if(w(this,Ga,void 0),w(this,Ka,new WeakMap),!function(e){return e&&typeof e==`object`&&Array.isArray(e.keys)&&e.keys.every(Ha)}(e))throw new wi(`JSON Web Key Set malformed`);T(Ga,this,structuredClone(e))}jwks(){return C(Ga,this)}async getKey(e,t){let{alg:n,kid:r}=D(D({},e),t?.header),i=function(e){switch(typeof e==`string`&&e.slice(0,2)){case`RS`:case`PS`:return`RSA`;case`ES`:return`EC`;case`Ed`:return`OKP`;case`ML`:return`AKP`;default:throw new xi(`Unsupported "alg" value for a JSON Web Key Set`)}}(n),a=C(Ga,this).keys.filter(e=>{let t=i===e.kty;if(t&&typeof r==`string`&&(t=r===e.kid),!t||typeof e.alg!=`string`&&i!==`AKP`||(t=n===e.alg),t&&typeof e.use==`string`&&(t=e.use===`sig`),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes(`verify`)),t)switch(n){case`ES256`:t=e.crv===`P-256`;break;case`ES384`:t=e.crv===`P-384`;break;case`ES512`:t=e.crv===`P-521`;break;case`Ed25519`:case`EdDSA`:t=e.crv===`Ed25519`}return t}),{0:o,length:s}=a;if(s===0)throw new Ti;if(s!==1){let e=new Ei,t=C(Ka,this);throw e[Symbol.asyncIterator]=ae(function*(){for(let e of a)try{yield yield ne(Ja(t,e,n))}catch{}}),e}return Ja(C(Ka,this),o,n)}};async function Ja(e,t,n){let r=e.get(t)||e.set(t,{}).get(t);if(r[n]===void 0){let e=await async function(e,t,n){if(!Ni(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return ui(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new xi(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return Ri(D(D({},e),{},{alg:t,ext:r}));case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return Ri(D(D({},e),{},{ext:r}));case`EC`:case`OKP`:return Ri(D(D({},e),{},{alg:t,ext:r}));default:throw new xi(`Unsupported "kty" (Key Type) Parameter value`)}}(D(D({},t),{},{ext:!0}),n);if(e instanceof Uint8Array||e.type!==`public`)throw new wi(`JSON Web Key Set members must be public keys`);r[n]=e}return r[n]}function Ya(e){let t=new qa(e),n=async(e,n)=>t.getKey(e,n);return Object.defineProperties(n,{jwks:{value:()=>structuredClone(t.jwks()),enumerable:!1,configurable:!1,writable:!1}}),n}var Xa;(typeof navigator>`u`||(Ua=navigator.userAgent)==null||(Wa=Ua.startsWith)==null||!Wa.call(Ua,`Mozilla/5.0 `))&&(Xa=`jose/v6.2.2`);var Za=Symbol(),Qa=Symbol(),$a=new WeakMap,eo=new WeakMap,to=new WeakMap,no=new WeakMap,ro=new WeakMap,io=new WeakMap,ao=new WeakMap,oo=new WeakMap,so=new WeakMap,co=new WeakMap,lo=class{constructor(e,t){if(w(this,$a,void 0),w(this,eo,void 0),w(this,to,void 0),w(this,no,void 0),w(this,ro,void 0),w(this,io,void 0),w(this,ao,void 0),w(this,oo,void 0),w(this,so,void 0),w(this,co,void 0),!(e instanceof URL))throw TypeError(`url must be an instance of URL`);var n,r;T($a,this,new URL(e.href)),T(eo,this,typeof t?.timeoutDuration==`number`?t?.timeoutDuration:5e3),T(to,this,typeof t?.cooldownDuration==`number`?t?.cooldownDuration:3e4),T(no,this,typeof t?.cacheMaxAge==`number`?t?.cacheMaxAge:6e5),T(ao,this,new Headers(t?.headers)),Xa&&!C(ao,this).has(`User-Agent`)&&C(ao,this).set(`User-Agent`,Xa),C(ao,this).has(`accept`)||(C(ao,this).set(`accept`,`application/json`),C(ao,this).append(`accept`,`application/jwk-set+json`)),T(oo,this,t?.[Za]),t?.[Qa]!==void 0&&(T(co,this,t?.[Qa]),n=t?.[Qa],r=C(no,this),typeof n==`object`&&n&&`uat`in n&&typeof n.uat==`number`&&!(Date.now()-n.uat>=r)&&`jwks`in n&&Ni(n.jwks)&&Array.isArray(n.jwks.keys)&&Array.prototype.every.call(n.jwks.keys,Ni)&&(T(ro,this,C(co,this).uat),T(so,this,Ya(C(co,this).jwks))))}pendingFetch(){return!!C(io,this)}coolingDown(){return typeof C(ro,this)==`number`&&Date.now()<C(ro,this)+C(to,this)}fresh(){return typeof C(ro,this)==`number`&&Date.now()<C(ro,this)+C(no,this)}jwks(){return C(so,this)?.jwks()}async getKey(e,t){C(so,this)&&this.fresh()||await this.reload();try{return await C(so,this).call(this,e,t)}catch(n){if(n instanceof Ti&&!1===this.coolingDown())return await this.reload(),C(so,this).call(this,e,t);throw n}}async reload(){C(io,this)&&(typeof WebSocketPair<`u`||typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`||typeof EdgeRuntime<`u`&&EdgeRuntime===`vercel`)&&T(io,this,void 0),C(io,this)||T(io,this,async function(e,t,n){let r=await(arguments.length>3&&arguments[3]!==void 0?arguments[3]:fetch)(e,{method:`GET`,signal:n,redirect:`manual`,headers:t}).catch(e=>{throw e.name===`TimeoutError`?new Di:e});if(r.status!==200)throw new _i(`Expected 200 OK from the JSON Web Key Set HTTP response`);try{return await r.json()}catch{throw new _i(`Failed to parse the JSON Web Key Set HTTP response as JSON`)}}(C($a,this).href,C(ao,this),AbortSignal.timeout(C(eo,this)),C(oo,this)).then(e=>{T(so,this,Ya(e)),C(co,this)&&(C(co,this).uat=Date.now(),C(co,this).jwks=e),T(ro,this,Date.now()),T(io,this,void 0)}).catch(e=>{throw T(io,this,void 0),e})),await C(io,this)}},uo=[`mfaToken`],fo=[`mfaToken`],po,mo,ho,go,_o,vo,yo,bo,xo,F,So,Co,wo,To,Eo,I,Do=class extends Error{constructor(e,t){super(t),E(this,`code`,void 0),this.name=`NotSupportedError`,this.code=e}},Oo=class extends Error{constructor(e,t,n){super(t),E(this,`cause`,void 0),E(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},ko=class extends Oo{constructor(e,t){super(`token_by_code_error`,e,t),this.name=`TokenByCodeError`}},Ao=class extends Oo{constructor(e,t){super(`token_by_client_credentials_error`,e,t),this.name=`TokenByClientCredentialsError`}},jo=class extends Oo{constructor(e,t){super(`token_by_refresh_token_error`,e,t),this.name=`TokenByRefreshTokenError`}},Mo=class extends Oo{constructor(e,t){super(`token_by_password_error`,e,t),this.name=`TokenByPasswordError`}},No=class extends Oo{constructor(e,t){super(`token_for_connection_error`,e,t),this.name=`TokenForConnectionErrorCode`}},Po=class extends Oo{constructor(e,t){super(`token_exchange_error`,e,t),this.name=`TokenExchangeError`}},Fo=class extends Error{constructor(e){super(e),E(this,`code`,`verify_logout_token_error`),this.name=`VerifyLogoutTokenError`}},Io=class extends Oo{constructor(e){super(`backchannel_authentication_error`,`There was an error when trying to use Client-Initiated Backchannel Authentication.`,e),E(this,`code`,`backchannel_authentication_error`),this.name=`BackchannelAuthenticationError`}},Lo=class extends Oo{constructor(e){super(`build_authorization_url_error`,`There was an error when trying to build the authorization URL.`,e),this.name=`BuildAuthorizationUrlError`}},Ro=class extends Oo{constructor(e){super(`build_link_user_url_error`,`There was an error when trying to build the Link User URL.`,e),this.name=`BuildLinkUserUrlError`}},zo=class extends Oo{constructor(e){super(`build_unlink_user_url_error`,`There was an error when trying to build the Unlink User URL.`,e),this.name=`BuildUnlinkUserUrlError`}},Bo=class extends Error{constructor(){super(`The client secret or client assertion signing key must be provided.`),E(this,`code`,`missing_client_auth_error`),this.name=`MissingClientAuthError`}};function Vo(e){return Object.entries(e).filter(e=>{let[,t]=e;return t!==void 0}).reduce((e,t)=>D(D({},e),{},{[t[0]]:t[1]}),{})}var Ho=class extends Error{constructor(e,t,n){super(t),E(this,`cause`,void 0),E(this,`code`,void 0),this.code=e,this.cause=n&&{error:n.error,error_description:n.error_description,message:n.message}}},Uo=class extends Ho{constructor(e,t){super(`mfa_list_authenticators_error`,e,t),this.name=`MfaListAuthenticatorsError`}},Wo=class extends Ho{constructor(e,t){super(`mfa_enrollment_error`,e,t),this.name=`MfaEnrollmentError`}},Go=class extends Ho{constructor(e,t){super(`mfa_delete_authenticator_error`,e,t),this.name=`MfaDeleteAuthenticatorError`}},Ko=class extends Ho{constructor(e,t){super(`mfa_challenge_error`,e,t),this.name=`MfaChallengeError`}};function qo(e){return{id:e.id,authenticatorType:e.authenticator_type,active:e.active,name:e.name,oobChannels:e.oob_channels,type:e.type}}var Jo=(po=new WeakMap,mo=new WeakMap,ho=new WeakMap,class{constructor(e){w(this,po,void 0),w(this,mo,void 0),w(this,ho,void 0),T(po,this,`https://${e.domain}`),T(mo,this,e.clientId),T(ho,this,e.customFetch??function(){return fetch(...arguments)})}async listAuthenticators(e){let t=`${C(po,this)}/mfa/authenticators`,{mfaToken:n}=e,r=await C(ho,this).call(this,t,{method:`GET`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!r.ok){let e=await r.json();throw new Uo(e.error_description||`Failed to list authenticators`,e)}return(await r.json()).map(qo)}async enrollAuthenticator(e){let t=`${C(po,this)}/mfa/associate`,{mfaToken:n}=e,r=O(e,uo),i={authenticator_types:r.authenticatorTypes};`oobChannels`in r&&(i.oob_channels=r.oobChannels),`phoneNumber`in r&&r.phoneNumber&&(i.phone_number=r.phoneNumber),`email`in r&&r.email&&(i.email=r.email);let a=await C(ho,this).call(this,t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new Wo(e.error_description||`Failed to enroll authenticator`,e)}return function(e){if(e.authenticator_type===`otp`)return{authenticatorType:`otp`,secret:e.secret,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes,id:e.id};if(e.authenticator_type===`oob`)return{authenticatorType:`oob`,oobChannel:e.oob_channel,oobCode:e.oob_code,bindingMethod:e.binding_method,id:e.id,barcodeUri:e.barcode_uri,recoveryCodes:e.recovery_codes};throw Error(`Unexpected authenticator type: ${e.authenticator_type}`)}(await a.json())}async deleteAuthenticator(e){let{authenticatorId:t,mfaToken:n}=e,r=`${C(po,this)}/mfa/authenticators/${encodeURIComponent(t)}`,i=await C(ho,this).call(this,r,{method:`DELETE`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`}});if(!i.ok){let e=await i.json();throw new Go(e.error_description||`Failed to delete authenticator`,e)}}async challengeAuthenticator(e){let t=`${C(po,this)}/mfa/challenge`,{mfaToken:n}=e,r=O(e,fo),i={mfa_token:n,client_id:C(mo,this),challenge_type:r.challengeType};r.authenticatorId&&(i.authenticator_id=r.authenticatorId);let a=await C(ho,this).call(this,t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)});if(!a.ok){let e=await a.json();throw new Ko(e.error_description||`Failed to challenge authenticator`,e)}return function(e){let t={challengeType:e.challenge_type};return e.oob_code!==void 0&&(t.oobCode=e.oob_code),e.binding_method!==void 0&&(t.bindingMethod=e.binding_method),t}(await a.json())}}),Yo=class e{constructor(e,t,n,r,i,a,o){E(this,`accessToken`,void 0),E(this,`idToken`,void 0),E(this,`refreshToken`,void 0),E(this,`expiresAt`,void 0),E(this,`scope`,void 0),E(this,`claims`,void 0),E(this,`authorizationDetails`,void 0),E(this,`tokenType`,void 0),E(this,`issuedTokenType`,void 0),this.accessToken=e,this.idToken=n,this.refreshToken=r,this.expiresAt=t,this.scope=i,this.claims=a,this.authorizationDetails=o}static fromTokenEndpointResponse(t){let n=t.id_token?t.claims():void 0,r=new e(t.access_token,Math.floor(Date.now()/1e3)+Number(t.expires_in),t.id_token,t.refresh_token,t.scope,n,t.authorization_details);return r.tokenType=t.token_type,r.issuedTokenType=t.issued_token_type,r}},Xo=(go=new WeakMap,_o=new WeakMap,vo=new WeakMap,class{constructor(e,t){w(this,go,new Map),w(this,_o,void 0),w(this,vo,void 0),T(vo,this,Math.max(1,Math.floor(e))),T(_o,this,Math.max(0,Math.floor(t)))}get(e){let t=C(go,this).get(e);if(t){if(!(Date.now()>=t.expiresAt))return C(go,this).delete(e),C(go,this).set(e,t),t.value;C(go,this).delete(e)}}set(e,t){for(C(go,this).has(e)&&C(go,this).delete(e),C(go,this).set(e,{value:t,expiresAt:Date.now()+C(_o,this)});C(go,this).size>C(vo,this);){let e=C(go,this).keys().next().value;if(e===void 0)break;C(go,this).delete(e)}}}),Zo=new Map;function Qo(e){return{ttlMs:1e3*(typeof e?.ttl==`number`?e.ttl:600),maxEntries:typeof e?.maxEntries==`number`&&e.maxEntries>0?e.maxEntries:100}}var $o=class{static createDiscoveryCache(e){let t=(n=e.maxEntries,r=e.ttlMs,`${n}:${r}`);var n,r;let i=(a=t,Zo.get(a));var a;return i||(i=new Xo(e.maxEntries,e.ttlMs),Zo.set(t,i)),i}static createJwksCache(){return{}}},es=`openid profile email offline_access`,ts=Object.freeze(new Set([`grant_type`,`client_id`,`client_secret`,`client_assertion`,`client_assertion_type`,`subject_token`,`subject_token_type`,`requested_token_type`,`actor_token`,`actor_token_type`,`audience`,`aud`,`resource`,`resources`,`resource_indicator`,`scope`,`connection`,`login_hint`,`organization`,`assertion`]));function ns(e){if(e==null)throw new Po(`subject_token is required`);if(typeof e!=`string`)throw new Po(`subject_token must be a string`);if(e.trim().length===0)throw new Po(`subject_token cannot be blank or whitespace`);if(e!==e.trim())throw new Po(`subject_token must not include leading or trailing whitespace`);if(/^bearer\s+/i.test(e))throw new Po(`subject_token must not include the 'Bearer ' prefix`)}function rs(e,t){if(t){for(let[n,r]of Object.entries(t))if(!ts.has(n))if(Array.isArray(r)){if(r.length>20)throw new Po(`Parameter '${n}' exceeds maximum array size of 20`);r.forEach(t=>{e.append(n,t)})}else e.append(n,r)}}var is=`urn:ietf:params:oauth:token-type:access_token`,as=(yo=new WeakMap,bo=new WeakMap,xo=new WeakMap,F=new WeakMap,So=new WeakMap,Co=new WeakMap,wo=new WeakMap,To=new WeakMap,Eo=new WeakMap,I=new WeakSet,class{constructor(e){var t;if(function(e,t){re(e,t),t.add(e)}(this,I),w(this,yo,void 0),w(this,bo,void 0),w(this,xo,void 0),w(this,F,void 0),w(this,So,void 0),w(this,Co,void 0),w(this,wo,void 0),w(this,To,void 0),w(this,Eo,void 0),E(this,`mfa`,void 0),T(F,this,e),e.useMtls&&!e.customFetch)throw new Do(`mtls_without_custom_fetch_not_supported`,`Using mTLS without a custom fetch implementation is not supported`);T(So,this,function(e,t){if(!1===t.enabled)return e;let n={name:t.name,version:t.version},r=btoa(JSON.stringify(n));return async(t,n)=>{let i=t instanceof Request?new Headers(t.headers):new Headers;return n!=null&&n.headers&&new Headers(n.headers).forEach((e,t)=>{i.set(t,e)}),i.set(`Auth0-Client`,r),e(t,D(D({},n),{},{headers:i}))}}(e.customFetch??function(){return fetch(...arguments)},!1===(t=e.telemetry)?.enabled?t:{enabled:!0,name:t?.name??`@auth0/auth0-auth-js`,version:t?.version??`1.6.0`}));let n=Qo(e.discoveryCache);T(wo,this,$o.createDiscoveryCache(n)),T(To,this,new Map),T(Eo,this,$o.createJwksCache()),this.mfa=new Jo({domain:C(F,this).domain,clientId:C(F,this).clientId,customFetch:C(So,this)})}async getServerMetadata(){let{serverMetadata:e}=await S(I,this,cs).call(this);return e}async buildAuthorizationUrl(e){let{serverMetadata:t}=await S(I,this,cs).call(this);if(e!=null&&e.pushedAuthorizationRequests&&!t.pushed_authorization_request_endpoint)throw new Do(`par_not_supported_error`,`The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par`);try{return await S(I,this,fs).call(this,e)}catch(e){throw new Lo(e)}}async buildLinkUserUrl(e){try{let t=await S(I,this,fs).call(this,{authorizationParams:D(D({},e.authorizationParams),{},{requested_connection:e.connection,requested_connection_scope:e.connectionScope,scope:`openid link_account offline_access`,id_token_hint:e.idToken})});return{linkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new Ro(e)}}async buildUnlinkUserUrl(e){try{let t=await S(I,this,fs).call(this,{authorizationParams:D(D({},e.authorizationParams),{},{requested_connection:e.connection,scope:`openid unlink_account`,id_token_hint:e.idToken})});return{unlinkUserUrl:t.authorizationUrl,codeVerifier:t.codeVerifier}}catch(e){throw new zo(e)}}async backchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await S(I,this,cs).call(this),r=Vo(D(D({},C(F,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(D(D({scope:es},r),{},{client_id:C(F,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await Ca(t,await Sa(t,i));return Yo.fromTokenEndpointResponse(e)}catch(e){throw new Io(e)}}async initiateBackchannelAuthentication(e){let{configuration:t,serverMetadata:n}=await S(I,this,cs).call(this),r=Vo(D(D({},C(F,this).authorizationParams),e?.authorizationParams)),i=new URLSearchParams(D(D({scope:es},r),{},{client_id:C(F,this).clientId,binding_message:e.bindingMessage,login_hint:JSON.stringify({format:`iss_sub`,iss:n.issuer,sub:e.loginHint.sub})}));e.requestedExpiry&&i.append(`requested_expiry`,e.requestedExpiry.toString()),e.authorizationDetails&&i.append(`authorization_details`,JSON.stringify(e.authorizationDetails));try{let e=await Sa(t,i);return{authReqId:e.auth_req_id,expiresIn:e.expires_in,interval:e.interval}}catch(e){throw new Io(e)}}async backchannelAuthenticationGrant(e){let{authReqId:t}=e,{configuration:n}=await S(I,this,cs).call(this),r=new URLSearchParams({auth_req_id:t});try{let e=await Pa(n,`urn:openid:params:grant-type:ciba`,r);return Yo.fromTokenEndpointResponse(e)}catch(e){throw new Io(e)}}async getTokenForConnection(e){if(e.refreshToken&&e.accessToken)throw new No(`Either a refresh or access token should be specified, but not both.`);let t=e.accessToken??e.refreshToken;if(!t)throw new No(`Either a refresh or access token must be specified.`);try{return await this.exchangeToken({connection:e.connection,subjectToken:t,subjectTokenType:e.accessToken?is:`urn:ietf:params:oauth:token-type:refresh_token`,loginHint:e.loginHint})}catch(e){throw e instanceof Po?new No(e.message,e.cause):e}}async exchangeToken(e){return`connection`in e?S(I,this,ls).call(this,e):S(I,this,us).call(this,e)}async getTokenByCode(e,t){let{configuration:n}=await S(I,this,cs).call(this);try{let r=await Ta(n,e,{pkceCodeVerifier:t.codeVerifier});return Yo.fromTokenEndpointResponse(r)}catch(e){throw new ko(`There was an error while trying to request a token.`,e)}}async getTokenByRefreshToken(e){let{configuration:t}=await S(I,this,cs).call(this),n=new URLSearchParams;e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope);try{let r=await Ea(t,e.refreshToken,n);return Yo.fromTokenEndpointResponse(r)}catch(e){throw new jo(`The access token has expired and there was an error while trying to refresh it.`,e)}}async getTokenByPassword(e){let{configuration:t}=await S(I,this,cs).call(this),n=new URLSearchParams({username:e.username,password:e.password});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.realm&&n.append(`realm`,e.realm);let r=t;if(e.auth0ForwardedFor){let n=await S(I,this,ds).call(this);r=new va(t.serverMetadata(),C(F,this).clientId,C(F,this).clientSecret,n),r[sa]=(t,n)=>C(So,this).call(this,t,D(D({},n),{},{headers:D(D({},n.headers),{},{"auth0-forwarded-for":e.auth0ForwardedFor})}))}try{let e=await Pa(r,`password`,n);return Yo.fromTokenEndpointResponse(e)}catch(e){throw new Mo(`There was an error while trying to request a token.`,e)}}async getTokenByClientCredentials(e){let{configuration:t}=await S(I,this,cs).call(this);try{let n=new URLSearchParams({audience:e.audience});e.organization&&n.append(`organization`,e.organization);let r=await Da(t,n);return Yo.fromTokenEndpointResponse(r)}catch(e){throw new Ao(`There was an error while trying to request a token.`,e)}}async buildLogoutUrl(e){let{configuration:t,serverMetadata:n}=await S(I,this,cs).call(this);if(!n.end_session_endpoint){let t=new URL(`https://${C(F,this).domain}/v2/logout`);return t.searchParams.set(`returnTo`,e.returnTo),t.searchParams.set(`client_id`,C(F,this).clientId),t}return function(e,t){Aa(e);let{as:n,c:r,tlsOnly:i}=ra(e),a=ar(n,`end_session_endpoint`,!1,i);(t=new URLSearchParams(t)).has(`client_id`)||t.set(`client_id`,r.client_id);for(let[e,n]of t.entries())a.searchParams.append(e,n);return a}(t,{post_logout_redirect_uri:e.returnTo})}async verifyLogoutToken(e){let{serverMetadata:t}=await S(I,this,cs).call(this),n=Qo(C(F,this).discoveryCache),r=t.jwks_uri;C(Co,this)||T(Co,this,function(e,t){let n=new lo(e,t),r=async(e,t)=>n.getKey(e,t);return Object.defineProperties(r,{coolingDown:{get:()=>n.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>n.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>n.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>n.pendingFetch(),enumerable:!0,configurable:!1},jwks:{value:()=>n.jwks(),enumerable:!0,configurable:!1,writable:!1}}),r}(new URL(r),{cacheMaxAge:n.ttlMs,[Za]:C(So,this),[Qa]:C(Eo,this)}));let{payload:i}=await Va(e.logoutToken,C(Co,this),{issuer:t.issuer,audience:C(F,this).clientId,algorithms:[`RS256`],requiredClaims:[`iat`]});if(!(`sid`in i)&&!(`sub`in i))throw new Fo(`either "sid" or "sub" (or both) claims must be present`);if(`sid`in i&&typeof i.sid!=`string`)throw new Fo(`"sid" claim must be a string`);if(`sub`in i&&typeof i.sub!=`string`)throw new Fo(`"sub" claim must be a string`);if(`nonce`in i)throw new Fo(`"nonce" claim is prohibited`);if(!(`events`in i))throw new Fo(`"events" claim is missing`);if(typeof i.events!=`object`||i.events===null)throw new Fo(`"events" claim must be an object`);if(!(`http://schemas.openid.net/event/backchannel-logout`in i.events))throw new Fo(`"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim`);if(typeof i.events[`http://schemas.openid.net/event/backchannel-logout`]!=`object`)throw new Fo(`"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object`);return{sid:i.sid,sub:i.sub}}});function os(){return`${C(F,this).domain.toLowerCase()}|mtls:${C(F,this).useMtls?`1`:`0`}`}async function ss(e){let t=await S(I,this,ds).call(this),n=new va(e,C(F,this).clientId,C(F,this).clientSecret,t);return n[sa]=C(So,this),n}async function cs(){if(C(yo,this)&&C(bo,this))return{configuration:C(yo,this),serverMetadata:C(bo,this)};let e=S(I,this,os).call(this),t=C(wo,this).get(e);if(t)return T(bo,this,t.serverMetadata),T(yo,this,await S(I,this,ss).call(this,t.serverMetadata)),{configuration:C(yo,this),serverMetadata:C(bo,this)};let n=C(To,this).get(e);if(n){let e=await n;return T(bo,this,e.serverMetadata),T(yo,this,await S(I,this,ss).call(this,e.serverMetadata)),{configuration:C(yo,this),serverMetadata:C(bo,this)}}let r=(async()=>{let t=await S(I,this,ds).call(this),n=await ga(new URL(`https://${C(F,this).domain}`),C(F,this).clientId,{use_mtls_endpoint_aliases:C(F,this).useMtls},t,{[sa]:C(So,this)}),r=n.serverMetadata();return C(wo,this).set(e,{serverMetadata:r}),{configuration:n,serverMetadata:r}})(),i=r.then(e=>{let{serverMetadata:t}=e;return{serverMetadata:t}});i.catch(()=>{}),C(To,this).set(e,i);try{let{configuration:e,serverMetadata:t}=await r;T(yo,this,e),T(bo,this,t),C(yo,this)[sa]=C(So,this)}finally{C(To,this).delete(e)}return{configuration:C(yo,this),serverMetadata:C(bo,this)}}async function ls(e){let{configuration:t}=await S(I,this,cs).call(this);if(`audience`in e||`resource`in e)throw new Po(`audience and resource parameters are not supported for Token Vault exchanges`);ns(e.subjectToken);let n=new URLSearchParams({connection:e.connection,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType??is,requested_token_type:e.requestedTokenType??`http://auth0.com/oauth/token-type/federated-connection-access-token`});e.loginHint&&n.append(`login_hint`,e.loginHint),e.scope&&n.append(`scope`,e.scope),rs(n,e.extra);try{let e=await Pa(t,`urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token`,n);return Yo.fromTokenEndpointResponse(e)}catch(t){throw new Po(`Failed to exchange token for connection '${e.connection}'.`,t)}}async function us(e){let{configuration:t}=await S(I,this,cs).call(this);ns(e.subjectToken);let n=new URLSearchParams({subject_token_type:e.subjectTokenType,subject_token:e.subjectToken});e.audience&&n.append(`audience`,e.audience),e.scope&&n.append(`scope`,e.scope),e.requestedTokenType&&n.append(`requested_token_type`,e.requestedTokenType),e.organization&&n.append(`organization`,e.organization),rs(n,e.extra);try{let e=await Pa(t,`urn:ietf:params:oauth:grant-type:token-exchange`,n);return Yo.fromTokenEndpointResponse(e)}catch(t){throw new Po(`Failed to exchange token of type '${e.subjectTokenType}'${e.audience?` for audience '${e.audience}'`:``}.`,t)}}async function ds(){return C(xo,this)||T(xo,this,(async()=>{if(!C(F,this).clientSecret&&!C(F,this).clientAssertionSigningKey&&!C(F,this).useMtls)throw new Bo;if(C(F,this).useMtls)return(e,t,n,r)=>{n.set(`client_id`,t.client_id)};let e=C(F,this).clientAssertionSigningKey;return!e||e instanceof CryptoKey||(e=await async function(e,t,n){if(typeof e!=`string`||e.indexOf(`-----BEGIN PRIVATE KEY-----`)!==0)throw TypeError(`"pkcs8" must be PKCS#8 formatted string`);return Yi(e,t,n)}(e,C(F,this).clientAssertionSigningAlg||`RS256`)),e?function(e,t){return tr(e,t)}(e):oa(C(F,this).clientSecret)})().catch(e=>{throw T(xo,this,void 0),e})),C(xo,this)}async function fs(e){let{configuration:t}=await S(I,this,cs).call(this),n=fa(),r=await da(n),i=Vo(D(D({},C(F,this).authorizationParams),e?.authorizationParams)),a=new URLSearchParams(D(D({scope:es},i),{},{client_id:C(F,this).clientId,code_challenge:r,code_challenge_method:`S256`}));return{authorizationUrl:e!=null&&e.pushedAuthorizationRequests?await ka(t,a):await Oa(t,a),codeVerifier:n}}var ps=class e extends A{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}static fromPayload(t){let{error:n,error_description:r}=t;return new e(n,r)}},ms=class e extends ps{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},hs=class e extends ps{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},gs=class e extends ps{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},_s=class e extends ps{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},vs=class e extends ps{constructor(t,n){super(t,n),Object.setPrototypeOf(this,e.prototype)}},ys=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:6e5;E(this,`contexts`,new Map),E(this,`ttlMs`,void 0),this.ttlMs=e}set(e,t){this.cleanup(),this.contexts.set(e,D(D({},t),{},{createdAt:Date.now()}))}get(e){let t=this.contexts.get(e);if(t){if(!(Date.now()-t.createdAt>this.ttlMs))return t;this.contexts.delete(e)}}remove(e){this.contexts.delete(e)}cleanup(){let e=Date.now();for(let[t,n]of this.contexts)e-n.createdAt>this.ttlMs&&this.contexts.delete(t)}get size(){return this.contexts.size}},bs=class{constructor(e,t){E(this,`authJsMfaClient`,void 0),E(this,`auth0Client`,void 0),E(this,`contextManager`,void 0),this.authJsMfaClient=e,this.auth0Client=t,this.contextManager=new ys}setMFAAuthDetails(e,t,n,r){this.contextManager.set(e,{scope:t,audience:n,mfaRequirements:r})}async getAuthenticators(e){var t;let n=this.contextManager.get(e);if(n==null||(t=n.mfaRequirements)==null||!t.challenge||n.mfaRequirements.challenge.length===0)throw new ms(`invalid_request`,`challengeType is required and must contain at least one challenge type, please check mfa_required error payload`);let r=n.mfaRequirements.challenge.map(e=>e.type);try{return(await this.authJsMfaClient.listAuthenticators({mfaToken:e})).filter(e=>!!e.type&&r.includes(e.type))}catch(e){throw e instanceof Uo?new ms(e.cause?.error,e.message):e}}async enroll(e){let t=function(e){let t=hn[e.factorType];return D(D(D({mfaToken:e.mfaToken,authenticatorTypes:t.authenticatorTypes},t.oobChannels&&{oobChannels:t.oobChannels}),`phoneNumber`in e&&{phoneNumber:e.phoneNumber}),`email`in e&&{email:e.email})}(e);try{return await this.authJsMfaClient.enrollAuthenticator(t)}catch(e){throw e instanceof Wo?new hs(e.cause?.error,e.message):e}}async challenge(e){try{let t={challengeType:e.challengeType,mfaToken:e.mfaToken};return e.authenticatorId&&(t.authenticatorId=e.authenticatorId),await this.authJsMfaClient.challengeAuthenticator(t)}catch(e){throw e instanceof Ko?new gs(e.cause?.error,e.message):e}}async getEnrollmentFactors(e){let t=this.contextManager.get(e);if(!t||!t.mfaRequirements)throw new vs(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);return t.mfaRequirements.enroll&&t.mfaRequirements.enroll.length!==0?t.mfaRequirements.enroll:[]}async verify(e){let t=this.contextManager.get(e.mfaToken);if(!t)throw new _s(`mfa_context_not_found`,`MFA context not found for this MFA token. Please retry the original request to get a new MFA token.`);let n=function(e){return`otp`in e&&e.otp?gn:`oobCode`in e&&e.oobCode?_n:`recoveryCode`in e&&e.recoveryCode?vn:void 0}(e);if(!n)throw new _s(`invalid_request`,`Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.`);let r=t.scope,i=t.audience;try{let t=await this.auth0Client._requestTokenForMfa({grant_type:n,mfaToken:e.mfaToken,scope:r,audience:i,otp:e.otp,oob_code:e.oobCode,binding_code:e.bindingCode,recovery_code:e.recoveryCode});return this.contextManager.remove(e.mfaToken),t}catch(e){if(e instanceof _e)this.setMFAAuthDetails(e.mfa_token,r,i,e.mfa_requirements);else if(e instanceof _s)throw new _s(e.error,e.error_description);throw e}}},xs=[`openUrl`,`fragment`,`appState`],Ss=[`url`],Cs=[`cacheMode`],ws=[`federated`],Ts=[`openUrl`],Es=[`id_token`,`decodedToken`],Ds=[`mfaToken`],Os=class{constructor(e){let t,n;if(E(this,`transactionManager`,void 0),E(this,`cacheManager`,void 0),E(this,`lockManager`,void 0),E(this,`domainUrl`,void 0),E(this,`tokenIssuer`,void 0),E(this,`scope`,void 0),E(this,`cookieStorage`,void 0),E(this,`dpop`,void 0),E(this,`sessionCheckExpiryDays`,void 0),E(this,`orgHintCookieName`,void 0),E(this,`isAuthenticatedCookieName`,void 0),E(this,`nowProvider`,void 0),E(this,`httpTimeoutMs`,void 0),E(this,`options`,void 0),E(this,`userCache`,new Ot().enclosedCache),E(this,`myAccountApi`,void 0),E(this,`mfa`,void 0),E(this,`worker`,void 0),E(this,`authJsClient`,void 0),E(this,`defaultOptions`,{authorizationParams:{scope:`openid profile email`},useRefreshTokensFallback:!1,useFormData:!0}),this.options=D(D(D({},this.defaultOptions),e),{},{authorizationParams:D(D({},this.defaultOptions.authorizationParams),e.authorizationParams)}),typeof window<`u`&&(()=>{if(!Ce())throw Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");if(Ce().subtle===void 0)throw Error(`
|
|
3
|
-
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
4
|
-
`)})(),this.lockManager=(Je||=qe(),Je),e.cache&&e.cacheLocation&&console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."),e.cache)n=e.cache;else{if(t=e.cacheLocation||ce,!an(t))throw Error(`Invalid cache location "${t}"`);n=an(t)()}var r;this.httpTimeoutMs=e.httpTimeoutInSeconds?1e3*e.httpTimeoutInSeconds:1e4,this.cookieStorage=!1===e.legacySameSiteCookie?Ht:Wt,this.orgHintCookieName=(r=this.options.clientId,`auth0.${r}.organization_hint`),this.isAuthenticatedCookieName=(e=>`auth0.${e}.is.authenticated`)(this.options.clientId),this.sessionCheckExpiryDays=e.sessionCheckExpiryDays||1;let i=e.useCookiesForTransactions?this.cookieStorage:Gt;var a;this.scope=function(e,t){var n=[...arguments].slice(2);if(typeof e!=`object`)return{[k]:St(t,e,...n)};let r={[k]:St(t,...n)};return Object.keys(e).forEach(i=>{let a=e[i];r[i]=St(t,a,...n)}),r}(this.options.authorizationParams.scope,`openid`,this.options.useRefreshTokens?`offline_access`:``),this.transactionManager=new At(i,this.options.clientId,this.options.cookieDomain),this.nowProvider=this.options.nowProvider||ue,this.cacheManager=new kt(n,n.allKeys?void 0:new en(n,this.options.clientId),this.nowProvider),this.dpop=this.options.useDpop?new un(this.options.clientId):void 0,this.domainUrl=(a=this.options.domain,/^https?:\/\//.test(a)?a:`https://${a}`),this.tokenIssuer=((e,t)=>e?e.startsWith(`https://`)?e:`https://${e}/`:`${t}/`)(this.options.issuer,this.domainUrl);let o=`${this.domainUrl}/me/`;this.myAccountApi=new pn(this.createFetcher(D(D({},this.options.useDpop&&{dpopNonceId:`__auth0_my_account_api__`}),{},{getAccessToken:()=>this.getTokenSilently({authorizationParams:{scope:`create:me:connected_accounts`,audience:o},detailedResponse:!0})})),o),this.authJsClient=new as({domain:this.options.domain,clientId:this.options.clientId}),this.mfa=new bs(this.authJsClient.mfa,this),typeof window<`u`&&window.Worker&&this.options.useRefreshTokens&&t===ce&&(this.options.workerUrl?this.worker=new Worker(this.options.workerUrl):this.worker=new Qt,this.worker.postMessage({type:`init`,allowedBaseUrl:this.domainUrl}))}getConfiguration(){return Object.freeze({domain:this.options.domain,clientId:this.options.clientId})}_url(e){let t=De(this.options.auth0Client||le,!0),n=encodeURIComponent(btoa(JSON.stringify(t)));return`${this.domainUrl}${e}&auth0Client=${n}`}_authorizeUrl(e){return this._url(`/authorize?${Oe(e)}`)}async _verifyIdToken(e,t,n){let r=await this.nowProvider();return Nt({iss:this.tokenIssuer,aud:this.options.clientId,id_token:e,nonce:t,organization:n,leeway:this.options.leeway,max_age:(i=this.options.authorizationParams.max_age,typeof i==`string`?parseInt(i,10)||void 0:i),now:r});var i}_processOrgHint(e){e?this.cookieStorage.save(this.orgHintCookieName,e,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}):this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain})}_extractSessionTransferToken(e){return new URLSearchParams(window.location.search).get(e)||void 0}_clearSessionTransferTokenFromUrl(e){try{let t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState({},``,t.toString()))}catch{}}_applySessionTransferToken(e){let t=this.options.sessionTransferTokenQueryParamName;if(!t||e.session_transfer_token)return e;let n=this._extractSessionTransferToken(t);return n?(this._clearSessionTransferTokenFromUrl(t),D(D({},e),{},{session_transfer_token:n})):e}async _prepareAuthorizeUrl(e,t,n){let r=Te(we()),i=Te(we()),a=we(),o=je(await ke(a)),s=await this.dpop?.calculateThumbprint(),c=((e,t,n,r,i,a,o,s,c)=>D(D(D({client_id:e.clientId},e.authorizationParams),n),{},{scope:Ct(t,n.scope,n.audience),response_type:`code`,response_mode:s||`query`,state:r,nonce:i,redirect_uri:o||e.authorizationParams.redirect_uri,code_challenge:a,code_challenge_method:`S256`,dpop_jkt:c}))(this.options,this.scope,e,r,i,o,e.redirect_uri||this.options.authorizationParams.redirect_uri||n,t?.response_mode,s),l=this._authorizeUrl(c);return{nonce:i,code_verifier:a,scope:c.scope,audience:c.audience||k,redirect_uri:c.redirect_uri,state:r,url:l}}async loginWithPopup(e,t){if(e||={},!(t||={}).popup&&(t.popup=(e=>{let t=window.screenX+(window.innerWidth-400)/2,n=window.screenY+(window.innerHeight-600)/2;return window.open(e,`auth0:authorize:popup`,`left=${t},top=${n},width=400,height=600,resizable,scrollbars=yes,status=1`)})(``),!t.popup))throw new ge;let n=this._applySessionTransferToken(e.authorizationParams||{}),r=await this._prepareAuthorizeUrl(n,{response_mode:`web_message`},window.location.origin);t.popup.location.href=r.url;let i=await((e,t)=>new Promise((n,r)=>{let i,a=setInterval(()=>{e.popup&&e.popup.closed&&(clearInterval(a),clearTimeout(o),window.removeEventListener(`message`,i,!1),r(new he(e.popup)))},1e3),o=setTimeout(()=>{clearInterval(a),r(new me(e.popup)),window.removeEventListener(`message`,i,!1)},1e3*(e.timeoutInSeconds||60));i=function(s){if(s.origin===t&&s.data&&s.data.type===`authorization_response`){if(clearTimeout(o),clearInterval(a),window.removeEventListener(`message`,i,!1),!1!==e.closePopup&&e.popup.close(),s.data.response.error)return r(A.fromPayload(s.data.response));n(s.data.response)}},window.addEventListener(`message`,i)}))(D(D({},t),{},{timeoutInSeconds:t.timeoutInSeconds||this.options.authorizeTimeoutInSeconds||60}),new URL(r.url).origin);if(r.state!==i.state)throw new A(`state_mismatch`,`Invalid state`);let a=e.authorizationParams?.organization||this.options.authorizationParams.organization;await this._requestToken({audience:r.audience,scope:r.scope,code_verifier:r.code_verifier,grant_type:`authorization_code`,code:i.code,redirect_uri:r.redirect_uri},{nonceIn:r.nonce,organization:a})}async getUser(){var e;let t=await this._getIdTokenFromCache();return t==null||(e=t.decodedToken)==null?void 0:e.user}async getIdTokenClaims(){var e;let t=await this._getIdTokenFromCache();return t==null||(e=t.decodedToken)==null?void 0:e.claims}async loginWithRedirect(){let e=on(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),{openUrl:t,fragment:n,appState:r}=e,i=O(e,xs),a=i.authorizationParams?.organization||this.options.authorizationParams.organization,o=this._applySessionTransferToken(i.authorizationParams||{}),s=await this._prepareAuthorizeUrl(o),{url:c}=s,l=O(s,Ss);this.transactionManager.create(D(D({},l),{},{appState:r,response_type:Kt.Code},a&&{organization:a}));let u=n?`${c}#${n}`:c;t?await t(u):window.location.assign(u)}async handleRedirectCallback(){let e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.location.href).split(`?`).slice(1);if(e.length===0)throw Error(`There are no query params available for parsing.`);let t=this.transactionManager.get();if(!t)throw new A(`missing_transaction`,`Invalid state`);this.transactionManager.remove();let n=(e=>{e.indexOf(`#`)>-1&&(e=e.substring(0,e.indexOf(`#`)));let t=new URLSearchParams(e);return{state:t.get(`state`),code:t.get(`code`)||void 0,connect_code:t.get(`connect_code`)||void 0,error:t.get(`error`)||void 0,error_description:t.get(`error_description`)||void 0}})(e.join(``));return t.response_type===Kt.ConnectCode?this._handleConnectAccountRedirectCallback(n,t):this._handleLoginRedirectCallback(n,t)}async _handleLoginRedirectCallback(e,t){let{code:n,state:r,error:i,error_description:a}=e;if(i)throw new de(i,a||i,r,t.appState);if(!t.code_verifier||t.state&&t.state!==r)throw new A(`state_mismatch`,`Invalid state`);let o=t.organization,s=t.nonce,c=t.redirect_uri;return await this._requestToken(D({audience:t.audience,scope:t.scope,code_verifier:t.code_verifier,grant_type:`authorization_code`,code:n},c?{redirect_uri:c}:{}),{nonceIn:s,organization:o}),{appState:t.appState,response_type:Kt.Code}}async _handleConnectAccountRedirectCallback(e,t){let{connect_code:n,state:r,error:i,error_description:a}=e;if(i)throw new fe(i,a||i,t.connection,r,t.appState);if(!n)throw new A(`missing_connect_code`,`Missing connect code`);if(!(t.code_verifier&&t.state&&t.auth_session&&t.redirect_uri&&t.state===r))throw new A(`state_mismatch`,`Invalid state`);return D(D({},await this.myAccountApi.completeAccount({auth_session:t.auth_session,connect_code:n,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier})),{},{appState:t.appState,response_type:Kt.ConnectCode})}async checkSession(e){if(!this.cookieStorage.get(this.isAuthenticatedCookieName)){if(!this.cookieStorage.get(nn))return;this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(nn)}try{await this.getTokenSilently(e)}catch{}}async getTokenSilently(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=D(D({cacheMode:`on`},e),{},{authorizationParams:D(D(D({},this.options.authorizationParams),e.authorizationParams),{},{scope:Ct(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})}),n=await((e,t)=>{let n=$t[t];return n||(n=e().finally(()=>{delete $t[t],n=null}),$t[t]=n),n})(()=>this._getTokenSilently(t),`${this.options.clientId}::${t.authorizationParams.audience}::${t.authorizationParams.scope}`);return e.detailedResponse?n:n?.access_token}async _getTokenSilently(e){let{cacheMode:t}=e,n=O(e,Cs);if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||k,clientId:this.options.clientId,cacheMode:t});if(e)return e}if(t===`cache-only`)return;let r=(i=this.options.clientId,a=n.authorizationParams.audience||`default`,`auth0.lock.getTokenSilently.${i}.${a}`);var i,a;try{return await this.lockManager.runWithLock(r,5e3,async()=>{if(t!==`off`){let e=await this._getEntryFromCache({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||k,clientId:this.options.clientId});if(e)return e}let{id_token:e,token_type:r,access_token:i,oauthTokenScope:a,expires_in:o}=this.options.useRefreshTokens?await this._getTokenUsingRefreshToken(n):await this._getTokenFromIFrame(n);return D(D({id_token:e,token_type:r,access_token:i},a?{scope:a}:null),{},{expires_in:o})})}catch(e){if(this._isInteractiveError(e)&&this.options.interactiveErrorHandler===`popup`)return await this._handleInteractiveErrorWithPopup(n);throw e}}_isInteractiveError(e){return e instanceof _e||e instanceof A&&this._isIframeMfaError(e)}_isIframeMfaError(e){return e.error===`login_required`&&e.error_description===`Multifactor authentication required`}async _handleInteractiveErrorWithPopup(e){try{await this.loginWithPopup({authorizationParams:e.authorizationParams});let t=await this._getEntryFromCache({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||k,clientId:this.options.clientId});if(!t)throw new A(`interactive_handler_cache_miss`,`Token not found in cache after interactive authentication`);return t}catch(e){throw e}}async getTokenWithPopup(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=D(D({},e),{},{authorizationParams:D(D(D({},this.options.authorizationParams),e.authorizationParams),{},{scope:Ct(this.scope,e.authorizationParams?.scope,e.authorizationParams?.audience||this.options.authorizationParams.audience)})});return t=D(D({},se),t),await this.loginWithPopup(n,t),(await this.cacheManager.get(new Et({scope:n.authorizationParams.scope,audience:n.authorizationParams.audience||k,clientId:this.options.clientId}),void 0,this.options.useMrrt)).access_token}async isAuthenticated(){return!!await this.getUser()}_buildLogoutUrl(e){e.clientId===null?delete e.clientId:e.clientId=e.clientId||this.options.clientId;let t=e.logoutParams||{},{federated:n}=t,r=O(t,ws),i=n?`&federated`:``;return this._url(`/v2/logout?${Oe(D({clientId:e.clientId},r))}`)+i}async logout(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=on(e),{openUrl:n}=t,r=O(t,Ts);e.clientId===null?await this.cacheManager.clear():await this.cacheManager.clear(e.clientId||this.options.clientId),this.cookieStorage.remove(this.orgHintCookieName,{cookieDomain:this.options.cookieDomain}),this.cookieStorage.remove(this.isAuthenticatedCookieName,{cookieDomain:this.options.cookieDomain}),this.userCache.remove(Tt),await this.dpop?.clear();let i=this._buildLogoutUrl(r);n?await n(i):!1!==n&&window.location.assign(i)}async _getTokenFromIFrame(e){let t=(n=this.options.clientId,`auth0.lock.getTokenFromIFrame.${n}`);var n;try{return await this.lockManager.runWithLock(t,5e3,async()=>{let t=D(D({},e.authorizationParams),{},{prompt:`none`}),n=this.cookieStorage.get(this.orgHintCookieName);n&&!t.organization&&(t.organization=n);let{url:r,state:i,nonce:a,code_verifier:o,redirect_uri:s,scope:c,audience:l}=await this._prepareAuthorizeUrl(t,{response_mode:`web_message`},window.location.origin);if(window.crossOriginIsolated)throw new A(`login_required`,`The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.`);let u=e.timeoutInSeconds||this.options.authorizeTimeoutInSeconds,d;try{d=new URL(this.domainUrl).origin}catch{d=this.domainUrl}let f=await function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:60;return new Promise((r,i)=>{let a=window.document.createElement(`iframe`);a.setAttribute(`width`,`0`),a.setAttribute(`height`,`0`),a.style.display=`none`;let o=()=>{window.document.body.contains(a)&&(window.document.body.removeChild(a),window.removeEventListener(`message`,s,!1))},s,c=setTimeout(()=>{i(new pe),o()},1e3*n);s=function(e){if(e.origin!=t||!e.data||e.data.type!==`authorization_response`)return;let n=e.source;n&&n.close(),e.data.response.error?i(A.fromPayload(e.data.response)):r(e.data.response),clearTimeout(c),window.removeEventListener(`message`,s,!1),setTimeout(o,2e3)},window.addEventListener(`message`,s,!1),window.document.body.appendChild(a),a.setAttribute(`src`,e)})}(r,d,u);if(i!==f.state)throw new A(`state_mismatch`,`Invalid state`);let p=await this._requestToken(D(D({},e.authorizationParams),{},{code_verifier:o,code:f.code,grant_type:`authorization_code`,redirect_uri:s,timeout:e.authorizationParams.timeout||this.httpTimeoutMs}),{nonceIn:a,organization:t.organization});return D(D({},p),{},{scope:c,oauthTokenScope:p.scope,audience:l})})}catch(e){throw e.error===`login_required`&&(e instanceof A&&this._isIframeMfaError(e)&&this.options.interactiveErrorHandler===`popup`||this.logout({openUrl:!1})),e}}async _getTokenUsingRefreshToken(e){let t=await this.cacheManager.get(new Et({scope:e.authorizationParams.scope,audience:e.authorizationParams.audience||k,clientId:this.options.clientId}),void 0,this.options.useMrrt);if(!(t&&t.refresh_token||this.worker)){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);throw new ve(e.authorizationParams.audience||k,e.authorizationParams.scope)}let n=e.authorizationParams.redirect_uri||this.options.authorizationParams.redirect_uri||window.location.origin,r=typeof e.timeoutInSeconds==`number`?1e3*e.timeoutInSeconds:null,i=((e,t,n,r)=>{if(e&&n&&r){if(t.audience!==n)return t.scope;let e=r.split(` `),i=t.scope?.split(` `)||[],a=i.every(t=>e.includes(t));return e.length>=i.length&&a?r:t.scope}return t.scope})(this.options.useMrrt,e.authorizationParams,t?.audience,t?.scope);try{let l=await this._requestToken(D(D({},e.authorizationParams),{},{grant_type:`refresh_token`,refresh_token:t&&t.refresh_token,redirect_uri:n},r&&{timeout:r}),{scopesToRequest:i});if(l.refresh_token&&t!=null&&t.refresh_token&&await this.cacheManager.updateEntry(t.refresh_token,l.refresh_token),this.options.useMrrt&&(a=t?.audience,o=t?.scope,s=e.authorizationParams.audience,c=e.authorizationParams.scope,(a!==s||!sn(c,o))&&!sn(i,l.scope))){if(this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e);await this.cacheManager.remove(this.options.clientId,e.authorizationParams.audience,e.authorizationParams.scope);let t=((e,t)=>{let n=e?.split(` `)||[],r=t?.split(` `)||[];return n.filter(e=>r.indexOf(e)==-1).join(`,`)})(i,l.scope);throw new ye(e.authorizationParams.audience||`default`,t)}return D(D({},l),{},{scope:e.authorizationParams.scope,oauthTokenScope:l.scope,audience:e.authorizationParams.audience||k})}catch(t){if(t.message){if(t.message.includes(`user is blocked`))throw await this.logout({openUrl:!1}),t;if((t.message.includes(`Missing Refresh Token`)||t.message.includes(`invalid refresh token`))&&this.options.useRefreshTokensFallback)return await this._getTokenFromIFrame(e)}throw t instanceof _e&&this.mfa.setMFAAuthDetails(t.mfa_token,e.authorizationParams?.scope,e.authorizationParams?.audience,t.mfa_requirements),t}var a,o,s,c}async _saveEntryInCache(e){let{id_token:t,decodedToken:n}=e,r=O(e,Es);this.userCache.set(Tt,{id_token:t,decodedToken:n}),await this.cacheManager.setIdToken(this.options.clientId,e.id_token,e.decodedToken),await this.cacheManager.set(r)}async _getIdTokenFromCache(){let e=this.options.authorizationParams.audience||k,t=this.scope[e],n=await this.cacheManager.getIdToken(new Et({clientId:this.options.clientId,audience:e,scope:t})),r=this.userCache.get(Tt);return n&&n.id_token===r?.id_token?r:(this.userCache.set(Tt,n),n)}async _getEntryFromCache(e){let{scope:t,audience:n,clientId:r,cacheMode:i}=e,a=await this.cacheManager.get(new Et({scope:t,audience:n,clientId:r}),60,this.options.useMrrt,i);if(a&&a.access_token){let{token_type:e,access_token:t,oauthTokenScope:n,expires_in:r}=a,i=await this._getIdTokenFromCache();return i&&D(D({id_token:i.id_token,token_type:e||`Bearer`,access_token:t},n?{scope:n}:null),{},{expires_in:r})}}async _requestToken(e,t){let{nonceIn:n,organization:r,scopesToRequest:i}=t||{},a=await xt(D(D({baseUrl:this.domainUrl,client_id:this.options.clientId,auth0Client:this.options.auth0Client,useFormData:this.options.useFormData,timeout:this.httpTimeoutMs,useMrrt:this.options.useMrrt,dpop:this.dpop},e),{},{scope:i||e.scope}),this.worker),o=await this._verifyIdToken(a.id_token,n,r);if(e.grant_type===`authorization_code`){var s;let e=await this._getIdTokenFromCache();e!=null&&(s=e.decodedToken)!=null&&(s=s.claims)!=null&&s.sub&&e.decodedToken.claims.sub!==o.claims.sub&&(await this.cacheManager.clear(this.options.clientId),this.userCache.remove(Tt))}return await this._saveEntryInCache(D(D(D({},a),{},{decodedToken:o,scope:e.scope,audience:e.audience||k},a.scope?{oauthTokenScope:a.scope}:null),{},{client_id:this.options.clientId})),this.cookieStorage.save(this.isAuthenticatedCookieName,!0,{daysUntilExpire:this.sessionCheckExpiryDays,cookieDomain:this.options.cookieDomain}),this._processOrgHint(r||o.claims.org_id),D(D({},a),{},{decodedToken:o})}async loginWithCustomTokenExchange(e){return this._requestToken(D(D({},e),{},{grant_type:`urn:ietf:params:oauth:grant-type:token-exchange`,subject_token:e.subject_token,subject_token_type:e.subject_token_type,scope:Ct(this.scope,e.scope,e.audience||this.options.authorizationParams.audience),audience:e.audience||this.options.authorizationParams.audience,organization:e.organization||this.options.authorizationParams.organization}))}async exchangeToken(e){return this.loginWithCustomTokenExchange(e)}_assertDpop(e){if(!e)throw Error("`useDpop` option must be enabled before using DPoP.")}getDpopNonce(e){return this._assertDpop(this.dpop),this.dpop.getNonce(e)}setDpopNonce(e,t){return this._assertDpop(this.dpop),this.dpop.setNonce(e,t)}generateDpopProof(e){return this._assertDpop(this.dpop),this.dpop.generateProof(e)}createFetcher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return new fn(e,{isDpopEnabled:()=>!!this.options.useDpop,getAccessToken:e=>{var t;return this.getTokenSilently({authorizationParams:{scope:e==null||(t=e.scope)==null?void 0:t.join(` `),audience:e?.audience},detailedResponse:!0})},getDpopNonce:()=>this.getDpopNonce(e.dpopNonceId),setDpopNonce:t=>this.setDpopNonce(t,e.dpopNonceId),generateDpopProof:e=>this.generateDpopProof(e)})}async connectAccountWithRedirect(e){let{openUrl:t,appState:n,connection:r,scopes:i,authorization_params:a,redirectUri:o=this.options.authorizationParams.redirect_uri||window.location.origin}=e;if(!r)throw Error(`connection is required`);let s=Te(we()),c=we(),l=je(await ke(c)),{connect_uri:u,connect_params:d,auth_session:f}=await this.myAccountApi.connectAccount({connection:r,scopes:i,redirect_uri:o,state:s,code_challenge:l,code_challenge_method:`S256`,authorization_params:a});this.transactionManager.create({state:s,code_verifier:c,auth_session:f,redirect_uri:o,appState:n,connection:r,response_type:Kt.ConnectCode});let p=new URL(u);p.searchParams.set(`ticket`,d.ticket),t?await t(p.toString()):window.location.assign(p)}async _requestTokenForMfa(e,t){let{mfaToken:n}=e,r=O(e,Ds);return this._requestToken(D(D({},r),{},{mfa_token:n}),t)}},ks={isAuthenticated:!1,isLoading:!0,error:void 0,user:void 0},L=function(){throw Error(`You forgot to wrap your component in <Auth0Provider>.`)},As=v(v({},ks),{buildAuthorizeUrl:L,buildLogoutUrl:L,getAccessTokenSilently:L,getAccessTokenWithPopup:L,getIdTokenClaims:L,loginWithCustomTokenExchange:L,exchangeToken:L,loginWithRedirect:L,loginWithPopup:L,connectAccountWithRedirect:L,logout:L,handleRedirectCallback:L,getDpopNonce:L,setDpopNonce:L,generateDpopProof:L,createFetcher:L,getConfiguration:L,mfa:{getAuthenticators:L,enroll:L,challenge:L,verify:L,getEnrollmentFactors:L}}),js=(0,c.createContext)(As),Ms=function(e){_(t,e);function t(n,r){var i=e.call(this,r??n)||this;return i.error=n,i.error_description=r,Object.setPrototypeOf(i,t.prototype),i}return t}(Error),Ns=/[?&](?:connect_)?code=[^&]+/,Ps=/[?&]state=[^&]+/,Fs=/[?&]error=[^&]+/,Is=function(e){return e===void 0&&(e=window.location.search),(Ns.test(e)||Fs.test(e))&&Ps.test(e)},Ls=function(e){return function(t){if(t instanceof Error)return t;if(typeof t==`object`&&t&&`error`in t&&typeof t.error==`string`){if(`error_description`in t&&typeof t.error_description==`string`){var n=t;return new Ms(n.error,n.error_description)}return new Ms(t.error)}return Error(e)}},Rs=Ls(`Login failed`),zs=Ls(`Get access token failed`),Bs=function(e){e?.redirectUri&&(console.warn("Using `redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `redirectUri` will be no longer supported in a future version"),e.authorizationParams=e.authorizationParams??{},e.authorizationParams.redirect_uri=e.redirectUri,delete e.redirectUri),e?.authorizationParams?.redirectUri&&(console.warn("Using `authorizationParams.redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `authorizationParams.redirectUri` will be removed in a future version"),e.authorizationParams.redirect_uri=e.authorizationParams.redirectUri,delete e.authorizationParams.redirectUri)},Vs=function(e,t){switch(t.type){case`LOGIN_POPUP_STARTED`:return v(v({},e),{isLoading:!0});case`LOGIN_POPUP_COMPLETE`:case`INITIALISED`:return v(v({},e),{isAuthenticated:!!t.user,user:t.user,isLoading:!1,error:void 0});case`HANDLE_REDIRECT_COMPLETE`:case`GET_ACCESS_TOKEN_COMPLETE`:return e.user===t.user?e:v(v({},e),{isAuthenticated:!!t.user,user:t.user});case`LOGOUT`:return v(v({},e),{isAuthenticated:!1,user:void 0});case`ERROR`:return v(v({},e),{isLoading:!1,error:t.error})}},Hs=function(e){return Bs(e),v(v({},e),{auth0Client:{name:`auth0-react`,version:`2.16.1`}})},Us=function(e){window.history.replaceState({},document.title,e.returnTo??window.location.pathname)},Ws=function(e){var t=e,n=t.children,r=t.skipRedirectCallback,i=t.onRedirectCallback,a=i===void 0?Us:i,o=t.context,s=o===void 0?js:o,l=t.client,u=ee(t,[`children`,`skipRedirectCallback`,`onRedirectCallback`,`context`,`client`]);l&&(u.domain||u.clientId)&&console.warn("Auth0Provider: the `client` prop takes precedence over `domain`/`clientId` and other configuration options. Remove `domain`, `clientId`, and any other Auth0Client configuration props when using the `client` prop.");var d=(0,c.useState)(function(){return l??new Os(Hs(u))})[0],f=(0,c.useReducer)(Vs,ks),p=f[0],m=f[1],h=(0,c.useRef)(!1),g=(0,c.useCallback)(function(e){return m({type:`ERROR`,error:e}),e},[]);(0,c.useEffect)(function(){h.current||(h.current=!0,(function(){return y(void 0,void 0,void 0,function(){var e,t,n,i,o,s,c;return b(this,function(l){switch(l.label){case 0:return l.trys.push([0,7,,8]),e=void 0,Is()&&!r?[4,d.handleRedirectCallback()]:[3,3];case 1:return t=l.sent(),n=t.appState,i=n===void 0?{}:n,o=t.response_type,s=ee(t,[`appState`,`response_type`]),[4,d.getUser()];case 2:return e=l.sent(),i.response_type=o,o===Kt.ConnectCode&&(i.connectedAccount=s),a(i,e),[3,6];case 3:return[4,d.checkSession()];case 4:return l.sent(),[4,d.getUser()];case 5:e=l.sent(),l.label=6;case 6:return m({type:`INITIALISED`,user:e}),[3,8];case 7:return c=l.sent(),g(Rs(c)),[3,8];case 8:return[2]}})})})())},[d,a,r,g]);var _=(0,c.useCallback)(function(e){return Bs(e),d.loginWithRedirect(e)},[d]),x=(0,c.useCallback)(function(e,t){return y(void 0,void 0,void 0,function(){var n,r;return b(this,function(i){switch(i.label){case 0:m({type:`LOGIN_POPUP_STARTED`}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,d.loginWithPopup(e,t)];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),g(Rs(n)),[2];case 4:return[4,d.getUser()];case 5:return r=i.sent(),m({type:`LOGIN_POPUP_COMPLETE`,user:r}),[2]}})})},[d,g]),S=(0,c.useCallback)(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return y(void 0,te([],e,!0),void 0,function(e){return e===void 0&&(e={}),b(this,function(t){switch(t.label){case 0:return[4,d.logout(e)];case 1:return t.sent(),(e.openUrl||e.openUrl===!1)&&m({type:`LOGOUT`}),[2]}})})},[d]),ne=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r,i;return b(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,d.getTokenSilently(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),zs(n);case 3:return r=m,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[d]),re=(0,c.useCallback)(function(e,t){return y(void 0,void 0,void 0,function(){var n,r,i,a;return b(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,3,5]),[4,d.getTokenWithPopup(e,t)];case 1:return n=o.sent(),[3,5];case 2:throw r=o.sent(),zs(r);case 3:return i=m,a={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return i.apply(void 0,[(a.user=o.sent(),a)]),[7];case 5:return[2,n]}})})},[d]),C=(0,c.useCallback)(function(e){return d.connectAccountWithRedirect(e)},[d]),w=(0,c.useCallback)(function(){return d.getIdTokenClaims()},[d]),T=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r,i;return b(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,5]),[4,d.loginWithCustomTokenExchange(e)];case 1:return t=a.sent(),[3,5];case 2:throw n=a.sent(),zs(n);case 3:return r=m,i={type:`GET_ACCESS_TOKEN_COMPLETE`},[4,d.getUser()];case 4:return r.apply(void 0,[(i.user=a.sent(),i)]),[7];case 5:return[2,t]}})})},[d]),E=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){return b(this,function(t){return[2,T(e)]})})},[T]),ie=(0,c.useCallback)(function(e){return y(void 0,void 0,void 0,function(){var t,n,r;return b(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,3,5]),[4,d.handleRedirectCallback(e)];case 1:return[2,i.sent()];case 2:throw t=i.sent(),zs(t);case 3:return n=m,r={type:`HANDLE_REDIRECT_COMPLETE`},[4,d.getUser()];case 4:return n.apply(void 0,[(r.user=i.sent(),r)]),[7];case 5:return[2]}})})},[d]),D=(0,c.useCallback)(function(e){return d.getDpopNonce(e)},[d]),O=(0,c.useCallback)(function(e,t){return d.setDpopNonce(e,t)},[d]),ae=(0,c.useCallback)(function(e){return d.generateDpopProof(e)},[d]),oe=(0,c.useCallback)(function(e){return d.createFetcher(e)},[d]),se=(0,c.useCallback)(function(){return d.getConfiguration()},[d]),ce=(0,c.useMemo)(function(){return d.mfa},[d]),le=(0,c.useMemo)(function(){return v(v({},p),{getAccessTokenSilently:ne,getAccessTokenWithPopup:re,getIdTokenClaims:w,loginWithCustomTokenExchange:T,exchangeToken:E,loginWithRedirect:_,loginWithPopup:x,connectAccountWithRedirect:C,logout:S,handleRedirectCallback:ie,getDpopNonce:D,setDpopNonce:O,generateDpopProof:ae,createFetcher:oe,getConfiguration:se,mfa:ce})},[p,ne,re,w,T,E,_,x,C,S,ie,D,O,ae,oe,se,ce]);return c.default.createElement(s.Provider,{value:le},n)},Gs=function(e){return e===void 0&&(e=js),(0,c.useContext)(e)},Ks=({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 qs(e){let{protocol:t,hostname:n,port:r}=window.location;return e({logoutParams:{returnTo:`${t}//${n}:${r}`}})}var Js=({children:e,decorateUser:t,getReturnPath:n})=>{let[r,i]=(0,c.useState)(void 0),{user:a,getAccessTokenSilently:o,loginWithRedirect:s,logout:p,isLoading:g,isAuthenticated:_,error:v}=Gs();return(0,c.useEffect)(()=>{_&&(async()=>{try{i(await t(a,await o()))}catch(e){console.error(`Error fetching user data:`,e)}})()},[t,o,_,a]),!g&&!_?(s({appState:{returnTo:n()}}),(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Redirecting to login page`})):g||!r?(0,h.jsx)(u.Loader,{style:{marginTop:d.space.extraLarge9},children:`Authenticating`}):v?(process.env.NODE_ENV!==`production`&&console.error(v),(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:v?.toString()})]})]})):((0,m.assertIsDefined)(r),(0,h.jsx)(h.Fragment,{children:e({user:r,logout:()=>qs(p),getToken:o})}))},Ys=({children:e,audience:t,domain:n,clientId:r,decorateUser:i,environment:a,redirectUri:o,navigate:s})=>(0,h.jsx)(Ws,{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)(Js,{decorateUser:i,getReturnPath:()=>`${window.location.pathname}${window.location.search}${window.location.hash}`,children:t=>(0,h.jsxs)(h.Fragment,{children:[a&&a!==p.Environment.Production&&(0,h.jsx)(Ks,{environment:a}),e(t)]})})}),Xs=`EP::activeOrgId`,Zs={get:()=>localStorage.getItem(Xs),set:e=>localStorage.setItem(Xs,e)},Qs=`EP::locale`,$s={get:()=>localStorage.getItem(Qs),set:e=>localStorage.setItem(Qs,e)},ec=`ucData`,tc={get:()=>localStorage.getItem(ec)},nc={Usercentrics:`Usercentrics Consent Management Platform`,PostHog:`PostHog.com`,Sentry:`Sentry`},rc={Usercentrics:{consentGiven:!1},PostHog:{consentGiven:!1},Sentry:{consentGiven:!1}},ic=e=>e.map(e=>{let t=Object.entries(nc).find(t=>t[1]===e.name)?.[0];if((0,m.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}),rc),ac=(0,c.createContext)(rc),oc=()=>(0,c.useContext)(ac),sc=({children:e})=>{let[t,n]=(0,c.useState)(rc);return(0,c.useEffect)(()=>{if(typeof window>`u`)return;let e=tc.get();if(e){let t=JSON.parse(e);n(ic(Object.values(t.consent.services)))}},[]),(0,c.useEffect)(()=>{let e=async e=>{typeof window>`u`||n(ic(Object.values(e.detail.services)))};return window.addEventListener(`UC_CONSENT`,e),()=>window.removeEventListener(`UC_CONSENT`,e)},[]),(0,h.jsx)(ac.Provider,{value:t,children:e})},cc=(0,c.createContext)(void 0),lc=e=>{let[t,n]=(0,c.useState)(e);return(0,c.useEffect)(()=>{$s.set(t)},[t]),[t,n]},uc=()=>{let e=(0,c.useContext)(cc);return(0,m.assertIsDefined)(e),e},dc=({children:e,language:t})=>{let[n,r]=lc(t);return(0,h.jsx)(cc.Provider,{value:{language:n,setLanguage:r},children:e})},fc=(0,c.createContext)({addItems:()=>{},getItemsForPath:()=>[],getMFNavigate:()=>void 0,setMFNavigate:()=>{},getItemGroupsPerPath:()=>({})}),pc=e=>(0,c.useContext)(fc).getItemsForPath(e),mc=()=>(0,c.useContext)(fc),hc=e=>{let{getMFNavigate:t}=mc();return t(e)},gc=({children:e})=>{let[t,n]=(0,c.useState)({}),[r,i]=(0,c.useState)({}),a=(0,c.useCallback)((e,t)=>{n(n=>({...n,[t]:e}))},[]);return(0,h.jsx)(fc.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 _c(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var vc=({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`)&&!_c(t)&&(t.preventDefault(),e())},target:r,...i,children:t}),yc=(0,c.createContext)(void 0),bc=()=>{let e=(0,c.useContext)(yc);return(0,m.assertIsDefined)(e),e},xc=()=>{let e=(0,c.useContext)(yc);return(0,m.assertIsDefined)(e),e.organisationId},Sc=e=>{let[t,n]=(0,c.useState)(Number(e));return(0,c.useEffect)(()=>{Zs.set(t.toString())},[t]),[t,n]},Cc=({children:e,organisationId:t})=>{let[n,r]=Sc(t);return(0,h.jsx)(yc.Provider,{value:{organisationId:n,setOrganisationId:r},children:e})},wc=class extends Error{constructor(...e){super(...e),this.message=`Failed fetching organisations`}},Tc=({getToken:e,getOrganisations:t,selectedOrganisationId:n,onChange:r,...i})=>{let[a,o]=(0,c.useState)([]),{language:s}=uc(),[l,d]=(0,c.useState)(`LOADING`);switch((0,c.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),d(`SUCCESS`)})().catch(e=>{process.env.NODE_ENV===`development`&&console.error(e),d(`ERROR`)})},[t,e]),l){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 wc;default:return null}},R=typeof window<`u`?window:void 0,Ec=typeof globalThis<`u`?globalThis:R;typeof self>`u`&&(Ec.self=Ec),typeof File>`u`&&(Ec.File=function(){});var Dc=Ec?.navigator,z=Ec?.document,Oc=Ec?.location,kc=Ec?.fetch,Ac=Ec!=null&&Ec.XMLHttpRequest&&`withCredentials`in new Ec.XMLHttpRequest?Ec.XMLHttpRequest:void 0,jc=Ec?.AbortController,Mc=Ec?.CompressionStream,Nc=Dc?.userAgent,B=R??{},Pc=`1.365.5`,Fc={DEBUG:!1,LIB_VERSION:Pc,LIB_NAME:`web`,JS_SDK_VERSION:Pc};function Ic(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 Lc(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ic(a,r,i,o,s,`next`,e)}function s(e){Ic(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function V(){return V=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},V.apply(null,arguments)}function Rc(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 zc(){return(zc=Lc((function*(e,t){t===void 0&&(t=!0);try{var n=new Blob([e],{type:`text/plain`}).stream().pipeThrough(new CompressionStream(`gzip`));return yield new Response(n).blob()}catch(e){return t&&console.error(`Failed to gzip compress data`,e),null}}))).apply(this,arguments)}var Bc=[`$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`],Vc=`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(`,`),Hc=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return Vc.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))};function H(e,t){return e.indexOf(t)!==-1}var Uc=function(e){return e.trim()},Wc=function(e){return e.replace(/^\$/,``)},Gc=Object.prototype,Kc=Gc.hasOwnProperty,qc=Gc.toString,U=Array.isArray||function(e){return qc.call(e)===`[object Array]`},Jc=e=>typeof e==`function`,Yc=e=>e===Object(e)&&!U(e),Xc=e=>{if(Yc(e)){for(var t in e)if(Kc.call(e,t))return!1;return!0}return!1},W=e=>e===void 0,Zc=e=>qc.call(e)==`[object String]`,Qc=e=>Zc(e)&&e.trim().length===0,$c=e=>e===null,G=e=>W(e)||$c(e),el=e=>qc.call(e)==`[object Number]`&&e==e,tl=e=>el(e)&&e>0,nl=e=>qc.call(e)===`[object Boolean]`,rl=e=>e instanceof FormData,il=e=>H(Bc,e);function al(e){return typeof e!=`object`||!e}function ol(e,t){return{}.toString.call(e)===`[object `+t+`]`}function sl(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var cl=[!0,`true`,1,`1`,`yes`],ll=e=>H(cl,e),ul=[!1,`false`,0,`0`,`no`];function dl(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),el(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),dl(i||n,t,n,r))}var fl=class{constructor(e){this.Pt={},this.Dt=e.Dt,this.jt=dl(e.bucketSize,0,100,e.qt),this.$t=dl(e.refillRate,0,this.jt,e.qt),this.Ht=dl(e.refillInterval,0,864e5,e.qt)}Vt(e,t){var n=Math.floor((t-e.lastAccess)/this.Ht);n>0&&(e.tokens=Math.min(e.tokens+n*this.$t,this.jt),e.lastAccess+=n*this.Ht)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.Pt[r];return i?this.Vt(i,n):this.Pt[r]=i={tokens:this.jt,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.Dt)==null||t.call(this,e)),i.tokens===0)}stop(){this.Pt={}}},pl,ml,hl,gl=`Mobile`,_l=`iOS`,vl=`Android`,yl=`Tablet`,bl=vl+` `+yl,xl=`iPad`,Sl=`Apple`,Cl=Sl+` Watch`,wl=`Safari`,Tl=`BlackBerry`,El=`Samsung`,Dl=El+`Browser`,Ol=El+` Internet`,kl=`Chrome`,Al=kl+` OS`,jl=kl+` `+_l,Ml=`Internet Explorer`,Nl=Ml+` `+gl,Pl=`Opera`,Fl=Pl+` Mini`,Il=`Edge`,Ll=`Microsoft `+Il,Rl=`Firefox`,zl=Rl+` `+_l,Bl=`Nintendo`,Vl=`PlayStation`,Hl=`Xbox`,Ul=vl+` `+gl,Wl=gl+` `+wl,Gl=`Windows`,Kl=Gl+` Phone`,ql=`Nokia`,Jl=`Ouya`,Yl=`Generic`,Xl=Yl+` `+gl.toLowerCase(),Zl=Yl+` `+yl.toLowerCase(),Ql=`Konqueror`,$l=`(\\d+(\\.\\d+)?)`,eu=RegExp(`Version/`+$l),tu=new RegExp(Hl,`i`),nu=RegExp(Vl+` \\w+`,`i`),ru=RegExp(Bl+` \\w+`,`i`),iu=RegExp(Tl+`|PlayBook|BB10`,`i`),au={"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`},ou=function(e,t){return t||=``,H(e,` OPR/`)&&H(e,`Mini`)?Fl:H(e,` OPR/`)?Pl:iu.test(e)?Tl:H(e,`IE`+gl)||H(e,`WPDesktop`)?Nl:H(e,Dl)?Ol:H(e,Il)||H(e,`Edg/`)?Ll:H(e,`FBIOS`)?`Facebook `+gl:H(e,`UCWEB`)||H(e,`UCBrowser`)?`UC Browser`:H(e,`CriOS`)?jl:H(e,`CrMo`)||H(e,kl)?kl:H(e,vl)&&H(e,wl)?Ul:H(e,`FxiOS`)?zl:H(e.toLowerCase(),Ql.toLowerCase())?Ql:((e,t)=>t&&H(t,Sl)||function(e){return H(e,wl)&&!H(e,kl)&&!H(e,vl)}(e))(e,t)?H(e,gl)?Wl:wl:H(e,Rl)?Rl:H(e,`MSIE`)||H(e,`Trident/`)?Ml:H(e,`Gecko`)?Rl:``},su={[Nl]:[RegExp(`rv:`+$l)],[Ll]:[RegExp(Il+`?\\/`+$l)],[kl]:[RegExp(`(`+kl+`|CrMo)\\/`+$l)],[jl]:[RegExp(`CriOS\\/`+$l)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+$l)],[wl]:[eu],[Wl]:[eu],[Pl]:[RegExp(`(Opera|OPR)\\/`+$l)],[Rl]:[RegExp(Rl+`\\/`+$l)],[zl]:[RegExp(`FxiOS\\/`+$l)],[Ql]:[RegExp(`Konqueror[:/]?`+$l,`i`)],[Tl]:[RegExp(Tl+` `+$l),eu],[Ul]:[RegExp(`android\\s`+$l,`i`)],[Ol]:[RegExp(Dl+`\\/`+$l)],[Ml]:[RegExp(`(rv:|MSIE )`+$l)],Mozilla:[RegExp(`rv:`+$l)]},cu=function(e,t){var n=su[ou(e,t)];if(W(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},lu=[[RegExp(Hl+`; `+Hl+` (.*?)[);]`,`i`),e=>[Hl,e&&e[1]||``]],[new RegExp(Bl,`i`),[Bl,``]],[new RegExp(Vl,`i`),[Vl,``]],[iu,[Tl,``]],[new RegExp(Gl,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Kl,``];if(new RegExp(gl).test(t)&&!/IEMobile\b/.test(t))return[Gl+` `+gl,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=au[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[Gl,r]}return[Gl,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[_l,[e[3],e[4],e[5]||`0`].join(`.`)]:[_l,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=W(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+vl+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+vl+`)`,`i`),e=>e&&e[2]?[vl,[e[2],e[3],e[4]||`0`].join(`.`)]:[vl,``]],[/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/,[Al,``]],[/Linux|debian/i,[`Linux`,``]]],uu=function(e){return ru.test(e)?Bl:nu.test(e)?Vl:tu.test(e)?Hl:new RegExp(Jl,`i`).test(e)?Jl:RegExp(`(`+Kl+`|WPDesktop)`,`i`).test(e)?Kl:/iPad/.test(e)?xl:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Cl:iu.test(e)?Tl:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(ql,`i`).test(e)?ql:/(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(gl).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)?vl:bl:RegExp(`(pda|`+gl+`)`,`i`).test(e)?Xl:new RegExp(yl,`i`).test(e)&&!RegExp(yl+` pc`,`i`).test(e)?Zl:``},du=e=>e instanceof Error;function fu(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return hl&&n.length===ml||(ml=n.length,hl=n.reduce(((n,r)=>{pl||={};var i=pl[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,pl[r]=[s,c];break}}return n}),{})),hl}}var pu=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 Lc((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&U(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)),V({},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 Lc((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,V({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:fu(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 V({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},mu=`?`;function hu(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?mu:n,in_app:!0};return W(r)||(a.lineno=r),W(i)||(a.colno=i),a}var gu=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?mu:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},_u=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,vu=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,yu=/\((\S*)(?::(\d+))(?::(\d+))\)/,bu=(e,t)=>{var n=_u.exec(e);if(n){var[,r,i,a]=n;return hu(t,r,mu,+i,+a)}var o=vu.exec(e);if(o){if(o[2]&&o[2].indexOf(`eval`)===0){var s=yu.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}var[c,l]=gu(o[1]||mu,o[2]);return hu(t,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},xu=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Su=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Cu=(e,t)=>{var n=xu.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=Su.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]||mu;return[a,i]=gu(a,i),hu(t,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},wu=/\(error: (.*)\)/,Tu=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=Zc(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 ol(e,`DOMException`)}isDOMError(e){return ol(e,`DOMError`)}},Eu=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}},Du=class{constructor(){}match(e){return ol(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},Ou=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ku=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(Ou);return r&&(t=r[1],n=r[2]),[t,n]}},Au=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function ju(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 Mu=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 sl(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: `+ju(e)}isSeverityLevel(e){return Zc(e)&&!Qc(e)&&Au.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(du(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Nu=class{match(e){return sl(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+ju(e),stack:t.syntheticException?.stack,synthetic:!0}}},Pu=class{match(e){return al(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},Fu=class{match(e){return ol(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!sl(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 al(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}},Iu=function(e,t){var{debugEnabled:n}=t===void 0?{}:t,r={C(t){if(R&&(Fc.DEBUG||B.POSTHOG_DEBUG||n)&&!W(R.console)&&R.console){for(var r=(`__rrweb_original__`in R.console[t])?R.console[t].__rrweb_original__:R.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)}},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)=>Iu(e+` `+t,n)};return r},K=Iu(`[PostHog.js]`),q=K.createLogger,Lu=q(`[ExternalScriptsLoader]`),Ru=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Lu.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var r=z?.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(!z)return n(`document not found`);var r=z.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`)z.head.appendChild(r);else{var i,a=z.querySelectorAll(`body > script`);a.length>0?(i=a[0].parentNode)==null||i.insertBefore(r,a[0]):z.body.appendChild(r)}};z!=null&&z.body?s():z?.addEventListener(`DOMContentLoaded`,s)};B.__PosthogExtensions__=B.__PosthogExtensions__||{},B.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var r=`/static/`+t+`.js?v=`+e.version;if(t===`remote-config`&&(r=`/array/`+e.config.token+`/config.js`),t===`toolbar`){var i=3e5;r=r+`&t=`+Math.floor(Date.now()/i)*i}Ru(e,e.requestRouter.endpointFor(`assets`,r),n)},B.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{Ru(e,e.requestRouter.endpointFor(`api`,t),n)};var zu=`$people_distinct_id`,Bu=`$device_id`,Vu=`__alias`,Hu=`__timers`,Uu=`$autocapture_disabled_server_side`,Wu=`$heatmaps_enabled_server_side`,Gu=`$exception_capture_enabled_server_side`,Ku=`$error_tracking_suppression_rules`,qu=`$error_tracking_capture_extension_exceptions`,Ju=`$web_vitals_enabled_server_side`,Yu=`$dead_clicks_enabled_server_side`,Xu=`$product_tours_enabled_server_side`,Zu=`$web_vitals_allowed_metrics`,Qu=`$session_recording_remote_config`,$u=`$sesid`,ed=`$session_is_sampled`,td=`$enabled_feature_flags`,nd=`$early_access_features`,rd=`$feature_flag_details`,id=`$stored_person_properties`,ad=`$stored_group_properties`,od=`$surveys`,sd=`$flag_call_reported`,cd=`$flag_call_reported_session_id`,ld=`$feature_flag_errors`,ud=`$feature_flag_evaluated_at`,dd=`$user_state`,fd=`$client_session_props`,pd=`$capture_rate_limit`,md=`$initial_campaign_params`,hd=`$initial_referrer_info`,gd=`$initial_person_info`,_d=`$epp`,vd=`__POSTHOG_TOOLBAR__`,yd=`$posthog_cookieless`,bd=[zu,Vu,`__cmpns`,Hu,`$session_recording_enabled_server_side`,Wu,$u,td,Ku,dd,nd,rd,ad,id,od,sd,cd,ld,ud,fd,pd,md,hd,_d,gd],xd=`PostHog loadExternalDependency extension not found.`,Sd=`on_reject`,Cd=`always`,wd=`anonymous`,Td=`identified`,Ed=`identified_only`,Dd=`visibilitychange`,Od=`beforeunload`,kd=`$pageview`,Ad=`$pageleave`,jd=`$identify`,Md=`$groupidentify`;function Nd(e,t){U(e)&&e.forEach(t)}function J(e,t){if(!G(e))if(U(e))e.forEach(t);else if(rl(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)Kc.call(e,n)&&t(e[n],n)}var Y=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 Pd(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Fd=function(e){try{return e()}catch{return}},Id=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){K.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),K.critical(e)}}},Ld=function(e){var t={};return J(e,(function(e,n){(Zc(e)&&e.length>0||el(e))&&(t[n]=e)})),t},Rd=[`herokuapp.com`,`vercel.app`,`netlify.app`];function zd(e){var t=e?.hostname;if(!Zc(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of Rd)if(n===r)return!1;return!0}function X(e,t,n,r){var{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function Bd(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 el(e)&&isFinite(e)&&Math.floor(e)===e});var Vd=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}},Hd=class{constructor(){this.I=0,this.S=0,this.k=new Gd}generate(){var e=this.generateOrAbort();if(W(e)){this.I=0;var t=this.generateOrAbort();if(W(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 Vd.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())}},Ud,Wd=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};R&&!W(R.crypto)&&crypto.getRandomValues&&(Wd=e=>crypto.getRandomValues(e));var Gd=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(Wd(this.T),this.N=0),this.T[this.N++]}},Kd=()=>qd().toString(),qd=()=>(Ud||=new Hd).generate(),Jd=``,Yd=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Xd={Yt:()=>!!z,Ut(e){K.error(`cookieStore error: `+e)},Wt(e){if(z){try{for(var t=e+`=`,n=z.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}},Gt(e){var t;try{t=JSON.parse(Xd.Wt(e))||{}}catch{}return t},Xt(e,t,n,r,i){if(z)try{var a=``,o=``,s=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=z),Jd)return Jd;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+Kd();!Jd&&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`,Jd=a)}return Jd}(e);if(!n){var r=(e=>{var t=e.match(Yd);return t?t[0]:``})(e);r!==n&&K.info(`Warning: cookie subdomain discovery mismatch`,r,n),n=r}return n?`; domain=.`+n:``}return``}(z.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&&K.warn(`cookieStore warning: large cookie, len=`+l.length),z.cookie=l,l}catch{return}},Jt(e,t){if(z!=null&&z.cookie)try{Xd.Xt(e,``,-1,t)}catch{return}}},Zd=null,Z={Yt(){if(!$c(Zd))return Zd;var e=!0;if(W(R))e=!1;else try{var t=`__mplssupport__`;Z.Xt(t,`xyz`),Z.Wt(t)!==`"xyz"`&&(e=!1),Z.Jt(t)}catch{e=!1}return e||K.error(`localStorage unsupported; falling back to cookie store`),Zd=e,e},Ut(e){K.error(`localStorage error: `+e)},Wt(e){try{return R?.localStorage.getItem(e)}catch(e){Z.Ut(e)}return null},Gt(e){try{return JSON.parse(Z.Wt(e))||{}}catch{}return null},Xt(e,t){try{R?.localStorage.setItem(e,JSON.stringify(t))}catch(e){Z.Ut(e)}},Jt(e){try{R?.localStorage.removeItem(e)}catch(e){Z.Ut(e)}}},Qd=[Bu,`distinct_id`,$u,ed,_d,gd,dd],$d={},ef={Yt:()=>!0,Ut(e){K.error(`memoryStorage error: `+e)},Wt:e=>$d[e]||null,Gt:e=>$d[e]||null,Xt(e,t){$d[e]=t},Jt(e){delete $d[e]}},tf=null,nf={Yt(){if(!$c(tf))return tf;if(tf=!0,W(R))tf=!1;else try{var e=`__support__`;nf.Xt(e,`xyz`),nf.Wt(e)!==`"xyz"`&&(tf=!1),nf.Jt(e)}catch{tf=!1}return tf},Ut(e){K.error(`sessionStorage error: `,e)},Wt(e){try{return R?.sessionStorage.getItem(e)}catch(e){nf.Ut(e)}return null},Gt(e){try{return JSON.parse(nf.Wt(e))||null}catch{}return null},Xt(e,t){try{R?.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){nf.Ut(e)}},Jt(e){try{R?.sessionStorage.removeItem(e)}catch(e){nf.Ut(e)}}},rf=class{constructor(e){this._instance=e}get Rt(){return this._instance.config}get consent(){return this.Kt()?0:this.Qt}isOptedOut(){return this.Rt.cookieless_mode===Cd||this.consent===0||this.consent===-1&&(this.Rt.opt_out_capturing_by_default||this.Rt.cookieless_mode===Sd)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.tr.Xt(this.er,+!!e,this.Rt.cookie_expiration,this.Rt.cross_subdomain_cookie,this.Rt.secure_cookie)}reset(){this.tr.Jt(this.er,this.Rt.cross_subdomain_cookie)}get er(){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 Qt(){var e=this.tr.Wt(this.er);return ll(e)?1:H(ul,e)?0:-1}get tr(){if(!this.rr){var e=this.Rt.opt_out_capturing_persistence_type;this.rr=e===`localStorage`?Z:Xd;var t=e===`localStorage`?Xd:Z;t.Wt(this.er)&&(this.rr.Wt(this.er)||this.optInOut(ll(t.Wt(this.er))),t.Jt(this.er,this.Rt.cross_subdomain_cookie))}return this.rr}Kt(){return!!this.Rt.respect_dnt&&[Dc?.doNotTrack,Dc?.msDoNotTrack,B.doNotTrack].some((e=>ll(e)))}},af=q(`[Dead Clicks]`),of=()=>!0,sf=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Yu)),r=e.instance.config.capture_dead_clicks;return nl(r)?r:!!Yc(r)||n},cf=class{get lazyLoadedDeadClicksAutocapture(){return this.ir}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({[Yu]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.nr((()=>{this.sr()})):this.stop()}nr(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?af.error(`failed to load script`,t):e()}))}sr(){var e;if(z){if(!this.ir&&(e=B.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Yc(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.ir=B.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ir.start(z),af.info(`starting...`)}}else af.error("`document` not found. Cannot start.")}stop(){this.ir&&(this.ir.stop(),this.ir=void 0,af.info(`stopping...`))}},lf=q(`[SegmentIntegration]`),uf=`posthog-js`;function df(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=>V({},e,{stacktrace:e.stacktrace?V({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>V({},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 ff=class{constructor(e,t,n,r,i,a){this.name=uf,this.setupOnce=function(o){o(df(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},pf=class{constructor(e){this.ar=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(K.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.lr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.ur()}ur(){this.hr=this._instance.sessionManager?.onSessionId(this.ar)}destroy(){var e;(e=this.hr)==null||e.call(this),this.hr=void 0}doPageView(e,t){var n=this.cr(e,t);return this.lr={pathname:R?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.cr(e,this.lr?.pageViewId)}doEvent(){return{$pageview_id:this.lr?.pageViewId}}cr(e,t){var n=this.lr;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(!(W(a)||W(o)||W(s)||W(c)||W(l)||W(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?dl(o/a,0,1,K):1,f=a>1?dl(s/a,0,1,K):1,p=c>1?dl(l/c,0,1,K):1,m=c>1?dl(u/c,0,1,K):1;r=Y(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}},mf=e=>{var t=z?.createElement(`a`);return W(t)?null:(t.href=e,t)},hf=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(!U(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{K.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},gf=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(`=`);U(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},_f=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},vf=`https?://(.*)`,yf=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],bf=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...yf],xf=`<masked>`,Sf=[`li_fat_id`];function Cf(e,t,n){if(!z)return{};var r,i=t?[...yf,...n||[]]:[],a=wf(gf(z.URL,i,xf),e);return Y((r={},J(Sf,(function(e){var t=Xd.Wt(e);r[e]=t||null})),r),a)}function wf(e,t){var n=bf.concat(t||[]),r={};return J(n,(function(t){r[t]=hf(e,t)||null})),r}function Tf(e){var t=function(e){return e?e.search(vf+`google.([^/?]*)`)===0?`google`:e.search(vf+`bing.com`)===0?`bing`:e.search(vf+`yahoo.com`)===0?`yahoo`:e.search(vf+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!$c(t)){r.$search_engine=t;var i=z?hf(z.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function Ef(){return navigator.language||navigator.userLanguage}var Df=`$direct`;function Of(){return z?.referrer||Df}function kf(e,t){var n=e?[...yf,...t||[]]:[],r=Oc?.href.substring(0,1e3);return{r:Of().substring(0,1e3),u:r?gf(r,n,xf):void 0}}function Af(e){var{r:t,u:n}=e,r={$referrer:t,$referring_domain:t==null?void 0:t==Df?Df:mf(t)?.host};if(n){r.$current_url=n;var i=mf(n);r.$host=i?.host,r.$pathname=i?.pathname,Y(r,wf(n))}return t&&Y(r,Tf(t)),r}function jf(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Mf(){try{return new Date().getTimezoneOffset()}catch{return}}var Nf=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Pf=class{constructor(e,t){this.Rt=e,this.props={},this.dr=!1,this.vr=(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.tr=this.pr(e),this.load(),e.debug&&K.info(`Persistence loaded`,e.persistence,V({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.gr}pr(e){Nf.indexOf(e.persistence.toLowerCase())===-1&&(K.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=[...Qd,...e];return V({},Z,{Gt(e){try{var t={};try{t=Xd.Gt(e)||{}}catch{}var n=Y(t,JSON.parse(Z.Wt(e)||`{}`));return Z.Xt(e,n),n}catch{}return null},Xt(e,n,r,i,a,o){try{Z.Xt(e,n,void 0,void 0,o);var s={};t.forEach((e=>{n[e]&&(s[e]=n[e])})),Object.keys(s).length&&Xd.Xt(e,s,r,i,a,o)}catch(e){Z.Ut(e)}},Jt(e,t){try{R?.localStorage.removeItem(e),Xd.Jt(e,t)}catch(e){Z.Ut(e)}}})}(e.cookie_persisted_properties||[]),n=e.persistence.toLowerCase();return n===`localstorage`&&Z.Yt()?Z:n===`localstorage+cookie`&&t.Yt()?t:n===`sessionstorage`&&nf.Yt()?nf:n===`memory`?ef:n===`cookie`?Xd:t.Yt()?t:Xd}mr(e){var t=e??this.Rt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[ud];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return J(this.props,((t,n)=>{if(n===td&&Yc(t)){if(!this.mr())for(var r=Object.keys(t),i=0;r.length>i;i++)e[`$feature/`+r[i]]=t[r[i]]}else bd.indexOf(n)===-1&&(e[n]=t)})),e}load(){if(!this.gr){var e=this.tr.Gt(this.vr);e&&(this.props=Y({},e))}}save(){this.gr||this.tr.Xt(this.vr,this.props,this.yr,this.br,this.wr,this.Rt.debug)}remove(){this.tr.Jt(this.vr,!1),this.tr.Jt(this.vr,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(Yc(e)){W(t)&&(t=`None`),this.yr=W(n)?this._r:n;var r=!1;if(J(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.props[n]=e,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(Yc(e)){this.yr=W(t)?this._r:t;var n=!1;if(J(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.dr){var e=Cf(this.Rt.custom_campaign_params,this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties);Xc(Ld(e))||this.register(e),this.dr=!0}}update_search_keyword(){var e;this.register((e=z?.referrer)?Tf(e):{})}update_referrer_info(){this.register_once({$referrer:Of(),$referring_domain:z!=null&&z.referrer&&mf(z.referrer)?.host||Df},void 0)}set_initial_person_info(){this.props[md]||this.props[hd]||this.register_once({[gd]:kf(this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};J([hd,md],(t=>{var n=this.props[t];n&&J(n,(function(t,n){e[`$initial_`+Wc(n)]=t}))}));var t,n,r=this.props[gd];return r&&Y(e,(t=Af(r),n={},J(t,(function(e,t){n[`$initial_`+Wc(t)]=e})),n)),e}safe_merge(e){return J(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){if(this._r=this.yr=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.pr(e),i=this.props;this.clear(),this.tr=r,this.props=i,this.save()}}set_disabled(e){this.gr=e,this.gr?this.remove():this.save()}set_cross_subdomain(e){e!==this.br&&(this.br=e,this.remove(),this.save())}set_secure(e){e!==this.wr&&(this.wr=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[Hu]||{};n[e]=t,this.props[Hu]=n,this.save()}remove_event_timer(e){var t=(this.props[Hu]||{})[e];return W(t)||(delete this.props[Hu][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},Ff={Activation:`events`,Cancellation:`cancelEvents`},If={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},Lf={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},Rf={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`},zf={Popover:`popover`,Inline:`inline`},Bf={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`},Vf={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`},Hf=q(`[RateLimiter]`),Uf=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=>{Hf.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){Hf.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(pd)??{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(pd,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Wf=q(`[RemoteConfig]`),Gf=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=B._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ir(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Cr(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 Wf.info(`Using preloaded remote config`,this.remoteConfig),this.Sr(this.remoteConfig),void this.kr();if(this._instance.Tr())return void Wf.warn(`Remote config is disabled. Falling back to local config.`);this.Ir((e=>{if(!e)return Wf.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Cr((e=>{this.Sr(e),this.kr()}));this.Sr(e),this.kr()}))}catch(e){Wf.error(`Error loading remote config`,e)}}stop(){this.Ar&&=(clearInterval(this.Ar),void 0)}refresh(){this._instance.Tr()||z?.visibilityState===`hidden`||this._instance.reloadFeatureFlags()}kr(){if(!this.Ar){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.Ar=setInterval((()=>{this.refresh()}),e))}}Sr(e){var t;e||Wf.error(`Failed to fetch remote config from PostHog.`),this._instance.Sr(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},Kf={GZipJS:`gzip-js`,Base64:`base64`},qf=Uint8Array,Jf=Uint16Array,Yf=Uint32Array,Xf=new qf([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]),Zf=new qf([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]),Qf=new qf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$f=function(e,t){for(var n=new Jf(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Yf(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]},ep=$f(Xf,2),tp=ep[1];ep[0][28]=258,tp[258]=28;for(var np=$f(Zf,0)[1],rp=new Jf(32768),Q=0;32768>Q;++Q){var ip=(43690&Q)>>>1|(21845&Q)<<1;rp[Q]=((65280&(ip=(61680&(ip=(52428&ip)>>>2|(13107&ip)<<2))>>>4|(3855&ip)<<4))>>>8|(255&ip)<<8)>>>1}var ap=function(e,t,n){for(var r=e.length,i=0,a=new Jf(t);r>i;++i)++a[e[i]-1];var o,s=new Jf(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new Jf(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[rp[d]>>>c]=l}else for(o=new Jf(r),i=0;r>i;++i)o[i]=rp[s[e[i]-1]++]>>>15-e[i];return o},op=new qf(288);for(Q=0;144>Q;++Q)op[Q]=8;for(Q=144;256>Q;++Q)op[Q]=9;for(Q=256;280>Q;++Q)op[Q]=7;for(Q=280;288>Q;++Q)op[Q]=8;var sp=new qf(32);for(Q=0;32>Q;++Q)sp[Q]=5;var cp=ap(op,9,0),lp=ap(sp,5,0),up=function(e){return(e/8>>0)+(7&e&&1)},dp=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Jf?Jf:e instanceof Yf?Yf:qf)(n-t);return r.set(e.subarray(t,n)),r},fp=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},pp=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},mp=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 qf(0),0];if(i==1){var o=new qf(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 Jf(f+1),m=hp(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 qf(p),m]},hp=function(e,t,n){return e.s==-1?Math.max(hp(e.l,t,n+1),hp(e.r,t,n+1)):t[e.s]=n},gp=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Jf(++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]},_p=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},vp=function(e,t,n){var r=n.length,i=up(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)},yp=function(e,t,n,r,i,a,o,s,c,l,u){fp(t,u++,n),++i[256];for(var d=mp(i,15),f=d[0],p=d[1],m=mp(a,15),h=m[0],g=m[1],_=gp(f),v=_[0],ee=_[1],y=gp(h),b=y[0],te=y[1],x=new Jf(19),S=0;v.length>S;++S)x[31&v[S]]++;for(S=0;b.length>S;++S)x[31&b[S]]++;for(var ne=mp(x,7),re=ne[0],C=ne[1],w=19;w>4&&!re[Qf[w-1]];--w);var T,E,ie,D,O=l+5<<3,ae=_p(i,op)+_p(a,sp)+o,oe=_p(i,f)+_p(a,h)+o+14+3*w+_p(x,re)+(2*x[16]+3*x[17]+7*x[18]);if(ae>=O&&oe>=O)return vp(t,u,e.subarray(c,c+l));if(fp(t,u,1+(ae>oe)),u+=2,ae>oe){T=ap(f,p,0),E=f,ie=ap(h,g,0),D=h;var se=ap(re,C,0);for(fp(t,u,ee-257),fp(t,u+5,te-1),fp(t,u+10,w-4),u+=14,S=0;w>S;++S)fp(t,u+3*S,re[Qf[S]]);u+=3*w;for(var ce=[v,b],le=0;2>le;++le){var ue=ce[le];for(S=0;ue.length>S;++S)fp(t,u,se[k=31&ue[S]]),u+=re[k],k>15&&(fp(t,u,ue[S]>>>5&127),u+=ue[S]>>>12)}}else T=cp,E=op,ie=lp,D=sp;for(S=0;s>S;++S)if(r[S]>255){var k;pp(t,u,T[257+(k=r[S]>>>18&31)]),u+=E[k+257],k>7&&(fp(t,u,r[S]>>>23&31),u+=Xf[k]);var A=31&r[S];pp(t,u,ie[A]),u+=D[A],A>3&&(pp(t,u,r[S]>>>5&8191),u+=Zf[A])}else pp(t,u,T[r[S]]),u+=E[r[S]];return pp(t,u,T[256]),u+E[256]},bp=new Yf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),xp=function(){for(var e=new Yf(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Sp=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Cp(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=xp[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 qf(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=vp(c,l,e.subarray(u,d)):(c[u]=!0,l=vp(c,l,e.subarray(u,o)))}else{for(var f=bp[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new Jf(32768),_=new Jf(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 Yf(25e3),te=new Jf(288),x=new Jf(32),S=0,ne=0,re=(u=0,0),C=0,w=0;o>u;++u){var T=y(u),E=32767&u,ie=_[T];if(g[E]=ie,_[T]=E,u>=C){var D=o-u;if((S>7e3||re>24576)&&D>423){l=yp(e,c,0,b,te,x,ne,re,w,u-w,l),re=S=ne=0,w=u;for(var O=0;286>O;++O)te[O]=0;for(O=0;30>O;++O)x[O]=0}var ae=2,oe=0,se=m,ce=E-ie&32767;if(D>2&&T==y(u-ce))for(var le=Math.min(p,D)-1,ue=Math.min(32767,u),k=Math.min(258,D);ue>=ce&&--se&&E!=ie;){if(e[u+ae]==e[u+ae-ce]){for(var A=0;k>A&&e[u+A]==e[u+A-ce];++A);if(A>ae){if(ae=A,oe=ce,A>le)break;var de=Math.min(ce,A-2),fe=0;for(O=0;de>O;++O){var pe=u-ce+O+32768&32767,me=pe-g[pe]+32768&32767;me>fe&&(fe=me,ie=pe)}}}ce+=(E=ie)-(ie=g[E])+32768&32767}if(oe){b[re++]=268435456|tp[ae]<<18|np[oe];var he=31&tp[ae],ge=31&np[oe];ne+=Xf[he]+Zf[ge],++te[257+he],++x[ge],C=u+ae,++S}else b[re++]=e[u],++te[e[u]]}}l=yp(e,c,!0,b,te,x,ne,re,w,u-w,l)}return dp(s,0,r+up(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&&Sp(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),Sp(l,u-8,n.d()),Sp(l,u-4,r),l}var wp=!!Ac||!!kc,Tp=`text/plain`,Ep=function(e,t,n){n===void 0&&(n=!0);var[r,i]=e.split(`?`),a=V({},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 J(e,(function(e,t){W(e)||W(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(`&`)},Dp=(e,t)=>JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t),Op=e=>{if(e.zt)return e.zt;var{data:t,compression:n}=e;if(t){if(n===Kf.GZipJS){var r=Cp(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new qf(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 qf(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 dp(r,0,i)}(Dp(t)),{mtime:0});return{contentType:Tp,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Kf.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Dp(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(Dp(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=Dp(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},kp=function(){var e=Lc((function*(e){var t=yield function(e,t){return zc.apply(this,arguments)}(Dp(e.data),Fc.DEBUG);if(!t)return e;var n=yield t.arrayBuffer();return V({},e,{zt:{contentType:Tp,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Ap=[];kc&&Ap.push({transport:`fetch`,method(e){var{contentType:t,body:n,estimatedSize:r}=Op(e)??{},i=new Headers;J(e.headers,(function(e,t){i.append(t,e)})),t&&i.append(`Content-Type`,t);var a=e.url,o=null;if(jc){var s=new jc;o={signal:s.signal,timeout:setTimeout((()=>s.abort()),e.timeout)}}kc(a,V({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){K.error(e)}e.callback==null||e.callback(r)})))).catch((t=>{K.error(t),e.callback==null||e.callback({statusCode:0,error:t})})).finally((()=>o?clearTimeout(o.timeout):null))}}),Ac&&Ap.push({transport:`XHR`,method(e){var t=new Ac;t.open(e.method||`GET`,e.url,!0);var{contentType:n,body:r}=Op(e)??{};J(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)}}),Dc!=null&&Dc.sendBeacon&&Ap.push({transport:`sendBeacon`,method(e){var t=Ep(e.url,{beacon:`1`});try{var{contentType:n,body:r}=Op(e)??{};if(!r)return;var i=r instanceof Blob?r:new Blob([r],{type:n});Dc.sendBeacon(t,i)}catch{}}});var jp=3e3,Mp=class{constructor(e,t){this.Er=!0,this.Rr=[],this.Nr=dl(t?.flush_interval_ms||jp,250,5e3,K.createLogger(`flush interval`),jp),this.Mr=e}enqueue(e){this.Rr.push(e),this.Fr||this.Or()}unload(){this.Pr();var e=this.Rr.length>0?this.Lr():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Mr(V({},e,{transport:`sendBeacon`}))}))}enable(){this.Er=!1,this.Or()}Or(){var e=this;this.Er||(this.Fr=setTimeout((()=>{if(this.Pr(),this.Rr.length>0){var t=this.Lr(),n=function(){var n=t[r],i=new Date().getTime();n.data&&U(n.data)&&J(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.Mr(n)};for(var r in t)n()}}),this.Nr))}Pr(){clearTimeout(this.Fr),this.Fr=void 0}Lr(){var e={};return J(this.Rr,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;W(e[i])&&(e[i]=V({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Rr=[],e}},Np=[`retriesPerformedSoFar`],Pp=class{constructor(e){this.Dr=!1,this.Br=3e3,this.Rr=[],this._instance=e,this.Rr=[],this.jr=!0,!W(R)&&`onLine`in R.navigator&&(this.jr=R.navigator.onLine,this.qr=()=>{this.jr=!0,this.Zr()},this.$r=()=>{this.jr=!1},X(R,`online`,this.qr),X(R,`offline`,this.$r))}get length(){return this.Rr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=Rc(e,Np);tl(t)&&(n.url=Ep(n.url,{retry_count:t})),this._instance._send_request(V({},n,{callback:e=>{e.statusCode===200||e.statusCode>=400&&500>e.statusCode||(t??0)>=10?n.callback==null||n.callback(e):this.Hr(V({retriesPerformedSoFar:t},n))}}))}Hr(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.Rr.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),K.warn(i),this.Dr||(this.Dr=!0,this.Vr())}Vr(){if(this.zr&&clearTimeout(this.zr),this.Rr.length===0)return this.Dr=!1,void(this.zr=void 0);this.zr=setTimeout((()=>{this.jr&&this.Rr.length>0&&this.Zr(),this.Vr()}),this.Br)}Zr(){var e=Date.now(),t=[],n=this.Rr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Rr=t,n.length>0)for(var{requestOptions:r}of n)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.zr&&=(clearTimeout(this.zr),void 0),this.Dr=!1,W(R)||(this.qr&&=(R.removeEventListener(`online`,this.qr),void 0),this.$r&&=(R.removeEventListener(`offline`,this.$r),void 0)),this.Rr))try{this._instance._send_request(V({},e,{transport:`sendBeacon`}))}catch(e){K.error(e)}this.Rr=[]}},Fp=class{constructor(e){this.Yr=()=>{this.Ur||={};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.Ur.lastScrollY=Math.ceil(t),this.Ur.maxScrollY=Math.max(t,this.Ur.maxScrollY??0),this.Ur.maxScrollHeight=Math.max(n,this.Ur.maxScrollHeight??0),this.Ur.lastContentY=r,this.Ur.maxContentY=Math.max(r,this.Ur.maxContentY??0),this.Ur.maxContentHeight=Math.max(i,this.Ur.maxContentHeight??0)},this._instance=e}get Wr(){return this._instance.config.scroll_root_selector}getContext(){return this.Ur}resetContext(){var e=this.Ur;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){X(R,`scroll`,this.Yr,{capture:!0}),X(R,`scrollend`,this.Yr,{capture:!0}),X(R,`resize`,this.Yr)}scrollElement(){if(!this.Wr)return R?.document.documentElement;for(var e of U(this.Wr)?this.Wr:[this.Wr]){var t=R?.document.querySelector(e);if(t)return t}}scrollY(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollTop||0}return R&&(R.scrollY||R.pageYOffset||R.document.documentElement.scrollTop)||0}scrollX(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollLeft||0}return R&&(R.scrollX||R.pageXOffset||R.document.documentElement.scrollLeft)||0}},Ip=e=>kf(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties),Lp=class{constructor(e,t,n,r){this.Gr=e=>{var t=this.Xr();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.Jr(this._instance)};this.Kr.register({[fd]:n})}},this._instance=e,this.Qr=t,this.Kr=n,this.Jr=r||Ip,this.Qr.onSessionId(this.Gr)}Xr(){return this.Kr.props[fd]}getSetOnceProps(){var e=this.Xr()?.props;return e?`r`in e?Af(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 J(Ld(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+Wc(n)]=t})),e}},Rp=class{constructor(){this.ti={}}on(e,t){return this.ti[e]||(this.ti[e]=[]),this.ti[e].push(t),()=>{this.ti[e]=this.ti[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.ti[e]||[])n(t);for(var r of this.ti[`*`]||[])r(e,t)}},zp=q(`[SessionId]`),Bp=class{on(e,t){return this.ei.on(e,t)}constructor(e,t,n){var r;if(this.ri=[],this.ii=void 0,this.ei=new Rp,this.ni=(e,t)=>!(!tl(e)||!tl(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===Cd)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Rt=e.config,this.Kr=e.persistence,this.si=void 0,this.oi=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ai=t||Kd,this.li=n||Kd;var i=this.Rt.persistence_name||this.Rt.token;if(this._sessionTimeoutMs=1e3*dl(this.Rt.session_idle_timeout_seconds||1800,60,36e3,zp.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ui(),this.hi=`ph_`+i+`_window_id`,this.ci=`ph_`+i+`_primary_window_exists`,this.di()){var a=nf.Gt(this.hi),o=nf.Gt(this.ci);a&&!o?this.si=a:nf.Jt(this.hi),nf.Xt(this.ci,!0)}if((r=this.Rt.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Rt.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.vi(this.Rt.bootstrap.sessionID,new Date().getTime(),s)}catch(e){zp.error(`Invalid sessionID in bootstrap`,e)}this.fi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return W(this.ri)&&(this.ri=[]),this.ri.push(e),this.oi&&e(this.oi,this.si),()=>{this.ri=this.ri.filter((t=>t!==e))}}di(){return this.Rt.persistence!==`memory`&&!this.Kr.gr&&nf.Yt()}pi(e){e!==this.si&&(this.si=e,this.di()&&nf.Xt(this.hi,e))}gi(){return this.si?this.si:this.di()?nf.Gt(this.hi):null}vi(e,t,n){e===this.oi&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.oi=e,this.Kr.register({[$u]:[t,e,n]}))}mi(){var e=this.Kr.props[$u];return U(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vi(null,null,null)}destroy(){clearTimeout(this.yi),this.yi=void 0,this.ii&&R&&(R.removeEventListener(Od,this.ii,{capture:!1}),this.ii=void 0),this.ri=[]}fi(){this.ii=()=>{this.di()&&nf.Jt(this.ci)},X(R,Od,this.ii,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Rt.cookieless_mode===Cd)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),[r,i,a]=this.mi(),o=this.gi(),s=tl(a)&&Math.abs(n-a)>864e5,c=!1,l=!i,u=!l&&!e&&this.ni(n,r);l||u||s?(i=this.ai(),o=this.li(),zp.info(`new session ID generated`,{sessionId:i,windowId:o,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}}),a=n,c=!0):o||(o=this.li(),c=!0);var d=tl(r)&&e&&!s?r:n,f=tl(a)?a:new Date().getTime();return this.pi(o),this.vi(i,d,f),e||this.ui(),c&&this.ri.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}}ui(){clearTimeout(this.yi),this.yi=setTimeout((()=>{var[e]=this.mi();if(this.ni(new Date().getTime(),e)){var t=this.oi;this.resetSessionId(),this.ei.emit(`forcedIdleReset`,{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},Vp=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&Hc(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>Hc(e?.brand,t))))return!0}catch{}return!!e.webdriver},Hp=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 Up(e,t,n){return Dp({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Wp={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=>Hp(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Hp(t,e))))),icontains:(e,t)=>t.map(Gp).some((t=>e.map(Gp).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Gp).every((t=>e.map(Gp).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)))}))},Gp=e=>e.toLowerCase();function Kp(e,t){return!e||Object.entries(e).every((e=>{var[n,r]=e,i=t?.[n];if(W(i)||$c(i))return!1;var a=[String(i)],o=Wp[r.operator];return!!o&&o(r.values,a)}))}var qp=`custom`,Jp=`i.posthog.com`,Yp=class{constructor(e){this.bi={},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(`.`+Jp,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.bi[this.apiHost]||(this.bi[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`:qp),this.bi[this.apiHost]}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(this.region===qp)return this.apiHost+t;var n=Jp+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+n;case`api`:return`https://`+this.region+`.`+n}}},$=q(`[Surveys]`),Xp=`seenSurvey_`,Zp=(e,t)=>{var n=`$survey_`+t+`/`+e.id;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_`+t+`/`+e.id+`/`+e.current_iteration),n},Qp=e=>((e,t)=>{var n=``+Xp+t.id;return t.current_iteration&&t.current_iteration>0&&(n=``+Xp+t.id+`_`+t.current_iteration),n})(0,e),$p=[If.Popover,If.Widget,If.API],em={ignoreConditions:!1,ignoreDelay:!1,displayType:zf.Popover},tm=q(`[PostHog ExternalIntegrations]`),nm={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},rm=class{constructor(e){this._instance=e}nr(e,t){var n;(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return tm.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var n,i,a;!r||(n=B.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[t]||e.nr(nm[t],(()=>{var n;(n=B.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[t])==null||n.start(e._instance)})),!r&&(i=B.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[t]&&((a=B.__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)}}},im={},am=0,om=()=>{},sm=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,cm=`Surveys module not available`,lm=`sanitize_properties is deprecated. Use before_send instead`,um=`Invalid value for property_denylist config: `,dm=`posthog`,fm=!wp&&Nc?.indexOf(`MSIE`)===-1&&Nc?.indexOf(`Mozilla`)===-1,pm=e=>{var t;return V({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,token:``,autocapture:!0,cross_subdomain_cookie:zd(z?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:om,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,debug:Oc&&Zc(Oc?.search)&&Oc.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:(R==null||(t=R.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){K.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:Ed,before_send:void 0,request_queue_config:{flush_interval_ms:jp},error_tracking:{},_onCapture:om,__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))},mm=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],hm=e=>{var t={};for(var[n,r]of mm)W(e[n])||(t[r]=e[n]);var i=Y({},t,e);return U(e.property_blacklist)&&(W(e.property_denylist)?i.property_denylist=e.property_blacklist:U(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:K.error(um+e.property_denylist)),i},gm=class{constructor(){this.__forceAllowLocalhost=!1}get wi(){return this.__forceAllowLocalhost}set wi(e){K.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},_m=class e{Ii(e,t){if(e){var n=this.Ci.indexOf(e);n!==-1&&this.Ci.splice(n,1)}return this.Ci.push(t),t.initialize==null||t.initialize(),t}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 gm,this.Si=!1,this.version=Fc.LIB_VERSION,this.ki=new Rp,this.Ci=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=pm(),this.SentryIntegration=ff,this.sentryIntegration=e=>function(e,t){var n=df(e,t);return{name:uf,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.xi=!1,this.Ti=null,this.Ai=null,this.Ei=null,this.scrollManager=new Fp(this),this.pageViewManager=new pf(this),this.rateLimiter=new Uf(this),this.requestRouter=new Yp(this),this.consent=new rf(this),this.externalIntegrations=new rm(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=Zc(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=Zc(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>K.info(`send "`+e?.event+`"`,e)))}init(t,n,r){if(r&&r!==dm){var i=im[r]??new e;return i._init(t,n,r),im[r]=i,im[dm][r]=i,i}return this._init(t,n,r)}_init(e,t,n){if(t===void 0&&(t={}),W(e)||Qc(e))return K.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.Ri(t.debug),this.Ni=t,this.Mi=[],t.person_profiles?this.Ai=t.person_profiles:t.process_person&&(this.Ai=t.process_person),this.set_config(Y({},pm(t.defaults),hm(t),{name:n,token:e})),this.config.on_xhr_error&&K.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:Kf.GZipJS;var r=this.Fi();this.persistence=new Pf(this.config,r),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Pf(V({},this.config,{persistence:`sessionStorage`}),r);var i=V({},this.persistence.props),a=V({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Oi=new Mp((e=>this.Pi(e)),this.config.request_queue_config),this.Li=new Pp(this),this.__request_queue=[];var o=this.config.cookieless_mode===Cd||this.config.cookieless_mode===Sd&&this.consent.isExplicitlyOptedOut();if(o||(this.sessionManager=new Bp(this),this.sessionPropsManager=new Lp(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(K.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.Di(o)}),0)):(K.info(`Initializing extensions synchronously`),this.Di(o)),Fc.DEBUG=Fc.DEBUG||this.config.debug,Fc.DEBUG&&K.info(`Starting in debug mode`,{this:this,config:t,thisC:V({},this.config),p:i,s:a}),t.bootstrap?.distinctID!==void 0){var s=t.bootstrap.distinctID,c=this.get_distinct_id(),l=this.persistence.get_property(dd);if(t.bootstrap.isIdentifiedID&&c!=null&&c!==s&&l===wd)this.identify(s);else if(t.bootstrap.isIdentifiedID&&c!=null&&c!==s&&l===Td)K.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 u=this.config.get_device_id(Kd()),d=t.bootstrap.isIdentifiedID?u:s;this.persistence.set_property(dd,t.bootstrap.isIdentifiedID?Td:wd),this.register({distinct_id:s,$device_id:d})}}if(o)this.register_once({distinct_id:yd,$device_id:null},``);else if(!this.get_distinct_id()){var f=this.config.get_device_id(Kd());this.register_once({distinct_id:f,$device_id:f},``),this.persistence.set_property(dd,wd)}return X(R,`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()||Kd();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(dd,Td)),t()},i=n.user();`then`in i&&Jc(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{Promise&&Promise.resolve||lf.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()||(lf.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(lf.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,kd),identify:e=>t(e,jd),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.Bi())):this.Bi(),Jc(this.config._onCapture)&&this.config._onCapture!==om&&(K.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&K.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}Di(t){var n=performance.now(),r=V({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Ci.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Ci.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Ci.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Ci.push(new r.tracingHeaders(this)),r.siteApps&&this.Ci.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Ci.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Ci.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Ci.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Ci.push(this.logs=this.logs??new r.logs(this)),r.conversations&&this.Ci.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Ci.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Ci.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Ci.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Ci.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Ci.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,sf)),r.toolbar&&this.Ci.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Ci.push(this.experiments=this.experiments??new r.experiments(this)),this.Ci.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.ji){var e=this.ji;this.ji=void 0,this.Sr(e)}})),this.qi(i,n)}qi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.qi(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){K.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&K.info(`PostHog extensions initialized (`+r+`ms)`)}Sr(e){var t;if(!z||!z.body)return K.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Sr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ji=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=H(e.supportedCompression,Kf.GZipJS)?Kf.GZipJS:H(e.supportedCompression,Kf.Base64)?Kf.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ai?this.Ai:Ed}),this.Ci.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}Bi(){try{this.config.loaded(this)}catch(e){K.critical("`loaded` function failed",e)}if(this.Zi(),this.config.internal_or_test_user_hostname&&Oc!=null&&Oc.hostname){var e=Oc.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.config.cookieless_mode===Cd)&&this.$i()}),1),this.Hi=new Gf(this),this.Hi.load()}Zi(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Oi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Nd(this.__request_queue,(e=>this.Pi(e))),this.__request_queue=[],this.Zi()}_handle_unload(){var e,t,n;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Vi()&&this.capture(Ad),(t=this.Oi)==null||t.unload(),(n=this.Li)==null||n.unload()):this.Vi()&&this.capture(Ad,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded&&(fm?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ep(e.url,{ip:+!!this.config.ip}),e.headers=V({},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=V({},e);t.timeout=t.timeout||6e4,t.url=Ep(t.url,{_:new Date().getTime().toString(),ver:Fc.JS_SDK_VERSION,compression:t.compression});var n=t.transport??`fetch`,r=Ap.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===Kf.GZipJS&&Mc?kp(t).then((e=>{i(e)})).catch((()=>{i(t)})):i(t)})(V({},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)}}))))}Pi(e){this.Li?this.Li.retriableRequest(e):this._send_request(e)}_execute_array(e){am++;try{var t,n=[],r=[],i=[];Nd(e,(e=>{e&&(U(t=e[0])?i.push(e):Jc(e)?e.call(this):U(e)&&t===`alias`?n.push(e):U(e)&&t.indexOf(`capture`)!==-1&&Jc(this[t])?i.push(e):r.push(e))}));var a=function(e,t){Nd(e,(function(e){if(U(e[0])){var n=t;J(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{am--}}push(t){if(am>0&&U(t)&&Zc(t[0])){var n=e.prototype[t[0]];Jc(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.Oi){if(this.is_capturing())if(!W(e)&&Zc(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&&!Zc(t?.$current_url)&&(K.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.zi||K.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=Kd(),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===kd&&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=this.Yi(n?.$set_once,e!==Md,e===jd);if(m&&(f.$set_once=m),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>Zc(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),U(t)?(r=[],Nd(t,(t=>{r.push(e(t))}))):(r={},J(t,((t,n)=>{o.has(t)||(r[n]=e(t,n))}))),r):a?a(t):t;var r}(i)),f.timestamp=u,W(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),e===Lf.DISMISSED||e===Lf.SENT){var h=t?.[Rf.SURVEY_ID],g=t?.[Rf.SURVEY_ITERATION];p={id:h,current_iteration:g},localStorage.getItem(Qp(p))||localStorage.setItem(Qp(p),`true`),f.$set=V({},f.$set,{[Zp({id:h,current_iteration:g},e===Lf.SENT?`responded`:`dismissed`)]:!0})}else e===Lf.SHOWN&&(f.$set=V({},f.$set,{[Rf.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Bf.SHOWN){var _=t?.[Vf.TOUR_TYPE];_&&(f.$set=V({},f.$set,{[Vf.TOUR_LAST_SEEN_DATE+`/`+_]:new Date().toISOString()}))}var v=V({},f.properties.$set,f.$set);if(Xc(v)||this.setPersonPropertiesForFlags(v),!G(this.config.before_send)){var ee=this.Ui(f);if(!ee)return;f=ee}this.ki.emit(`eventCaptured`,f);var y={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.Pi(y):this.Oi.enqueue(y),f}K.critical(`This capture call is ignored due to client rate limiting.`)}}else K.error(`No event name provided to posthog.capture`)}else K.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=V({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,(this.config.cookieless_mode==Cd||this.config.cookieless_mode==Sd&&this.consent.isExplicitlyOptedOut())&&(o.$cookieless_mode=!0),e===`$snapshot`){var s=V({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=s.distinct_id,(!Zc(o.distinct_id)&&!el(o.distinct_id)||Qc(o.distinct_id))&&K.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(!Nc)return{};var a,o,s,c,l=e?[...yf,...t||[]]:[],[u,d]=function(e){for(var t=0;lu.length>t;t++){var[n,r]=lu[t],i=n.exec(e),a=i&&(Jc(r)?r(i,e):r);if(a)return a}return[``,``]}(Nc);return Y(Ld({$os:u,$os_version:d,$browser:ou(Nc,navigator.vendor),$device:uu(Nc),$device_type:(o=Nc,s={userAgentDataPlatform:(n=navigator)==null||(n=n.userAgentData)==null?void 0:n.platform,maxTouchPoints:navigator?.maxTouchPoints,screenWidth:R==null||(r=R.screen)==null?void 0:r.width,screenHeight:R==null||(i=R.screen)==null?void 0:i.height,devicePixelRatio:R?.devicePixelRatio},c=uu(o),c===xl||c===bl||c===`Kobo`||c===`Kindle Fire`||c===Zl?yl:c===Bl||c===Hl||c===Vl||c===Jl?`Console`:c===Cl?`Wearable`:c?gl:s?.userAgentDataPlatform===`Android`&&(s?.maxTouchPoints??0)>0?600>Math.min(s?.screenWidth??0,s?.screenHeight??0)/(s?.devicePixelRatio??1)?gl:yl:`Desktop`),$timezone:jf(),$timezone_offset:Mf()}),{$current_url:gf(Oc?.href,l,xf),$host:Oc?.host,$pathname:Oc?.pathname,$raw_user_agent:Nc.length>1e3?Nc.substring(0,997)+`...`:Nc,$browser_version:cu(Nc,navigator.vendor),$browser_language:Ef(),$browser_language_prefix:(a=Ef(),typeof a==`string`?a.split(`-`)[0]:void 0),$screen_height:R?.screen.height,$screen_width:R?.screen.width,$viewport_height:R?.innerHeight,$viewport_width:R?.innerWidth,$lib:Fc.LIB_NAME,$lib_version:Fc.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&&Y(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&Y(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.Li?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===qp&&(o.$lib_custom_api_host=this.config.api_host),c=e!==kd||i?e!==Ad||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=Y(o,c),e===kd&&z&&(o.title=z.title),!W(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}Nc&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`),(o=Y({},l,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),U(this.config.property_denylist)?J(this.config.property_denylist,(function(e){delete o[e]})):K.error(um+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(K.error(lm),o=p(o,e));var m=this.Wi();return o.$process_person_profile=m,m&&!i&&this.Gi(`_calculate_event_properties`),o}Yi(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.Wi()||this.Si&&!n)return e;var r=Y({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(K.error(lm),r=i(r,`$set_once`)),t&&(this.Si=!0),Xc(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)}Xi(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.ki.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:cm}),()=>{})}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:cm})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:cm})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=em),(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:cm}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:cm})}Ji(e){return!e||Qc(e)?(K.critical(`Unique user id has not been set in posthog.identify`),!1):e===yd?(K.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())||(K.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 K.uninitializedWarning(`posthog.identify`);if(el(e)&&(e=e.toString(),K.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.Ji(e)&&this.Gi(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Bu)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Vu)&&(this.unregister(Vu),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(dd)||wd)===wd;e!==r&&a?(this.persistence.set_property(dd,Td),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(jd,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.Ei=Up(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister(sd))}}setPersonProperties(e,t){if((e||t)&&this.Gi(`posthog.setPersonProperties`)){var n=Up(this.get_distinct_id(),e,t);this.Ei===n?K.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.Ei=n)}}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:V({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(Md,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else K.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.Gi(`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;if(K.info(`reset`),!this.__loaded)return K.uninitializedWarning(`posthog.reset`);var c=this.get_property(Bu);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),(r=this.surveys)==null||r.reset(),(i=this.Hi)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.persistence)==null||o.set_property(dd,wd),(s=this.sessionManager)==null||s.resetSessionId(),this.Ei=null,this.config.cookieless_mode===Cd)this.register_once({distinct_id:yd,$device_id:null},``);else{var l=this.config.get_device_id(Kd());this.register_once({distinct_id:l,$device_id:e?l:c},``)}this.register({$last_posthog_reset:new Date().toISOString()},1),this.reloadFeatureFlags()}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(zu)?(K.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.Gi(`posthog.alias`)?(W(t)&&(t=this.get_distinct_id()),e===t?(K.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.Xi(Vu,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=V({},this.config);if(Yc(e)){var n,r,i,a,o,s,c,l,u;Y(this.config,hm(e));var d=this.Fi();(n=this.persistence)==null||n.update_config(this.config,t,d),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Pf(V({},this.config,{persistence:`sessionStorage`}),d);var f=this.Ri(this.config.debug);nl(f)&&(this.config.debug=f),nl(this.config.debug)&&(this.config.debug?(Fc.DEBUG=!0,Z.Yt()&&Z.Xt(`ph_debug`,!0),K.info(`set_config`,{config:e,oldConfig:t,newConfig:V({},this.config)})):(Fc.DEBUG=!1,Z.Yt()&&Z.Jt(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),(s=this.exceptionObserver)==null||s.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(l=this.surveys)==null||l.loadIfEnabled(),this.Ki(),(u=this.externalIntegrations)==null||u.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Fc.LIB_NAME=e,Fc.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(V({},r,t))}}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??dm;return e!==dm&&(e=dm+`.`+e),e}_isIdentified(){return this.persistence?.get_property(dd)===Td||this.sessionPersistence?.get_property(dd)===Td}Wi(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===Ed&&!this._isIdentified()&&Xc(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Vu])&&((t=this.persistence)==null||(t=t.props)==null||!t[_d]))}Vi(){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.Wi()||this.Gi(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Gi(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}Gi(e){return this.config.person_profiles===`never`?(K.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.Xi(_d,!0),!0)}Fi(){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!==Sd)}Ki(){var e,t,n=this.Fi();return this.persistence?.gr!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.gr!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==Cd){if(this.config.cookieless_mode===Sd&&this.consent.isExplicitlyOptedOut()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Bp(this),this.pageViewManager=new pf(this),this.persistence&&(this.sessionPropsManager=new Lp(this,this.sessionManager,this.persistence));var a=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;a&&(this.sessionRecording=this.Ii(this.sessionRecording,new a(this)))}var o;this.consent.optInOut(!0),this.Ki(),this.Zi(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Sd&&((o=this.surveys)==null||o.loadIfEnabled()),(W(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.$i()}else K.warn(sm)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===Cd?K.warn(sm):(this.config.cookieless_mode===Sd&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Ki(),this.config.cookieless_mode===Sd&&(this.register({distinct_id:yd,$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.$i()))}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===Cd||(this.config.cookieless_mode===Sd?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Ki()}_is_bot(){return Dc?Vp(Dc,this.config.custom_blocked_useragents):void 0}$i(){z&&(z.visibilityState===`visible`?this.xi||(this.xi=!0,this.capture(kd,{title:z.title},{send_instantly:!0}),this.Ti&&=(z.removeEventListener(Dd,this.Ti),null)):this.Ti||(this.Ti=this.$i.bind(this),X(z,Dd,this.Ti)))}debug(e){!1===e?(R?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(R?.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}))}Tr(){var e,t,n,r,i,a,o=this.Ni||{};return`advanced_disable_flags`in o?!!o.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(K.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=K,i=(t=`advanced_disable_flags`)in(e=o)&&!G(e[t]),a=n in e&&!G(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}Ui(e){if(G(this.config.before_send))return e;var t=U(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var r of t){if(n=r(n),G(n)){var i=`Event '`+e.event+`' was rejected in beforeSend function`;return il(e.event)?K.warn(i+`. This can cause unexpected behavior.`):K.info(i),null}n.properties&&!Xc(n.properties)||K.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}return n}getPageViewId(){return this.pageViewManager.lr?.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)})}Ri(e){var t=nl(e)&&!e,n=Z.Yt()&&Z.Wt(`ph_debug`)===`true`;return!t&&(!!n||e)}};function vm(e){return e instanceof Element&&(e.id===vd||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function ym(e){return!!e&&e.nodeType===1}function bm(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function xm(e){return!!e&&e.nodeType===3}function Sm(e){return!!e&&e.nodeType===11}function Cm(e){return e?Uc(e).split(/\s+/):[]}function wm(e){var t=R?.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Tm(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 Cm(t)}function Em(e){return G(e)?null:Uc(e).split(/(\s+)/).filter((e=>Wm(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Dm(e){var t=``;return Im(e)&&!Lm(e)&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){xm(e)&&e.textContent&&(t+=Em(e.textContent)??``)})),Uc(t)}function Om(e){return W(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}_m.__defaultExtensionClasses={},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=Id(e.prototype[t[n]])}(_m,[`identify`]);var km=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Am(e,t){if(W(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 jm(e){var t=e.parentNode;return!(!t||!ym(t))&&t}var Mm=[`next`,`previous`,`prev`,`>`,`<`],Nm=[`.ph-no-rageclick`,`.ph-no-capture`],Pm=e=>!e||bm(e,`html`)||!ym(e),Fm=(e,t)=>{if(!R||Pm(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!bm(i,`body`);)if(Sm(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=jm(i);if(!a)break;if(t||km.indexOf(a.tagName.toLowerCase())>-1)n=!0;else{var o=R.getComputedStyle(a);o&&o.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}r.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:r}};function Im(e){for(var t=e;t.parentNode&&!bm(t,`body`);t=t.parentNode){var n=Tm(t);if(H(n,`ph-sensitive`)||H(n,`ph-no-capture`))return!1}if(H(Tm(e),`ph-include`))return!0;var r=e.type||``;if(Zc(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}var i=e.name||e.id||``;return!Zc(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 Lm(e){return!!(bm(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||bm(e,`select`)||bm(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var Rm=`(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})`,zm=RegExp(`^(?:`+Rm+`)$`),Bm=new RegExp(Rm),Vm=`\\d{3}-?\\d{2}-?\\d{4}`,Hm=RegExp(`^(`+Vm+`)$`),Um=RegExp(`(`+Vm+`)`);function Wm(e,t){return t===void 0&&(t=!0),!(G(e)||Zc(e)&&(e=Uc(e),(t?zm:Bm).test((e||``).replace(/[- ]/g,``))||(t?Hm:Um).test(e)))}function Gm(e){var t=Dm(e);return Wm(t=(t+` `+Km(e)).trim())?t:``}function Km(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=Dm(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+Km(e)).trim())}catch(e){K.error(`[AutoCapture]`,e)}})),t}function qm(e){return e.replace(/"|\\"/g,`\\"`)}function Jm(e){var t=e.attr__class;return t?U(t)?t:Cm(t):void 0}var Ym=class{constructor(e){this.disabled=!1===e;var t=Yc(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}},Xm=`$copy_autocapture`,Zm=q(`[AutoCapture]`);function Qm(e,t){return t.length>e?t.slice(0,e)+`...`:t}function $m(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!ym(t));return t}function eh(e,t){for(var n,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:s}=t,c=[e],l=e;l.parentNode&&!bm(l,`body`);)Sm(l.parentNode)?(c.push(l.parentNode.host),l=l.parentNode.host):(c.push(l.parentNode),l=l.parentNode);var u,d,f=[],p={},m=!1,h=!1;if(J(c,(e=>{var t=Im(e);e.tagName.toLowerCase()===`a`&&(m=e.getAttribute(`href`),m=t&&m&&Wm(m)&&m),H(Tm(e),`ph-no-capture`)&&(h=!0),f.push(function(e,t,n,r){var i=e.tagName.toLowerCase(),a={tag_name:i};km.indexOf(i)>-1&&!n&&(a.$el_text=i.toLowerCase()===`a`||i.toLowerCase()===`button`?Qm(1024,Gm(e)):Qm(1024,Dm(e)));var o=Tm(e);o.length>0&&(a.classes=o.filter((function(e){return e!==``}))),J(e.attributes,(function(n){var i;if((!Lm(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&Wm(n.value)&&(!Zc(i=n.name)||i.substring(0,10)!==`_ngcontent`&&i.substring(0,7)!==`_nghost`)){var o=n.value;n.name===`class`&&(o=Cm(o).join(` `)),a[`attr__`+n.name]=Qm(1024,o)}}));for(var s=1,c=1,l=e;l=$m(l);)s++,l.tagName===e.tagName&&c++;return a.nth_child=s,a.nth_of_type=c,a}(e,i,a,o)),Y(p,function(e){if(!Im(e))return{};var t={};return J(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&&Wm(r)&&(t[n]=r)}})),t}(e))})),h)return{props:{},explicitNoCapture:h};if(a||(f[0].$el_text=e.tagName.toLowerCase()===`a`||e.tagName.toLowerCase()===`button`?Gm(e):Dm(e)),m){var g;f[0].attr__href=m;var _=mf(m)?.host,v=R==null||(g=R.location)==null?void 0:g.host;_&&v&&_!==v&&(u=m)}return{props:Y({$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=V({},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 Pd(r).sort(((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)})).forEach((e=>{var[t,n]=e;return i[qm(t.toString())]=qm(n.toString())})),(t+=`:`)+Pd(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:Jm(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Pd(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 th=q(`[ExceptionAutocapture]`);function nh(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return Jc(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var rh=q(`[TracingHeaders]`),ih=q(`[Web Vitals]`),ah=9e5,oh=`disabled`,sh=`lazy_loading`,ch=`awaiting_config`,lh=`missing_config`;q(`[SessionRecording]`);var uh=`[SessionRecording]`,dh=q(uh),fh=q(`[Heatmaps]`);function ph(e){return Yc(e)&&`clientX`in e&&`clientY`in e&&el(e.clientX)&&el(e.clientY)}var mh=q(`[Product Tours]`),hh=`ph_product_tours`,gh=[`$set_once`,`$set`],_h=q(`[SiteApps]`),vh=`Error while initializing PostHog app with config id `;function yh(e,t,n){if(G(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 bh=class{constructor(e){this.Qi=new Rp,this.tn=(e,t)=>this.en(e,t)&&this.rn(e,t)&&this.nn(e,t)&&this.sn(e,t),this.en=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.an=new Set,this.ln=new Set}init(){var e;W(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!W(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.ln)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.an)==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.an.has(e)||this.an.has(t?.event))&&this.ln&&this.ln?.size>0&&this.ln.forEach((e=>{this.un(t,e)&&this.Qi.emit(`actionCaptured`,e.name)}))}hn(e){this.onAction(`actionCaptured`,(t=>e(t)))}un(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.tn(e,n))return!0;return!1}onAction(e,t){return this.Qi.on(e,t)}rn(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`||!yh(r,t.url,t.url_matching||`contains`))return!1}return!0}nn(e,t){return!!this.cn(e,t)&&!!this.dn(e,t)&&!!this.vn(e,t)}cn(e,t){var n;if(t==null||!t.href)return!0;var r=this.fn(e);if(r.length>0)return r.some((e=>yh(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&yh((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}dn(e,t){var n;if(t==null||!t.text)return!0;var r=this.fn(e);if(r.length>0)return r.some((e=>yh(e.text,t.text,t.text_matching||`exact`)||yh(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;!G(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=>yh(e,a,o))))}vn(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}fn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}sn(e,t){return t==null||!t.properties||t.properties.length===0||Kp(t.properties.reduce(((e,t)=>{var n=U(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)}},xh=class{constructor(e){this._instance=e,this.pn=new Map,this.gn=new Map,this.mn=new Map}yn(e,t){return!!e&&Kp(e.propertyFilters,t?.properties)}bn(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}wn(e,t,n){var r=(n===Ff.Activation?this.pn:this.gn).get(e),i=[];return this._n((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.yn(a,t)}))}register(e){W(this._instance?._addCaptureHook)||(this.In(e),this.Cn(e))}Cn(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.Sn??(this.Sn=new bh(this._instance),this.Sn.init(),this.Sn.hn((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.Sn)==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.mn.get(t.name);n&&n.push(e.id),this.mn.set(t.name,n||[e.id])}})))})))}In(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.pn=this.bn(e,Ff.Activation),this.gn=this.bn(e,Ff.Cancellation))}onEvent(e,t){var n,r=this.re(),i=this.kn(),a=this.xn(),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.Tn(o))}}else{if(this.gn.has(e)){var d=this.wn(e,t,Ff.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.An(e.id)})),this.Tn(o))}if(this.pn.has(e)){r.info(`event name matched`,{event:e,eventPayload:t,items:this.pn.get(e)});var f=this.wn(e,t,Ff.Activation);this.Tn(o.concat(f.map((e=>e.id))||[]))}}}onAction(e){var t,n=this.kn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[];this.mn.has(e)&&this.Tn(r.concat(this.mn.get(e)||[]))}Tn(e){var t,n=this.re(),r=this.kn(),i=[...new Set(e)].filter((e=>!this.En(e)));n.info(`updating activated items`,{activatedItems:i}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:i})}getActivatedIds(){var e,t=this.kn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.pn}Rn(){return this.Sn}},Sh=class extends xh{constructor(e){super(e)}kn(){return`$surveys_activated`}xn(){return Lf.SHOWN}_n(e){var t;(t=this._instance)==null||t.getSurveys(e)}An(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}re(){return $}En(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Ch=`SDK is not enabled or survey functionality is not yet loaded`,wh=`Disabled. Not loading surveys.`,Th=R!=null&&R.location?_f(R.location.hash,`__posthog`)||_f(location.hash,`state`):null,Eh=`_postHogToolbarParams`,Dh=q(`[Toolbar]`),Oh=q(`[FeatureFlags]`),kh=q(`[FeatureFlags]`,{debugEnabled:!0}),Ah=`" failed. Feature flags didn't load in time.`,jh=`$active_feature_flags`,Mh=`$override_feature_flags`,Nh=`$feature_flag_payloads`,Ph=`$override_feature_flag_payloads`,Fh=`$feature_flag_request_id`,Ih=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},Lh=e=>{var t={};for(var[n,r]of Pd(e||{}))r&&(t[n]=r);return t},Rh=q(`[Error tracking]`),zh=`Refusing to render web experiment since the viewer is a likely bot`,Bh={icontains:(e,t)=>!!R&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!R&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!R&&Hp(t.href,e),not_regex:(e,t)=>!!R&&!Hp(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e},Vh=class e{get Rt(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.Nn(`retrieved web experiments from the server`),n.Mn=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.Mn&&(e.Nn(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.Mn)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);Zc(i)&&t.variants[i]&&n.Fn(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.On(o)&&n.Fn(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Nn(zh);else if(!this.Rt.disable_web_experiments){if(G(this.Mn))return this.Mn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Nn(`applying feature flags`,t),t.forEach((e=>{var t;if(this.Mn&&(t=this.Mn)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.Mn?.get(e);n&&r!=null&&r.variants[n]&&this.Fn(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=hf(t?.search,`__experiment_id`),r=hf(t?.search,`__experiment_variant`);n&&r&&(e.Nn(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.Pn(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Rt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Rt.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.Rt.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Pn(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.Nn(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.Fn(i[0].name,n,i[0].variants[n].transforms))}static On(t){return!G(t.conditions)&&e.Ln(t)&&e.Dn(t)}static Ln(t){if(G(t.conditions)||G(t.conditions?.url))return!0;var n,r=e.getWindowLocation();return!!r&&((n=t.conditions)==null||!n.url||Bh[t.conditions?.urlMatchType??`icontains`](t.conditions.url,r))}static getWindowLocation(){return R?.location}static Dn(e){if(G(e.conditions)||G(e.conditions?.utm))return!0;var t=Cf();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 Nn(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];K.info(`[WebExperiments] `+e,n)}Fn(t,n,r){this._is_bot()?e.Nn(zh):n===`control`?e.Nn(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.Nn(`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 Dc&&this._instance?Vp(Dc,this.Rt.custom_blocked_useragents):void 0}},Hh=q(`[Conversations]`),Uh=`Conversations not available yet.`,Wh={featureFlags:class{constructor(e){this.Bn=!1,this.jn=!1,this.qn=!1,this.Zn=!1,this.$n=!1,this.Hn=!1,this.Vn=!1,this.zn=!1,this._instance=e,this.featureFlagEventHandlers=[]}get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}Yn(e){return this._instance.get_property(e)}Un(){var e;return(e=this.Kr?.mr(this.Rt.feature_flag_cache_ttl_ms))!=null&&e}Wn(){return!!this.Un()&&(this.zn||this.qn||(this.zn=!0,Oh.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}Gn(){var e=this.Rt.evaluation_contexts??this.Rt.evaluation_environments;return!this.Rt.evaluation_environments||this.Rt.evaluation_contexts||this.Vn||(Oh.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.Vn=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||Oh.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}Xn(){return this.Gn().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=V({},r,e),o=V({},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:W(o?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:o[c]}}}this.receivedFeatureFlags({flags:s})}get hasLoadedFlags(){return this.jn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Yn(rd),t=this.Yn(Mh),n=this.Yn(Ph);if(!n&&!t)return e||{};var r=Y({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=W(c)?(a=s?.enabled)!=null&&a:!!c,u=W(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=V({},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=V({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.Bn||=(Oh.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getFlagVariants(){var e=this.Yn(td),t=this.Yn(Mh);if(!t)return e||{};for(var n=Y({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Bn||=(Oh.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.Yn(Nh),t=this.Yn(Ph);if(!t)return e||{};for(var n=Y({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Bn||=(Oh.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.Zn||this.Rt.advanced_disable_feature_flags||this.Jn||(this._instance.ki.emit(`featureFlagsReloading`,!0),this.Jn=setTimeout((()=>{this.Kn()}),5))}Qn(){clearTimeout(this.Jn),this.Jn=void 0}ensureFlagsLoaded(){this.jn||this.qn||this.Jn||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Zn=e}Kn(e){if(this.Qn(),!this._instance.Tr())if(this.qn)this.$n=!0;else{var t=this.Rt.token,n=this.Yn(Bu),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:V({},this.Kr?.get_initial_props()||{},this.Yn(id)||{}),group_properties:this.Yn(ad),timezone:jf()};$c(n)||W(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Rt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Xn()&&(r.evaluation_contexts=this.Gn());var i=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Rt.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.Rt.disable_compression?void 0:Kf.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,a=!0;if(e.statusCode===200&&(this.$n||(this.$anon_distinct_id=void 0),a=!1),this.qn=!1,!r.disable_flags||this.$n){this.Hn=!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.Kr)==null||i.register({[ld]:o}),s?Oh.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),this.$n&&(this.$n=!1,this.Kn()))}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.Hn)if(this.jn||this.getFlags()&&this.getFlags().length>0){if(!this.Wn()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else Oh.warn(`getFeatureFlag for key "`+e+Ah)}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.Hn)if(this.jn||this.getFlags()&&this.getFlags().length>0){if(!this.Wn()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Yn(Fh)||void 0,c=this.Yn(ud)||void 0,l=this.Yn(sd)||{};if(this.Rt.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.Yn(cd);d&&d!==f&&(l={},(u=this.Kr)==null||u.register({[sd]:l,[cd]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,ee,y;U(l[e])?l[e].push(o):l[e]=[o],(p=this.Kr)==null||p.register({[sd]:l});var b=this.getFeatureFlagDetails(e),te=[...this.Yn(ld)??[]];W(i)&&te.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.Rt.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Rt.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.Hn};W(b==null||(g=b.metadata)==null?void 0:g.version)||(x.$feature_flag_version=b.metadata.version);var S,ne=(b==null||(_=b.reason)==null?void 0:_.description)??(b==null||(v=b.reason)==null?void 0:v.code);ne&&(x.$feature_flag_reason=ne),b!=null&&(ee=b.metadata)!=null&&ee.id&&(x.$feature_flag_id=b.metadata.id),W(b?.original_variant)&&W(b?.original_enabled)||(x.$feature_flag_original_response=W(b.original_variant)?b.original_enabled:b.original_variant),b!=null&&(y=b.metadata)!=null&&y.original_payload&&(x.$feature_flag_original_payload=b==null||(S=b.metadata)==null?void 0:S.original_payload),te.length&&(x.$feature_flag_error=te.join(`,`)),this._instance.capture(`$feature_flag_called`,x)}if(r){var re=a;if(!W(a))try{re=JSON.parse(a)}catch{}return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:re}}}}else Oh.warn(`getFeatureFlagResult for key "`+e+Ah)}getRemoteConfigPayload(e,t){var n=this.Rt.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.Xn()&&(r.evaluation_contexts=this.Gn()),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Rt.disable_compression?void 0:Kf.Base64,timeout:this.Rt.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.Hn){if(this.jn||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return W(n)?void 0:!!n}Oh.warn(`isFeatureEnabled for key "`+e+Ah)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this.Kr){this.jn=!0;var n=this.getFlagVariants(),r=this.getFlagPayloads(),i=this.getFlagsWithDetails();(function(e,t,n,r,i){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var a=(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])))):Oh.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),o=a.flags,s=a.featureFlags,c=a.featureFlagPayloads;if(s){var l=e.requestId,u=e.evaluatedAt;if(U(s)){Oh.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var d={};if(s)for(var f=0;s.length>f;f++)d[s[f]]=!0;t&&t.register({[jh]:s,[td]:d})}else{var p=s,m=c,h=o;if(e.errorsWhileComputingFlags)if(o){var g=new Set(Object.keys(o).filter((e=>{var t;return!((t=o[e])!=null&&t.failed)})));p=V({},n,Object.fromEntries(Object.entries(p).filter((e=>{var[t]=e;return g.has(t)})))),m=V({},r,Object.fromEntries(Object.entries(m||{}).filter((e=>{var[t]=e;return g.has(t)})))),h=V({},i,Object.fromEntries(Object.entries(h||{}).filter((e=>{var[t]=e;return g.has(t)}))))}else p=V({},n,p),m=V({},r,m),h=V({},i,h);t&&t.register(V({[jh]:Object.keys(Lh(p)),[td]:p||{},[Nh]:m||{},[rd]:h||{}},l?{[Fh]:l}:{},u?{[ud]:u}:{}))}}})(e,this.Kr,n,r,i),t||(this.zn=!1),this.ts(t)}}override(e,t){t===void 0&&(t=!1),Oh.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.Kr)return Oh.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.Kr.unregister(Mh),this.Kr.unregister(Ph),this.ts(),kh.info(`All overrides cleared`);if(U(e)){var t=Ih(e);return this.Kr.register({[Mh]:t}),this.ts(),kh.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Bn=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.Kr.unregister(Mh),kh.info(`Flag overrides cleared`);else if(r.flags){if(U(r.flags)){var i=Ih(r.flags);this.Kr.register({[Mh]:i})}else this.Kr.register({[Mh]:r.flags});kh.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.Kr.unregister(Ph),kh.info(`Payload overrides cleared`)):r.payloads&&(this.Kr.register({[Ph]:r.payloads}),kh.info(`Payload overrides set`,{payloads:r.payloads}))),this.ts();return}if(e&&typeof e==`object`)return this.Kr.register({[Mh]:e}),this.ts(),kh.info(`Flag overrides set`,{flags:e});Oh.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.jn){var{flags:t,flagVariants:n}=this.es();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.Yn(nd)||[]).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=V({},this.getFlagVariants(),{[e]:t});(r=this.Kr)==null||r.register({[jh]:Object.keys(Lh(s)),[td]:s}),this.ts()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Yn(nd),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.Rt.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.Kr)==null||n.unregister(nd),(r=this.Kr)==null||r.register({[nd]:i}),e(i)}}})}es(){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)),{})}}ts(e){var{flags:t,flagVariants:n}=this.es();this.featureFlagEventHandlers.forEach((r=>r(t,n,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Yn(id)||{},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({[id]:V({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(id)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Yn(ad)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=V({},n[t],e[t]),delete e[t]})),this._instance.register({[ad]:V({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Yn(ad)||{};this._instance.register({[ad]:V({},t,{[e]:{}})})}else this._instance.unregister(ad)}reset(){this.jn=!1,this.qn=!1,this.Zn=!1,this.$n=!1,this.Hn=!1,this.$anon_distinct_id=void 0,this.Qn(),this.Bn=!1}}},Gh={sessionRecording:class{get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}get started(){var e;return!((e=this.rs)==null||!e.isStarted)}get status(){return this.ns===ch||this.ns===lh?this.ns:this.rs?.status??this.ns}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.ns=oh,this.ss=void 0,this._instance=e,!this._instance.sessionManager)throw dh.error(`started without valid sessionManager`),Error(uh+` started without valid sessionManager. This is a bug.`);if(this.Rt.cookieless_mode===Cd)throw Error(uh+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get os(){var e,t=!((e=this._instance.get_property(Qu))==null||!e.enabled),n=!this.Rt.disable_session_recording,r=this.Rt.disable_session_recording||this._instance.consent.isOptedOut();return R&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this.os||(t=this.rs)==null||!t.isStarted){var n=!W(Object.assign)&&!W(Array.from);this.os&&n?(this.ls(e),dh.info(`starting`)):(this.ns=oh,this.stopRecording())}}ls(e){var t,n,r;this.os&&(this.ns!==ch&&this.ns!==lh&&(this.ns=sh),B!=null&&(t=B.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=B.__PosthogExtensions__)!=null&&n.initSessionRecording?this.us(e):(r=B.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.hs,(t=>{if(t)return dh.error(`could not load recorder`,t);this.us(e)})))}stopRecording(){var e,t;(e=this.ss)==null||e.call(this),this.ss=void 0,(t=this.rs)==null||t.stop()}cs(){var e,t;(e=this.ss)==null||e.call(this),this.ss=void 0,(t=this.rs)==null||t.discard()}ds(){var e;(e=this.Kr)==null||e.unregister(ed)}vs(e,t){if(G(e))return null;var n,r=el(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(dh.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}fs(e){if(this.Kr){var t,n=this.Kr,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.vs(this.Rt.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.vs(t?.sampleRate,`remote config sampleRate`),a=r??i;G(a)&&this.ds();var o=t?.minimumDurationMilliseconds;n.register({[Qu]:V({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:V({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:W(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers})})};r(),(t=this.ss)==null||t.call(this),this.ss=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this.fs(e),this.cs()):(this.fs(e),this.startIfEnabledOrStop()):(this.ns===ch&&(this.ns=lh,dh.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.rs)!=null&&n.log?this.rs.log(e,t):dh.warn(`log called before recorder was ready`)}get hs(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Qu);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}ps(){var e=this._instance.get_property(Qu);if(!e)return!1;var t=(typeof e==`object`?e:JSON.parse(e)).cache_timestamp??Date.now();return 36e5>=Date.now()-t}us(e){var t;if((t=B.__PosthogExtensions__)==null||!t.initSessionRecording)return dh.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.rs||(this.rs=B.__PosthogExtensions__?.initSessionRecording(this._instance),this.rs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ps()){if(this.ns===lh||this.ns===ch)return;this.ns=ch,dh.info(`persisted remote config is stale, requesting fresh config before starting`),new Gf(this._instance).load();return}this.ns=sh,this.rs.start(e)}onRRwebEmit(e){var t;(t=this.rs)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.rs||(t=this.Kr)==null||t.register({$replay_override_linked_flag:!0}),(e=this.rs)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.rs||(t=this.Kr)==null||t.register({$replay_override_sampling:!0}),(e=this.rs)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.rs||(n=this.Kr)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this.rs)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.rs?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.rs)==null||!n.tryAddCustomEvent(e,t))}}},Kh={autocapture:class{constructor(e){this.gs=!1,this.ys=null,this.bs=!1,this.instance=e,this.rageclicks=new Ym(e.config.rageclick),this.ws=null}initialize(){this.startIfEnabled()}get Rt(){var e=Yc(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}_s(){if(this.isBrowserSupported()){if(R&&z){var e=e=>{e||=R?.event;try{this.Is(e)}catch(e){Zm.error(`Failed to capture event`,e)}};if(X(z,`submit`,e,{capture:!0}),X(z,`change`,e,{capture:!0}),X(z,`click`,e,{capture:!0}),this.Rt.capture_copied_text){var t=e=>{this.Is(e||=R?.event,Xm)};X(z,`copy`,t,{capture:!0}),X(z,`cut`,t,{capture:!0})}}}else Zm.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.gs&&(this._s(),this.gs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.bs=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Uu]:!!e.autocapture_opt_out}),this.ys=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.ws=e}getElementSelectors(e){var t,n=[];return(t=this.ws)==null||t.forEach((t=>{(z?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[Uu];if($c(this.ys)&&!nl(e)&&!this.instance.Tr())return!1;var t=this.ys??!!e;return!!this.instance.config.autocapture&&!t}Is(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=Om(e);xm(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(!R||Pm(e))return!1;var n,r;if(nl(t)?(n=!!t&&Nm,r=void 0):(n=t?.css_selector_ignorelist??Nm,r=t?.content_ignorelist),!1===n)return!1;var{targetElementList:i}=Fm(e,!1);return!function(e,t){if(!1===e||W(e))return!1;var n;if(!0===e)n=Mm;else{if(!U(e))return!1;if(e.length>10)return K.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:Dm(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!Am(i,n)}(r,this.instance.config.rageclick)&&this.Is(e,`$rageclick`);var i=t===Xm;if(r&&function(e,t,n,r,i){var a,o,s;if(n===void 0&&(n=void 0),!R||Pm(e)||(a=n)!=null&&a.url_allowlist&&!wm(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&wm(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}=Fm(e,r);if(!function(e,t){var n=t?.element_allowlist;if(W(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)||!Am(u,n?.css_selector_allowlist))return!1;var d=R.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&&(km.indexOf(f)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.Rt,i,i?[`copy`,`cut`]:void 0)){var{props:a,explicitNoCapture:o}=eh(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Rt.element_attribute_ignorelist,elementsChainAsString:this.bs});if(o)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(a.$element_selectors=s),t===Xm){var c,l=Em(R==null||(c=R.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 Jc(z?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.Cs=(R==null||(t=R.location)==null?void 0:t.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(K.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.Ss&&this.Ss(),this.Ss=void 0,K.info(`History API monitoring stopped`)}monitorHistoryChanges(){var e,t;if(R&&R.history){var n=this;(e=R.history.pushState)!=null&&e.__posthog_wrapped__||nh(R.history,`pushState`,(e=>function(t,r,i){e.call(this,t,r,i),n.ks(`pushState`)})),(t=R.history.replaceState)!=null&&t.__posthog_wrapped__||nh(R.history,`replaceState`,(e=>function(t,r,i){e.call(this,t,r,i),n.ks(`replaceState`)})),this.xs()}}ks(e){try{var t,n=R==null||(t=R.location)==null?void 0:t.pathname;if(!n)return;n!==this.Cs&&this.isEnabled&&this._instance.capture(kd,{navigation_type:e}),this.Cs=n}catch(t){K.error(`Error capturing `+e+` pageview`,t)}}xs(){if(!this.Ss){var e=()=>{this.ks(`popstate`)};X(R,`popstate`,e),this.Ss=()=>{R&&R.removeEventListener(`popstate`,e)}}}},heatmaps:class{get Rt(){return this.instance.config}constructor(e){var t;this.Ts=!1,this.gs=!1,this.As=null,this.instance=e,this.Ts=!((t=this.instance.persistence)==null||!t.props[Wu]),this.rageclicks=new Ym(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Yc(this.Rt.capture_heatmaps)&&this.Rt.capture_heatmaps.flush_interval_milliseconds&&(e=this.Rt.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return G(this.Rt.capture_heatmaps)?G(this.Rt.enable_heatmaps)?this.Ts:this.Rt.enable_heatmaps:!1!==this.Rt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.gs)return;fh.info(`starting...`),this.Es(),this.Tt()}else clearInterval(this.As??void 0),this.Rs(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Wu]:t}),this.Ts=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.T;return this.T=void 0,e}Ns(e){this.wt(e.originalEvent,`deadclick`)}Tt(){this.As&&clearInterval(this.As),this.As=z?.visibilityState===`visible`?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Es(){R&&z&&(this.Ms=this.Zr.bind(this),X(R,Od,this.Ms),this.Fs=e=>this.wt(e||R?.event),X(z,`click`,this.Fs,{capture:!0}),this.Os=e=>this.Ps(e||R?.event),X(z,`mousemove`,this.Os,{capture:!0}),this.Ls=new cf(this.instance,of,this.Ns.bind(this)),this.Ls.startIfEnabledOrStop(),this.Ds=this.Tt.bind(this),X(z,Dd,this.Ds),this.gs=!0)}Rs(){var e;R&&z&&(this.Ms&&R.removeEventListener(Od,this.Ms),this.Fs&&z.removeEventListener(`click`,this.Fs,{capture:!0}),this.Os&&z.removeEventListener(`mousemove`,this.Os,{capture:!0}),this.Ds&&z.removeEventListener(Dd,this.Ds),clearTimeout(this.Bs),(e=this.Ls)==null||e.stop(),this.gs=!1)}js(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&&ym(r)&&!bm(r,`body`);){if(r===n)return!1;if(H(t,R?.getComputedStyle(r).position))return!0;r=jm(r)}return!1}(Om(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}wt(e,t){var n;if(t===void 0&&(t=`click`),!vm(e.target)&&ph(e)){var r=this.js(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.qs(V({},r,{type:`rageclick`})),this.qs(r)}}Ps(e){!vm(e.target)&&ph(e)&&(clearTimeout(this.Bs),this.Bs=setTimeout((()=>{this.qs(this.js(e,`mousemove`))}),500))}qs(e){if(R){var t=R.location.href,n=this.Rt.custom_personal_data_properties,r=gf(t,this.Rt.mask_personal_data_properties?[...yf,...n||[]]:[],xf);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(e)}}Zr(){this.T&&!Xc(this.T)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:cf,webVitalsAutocapture:class{constructor(e){var t;this.Ts=!1,this.gs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Zs=()=>{clearTimeout(this.$s),this.T.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.T.metrics.reduce(((e,t)=>V({},e,{[`$web_vitals_`+t.name+`_event`]:V({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.nt=e=>{var t=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0);if(W(t))ih.error(`Could not read session ID. Dropping metrics!`);else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Hs();W(n)||(G(e?.name)||G(e?.value)?ih.error(`Invalid metric received`,e):!this.Vs||this.Vs>e.value?(this.T.url!==n&&(this.Zs(),this.$s=setTimeout(this.Zs,this.flushToCaptureTimeoutMs)),W(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=W(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.T.metrics.push(V({},e,{$current_url:n,$session_id:t.sessionId,$window_id:t.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.Zs()):ih.error(`Ignoring metric with value >= `+this.Vs,e))}},this.zs=()=>{if(!this.gs){var e,t,n,r,i=B.__PosthogExtensions__;W(i)||W(i.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:n,onINP:r}=i.postHogWebVitalsCallbacks),e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.nt.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.nt.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.nt.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.nt.bind(this)),this.gs=!0):ih.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.Ts=!((t=this._instance.persistence)==null||!t.props[Ju]),this.startIfEnabled()}get Ys(){return this._instance.config.capture_performance}get allowedMetrics(){var e=Yc(this.Ys)?this.Ys?.web_vitals_allowed_metrics:void 0;return G(e)?this._instance.persistence?.props[Zu]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(Yc(this.Ys)?this.Ys.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Yc(this.Ys)?this.Ys.web_vitals_attribution:void 0;return e!=null&&e}get Vs(){var e=Yc(this.Ys)&&el(this.Ys.__web_vitals_max_value)?this.Ys.__web_vitals_max_value:ah;return e>0&&6e4>=e?ah:e}get isEnabled(){var e=Oc?.protocol;if(e!==`http:`&&e!==`https:`)return ih.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=Yc(this.Ys)?this.Ys.web_vitals:nl(this.Ys)?this.Ys:void 0;return nl(t)?t:this.Ts}startIfEnabled(){this.isEnabled&&!this.gs&&(ih.info(`enabled, starting...`),this.nr(this.zs))}onRemoteConfig(e){if(`capturePerformance`in e){var t=Yc(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=Yc(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ju]:t}),this._instance.persistence.register({[Zu]:n})),this.Ts=t,this.startIfEnabled()}}nr(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?ih.error(`failed to load script`,t):e()}))}Hs(){var e=R?R.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return gf(e,this._instance.config.mask_personal_data_properties?[...yf,...t||[]]:[],xf)}ih.error(`Could not determine current URL`)}}},qh={exceptionObserver:class{constructor(e){var t;this.zs=()=>{var e;if(R&&this.isEnabled&&(e=B.__PosthogExtensions__)!=null&&e.errorWrappingFunctions){var t=B.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=B.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=B.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Us&&this.Rt.capture_unhandled_errors&&(this.Us=t(this.captureException.bind(this))),!this.Ws&&this.Rt.capture_unhandled_rejections&&(this.Ws=n(this.captureException.bind(this))),!this.Gs&&this.Rt.capture_console_errors&&(this.Gs=r(this.captureException.bind(this)))}catch(e){th.error(`failed to start`,e),this.Xs()}}},this._instance=e,this.Js=!((t=this._instance.persistence)==null||!t.props[Gu]),this.Ks=new fl({refillRate:this._instance.config.error_tracking.__exceptionRateLimiterRefillRate??1,bucketSize:this._instance.config.error_tracking.__exceptionRateLimiterBucketSize??10,refillInterval:1e4,qt:th}),this.Rt=this.Qs(),this.startIfEnabledOrStop()}Qs(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Yc(e)?t=V({},t,e):(W(e)?this.Js:e)&&(t=V({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Rt.capture_console_errors||this.Rt.capture_unhandled_errors||this.Rt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(th.info(`enabled`),this.Xs(),this.nr(this.zs)):this.Xs()}nr(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return th.error(`failed to load script`,t);e()}))}Xs(){var e,t,n;(e=this.Us)==null||e.call(this),this.Us=void 0,(t=this.Ws)==null||t.call(this),this.Ws=void 0,(n=this.Gs)==null||n.call(this),this.Gs=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.Js=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Gu]:this.Js}),this.Rt=this.Qs(),this.startIfEnabledOrStop())}onConfigChange(){this.Rt=this.Qs()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.Ks.consumeRateLimit(r)?th.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.eo=[],this.ro=new pu([new Tu,new Fu,new Du,new Eu,new Nu,new Mu,new ku,new Pu],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(`
|
|
5
|
-
`),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=wu.test(s)?s.replace(wu,`$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 V({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||mu});var n}))}(i)}}(`web:javascript`,bu,Cu)),this._instance=e,this.eo=this._instance.persistence?.get_property(Ku)??[]}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.eo=t,this._instance.persistence&&this._instance.persistence.register({[Ku]:this.eo,[qu]:n})}}get io(){var e,t=!!this._instance.get_property(qu);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.ro.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.no(t)){if(this.so(t))return void Rh.info(`Skipping exception capture because a suppression rule matched`);if(!this.io&&this.oo(t))return void Rh.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ao(t))return void Rh.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}return this._instance.capture(`$exception`,e,{_noTruncate:!0,_batchKey:`exceptionEvent`,zi:!0})}so(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var{type:n,value:r}=t;return Zc(n)&&n.length>0&&e.$exception_types.push(n),Zc(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.eo.some((e=>{var n=e.values.map((e=>{var n=Wp[e.operator],r=U(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)}))}oo(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}ao(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}no(e){return!G(e)&&U(e)}}},Jh=V({productTours:class{get Kr(){return this._instance.persistence}constructor(e){this.lo=null,this.uo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.Kr&&this.Kr.register({[Xu]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.lo||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Xu)||this.nr((()=>this.ho()))}nr(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?mh.error(`Could not load product tours script`,t):e()}))}ho(){var e;!this.lo&&(e=B.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.lo=B.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!U(this.uo)||t){var n=this.Kr;if(n){var r=n.props[hh];if(U(r)&&!t)return this.uo=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;mh.error(i),e([],{isLoaded:!1,error:i});return}var a=U(t.json.product_tours)?t.json.product_tours:[];this.uo=a,n&&n.register({[hh]:a}),e(a,{isLoaded:!0})}})}else e(this.uo,{isLoaded:!0})}getActiveProductTours(e){G(this.lo)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.lo.getActiveProductTours(e)}showProductTour(e){var t;(t=this.lo)==null||t.showTourById(e)}previewTour(e){this.lo?this.lo.previewTour(e):this.nr((()=>{var t;this.ho(),(t=this.lo)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.lo)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.lo)==null||e.nextStep()}previousStep(){var e;(e=this.lo)==null||e.previousStep()}clearCache(){var e;this.uo=null,(e=this.Kr)==null||e.unregister(hh)}resetTour(e){var t;(t=this.lo)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.lo)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.lo)==null||t.cancelPendingTour(e)}}},Wh),Yh={siteApps:class{constructor(e){this._instance=e,this.co=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}do(e,t){if(t){var n=this.globalsForEvent(t);this.co.push(n),this.co.length>1e3&&(this.co=this.co.slice(10))}}get siteAppLoaders(){var e;return(e=B._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.do.bind(this));this.vo=()=>{e(),this.co=[],this.vo=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:V({},Rc(e,gh),{properties:V({},e.properties,s?{$set:V({},e.properties?.$set??{},s)}:{},o?{$set_once:V({},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.co.length&&(_h.info(`Processing `+this.co.length+` events for site app with id `+e.id),this.co.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.vo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,_h.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){_h.error(vh+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){_h.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}fo(){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){_h.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.fo(),void this._instance.on(`eventCaptured`,(e=>this.po(e)))):void _h.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.vo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(e){var t;B[`__$$ph_site_app_`+e]=i._instance,(t=B.__PosthogExtensions__)==null||t.loadSiteApp==null||t.loadSiteApp(i._instance,s,(t=>{if(t)return _h.error(vh+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else _h.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},Xh={tracingHeaders:class{constructor(e){this.mo=void 0,this.yo=void 0,this.zs=()=>{var e,t;W(this.mo)&&((e=B.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),W(this.yo)&&((t=B.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}nr(e){var t,n;(t=B.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=B.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return rh.error(`failed to load script`,t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.nr(this.zs):((e=this.mo)==null||e.call(this),(t=this.yo)==null||t.call(this),this.mo=void 0,this.yo=void 0)}}},Zh=V({surveys:class{get Rt(){return this._instance.config}constructor(e){this.bo=void 0,this._surveyManager=null,this.wo=!1,this._o=[],this.Io=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Rt.disable_surveys){var t=e.surveys;if(G(t))return $.warn(`Flags not loaded yet. Not loading surveys.`);this.bo=U(t)?t.length>0:t,$.info(`flags response received, isSurveysEnabled: `+this.bo),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(Xp)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.wo)$.info(`Already initializing surveys, skipping...`);else if(this.Rt.disable_surveys)$.info(wh);else if(this.Rt.cookieless_mode&&this._instance.consent.isOptedOut())$.info(`Not loading surveys in cookieless mode without consent.`);else{var e=B?.__PosthogExtensions__;if(e){if(!W(this.bo)||this.Rt.advanced_enable_surveys){var t=this.bo||this.Rt.advanced_enable_surveys;this.wo=!0;try{var n=e.generateSurveys;if(n)return void this.Co(n,t);var r=e.loadExternalDependency;if(!r)return void this.So(xd);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.So(`Could not load surveys script`,n):this.Co(e.generateSurveys,t)}))}catch(e){throw this.So(`Error initializing surveys`,e),e}finally{this.wo=!1}}}else $.error(`PostHog Extensions not found.`)}}Co(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Sh(this._instance),$.info(`Surveys loaded successfully`),this.ko({isLoaded:!0})}So(e,t){$.error(e,t),this.ko({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._o.push(e),this._surveyManager&&this.ko({isLoaded:!0}),()=>{this._o=this._o.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Rt.disable_surveys)return $.info(wh),e([]);var n,r=this._instance.get_property(od);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Io?this.Io.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Io=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Rt.token),method:`GET`,timeout:this.Rt.surveys_request_timeout_ms,callback:t=>{var r;this.Io=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;$.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({[od]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}ko(e){for(var t of this._o)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){$.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!G(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);$.warn(`init was not called`)}xo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}To(e){if(G(this._surveyManager))return{eligible:!1,reason:Ch};var t=typeof e==`string`?this.xo(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(G(this._surveyManager))return $.warn(`init was not called`),{visible:!1,disabledReason:Ch};var t=this.To(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return G(this._surveyManager)?($.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Ch})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.To(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(G(this._surveyManager))$.warn(`init was not called`);else{var i=typeof e==`string`?this.xo(e):e;if(i!=null&&i.id)if($p.includes(i.type)){var a=z?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?($.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;$.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),$.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);$.warn(`Survey element not found`)}else $.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else $.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(G(this._surveyManager))$.warn(`init was not called`);else{var r=this.xo(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=V({},r,{appearance:V({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==zf.Popover&&t.initialResponses&&$.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 $.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===zf.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else $.warn(`Survey not found`)}}cancelPendingSurvey(e){G(this._surveyManager)?$.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}},Wh),Qh={toolbar:class{constructor(e){this.instance=e}Ao(e){B.ph_toolbar_state=e}Eo(){return B.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),Bd(this.instance.config)||!R||!z)return!1;e??=R.location,n??=R.history;try{if(!t){try{R.localStorage.setItem(`test`,`test`),R.localStorage.removeItem(`test`)}catch{return!1}t=R?.localStorage}var r,i=Th||_f(e.hash,`__posthog`)||_f(e.hash,`state`),a=i?Fd((()=>JSON.parse(atob(decodeURIComponent(i)))))||Fd((()=>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(Eh)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Ro(e){var t=B.ph_load_toolbar||B.ph_load_editor;!G(t)&&Jc(t)?t(e,this.instance):Dh.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(z==null||!z.getElementById(vd));if(!R||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=V({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(R.localStorage.setItem(Eh,JSON.stringify(V({},r,{source:void 0}))),this.Eo()===2)this.Ro(r);else if(this.Eo()===0){var i;this.Ao(1),(i=B.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return Dh.error(`[Toolbar] Failed to load`,e),void this.Ao(0);this.Ao(2),this.Ro(r)})),X(R,`turbolinks:load`,(()=>{this.Ao(0),this.loadToolbar(r)}))}return!0}No(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)}}},$h=V({experiments:Vh},Wh),eg=V({},Wh,Gh,Kh,qh,Jh,Yh,Zh,Xh,Qh,$h,{conversations:class{constructor(e){this.Mo=void 0,this._conversationsManager=null,this.Fo=!1,this.Oo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;G(t)||(nl(t)?this.Mo=t:(this.Mo=t.enabled,this.Oo=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Mo=void 0,this.Oo=null}loadIfEnabled(){if(!(this._conversationsManager||this.Fo||this._instance.config.disable_conversations||Bd(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=B?.__PosthogExtensions__;if(e&&!W(this.Mo)&&this.Mo)if(this.Oo&&this.Oo.token){this.Fo=!0;try{var t=e.initConversations;if(t)return this.Po(t),void(this.Fo=!1);var n=e.loadExternalDependency;if(!n)return void this.Lo(xd);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.Lo(`Could not load conversations script`,t):this.Po(e.initConversations),this.Fo=!1}))}catch(e){this.Lo(`Error initializing conversations`,e),this.Fo=!1}}else Hh.error(`Conversations enabled but missing token in remote config.`)}}Po(e){if(this.Oo)try{this._conversationsManager=e(this.Oo,this._instance),Hh.info(`Conversations loaded successfully`)}catch(e){this.Lo(`Error completing conversations initialization`,e)}else Hh.error(`Cannot complete initialization: remote config is null`)}Lo(e,t){Hh.error(e,t),this._conversationsManager=null,this.Fo=!1}show(){this._conversationsManager?this._conversationsManager.show():Hh.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Mo&&!$c(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return Lc((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(Hh.warn(Uh),null)}))()}getMessages(e,t){var n=this;return Lc((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Hh.warn(Uh),null)}))()}markAsRead(e){var t=this;return Lc((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Hh.warn(Uh),null)}))()}getTickets(e){var t=this;return Lc((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Hh.warn(Uh),null)}))()}requestRestoreLink(e){var t=this;return Lc((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Hh.warn(Uh),null)}))()}restoreFromToken(e){var t=this;return Lc((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Hh.warn(Uh),null)}))()}restoreFromUrlToken(){var e=this;return Lc((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Hh.warn(Uh),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}}},{logs:class{constructor(e){var t;this.Do=!1,this.Bo=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Do=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!G(t)&&t&&(this.Do=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Do&&!this.Bo){var e=q(`[logs]`),t=B?.__PosthogExtensions__;if(t){var n=t.loadExternalDependency;n?n(this._instance,`logs`,(n=>{var r;n||(r=t.logs)==null||!r.initializeLogs?e.error(`Could not load logs script`,n):(t.logs.initializeLogs(this._instance),this.Bo=!0)})):e.error(xd)}else e.error(`PostHog Extensions not found.`)}}}});_m.__defaultExtensionClasses=V({},eg);var tg,ng=(tg=im[dm]=new _m,function(){function e(){e.done||(e.done=!0,fm=!1,J(im,(function(e){e._dom_loaded()})))}z!=null&&z.addEventListener?z.readyState===`complete`?e():X(z,`DOMContentLoaded`,e,{capture:!1}):R&&K.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),tg),rg;function ig(e){rg=e}function ag(){return rg}var og=(0,c.createContext)({get client(){return ag()},bootstrap:void 0});function sg(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)||!sg(e[s],t[s],n))return!1}return!0}function cg(e){var t=e.children,n=e.client,r=e.apiKey,i=e.options,a=(0,c.useRef)(null),o=(0,c.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=ag();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,c.useEffect)(function(){if(!n){var e=ag(),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&&!sg(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)]),c.default.createElement(og.Provider,{value:{client:o,bootstrap:i?.bootstrap??n?.config?.bootstrap}},t)}var lg=function(e){return typeof e==`function`},ug=function(e,t){return ug=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])},ug(e,t)};function dg(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);ug(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var fg={componentStack:null,exceptionEvent:null,error:null},pg={INVALID_FALLBACK:`[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.`};(function(e){dg(t,e);function t(t){var n=e.call(this,t)||this;return n.state=fg,n}return t.prototype.componentDidCatch=function(e,t){var n=this.props.additionalProperties,r;lg(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 lg(t)?t():t;var i=lg(n)?c.default.createElement(n,{error:r.error,componentStack:r.componentStack,exceptionEvent:r.exceptionEvent}):n;return c.default.isValidElement(i)?i:(console.warn(pg.INVALID_FALLBACK),c.default.createElement(c.default.Fragment,null))},t.contextType=og,t})(c.default.Component),ig(ng);var mg=({debug:e=!1,postHogApiKey:t,isStandalone:n,project:r,forceDisablePostHog:i=!1,children:a})=>{let o=oc();return(0,c.useEffect)(()=>{!t||i||(o?.PostHog.consentGiven?ng.opt_in_capturing():ng.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})):(ng.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)(cg,{client:ng,children:a}))};exports.AppShell=Ys,exports.ConsentManagerProvider=sc,exports.LanguageProvider=dc,exports.MenuProvider=gc,exports.MicroFrontendLink=vc,exports.OrganisationProvider=Cc,exports.OrganisationSelector=Tc,exports.OrganisationsError=wc,exports.PostHogProviderWrapper=mg,exports.languageStorage=$s,exports.organisationStorage=Zs,exports.useConsentManager=oc,exports.useLanguage=uc,exports.useMFNavigation=hc,exports.useMenu=mc,exports.useMenuGroupItems=pc,exports.useOrganisation=bc,exports.useOrganisationId=xc;
|
|
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`);var _=({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 v(e){let{protocol:t,hostname:n,port:r}=window.location;return e({logoutParams:{returnTo:`${t}//${n}:${r}`}})}var ee=({children:e,decorateUser:t,getReturnPath:n,isPublicView:r})=>{let[i,a]=(0,m.useState)(void 0),[o,s]=(0,m.useState)(!1),{user:p,getAccessTokenSilently:g,loginWithRedirect:_,logout:ee,isLoading:te,isAuthenticated:y,error:b}=(0,c.useAuth0)();return(0,m.useEffect)(()=>{y&&(async()=>{s(!0);try{a(await t(p,await g()))}catch(e){console.error(`Error fetching user data:`,e)}finally{s(!1)}})()},[t,g,y,p]),te||o||y&&!i?(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`})):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:()=>v(ee),loginWithRedirect:_,getToken:g})})},te=({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)(ee,{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)(_,{environment:a}),e(t)]})})}),y=`EP::activeOrgId`,b={get:()=>localStorage.getItem(y),set:e=>localStorage.setItem(y,e)},x=`EP::locale`,S={get:()=>localStorage.getItem(x),set:e=>localStorage.setItem(x,e)},ne=`ucData`,C={get:()=>localStorage.getItem(ne)},re={Usercentrics:`Usercentrics Consent Management Platform`,PostHog:`PostHog.com`,Sentry:`Sentry`},w={Usercentrics:{consentGiven:!1},PostHog:{consentGiven:!1},Sentry:{consentGiven:!1}},ie=e=>e.map(e=>{let t=Object.entries(re).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}),w),T=(0,m.createContext)(w),ae=()=>(0,m.useContext)(T),oe=({children:e})=>{let[t,n]=(0,m.useState)(w);return(0,m.useEffect)(()=>{if(typeof window>`u`)return;let e=C.get();if(e){let t=JSON.parse(e);n(ie(Object.values(t.consent.services)))}},[]),(0,m.useEffect)(()=>{let e=async e=>{typeof window>`u`||n(ie(Object.values(e.detail.services)))};return window.addEventListener(`UC_CONSENT`,e),()=>window.removeEventListener(`UC_CONSENT`,e)},[]),(0,h.jsx)(T.Provider,{value:t,children:e})},E=(0,m.createContext)(void 0),se=e=>{let[t,n]=(0,m.useState)(e);return(0,m.useEffect)(()=>{S.set(t)},[t]),[t,n]},ce=()=>{let e=(0,m.useContext)(E);return(0,g.assertIsDefined)(e),e},le=({children:e,language:t})=>{let[n,r]=se(t);return(0,h.jsx)(E.Provider,{value:{language:n,setLanguage:r},children:e})},D=(0,m.createContext)({addItems:()=>{},getItemsForPath:()=>[],getMFNavigate:()=>void 0,setMFNavigate:()=>{},getItemGroupsPerPath:()=>({})}),ue=e=>(0,m.useContext)(D).getItemsForPath(e),de=()=>(0,m.useContext)(D),fe=e=>{let{getMFNavigate:t}=de();return t(e)},O=({children:e})=>{let[t,n]=(0,m.useState)({}),[r,i]=(0,m.useState)({}),a=(0,m.useCallback)((e,t)=>{n(n=>({...n,[t]:e}))},[]);return(0,h.jsx)(D.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 pe(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var me=({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`)&&!pe(t)&&(t.preventDefault(),e())},target:r,...i,children:t}),he=(0,m.createContext)(void 0),ge=()=>{let e=(0,m.useContext)(he);return(0,g.assertIsDefined)(e),e},_e=()=>{let e=(0,m.useContext)(he);return(0,g.assertIsDefined)(e),e.organisationId},ve=e=>{let[t,n]=(0,m.useState)(Number(e));return(0,m.useEffect)(()=>{b.set(t.toString())},[t]),[t,n]},ye=({children:e,organisationId:t})=>{let[n,r]=ve(t);return(0,h.jsx)(he.Provider,{value:{organisationId:n,setOrganisationId:r},children:e})},be=class extends Error{constructor(...e){super(...e),this.message=`Failed fetching organisations`}},xe=({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 be;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 Se=A?.navigator,j=A?.document,Ce=A?.location,we=A?.fetch,Te=A!=null&&A.XMLHttpRequest&&`withCredentials`in new A.XMLHttpRequest?A.XMLHttpRequest:void 0,Ee=A?.AbortController,De=A?.CompressionStream,Oe=Se?.userAgent,M=k??{},ke=`1.365.5`,N={DEBUG:!1,LIB_VERSION:ke,LIB_NAME:`web`,JS_SDK_VERSION:ke};function Ae(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 je(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ae(a,r,i,o,s,`next`,e)}function s(e){Ae(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 Me(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 Ne(){return(Ne=je((function*(e,t){t===void 0&&(t=!0);try{var n=new Blob([e],{type:`text/plain`}).stream().pipeThrough(new CompressionStream(`gzip`));return yield new Response(n).blob()}catch(e){return t&&console.error(`Failed to gzip compress data`,e),null}}))).apply(this,arguments)}var Pe=[`$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`],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}))};function F(e,t){return e.indexOf(t)!==-1}var Le=function(e){return e.trim()},Re=function(e){return e.replace(/^\$/,``)},ze=Object.prototype,Be=ze.hasOwnProperty,Ve=ze.toString,I=Array.isArray||function(e){return Ve.call(e)===`[object Array]`},He=e=>typeof e==`function`,L=e=>e===Object(e)&&!I(e),Ue=e=>{if(L(e)){for(var t in e)if(Be.call(e,t))return!1;return!0}return!1},R=e=>e===void 0,z=e=>Ve.call(e)==`[object String]`,We=e=>z(e)&&e.trim().length===0,Ge=e=>e===null,B=e=>R(e)||Ge(e),Ke=e=>Ve.call(e)==`[object Number]`&&e==e,qe=e=>Ke(e)&&e>0,Je=e=>Ve.call(e)===`[object Boolean]`,Ye=e=>e instanceof FormData,Xe=e=>F(Pe,e);function Ze(e){return typeof e!=`object`||!e}function Qe(e,t){return{}.toString.call(e)===`[object `+t+`]`}function $e(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var et=[!0,`true`,1,`1`,`yes`],tt=e=>F(et,e),nt=[!1,`false`,0,`0`,`no`];function rt(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Ke(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),rt(i||n,t,n,r))}var it=class{constructor(e){this.Pt={},this.Dt=e.Dt,this.jt=rt(e.bucketSize,0,100,e.qt),this.$t=rt(e.refillRate,0,this.jt,e.qt),this.Ht=rt(e.refillInterval,0,864e5,e.qt)}Vt(e,t){var n=Math.floor((t-e.lastAccess)/this.Ht);n>0&&(e.tokens=Math.min(e.tokens+n*this.$t,this.jt),e.lastAccess+=n*this.Ht)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.Pt[r];return i?this.Vt(i,n):this.Pt[r]=i={tokens:this.jt,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.Dt)==null||t.call(this,e)),i.tokens===0)}stop(){this.Pt={}}},at,ot,st,V=`Mobile`,ct=`iOS`,lt=`Android`,ut=`Tablet`,dt=lt+` `+ut,ft=`iPad`,pt=`Apple`,mt=pt+` Watch`,ht=`Safari`,gt=`BlackBerry`,_t=`Samsung`,vt=_t+`Browser`,yt=_t+` Internet`,bt=`Chrome`,xt=bt+` OS`,St=bt+` `+ct,Ct=`Internet Explorer`,wt=Ct+` `+V,Tt=`Opera`,Et=Tt+` Mini`,Dt=`Edge`,Ot=`Microsoft `+Dt,kt=`Firefox`,At=kt+` `+ct,jt=`Nintendo`,Mt=`PlayStation`,Nt=`Xbox`,Pt=lt+` `+V,Ft=V+` `+ht,It=`Windows`,Lt=It+` Phone`,Rt=`Nokia`,zt=`Ouya`,Bt=`Generic`,Vt=Bt+` `+V.toLowerCase(),Ht=Bt+` `+ut.toLowerCase(),Ut=`Konqueror`,H=`(\\d+(\\.\\d+)?)`,Wt=RegExp(`Version/`+H),Gt=new RegExp(Nt,`i`),Kt=RegExp(Mt+` \\w+`,`i`),qt=RegExp(jt+` \\w+`,`i`),Jt=RegExp(gt+`|PlayBook|BB10`,`i`),Yt={"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`},Xt=function(e,t){return t||=``,F(e,` OPR/`)&&F(e,`Mini`)?Et:F(e,` OPR/`)?Tt:Jt.test(e)?gt:F(e,`IE`+V)||F(e,`WPDesktop`)?wt:F(e,vt)?yt:F(e,Dt)||F(e,`Edg/`)?Ot:F(e,`FBIOS`)?`Facebook `+V:F(e,`UCWEB`)||F(e,`UCBrowser`)?`UC Browser`:F(e,`CriOS`)?St:F(e,`CrMo`)||F(e,bt)?bt:F(e,lt)&&F(e,ht)?Pt:F(e,`FxiOS`)?At:F(e.toLowerCase(),Ut.toLowerCase())?Ut:((e,t)=>t&&F(t,pt)||function(e){return F(e,ht)&&!F(e,bt)&&!F(e,lt)}(e))(e,t)?F(e,V)?Ft:ht:F(e,kt)?kt:F(e,`MSIE`)||F(e,`Trident/`)?Ct:F(e,`Gecko`)?kt:``},Zt={[wt]:[RegExp(`rv:`+H)],[Ot]:[RegExp(Dt+`?\\/`+H)],[bt]:[RegExp(`(`+bt+`|CrMo)\\/`+H)],[St]:[RegExp(`CriOS\\/`+H)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+H)],[ht]:[Wt],[Ft]:[Wt],[Tt]:[RegExp(`(Opera|OPR)\\/`+H)],[kt]:[RegExp(kt+`\\/`+H)],[At]:[RegExp(`FxiOS\\/`+H)],[Ut]:[RegExp(`Konqueror[:/]?`+H,`i`)],[gt]:[RegExp(gt+` `+H),Wt],[Pt]:[RegExp(`android\\s`+H,`i`)],[yt]:[RegExp(vt+`\\/`+H)],[Ct]:[RegExp(`(rv:|MSIE )`+H)],Mozilla:[RegExp(`rv:`+H)]},Qt=function(e,t){var n=Zt[Xt(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},$t=[[RegExp(Nt+`; `+Nt+` (.*?)[);]`,`i`),e=>[Nt,e&&e[1]||``]],[new RegExp(jt,`i`),[jt,``]],[new RegExp(Mt,`i`),[Mt,``]],[Jt,[gt,``]],[new RegExp(It,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Lt,``];if(new RegExp(V).test(t)&&!/IEMobile\b/.test(t))return[It+` `+V,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=Yt[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[It,r]}return[It,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[ct,[e[3],e[4],e[5]||`0`].join(`.`)]:[ct,``]],[/(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(`(`+lt+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+lt+`)`,`i`),e=>e&&e[2]?[lt,[e[2],e[3],e[4]||`0`].join(`.`)]:[lt,``]],[/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/,[xt,``]],[/Linux|debian/i,[`Linux`,``]]],en=function(e){return qt.test(e)?jt:Kt.test(e)?Mt:Gt.test(e)?Nt:new RegExp(zt,`i`).test(e)?zt:RegExp(`(`+Lt+`|WPDesktop)`,`i`).test(e)?Lt:/iPad/.test(e)?ft:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?mt:Jt.test(e)?gt:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Rt,`i`).test(e)?Rt:/(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)?lt:dt:RegExp(`(pda|`+V+`)`,`i`).test(e)?Vt:new RegExp(ut,`i`).test(e)&&!RegExp(ut+` pc`,`i`).test(e)?Ht:``},tn=e=>e instanceof Error;function nn(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return st&&n.length===ot||(ot=n.length,st=n.reduce(((n,r)=>{at||={};var i=at[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,at[r]=[s,c];break}}return n}),{})),st}}var rn=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 je((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 je((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:nn(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)})}},an=`?`;function on(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?an:n,in_app:!0};return R(r)||(a.lineno=r),R(i)||(a.colno=i),a}var sn=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?an:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},cn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ln=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,un=/\((\S*)(?::(\d+))(?::(\d+))\)/,dn=(e,t)=>{var n=cn.exec(e);if(n){var[,r,i,a]=n;return on(t,r,an,+i,+a)}var o=ln.exec(e);if(o){if(o[2]&&o[2].indexOf(`eval`)===0){var s=un.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}var[c,l]=sn(o[1]||an,o[2]);return on(t,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},fn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,mn=(e,t)=>{var n=fn.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=pn.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]||an;return[a,i]=sn(a,i),on(t,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},hn=/\(error: (.*)\)/,gn=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 Qe(e,`DOMException`)}isDOMError(e){return Qe(e,`DOMError`)}},_n=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}},vn=class{constructor(){}match(e){return Qe(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},yn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,bn=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(yn);return r&&(t=r[1],n=r[2]),[t,n]}},xn=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function Sn(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 Cn=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 $e(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: `+Sn(e)}isSeverityLevel(e){return z(e)&&!We(e)&&xn.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(tn(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},wn=class{match(e){return $e(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+Sn(e),stack:t.syntheticException?.stack,synthetic:!0}}},Tn=class{match(e){return Ze(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},En=class{match(e){return Qe(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!$e(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 Ze(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}},Dn=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)}},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)=>Dn(e+` `+t,n)};return r},U=Dn(`[PostHog.js]`),W=U.createLogger,On=W(`[ExternalScriptsLoader]`),kn=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return On.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)=>{var r=`/static/`+t+`.js?v=`+e.version;if(t===`remote-config`&&(r=`/array/`+e.config.token+`/config.js`),t===`toolbar`){var i=3e5;r=r+`&t=`+Math.floor(Date.now()/i)*i}kn(e,e.requestRouter.endpointFor(`assets`,r),n)},M.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{kn(e,e.requestRouter.endpointFor(`api`,t),n)};var An=`$people_distinct_id`,jn=`$device_id`,Mn=`__alias`,Nn=`__timers`,Pn=`$autocapture_disabled_server_side`,Fn=`$heatmaps_enabled_server_side`,In=`$exception_capture_enabled_server_side`,Ln=`$error_tracking_suppression_rules`,Rn=`$error_tracking_capture_extension_exceptions`,zn=`$web_vitals_enabled_server_side`,Bn=`$dead_clicks_enabled_server_side`,Vn=`$product_tours_enabled_server_side`,Hn=`$web_vitals_allowed_metrics`,Un=`$session_recording_remote_config`,Wn=`$sesid`,Gn=`$session_is_sampled`,Kn=`$enabled_feature_flags`,qn=`$early_access_features`,Jn=`$feature_flag_details`,Yn=`$stored_person_properties`,Xn=`$stored_group_properties`,Zn=`$surveys`,Qn=`$flag_call_reported`,$n=`$flag_call_reported_session_id`,er=`$feature_flag_errors`,tr=`$feature_flag_evaluated_at`,nr=`$user_state`,rr=`$client_session_props`,ir=`$capture_rate_limit`,ar=`$initial_campaign_params`,or=`$initial_referrer_info`,sr=`$initial_person_info`,cr=`$epp`,lr=`__POSTHOG_TOOLBAR__`,ur=`$posthog_cookieless`,dr=[An,Mn,`__cmpns`,Nn,`$session_recording_enabled_server_side`,Fn,Wn,Kn,Ln,nr,qn,Jn,Xn,Yn,Zn,Qn,$n,er,tr,rr,ir,ar,or,cr,sr],fr=`PostHog loadExternalDependency extension not found.`,pr=`on_reject`,mr=`always`,hr=`anonymous`,gr=`identified`,_r=`identified_only`,vr=`visibilitychange`,yr=`beforeunload`,br=`$pageview`,xr=`$pageleave`,Sr=`$identify`,Cr=`$groupidentify`;function wr(e,t){I(e)&&e.forEach(t)}function G(e,t){if(!B(e))if(I(e))e.forEach(t);else if(Ye(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)Be.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 Tr(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Er=function(e){try{return e()}catch{return}},Dr=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)}}},Or=function(e){var t={};return G(e,(function(e,n){(z(e)&&e.length>0||Ke(e))&&(t[n]=e)})),t},kr=[`herokuapp.com`,`vercel.app`,`netlify.app`];function Ar(e){var t=e?.hostname;if(!z(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of kr)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 jr(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 Ke(e)&&isFinite(e)&&Math.floor(e)===e});var Mr=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}},Nr=class{constructor(){this.I=0,this.S=0,this.k=new Ir}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 Mr.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())}},Pr,Fr=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&&(Fr=e=>crypto.getRandomValues(e));var Ir=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(Fr(this.T),this.N=0),this.T[this.N++]}},Lr=()=>Rr().toString(),Rr=()=>(Pr||=new Nr).generate(),zr=``,Br=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Vr={Yt:()=>!!j,Ut(e){U.error(`cookieStore error: `+e)},Wt(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}},Gt(e){var t;try{t=JSON.parse(Vr.Wt(e))||{}}catch{}return t},Xt(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),zr)return zr;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+Lr();!zr&&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`,zr=a)}return zr}(e);if(!n){var r=(e=>{var t=e.match(Br);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}},Jt(e,t){if(j!=null&&j.cookie)try{Vr.Xt(e,``,-1,t)}catch{return}}},Hr=null,J={Yt(){if(!Ge(Hr))return Hr;var e=!0;if(R(k))e=!1;else try{var t=`__mplssupport__`;J.Xt(t,`xyz`),J.Wt(t)!==`"xyz"`&&(e=!1),J.Jt(t)}catch{e=!1}return e||U.error(`localStorage unsupported; falling back to cookie store`),Hr=e,e},Ut(e){U.error(`localStorage error: `+e)},Wt(e){try{return k?.localStorage.getItem(e)}catch(e){J.Ut(e)}return null},Gt(e){try{return JSON.parse(J.Wt(e))||{}}catch{}return null},Xt(e,t){try{k?.localStorage.setItem(e,JSON.stringify(t))}catch(e){J.Ut(e)}},Jt(e){try{k?.localStorage.removeItem(e)}catch(e){J.Ut(e)}}},Ur=[jn,`distinct_id`,Wn,Gn,cr,sr,nr],Wr={},Gr={Yt:()=>!0,Ut(e){U.error(`memoryStorage error: `+e)},Wt:e=>Wr[e]||null,Gt:e=>Wr[e]||null,Xt(e,t){Wr[e]=t},Jt(e){delete Wr[e]}},Kr=null,Y={Yt(){if(!Ge(Kr))return Kr;if(Kr=!0,R(k))Kr=!1;else try{var e=`__support__`;Y.Xt(e,`xyz`),Y.Wt(e)!==`"xyz"`&&(Kr=!1),Y.Jt(e)}catch{Kr=!1}return Kr},Ut(e){U.error(`sessionStorage error: `,e)},Wt(e){try{return k?.sessionStorage.getItem(e)}catch(e){Y.Ut(e)}return null},Gt(e){try{return JSON.parse(Y.Wt(e))||null}catch{}return null},Xt(e,t){try{k?.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Y.Ut(e)}},Jt(e){try{k?.sessionStorage.removeItem(e)}catch(e){Y.Ut(e)}}},qr=class{constructor(e){this._instance=e}get Rt(){return this._instance.config}get consent(){return this.Kt()?0:this.Qt}isOptedOut(){return this.Rt.cookieless_mode===mr||this.consent===0||this.consent===-1&&(this.Rt.opt_out_capturing_by_default||this.Rt.cookieless_mode===pr)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.tr.Xt(this.er,+!!e,this.Rt.cookie_expiration,this.Rt.cross_subdomain_cookie,this.Rt.secure_cookie)}reset(){this.tr.Jt(this.er,this.Rt.cross_subdomain_cookie)}get er(){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 Qt(){var e=this.tr.Wt(this.er);return tt(e)?1:F(nt,e)?0:-1}get tr(){if(!this.rr){var e=this.Rt.opt_out_capturing_persistence_type;this.rr=e===`localStorage`?J:Vr;var t=e===`localStorage`?Vr:J;t.Wt(this.er)&&(this.rr.Wt(this.er)||this.optInOut(tt(t.Wt(this.er))),t.Jt(this.er,this.Rt.cross_subdomain_cookie))}return this.rr}Kt(){return!!this.Rt.respect_dnt&&[Se?.doNotTrack,Se?.msDoNotTrack,M.doNotTrack].some((e=>tt(e)))}},Jr=W(`[Dead Clicks]`),Yr=()=>!0,Xr=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Bn)),r=e.instance.config.capture_dead_clicks;return Je(r)?r:!!L(r)||n},Zr=class{get lazyLoadedDeadClicksAutocapture(){return this.ir}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({[Bn]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.nr((()=>{this.sr()})):this.stop()}nr(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?Jr.error(`failed to load script`,t):e()}))}sr(){var e;if(j){if(!this.ir&&(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.ir=M.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ir.start(j),Jr.info(`starting...`)}}else Jr.error("`document` not found. Cannot start.")}stop(){this.ir&&(this.ir.stop(),this.ir=void 0,Jr.info(`stopping...`))}},Qr=W(`[SegmentIntegration]`),$r=`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 ti=class{constructor(e,t,n,r,i,a){this.name=$r,this.setupOnce=function(o){o(ei(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},ni=class{constructor(e){this.ar=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(U.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.lr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.ur()}ur(){this.hr=this._instance.sessionManager?.onSessionId(this.ar)}destroy(){var e;(e=this.hr)==null||e.call(this),this.hr=void 0}doPageView(e,t){var n=this.cr(e,t);return this.lr={pathname:k?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.cr(e,this.lr?.pageViewId)}doEvent(){return{$pageview_id:this.lr?.pageViewId}}cr(e,t){var n=this.lr;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?rt(o/a,0,1,U):1,f=a>1?rt(s/a,0,1,U):1,p=c>1?rt(l/c,0,1,U):1,m=c>1?rt(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}},ri=e=>{var t=j?.createElement(`a`);return R(t)?null:(t.href=e,t)},ii=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,` `)},ai=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},oi=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},si=`https?://(.*)`,ci=[`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`,...ci],ui=`<masked>`,di=[`li_fat_id`];function fi(e,t,n){if(!j)return{};var r,i=t?[...ci,...n||[]]:[],a=pi(ai(j.URL,i,ui),e);return K((r={},G(di,(function(e){var t=Vr.Wt(e);r[e]=t||null})),r),a)}function pi(e,t){var n=li.concat(t||[]),r={};return G(n,(function(t){r[t]=ii(e,t)||null})),r}function mi(e){var t=function(e){return e?e.search(si+`google.([^/?]*)`)===0?`google`:e.search(si+`bing.com`)===0?`bing`:e.search(si+`yahoo.com`)===0?`yahoo`:e.search(si+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!Ge(t)){r.$search_engine=t;var i=j?ii(j.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function hi(){return navigator.language||navigator.userLanguage}var gi=`$direct`;function _i(){return j?.referrer||gi}function vi(e,t){var n=e?[...ci,...t||[]]:[],r=Ce?.href.substring(0,1e3);return{r:_i().substring(0,1e3),u:r?ai(r,n,ui):void 0}}function yi(e){var{r:t,u:n}=e,r={$referrer:t,$referring_domain:t==null?void 0:t==gi?gi:ri(t)?.host};if(n){r.$current_url=n;var i=ri(n);r.$host=i?.host,r.$pathname=i?.pathname,K(r,pi(n))}return t&&K(r,mi(t)),r}function bi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function xi(){try{return new Date().getTimezoneOffset()}catch{return}}var Si=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Ci=class{constructor(e,t){this.Rt=e,this.props={},this.dr=!1,this.vr=(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.tr=this.pr(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.gr}pr(e){Si.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=[...Ur,...e];return P({},J,{Gt(e){try{var t={};try{t=Vr.Gt(e)||{}}catch{}var n=K(t,JSON.parse(J.Wt(e)||`{}`));return J.Xt(e,n),n}catch{}return null},Xt(e,n,r,i,a,o){try{J.Xt(e,n,void 0,void 0,o);var s={};t.forEach((e=>{n[e]&&(s[e]=n[e])})),Object.keys(s).length&&Vr.Xt(e,s,r,i,a,o)}catch(e){J.Ut(e)}},Jt(e,t){try{k?.localStorage.removeItem(e),Vr.Jt(e,t)}catch(e){J.Ut(e)}}})}(e.cookie_persisted_properties||[]),n=e.persistence.toLowerCase();return n===`localstorage`&&J.Yt()?J:n===`localstorage+cookie`&&t.Yt()?t:n===`sessionstorage`&&Y.Yt()?Y:n===`memory`?Gr:n===`cookie`?Vr:t.Yt()?t:Vr}mr(e){var t=e??this.Rt.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)=>{if(n===Kn&&L(t)){if(!this.mr())for(var r=Object.keys(t),i=0;r.length>i;i++)e[`$feature/`+r[i]]=t[r[i]]}else dr.indexOf(n)===-1&&(e[n]=t)})),e}load(){if(!this.gr){var e=this.tr.Gt(this.vr);e&&(this.props=K({},e))}}save(){this.gr||this.tr.Xt(this.vr,this.props,this.yr,this.br,this.wr,this.Rt.debug)}remove(){this.tr.Jt(this.vr,!1),this.tr.Jt(this.vr,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(L(e)){R(t)&&(t=`None`),this.yr=R(n)?this._r:n;var r=!1;if(G(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.props[n]=e,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(L(e)){this.yr=R(t)?this._r:t;var n=!1;if(G(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.dr){var e=fi(this.Rt.custom_campaign_params,this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties);Ue(Or(e))||this.register(e),this.dr=!0}}update_search_keyword(){var e;this.register((e=j?.referrer)?mi(e):{})}update_referrer_info(){this.register_once({$referrer:_i(),$referring_domain:j!=null&&j.referrer&&ri(j.referrer)?.host||gi},void 0)}set_initial_person_info(){this.props[ar]||this.props[or]||this.register_once({[sr]:vi(this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};G([or,ar],(t=>{var n=this.props[t];n&&G(n,(function(t,n){e[`$initial_`+Re(n)]=t}))}));var t,n,r=this.props[sr];return r&&K(e,(t=yi(r),n={},G(t,(function(e,t){n[`$initial_`+Re(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._r=this.yr=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.pr(e),i=this.props;this.clear(),this.tr=r,this.props=i,this.save()}}set_disabled(e){this.gr=e,this.gr?this.remove():this.save()}set_cross_subdomain(e){e!==this.br&&(this.br=e,this.remove(),this.save())}set_secure(e){e!==this.wr&&(this.wr=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[Nn]||{};n[e]=t,this.props[Nn]=n,this.save()}remove_event_timer(e){var t=(this.props[Nn]||{})[e];return R(t)||(delete this.props[Nn][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},wi={Activation:`events`,Cancellation:`cancelEvents`},Ti={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},Ei={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},Di={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`},Oi={Popover:`popover`,Inline:`inline`},ki={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`},Ai={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`},ji=W(`[RateLimiter]`),Mi=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=>{ji.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){ji.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(ir)??{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(ir,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Ni=W(`[RemoteConfig]`),Pi=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}Ir(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()}Cr(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 Ni.info(`Using preloaded remote config`,this.remoteConfig),this.Sr(this.remoteConfig),void this.kr();if(this._instance.Tr())return void Ni.warn(`Remote config is disabled. Falling back to local config.`);this.Ir((e=>{if(!e)return Ni.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Cr((e=>{this.Sr(e),this.kr()}));this.Sr(e),this.kr()}))}catch(e){Ni.error(`Error loading remote config`,e)}}stop(){this.Ar&&=(clearInterval(this.Ar),void 0)}refresh(){this._instance.Tr()||j?.visibilityState===`hidden`||this._instance.reloadFeatureFlags()}kr(){if(!this.Ar){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.Ar=setInterval((()=>{this.refresh()}),e))}}Sr(e){var t;e||Ni.error(`Failed to fetch remote config from PostHog.`),this._instance.Sr(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},Fi={GZipJS:`gzip-js`,Base64:`base64`},Ii=Uint8Array,X=Uint16Array,Li=Uint32Array,Ri=new Ii([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]),zi=new Ii([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]),Bi=new Ii([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vi=function(e,t){for(var n=new X(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Li(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]},Hi=Vi(Ri,2),Ui=Hi[1];Hi[0][28]=258,Ui[258]=28;for(var Wi=Vi(zi,0)[1],Gi=new X(32768),Z=0;32768>Z;++Z){var Ki=(43690&Z)>>>1|(21845&Z)<<1;Gi[Z]=((65280&(Ki=(61680&(Ki=(52428&Ki)>>>2|(13107&Ki)<<2))>>>4|(3855&Ki)<<4))>>>8|(255&Ki)<<8)>>>1}var qi=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[Gi[d]>>>c]=l}else for(o=new X(r),i=0;r>i;++i)o[i]=Gi[s[e[i]-1]++]>>>15-e[i];return o},Ji=new Ii(288);for(Z=0;144>Z;++Z)Ji[Z]=8;for(Z=144;256>Z;++Z)Ji[Z]=9;for(Z=256;280>Z;++Z)Ji[Z]=7;for(Z=280;288>Z;++Z)Ji[Z]=8;var Yi=new Ii(32);for(Z=0;32>Z;++Z)Yi[Z]=5;var Xi=qi(Ji,9,0),Zi=qi(Yi,5,0),Qi=function(e){return(e/8>>0)+(7&e&&1)},$i=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof X?X:e instanceof Li?Li:Ii)(n-t);return r.set(e.subarray(t,n)),r},ea=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},ta=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},na=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 Ii(0),0];if(i==1){var o=new Ii(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=ra(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 Ii(p),m]},ra=function(e,t,n){return e.s==-1?Math.max(ra(e.l,t,n+1),ra(e.r,t,n+1)):t[e.s]=n},ia=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]},aa=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},oa=function(e,t,n){var r=n.length,i=Qi(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)},sa=function(e,t,n,r,i,a,o,s,c,l,u){ea(t,u++,n),++i[256];for(var d=na(i,15),f=d[0],p=d[1],m=na(a,15),h=m[0],g=m[1],_=ia(f),v=_[0],ee=_[1],te=ia(h),y=te[0],b=te[1],x=new X(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=na(x,7),C=ne[0],re=ne[1],w=19;w>4&&!C[Bi[w-1]];--w);var ie,T,ae,oe,E=l+5<<3,se=aa(i,Ji)+aa(a,Yi)+o,ce=aa(i,f)+aa(a,h)+o+14+3*w+aa(x,C)+(2*x[16]+3*x[17]+7*x[18]);if(se>=E&&ce>=E)return oa(t,u,e.subarray(c,c+l));if(ea(t,u,1+(se>ce)),u+=2,se>ce){ie=qi(f,p,0),T=f,ae=qi(h,g,0),oe=h;var le=qi(C,re,0);for(ea(t,u,ee-257),ea(t,u+5,b-1),ea(t,u+10,w-4),u+=14,S=0;w>S;++S)ea(t,u+3*S,C[Bi[S]]);u+=3*w;for(var D=[v,y],ue=0;2>ue;++ue){var de=D[ue];for(S=0;de.length>S;++S)ea(t,u,le[fe=31&de[S]]),u+=C[fe],fe>15&&(ea(t,u,de[S]>>>5&127),u+=de[S]>>>12)}}else ie=Xi,T=Ji,ae=Zi,oe=Yi;for(S=0;s>S;++S)if(r[S]>255){var fe;ta(t,u,ie[257+(fe=r[S]>>>18&31)]),u+=T[fe+257],fe>7&&(ea(t,u,r[S]>>>23&31),u+=Ri[fe]);var O=31&r[S];ta(t,u,ae[O]),u+=oe[O],O>3&&(ta(t,u,r[S]>>>5&8191),u+=zi[O])}else ta(t,u,ie[r[S]]),u+=T[r[S]];return ta(t,u,ie[256]),u+T[256]},ca=new Li([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),la=function(){for(var e=new Li(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),ua=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function da(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 Ii(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=oa(c,l,e.subarray(u,d)):(c[u]=!0,l=oa(c,l,e.subarray(u,o)))}else{for(var f=ca[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,te=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<ee)&h},y=new Li(25e3),b=new X(288),x=new X(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=sa(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,D=T-ae&32767;if(oe>2&&ie==te(u-D))for(var ue=Math.min(p,oe)-1,de=Math.min(32767,u),fe=Math.min(258,oe);de>=D&&--le&&T!=ae;){if(e[u+se]==e[u+se-D]){for(var O=0;fe>O&&e[u+O]==e[u+O-D];++O);if(O>se){if(se=O,ce=D,O>ue)break;var pe=Math.min(D,O-2),me=0;for(E=0;pe>E;++E){var he=u-D+E+32768&32767,ge=he-g[he]+32768&32767;ge>me&&(me=ge,ae=he)}}}D+=(T=ae)-(ae=g[T])+32768&32767}if(ce){y[C++]=268435456|Ui[se]<<18|Wi[ce];var _e=31&Ui[se],ve=31&Wi[ce];ne+=Ri[_e]+zi[ve],++b[257+_e],++x[ve],re=u+se,++S}else y[C++]=e[u],++b[e[u]]}}l=sa(e,c,!0,y,b,x,ne,C,w,u-w,l)}return $i(s,0,r+Qi(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&&ua(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),ua(l,u-8,n.d()),ua(l,u-4,r),l}var fa=!!Te||!!we,pa=`text/plain`,ma=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(`&`)},ha=(e,t)=>JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t),ga=e=>{if(e.zt)return e.zt;var{data:t,compression:n}=e;if(t){if(n===Fi.GZipJS){var r=da(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new Ii(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 Ii(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 $i(r,0,i)}(ha(t)),{mtime:0});return{contentType:pa,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Fi.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:ha(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(ha(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=ha(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},_a=function(){var e=je((function*(e){var t=yield function(e,t){return Ne.apply(this,arguments)}(ha(e.data),N.DEBUG);if(!t)return e;var n=yield t.arrayBuffer();return P({},e,{zt:{contentType:pa,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),va=[];we&&va.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(Ee){var s=new Ee;o={signal:s.signal,timeout:setTimeout((()=>s.abort()),e.timeout)}}we(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))}}),Te&&va.push({transport:`XHR`,method(e){var t=new Te;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)}}),Se!=null&&Se.sendBeacon&&va.push({transport:`sendBeacon`,method(e){var t=ma(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});Se.sendBeacon(t,i)}catch{}}});var ya=3e3,ba=class{constructor(e,t){this.Er=!0,this.Rr=[],this.Nr=rt(t?.flush_interval_ms||ya,250,5e3,U.createLogger(`flush interval`),ya),this.Mr=e}enqueue(e){this.Rr.push(e),this.Fr||this.Or()}unload(){this.Pr();var e=this.Rr.length>0?this.Lr():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Mr(P({},e,{transport:`sendBeacon`}))}))}enable(){this.Er=!1,this.Or()}Or(){var e=this;this.Er||(this.Fr=setTimeout((()=>{if(this.Pr(),this.Rr.length>0){var t=this.Lr(),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.Mr(n)};for(var r in t)n()}}),this.Nr))}Pr(){clearTimeout(this.Fr),this.Fr=void 0}Lr(){var e={};return G(this.Rr,(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.Rr=[],e}},xa=[`retriesPerformedSoFar`],Sa=class{constructor(e){this.Dr=!1,this.Br=3e3,this.Rr=[],this._instance=e,this.Rr=[],this.jr=!0,!R(k)&&`onLine`in k.navigator&&(this.jr=k.navigator.onLine,this.qr=()=>{this.jr=!0,this.Zr()},this.$r=()=>{this.jr=!1},q(k,`online`,this.qr),q(k,`offline`,this.$r))}get length(){return this.Rr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=Me(e,xa);qe(t)&&(n.url=ma(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.Hr(P({retriesPerformedSoFar:t},n))}}))}Hr(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.Rr.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),U.warn(i),this.Dr||(this.Dr=!0,this.Vr())}Vr(){if(this.zr&&clearTimeout(this.zr),this.Rr.length===0)return this.Dr=!1,void(this.zr=void 0);this.zr=setTimeout((()=>{this.jr&&this.Rr.length>0&&this.Zr(),this.Vr()}),this.Br)}Zr(){var e=Date.now(),t=[],n=this.Rr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Rr=t,n.length>0)for(var{requestOptions:r}of n)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.zr&&=(clearTimeout(this.zr),void 0),this.Dr=!1,R(k)||(this.qr&&=(k.removeEventListener(`online`,this.qr),void 0),this.$r&&=(k.removeEventListener(`offline`,this.$r),void 0)),this.Rr))try{this._instance._send_request(P({},e,{transport:`sendBeacon`}))}catch(e){U.error(e)}this.Rr=[]}},Ca=class{constructor(e){this.Yr=()=>{this.Ur||={};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.Ur.lastScrollY=Math.ceil(t),this.Ur.maxScrollY=Math.max(t,this.Ur.maxScrollY??0),this.Ur.maxScrollHeight=Math.max(n,this.Ur.maxScrollHeight??0),this.Ur.lastContentY=r,this.Ur.maxContentY=Math.max(r,this.Ur.maxContentY??0),this.Ur.maxContentHeight=Math.max(i,this.Ur.maxContentHeight??0)},this._instance=e}get Wr(){return this._instance.config.scroll_root_selector}getContext(){return this.Ur}resetContext(){var e=this.Ur;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){q(k,`scroll`,this.Yr,{capture:!0}),q(k,`scrollend`,this.Yr,{capture:!0}),q(k,`resize`,this.Yr)}scrollElement(){if(!this.Wr)return k?.document.documentElement;for(var e of I(this.Wr)?this.Wr:[this.Wr]){var t=k?.document.querySelector(e);if(t)return t}}scrollY(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollTop||0}return k&&(k.scrollY||k.pageYOffset||k.document.documentElement.scrollTop)||0}scrollX(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollLeft||0}return k&&(k.scrollX||k.pageXOffset||k.document.documentElement.scrollLeft)||0}},wa=e=>vi(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties),Ta=class{constructor(e,t,n,r){this.Gr=e=>{var t=this.Xr();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.Jr(this._instance)};this.Kr.register({[rr]:n})}},this._instance=e,this.Qr=t,this.Kr=n,this.Jr=r||wa,this.Qr.onSessionId(this.Gr)}Xr(){return this.Kr.props[rr]}getSetOnceProps(){var e=this.Xr()?.props;return e?`r`in e?yi(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(Or(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+Re(n)]=t})),e}},Ea=class{constructor(){this.ti={}}on(e,t){return this.ti[e]||(this.ti[e]=[]),this.ti[e].push(t),()=>{this.ti[e]=this.ti[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.ti[e]||[])n(t);for(var r of this.ti[`*`]||[])r(e,t)}},Da=W(`[SessionId]`),Oa=class{on(e,t){return this.ei.on(e,t)}constructor(e,t,n){var r;if(this.ri=[],this.ii=void 0,this.ei=new Ea,this.ni=(e,t)=>!(!qe(e)||!qe(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===mr)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Rt=e.config,this.Kr=e.persistence,this.si=void 0,this.oi=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ai=t||Lr,this.li=n||Lr;var i=this.Rt.persistence_name||this.Rt.token;if(this._sessionTimeoutMs=1e3*rt(this.Rt.session_idle_timeout_seconds||1800,60,36e3,Da.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ui(),this.hi=`ph_`+i+`_window_id`,this.ci=`ph_`+i+`_primary_window_exists`,this.di()){var a=Y.Gt(this.hi),o=Y.Gt(this.ci);a&&!o?this.si=a:Y.Jt(this.hi),Y.Xt(this.ci,!0)}if((r=this.Rt.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Rt.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.vi(this.Rt.bootstrap.sessionID,new Date().getTime(),s)}catch(e){Da.error(`Invalid sessionID in bootstrap`,e)}this.fi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return R(this.ri)&&(this.ri=[]),this.ri.push(e),this.oi&&e(this.oi,this.si),()=>{this.ri=this.ri.filter((t=>t!==e))}}di(){return this.Rt.persistence!==`memory`&&!this.Kr.gr&&Y.Yt()}pi(e){e!==this.si&&(this.si=e,this.di()&&Y.Xt(this.hi,e))}gi(){return this.si?this.si:this.di()?Y.Gt(this.hi):null}vi(e,t,n){e===this.oi&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.oi=e,this.Kr.register({[Wn]:[t,e,n]}))}mi(){var e=this.Kr.props[Wn];return I(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vi(null,null,null)}destroy(){clearTimeout(this.yi),this.yi=void 0,this.ii&&k&&(k.removeEventListener(yr,this.ii,{capture:!1}),this.ii=void 0),this.ri=[]}fi(){this.ii=()=>{this.di()&&Y.Jt(this.ci)},q(k,yr,this.ii,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Rt.cookieless_mode===mr)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),[r,i,a]=this.mi(),o=this.gi(),s=qe(a)&&Math.abs(n-a)>864e5,c=!1,l=!i,u=!l&&!e&&this.ni(n,r);l||u||s?(i=this.ai(),o=this.li(),Da.info(`new session ID generated`,{sessionId:i,windowId:o,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}}),a=n,c=!0):o||(o=this.li(),c=!0);var d=qe(r)&&e&&!s?r:n,f=qe(a)?a:new Date().getTime();return this.pi(o),this.vi(i,d,f),e||this.ui(),c&&this.ri.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}}ui(){clearTimeout(this.yi),this.yi=setTimeout((()=>{var[e]=this.mi();if(this.ni(new Date().getTime(),e)){var t=this.oi;this.resetSessionId(),this.ei.emit(`forcedIdleReset`,{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},ka=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},Aa=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 ja(e,t,n){return ha({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Ma={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=>Aa(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Aa(t,e))))),icontains:(e,t)=>t.map(Na).some((t=>e.map(Na).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(Na).every((t=>e.map(Na).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)))}))},Na=e=>e.toLowerCase();function Pa(e,t){return!e||Object.entries(e).every((e=>{var[n,r]=e,i=t?.[n];if(R(i)||Ge(i))return!1;var a=[String(i)],o=Ma[r.operator];return!!o&&o(r.values,a)}))}var Fa=`custom`,Ia=`i.posthog.com`,La=class{constructor(e){this.bi={},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(`.`+Ia,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.bi[this.apiHost]||(this.bi[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`:Fa),this.bi[this.apiHost]}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(this.region===Fa)return this.apiHost+t;var n=Ia+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+n;case`api`:return`https://`+this.region+`.`+n}}},Q=W(`[Surveys]`),Ra=`seenSurvey_`,za=(e,t)=>{var n=`$survey_`+t+`/`+e.id;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_`+t+`/`+e.id+`/`+e.current_iteration),n},Ba=e=>((e,t)=>{var n=``+Ra+t.id;return t.current_iteration&&t.current_iteration>0&&(n=``+Ra+t.id+`_`+t.current_iteration),n})(0,e),Va=[Ti.Popover,Ti.Widget,Ti.API],Ha={ignoreConditions:!1,ignoreDelay:!1,displayType:Oi.Popover},Ua=W(`[PostHog ExternalIntegrations]`),Wa={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},Ga=class{constructor(e){this._instance=e}nr(e,t){var n;(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return Ua.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.nr(Wa[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)}}},Ka={},qa=0,Ja=()=>{},Ya=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,Xa=`Surveys module not available`,Za=`sanitize_properties is deprecated. Use before_send instead`,Qa=`Invalid value for property_denylist config: `,$a=`posthog`,eo=!fa&&Oe?.indexOf(`MSIE`)===-1&&Oe?.indexOf(`Mozilla`)===-1,to=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:Ar(j?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:Ja,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,debug:Ce&&z(Ce?.search)&&Ce.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:_r,before_send:void 0,request_queue_config:{flush_interval_ms:ya},error_tracking:{},_onCapture:Ja,__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))},no=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],ro=e=>{var t={};for(var[n,r]of no)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(Qa+e.property_denylist)),i},io=class{constructor(){this.__forceAllowLocalhost=!1}get wi(){return this.__forceAllowLocalhost}set wi(e){U.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},ao=class e{Ii(e,t){if(e){var n=this.Ci.indexOf(e);n!==-1&&this.Ci.splice(n,1)}return this.Ci.push(t),t.initialize==null||t.initialize(),t}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 io,this.Si=!1,this.version=N.LIB_VERSION,this.ki=new Ea,this.Ci=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=to(),this.SentryIntegration=ti,this.sentryIntegration=e=>function(e,t){var n=ei(e,t);return{name:$r,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.xi=!1,this.Ti=null,this.Ai=null,this.Ei=null,this.scrollManager=new Ca(this),this.pageViewManager=new ni(this),this.rateLimiter=new Mi(this),this.requestRouter=new La(this),this.consent=new qr(this),this.externalIntegrations=new Ga(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!==$a){var i=Ka[r]??new e;return i._init(t,n,r),Ka[r]=i,Ka[$a][r]=i,i}return this._init(t,n,r)}_init(e,t,n){if(t===void 0&&(t={}),R(e)||We(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.Ri(t.debug),this.Ni=t,this.Mi=[],t.person_profiles?this.Ai=t.person_profiles:t.process_person&&(this.Ai=t.process_person),this.set_config(K({},to(t.defaults),ro(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:Fi.GZipJS;var r=this.Fi();this.persistence=new Ci(this.config,r),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Ci(P({},this.config,{persistence:`sessionStorage`}),r);var i=P({},this.persistence.props),a=P({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Oi=new ba((e=>this.Pi(e)),this.config.request_queue_config),this.Li=new Sa(this),this.__request_queue=[];var o=this.config.cookieless_mode===mr||this.config.cookieless_mode===pr&&this.consent.isExplicitlyOptedOut();if(o||(this.sessionManager=new Oa(this),this.sessionPropsManager=new Ta(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(U.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.Di(o)}),0)):(U.info(`Initializing extensions synchronously`),this.Di(o)),N.DEBUG=N.DEBUG||this.config.debug,N.DEBUG&&U.info(`Starting in debug mode`,{this:this,config:t,thisC:P({},this.config),p:i,s:a}),t.bootstrap?.distinctID!==void 0){var s=t.bootstrap.distinctID,c=this.get_distinct_id(),l=this.persistence.get_property(nr);if(t.bootstrap.isIdentifiedID&&c!=null&&c!==s&&l===hr)this.identify(s);else if(t.bootstrap.isIdentifiedID&&c!=null&&c!==s&&l===gr)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 u=this.config.get_device_id(Lr()),d=t.bootstrap.isIdentifiedID?u:s;this.persistence.set_property(nr,t.bootstrap.isIdentifiedID?gr:hr),this.register({distinct_id:s,$device_id:d})}}if(o)this.register_once({distinct_id:ur,$device_id:null},``);else if(!this.get_distinct_id()){var f=this.config.get_device_id(Lr());this.register_once({distinct_id:f,$device_id:f},``),this.persistence.set_property(nr,hr)}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()||Lr();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(nr,gr)),t()},i=n.user();`then`in i&&He(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{Promise&&Promise.resolve||Qr.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()||(Qr.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Qr.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,br),identify:e=>t(e,Sr),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.Bi())):this.Bi(),He(this.config._onCapture)&&this.config._onCapture!==Ja&&(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}Di(t){var n=performance.now(),r=P({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Ci.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Ci.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Ci.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Ci.push(new r.tracingHeaders(this)),r.siteApps&&this.Ci.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Ci.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Ci.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Ci.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Ci.push(this.logs=this.logs??new r.logs(this)),r.conversations&&this.Ci.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Ci.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Ci.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Ci.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Ci.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Ci.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,Xr)),r.toolbar&&this.Ci.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Ci.push(this.experiments=this.experiments??new r.experiments(this)),this.Ci.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.ji){var e=this.ji;this.ji=void 0,this.Sr(e)}})),this.qi(i,n)}qi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.qi(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({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&U.info(`PostHog extensions initialized (`+r+`ms)`)}Sr(e){var t;if(!j||!j.body)return U.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Sr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ji=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=F(e.supportedCompression,Fi.GZipJS)?Fi.GZipJS:F(e.supportedCompression,Fi.Base64)?Fi.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ai?this.Ai:_r}),this.Ci.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}Bi(){try{this.config.loaded(this)}catch(e){U.critical("`loaded` function failed",e)}if(this.Zi(),this.config.internal_or_test_user_hostname&&Ce!=null&&Ce.hostname){var e=Ce.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.config.cookieless_mode===mr)&&this.$i()}),1),this.Hi=new Pi(this),this.Hi.load()}Zi(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Oi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&wr(this.__request_queue,(e=>this.Pi(e))),this.__request_queue=[],this.Zi()}_handle_unload(){var e,t,n;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Vi()&&this.capture(xr),(t=this.Oi)==null||t.unload(),(n=this.Li)==null||n.unload()):this.Vi()&&this.capture(xr,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded&&(eo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=ma(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=ma(t.url,{_:new Date().getTime().toString(),ver:N.JS_SDK_VERSION,compression:t.compression});var n=t.transport??`fetch`,r=va.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===Fi.GZipJS&&De?_a(t).then((e=>{i(e)})).catch((()=>{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)}}))))}Pi(e){this.Li?this.Li.retriableRequest(e):this._send_request(e)}_execute_array(e){qa++;try{var t,n=[],r=[],i=[];wr(e,(e=>{e&&(I(t=e[0])?i.push(e):He(e)?e.call(this):I(e)&&t===`alias`?n.push(e):I(e)&&t.indexOf(`capture`)!==-1&&He(this[t])?i.push(e):r.push(e))}));var a=function(e,t){wr(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{qa--}}push(t){if(qa>0&&I(t)&&z(t[0])){var n=e.prototype[t[0]];He(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.Oi){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.zi||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=Lr(),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===br&&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=this.Yi(n?.$set_once,e!==Cr,e===Sr);if(m&&(f.$set_once=m),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=[],wr(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===Ei.DISMISSED||e===Ei.SENT){var h=t?.[Di.SURVEY_ID],g=t?.[Di.SURVEY_ITERATION];p={id:h,current_iteration:g},localStorage.getItem(Ba(p))||localStorage.setItem(Ba(p),`true`),f.$set=P({},f.$set,{[za({id:h,current_iteration:g},e===Ei.SENT?`responded`:`dismissed`)]:!0})}else e===Ei.SHOWN&&(f.$set=P({},f.$set,{[Di.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===ki.SHOWN){var _=t?.[Ai.TOUR_TYPE];_&&(f.$set=P({},f.$set,{[Ai.TOUR_LAST_SEEN_DATE+`/`+_]:new Date().toISOString()}))}var v=P({},f.properties.$set,f.$set);if(Ue(v)||this.setPersonPropertiesForFlags(v),!B(this.config.before_send)){var ee=this.Ui(f);if(!ee)return;f=ee}this.ki.emit(`eventCaptured`,f);var te={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.Pi(te):this.Oi.enqueue(te),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.config.cookieless_mode==mr||this.config.cookieless_mode==pr&&this.consent.isExplicitlyOptedOut())&&(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)&&!Ke(o.distinct_id)||We(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(!Oe)return{};var a,o,s,c,l=e?[...ci,...t||[]]:[],[u,d]=function(e){for(var t=0;$t.length>t;t++){var[n,r]=$t[t],i=n.exec(e),a=i&&(He(r)?r(i,e):r);if(a)return a}return[``,``]}(Oe);return K(Or({$os:u,$os_version:d,$browser:Xt(Oe,navigator.vendor),$device:en(Oe),$device_type:(o=Oe,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=en(o),c===ft||c===dt||c===`Kobo`||c===`Kindle Fire`||c===Ht?ut:c===jt||c===Nt||c===Mt||c===zt?`Console`:c===mt?`Wearable`:c?V:s?.userAgentDataPlatform===`Android`&&(s?.maxTouchPoints??0)>0?600>Math.min(s?.screenWidth??0,s?.screenHeight??0)/(s?.devicePixelRatio??1)?V:ut:`Desktop`),$timezone:bi(),$timezone_offset:xi()}),{$current_url:ai(Ce?.href,l,ui),$host:Ce?.host,$pathname:Ce?.pathname,$raw_user_agent:Oe.length>1e3?Oe.substring(0,997)+`...`:Oe,$browser_version:Qt(Oe,navigator.vendor),$browser_language:hi(),$browser_language_prefix:(a=hi(),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.Li?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===Fa&&(o.$lib_custom_api_host=this.config.api_host),c=e!==br||i?e!==xr||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=K(o,c),e===br&&j&&(o.title=j.title),!R(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}Oe&&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(Qa+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(U.error(Za),o=p(o,e));var m=this.Wi();return o.$process_person_profile=m,m&&!i&&this.Gi(`_calculate_event_properties`),o}Yi(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.Wi()||this.Si&&!n)return e;var r=K({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(U.error(Za),r=i(r,`$set_once`)),t&&(this.Si=!0),Ue(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)}Xi(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.ki.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:Xa}),()=>{})}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:Xa})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Xa})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=Ha),(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:Xa}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:Xa})}Ji(e){return!e||We(e)?(U.critical(`Unique user id has not been set in posthog.identify`),!1):e===ur?(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(Ke(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.Ji(e)&&this.Gi(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(jn)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Mn)&&(this.unregister(Mn),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(nr)||hr)===hr;e!==r&&a?(this.persistence.set_property(nr,gr),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(Sr,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.Ei=ja(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister(Qn))}}setPersonProperties(e,t){if((e||t)&&this.Gi(`posthog.setPersonProperties`)){var n=ja(this.get_distinct_id(),e,t);this.Ei===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.Ei=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(Cr,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.Gi(`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;if(U.info(`reset`),!this.__loaded)return U.uninitializedWarning(`posthog.reset`);var c=this.get_property(jn);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),(r=this.surveys)==null||r.reset(),(i=this.Hi)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.persistence)==null||o.set_property(nr,hr),(s=this.sessionManager)==null||s.resetSessionId(),this.Ei=null,this.config.cookieless_mode===mr)this.register_once({distinct_id:ur,$device_id:null},``);else{var l=this.config.get_device_id(Lr());this.register_once({distinct_id:l,$device_id:e?l:c},``)}this.register({$last_posthog_reset:new Date().toISOString()},1),this.reloadFeatureFlags()}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(An)?(U.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.Gi(`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.Xi(Mn,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;K(this.config,ro(e));var d=this.Fi();(n=this.persistence)==null||n.update_config(this.config,t,d),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Ci(P({},this.config,{persistence:`sessionStorage`}),d);var f=this.Ri(this.config.debug);Je(f)&&(this.config.debug=f),Je(this.config.debug)&&(this.config.debug?(N.DEBUG=!0,J.Yt()&&J.Xt(`ph_debug`,!0),U.info(`set_config`,{config:e,oldConfig:t,newConfig:P({},this.config)})):(N.DEBUG=!1,J.Yt()&&J.Jt(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),(s=this.exceptionObserver)==null||s.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(l=this.surveys)==null||l.loadIfEnabled(),this.Ki(),(u=this.externalIntegrations)==null||u.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))}}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??$a;return e!==$a&&(e=$a+`.`+e),e}_isIdentified(){return this.persistence?.get_property(nr)===gr||this.sessionPersistence?.get_property(nr)===gr}Wi(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===_r&&!this._isIdentified()&&Ue(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Mn])&&((t=this.persistence)==null||(t=t.props)==null||!t[cr]))}Vi(){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.Wi()||this.Gi(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Gi(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}Gi(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.Xi(cr,!0),!0)}Fi(){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!==pr)}Ki(){var e,t,n=this.Fi();return this.persistence?.gr!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.gr!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==mr){if(this.config.cookieless_mode===pr&&this.consent.isExplicitlyOptedOut()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Oa(this),this.pageViewManager=new ni(this),this.persistence&&(this.sessionPropsManager=new Ta(this,this.sessionManager,this.persistence));var a=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;a&&(this.sessionRecording=this.Ii(this.sessionRecording,new a(this)))}var o;this.consent.optInOut(!0),this.Ki(),this.Zi(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==pr&&((o=this.surveys)==null||o.loadIfEnabled()),(R(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.$i()}else U.warn(Ya)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===mr?U.warn(Ya):(this.config.cookieless_mode===pr&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Ki(),this.config.cookieless_mode===pr&&(this.register({distinct_id:ur,$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.$i()))}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===mr||(this.config.cookieless_mode===pr?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Ki()}_is_bot(){return Se?ka(Se,this.config.custom_blocked_useragents):void 0}$i(){j&&(j.visibilityState===`visible`?this.xi||(this.xi=!0,this.capture(br,{title:j.title},{send_instantly:!0}),this.Ti&&=(j.removeEventListener(vr,this.Ti),null)):this.Ti||(this.Ti=this.$i.bind(this),q(j,vr,this.Ti)))}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}))}Tr(){var e,t,n,r,i,a,o=this.Ni||{};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}Ui(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 Xe(e.event)?U.warn(i+`. This can cause unexpected behavior.`):U.info(i),null}n.properties&&!Ue(n.properties)||U.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}return n}getPageViewId(){return this.pageViewManager.lr?.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)})}Ri(e){var t=Je(e)&&!e,n=J.Yt()&&J.Wt(`ph_debug`)===`true`;return!t&&(!!n||e)}};function oo(e){return e instanceof Element&&(e.id===lr||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function so(e){return!!e&&e.nodeType===1}function co(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function lo(e){return!!e&&e.nodeType===3}function uo(e){return!!e&&e.nodeType===11}function fo(e){return e?Le(e).split(/\s+/):[]}function po(e){var t=k?.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function mo(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 fo(t)}function ho(e){return B(e)?null:Le(e).split(/(\s+)/).filter((e=>No(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function go(e){var t=``;return To(e)&&!Eo(e)&&e.childNodes&&e.childNodes.length&&G(e.childNodes,(function(e){lo(e)&&e.textContent&&(t+=ho(e.textContent)??``)})),Le(t)}function _o(e){return R(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}ao.__defaultExtensionClasses={},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=Dr(e.prototype[t[n]])}(ao,[`identify`]);var vo=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function yo(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 bo(e){var t=e.parentNode;return!(!t||!so(t))&&t}var xo=[`next`,`previous`,`prev`,`>`,`<`],So=[`.ph-no-rageclick`,`.ph-no-capture`],Co=e=>!e||co(e,`html`)||!so(e),wo=(e,t)=>{if(!k||Co(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!co(i,`body`);)if(uo(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=bo(i);if(!a)break;if(t||vo.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 To(e){for(var t=e;t.parentNode&&!co(t,`body`);t=t.parentNode){var n=mo(t);if(F(n,`ph-sensitive`)||F(n,`ph-no-capture`))return!1}if(F(mo(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 Eo(e){return!!(co(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||co(e,`select`)||co(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var Do=`(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})`,Oo=RegExp(`^(?:`+Do+`)$`),ko=new RegExp(Do),Ao=`\\d{3}-?\\d{2}-?\\d{4}`,jo=RegExp(`^(`+Ao+`)$`),Mo=RegExp(`(`+Ao+`)`);function No(e,t){return t===void 0&&(t=!0),!(B(e)||z(e)&&(e=Le(e),(t?Oo:ko).test((e||``).replace(/[- ]/g,``))||(t?jo:Mo).test(e)))}function Po(e){var t=go(e);return No(t=(t+` `+Fo(e)).trim())?t:``}function Fo(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&G(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=go(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+Fo(e)).trim())}catch(e){U.error(`[AutoCapture]`,e)}})),t}function Io(e){return e.replace(/"|\\"/g,`\\"`)}function Lo(e){var t=e.attr__class;return t?I(t)?t:fo(t):void 0}var Ro=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}},zo=`$copy_autocapture`,Bo=W(`[AutoCapture]`);function Vo(e,t){return t.length>e?t.slice(0,e)+`...`:t}function Ho(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!so(t));return t}function Uo(e,t){for(var n,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:s}=t,c=[e],l=e;l.parentNode&&!co(l,`body`);)uo(l.parentNode)?(c.push(l.parentNode.host),l=l.parentNode.host):(c.push(l.parentNode),l=l.parentNode);var u,d,f=[],p={},m=!1,h=!1;if(G(c,(e=>{var t=To(e);e.tagName.toLowerCase()===`a`&&(m=e.getAttribute(`href`),m=t&&m&&No(m)&&m),F(mo(e),`ph-no-capture`)&&(h=!0),f.push(function(e,t,n,r){var i=e.tagName.toLowerCase(),a={tag_name:i};vo.indexOf(i)>-1&&!n&&(a.$el_text=i.toLowerCase()===`a`||i.toLowerCase()===`button`?Vo(1024,Po(e)):Vo(1024,go(e)));var o=mo(e);o.length>0&&(a.classes=o.filter((function(e){return e!==``}))),G(e.attributes,(function(n){var i;if((!Eo(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&No(n.value)&&(!z(i=n.name)||i.substring(0,10)!==`_ngcontent`&&i.substring(0,7)!==`_nghost`)){var o=n.value;n.name===`class`&&(o=fo(o).join(` `)),a[`attr__`+n.name]=Vo(1024,o)}}));for(var s=1,c=1,l=e;l=Ho(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(!To(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&&No(r)&&(t[n]=r)}})),t}(e))})),h)return{props:{},explicitNoCapture:h};if(a||(f[0].$el_text=e.tagName.toLowerCase()===`a`||e.tagName.toLowerCase()===`button`?Po(e):go(e)),m){var g;f[0].attr__href=m;var _=ri(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 Tr(r).sort(((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)})).forEach((e=>{var[t,n]=e;return i[Io(t.toString())]=Io(n.toString())})),(t+=`:`)+Tr(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:Lo(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Tr(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 Wo=W(`[ExceptionAutocapture]`);function Go(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return He(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var Ko=W(`[TracingHeaders]`),qo=W(`[Web Vitals]`),Jo=9e5,Yo=`disabled`,Xo=`lazy_loading`,Zo=`awaiting_config`,Qo=`missing_config`;W(`[SessionRecording]`);var $o=`[SessionRecording]`,es=W($o),ts=W(`[Heatmaps]`);function ns(e){return L(e)&&`clientX`in e&&`clientY`in e&&Ke(e.clientX)&&Ke(e.clientY)}var rs=W(`[Product Tours]`),is=`ph_product_tours`,as=[`$set_once`,`$set`],os=W(`[SiteApps]`),ss=`Error while initializing PostHog app with config id `;function cs(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 ls=class{constructor(e){this.Qi=new Ea,this.tn=(e,t)=>this.en(e,t)&&this.rn(e,t)&&this.nn(e,t)&&this.sn(e,t),this.en=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.an=new Set,this.ln=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.ln)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.an)==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.an.has(e)||this.an.has(t?.event))&&this.ln&&this.ln?.size>0&&this.ln.forEach((e=>{this.un(t,e)&&this.Qi.emit(`actionCaptured`,e.name)}))}hn(e){this.onAction(`actionCaptured`,(t=>e(t)))}un(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.tn(e,n))return!0;return!1}onAction(e,t){return this.Qi.on(e,t)}rn(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`||!cs(r,t.url,t.url_matching||`contains`))return!1}return!0}nn(e,t){return!!this.cn(e,t)&&!!this.dn(e,t)&&!!this.vn(e,t)}cn(e,t){var n;if(t==null||!t.href)return!0;var r=this.fn(e);if(r.length>0)return r.some((e=>cs(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&cs((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}dn(e,t){var n;if(t==null||!t.text)return!0;var r=this.fn(e);if(r.length>0)return r.some((e=>cs(e.text,t.text,t.text_matching||`exact`)||cs(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=>cs(e,a,o))))}vn(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}fn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}sn(e,t){return t==null||!t.properties||t.properties.length===0||Pa(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)}},us=class{constructor(e){this._instance=e,this.pn=new Map,this.gn=new Map,this.mn=new Map}yn(e,t){return!!e&&Pa(e.propertyFilters,t?.properties)}bn(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}wn(e,t,n){var r=(n===wi.Activation?this.pn:this.gn).get(e),i=[];return this._n((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.yn(a,t)}))}register(e){R(this._instance?._addCaptureHook)||(this.In(e),this.Cn(e))}Cn(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.Sn??(this.Sn=new ls(this._instance),this.Sn.init(),this.Sn.hn((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.Sn)==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.mn.get(t.name);n&&n.push(e.id),this.mn.set(t.name,n||[e.id])}})))})))}In(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.pn=this.bn(e,wi.Activation),this.gn=this.bn(e,wi.Cancellation))}onEvent(e,t){var n,r=this.re(),i=this.kn(),a=this.xn(),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.Tn(o))}}else{if(this.gn.has(e)){var d=this.wn(e,t,wi.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.An(e.id)})),this.Tn(o))}if(this.pn.has(e)){r.info(`event name matched`,{event:e,eventPayload:t,items:this.pn.get(e)});var f=this.wn(e,t,wi.Activation);this.Tn(o.concat(f.map((e=>e.id))||[]))}}}onAction(e){var t,n=this.kn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[];this.mn.has(e)&&this.Tn(r.concat(this.mn.get(e)||[]))}Tn(e){var t,n=this.re(),r=this.kn(),i=[...new Set(e)].filter((e=>!this.En(e)));n.info(`updating activated items`,{activatedItems:i}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:i})}getActivatedIds(){var e,t=this.kn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.pn}Rn(){return this.Sn}},ds=class extends us{constructor(e){super(e)}kn(){return`$surveys_activated`}xn(){return Ei.SHOWN}_n(e){var t;(t=this._instance)==null||t.getSurveys(e)}An(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}re(){return Q}En(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},fs=`SDK is not enabled or survey functionality is not yet loaded`,ps=`Disabled. Not loading surveys.`,ms=k!=null&&k.location?oi(k.location.hash,`__posthog`)||oi(location.hash,`state`):null,hs=`_postHogToolbarParams`,gs=W(`[Toolbar]`),$=W(`[FeatureFlags]`),_s=W(`[FeatureFlags]`,{debugEnabled:!0}),vs=`" failed. Feature flags didn't load in time.`,ys=`$active_feature_flags`,bs=`$override_feature_flags`,xs=`$feature_flag_payloads`,Ss=`$override_feature_flag_payloads`,Cs=`$feature_flag_request_id`,ws=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},Ts=e=>{var t={};for(var[n,r]of Tr(e||{}))r&&(t[n]=r);return t},Es=W(`[Error tracking]`),Ds=`Refusing to render web experiment since the viewer is a likely bot`,Os={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&&Aa(t.href,e),not_regex:(e,t)=>!!k&&!Aa(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e},ks=class e{get Rt(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.Nn(`retrieved web experiments from the server`),n.Mn=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.Mn&&(e.Nn(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.Mn)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);z(i)&&t.variants[i]&&n.Fn(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.On(o)&&n.Fn(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.Nn(Ds);else if(!this.Rt.disable_web_experiments){if(B(this.Mn))return this.Mn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.Nn(`applying feature flags`,t),t.forEach((e=>{var t;if(this.Mn&&(t=this.Mn)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.Mn?.get(e);n&&r!=null&&r.variants[n]&&this.Fn(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=ii(t?.search,`__experiment_id`),r=ii(t?.search,`__experiment_variant`);n&&r&&(e.Nn(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.Pn(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Rt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Rt.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.Rt.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Pn(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.Nn(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.Fn(i[0].name,n,i[0].variants[n].transforms))}static On(t){return!B(t.conditions)&&e.Ln(t)&&e.Dn(t)}static Ln(t){if(B(t.conditions)||B(t.conditions?.url))return!0;var n,r=e.getWindowLocation();return!!r&&((n=t.conditions)==null||!n.url||Os[t.conditions?.urlMatchType??`icontains`](t.conditions.url,r))}static getWindowLocation(){return k?.location}static Dn(e){if(B(e.conditions)||B(e.conditions?.utm))return!0;var t=fi();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 Nn(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)}Fn(t,n,r){this._is_bot()?e.Nn(Ds):n===`control`?e.Nn(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.Nn(`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 Se&&this._instance?ka(Se,this.Rt.custom_blocked_useragents):void 0}},As=W(`[Conversations]`),js=`Conversations not available yet.`,Ms={featureFlags:class{constructor(e){this.Bn=!1,this.jn=!1,this.qn=!1,this.Zn=!1,this.$n=!1,this.Hn=!1,this.Vn=!1,this.zn=!1,this._instance=e,this.featureFlagEventHandlers=[]}get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}Yn(e){return this._instance.get_property(e)}Un(){var e;return(e=this.Kr?.mr(this.Rt.feature_flag_cache_ttl_ms))!=null&&e}Wn(){return!!this.Un()&&(this.zn||this.qn||(this.zn=!0,$.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}Gn(){var e=this.Rt.evaluation_contexts??this.Rt.evaluation_environments;return!this.Rt.evaluation_environments||this.Rt.evaluation_contexts||this.Vn||($.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.Vn=!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})):[]}Xn(){return this.Gn().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.jn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Yn(Jn),t=this.Yn(bs),n=this.Yn(Ss);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.Bn||=($.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getFlagVariants(){var e=this.Yn(Kn),t=this.Yn(bs);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.Bn||=($.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.Yn(xs),t=this.Yn(Ss);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.Bn||=($.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.Zn||this.Rt.advanced_disable_feature_flags||this.Jn||(this._instance.ki.emit(`featureFlagsReloading`,!0),this.Jn=setTimeout((()=>{this.Kn()}),5))}Qn(){clearTimeout(this.Jn),this.Jn=void 0}ensureFlagsLoaded(){this.jn||this.qn||this.Jn||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Zn=e}Kn(e){if(this.Qn(),!this._instance.Tr())if(this.qn)this.$n=!0;else{var t=this.Rt.token,n=this.Yn(jn),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.Kr?.get_initial_props()||{},this.Yn(Yn)||{}),group_properties:this.Yn(Xn),timezone:bi()};Ge(n)||R(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Rt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Xn()&&(r.evaluation_contexts=this.Gn());var i=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Rt.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.Rt.disable_compression?void 0:Fi.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,a=!0;if(e.statusCode===200&&(this.$n||(this.$anon_distinct_id=void 0),a=!1),this.qn=!1,!r.disable_flags||this.$n){this.Hn=!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.Kr)==null||i.register({[er]: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),this.$n&&(this.$n=!1,this.Kn()))}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.Hn)if(this.jn||this.getFlags()&&this.getFlags().length>0){if(!this.Wn()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else $.warn(`getFeatureFlag for key "`+e+vs)}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.Hn)if(this.jn||this.getFlags()&&this.getFlags().length>0){if(!this.Wn()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Yn(Cs)||void 0,c=this.Yn(tr)||void 0,l=this.Yn(Qn)||{};if(this.Rt.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.Yn($n);d&&d!==f&&(l={},(u=this.Kr)==null||u.register({[Qn]:l,[$n]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,ee,te;I(l[e])?l[e].push(o):l[e]=[o],(p=this.Kr)==null||p.register({[Qn]:l});var y=this.getFeatureFlagDetails(e),b=[...this.Yn(er)??[]];R(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.Rt.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Rt.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.Hn};R(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),R(y?.original_variant)&&R(y?.original_enabled)||(x.$feature_flag_original_response=R(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(!R(a))try{C=JSON.parse(a)}catch{}return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:C}}}}else $.warn(`getFeatureFlagResult for key "`+e+vs)}getRemoteConfigPayload(e,t){var n=this.Rt.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.Xn()&&(r.evaluation_contexts=this.Gn()),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Rt.disable_compression?void 0:Fi.Base64,timeout:this.Rt.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.Hn){if(this.jn||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return R(n)?void 0:!!n}$.warn(`isFeatureEnabled for key "`+e+vs)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this.Kr){this.jn=!0;var n=this.getFlagVariants(),r=this.getFlagPayloads(),i=this.getFlagsWithDetails();(function(e,t,n,r,i){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var a=(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),o=a.flags,s=a.featureFlags,c=a.featureFlagPayloads;if(s){var l=e.requestId,u=e.evaluatedAt;if(I(s)){$.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var d={};if(s)for(var f=0;s.length>f;f++)d[s[f]]=!0;t&&t.register({[ys]:s,[Kn]:d})}else{var p=s,m=c,h=o;if(e.errorsWhileComputingFlags)if(o){var g=new Set(Object.keys(o).filter((e=>{var t;return!((t=o[e])!=null&&t.failed)})));p=P({},n,Object.fromEntries(Object.entries(p).filter((e=>{var[t]=e;return g.has(t)})))),m=P({},r,Object.fromEntries(Object.entries(m||{}).filter((e=>{var[t]=e;return g.has(t)})))),h=P({},i,Object.fromEntries(Object.entries(h||{}).filter((e=>{var[t]=e;return g.has(t)}))))}else p=P({},n,p),m=P({},r,m),h=P({},i,h);t&&t.register(P({[ys]:Object.keys(Ts(p)),[Kn]:p||{},[xs]:m||{},[Jn]:h||{}},l?{[Cs]:l}:{},u?{[tr]:u}:{}))}}})(e,this.Kr,n,r,i),t||(this.zn=!1),this.ts(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.Kr)return $.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.Kr.unregister(bs),this.Kr.unregister(Ss),this.ts(),_s.info(`All overrides cleared`);if(I(e)){var t=ws(e);return this.Kr.register({[bs]:t}),this.ts(),_s.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Bn=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.Kr.unregister(bs),_s.info(`Flag overrides cleared`);else if(r.flags){if(I(r.flags)){var i=ws(r.flags);this.Kr.register({[bs]:i})}else this.Kr.register({[bs]:r.flags});_s.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.Kr.unregister(Ss),_s.info(`Payload overrides cleared`)):r.payloads&&(this.Kr.register({[Ss]:r.payloads}),_s.info(`Payload overrides set`,{payloads:r.payloads}))),this.ts();return}if(e&&typeof e==`object`)return this.Kr.register({[bs]:e}),this.ts(),_s.info(`Flag overrides set`,{flags:e});$.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.jn){var{flags:t,flagVariants:n}=this.es();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.Yn(qn)||[]).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.Kr)==null||r.register({[ys]:Object.keys(Ts(s)),[Kn]:s}),this.ts()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Yn(qn),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.Rt.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.Kr)==null||n.unregister(qn),(r=this.Kr)==null||r.register({[qn]:i}),e(i)}}})}es(){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)),{})}}ts(e){var{flags:t,flagVariants:n}=this.es();this.featureFlagEventHandlers.forEach((r=>r(t,n,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Yn(Yn)||{},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({[Yn]:P({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Yn)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Yn(Xn)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=P({},n[t],e[t]),delete e[t]})),this._instance.register({[Xn]:P({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Yn(Xn)||{};this._instance.register({[Xn]:P({},t,{[e]:{}})})}else this._instance.unregister(Xn)}reset(){this.jn=!1,this.qn=!1,this.Zn=!1,this.$n=!1,this.Hn=!1,this.$anon_distinct_id=void 0,this.Qn(),this.Bn=!1}}},Ns={sessionRecording:class{get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}get started(){var e;return!((e=this.rs)==null||!e.isStarted)}get status(){return this.ns===Zo||this.ns===Qo?this.ns:this.rs?.status??this.ns}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.ns=Yo,this.ss=void 0,this._instance=e,!this._instance.sessionManager)throw es.error(`started without valid sessionManager`),Error($o+` started without valid sessionManager. This is a bug.`);if(this.Rt.cookieless_mode===mr)throw Error($o+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get os(){var e,t=!((e=this._instance.get_property(Un))==null||!e.enabled),n=!this.Rt.disable_session_recording,r=this.Rt.disable_session_recording||this._instance.consent.isOptedOut();return k&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this.os||(t=this.rs)==null||!t.isStarted){var n=!R(Object.assign)&&!R(Array.from);this.os&&n?(this.ls(e),es.info(`starting`)):(this.ns=Yo,this.stopRecording())}}ls(e){var t,n,r;this.os&&(this.ns!==Zo&&this.ns!==Qo&&(this.ns=Xo),M!=null&&(t=M.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=M.__PosthogExtensions__)!=null&&n.initSessionRecording?this.us(e):(r=M.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.hs,(t=>{if(t)return es.error(`could not load recorder`,t);this.us(e)})))}stopRecording(){var e,t;(e=this.ss)==null||e.call(this),this.ss=void 0,(t=this.rs)==null||t.stop()}cs(){var e,t;(e=this.ss)==null||e.call(this),this.ss=void 0,(t=this.rs)==null||t.discard()}ds(){var e;(e=this.Kr)==null||e.unregister(Gn)}vs(e,t){if(B(e))return null;var n,r=Ke(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(es.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}fs(e){if(this.Kr){var t,n=this.Kr,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.vs(this.Rt.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.vs(t?.sampleRate,`remote config sampleRate`),a=r??i;B(a)&&this.ds();var o=t?.minimumDurationMilliseconds;n.register({[Un]: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})})};r(),(t=this.ss)==null||t.call(this),this.ss=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this.fs(e),this.cs()):(this.fs(e),this.startIfEnabledOrStop()):(this.ns===Zo&&(this.ns=Qo,es.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.rs)!=null&&n.log?this.rs.log(e,t):es.warn(`log called before recorder was ready`)}get hs(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Un);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}ps(){var e=this._instance.get_property(Un);if(!e)return!1;var t=(typeof e==`object`?e:JSON.parse(e)).cache_timestamp??Date.now();return 36e5>=Date.now()-t}us(e){var t;if((t=M.__PosthogExtensions__)==null||!t.initSessionRecording)return es.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.rs||(this.rs=M.__PosthogExtensions__?.initSessionRecording(this._instance),this.rs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ps()){if(this.ns===Qo||this.ns===Zo)return;this.ns=Zo,es.info(`persisted remote config is stale, requesting fresh config before starting`),new Pi(this._instance).load();return}this.ns=Xo,this.rs.start(e)}onRRwebEmit(e){var t;(t=this.rs)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.rs||(t=this.Kr)==null||t.register({$replay_override_linked_flag:!0}),(e=this.rs)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.rs||(t=this.Kr)==null||t.register({$replay_override_sampling:!0}),(e=this.rs)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.rs||(n=this.Kr)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this.rs)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.rs?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.rs)==null||!n.tryAddCustomEvent(e,t))}}},Ps={autocapture:class{constructor(e){this.gs=!1,this.ys=null,this.bs=!1,this.instance=e,this.rageclicks=new Ro(e.config.rageclick),this.ws=null}initialize(){this.startIfEnabled()}get Rt(){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}_s(){if(this.isBrowserSupported()){if(k&&j){var e=e=>{e||=k?.event;try{this.Is(e)}catch(e){Bo.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.Rt.capture_copied_text){var t=e=>{this.Is(e||=k?.event,zo)};q(j,`copy`,t,{capture:!0}),q(j,`cut`,t,{capture:!0})}}}else Bo.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.gs&&(this._s(),this.gs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.bs=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Pn]:!!e.autocapture_opt_out}),this.ys=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.ws=e}getElementSelectors(e){var t,n=[];return(t=this.ws)==null||t.forEach((t=>{(j?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[Pn];if(Ge(this.ys)&&!Je(e)&&!this.instance.Tr())return!1;var t=this.ys??!!e;return!!this.instance.config.autocapture&&!t}Is(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=_o(e);lo(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||Co(e))return!1;var n,r;if(Je(t)?(n=!!t&&So,r=void 0):(n=t?.css_selector_ignorelist??So,r=t?.content_ignorelist),!1===n)return!1;var{targetElementList:i}=wo(e,!1);return!function(e,t){if(!1===e||R(e))return!1;var n;if(!0===e)n=xo;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:go(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!yo(i,n)}(r,this.instance.config.rageclick)&&this.Is(e,`$rageclick`);var i=t===zo;if(r&&function(e,t,n,r,i){var a,o,s;if(n===void 0&&(n=void 0),!k||Co(e)||(a=n)!=null&&a.url_allowlist&&!po(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&po(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}=wo(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)||!yo(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&&(vo.indexOf(f)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.Rt,i,i?[`copy`,`cut`]:void 0)){var{props:a,explicitNoCapture:o}=Uo(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Rt.element_attribute_ignorelist,elementsChainAsString:this.bs});if(o)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(a.$element_selectors=s),t===zo){var c,l=ho(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 He(j?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.Cs=(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.Ss&&this.Ss(),this.Ss=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__||Go(k.history,`pushState`,(e=>function(t,r,i){e.call(this,t,r,i),n.ks(`pushState`)})),(t=k.history.replaceState)!=null&&t.__posthog_wrapped__||Go(k.history,`replaceState`,(e=>function(t,r,i){e.call(this,t,r,i),n.ks(`replaceState`)})),this.xs()}}ks(e){try{var t,n=k==null||(t=k.location)==null?void 0:t.pathname;if(!n)return;n!==this.Cs&&this.isEnabled&&this._instance.capture(br,{navigation_type:e}),this.Cs=n}catch(t){U.error(`Error capturing `+e+` pageview`,t)}}xs(){if(!this.Ss){var e=()=>{this.ks(`popstate`)};q(k,`popstate`,e),this.Ss=()=>{k&&k.removeEventListener(`popstate`,e)}}}},heatmaps:class{get Rt(){return this.instance.config}constructor(e){var t;this.Ts=!1,this.gs=!1,this.As=null,this.instance=e,this.Ts=!((t=this.instance.persistence)==null||!t.props[Fn]),this.rageclicks=new Ro(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return L(this.Rt.capture_heatmaps)&&this.Rt.capture_heatmaps.flush_interval_milliseconds&&(e=this.Rt.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return B(this.Rt.capture_heatmaps)?B(this.Rt.enable_heatmaps)?this.Ts:this.Rt.enable_heatmaps:!1!==this.Rt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.gs)return;ts.info(`starting...`),this.Es(),this.Tt()}else clearInterval(this.As??void 0),this.Rs(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Fn]:t}),this.Ts=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.T;return this.T=void 0,e}Ns(e){this.wt(e.originalEvent,`deadclick`)}Tt(){this.As&&clearInterval(this.As),this.As=j?.visibilityState===`visible`?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Es(){k&&j&&(this.Ms=this.Zr.bind(this),q(k,yr,this.Ms),this.Fs=e=>this.wt(e||k?.event),q(j,`click`,this.Fs,{capture:!0}),this.Os=e=>this.Ps(e||k?.event),q(j,`mousemove`,this.Os,{capture:!0}),this.Ls=new Zr(this.instance,Yr,this.Ns.bind(this)),this.Ls.startIfEnabledOrStop(),this.Ds=this.Tt.bind(this),q(j,vr,this.Ds),this.gs=!0)}Rs(){var e;k&&j&&(this.Ms&&k.removeEventListener(yr,this.Ms),this.Fs&&j.removeEventListener(`click`,this.Fs,{capture:!0}),this.Os&&j.removeEventListener(`mousemove`,this.Os,{capture:!0}),this.Ds&&j.removeEventListener(vr,this.Ds),clearTimeout(this.Bs),(e=this.Ls)==null||e.stop(),this.gs=!1)}js(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&&so(r)&&!co(r,`body`);){if(r===n)return!1;if(F(t,k?.getComputedStyle(r).position))return!0;r=bo(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}}wt(e,t){var n;if(t===void 0&&(t=`click`),!oo(e.target)&&ns(e)){var r=this.js(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.qs(P({},r,{type:`rageclick`})),this.qs(r)}}Ps(e){!oo(e.target)&&ns(e)&&(clearTimeout(this.Bs),this.Bs=setTimeout((()=>{this.qs(this.js(e,`mousemove`))}),500))}qs(e){if(k){var t=k.location.href,n=this.Rt.custom_personal_data_properties,r=ai(t,this.Rt.mask_personal_data_properties?[...ci,...n||[]]:[],ui);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(e)}}Zr(){this.T&&!Ue(this.T)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Zr,webVitalsAutocapture:class{constructor(e){var t;this.Ts=!1,this.gs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Zs=()=>{clearTimeout(this.$s),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.nt=e=>{var t=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0);if(R(t))qo.error(`Could not read session ID. Dropping metrics!`);else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Hs();R(n)||(B(e?.name)||B(e?.value)?qo.error(`Invalid metric received`,e):!this.Vs||this.Vs>e.value?(this.T.url!==n&&(this.Zs(),this.$s=setTimeout(this.Zs,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.Zs()):qo.error(`Ignoring metric with value >= `+this.Vs,e))}},this.zs=()=>{if(!this.gs){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.nt.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.nt.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.nt.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.nt.bind(this)),this.gs=!0):qo.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.Ts=!((t=this._instance.persistence)==null||!t.props[zn]),this.startIfEnabled()}get Ys(){return this._instance.config.capture_performance}get allowedMetrics(){var e=L(this.Ys)?this.Ys?.web_vitals_allowed_metrics:void 0;return B(e)?this._instance.persistence?.props[Hn]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(L(this.Ys)?this.Ys.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=L(this.Ys)?this.Ys.web_vitals_attribution:void 0;return e!=null&&e}get Vs(){var e=L(this.Ys)&&Ke(this.Ys.__web_vitals_max_value)?this.Ys.__web_vitals_max_value:Jo;return e>0&&6e4>=e?Jo:e}get isEnabled(){var e=Ce?.protocol;if(e!==`http:`&&e!==`https:`)return qo.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=L(this.Ys)?this.Ys.web_vitals:Je(this.Ys)?this.Ys:void 0;return Je(t)?t:this.Ts}startIfEnabled(){this.isEnabled&&!this.gs&&(qo.info(`enabled, starting...`),this.nr(this.zs))}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({[zn]:t}),this._instance.persistence.register({[Hn]:n})),this.Ts=t,this.startIfEnabled()}}nr(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?qo.error(`failed to load script`,t):e()}))}Hs(){var e=k?k.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return ai(e,this._instance.config.mask_personal_data_properties?[...ci,...t||[]]:[],ui)}qo.error(`Could not determine current URL`)}}},Fs={exceptionObserver:class{constructor(e){var t;this.zs=()=>{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.Us&&this.Rt.capture_unhandled_errors&&(this.Us=t(this.captureException.bind(this))),!this.Ws&&this.Rt.capture_unhandled_rejections&&(this.Ws=n(this.captureException.bind(this))),!this.Gs&&this.Rt.capture_console_errors&&(this.Gs=r(this.captureException.bind(this)))}catch(e){Wo.error(`failed to start`,e),this.Xs()}}},this._instance=e,this.Js=!((t=this._instance.persistence)==null||!t.props[In]),this.Ks=new it({refillRate:this._instance.config.error_tracking.__exceptionRateLimiterRefillRate??1,bucketSize:this._instance.config.error_tracking.__exceptionRateLimiterBucketSize??10,refillInterval:1e4,qt:Wo}),this.Rt=this.Qs(),this.startIfEnabledOrStop()}Qs(){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.Js:e)&&(t=P({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Rt.capture_console_errors||this.Rt.capture_unhandled_errors||this.Rt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Wo.info(`enabled`),this.Xs(),this.nr(this.zs)):this.Xs()}nr(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 Wo.error(`failed to load script`,t);e()}))}Xs(){var e,t,n;(e=this.Us)==null||e.call(this),this.Us=void 0,(t=this.Ws)==null||t.call(this),this.Ws=void 0,(n=this.Gs)==null||n.call(this),this.Gs=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.Js=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[In]:this.Js}),this.Rt=this.Qs(),this.startIfEnabledOrStop())}onConfigChange(){this.Rt=this.Qs()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.Ks.consumeRateLimit(r)?Wo.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.eo=[],this.ro=new rn([new gn,new En,new vn,new _n,new wn,new Cn,new bn,new Tn],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=hn.test(s)?s.replace(hn,`$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||an});var n}))}(i)}}(`web:javascript`,dn,mn)),this._instance=e,this.eo=this._instance.persistence?.get_property(Ln)??[]}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.eo=t,this._instance.persistence&&this._instance.persistence.register({[Ln]:this.eo,[Rn]:n})}}get io(){var e,t=!!this._instance.get_property(Rn);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.ro.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.no(t)){if(this.so(t))return void Es.info(`Skipping exception capture because a suppression rule matched`);if(!this.io&&this.oo(t))return void Es.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ao(t))return void Es.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}return this._instance.capture(`$exception`,e,{_noTruncate:!0,_batchKey:`exceptionEvent`,zi:!0})}so(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.eo.some((e=>{var n=e.values.map((e=>{var n=Ma[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)}))}oo(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}ao(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}no(e){return!B(e)&&I(e)}}},Is=P({productTours:class{get Kr(){return this._instance.persistence}constructor(e){this.lo=null,this.uo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.Kr&&this.Kr.register({[Vn]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.lo||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Vn)||this.nr((()=>this.ho()))}nr(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()}))}ho(){var e;!this.lo&&(e=M.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.lo=M.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!I(this.uo)||t){var n=this.Kr;if(n){var r=n.props[is];if(I(r)&&!t)return this.uo=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.uo=a,n&&n.register({[is]:a}),e(a,{isLoaded:!0})}})}else e(this.uo,{isLoaded:!0})}getActiveProductTours(e){B(this.lo)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.lo.getActiveProductTours(e)}showProductTour(e){var t;(t=this.lo)==null||t.showTourById(e)}previewTour(e){this.lo?this.lo.previewTour(e):this.nr((()=>{var t;this.ho(),(t=this.lo)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.lo)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.lo)==null||e.nextStep()}previousStep(){var e;(e=this.lo)==null||e.previousStep()}clearCache(){var e;this.uo=null,(e=this.Kr)==null||e.unregister(is)}resetTour(e){var t;(t=this.lo)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.lo)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.lo)==null||t.cancelPendingTour(e)}}},Ms),Ls={siteApps:class{constructor(e){this._instance=e,this.co=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}do(e,t){if(t){var n=this.globalsForEvent(t);this.co.push(n),this.co.length>1e3&&(this.co=this.co.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.do.bind(this));this.vo=()=>{e(),this.co=[],this.vo=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({},Me(e,as),{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.co.length&&(os.info(`Processing `+this.co.length+` events for site app with id `+e.id),this.co.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.vo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,os.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){os.error(ss+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){os.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}fo(){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){os.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.fo(),void this._instance.on(`eventCaptured`,(e=>this.po(e)))):void os.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.vo)==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 os.error(ss+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else os.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},Rs={tracingHeaders:class{constructor(e){this.mo=void 0,this.yo=void 0,this.zs=()=>{var e,t;R(this.mo)&&((e=M.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),R(this.yo)&&((t=M.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}nr(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 Ko.error(`failed to load script`,t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.nr(this.zs):((e=this.mo)==null||e.call(this),(t=this.yo)==null||t.call(this),this.mo=void 0,this.yo=void 0)}}},zs=P({surveys:class{get Rt(){return this._instance.config}constructor(e){this.bo=void 0,this._surveyManager=null,this.wo=!1,this._o=[],this.Io=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Rt.disable_surveys){var t=e.surveys;if(B(t))return Q.warn(`Flags not loaded yet. Not loading surveys.`);this.bo=I(t)?t.length>0:t,Q.info(`flags response received, isSurveysEnabled: `+this.bo),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(Ra)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.wo)Q.info(`Already initializing surveys, skipping...`);else if(this.Rt.disable_surveys)Q.info(ps);else if(this.Rt.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.bo)||this.Rt.advanced_enable_surveys){var t=this.bo||this.Rt.advanced_enable_surveys;this.wo=!0;try{var n=e.generateSurveys;if(n)return void this.Co(n,t);var r=e.loadExternalDependency;if(!r)return void this.So(fr);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.So(`Could not load surveys script`,n):this.Co(e.generateSurveys,t)}))}catch(e){throw this.So(`Error initializing surveys`,e),e}finally{this.wo=!1}}}else Q.error(`PostHog Extensions not found.`)}}Co(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new ds(this._instance),Q.info(`Surveys loaded successfully`),this.ko({isLoaded:!0})}So(e,t){Q.error(e,t),this.ko({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._o.push(e),this._surveyManager&&this.ko({isLoaded:!0}),()=>{this._o=this._o.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Rt.disable_surveys)return Q.info(ps),e([]);var n,r=this._instance.get_property(Zn);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Io?this.Io.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Io=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Rt.token),method:`GET`,timeout:this.Rt.surveys_request_timeout_ms,callback:t=>{var r;this.Io=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({[Zn]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}ko(e){for(var t of this._o)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`)}xo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}To(e){if(B(this._surveyManager))return{eligible:!1,reason:fs};var t=typeof e==`string`?this.xo(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:fs};var t=this.To(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:fs})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.To(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.xo(e):e;if(i!=null&&i.id)if(Va.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.xo(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!==Oi.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===Oi.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()}}},Ms),Bs={toolbar:class{constructor(e){this.instance=e}Ao(e){M.ph_toolbar_state=e}Eo(){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),jr(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=ms||oi(e.hash,`__posthog`)||oi(e.hash,`state`),a=i?Er((()=>JSON.parse(atob(decodeURIComponent(i)))))||Er((()=>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(hs)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Ro(e){var t=M.ph_load_toolbar||M.ph_load_editor;!B(t)&&He(t)?t(e,this.instance):gs.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(j==null||!j.getElementById(lr));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(hs,JSON.stringify(P({},r,{source:void 0}))),this.Eo()===2)this.Ro(r);else if(this.Eo()===0){var i;this.Ao(1),(i=M.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return gs.error(`[Toolbar] Failed to load`,e),void this.Ao(0);this.Ao(2),this.Ro(r)})),q(k,`turbolinks:load`,(()=>{this.Ao(0),this.loadToolbar(r)}))}return!0}No(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)}}},Vs=P({experiments:ks},Ms),Hs=P({},Ms,Ns,Ps,Fs,Is,Ls,zs,Rs,Bs,Vs,{conversations:class{constructor(e){this.Mo=void 0,this._conversationsManager=null,this.Fo=!1,this.Oo=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;B(t)||(Je(t)?this.Mo=t:(this.Mo=t.enabled,this.Oo=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Mo=void 0,this.Oo=null}loadIfEnabled(){if(!(this._conversationsManager||this.Fo||this._instance.config.disable_conversations||jr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=M?.__PosthogExtensions__;if(e&&!R(this.Mo)&&this.Mo)if(this.Oo&&this.Oo.token){this.Fo=!0;try{var t=e.initConversations;if(t)return this.Po(t),void(this.Fo=!1);var n=e.loadExternalDependency;if(!n)return void this.Lo(fr);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.Lo(`Could not load conversations script`,t):this.Po(e.initConversations),this.Fo=!1}))}catch(e){this.Lo(`Error initializing conversations`,e),this.Fo=!1}}else As.error(`Conversations enabled but missing token in remote config.`)}}Po(e){if(this.Oo)try{this._conversationsManager=e(this.Oo,this._instance),As.info(`Conversations loaded successfully`)}catch(e){this.Lo(`Error completing conversations initialization`,e)}else As.error(`Cannot complete initialization: remote config is null`)}Lo(e,t){As.error(e,t),this._conversationsManager=null,this.Fo=!1}show(){this._conversationsManager?this._conversationsManager.show():As.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Mo&&!Ge(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return je((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(As.warn(js),null)}))()}getMessages(e,t){var n=this;return je((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(As.warn(js),null)}))()}markAsRead(e){var t=this;return je((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(As.warn(js),null)}))()}getTickets(e){var t=this;return je((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(As.warn(js),null)}))()}requestRestoreLink(e){var t=this;return je((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(As.warn(js),null)}))()}restoreFromToken(e){var t=this;return je((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(As.warn(js),null)}))()}restoreFromUrlToken(){var e=this;return je((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(As.warn(js),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}}},{logs:class{constructor(e){var t;this.Do=!1,this.Bo=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Do=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!B(t)&&t&&(this.Do=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Do&&!this.Bo){var e=W(`[logs]`),t=M?.__PosthogExtensions__;if(t){var n=t.loadExternalDependency;n?n(this._instance,`logs`,(n=>{var r;n||(r=t.logs)==null||!r.initializeLogs?e.error(`Could not load logs script`,n):(t.logs.initializeLogs(this._instance),this.Bo=!0)})):e.error(fr)}else e.error(`PostHog Extensions not found.`)}}}});ao.__defaultExtensionClasses=P({},Hs);var Us,Ws=(Us=Ka[$a]=new ao,function(){function e(){e.done||(e.done=!0,eo=!1,G(Ka,(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")}(),Us),Gs;function Ks(e){Gs=e}function qs(){return Gs}var Js=(0,m.createContext)({get client(){return qs()},bootstrap:void 0});function Ys(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)||!Ys(e[s],t[s],n))return!1}return!0}function Xs(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=qs();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=qs(),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&&!Ys(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(Js.Provider,{value:{client:o,bootstrap:i?.bootstrap??n?.config?.bootstrap}},t)}var Zs=function(e){return typeof e==`function`},Qs=function(e,t){return Qs=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])},Qs(e,t)};function $s(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Qs(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ec={componentStack:null,exceptionEvent:null,error:null},tc={INVALID_FALLBACK:`[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.`};(function(e){$s(t,e);function t(t){var n=e.call(this,t)||this;return n.state=ec,n}return t.prototype.componentDidCatch=function(e,t){var n=this.props.additionalProperties,r;Zs(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 Zs(t)?t():t;var i=Zs(n)?m.default.createElement(n,{error:r.error,componentStack:r.componentStack,exceptionEvent:r.exceptionEvent}):n;return m.default.isValidElement(i)?i:(console.warn(tc.INVALID_FALLBACK),m.default.createElement(m.default.Fragment,null))},t.contextType=Js,t})(m.default.Component),Ks(Ws);var nc=({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?Ws.opt_in_capturing():Ws.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})):(Ws.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)(Xs,{client:Ws,children:a}))};exports.AppShell=te,exports.ConsentManagerProvider=oe,exports.LanguageProvider=le,exports.MenuProvider=O,exports.MicroFrontendLink=me,exports.OrganisationProvider=ye,exports.OrganisationSelector=xe,exports.OrganisationsError=be,exports.PostHogProviderWrapper=nc,exports.languageStorage=S,exports.organisationStorage=b,exports.useConsentManager=ae,exports.useLanguage=ce,exports.useMFNavigation=fe,exports.useMenu=de,exports.useMenuGroupItems=ue,exports.useOrganisation=ge,exports.useOrganisationId=_e;
|
|
6
3
|
//# sourceMappingURL=index.cjs.map
|