"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var ReactDom = __importStar(require("react-dom"));
var styled_components_1 = __importDefault(require("styled-components"));
var styleConstants_1 = require("./styleConstants");
exports.ModalWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  align-items: ", ";\n  background-color: ", ";\n  bottom: 0;\n  display: flex;\n  justify-content: center;\n  left: 0;\n  padding: ", ";\n  position: fixed;\n  overflow: auto;\n  right: 0;\n  top: 0;\n  z-index: ", ";\n"], ["\n  align-items: ", ";\n  background-color: ",
    ";\n  bottom: 0;\n  display: flex;\n  justify-content: center;\n  left: 0;\n  padding: ", ";\n  position: fixed;\n  overflow: auto;\n  right: 0;\n  top: 0;\n  z-index: ", ";\n"])), function (props) { return (props.solidBackground ? "flex-start" : "center"); }, function (props) {
    return props.solidBackground ? styleConstants_1.colors.basic.WHITE : "rgba(0, 0, 0, 0.4)";
}, function (props) { return (props.solidBackground ? "90px 0" : "0"); }, function (props) { return (props.solidBackground ? "9999999" : "2"); });
exports.ModalInner = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  align-items: ", ";\n  background-color: ", ";\n  border: ", ";\n  display: flex;\n  flex-direction: column;\n  font-family: ", ";\n  justify-content: space-around;\n  margin: auto;\n  min-width: 250px;\n  ", ";\n"], ["\n  align-items: ", ";\n  background-color: ", ";\n  border: ", ";\n  display: flex;\n  flex-direction: column;\n  font-family: ", ";\n  justify-content: space-around;\n  margin: auto;\n  min-width: 250px;\n  ", ";\n"])), function (props) { return (props.solidBackground ? "flex-start" : "center"); }, styleConstants_1.colors.basic.WHITE, function (props) { return (props.solidBackground ? "none" : "1px solid " + styleConstants_1.colors.accent.CIVIL_GRAY_4); }, styleConstants_1.fonts.SANS_SERIF, function (props) { return (props.solidBackground ? "width: 100%" : ""); });
var FullScreenModal = /** @class */ (function (_super) {
    __extends(FullScreenModal, _super);
    function FullScreenModal(props) {
        var _this = _super.call(this, props) || this;
        _this.state = {};
        if (typeof document !== "undefined") {
            _this.el = document.createElement("div");
        }
        _this.handleClickOutside = _this.handleClickOutside.bind(_this);
        return _this;
    }
    FullScreenModal.prototype.componentDidMount = function () {
        var _this = this;
        if (this.el) {
            document.body.appendChild(this.el);
            if (this.props.dismissOnOutsideClick) {
                document.addEventListener("mousedown", function (ev) { return _this.handleClickOutside(ev); });
            }
        }
    };
    FullScreenModal.prototype.componentWillUnmount = function () {
        var _this = this;
        if (this.el) {
            document.body.removeChild(this.el);
            document.removeEventListener("mousedown", function (ev) { return _this.handleClickOutside(ev); });
        }
    };
    FullScreenModal.prototype.render = function () {
        if (!this.props.open || this.el === undefined) {
            return null;
        }
        return ReactDom.createPortal(React.createElement(exports.ModalWrapper, { solidBackground: this.props.solidBackground },
            React.createElement(exports.ModalInner, { solidBackground: this.props.solidBackground }, this.props.children)), this.el);
    };
    FullScreenModal.prototype.handleClickOutside = function (event) {
        if (this.el &&
            this.el.children[0] &&
            this.el.children[0].children[0] &&
            !this.el.children[0].children[0].contains(event.target)) {
            this.close();
        }
    };
    FullScreenModal.prototype.close = function () {
        if (this.props.handleClose) {
            this.props.handleClose();
        }
    };
    return FullScreenModal;
}(React.Component));
exports.FullScreenModal = FullScreenModal;
var templateObject_1, templateObject_2;
//# sourceMappingURL=FullscreenModal.js.map