{% import "_includes/forms" as forms %}
{% set meta = meta is defined ? meta : false %}

{% if not craft.app.config.general.useEmailAsUsername %}
    {{ forms.textField({
        first: true,
        label: "Username"|t('app'),
        id: 'username',
        name: 'username',
        value: (user is defined ? user.username : null),
        autofocus: true,
        autocomplete: false,
        required: (isNewUser or (currentUser.admin or user.getIsCurrent()) ? true : false),
        disabled: (isNewUser or (currentUser.admin or user.getIsCurrent()) ? false : true),
        errors: (user is defined ? user.getErrors('username') : null)
    }) }}
{% endif %}

{% if not meta %}
<div class="flex">
    <div class="flex-grow">
{% endif %}
        {{ forms.textField({
            label: "First Name"|t('app'),
            id: 'firstName',
            name: 'firstName',
            value: user.firstName,
            autocomplete: false,
            errors: user.getErrors('firstName'),
            autofocus: craft.app.config.general.useEmailAsUsername
        }) }}
{% if not meta %}
    </div>
    <div class="flex-grow">
{% endif %}
        {{ forms.textField({
            label: "Last Name"|t('app'),
            id: 'lastName',
            name: 'lastName',
            value: user.lastName,
            autocomplete: false,
            errors: user.getErrors('lastName')
        }) }}
{% if not meta %}
    </div>
</div>
{% endif %}
