"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resizeBackdrops = exports.RAF_THROTTLE_INTERVAL = void 0;
exports.RAF_THROTTLE_INTERVAL = 100;
var resizeBackdrops = function (_a) {
    var anchorEl = _a.anchorEl, leftBackdropRef = _a.leftBackdropRef, rightBackdropRef = _a.rightBackdropRef, topBackdropRef = _a.topBackdropRef, bottomBackdropRef = _a.bottomBackdropRef, rafIdRef = _a.rafIdRef, _b = _a.lastResizeTimestamp, lastResizeTimestamp = _b === void 0 ? 0 : _b;
    if (anchorEl) {
        if (Date.now() - lastResizeTimestamp > exports.RAF_THROTTLE_INTERVAL &&
            topBackdropRef.current &&
            leftBackdropRef.current &&
            rightBackdropRef.current &&
            bottomBackdropRef.current) {
            var rect = anchorEl.getBoundingClientRect();
            topBackdropRef.current.style.top = '0';
            topBackdropRef.current.style.left = '0';
            topBackdropRef.current.style.right = '0';
            topBackdropRef.current.style.height = rect.top + 'px';
            leftBackdropRef.current.style.top = '0';
            leftBackdropRef.current.style.left = '0';
            leftBackdropRef.current.style.width = rect.left + 'px';
            leftBackdropRef.current.style.bottom = '0';
            rightBackdropRef.current.style.top = '0';
            rightBackdropRef.current.style.left = rect.right + 'px';
            rightBackdropRef.current.style.right = '0';
            rightBackdropRef.current.style.bottom = '0';
            bottomBackdropRef.current.style.top = rect.bottom + 'px';
            bottomBackdropRef.current.style.left = '0';
            bottomBackdropRef.current.style.right = '0';
            bottomBackdropRef.current.style.bottom = '0';
            lastResizeTimestamp = Date.now();
        }
        rafIdRef.current = requestAnimationFrame(function () {
            return (0, exports.resizeBackdrops)({
                anchorEl: anchorEl,
                leftBackdropRef: leftBackdropRef,
                rightBackdropRef: rightBackdropRef,
                topBackdropRef: topBackdropRef,
                bottomBackdropRef: bottomBackdropRef,
                rafIdRef: rafIdRef,
                lastResizeTimestamp: lastResizeTimestamp
            });
        });
    }
};
exports.resizeBackdrops = resizeBackdrops;
