import { defineComponent, computed, createVNode } from 'vue';
import '../../../utils/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import useStyle from '../style/index.mjs';
import { ExceptionMap, IconMap } from './constant.mjs';
import { resultProps } from './props.mjs';
import { classNames } from '../../../utils/dom/class.mjs';

const ExceptionStatus = Object.keys(ExceptionMap);
var AResult = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AResult",
  inheritAttrs: false,
  props: resultProps(),
  PRESENTED_IMAGE_403: ExceptionMap[403],
  PRESENTED_IMAGE_404: ExceptionMap[404],
  PRESENTED_IMAGE_500: ExceptionMap[500],
  slots: Object,
  setup(props, {
    slots,
    attrs
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject("result", props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const className = computed(() => classNames(prefixCls.value, hashId.value, `${prefixCls.value}-${props.status}`, {
      [`${prefixCls.value}-rtl`]: direction.value === "rtl"
    }));
    const renderIcon = (prefixCls2, {
      status,
      icon
    }) => {
      if (ExceptionStatus.includes(`${status}`)) {
        const SVGComponent = ExceptionMap[status];
        return createVNode("div", {
          "class": `${prefixCls2}-icon ${prefixCls2}-image`
        }, [createVNode(SVGComponent, null, null)]);
      }
      const IconComponent = IconMap[status];
      const iconNode = icon || createVNode(IconComponent, null, null);
      return createVNode("div", {
        "class": `${prefixCls2}-icon`
      }, [iconNode]);
    };
    const renderExtra = (prefixCls2, extra) => extra && createVNode("div", {
      "class": `${prefixCls2}-extra`
    }, [extra]);
    return () => {
      var _a, _b, _c, _d, _e, _f, _g, _h;
      const title = (_b = props.title) != null ? _b : (_a = slots.title) == null ? void 0 : _a.call(slots);
      const subTitle = (_d = props.subTitle) != null ? _d : (_c = slots.subTitle) == null ? void 0 : _c.call(slots);
      const icon = (_f = props.icon) != null ? _f : (_e = slots.icon) == null ? void 0 : _e.call(slots);
      const extra = (_h = props.extra) != null ? _h : (_g = slots.extra) == null ? void 0 : _g.call(slots);
      const pre = prefixCls.value;
      return wrapSSR(createVNode("div", {
        ...attrs,
        "class": [className.value, attrs.class]
      }, [renderIcon(pre, {
        status: props.status,
        icon
      }), createVNode("div", {
        "class": `${pre}-title`
      }, [title]), subTitle && createVNode("div", {
        "class": `${pre}-subtitle`
      }, [subTitle]), renderExtra(pre, extra), slots.default && createVNode("div", {
        "class": `${pre}-content`
      }, [slots.default()])]));
    };
  }
});

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