{% extends "simpl/base.html" %}
{% load static %}
{% load includecontents %}

{% block content_inner %}
{{ block.super }}
<div class="player-grid">
  {% if simpl_configuring and players %}
  <div class="player-col">
    <div class="all-players-managed">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23.043 17.154" class="icon">
        <path fill="currentColor"
          d="M22.501.542a1.852 1.852 0 00-2.526-.086l-.178.179-7.551 7.554-3.383 3.384c-.019.021-.038.043-.059.063l-.063.058-.007.006-.008.006a1.022 1.022 0 01-1.325-.027l-.009-.008a1.19 1.19 0 01-.073-.073l-.007-.009-3.404-3.403-.737-.738a1.855 1.855 0 00-2.627 0 1.852 1.852 0 00-.042 2.58l.087.088 6.7 6.7.056.057.019.018c.383.344.962.352 1.351.021l.12-.121 1.84-1.839-.001-.001.535-.534 4.7-4.699.042-.045.046-.042.678-.68.006.005L22.347 3.3l.291-.292a1.852 1.852 0 00-.137-2.466z" />
      </svg>
      <p class="text-center" style="max-width:40ch;">All players are ready to play. You may now enable Players Prepare
        and Start the {% if run.multiplayer %}Tournament{% else %}Practice{% endif %} game.</p>
      {% comment %} {% if next_url %}
      <p>
        <a href="{{ next_url }}" class="button large">Next Step</a>
      </p>
      {% endif %} {% endcomment %}
    </div>
  </div>
  {% endif %}
  <div class="player-col">
    <div class="player-header">
      <p class="walkthrough-chapter-heading">Players List</p>
    </div>
    <div class="team-scroll is-taller">
      {% if run.status >= run.STATUS.PLAY and run.multiplayer %}
      {% for team, team_players in teams.items %}
      <div class="card player-card glow-shadow team-card">
        <div class="player-item is-header">
          <h2 class="player-card-heading">
            {{ team }}
          </h2>
        </div>
        {% for player in team_players %}
        {% includecontents "simpl/includes/player.html" %}{% endincludecontents %}
        {% endfor %}
      </div>
      {% endfor %}
      {% else %}
      <div class="card player-card glow-shadow team-card">
        {% for player in players %}
        {% includecontents "simpl/includes/player.html" %}
        {% if player.character %}
        {%  if not player.character.instance.date_end %}
        <span class="status-flag is-player">Active</span>
        {% else %}
        <span class="status-flag is-finished">Done</span>
        {% endif %}
        {% else %}
        {% includecontents "simpl/includes/dropdown.html" %}
        {% includecontents "simpl/includes/dropdown-item.html" with post=True %}
        Mark inactive
        {% contents extra %}<input type="hidden" name="deactivate" value="{{ player.pk }}">{% endcontents %}
        {% endincludecontents %}
        {% endincludecontents %}
        {% endif %}
        {% endincludecontents %}
        {% endfor %}
      </div>
      {% endif %}

      {% if inactive_players %}
      <div class="player-header is-nested">
        <p class="walkthrough-chapter-heading">Inactive Players</p>
      </div>
      <div class="card player-card glow-shadow team-card is-inactive-player">
        {% for player in inactive_players %}
        {% includecontents "simpl/includes/player.html" %}
        {% if run.status <= run.STATUS.PREPARE %}
        {% includecontents "simpl/includes/dropdown.html" %}
        {% includecontents "simpl/includes/dropdown-item.html" with post=True %}
        Mark active
        {% contents extra %}<input type="hidden" name="reactivate" value="{{ player.pk }}">{% endcontents %}
        {% endincludecontents %}
        {% endincludecontents %}
        {% endif %}
        {% endincludecontents %}
        {% endfor %}
      </div>
      {% endif %}

      {% if invites %}
      <div class="player-header">
        <p class="walkthrough-chapter-heading">Invites Sent</p>
      </div>
      <div class="card player-card glow-shadow team-card is-inactive-player">
        {% for player in invites %}
        {% includecontents "simpl/includes/player.html" %}{% endincludecontents %}
        {% endfor %}
      </div>
      {% endif %}
    </div>

  </div>
</div>

{% endblock %}
