import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, typeof as _typeof } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { cx } from '../../utils/index.js';
import { base } from './variations/_view/base.js';
import { base as base$1 } from './variations/_size/base.js';
import { base as base$2 } from './variations/_disabled/base.js';
import { classes } from './Slider.tokens.js';
import { SingleSlider } from './components/Single/Single.js';
import { DoubleUncontrolled } from './components/DoubleUncontrolled/DoubleUncontrolled.js';

var _excluded = ["type"];

// TODO: проверить, можно ли обойтись без каста типов

var isSingleValueProps = function isSingleValueProps(props, type) {
  return typeof props.value === 'number' || type === 'single' && _typeof(props.value) !== 'object';
};
var isDoubleValueProps = function isDoubleValueProps(props, type) {
  return _typeof(props.value) === 'object' || type === 'double';
};
var sliderRoot = function sliderRoot(Root) {
  return /*#__PURE__*/forwardRef(function (_ref, ref) {
    var _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'single' : _ref$type,
      props = _objectWithoutProperties(_ref, _excluded);
    if (isSingleValueProps(props, type)) {
      return /*#__PURE__*/React__default.createElement(Root, _extends({}, props, {
        className: cx(props.orientation === 'vertical' && classes.verticalOrientation, props.className),
        ref: ref
      }), /*#__PURE__*/React__default.createElement(SingleSlider, props));
    }
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      ref: ref
    }, props), isDoubleValueProps(props, type) && /*#__PURE__*/React__default.createElement(DoubleUncontrolled, props));
  });
};
var sliderConfig = {
  name: 'Slider',
  tag: 'div',
  layout: sliderRoot,
  base: '',
  variations: {
    view: {
      css: base
    },
    size: {
      css: base$1
    },
    disabled: {
      css: base$2,
      attrs: true
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

export { sliderConfig, sliderRoot };
//# sourceMappingURL=Slider.js.map
