{% load wagtailadmin_tags i18n %}
{% fragment as account_link %}<a class="w-underline" href="{% url 'wagtailadmin_account' %}">{% trans 'account' %}</a>{% endfragment %}
{% dialog icon_name="keyboard" classname="w-keyboard-shortcuts" id="keyboard-shortcuts-dialog" title=_("Keyboard shortcuts") %}
    {% if not keyboard_shortcuts_enabled %}
        {% help_block status="warning" %}
            <p>
                {% blocktrans trimmed %}
                    Keyboard shortcuts are currently disabled; manage your {{ account_link }} to enable them.
                {% endblocktrans %}
            </p>
        {% endhelp_block %}
    {% endif %}
    <table class="w-w-full">
        <caption class="w-sr-only">
            {% trans "All keyboard shortcuts" %}
        </caption>
        <thead class="w-sr-only">
            <tr>
                <th scope="col">{% trans "Section" %}</th>
                <th scope="col">{% trans "Keyboard shortcut" %}</th>
            </tr>
        </thead>
        {% block shortcuts %}
            {% for category, shortcuts in shortcuts.items %}
                <tbody class="w-w-full" id="keyboard-shortut-group-{{ category.0 }}">
                    <tr class="w-keyboard-shortcuts__category" colspan="2">
                        <th class="w-h4" scope="rowgroup">{{ category.1 }}</th>
                    </tr>
                    {% for shortcut in shortcuts %}
                        {% if shortcut %}
                            <tr class="w-keyboard_shortcuts__key">
                                <th scope="row">{{ shortcut.0 }}</th>
                                <td><kbd>{{ shortcut.1 }}</kbd></td>
                            </tr>
                        {% endif %}
                    {% endfor %}
                </tbody>
            {% endfor %}
        {% endblock %}
    </table>
    {% if keyboard_shortcuts_enabled %}
        {% help_block status="info" %}
            <p>
                {% blocktrans trimmed %}
                    Keyboard shortcuts are currently enabled; manage your {{ account_link }} to disable them.
                {% endblocktrans %}
            </p>
        {% endhelp_block %}
    {% endif %}
{% enddialog %}
