"use strict";

exports.__esModule = true;
exports.default = BaseDialog;

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

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

var _Button = _interopRequireDefault(require("@mui/material/Button"));

var _Dialog = _interopRequireDefault(require("@mui/material/Dialog"));

var _DialogActions = _interopRequireDefault(require("@mui/material/DialogActions"));

var _DialogContent = _interopRequireDefault(require("@mui/material/DialogContent"));

var _reactIntl = require("react-intl");

var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));

var _title = _interopRequireDefault(require("./title"));

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

const _excluded = ["className", "title", "open", "onClose"];

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

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; }

const PREFIX = 'SCBaseDialog';
const classes = {
  root: `${PREFIX}-root`
};
const Root = (0, _styles.styled)(_Dialog.default, {
  name: PREFIX,
  slot: 'Root',
  overridesResolver: (props, styles) => styles.root
})(({
  theme
}) => ({
  [theme.breakpoints.down(500)]: {
    minWidth: 300
  },
  minWidth: 500
}));

function BaseDialog(props) {
  // PROPS
  const {
    className,
    title = '',
    open = false,
    onClose = null
  } = props,
        rest = _objectWithoutPropertiesLoose(props, _excluded);

  const {
    children
  } = rest; // OPTIONS

  const fullScreen = (0, _useMediaQuery.default)(theme => theme['breakpoints'].down('sm'));
  /**
   * Renders root object
   */

  return /*#__PURE__*/_react.default.createElement(Root, {
    className: (0, _classnames.default)(classes.root, className),
    fullScreen: fullScreen,
    fullWidth: true,
    open: open,
    onClose: onClose,
    maxWidth: rest.maxWidth ? rest.maxWidth : 'sm',
    scroll: "body"
  }, /*#__PURE__*/_react.default.createElement(_title.default, {
    onClose: onClose
  }, title), /*#__PURE__*/_react.default.createElement(_DialogContent.default, {
    dividers: true
  }, children), /*#__PURE__*/_react.default.createElement(_DialogActions.default, null, /*#__PURE__*/_react.default.createElement(_Button.default, {
    onClick: onClose,
    color: "primary",
    autoFocus: true,
    variant: 'outlined'
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
    id: "ui.baseDialog.button.close",
    defaultMessage: "ui.baseDialog.button.close"
  }))));
}