<div class="changelog_content">
  {% set documents_modified = view_object.change_container.change_stats.get_changes_documents_modified() %}
  {% if documents_modified is not none %}
    {% set _documents_modified = documents_modified %}
  {% else %}
    {% set _documents_modified = "No documents were modified." %}
  {% endif %}

  {% set sections_modified = view_object.change_container.change_stats.get_changes_sections_modified() %}
  {% if sections_modified is not none %}
    {% set _sections_modified = sections_modified~" ("~view_object.change_container.change_stats.get_changes_sections_stats_string()~")" %}
  {% else %}
    {% set _sections_modified = "No sections were modified." %}
  {% endif %}

  <div class="sdoc-table_key_value">
    {% with key_value_pair =
      {"Section":"Compared revisions"}
    %}
      {% include "components/table_key_value/index.jinja" %}
    {% endwith %}

    {% with key_value_pair =
        {
          "Key":"Left",
          "Value": view_object.left_revision,
        }
    %}
      {% include "components/table_key_value/index.jinja" %}
    {% endwith %}

    {% with key_value_pair =
        {
          "Key":"Right",
          "Value": view_object.right_revision,
        }
    %}
      {% include "components/table_key_value/index.jinja" %}
    {% endwith %}

    {% with key_value_pair =
        {"Section":"Summary of the changes"}
    %}
      {% include "components/table_key_value/index.jinja" %}
    {% endwith %}

    {% with key_value_pair =
        {
          "Key":"Nodes modified",
          "Value": view_object.change_container.change_stats.get_total_changes(),
        }
    %}
      {% include "components/table_key_value/index.jinja" %}
    {% endwith %}

    {% with key_value_pair =
        {
          "Key":"Documents modified",
          "Value": _documents_modified,
        }
    %}
      {% include "components/table_key_value/index.jinja" %}
    {% endwith %}

    {% if not view_object.should_display_old_section_as_deprecated() %}
      {% with key_value_pair =
          {
            "Key":"Sections modified",
            "Value": _sections_modified,
          }
      %}
        {% include "components/table_key_value/index.jinja" %}
      {% endwith %}
    {% endif %}

    {% for node_type_ in view_object.get_node_types() %}
      {% set requirements_modified = view_object.change_container.change_stats.get_changes_requirements_changed(node_type_) %}
      {% if requirements_modified is not none %}
        {% set _requirements_modified = requirements_modified~" ("~view_object.change_container.change_stats.get_changes_requirements_stats_string(node_type_)~")" %}
      {% else %}
        {% set _requirements_modified = "No nodes were modified." %}
      {% endif %}

      {% with key_value_pair =
          {
            "Key":node_type_~" nodes",
            "Value": _requirements_modified,
          }
      %}
        {% include "components/table_key_value/index.jinja" %}
      {% endwith %}
    {% endfor %}
  </div>{# / .sdoc-table_key_value #}

  <div class="changelog_changes">
    {% for change in view_object.change_container.change_stats.changes %}
    <div class="changelog_change">
      <div class="changelog_change_meta">
        <span class="changelog_change_num"># {{ loop.index }}</span>
        {% set _change_type = change.change_type.value.split(' ') %}
        {# <span class="changelog_change_type {{ _change_type[1] }}">{{ _change_type[1] }}</span> #}
        <span class="changelog_change_type {{ _change_type[1] }}">{{ change.change_type.value }}</span>
      </div>
      <div class="changelog_change_node">
        {% if change.change_type == "Requirement added" or change.change_type == "Section added" %}
          <div class="changelog_node_null">{{ change.change_type.value }}</div>
        {% elif change.change_type == "Requirement removed" or change.change_type == "Requirement modified" %}
          {% with requirement=change.lhs_requirement, side="left", self_stats=view_object.change_container.lhs_stats, other_stats=view_object.change_container.rhs_stats, traceability_index=view_object.change_container.traceability_index_lhs %}
            {% set requirement_change = view_object.change_stats.find_change(requirement) %}
            {% include "screens/git/fields/requirement_fields.jinja" %}
          {% endwith %}
        {% elif change.change_type == "Section removed" or change.change_type == "Section modified" %}
          {% assert change.lhs_section is not none, change %}
          {% with section=change.lhs_section, side="left", self_stats=view_object.change_container.lhs_stats, other_stats=view_object.change_container.rhs_stats, traceability_index=view_object.change_container.traceability_index_lhs %}
            {% set section_change = view_object.change_stats.find_change(section) %}
            {% include "screens/git/fields/section_fields.jinja" %}
          {% endwith %}
        {% elif change.change_type == "Document modified" %}
          {% if change.lhs_document is not none %}
            {% with document=change.lhs_document, side="left", self_stats=view_object.change_container.lhs_stats, other_stats=view_object.change_container.rhs_stats, traceability_index=view_object.change_container.traceability_index_lhs %}
              {% include "screens/git/fields/document_fields.jinja" %}
            {% endwith %}
          {% else %}
            <div class="changelog_node_null"></div>
          {% endif %}
        {% else %}
          {% assert 0, "Must not reach here." %}
        {% endif %}
      </div>
      <div class="changelog_change_node">
        {% if change.change_type == "Requirement removed" or change.change_type == "Section removed" %}
          <div class="changelog_node_null">{{ change.change_type.value }}</div>
        {% elif change.change_type == "Requirement added" or change.change_type == "Requirement modified" %}
          {% with requirement=change.rhs_requirement, side="right", self_stats=view_object.change_container.rhs_stats, other_stats=view_object.change_container.lhs_stats, traceability_index=view_object.change_container.traceability_index_rhs %}
            {% set requirement_change = view_object.change_stats.find_change(requirement) %}
            {% include "screens/git/fields/requirement_fields.jinja" %}
          {% endwith %}
        {% elif change.change_type == "Section added" or change.change_type == "Section modified" %}
          {% with section=change.rhs_section, side="right", self_stats=view_object.change_container.rhs_stats, other_stats=view_object.change_container.lhs_stats, traceability_index=view_object.change_container.traceability_index_rhs %}
            {% set section_change = view_object.change_stats.find_change(section) %}
            {% include "screens/git/fields/section_fields.jinja" %}
          {% endwith %}
        {% elif change.change_type == "Document modified" %}
          {% if change.rhs_document is not none %}
            {% with document=change.rhs_document, side="right", self_stats=view_object.change_container.rhs_stats, other_stats=view_object.change_container.lhs_stats, traceability_index=view_object.change_container.traceability_index_rhs %}
              {% include "screens/git/fields/document_fields.jinja" %}
            {% endwith %}
          {% else %}
            <div class="changelog_node_null"></div>
          {% endif %}
        {% else %}
          {% assert 0, "Must not reach here." %}
        {% endif %}
      </div>
    </div>
    {% endfor %}
  </div>{# // changelog_changes #}
</div>{# // changelog_content #}
