import { defineComponent, useAttrs, computed, ref, useSlots, resolveComponent, createElementBlock, openBlock, mergeProps, unref, createCommentVNode, createElementVNode, normalizeStyle, normalizeClass, createVNode, withCtx, Fragment, renderList, createBlock, createSlots, renderSlot, toDisplayString, resolveDynamicComponent } from 'vue';
import '../../../utils/index.mjs';
import { Steps } from 'ant-design-vue';
import { omit } from 'lodash-es';
import { stepsProps } from './steps.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';
import { addUnit } from '../../../utils/add-unit.mjs';

"use strict";
const _hoisted_1 = { key: 1 };
const _hoisted_2 = { key: 0 };
const _hoisted_3 = { key: 0 };
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlSteps", inheritAttrs: false },
  __name: "steps",
  props: stepsProps,
  emits: ["update:current"],
  setup(__props, { emit: __emit }) {
    const bem = createNamespace("steps");
    const attrs = useAttrs();
    const containerAttrs = computed(() => ({
      class: attrs.class,
      style: attrs.style
    }));
    const componentAttrs = computed(() => omit(attrs, ["class", "style"]));
    const props = __props;
    const emits = __emit;
    const internalCurrent = ref(0);
    const currentVal = computed({
      get: () => props.current || internalCurrent.value,
      set: (v) => {
        if (props.clicked) {
          internalCurrent.value = v;
          emits("update:current", v);
        }
      }
    });
    const slots = useSlots();
    const currentStepComponent = computed(() => {
      const currentStep = stepItems.value.find(
        (step) => step.key === currentVal.value
      );
      return currentStep?.component || null;
    });
    const stepItems = computed(() => {
      const children = slots.default?.() || [];
      const result = [];
      let index = 0;
      const processNode = (node) => {
        if (!node) return;
        if (node.type && typeof node.type === "object" && node.type.name === "LlStepItem") {
          result.push({
            index,
            key: index,
            component: node
          });
          index++;
        } else if (node.type?.toString() === "Symbol(v-fgt)") {
          if (node.children) {
            node.children.forEach(processNode);
          }
        }
      };
      children.forEach(processNode);
      return result;
    });
    const filterItem = (item) => {
      const slotKeys = /* @__PURE__ */ new Set([
        ...Object.keys(slots),
        "icon",
        "description",
        "subTitle"
      ]);
      const newItem = Object.fromEntries(
        Object.entries(item).filter(([key]) => !slotKeys.has(key))
      );
      return newItem;
    };
    const getFooterPositional = computed(() => {
      switch (props.footerPositional) {
        case "left":
          return "left";
        case "center":
          return "center";
        case "right":
          return "right";
        default:
          return "right";
      }
    });
    return (_ctx, _cache) => {
      const _component_ll_icon = resolveComponent("ll-icon");
      const _component_a_step = resolveComponent("a-step");
      return openBlock(), createElementBlock(
        "div",
        mergeProps({
          class: unref(bem).b("container"),
          style: { width: unref(addUnit)(_ctx.width), height: unref(addUnit)(_ctx.height) }
        }, containerAttrs.value),
        [
          createCommentVNode(" \u6B65\u9AA4\u6761 "),
          createElementVNode(
            "div",
            {
              class: normalizeClass([unref(bem).b("nav"), unref(bem).is(_ctx.miniSize ? "mini" : "")]),
              style: normalizeStyle({ padding: _ctx.stepPadding })
            },
            [
              createVNode(unref(Steps), mergeProps(componentAttrs.value, {
                current: currentVal.value,
                "onUpdate:current": _cache[0] || (_cache[0] = ($event) => currentVal.value = $event),
                "progress-dot": _ctx.type === "breadcrumb" ? false : _ctx.progressDot,
                size: "default",
                items: _ctx.type === "inline" ? _ctx.items : void 0,
                class: [
                  unref(bem).b(),
                  unref(bem).is(_ctx.type === "tabs" ? "tabs" : ""),
                  unref(bem).is(_ctx.type === "breadcrumb" ? "breadcrumb" : ""),
                  unref(bem).is(
                    _ctx.left && (_ctx.type === "navigation" || _ctx.type === "breadcrumb") ? "left" : ""
                  )
                ],
                type: _ctx.type === "tabs" || _ctx.type === "breadcrumb" ? "navigation" : _ctx.type,
                direction: _ctx.type === "default" ? _ctx.direction : "horizontal"
              }), {
                default: withCtx(() => [
                  _ctx.type !== "inline" ? (openBlock(true), createElementBlock(
                    Fragment,
                    { key: 0 },
                    renderList(_ctx.items, (item, index) => {
                      return openBlock(), createBlock(
                        _component_a_step,
                        mergeProps({
                          key: index,
                          ref_for: true
                        }, filterItem(item)),
                        createSlots({
                          _: 2
                          /* DYNAMIC */
                        }, [
                          !_ctx.progressDot || _ctx.type === "breadcrumb" ? {
                            name: "icon",
                            fn: withCtx(() => [
                              renderSlot(_ctx.$slots, "icon", mergeProps({ ref_for: true }, { item, index }), () => [
                                item.icon ? (openBlock(), createBlock(_component_ll_icon, {
                                  key: 0,
                                  "icon-name": item.icon,
                                  color: "inherit"
                                }, null, 8, ["icon-name"])) : (openBlock(), createElementBlock(
                                  "span",
                                  _hoisted_1,
                                  toDisplayString(index + 1),
                                  1
                                  /* TEXT */
                                ))
                              ])
                            ]),
                            key: "0"
                          } : void 0,
                          _ctx.type !== "breadcrumb" || _ctx.$slots.subTitle ? {
                            name: "subTitle",
                            fn: withCtx(() => [
                              renderSlot(_ctx.$slots, "subTitle", mergeProps({ ref_for: true }, { item, index }), () => [
                                item.subTitle ? (openBlock(), createElementBlock(
                                  "span",
                                  _hoisted_2,
                                  toDisplayString(item.subTitle),
                                  1
                                  /* TEXT */
                                )) : createCommentVNode("v-if", true)
                              ])
                            ]),
                            key: "1"
                          } : void 0,
                          _ctx.type !== "breadcrumb" || _ctx.$slots.description ? {
                            name: "description",
                            fn: withCtx(() => [
                              renderSlot(_ctx.$slots, "description", mergeProps({ ref_for: true }, { item, index }), () => [
                                item.description ? (openBlock(), createElementBlock(
                                  "span",
                                  _hoisted_3,
                                  toDisplayString(item.description),
                                  1
                                  /* TEXT */
                                )) : createCommentVNode("v-if", true)
                              ])
                            ]),
                            key: "2"
                          } : void 0,
                          renderList(Object.keys(_ctx.$slots).filter(
                            (i) => i !== "icon" && i !== "description" && i !== "subTitle"
                          ), (slot) => {
                            return {
                              name: slot,
                              fn: withCtx(() => [
                                renderSlot(_ctx.$slots, slot, mergeProps({ ref_for: true }, { item, index }))
                              ])
                            };
                          })
                        ]),
                        1040
                        /* FULL_PROPS, DYNAMIC_SLOTS */
                      );
                    }),
                    128
                    /* KEYED_FRAGMENT */
                  )) : createCommentVNode("v-if", true)
                ]),
                _: 3
                /* FORWARDED */
              }, 16, ["current", "progress-dot", "items", "class", "type", "direction"])
            ],
            6
            /* CLASS, STYLE */
          ),
          createCommentVNode(" \u5185\u5BB9 "),
          stepItems.value.length > 0 && _ctx.direction !== "vertical" && _ctx.content ? (openBlock(), createElementBlock(
            "div",
            {
              key: 0,
              class: normalizeClass(unref(bem).e("content"))
            },
            [
              currentStepComponent.value ? (openBlock(), createBlock(resolveDynamicComponent(currentStepComponent.value), { key: 0 })) : createCommentVNode("v-if", true)
            ],
            2
            /* CLASS */
          )) : createCommentVNode("v-if", true),
          createCommentVNode(" \u9875\u811A "),
          _ctx.footer && _ctx.direction !== "vertical" ? (openBlock(), createElementBlock(
            "div",
            {
              key: 1,
              class: normalizeClass([unref(bem).e("footer"), unref(bem).is(getFooterPositional.value)])
            },
            [
              renderSlot(_ctx.$slots, "footer")
            ],
            2
            /* CLASS */
          )) : createCommentVNode("v-if", true)
        ],
        16
        /* FULL_PROPS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=steps.vue2.mjs.map
