import { __rest } from '../../../_virtual/_tslib.js';
import React__default, { forwardRef } from 'react';
import { CheckRadioInputGroupWrapper, CheckRadioErrorArea, CheckRadioHintArea } from '../styles.js';
import { getId, slugify, noop } from '../../../utils/index.js';
import AlertCircle from '../../../icons/AlertCircle.js';
import { CheckboxInput } from './CheckboxInput.js';

function CheckboxComponent(_a, ref) {
    var { id, name, label, value, checked, onChange = noop, disabled = false, hasError = false, errorText, assistText, indeterminate, tabIndex } = _a, props = __rest(_a, ["id", "name", "label", "value", "checked", "onChange", "disabled", "hasError", "errorText", "assistText", "indeterminate", "tabIndex"]);
    const appendTestId = getId(props['data-testid']);
    const appendTrackId = getId(props['data-trackid']);
    if (!id && label) {
        id = slugify(label);
    }
    return (React__default.createElement(CheckRadioInputGroupWrapper, null,
        React__default.createElement(CheckboxInput, { id: id, ref: ref, name: name, value: value, disabled: disabled, "aria-checked": props['aria-checked'], checked: checked, onChange: onChange, "data-testid": appendTestId('check'), "data-trackid": appendTrackId('check'), "aria-label": props['aria-label'] || label, hasError: hasError, label: label, indeterminate: indeterminate, tabIndex: tabIndex }),
        hasError && errorText && (React__default.createElement(CheckRadioErrorArea, { "data-testid": appendTestId('error'), "data-trackid": appendTrackId('error') },
            React__default.createElement(AlertCircle, null),
            errorText)),
        assistText && !hasError && (React__default.createElement(CheckRadioHintArea, { "data-testid": appendTestId('assistText'), "data-trackid": appendTrackId('assistText') }, assistText))));
}
const Checkbox = forwardRef(CheckboxComponent);

export { Checkbox };
