#pragma once

#include <algorithm>
#include <string_view>

#include "application/contracts/ConfigUiTypes.h"

namespace ta::presentation::config_snapshot
{
    [[nodiscard]] inline const ta::ui::ConfigValueSnapshot* find_value(
        const ta::ui::ConfigPanelSnapshot* panel,
        const std::string_view id) noexcept
    {
        if (!panel)
            return nullptr;

        const auto found = std::find_if(
            panel->values.begin(),
            panel->values.end(),
            [id](const ta::ui::ConfigValueSnapshot& value)
            {
                return value.id == id;
            });
        return found == panel->values.end() ? nullptr : &*found;
    }
}
