import { InjectionToken, inject } from '@angular/core';
import { RuntimeProviderStrategyService } from '../providers/runtime-provider-strategy.service';
import { ApiCategoryRepository } from './repositories/api-category.repository';
import { CategoryRepository } from './repositories/category.repository';

export const CATEGORY_REPOSITORY = new InjectionToken<CategoryRepository>('CATEGORY_REPOSITORY', {
  providedIn: 'root',
  factory: () => {
    const strategy = inject(RuntimeProviderStrategyService);
    const apiRepository = inject(ApiCategoryRepository);

    switch (strategy.getCategoryProviderMode()) {
      case 'mock':
      case 'remote-config':
      case 'api':
      default:
        return apiRepository;
    }
  }
});