import{B as v}from"./Button-LyDQSUp0.js";import{_ as A,a as B}from"./GoogleAuth.vue_vue_type_script_setup_true_lang-CL1AtZaZ.js";import{S as b,a7 as C,$ as i,am as S}from"./common-vYHpopNV.js";import{d as w,l as q,c as x,B as s,x as d,aG as N,w as R,aj as g,a_ as l,aZ as E,o as h,b1 as $,b2 as Z}from"./index-BXlk60bP.js";import"./_commonjsHelpers-BosuxZz1.js";function z(n){return n=n.trim(),/^[0-9a-zA-Z_.-]+[@][0-9a-zA-Z_.-]+([.][a-zA-Z]+){1,2}$/.test(n)}const I={class:"space-y-3"},L={class:"mt-1! block text-right font-bold text-current"},P=w({__name:"EmailAuth",emits:["success","error"],setup(n,{emit:c}){const u=c,o=q($),e=b({email:o==null?void 0:o.value,password:""}),t=C(!1),m=async()=>{if(e.email){if(!z(e.email)){l({type:"error",message:"Incorrect email address."});return}}else{l({type:"error",message:"Email is required."});return}if(!e.password){l({type:"error",message:"Password is required."});return}t.value=!0;try{const a=await S(e);u("success",a)}catch(a){a.code===10002?l({type:"error",message:"Email or password is incorrect."}):l({type:"error",message:"Network error please check and retry."}),u("error",a.msg)}t.value=!1},p=E();async function _(){await p.push("/register")}return(a,r)=>{const y=A,k=N("RouterLink"),V=v;return h(),x("div",I,[s(y,{modelValue:i(e).email,"onUpdate:modelValue":r[0]||(r[0]=f=>i(e).email=f),type:"text",icon:"i-line-md:email-twotone-alt text-blue-500",placeholder:"Enter your email address.",autofocus:"",required:""},null,8,["modelValue"]),s(y,{modelValue:i(e).password,"onUpdate:modelValue":r[1]||(r[1]=f=>i(e).password=f),type:"password",icon:"i-ant-design:lock-twotone text-orange-500",placeholder:"Enter your password.",required:""},null,8,["modelValue"]),d("p",L,[s(k,{class:"hover:underline hover:underline-current",to:"/resetPsw"},{default:R(()=>r[2]||(r[2]=[g("Forget Password?")])),_:1})]),s(V,{loading:i(t),icon:"i-ic:twotone-security",type:"success",text:"Sign in with Email",onClick:m},null,8,["loading"]),d("p",{class:"text-sm font-bold text-dark-50 text-center"},[r[3]||(r[3]=g(" New to SaveMyDayApp? ")),d("span",{class:"text-current underline underline-current cursor-pointer",onClick:_},"Create my account.")])])}}}),j={space:"y-3",md:"w-lg!"},K=w({__name:"Login",setup(n){const c=E(),u=Z();function o(){var t;c.push(((t=u.query)==null?void 0:t.next)||"/")}function e(t){}return(t,m)=>{const p=B,_=P;return h(),x("div",j,[s(p,{onSuccess:o,onError:e}),m[0]||(m[0]=d("p",{text:"sm center"},"or",-1)),s(_,{onSuccess:o,onError:e})])}}});export{K as default};
