import { jsx as _jsx } from "react/jsx-runtime";
import { createElement as _createElement } from "react";
import { IS_BROWSER } from '@redocly/theme/core/openapi';
import { useRouter } from '../hooks/index.js';
import { getDisplayName } from './utils.js';
export function withRouter(WrappedComponent) {
    const WithRouter = ({ disableRouter = false, ...props }) => {
        const basePath = props.basePath ?? '/';
        const routerType = props.router ?? 'history';
        const { Router, routerProps } = useRouter(routerType, basePath);
        return IS_BROWSER && !disableRouter ? (_createElement(Router, { ...routerProps, key: basePath },
            _jsx(WrappedComponent, { ...props }))) : (_jsx(WrappedComponent, { ...props }));
    };
    WithRouter.displayName = `WithRouter(${getDisplayName(WrappedComponent)})`;
    return WithRouter;
}
//# sourceMappingURL=withRouter.js.map