import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React, { useRef } from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/context'; // import DefaultEmptyImg from './empty_icon';
// @ts-ignore

import fail_png from './asset/fail.png'; // @ts-ignore

import noactive_png from './asset/noactive.png'; // @ts-ignore

import nodata_png from './asset/nodata.png'; // @ts-ignore

import nogoods_png from './asset/nogoods.png'; // @ts-ignore

import success_png from './asset/success.png';
var Empty = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var _React$useContext = React.useContext(ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var emptyRef = ref || useRef(null);

  var className = props.className,
      imageStyle = props.imageStyle,
      image = props.image,
      description = props.description,
      children = props.children,
      size = props.size,
      type = props.type,
      otherProps = _objectWithoutProperties(props, ["className", "imageStyle", "image", "description", "children", "size", "type"]);

  var des = typeof description !== 'undefined' ? description : '暂无数据';
  var alt = typeof des === 'string' ? des : 'empty';
  var emptyCls = getPrefixClassName('empty');
  var endCls = classNames(emptyCls, ["".concat(emptyCls, "-").concat(size)], className); // image node

  var imageNode = null;

  if (typeof image === 'string') {
    imageNode = /*#__PURE__*/React.createElement("img", {
      alt: alt,
      src: image
    });
  } else {
    switch (type) {
      case 'goods':
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-goods"),
          src: nogoods_png
        });
        break;

      case 'activity':
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-activity"),
          src: noactive_png
        });
        break;

      case 'data':
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-data"),
          src: nodata_png
        });
        break;

      case 'rule':
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-data"),
          src: fail_png
        });
        break;

      case 'organization':
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-data"),
          src: fail_png
        });
        break;

      case 'fail':
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-fail"),
          src: fail_png
        });
        break;

      case 'success':
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-success"),
          src: success_png
        });
        break;

      default:
        imageNode = /*#__PURE__*/React.createElement("img", {
          alt: alt,
          className: "".concat(emptyCls, "-data"),
          src: nodata_png
        });
        break;
    }
  }

  var comProps = _objectSpread({
    ref: emptyRef,
    className: endCls
  }, otherProps);

  return /*#__PURE__*/React.createElement("div", Object.assign({}, comProps), /*#__PURE__*/React.createElement("div", {
    className: "".concat(emptyCls, "-image"),
    style: imageStyle
  }, imageNode), des && /*#__PURE__*/React.createElement("div", {
    className: "".concat(emptyCls, "-description")
  }, des), children && /*#__PURE__*/React.createElement("div", {
    className: "".concat(emptyCls, "-footer")
  }, children));
});
Empty.displayName = 'Empty';
Empty.defaultProps = {
  size: 'middle'
};
export default Empty;