"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importStar(require("react"));
const core_1 = require("@bluebase/core");
const helpers_1 = require("../../helpers");
exports.MainNavigatorContext = react_1.createContext({ routes: [] });
/**
 * Navigation
 * This serves as an entry point where BlueBase passes routes and navigation
 * configs to this component.
 */
exports.Navigation = (props) => {
    const { Router, navigator } = props, rest = tslib_1.__rest(props, ["Router", "navigator"]);
    const Navigator = core_1.useComponent('Navigator');
    const [routerProps] = core_1.useConfig('plugin.react-router.router-props');
    // Make sure paths are in correct format.
    const navigatorObject = helpers_1.preparePaths(navigator);
    return (react_1.default.createElement(exports.MainNavigatorContext.Provider, { value: navigatorObject },
        react_1.default.createElement(Router, Object.assign({}, rest, routerProps),
            react_1.default.createElement(Navigator, Object.assign({}, navigatorObject)))));
};
