import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { CarouselWrapper, CarouselTrack, base } from './Carousel.styles.js';
import { useCarousel } from './useCarousel.js';
import { useDragScroll } from './useDragScroll.js';
import { useForkRef } from '../../../hooks/useForkRef.js';

var _excluded = ["index", "scrollSnapType", "scrollAlign", "detectActive", "detectThreshold", "scaleCallback", "scaleResetCallback", "onIndexChange", "paddingStart", "paddingEnd", "children", "ariaLive", "isDragScrollDisabled"];

/**
 * Компонент для создания списков с прокруткой.
 */
var carouselRoot = function carouselRoot(Root) {
  return /*#__PURE__*/forwardRef(function (_ref, ref) {
    var _ref$index = _ref.index,
      index = _ref$index === void 0 ? 0 : _ref$index,
      _ref$scrollSnapType = _ref.scrollSnapType,
      scrollSnapType = _ref$scrollSnapType === void 0 ? 'mandatory' : _ref$scrollSnapType,
      scrollAlign = _ref.scrollAlign,
      detectActive = _ref.detectActive,
      detectThreshold = _ref.detectThreshold,
      scaleCallback = _ref.scaleCallback,
      scaleResetCallback = _ref.scaleResetCallback,
      onIndexChange = _ref.onIndexChange,
      paddingStart = _ref.paddingStart,
      paddingEnd = _ref.paddingEnd,
      children = _ref.children,
      _ref$ariaLive = _ref.ariaLive,
      ariaLive = _ref$ariaLive === void 0 ? 'off' : _ref$ariaLive,
      _ref$isDragScrollDisa = _ref.isDragScrollDisabled,
      isDragScrollDisabled = _ref$isDragScrollDisa === void 0 ? false : _ref$isDragScrollDisa,
      rest = _objectWithoutProperties(_ref, _excluded);
    var axis = 'x';
    var _useCarousel = useCarousel({
        index: index,
        axis: axis,
        scrollAlign: scrollAlign,
        detectActive: detectActive,
        detectThreshold: detectThreshold,
        scaleCallback: scaleCallback,
        scaleResetCallback: scaleResetCallback,
        onIndexChange: onIndexChange
      }),
      scrollRef = _useCarousel.scrollRef,
      trackRef = _useCarousel.trackRef;
    var handleRef = useForkRef(scrollRef, ref);
    useDragScroll(scrollRef, isDragScrollDisabled);
    return /*#__PURE__*/React__default.createElement(Root, {
      index: index
    }, /*#__PURE__*/React__default.createElement(CarouselWrapper, _extends({
      ref: handleRef,
      scrollSnapType: scrollSnapType
    }, rest), /*#__PURE__*/React__default.createElement(CarouselTrack, {
      ref: trackRef,
      paddingStart: paddingStart,
      paddingEnd: paddingEnd,
      "aria-live": ariaLive
    }, children)));
  });
};
var carouselConfig = {
  name: 'Carousel',
  tag: 'div',
  layout: carouselRoot,
  base: base,
  variations: {},
  defaults: {}
};

export { carouselConfig, carouselRoot };
