/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-b04eed0 | Cube Dev Team */
import { _Tooltip } from "./Tooltip.js";
import { TooltipTrigger } from "./TooltipTrigger.js";
import { isValidElement, useEffect, useState } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";

//#region src/components/overlays/Tooltip/TooltipProvider.tsx
function TooltipProvider(props) {
	const [rendered, setRendered] = useState(false);
	const { title, children, tooltipStyles, width, isDisabled, ...otherProps } = props;
	useEffect(() => {
		setRendered(true);
	}, []);
	const isFunction = typeof children === "function";
	if (!rendered) return /* @__PURE__ */ jsx(Fragment$1, { children: isFunction ? children({}, { current: null }) : children });
	return /* @__PURE__ */ jsxs(TooltipTrigger, {
		...otherProps,
		isDisabled,
		disableFocusableProvider: isFunction,
		children: [isFunction || isValidElement(children) || typeof children === "string" ? children : /* @__PURE__ */ jsx(Fragment$1, { children }), isDisabled ? /* @__PURE__ */ jsx("div", {}) : /* @__PURE__ */ jsx(_Tooltip, {
			styles: tooltipStyles,
			...width ? { width } : null,
			children: title
		})]
	});
}

//#endregion
export { TooltipProvider };
//# sourceMappingURL=TooltipProvider.js.map