{"version":3,"file":"js/splits/account.js","sources":["webpack:///./org_colony/cartridge/js/giftcert.js","webpack:///./org_colony/cartridge/js/login.js","webpack:///./org_colony/cartridge/js/pages/login/mfaDialog.js","webpack:///./org_colony/cartridge/js/paymentutils.js"],"sourcesContent":["const ajax = require('./ajax');\nconst minicart = require('./minicart');\nconst util = require('./util');\n\nconst setAddToCartHandler = (event) => {\n    event.preventDefault();\n    const form = $(event.currentTarget).closest('form');\n\n    const options = {\n        url: util.ajaxUrl(form.attr('action')),\n        method: 'POST',\n        cache: false,\n        data: form.serialize(),\n    };\n    $.ajax(options).done((data) => {\n        if (data.success) {\n            ajax.load({\n                url: Urls.minicartGC,\n                data: {lineItemId: data.result.lineItemId},\n                callback(response) {\n                    minicart.show(response);\n                    form.find('input,textarea').val('');\n                },\n            });\n        } else {\n            form.find('span.error').hide();\n            Object.keys(data.errors.FormErrors).forEach((id) => {\n                let $errorEl = $(`#${id}`).addClass('error').removeClass('valid').next('.error');\n                if (!$errorEl || $errorEl.length === 0) {\n                    $errorEl = $(`<span for=\"${id}\" generated=\"true\" class=\"error\" style=\"\"></span>`);\n                    $(`#${id}`).after($errorEl);\n                }\n                $errorEl.text(data.errors.FormErrors[id].replace(/\\\\'/g, '\\'')).show();\n            });\n        }\n    }).fail((xhr, textStatus) => {\n        if (textStatus === 'parsererror') {\n            window.alert(Resources.BAD_RESPONSE);\n        } else {\n            window.alert(Resources.SERVER_CONNECTION_ERROR);\n        }\n    });\n};\n\nexports.init = () => {\n    $('#AddToBasketButton').on('click', setAddToCartHandler);\n};\n","const dialog = require('./dialog');\nconst page = require('./page');\nconst util = require('./util');\nconst validator = require('./validator');\nconst mfaDialog = require('./pages/login/mfaDialog');\n\nconst login = {\n    /**\n     * @private\n     * @function\n     * @description init events for the loginPage\n     */\n    init() {\n        // o-auth binding for which icon is clicked\n        $('.oAuthIcon').bind('click', (event) => {\n            $('#OAuthProvider').val(event.currentTarget.id);\n        });\n\n        // toggle the value of the rememberme checkbox\n        $('#dwfrm_login_rememberme').bind('change', () => {\n            if ($('#dwfrm_login_rememberme').attr('checked')) {\n                $('#rememberme').val('true');\n            } else {\n                $('#rememberme').val('false');\n            }\n        });\n\n        const $passwordReset = $('#password-reset');\n        $passwordReset.on('click', (e) => {\n            e.preventDefault();\n            const $target = $(e.target);\n            const isLegacy = $target.hasClass('legacy');\n            const url = $target.attr('href');\n            dialog.open({\n                url: isLegacy ? util.appendParamToURL(url, 'email', $('.email input').val()) : url,\n                options: {\n                    title: isLegacy ? Resources.TITLE_FORGOTPASSWORDLEGACY : Resources.TITLE_FORGOTPASSWORD,\n                    dialogClass: 'ui-dialog-resetpass',\n                    height: 'auto',\n                    open() {\n                        validator.init();\n                        const $requestPasswordForm = $('[name$=\"_requestpassword\"]');\n                        const $submit = $requestPasswordForm.find('[name$=\"_requestpassword_send\"]');\n                        $($submit).on('click', (event) => {\n                            if (!$requestPasswordForm.valid()) {\n                                return;\n                            }\n                            event.preventDefault();\n                            let data = $requestPasswordForm.serialize();\n                            // add form action to data\n                            data += `&${$submit.attr('name')}=`;\n                            // make sure the server knows this is an ajax request\n                            if (data.indexOf('ajax') === -1) {\n                                data += '&format=ajax';\n                            }\n                            $.ajax({\n                                type: 'POST',\n                                url: $requestPasswordForm.attr('action'),\n                                data,\n                                success(response) {\n                                    if (typeof response === 'object'\n                                            && !response.success\n                                            && response.error === 'CSRF Token Mismatch') {\n                                        page.redirect(Urls.csrffailed);\n                                    } else if (typeof response === 'string') {\n                                        dialog.$container.html(response);\n                                    }\n                                },\n                                failure() {\n                                    dialog.$container.html(`<h1>${Resources.SERVER_ERROR}</h1>`);\n                                },\n                            });\n                        });\n                    },\n                },\n            });\n        });\n\n        // Trigger password reset dialog if marked as legacy\n        if ($passwordReset.hasClass('legacy')) {\n            $passwordReset.click();\n        }\n\n        const $mfaDialogTarget = $(mfaDialog.MFA_DIALOG_SELECTOR);\n        if ($mfaDialogTarget.length) {\n            mfaDialog.openMfaDialog();\n            mfaDialog.handleKeyPress();\n        }\n    },\n};\n\nmodule.exports = login;\n","const dialog = require('../../dialog');\nconst validator = require('../../validator');\n\nconst MFA_DIALOG_SELECTOR = '#mfa-dialog';\nconst MFA_INPUT_SELECTOR = '#dwfrm_login_otp';\nconst VERIFY_OTP_SELECTOR = '#cta-verifyotp';\n\nconst $body = $('body');\n\nfunction handleKeyPress() {\n    $body.on('keypress', MFA_INPUT_SELECTOR, (event) => {\n        if (event.key === 'Enter') {\n            // Prevent default form submission\n            event.preventDefault();\n\n            // Focus and Trigger click event on submit button\n            $(VERIFY_OTP_SELECTOR).trigger('focus').trigger('click');\n        }\n    });\n}\n\nfunction openMfaDialog() {\n    const $mfaDialogContainer = $(MFA_DIALOG_SELECTOR);\n    const mfaDialogUrl = $mfaDialogContainer.attr('href');\n    dialog.open({\n        url: mfaDialogUrl,\n        options: {\n            title: Resources.AUTHENTICATION,\n            width: 300,\n            draggable: false,\n            modal: true,\n            closeOnEscape: false,\n            dialogClass: 'no-close',\n            open() {\n                validator.init();\n                document.getElementById(MFA_INPUT_SELECTOR).focus();\n            },\n            beforeClose() {\n                // Prevent closing when clicking outside\n                return false;\n            },\n        },\n    });\n}\n\nmodule.exports = {\n    MFA_DIALOG_SELECTOR,\n    openMfaDialog,\n    handleKeyPress,\n};\n","const paymentutils = {\n    /** Begin other payment amount validation* */\n    validateOtherPaymentAmount() {\n        const isOtherPayment = $('#dwfrm_accountpayment_amountChoice_other').is(':checked');\n        // If other payment is not selected return true to allow forms submission so no validation is needed\n        if (!isOtherPayment) {\n            return true;\n        }\n        const pendingPayments = parseFloat($('.payment-row.other-payment label').first().data('pendingpayment')).toFixed('2');\n        const accountBalance = parseFloat($('.payment-row.other-payment label').first().data('currentbalance')).toFixed('2');\n        // If the other payment amount is less than or equal to the account balance plus any pending payments return true\n        const isValidPayment = $('#dwfrm_accountpayment_otherAmount').val() <= (accountBalance - pendingPayments);\n        if (isValidPayment) {\n            return true;\n        }\n        return false;\n    },\n    /** End other payment amount validation* */\n\n    /** Start bank routing number validation* */\n    validateRoutingNumber() {\n        // If any of the possible bank account radio buttons are checked we are utilizing at least one set of ACH fields\n        const isBankPaymentMethod = $('#dwfrm_accountpayment_paymentMethods_selectedPaymentMethodID_ACH').is(':checked') || $('#dwfrm_accountautopay_accountpayment_paymentMethods_selectedPaymentMethodID_ACH').is(':checked') || $('#is-ACH').is(':checked');\n        // If a bank account is not in use return true indicating validation is not needed and to proceed\n        if (isBankPaymentMethod) {\n            // Routing number fields should have class .routing-field added to the field to apply routing number validation\n            const routingNumberField = $('.routing-field');\n            const routingNumberResults = {};\n            // Loop through routing number fields\n            for (let i = 0; i < routingNumberField.length; i += 1) {\n                // Check the current routing number field if it is visible the user is utilizing it\n                const isFieldInUse = $(routingNumberField[i]).is(':visible');\n                if (isFieldInUse) {\n                    // Build results object out using field id + the results of passing the routing number into the validation helper\n                    const routingFieldName = $(routingNumberField[i]).find('input').attr('id');\n                    const routingFieldNumber = $(routingNumberField[i]).find('input').val();\n                    routingNumberResults[routingFieldName] = this.checkRoutingNumber(routingFieldNumber);\n                }\n            }\n            return routingNumberResults;\n        }\n        return true;\n    },\n\n    checkRoutingNumber(routingNumber) {\n        // Verify length routing numbers need to be exactly 9 digits\n        if (routingNumber.length === 9) {\n            let n = 0;\n            let i;\n            // Standard formula for routing number validation\n            for (i = 0; i < routingNumber.length; i += 3) {\n                n += parseInt(routingNumber.charAt(i), 10) * 3\n                + parseInt(routingNumber.charAt(i + 1), 10) * 7\n                + parseInt(routingNumber.charAt(i + 2), 10);\n            }\n            // If the resulting sum is an even multiple of ten (but not zero), the routing number is good.\n            if (n !== 0 && n % 10 === 0) {\n                return true;\n            }\n            return false;\n        }\n        return false;\n    },\n    /** End bank routing number validation* */\n};\n\nmodule.exports = paymentutils;\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;AC9CA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;AC3FA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACjDA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;;;;A","sourceRoot":""}