export const resizeRootEl = (el, rootEl, itemCount, scrollAt) => {
    const hasLegend = !!el.firstElementChild?.matches('legend');
    const selectors = [
        ':scope > ul > li:not([role="separator"]):not([role="presentation"])',
        ':scope > ul > li[role="presentation"] > div:first-child',
        ':scope > ul > li > ul[role="group"] > li:not([role="separator"])'
    ];
    const lastVisibleLI = el.querySelectorAll(selectors.join(', '))[Math.max(Math.min(scrollAt - (hasLegend ? 2 : 1), itemCount - 1), 0)];
    let menuRootElHeight;
    if (lastVisibleLI) {
        const containerTop = el.getBoundingClientRect().top;
        const lastVisibleLIRect = lastVisibleLI.getBoundingClientRect();
        const ulScrollTop = el.querySelector(':scope > ul')?.scrollTop ?? 0;
        let btm = lastVisibleLIRect.bottom;
        if (itemCount > scrollAt) {
            btm = (lastVisibleLIRect.top + lastVisibleLIRect.bottom) / 2;
        }
        menuRootElHeight = btm - containerTop + ulScrollTop;
    }
    rootEl.style.height = menuRootElHeight ? `${menuRootElHeight}px` : '';
};
export default { resizeRootEl };
//# sourceMappingURL=NavItemsList.js.map