import{r as o,L as f,u as x,a as R,b as k,c as A,d as u,e as B,j as s,F as q,S as r,f as e,A as m,R as g,I as D,g as H,h as T,i as W,o as E,k as p,C as z,l as M,B as G,T as h,s as i}from"./index.8aed0a19.js";import{P as N}from"./Page.7007a3b0.js";import{C as y}from"./Card.d296fd42.js";function V(){const{localeData:t}=o.exports.useContext(f),{login:b}=x(),w=R(),S=k(),[n,v]=o.exports.useState(!1),C=A().shape({email:u().email("Format email tidak valid").required("Email harus diisi"),password:u().required("Password harus diisi")}),L={email:"",password:"",remember:!0},d=B({resolver:E(C),defaultValues:L}),{reset:I,setError:P,handleSubmit:j,formState:{errors:l,isSubmitting:F}}=d;return s(q,{methods:d,onSubmit:j(async c=>{try{const a=await b(c.email,c.password);w("/dashboard")}catch(a){console.error(a),I(),S.current&&P("afterSubmit",{...a,message:a.data.message})}}),children:[s(r,{spacing:3,children:[e(m,{severity:"info",children:t.infoLogin}),!!l.afterSubmit&&e(m,{severity:"error",children:l.afterSubmit.data.meta.message}),e(g,{name:"email",label:"Email",required:!0}),e(g,{name:"password",label:"Password",type:n?"text":"password",InputProps:{endAdornment:e(D,{position:"end",children:e(H,{onClick:()=>v(!n),edge:"end",children:e(T,{icon:n?"eva:eye-fill":"eva:eye-off-fill"})})})},required:!0})]}),e(r,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{my:2}}),e(W,{fullWidth:!0,size:"large",type:"submit",variant:"contained",loading:F,sx:{marginTop:2},children:"Login"})]})}const $=i("div")(({theme:t})=>({[t.breakpoints.up("md")]:{display:"flex"}})),J=i("header")(({theme:t})=>({top:0,zIndex:9,lineHeight:0,width:"100%",display:"flex",alignItems:"center",position:"absolute",padding:t.spacing(3),justifyContent:"space-between",[t.breakpoints.up("md")]:{alignItems:"flex-start",padding:t.spacing(7,5,0,7)}}));i(y)(({theme:t})=>({width:"100%",maxWidth:464,display:"flex",flexDirection:"column",justifyContent:"center",margin:t.spacing(2,0,2,2)}));const K=i("div")(({theme:t})=>({maxWidth:480,margin:"auto",display:"flex",minHeight:"100vh",flexDirection:"column",justifyContent:"center",padding:t.spacing(12,0)}));function Y(){const{localeData:t}=o.exports.useContext(f);return x(),p("up","sm"),p("up","md"),e(N,{title:"Login",children:s($,{children:[e(J,{}),e(z,{maxWidth:"sm",children:e(K,{children:s(y,{sx:{padding:2},children:[s(r,{direction:"row",alignItems:"center",sx:{mb:5},children:[e(M,{sx:{width:90,height:90}}),s(G,{sx:{flexGrow:1},children:[e(h,{variant:"h4",gutterBottom:!0,children:t.txtLogin1}),e(h,{variant:"body1",sx:{color:"text.secondary"},children:t.txtLogin2})]})]}),e(V,{})]})})})]})})}export{Y as default};
