{% extends "_layouts/message" %}
{% import "_includes/forms" as forms %}

{% if newUser %}
    {% set title = "Set Your Password"|t('app') %}
{% else %}
    {% set title = "Set Your New Password"|t('app') %}
{% endif %}

{% block message %}
    <form method="post" accept-charset="UTF-8">
        {{ hiddenInput('code', code) }}
        {{ hiddenInput('id', id) }}
        {{ csrfInput() }}

        <div>
            {{ forms.passwordField({
                id: 'newPassword',
                label: (newUser ? "Choose a password"|t('app') : "Choose a new password"|t('app')),
                name: 'newPassword',
                autocomplete: 'new-password',
                autofocus: true,
                errors: (errors is defined ? errors : null)
            }) }}
        </div>

        <div class="buttons">
            <button class="btn submit" type="submit">{{ 'Set Password'|t('app') }}</button>
        </div>
    </form>
{% endblock %}

{% js %}
    (() => {
        new Craft.PasswordInput($('#newPassword'));
    })();
{% endjs %}
