"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};
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 ModalContext_1 = __importDefault(require("./ModalContext"));
var ModalProvider = function (_a) {
    var children = _a.children;
    var _b = React.useState([]), windows = _b[0], setWindows = _b[1];
    var _c = React.useState(), activeWindow = _c[0], setActiveWindow = _c[1];
    var addWindows = function (window) {
        return setWindows(function (state) { return __spreadArrays(state, [window]); });
    };
    var removeWindows = function (title) {
        return setWindows(function (state) { return state.filter(function (w) { return w.title !== title; }); });
    };
    return (React.createElement(ModalContext_1.default.Provider, { value: {
            windows: windows,
            addWindows: addWindows,
            removeWindows: removeWindows,
            setActiveWindow: setActiveWindow,
            activeWindow: activeWindow,
        } }, children));
};
exports.default = ModalProvider;
//# sourceMappingURL=ModalProvider.js.map