{% extends "admin/login.html" %}

{% load i18n static %}

{% block extrahead %}
    <script src="{% static 'passkeys/passkeys.js' %}"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const row = document.querySelector(".submit-row");
            const passkeyBtn = document.createElement("input");
            passkeyBtn.type = "button";
            passkeyBtn.value = "{% translate 'Passkey Login' %}";
            passkeyBtn.addEventListener("click", function() {
                authenticatePasskey('{% url "passkey-login" %}', '{% url "admin:index" %}');
                return false;
            });
            row.appendChild(passkeyBtn);

            const username = document.getElementById("id_username");
            username.autocomplete = "username webauthn";
            username.focus();

            maybeAuthenticate('{% url "passkey-login" %}', '{% url "admin:index" %}');
        });
    </script>
{% endblock %}
