"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@bluebase/core");
const react_1 = tslib_1.__importDefault(require("react"));
const index_1 = require("../../lib/index");
const preparePaths_1 = require("./preparePaths");
const renderNavigator_1 = require("../../helpers/renderNavigator");
/**
 * Navigation
 * This serves as an entry point where BlueBase passes routes and navigation
 * configs to this component.
 */
class Navigation extends react_1.default.Component {
    render() {
        const _a = this.props, { navigator } = _a, rest = tslib_1.__rest(_a, ["navigator"]);
        const BB = this.context;
        // Make sure paths are in correct format.
        const navigatorObject = preparePaths_1.preparePaths(navigator);
        // Save the resolved tree in configs to use later
        BB.Configs.setValue('plugin.react-router.navigationConfigs', navigatorObject);
        return (react_1.default.createElement(index_1.Router, Object.assign({}, rest), renderNavigator_1.renderNavigator(navigatorObject, BB)));
    }
}
Navigation.contextType = core_1.BlueBaseContext;
exports.Navigation = Navigation;
