/** Helpers for free-text genotype input (parse/validate/preview via GEN-1). */
import { fromDisplayString, genotypeToFarbschlag } from '../genetics'

export function isValidGenotype(genotype: string): boolean {
  if (!genotype.trim()) return false
  try {
    fromDisplayString(genotype)
    return true
  } catch {
    return false
  }
}

/** Resolved Farbschlag for a genotype string, or null if empty/invalid. */
export function previewFarbschlag(genotype: string): string | null {
  if (!genotype.trim()) return null
  try {
    return genotypeToFarbschlag(fromDisplayString(genotype))
  } catch {
    return null
  }
}
