'use strict';

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

var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var index = require('../../../utils/index.js');
var base = require('./variations/_view/base.js');
var base$1 = require('./variations/_size/base.js');
var base$2 = require('./variations/_disabled/base.js');
var EmbeddedButton_styles = require('./EmbeddedButton.styles.js');
var EmbeddedButton_tokens = require('./EmbeddedButton.tokens.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

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

var _StyledSpinner;
var _excluded = ["children", "view", "size", "disabled", "isLoading", "loader", "position", "className"];
var embeddedButtonRoot = function embeddedButtonRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (props, ref) {
    var children = props.children,
      view = props.view,
      size = props.size,
      disabled = props.disabled,
      isLoading = props.isLoading,
      loader = props.loader,
      _props$position = props.position,
      position = _props$position === void 0 ? 'center' : _props$position,
      className = props.className,
      rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
    var isLoadingClass = isLoading ? EmbeddedButton_tokens.classes.embeddedButtonLoading : undefined;
    return /*#__PURE__*/React__default.default.createElement(Root, _rollupPluginBabelHelpers.extends({
      type: "button",
      ref: ref,
      view: view,
      size: size,
      disabled: disabled,
      className: index.cx(isLoadingClass, className)
    }, rest), /*#__PURE__*/React__default.default.createElement(EmbeddedButton_styles.LoadWrap, {
      position: position,
      isLoading: isLoading
    }, /*#__PURE__*/React__default.default.createElement(EmbeddedButton_styles.IconContainer, null, children)), isLoading && /*#__PURE__*/React__default.default.createElement(EmbeddedButton_styles.Loader, null, loader || _StyledSpinner || (_StyledSpinner = /*#__PURE__*/React__default.default.createElement(EmbeddedButton_styles.StyledSpinner, null))));
  });
};
var embeddedButtonConfig = {
  name: 'EmbeddedButton',
  tag: 'button',
  layout: embeddedButtonRoot,
  base: EmbeddedButton_styles.base,
  variations: {
    view: {
      css: base.base
    },
    size: {
      css: base$1.base
    },
    disabled: {
      css: base$2.base,
      attrs: true
    }
  },
  defaults: {
    view: 'secondary',
    size: 'm'
  }
};

exports.embeddedButtonConfig = embeddedButtonConfig;
exports.embeddedButtonRoot = embeddedButtonRoot;
