import { useCallback as m, useEffect as c } from "react";
import { useHandleKeyDown as a } from "../../../hooks/useHandleKeyDown.js";
import { LIST_CONTAINER_ID as n } from "../constants.js";
const E = ({
  initialFocusedIndex: r,
  listRef: s,
  isEnabled: l,
  onFocus: i,
  onBlur: o
}) => {
  a(
    "ArrowDown",
    () => {
      const e = document.getElementById(n);
      e && document.activeElement !== e && (i(r), s?.scrollToIndex(r, { align: "nearest" }), setTimeout(() => {
        e.focus({ preventScroll: !0 });
      }, 0));
    },
    [],
    { enabled: l }
  );
  const t = m(
    (e) => {
      const u = document.getElementById(n);
      e.target === u && o();
    },
    [o]
  );
  c(() => {
    const e = document.getElementById(n);
    return e?.addEventListener("blur", t), () => {
      e?.removeEventListener("blur", t);
    };
  }, [t]);
};
export {
  E as useFocusOnList
};
//# sourceMappingURL=useFocusOnList.js.map
