"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),j=require("../icons/ico-checkmark.js"),y=require("./text.js"),k=require("../../hooks/useToggleState.js"),d=require("../../lib/cn.js"),c=require("react"),s=require("react-aria");const b=c.forwardRef((o,h)=>{const{label:a,indeterminate:r=!1,disabled:n=!1,checked:f,"aria-label":m,...x}=o,t=k.useToggleState({...o,isSelected:f}),p=c.useRef(null),i=h||p;c.useEffect(()=>{const u="current"in i?i.current:null;u&&(u.indeterminate=!!r)},[r,i]);const{inputProps:v}=s.useCheckbox({...x,"aria-label":a||m||"Checkbox",isDisabled:n,isIndeterminate:r},t,i),{isFocusVisible:l,focusProps:g}=s.useFocusRing();return e.jsxs("label",{className:d.cn("flex items-center rounded-sm",n?"opacity-30":"opacity-100"),children:[e.jsx(s.VisuallyHidden,{children:e.jsx("input",{...s.mergeProps(v,g),ref:i})}),e.jsx("div",{className:d.cn("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||l?"border-brand-base":"border-text-tertiary",n?"pointer-events-none":"pointer-events-auto",l?"outline-brand-base outline-thick":"outline-transparent outline-thick"),children:e.jsxs("span",{children:[t.isSelected&&!r&&e.jsx(j.default,{height:16,width:16,color:"var(--color-surface-primary)"}),t.isSelected&&!!r&&e.jsx("div",{className:"flex justify-center items-center",children:e.jsx("div",{className:"w-2.5 h-0.5 bg-surface-primary"})})]})}),a&&e.jsx("div",{className:"ml-3",children:e.jsx(y.default,{fontWeight:"medium",styles:{lineHeight:1},children:a})})]})});b.displayName="Checkbox",exports.default=b;
//# sourceMappingURL=checkbox.js.map
