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

/**
 * Per-item metadata carried alongside a `<Toolbar.Button>` or `<Toolbar.Link>`
 * registration. `focusableWhenDisabled` is the only field — it drives the
 * `disabledIndices` projection on the composite root so arrow navigation can
 * skip items that cannot take focus.
 */

/**
 * Value handed down by `<Toolbar.Root>` to descendant parts.
 *
 * Solid 2 adaptations from Base UI React's `ToolbarRootContext`:
 *
 * - Reactive slots are `Accessor<T>` so children pull on demand without
 *   tripping the top-level-reactive-read rule.
 * - `present` is `true` only when provided by a real `<Toolbar.Root>`.
 *   Parts branch on it — `<Toolbar.Separator>` tolerates being rendered
 *   outside, and `<Toolbar.Button>` / `<Toolbar.Link>` throw (matching React).
 *
 * Note: React's `setItemMap` does NOT appear here. Each item already reports
 * its metadata via `useCompositeListItem({ metadata })`; the root captures the
 * sorted map from `<CompositeList onMapChange>` and derives `disabledIndices`
 * directly. See the header comment in `toolbar-root.tsx`.
 */

/**
 * No-op sentinel used when parts are rendered outside a `<Toolbar.Root>`.
 * Children branch on `.present` to decide whether to throw.
 */
export const NOOP_TOOLBAR_ROOT_CONTEXT = {
  disabled: () => false,
  orientation: () => "horizontal",
  present: false
};
export const ToolbarRootContext = createContext(NOOP_TOOLBAR_ROOT_CONTEXT);
export function useToolbarRootContext(optional = false) {
  const context = useContext(ToolbarRootContext);
  if (!context.present && !optional) {
    throw new Error("Base UI: ToolbarRootContext is missing. Toolbar parts must be placed within <Toolbar.Root>.");
  }
  return context;
}
//# sourceMappingURL=toolbar-root-context.jsx.map
