import { z, ZodObject } from 'zod'
import { RUMObjectSchema, TYPE_ETAB } from '../../utils'
import { Grp2024Result } from './grp-2024.types'
import { Grp2025Result } from './grp-2025.types'

/**
 * Input parameters for both grouping functions
 */
const groupingInputSchema: ZodObject<{
  rumObjects: z.ZodArray<typeof RUMObjectSchema>
  typeEtab: z.ZodNativeEnum<typeof TYPE_ETAB>
}> = z.object({
  /** Array of RUM (Résumé d'Unité Médicale) objects */
  rumObjects: z.array(RUMObjectSchema),

  /** Type of establishment (1: ex-DGF, 2: ex-OQN) */
  typeEtab: z.nativeEnum(TYPE_ETAB)
})

export type GroupingInput = z.infer<typeof groupingInputSchema>

/**
 * Note: GrpAddon interface is kept as TypeScript interface since Zod is for data validation,
 * not for defining function signatures. Function interfaces are better defined with TypeScript.
 */
export interface GrpAddon {
  grp(input: GroupingInput): Grp2024Result | Grp2025Result
  grp2024(input: GroupingInput): Grp2024Result
  grp2025(input: GroupingInput): Grp2025Result
}
