import{jsxs as c,jsx as e}from"react/jsx-runtime";import y from"../icons/ico-checkmark.js";import v from"./text.js";import{useToggleState as k}from"../../hooks/useToggleState.js";import{cn as d}from"../../lib/cn.js";import{forwardRef as N,useRef as S,useEffect as j}from"react";import{useCheckbox as w,useFocusRing as C,VisuallyHidden as P,mergeProps as R}from"react-aria";const u=N((n,m)=>{const{label:o,indeterminate:r=!1,disabled:s=!1,checked:b,"aria-label":f,...p}=n,t=k({...n,isSelected:b}),h=S(null),i=m||h;j(()=>{const l="current"in i?i.current:null;l&&(l.indeterminate=!!r)},[r,i]);const{inputProps:g}=w({...p,"aria-label":o||f||"Checkbox",isDisabled:s,isIndeterminate:r},t,i),{isFocusVisible:a,focusProps:x}=C();return c("label",{className:d("flex items-center rounded-sm",s?"opacity-30":"opacity-100"),children:[e(P,{children:e("input",{...R(g,x),ref:i})}),e("div",{className:d("flex items-center justify-center w-5 h-5 border-thick transition-[background-color,border-color] duration-200 ease-in-out hover:cursor-pointer hover:border-brand-base rounded box-border outline outline-offset-[0.125rem]",t.isSelected?"bg-brand-base":"bg-transparent",t.isSelected||a?"border-brand-base":"border-text-tertiary",s?"pointer-events-none":"pointer-events-auto",a?"outline-brand-base outline-thick":"outline-transparent outline-thick"),children:c("span",{children:[t.isSelected&&!r&&e(y,{height:16,width:16,color:"var(--color-surface-primary)"}),t.isSelected&&!!r&&e("div",{className:"flex justify-center items-center",children:e("div",{className:"w-2.5 h-0.5 bg-surface-primary"})})]})}),o&&e("div",{className:"ml-3",children:e(v,{fontWeight:"medium",styles:{lineHeight:1},children:o})})]})});u.displayName="Checkbox";export{u as default};
//# sourceMappingURL=checkbox.js.map
