import{j as s}from"./vendor-mui-69397583.js";import{r as R,f as y}from"./vendor-react-ece1c85f.js";import{F as N,a as p}from"./FormContainer-91c2b0e4.js";import{B as w,U as A}from"./index-c62ac197.js";import{A as I}from"./Alert-7dfbd254.js";import{P as f}from"./PasswordInput-8619a9df.js";import{A as M}from"./ActionLink-33e476e1.js";import{u as B}from"./useTimeOutMessage-e4eaa9f2.js";import{c as E,f as T,F as U,b as $,d as h}from"./index.esm-70ab539c.js";import{p as u}from"./strongPassword-bbec776a.js";import"./vendor-redux-a1f00e6b.js";import"./vendor-pdf-b2a5d8b1.js";import"./vendor-devex-33a39e11.js";import"./vendor-i18n-2fcb1983.js";import"./vendor-msal-9caa1ed1.js";import"./vendor-charts-eccea5d1.js";import"./index-42e65911.js";const q=E().shape({password:u.required("Enter password"),confirmPassword:u.required("Confirm password").oneOf([T("password"),null],"Passwords do not match")}),L=x=>{const{disableSubmit:j=!1,className:P,signInUrl:g="/sign-in"}=x,[n,b]=R.useState(!1),[i,v]=B(),C=y(),F=async(o,e)=>{var m,c,l;const r=window.location.search,d=(m=new URLSearchParams(r).get("passwordToken"))==null?void 0:m.toString();let{password:t}=o;t=btoa(t);const k={password:t,resetToken:d||""};e(!0);try{(await A(k)).success&&(e(!1),b(!0))}catch(a){v(((l=(c=a==null?void 0:a.response)==null?void 0:c.data)==null?void 0:l.message)||a.toString()),e(!1)}},S=()=>{C("/sign-in")};return s.jsxs("div",{className:P,children:[s.jsx("div",{className:"mb-6",children:n?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"mb-1",children:"Reset done"}),s.jsx("p",{children:"Your password has been successfully reset"})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"mb-1",children:"Set new password"}),s.jsx("p",{children:"Your new password must different to previous password"})]})}),i&&s.jsx(I,{showIcon:!0,className:"mb-4",type:"danger",children:i}),s.jsx(U,{initialValues:{password:"",confirmPassword:""},validationSchema:q,onSubmit:(o,{setSubmitting:e})=>{j?e(!1):F(o,e)},children:({touched:o,errors:e,isSubmitting:r})=>s.jsx($,{children:s.jsxs(N,{children:[n?s.jsx(w,{block:!0,variant:"solid",type:"button",onClick:S,children:"Continue"}):s.jsxs(s.Fragment,{children:[s.jsx(p,{label:"Password",invalid:e.password&&o.password,errorMessage:e.password,children:s.jsx(h,{autoComplete:"off",name:"password",placeholder:"Password",component:f,showPasswordStrength:!0,touched:o,errors:e})}),s.jsx(p,{label:"Confirm Password",invalid:e.confirmPassword&&o.confirmPassword,errorMessage:e.confirmPassword,children:s.jsx(h,{autoComplete:"off",name:"confirmPassword",placeholder:"Confirm Password",component:f,showPasswordStrength:!0,touched:o,errors:e})}),s.jsx(w,{block:!0,loading:r,variant:"solid",type:"submit",children:r?"Submitting...":"Submit"})]}),s.jsxs("div",{className:"mt-4 text-center",children:[s.jsx("span",{children:"Back to "}),s.jsx(M,{to:g,children:"Sign in"})]})]})})})]})},O=()=>s.jsx(L,{disableSubmit:!1}),ts=O;export{ts as default};
