{% macro account_row(dataset, current_account, config) %}

{% endmacro %}

{% macro account_collapsible(account, review=False, config = None, models=None, current_account=None) %}
<details class="collapsible account-collapsible" id="account-collapsible-{{ account.account_id }}">
    <summary class="collapsible-summary"
             hx-get="/accounts/{{ account.username }}/partial"
             hx-trigger="click once"
             hx-target="#account-{{ account.username }}">

        <span class="collapsible-marker"></span>
        <span class="account-username item-link">
            <a href="/accounts/{{ account.username }}">
                {{ account.username }}
            </a>
        </span>

        <span class="account-scopes tokens">
        {% if review %}
            {% for scope_name in models.Scopes.__members__.values() %}
                {% set disabled=(current_account and
                    (current_account.has_scope("root") and (scope_name == "root" or scope_name == "admin") and (current_account.username == account.username)) or
                    (((not current_account.has_scope("root")) and (current_account.has_scope("admin")) and (scope_name == "root" or scope_name == "admin"))))
                %}
                {% if account.has_scope(scope_name) %}
                    <button
                        class="toggle-button checked"
                        id="{{ account.username }}-scope-{{scope_name}}"
                        hx-delete="{{ config.api_prefix }}/accounts/{{ account.username }}/scopes/{{ scope_name }}"
                        hx-target="this"
                        hx-swap="outerHTML"
                        {% if disabled %}disabled{% endif %}
                    >
                        {{scope_name}}
                    </button>
                {% else %}
                    <button class="toggle-button"
                            id="{{ account.username }}-scope-{{scope_name}}"
                            hx-put="{{ config.api_prefix }}/accounts/{{ account.username }}/scopes/{{ scope_name }}"
                            hx-target="this"
                            hx-swap="outerHTML"
                            {% if disabled %}disabled{% endif %}
                    >{{scope_name
                        }}</button>
                {% endif %}

            {% endfor %}
        {% else %}
              {% for scope in account.scopes %}
              <span class="account-scope token">{{ scope.scope.value }}</span>
              {% endfor %}
        {% endif %}
        </span>
        <time class="account-timestamp timestamp" datetime="{{ account.created_at.strftime('%y-%m-%d %H:%M') }}Z">
            {{ account.created_at.strftime("%y-%m-%d %H:%M") }}
        </time>
        {% if review %}
        {% set suspend_disabled=not current_account or not current_account.can_suspend(account) %}
        <button class="button suspend-button success-button caution"
                hx-post="{{ config.api_prefix }}/accounts/{{ account.username }}/suspend"
                {% if suspend_disabled %}disabled{% endif %}
        >Suspend
        </button>
        {% endif %}
    </summary>
    <div class="account" id="account-{{ account.username }}"></div>
</details>
{% endmacro %}