'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var CloseOutlined = require('@ant-design/icons-vue');
require('../vc-steps/index.js');
var index$2 = require('../progress/index.js');
var index$3 = require('../tooltip/index.js');
var Step$1 = require('../vc-steps/Step.js');
var internal = require('../theme/internal.js');
var type = require('../_util/type.js');
var initDefaultProps = require('../_util/props-util/initDefaultProps.js');
require('../hooks/index.js');
var classNames = require('../_util/classNames.js');
var omit = require('../_util/omit.js');
var index$1 = require('./style/index.js');
var useConfigInject = require('../config-provider/hooks/useConfigInject.js');
var useBreakpoint = require('../hooks/useBreakpoint.js');
var Steps$1 = require('../vc-steps/Steps.js');

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
}
const stepsProps = () => ({
  "prefixCls": String,
  "iconPrefix": String,
  "current": Number,
  "initial": Number,
  "percent": Number,
  "responsive": type.booleanType(),
  "items": type.arrayType(),
  "labelPlacement": type.stringType(),
  "status": type.stringType(),
  "size": type.stringType(),
  "direction": type.stringType(),
  "progressDot": type.someType([Boolean, Function]),
  "type": type.stringType(),
  "onChange": type.functionType(),
  "onUpdate:current": type.functionType()
});
const stepProps = () => ({
  description: type.anyType(),
  icon: type.anyType(),
  status: type.stringType(),
  disabled: type.booleanType(),
  title: type.anyType(),
  subTitle: type.anyType(),
  onClick: type.functionType()
});
const Steps = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ASteps",
  inheritAttrs: false,
  props: initDefaultProps.default(stepsProps(), {
    current: 0,
    responsive: true,
    labelPlacement: "horizontal"
  }),
  slots: Object,
  // emits: ['update:current', 'change'],
  setup(props, {
    attrs,
    slots,
    emit
  }) {
    const {
      prefixCls,
      direction: rtlDirection,
      configProvider
    } = useConfigInject.default("steps", props);
    const [wrapSSR, hashId] = index$1.default(prefixCls);
    const [, token] = internal.useToken();
    const screens = useBreakpoint.useBreakpoint();
    const direction = vue.computed(() => props.responsive && screens.value.xs ? "vertical" : props.direction);
    const iconPrefix = vue.computed(() => configProvider.getPrefixCls("", props.iconPrefix));
    const handleChange = (current) => {
      emit("update:current", current);
      emit("change", current);
    };
    const isInline = vue.computed(() => props.type === "inline");
    const mergedPercent = vue.computed(() => isInline.value ? void 0 : props.percent);
    const stepIconRender = ({
      node,
      status
    }) => {
      if (status === "process" && props.percent !== void 0) {
        const progressWidth = props.size === "small" ? token.value.controlHeight : token.value.controlHeightLG;
        const iconWithProgress = vue.createVNode("div", {
          "class": `${prefixCls.value}-progress-icon`
        }, [vue.createVNode(index$2.default, {
          "type": "circle",
          "percent": mergedPercent.value,
          "size": progressWidth,
          "strokeWidth": 4,
          "format": () => null
        }, null), node]);
        return iconWithProgress;
      }
      return node;
    };
    const icons = vue.computed(() => ({
      finish: vue.createVNode(CloseOutlined.CheckOutlined, {
        "class": `${prefixCls.value}-finish-icon`
      }, null),
      error: vue.createVNode(CloseOutlined.CloseOutlined, {
        "class": `${prefixCls.value}-error-icon`
      }, null)
    }));
    return () => {
      const stepsClassName = classNames.default({
        [`${prefixCls.value}-rtl`]: rtlDirection.value === "rtl",
        [`${prefixCls.value}-with-progress`]: mergedPercent.value !== void 0
      }, attrs.class, hashId.value);
      const itemRender = (item, stepItem) => item.description ? vue.createVNode(index$3.default, {
        "title": item.description
      }, _isSlot(stepItem) ? stepItem : {
        default: () => [stepItem]
      }) : stepItem;
      return wrapSSR(vue.createVNode(Steps$1.default, vue.mergeProps({
        "icons": icons.value
      }, attrs, omit.default(props, ["percent", "responsive"]), {
        "items": props.items,
        "direction": direction.value,
        "prefixCls": prefixCls.value,
        "iconPrefix": iconPrefix.value,
        "class": stepsClassName,
        "onChange": handleChange,
        "isInline": isInline.value,
        "itemRender": isInline.value ? itemRender : void 0
      }), {
        stepIcon: stepIconRender,
        ...slots
      }));
    };
  }
});
const Step = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  ...Step$1.default,
  name: "AStep",
  props: Step$1.VcStepProps()
});
var index = Object.assign(Steps, {
  Step,
  install: (app) => {
    app.component(Steps.name, Steps);
    app.component(Step.name, Step);
    return app;
  }
});

exports.Step = Step;
exports.default = index;
exports.stepProps = stepProps;
exports.stepsProps = stepsProps;
//# sourceMappingURL=index.js.map
