'use strict';

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

var vue = require('vue');
var CloseOutlined = require('@ant-design/icons-vue');
require('../hooks/index.js');
var classNames = require('../_util/classNames.js');
var index = require('../_util/vue-types/index.js');
var unauthorized = require('./unauthorized.js');
var noFound = require('./noFound.js');
var serverError = require('./serverError.js');
var index$1 = require('./style/index.js');
var useConfigInject = require('../config-provider/hooks/useConfigInject.js');

const IconMap = {
  success: CloseOutlined.CheckCircleFilled,
  error: CloseOutlined.CloseCircleFilled,
  info: CloseOutlined.ExclamationCircleFilled,
  warning: CloseOutlined.WarningFilled
};
const ExceptionMap = {
  404: noFound.default,
  500: serverError.default,
  403: unauthorized.default
};
const ExceptionStatus = Object.keys(ExceptionMap);
const resultProps = () => ({
  prefixCls: String,
  icon: index.default.any,
  status: {
    type: [Number, String],
    default: "info"
  },
  title: index.default.any,
  subTitle: index.default.any,
  extra: index.default.any
});
const renderIcon = (prefixCls, {
  status,
  icon
}) => {
  if (ExceptionStatus.includes(`${status}`)) {
    const SVGComponent = ExceptionMap[status];
    return vue.createVNode("div", {
      "class": `${prefixCls}-icon ${prefixCls}-image`
    }, [vue.createVNode(SVGComponent, null, null)]);
  }
  const IconComponent = IconMap[status];
  const iconNode = icon || vue.createVNode(IconComponent, null, null);
  return vue.createVNode("div", {
    "class": `${prefixCls}-icon`
  }, [iconNode]);
};
const renderExtra = (prefixCls, extra) => extra && vue.createVNode("div", {
  "class": `${prefixCls}-extra`
}, [extra]);
const Result = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AResult",
  inheritAttrs: false,
  props: resultProps(),
  slots: Object,
  setup(props, {
    slots,
    attrs
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject.default("result", props);
    const [wrapSSR, hashId] = index$1.default(prefixCls);
    const className = vue.computed(() => classNames.default(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(vue.createVNode("div", vue.mergeProps(attrs, {
        "class": [className.value, attrs.class]
      }), [renderIcon(pre, {
        status: props.status,
        icon
      }), vue.createVNode("div", {
        "class": `${pre}-title`
      }, [title]), subTitle && vue.createVNode("div", {
        "class": `${pre}-subtitle`
      }, [subTitle]), renderExtra(pre, extra), slots.default && vue.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;
};

exports.ExceptionMap = ExceptionMap;
exports.IconMap = IconMap;
exports.default = Result;
exports.resultProps = resultProps;
//# sourceMappingURL=index.js.map
