import{defineProperty as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import a,{forwardRef as o,useRef as c,useCallback as n,useEffect as i}from"react";import{isNil as r,noop as t}from"lodash-es";import"prop-types";import l from"classnames";import s from"../Icon/Icon.js";import m from"../Icon/Icons/components/Check.js";import d from"../Icon/Icons/components/Remove.js";import{backwardCompatibilityForProperties as p}from"../../helpers/backwardCompatibilityForProperties.js";import{useSupportFirefoxLabelClick as u}from"./hooks/useSupportFirefoxLabelClick.js";import b from"../../hooks/useMergeRefs.js";import"./Checkbox.scss.js";var f="l3-style-checkbox",v=o((function(o,t){var v=o.className,k=o.componentClassName,h=o.checkboxClassName,_=o.labelClassName,C=o.ariaLabel,N=o.label,y=o.ariaLabelledBy,j=o.onChange,x=o.checked,g=o.indeterminate,w=o.disabled,E=o.defaultChecked,F=o.value,I=o.name,z=o.id,L=o.size,P=void 0===L?"large":L,S=o.kind,B=void 0===S?"primary":S,R=o.description,q=c(null),A=c(null),H=b({refs:[t,A]}),M=p([v,k]),G=n((function(){var e=A.current;e&&window.requestAnimationFrame((function(){window.requestAnimationFrame((function(){e.blur()}))}))}),[A]),T=["".concat(f,"__checkbox"),"".concat(f,"__prevent-animation"),h],U=E;r(U)&&r(x)&&(U=!1),i((function(){A.current&&(A.current.indeterminate=g)}),[A,g]);var V=u({inputRef:A}).onClickCapture;return a.createElement("div",{className:l("wrapper",R&&"wrapper--size-".concat(P))},a.createElement("label",{className:l(f,M,e({},"".concat(f,"__disabled"),w),["".concat(f,"--size-").concat(P)],["".concat(f,"--kind-").concat(B)]),onMouseUp:G,htmlFor:z,onClickCapture:V},a.createElement("input",{ref:H,id:z,className:"".concat(f,"__input"),value:F,name:I,type:"checkbox",onChange:j,defaultChecked:U,disabled:w,"aria-label":C||N,"aria-labelledby":y,checked:x}),a.createElement("div",{className:l.apply(void 0,T),ref:q},a.createElement(s,{className:"".concat(f,"__icon"),iconType:s.type.SVG,icon:g?d:m,ignoreFocusStyle:!0,clickable:!1,ariaHidden:!0,iconSize:"16"})),!1===N?null:a.createElement("span",{className:l("".concat(f,"__label"),_)},N)),!1===R?null:a.createElement("span",{className:l("".concat(f,"__description"),"".concat(f,"__description--size-").concat(P),"".concat(f,"__description--kind-").concat(B))},R))}));v.defaultProps={id:void 0,className:void 0,checkboxClassName:void 0,labelClassName:void 0,label:void 0,onChange:t,disabled:!1,name:"",value:"",ariaLabelledBy:void 0,checked:void 0,indeterminate:!1,defaultChecked:void 0,ariaLabel:void 0,ref:void 0};var k=v;export{v as Checkbox,k as default};
