import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useCallback, useEffect, useState } from 'react';
import { useAppContext } from '../hooks';
export const AppContext = createContext({});
export function AppContextProvider({ children, ...contextProps }) {
    const [context, setContextState] = useState(contextProps || null);
    const setContext = useCallback((context) => {
        setContextState((currentContext) => ({
            ...currentContext,
            ...context,
            playgroundContext: {
                ...currentContext?.playgroundContext,
                ...context?.playgroundContext,
            }
        }));
    }, []);
    return (_jsx(AppContext.Provider, { value: {
            apiUrl: null,
            schemaVersion: 0,
            ready: false,
            ...context,
            token: context?.token || null,
            playgroundContext: context?.playgroundContext || {},
            setContext
        }, children: children }));
}
export function AppContextConsumer({ onReady }) {
    const context = useAppContext();
    useEffect(() => {
        onReady(context);
    }, [context]);
    return null;
}
//# sourceMappingURL=AppContext.js.map