"use client";
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
//#region src/components/client/Menu/utils/transformAriakitPlacement.ts
/**
* Maps directionally-agnostic placement values to Ariakit LTR values
* - Converts 'start' to 'left' and 'end' to 'right' (with RTL support)
* - Examples:
*   - 'start' -> 'left' (or 'right' in RTL)
*   - 'end' -> 'right' (or 'left' in RTL)
*   - 'top-start' -> 'top-left' (or 'top-right' in RTL)
*   - 'bottom-end' -> 'bottom-right' (or 'bottom-left' in RTL)
*   - 'start-top' -> 'left-top' (or 'right-top' in RTL)
*   - 'end-bottom' -> 'right-bottom' (or 'left-bottom' in RTL)
*
* The function handles:
* - Simple placements (start/end)
* - Vertical-horizontal combinations (top-start, bottom-end, etc.)
* - Horizontal-vertical combinations (start-top, end-bottom, etc.)
* - RTL/LTR directionality
* - Undefined placements and options
*/
const transformAriakitPlacement = (placement, options) => {
	const isRtl = options?.rtl;
	if (placement === "start") return isRtl ? "right" : "left";
	if (placement === "end") return isRtl ? "left" : "right";
	if (placement?.includes("-")) {
		const [first, second] = placement.split("-");
		if (first === "start" || first === "end") {
			const horizontal = first === "start" ? isRtl ? "right" : "left" : isRtl ? "left" : "right";
			if (second === "top" || second === "bottom") return `${horizontal}-${second === "bottom" ? "end" : "start"}`;
		}
		if (first === "top" || first === "bottom") return `${first}-${second === "start" ? isRtl ? "end" : "start" : isRtl ? "start" : "end"}`;
	}
	return placement;
};

//#endregion
export { transformAriakitPlacement };