import { Module, forwardRef } from "@nestjs/common";
import { FreebitModule } from "@bff/integrations/freebit/freebit.module";
import { WhmcsModule } from "@bff/integrations/whmcs/whmcs.module";
import { SalesforceModule } from "@bff/integrations/salesforce/salesforce.module";
import { MappingsModule } from "@bff/modules/id-mappings/mappings.module";
import { EmailModule } from "@bff/infra/email/email.module";
import { SimUsageStoreService } from "../sim-usage-store.service";
import { SubscriptionsService } from "../subscriptions.service";

// Import all SIM management services
import { SimOrchestratorService } from "./services/sim-orchestrator.service";
import { SimDetailsService } from "./services/sim-details.service";
import { SimUsageService } from "./services/sim-usage.service";
import { SimTopUpService } from "./services/sim-topup.service";
import { SimTopUpPricingService } from "./services/sim-topup-pricing.service";
import { SimPlanService } from "./services/sim-plan.service";
import { SimCancellationService } from "./services/sim-cancellation.service";
import { EsimManagementService } from "./services/esim-management.service";
import { SimValidationService } from "./services/sim-validation.service";
import { SimNotificationService } from "./services/sim-notification.service";
import { SimApiNotificationService } from "./services/sim-api-notification.service";
import { SimBillingService } from "./services/sim-billing.service";
import { SimScheduleService } from "./services/sim-schedule.service";
import { SimActionRunnerService } from "./services/sim-action-runner.service";
import { SimManagementQueueService } from "./queue/sim-management.queue";
import { SimManagementProcessor } from "./queue/sim-management.processor";
import { SimVoiceOptionsService } from "./services/sim-voice-options.service";
import { CatalogModule } from "@bff/modules/catalog/catalog.module";

@Module({
  imports: [
    forwardRef(() => FreebitModule),
    WhmcsModule,
    SalesforceModule,
    MappingsModule,
    EmailModule,
    CatalogModule,
  ],
  providers: [
    // Core services that the SIM services depend on
    SimUsageStoreService,
    SubscriptionsService,

    // SIM management services
    SimValidationService,
    SimNotificationService,
    SimApiNotificationService,
    SimVoiceOptionsService,
    SimDetailsService,
    SimUsageService,
    SimTopUpService,
    SimTopUpPricingService,
    SimPlanService,
    SimCancellationService,
    EsimManagementService,
    SimOrchestratorService,
    SimBillingService,
    SimScheduleService,
    SimActionRunnerService,
    SimManagementQueueService,
    SimManagementProcessor,
    // Export with token for optional injection in Freebit module
    {
      provide: "SimVoiceOptionsService",
      useExisting: SimVoiceOptionsService,
    },
  ],
  exports: [
    SimOrchestratorService,
    // Export individual services in case they're needed elsewhere
    SimDetailsService,
    SimUsageService,
    SimTopUpService,
    SimTopUpPricingService,
    SimPlanService,
    SimCancellationService,
    EsimManagementService,
    SimValidationService,
    SimNotificationService,
    SimApiNotificationService,
    SimBillingService,
    SimScheduleService,
    SimActionRunnerService,
    SimManagementQueueService,
    SimVoiceOptionsService,
    "SimVoiceOptionsService", // Export the token
  ],
})
export class SimManagementModule {}
