/**
 * DevExtreme (esm/__internal/ui/overlay/m_utils.js)
 * Version: 24.1.7-build-24272-1937
 * Build date: Sat Sep 28 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import $ from "../../../core/renderer";
import {
    getInnerHeight,
    getOuterHeight
} from "../../../core/utils/size";
import {
    isNumeric
} from "../../../core/utils/type";
import {
    getWindow
} from "../../../core/utils/window";
const WINDOW_HEIGHT_PERCENT = .9;
export const getElementMaxHeightByWindow = ($element, startLocation) => {
    const $window = $(getWindow());
    const {
        top: elementOffset
    } = $element.offset();
    let actualOffset;
    if (isNumeric(startLocation)) {
        if (startLocation < elementOffset) {
            return elementOffset - startLocation
        }
        actualOffset = getInnerHeight($window) - startLocation + $window.scrollTop()
    } else {
        const offsetTop = elementOffset - $window.scrollTop();
        const offsetBottom = getInnerHeight($window) - offsetTop - getOuterHeight($element);
        actualOffset = Math.max(offsetTop, offsetBottom)
    }
    return .9 * actualOffset
};
