import{s as l}from"./ForgotPassword.module.51f61226.js";import{i as g,u as v,r as d,j as e,d as n}from"./react.6693569e.js";import{u as I,l as k,a as x}from"./index.ab3d776b.js";/* empty css               *//* empty css              */import{C as T}from"./Cover.fc91526c.js";import{f as j}from"./antd.5e666edb.js";import{P as C}from"./regular.2d81b23f.js";import{u as N}from"./RSA.f54b2b0a.js";import{m,F as o,I as u,B as w}from"./antd.e57bc55d.js";const{layout:q}=j,R=()=>{const{T:s}=I(),t=g(),c=v(),[h,P]=d.exports.useState(""),[f,b]=d.exports.useState(""),{encrypt:y}=N();return d.exports.useEffect(()=>{if(c.search){const{email:r,access_token:a}=k.parse(c.search.slice(1));if(r&&a){P(r),b(a);return}}m.error(s("resetPassword.intercept")),t.push("/login")},[t,c]),e(T,{children:n("div",{className:l.forgotPassword,children:[e("div",{className:l.header,children:s("resetPassword.header")}),n(o,{className:l.form,...q,onFinish:async({password:r})=>{try{await x.authApi.resetPassword({password:y(r),accessToken:f}),m.success(s("resetPassword.submit.success")),setTimeout(()=>t.push("/login"),1e3)}catch(a){console.error(a);let i=s("resetPassword.submit.error.basic");m.error(i)}},children:[e(o.Item,{label:s("resetPassword.label.email"),children:e(u,{value:h,disabled:!0})}),e(o.Item,{label:s("resetPassword.label.password"),name:"password",rules:[{required:!0,message:s("resetPassword.rules.password.required")},{pattern:C,message:s("resetPassword.rules.password.pattern")}],children:e(u,{})}),e(o.Item,{label:s("resetPassword.label.repassword"),name:"repassword",required:!0,rules:[({getFieldValue:r})=>({validator:(a,i)=>{if(!i)return Promise.reject(s("resetPassword.rules.repassword.required"));const p=r("password");return p&&p!==i?Promise.reject(s("resetPassword.rules.repassword.validator")):Promise.resolve()}})],children:e(u,{})}),e(o.Item,{wrapperCol:{span:24},children:n("div",{className:l.btnGroup,children:[e(w,{type:"primary",htmlType:"submit",children:s("resetPassword.submit.button")}),e(w,{onClick:()=>t.go(-1),children:s("resetPassword.goBackButton")})]})})]})]})})};export{R as default};
