import { jsx as _jsx } from "react/jsx-runtime";
import { useEffect, useState } from "react";
import "./style.scss";
import { v4 as uuidv4 } from "uuid";
const SearchCheckboxComponent = ({ checked = false, onClick, id = uuidv4(), sizeVariant = "sm", isAllSelected = false, isSubsetSelected = false, isDisabled = false, }) => {
    const [isOn, setIsOn] = useState(checked);
    //   useEffect(() => {
    //     setIsOn(checked);
    //   }, [checked]);
    useEffect(() => {
        setIsOn(isAllSelected);
    }, [isAllSelected]);
    const handleToggle = () => {
        onClick(!isOn);
        if (isAllSelected) {
            setIsOn(false);
        }
    };
    return (_jsx("input", { type: "checkbox", className: `searchCheckboxComponent--Generic ${sizeVariant}SizeCheckBox ${isSubsetSelected ? "subSelected" : ""}`, id: `${id}`, checked: isOn, onClick: (e) => e.stopPropagation(), onChange: handleToggle, disabled: isDisabled }));
};
export default SearchCheckboxComponent;
