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

/**
 * The full state shape exposed by `<Radio.Root>` to its children. Mirrors
 * React's `RadioRootState` (see
 * `packages/react/src/radio/root/RadioRoot.tsx` — the inline `RadioRootState`
 * interface extends `FieldRootState`).
 *
 * `checked`, `disabled`, `readOnly` and `required` are the radio-specific
 * slots. The remainder (`valid`, `touched`, `dirty`, `filled`, `focused`) are
 * inherited from the surrounding `<Field.Root>` when one exists — they flow
 * through `data-*` projection and the `render` / `class` / `style` callbacks.
 */

/**
 * The context value consumed by `<Radio.Indicator>`. Every reactive slot is
 * exposed as an `Accessor<T>` so descendants pull the latest value on demand
 * and don't trip the top-level reactive read rule (RFC 01).
 *
 * Shape diverges from the React port: React stores a plain object + dispatches
 * via re-render. Solid's no-top-level-reactive-reads rule means we need a
 * live accessor for each field so `<Radio.Indicator>`'s render body (which
 * reads `checked` inside JSX to decide whether to emit the span) stays
 * reactive without a memo ping-pong.
 */

/**
 * Radio root context. `createContext<T | null>(null)` + `== null` sentinel
 * — Solid 2's `useContext` throws `ContextNotFoundError` when
 * the default is `undefined`, which would shadow the intended Base UI error
 * message below.
 */
export const RadioRootContext = createContext(null);

/**
 * Read the `<Radio.Root>` context. Throws a descriptive error if the caller
 * forgot to wrap their subtree in `<Radio.Root>` — matches Base UI React's
 * `useRadioRootContext`.
 */
export function useRadioRootContext() {
  const context = useContext(RadioRootContext);
  if (context == null) {
    throw new Error("Base UI: RadioRootContext is missing. Radio parts must be placed within <Radio.Root>.");
  }
  return context;
}
//# sourceMappingURL=radio-root-context.jsx.map
