import { createContext, useContext } from "solid-js";

/**
 * Change-reason union for `Popover.Root`. Mirrors Base UI React's
 * `PopoverRootChangeEventReason`. The Solid port omits reasons that depend on
 * behaviors not yet ported (hover, focus-based open, imperative-action via
 * `actionsRef`); those are listed as a comment on `<Popover.Root>`.
 */

/**
 * Modal surface kind. Mirrors Base UI React's `modal` prop union. `true`
 * traps focus AND locks scroll / blocks outside pointer input via the
 * internal backdrop; `'trap-focus'` traps focus only; `false` does neither.
 */

/**
 * Shared state / handles surfaced through the Popover root context. Every
 * reactive field is exposed as an `Accessor<T>` so consumers don't need to
 * guard reactive reads.
 */

/**
 * Context for the Popover compound components. `null` is the default so
 * `usePopoverRootContext(true)` can be called from above a provider (e.g.
 * the `<Popover.Root>` wrapper's `FloatingTree` gate) without triggering
 * Solid 2's `ContextNotFoundError`.
 */
export const PopoverRootContext = createContext(null);

/**
 * Read the current `<Popover.Root>` context. Throws unless `optional` is
 * `true`. Matches Base UI React's `usePopoverRootContext` overload shape.
 */

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