<?php

declare(strict_types=1);

namespace App\Services\Sitemaps;

use App\Services\Sitemaps\Builders\ArtworksSitemapBuilder;
use App\Services\Sitemaps\Builders\AcademyChallengesSitemapBuilder;
use App\Services\Sitemaps\Builders\AcademyCoursesSitemapBuilder;
use App\Services\Sitemaps\Builders\AcademyLessonsSitemapBuilder;
use App\Services\Sitemaps\Builders\AcademyPacksSitemapBuilder;
use App\Services\Sitemaps\Builders\AcademyPromptsSitemapBuilder;
use App\Services\Sitemaps\Builders\CardsSitemapBuilder;
use App\Services\Sitemaps\Builders\CategoriesSitemapBuilder;
use App\Services\Sitemaps\Builders\CollectionsSitemapBuilder;
use App\Services\Sitemaps\Builders\ForumCategoriesSitemapBuilder;
use App\Services\Sitemaps\Builders\ForumIndexSitemapBuilder;
use App\Services\Sitemaps\Builders\ForumThreadsSitemapBuilder;
use App\Services\Sitemaps\Builders\GoogleNewsSitemapBuilder;
use App\Services\Sitemaps\Builders\NewsSitemapBuilder;
use App\Services\Sitemaps\Builders\StaticPagesSitemapBuilder;
use App\Services\Sitemaps\Builders\StoriesSitemapBuilder;
use App\Services\Sitemaps\Builders\TagsSitemapBuilder;
use App\Services\Sitemaps\Builders\UsersSitemapBuilder;
use App\Services\Sitemaps\Builders\WorldWebStoriesSitemapBuilder;

final class SitemapRegistry
{
    /**
     * @var array<string, SitemapBuilder>
     */
    private array $builders;

    public function __construct(
        ArtworksSitemapBuilder $artworks,
        AcademyCoursesSitemapBuilder $academyCourses,
        AcademyLessonsSitemapBuilder $academyLessons,
        AcademyPromptsSitemapBuilder $academyPrompts,
        AcademyPacksSitemapBuilder $academyPacks,
        AcademyChallengesSitemapBuilder $academyChallenges,
        UsersSitemapBuilder $users,
        TagsSitemapBuilder $tags,
        CategoriesSitemapBuilder $categories,
        CollectionsSitemapBuilder $collections,
        CardsSitemapBuilder $cards,
        StoriesSitemapBuilder $stories,
        WorldWebStoriesSitemapBuilder $webStories,
        NewsSitemapBuilder $news,
        GoogleNewsSitemapBuilder $googleNews,
        ForumIndexSitemapBuilder $forumIndex,
        ForumCategoriesSitemapBuilder $forumCategories,
        ForumThreadsSitemapBuilder $forumThreads,
        StaticPagesSitemapBuilder $staticPages,
    ) {
        $this->builders = [
            $artworks->name() => $artworks,
            $academyCourses->name() => $academyCourses,
            $academyLessons->name() => $academyLessons,
            $academyPrompts->name() => $academyPrompts,
            $academyPacks->name() => $academyPacks,
            $academyChallenges->name() => $academyChallenges,
            $users->name() => $users,
            $tags->name() => $tags,
            $categories->name() => $categories,
            $collections->name() => $collections,
            $cards->name() => $cards,
            $stories->name() => $stories,
            $webStories->name() => $webStories,
            $news->name() => $news,
            $googleNews->name() => $googleNews,
            $forumIndex->name() => $forumIndex,
            $forumCategories->name() => $forumCategories,
            $forumThreads->name() => $forumThreads,
            $staticPages->name() => $staticPages,
        ];
    }

    /**
     * @return array<string, SitemapBuilder>
     */
    public function all(): array
    {
        return $this->builders;
    }

    public function get(string $name): ?SitemapBuilder
    {
        return $this->builders[$name] ?? null;
    }
}