'use strict';

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

var _tslib = require('../../_virtual/_tslib.js');
var React = require('react');
var Check = require('../../icons/Check.js');
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 Toggle(_a) {
    var { checked, disabled, id, onChange, value, label, name } = _a, props = _tslib.__rest(_a, ["checked", "disabled", "id", "onChange", "value", "label", "name"]);
    const handleInputChange = (event) => onChange(event);
    const appendTestId = index.getId(props['data-testid']);
    const appendTrackId = index.getId(props['data-testid']);
    return (React__default['default'].createElement(styles.Wrapper, { htmlFor: id || label, "data-testid": appendTestId('wrapper'), "data-trackid": appendTrackId('wrapper') },
        label && (React__default['default'].createElement(styles.ToggleLabel, { disabled: disabled, "aria-label": label, "data-testid": appendTestId('label') }, label)),
        React__default['default'].createElement(styles.ToggleWrapper, null,
            React__default['default'].createElement(styles.ToggleInput, { id: id ? id : label, name: name, value: value, checked: checked, "aria-checked": props['aria-checked'], disabled: disabled, type: "checkbox", role: "checkbox", onChange: handleInputChange, "data-testid": appendTestId('input'), "data-trackid": appendTrackId('input') }),
            React__default['default'].createElement(styles.ToggleSlider, null,
                React__default['default'].createElement(Check['default'], null)))));
}

exports.Toggle = Toggle;
