<?php

declare(strict_types=1);

namespace App\Framework\EventSourcing\Replay;

use App\Framework\Attributes\Initializer;
use App\Framework\EventSourcing\EventStore;
use App\Framework\EventSourcing\Projections\ProjectionManager;

/**
 * Replay System Initializer
 *
 * Registers replay components in DI container
 */
final readonly class ReplayInitializer
{
    #[Initializer]
    public function initializeEventReplayer(EventStore $eventStore): EventReplayer
    {
        return new EventReplayer($eventStore);
    }

    #[Initializer]
    public function initializeTimeTravelDebugger(EventStore $eventStore): TimeTravelDebugger
    {
        return new TimeTravelDebugger($eventStore);
    }

    #[Initializer]
    public function initializeEventHistoryVisualizer(EventStore $eventStore): EventHistoryVisualizer
    {
        return new EventHistoryVisualizer($eventStore);
    }

    #[Initializer]
    public function initializeProjectionRebuilder(
        EventStore $eventStore,
        EventReplayer $replayer,
        ProjectionManager $projectionManager
    ): ProjectionRebuilder {
        return new ProjectionRebuilder($eventStore, $replayer, $projectionManager);
    }

    #[Initializer]
    public function initializeReplayCommands(
        EventReplayer $replayer,
        TimeTravelDebugger $timeTravelDebugger,
        EventHistoryVisualizer $visualizer,
        ProjectionRebuilder $projectionRebuilder
    ): ReplayCommands {
        return new ReplayCommands(
            $replayer,
            $timeTravelDebugger,
            $visualizer,
            $projectionRebuilder
        );
    }
}
