/**
 * @file constants.hpp
 * @brief Internal constants and lightweight helper utilities for the brain module.
 *
 * Centralizes magic strings and naming helpers to avoid scattering literals. If broader reuse is
 * required later these can be promoted to a shared package/API surface.
 */

#pragma once

#include <string>

namespace brain
{

/// Canonical action name used for ExecuteBtAction (historical misspelling fixed).
inline constexpr const char * kExecuteBtActionName = "/execute_bt_action";

/// Suffix appended to skill names to form BT node type identifiers.
inline constexpr const char * kBtNodeSuffix = "_H";

/**
 * @brief Compose a Behavior Tree node type name from a skill base name.
 * @param skill_name Base skill name.
 * @return Concatenated skill name with the node suffix.
 */
inline std::string make_bt_node_type(const std::string & skill_name)
{
  return skill_name + std::string{kBtNodeSuffix};
}

/**
 * @brief Check if a string ends with a specified suffix.
 * @param s Input string.
 * @param suffix Suffix to test.
 * @return true if s ends with suffix.
 */
inline bool ends_with(const std::string & s, const std::string & suffix)
{
  return s.size() >= suffix.size() &&
         s.compare(s.size() - suffix.size(), suffix.size(), suffix) == 0;
}

/**
 * @brief Remove the BT node suffix from a type name if present.
 * @param node_type Candidate node type string.
 * @return Stripped base name or the original if the suffix is absent.
 */
inline std::string strip_bt_node_suffix(const std::string & node_type)
{
  if (ends_with(node_type, kBtNodeSuffix)) {
    return node_type.substr(0, node_type.size() - std::string(kBtNodeSuffix).size());
  }
  return node_type;
}

} // namespace brain
