import { t as DictionaryTrigger_default } from "../../DictionaryTrigger.js";
import { a as useDismiss, c as useHover, l as useInteractions, n as FloatingDelayGroup, o as useFloating, s as useFocus } from "../../floating-ui.react.js";
import { t as PopOver_default } from "../../PopOver.js";
import { useId, useRef, useState } from "react";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
const HelpTooltip = ({ children, description, testId }) => {
	const popoverId = useId();
	const [showTooltip, setShowTooltip] = useState(false);
	const wordRef = useRef(null);
	const { refs, context } = useFloating({
		open: showTooltip,
		elements: { reference: wordRef.current },
		onOpenChange: setShowTooltip
	});
	const { getReferenceProps } = useInteractions([
		useHover(context, { move: false }),
		useFocus(context),
		useDismiss(context)
	]);
	return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DictionaryTrigger_default, {
		ref: wordRef,
		...getReferenceProps(),
		selected: showTooltip,
		"aria-describedby": popoverId,
		"data-testid": testId,
		children
	}), /* @__PURE__ */ jsx(PopOver_default, {
		role: "tooltip",
		ref: refs.setFloating,
		id: popoverId,
		show: showTooltip,
		testId,
		controllerRef: wordRef,
		children: description
	})] });
};
const HelpTooltipDelayGroup = FloatingDelayGroup;
var HelpTooltip_default = HelpTooltip;
export { HelpTooltip, HelpTooltipDelayGroup, HelpTooltip_default as default };

//# sourceMappingURL=index.js.map