import React, { createContext, useCallback, useContext, useMemo, useState, } from 'react';
const UIStateContext = createContext(undefined);
// Existing hook that builds the UI state (kept to separate creation from context)
function useUIState() {
    const [showClearMessage, setShowClearMessage] = useState(false);
    const [showCompletions, setShowCompletions] = useState(false);
    const [completions, setCompletions] = useState([]);
    const resetUIState = useCallback(() => {
        setShowClearMessage(false);
        setShowCompletions(false);
        setCompletions([]);
    }, []);
    return useMemo(() => ({
        showClearMessage,
        showCompletions,
        completions,
        setShowClearMessage,
        setShowCompletions,
        setCompletions,
        resetUIState,
    }), [showClearMessage, showCompletions, completions, resetUIState]);
}
// Provider to expose a single shared UI state instance to the subtree
export function UIStateProvider({ children }) {
    const state = useUIState();
    return React.createElement(UIStateContext.Provider, { value: state }, children);
}
// Hook to consume the shared UI state from context (preferred for consumers)
export function useUIStateContext() {
    const ctx = useContext(UIStateContext);
    if (!ctx) {
        throw new Error('useUIStateContext must be used within a UIStateProvider');
    }
    return ctx;
}
//# sourceMappingURL=useUIState.js.map