import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends, typeof as _typeof } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import cls from 'classnames';
import { base } from './variations/_view/base.js';
import { base as base$1 } from './variations/_size/base.js';
import { base as base$2 } from './variations/_pointer-size/base.js';
import { base as base$3 } from './variations/_disabled/base.js';
import { classes } from './Slider.tokens.js';
import { SingleSlider } from './components/Single/Single.js';
import { DoubleSlider } from './components/Double/Double.js';

var _excluded = ["type", "view", "size", "pointerSize", "disabled", "className", "style"];
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,
      view = _ref.view,
      size = _ref.size,
      pointerSize = _ref.pointerSize,
      disabled = _ref.disabled,
      className = _ref.className,
      style = _ref.style,
      props = _objectWithoutProperties(_ref, _excluded);
    var doublePointerSize = pointerSize === 'none' ? 'small' : pointerSize;
    if (isSingleValueProps(props, type)) {
      return /*#__PURE__*/React__default.createElement(Root, {
        ref: ref,
        view: view,
        size: size,
        pointerSize: pointerSize,
        disabled: disabled,
        className: cls(className, _defineProperty({}, classes.verticalOrientation, props.orientation === 'vertical')),
        style: style
      }, /*#__PURE__*/React__default.createElement(SingleSlider, _extends({
        disabled: disabled,
        pointerSize: pointerSize
      }, props)));
    }
    return /*#__PURE__*/React__default.createElement(Root, {
      ref: ref,
      view: view,
      size: size,
      pointerSize: doublePointerSize,
      disabled: disabled,
      className: className,
      style: style
    }, isDoubleValueProps(props, type) && /*#__PURE__*/React__default.createElement(DoubleSlider, _extends({
      disabled: disabled
    }, props)));
  });
};
var sliderConfig = {
  name: 'Slider',
  tag: 'div',
  layout: sliderRoot,
  base: '',
  variations: {
    view: {
      css: base
    },
    size: {
      css: base$1
    },
    pointerSize: {
      css: base$2
    },
    disabled: {
      css: base$3,
      attrs: true
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

export { sliderConfig, sliderRoot };
