"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _context = require("../config-provider/context");

var _fail = _interopRequireDefault(require("./asset/fail.png"));

var _noactive = _interopRequireDefault(require("./asset/noactive.png"));

var _nodata = _interopRequireDefault(require("./asset/nodata.png"));

var _nogoods = _interopRequireDefault(require("./asset/nogoods.png"));

var _success = _interopRequireDefault(require("./asset/success.png"));

// import DefaultEmptyImg from './empty_icon';
// @ts-ignore
// @ts-ignore
// @ts-ignore
// @ts-ignore
// @ts-ignore
var Empty = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var _React$useContext = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var emptyRef = ref || (0, _react.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 = (0, _objectWithoutProperties2.default)(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 = (0, _classnames.default)(emptyCls, ["".concat(emptyCls, "-").concat(size)], className); // image node

  var imageNode = null;

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

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

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

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

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

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

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

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

  var comProps = (0, _objectSpread2.default)({
    ref: emptyRef,
    className: endCls
  }, otherProps);
  return /*#__PURE__*/_react.default.createElement("div", Object.assign({}, comProps), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(emptyCls, "-image"),
    style: imageStyle
  }, imageNode), des && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(emptyCls, "-description")
  }, des), children && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(emptyCls, "-footer")
  }, children));
});

Empty.displayName = 'Empty';
Empty.defaultProps = {
  size: 'middle'
};
var _default = Empty;
exports.default = _default;