"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlyoutRegionContainer = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var flyout_region_1 = require("../components/flyout-region");
var command_1 = require("../api/registry/command");
var hooks_1 = require("./hooks");
var flyout_1 = require("../actions/flyout");
var map_1 = require("../actions/map");
var context_1 = require("../components/map-providers/context");
var FlyoutRegionContainer = function () {
    var dispatch = (0, context_1.useReduxDispatch)();
    var closeFlyoutAction = function (id) { return dispatch((0, flyout_1.closeFlyout)(id)); };
    var invokeCommandAction = function (cmd, parameters) { return dispatch((0, map_1.invokeCommand)(cmd, parameters)); };
    var onCloseFlyout = function (id) { return closeFlyoutAction(id); };
    var flyouts = (0, hooks_1.useViewerFlyouts)();
    var locale = (0, hooks_1.useViewerLocale)();
    var tbState = (0, hooks_1.useReducedToolbarAppState)();
    var prepared = {};
    if (invokeCommandAction) {
        for (var flyoutId in flyouts) {
            var tb = flyouts[flyoutId];
            if (typeof (tb.componentName) == 'undefined') {
                prepared[flyoutId] = (0, command_1.mapToolbarReference)(tb, tbState, invokeCommandAction);
                prepared[flyoutId].open = !!flyouts[flyoutId].open;
                prepared[flyoutId].metrics = flyouts[flyoutId].metrics;
            }
            else {
                prepared[flyoutId] = flyouts[flyoutId];
            }
        }
    }
    return React.createElement(flyout_region_1.FlyoutRegion, { flyoutConf: prepared, onCloseFlyout: onCloseFlyout, locale: locale });
};
exports.FlyoutRegionContainer = FlyoutRegionContainer;
//# sourceMappingURL=flyout-region.js.map