import { useMemo, useCallback } from 'react';
import { useGetRoleDescription } from './useGetRoleDescription.mjs';
import { useGetRoleDisplayName } from './useGetRoleDisplayName.mjs';
import { useRoles } from './useRoles.mjs';

const useRoleDisplayInfo = (includeOrgRoles = false)=>{
    const allRoles = useRoles(includeOrgRoles);
    const getRoleDisplayName = useGetRoleDisplayName();
    const getRoleDescription = useGetRoleDescription();
    const roleInfo = useMemo(()=>{
        return allRoles?.reduce((acc, role)=>{
            acc[role.role_id] = {
                description: getRoleDescription(role),
                label: getRoleDisplayName(role)
            };
            return acc;
        }, {}) ?? {};
    }, [
        allRoles,
        getRoleDescription,
        getRoleDisplayName
    ]);
    const getRoleIdDisplayName = useCallback((roleId)=>roleInfo[roleId].label ?? roleId, [
        roleInfo
    ]);
    return {
        roleInfo,
        getRoleIdDisplayName
    };
};

export { useRoleDisplayInfo };
//# sourceMappingURL=useRoleDisplayInfo.mjs.map
