import { Provider } from '@nestjs/common';

// Import core interfaces
import type { LeagueMembershipRepository } from '@core/racing/domain/repositories/LeagueMembershipRepository';
import type { ProtestRepository } from '@core/racing/domain/repositories/ProtestRepository';
import type { RaceRepository } from '@core/racing/domain/repositories/RaceRepository';
import type { Logger } from '@core/shared/domain/Logger';

// Import concrete in-memory implementations
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';

// Import use cases
import { ReviewProtestUseCase } from '@core/racing/application/use-cases/ReviewProtestUseCase';

// Import presenters
import { ReviewProtestPresenter } from './presenters/ReviewProtestPresenter';

// Define injection tokens
export const PROTEST_REPOSITORY_TOKEN = 'IProtestRepository';
export const RACE_REPOSITORY_TOKEN = 'IRaceRepository';
export const LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN = 'ILeagueMembershipRepository';
export const LOGGER_TOKEN = 'Logger';

export const ProtestsProviders: Provider[] = [
  {
    provide: LOGGER_TOKEN,
    useClass: ConsoleLogger,
  },
  ReviewProtestPresenter,
  // Use cases
  {
    provide: ReviewProtestUseCase,
    useFactory: (
      protestRepo: ProtestRepository,
      raceRepo: RaceRepository,
      leagueMembershipRepo: LeagueMembershipRepository,
      logger: Logger,
    ) => new ReviewProtestUseCase(protestRepo, raceRepo, leagueMembershipRepo, logger),
    inject: [
      PROTEST_REPOSITORY_TOKEN,
      RACE_REPOSITORY_TOKEN,
      LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN,
      LOGGER_TOKEN,
    ],
  },
];