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 { Radio } from './Radio.js';

function RadioButtonComponent(_a, ref) {
    var { id, name, label, value, checked, onChange = noop, disabled = false, hasError = false, errorText, assistText } = _a, props = __rest(_a, ["id", "name", "label", "value", "checked", "onChange", "disabled", "hasError", "errorText", "assistText"]);
    const appendTestId = getId(props['data-testid']);
    const appendTrackId = getId(props['data-testid']);
    if (!id && label) {
        id = slugify(label);
    }
    return (React__default.createElement(CheckRadioInputGroupWrapper, null,
        React__default.createElement(Radio, { id: id, ref: ref, name: name, value: value, checked: checked, disabled: disabled, "aria-checked": props['aria-checked'], onChange: onChange, "data-testid": appendTestId('radio'), "data-trackid": appendTrackId('radio'), "aria-label": props['aria-label'] || label, hasError: hasError, label: label }),
        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 RadioButton = forwardRef(RadioButtonComponent);

export { RadioButton };
