'use strict';

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

var _templateObject = _taggedTemplateLiteral(['\n  0% {\n    left     : 0;\n    right    : 100%;\n    transform: scaleX(0);\n  }\n  50% {\n    left     : 0;\n    right    : 0;\n    transform: scaleX(1);\n  }\n  100% {\n    left     : 100%;\n    right    : 0;\n    transform: scaleX(0);\n  }\n'], ['\n  0% {\n    left     : 0;\n    right    : 100%;\n    transform: scaleX(0);\n  }\n  50% {\n    left     : 0;\n    right    : 0;\n    transform: scaleX(1);\n  }\n  100% {\n    left     : 100%;\n    right    : 0;\n    transform: scaleX(0);\n  }\n']),
    _templateObject2 = _taggedTemplateLiteral(['\n  background-color        : var(--px-progress-bar-fill-color,black);\n  height                  : var(--px-progress-bar-height, 5px);\n  transition              : transform 1s cubic-bezier(.78,.13,.16,.87);\n  -webkit-transform-origin: left center;\n  transform-origin        : left center;\n  -webkit-transform       : scaleX(0);\n  transform               : scaleX(0);\n  overflow                : hidden;\n  \n  ', '\n  ', '\n'], ['\n  background-color        : var(--px-progress-bar-fill-color,black);\n  height                  : var(--px-progress-bar-height, 5px);\n  transition              : transform 1s cubic-bezier(.78,.13,.16,.87);\n  -webkit-transform-origin: left center;\n  transform-origin        : left center;\n  -webkit-transform       : scaleX(0);\n  transform               : scaleX(0);\n  overflow                : hidden;\n  \n  ', '\n  ', '\n']),
    _templateObject3 = _taggedTemplateLiteral(['\n    transform               : scaleX(', ');\n  '], ['\n    transform               : scaleX(', ');\n  ']),
    _templateObject4 = _taggedTemplateLiteral(['\n    position : relative;\n    animation: ', ' 2s cubic-bezier(.78,.13,.16,.87) infinite;\n  '], ['\n    position : relative;\n    animation: ', ' 2s cubic-bezier(.78,.13,.16,.87) infinite;\n  ']),
    _templateObject5 = _taggedTemplateLiteral(['\n  background-color: var(--px-progress-bar-background-color, lightgray);\n  height          : var(--px-progress-bar-height, 5px);\n'], ['\n  background-color: var(--px-progress-bar-background-color, lightgray);\n  height          : var(--px-progress-bar-height, 5px);\n']),
    _templateObject6 = _taggedTemplateLiteral(['\n  height: var(--px-progress-bar-height, 5px);\n'], ['\n  height: var(--px-progress-bar-height, 5px);\n']);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _styledComponents2 = _interopRequireDefault(_styledComponents);

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

function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }

var ProgressAnimation = (0, _styledComponents.keyframes)(_templateObject);

var _computeRatio = function _computeRatio(v) {
  return v < 0 ? 0 : v > 100 ? 1 : v / 100;
};

var ProgressFill = _styledComponents2.default.div(_templateObject2, function (props) {
  return props.value && (0, _styledComponents.css)(_templateObject3, _computeRatio(props.value));
}, function (props) {
  return props.infinite && (0, _styledComponents.css)(_templateObject4, ProgressAnimation);
});
var ProgressBackground = _styledComponents2.default.div(_templateObject5);

var ProgressBar = _styledComponents2.default.div(_templateObject6);

exports.default = function (_ref) {
  var _ref$value = _ref.value,
      value = _ref$value === undefined ? 0 : _ref$value,
      _ref$max = _ref.max,
      max = _ref$max === undefined ? 100 : _ref$max,
      _ref$min = _ref.min,
      min = _ref$min === undefined ? 0 : _ref$min,
      infinite = _ref.infinite;

  return _react2.default.createElement(
    'div',
    { 'aria-valuemin': min, 'aria-valuemax': max },
    _react2.default.createElement(
      ProgressBar,
      null,
      _react2.default.createElement(
        ProgressBackground,
        null,
        _react2.default.createElement(ProgressFill, { value: value, infinite: infinite })
      )
    )
  );
};