'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useMemo } from 'react';
import { useAllTurnStatuses } from './use-turn-statuses.js';
const TurnStatusesContext = createContext({
    getStatus: () => 'idle',
});
/**
 * Polls ALL active turn statuses in a single API call (no IDs needed).
 * Children use `useTurnStatus(scopeId)` to read individual statuses.
 */
export function TurnStatusesProvider({ children }) {
    const statuses = useAllTurnStatuses();
    const value = useMemo(() => ({
        getStatus: (scopeId) => statuses[scopeId] ?? 'idle',
    }), [statuses]);
    return _jsx(TurnStatusesContext.Provider, { value: value, children: children });
}
/**
 * Get the turn status for a specific scope ID.
 * Must be used within a TurnStatusesProvider.
 */
export function useTurnStatus(scopeId) {
    const ctx = useContext(TurnStatusesContext);
    return ctx.getStatus(scopeId);
}
