export type DocumentType =
  | 'driving_licence'
  | 'national_identity_card'
  | 'residence_permit'
  | 'passport'
  | 'passport_card'

export type DocumentTypeGeneric = 'generic_document'

export type DocumentCountrySelection = {
  documentType: DocumentType
  issuingCountry: string
}

export type DocumentAllSelection = {
  documentType: DocumentType
  allCountries: true
}

export type DocumentGenericSelection = {
  documentType: DocumentTypeGeneric
  id: string
}

export type DocumentSelection =
  | DocumentCountrySelection
  | DocumentAllSelection
  | DocumentGenericSelection

export type DocumentSelectionFilter = {
  include?: DocumentSelection[]
  exclude?: DocumentSelection[]
}

export type GenericDocumentType = {
  id: string
  title: string
  subTitle: string
  country: string
  pages: number
}

export type DocumentModuleConfiguration = {
  filter?: DocumentSelectionFilter
  extend?: GenericDocumentType[]
  hideCountrySelection?: boolean
  uploadFallback?: boolean
}

export type DocumentModuleInput = {
  preferredUserCountry?: string
}

export type DocumentSideOutput = {
  id: string
  type?: string
}

export type Side = 'front' | 'back'

export type DocumentIds = {
  front?: DocumentSideOutput,
  back?: DocumentSideOutput,
  front_video?: DocumentSideOutput,
  back_video?: DocumentSideOutput,
}

export type DocumentModuleOutput = {
  type: string
  sides: DocumentIds
}

export type EnabledDocumentType = {
  country: string
  document_type: string
}

export type DocumentFeatureFlags = {
  auto_capture_enabled_documents: EnabledDocumentType[]
  auto_capture_timeout_ms?: number
  enable_auto_capture_doc_capture?: boolean
  enable_js_camera_doc_capture?: boolean
  max_total_retries?: number
  enable_native_camera_fallback?: boolean
  enable_passport_card?: boolean
  enable_photon?: boolean
  enable_iq_experiment?: boolean
}
