{#
Copyright 2024, 2025 New Vector Ltd.
Copyright 2022-2024 The Matrix.org Foundation C.I.C.

SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
-#}

{% macro button(csrf_token, text="", as_link=false, post_logout_action={}) %}
  <form method="POST" action="{{ "/logout" | prefix_url }}" class="inline-flex [&>button]:flex-1">
    <input type="hidden" name="csrf" value="{{ csrf_token }}" />
    {% for key, value in post_logout_action|items %}
      <input type="hidden" name="{{ key }}" value="{{ value }}" />
    {% endfor %}
    {% if caller is defined %}
      {{ caller() }}
    {% elif as_link %}
      <button class="cpd-link" data-kind="critical" type="submit">{{ text }}</button>
    {% else %}
      <button class="cpd-button destructive" data-kind="secondary" data-size="lg" type="submit">{{ text }}</button>
    {% endif %}
  </form>
{% endmacro %}
