import { Hint } from "./Hint";
import { jsx as _jsx } from "preact/compat/jsx-runtime";
/**
 * Hook that takes the props for a form field component, extracts the props relevant
 * to the Hint, and conditionally renders the hint if it is needed.
 */
export function useHint(props) {
  const {
    hint,
    inversed,
    requirementLabel
  } = props;
  let hintElement;
  let hintId;
  if (hint || requirementLabel) {
    hintId = props.hintId ?? `${props.id}__hint`;
    hintElement = /*#__PURE__*/_jsx(Hint, {
      requirementLabel: requirementLabel,
      inversed: inversed,
      id: hintId,
      children: hint
    });
  }
  return {
    hintId,
    hintElement
  };
}