import { parseFromValuesOrFunc } from "@/core/utils/utils";
import { Box } from "@mui/material";
import DataTable_ShowHideColumnsButton from "../buttons/ShowHideColumnsButton";
import DataTable_ToggleFiltersButton from "../buttons/ToggleFiltersButton";

const DataTable_ToolbarInternalButtons = ({ table, ...rest }) => {
    const {
        options: {
            columnFilterDisplayMode,
            enableColumnFilters,
            enableColumnOrdering,
            enableColumnPinning,
            enableFilters,
            enableHiding,
            renderToolbarInternalActions,
        },
    } = table;


    return (
        <Box
            {...rest}
            sx={(theme) => ({
                alignItems: 'center',
                display: 'flex',
                zIndex: 3,
                ...(parseFromValuesOrFunc(rest?.sx, theme)),
            })}
        >
            {renderToolbarInternalActions?.({
                table,
            }) ?? (
                    <>
                        {enableFilters &&
                            enableColumnFilters &&
                            columnFilterDisplayMode !== 'popover' && (
                                <DataTable_ToggleFiltersButton table={table} />
                            )}
                        {(enableHiding || enableColumnOrdering || enableColumnPinning) && (
                            <DataTable_ShowHideColumnsButton table={table} />
                        )}
                    </>
                )}
        </Box>
    );
}
export default DataTable_ToolbarInternalButtons