import * as r from "react";
import { useMergedRefs as p } from "../../../../../../../@base-ui_utils@0.2.4_@types_react@18.3.27_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useMergedRefs.js";
import { useCompositeRootContext as h } from "../root/CompositeRootContext.js";
import { useCompositeListItem as g } from "../list/useCompositeListItem.js";
function I(m = {}) {
  const {
    highlightItemOnHover: s,
    highlightedIndex: c,
    onHighlightedIndexChange: i
  } = h(), {
    ref: u,
    index: e
  } = g(m), t = c === e, n = r.useRef(null), d = p(u, n);
  return {
    compositeProps: r.useMemo(() => ({
      tabIndex: t ? 0 : -1,
      onFocus() {
        i(e);
      },
      onMouseMove() {
        const o = n.current;
        if (!s || !o)
          return;
        const f = o.hasAttribute("disabled") || o.ariaDisabled === "true";
        !t && !f && o.focus();
      }
    }), [t, i, e, s]),
    compositeRef: d,
    index: e
  };
}
export {
  I as useCompositeItem
};
