// AUTO-GENERATED FILE - DO NOT EDIT
// Generated by zacus_story_gen_ai (Yamale + Jinja2)
// spec_hash: {{ spec_hash }}
// scenarios: {{ scenario_count }}

#include "apps_gen.h"

#include <cstring>

namespace {
constexpr AppBindingDef kGeneratedAppBindings[] = {
{% for app in app_entries %}    {"{{ app.id }}", {{ app.app_cpp }}},
{% endfor %}};
{% set la_configs = app_entries | selectattr('la_config') | list %}
{% if la_configs %}
constexpr LaDetectorAppConfigDef kGeneratedLaConfigs[] = {
{% for app in la_configs %}    {"{{ app.id }}", true, {{ app.la_config.hold_ms }}U, "{{ app.la_config.unlock_event }}", {{ 'true' if app.la_config.require_listening else 'false' }}},
{% endfor %}};
{% endif %}
}  // namespace

const AppBindingDef* generatedAppBindingById(const char* id) {
  if (id == nullptr || id[0] == '\0') {
    return nullptr;
  }
  for (const AppBindingDef& binding : kGeneratedAppBindings) {
    if (binding.id != nullptr && strcmp(binding.id, id) == 0) {
      return &binding;
    }
  }
  return nullptr;
}

uint8_t generatedAppBindingCount() {
  return static_cast<uint8_t>(sizeof(kGeneratedAppBindings) / sizeof(kGeneratedAppBindings[0]));
}

const char* generatedAppBindingIdAt(uint8_t index) {
  if (index >= generatedAppBindingCount()) {
    return nullptr;
  }
  return kGeneratedAppBindings[index].id;
}

const LaDetectorAppConfigDef* generatedLaDetectorConfigByBindingId(const char* id) {
  if (id == nullptr || id[0] == '\0') {
    return nullptr;
  }
{% if la_configs %}
  for (const LaDetectorAppConfigDef& cfg : kGeneratedLaConfigs) {
    if (cfg.bindingId != nullptr && strcmp(cfg.bindingId, id) == 0) {
      return &cfg;
    }
  }
{% endif %}
  return nullptr;
}
