import{j as s}from"./vendor-mui-69397583.js";import{P as t}from"./PasswordInput-8619a9df.js";import{a as P,B as p,ek as f,O as i,Q as m}from"./index-c62ac197.js";import{F as h}from"./FormContainer-91c2b0e4.js";import{F as x,a as n,c as j}from"./index-51ee35f9.js";import{c as F,a as y,f as C,F as N,b,d}from"./index.esm-70ab539c.js";import{p as w}from"./strongPassword-bbec776a.js";import"./vendor-react-ece1c85f.js";import"./index-42e65911.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"./PreferenceService-75bf9db6.js";const g=F().shape({password:y().required("Enter current password"),newPassword:w.required("Enter new password"),confirmNewPassword:w.required("Confirm password").oneOf([C("newPassword"),null],"Passwords do not match")}),G=({data:U})=>{const c=P(),l=async(o,r)=>{r(!0);try{const e=await j(o);c(f()),i.push(s.jsx(m,{title:"Password Updated",type:"success"}),{placement:"top-center"})}catch(e){i.push(s.jsx(m,{title:`Failed to update password: ${e.message}`,type:"error"}),{placement:"top-center"})}r(!1)};return s.jsx(s.Fragment,{children:s.jsx(N,{initialValues:{password:"",newPassword:"",confirmNewPassword:""},validationSchema:g,onSubmit:(o,{setSubmitting:r})=>{r(!0),setTimeout(()=>{l(o,r)},1e3)},children:({touched:o,errors:r,isSubmitting:e,resetForm:u})=>{const a={touched:o,errors:r};return s.jsx(b,{children:s.jsxs(h,{children:[s.jsx(x,{title:"Password",desc:"Enter your current & new password to reset your password"}),s.jsx(n,{name:"password",label:"Current Password",...a,children:s.jsx(d,{type:"password",autoComplete:"off",name:"password",placeholder:"Current Password",component:t,touched:o,errors:r})}),s.jsx(n,{name:"newPassword",label:"New Password",...a,children:s.jsx(d,{type:"password",autoComplete:"off",name:"newPassword",placeholder:"New Password",component:t,showPasswordStrength:!0,touched:o,errors:r})}),s.jsx(n,{name:"confirmNewPassword",label:"Confirm Password",...a,children:s.jsx(d,{type:"password",autoComplete:"off",name:"confirmNewPassword",placeholder:"Confirm Password",component:t,showPasswordStrength:!0,touched:o,errors:r})}),s.jsxs("div",{className:"mt-4 ltr:text-right",children:[s.jsx(p,{className:"ltr:mr-2 rtl:ml-2",type:"button",onClick:u,children:"Reset"}),s.jsx(p,{variant:"solid",loading:e,type:"submit",children:e?"Updating":"Update Password"})]})]})})}})})};export{G as default};
