#pragma once

#include <nlohmann/json.hpp>

#include <optional>
#include <string>

namespace lm {

class LayoutProfile
{
public:
  static nlohmann::json make(const std::string& name,
                             const nlohmann::json& layout,
                             const nlohmann::json& lidars,
                             const nlohmann::json& imus = nlohmann::json::array());

  static void touch(nlohmann::json& profile);
  static std::string modelFromLayout(const nlohmann::json& layout);
  static nlohmann::json catalogEntryFromProfile(const nlohmann::json& profile);

  static std::optional<size_t> findIndex(const nlohmann::json& state, const std::string& id);
  static std::optional<size_t> findActiveIndex(nlohmann::json& state);

  static bool nameExists(const nlohmann::json& state,
                         const std::string& name,
                         const std::string* exclude_id = nullptr);

  static nlohmann::json buildCatalog(const nlohmann::json& state);
};

}  // namespace lm
