function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import { getPercent } from '../utils';

function _getProps(min, max, value, rtl) {
  return {
    style: {
      left: rtl ? "".concat(100 - getPercent(min, max, value), "%") : "".concat(getPercent(min, max, value), "%"),
      zIndex: 100
    },
    'aria-valuenow': value,
    'aria-valuetext': value,
    'aria-valuemin': min,
    'aria-valuemax': max
  };
}

function Slider(_ref) {
  var _classNames;

  var prefix = _ref.prefix,
      hasMovingClass = _ref.hasMovingClass,
      min = _ref.min,
      max = _ref.max,
      value = _ref.value,
      onKeyDown = _ref.onKeyDown,
      rtl = _ref.rtl;
  var classes = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "range-slider"), true), _defineProperty(_classNames, "".concat(prefix, "range-slider-moving"), hasMovingClass), _classNames));
  return React.createElement("div", _extends({
    className: classes,
    onKeyDown: onKeyDown,
    role: "slider",
    tabIndex: 0
  }, _getProps(min, max, value, rtl)), React.createElement("div", {
    className: "".concat(prefix, "range-slider-inner")
  }));
}

Slider.propTypes = {
  min: PropTypes.number,
  max: PropTypes.number,
  value: PropTypes.number,
  prefix: PropTypes.string,
  hasMovingClass: PropTypes.bool,
  rtl: PropTypes.bool
};
Slider.defaultProps = {
  prefix: 'next-',
  min: 0,
  max: 100,
  value: 0,
  hasMovingClass: false,
  rtl: false
};
export default Slider;