wjec-one 4.0.1-alpha.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/auth/index.js CHANGED
@@ -1 +1 @@
1
- import{Auth as e,Hub as t,Amplify as r}from"aws-amplify";import{assertNever as n,developerWarning as o,isCallableFunction as a}from"wjec-one/utils";function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function c(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){u(a,n,o,i,c,"next",e)}function c(e){u(a,n,o,i,c,"throw",e)}i(void 0)}))}}function s(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function p(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function d(){d=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof E?t:E,i=Object.create(a.prototype),u=new C(n||[]);return o(i,"_invoke",{value:P(e,r,u)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p="suspendedStart",y="suspendedYield",h="executing",m="completed",v={};function E(){}function g(){}function _(){}var b={};s(b,i,(function(){return this}));var S=Object.getPrototypeOf,T=S&&S(S(I([])));T&&T!==r&&n.call(T,i)&&(b=T);var w=_.prototype=E.prototype=Object.create(b);function O(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(o,a,i,u){var c=l(e[o],e,a);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(f).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return a=a?a.then(o,o):o()}})}function P(t,r,n){var o=p;return function(a,i){if(o===h)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var c=N(u,n);if(c){if(c===v)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=h;var s=l(t,r,n);if("normal"===s.type){if(o=n.done?m:y,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function N(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,N(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function I(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return g.prototype=_,o(w,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:g,configurable:!0}),g.displayName=s(_,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,_):(e.__proto__=_,s(e,c,"GeneratorFunction")),e.prototype=Object.create(w),e},t.awrap=function(e){return{__await:e}},O(R.prototype),s(R.prototype,u,(function(){return this})),t.AsyncIterator=R,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new R(f(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(w),s(w,c,"Generator"),s(w,i,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=I,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return u.type="throw",u.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:I(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,u=[],c=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return u}}(e,t)||v(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function v(e,t){if(e){if("string"==typeof e)return i(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}var E,g,_,b,S;!function(e){e.CHANGE_PASSWORD="changePassword",e.COMPLETE_PASSWORD_RESET="completePasswordReset",e.FORCE_CHANGE_PASSWORD="forceChangePassword",e.GET_AUTHORIZATION_TOKEN="getAuthorizationToken",e.GET_USER_PREFERENCES="getUserPreferences",e.GET_USER_SESSION="getUserSession",e.INIT="init",e.REFRESH_USER_SESSION="refreshUserSession",e.REQUEST_PASSWORD_RESET="requestPasswordReset",e.REQUEST_TOTP_TOKEN="requestSoftwareToken",e.SET_MFA_TYPE="setMfaType",e.SIGN_IN="signIn",e.SIGN_OUT="signOut",e.SUBMIT_MFA_CODE="confirmSignIn",e.UPDATE_USER_ATTRIBUTES="updateUserAttributes",e.UPDATE_USER_PREFERENCES="updateUserPreferences",e.VERIFY_TELEPHONE_NUMBER="verifyTelephoneNumber",e.VERIFY_TOTP_TOKEN="verifySoftwareToken"}(E||(E={})),function(e){e.CUSTOM_CHALLENGE="CUSTOM_CHALLENGE",e.EMAIL_MFA="EMAIL",e.MFA_SETUP="MFA_SETUP",e.NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",e.SMS_MFA="SMS",e.TOTP_MFA="TOTP",e.VERIFY_TELEPHONE_NUMBER="VERIFY_TELEPHONE_NUMBER",e.VERIFY_TOTP_TOKEN="VERIFY_TOTP_TOKEN"}(g||(g={})),function(e){e.EMAIL="EMAIL",e.NONE="NONE",e.SMS="SMS",e.TOTP="TOTP"}(_||(_={})),function(e){e.ADMINISTRATIVE_SUPPORT="administrativeSupport",e.EXAMS_OFFICER="examsOfficer",e.HEAD_OF_DEPARTMENT="headOfDepartment",e.HEAD_OF_YEAR="headOfYear",e.HEAD_TEACHER="headTeacher",e.LOCAL_AUTHORITY_ADVISOR="localAuthorityAdvisor",e.OTHER="other",e.STAKEHOLDER="stakeholder",e.TEACHER="teacher",e.TUTOR="tutor"}(b||(b={})),function(e){e.ENGLISH="english",e.MATHS="maths",e.SCIENCE="science"}(S||(S={}));var T,w=function(t,r){return function(){var n;if(H("isInitialized")){for(var o=arguments.length,a=new Array(o),i=0;i<o;i++)a[i]=arguments[i];(n=t.call.apply(t,[e].concat(a)))instanceof Promise&&n.catch((function(e){I(r,e)}))}else console.error("WJEC One Authorization: You tried to call ".concat(r,"() before AWS Amplify was initialized. Please provide values for amplifyConfig & oAuthConfig to get set up"));return n}},O=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.then((function(){return r&&A(t,"done"),!0})).catch((function(e){return(e instanceof Error||"string"==typeof e)&&I(t,e),!1}))},R=function(e){return"object"===m(e)&&Object.hasOwn(e,"name")&&"NotAuthorizedException"===e.name},P=function(e){return"object"===m(e)&&Object.hasOwn(e,"name")&&"InvalidPasswordException"===e.name},N=function(e){return Object.entries(e).reduce((function(e,t){var r=y(t,2),o=r[0],a=r[1];return l(l({},e),{},s({},function(e){return"telephoneNumber"===e?"phone_number":n(e)}(o),a))}),{})},k=function(e){return l(l({},e),{},{emailMfaAccepted:e.emailMfaAccepted?new Date(e.emailMfaAccepted):void 0})},A=function(e,t){var r=H("requestStatuses");G({requestStatuses:l(l({},r),{},s({},e,t))})},C=function(e){t.dispatch("custom",{data:{challenge:e},event:"challenge"})},I=function(e,r){t.dispatch("custom",{data:{errorDetails:r,errorType:e},event:"error"})},x=function(e,r){t.dispatch("custom",{data:r,event:e})},j=function(e){x(E.INIT,{session:e})},U=function(){var t=c(d().mark((function t(){var r,n,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,n=r.getIdToken(),t.next=6,fetch("".concat(H("usersEndpoint")).concat(n.payload.sub,"/mfa/secret"),{headers:{Authorization:n.getJwtToken()}}).then((function(e){return e.json()})).then((function(e){return e.secret}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),M=function(){var t=c(d().mark((function t(){var r,n,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,n=r.getIdToken(),t.next=6,fetch("".concat(H("usersEndpoint")).concat(n.payload.sub,"/preferences"),{headers:{Authorization:n.getJwtToken()}}).then((function(e){return null==e?void 0:e.json()}));case 6:return o=t.sent,t.abrupt("return",o||{});case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),L=function(){var t=c(d().mark((function t(r){var n,o,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,o=n.getIdToken(),t.next=6,fetch("".concat(H("usersEndpoint")).concat(o.payload.sub,"/mfa"),{body:JSON.stringify({mfaType:r}),headers:{Authorization:o.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return a=t.sent,t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),D=function(){var t=c(d().mark((function t(r){var n,o,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,o=n.getIdToken(),t.next=6,fetch("".concat(H("usersEndpoint")).concat(o.payload.sub),{body:JSON.stringify(r),headers:{Authorization:o.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return a=t.sent,t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),F=function(){var t=c(d().mark((function t(r){var n,o,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,o=n.getIdToken(),t.next=6,fetch("".concat(H("usersEndpoint")).concat(o.payload.sub,"/preferences"),{body:JSON.stringify(r),headers:{Authorization:o.getJwtToken()},method:"POST"}).then((function(e){return e.json()})).then((function(e){return e.success}));case 6:return a=t.sent,t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),V=function(){var t=c(d().mark((function t(r){var n,o,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,o=n.getIdToken(),t.next=6,fetch("".concat(H("usersEndpoint")).concat(o.payload.sub,"/mfa/secret"),{body:JSON.stringify({totpCode:r}),headers:{Authorization:o.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return a=t.sent,t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),$={centrePermissions:{},emailAddress:void 0,emailAddressVerified:!1,familyName:void 0,name:void 0,givenName:void 0,groups:[],id:void 0,isInitialized:!1,isSignedIn:!1,languagePreference:"en-gb",mfaType:void 0,middleName:void 0,preferences:{},provider:void 0,requestStatuses:Object.values(E).reduce((function(e,t){return l(l({},e),{},s({},t,"idle"))}),{}),telephoneNumber:void 0,telephoneNumberVerified:!1,totpVerified:!1,usersEndpoint:void 0},H=function(e){return $[e]},G=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Object.entries(e).forEach((function(e){var t=y(e,2),r=t[0],n=t[1];$[r]=n})),r&&t.dispatch("custom",{data:{updatedTimestamp:Date.now()},event:"cacheUpdated"})},W=function(){var e=c(d().mark((function e(t){var r,n,o,a,i,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.getIdToken().payload,A(E.GET_USER_PREFERENCES,"loading"),e.next=4,M().then((function(e){return A(E.GET_USER_PREFERENCES,"done"),e})).catch((function(e){return I(E.GET_USER_PREFERENCES,e),{}}));case 4:i=e.sent,u=k(i),G({centrePermissions:JSON.parse(a["custom:centre_permissions"]||"{}"),emailAddress:a.email,emailAddressVerified:a.email_verified,familyName:a.family_name||a.familyName,name:a.name,givenName:a.given_name||a.givenName,groups:a["cognito:groups"]||[],id:a.sub,isInitialized:!0,isSignedIn:!0,languagePreference:a["custom:language_preference"],mfaType:a["custom:mfa_type"],middleName:a.middle_name||a.middleName,preferences:u,provider:(null===(r=a.identities)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.providerName)||"Cognito",telephoneNumber:a.phone_number,telephoneNumberVerified:a.phone_number_verified,totpVerified:"true"===(null===(o=a["custom:totp_verified"])||void 0===o?void 0:o.toLowerCase())});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Y=function(){G({centrePermissions:{},emailAddress:void 0,emailAddressVerified:!1,familyName:void 0,name:void 0,givenName:void 0,groups:[],id:void 0,isSignedIn:!1,languagePreference:void 0,mfaType:void 0,middleName:void 0,preferences:{},provider:void 0,telephoneNumber:void 0,telephoneNumberVerified:!1,totpVerified:!1})},z=function(t){return function(){var r=c(d().mark((function r(n){var o,a,i;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return A(E.FORCE_CHANGE_PASSWORD,"loading"),r.next=3,e.completeNewPassword(t,n).catch((function(e){R(e)||P(e)||I(E.FORCE_CHANGE_PASSWORD,e),o=!1}));case 3:if(!(a=r.sent)){r.next=12;break}if(!a.challengeName){r.next=10;break}return r.next=8,q(a.challengeName,a,a.challengeParam);case 8:i=r.sent,C(i);case 10:A(E.FORCE_CHANGE_PASSWORD,"done"),o=!0;case 12:return r.abrupt("return",o);case 13:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()},B=function(t){return function(){var r=c(d().mark((function r(n){var o;return d().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return A(E.SUBMIT_MFA_CODE,"loading"),r.next=3,e.sendCustomChallengeAnswer(t,n).then(function(){var e=c(d().mark((function e(r){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==r||!r.challengeName){e.next=5;break}return e.next=3,q(r.challengeName,t,r.challengeParam);case 3:o=e.sent,C(o);case 5:A(E.SUBMIT_MFA_CODE,"done");case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){I(E.SUBMIT_MFA_CODE,e)}));case 3:return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()},q=function(t,r){var n,o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=K(t,null==a?void 0:a.selectedMfaType);switch(i){case g.EMAIL_MFA:n={attemptNumber:a.attemptNumber?parseInt(a.attemptNumber):void 0,challengeType:g.EMAIL_MFA,completeChallenge:B(r),emailAddress:a.emailAddress};break;case g.NEW_PASSWORD_REQUIRED:n={challengeType:g.NEW_PASSWORD_REQUIRED,completeChallenge:z(r)};break;case g.SMS_MFA:n={attemptNumber:a.attemptNumber?parseInt(a.attemptNumber):void 0,challengeType:i,completeChallenge:B(r),telephoneNumber:t===g.CUSTOM_CHALLENGE?a.redactedPhoneNumber:a.CODE_DELIVERY_DESTINATION};break;case g.TOTP_MFA:n={attemptNumber:a.attemptNumber?parseInt(a.attemptNumber):void 0,challengeType:i,completeChallenge:B(r)};break;case g.VERIFY_TELEPHONE_NUMBER:n={challengeType:i,completeChallenge:(o=a.currentMfaType,function(){var t=c(d().mark((function t(r){var n;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return A(E.VERIFY_TELEPHONE_NUMBER,"loading"),t.next=3,O(e.verifyCurrentUserAttributeSubmit("phone_number",r),E.VERIFY_TELEPHONE_NUMBER);case 3:if(!(n=t.sent)){t.next=9;break}if(G({telephoneNumberVerified:!0}),H("mfaType")===_.SMS||o!==_.SMS){t.next=9;break}return t.next=9,me(_.SMS,!0);case 9:return t.abrupt("return",n);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())};break;case g.VERIFY_TOTP_TOKEN:n={challengeType:i,completeChallenge:function(){var e=c(d().mark((function e(t){var r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Te(t);case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),secretKey:a.secretKey}}return n},K=function(e,t){if(e===g.CUSTOM_CHALLENGE)switch(t){case _.EMAIL:return g.EMAIL_MFA;case _.SMS:return g.SMS_MFA;case _.TOTP:return g.TOTP_MFA}return e},J={},Q={get exports(){return J},set exports(e){J=e}},X={};function Z(){if(T)return X;T=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),i=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),s=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),l=Symbol.iterator;var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},d=Object.assign,y={};function h(e,t,r){this.props=e,this.context=t,this.refs=y,this.updater=r||p}function m(){}function v(e,t,r){this.props=e,this.context=t,this.refs=y,this.updater=r||p}h.prototype.isReactComponent={},h.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},h.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=h.prototype;var E=v.prototype=new m;E.constructor=v,d(E,h.prototype),E.isPureReactComponent=!0;var g=Array.isArray,_=Object.prototype.hasOwnProperty,b={current:null},S={key:!0,ref:!0,__self:!0,__source:!0};function w(t,r,n){var o,a={},i=null,u=null;if(null!=r)for(o in void 0!==r.ref&&(u=r.ref),void 0!==r.key&&(i=""+r.key),r)_.call(r,o)&&!S.hasOwnProperty(o)&&(a[o]=r[o]);var c=arguments.length-2;if(1===c)a.children=n;else if(1<c){for(var s=Array(c),f=0;f<c;f++)s[f]=arguments[f+2];a.children=s}if(t&&t.defaultProps)for(o in c=t.defaultProps)void 0===a[o]&&(a[o]=c[o]);return{$$typeof:e,type:t,key:i,ref:u,props:a,_owner:b.current}}function O(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var R=/\/+/g;function P(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function N(r,n,o,a,i){var u=typeof r;"undefined"!==u&&"boolean"!==u||(r=null);var c=!1;if(null===r)c=!0;else switch(u){case"string":case"number":c=!0;break;case"object":switch(r.$$typeof){case e:case t:c=!0}}if(c)return i=i(c=r),r=""===a?"."+P(c,0):a,g(i)?(o="",null!=r&&(o=r.replace(R,"$&/")+"/"),N(i,n,o,"",(function(e){return e}))):null!=i&&(O(i)&&(i=function(t,r){return{$$typeof:e,type:t.type,key:r,ref:t.ref,props:t.props,_owner:t._owner}}(i,o+(!i.key||c&&c.key===i.key?"":(""+i.key).replace(R,"$&/")+"/")+r)),n.push(i)),1;if(c=0,a=""===a?".":a+":",g(r))for(var s=0;s<r.length;s++){var f=a+P(u=r[s],s);c+=N(u,n,o,f,i)}else if(f=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=l&&e[l]||e["@@iterator"])?e:null}(r),"function"==typeof f)for(r=f.call(r),s=0;!(u=r.next()).done;)c+=N(u=u.value,n,o,f=a+P(u,s++),i);else if("object"===u)throw n=String(r),Error("Objects are not valid as a React child (found: "+("[object Object]"===n?"object with keys {"+Object.keys(r).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return c}function k(e,t,r){if(null==e)return e;var n=[],o=0;return N(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function A(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var C={current:null},I={transition:null},x={ReactCurrentDispatcher:C,ReactCurrentBatchConfig:I,ReactCurrentOwner:b};function j(){throw Error("act(...) is not supported in production builds of React.")}return X.Children={map:k,forEach:function(e,t,r){k(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return k(e,(function(){t++})),t},toArray:function(e){return k(e,(function(e){return e}))||[]},only:function(e){if(!O(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},X.Component=h,X.Fragment=r,X.Profiler=o,X.PureComponent=v,X.StrictMode=n,X.Suspense=c,X.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=x,X.act=j,X.cloneElement=function(t,r,n){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var o=d({},t.props),a=t.key,i=t.ref,u=t._owner;if(null!=r){if(void 0!==r.ref&&(i=r.ref,u=b.current),void 0!==r.key&&(a=""+r.key),t.type&&t.type.defaultProps)var c=t.type.defaultProps;for(s in r)_.call(r,s)&&!S.hasOwnProperty(s)&&(o[s]=void 0===r[s]&&void 0!==c?c[s]:r[s])}var s=arguments.length-2;if(1===s)o.children=n;else if(1<s){c=Array(s);for(var f=0;f<s;f++)c[f]=arguments[f+2];o.children=c}return{$$typeof:e,type:t.type,key:a,ref:i,props:o,_owner:u}},X.createContext=function(e){return(e={$$typeof:i,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},X.createElement=w,X.createFactory=function(e){var t=w.bind(null,e);return t.type=e,t},X.createRef=function(){return{current:null}},X.forwardRef=function(e){return{$$typeof:u,render:e}},X.isValidElement=O,X.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:A}},X.memo=function(e,t){return{$$typeof:s,type:e,compare:void 0===t?null:t}},X.startTransition=function(e){var t=I.transition;I.transition={};try{e()}finally{I.transition=t}},X.unstable_act=j,X.useCallback=function(e,t){return C.current.useCallback(e,t)},X.useContext=function(e){return C.current.useContext(e)},X.useDebugValue=function(){},X.useDeferredValue=function(e){return C.current.useDeferredValue(e)},X.useEffect=function(e,t){return C.current.useEffect(e,t)},X.useId=function(){return C.current.useId()},X.useImperativeHandle=function(e,t,r){return C.current.useImperativeHandle(e,t,r)},X.useInsertionEffect=function(e,t){return C.current.useInsertionEffect(e,t)},X.useLayoutEffect=function(e,t){return C.current.useLayoutEffect(e,t)},X.useMemo=function(e,t){return C.current.useMemo(e,t)},X.useReducer=function(e,t,r){return C.current.useReducer(e,t,r)},X.useRef=function(e){return C.current.useRef(e)},X.useState=function(e){return C.current.useState(e)},X.useSyncExternalStore=function(e,t,r){return C.current.useSyncExternalStore(e,t,r)},X.useTransition=function(){return C.current.useTransition()},X.version="18.3.1",X}var ee,te,re={},ne={get exports(){return re},set exports(e){re=e}};function oe(){return ee||(ee=1,e=ne,t=re,"production"!==process.env.NODE_ENV&&function(){"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),h=Symbol.iterator;function m(e){if(null===e||"object"!=typeof e)return null;var t=h&&e[h]||e["@@iterator"];return"function"==typeof t?t:null}var v={current:null},E={transition:null},g={current:null,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1},_={current:null},b={},S=null;function T(e){S=e}b.setExtraStackFrame=function(e){S=e},b.getCurrentStack=null,b.getStackAddendum=function(){var e="";S&&(e+=S);var t=b.getCurrentStack;return t&&(e+=t()||""),e};var w={ReactCurrentDispatcher:v,ReactCurrentBatchConfig:E,ReactCurrentOwner:_};function O(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];P("warn",e,r)}function R(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];P("error",e,r)}function P(e,t,r){var n=w.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(t+="%s",r=r.concat([n]));var o=r.map((function(e){return String(e)}));o.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,o)}w.ReactDebugCurrentFrame=b,w.ReactCurrentActQueue=g;var N={};function k(e,t){var r=e.constructor,n=r&&(r.displayName||r.name)||"ReactClass",o=n+"."+t;N[o]||(R("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",t,n),N[o]=!0)}var A={isMounted:function(e){return!1},enqueueForceUpdate:function(e,t,r){k(e,"forceUpdate")},enqueueReplaceState:function(e,t,r,n){k(e,"replaceState")},enqueueSetState:function(e,t,r,n){k(e,"setState")}},C=Object.assign,I={};function x(e,t,r){this.props=e,this.context=t,this.refs=I,this.updater=r||A}Object.freeze(I),x.prototype.isReactComponent={},x.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},x.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var j={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]},U=function(e,t){Object.defineProperty(x.prototype,e,{get:function(){O("%s(...) is deprecated in plain JavaScript React classes. %s",t[0],t[1])}})};for(var M in j)j.hasOwnProperty(M)&&U(M,j[M]);function L(){}function D(e,t,r){this.props=e,this.context=t,this.refs=I,this.updater=r||A}L.prototype=x.prototype;var F=D.prototype=new L;F.constructor=D,C(F,x.prototype),F.isPureReactComponent=!0;var V=Array.isArray;function $(e){return V(e)}function H(e){return""+e}function G(e){if(function(e){try{return H(e),!1}catch(e){return!0}}(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),H(e)}function W(e){return e.displayName||"Context"}function Y(e){if(null==e)return null;if("number"==typeof e.tag&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case o:return"Fragment";case n:return"Portal";case i:return"Profiler";case a:return"StrictMode";case f:return"Suspense";case l:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return W(e)+".Consumer";case u:return W(e._context)+".Provider";case s:return function(e,t,r){var n=e.displayName;if(n)return n;var o=t.displayName||t.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case p:var t=e.displayName||null;return null!==t?t:Y(e.type)||"Memo";case d:var r=e,y=r._payload,h=r._init;try{return Y(h(y))}catch(e){return null}}return null}var z,B,q,K=Object.prototype.hasOwnProperty,J={key:!0,ref:!0,__self:!0,__source:!0};function Q(e){if(K.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}function X(e){if(K.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}q={};var Z=function(e,t,n,o,a,i,u){var c={$$typeof:r,type:e,key:t,ref:n,props:u,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function ee(e,t,r){var n,o={},a=null,i=null,u=null,c=null;if(null!=t)for(n in Q(t)&&(i=t.ref,function(e){if("string"==typeof e.ref&&_.current&&e.__self&&_.current.stateNode!==e.__self){var t=Y(_.current.type);q[t]||(R('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',t,e.ref),q[t]=!0)}}(t)),X(t)&&(G(t.key),a=""+t.key),u=void 0===t.__self?null:t.__self,c=void 0===t.__source?null:t.__source,t)K.call(t,n)&&!J.hasOwnProperty(n)&&(o[n]=t[n]);var s=arguments.length-2;if(1===s)o.children=r;else if(s>1){for(var f=Array(s),l=0;l<s;l++)f[l]=arguments[l+2];Object.freeze&&Object.freeze(f),o.children=f}if(e&&e.defaultProps){var p=e.defaultProps;for(n in p)void 0===o[n]&&(o[n]=p[n])}if(a||i){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;a&&function(e,t){var r=function(){z||(z=!0,R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(o,d),i&&function(e,t){var r=function(){B||(B=!0,R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(o,d)}return Z(e,a,i,u,c,_.current,o)}function te(e,t,r){if(null==e)throw new Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n,o,a=C({},e.props),i=e.key,u=e.ref,c=e._self,s=e._source,f=e._owner;if(null!=t)for(n in Q(t)&&(u=t.ref,f=_.current),X(t)&&(G(t.key),i=""+t.key),e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)K.call(t,n)&&!J.hasOwnProperty(n)&&(void 0===t[n]&&void 0!==o?a[n]=o[n]:a[n]=t[n]);var l=arguments.length-2;if(1===l)a.children=r;else if(l>1){for(var p=Array(l),d=0;d<l;d++)p[d]=arguments[d+2];a.children=p}return Z(e.type,i,u,c,s,f,a)}function re(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}var ne,oe=!1,ae=/\/+/g;function ie(e){return e.replace(ae,"$&/")}function ue(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(G(e.key),r=""+e.key,n={"=":"=0",":":"=2"},"$"+r.replace(/[=:]/g,(function(e){return n[e]}))):t.toString(36);var r,n}function ce(e,t,o,a,i){var u=typeof e;"undefined"!==u&&"boolean"!==u||(e=null);var c,s,f,l=!1;if(null===e)l=!0;else switch(u){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case r:case n:l=!0}}if(l){var p=e,d=i(p),y=""===a?"."+ue(p,0):a;if($(d)){var h="";null!=y&&(h=ie(y)+"/"),ce(d,t,h,"",(function(e){return e}))}else null!=d&&(re(d)&&(!d.key||p&&p.key===d.key||G(d.key),c=d,s=o+(!d.key||p&&p.key===d.key?"":ie(""+d.key)+"/")+y,d=Z(c.type,s,c.ref,c._self,c._source,c._owner,c.props)),t.push(d));return 1}var v=0,E=""===a?".":a+":";if($(e))for(var g=0;g<e.length;g++)v+=ce(f=e[g],t,o,E+ue(f,g),i);else{var _=m(e);if("function"==typeof _){var b=e;_===b.entries&&(oe||O("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),oe=!0);for(var S,T=_.call(b),w=0;!(S=T.next()).done;)v+=ce(f=S.value,t,o,E+ue(f,w++),i)}else if("object"===u){var R=String(e);throw new Error("Objects are not valid as a React child (found: "+("[object Object]"===R?"object with keys {"+Object.keys(e).join(", ")+"}":R)+"). If you meant to render a collection of children, use an array instead.")}}return v}function se(e,t,r){if(null==e)return e;var n=[],o=0;return ce(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function fe(e){if(-1===e._status){var t=(0,e._result)();if(t.then((function(t){if(0===e._status||-1===e._status){var r=e;r._status=1,r._result=t}}),(function(t){if(0===e._status||-1===e._status){var r=e;r._status=2,r._result=t}})),-1===e._status){var r=e;r._status=0,r._result=t}}if(1===e._status){var n=e._result;return void 0===n&&R("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",n),"default"in n||R("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",n),n.default}throw e._result}function le(e){return"string"==typeof e||"function"==typeof e||e===o||e===i||e===a||e===f||e===l||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===d||e.$$typeof===p||e.$$typeof===u||e.$$typeof===c||e.$$typeof===s||e.$$typeof===ne||void 0!==e.getModuleId)}function pe(){var e=v.current;return null===e&&R("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."),e}ne=Symbol.for("react.module.reference");var de,ye,he,me,ve,Ee,ge,_e=0;function be(){}be.__reactDisabledLog=!0;var Se,Te=w.ReactCurrentDispatcher;function we(e,t,r){if(void 0===Se)try{throw Error()}catch(e){var n=e.stack.trim().match(/\n( *(at )?)/);Se=n&&n[1]||""}return"\n"+Se+e}var Oe,Re=!1,Pe="function"==typeof WeakMap?WeakMap:Map;function Ne(e,t){if(!e||Re)return"";var r,n=Oe.get(e);if(void 0!==n)return n;Re=!0;var o,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=Te.current,Te.current=null,function(){if(0===_e){de=console.log,ye=console.info,he=console.warn,me=console.error,ve=console.group,Ee=console.groupCollapsed,ge=console.groupEnd;var e={configurable:!0,enumerable:!0,value:be,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}_e++}();try{if(t){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(e){r=e}Reflect.construct(e,[],i)}else{try{i.call()}catch(e){r=e}e.call(i.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&"string"==typeof t.stack){for(var u=t.stack.split("\n"),c=r.stack.split("\n"),s=u.length-1,f=c.length-1;s>=1&&f>=0&&u[s]!==c[f];)f--;for(;s>=1&&f>=0;s--,f--)if(u[s]!==c[f]){if(1!==s||1!==f)do{if(s--,--f<0||u[s]!==c[f]){var l="\n"+u[s].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),"function"==typeof e&&Oe.set(e,l),l}}while(s>=1&&f>=0);break}}}finally{Re=!1,Te.current=o,function(){if(0==--_e){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},e,{value:de}),info:C({},e,{value:ye}),warn:C({},e,{value:he}),error:C({},e,{value:me}),group:C({},e,{value:ve}),groupCollapsed:C({},e,{value:Ee}),groupEnd:C({},e,{value:ge})})}_e<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var p=e?e.displayName||e.name:"",d=p?we(p):"";return"function"==typeof e&&Oe.set(e,d),d}function ke(e,t,r){if(null==e)return"";if("function"==typeof e)return Ne(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return we(e);switch(e){case f:return we("Suspense");case l:return we("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case s:return Ne(e.render,!1);case p:return ke(e.type,t,r);case d:var n=e,o=n._payload,a=n._init;try{return ke(a(o),t,r)}catch(e){}}return""}Oe=new Pe;var Ae,Ce={},Ie=w.ReactDebugCurrentFrame;function xe(e){if(e){var t=e._owner,r=ke(e.type,e._source,t?t.type:null);Ie.setExtraStackFrame(r)}else Ie.setExtraStackFrame(null)}function je(e){if(e){var t=e._owner;T(ke(e.type,e._source,t?t.type:null))}else T(null)}function Ue(){if(_.current){var e=Y(_.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Ae=!1;var Me={};function Le(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=Ue();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!Me[r]){Me[r]=!0;var n="";e&&e._owner&&e._owner!==_.current&&(n=" It was passed a child from "+Y(e._owner.type)+"."),je(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,n),je(null)}}}function De(e,t){if("object"==typeof e)if($(e))for(var r=0;r<e.length;r++){var n=e[r];re(n)&&Le(n,t)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var o=m(e);if("function"==typeof o&&o!==e.entries)for(var a,i=o.call(e);!(a=i.next()).done;)re(a.value)&&Le(a.value,t)}}function Fe(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==s&&r.$$typeof!==p)return;t=r.propTypes}if(t){var n=Y(r);!function(e,t,r,n,o){var a=Function.call.bind(K);for(var i in e)if(a(e,i)){var u=void 0;try{if("function"!=typeof e[i]){var c=Error((n||"React class")+": "+r+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}u=e[i](t,i,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){u=e}!u||u instanceof Error||(xe(o),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,i,typeof u),xe(null)),u instanceof Error&&!(u.message in Ce)&&(Ce[u.message]=!0,xe(o),R("Failed %s type: %s",r,u.message),xe(null))}}(t,e.props,"prop",n,e)}else void 0===r.PropTypes||Ae||(Ae=!0,R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Y(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ve(e,t,n){var a,i,u=le(e);if(!u){var c="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(c+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var s,f=null!=(a=t)&&void 0!==(i=a.__source)?"\n\nCheck your code at "+i.fileName.replace(/^.*[\\\/]/,"")+":"+i.lineNumber+".":"";c+=f||Ue(),null===e?s="null":$(e)?s="array":void 0!==e&&e.$$typeof===r?(s="<"+(Y(e.type)||"Unknown")+" />",c=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,R("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,c)}var l=ee.apply(this,arguments);if(null==l)return l;if(u)for(var p=2;p<arguments.length;p++)De(arguments[p],e);return e===o?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){je(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),je(null);break}}null!==e.ref&&(je(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),je(null))}(l):Fe(l),l}var $e=!1,He=!1,Ge=null,We=0,Ye=!1;function ze(e){var t=We;We++,null===g.current&&(g.current=[]);var r,n=g.isBatchingLegacy;try{if(g.isBatchingLegacy=!0,r=e(),!n&&g.didScheduleLegacyUpdate){var o=g.current;null!==o&&(g.didScheduleLegacyUpdate=!1,Je(o))}}catch(e){throw Be(t),e}finally{g.isBatchingLegacy=n}if(null!==r&&"object"==typeof r&&"function"==typeof r.then){var a=r,i=!1,u={then:function(e,r){i=!0,a.then((function(n){Be(t),0===We?qe(n,e,r):e(n)}),(function(e){Be(t),r(e)}))}};return Ye||"undefined"==typeof Promise||Promise.resolve().then((function(){})).then((function(){i||(Ye=!0,R("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))})),u}var c=r;if(Be(t),0===We){var s=g.current;return null!==s&&(Je(s),g.current=null),{then:function(e,t){null===g.current?(g.current=[],qe(c,e,t)):e(c)}}}return{then:function(e,t){e(c)}}}function Be(e){e!==We-1&&R("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),We=e}function qe(t,r,n){var o=g.current;if(null!==o)try{Je(o),function(t){if(null===Ge)try{var r=("require"+Math.random()).slice(0,7),n=e&&e[r];Ge=n.call(e,"timers").setImmediate}catch(e){Ge=function(e){!1===He&&(He=!0,"undefined"==typeof MessageChannel&&R("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var t=new MessageChannel;t.port1.onmessage=e,t.port2.postMessage(void 0)}}Ge(t)}((function(){0===o.length?(g.current=null,r(t)):qe(t,r,n)}))}catch(e){n(e)}else r(t)}var Ke=!1;function Je(e){if(!Ke){Ke=!0;var t=0;try{for(;t<e.length;t++){var r=e[t];do{r=r(!0)}while(null!==r)}e.length=0}catch(r){throw e=e.slice(t+1),r}finally{Ke=!1}}}var Qe=Ve,Xe=function(e,t,r){for(var n=te.apply(this,arguments),o=2;o<arguments.length;o++)De(arguments[o],n.type);return Fe(n),n},Ze=function(e){var t=Ve.bind(null,e);return t.type=e,$e||($e=!0,O("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.")),Object.defineProperty(t,"type",{enumerable:!1,get:function(){return O("Factory.type is deprecated. Access the class directly before passing it to createFactory."),Object.defineProperty(this,"type",{value:e}),e}}),t},et={map:se,forEach:function(e,t,r){se(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return se(e,(function(){t++})),t},toArray:function(e){return se(e,(function(e){return e}))||[]},only:function(e){if(!re(e))throw new Error("React.Children.only expected to receive a single React element child.");return e}};t.Children=et,t.Component=x,t.Fragment=o,t.Profiler=i,t.PureComponent=D,t.StrictMode=a,t.Suspense=f,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=w,t.act=ze,t.cloneElement=Xe,t.createContext=function(e){var t={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};t.Provider={$$typeof:u,_context:t};var r=!1,n=!1,o=!1,a={$$typeof:c,_context:t};return Object.defineProperties(a,{Provider:{get:function(){return n||(n=!0,R("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?")),t.Provider},set:function(e){t.Provider=e}},_currentValue:{get:function(){return t._currentValue},set:function(e){t._currentValue=e}},_currentValue2:{get:function(){return t._currentValue2},set:function(e){t._currentValue2=e}},_threadCount:{get:function(){return t._threadCount},set:function(e){t._threadCount=e}},Consumer:{get:function(){return r||(r=!0,R("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?")),t.Consumer}},displayName:{get:function(){return t.displayName},set:function(e){o||(O("Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.",e),o=!0)}}}),t.Consumer=a,t._currentRenderer=null,t._currentRenderer2=null,t},t.createElement=Qe,t.createFactory=Ze,t.createRef=function(){var e={current:null};return Object.seal(e),e},t.forwardRef=function(e){null!=e&&e.$$typeof===p?R("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):"function"!=typeof e?R("forwardRef requires a render function but was given %s.",null===e?"null":typeof e):0!==e.length&&2!==e.length&&R("forwardRef render functions accept exactly two parameters: props and ref. %s",1===e.length?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),null!=e&&(null==e.defaultProps&&null==e.propTypes||R("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?"));var t,r={$$typeof:s,render:e};return Object.defineProperty(r,"displayName",{enumerable:!1,configurable:!0,get:function(){return t},set:function(r){t=r,e.name||e.displayName||(e.displayName=r)}}),r},t.isValidElement=re,t.lazy=function(e){var t,r,n={$$typeof:d,_payload:{_status:-1,_result:e},_init:fe};return Object.defineProperties(n,{defaultProps:{configurable:!0,get:function(){return t},set:function(e){R("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."),t=e,Object.defineProperty(n,"defaultProps",{enumerable:!0})}},propTypes:{configurable:!0,get:function(){return r},set:function(e){R("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."),r=e,Object.defineProperty(n,"propTypes",{enumerable:!0})}}}),n},t.memo=function(e,t){le(e)||R("memo: The first argument must be a component. Instead received: %s",null===e?"null":typeof e);var r,n={$$typeof:p,type:e,compare:void 0===t?null:t};return Object.defineProperty(n,"displayName",{enumerable:!1,configurable:!0,get:function(){return r},set:function(t){r=t,e.name||e.displayName||(e.displayName=t)}}),n},t.startTransition=function(e,t){var r=E.transition;E.transition={};var n=E.transition;E.transition._updatedFibers=new Set;try{e()}finally{E.transition=r,null===r&&n._updatedFibers&&(n._updatedFibers.size>10&&O("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."),n._updatedFibers.clear())}},t.unstable_act=ze,t.useCallback=function(e,t){return pe().useCallback(e,t)},t.useContext=function(e){var t=pe();if(void 0!==e._context){var r=e._context;r.Consumer===e?R("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?"):r.Provider===e&&R("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?")}return t.useContext(e)},t.useDebugValue=function(e,t){return pe().useDebugValue(e,t)},t.useDeferredValue=function(e){return pe().useDeferredValue(e)},t.useEffect=function(e,t){return pe().useEffect(e,t)},t.useId=function(){return pe().useId()},t.useImperativeHandle=function(e,t,r){return pe().useImperativeHandle(e,t,r)},t.useInsertionEffect=function(e,t){return pe().useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return pe().useLayoutEffect(e,t)},t.useMemo=function(e,t){return pe().useMemo(e,t)},t.useReducer=function(e,t,r){return pe().useReducer(e,t,r)},t.useRef=function(e){return pe().useRef(e)},t.useState=function(e){return pe().useState(e)},t.useSyncExternalStore=function(e,t,r){return pe().useSyncExternalStore(e,t,r)},t.useTransition=function(){return pe().useTransition()},t.version="18.3.1","undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),re;var e,t}te=Q,"production"===process.env.NODE_ENV?te.exports=Z():te.exports=oe();var ae=["amplifyConfig","oAuthConfig","usersEndpoint"],ie=!1,ue=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.amplifyConfig,n=e.oAuthConfig,i=e.usersEndpoint,u=p(e,ae),c=y(J.useState(Date.now()),2);c[0];var s=c[1],f=J.useRef(!1),d=J.useRef(l({},u));J.useEffect((function(){d.current=l({},u)}),h(Object.values(u)));var m=function(e){if(a(d.current[e])){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];(t=d.current[e]).call.apply(t,[void 0].concat(n))}};return J.useEffect((function(){if(r||n||i){try{de(r,n,i),f.current=!0,ie=!0}catch(e){m("onError",E.INIT)}ie&&!f.current&&o("WJEC One useAuthorization: Config should only be provided to the first instance of the useAuthorization hook in your component tree (recommendation is to include this in your entry point component, even if you don't need authorization tools at that point)")}}),[r,n,i]),J.useEffect((function(){var e=!1,r=t.listen("auth",(function(t){var r=t.payload,n=r.data,o=r.event;if(!e)switch(o){case"completeNewPassword_failure":m("onError",E.FORCE_CHANGE_PASSWORD,n);break;case"forgotPassword":m("onRequestPasswordReset",n.username);break;case"forgotPassword_failure":m("onError",E.REQUEST_PASSWORD_RESET,n);break;case"forgotPasswordSubmit":m("onCompletePasswordReset");break;case"forgotPasswordSubmit_failure":m("onError",E.COMPLETE_PASSWORD_RESET,n);break;case"signIn_failure":m("onError",E.SIGN_IN,n);break;case"signOut":m("onSignOut");break;case"tokenRefresh":a(d.current.onRefreshSession)&&pe().then(d.current.onRefreshSession);break;case"tokenRefresh_failure":m("onError",E.REFRESH_USER_SESSION,n)}})),n=t.listen("custom",(function(t){var r=t.payload,n=r.data,o=r.event;if(!e)switch(o){case"cacheUpdated":s(n.updatedTimestamp);break;case"challenge":m("onChallenge",n.challenge);break;case"error":m("onError",n.errorType,n.errorDetails);break;case"init":m("onInit",n.session);break;case"setMfaType":m("onSetMfaType",n.mfaType);break;case E.SIGN_IN:m("onSignIn",n.session)}}));return function(){e=!0,r(),n()}}),[]),we},ce=["telephoneNumber"],se=w(function(){var t=c(d().mark((function t(r,n){var o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return A(E.CHANGE_PASSWORD,"loading"),t.next=3,e.currentAuthenticatedUser();case 3:return o=t.sent,t.abrupt("return",O(e.changePassword(o,r,n),E.CHANGE_PASSWORD));case 5:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),E.CHANGE_PASSWORD),fe=w((function(t,r,n){return A(E.COMPLETE_PASSWORD_RESET,"loading"),O(e.forgotPasswordSubmit(t,r,n),E.COMPLETE_PASSWORD_RESET)}),E.COMPLETE_PASSWORD_RESET),le=w(c(d().mark((function e(){var t,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,pe();case 2:return t=e.sent,r=t.getIdToken().getJwtToken(),e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),E.GET_AUTHORIZATION_TOKEN),pe=w(c(d().mark((function t(){var r;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,t.abrupt("return",r);case 4:case"end":return t.stop()}}),t)}))),E.GET_USER_SESSION),de=function(){var n=c(d().mark((function n(a,i,u){var s;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!H("isInitialized")){n.next=4;break}o("WJEC One Authorization: Config cannot be changed after initialization - the config that was originally provided will continue to be used"),n.next=23;break;case 4:if(a&&i&&u){n.next=8;break}throw new Error("WJEC One Authorization: Both amplifyConfig and oAuthConfig objects must be provided, in addition to the endpoint URL for the users service");case 8:return n.prev=8,r.configure(a),e.configure({oauth:i}),G({usersEndpoint:u},!1),t.listen("auth",function(){var e=c(d().mark((function e(t){var r,n,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.payload,n=r.data,o=r.event,e.t0=o,e.next="completeNewPassword_failure"===e.t0?4:"forgotPassword_failure"===e.t0?6:"forgotPasswordSubmit_failure"===e.t0?8:"signIn"===e.t0?10:"signIn_failure"===e.t0?14:"signOut"===e.t0?16:"signOut_failure"===e.t0?18:"tokenRefresh_failure"===e.t0?20:22;break;case 4:return A(E.FORCE_CHANGE_PASSWORD,"failed"),e.abrupt("break",22);case 6:return A(E.REQUEST_PASSWORD_RESET,"failed"),e.abrupt("break",22);case 8:return A(E.COMPLETE_PASSWORD_RESET,"failed"),e.abrupt("break",22);case 10:return e.next=12,W(n.signInUserSession);case 12:return x(E.SIGN_IN,{session:n.signInUserSession}),e.abrupt("break",22);case 14:return A(E.SIGN_IN,"failed"),e.abrupt("break",22);case 16:return Y(),e.abrupt("break",22);case 18:return A(E.SIGN_OUT,"failed"),e.abrupt("break",22);case 20:return A(E.REFRESH_USER_SESSION,"failed"),e.abrupt("break",22);case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),t.listen("custom",(function(e){var t=e.payload,r=t.data;if("error"===t.event){var n=r.errorType;"loading"===H("requestStatuses")[n]&&A(n,"failed")}})),n.next=15,e.currentAuthenticatedUser({bypassCache:!0}).then(function(){var e=c(d().mark((function e(t){var r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.getSignInUserSession(),e.next=3,W(r);case 3:return e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(){}));case 15:(s=n.sent)||G({isInitialized:!0}),j(s),n.next=23;break;case 20:n.prev=20,n.t0=n.catch(8),I(E.INIT,n.t0);case 23:return n.abrupt("return",s);case 24:case"end":return n.stop()}}),n,null,[[8,20]])})));return function(e,t,r){return n.apply(this,arguments)}}(),ye=w(c(d().mark((function t(){var r,n,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,t.next=5,e.currentAuthenticatedUser();case 5:return n=t.sent,t.next=8,new Promise((function(e,t){try{n.refreshSession(r.getRefreshToken(),(function(t,r){if(t)throw t;e(r)}))}catch(e){I(E.REFRESH_USER_SESSION,e),t(e)}}));case 8:return o=t.sent,t.abrupt("return",o);case 10:case"end":return t.stop()}}),t)}))),E.REFRESH_USER_SESSION),he=w((function(t){return A(E.REQUEST_PASSWORD_RESET,"loading"),O(e.forgotPassword(t),E.REQUEST_PASSWORD_RESET)}),E.REQUEST_PASSWORD_RESET),me=w(function(){var e=c(d().mark((function e(t){var r,n,o=arguments;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]&&o[1],A(E.SET_MFA_TYPE,"loading"),e.next=4,L(t).catch((function(e){return I(E.SET_MFA_TYPE,e),!1}));case 4:return(n=e.sent)&&(G({mfaType:t},r),x(E.SET_MFA_TYPE,{mfaType:t}),A(E.SET_MFA_TYPE,"done"),t!==_.EMAIL&&be({emailMfaAccepted:void 0})),e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),E.SET_MFA_TYPE),ve=w(c(d().mark((function t(){var r,n,o,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return A(E.REQUEST_TOTP_TOKEN,"loading"),n=H("mfaType"),t.next=4,e.currentAuthenticatedUser();case 4:if(o=t.sent,n!==_.TOTP){t.next=8;break}return t.next=8,me(_.EMAIL);case 8:return t.next=10,U().catch((function(e){I(E.REQUEST_TOTP_TOKEN,e)}));case 10:if(!(a=t.sent)){t.next=18;break}return t.next=14,q(g.VERIFY_TOTP_TOKEN,o,{secretKey:a});case 14:r=t.sent,C(r),G({totpVerified:!1},!1),A(E.REQUEST_TOTP_TOKEN,"done");case 18:return t.abrupt("return",{challenge:r,secretKey:a});case 19:case"end":return t.stop()}}),t)}))),E.REQUEST_TOTP_TOKEN),Ee=w(function(){var t=c(d().mark((function t(r,n){var o,a,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return A(E.SIGN_IN,"loading"),t.next=3,e.signIn(r,n).catch((function(e){R(e)||I(E.SIGN_IN,e)}));case 3:if(!(a=t.sent)){t.next=16;break}if(!a.challengeName){t.next=15;break}if((null===(i=a.challengeParam)||void 0===i?void 0:i.selectedMfaType)!==_.NONE){t.next=11;break}return t.next=9,e.sendCustomChallengeAnswer(a,"N/A").catch((function(e){I(E.SIGN_IN,e)}));case 9:t.next=15;break;case 11:return t.next=13,q(a.challengeName,a,a.challengeParam);case 13:o=t.sent,C(o);case 15:A(E.SIGN_IN,"done");case 16:return t.abrupt("return",{challenge:o,user:a});case 17:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),E.SIGN_IN),ge=w((function(){return A(E.SIGN_OUT,"loading"),O(e.signOut(),E.SIGN_OUT)}),E.SIGN_OUT),_e=w(function(){var t=c(d().mark((function t(r){var n,o,a,i,u,c,s;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.telephoneNumber,o=p(r,ce),a=!0,A(E.UPDATE_USER_ATTRIBUTES,"loading"),!Object.hasOwn(r,"telephoneNumber")){t.next=13;break}return i=H("telephoneNumber"),u=H("telephoneNumberVerified"),t.next=8,e.currentAuthenticatedUser();case 8:return c=t.sent,t.next=11,O(e.updateUserAttributes(c,N({telephoneNumber:n})),E.UPDATE_USER_ATTRIBUTES,!1);case 11:(a=t.sent)&&G({telephoneNumber:n,telephoneNumberVerified:n===i&&u},!1);case 13:return t.next=15,D(o);case 15:return(s=t.sent)&&G(o,!1),A(E.UPDATE_USER_ATTRIBUTES,a&&s?"done":"failed"),t.abrupt("return",a&&s);case 19:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),E.UPDATE_USER_ATTRIBUTES),be=w(function(){var e=c(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return A(E.UPDATE_USER_PREFERENCES,"loading"),r=l(l({},H("preferences")),t),e.next=4,F(r).catch((function(e){return I(E.UPDATE_USER_PREFERENCES,e),!1}));case 4:return(n=e.sent)&&(G({preferences:r},!1),A(E.UPDATE_USER_PREFERENCES,"done")),e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),E.UPDATE_USER_PREFERENCES),Se=w(c(d().mark((function t(){var r,n,o;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return A(E.VERIFY_TELEPHONE_NUMBER,"loading"),t.next=3,e.currentAuthenticatedUser();case 3:return n=t.sent,o=H("mfaType"),t.next=7,O(e.verifyCurrentUserAttribute("phone_number"),E.VERIFY_TELEPHONE_NUMBER);case 7:if(!t.sent){t.next=17;break}return t.next=11,q(g.VERIFY_TELEPHONE_NUMBER,n,{currentMfaType:o});case 11:if(r=t.sent,o!==_.SMS){t.next=15;break}return t.next=15,me(_.EMAIL,!0);case 15:C(r),A(E.VERIFY_TELEPHONE_NUMBER,"done");case 17:return t.abrupt("return",r);case 18:case"end":return t.stop()}}),t)}))),E.VERIFY_TELEPHONE_NUMBER),Te=w(function(){var e=c(d().mark((function e(t){var r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return A(E.VERIFY_TOTP_TOKEN,"loading"),e.next=3,V(t).catch((function(e){return I(E.VERIFY_TOTP_TOKEN,e),!1}));case 3:return(r=e.sent)&&(G({totpVerified:!0},!1),A(E.VERIFY_TOTP_TOKEN,"done")),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),E.VERIFY_TOTP_TOKEN),we=Object.freeze({get centrePermissions(){return H("centrePermissions")},get emailAddress(){return H("emailAddress")},get emailAddressVerified(){return H("emailAddressVerified")},get familyName(){return H("familyName")},get name(){return H("name")},get givenName(){return H("givenName")},get groups(){return H("groups")},get id(){return H("id")},get isInitialized(){return H("isInitialized")},get isSignedIn(){return H("isSignedIn")},get languagePreference(){return H("languagePreference")},get mfaType(){return H("mfaType")},get middleName(){return H("middleName")},get preferences(){return H("preferences")},get provider(){return H("provider")},get requestStatuses(){return H("requestStatuses")},get telephoneNumber(){return H("telephoneNumber")},get telephoneNumberVerified(){return H("telephoneNumberVerified")},get totpVerified(){return H("totpVerified")}});export{E as AuthAction,g as ChallengeType,_ as MFAType,b as Role,S as Subject,se as changePassword,fe as completePasswordReset,le as getAuthorizationToken,pe as getUserSession,de as init,ye as refreshUserSession,he as requestPasswordReset,me as setMfaType,ve as setupTotp,Ee as signIn,ge as signOut,we as state,_e as updateUserAttributes,be as updateUserPreferences,ue as useAuthorization,Se as verifyTelephoneNumber,Te as verifyTotp};
1
+ import{Auth as e,Hub as t,Amplify as r}from"aws-amplify";import{assertNever as n,developerWarning as a,isCallableFunction as o}from"wjec-one/utils";import{useState as i,useRef as u,useEffect as c}from"react";function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function l(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){f(o,n,a,i,u,"next",e)}function u(e){f(o,n,a,i,u,"throw",e)}i(void 0)}))}}function p(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){p(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function m(){m=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var o=t&&t.prototype instanceof S?t:S,i=Object.create(o.prototype),u=new x(n||[]);return a(i,"_invoke",{value:w(e,r,u)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p="suspendedStart",d="suspendedYield",h="executing",E="completed",v={};function S(){}function g(){}function y(){}var T={};s(T,i,(function(){return this}));var _=Object.getPrototypeOf,b=_&&_(_(k([])));b&&b!==r&&n.call(b,i)&&(T=b);var O=y.prototype=S.prototype=Object.create(T);function N(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(a,o,i,u){var c=l(e[a],e,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(f).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function w(t,r,n){var a=p;return function(o,i){if(a===h)throw Error("Generator is already running");if(a===E){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var u=n.delegate;if(u){var c=A(u,n);if(c){if(c===v)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===p)throw a=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=h;var s=l(t,r,n);if("normal"===s.type){if(a=n.done?E:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=E,n.method="throw",n.arg=s.arg)}}}function A(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function k(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return g.prototype=y,a(O,"constructor",{value:y,configurable:!0}),a(y,"constructor",{value:g,configurable:!0}),g.displayName=s(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,s(e,c,"GeneratorFunction")),e.prototype=Object.create(O),e},t.awrap=function(e){return{__await:e}},N(R.prototype),s(R.prototype,u,(function(){return this})),t.AsyncIterator=R,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new R(f(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},N(O),s(O,c,"Generator"),s(O,i,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=k,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return u.type="throw",u.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;I(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,i,u=[],c=!0,s=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,a=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return u}}(e,t)||y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function y(e,t){if(e){if("string"==typeof e)return s(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}var T,_,b,O,N;!function(e){e.CHANGE_PASSWORD="changePassword",e.COMPLETE_PASSWORD_RESET="completePasswordReset",e.FORCE_CHANGE_PASSWORD="forceChangePassword",e.GET_AUTHORIZATION_TOKEN="getAuthorizationToken",e.GET_USER_PREFERENCES="getUserPreferences",e.GET_USER_SESSION="getUserSession",e.INIT="init",e.REFRESH_USER_SESSION="refreshUserSession",e.REQUEST_PASSWORD_RESET="requestPasswordReset",e.REQUEST_TOTP_TOKEN="requestSoftwareToken",e.SET_MFA_TYPE="setMfaType",e.SIGN_IN="signIn",e.SIGN_OUT="signOut",e.SUBMIT_MFA_CODE="confirmSignIn",e.UPDATE_USER_ATTRIBUTES="updateUserAttributes",e.UPDATE_USER_PREFERENCES="updateUserPreferences",e.VERIFY_TELEPHONE_NUMBER="verifyTelephoneNumber",e.VERIFY_TOTP_TOKEN="verifySoftwareToken"}(T||(T={})),function(e){e.CUSTOM_CHALLENGE="CUSTOM_CHALLENGE",e.EMAIL_MFA="EMAIL",e.MFA_SETUP="MFA_SETUP",e.NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",e.SMS_MFA="SMS",e.TOTP_MFA="TOTP",e.VERIFY_TELEPHONE_NUMBER="VERIFY_TELEPHONE_NUMBER",e.VERIFY_TOTP_TOKEN="VERIFY_TOTP_TOKEN"}(_||(_={})),function(e){e.EMAIL="EMAIL",e.NONE="NONE",e.SMS="SMS",e.TOTP="TOTP"}(b||(b={})),function(e){e.ADMINISTRATIVE_SUPPORT="administrativeSupport",e.EXAMS_OFFICER="examsOfficer",e.HEAD_OF_DEPARTMENT="headOfDepartment",e.HEAD_OF_YEAR="headOfYear",e.HEAD_TEACHER="headTeacher",e.LOCAL_AUTHORITY_ADVISOR="localAuthorityAdvisor",e.OTHER="other",e.STAKEHOLDER="stakeholder",e.TEACHER="teacher",e.TUTOR="tutor"}(O||(O={})),function(e){e.ENGLISH="english",e.MATHS="maths",e.SCIENCE="science"}(N||(N={}));var R=function(t,r){return function(){var n;if(Y("isInitialized")){for(var a=arguments.length,o=new Array(a),i=0;i<a;i++)o[i]=arguments[i];(n=t.call.apply(t,[e].concat(o)))instanceof Promise&&n.catch((function(e){M(r,e)}))}else console.error("WJEC One Authorization: You tried to call ".concat(r,"() before AWS Amplify was initialized. Please provide values for amplifyConfig & oAuthConfig to get set up"));return n}},w=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.then((function(){return r&&k(t,"done"),!0})).catch((function(e){return(e instanceof Error||"string"==typeof e)&&M(t,e),!1}))},A=function(e){return"object"===g(e)&&Object.hasOwn(e,"name")&&"NotAuthorizedException"===e.name},P=function(e){return"object"===g(e)&&Object.hasOwn(e,"name")&&"InvalidPasswordException"===e.name},I=function(e){return Object.entries(e).reduce((function(e,t){var r=v(t,2),a=r[0],o=r[1];return h(h({},e),{},p({},function(e){return"telephoneNumber"===e?"phone_number":n(e)}(a),o))}),{})},x=function(e){return h(h({},e),{},{emailMfaAccepted:e.emailMfaAccepted?new Date(e.emailMfaAccepted):void 0})},k=function(e,t){var r=Y("requestStatuses");z({requestStatuses:h(h({},r),{},p({},e,t))})},U=function(e){t.dispatch("custom",{data:{challenge:e},event:"challenge"})},M=function(e,r){t.dispatch("custom",{data:{errorDetails:r,errorType:e},event:"error"})},C=function(e,r){t.dispatch("custom",{data:r,event:e})},F=function(e){C(T.INIT,{session:e})},L=function(){var t=l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,n=r.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(n.payload.sub,"/mfa/secret"),{headers:{Authorization:n.getJwtToken()}}).then((function(e){return e.json()})).then((function(e){return e.secret}));case 6:return a=t.sent,t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),D=function(){var t=l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,n=r.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(n.payload.sub,"/preferences"),{headers:{Authorization:n.getJwtToken()}}).then((function(e){return null==e?void 0:e.json()}));case 6:return a=t.sent,t.abrupt("return",a||{});case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),j=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub,"/mfa"),{body:JSON.stringify({mfaType:r}),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),G=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub),{body:JSON.stringify(r),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),V=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub,"/preferences"),{body:JSON.stringify(r),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){return e.json()})).then((function(e){return e.success}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),H=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub,"/mfa/secret"),{body:JSON.stringify({totpCode:r}),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),W={centrePermissions:{},emailAddress:void 0,emailAddressVerified:!1,familyName:void 0,name:void 0,givenName:void 0,groups:[],id:void 0,isInitialized:!1,isSignedIn:!1,languagePreference:"en-gb",mfaType:void 0,middleName:void 0,preferences:{},provider:void 0,requestStatuses:Object.values(T).reduce((function(e,t){return h(h({},e),{},p({},t,"idle"))}),{}),telephoneNumber:void 0,telephoneNumberVerified:!1,totpVerified:!1,usersEndpoint:void 0},Y=function(e){return W[e]},z=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Object.entries(e).forEach((function(e){var t=v(e,2),r=t[0],n=t[1];W[r]=n})),r&&t.dispatch("custom",{data:{updatedTimestamp:Date.now()},event:"cacheUpdated"})},B=function(){var e=l(m().mark((function e(t){var r,n,a,o,i,u;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.getIdToken().payload,k(T.GET_USER_PREFERENCES,"loading"),e.next=4,D().then((function(e){return k(T.GET_USER_PREFERENCES,"done"),e})).catch((function(e){return M(T.GET_USER_PREFERENCES,e),{}}));case 4:i=e.sent,u=x(i),z({centrePermissions:JSON.parse(o["custom:centre_permissions"]||"{}"),emailAddress:o.email,emailAddressVerified:o.email_verified,familyName:o.family_name||o.familyName,name:o.name,givenName:o.given_name||o.givenName,groups:o["cognito:groups"]||[],id:o.sub,isInitialized:!0,isSignedIn:!0,languagePreference:o["custom:language_preference"],mfaType:o["custom:mfa_type"],middleName:o.middle_name||o.middleName,preferences:u,provider:(null===(r=o.identities)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.providerName)||"Cognito",telephoneNumber:o.phone_number,telephoneNumberVerified:o.phone_number_verified,totpVerified:"true"===(null===(a=o["custom:totp_verified"])||void 0===a?void 0:a.toLowerCase())});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),K=function(){z({centrePermissions:{},emailAddress:void 0,emailAddressVerified:!1,familyName:void 0,name:void 0,givenName:void 0,groups:[],id:void 0,isSignedIn:!1,languagePreference:void 0,mfaType:void 0,middleName:void 0,preferences:{},provider:void 0,telephoneNumber:void 0,telephoneNumberVerified:!1,totpVerified:!1})},J=function(t){return function(){var r=l(m().mark((function r(n){var a,o,i;return m().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return k(T.FORCE_CHANGE_PASSWORD,"loading"),r.next=3,e.completeNewPassword(t,n).catch((function(e){A(e)||P(e)||M(T.FORCE_CHANGE_PASSWORD,e),a=!1}));case 3:if(!(o=r.sent)){r.next=12;break}if(!o.challengeName){r.next=10;break}return r.next=8,q(o.challengeName,o,o.challengeParam);case 8:i=r.sent,U(i);case 10:k(T.FORCE_CHANGE_PASSWORD,"done"),a=!0;case 12:return r.abrupt("return",a);case 13:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()},Q=function(t){return function(){var r=l(m().mark((function r(n){var a;return m().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return k(T.SUBMIT_MFA_CODE,"loading"),r.next=3,e.sendCustomChallengeAnswer(t,n).then(function(){var e=l(m().mark((function e(r){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==r||!r.challengeName){e.next=5;break}return e.next=3,q(r.challengeName,t,r.challengeParam);case 3:a=e.sent,U(a);case 5:k(T.SUBMIT_MFA_CODE,"done");case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){M(T.SUBMIT_MFA_CODE,e)}));case 3:return r.abrupt("return",a);case 4:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()},q=function(t,r){var n,a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=Z(t,null==o?void 0:o.selectedMfaType);switch(i){case _.EMAIL_MFA:n={attemptNumber:o.attemptNumber?parseInt(o.attemptNumber):void 0,challengeType:_.EMAIL_MFA,completeChallenge:Q(r),emailAddress:o.emailAddress};break;case _.NEW_PASSWORD_REQUIRED:n={challengeType:_.NEW_PASSWORD_REQUIRED,completeChallenge:J(r)};break;case _.SMS_MFA:n={attemptNumber:o.attemptNumber?parseInt(o.attemptNumber):void 0,challengeType:i,completeChallenge:Q(r),telephoneNumber:t===_.CUSTOM_CHALLENGE?o.redactedPhoneNumber:o.CODE_DELIVERY_DESTINATION};break;case _.TOTP_MFA:n={attemptNumber:o.attemptNumber?parseInt(o.attemptNumber):void 0,challengeType:i,completeChallenge:Q(r)};break;case _.VERIFY_TELEPHONE_NUMBER:n={challengeType:i,completeChallenge:(a=o.currentMfaType,function(){var t=l(m().mark((function t(r){var n;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.VERIFY_TELEPHONE_NUMBER,"loading"),t.next=3,w(e.verifyCurrentUserAttributeSubmit("phone_number",r),T.VERIFY_TELEPHONE_NUMBER);case 3:if(!(n=t.sent)){t.next=9;break}if(z({telephoneNumberVerified:!0}),Y("mfaType")===b.SMS||a!==b.SMS){t.next=9;break}return t.next=9,se(b.SMS,!0);case 9:return t.abrupt("return",n);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())};break;case _.VERIFY_TOTP_TOKEN:n={challengeType:i,completeChallenge:function(){var e=l(m().mark((function e(t){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,me(t);case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),secretKey:o.secretKey}}return n},Z=function(e,t){if(e===_.CUSTOM_CHALLENGE)switch(t){case b.EMAIL:return _.EMAIL_MFA;case b.SMS:return _.SMS_MFA;case b.TOTP:return _.TOTP_MFA}return e},X=["amplifyConfig","oAuthConfig","usersEndpoint"],$=!1,ee=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.amplifyConfig,n=e.oAuthConfig,s=e.usersEndpoint,f=E(e,X),l=v(i(Date.now()),2);l[0];var p=l[1],d=u(!1),m=u(h({},f));c((function(){m.current=h({},f)}),S(Object.values(f)));var g=function(e){if(o(m.current[e])){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];(t=m.current[e]).call.apply(t,[void 0].concat(n))}};return c((function(){if(r||n||s){try{ie(r,n,s),d.current=!0,$=!0}catch(e){g("onError",T.INIT)}$&&!d.current&&a("WJEC One useAuthorization: Config should only be provided to the first instance of the useAuthorization hook in your component tree (recommendation is to include this in your entry point component, even if you don't need authorization tools at that point)")}}),[r,n,s]),c((function(){var e=!1,r=t.listen("auth",(function(t){var r=t.payload,n=r.data,a=r.event;if(!e)switch(a){case"completeNewPassword_failure":g("onError",T.FORCE_CHANGE_PASSWORD,n);break;case"forgotPassword":g("onRequestPasswordReset",n.username);break;case"forgotPassword_failure":g("onError",T.REQUEST_PASSWORD_RESET,n);break;case"forgotPasswordSubmit":g("onCompletePasswordReset");break;case"forgotPasswordSubmit_failure":g("onError",T.COMPLETE_PASSWORD_RESET,n);break;case"signIn_failure":g("onError",T.SIGN_IN,n);break;case"signOut":g("onSignOut");break;case"tokenRefresh":o(m.current.onRefreshSession)&&oe().then(m.current.onRefreshSession);break;case"tokenRefresh_failure":g("onError",T.REFRESH_USER_SESSION,n)}})),n=t.listen("custom",(function(t){var r=t.payload,n=r.data,a=r.event;if(!e)switch(a){case"cacheUpdated":p(n.updatedTimestamp);break;case"challenge":g("onChallenge",n.challenge);break;case"error":g("onError",n.errorType,n.errorDetails);break;case"init":g("onInit",n.session);break;case"setMfaType":g("onSetMfaType",n.mfaType);break;case T.SIGN_IN:g("onSignIn",n.session)}}));return function(){e=!0,r(),n()}}),[]),ve},te=["telephoneNumber"],re=R(function(){var t=l(m().mark((function t(r,n){var a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.CHANGE_PASSWORD,"loading"),t.next=3,e.currentAuthenticatedUser();case 3:return a=t.sent,t.abrupt("return",w(e.changePassword(a,r,n),T.CHANGE_PASSWORD));case 5:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),T.CHANGE_PASSWORD),ne=R((function(t,r,n){return k(T.COMPLETE_PASSWORD_RESET,"loading"),w(e.forgotPasswordSubmit(t,r,n),T.COMPLETE_PASSWORD_RESET)}),T.COMPLETE_PASSWORD_RESET),ae=R(l(m().mark((function e(){var t,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe();case 2:return t=e.sent,r=t.getIdToken().getJwtToken(),e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),T.GET_AUTHORIZATION_TOKEN),oe=R(l(m().mark((function t(){var r;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,t.abrupt("return",r);case 4:case"end":return t.stop()}}),t)}))),T.GET_USER_SESSION),ie=function(){var n=l(m().mark((function n(o,i,u){var c;return m().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!Y("isInitialized")){n.next=4;break}a("WJEC One Authorization: Config cannot be changed after initialization - the config that was originally provided will continue to be used"),n.next=23;break;case 4:if(o&&i&&u){n.next=8;break}throw new Error("WJEC One Authorization: Both amplifyConfig and oAuthConfig objects must be provided, in addition to the endpoint URL for the users service");case 8:return n.prev=8,r.configure(o),e.configure({oauth:i}),z({usersEndpoint:u},!1),t.listen("auth",function(){var e=l(m().mark((function e(t){var r,n,a;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.payload,n=r.data,a=r.event,e.t0=a,e.next="completeNewPassword_failure"===e.t0?4:"forgotPassword_failure"===e.t0?6:"forgotPasswordSubmit_failure"===e.t0?8:"signIn"===e.t0?10:"signIn_failure"===e.t0?14:"signOut"===e.t0?16:"signOut_failure"===e.t0?18:"tokenRefresh_failure"===e.t0?20:22;break;case 4:return k(T.FORCE_CHANGE_PASSWORD,"failed"),e.abrupt("break",22);case 6:return k(T.REQUEST_PASSWORD_RESET,"failed"),e.abrupt("break",22);case 8:return k(T.COMPLETE_PASSWORD_RESET,"failed"),e.abrupt("break",22);case 10:return e.next=12,B(n.signInUserSession);case 12:return C(T.SIGN_IN,{session:n.signInUserSession}),e.abrupt("break",22);case 14:return k(T.SIGN_IN,"failed"),e.abrupt("break",22);case 16:return K(),e.abrupt("break",22);case 18:return k(T.SIGN_OUT,"failed"),e.abrupt("break",22);case 20:return k(T.REFRESH_USER_SESSION,"failed"),e.abrupt("break",22);case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),t.listen("custom",(function(e){var t=e.payload,r=t.data;if("error"===t.event){var n=r.errorType;"loading"===Y("requestStatuses")[n]&&k(n,"failed")}})),n.next=15,e.currentAuthenticatedUser({bypassCache:!0}).then(function(){var e=l(m().mark((function e(t){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.getSignInUserSession(),e.next=3,B(r);case 3:return e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(){}));case 15:(c=n.sent)||z({isInitialized:!0}),F(c),n.next=23;break;case 20:n.prev=20,n.t0=n.catch(8),M(T.INIT,n.t0);case 23:return n.abrupt("return",c);case 24:case"end":return n.stop()}}),n,null,[[8,20]])})));return function(e,t,r){return n.apply(this,arguments)}}(),ue=R(l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,t.next=5,e.currentAuthenticatedUser();case 5:return n=t.sent,t.next=8,new Promise((function(e,t){try{n.refreshSession(r.getRefreshToken(),(function(t,r){if(t)throw t;e(r)}))}catch(e){M(T.REFRESH_USER_SESSION,e),t(e)}}));case 8:return a=t.sent,t.abrupt("return",a);case 10:case"end":return t.stop()}}),t)}))),T.REFRESH_USER_SESSION),ce=R((function(t){return k(T.REQUEST_PASSWORD_RESET,"loading"),w(e.forgotPassword(t),T.REQUEST_PASSWORD_RESET)}),T.REQUEST_PASSWORD_RESET),se=R(function(){var e=l(m().mark((function e(t){var r,n,a=arguments;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],k(T.SET_MFA_TYPE,"loading"),e.next=4,j(t).catch((function(e){return M(T.SET_MFA_TYPE,e),!1}));case 4:return(n=e.sent)&&(z({mfaType:t},r),C(T.SET_MFA_TYPE,{mfaType:t}),k(T.SET_MFA_TYPE,"done"),t!==b.EMAIL&&he({emailMfaAccepted:void 0})),e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),T.SET_MFA_TYPE),fe=R(l(m().mark((function t(){var r,n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.REQUEST_TOTP_TOKEN,"loading"),n=Y("mfaType"),t.next=4,e.currentAuthenticatedUser();case 4:if(a=t.sent,n!==b.TOTP){t.next=8;break}return t.next=8,se(b.EMAIL);case 8:return t.next=10,L().catch((function(e){M(T.REQUEST_TOTP_TOKEN,e)}));case 10:if(!(o=t.sent)){t.next=18;break}return t.next=14,q(_.VERIFY_TOTP_TOKEN,a,{secretKey:o});case 14:r=t.sent,U(r),z({totpVerified:!1},!1),k(T.REQUEST_TOTP_TOKEN,"done");case 18:return t.abrupt("return",{challenge:r,secretKey:o});case 19:case"end":return t.stop()}}),t)}))),T.REQUEST_TOTP_TOKEN),le=R(function(){var t=l(m().mark((function t(r,n){var a,o,i;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.SIGN_IN,"loading"),t.next=3,e.signIn(r,n).catch((function(e){A(e)||M(T.SIGN_IN,e)}));case 3:if(!(o=t.sent)){t.next=16;break}if(!o.challengeName){t.next=15;break}if((null===(i=o.challengeParam)||void 0===i?void 0:i.selectedMfaType)!==b.NONE){t.next=11;break}return t.next=9,e.sendCustomChallengeAnswer(o,"N/A").catch((function(e){M(T.SIGN_IN,e)}));case 9:t.next=15;break;case 11:return t.next=13,q(o.challengeName,o,o.challengeParam);case 13:a=t.sent,U(a);case 15:k(T.SIGN_IN,"done");case 16:return t.abrupt("return",{challenge:a,user:o});case 17:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),T.SIGN_IN),pe=R((function(){return k(T.SIGN_OUT,"loading"),w(e.signOut(),T.SIGN_OUT)}),T.SIGN_OUT),de=R(function(){var t=l(m().mark((function t(r){var n,a,o,i,u,c,s;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.telephoneNumber,a=E(r,te),o=!0,k(T.UPDATE_USER_ATTRIBUTES,"loading"),!Object.hasOwn(r,"telephoneNumber")){t.next=13;break}return i=Y("telephoneNumber"),u=Y("telephoneNumberVerified"),t.next=8,e.currentAuthenticatedUser();case 8:return c=t.sent,t.next=11,w(e.updateUserAttributes(c,I({telephoneNumber:n})),T.UPDATE_USER_ATTRIBUTES,!1);case 11:(o=t.sent)&&z({telephoneNumber:n,telephoneNumberVerified:n===i&&u},!1);case 13:return t.next=15,G(a);case 15:return(s=t.sent)&&z(a,!1),k(T.UPDATE_USER_ATTRIBUTES,o&&s?"done":"failed"),t.abrupt("return",o&&s);case 19:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),T.UPDATE_USER_ATTRIBUTES),he=R(function(){var e=l(m().mark((function e(t){var r,n;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k(T.UPDATE_USER_PREFERENCES,"loading"),r=h(h({},Y("preferences")),t),e.next=4,V(r).catch((function(e){return M(T.UPDATE_USER_PREFERENCES,e),!1}));case 4:return(n=e.sent)&&(z({preferences:r},!1),k(T.UPDATE_USER_PREFERENCES,"done")),e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),T.UPDATE_USER_PREFERENCES),Ee=R(l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.VERIFY_TELEPHONE_NUMBER,"loading"),t.next=3,e.currentAuthenticatedUser();case 3:return n=t.sent,a=Y("mfaType"),t.next=7,w(e.verifyCurrentUserAttribute("phone_number"),T.VERIFY_TELEPHONE_NUMBER);case 7:if(!t.sent){t.next=17;break}return t.next=11,q(_.VERIFY_TELEPHONE_NUMBER,n,{currentMfaType:a});case 11:if(r=t.sent,a!==b.SMS){t.next=15;break}return t.next=15,se(b.EMAIL,!0);case 15:U(r),k(T.VERIFY_TELEPHONE_NUMBER,"done");case 17:return t.abrupt("return",r);case 18:case"end":return t.stop()}}),t)}))),T.VERIFY_TELEPHONE_NUMBER),me=R(function(){var e=l(m().mark((function e(t){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k(T.VERIFY_TOTP_TOKEN,"loading"),e.next=3,H(t).catch((function(e){return M(T.VERIFY_TOTP_TOKEN,e),!1}));case 3:return(r=e.sent)&&(z({totpVerified:!0},!1),k(T.VERIFY_TOTP_TOKEN,"done")),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),T.VERIFY_TOTP_TOKEN),ve=Object.freeze({get centrePermissions(){return Y("centrePermissions")},get emailAddress(){return Y("emailAddress")},get emailAddressVerified(){return Y("emailAddressVerified")},get familyName(){return Y("familyName")},get name(){return Y("name")},get givenName(){return Y("givenName")},get groups(){return Y("groups")},get id(){return Y("id")},get isInitialized(){return Y("isInitialized")},get isSignedIn(){return Y("isSignedIn")},get languagePreference(){return Y("languagePreference")},get mfaType(){return Y("mfaType")},get middleName(){return Y("middleName")},get preferences(){return Y("preferences")},get provider(){return Y("provider")},get requestStatuses(){return Y("requestStatuses")},get telephoneNumber(){return Y("telephoneNumber")},get telephoneNumberVerified(){return Y("telephoneNumberVerified")},get totpVerified(){return Y("totpVerified")}});export{T as AuthAction,_ as ChallengeType,b as MFAType,O as Role,N as Subject,re as changePassword,ne as completePasswordReset,ae as getAuthorizationToken,oe as getUserSession,ie as init,ue as refreshUserSession,ce as requestPasswordReset,se as setMfaType,fe as setupTotp,le as signIn,pe as signOut,ve as state,de as updateUserAttributes,he as updateUserPreferences,ee as useAuthorization,Ee as verifyTelephoneNumber,me as verifyTotp};
@@ -11,33 +11,33 @@ const coverageThreshold = overrides.coverageThreshold === undefined ? 100 : over
11
11
 
12
12
  module.exports = {
13
13
  collectCoverageFrom: [
14
- 'auth/**/*.{ts,tsx}',
15
- 'localization/**/*.{ts,tsx}',
16
- 'portal/**/*.{ts,tsx}',
17
- 'services/**/*.{ts,tsx}',
18
- 'src/**/*.{ts,tsx}',
19
- 'store/**/*.{ts,tsx}',
20
- 'theme/**/*.{ts,tsx}',
21
- 'utils/**/*.{ts,tsx}',
14
+ './auth/**/*.{ts,tsx}',
15
+ './localization/**/*.{ts,tsx}',
16
+ './portal/**/*.{ts,tsx}',
17
+ './services/**/*.{ts,tsx}',
18
+ './src/**/*.{ts,tsx}',
19
+ './store/**/*.{ts,tsx}',
20
+ './theme/**/*.{ts,tsx}',
21
+ './utils/**/*.{ts,tsx}',
22
22
 
23
- '!**/*.d.ts',
24
- '!localization/index.ts',
25
- '!portal/index.ts',
26
- '!portal/**/store/state.{ts,tsx}',
27
- '!services/index.ts',
28
- '!src/ColorPalette*.ts',
29
- '!src/components/**/styles.{ts,tsx}',
30
- '!src/StylePalette.ts',
31
- '!src/styles',
32
- '!test/**/*',
33
- '!theme/index.ts',
34
- '!theme/ThemeContext.ts',
35
- '!theme/ThemeState.ts',
36
- '!theme/utils.ts',
37
- '!**/types',
38
- '!types.ts',
39
- '!utils/index.ts',
40
- '!utils/ConfigUtils.ts'
23
+ '!./**/*.d.ts',
24
+ '!./localization/index.ts',
25
+ '!./portal/index.ts',
26
+ '!./portal/**/store/state.{ts,tsx}',
27
+ '!./services/index.ts',
28
+ '!./src/ColorPalette*.ts',
29
+ '!./src/components/**/styles.{ts,tsx}',
30
+ '!./src/StylePalette.ts',
31
+ '!./src/styles',
32
+ '!./test/**/*',
33
+ '!./theme/index.ts',
34
+ '!./theme/ThemeContext.ts',
35
+ '!./theme/ThemeState.ts',
36
+ '!./theme/utils.ts',
37
+ '!./**/types',
38
+ '!./types.ts',
39
+ '!./utils/index.ts',
40
+ '!./utils/ConfigUtils.ts'
41
41
  ],
42
42
  coverageReporters: ['cobertura', 'json', 'text'],
43
43
  coverageThreshold: {
package/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { Interpolation, ArrayInterpolation } from '@emotion/core';
3
2
  import * as _emotion_utils from '@emotion/utils';
4
- import React$1, { SVGProps, ButtonHTMLAttributes, CSSProperties, FC, PropsWithChildren, InputHTMLAttributes, MouseEvent, Dispatch, Context } from 'react';
3
+ import React$1, { SVGProps, ButtonHTMLAttributes, CSSProperties, FC, PropsWithChildren, InputHTMLAttributes, MouseEvent, Dispatch, Context, ReactNode, Key } from 'react';
5
4
  import { AriaButtonProps } from 'react-aria';
6
5
  import { GapProperty, BottomProperty, LeftProperty, RightProperty, TopProperty, ColorProperty, WidthProperty, HeightProperty, MarginProperty, PaddingProperty } from 'csstype';
7
6
  import { Record } from 'immutable';
7
+ import { Interpolation, ArrayInterpolation } from '@emotion/core';
8
8
 
9
9
  type ColorPalette = {
10
10
  border: string;
@@ -48,8 +48,7 @@ type ColorPalette = {
48
48
  welshBaccFoundation: string;
49
49
  welshBaccNational: string;
50
50
  welshBaccKS4: string;
51
- };
52
- type Styles = Interpolation | ArrayInterpolation<any>;
51
+ };
53
52
 
54
53
  declare const _default$2: ColorPalette;
55
54
 
@@ -1653,72 +1652,102 @@ declare const SubParagraph: WjecOneComponent<SubParagraphProps>;
1653
1652
 
1654
1653
  declare const SubTitle: WjecOneComponent;
1655
1654
 
1656
- type CellAlignment = 'center' | 'left' | 'right';
1657
- type CellStyleExtractor<T> = (row: T, cellValue: string | number | JSX.Element, index: number) => Styles;
1658
1655
  type ColumnOptions = {
1656
+ /**
1657
+ * Determines the alignment of cell content (may result in unexpected behaviour if a component/element is provided as the cell's content)
1658
+ * @default "left"
1659
+ */
1659
1660
  align?: 'center' | 'left' | 'right';
1661
+ /**
1662
+ * Determines the spacing between columns
1663
+ * @default "16px"
1664
+ */
1665
+ gap?: CSSProperties['gap'];
1660
1666
  };
1661
- type ColumnWidth = 'max' | 'min' | CSSProperties['width'];
1662
- type RowOptions<T> = {
1663
- group?: (row: T) => string;
1667
+ type RowOptions = {
1668
+ /**
1669
+ * Determines the spacing between rows
1670
+ * @default "8px"
1671
+ */
1672
+ gap?: CSSProperties['gap'];
1673
+ /**
1674
+ * Determines the highlight behaviour of the row:
1675
+ * * "hover" - highlight will appear when the cursor moves over a row
1676
+ * * "selected" - highlight will appear when a row is the specified `selectedRow` (also applies for "hover")
1677
+ * * false - no highlighting will be applied
1678
+ * @default false
1679
+ */
1680
+ highlight?: 'hover' | 'selected' | false;
1681
+ /**
1682
+ * Determines the colour of the row highlight, where applicable
1683
+ * @default ```js
1684
+ * ColorPalette.highlight
1685
+ * ```
1686
+ */
1687
+ highlightColor?: CSSProperties['color'];
1664
1688
  };
1665
- type RowStyleExtractor<T> = (row: T, index: number) => Styles;
1666
1689
  type SortDirection = 'ascending' | 'descending';
1667
- type TableColumnCellRenderer<T> = (row?: T) => JSX.Element;
1668
- type TableColumnExtractor<T> = (row: T) => Array<TableColumnEntry<T>>;
1669
- type TableColumnValueExtractor<T> = (row?: T) => FormattedString | number;
1670
- interface TableColumnEntryTemplate<T> {
1671
- align?: CellAlignment;
1672
- headingStyle?: Styles;
1673
- onSort?: (direction: SortDirection) => void;
1690
+ type TableColumn<T, N extends string = string> = {
1691
+ /**
1692
+ * Determines the alignment of cell content (may result in unexpected behaviour if a component/element is provided as the cell's content)
1693
+ * @default "left"
1694
+ */
1695
+ align?: 'center' | 'left' | 'right';
1696
+ /**
1697
+ * Specifies either an explicit value to display, or the return value of a function to which the current row is provided as an argument */
1698
+ displayValue: ReactNode | ((row: T) => ReactNode);
1699
+ /** A unique identifier for each column. Strongly recommended when using dynamically-defined columns and/or sorting */
1700
+ name?: N;
1701
+ /** A handler that will be called when the column header cell is pressed */
1702
+ onPressHeader?: () => void;
1703
+ /** Determines whether this column is sortable (may override/be overridden by top-level `sortable` value) */
1674
1704
  sortable?: boolean;
1675
- sortableValue?: KeyExtractor<T>;
1676
- sorted?: SortDirection | false;
1677
- style?: Styles | CellStyleExtractor<T>;
1678
- title: FormattedString;
1679
- width?: ColumnWidth;
1680
- }
1681
- interface TableColumnEntryWithComponent<T> extends TableColumnEntryTemplate<T> {
1682
- render: JSX.Element | TableColumnCellRenderer<T>;
1683
- }
1684
- interface TableColumnEntryWithKey<T> extends TableColumnEntryTemplate<T> {
1685
- key: keyof T;
1686
- }
1687
- interface TableColumnEntryWithValue<T> extends TableColumnEntryTemplate<T> {
1688
- value: FormattedString | number | TableColumnValueExtractor<T>;
1689
- }
1690
- type TableColumnEntry<T> = TableColumnEntryWithComponent<T> | TableColumnEntryWithKey<T> | TableColumnEntryWithValue<T>;
1691
- type TableProps<T> = {
1692
- /** A React styles object or a serialized Emotion styles object (or a function that returns either of these) used to style each cell */
1693
- cellStyle?: Styles | CellStyleExtractor<T>;
1694
- /** A list of column configuration objects (or a function that returns the same) used to determine what is displayed by the Table */
1695
- columns: Array<TableColumnEntry<T>> | TableColumnExtractor<T>;
1705
+ /** Determines the value to be considered by the Table's internal sorting algorithm */
1706
+ sortableValue?: (row: T) => number | string;
1707
+ /** Determines the value to be displayed in the column's header cell */
1708
+ title?: ReactNode;
1709
+ /** Specifies the width of the column */
1710
+ width?: 'max' | 'min' | CSSProperties['width'];
1711
+ };
1712
+ type TableProps<T, N extends string> = {
1713
+ /** A list of column configurations objects used to determine what is displayed by the Table */
1714
+ columns: Array<TableColumn<T, N>>;
1696
1715
  /** Options that will be applied to all columns in the Table (some options may be overridden on a per-column basis) */
1697
1716
  columnOptions?: ColumnOptions;
1698
1717
  /** The array of data that will be used to populate the table */
1699
1718
  data: T[];
1700
- /** A function that will be used to return a unique key for each row; required if data contains non-primitive entries */
1701
- keyExtractor?: KeyExtractor<T>;
1702
1719
  /**
1703
- * A handler that will be called when a row in the table is clicked
1704
- * @deprecated onClickRow has been deprecated in favor of the new onPressRow prop, which behaves similarly but with better accessibility support
1705
- */
1706
- onClickRow?: (row: T, index: number) => void;
1720
+ * A function that will be used to return a unique key for each row; required if data contains non-primitive entries
1721
+ * @default ```ts
1722
+ * (row) => data.indexOf(row)
1723
+ * ```
1724
+ */
1725
+ keyExtractor?: (row: T) => Key;
1707
1726
  /** A handler that will be called when a row in the table is pressed */
1708
- onPressRow?: (row: T, index: number) => void;
1709
- /** Determines whether the data arrives pre-sorted; if true, the Table will not attempt to sort the data itself even if sortable controls are presented */
1710
- preSorted?: boolean;
1727
+ onPressRow?: (row: T) => void;
1728
+ /** A handler that will be called whenever the sort order is changed as a result of the Table component's internal algorithm */
1729
+ onSort?: (columnName: string, columnIndex: number, direction: SortDirection) => void;
1711
1730
  /** Options that will be applied to all rows in the Table */
1712
- rowOptions?: RowOptions<T>;
1713
- /** A React styles object or a serialized Emotion styles object (or a function that returns either of these) used to style each row */
1714
- rowStyle?: Styles | RowStyleExtractor<T>;
1715
- /** Determines whether the row for a particular data entry should be visually highlighted */
1731
+ rowOptions?: RowOptions;
1732
+ /** Specifies the active row. May be used to trigger visual highlight depending on rowOptions */
1716
1733
  selectedRow?: T;
1717
- /** Determines whether the Table should present sortable controls (may be overridden on a per-column basis, and behavior may differ depending on the value of the preSorted prop) */
1734
+ /** Determines whether the Table should present sortable controls (may be overridden on a per-column basis) */
1718
1735
  sortable?: boolean;
1736
+ /** Specifies whether the `data` is already sorted. If `true`, the component's sorting algorithm will NOT be used */
1737
+ sorted?: boolean;
1738
+ /**
1739
+ * Specifies the sorted column, by index or column name (using column names is strongly recommended)
1740
+ * @default (First sortable column)
1741
+ */
1742
+ sortedColumn?: number | N;
1743
+ /**
1744
+ * Specifies the direction of the sort
1745
+ * @default "ascending"
1746
+ */
1747
+ sortedDirection?: SortDirection;
1719
1748
  };
1720
1749
 
1721
- declare const Table: <T extends {}>({ cellStyle, columns, columnOptions, data, keyExtractor, id, onClickRow, onPressRow, preSorted, rowOptions, rowStyle, selectedRow, sortable }: WjecOneComponentProps<TableProps<T>>) => JSX.Element;
1750
+ declare const Table: <T extends unknown, N extends string>({ columnOptions, columns, data, id, keyExtractor, onPressRow, onSort, rowOptions, selectedRow, sortable, sorted, sortedColumn: defaultSortedColumn, sortedDirection: defaultSortedDirection }: WjecOneComponentProps<TableProps<T, N>>) => React$1.JSX.Element;
1722
1751
 
1723
1752
  type TabsProps<T> = {
1724
1753
  backgroundStyle?: 'filled' | 'transparent';
@@ -1737,4 +1766,4 @@ type TabsProps<T> = {
1737
1766
  } & Pick<AriaProperties, 'ariaLabel'>;
1738
1767
  declare const Tabs: <T extends unknown>({ ariaLabel, backgroundStyle, disabledTabs, id, keyExtractor, labelExtractor, onSelect, scrollable, selectedTab, selectedTabColor, tabs }: WjecOneComponentProps<TabsProps<T>>) => JSX.Element;
1739
1768
 
1740
- export { Accordion, Breadcrumb, Button, Card, Carousel, CheckBox, CircularProgress, _default$2 as ColorPalette, _default$1 as ColorPaletteEduqas, ContextHelp, ContextMenu, DateTimePicker, DestructiveButton, DragAndDropList, Email, Emphasis, ErrorCard, ErrorNotification, FileInput, FilterList, Footer, Form, Header, IconButton, InfoNotification, InformationCard, Input, LinearProgress, Link, LinkButton, LocalizationMenu, Modal, Notification, Page, PageTitle, Pagination, Paragraph, Password, Popup, PopupWindow, PrimaryButton, PrintLayout, PrintWindow, RadioGroup, ScrollableContainer, SecondaryButton, SectionHeading, SectionTitle, Select, SigninForm, SigninMenu, _default as StylePalette, SubParagraph, SubTitle, SuccessCard, SuccessNotification, Table, Tabs, TextArea, Toggle, VerificationCodeInput, WarningCard };
1769
+ export { Accordion, Breadcrumb, Button, Card, Carousel, CheckBox, CircularProgress, _default$2 as ColorPalette, _default$1 as ColorPaletteEduqas, ColumnOptions, ContextHelp, ContextMenu, DateTimePicker, DestructiveButton, DragAndDropList, Email, Emphasis, ErrorCard, ErrorNotification, FileInput, FilterList, Footer, Form, Header, IconButton, InfoNotification, InformationCard, Input, LinearProgress, Link, LinkButton, LocalizationMenu, Modal, Notification, Page, PageTitle, Pagination, Paragraph, Password, Popup, PopupWindow, PrimaryButton, PrintLayout, PrintWindow, RadioGroup, RowOptions, ScrollableContainer, SecondaryButton, SectionHeading, SectionTitle, Select, SigninForm, SigninMenu, SortDirection, _default as StylePalette, SubParagraph, SubTitle, SuccessCard, SuccessNotification, Table, TableColumn, Tabs, TextArea, Toggle, VerificationCodeInput, WarningCard };