"use strict";

exports.__esModule = true;
exports.default = void 0;

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

var _notistack = require("notistack");

var _styles = require("@mui/material/styles");

var _material = require("@mui/material");

var _Icon = _interopRequireDefault(require("@mui/material/Icon"));

var _Widget = _interopRequireDefault(require("../../components/Widget"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

const PREFIX = 'SCCustomSnackMessage';
const classes = {
  root: `${PREFIX}-root`,
  card: `${PREFIX}-card`,
  cardContent: `${PREFIX}-card-content`,
  closeAction: `${PREFIX}-close-action`
};
const Root = (0, _styles.styled)(_notistack.SnackbarContent, {
  name: PREFIX,
  slot: 'Root',
  overridesResolver: (props, styles) => styles.root
})(({
  theme
}) => ({
  width: 370,
  [theme.breakpoints.up('sm')]: {
    minWidth: '345px !important'
  },
  [`& .${classes.card}`]: {
    backgroundColor: '#fff',
    width: '100%',
    padding: theme.spacing(),
    borderRadius: 10
  },
  [`& .${classes.cardContent}`]: {
    padding: `5px 5px`,
    paddingBottom: `5px !important`
  },
  [`& .${classes.closeAction}`]: {
    position: 'absolute',
    right: 0,
    top: 0,
    zIndex: 1
  },
  '& a': {
    textDecoration: 'none',
    color: theme.palette.text.primary
  }
}));
/**
 * Custom Snackbar for notistack messages
 * Use this component:
 *  - pass this component as property 'content' in the 'options' of enqueueSnackbar
 *
 * This component add a CloseIcon button on the top-right corner
 * and attach a close handler that close the snackMessage identified as props.id
 */

const CustomSnackMessage = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
  const {
    closeSnackbar
  } = (0, _notistack.useSnackbar)();
  const handleDismiss = (0, _react.useCallback)(() => {
    closeSnackbar(props.id);
  }, [props.id, closeSnackbar]);
  return /*#__PURE__*/_react.default.createElement(Root, {
    ref: ref,
    className: classes.root,
    key: props.id
  }, /*#__PURE__*/_react.default.createElement(_Widget.default, {
    className: classes.card
  }, /*#__PURE__*/_react.default.createElement(_material.CardContent, {
    className: classes.cardContent
  }, /*#__PURE__*/_react.default.createElement(_material.IconButton, {
    className: classes.closeAction,
    onClick: handleDismiss
  }, /*#__PURE__*/_react.default.createElement(_Icon.default, null, "close")), props.message)));
});
var _default = CustomSnackMessage;
exports.default = _default;