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

#include "scenarios_gen.h"

#include <cstring>

namespace {
{% for scenario in scenarios %}
{% for step in scenario.steps %}
{% if step.actions %}
constexpr const char* {{ step.prefix }}Actions[] = {
{% for action in step.actions %}    "{{ action }}",
{% endfor %}};
{% endif %}
{% if step.apps %}
constexpr const char* {{ step.prefix }}Apps[] = {
{% for app_id in step.apps %}    "{{ app_id }}",
{% endfor %}};
{% endif %}
{% if step.transitions %}
constexpr TransitionDef {{ step.prefix }}Transitions[] = {
{% for tr in step.transitions %}    {"{{ tr.id }}", {{ tr.trigger_cpp }}, {{ tr.event_cpp }}, "{{ tr.event_name }}", {{ tr.after_ms }}U, "{{ tr.target_step_id }}", {{ tr.priority }}U, {{ tr.debug_only }}},
{% endfor %}};
{% endif %}
{% endfor %}

constexpr StepDef kScenario{{ scenario.index }}Steps[] = {
{% for step in scenario.steps %}    {"{{ step.id }}", {{ "{" }}{% if step.screen_scene_id == 'nullptr' %}nullptr{% else %}"{{ step.screen_scene_id }}"{% endif %}, {% if step.audio_pack_id == 'nullptr' %}nullptr{% else %}"{{ step.audio_pack_id }}"{% endif %}, {% if step.actions %}{{ step.prefix }}Actions{% else %}nullptr{% endif %}, {{ step.actions|length }}U, {% if step.apps %}{{ step.prefix }}Apps{% else %}nullptr{% endif %}, {{ step.apps|length }}U{{ "}" }}, {% if step.transitions %}{{ step.prefix }}Transitions{% else %}nullptr{% endif %}, {{ step.transitions|length }}U, {{ step.mp3_gate_open }}},
{% endfor %}};

constexpr ScenarioDef kScenario{{ scenario.index }} = {
    "{{ scenario.id }}",
    {{ scenario.version }}U,
    kScenario{{ scenario.index }}Steps,
    {{ scenario.steps|length }}U,
    "{{ scenario.initial_step }}",
};

{% endfor %}
constexpr const ScenarioDef* kGeneratedScenarios[] = {
{% for scenario in scenarios %}    &kScenario{{ scenario.index }},
{% endfor %}};

}  // namespace

const ScenarioDef* generatedScenarioById(const char* id) {
  if (id == nullptr || id[0] == '\0') {
    return generatedScenarioDefault();
  }
  for (const ScenarioDef* scenario : kGeneratedScenarios) {
    if (scenario != nullptr && scenario->id != nullptr && strcmp(scenario->id, id) == 0) {
      return scenario;
    }
  }
  return nullptr;
}

const ScenarioDef* generatedScenarioDefault() {
  return (generatedScenarioCount() == 0U) ? nullptr : kGeneratedScenarios[0];
}

uint8_t generatedScenarioCount() {
  return static_cast<uint8_t>(sizeof(kGeneratedScenarios) / sizeof(kGeneratedScenarios[0]));
}

const char* generatedScenarioIdAt(uint8_t index) {
  if (index >= generatedScenarioCount()) {
    return nullptr;
  }
  return kGeneratedScenarios[index]->id;
}

const char* generatedScenarioSpecHash() {
  return "{{ spec_hash }}";
}
