'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../../_virtual/_tslib.js');
var React = require('react');
var styles = require('../styles.js');
var index = require('../../../utils/index.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

function CheckboxInputComponent(_a, ref) {
    var { id, name, label, value, onChange = index.noop, disabled = false, hasError = false, indeterminate, checked, tabIndex } = _a, props = _tslib.__rest(_a, ["id", "name", "label", "value", "onChange", "disabled", "hasError", "indeterminate", "checked", "tabIndex"]);
    if (!id && label) {
        id = index.slugify(label);
    }
    const appendTestId = index.getId(props['data-testid']);
    const appendTrackId = index.getId(props['data-trackid']);
    return (React__default['default'].createElement(styles.CheckRadioWrapper, null,
        React__default['default'].createElement(styles.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['default'].createElement(styles.CheckRadioLabel, { htmlFor: id, "data-testid": appendTestId('label'), "data-trackid": appendTrackId('label') }, label))));
}
const CheckboxInput = React.forwardRef(CheckboxInputComponent);

exports.CheckboxInput = CheckboxInput;
