import { isVNode, defineComponent, createVNode } from 'vue';
import classNames from '../_util/classNames.mjs';
import PropTypes from '../_util/vue-types/index.mjs';
import { cloneElement } from '../_util/vnode.mjs';
import '../hooks/index.mjs';
import { filterEmpty } from '../_util/props-util/index.mjs';
import SingleNumber from './SingleNumber.mjs';
import useConfigInject from '../config-provider/hooks/useConfigInject.mjs';

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const scrollNumberProps = {
  prefixCls: String,
  count: PropTypes.any,
  component: String,
  title: PropTypes.any,
  show: Boolean
};
var ScrollNumber = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ScrollNumber",
  inheritAttrs: false,
  props: scrollNumberProps,
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls
    } = useConfigInject("scroll-number", props);
    return () => {
      var _a;
      const {
        prefixCls: customizePrefixCls,
        count,
        title,
        show,
        component: Tag = "sup",
        class: className,
        style,
        ...restProps
      } = {
        ...props,
        ...attrs
      };
      const newProps = {
        ...restProps,
        style,
        "data-show": props.show,
        "class": classNames(prefixCls.value, className),
        "title": title
      };
      let numberNodes = count;
      if (count && Number(count) % 1 === 0) {
        const numberList = String(count).split("");
        numberNodes = numberList.map((num, i) => createVNode(SingleNumber, {
          "prefixCls": prefixCls.value,
          "count": Number(count),
          "value": num,
          "key": numberList.length - i
        }, null));
      }
      if (style && style.borderColor) {
        newProps.style = {
          ...style,
          boxShadow: `0 0 0 1px ${style.borderColor} inset`
        };
      }
      const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
      if (children && children.length) {
        return cloneElement(children, {
          class: classNames(`${prefixCls.value}-custom-component`)
        }, false);
      }
      return createVNode(Tag, newProps, _isSlot(numberNodes) ? numberNodes : {
        default: () => [numberNodes]
      });
    };
  }
});

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