import { useRepo } from 'pinia-orm'
import EntityManager from '~/services/data/entityManager'
import { useMaestroRequestService } from '~/composables/data/useMaestroRequestService'

let entityManager: EntityManager | null = null

export const useEntityManager = () => {
  if (entityManager === null) {
    const { apiRequestService } = useMaestroRequestService()
    const getRepo = useRepo

    entityManager = new EntityManager(apiRequestService, getRepo)
  }
  return { em: entityManager }
}
