{"version":3,"file":"../../js/llms-form-checkout.min.js","sources":["llms-form-checkout.js"],"sourcesContent":["/**\n * LifterLMS Checkout Screen related events and interactions\n *\n * @package LifterLMS/Scripts\n *\n * @since 3.0.0\n * @version 7.0.0\n */\n\n( function( $ ) {\n\n\tvar llms_checkout = function() {\n\n\t\t/**\n\t\t * Array of validation functions to call on form submission\n\t\t *\n\t\t * @type array\n\t\t * @since 3.0.0\n\t\t * @version 3.0.0\n\t\t */\n\t\tvar before_submit = [];\n\n\t\t/**\n\t\t * Array of gateways to be automatically bound when needed\n\t\t *\n\t\t * @type array\n\t\t * @since 3.0.0\n\t\t * @version 3.0.0\n\t\t */\n\t\tvar gateways = [];\n\n\t\tthis.$checkout_form = $( '#llms-product-purchase-form' );\n\t\tthis.$confirm_form = $( '#llms-product-purchase-confirm-form' );\n\t\tthis.$form_sections = false;\n\t\tthis.form_action = false;\n\n\t\t/**\n\t\t * Initialize checkout JS & bind if on the checkout screen\n\t\t *\n\t\t * @since 3.0.0\n\t\t * @since 3.34.5 Make sure we bind click events for the Show / Hide login area at the top of the checkout screen\n\t\t * even if there's no llms product purchase form.\n\t\t * @since 7.0.0 Disable smooth scroll-behavior on checkout.\n\t\t *\n\t\t * @return void\n\t\t */\n\t\tthis.init = function() {\n\n\t\t\tvar self = this;\n\n\t\t\tif ( $( '.llms-checkout-wrapper' ).length ) {\n\t\t\t\tthis.bind_login();\n\t\t\t}\n\n\t\t\tif ( this.$checkout_form.length ) {\n\n\t\t\t\tthis.form_action = 'checkout';\n\t\t\t\tthis.$form_sections = this.$checkout_form.find( '.llms-checkout-section' );\n\n\t\t\t\tthis.$checkout_form.on( 'submit', this, this.submit );\n\n\t\t\t\t/**\n\t\t\t\t * Fix `HTMLFormElement.reportValidity()` when `scroll-behavior: smooth`.\n\t\t\t\t *\n\t\t\t\t * @see {@link https://github.com/gocodebox/lifterlms/issues/2206}\n\t\t\t\t */\n\t\t\t\tdocument.querySelector( 'html' ).style.scrollBehavior = 'auto';\n\n\t\t\t\t// add before submit event for password strength meter if one's found\n\t\t\t\tif ( $( '.llms-password-strength-meter' ).length ) {\n\t\t\t\t\tthis.add_before_submit_event( {\n\t\t\t\t\t\tdata: LLMS.PasswordStrength,\n\t\t\t\t\t\thandler: LLMS.PasswordStrength.checkout,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tthis.bind_coupon();\n\n\t\t\t\tthis.bind_gateways();\n\n\t\t\t\t$( document ).trigger( \"llms-checkout-refreshed\" );\n\n\t\t\t} else if ( this.$confirm_form.length ) {\n\n\t\t\t\tthis.form_action = 'confirm';\n\t\t\t\tthis.$form_sections = this.$confirm_form.find( '.llms-checkout-section' );\n\n\t\t\t\tthis.$confirm_form.on( 'submit', function() {\n\t\t\t\t\tself.processing( 'start' );\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t};\n\n\t\t/**\n\t\t * Public function which allows other classes or extensions to add\n\t\t * before submit events to llms checkout private \"before_submit\" array\n\t\t *\n\t\t * @param object obj object of data to push to the array\n\t\t * requires at least a \"handler\" key which should pass a callable function\n\t\t * \"data\" can be anything, will be passed as the first parameter to the handler function\n\t\t * @since 3.0.0\n\t\t * @version 3.0.0\n\t\t */\n\t\tthis.add_before_submit_event = function( obj ) {\n\n\t\t\tif ( ! obj.handler || 'function' !== typeof obj.handler ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! obj.data ) {\n\t\t\t\tobj.data = null;\n\t\t\t}\n\n\t\t\tbefore_submit.push( obj );\n\n\t\t};\n\n\t\t/**\n\t\t * Add an error message\n\t\t *\n\t\t * @param string message error message string\n\t\t * @param mixed data optional error data to output on the console\n\t\t * @return void\n\t\t * @since 3.27.0\n\t\t * @version 3.27.0\n\t\t */\n\t\tthis.add_error = function( message, data ) {\n\n\t\t\tvar id = 'llms-checkout-errors';\n\t\t\t\t$err = $( '#' + id );\n\n\t\t\tif ( ! $err.length ) {\n\t\t\t\t$err = $( '