<?php
/**
 * Copyright 2011 Adobe
 * All Rights Reserved.
 */

// phpcs:disable Generic.Files.LineLength.TooLong

/** @var \Magento\Customer\Block\Form\Login $block */
if (!$block->getButtonLockManager()) {
    // phpcs:ignore
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $block->setButtonLockManager(
        $objectManager->get(\Magento\Framework\View\Element\ButtonLockManager::class)
    );
}
/** @var $escaper \Magento\Framework\Escaper */
?>
<div class="block block-customer-login">
    <div class="block-title">
        <strong id="block-customer-login-heading" role="heading" aria-level="2"><?= $escaper->escapeHtml(__('Registered Customers')) ?></strong>
    </div>
    <div class="block-content" aria-labelledby="block-customer-login-heading">
        <form class="form form-login"
              action="<?= $escaper->escapeUrl($block->getPostActionUrl()) ?>"
              method="post"
              id="login-form"
              data-mage-init='{"validation":{}}'>
            <?= $block->getBlockHtml('formkey') ?>
            <fieldset class="fieldset login" data-hasrequired="<?= $escaper->escapeHtml(__('* Required Fields')) ?>">
                <div class="field note"><?= $escaper->escapeHtml(__('If you have an account, sign in with your email address.')) ?></div>
                <div class="field email required">
                    <label class="label" for="email"><span><?= $escaper->escapeHtml(__('Email')) ?></span></label>
                    <div class="control">
                        <input name="login[username]" value="<?= $escaper->escapeHtmlAttr($block->getUsername()) ?>"
                            <?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
                               id="email" type="email" class="input-text"
                               title="<?= $escaper->escapeHtmlAttr(__('Email')) ?>"
                               data-validate="{required:true, 'validate-email':true}">
                    </div>
                </div>
                <div class="field password required">
                    <label for="pass" class="label"><span><?= $escaper->escapeHtml(__('Password')) ?></span></label>
                    <div class="control">
                        <input name="login[password]" type="password"
                            <?php if ($block->isAutocompleteDisabled()): ?> autocomplete="off"<?php endif; ?>
                               class="input-text" id="password"
                               title="<?= $escaper->escapeHtmlAttr(__('Password')) ?>"
                               data-validate="{required:true}">
                    </div>
                </div>
                <div class="field choice" data-bind="scope: 'showPassword'">
                    <!-- ko template: getTemplate() --><!-- /ko -->
                </div>
                <?= $block->getChildHtml('form_additional_info') ?>
                <div class="actions-toolbar">
                    <div class="primary">
                        <button type="submit" class="action login primary" name="send" id="send2" <?php if ($block->getButtonLockManager()->isDisabled('customer_login_form_submit')): ?> disabled="disabled" <?php endif; ?>>
                            <span><?= $escaper->escapeHtml(__('Sign In')) ?></span>
                        </button>
                    </div>
                    <div class="secondary"><a class="action remind" href="<?= $escaper->escapeUrl($block->getForgotPasswordUrl()) ?>"><span><?= $escaper->escapeHtml(__('Forgot Your Password?')) ?></span></a></div>
                </div>
            </fieldset>
        </form>
    </div>
    <?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
    <script type="text/x-magento-init">
        {
            "*": {
                "Magento_Customer/js/block-submit-on-send": {
                    "formId": "login-form"
                },
                "Magento_Ui/js/core/app": {
                    "components": {
                        "showPassword": {
                            "component": "Magento_Customer/js/show-password",
                            "passwordSelector": "#password"
                        }
                    }
                }
            }
        }
    </script>
</div>
