export function getTopVisibleNodeKey(scrollContainerWrapper, treeData) {
    if (!scrollContainerWrapper) {
        return null;
    }
    const container = scrollContainerWrapper.querySelector('.table-fn-scrollable, .table-scrollable');
    if (!container) {
        return null;
    }
    const visibleNodes = treeData.filter((node) => !node.hide);
    if (visibleNodes.length === 0) {
        return null;
    }
    const scrollTop = container.scrollTop;
    const firstRow = container.querySelector('.ff-table-tree-fn-row, .ff-table-tree-row');
    const rowHeight = firstRow?.offsetHeight || 32;
    const approxIndex = Math.floor(scrollTop / rowHeight);
    const safeIndex = Math.min(approxIndex, visibleNodes.length - 1);
    const topRow = visibleNodes[safeIndex];
    return {
        key: topRow?.key || null,
        searchKey: topRow?.searchKey || null,
    };
}
//# sourceMappingURL=getTopVisibleNodeKey.js.map