"use strict";

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

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

var _reactBootstrapSweetalert = _interopRequireDefault(require("react-bootstrap-sweetalert"));

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

let openSnackbarFn;

class Notifier extends _react.default.Component {
  constructor(...args) {
    super(...args);

    _defineProperty(this, "state", {
      open: false,
      message: ''
    });

    _defineProperty(this, "handleSnackbarClose", () => {
      this.setState({
        open: false,
        message: ''
      });
    });

    _defineProperty(this, "openSnackbar", ({
      message
    }) => {
      this.setState({
        open: true,
        message
      });
    });
  }

  componentDidMount() {
    openSnackbarFn = this.openSnackbar;
  }

  render() {
    const {
      open,
      message
    } = this.state;

    const msg = /*#__PURE__*/_react.default.createElement("span", {
      id: "snackbar-message-id",
      dangerouslySetInnerHTML: {
        __html: message
      }
    });

    return open ? /*#__PURE__*/_react.default.createElement(_reactBootstrapSweetalert.default, {
      onConfirm: this.handleSnackbarClose,
      onCancel: this.handleSnackbarClose,
      title: "",
      style: {
        overflow: 'auto',
        maxHeight: '450px',
        left: '50.9%'
      },
      confirmBtnStyle: {
        height: '35px'
      },
      btnSize: "md"
    }, msg) : null;
  }

}

function openSnackbar({
  message
}) {
  openSnackbarFn({
    message
  });
}

var _default = Notifier;
exports.default = _default;