"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const React = __importStar(require("react"));
// create empty context as default
const RoutesContext = React.createContext({});
/**
 * This HOC attaches the Routes of a SinglePageApp or a WebApp
 */
const AttachRoutes = (props) => {
    return React.createElement(RoutesContext.Provider, { value: {
            routes: props.routes
        } }, props.children);
};
/**
 * @param Component
 * @returns {function(any): any}
 */
function withRoutes(Component) {
    return function WrapperComponent(props) {
        return (React.createElement(RoutesContext.Consumer, null, (context) => {
            return React.createElement(Component, Object.assign({}, props, { routes: context.routes }));
        }));
    };
}
exports.withRoutes = withRoutes;
exports.default = AttachRoutes;
//# sourceMappingURL=attach-routes.js.map