'use strict';

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

var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var cls = require('classnames');
var base = require('./variations/_view/base.js');
var base$1 = require('./variations/_size/base.js');
var base$2 = require('./variations/_pointer-size/base.js');
var base$3 = require('./variations/_disabled/base.js');
var Slider_tokens = require('./Slider.tokens.js');
var Single = require('./components/Single/Single.js');
var Double = require('./components/Double/Double.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);
var cls__default = /*#__PURE__*/_interopDefault(cls);

var _excluded = ["type", "view", "size", "pointerSize", "disabled", "className", "style"];
var isSingleValueProps = function isSingleValueProps(props, type) {
  return typeof props.value === 'number' || type === 'single' && _rollupPluginBabelHelpers.typeof(props.value) !== 'object';
};
var isDoubleValueProps = function isDoubleValueProps(props, type) {
  return _rollupPluginBabelHelpers.typeof(props.value) === 'object' || type === 'double';
};
var sliderRoot = function sliderRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (_ref, ref) {
    var _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'single' : _ref$type,
      view = _ref.view,
      size = _ref.size,
      pointerSize = _ref.pointerSize,
      disabled = _ref.disabled,
      className = _ref.className,
      style = _ref.style,
      props = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
    var doublePointerSize = pointerSize === 'none' ? 'small' : pointerSize;
    if (isSingleValueProps(props, type)) {
      return /*#__PURE__*/React__default.default.createElement(Root, {
        ref: ref,
        view: view,
        size: size,
        pointerSize: pointerSize,
        disabled: disabled,
        className: cls__default.default(className, _rollupPluginBabelHelpers.defineProperty({}, Slider_tokens.classes.verticalOrientation, props.orientation === 'vertical')),
        style: style
      }, /*#__PURE__*/React__default.default.createElement(Single.SingleSlider, _rollupPluginBabelHelpers.extends({
        disabled: disabled,
        pointerSize: pointerSize
      }, props)));
    }
    return /*#__PURE__*/React__default.default.createElement(Root, {
      ref: ref,
      view: view,
      size: size,
      pointerSize: doublePointerSize,
      disabled: disabled,
      className: className,
      style: style
    }, isDoubleValueProps(props, type) && /*#__PURE__*/React__default.default.createElement(Double.DoubleSlider, _rollupPluginBabelHelpers.extends({
      disabled: disabled
    }, props)));
  });
};
var sliderConfig = {
  name: 'Slider',
  tag: 'div',
  layout: sliderRoot,
  base: '',
  variations: {
    view: {
      css: base.base
    },
    size: {
      css: base$1.base
    },
    pointerSize: {
      css: base$2.base
    },
    disabled: {
      css: base$3.base,
      attrs: true
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

exports.sliderConfig = sliderConfig;
exports.sliderRoot = sliderRoot;
