/**
 * Suggestions Context
 *
 * Type definitions and React context for composable suggestions primitives.
 * Consuming components use useSuggestionsContext() for state and actions.
 */
import { createContext, useContext } from "react";
import { log } from "@seekora-ai/ui-sdk-core";
export const SuggestionsContext = createContext(null);
/**
 * Safe noop fallback returned when no SuggestionsProvider is mounted.
 * Mirrors the pattern in SearchProvider.__buildNoopContext — never throw,
 * silently degrade so standalone usage does not crash the React tree.
 * Logged once to aid debugging (not thrown).
 */
let __noopSuggestionsContext = null;
const __buildNoopSuggestionsContext = () => {
    if (__noopSuggestionsContext)
        return __noopSuggestionsContext;
    const noop = (..._args) => undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
    __noopSuggestionsContext = {
        query: "",
        setQuery: noop,
        isOpen: false,
        setIsOpen: noop,
        activeIndex: -1,
        setActiveIndex: noop,
        suggestions: [],
        recentSearches: [],
        trendingSearches: [],
        trendingProducts: [],
        prefetchedProducts: [],
        filteredTabs: [],
        activeTabId: "",
        setActiveTabId: noop,
        loading: false,
        error: null,
        hasContent: false,
        getAllNavigableItems: () => [],
        selectSuggestion: noop,
        selectProduct: noop,
        selectRecentSearch: noop,
        selectTrendingSearch: noop,
        setActiveTab: noop,
        submitSearch: noop,
        clearRecentSearches: noop,
        close: noop,
        navigateNext: noop,
        navigatePrev: noop,
        selectActive: noop,
    };
    return __noopSuggestionsContext;
};
export function useSuggestionsContext() {
    const context = useContext(SuggestionsContext);
    if (!context) {
        log.warn("SuggestionsContext: no provider — using no-op fallback (component will render empty)");
        return __buildNoopSuggestionsContext();
    }
    return context;
}
