1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/userService-BHOTfUp_.js","assets/apiClient-CEHBCmoT.js"])))=>i.map(i=>d[i]); 2import{r as wn}from"./mixpanel-Dn-GqnH4.js";import{f as A,m as xn,n as Rn,p as We,o as Cn,u as Pn,c as V,q as Wt,r as zt,s as $t,t as ze,v as Nn,w as $e,x as jt,C as _e,y as _n,z as kn,B as E,g as f,D as G,a as Y,b as J,d as X,j as w,E as H,l as x,F as Gt,H as de,G as le,I as K,J as Yt,S as xe,K as Re,i as W,k as z,h as $,e as P,A as N,L as Jt,M as Ae,N as Le,O as Dn}from"./userContextData-DmUF5KbC.js";const Fn="modulepreload",Mn=function(e){return"/"+e},st={},On=function(t,n,o){let s=Promise.resolve();if(n&&n.length>0){let c=function(d){return Promise.all(d.map(l=>Promise.resolve(l).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const r=document.querySelector("meta[property=csp-nonce]"),a=r?.nonce||r?.getAttribute("nonce");s=c(n.map(d=>{if(d=Mn(d),d in st)return;st[d]=!0;const l=d.endsWith(".css"),u=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const g=document.createElement("link");if(g.rel=l?"stylesheet":Fn,l||(g.as="script"),g.crossOrigin="",g.href=d,a&&g.setAttribute("nonce",a),document.head.appendChild(g),l)return new Promise((p,m)=>{g.addEventListener("load",p),g.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(r){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=r,window.dispatchEvent(a),!a.defaultPrevented)throw r}return s.then(r=>{for(const a of r||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},Xt=()=>typeof window<"u"&&typeof window.document<"u",Un=(e,t)=>e.Auth.fetchAuthSession(t),bn=e=>Un(A,e);function Zt(){return A.Auth.clearCredentials()}const Qt="cognito-identity",en={service:Qt,retryDecider:Rn(We),computeDelay:xn,cache:"no-store"},Kn=()=>e=>async function(n){return n.headers["cache-control"]="no-store",e(n)},tn=Cn(Pn,[Kn]),nn=e=>(t,n)=>{const o=Ln(e),s=JSON.stringify(t);return Bn(n,o,s)},Ln=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}),Bn=({url:e},t,n)=>({headers:t,url:e,body:n,method:"POST"}),it=e=>V(tn,nn("GetCredentialsForIdentity"),Vn,{...en,...e,userAgentValue:Wt()}),Vn=async e=>{if(e.statusCode>=300)throw await We(e);const t=await zt(e);return{IdentityId:t.IdentityId,Credentials:Hn(t.Credentials),$metadata:$t(e)}},Hn=({Expiration:e,...t}={})=>({...t,Expiration:e&&new Date(e*1e3)}),qn=e=>V(tn,nn("GetId"),Wn,{...en,...e,userAgentValue:Wt()}),Wn=async e=>{if(e.statusCode>=300)throw await We(e);return{IdentityId:(await zt(e)).IdentityId,$metadata:$t(e)}},zn=({region:e})=>({url:new ze(`https://${Qt}.${e}.${Nn(e)}`)});class ae extends $e{constructor(){super({name:jt.PlatformNotSupported,message:"Function not supported on current platform"})}}class on{constructor(t){this.storage=t}async setItem(t,n){if(!this.storage)throw new ae;this.storage.setItem(t,n)}async getItem(t){if(!this.storage)throw new ae;return this.storage.getItem(t)}async removeItem(t){if(!this.storage)throw new ae;this.storage.removeItem(t)}async clear(){if(!this.storage)throw new ae;this.storage.clear()}}class sn{constructor(){this.storage=new Map}get length(){return this.storage.size}key(t){return t>this.length-1?null:Array.from(this.storage.keys())[t]}setItem(t,n){this.storage.set(t,n)}getItem(t){return this.storage.get(t)??null}removeItem(t){this.storage.delete(t)}clear(){this.storage.clear()}}const rn=new _e("CoreStorageUtils"),$n=()=>{try{if(typeof window<"u"&&window.localStorage)return window.localStorage}catch{rn.info("localStorage not found. InMemoryStorage is used as a fallback.")}return new sn},an=()=>{try{if(typeof window<"u"&&window.sessionStorage)return window.sessionStorage.getItem("test"),window.sessionStorage;throw new Error("sessionStorage is not defined")}catch{return rn.info("sessionStorage not found. InMemoryStorage is used as a fallback."),new sn}};class jn extends on{constructor(){super($n())}}class Gn extends on{constructor(){super(an())}}class Yn{constructor(t){this._storage=t}get storage(){if(!this._storage)throw new ae;return this._storage}setItem(t,n){this.storage.setItem(t,n)}getItem(t){return this.storage.getItem(t)}removeItem(t){this.storage.removeItem(t)}clear(){this.storage.clear()}}class Jn extends Yn{constructor(){super(an())}}function fe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var Xn={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decode
2URIComponent)}};function Be(e,t){function n(s,i,r){if(!(typeof document>"u")){r=fe({},t,r),typeof r.expires=="number"&&(r.expires=new Date(Date.now()+r.expires*864e5)),r.expires&&(r.expires=r.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in r)r[c]&&(a+="; "+c,r[c]!==!0&&(a+="="+r[c].split(";")[0]));return document.cookie=s+"="+e.write(i,s)+a}}function o(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var i=document.cookie?document.cookie.split("; "):[],r={},a=0;a<i.length;a++){var c=i[a].split("="),d=c.slice(1).join("=");try{var l=decodeURIComponent(c[0]);if(r[l]=e.read(d,l),s===l)break}catch{}}return s?r[s]:r}}return Object.create({set:n,get:o,remove:function(s,i){n(s,"",fe({},i,{expires:-1}))},withAttributes:function(s){return Be(this.converter,fe({},this.attributes,s))},withConverter:function(s){return Be(fe({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var Ie=Be(Xn,{path:"/"});class Zn{constructor(t={}){const{path:n,domain:o,expires:s,sameSite:i,secure:r}=t;if(this.domain=o,this.path=n||"/",this.expires=Object.prototype.hasOwnProperty.call(t,"expires")?s:365,this.secure=Object.prototype.hasOwnProperty.call(t,"secure")?r:!0,Object.prototype.hasOwnProperty.call(t,"sameSite")){if(!i||!["strict","lax","none"].includes(i))throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');if(i==="none"&&!this.secure)throw new Error("sameSite = None requires the Secure attribute in latest browser versions.");this.sameSite=i}}async setItem(t,n){Ie.set(t,n,this.getData())}async getItem(t){return Ie.get(t)??null}async removeItem(t){Ie.remove(t,this.getData())}async clear(){const t=Ie.get(),n=Object.keys(t).map(o=>this.removeItem(o));await Promise.all(n)}getData(){return{path:this.path,expires:this.expires,domain:this.domain,secure:this.secure,...this.sameSite&&{sameSite:this.sameSite}}}}const he=new jn;new Gn;const O=new Jn,Qn=e=>{let t;return async(...n)=>t||(t=new Promise((o,s)=>{e(...n).then(i=>{o(i)}).catch(i=>{s(i)}).finally(()=>{t=void 0})}),t)};function rt({expiresAt:e,clockDrift:t,tolerance:n=5e3}){return Date.now()+t+n>e}const eo=async()=>{const{userAgentData:e}=navigator;if(!e)return navigator.userAgent;const{platform:t="",platformVersion:n="",model:o="",architecture:s="",fullVersionList:i=[]}=await e.getHighEntropyValues(["platform","platformVersion","architecture","model","fullVersionList"]),r=i.map(c=>`${c.brand}/${c.version}`).join(";");return[t,n,s,o,t,r].filter(c=>c).join(" ")||navigator.userAgent};function to(e){return Array.from(e,t=>String.fromCodePoint(t)).join("")}const ue={convert(e,t={urlSafe:!1,skipPadding:!1}){const n=typeof e=="string"?e:to(e);let o=_n()(n);return t.urlSafe&&(o=o.replace(/\+/g,"-").replace(/\//g,"_")),t.skipPadding&&(o=o.replace(/=/g,"")),o}};function no(){return kn().getRandomValues(new Uint32Array(1))[0]}function oo(e){const{words:t}=e,{sigBytes:n}=e,o=[];for(let s=0;s<n;s++){const i=t[s>>>2]>>>24-s%4*8&255;o.push((i>>>4).toString(16)),o.push((i&15).toString(16))}return o.join("")}class je{constructor(t,n){this.words=[];let o=t;o=this.words=o||[],n!==void 0?this.sigBytes=n:this.sigBytes=o.length*4}random(t){const n=[];for(let o=0;o<t;o+=4)n.push(no());return new je(n,t)}toString(){return oo(this)}}var at;(function(e){e.ConcurrentModificationException="ConcurrentModificationException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException"})(at||(at={}));var ct;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(ct||(ct={}));var dt;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UsernameExistsException="UsernameExistsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(dt||(dt={}));var lt;(function(e){e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyFailedAttemptsException="TooManyFailedAttemptsException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(lt||(lt={}));var ut;(function(e){e.AliasExistsException="AliasExistsException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyFailedAttemptsException="TooManyFailedAttemptsException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(ut||(ut={}));var ht;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(ht||(ht={}));var gt;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(gt||(gt={}));var pt;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(pt||(pt={}));var Et;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPol
2icyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(Et||(Et={}));var mt;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(mt||(mt={}));var ft;(function(e){e.ExternalServiceException="ExternalServiceException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceConflictException="ResourceConflictException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException"})(ft||(ft={}));var It;(function(e){e.ExternalServiceException="ExternalServiceException",e.InternalErrorException="InternalErrorException",e.InvalidIdentityPoolConfigurationException="InvalidIdentityPoolConfigurationException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceConflictException="ResourceConflictException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException"})(It||(It={}));var yt;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(yt||(yt={}));var St;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException"})(St||(St={}));var Ce;(function(e){e.PasswordResetRequiredException="PasswordResetRequiredException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Ce||(Ce={}));var Tt;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPol
2icyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(Tt||(Tt={}));var At;(function(e){e.AliasExistsException="AliasExistsException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.MFAMethodNotFoundException="MFAMethodNotFoundException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(At||(At={}));var vt;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(vt||(vt={}));var wt;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UsernameExistsException="UsernameExistsException"})(wt||(wt={}));var xt;(function(e){e.AliasExistsException="AliasExistsException",e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(xt||(xt={}));var Rt;(function(e){e.CodeMismatchException="CodeMismatchException",e.EnableSoftw
2areTokenMFAException="EnableSoftwareTokenMFAException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Rt||(Rt={}));var Ct;(function(e){e.AliasExistsException="AliasExistsException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Ct||(Ct={}));var Pt;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Pt||(Pt={}));var Nt;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Nt||(Nt={}));const ke="UserUnAuthenticatedException",so="UserAlreadyAuthenticatedException",io="DeviceMetadataNotFoundException",ro="InvalidRedirectException",ao="InvalidAppSchemeException",co="InvalidPreferredRedirectUrlException",lo=new E({name:ro,message:"signInRedirect or signOutRedirect had an invalid format or was not found.",recoverySuggestion:"Please make sure the signIn/Out redirect in your oauth config is valid."});new E({name:ao,message:"A valid non-http app scheme was not found in the config.",recoverySuggestion:"Please make sure a valid custom app scheme is present in the config."});new E({name:co,message:"The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.",recoverySuggestion:"Please make sure a matching preferredRedirectUrl is provided."});const uo="InvalidOriginException",ho=new E({name:uo,message:"redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin",recoverySuggestion:"Please call signInWithRedirect from the same origin."}),go="OAuthSignOutException",po="TokenRefreshException",Eo="UnexpectedSignInInterruptionException";function mo(e){if(!e||!e.accessToken)throw new E({name:ke,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function fo(e){if(!e||!e.idToken)throw new E({name:ke,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}const Io=new E({name:po,message:`Token refresh is not supported when authenticated with the 'implicit grant' (token) oauth flow. 3 Please change your oauth configuration to use 'code grant' flow.`,recoverySuggestion:`Please logout and change your Amplify configuration to use "code grant" flow. 4 E.g { responseType: 'code' }`}),yo=new E({name:ke,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});function cn(e){if(Ao(e))throw Io;if(!To(e))throw yo}function dn(e){if(!e||!e.deviceKey||!e.deviceGroupKey||!e.randomPassword)throw new E({name:io,message:"Either deviceKey, deviceGroupKey or secretPassword were not found during the sign-in process.",recoverySuggestion:"Make sure to not clear storage after calling the signIn API."})}const So={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"};function ln(e){return e?.accessToken||e?.idToken}function To(e){return ln(e)&&e?.refreshToken}function Ao(e){return ln(e)&&!e?.refreshToken}const vo=async e=>{const t=e.getConfig().Auth?.Cognito;f(t);const n=await e.Auth.getTokens({forceRefresh:!1});mo(n);const{"cognito:username":o,sub:s}=n.idToken?.payload??{},i={username:o,userId:s},r=wo(n);
4return r&&(i.signInDetails=r),i};function wo(e){return e?.signInDetails}const De=async()=>vo(A),ge=e=>V(X,J("InitiateAuth"),Y(),{...G,...e}),Fe=e=>V(X,J("RespondToAuthChallenge"),Y(),{...G,...e}),xo=e=>V(X,J("AssociateSoftwareToken"),Y(),{...G,...e}),Ro=e=>V(X,J("GetTokensFromRefreshToken"),Y(),{...G,...e}),Co=async({tokens:e,authConfig:t,username:n,clientMetadata:o})=>{f(t?.Cognito);const{userPoolId:s,userPoolClientId:i,userPoolEndpoint:r}=t.Cognito,a=w(s);cn(e);const c=Ro({endpointResolver:x({endpointOverride:r})}),{AuthenticationResult:d}=await c({region:a},{ClientId:i,RefreshToken:e.refreshToken,DeviceKey:e.deviceMetadata?.deviceKey,ClientMetadata:o}),l=H(d?.AccessToken??""),u=d?.IdToken?H(d.IdToken):void 0,{iat:g}=l.payload;if(!g)throw new E({name:"iatNotFoundException",message:"iat not found in access token"});const p=g*1e3-new Date().getTime();return{accessToken:l,idToken:u,clockDrift:p,refreshToken:d?.RefreshToken??e.refreshToken,username:n}},Po=Qn(Co),No={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"};var Pe;(function(e){e.InvalidAuthTokens="InvalidAuthTokens"})(Pe||(Pe={}));const _o={[Pe.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},ko=Gt(_o),_t="CognitoIdentityServiceProvider";class Do{getKeyValueStorage(){if(!this.keyValueStorage)throw new E({name:"KeyValueStorageNotFoundException",message:"KeyValueStorage was not found in TokenStore"});return this.keyValueStorage}setKeyValueStorage(t){this.keyValueStorage=t}setAuthConfig(t){this.authConfig=t}async loadTokens(){try{const t=await this.getAuthKeys(),n=await this.getKeyValueStorage().getItem(t.accessToken);if(!n)throw new E({name:"NoSessionFoundException",message:"Auth session was not found. Make sure to call signIn."});const o=H(n),s=await this.getKeyValueStorage().getItem(t.idToken),i=s?H(s):void 0,r=await this.getKeyValueStorage().getItem(t.refreshToken)??void 0,a=await this.getKeyValueStorage().getItem(t.clockDrift)??"0",c=Number.parseInt(a),d=await this.getKeyValueStorage().getItem(t.signInDetails),l={accessToken:o,idToken:i,refreshToken:r,deviceMetadata:await this.getDeviceMetadata()??void 0,clockDrift:c,username:await this.getLastAuthUser()};return d&&(l.signInDetails=JSON.parse(d)),l}catch{return null}}async storeTokens(t){ko(t!==void 0,Pe.InvalidAuthTokens);const n=t.username;await this.getKeyValueStorage().setItem(this.getLastAuthUserKey(),n);const o=await this.getAuthKeys();await this.getKeyValueStorage().setItem(o.accessToken,t.accessToken.toString()),t.idToken?await this.getKeyValueStorage().setItem(o.idToken,t.idToken.toString()):await this.getKeyValueStorage().removeItem(o.idToken),t.refreshToken?await this.getKeyValueStorage().setItem(o.refreshToken,t.refreshToken):await this.getKeyValueStorage().removeItem(o.refreshToken),t.deviceMetadata&&(t.deviceMetadata.deviceKey&&await this.getKeyValueStorage().setItem(o.deviceKey,t.deviceMetadata.deviceKey),t.deviceMetadata.deviceGroupKey&&await this.getKeyValueStorage().setItem(o.deviceGroupKey,t.deviceMetadata.deviceGroupKey),await this.getKeyValueStorage().setItem(o.randomPasswordKey,t.deviceMetadata.randomPassword)),t.signInDetails?await this.getKeyValueStorage().setItem(o.signInDetails,JSON.stringify(t.signInDetails)):await this.getKeyValueStorage().removeItem(o.signInDetails),await this.getKeyValueStorage().setItem(o.clockDrift,`${t.clockDrift}`)}async clearTokens(){const t=await this.getAuthKeys();await Promise.all([this.getKeyValueStorage().removeItem(t.accessToken),this.getKeyValueStorage().removeItem(t.idToken),this.getKeyValueStorage().removeItem(t.clockDrift),this.getKeyValueStorage().removeItem(t.refreshToken),this.getKeyValueStorage().removeItem(t.signInDetails),this.getKeyValueStorage().removeItem(this.getLastAuthUserKey()),this.getKeyValueStorage().removeItem(t.oauthMetadata)])}async getDeviceMetadata(t){const n=await this.getAuthKeys(t),o=await this.getKeyValueStorage().getItem(n.deviceKey),s=await this.getKeyValueStorage().getItem(n.deviceGroupKey),i=await this.getKeyValueStorage().getItem(n.randomPasswordKey);return i&&s&&o?{deviceKey:o,deviceGroupKey:s,randomPassword:i}:null}async clearDeviceMetadata(t){const n=await this.getAuthKeys(t);await Promise.all([this.getKeyValueStorage().removeItem(n.deviceKey),this.getKeyValueStorage().removeItem(n.deviceGroupKey),this.getKeyValueStorage().removeItem(n.randomPasswordKey)])}async getAuthKeys(t){f(this.authConfig?.Cognito);const n=t??await this.getLastAuthUser();return Fo(_t,`${this.authConfig.Cognito.userPoolClientId}.${n}`)}getLastAuthUserKey(){f(this.authConfig?.Cognito);const t=this.authConfig.Cognito.userPoolClientId;return`${_t}.${t}.LastAuthUser`}async getLastAuthUser(){return await this.getKeyValueStorage().getItem(this.getLastAuthUserKey())??"username"}async setOAuthMetadata(t){const{oauthMetadata:n}=await this.getAuthKeys();await this.getKeyValueStorage().setItem(n,JSON.stringify(t))}async getOAuthMetadata(){const{oauthMetadata:t}=await this.getAuthKeys(),n=await this.getKeyValueStorage().getItem(t);return n&&JSON.parse(n)}}const Fo=(e,t)=>Ge(No)(`${e}`,t);function Ge(e){const t=Object.values({...e});return(n,o)=>t.reduce((s,i)=>({...s,[i]:`${n}.${o}.${i}`}),{})}const kt="amplify-signin-with-hostedUI",_="CognitoIdentityServiceProvider";class un{constructor(t){this.keyValueStorage=t}async clearOAuthInflightData(){f(this.cognitoConfig);const t=k(_,this.cognitoConfig.userPoolClientId);await Promise.all([this.keyValueStorage.removeItem(t.inflightOAuth),this.keyValueStorage.removeItem(t.oauthPKCE),this.keyValueStorage.removeItem(t.oauthState)])}async clearOAuthData(){f(this.cognitoConfig);const t=k(_,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(kt),this.keyValueStorage.removeItem(t.oauthSignIn)}loadOAuthState(){f(this.cognitoConfig);const t=k(_,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthState)}storeOAuthState(t){f(this.cognitoConfig);const n=k(_,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthState,t)}loadPKCE(){f(this.cognitoConfig);const t=k(_,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthPKCE)}storePKCE(t){f(this.cognitoConfig);const n=k(_,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthPKCE,t)}setAuthConfig(t){this.cognitoConfig=t}async loadOAuthInFlight(){f(this.cognitoConfig);const t=k(_,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(t.inflightOAuth)==="true"}async storeOAuthInFlight(t){f(this.cognitoConfig);const n=k(_,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(n.inflightOAuth,`${t}`)}async loadOAuthSignIn(){f(this.cognitoConfig);const t=k(_,this.cognitoConfig.userPoolClientId),n=await this.keyValueStorage.getItem(kt),[o,s]=(await this.keyValueStorage.getItem(t.oauthSignIn))?.split(",")??[];return{isOAuthSignIn:o==="true"||n==="true",preferPrivateSession:s==="true"}}async storeOAuthSignIn(t,n=!1){f(this.cognitoConfig);const o=k(_,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(o.oauthSignIn,`${t},${n}`)}}const k=(e,t)=>Ge(So)(e,t),Dt=new un(he);class Mo{constructor(){this.waitForInflightOAuth=Xt()?async()=>
4{if(await Dt.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((t,n)=>{}),this.inflightPromise)}:async()=>{}}setAuthConfig(t){Dt.setAuthConfig(t.Cognito),this.authConfig=t}setTokenRefresher(t){this.tokenRefresher=t}setAuthTokenStore(t){this.tokenStore=t}getTokenStore(){if(!this.tokenStore)throw new E({name:"EmptyTokenStoreException",message:"TokenStore not set"});return this.tokenStore}getTokenRefresher(){if(!this.tokenRefresher)throw new E({name:"EmptyTokenRefresherException",message:"TokenRefresher not set"});return this.tokenRefresher}setClientMetadataProvider(t){this.clientMetadataProvider=t}async getTokens(t){let n;try{f(this.authConfig?.Cognito)}catch{return null}await this.waitForInflightOAuth(),this.inflightPromise=void 0,n=await this.getTokenStore().loadTokens();const o=await this.getTokenStore().getLastAuthUser();if(n===null)return null;const s=!!n?.idToken&&rt({expiresAt:(n.idToken?.payload?.exp??0)*1e3,clockDrift:n.clockDrift??0}),i=rt({expiresAt:(n.accessToken?.payload?.exp??0)*1e3,clockDrift:n.clockDrift??0});return(t?.forceRefresh||s||i)&&(n=await this.refreshTokens({tokens:n,username:o,clientMetadata:t?.clientMetadata??await this.clientMetadataProvider?.()}),n===null)?null:{accessToken:n?.accessToken,idToken:n?.idToken,signInDetails:n?.signInDetails}}async refreshTokens({tokens:t,username:n,clientMetadata:o}){try{const{signInDetails:s}=t,i=await this.getTokenRefresher()({tokens:t,authConfig:this.authConfig,username:n,clientMetadata:o});return i.signInDetails=s,await this.setTokens({tokens:i}),de.dispatch("auth",{event:"tokenRefresh"},"Auth",le),i}catch(s){return this.handleErrors(s)}}handleErrors(t){if(K(t),this.isAuthenticationError(t)&&this.clearTokens(),de.dispatch("auth",{event:"tokenRefresh_failure",data:{error:t}},"Auth",le),t.name.startsWith("NotAuthorizedException"))return null;throw t}isAuthenticationError(t){return["NotAuthorizedException","TokenRevokedException","UserNotFoundException","PasswordResetRequiredException","UserNotConfirmedException","RefreshTokenReuseException"].some(o=>t?.name?.startsWith?.(o))}async setTokens({tokens:t}){return this.getTokenStore().storeTokens(t)}async clearTokens(){return this.getTokenStore().clearTokens()}getDeviceMetadata(t){return this.getTokenStore().getDeviceMetadata(t)}clearDeviceMetadata(t){return this.getTokenStore().clearDeviceMetadata(t)}setOAuthMetadata(t){return this.getTokenStore().setOAuthMetadata(t)}getOAuthMetadata(){return this.getTokenStore().getOAuthMetadata()}}class Oo{constructor(){this.authTokenStore=new Do,this.authTokenStore.setKeyValueStorage(he),this.tokenOrchestrator=new Mo,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(Po)}getTokens(t={}){return this.tokenOrchestrator.getTokens(t)}setKeyValueStorage(t){this.authTokenStore.setKeyValueStorage(t)}
4setClientMetadataProvider(t){this.tokenOrchestrator.setClientMetadataProvider(t)}setAuthConfig(t){this.authTokenStore.setAuthConfig(t),this.tokenOrchestrator.setAuthConfig(t)}}const ce=new Oo,{tokenOrchestrator:C}=ce;async function Z(e){if(e.AccessToken){const t=H(e.AccessToken),n=(t.payload.iat||0)*1e3,o=new Date().getTime(),s=n>0?n-o:0;let i,r,a;e.RefreshToken&&(r=e.RefreshToken),e.IdToken&&(i=H(e.IdToken)),e?.NewDeviceMetadata&&(a=e.NewDeviceMetadata);const c={accessToken:t,idToken:i,refreshToken:r,clockDrift:s,deviceMetadata:a,username:e.username};e?.signInDetails&&(c.signInDetails=e.signInDetails),await C.setTokens({tokens:c})}else throw new $e({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}const Uo="Unable to get user session following successful sign-in.",Q=async()=>{try{de.dispatch("auth",{event:"signedIn",data:await De()},"Auth",le)}catch(e){throw e.name===ke?new E({name:Eo,message:Uo,recoverySuggestion:"This most likely is due to auth tokens not being persisted. If you are using cookie store, please ensure cookies can be correctly set from your server."}):e}};function hn(){return{active:!1}}const bo=(e,t)=>{switch(t.type){case"SET_USERNAME":return{...e,username:t.value};case"SET_SESSION":return{...e,session:t.value};case"START":return{...e,active:!0};case"RESET":return hn();default:return e}},Ko=e=>{let t=e(hn(),{type:"RESET"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},gn=Ko(bo),Lo=180*1e3,ye="CognitoSignInState",U={username:`${ye}.username`,challengeName:`${ye}.challengeName`,signInSession:`${ye}.signInSession`,expiry:`${ye}.expiry`},Bo=(e,t)=>{switch(t.type){case"SET_SIGN_IN_SESSION":return Se({signInSession:t.value}),{...e,signInSession:t.value};case"SET_SIGN_IN_STATE":return Se(t.value),{...t.value};case"SET_CHALLENGE_NAME":return Se({challengeName:t.value}),{...e,challengeName:t.value};case"SET_USERNAME":return Se({username:t.value}),{...e,username:t.value};case"SET_INITIAL_STATE":return Ho();case"RESET_STATE":return pn(),Ye();default:return e}},Vo=e=>{const t=Number(e),n=Date.now();return t<=n},D=()=>{B.dispatch({type:"RESET_STATE"})},pn=()=>{for(const e of Object.values(U))O.removeItem(e)},Ye=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),Ho=()=>{const e=O.getItem(U.expiry);if(!e||Vo(e))return pn(),Ye();const t=O.getItem(U.username)??void 0,n=O.getItem(U.challengeName)??void 0,o=O.getItem(U.signInSession)??void 0;return{username:t,challengeName:n,signInSession:o}},qo=e=>{let t=e(Ye(),{type:"SET_INITIAL_STATE"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},B=qo(Bo);function ee(e){B.dispatch({type:"SET_SIGN_IN_STATE",value:e})}const Se=({challengeName:e,signInSession:t,username:n})=>{n&&O.setItem(U.username,n),e&&O.setItem(U.challengeName,e),t&&(O.setItem(U.signInSession,t),O.setItem(U.expiry,String(Date.now()+Lo)))},Ft="Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported.";class b extends $e{constructor(t){super(t),this.constructor=b,Object.setPrototypeOf(this,b.prototype)}}var I;(function(e){e.PasskeyNotSupported="PasskeyNotSupported",e.PasskeyAlreadyExists="PasskeyAlreadyExists",e.InvalidPasskeyRegistrationOptions="InvalidPasskeyRegistrationOptions",e.InvalidPasskeyAuthenticationOptions="InvalidPasskeyAuthenticationOptions",e.RelyingPartyMismatch="RelyingPartyMismatch",e.PasskeyRegistrationFailed="PasskeyRegistrationFailed",e.PasskeyRetrievalFailed="PasskeyRetrievalFailed",e.PasskeyRegistrationCanceled="PasskeyRegistrationCanceled",e.PasskeyAuthenticationCanceled="PasskeyAuthenticationCanceled",e.PasskeyOperationAborted="PasskeyOperationAborted"})(I||(I={}));const Ke="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",Mt="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",Ne={[I.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:Ft},[I.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:Mt},[I.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:Mt},[I.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:Ft},[I.PasskeyRetrievalFailed]:{message:"Device failed to retrieve passkey.",recoverySuggestion:"Passkeys may not be available on this device. Try an alternative authentication factor like PASSWORD, EMAIL_OTP, or SMS_OTP."},[I.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[I.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:Ke},[I.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:Ke},[I.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:Ke},[I.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},Je=Gt(Ne,b),Wo=e=>{if(e instanceof Error){if(e.name==="AbortError"){const{message:t,recoverySuggestion:n}=Ne[I.PasskeyOperationAborted];return new b({name:I.PasskeyOperationAborted,message:t,recoverySuggestion:n,underlyingError:e})}if(e.name==="SecurityError"){const{message:t,recoverySuggestion:n}=Ne[I.RelyingPartyMismatch];return new b({name:I.RelyingPartyMismatch,message:t,recoverySuggestion:n,underlyingError:e})}}return new b({name:jt.Unknown,message:"An unknown error has occurred.",underlyingError:e})},zo=e=>{if(e instanceof b)return e;if(e instanceof Error&&e.name==="NotAllowedError"){const{message:t,recoverySuggestion:n}=Ne[I.PasskeyAuthenticationCanceled];return new b({name:I.PasskeyAuthenticationCanceled,message:t,recoverySuggestion:n,underlyingError:e})}return Wo(e)},$o=()=>Xt()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function",re=e=>ue.convert(new Uint8Array(e),{urlSafe:!0,skipPadding:!0}),Ot=e=>Uint8Array.from(Yt.convert(e,{urlSafe:!0}),t=>t.charCodeAt(0)).buffer,jo=e=>{const t=Ot(e.challenge),n=(e.allowCredentials||[]).map(o=>({...o,id:Ot(o.id)}));return{...e,challenge:t,allowCredentials:n}},Go=e=>{const t={clientDataJSON:re(e.response.clientDataJSON),authenticatorData:re(e.response.authenticatorData),signature:re(e.response.signature)};e.response.userHandle&&(t.userHandle=re(e.response.userHandle));const n={id:e.id,rawId:re(e.rawId),type:e.type,clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(n.authenticatorAttachment=e.authenticatorAttachment),n};function Yo(e){Je(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAssertionResponse,I.PasskeyRetrievalFailed)}const Jo=async e=>{try{const t=$o();Je(t,I.PasskeyNotSupported);const n=jo(e),o=await navigator.credentials.get({publicKey:n});return Yo(o),Go(o)}catch(t){throw zo(t)}},Xo=e=>
4V(X,J("ConfirmDevice"),Y(),{...G,...e}),ve={convert(e){return new TextEncoder().encode(e)}};function h(e,t){e!=null&&this.fromString(e,t)}function v(){return new h(null,null)}let L;const Zo=0xdeadbeefcafe,Ut=(Zo&16777215)===15715070;function Qo(e,t,n,o,s,i){for(;--i>=0;){const r=t*this[e++]+n[o]+s;s=Math.floor(r/67108864),n[o++]=r&67108863}return s}function es(e,t,n,o,s,i){const r=t&32767,a=t>>15;for(;--i>=0;){let c=this[e]&32767;const d=this[e++]>>15,l=a*c+d*r;c=r*c+((l&32767)<<15)+n[o]+(s&1073741823),s=(c>>>30)+(l>>>15)+a*d+(s>>>30),n[o++]=c&1073741823}return s}function ts(e,t,n,o,s,i){const r=t&16383,a=t>>14;for(;--i>=0;){let c=this[e]&16383;const d=this[e++]>>14,l=a*c+d*r;c=r*c+((l&16383)<<14)+n[o]+s,s=(c>>28)+(l>>14)+a*d,n[o++]=c&268435455}return s}const bt=typeof navigator<"u";bt&&Ut&&navigator.appName==="Microsoft Internet Explorer"?(h.prototype.am=es,L=30):bt&&Ut&&navigator.appName!=="Netscape"?(h.prototype.am=Qo,L=26):(h.prototype.am=ts,L=28);h.prototype.DB=L;h.prototype.DM=(1<<L)-1;h.prototype.DV=1<<L;const Xe=52;h.prototype.FV=Math.pow(2,Xe);h.prototype.F1=Xe-L;h.prototype.F2=2*L-Xe;const ns="0123456789abcdefghijklmnopqrstuvwxyz",Me=[];let te,R;te=48;for(R=0;R<=9;++R)Me[te++]=R;te=97;for(R=10;R<36;++R)Me[te++]=R;te=65;for(R=10;R<36;++R)Me[te++]=R;function Kt(e){return ns.charAt(e)}function os(e,t){const n=Me[e.charCodeAt(t)];return n??-1}function ss(e){for(let t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function is(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}function Ze(e){const t=v();return t.fromInt(e),t}function rs(e,t){let n;if(t===16)n=4;else if(t===8)n=3;else if(t===2)n=1;else if(t===32)n=5;else if(t===4)n=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");this.t=0,this.s=0;let o=e.length,s=!1,i=0;for(;--o>=0;){const r=os(e,o);if(r<0){e.charAt(o)==="-"&&(s=!0);continue}s=!1,i===0?this[this.t++]=r:i+n>this.DB?(this[this.t-1]|=(r&(1<<this.DB-i)-1)<<i,this[this.t++]=r>>this.DB-i):this[this.t-1]|=r<<i,i+=n,i>=this.DB&&(i-=this.DB)}this.clamp(),s&&h.ZERO.subTo(this,this)}function as(){const e=this.s&this.DM;for(;this.t>0&&this[this.t-1]==e;)--this.t}function cs(e){if(this.s<0)return"-"+this.negate().toString(e);let t;if(e==16)t=4;else if(e===8)t=3;else if(e===2)t=1;else if(e===32)t=5;else if(e===4)t=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");const n=(1<<t)-1;let o,s=!1,i="",r=this.t,a=this.DB-r*this.DB%t;if(r-- >0)for(a<this.DB&&(o=this[r]>>a)>0&&(s=!0,i=Kt(o));r>=0;)a<t?(o=(this[r]&(1<<a)-1)<<t-a,o|=this[--r]>>(a+=this.DB-t)):(o=this[r]>>(a-=t)&n,a<=0&&(a+=this.DB,--r)),o>0&&(s=!0),s&&(i+=Kt(o));return s?i:"0"}function ds(){const e=v();return h.ZERO.subTo(this,e),e}function ls(){return this.s<0?this.negate():this}function us(e){let t=this.s-e.s;if(t!=0)return t;let n=this.t;if(t=n-e.t,t!=0)return this.s<0?-t:t;for(;--n>=0;)if((t=this[n]-e[n])!=0)return t;return 0}function Qe(e){let t=1,n;return(n=e>>>16)!==0&&(e=n,t+=16),(n=e>>8)!==0&&(e=n,t+=8),(n=e>>4)!==0&&(e=n,t+=4),(n=e>>2)!==0&&(e=n,t+=2),(n=e>>1)!==0&&(e=n,t+=1),t}function hs(){return this.t<=0?0:this.DB*(this.t-1)+Qe(this[this.t-1]^this.s&this.DM)}function gs(e,t){let n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s}function ps(e,t){for(let n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s}function Es(e,t){const n=e%this.DB,o=this.DB-n,s=(1<<o)-1,i=Math.floor(e/this.DB);let r=this.s<<n&this.DM,a;for(a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>o|r,r=(this[a]&s)<<n;for(a=i-1;a>=0;--a)t[a]=0;t[i]=r,t.t=this.t+i+1,t.s=this.s,t.clamp()}function ms(e,t){t.s=this.s;const n=Math.floor(e/this.DB);if(n>=this.t){t.t=0;return}const o=e%this.DB,s=this.DB-o,i=(1<<o)-1;t[0]=this[n]>>o;for(let r=n+1;r<this.t;++r)t[r-n-1]|=(this[r]&i)<<s,t[r-n]=this[r]>>o;o>0&&(t[this.t-n-1]|=(this.s&i)<<s),t.t=this.t-n,t.clamp()}function fs(e,t){let n=0,o=0;const s=Math.min(e.t,this.t);for(;n<s;)o+=this[n]-e[n],t[n++]=o&this.DM,o>>=this.DB;if(e.t<this.t){for(o-=e.s;n<this.t;)o+=this[n],t[n++]=o&this.DM,o>>=this.DB;o+=this.s}else{for(o+=this.s;n<e.t;)o-=e[n],t[n++]=o&this.DM,o>>=this.DB;o-=e.s}t.s=o<0?-1:0,o<-1?t[n++]=this.DV+o:o>0&&(t[n++]=o),t.t=n,t.clamp()}function Is(e,t){const n=this.abs(),o=e.abs();let s=n.t;for(t.t=s+o.t;--s>=0;)t[s]=0;for(s=0;s<o.t;++s)t[s+n.t]=n.am(0,o[s],t,s,0,n.t);t.s=0,t.clamp(),this.s!==e.s&&h.ZERO.subTo(t,t)}function ys(e){const t=this.abs();let n=e.t=2*t.t;for(;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){const o=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,o,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()}function Ss(e,t,n){const o=e.abs();if(o.t<=0)return;const s=this.abs();if(s.t<o.t){t?.fromInt(0),n!=null&&this.copyTo(n);return}n===null&&(n=v());const i=v(),r=this.s,a=e.s,c=this.DB-Qe(o[o.t-1]);c>0?(o.lShiftTo(c,i),s.lShiftTo(c,n)):(o.copyTo(i),s.copyTo(n));const d=i.t,l=i[d-1];if(l===0)return;const u=l*(1<<this.F1)+(d>1?i[d-2]>>this.F2:0),g=this.FV/u,p=(1<<this.F1)/u,m=1<<this.F2;let y=n.t,T=y-d;const S=t===null?v():t;
4for(i.dlShiftTo(T,S),n.compareTo(S)>=0&&(n[n.t++]=1,n.subTo(S,n)),h.ONE.dlShiftTo(d,S),S.subTo(i,i);i.t<d;)i[i.t++]=0;for(;--T>=0;){let F=n[--y]===l?this.DM:Math.floor(n[y]*g+(n[y-1]+m)*p);if((n[y]+=i.am(0,F,n,T,0,d))<F)for(i.dlShiftTo(T,S),n.subTo(S,n);n[y]<--F;)n.subTo(S,n)}t!==null&&(n.drShiftTo(d,t),r!==a&&h.ZERO.subTo(t,t)),n.t=d,n.clamp(),c>0&&n.rShiftTo(c,n),r<0&&h.ZERO.subTo(n,n)}function Ts(e){const t=v();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(h.ZERO)>0&&e.subTo(t,t),t}function As(){if(this.t<1)return 0;const e=this[0];if((e&1)===0)return 0;let t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function vs(e){return this.compareTo(e)===0}function ws(e,t){let n=0,o=0;const s=Math.min(e.t,this.t);for(;n<s;)o+=this[n]+e[n],t[n++]=o&this.DM,o>>=this.DB;if(e.t<this.t){for(o+=e.s;n<this.t;)o+=this[n],t[n++]=o&this.DM,o>>=this.DB;o+=this.s}else{for(o+=this.s;n<e.t;)o+=e[n],t[n++]=o&this.DM,o>>=this.DB;o+=e.s}t.s=o<0?-1:0,o>0?t[n++]=o:o<-1&&(t[n++]=this.DV+o),t.t=n,t.clamp()}function xs(e){const t=v();return this.addTo(e,t),t}function Rs(e){const t=v();return this.subTo(e,t),t}function Cs(e){const t=v();return this.multiplyTo(e,t),t}function Ps(e){const t=v();return this.divRemTo(e,t,null),t}function ne(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function Ns(e){const t=v();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(h.ZERO)>0&&this.m.subTo(t,t),t}function _s(e){const t=v();return e.copyTo(t),this.reduce(t),t}function ks(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(let t=0;t<this.m.t;++t){let n=e[t]&32767;const o=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(n=t+this.m.t,e[n]+=this.m.am(0,o,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Ds(e,t){e.squareTo(t),this.reduce(t)}function Fs(e,t,n){e.multiplyTo(t,n),this.reduce(n)}ne.prototype.convert=Ns;ne.prototype.revert=_s;ne.prototype.reduce=ks;ne.prototype.mulTo=Fs;ne.prototype.sqrTo=Ds;function Ms(e,t,n){let o=e.bitLength(),s,i=Ze(1);const r=new ne(t);if(o<=0)return i;o<18?s=1:o<48?s=3:o<144?s=4:o<768?s=5:s=6;const a=[];let c=3;const d=s-1,l=(1<<s)-1;if(a[1]=r.convert(this),s>1){const S=v();for(r.sqrTo(a[1],S);c<=l;)a[c]=v(),r.mulTo(S,a[c-2],a[c]),c+=2}let u=e.t-1,g,p=!0,m=v(),y;for(o=Qe(e[u])-1;u>=0;){for(o>=d?g=e[u]>>o-d&l:(g=(e[u]&(1<<o+1)-1)<<d-o,u>0&&(g|=e[u-1]>>this.DB+o-d)),c=s;(g&1)===0;)g>>=1,--c;if((o-=c)<0&&(o+=this.DB,--u),p)a[g].copyTo(i),p=!1;else{for(;c>1;)r.sqrTo(i,m),r.sqrTo(m,i),c-=2;c>0?r.sqrTo(i,m):(y=i,i=m,m=y),r.mulTo(m,a[g],i)}for(;u>=0&&(e[u]&1<<o)===0;)r.sqrTo(i,m),y=i,i=m,m=y,--o<0&&(o=this.DB-1,--u)}const T=r.revert(i);return n(null,T),T}h.prototype.copyTo=ss;h.prototype.fromInt=is;h.prototype.fromString=rs;h.prototype.clamp=as;h.prototype.dlShiftTo=gs;h.prototype.drShiftTo=ps;h.prototype.lShiftTo=Es;h.prototype.rShiftTo=ms;h.prototype.subTo=fs;h.prototype.multiplyTo=Is;h.prototype.squareTo=ys;h.prototype.divRemTo=Ss;h.prototype.invDigit=As;h.prototype.addTo=ws;h.prototype.toString=cs;h.prototype.negate=ds;h.prototype.abs=ls;h.prototype.compareTo=us;h.prototype.bitLength=hs;h.prototype.mod=Ts;h.prototype.equals=vs;h.prototype.add=xs;h.prototype.subtract=Rs;h.prototype.multiply=Cs;h.prototype.divide=Ps;h.prototype.modPow=Ms;h.ZERO=Ze(0);h.ONE=Ze(1);const Os=async({a:e,g:t,k:n,x:o,B:s,N:i,U:r})=>new Promise((a,c)=>{t.modPow(o,i,(d,l)=>{if(d){c(d);return}s.subtract(n.multiply(l)).modPow(e.add(r.multiply(o)),i,(u,g)=>{if(u){c(u);return}a(g.mod(i))})})}),Us="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",En={},Ve={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),En[e]=t,Ve[t]=e}const j=e=>{if(e.length%2!==0)throw new Error("Hex encoded strings must have an even number length");const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2){const o=e.slice(n,n+2).toLowerCase();if(o in Ve)t[n/2]=Ve[o];else throw new Error(`Cannot decode unrecognized sequence ${o} as hexadecimal`)}return t},et=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=En[e[n]];return t},He=e=>{const t=new xe;t.update(e);const n=t.digestSync(),o=et(n);return new Array(64-o.length).join("0")+o},we=e=>He(j(e)),bs=/^[89a-f]/i,M=e=>{if(!(e instanceof h))throw new Error("Not a BigInteger");const t=e.compareTo(h.ZERO)<0;let n=e.abs().toString(16);if(n=n.length%2!==0?`0${n}`:n,n=bs.test(n)?`00${n}`:n,t){const o=n.split("").map(i=>{const r=~parseInt(i,16)&15;return"0123456789ABCDEF".charAt(r)}).join("");n=new h(o,16).add(h.ONE).toString(16),n.toUpperCase().startsWith("FF8")&&(n=n.substring(2))}return n},Ks=({A:e,B:t})=>{const n=new h(we(M(e)+M(t)),16);if(n.equals(h.ZERO))throw new Error("U cannot be zero.");return n},Ls=(e,t,n)=>{const o=new xe(t);o.update(e);const s=o.digestSync(),i=new xe(s);return i.update(n),i.digestSync().slice(0,16)},tt=e=>{const t=new je().random(e).toString();return j(t)},Bs=()=>ue.convert(tt(40));class Vs{constructor({userPoolName:t,a:n,g:o,A:s,N:i}){this.encoder=ve,this.userPoolName=t,this.a=n,this.g=o,this.A=s,this.N=i,this.k=new h(we(`${M(i)}${M(o)}`),16)}getRandomPassword(){if(!this.randomPassword)throw new E({name:"EmptyBigIntegerRandomPassword",message:"random password is empty"});return this.randomPassword}getSaltToHashDevices(){if(!this.saltToHashDevices)throw new E({name:"EmptyBigIntegersaltToHashDevices",message:"saltToHashDevices is empty"});return this.saltToHashDevices}getVerifierDevices(){if(!this.verifierDevices)throw new E({name:"EmptyBigIntegerVerifierDevices",message:"verifyDevices is empty"});return this.verifierDevices}async generateHashDevice(t,n){this.randomPassword=Bs();const o=`${t}${n}:${this.randomPassword}`,s=He(o),i=et(tt(16));return this.saltToHashDevices=M(new h(i,16)),new Promise((r,a)=>{this.g.modPow(new h(we(this.saltToHashDevices+s),16),this.N,(c,d)=>
4{if(c){a(c);return}this.verifierDevices=M(d),r()})})}async getPasswordAuthenticationKey({username:t,password:n,serverBValue:o,salt:s}){if(o.mod(this.N).equals(h.ZERO))throw new Error("B cannot be zero.");const i=Ks({A:this.A,B:o}),r=`${this.userPoolName}${t}:${n}`,a=He(r),c=new h(we(M(s)+a),16),d=await Os({a:this.a,g:this.g,k:this.k,x:c,B:o,N:this.N,U:i}),l=this.encoder.convert("Caldera Derived Key"),u=this.encoder.convert("�"),g=new Uint8Array(l.byteLength+u.byteLength);return g.set(l,0),g.set(u,l.byteLength),Ls(j(M(d)),j(M(i)),g)}}const Hs=async({a:e,g:t,N:n})=>new Promise((o,s)=>{t.modPow(e,n,(i,r)=>{if(i){s(i);return}if(r.mod(n).equals(h.ZERO)){s(new Error("Illegal parameter. A mod N cannot be 0."));return}o(r)})}),Oe=async e=>{const t=new h(Us,16),n=new h("2",16),o=qs(),s=await Hs({a:o,g:n,N:t});return new Vs({userPoolName:e,a:o,g:n,A:s,N:t})},qs=()=>{const e=et(tt(128));return new h(e,16)};async function oe({userPoolId:e,userPoolEndpoint:t,newDeviceMetadata:n,accessToken:o}){if(!n)return;const s=e.split("_")[1]||"",i=await Oe(s),r=n?.DeviceKey,a=n?.DeviceGroupKey;try{await i.generateHashDevice(a??"",r??"")}catch{return}const c={Salt:ue.convert(j(i.getSaltToHashDevices())),PasswordVerifier:ue.convert(j(i.getVerifierDevices()))},d=i.getRandomPassword();try{return await Xo({endpointResolver:x({endpointOverride:t})})({region:w(e)},{AccessToken:o,DeviceName:await eo(),DeviceKey:n?.DeviceKey,DeviceSecretVerifierConfig:c}),{deviceKey:r,deviceGroupKey:a,randomPassword:d}}catch{return}}async function Ws(e){const t=A.getConfig().Auth?.Cognito;f(t);const{username:n,signInSession:o,signInDetails:s,challengeName:i}=B.getState();if(i!=="WEB_AUTHN"||!n)throw new E({name:Re.SignInException,message:"Unable to proceed due to invalid sign in state."});const{CREDENTIAL_REQUEST_OPTIONS:r}=e;Je(!!r,I.InvalidPasskeyAuthenticationOptions);const a=await Jo(JSON.parse(r)),c=Fe({endpointResolver:x({endpointOverride:t.userPoolEndpoint})}),{ChallengeName:d,ChallengeParameters:l,AuthenticationResult:u,Session:g}=await c({region:w(t.userPoolId),userAgentValue:W(z.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:n,CREDENTIAL:JSON.stringify(a)},ClientId:t.userPoolClientId,Session:o});if(ee({signInSession:g,username:n,challengeName:d,signInDetails:s}),u)return await Z({...u,username:n,NewDeviceMetadata:await oe({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),B.dispatch({type:"RESET_STATE"}),await Q(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(d==="WEB_AUTHN")throw new E({name:Re.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:d,challengeParameters:l}}const zs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],$s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],mn=()=>{const e=new Date,t=$s[e.getUTCDay()],n=zs[e.getUTCMonth()],o=e.getUTCDate();let s=e.getUTCHours();s<10&&(s=`0${s}`);let i=e.getUTCMinutes();i<10&&(i=`0${i}`);let r=e.getUTCSeconds();r<10&&(r=`0${r}`);const a=e.getUTCFullYear();return`${t} ${n} ${o} ${s}:${i}:${r} UTC ${a}`},fn=({userPoolName:e,username:t,challengeParameters:n,dateNow:o,hkdf:s})=>{const i=ve.convert(e),r=ve.convert(t),a=js(n.SECRET_BLOCK),c=ve.convert(o),d=new Uint8Array(i.byteLength+r.byteLength+a.byteLength+c.byteLength);d.set(i,0),d.set(r,i.byteLength),d.set(a,i.byteLength+r.byteLength),d.set(c,i.byteLength+r.byteLength+a.byteLength);const l=new xe(s);l.update(d);const u=l.digestSync();return ue.convert(u)},js=e=>{const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),o=Yt.convert(n),s=new Uint8Array(o.length);for(let i=0;i<o.length;++i)s[i]=o.charCodeAt(i);return s};async function nt({username:e,config:t,clientMetadata:n,session:o,tokenOrchestrator:s}){const{userPoolId:i,userPoolEndpoint:r}=t,a=t.userPoolClientId,c=await s?.getDeviceMetadata(e);dn(c);const d=await Oe(c.deviceGroupKey),l={USERNAME:e,SRP_A:d.A.toString(16),DEVICE_KEY:c.deviceKey},u={ChallengeName:"DEVICE_SRP_AUTH",ClientId:a,ChallengeResponses:l,ClientMetadata:n,Session:o},g=Fe({endpointResolver:x({endpointOverride:r})}),{ChallengeParameters:p,Session:m}=await g({region:w(i)},u);return Gs(e,p,n,m,d,t,s)}async function Gs(e,t,n,o,s,{userPoolId:i,userPoolClientId:r,userPoolEndpoint:a},c){const d=await c?.getDeviceMetadata(e);dn(d);const l=new h(t?.SRP_B,16),u=new h(t?.SALT,16),{deviceKey:g}=d,{deviceGroupKey:p}=d,m=await s.getPasswordAuthenticationKey({username:d.deviceKey,password:d.randomPassword,serverBValue:l,salt:u}),y=mn(),T={USERNAME:t?.USERNAME??e,PASSWORD_CLAIM_SECRET_BLOCK:t?.SECRET_BLOCK,TIMESTAMP:y,PASSWORD_CLAIM_SIGNATURE:fn({username:g,userPoolName:p,challengeParameters:t,dateNow:y,hkdf:m}),DEVICE_KEY:g},S=$({username:e,userPoolId:i,userPoolClientId:r}),F={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:r,ChallengeResponses:T,Session:o,ClientMetadata:n,UserContextData:S};return Fe({endpointResolver:x({endpointOverride:a})})({region:w(i)},F)}async function In(e,t,n,o,s,i,r){const{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}
4=i,l=a?.split("_")[1]||"",u=new h(t?.SRP_B,16),g=new h(t?.SALT,16),p=t?.USER_ID_FOR_SRP;if(!p)throw new E({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});const m=await s.getPasswordAuthenticationKey({username:p,password:e,serverBValue:u,salt:g}),y=mn(),T={USERNAME:p,PASSWORD_CLAIM_SECRET_BLOCK:t?.SECRET_BLOCK,TIMESTAMP:y,PASSWORD_CLAIM_SIGNATURE:fn({username:p,userPoolName:l,challengeParameters:t,dateNow:y,hkdf:m})},S=await r.getDeviceMetadata(p);S&&S.deviceKey&&(T.DEVICE_KEY=S.deviceKey);const F=$({username:p,userPoolId:a,userPoolClientId:c}),ie={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:T,ClientMetadata:n,Session:o,ClientId:c,UserContextData:F},be=await Fe({endpointResolver:x({endpointOverride:d})})({region:w(a)},ie);return be.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:p,config:i,clientMetadata:n,session:be.Session,tokenOrchestrator:r}):be}async function Ue(e,t,n,o){try{return await e(...t)}catch(s){if(s instanceof E&&s.name==="ResourceNotFoundException"&&s.message.includes("Device does not exist."))return await o.clearDeviceMetadata(n),e(...t);throw s}}function pe(e){const{dispatch:t}=B;t({type:"SET_USERNAME",value:e})}async function yn({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:i,preferredChallenge:r}){const{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=o,l=a?.split("_")[1]||"",u=await Oe(l),g={USERNAME:e,SRP_A:u.A.toString(16)};i==="USER_AUTH"&&r&&(g.PREFERRED_CHALLENGE=r);const p=$({username:e,userPoolId:a,userPoolClientId:c}),m={AuthFlow:i,AuthParameters:g,ClientMetadata:n,ClientId:c,UserContextData:p},T=await ge({endpointResolver:x({endpointOverride:d})})({region:w(a),userAgentValue:W(z.SignIn)},m),{ChallengeParameters:S,Session:F}=T,ie=S?.USERNAME??e;return pe(ie),T.ChallengeName==="PASSWORD_VERIFIER"?Ue(In,[t,S,n,F,u,o,s],ie,s):T}const Lt="userAttributes.";function Ys(e){return"isSignedIn"in e&&"nextStep"in e}async function Js(e,t,n,o,s){const{userPoolClientId:i,userPoolId:r,userPoolEndpoint:a}=o,c={USERNAME:e,PASSWORD:t},d=await s.getDeviceMetadata(e);d&&d.deviceKey&&(c.DEVICE_KEY=d.deviceKey);const l=$({username:e,userPoolId:r,userPoolClientId:i}),u={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:c,ClientMetadata:n,ClientId:i,UserContextData:l},p=await ge({endpointResolver:x({endpointOverride:a})})({region:w(r),userAgentValue:W(z.SignIn)},u),m=p.ChallengeParameters?.USERNAME??p.ChallengeParameters?.USER_ID_FOR_SRP??e;return pe(m),p.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:m,config:o,clientMetadata:n,session:p.Session,tokenOrchestrator:s}):p}async function Xs(e,t,n,o,s){return yn({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:"USER_SRP_AUTH"})}async function Zs(e,t,n,o){const{userPoolClientId:s,userPoolId:i,userPoolEndpoint:r}=n,a={USERNAME:e},c=await o.getDeviceMetadata(e);c&&c.deviceKey&&(a.DEVICE_KEY=c.deviceKey);const d=$({username:e,userPoolId:i,userPoolClientId:s}),l={AuthFlow:"CUSTOM_AUTH",AuthParameters:a,ClientMetadata:t,ClientId:s,UserContextData:d},g=await ge({endpointResolver:x({endpointOverride:r})})({region:w(i),userAgentValue:W(z.SignIn)},l),p=g.ChallengeParameters?.USERNAME??e;return pe(p),g.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:p,config:n,clientMetadata:t,session:g.Session,tokenOrchestrator:o}):g}async function Qs(e,t,n,o,s){f(o);const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:a}=o,c=i?.split("_")[1]||"",d=await Oe(c),l={USERNAME:e,SRP_A:d.A.toString(16),CHALLENGE_NAME:"SRP_A"},u=$({username:e,userPoolId:i,userPoolClientId:r}),g={AuthFlow:"CUSTOM_AUTH",AuthParameters:l,ClientMetadata:n,ClientId:r,UserContextData:u},p=ge({endpointResolver:x({endpointOverride:a})}),{ChallengeParameters:m,Session:y}=await p({region:w(i),userAgentValue:W(z.SignIn)},g),T=m?.USERNAME??e;return pe(T),Ue(In,[t,m,n,y,d,o,s],T,s)}async function se(e){const{challengeName:t,challengeParameters:n,availableChallenges:o}=e,s=A.getConfig().Auth?.Cognito;switch(f(s),t){case"CUSTOM_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE",additionalInfo:n}};case"MFA_SETUP":{const{signInSession:i,username:r}=B.getState(),a=Bt(Vt(n.MFAS_CAN_SETUP))||[],c=oi(a),d=c.includes("TOTP"),l=c.includes("EMAIL");if(d&&l)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:c}};if(l)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(d){const u=xo({endpointResolver:x({endpointOverride:s.userPoolEndpoint})}),{Session:g,SecretCode:p}=await u({region:w(s.userPoolId)},{Session:i});return B.dispatch({type:"SET_SIGN_IN_SESSION",value:g}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:ei(
4p,r)}}}throw new E({name:Re.SignInException,message:`Cannot initiate MFA setup from available types: ${a}`})}case"NEW_PASSWORD_REQUIRED":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED",missingAttributes:ti(n.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:Bt(Vt(n.MFAS_CAN_CHOOSE))}};case"SMS_OTP":case"SMS_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_SMS_CODE",codeDeliveryDetails:{deliveryMedium:n.CODE_DELIVERY_DELIVERY_MEDIUM,destination:n.CODE_DELIVERY_DESTINATION}}};case"SOFTWARE_TOKEN_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_TOTP_CODE"}};case"EMAIL_OTP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_EMAIL_CODE",codeDeliveryDetails:{deliveryMedium:n.CODE_DELIVERY_DELIVERY_MEDIUM,destination:n.CODE_DELIVERY_DESTINATION}}};case"WEB_AUTHN":{const i=await Ws(n);return Ys(i)?i:se(i)}case"PASSWORD":case"PASSWORD_SRP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_PASSWORD"}};case"SELECT_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION",availableChallenges:o}}}throw new E({name:Re.SignInException,message:`An error occurred during the sign in process. ${t} challengeName returned by the underlying service was not addressed.`})}function ei(e,t){return{sharedSecret:e,getSetupUri:(n,o)=>{const s=`otpauth://totp/${n}:${o??t}?secret=${e}&issuer=${n}`;return new ze(s)}}}function Ee(e){if(e===Ce.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(e===Ce.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function ti(e){return e?JSON.parse(e).map(n=>n.includes(Lt)?n.replace(Lt,""):n):[]}function ni(e){if(e==="SMS_MFA")return"SMS";if(e==="SOFTWARE_TOKEN_MFA")return"TOTP";if(e==="EMAIL_OTP")return"EMAIL"}function Bt(e){if(e)return e.map(ni).filter(Boolean)}function Vt(e){return e?JSON.parse(e):[]}function oi(e){return e.filter(t=>t==="EMAIL"||t==="TOTP")}async function si(){let e;try{e=await De()}catch{}if(e&&e.userId&&e.username)throw new E({name:so,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function me(e){return B.getState().username??e}async function ii(e){const t=A.getConfig().Auth?.Cognito;f(t);const{username:n,password:o,options:s}=e,i={loginId:n,authFlowType:"CUSTOM_WITHOUT_SRP"},r=s?.clientMetadata;P(!!n,N.EmptySignInUsername),P(!o,N.CustomAuthSignInPassword);try{const{ChallengeName:a,ChallengeParameters:c,AuthenticationResult:d,Session:l}=await Ue(Zs,[n,r,t,C],n,C),u=me(n);return ee({signInSession:l,username:u,challengeName:a,signInDetails:i}
4),d?(await Z({username:u,...d,NewDeviceMetadata:await oe({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:d.NewDeviceMetadata,accessToken:d.AccessToken}),signInDetails:i}),D(),await Q(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):se({challengeName:a,challengeParameters:c})}catch(a){D(),K(a);const c=Ee(a.name);if(c)return c;throw a}}async function ri(e){const{username:t,password:n,options:o}=e,s={loginId:t,authFlowType:"CUSTOM_WITH_SRP"},i=A.getConfig().Auth?.Cognito;f(i);const r=o?.clientMetadata;P(!!t,N.EmptySignInUsername),P(!!n,N.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:c,AuthenticationResult:d,Session:l}=await Qs(t,n,r,i,C),u=me(t);return ee({signInSession:l,username:u,challengeName:a,signInDetails:s}),d?(await Z({username:u,...d,NewDeviceMetadata:await oe({userPoolId:i.userPoolId,userPoolEndpoint:i.userPoolEndpoint,newDeviceMetadata:d.NewDeviceMetadata,accessToken:d.AccessToken}),signInDetails:s}),D(),await Q(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):se({challengeName:a,challengeParameters:c})}catch(a){D(),K(a);const c=Ee(a.name);if(c)return c;throw a}}function q(e=!0){gn.dispatch({type:"RESET"})}async function Ht(e){const{username:t,password:n}=e,o=A.getConfig().Auth?.Cognito,s={loginId:t,authFlowType:"USER_SRP_AUTH"};f(o);const i=e.options?.clientMetadata;P(!!t,N.EmptySignInUsername),P(!!n,N.EmptySignInPassword);try{const{ChallengeName:r,ChallengeParameters:a,AuthenticationResult:c,Session:d}=await Xs(t,n,i,o,C),l=me(t);return ee({signInSession:d,username:l,challengeName:r,signInDetails:s}),c?(await Z({username:l,...c,NewDeviceMetadata:await oe({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:c.NewDeviceMetadata,accessToken:c.AccessToken}),signInDetails:s}),D(),await Q(),q(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):se({challengeName:r,challengeParameters:a})}catch(r){D(),q(),K(r);const a=Ee(r.name);if(a)return a;throw r}}async function ai(e){const{username:t,password:n,options:o}=e,s=A.getConfig().Auth?.Cognito,i={loginId:t,authFlowType:"USER_PASSWORD_AUTH"};f(s);const r=o?.clientMetadata;P(!!t,N.EmptySignInUsername),P(!!n,N.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:c,AuthenticationResult:d,Session:l}=await Ue(Js,[t,n,r,s,C],t,C),u=me(t);return ee({signInSession:l,username:u,challengeName:a,signInDetails:i}
4),d?(await Z({...d,username:u,NewDeviceMetadata:await oe({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:d.NewDeviceMetadata,accessToken:d.AccessToken}),signInDetails:i}),D(),await Q(),q(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):se({challengeName:a,challengeParameters:c})}catch(a){D(),q(),K(a);const c=Ee(a.name);if(c)return c;throw a}}async function ci({username:e,clientMetadata:t,config:n,tokenOrchestrator:o,preferredChallenge:s,password:i,session:r}){const{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=n,l=$({username:e,userPoolId:a,userPoolClientId:c}),u={USERNAME:e};if(s){if(s==="PASSWORD_SRP")return P(!!i,N.EmptySignInPassword),yn({username:e,password:i,clientMetadata:t,config:n,tokenOrchestrator:o,authFlow:"USER_AUTH",preferredChallenge:s});s==="PASSWORD"&&(P(!!i,N.EmptySignInPassword),u.PASSWORD=i),u.PREFERRED_CHALLENGE=s}const g={AuthFlow:"USER_AUTH",AuthParameters:u,ClientMetadata:t,ClientId:c,UserContextData:l};r&&(g.Session=r);const m=await ge({endpointResolver:x({endpointOverride:d})})({region:w(a),userAgentValue:W(z.SignIn)},g);return pe(e),m}async function di(e){const{username:t,password:n,options:o}=e,s=A.getConfig().Auth?.Cognito,i={loginId:t,authFlowType:"USER_AUTH"};f(s);const r=o?.clientMetadata,a=o?.preferredChallenge;P(!!t,N.EmptySignInUsername);try{const c={username:t,config:s,tokenOrchestrator:C,clientMetadata:r,preferredChallenge:a,password:n},d=gn.getState();d.active&&d.username===t&&(c.session=d.session);const l=await ci(c),u=me(t);return ee({signInSession:l.Session,username:u,challengeName:l.ChallengeName,signInDetails:i}
4),l.AuthenticationResult?(await Z({username:u,...l.AuthenticationResult,NewDeviceMetadata:await oe({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:l.AuthenticationResult.NewDeviceMetadata,accessToken:l.AuthenticationResult.AccessToken}),signInDetails:i}),D(),await Q(),q(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):se({challengeName:l.ChallengeName,challengeParameters:l.ChallengeParameters,availableChallenges:"AvailableChallenges"in l?l.AvailableChallenges:void 0})}catch(c){D(),q(),K(c);const d=Ee(c.name);if(d)return d;throw c}}async function li(e){q(!1);const t=e.options?.authFlowType;switch(await si(),t){case"USER_SRP_AUTH":return Ht(e);case"USER_PASSWORD_AUTH":return ai(e);case"CUSTOM_WITHOUT_SRP":return ii(e);case"CUSTOM_WITH_SRP":return ri(e);case"USER_AUTH":return di(e);default:return Ht(e)}}function ui(e,t){{const n=e?.find(hi)??e?.find(gi),o=e?.find(Ei)??e?.find(pi);if(n)return n;throw o?ho:lo}}const hi=e=>e.startsWith(String(window.location.origin+(window.location.pathname||"/"))),gi=e=>e.includes(String(window.location.hostname)),pi=e=>e.startsWith("http://"),Ei=e=>e.startsWith("https://"),mi=async e=>{window?.location&&(window.location.href=e.replace("http://","https://"))},fi=async e=>{await e.clearOAuthData(),C.clearTokens(),await Zt(),de.dispatch("auth",{event:"signedOut"},"Auth",le)},Ii=async(e,t=!1,n)=>{Jt(e);const{loginWith:o,userPoolClientId:s}=e,{domain:i,redirectSignOut:r}=o.oauth,a=ui(r),c=`https://${i}/logout?${Object.entries({client_id:s,logout_uri:encodeURIComponent(a)}).map(([d,l])=>`${d}=${l}`).join("&")}`;return mi(c)},yi=async(e,t,n,o)=>{const{isOAuthSignIn:s}=await t.loadOAuthSignIn(),i=await n.getOAuthMetadata();if(await fi(t),s||i?.oauthSignIn)return Ii(e,!1)},Si=e=>V(X,J("RevokeToken"),Y(),{...G,...e}),Ti=new _e("Auth");async function Ai(e){const t=A.getConfig().Auth?.Cognito;f(t),await vi(t);let n;try{Jt(t),n=!0}catch{n=!1}if(n){const o=new un(he);o.setAuthConfig(t);const{type:s}=await yi(t,o,C)??{};if(s==="error")throw new E({name:go,message:"An error occurred when attempting to log out from OAuth provider."})}else C.clearTokens(),await Zt(),de.dispatch("auth",{event:"signedOut"},"Auth",le)}async function vi(e){try{const{userPoolEndpoint:t,userPoolId:n,userPoolClientId:o}=e,s=await C.getTokenStore().loadTokens();cn(s),wi(s.accessToken)&&await Si({endpointResolver:x({endpointOverride:t})})({region:w(n),userAgentValue:W(z.SignOut)},{ClientId:o,Token:s.refreshToken})}catch{Ti.debug("Client signOut error caught but will proceed with token removal")}}const wi=e=>!!e?.payload?.origin_jti,xi={identityId:"identityId"},Ri=new _e("DefaultIdentityIdStore");class Sn{setAuthConfig(t){Ae(t.Cognito),this.authConfig=t,this._authKeys=Ci("Cognito",t.Cognito.identityPoolId)}constructor(t){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=t}async loadIdentityId(){Ae(this.authConfig?.Cognito);try{if(this._primaryIdentityId)return{id:this._primaryIdentityId,type:"primary"};{const t=await this.keyValueStorage.getItem(this._authKeys.identityId);return t?(this._hasGuestIdentityId=!0,{id:t,type:"guest"}):null}}catch(t){return Ri.log("Error getting stored IdentityId.",t),null}}async storeIdentityId(t){Ae(this.authConfig?.Cognito),t.type==="guest"?(this.keyValueStorage.setItem(this._authKeys.identityId,t.id),this._primaryIdentityId=void 0,this._hasGuestIdentityId=!0):(this._primaryIdentityId=t.id,this._hasGuestIdentityId&&(this.keyValueStorage.removeItem(this._authKeys.identityId),this._hasGuestIdentityId=!1))}async clearIdentityId(){this._primaryIdentityId=void 0,await this.keyValueStorage.removeItem(this._authKeys.identityId)}}const Ci=(e,t)=>Ge(xi)(`com.amplify.${e}`,t),qe=({endpointOverride:e})=>t=>e?{url:new ze(e)}:zn(t);function Tn(e){const t=H(e).payload.iss,n={};if(!t)throw new E({name:"InvalidIdTokenException",message:"Invalid Idtoken."});const o=t.replace(/(^\w+:|^)\/\//,"");return n[o]=e,n}async function Pi({tokens:e,authConfig:t,identityIdStore:n}){n.setAuthConfig({Cognito:t});const o=await n.loadIdentityId();if(o)return o.id;const s=e?.idToken?Tn(e.idToken.toString()):{},i=await Ni(s,t);return n.storeIdentityId({id:i,type:e?"primary":"guest"}),i}async function Ni(e,t){const n=t?.identityPoolId,o=Le(n),s=qn({endpointResolver:qe({endpointOverride:t.identityPoolEndpoint})});let i;try{i=(await s({region:o},{IdentityPoolId:n,Logins:e})).IdentityId}catch(r){throw K(r),new E(r)}if(!i)throw new E({name:"GetIdResponseException",message:"Received undefined response from getId operation",recoverySuggestion:"Make sure to pass a valid identityPoolId in the configuration."});return i}const Te=new _e("CognitoCredentialsProvider"),qt=3e3*1e3;class An{constructor(t){this._nextCredentialsRefresh=0,this._identityIdStore=t}async clearCredentialsAndIdentityId(){Te.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){Te.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(t){const n=t.authenticated,{tokens:o}=t,{authConfig:s}=t;try{Ae(s?.Cognito)}catch{return}if(!n&&!s.Cognito.allowGuestAccess)return;const{forceRefresh:i}=t,r=this.hasTokenChanged(o),a=await Pi({tokens:o,authConfig:s.Cognito,identityIdStore:this._identityIdStore});return(i||r)&&this.clearCredentials(),n?(fo(o),this.credsForOIDCTokens(s.Cognito,o,a)):this.getGuestCredentials(a,s.Cognito)}async getGuestCredentials(t,n){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return Te.info("returning stored credentials as they neither past TTL n
4or expired."),this._credentialsAndIdentityId;this.clearCredentials();const o=Le(n.identityPoolId),s=it({endpointResolver:qe({endpointOverride:n.identityPoolEndpoint})});let i;try{i=await s({region:o},{IdentityId:t})}catch(r){throw K(r),new E(r)}if(i?.Credentials?.AccessKeyId&&i?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+qt;const r={credentials:{accessKeyId:i.Credentials.AccessKeyId,secretAccessKey:i.Credentials.SecretKey,sessionToken:i.Credentials.SessionToken,expiration:i.Credentials.Expiration},identityId:t};return i.IdentityId&&(r.identityId=i.IdentityId,this._identityIdStore.storeIdentityId({id:i.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...r,isAuthenticatedCreds:!1},r}else throw new E({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(t,n,o){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return Te.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const s=n.idToken?Tn(n.idToken.toString()):{}
4,i=Le(t.identityPoolId),r=it({endpointResolver:qe({endpointOverride:t.identityPoolEndpoint})});let a;try{a=await r({region:i},{IdentityId:o,Logins:s})}catch(c){throw K(c),new E(c)}if(a?.Credentials?.AccessKeyId&&a?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+qt;const c={credentials:{accessKeyId:a.Credentials.AccessKeyId,secretAccessKey:a.Credentials.SecretKey,sessionToken:a.Credentials.SessionToken,expiration:a.Credentials.Expiration},identityId:o};return a.IdentityId&&(c.identityId=a.IdentityId,this._identityIdStore.storeIdentityId({id:a.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...c,isAuthenticatedCreds:!0,associatedIdToken:n.idToken?.toString()},c}else throw new E({name:"CredentialsException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}isPastTTL(){return this._nextCredentialsRefresh===void 0?!0:this._nextCredentialsRefresh<=Date.now()}hasTokenChanged(t){return!!t&&!!this._credentialsAndIdentityId?.associatedIdToken&&t.idToken?.toString()!==this._credentialsAndIdentityId.associatedIdToken}}const _i=new An(new Sn(he)),ki={configure(e,t){const n=Dn(e),o=new Zn({sameSite:"lax"}),s=t?.ssr?o:he,i=t?.ssr?new An(new Sn(o)):_i;if(!n.Auth){A.configure(n,t);return}if(t?.Auth){A.configure(n,t);return}if(!A.libraryOptions.Auth){ce.setAuthConfig(n.Auth),ce.setKeyValueStorage(s),A.configure(n,{...t,Auth:{tokenProvider:ce,credentialsProvider:i}});return}if(t){const r=A.libraryOptions.Auth;t.ssr!==void 0&&(ce.setKeyValueStorage(s),r.credentialsProvider=i),A.configure(n,{Auth:r,...t});return}A.configure(n)},getConfig(){return A.getConfig()}},Di={aws_project_region:"us-east-1",aws_cognito_identity_pool_id:"us-east-1:53ae22eb-ead5-43f4-aea3-51479c838870",aws_cognito_region:"us-east-1",aws_user_pools_id:"us-east-1_eO1IMyxRA",aws_user_pools_web_client_id:"o4uqjda3f6drnnjjocprq7lu1",oauth:{},aws_cognito_username_attributes:["EMAIL"],aws_cognito_social_providers:[],aws_cognito_signup_attributes:["EMAIL","NAME"],aws_cognito_mfa_configuration:"OFF",aws_cognito_mfa_types:["SMS"],aws_cognito_password_protection_settings:{passwordPolicyMinLength:8,passwordPolicyCharacters:[]},aws_cognito_verification_mechanisms:["EMAIL"],aws_mandatory_sign_in:"enable"};ki.configure(Di);const ot="willa_bearer_token";async function Ki(e,t){await li({username:e,password:t}),await vn()}async function Li(){await Ai();try{window.localStorage.removeItem(ot)}catch{}wn()}async function Bi(){try{return await De(),await vn(),!0}catch{return!1}}async function vn(){try{const e=await bn(),t=e.tokens?.idToken?.toString()||e.tokens?.accessToken?.toString();t&&window.localStorage.setItem(ot,t)}catch{}}function Fi(){try{return window.localStorage.getItem(ot)}catch{return null}}function Mi(e){if(!e)return null;const t=e.split(".");if(t.length<2)return null;try{const o=t[1].replace(/-/g,"+").replace(/_/g,"/"),s="=".repeat((4-o.length%4)%4),i=atob(o+s);return JSON.parse(i)}catch{return null}}async function Vi(){try{const e=await De(),t=Fi(),n=Mi(t),o=e.username||e.userId||"",s=n?.given_name||n?.name?.split(" ")?.[0]||void 0,i=n?.email||(o.includes("@")?o:void 0),r=n?.picture||null,a=s&&s.trim()||i&&i.trim()||"User";let c=null;try{const{getUserSettings:l}=await On(async()=>{const{getUserSettings:g}=await import("./userService-BHOTfUp_.js");return{getUserSettings:g}},__vite__mapDeps([0,1]));c=(await l())?.data?.item?.cover||null}catch{}const d=c||(r&&r.trim()?r.trim():null);return{email:i||o||"",name:a,avatarUrl:d}}catch{return null}}export{Li as a,Fi as b,De as c,Bi as e,Vi as g,Ki as l};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.