import { useFocus as V } from "../../../../../@react-aria_interactions@3.27.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@react-aria/interactions/dist/useFocus.js";
import { isFocusVisible as r, useFocusVisibleListener as h } from "../../../../../@react-aria_interactions@3.27.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@react-aria/interactions/dist/useFocusVisible.js";
import { useFocusWithin as x } from "../../../../../@react-aria_interactions@3.27.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@react-aria/interactions/dist/useFocusWithin.js";
import { useRef as m, useState as a, useCallback as f } from "react";
function I(n = {}) {
  let { autoFocus: b = !1, isTextInput: u, within: i } = n, s = m({
    isFocused: !1,
    isFocusVisible: b || r()
  }), [o, l] = a(!1), [d, F] = a(() => s.current.isFocused && s.current.isFocusVisible), t = f(() => F(s.current.isFocused && s.current.isFocusVisible), []), c = f((e) => {
    s.current.isFocused = e, s.current.isFocusVisible = r(), l(e), t();
  }, [
    t
  ]);
  h((e) => {
    s.current.isFocusVisible = e, t();
  }, [
    u,
    o
  ], {
    enabled: o,
    isTextInput: u
  });
  let { focusProps: p } = V({
    isDisabled: i,
    onFocusChange: c
  }), { focusWithinProps: $ } = x({
    isDisabled: !i,
    onFocusWithinChange: c
  });
  return {
    isFocused: o,
    isFocusVisible: d,
    focusProps: i ? $ : p
  };
}
export {
  I as useFocusRing
};
