import { createVNode, defineComponent, computed, mergeProps } from 'vue';
import { CheckCircleFilled, CloseCircleFilled, ExclamationCircleFilled, WarningFilled } from '@ant-design/icons-vue';
import '../hooks/index.mjs';
import classNames from '../_util/classNames.mjs';
import PropTypes from '../_util/vue-types/index.mjs';
import Unauthorized from './unauthorized.mjs';
import NoFound from './noFound.mjs';
import ServerError from './serverError.mjs';
import useStyle from './style/index.mjs';
import useConfigInject from '../config-provider/hooks/useConfigInject.mjs';

const IconMap = {
  success: CheckCircleFilled,
  error: CloseCircleFilled,
  info: ExclamationCircleFilled,
  warning: WarningFilled
};
const ExceptionMap = {
  404: NoFound,
  500: ServerError,
  403: Unauthorized
};
const ExceptionStatus = Object.keys(ExceptionMap);
const resultProps = () => ({
  prefixCls: String,
  icon: PropTypes.any,
  status: {
    type: [Number, String],
    default: "info"
  },
  title: PropTypes.any,
  subTitle: PropTypes.any,
  extra: PropTypes.any
});
const renderIcon = (prefixCls, {
  status,
  icon
}) => {
  if (ExceptionStatus.includes(`${status}`)) {
    const SVGComponent = ExceptionMap[status];
    return createVNode("div", {
      "class": `${prefixCls}-icon ${prefixCls}-image`
    }, [createVNode(SVGComponent, null, null)]);
  }
  const IconComponent = IconMap[status];
  const iconNode = icon || createVNode(IconComponent, null, null);
  return createVNode("div", {
    "class": `${prefixCls}-icon`
  }, [iconNode]);
};
const renderExtra = (prefixCls, extra) => extra && createVNode("div", {
  "class": `${prefixCls}-extra`
}, [extra]);
const Result = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AResult",
  inheritAttrs: false,
  props: resultProps(),
  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"
    }));
    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", mergeProps(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()])]));
    };
  }
});
Result.PRESENTED_IMAGE_403 = ExceptionMap[403];
Result.PRESENTED_IMAGE_404 = ExceptionMap[404];
Result.PRESENTED_IMAGE_500 = ExceptionMap[500];
Result.install = function(app) {
  app.component(Result.name, Result);
  return app;
};

export { ExceptionMap, IconMap, Result as default, resultProps };
//# sourceMappingURL=index.mjs.map
