import { SQLiteSettingsRepository } from '../../repositories/sqlite-settings.repository.js';
import { SQLiteFeatureRepository } from '../../repositories/sqlite-feature.repository.js';
import { SQLiteRepositoryRepository } from '../../repositories/sqlite-repository.repository.js';
import { SQLiteApplicationRepository } from '../../repositories/sqlite-application.repository.js';
import { SQLiteAgentRunRepository } from '../../repositories/agent-run.repository.js';
import { SQLitePhaseTimingRepository } from '../../repositories/sqlite-phase-timing.repository.js';
import { SQLiteInteractiveSessionRepository } from '../../repositories/sqlite-interactive-session.repository.js';
import { SQLiteInteractiveMessageRepository } from '../../repositories/sqlite-interactive-message.repository.js';
import { SQLiteWorkflowStepRepository } from '../../repositories/sqlite-workflow-step.repository.js';
import { SQLiteOperationLogRepository } from '../../repositories/sqlite-operation-log.repository.js';
import { SQLitePmProjectRepository } from '../../repositories/sqlite-pm-project.repository.js';
import { SQLiteWorkItemRepository } from '../../repositories/sqlite-work-item.repository.js';
import { SQLiteWorkItemStateRepository } from '../../repositories/sqlite-work-item-state.repository.js';
import { SQLiteLabelRepository } from '../../repositories/sqlite-label.repository.js';
import { SQLiteCommentRepository } from '../../repositories/sqlite-comment.repository.js';
import { SQLiteSavedViewRepository } from '../../repositories/sqlite-saved-view.repository.js';
import { SQLiteCustomPropertyRepository } from '../../repositories/sqlite-custom-property.repository.js';
import { SQLiteActivityLogRepository } from '../../repositories/sqlite-activity-log.repository.js';
import { SQLiteWorkItemRelationRepository } from '../../repositories/sqlite-work-item-relation.repository.js';
import { SQLiteCycleRepository } from '../../repositories/sqlite-cycle.repository.js';
import { SQLitePmModuleRepository } from '../../repositories/sqlite-pm-module.repository.js';
import { SQLitePageRepository } from '../../repositories/sqlite-page.repository.js';
import { SQLitePageVersionRepository } from '../../repositories/sqlite-page-version.repository.js';
import { SQLiteEpicRepository } from '../../repositories/sqlite-epic.repository.js';
import { SQLitePmAttachmentRepository } from '../../repositories/sqlite-pm-attachment.repository.js';
import { SQLiteTimeEntryRepository } from '../../repositories/sqlite-time-entry.repository.js';
import { SQLiteIntakeItemRepository } from '../../repositories/sqlite-intake-item.repository.js';
import { SQLiteNotificationRepository } from '../../repositories/sqlite-notification.repository.js';
import { SQLitePmUserRepository } from '../../repositories/sqlite-pm-user.repository.js';
import { SQLitePmSessionRepository } from '../../repositories/sqlite-pm-session.repository.js';
import { SQLitePmProjectMemberRepository } from '../../repositories/sqlite-pm-project-member.repository.js';
import { SQLitePmAuditLogRepository } from '../../repositories/sqlite-pm-audit-log.repository.js';
import { SQLiteCodeReviewRepository } from '../../repositories/sqlite-code-review.repository.js';
import { SQLiteAgentMessageRepository } from '../../repositories/sqlite-agent-message.repository.js';
import { SQLiteAgentQuestionRepository } from '../../repositories/sqlite-agent-question.repository.js';
import { SQLiteSupervisorPolicyRepository } from '../../repositories/sqlite-supervisor-policy.repository.js';
import { SQLiteSupervisorDecisionRepository } from '../../repositories/sqlite-supervisor-decision.repository.js';
import { SQLiteAgentPromptOverrideRepository } from '../../repositories/sqlite-agent-prompt-override.repository.js';
import { SQLiteAgentPromptResolver } from '../../services/agents/prompt-resolver/sqlite-agent-prompt-resolver.service.js';
import { SQLiteAgentGraphOverrideRepository } from '../../repositories/sqlite-agent-graph-override.repository.js';
import { SQLiteCustomAgentRepository } from '../../repositories/sqlite-custom-agent.repository.js';
import { SQLiteContributorRepository } from '../../repositories/sqlite-contributor.repository.js';
import { SQLiteRecognitionEventRepository } from '../../repositories/sqlite-recognition-event.repository.js';
import { SQLiteSdlcTaskRepository } from '../../repositories/sqlite-sdlc-task.repository.js';
import { SQLiteSdlcSubTaskRepository } from '../../repositories/sqlite-sdlc-subtask.repository.js';
/**
 * Register all SQLite-backed repositories.
 *
 * Depends on the `'Database'` token being registered first.
 */
export function registerRepositories(container) {
    container.register('ISettingsRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteSettingsRepository(database);
        },
    });
    container.register('IFeatureRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteFeatureRepository(database);
        },
    });
    container.register('IRepositoryRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteRepositoryRepository(database);
        },
    });
    container.register('IApplicationRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteApplicationRepository(database);
        },
    });
    container.register('IAgentRunRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteAgentRunRepository(database);
        },
    });
    container.register('IPhaseTimingRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLitePhaseTimingRepository(database);
        },
    });
    container.register('IInteractiveSessionRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteInteractiveSessionRepository(database);
        },
    });
    container.register('IInteractiveMessageRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteInteractiveMessageRepository(database);
        },
    });
    container.register('IWorkflowStepRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            return new SQLiteWorkflowStepRepository(database);
        },
    });
    container.register('IOperationLogRepository', {
        useFactory: (c) => {
            const database = c.resolve('Database');
            const bus = c.resolve('IOperationLogEventBus');
            return new SQLiteOperationLogRepository(database, bus);
        },
    });
    // ─── Project management (feature 087) repositories ──────────────────────
    container.register('IPmProjectRepository', {
        useFactory: (c) => new SQLitePmProjectRepository(c.resolve('Database')),
    });
    container.register('IWorkItemRepository', {
        useFactory: (c) => new SQLiteWorkItemRepository(c.resolve('Database')),
    });
    container.register('IWorkItemStateRepository', {
        useFactory: (c) => new SQLiteWorkItemStateRepository(c.resolve('Database')),
    });
    container.register('ILabelRepository', {
        useFactory: (c) => new SQLiteLabelRepository(c.resolve('Database')),
    });
    container.register('ICommentRepository', {
        useFactory: (c) => new SQLiteCommentRepository(c.resolve('Database')),
    });
    container.register('ISavedViewRepository', {
        useFactory: (c) => new SQLiteSavedViewRepository(c.resolve('Database')),
    });
    container.register('ICustomPropertyRepository', {
        useFactory: (c) => new SQLiteCustomPropertyRepository(c.resolve('Database')),
    });
    container.register('IActivityLogRepository', {
        useFactory: (c) => new SQLiteActivityLogRepository(c.resolve('Database')),
    });
    container.register('IWorkItemRelationRepository', {
        useFactory: (c) => new SQLiteWorkItemRelationRepository(c.resolve('Database')),
    });
    container.register('ICycleRepository', {
        useFactory: (c) => new SQLiteCycleRepository(c.resolve('Database')),
    });
    container.register('IPmModuleRepository', {
        useFactory: (c) => new SQLitePmModuleRepository(c.resolve('Database')),
    });
    container.register('IPageRepository', {
        useFactory: (c) => new SQLitePageRepository(c.resolve('Database')),
    });
    container.register('IPageVersionRepository', {
        useFactory: (c) => new SQLitePageVersionRepository(c.resolve('Database')),
    });
    container.register('IEpicRepository', {
        useFactory: (c) => new SQLiteEpicRepository(c.resolve('Database')),
    });
    container.register('IPmAttachmentRepository', {
        useFactory: (c) => new SQLitePmAttachmentRepository(c.resolve('Database')),
    });
    container.register('ITimeEntryRepository', {
        useFactory: (c) => new SQLiteTimeEntryRepository(c.resolve('Database')),
    });
    container.register('IIntakeItemRepository', {
        useFactory: (c) => new SQLiteIntakeItemRepository(c.resolve('Database')),
    });
    container.register('INotificationRepository', {
        useFactory: (c) => new SQLiteNotificationRepository(c.resolve('Database')),
    });
    container.register('IPmUserRepository', {
        useFactory: (c) => new SQLitePmUserRepository(c.resolve('Database')),
    });
    container.register('IPmSessionRepository', {
        useFactory: (c) => new SQLitePmSessionRepository(c.resolve('Database')),
    });
    container.register('IPmProjectMemberRepository', {
        useFactory: (c) => new SQLitePmProjectMemberRepository(c.resolve('Database')),
    });
    container.register('IPmAuditLogRepository', {
        useFactory: (c) => new SQLitePmAuditLogRepository(c.resolve('Database')),
    });
    // ─── Code review (feature 090) repository ─────────────────────────────
    container.register('ICodeReviewRepository', {
        useFactory: (c) => new SQLiteCodeReviewRepository(c.resolve('Database')),
    });
    // ─── Collaboration & supervision (feature 093) repositories ──────────
    container.register('IAgentMessageRepository', {
        useFactory: (c) => new SQLiteAgentMessageRepository(c.resolve('Database')),
    });
    container.register('IAgentQuestionRepository', {
        useFactory: (c) => new SQLiteAgentQuestionRepository(c.resolve('Database')),
    });
    container.register('ISupervisorPolicyRepository', {
        useFactory: (c) => new SQLiteSupervisorPolicyRepository(c.resolve('Database')),
    });
    container.register('ISupervisorDecisionRepository', {
        useFactory: (c) => new SQLiteSupervisorDecisionRepository(c.resolve('Database')),
    });
    container.register('IAgentPromptOverrideRepository', {
        useFactory: (c) => new SQLiteAgentPromptOverrideRepository(c.resolve('Database')),
    });
    container.register('IAgentPromptResolver', {
        useFactory: (c) => new SQLiteAgentPromptResolver(c.resolve('IAgentPromptOverrideRepository')),
    });
    container.register('IAgentGraphOverrideRepository', {
        useFactory: (c) => new SQLiteAgentGraphOverrideRepository(c.resolve('Database')),
    });
    container.register('ICustomAgentRepository', {
        useFactory: (c) => new SQLiteCustomAgentRepository(c.resolve('Database')),
    });
    // ─── Contributor onboarding (feature 097) repositories ────────────────
    container.register('IContributorRepository', {
        useFactory: (c) => new SQLiteContributorRepository(c.resolve('Database')),
    });
    container.register('IRecognitionEventRepository', {
        useFactory: (c) => new SQLiteRecognitionEventRepository(c.resolve('Database')),
    });
    // ─── SDLC Kanban Board (feature sdlc-board) repositories ──────────────
    container.register('ISdlcTaskRepository', {
        useFactory: (c) => new SQLiteSdlcTaskRepository(c.resolve('Database')),
    });
    container.register('ISdlcSubTaskRepository', {
        useFactory: (c) => new SQLiteSdlcSubTaskRepository(c.resolve('Database')),
    });
}
