import { useRef as u, useCallback as i, useEffect as l } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { InteractionKeyCode as f } from "../../types.js";
import m from "../../../hooks/useBooleanState.js";
const y = () => {
  const [c, t] = m(), o = u(), r = u(() => {
    o.current && clearTimeout(o.current), o.current = void 0;
  }).current, e = i(() => {
    r(), t(!1);
  }, [r, t]), n = i(() => {
    o.current ??= setTimeout(() => {
      o.current = setTimeout(e, 15e3), t(!0);
    }, 500);
  }, [e, t]), a = i(
    (s) => {
      s.code === f.ESCAPE && (s.preventDefault(), s.stopPropagation(), e());
    },
    [e]
  );
  return l(() => e, [e]), {
    listeners: {
      onfocusin: n,
      onfocusout: e,
      onMouseEnter: n,
      onMouseLeave: e,
      onKeyDown: a
    },
    isVisible: c
  };
};
export {
  y as useTooltipListeners
};
