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 __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import React from 'react';
import { Popup } from '../components/consentPopup';
/** Create a popup when there is no existing consent event */
export var makeConsentPopup = function (Component) { return /** @class */ (function (_super) {
    __extends(class_1, _super);
    function class_1() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.state = {
            show: false
        };
        _this._isMounted = false;
        return _this;
    }
    class_1.prototype.componentWillMount = function () {
        this.setState({ show: this.props.show });
    };
    class_1.prototype.componentWillReceiveProps = function (props) {
        this.setState({ show: props.show });
    };
    class_1.prototype.componentDidMount = function () {
        this._isMounted = true;
    };
    class_1.prototype.componentWillUnmount = function () {
        this._isMounted = false;
    };
    class_1.prototype.render = function () {
        var _this = this;
        /** We need to pre-load the component, so we cannot have it behind a conditional */
        return React.createElement(Popup, { preload: true, show: this.state.show, onClose: function () {
                if (!_this._isMounted)
                    return;
                _this.setState({ show: false });
                _this.props.onClose && _this.props.onClose();
            } },
            React.createElement(Component, __assign({}, this.props)));
    };
    return class_1;
}(React.Component)); };
//# sourceMappingURL=makePopup.js.map