{#
SPDX-FileCopyrightText: 2026 Martin Kirchgessner

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{% from 'macros.jinja' import audio_player %}

<h2
    id="test-results-header"
    {% if not results %}
    class="has-text-danger"
    {% endif %}
    >
    Filter test: {{ nb_results }} results
</h2>
{% if results %}
<table class="table is-fullwidth is-striped is-hoverable">
    <thead>
        <tr><th colspan="3">
            Sample for filter <code>{{ query }}</code>:
        </th></tr>
    </thead>
    <tfoot>
        <tr><th colspan="3">
            <input type="hidden" name="filters[][filter]" value="{{ query }}">
            <button
                class="button is-primary"
                hx-trigger="click"
                hx-get="{{ url_for('autodj.testquery') }}"
                hx-target="#test-results"
                hx-include="previous input"
                >
                Re-sample
            </button>
            <button class="button is-danger" x-on:click="closeTest()">
                Close
            </button>
        </th></tr>
    </tfoot>
    <tbody>
        {% for item in results %}
        <tr>
            <td>{{ item.artist }}</td>
            <td>{{ item.title }}</td>
            <td>{{ audio_player(url_for('library.download', item_id=item.id)) }}</td>
        </tr>
        {% endfor %}
    </tbody>

</table>

{% endif %}
