var P=(a,u,o)=>new Promise((r,t)=>{var l=n=>{try{c(o.next(n))}catch(m){t(m)}},i=n=>{try{c(o.throw(n))}catch(m){t(m)}},c=n=>n.done?r(n.value):Promise.resolve(n.value).then(l,i);c((o=o.apply(a,u)).next())});import{bh as y,b7 as V,b6 as e,b8 as $,bi as g,bT as B}from"./bootstrap-Bqxdt4iG.js";import{T as N}from"./auth-title-Cr5EWHYB.js";import{a1 as C,P as A,E as S,ap as _,aj as k,p as b,az as v,ak as w,al as T,ax as h,ay as p,a9 as s,aR as F,L as R,f as x,ai as L}from"../jse/index-index-BUJ_4tQs.js";const I={class:"mt-4 text-center text-sm"},q=C({name:"RegisterForm",__name:"register",props:{formSchema:{default:()=>[]},loading:{type:Boolean,default:!1},loginPath:{default:"/auth/login"},title:{default:""},subTitle:{default:""},submitButtonText:{default:""}},emits:["submit"],setup(a,{expose:u,emit:o}){const r=a,t=o,[l,i]=y(A({commonConfig:{hideLabel:!0,hideRequiredMark:!0},schema:S(()=>r.formSchema),showDefaultActions:!1})),c=V();function n(){return P(this,null,function*(){const{valid:d}=yield i.validate(),f=yield i.getValues();d&&t("submit",f)})}function m(){c.push(r.loginPath)}return u({getFormApi:()=>i}),(d,f)=>(k(),_("div",null,[b(N,null,{desc:w(()=>[T(d.$slots,"subTitle",{},()=>[h(p(a.subTitle||s(e)("authentication.signUpSubtitle")),1)])]),default:w(()=>[T(d.$slots,"title",{},()=>[h(p(a.title||s(e)("authentication.createAnAccount"))+" 🚀 ",1)])]),_:3}),b(s(l)),b(s($),{class:F([{"cursor-wait":a.loading},"mt-2 w-full"]),loading:a.loading,"aria-label":"register",onClick:n},{default:w(()=>[T(d.$slots,"submitButtonText",{},()=>[h(p(a.submitButtonText||s(e)("authentication.signUp")),1)])]),_:3},8,["class","loading"]),v("div",I,[h(p(s(e)("authentication.alreadyHaveAccount"))+" ",1),v("span",{class:"vben-link text-sm font-normal",onClick:f[0]||(f[0]=z=>m())},p(s(e)("authentication.goToLogin")),1)])]))}}),H=C({name:"Register",__name:"register",setup(a){const u=R(!1),o=S(()=>[{component:"VbenInput",componentProps:{placeholder:e("authentication.usernameTip")},fieldName:"username",label:e("authentication.username"),rules:g().min(1,{message:e("authentication.usernameTip")})},{component:"VbenInputPassword",componentProps:{passwordStrength:!0,placeholder:e("authentication.password")},fieldName:"password",label:e("authentication.password"),renderComponentContent(){return{strengthText:()=>e("authentication.passwordStrength")}},rules:g().min(1,{message:e("authentication.passwordTip")})},{component:"VbenInputPassword",componentProps:{placeholder:e("authentication.confirmPassword")},dependencies:{rules(t){const{password:l}=t;return g({required_error:e("authentication.passwordTip")}).min(1,{message:e("authentication.passwordTip")}).refine(i=>i===l,{message:e("authentication.confirmPasswordTip")})},triggerFields:["password"]},fieldName:"confirmPassword",label:e("authentication.confirmPassword")},{component:"VbenCheckbox",fieldName:"agreePolicy",renderComponentContent:()=>({default:()=>x("span",[e("authentication.agree"),x("a",{class:"vben-link ml-1 ",href:""},`${e("authentication.privacyPolicy")} & ${e("authentication.terms")}`)])}),rules:B().refine(t=>!!t,{message:e("authentication.agreeTip")})}]);function r(t){console.log("register submit:",t)}return(t,l)=>(k(),L(s(q),{"form-schema":o.value,loading:u.value,onSubmit:r},null,8,["form-schema","loading"]))}});export{H as default};
