"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
/**
 * Copyright (c) JOB TODAY S.A. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

const Modal = ({
  visible,
  children,
  presentationStyle,
  onRequestClose
}) => {
  if (!visible) {
    return null;
  }
  (0, _react.useEffect)(() => {
    const backHandler = _reactNative.BackHandler.addEventListener('hardwareBackPress', () => {
      if (typeof onRequestClose === 'function') {
        onRequestClose();
      }
      return true;
    });
    return () => {
      backHandler.remove();
    };
  }, []);
  const statusBarHidden = presentationStyle === 'overFullScreen';
  const statusBarStateStyle = presentationStyle === 'overFullScreen' ? styles.overFullscreen : styles.defaultStyle;
  return /*#__PURE__*/React.createElement(React.Fragment, null, statusBarHidden && /*#__PURE__*/React.createElement(_reactNative.StatusBar, {
    hidden: true
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: [styles.root, statusBarStateStyle]
  }, children));
};
const styles = _reactNative.StyleSheet.create({
  root: {
    ..._reactNative.StyleSheet.absoluteFillObject,
    zIndex: 1000,
    backgroundColor: 'transparent'
  },
  overFullscreen: {
    top: 0
  },
  defaultStyle: {
    top: _reactNative.StatusBar.currentHeight
  }
});
var _default = exports.default = Modal;
//# sourceMappingURL=Modal.android.js.map