/*!
 * Copyright (c) Microsoft. All rights reserved.
 * Licensed under the MIT license. See LICENSE file in the project.
 */ import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback } from 'react';
import { GroupHeader } from '../../GroupHeader/index.js';
/**
 * Overrides the default group header rendering so we can inject customization
 * @returns
 */ export function useGroupHeaderRenderer(table, computedMetadata, groupHeaderFunction, lazyLoadGroups = true) {
    return useCallback((props, defaultRender)=>{
        if (!props || !defaultRender) {
            return null;
        }
        const columnName = table.groups().names[props.groupLevel];
        const meta = columnName ? computedMetadata?.columns[columnName] : undefined;
        if (!groupHeaderFunction) {
            return /*#__PURE__*/ _jsx(GroupHeader, {
                props: props,
                columnName: columnName,
                lazyLoadGroups: lazyLoadGroups
            });
        }
        return groupHeaderFunction(meta, columnName, props);
    }, [
        groupHeaderFunction,
        table,
        lazyLoadGroups,
        computedMetadata?.columns
    ]);
}
