'use strict';

exports.__esModule = true;
exports.Spinning = undefined;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _styledComponents = require('styled-components');

var _spinners = require('./spinners');

var _StyledSpinning = require('./StyledSpinning');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // ported to styled-componnets from
// https://github.com/KyleAMathews/react-spinkit


var styledComponents = {
  'circle': _StyledSpinning.CircleSpinner,
  'three-bounce': _StyledSpinning.ThreeBounceSpinner,
  'cube-grid': _StyledSpinning.CubeGridSpinner,
  'wave': _StyledSpinning.WaveSpinner,
  'folding-cube': _StyledSpinning.FoldingCubeSpinner,
  'double-bounce': _StyledSpinning.DoubleBounceSpinner,
  'wandering-cubes': _StyledSpinning.WanderingCubesSpinner,
  'chasing-dots': _StyledSpinning.ChasingDotsSpinner,
  'rotating-plane': _StyledSpinning.RotatingPlaneSpinner,
  'pulse': _StyledSpinning.PulseSpinner,
  'wordpress': _StyledSpinning.WordPressSpinner

};

var Spinning = function (_Component) {
  _inherits(Spinning, _Component);

  function Spinning() {
    _classCallCheck(this, Spinning);

    return _possibleConstructorReturn(this, _Component.apply(this, arguments));
  }

  Spinning.prototype.render = function render() {
    var _props = this.props,
        kind = _props.kind,
        fadeIn = _props.fadeIn,
        color = _props.color,
        size = _props.size;

    var spinnerInfo = _spinners.allSpinners[kind] || _spinners.allSpinners['three-bounce'];
    var StyledSpinning = styledComponents[kind];
    return _react2.default.createElement(
      _styledComponents.ThemeContext.Consumer,
      null,
      function (theme) {
        return _react2.default.createElement(
          StyledSpinning,
          { color: color || theme.dark ? 'light-1' : 'dark-1', fadeIn: fadeIn, theme: theme, size: size },
          Array.from(Array(spinnerInfo.divCount).keys()).map(function (_, idx) {
            return _react2.default.createElement('div', { key: idx });
          })
        );
      }
    );
  };

  return Spinning;
}(_react.Component);

Spinning.defaultProps = {
  kind: 'circle',
  fadeIn: 'full',
  color: undefined,
  size: 'medium'
};
Spinning.propTypes = {
  fadeIn: _propTypes2.default.oneOf(['full', 'half', 'quarter', 'none', 'wordpress']),
  color: _propTypes2.default.string
};


var SpinningDoc = void 0;
if (process.env.NODE_ENV !== 'production') {
  SpinningDoc = require('./doc').default(Spinning); // eslint-disable-line global-require
}

var SpinningWrapper = SpinningDoc || Spinning;

exports.Spinning = SpinningWrapper;