"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const Context_1 = require("../../Context");
const react_1 = tslib_1.__importDefault(require("react"));
const utils_1 = require("../../utils");
/**
 * 🔀 Navigation
 *
 * This is a stub router. Intended to be replaced by an external router plugin.
 */
// export const Navigation = ({ component: Component }: NavigationProps) => (<Component />);
class Navigation extends react_1.default.PureComponent {
    render() {
        const BB = this.context;
        const routes = utils_1.resolveThunk(this.props.navigator.routes, BB) || [];
        const route = routes[0];
        if (!route) {
            return null;
        }
        if (route.screen) {
            const Component = (typeof route.screen === 'string')
                ? BB.Components.resolve(route.screen)
                : route.screen;
            return react_1.default.createElement(Component, { key: route.name });
        }
        if (route.navigator) {
            return react_1.default.createElement(Navigation, { navigator: route.navigator });
        }
        return null;
    }
}
Navigation.contextType = Context_1.BlueBaseContext;
exports.Navigation = Navigation;
