import{b6 as k,j as s,R as g,ao as p,b7 as w,b8 as v,b9 as y,r as N,d as f}from"./main-D6SjkSWq.js";const j=g.forwardRef((e,c)=>{const{children:t,size:d="sm",description:o,className:n,invalid:a,autoFocus:i,errorMessage:r,iconRight:u,...h}=e,m=w(c);v({autoFocus:i},m);const x=C(d),l=y(e),b=N.useId();return s.jsxs("div",{className:f(n,"isolate"),children:[s.jsxs("label",{className:"flex select-none items-center",children:[s.jsx("input",{...h,type:"checkbox",role:"switch","aria-invalid":a||void 0,"aria-describedby":o?b:void 0,ref:m,"aria-checked":h.checked,className:f(x,!a&&"checked:border-primary checked:bg-primary dark:checked:border-primary-dark dark:checked:bg-primary-dark",a&&"checked:border-danger checked:bg-danger","relative flex flex-shrink-0 cursor-pointer appearance-none items-center overflow-hidden rounded-3xl border border-chip bg-chip p-0 outline-none transition-colors checked:border-primary checked:bg-primary","before:z-10 before:block before:translate-x-2 before:rounded-3xl before:border before:bg-white before:transition-transform","checked:before:border-white","focus-visible:ring",e.disabled&&"cursor-not-allowed opacity-80")}),t&&s.jsx("span",{className:f(l.size.font,"ml-12",a&&"text-danger",e.disabled&&"text-disabled"),children:t}),u]}),o&&!r&&s.jsx("div",{id:b,className:l.description,children:o}),r&&s.jsx("div",{id:b,className:l.error,children:r})]})});function $(e){const{field:{onChange:c,onBlur:t,value:d=!1,ref:o},fieldState:{invalid:n,error:a}}=k({name:e.name}),i={onChange:r=>{r.target.value&&r.target.value!=="on"?c(r.target.checked?r.target.value:!1):c(r)},onBlur:t,checked:!!d,invalid:n,errorMessage:a==null?void 0:a.message,name:e.name};return s.jsx(j,{ref:o,...p(e,i)})}function C(e){switch(e){case"xl":return"w-68 h-36 before:w-28 before:h-28 checked:before:translate-x-36";case"lg":return"w-56 h-30 before:w-22 before:h-22 checked:before:translate-x-30";case"md":return"w-46 h-24 before:w-18 before:h-18 checked:before:translate-x-24";case"xs":return"w-30 h-18 before:w-12 before:h-12 checked:before:translate-x-14";default:return"w-38 h-20 before:w-14 before:h-14 checked:before:translate-x-20"}}export{$ as F,j as S};
