import { jsx as _jsx } from "react/jsx-runtime";
import { useContext } from 'react';
import { ThemeProvider } from 'styled-components';
import { ThemeMachine } from '../../theme';
import { windowIsAvailable } from '../../utils';
import { ConfigurationContext } from './Configuration';
const ThemeOverride = ({ children, theme }) => {
    const context = windowIsAvailable
        ? window.cosmos.configurationContext ?? ConfigurationContext
        : ConfigurationContext;
    const ctx = useContext(context);
    const themeMachine = new ThemeMachine({
        theme,
        parent: ctx.themeMachine
    });
    return (_jsx(context.Provider
    // eslint-disable-next-line react/jsx-no-constructed-context-values
    , { 
        // eslint-disable-next-line react/jsx-no-constructed-context-values
        value: { ...ctx, themeMachine }, children: _jsx(ThemeProvider, { theme: themeMachine.theme, children: children }) }));
};
export default ThemeOverride;
//# sourceMappingURL=ThemeOverride.js.map