<?php

declare(strict_types=1);

namespace App\Application\LiveComponents\Services;

use App\Application\LiveComponents\ValueObjects\ChartData;
use App\Application\LiveComponents\ValueObjects\ChartType;
use App\Application\LiveComponents\ValueObjects\DataRange;
use App\Application\LiveComponents\ValueObjects\DataSource;
use App\Framework\LiveComponents\Attributes\DataProvider;

/**
 * DatabaseChartDataProvider - Production implementation with database
 *
 * TODO: Implement actual database queries for analytics data
 * The DataSource parameter determines which data to load:
 * - 'sales' - Sales metrics from database
 * - 'traffic' - Website traffic analytics
 * - 'users' - User statistics
 */
#[DataProvider(name: 'database')]
final readonly class DatabaseChartDataProvider implements ChartDataProvider
{
    public function __construct(
        private DataSource $dataSource
        // TODO: Inject repositories/services needed for analytics
        // private readonly AnalyticsRepository $repository,
        // private readonly MetricsService $metrics
    ) {
    }

    public function getChartData(ChartType $chartType, DataRange $dataRange): ChartData
    {
        // TODO: Implement database query to load chart data
        // Example:
        // return $this->repository->getChartDataByTypeAndRange($chartType, $dataRange);

        throw new \RuntimeException(
            'DatabaseChartDataProvider not yet implemented. Use DemoChartDataProvider for now.'
        );
    }

    public function getNewDataPoint(ChartType $chartType): array
    {
        // TODO: Implement real-time data point retrieval
        throw new \RuntimeException(
            'DatabaseChartDataProvider not yet implemented. Use DemoChartDataProvider for now.'
        );
    }

    public function getAvailableChartTypes(): array
    {
        // TODO: Load from configuration or database
        throw new \RuntimeException(
            'DatabaseChartDataProvider not yet implemented. Use DemoChartDataProvider for now.'
        );
    }

    public function getAvailableDataRanges(): array
    {
        // TODO: Load from configuration or database
        throw new \RuntimeException(
            'DatabaseChartDataProvider not yet implemented. Use DemoChartDataProvider for now.'
        );
    }
}
