/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
import { createContext, useContext } from "react";
import { jsx } from "react/jsx-runtime";
//#region src/components/client/Tooltip/UDSTooltipConfigProvider.tsx
const TooltipContext = createContext(void 0);
const UDSTooltipConfigProvider = ({ children, value }) => {
	const existingContext = useContext(TooltipContext);
	if ("type" in value) {
		if (!existingContext) throw new Error("Cannot merge context values without an existing TooltipContext");
		return /* @__PURE__ */ jsx(TooltipContext.Provider, {
			value: {
				...existingContext,
				...value.value
			},
			children
		});
	}
	return /* @__PURE__ */ jsx(TooltipContext.Provider, {
		value,
		children
	});
};
UDSTooltipConfigProvider.displayName = "UDSTooltipConfigProvider";
function useTooltipConfig(options) {
	const context = useContext(TooltipContext);
	if (!context) throw new Error("useTooltipConfig must be used within a UDSConfigProvider or UDSTooltipConfigProvider");
	const { placementMap, placement, ...contextRest } = context;
	return {
		...contextRest,
		ariaKitPlacement: placementMap[options?.placement ?? placement]
	};
}
//#endregion
export { UDSTooltipConfigProvider, useTooltipConfig };
