import { getContainerInfoFromElement } from "../elements/ContainerInfo.js";

//#region src/gui/FitScaleHelpers.ts
/**
* Determines if an element needs FitScale wrapping based on its parent container
* and whether it has explicit size.
*
* FitScale is needed when:
* - Parent is a grid container (grid or flex display)
* - Element doesn't have explicit width/height
*
* @param parentElement - The parent element (can be HTMLElement or null)
* @param elementHasExplicitSize - Whether the element has explicit width/height
* @returns true if FitScale should be applied
*
* @public
*/
function needsFitScale(parentElement, elementHasExplicitSize) {
	if (!parentElement) return false;
	const containerInfo = getContainerInfoFromElement(parentElement);
	return (containerInfo.displayMode === "grid" || containerInfo.displayMode === "flex") && !elementHasExplicitSize;
}
/**
* Determines if an element needs FitScale wrapping by checking computed styles.
* This is a convenience function that reads the element's computed style to check
* for explicit size.
*
* @param element - The element to check
* @param parentElement - The parent element (can be HTMLElement or null)
* @returns true if FitScale should be applied
*
* @public
*/
function elementNeedsFitScale(element, parentElement) {
	const computedStyle = window.getComputedStyle(element);
	return needsFitScale(parentElement, !!(computedStyle.width && computedStyle.width !== "auto") || !!(computedStyle.height && computedStyle.height !== "auto"));
}

//#endregion
export { elementNeedsFitScale, needsFitScale };
//# sourceMappingURL=FitScaleHelpers.js.map