import{F as x,Q as h,V as u,X as g,Y as j,r as N,Z as _,ap as f,ah as w,G as e,aq as v,H as b,ai as y,J as S,N as t,$ as n,ar as I}from"./screen.html-7a5JuVXO.js";import{z as r,k as P,d as k}from"./BLLock-n8n7x0Gc.js";function A(){const{t:a}=x(),i=h(s=>s.mainStorage),m=u(),c=g(),d=r.object({email:r.string().email(),re_email:r.string().email(),password:r.string()}).refine(s=>s.email!==i.identity.email,{params:{i18n:"email_equal_old_email"},path:["email"]}).refine(s=>s.email===s.re_email,{params:{i18n:"re_email_not_match"},path:["re_email"]}).refine(s=>{var o;return P.SHA256(s.password).toString()===((o=i.security.browser_password)==null?void 0:o.password)},{params:{i18n:"wrong_password"},path:["password"]}),l=j({initialValues:{email:"",re_email:"",password:""},validate:I(d)}),p=N.useCallback(s=>{console.log("Browser mail is changes to",s.email),c(_.actions.updateIdentity({email:s.email,email_changed_at:k().unix(),email_verified_at:null})),c(f.actions.clearOtps("email_verification")),w.show({title:a("util.success"),message:a("mail.mail_changed"),color:"blue"}),l.reset()},[]);return e.jsx(v,{animateIn:"slideInLeft",children:e.jsx("div",{className:"row",children:e.jsx("div",{className:"col",children:e.jsx(b,{header:a("mail.update_mail"),children:e.jsx("form",{onSubmit:l.onSubmit(p),children:e.jsxs("div",{className:"g-3 row px-6 py-2",children:[e.jsx("div",{className:"col-12",children:e.jsx(y,{size:"xlarge",className:"bg-indigo-500/10",shape:"circle",icon:e.jsx(S,{icon:"line-md:email-opened-twotone",className:"text-3xl text-indigo-600"})})}),e.jsx("div",{className:"col-12",children:e.jsx("h1",{className:"text-2xl font-bold",children:a("mail.update_mail")})}),e.jsx("div",{className:"col-12",children:e.jsx("p",{className:"max-w-3xl tracking-wide",children:a("mail.update_mail_desc")})}),i.identity.email_verified_at!==null&&e.jsx("div",{className:"col-12",children:e.jsx("div",{className:"rounded-lg border-2 border-red-400 bg-red-400/10 px-2 py-4 text-red-500",children:e.jsx("p",{className:" font-medium ",children:a("mail.validation_lose_warning",{mail:i.identity.email})})})}),e.jsx("div",{className:"col-12",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-lg font-semibold",children:a("util.browser_password")}),e.jsx(t,{...l.getInputProps("password"),placeholder:a("util.browser_password"),type:"password",className:"w-full"}),e.jsx("span",{className:"text-red-400",children:l.getInputProps("password").error})]})}),e.jsx("div",{className:"col-12 md:col-6",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-lg font-semibold",children:a("mail.email")}),e.jsx(t,{...l.getInputProps("email"),placeholder:a("mail.email"),type:"email",className:"w-full"}),e.jsx("span",{className:"text-red-400",children:l.getInputProps("email").error})]})}),e.jsx("div",{className:"col-12 md:col-6",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-lg font-semibold",children:a("mail.re_email")}),e.jsx(t,{...l.getInputProps("re_email"),placeholder:a("mail.re_email"),type:"email",className:"w-full"}),e.jsx("span",{className:"text-red-400",children:l.getInputProps("re_email").error})]})}),e.jsx("div",{className:"col-4",children:e.jsx(n,{type:"button",onClick:()=>m("/"),label:a("util.cancel"),className:"w-full",severity:"secondary"})}),e.jsx("div",{className:"col",children:e.jsx(n,{type:"submit",label:a("util.save"),className:"w-full",severity:"help"})})]})})})})})})}export{A as default};
