/**
 * Context plumbing for `<ContextMenu.Root>` → `<Menu.Root>` and
 * `<ContextMenu.Trigger>`. Mirrors React's
 * `packages/react/src/context-menu/root/ContextMenuRootContext.ts`.
 *
 * The ContextMenu compound is a thin wrapper around `<Menu.Root>`: it
 * captures a `(clientX, clientY)` point on `contextmenu` (or long press),
 * threads a virtual anchor into the inner menu's floating-root context,
 * and calls `setOpen(true, …)` via an `actionsRef` populated by
 * `<Menu.Root>` once it detects the outer context-menu.
 *
 * Null-sentinel context (solidify P5) — `<ContextMenu.Trigger>`
 * requires the provider, but `<Menu.Root>` optionally reads it to detect
 * the context-menu interop path and tolerates `null`.
 */
import { createContext, useContext } from "solid-js";

/**
 * A virtual anchor element Floating UI can position against. Mirrors React's
 * `ContextMenuRootContext['anchor']` shape.
 */

export const ContextMenuRootContext = createContext(null);
export function useContextMenuRootContext(optional) {
  const ctx = useContext(ContextMenuRootContext);
  if (ctx == null && !optional) {
    throw new Error("Base UI: ContextMenuRootContext is missing. ContextMenu parts must be placed within <ContextMenu.Root>.");
  }
  return ctx;
}
//# sourceMappingURL=context-menu-root-context.jsx.map
