import { __rest } from '../../../_virtual/_tslib.js';
import React__default, { forwardRef } from 'react';
import { CheckRadioWrapper, CheckRadioInput, CheckRadioLabel } from '../styles.js';
import { slugify, getId, noop } from '../../../utils/index.js';

function CheckboxInputComponent(_a, ref) {
    var { id, name, label, value, onChange = noop, disabled = false, hasError = false, indeterminate, checked, tabIndex } = _a, props = __rest(_a, ["id", "name", "label", "value", "onChange", "disabled", "hasError", "indeterminate", "checked", "tabIndex"]);
    if (!id && label) {
        id = slugify(label);
    }
    const appendTestId = getId(props['data-testid']);
    const appendTrackId = getId(props['data-trackid']);
    return (React__default.createElement(CheckRadioWrapper, null,
        React__default.createElement(CheckRadioInput, { ref: (ref) => {
                if (ref && indeterminate !== undefined) {
                    ref.indeterminate = indeterminate;
                }
            }, type: "checkbox", id: id, name: name, value: value, disabled: disabled, hasError: hasError, onChange: onChange, "data-testid": appendTestId('input'), "data-trackid": appendTrackId('input'), "aria-label": props['aria-label'] || label, checked: checked, tabIndex: tabIndex }),
        label && (React__default.createElement(CheckRadioLabel, { htmlFor: id, "data-testid": appendTestId('label'), "data-trackid": appendTrackId('label') }, label))));
}
const CheckboxInput = forwardRef(CheckboxInputComponent);

export { CheckboxInput };
