<script>
    document.addEventListener('click', function (event) {
        var button = event.target.closest('.js-toggle-password');
        if (!button) {
            return;
        }

        var wrap = button.closest('.js-password-wrap');
        var input = wrap ? wrap.querySelector('input') : null;
        var icon = button.querySelector('i');
        if (!input) {
            return;
        }

        var show = input.type === 'password';
        input.type = show ? 'text' : 'password';
        button.setAttribute('aria-label', show ? 'Hide password' : 'Show password');
        if (icon) {
            icon.classList.toggle('fa-eye', !show);
            icon.classList.toggle('fa-eye-slash', show);
        }
    });

    function normalizeEmailInput(input) {
        input.value = input.value.toLowerCase().replace(/\s+/g, '');
    }

    document.querySelectorAll('input[type="email"]').forEach(function (input) {
        input.setAttribute('autocapitalize', 'none');
        input.setAttribute('spellcheck', 'false');
        input.addEventListener('keydown', function (event) {
            if (event.key === ' ') {
                event.preventDefault();
            }
        });
        input.addEventListener('input', function () {
            normalizeEmailInput(input);
        });
        input.addEventListener('blur', function () {
            normalizeEmailInput(input);
        });
        input.addEventListener('paste', function () {
            setTimeout(function () {
                normalizeEmailInput(input);
            }, 0);
        });
    });

    if (window.jQuery && jQuery.fn.select2) {
        jQuery('.js-select2').each(function () {
            var $el = jQuery(this);
            var options = {
                width: '100%',
                placeholder: $el.data('placeholder') || 'Search and select',
                allowClear: true,
                closeOnSelect: ! $el.prop('multiple'),
            };

            if ($el.data('tags')) {
                options.tags = true;
            }

            $el.select2(options);
        });
    }
</script>
<?php /**PATH /Users/fasil/Sites/iqec/admin/resources/views/iqec/partials/form-helpers.blade.php ENDPATH**/ ?>