import{j as a}from"./vendor-mui-69397583.js";import{r as l}from"./vendor-react-ece1c85f.js";import{I,bV as N,bW as S,bX as k}from"./index-c62ac197.js";import{F as A}from"./index-42e65911.js";const z=({onVisibleChange:r,showPasswordStrength:o=!1,field:e,form:t,errors:p,touched:u,...v})=>{var h;const[m,i]=l.useState("password"),[c,w]=l.useState({minLength:!1,lowercase:!1,uppercase:!1,numbers:!1,specialChars:!1}),b=t.values[e.name],x=s=>{w({minLength:s.length>=8,lowercase:/[a-z]/.test(s),uppercase:/[A-Z]/.test(s),numbers:/[0-9]/.test(s),specialChars:/[!@#$%^&*(),.?":{}|<>]/.test(s)})},j=s=>{const n=s.target.value.trim();t.setFieldValue(e.name,n),x(n)},g=l.useMemo(()=>Object.values(c).every(Boolean),[c]),y=s=>{s.preventDefault();const n=m==="password"?"text":"password";i(n),r==null||r(n==="text")};l.useEffect(()=>{o&&x((t==null?void 0:t.values[e==null?void 0:e.name])||"")},[t==null?void 0:t.values[e==null?void 0:e.name],o]);const P=s=>s?"text-teal-500":"text-red-500",C=s=>s?a.jsx(k,{className:"mr-2"}):a.jsx(A,{className:"mr-2"});return a.jsxs("div",{className:"relative",children:[a.jsx(I,{...v,type:m,autoComplete:"on",value:b,onChange:j,invalid:(p==null?void 0:p[e==null?void 0:e.name])&&(u==null?void 0:u[e==null?void 0:e.name]),suffix:a.jsx("span",{className:"cursor-pointer text-xl",onClick:y,children:m==="password"?a.jsx(N,{}):a.jsx(S,{})})}),o&&!g&&((h=t==null?void 0:t.values[e==null?void 0:e.name])==null?void 0:h.length)>0&&a.jsx("div",{className:"absolute left-0 mt-2 w-full bg-white border border-gray-300 rounded-lg shadow-lg p-2 z-10",children:[{condition:c.minLength,label:"Minimum length of 8 characters"},{condition:c.lowercase,label:"At least one lowercase letter"},{condition:c.uppercase,label:"At least one uppercase letter"},{condition:c.numbers,label:"At least one number"},{condition:c.specialChars,label:"At least one special character"}].map(({condition:s,label:n})=>a.jsx("div",{children:a.jsxs("span",{className:`text-sm flex items-center ${P(s)}`,children:[C(s),n]})},n))})]})};export{z as P};
