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

/**
 * State accessible to `<Checkbox.Indicator>` (and any future checkbox parts).
 *
 * Mirrors React's `CheckboxRootState` but exposed as `Accessor<T>` fields so
 * descendants can read each slot lazily — matches the tier-1 compound
 * convention used by `<Progress.Root>` / `<Avatar.Root>`, and honours the
 * no-top-level-reactive-reads rule from Solid 2 RFC 01.
 *
 * `state` is a composite accessor handed to `renderElement` for the `data-*`
 * projection; individual accessors (`checked`, `indeterminate`, …) are the
 * read surface for `<Checkbox.Indicator>` so it doesn't need to destructure
 * `state()` at the top of its body.
 */

/**
 * Full checkbox state: field-root state merged with checkbox-specific flags.
 *
 * The order of the extension matters only for clarity — `data-disabled` is
 * sourced from `disabled`, and `checked` / `indeterminate` drive the
 * checkbox-specific `data-checked` / `data-unchecked` / `data-indeterminate`
 * triplet via the custom state-attributes mapping.
 */

/**
 * Checkbox 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 CheckboxRootContext = createContext(null);

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