{#
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.
-#}

{% set consent_page = true %}

{% extends "base.html" %}

{% block content %}
  {% set client_name = client.client_name or client.client_id %}
  <header class="page-heading">
    {% if client.logo_uri %}
    <img class="consent-client-icon image" referrerpolicy="no-referrer" src="{{ client.logo_uri }}" />
    {% else %}
    <div class="consent-client-icon generic">
      {{ icon.web_browser() }}
    </div>
    {% endif %}

    <div class="header">
      <h1 class="title">{{ _("mas.consent.heading") }}</h1>
      <p class="text [&>span]:whitespace-nowrap">
        {{ _("mas.consent.client_wants_access", client_name=client_name, redirect_uri=(grant.redirect_uri | simplify_url)) }}
        {{ _("mas.consent.this_will_allow", client_name=client_name) }}
      </p>
    </div>
  </header>

  <section class="consent-scope-list">
    {{ scope.list(scopes=grant.scope) }}
  </section>

  <section class="text-center cpd-text-secondary cpd-text-body-md-regular [&>span]:whitespace-nowrap">
    <strong class="font-semibold cpd-text-primary [&>span]:whitespace-nowrap">{{ _("mas.consent.make_sure_you_trust", client_name=client_name) }}</strong>
    {{ _("mas.consent.you_may_be_sharing") }}
    {% if client.policy_uri or client.tos_uri %}
      Find out how <span>{{ client_name }}</span> will handle your data by reviewing its
      {% if client.policy_uri %}
        <a target="_blank" href="{{ client.policy_uri }}" class="cpd-link" data-kind="primary">privacy policy</a>{% if not client.tos_uri %}.{% endif %}
      {% endif %}
      {% if client.policy_uri and client.tos_uri%}
        and
      {% endif %}
      {% if client.tos_uri %}
        <a target="_blank" href="{{ client.tos_uri }}" class="cpd-link" data-kind="primary">terms of service</a>.
      {% endif %}
    {% endif %}
  </section>

  <section class="flex flex-col gap-6">
    <form method="POST" class="cpd-form-root">
      <input type="hidden" name="csrf" value="{{ csrf_token }}" />
      {{ button.button(text=_("action.continue")) }}
    </form>

    <div class="flex gap-1 justify-center items-center">
      <p class="cpd-text-secondary cpd-text-body-md-regular">
        {{ _("mas.not_you", username=current_session.user.username) }}
      </p>

      {{ logout.button(text=_("action.sign_out"), csrf_token=csrf_token, post_logout_action=action, as_link=true) }}
    </div>

    {{ back_to_client.link(
      text=_("action.cancel"),
      kind="tertiary",
      uri=grant.redirect_uri,
      mode=grant.response_mode,
      params=dict(error="access_denied", state=grant.state)
    ) }}
  </section>
{% endblock content %}
