import type { FileTypeItem } from '#/api/core/file-gallery';

export const ALL_TYPE_ICON = 'ant-design:appstore-outlined';

export function resolveTypeIcon(
  typeValue: number | undefined,
  fileTypes: FileTypeItem[],
  fallback = 'ant-design:file-outlined',
): string {
  if (typeValue === undefined || typeValue === null) {
    return fallback;
  }
  const matched = fileTypes.find((item) => item.value === typeValue);
  return matched?.icon || fallback;
}

export function iconToMenuItem(iconName: string) {
  if (!iconName) {
    return undefined;
  }
  return iconName;
}
