import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["className", "cssModule", "type", "size", "color", "children", "tag"];
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { mapToCssModules, tagPropType } from './utils';
var propTypes = {
  tag: tagPropType,
  type: PropTypes.string,
  size: PropTypes.string,
  color: PropTypes.string,
  className: PropTypes.string,
  cssModule: PropTypes.object,
  children: PropTypes.string
};

var Spinner = function Spinner(props) {
  var className = props.className,
      cssModule = props.cssModule,
      _props$type = props.type,
      type = _props$type === void 0 ? 'border' : _props$type,
      size = props.size,
      color = props.color,
      _props$children = props.children,
      children = _props$children === void 0 ? 'Loading...' : _props$children,
      _props$tag = props.tag,
      Tag = _props$tag === void 0 ? 'div' : _props$tag,
      attributes = _objectWithoutPropertiesLoose(props, _excluded);

  var classes = mapToCssModules(classNames(className, size ? "spinner-" + type + "-" + size : false, "spinner-" + type, color ? "text-" + color : false), cssModule);
  return /*#__PURE__*/React.createElement(Tag, _extends({
    role: "status"
  }, attributes, {
    className: classes
  }), children && /*#__PURE__*/React.createElement("span", {
    className: mapToCssModules('sr-only', cssModule)
  }, children));
};

Spinner.propTypes = propTypes;
export default Spinner;