{% import "macros.html" as m %}
{% if not view.ok %}
  {{ m.absence(view) }}
{% else %}
<section class="card fw-panel">
  <header class="fw-panel__head">
    <h2 class="card__title fw-panel__title">Architecture</h2>
    <span class="fw-spacer"></span>
    {% if view.note %}<span class="fw-panel__note mono">{{ view.note }}</span>{% endif %}
  </header>

  {% if view.mode == 'embed_svg' %}
    <div class="detail-block detail-block--derived">
      <div class="detail-block__head">⧉ embedded diagram</div>
      The project's own diagram is the source of truth at
      <span class="mono">{{ view.embed.ref }}</span>{% if view.embed.title %} — “{{ view.embed.title }}”{% endif %}.
      mgf-fed-web embeds it, never redraws it.
    </div>
  {% else %}
    <p class="lead fw-lede">
      Federation dependency graph — <b>{{ view.counts.nodes }}</b> nodes ·
      <b>{{ view.counts.edges }}</b> edges · <b>{{ view.counts.layers }}</b> layers, projected from the
      project's <span class="mono">graph</span> mode. Each node lists what it depends on.
    </p>
    {% for group in view.grouped %}
    <div class="fw-arch-layer">
      <div class="fw-arch-layer__h mono">{{ group.layer|upper }} · {{ group.nodes|length }}</div>
      <div class="fw-arch-nodes">
        {% for n in group.nodes %}
        <div class="fw-node">
          <span class="fw-node__label mono">{{ n.label }}</span>
          {% set deps = view.deps_by_node.get(n.id) %}
          {% if deps %}<span class="fw-node__deps mono">→ {{ deps|join(', ') }}</span>{% endif %}
        </div>
        {% endfor %}
      </div>
    </div>
    {% endfor %}
  {% endif %}
</section>
{% endif %}
