var _excluded = ["content", "open", "icon", "className"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { useMemo } from 'react';
import Modal from "../../modal";
import Icon from "../../icon";
import classNames from 'classnames';
import "./index.less";
var icons = {
  info: '',
  success: 'iconchenggong-1-01',
  error: 'icon-warning',
  warning: 'icon-warning',
  loading: 'icon-loading',
  fail: 'icon-warning'
};
var Toast = function Toast(_ref) {
  var content = _ref.content,
    open = _ref.open,
    icon = _ref.icon,
    className = _ref.className,
    rest = _objectWithoutProperties(_ref, _excluded);
  var iconElement = useMemo(function () {
    if (icon === null || icon === undefined) return null;
    if (typeof icon === 'string' && icon in icons) {
      if (!icons[icon]) return null;
      return /*#__PURE__*/React.createElement(Icon, {
        type: icons[icon],
        className: "pisell-square-toast-icon pisell-square-toast-icon-".concat(icon)
      });
    }
    return icon;
  }, [icon]);
  return /*#__PURE__*/React.createElement(Modal, _extends({
    open: open,
    footer: null,
    closable: false,
    centered: true,
    maskTransitionName: "",
    transitionName: "",
    width: "unset",
    wrapClassName: "pisell-square-toast-wrap",
    className: classNames('pisell-square-toast-modal', className),
    bodyStyle: {
      padding: 0
    },
    destroyOnClose: true,
    modalRender: function modalRender() {
      return /*#__PURE__*/React.createElement("div", {
        className: "pisell-square-toast"
      }, iconElement && /*#__PURE__*/React.createElement("div", {
        className: "pisell-square-toast-icon-wrapper"
      }, iconElement), /*#__PURE__*/React.createElement("div", {
        className: "pisell-square-toast-content"
      }, content));
    }
  }, rest));
};
export default Toast;