import { createVNode as _createVNode } from "vue";
import _extends from "@babel/runtime/helpers/esm/extends";
import { defineComponent } from 'vue';
import { useInjectSlider } from '../context';
import { getDirectionStyle } from '../util';
import classnames from '../../_util/classNames';
const dotProps = () => ({
  prefixCls: String,
  value: Number,
  style: [Object, Function],
  activeStyle: [Object, Function]
});
const Dot = defineComponent({
  name: 'ADot',
  props: dotProps(),
  setup(props) {
    const context = useInjectSlider();
    return () => {
      const {
        prefixCls,
        value,
        style,
        activeStyle
      } = props;
      const {
        min,
        max,
        direction,
        included,
        includedStart,
        includedEnd
      } = context.value;
      const dotClassName = `${prefixCls}-dot`;
      const active = included && includedStart <= value && value <= includedEnd;
      let mergedStyle = _extends(_extends({}, getDirectionStyle(direction, value, min, max)), typeof style === 'function' ? style(value) : style);
      if (active) {
        mergedStyle = _extends(_extends({}, mergedStyle), typeof activeStyle === 'function' ? activeStyle(value) : activeStyle);
      }
      return _createVNode("span", {
        "class": classnames(dotClassName, {
          [`${dotClassName}-active`]: active
        }),
        "style": mergedStyle
      }, null);
    };
  }
});
export default Dot;