import { useI18n } from 'vue-i18n'
import { useMaestroRequestService } from '~/composables/data/useMaestroRequestService'
import EnumManager from '~/services/data/enumManager'

let enumManager: EnumManager | null = null

export const useEnumManager = () => {
  // Avoid memory leak
  if (enumManager === null) {
    const { apiRequestService } = useMaestroRequestService()
    const i18n = useI18n()
    // @ts-expect-error TODO: explain the error of conversion from useI18n result to VueI18n
    enumManager = new EnumManager(apiRequestService, i18n)
  }
  return { enumManager }
}
