/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { _ as _toConsumableArray } from '../../_chunks/dep-e091cfd9.mjs';
import { computed, createVNode } from 'vue';
import { c as cloneDeep_1 } from '../../_chunks/dep-44417261.mjs';
import { i as isArray_1 } from '../../_chunks/dep-e3b14d70.mjs';
import log from '../../_common/js/log/log.mjs';
import { getStopStyle } from '../util/common.mjs';
import TSliderMark from '../slider-mark.mjs';
import '../../_chunks/dep-cfcedf47.mjs';
import '../../_chunks/dep-a0b4a044.mjs';
import '../../_chunks/dep-bf74f1c2.mjs';
import '../../_chunks/dep-79821ff2.mjs';
import '../../_chunks/dep-0bfbf721.mjs';
import '../../_chunks/dep-39cc276d.mjs';
import '../../_chunks/dep-6b22dd27.mjs';
import '../../_chunks/dep-c959a6fb.mjs';
import '../../_chunks/dep-b4041200.mjs';
import '../../_chunks/dep-0f0c89ff.mjs';
import '../../_chunks/dep-8f777748.mjs';
import '../../_chunks/dep-ae357f26.mjs';
import '../../_chunks/dep-352691c2.mjs';
import '../../_chunks/dep-2cfd5b3a.mjs';
import '../../_chunks/dep-05fa17c9.mjs';
import '../../_chunks/dep-c31e1d9e.mjs';
import '../../_chunks/dep-66d6733b.mjs';
import '../../_chunks/dep-a9c8a5d5.mjs';
import '../../_chunks/dep-10085c61.mjs';
import '../../_chunks/dep-1b058de3.mjs';
import '../../_chunks/dep-c852a61a.mjs';
import '../../_chunks/dep-92e7085e.mjs';
import '../../_chunks/dep-44f056cd.mjs';
import '../../_chunks/dep-23a0f453.mjs';
import '../../_chunks/dep-1cf2b129.mjs';
import '../../hooks/useConfig.mjs';
import '../../config-provider/useConfig.mjs';
import '../../_chunks/dep-99920870.mjs';
import '../../_chunks/dep-c7e9ce16.mjs';
import '../../_chunks/dep-3afa94cf.mjs';
import '../../_chunks/dep-ba3c0b2e.mjs';
import '../../_chunks/dep-ee57d235.mjs';
import '../../_common/js/global-config/default-config.mjs';
import '../../_common/js/global-config/locale/zh_CN.mjs';
import '../../_chunks/dep-6b4aa943.mjs';
import '../../_chunks/dep-d52291a9.mjs';
import '../../config-provider/type.mjs';

var useSliderMark = function useSliderMark(config) {
  var name = config.value.prefixName;
  var markList = computed(function () {
    var markProps = config.value;
    if (!markProps.marks) return [];
    var legalMarks = [];
    if (isArray_1(markProps.marks)) {
      var marksList = cloneDeep_1(markProps.marks).sort(function (a, b) {
        return a - b;
      });
      var maxLimit = Math.max.apply(Math, _toConsumableArray(marksList).concat([markProps.max]));
      var minLimit = Math.min.apply(Math, _toConsumableArray(marksList).concat([markProps.min]));
      if (minLimit < markProps.min) log.errorOnce("TSlider", "marks min value should >= props min");
      if (maxLimit > markProps.max) log.errorOnce("TSlider", "marks max value should <= props max");
      marksList.forEach(function (item) {
        legalMarks.push({
          point: item,
          position: (item - minLimit) / (maxLimit - minLimit) * 100,
          mark: item
        });
      });
    } else {
      Object.keys(markProps.marks).map(parseFloat).sort(function (a, b) {
        return a - b;
      }).filter(function (point) {
        return point <= markProps.max && point >= markProps.min;
      }).forEach(function (point) {
        var item = {
          point: point,
          position: (point - markProps.min) * 100 / (markProps.max - markProps.min),
          mark: markProps.marks[point]
        };
        legalMarks.push(item);
      });
    }
    return legalMarks;
  });
  var renderMask = function renderMask(onChangeFn) {
    if (!markList.value.length) return null;
    return createVNode("div", null, [createVNode("div", {
      "class": "".concat(name, "__stops")
    }, [markList.value.map(function (item, index) {
      if (item.position === 0 || item.position === 100) return null;
      return createVNode("div", {
        "class": "".concat(name, "__stop ").concat(name, "__mark-stop"),
        "style": getStopStyle(item.position, config.value.vertical),
        "key": index
      }, null);
    })]), createVNode("div", {
      "class": "".concat(name, "__mark")
    }, [markList.value.map(function (item, key) {
      return createVNode(TSliderMark, {
        "mark": item.mark,
        "point": item.point,
        "key": key,
        "style": getStopStyle(item.position, config.value.vertical),
        "onClickMarkPoint": onChangeFn
      }, null);
    })])]);
  };
  return renderMask;
};

export { useSliderMark };
//# sourceMappingURL=useSliderMark.mjs.map
