import{_ as y,o as t,c as l,N as h,c6 as f,a as r,y as c,l as d,t as g,F as v,d as u,s as k,q,c7 as p,c8 as w,c9 as b,f as C}from"./CmnEfQIC.js";import{_ as T}from"./WebFormFieldCore_String-Daj5WKW-.mjs";import"./WebFormFieldCore-xNTPdj0N.mjs";const M={extends:T,props:{icon:{type:Boolean,default:!1},togglePassword:{type:Boolean,default:!0},confirmation:{type:Object,default:()=>({required:!1})}},data(){return{password:"",passwordType:"password",confirmPassword:"",confirmPasswordType:"password",validation:{valid:!1}}},computed:{uppercaseCheck(){return this.generateIconProps(this.validation.uppercaseMet)},lowercaseCheck(){return this.generateIconProps(this.validation.lowercaseMet)},numericCheck(){return this.generateIconProps(this.validation.numericMet)},lengthCheck(){return this.generateIconProps(this.validation.lengthMet)}},mounted(){this.password=this.value??""},methods:{toggleView(){this.passwordType=this.passwordType==="password"?"text":"password"},confirmToggle(){this.confirmPasswordType=this.confirmPasswordType==="password"?"text":"password"},validate(){const s=this.confirmation.required&&this.password!==this.confirmPassword,e=this.confirmation.required&&!this.password.match(/^((?=\S*?[A-Z])(?=\S*?[a-z])(?=\S*?[0-9]).{5,})\S$/gm);return!this.password||this.password.trim()===""?{valid:!1,errors:["Field is required"]}:e?{valid:!1,errors:["Password must contain at least 6 characters with an uppercase, a lowercase and a number"]}:s?{valid:!1,errors:["Passwords must match"]}:{valid:!0,errors:[]}},processPassword(s){this.confirmation.required&&(this.validation.uppercaseMet=s.match(/[A-Z]+/gm)!==null,this.validation.lowercaseMet=s.match(/[a-z]+/gm)!==null,this.validation.numericMet=s.match(/\d+/gm)!==null,this.validation.lengthMet=s.length>5),this.update(s)},generateIconProps(s){return s?{icon:"mdi:check-circle",iconColor:"#34a853",width:14,class:"valid"}:{icon:"mdi:warning",iconColor:"#ba3329",width:14,class:"invalid"}}}},V=["id","name","type","placeholder","disabled","required"],I={key:0,class:"icon"},F={key:2,class:"error"},_=["id","type","placeholder","disabled","required"],E={key:0,class:"icon"},B={class:"requirements"};function N(s,e,a,S,i,n){const P=b,m=C;return t(),l("div",{class:c(["password-field",a.icon?"has-icon":""])},[h(r("input",{id:s.name+Math.random(),"onUpdate:modelValue":e[0]||(e[0]=o=>i.password=o),name:s.name,type:i.passwordType,placeholder:s.placeholder,disabled:s.disabled,required:s.required,class:c(s.hasError&&s.showErrors?"has-error":""),onInput:e[1]||(e[1]=o=>n.processPassword(o.target.value))},null,42,V),[[f,i.password]]),a.icon?(t(),l("span",I)):d("",!0),i.password&&a.togglePassword?(t(),l("span",{key:1,class:c([i.passwordType==="password"?"showPassword":"hidePassword"]),onClick:e[2]||(e[2]=(...o)=>n.toggleView&&n.toggleView(...o))},null,2)):d("",!0),s.hasError&&s.showErrors?(t(),l("span",F,g(s.errorMsg),1)):d("",!0),a.confirmation.required?(t(),l(v,{key:3},[u(P,{required:!0,class:"confirm-password"},{default:k(()=>[q(g(a.confirmation.label),1)]),_:1}),r("div",{class:c(["password-field",a.icon?"has-icon":""])},[h(r("input",{id:"confirm_password"+Math.random(),"onUpdate:modelValue":e[3]||(e[3]=o=>i.confirmPassword=o),name:"confirm_password",type:i.confirmPasswordType,placeholder:a.confirmation.placeholder,disabled:s.disabled,required:a.confirmation.required,onInput:e[4]||(e[4]=o=>s.update(o.target.value))},null,40,_),[[f,i.confirmPassword]]),a.icon?(t(),l("span",E)):d("",!0),i.confirmPassword&&a.togglePassword?(t(),l("span",{key:1,class:c([i.confirmPasswordType==="password"?"showPassword":"hidePassword"]),onClick:e[5]||(e[5]=(...o)=>n.confirmToggle&&n.confirmToggle(...o))},null,2)):d("",!0)],2),e[10]||(e[10]=r("div",{class:"requirements-label"}," Password must include at least: ",-1)),r("ul",B,[r("li",null,[u(m,p(w(n.uppercaseCheck)),null,16),e[6]||(e[6]=r("span",null,"One capital letter",-1))]),r("li",null,[u(m,p(w(n.lowercaseCheck)),null,16),e[7]||(e[7]=r("span",null,"One lowercase letter",-1))]),r("li",null,[u(m,p(w(n.numericCheck)),null,16),e[8]||(e[8]=r("span",null,"One number",-1))]),r("li",null,[u(m,p(w(n.lengthCheck)),null,16),e[9]||(e[9]=r("span",null,"A minimum of 6 characters",-1))])])],64)):d("",!0)],2)}const D=y(M,[["render",N],["__scopeId","data-v-d8a34c14"]]);export{D as default};