extends ../layout-marketing
include ../_mixins/recaptcha

block content
	- var showCaptcha = settings.recaptcha && settings.recaptcha.siteKey && !(settings.recaptcha.disabled && settings.recaptcha.disabled.passwordReset)

	if showCaptcha
		script(type="text/javascript", nonce=scriptNonce, src="https://www.recaptcha.net/recaptcha/api.js?render=explicit")
		div(
			id="recaptcha"
			class="g-recaptcha"
			data-sitekey=settings.recaptcha.siteKey
			data-size="invisible"
			data-badge="inline"
		)

	main.content.content-alt#main-content
		.container-custom-sm.mx-auto
			.card
				form(
					data-ol-async-form
					name="passwordResetForm"
					action="/user/password/reset",
					method="POST",
					captcha=(showCaptcha ? '' : false),
					captcha-action-name=(showCaptcha ? "passwordReset" : false),
				)
					if error === 'password_reset_token_expired'
						h3.mt-0.mb-2 #{translate("sorry_your_token_expired")}
						p #{translate('please_request_a_new_password_reset_email_and_follow_the_link')}.
					else
						h3.mt-0.mb-2(data-ol-not-sent) #{translate("password_reset")}
						h3.mt-0.mb-2(hidden data-ol-sent) #{translate("check_your_email")}	
						p(data-ol-not-sent) #{translate("enter_your_email_address_below_and_we_will_send_you_a_link_to_reset_your_password")}.

					div(data-ol-not-sent)
						+formMessages()
						if error && error !== 'password_reset_token_expired'
							div.alert.alert-danger.mb-2(
								role="alert"
								aria-live="assertive"
							)
								| #{translate(error)}

						input(type="hidden", name="_csrf", value=csrfToken)
						.form-group.mb-3
							label(for='email') #{translate("email")}
							input.form-control#email(
								aria-label="email"
								type='email',
								name='email',
								placeholder=translate("enter_your_email_address"),
								required,
								autocomplete="username",
								autofocus
							)
						.actions
							button.btn.btn-primary.w-100(
								type='submit',
								data-ol-disabled-inflight,
								aria-label=translate('request_password_reset_to_reconfirm')
							)
								span(data-ol-inflight="idle")
									| #{translate("request_password_reset")}
								span(hidden data-ol-inflight="pending")
									| #{translate("requesting_password_reset")}…
					div(hidden data-ol-sent)
						p.mb-4 #{translate('password_reset_email_sent')}
						a(href="/login") #{translate('back_to_log_in')}

			if showCaptcha
				+recaptchaConditions
