/**
 * Solid 2 port of Base UI React's `NavigationMenuRootContext`
 * (`packages/react/src/navigation-menu/root/NavigationMenuRootContext.ts`).
 *
 * Thread the navigation-menu root's reactive state + mutable slots to every
 * descendant part. Every reactive field is exposed as an accessor (no bare
 * values) so consumers don't need to unwrap signals.
 *
 * `createContext<T | null>(null)` + `== null` sentinel — the
 * nested `<NavigationMenu.Root>` branch checks the parent context before
 * wrapping in a second `FloatingTree`, so the context must tolerate being
 * read from above a provider.
 */
import { createContext, useContext } from "solid-js";

/**
 * Shared slot between triggers for canceling a stale popup auto-size reset.
 * Mutable — React uses a `useRef`; Solid uses a plain object carried on
 * context. The `owner` key is the item value that scheduled the reset, so a
 * newly-active trigger can detect whether it "owns" the abort controller
 * before clobbering it.
 */

/**
 * Direction of activation — set when a new trigger takes over from the
 * previously active one. Used by the content panel to choose an enter
 * direction for its animation.
 */

/**
 * Change-event reason union for `NavigationMenu.Root`. Ported 1:1 from
 * React's `NavigationMenuRootChangeEventReason`.
 */

export const NavigationMenuRootContext = createContext(null);
export function useNavigationMenuRootContext(optional) {
  const value = useContext(NavigationMenuRootContext);
  if (value == null && !optional) {
    throw new Error("Base UI: NavigationMenuRootContext is missing. Navigation Menu parts must be placed within <NavigationMenu.Root>.");
  }
  return value;
}

/**
 * Tree-scope context — carries the `FloatingTree` node id the current root
 * registered itself under. Nested menus read it so `isOutsideMenuEvent` can
 * consult child-node floatings.
 *
 * `null` sentinel because top-level roots may be mounted without a parent
 * `FloatingTree` (first-mount path wraps itself).
 */
export const NavigationMenuTreeContext = createContext(null);
export function useNavigationMenuTreeContext() {
  const v = useContext(NavigationMenuTreeContext);
  return v ?? undefined;
}
//# sourceMappingURL=navigation-menu-root-context.jsx.map
