import { Module } from "@nestjs/common";
import { SubscriptionsController } from "./subscriptions.controller.js";
import { SubscriptionsOrchestrator } from "./subscriptions-orchestrator.service.js";
import { SimUsageStoreService } from "./sim-usage-store.service.js";
import { SimOrdersController } from "./sim-orders/sim-orders.controller.js";
import { SimOrderActivationService } from "./sim-order-activation.service.js";
import { SecurityModule } from "@bff/core/security/security.module.js";
import { WhmcsModule } from "@bff/integrations/whmcs/whmcs.module.js";
import { MappingsModule } from "@bff/modules/id-mappings/mappings.module.js";
import { FreebitModule } from "@bff/integrations/freebit/freebit.module.js";
import { SimManagementModule } from "./sim-management/sim-management.module.js";
import { InternetManagementModule } from "./internet-management/internet-management.module.js";
import { CallHistoryModule } from "./call-history/call-history.module.js";
import { CancellationModule } from "./cancellation/cancellation.module.js";
// Import controllers to register them directly in this module before SubscriptionsController
// This ensures more specific routes (like :id/sim, :id/cancel) are matched before :id
import { SimController } from "./sim-management/sim.controller.js";
import { CancellationController } from "./cancellation/cancellation.controller.js";

@Module({
  imports: [
    SecurityModule,
    WhmcsModule,
    MappingsModule,
    FreebitModule,
    SimManagementModule,
    InternetManagementModule,
    CallHistoryModule,
    CancellationModule,
  ],
  // Register specific route controllers BEFORE SubscriptionsController
  // to ensure routes like :id/sim and :id/cancel are matched before :id
  controllers: [
    SimController,
    CancellationController,
    SubscriptionsController,
    SimOrdersController,
  ],
  providers: [SubscriptionsOrchestrator, SimUsageStoreService, SimOrderActivationService],
})
export class SubscriptionsModule {}
