import { InjectionToken, inject } from '@angular/core';
import { RuntimeProviderStrategyService } from '../providers/runtime-provider-strategy.service';
import { ApiProductDataProvider } from './providers/api-product-data.provider';
import { ProductDataProvider } from './providers/product-data-provider.interface';

export const PRODUCT_DATA_PROVIDER = new InjectionToken<ProductDataProvider>('PRODUCT_DATA_PROVIDER', {
  providedIn: 'root',
  factory: () => {
    const strategy = inject(RuntimeProviderStrategyService);
    const apiProvider = inject(ApiProductDataProvider);

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