{% extends "tablepage.html" %}
{% block head %}
    {{ super() }}
    <title>{{ player_name }}&apos;s Tracker</title>
    <link rel="stylesheet" type="text/css" href="{{ url_for("static", filename="styles/tracker.css") }}"/>
    <script type="application/ecmascript" src="{{ url_for("static", filename="assets/jquery.scrollsync.js") }}"></script>
    <script type="application/ecmascript" src="{{ url_for("static", filename="assets/trackerCommon.js") }}"></script>
{% endblock %}

{% block body %}
    {% include "header/dirtHeader.html" %}

    <div id="tracker-navigation">
        <div class="tracker-navigation-bar">
            <a
                class="tracker-navigation-button"
                href="{{ url_for("get_multiworld_tracker", tracker=room.tracker) }}"
            >
                 🡸 Return to Multiworld Tracker
            </a>
            {% if game_specific_tracker %}
            <a
                class="tracker-navigation-button"
                href="{{ url_for("get_player_tracker", tracker=room.tracker, tracked_team=team, tracked_player=player) }}"
            >
                Game-Specific Tracker
            </a>
            {% endif %}
        </div>
    </div>

    <div id="tracker-wrapper" data-tracker="{{ room.tracker | suuid }}/{{ team }}/{{ player }}" data-second="{{ saving_second }}">
        <div id="tracker-header-bar">
            <input placeholder="Search" id="search" />
            <div class="info">This tracker will automatically update itself periodically.</div>
        </div>
        <div id="tables-container">
            <div class="table-wrapper">
                <table id="received-table" class="table non-unique-item-table">
                    <thead>
                        <tr>
                            <th>Item</th>
                            <th>Amount</th>
                            <th>Last Order Received</th>
                        </tr>
                    </thead>
                    <tbody>

                    {% for id, count in inventory.items() if count > 0 %}
                        <tr>
                            <td>{{ item_id_to_name[game][id] }}</td>
                            <td>{{ count }}</td>
                            <td>{{ received_items[id] }}</td>
                        </tr>
                    {%- endfor -%}

                    </tbody>
                </table>
            </div>
            <div class="table-wrapper">
                <table id="locations-table" class="table non-unique-item-table">
                    <thead>
                        <tr>
                            <th>Location</th>
                            <th class="center-column">Checked</th>
                        </tr>
                    </thead>
                    <tbody>

                    {%- for location in locations -%}
                        <tr>
                            <td>{{ location_id_to_name[game][location] }}</td>
                            <td class="center-column">
                                {% if location in checked_locations %}✔{% endif %}
                            </td>
                        </tr>
                    {%- endfor -%}

                    </tbody>
                </table>
            </div>
            <div class="table-wrapper">
                <table id="hints-table" class="table non-unique-item-table">
                    <thead>
                        <tr>
                            <th>Finder</th>
                            <th>Receiver</th>
                            <th>Item</th>
                            <th>Location</th>
                            <th>Game</th>
                            <th>Entrance</th>
                            <th class="center-column">Found</th>
                        </tr>
                    </thead>
                    <tbody>
                    {%- for hint in hints -%}
                        <tr>
                            <td>
                                {% if hint.finding_player == player %}
                                    <b>{{ player_names_with_alias[(team, hint.finding_player)] }}</b>
                                {% elif get_slot_info(hint.finding_player).type == 2 %}
                                    <i>{{ player_names_with_alias[(team, hint.finding_player)] }}</i>
                                {% else %}
                                    <a href="{{ url_for("get_player_tracker", tracker=room.tracker, tracked_team=team, tracked_player=hint.finding_player) }}">
                                        {{ player_names_with_alias[(team, hint.finding_player)] }}
                                    </a>
                                {% endif %}
                            </td>
                            <td>
                                {% if hint.receiving_player == player %}
                                    <b>{{ player_names_with_alias[(team, hint.receiving_player)] }}</b>
                                {% elif get_slot_info(hint.receiving_player).type == 2 %}
                                    <i>{{ player_names_with_alias[(team, hint.receiving_player)] }}</i>
                                {% else %}
                                    <a href="{{ url_for("get_player_tracker", tracker=room.tracker, tracked_team=team, tracked_player=hint.receiving_player) }}">
                                        {{ player_names_with_alias[(team, hint.receiving_player)] }}
                                    </a>
                                {% endif %}
                            </td>
                            <td>{{ item_id_to_name[games[(team, hint.receiving_player)]][hint.item] }}</td>
                            <td>{{ location_id_to_name[games[(team, hint.finding_player)]][hint.location] }}</td>
                            <td>{{ games[(team, hint.finding_player)] }}</td>
                            <td>{% if hint.entrance %}{{ hint.entrance }}{% else %}Vanilla{% endif %}</td>
                            <td class="center-column">{% if hint.found %}✔{% endif %}</td>
                        </tr>
                    {%- endfor -%}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}
