'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

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

var _styledComponents2 = _interopRequireDefault(_styledComponents);

var _ramda = require('ramda');

var _Colors = require('../Colors');

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var bounceAnimation = (0, _styledComponents.keyframes)(['0%,100%{transform:scale(0.0);}50%{transform:scale(1.0);}']);
var Container = _styledComponents2.default.div.withConfig({
  displayName: 'HeartbeatLoader__Container'
})(['position:relative;width:', ';height:', ';'], function (props) {
  return props.width;
}, function (props) {
  return props.height;
});
var Circle1 = _styledComponents2.default.div.withConfig({
  displayName: 'HeartbeatLoader__Circle1'
})(['position:absolute;top:0;left:0;width:100%;height:100%;border-radius:50%;opacity:0.7;background-color:', ';animation:', ' 2s infinite ease-in-out;'], function (props) {
  return props.theme[props.color];
}, bounceAnimation);
var Circle2 = (0, _styledComponents2.default)(Circle1).withConfig({
  displayName: 'HeartbeatLoader__Circle2'
})(['animation-delay:-1.0s;']);

var HeartbeatLoader = function HeartbeatLoader(props) {
  var color = props.color,
      rest = _objectWithoutProperties(props, ['color']);

  return _react2.default.createElement(
    Container,
    rest,
    _react2.default.createElement(Circle1, { color: color }),
    _react2.default.createElement(Circle2, { color: color })
  );
};

HeartbeatLoader.propTypes = {
  width: _propTypes2.default.string.isRequired,
  height: _propTypes2.default.string.isRequired,
  color: _propTypes2.default.oneOf((0, _ramda.keysIn)((0, _Colors.Palette)()))
};

HeartbeatLoader.defaultProps = {
  width: '40px',
  height: '40px',
  color: 'brand-secondary'
};

exports.default = HeartbeatLoader;