import React from 'react';
import PropTypes from 'prop-types';
import { AnimatePresence } from 'framer-motion';
import Toast from './Toast';
import window from '../window';

const ToastManager = ({
  toasts,
  removeToast
}) => /*#__PURE__*/React.createElement("div", {
  className: "toast-container"
}, /*#__PURE__*/React.createElement("ul", {
  className: "toast-container-list"
}, /*#__PURE__*/React.createElement(AnimatePresence, null, toasts.map(toast => /*#__PURE__*/React.createElement(Toast, {
  key: toast.id,
  id: toast.id,
  dismissHandler: () => {
    if (toast.dismissHandler) {
      toast.dismissHandler();
    }

    removeToast(toast.id);
  },
  title: toast.title,
  content: toast.content,
  type: toast.type,
  autoDismiss: toast.autoDismiss,
  className: toast.classNames,
  CustomIcon: toast.CustomIcon
})))));

ToastManager.propTypes = {
  toasts: PropTypes.array.isRequired,
  removeToast: PropTypes.func.isRequired
};
export default window(ToastManager);