import type { SelectOption } from "./types";

export const CROSS_TYPE_OPTIONS: SelectOption[] = [
  { value: "BIPARENTAL", label: "BIPARENTAL 双亲杂交" },
  { value: "SELF", label: "SELF 自交" },
  { value: "OPEN_POLLINATED", label: "OPEN_POLLINATED 开放授粉" },
  { value: "BULK", label: "BULK  bulk" },
  { value: "BULK_SELFED", label: "BULK_SELFED" },
  { value: "BULK_OPEN_POLLINATED", label: "BULK_OPEN_POLLINATED" },
  { value: "DOUBLE_HAPLOID", label: "DOUBLE_HAPLOID 双单倍体" },
];

export const PLANNED_CROSS_STATUS_OPTIONS: SelectOption[] = [
  { value: "TODO", label: "TODO 待执行" },
  { value: "DONE", label: "DONE 已完成" },
  { value: "SKIPPED", label: "SKIPPED 已跳过" },
];

export const PARENT_TYPE_OPTIONS: SelectOption[] = [
  { value: "FEMALE", label: "FEMALE 母本" },
  { value: "MALE", label: "MALE 父本" },
  { value: "SELF", label: "SELF 自交" },
  { value: "POPULATION", label: "POPULATION 群体" },
  { value: "CLONAL", label: "CLONAL 克隆" },
];

export const crossTypeLabel = (value: unknown) =>
  CROSS_TYPE_OPTIONS.find((option) => option.value === String(value))?.label ?? (value ? String(value) : "—");

export const plannedStatusLabel = (value: unknown) =>
  PLANNED_CROSS_STATUS_OPTIONS.find((option) => option.value === String(value))?.label ?? (value ? String(value) : "—");

export const parentTypeLabel = (value: unknown) =>
  PARENT_TYPE_OPTIONS.find((option) => option.value === String(value))?.label ?? (value ? String(value) : "—");

export const EDGE_TYPE_OPTIONS: SelectOption[] = [
  { value: "parent", label: "parent 亲本" },
  { value: "child", label: "child 后代" },
];

export const edgeTypeLabel = (value: unknown) => {
  const text = String(value ?? "");
  if (text === "parent") return "parent 亲本";
  if (text === "child") return "child 后代";
  if (text === "sibling") return "sibling 同胞";
  return text || "—";
};
