import type { BffCatalogRelatedEntity } from '@redocly/theme/core/types';

import { reverseRelationMap, relationTypeMap } from '@redocly/theme/core/constants';

export type CatalogEntityRelationCellProps = Pick<
  BffCatalogRelatedEntity,
  'relationType' | 'relationRole'
>;

export function CatalogEntityRelationCell({
  relationType,
  relationRole,
}: CatalogEntityRelationCellProps) {
  if (relationRole === 'source') {
    return relationTypeMap[reverseRelationMap[relationType]];
  }

  return relationTypeMap[relationType];
}
