import { Module, forwardRef } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { KnowledgeBase } from './knowledge-base.entity';
import { KnowledgeGroup } from '../knowledge-group/knowledge-group.entity';
import { KnowledgeBaseService } from './knowledge-base.service';
import { KnowledgeBaseController } from './knowledge-base.controller';
import { ElasticsearchModule } from '../elasticsearch/elasticsearch.module';
import { TikaModule } from '../tika/tika.module';
import { ModelConfigModule } from '../model-config/model-config.module';
import { EmbeddingService } from './embedding.service';
import { TextChunkerService } from './text-chunker.service';
import { RagModule } from '../rag/rag.module';
import { VisionModule } from '../vision/vision.module';
import { MemoryMonitorService } from './memory-monitor.service';
import { ChunkConfigService } from './chunk-config.service';
import { LibreOfficeModule } from '../libreoffice/libreoffice.module';
import { Pdf2ImageModule } from '../pdf2image/pdf2image.module';
import { VisionPipelineModule } from '../vision-pipeline/vision-pipeline.module';
import { KnowledgeGroupModule } from '../knowledge-group/knowledge-group.module';
import { ChatModule } from '../chat/chat.module';
import { UserModule } from '../user/user.module';
import { TenantModule } from '../tenant/tenant.module';
import { CombinedAuthGuard } from '../auth/combined-auth.guard';

@Module({
  imports: [
    TypeOrmModule.forFeature([KnowledgeBase, KnowledgeGroup]),
    forwardRef(() => ElasticsearchModule),
    TikaModule,
    ModelConfigModule,
    forwardRef(() => RagModule),
    VisionModule,
    LibreOfficeModule,
    Pdf2ImageModule,
    VisionPipelineModule,
    forwardRef(() => KnowledgeGroupModule),
    forwardRef(() => ChatModule),
    UserModule,
    TenantModule,
  ],
  controllers: [KnowledgeBaseController],
  providers: [
    KnowledgeBaseService,
    EmbeddingService,
    TextChunkerService,
    MemoryMonitorService,
    ChunkConfigService,
    CombinedAuthGuard,
  ],
  exports: [KnowledgeBaseService, EmbeddingService],
})
export class KnowledgeBaseModule { }
