#pragma once

#include <algorithm>

#include "application/contracts/ILocaleController.h"
#include "presentation/localization/UiLocalizationService.h"

namespace ta::presentation::localization
{
    class UiLocaleController final : public ta::application::ILocaleController
    {
    public:
        [[nodiscard]] int default_index() const override
        {
            return (std::max)(0, locale_index({}));
        }

        [[nodiscard]] std::vector<std::string> option_labels() const override
        {
            return locale_option_labels();
        }

        [[nodiscard]] int index_for_id(const std::string_view id) const override
        {
            return locale_index(id);
        }

        [[nodiscard]] std::string id_for_index(const int index) const override
        {
            return locale_id_for_index(index);
        }

        [[nodiscard]] bool select_index(const int index) override
        {
            return set_locale(locale_id_for_index(index));
        }
    };
}
