import { createVNode } from 'vue';
import '../../../utils/index.mjs';
import { clamp } from './utils/innerSliderUtils.mjs';
import { classNames } from '../../../utils/dom/class.mjs';
import { cloneElement } from '../../../utils/vue/vnode.mjs';

const getDotCount = function(spec) {
  let dots;
  if (spec.infinite)
    dots = Math.ceil(spec.slideCount / spec.slidesToScroll);
  else
    dots = Math.ceil((spec.slideCount - spec.slidesToShow) / spec.slidesToScroll) + 1;
  return dots;
};
function Dots(_, {
  attrs
}) {
  const {
    slideCount,
    slidesToScroll,
    slidesToShow,
    infinite,
    currentSlide,
    appendDots,
    customPaging,
    clickHandler,
    dotsClass,
    onMouseenter,
    onMouseover,
    onMouseleave
  } = attrs;
  const dotCount = getDotCount({
    slideCount,
    slidesToScroll,
    slidesToShow,
    infinite
  });
  const mouseEvents = {
    onMouseenter,
    onMouseover,
    onMouseleave
  };
  let dots = [];
  for (let i = 0; i < dotCount; i++) {
    let onClick = function(e) {
      if (e)
        e.preventDefault();
      clickHandler(dotOptions);
    };
    const _rightBound = (i + 1) * slidesToScroll - 1;
    const rightBound = infinite ? _rightBound : clamp(_rightBound, 0, slideCount - 1);
    const _leftBound = rightBound - (slidesToScroll - 1);
    const leftBound = infinite ? _leftBound : clamp(_leftBound, 0, slideCount - 1);
    const className = classNames({
      "slick-active": infinite ? currentSlide >= leftBound && currentSlide <= rightBound : currentSlide === leftBound
    });
    const dotOptions = {
      message: "dots",
      index: i,
      slidesToScroll,
      currentSlide
    };
    dots = dots.concat(createVNode("li", {
      "key": i,
      "class": className
    }, [cloneElement(customPaging({
      i
    }), {
      onClick
    })]));
  }
  return cloneElement(appendDots({
    dots
  }), {
    class: dotsClass,
    ...mouseEvents
  });
}
Dots.inheritAttrs = false;

export { Dots as default };
//# sourceMappingURL=dots.mjs.map
