import type { DuplicateCheckConfig } from './detection'

const registry = new Map<string, DuplicateCheckConfig>()

export function registerDuplicateConfig(
  entityType: string,
  config: Omit<DuplicateCheckConfig, 'entityType'>
): void {
  registry.set(entityType, { entityType, ...config })
}

export function getDuplicateConfig(entityType: string): DuplicateCheckConfig | undefined {
  return registry.get(entityType)
}

registerDuplicateConfig('supplier', {
  exactMatchFields: ['supplier_number'],
  fuzzyMatchFields: ['supplier_name'],
  compositeKeys: [['supplier_name', 'country', 'city']],
})

registerDuplicateConfig('consultant', {
  exactMatchFields: ['email'],
  fuzzyMatchFields: ['last_name'],
  compositeKeys: [['first_name', 'last_name', 'team_code']],
})

registerDuplicateConfig('department', {
  exactMatchFields: ['department_code'],
  fuzzyMatchFields: ['department_name'],
  compositeKeys: [],
})

registerDuplicateConfig('user', {
  exactMatchFields: ['email'],
  fuzzyMatchFields: ['last_name'],
  compositeKeys: [['first_name', 'last_name', 'email']],
})
