import { defineComponent, toRefs, computed, createVNode } from 'vue';
import { CloseOutlined } from '@ant-design/icons-vue';
import '../../../utils/index.mjs';
import '../../../locale/index.mjs';
import LocaleReceiver from '../../locale-provider/src/LocaleReceiver.mjs';
import { Button } from '../../button/index.mjs';
import { tourStepProps } from './props.mjs';
import { classNames } from '../../../utils/dom/class.mjs';
import localeValues from '../../../locale/lang/en_US.mjs';

var TourPanel = /* @__PURE__ */ defineComponent({
  name: "ATourPanel",
  inheritAttrs: false,
  props: tourStepProps(),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      current,
      total
    } = toRefs(props);
    const isLastStep = computed(() => current.value === total.value - 1);
    const prevBtnClick = (e) => {
      var _a;
      const prevButtonProps = props.prevButtonProps;
      (_a = props.onPrev) == null ? void 0 : _a.call(props, e);
      if (typeof (prevButtonProps == null ? void 0 : prevButtonProps.onClick) === "function")
        prevButtonProps == null ? void 0 : prevButtonProps.onClick();
    };
    const nextBtnClick = (e) => {
      var _a, _b;
      const nextButtonProps = props.nextButtonProps;
      if (isLastStep.value)
        (_a = props.onFinish) == null ? void 0 : _a.call(props, e);
      else
        (_b = props.onNext) == null ? void 0 : _b.call(props, e);
      if (typeof (nextButtonProps == null ? void 0 : nextButtonProps.onClick) === "function")
        nextButtonProps == null ? void 0 : nextButtonProps.onClick();
    };
    return () => {
      const {
        prefixCls,
        title,
        onClose,
        cover,
        description,
        type: stepType,
        arrow
      } = props;
      const prevButtonProps = props.prevButtonProps;
      const nextButtonProps = props.nextButtonProps;
      let headerNode;
      if (title) {
        headerNode = createVNode("div", {
          "class": `${prefixCls}-header`
        }, [createVNode("div", {
          "class": `${prefixCls}-title`
        }, [title])]);
      }
      let descriptionNode;
      if (description)
        descriptionNode = createVNode("div", {
          "class": `${prefixCls}-description`
        }, [description]);
      let coverNode;
      if (cover)
        coverNode = createVNode("div", {
          "class": `${prefixCls}-cover`
        }, [cover]);
      let mergeIndicatorNode;
      if (slots.indicatorsRender) {
        mergeIndicatorNode = slots.indicatorsRender({
          current: current.value,
          total
        });
      } else {
        mergeIndicatorNode = [...Array.from({
          length: total.value
        }).keys()].map((stepItem, index) => {
          return createVNode("span", {
            "key": stepItem,
            "class": classNames(index === current.value && `${prefixCls}-indicator-active`, `${prefixCls}-indicator`)
          }, null);
        });
      }
      const mainBtnType = stepType === "primary" ? "default" : "primary";
      const secondaryBtnProps = {
        type: "default",
        ghost: stepType === "primary"
      };
      return createVNode(LocaleReceiver, {
        "componentName": "Tour",
        "defaultLocale": localeValues.Tour
      }, {
        default: (contextLocale) => createVNode("div", {
          ...attrs,
          "class": classNames(stepType === "primary" ? `${prefixCls}-primary` : "", attrs.class, `${prefixCls}-content`)
        }, [arrow && createVNode("div", {
          "class": `${prefixCls}-arrow`,
          "key": "arrow"
        }, null), createVNode("div", {
          "class": `${prefixCls}-inner`
        }, [createVNode(CloseOutlined, {
          "class": `${prefixCls}-close`,
          "onClick": onClose
        }, null), coverNode, headerNode, descriptionNode, createVNode("div", {
          "class": `${prefixCls}-footer`
        }, [total.value > 1 && createVNode("div", {
          "class": `${prefixCls}-indicators`
        }, [mergeIndicatorNode]), createVNode("div", {
          "class": `${prefixCls}-buttons`
        }, [current.value !== 0 ? createVNode(Button, {
          ...secondaryBtnProps,
          ...prevButtonProps,
          "onClick": prevBtnClick,
          "size": "small",
          "class": classNames(`${prefixCls}-prev-btn`, prevButtonProps == null ? void 0 : prevButtonProps.className)
        }, {
          default: () => {
            var _a;
            return [(_a = prevButtonProps == null ? void 0 : prevButtonProps.children) != null ? _a : contextLocale.Previous];
          }
        }) : null, createVNode(Button, {
          "type": mainBtnType,
          ...nextButtonProps,
          "onClick": nextBtnClick,
          "size": "small",
          "class": classNames(`${prefixCls}-next-btn`, nextButtonProps == null ? void 0 : nextButtonProps.className)
        }, {
          default: () => {
            var _a;
            return [(_a = nextButtonProps == null ? void 0 : nextButtonProps.children) != null ? _a : isLastStep.value ? contextLocale.Finish : contextLocale.Next];
          }
        })])])])])
      });
    };
  }
});

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