import { createVNode as _createVNode } from "vue";
import { isValidElement } from '../_util/props-util';
export default ((_, {
  attrs
}) => {
  const {
    prefixCls,
    marks = {},
    min,
    max
  } = attrs;

  function onClickLabel(e, num) {
    var _attrs$onClickLabel;

    e.stopPropagation();
    e.preventDefault();
    (_attrs$onClickLabel = attrs.onClickLabel) === null || _attrs$onClickLabel === void 0 ? void 0 : _attrs$onClickLabel.call(attrs, e, num);
  }

  const marksNode = Object.keys(marks).map(num => {
    const mark = marks[num];
    const isObject = typeof mark === 'object' && !isValidElement(mark);
    const markLabel = isObject ? `${mark.label}` : `${mark}`;
    const markProps = {
      class: `${prefixCls}_mark`,
      style: {
        trasnform: 'translateX(-50%)',
        left: `${(+num - min) / (max - min) * 100}%`,
        ...(mark === null || mark === void 0 ? void 0 : mark.style)
      },
      key: num,
      onMousedown: e => onClickLabel(e, +num),
      onTouchstart: e => onClickLabel(e, +num)
    };
    return _createVNode("span", markProps, [markLabel]);
  });
  return _createVNode("div", {
    "class": `${prefixCls}_marks`
  }, [marksNode]);
});