'use strict';

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

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

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

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

const Button = React__default['default'].forwardRef((_a, ref) => {
    var { variant = 'primary', size = 'large', children, type = 'button', disabled = false, isLoading = false, fullWidth = false, iconPosition = 'leading' } = _a, props = _tslib.__rest(_a, ["variant", "size", "children", "type", "disabled", "isLoading", "fullWidth", "iconPosition"]);
    const appendTestId = index$1.getId(props['data-testid']);
    return (React__default['default'].createElement(styles.StyledButton, Object.assign({}, props, { variant: variant, size: size, ref: ref, disabled: disabled, isLoading: isLoading, type: type, fullWidth: fullWidth, "data-status": isLoading ? 'loading' : null }), isLoading ? (React__default['default'].createElement(styles.SpinnerWrapper, null,
        React__default['default'].createElement(index.Spinner, { "data-testid": appendTestId('spinner'), variant: utils.getSpinnerVariant(variant), size: "S" }))) : (React__default['default'].createElement(React__default['default'].Fragment, null,
        iconPosition === 'leading' && props.icon && (React__default['default'].createElement(styles.IconContainer, null, props.icon)),
        children && (React__default['default'].createElement(styles.ContentWrapper, { "data-testid": appendTestId('content') }, children)),
        iconPosition === 'trailing' && props.icon && (React__default['default'].createElement(styles.IconContainer, null, props.icon))))));
});

exports.Button = Button;
