{#
  Copyright (C) 2023 CERN.
  Copyright (C) 2024 KTH Royal Institute of Technology.
  Invenio RDM Records is free software; you can redistribute it and/or modify
  it under the terms of the MIT License; see LICENSE file for more details.
-#}

{% from "invenio_accounts/_macros.html" import render_field, form_errors %}

<div class="container rel-mt-2">
  {%- if current_user.is_anonymous %}
    {% set email = None %}
    {% set full_name = None %}
    <p class="rel-mb-2">
      <i aria-hidden="true" class="user secret icon"></i>
      <strong>{{ _("You are currently not logged in") }}</strong>. {{ _("Do you have an account?") }}
      <a href="/login/">{{ _("Log in here") }}</a>
    </p>
  {% else %}
    {% set email = current_user.email %}
    {% set full_name = current_user.user_profile.full_name or "" %}
    <h4>{{ _("You are logged in as") }}</h4>
    <div class="flex align-items-center column-mobile mb-10">
      <div class="ui image label mb-10 rel-mr-1">
        <img src="{{ user_avatar }}" alt="" />
        <strong class="text-muted mr-5">{{ full_name }}</strong>
      </div>

      <p class="mt-0 mb-10">
        {{ _("Not you?") }}
        <a href="{{ url_for('security.login') }}">{{ _("Log out") }}</a> {{ _("to switch account.") }}
      </p>
    </div>
  {% endif %}
  <div id="access-request-form-root"
       data-record='{{ record | tojson }}'
       data-user-anonymous='{{ current_user.is_anonymous | tojson }}'
       data-user-full-name='{{ full_name | tojson }}'
       data-user-email='{{ email | tojson }}'>
    <div class="ui fluid placeholder">
      <div class="header">
        {%- if current_user.is_anonymous %}
        <div class="paragraph">
          <div class="line"></div>
          <div class="line"></div>
          <div class="line"></div>
          <div class="line"></div>
          <div class="line"></div>
        </div>
        {% endif %}
        <div class="full line"></div>
        <div class="full line"></div>
        <div class="full line"></div>
        <div class="full line"></div>
        <div class="full line"></div>
        <div class="full line"></div>
        <div class="full line"></div>
      </div>
    </div>
  </div>
</div>
  {%- block javascript %}
    {{ webpack['invenio-app-rdm-landing-page-access-form.js'] }}
  {%-endblock %}
