function extraSettings(baseUrl, additionalPath) {
    (document.getElementById("extraSettingsRedirectURL").value = baseUrl.concat(additionalPath)),
        document.getElementById("showExtraSettings").submit();

}
function mo_registration_valid_query(inputElement) {
    /^[a-zA-Z?,.\(\)\/@ 0-9]*$mo/.test(inputElement.value) ||
        (inputElement.value = inputElement.value.replace(/[^a-zA-Z?,.\(\)\/@ 0-9]/, ""));
}

function calculateCharacterCount($this) {
    var characterCount = ($mo = jQuery)($this).val().length,
    elem = $mo("span#remaining");

    var field_id = $mo($this).attr('id');
    var elem = $mo('span[id^="remaining_'+field_id+'"]');

    elem.html(160 - characterCount),
        characterCount > 160
            ? elem.parent("span").addClass("limit")
            : elem.parent("span").removeClass("limit");
}

/*function toggleSupportForm(a) {
    var b = $mo("#mowc_support_form").prev(".mo_customer_validation-modal-backdrop");
    ("toggle" !== a && b.is(":hidden")) ||
        $mo("#mowc_support_form").slideToggle(400, function () {
            b.is(":hidden") ? b.show() : b.hide(),
                b.is(":hidden") && $mo(".mo-otp-help-button-text").show();
        });
}*/

function updateFormValues(inputElement, updateThirdField) {
    var inputValue = $mo(inputElement).val(),
        inputId = $mo(inputElement).attr("id");
    $mo(inputElement).attr("name"),
        $mo(
            (id1 =
                "#" +
                (inputId.indexOf("_1_") >= 0
                    ? inputId.replace("_1_", "_2_")
                    : inputId.indexOf("_3_") >= 0
                    ? inputId.replace("_3_", "_1_")
                    : inputId.replace("_2_", "_1_")))
        ).val(inputValue),
        updateThirdField &&
            $mo(
                (id2 =
                    "#" +
                    (inputId.indexOf("_1_") >= 0
                        ? inputId.replace("_1_", "_3_")
                        : inputId.indexOf("_3_") >= 0
                        ? inputId.replace("_3_", "_2_")
                        : inputId.replace("_2_", "_3_")))
            ).val(inputValue);
}
function scrollToForm(formName) {
    $mo("#moblock").hide(),
        $mo("#mo_forms .mo_otp_note #text").show(),
        $mo("#mo_forms .mo_otp_note #loader").hide(),
        $mo(".mo_otp_form").each(function (index) {
            if (
                ($row = $mo(this)).find("strong:first").text().toLowerCase() ===
                formName.toLowerCase()
            )
                return moScrollTo($row.parent()), !1;
        });
}
function moScrollTo(targetElement) {
    $mo("html, body").animate({ scrollTop: $mo(targetElement).offset().top - 100 }, 900);
}
function hideDiv(arrowElement) {
    arrowElement.removeClass("dashicons-arrow-down"),
        arrowElement.addClass("dashicons-arrow-up"),
        arrowElement.data("show", "true");
}
function showDiv(arrowElement) {
    arrowElement.removeClass("dashicons-arrow-up"),
        arrowElement.addClass("dashicons-arrow-down"),
        arrowElement.data("show", "false");
}
function mowc_otp_feedback_goback() {
    $mo("#mowc_support_form").hide();
}

function mowc_show_feedback_form(event, showNote, isDeactivation) {
    $mo(".mowc_deactivation_popup_container").show(), $mo(".mowc_deactivation_popup_wrapper").show(), showNote ? $mo(".mowc_feedback_note").show() : $mo(".mowc_feedback_note").hide(), $mo("#wc_feedback_type").val(!0);
    var submitButton = $mo("input[name='miniorange_wc_feedback_submit']:first");
    isDeactivation ? (submitButton.val(submitButton.data("sm")), event.preventDefault()) : ($mo("input[name='feedback_reason']").first().parent().hide(), submitButton.val(submitButton.data("sm2")), $mo("#mowc_skip_and_deactivate").remove());
}
function mo_otp_feedback_show_extra(event, feedbackElement) {
    var feedbackMessage = $mo("#feedback_message"),
        queryFeedback = $mo("#query_feedback");
    "" !== feedbackElement.data("message")
        ? (feedbackMessage.empty(), feedbackMessage.append(feedbackElement.data("message")), feedbackMessage.show())
        : feedbackMessage.hide(),
        feedbackElement.data("textbox") ? queryFeedback.show() : queryFeedback.hide();
}
function otpSupportOnClickWC(queryText) {
    document.getElementById('contactQuery').value = queryText;
    $mo("#contact-us-toggle").prop('checked', true);
    $mo(".mowc_contactus_popup_container").show();
    // $mo(".mo-otp-mail-button").length > 0 &&
    //     void 0 !== queryText &&
    //     queryText.length > 0 &&
    //     $mo("textarea#contactQuery").val(queryText),
    //     $mo("#contact-us-toggle").prop('checked', true);
}
function otpPackDetailsOnClick(packClass) {
    $mo("div." + packClass)
        .closest("div.details-front")
        .toggleClass("flip"),
        $mo("div." + packClass)
            .closest("div.details-front")
            .hasClass("flip")
            ? ($mo("div." + packClass)
                  .closest("div.details-front")
                  .addClass("hidden"),
              $mo("div.details-back" + packClass).addClass("flipped"))
            : ($mo("div." + packClass)
                  .closest("div.details-front")
                  .removeClass("hidden"),
              $mo("div.details-back" + packClass).removeClass("flipped"));
}
function otpAddonDetailsOnClick(addonClass) {
    $mo("div." + addonClass)
        .closest("div.details-front")
        .toggleClass("flip"),
        $mo("div." + addonClass)
            .closest("div.details-front")
            .hasClass("flip")
            ? ($mo("div." + addonClass)
                  .closest("div.details-front")
                  .addClass("hidden"),
              $mo("div.details-back" + addonClass).addClass("flipped"))
            : ($mo("div." + addonClass)
                  .closest("div.details-front")
                  .removeClass("hidden"),
              $mo("div.details-back" + addonClass).removeClass("flipped"));
}
function timeNow(timeInput) {
    var currentDate = new Date(),
        hours = (10 > currentDate.getHours() ? "0" : "") + currentDate.getHours(),
        minutes = (10 > currentDate.getMinutes() ? "0" : "") + currentDate.getMinutes();
    return (timeInput.value = hours + ":" + minutes), timeInput.value;
}
(jQuery.fn.mowcToggleDiv = function () {
    "false" === $mo(this).data("show")
        ? hideDiv($mo(this))
        : showDiv($mo(this)),
        $mo("#".concat($mo(this).data("toggle"))).slideToggle(400);
}),
    jQuery(document).ready(function () {
        ($mo = jQuery)(".mo_custom_message_enable").change(function (event) {
            "Template2" == event.target.defaultValue
                ? ($mo("#mo_custom_msg_template1").removeAttr("checked"),
                  $mo("#custom_sms_msg").val("Hello {#var#}"),
                  $mo("#mo_wc_custom_order_msg").val("Hello {#var#}"))
                : "Template1" == event.target.defaultValue &&
                  ($mo("#mo_custom_msg_template2").removeAttr("checked"),
                  $mo("#custom_sms_msg").val(
                      "You have received a message from {#var#}"
                  ),
                  $mo("#mo_wc_custom_order_msg").val(
                      "You have received a message from {#var#}"
                  ));
        }),
            $mo(".mo-otp-help-button"),
            $mo("#restart_tour_button"),
            window.location.href.slice(window.location.href.indexOf("?") + 1),
           
            $mo("#mowc_close_contactus").click(function () {
                $mo(".mowc_contactus_popup_container").hide();
            }),
            $mo('.mowc_remaining_characters').each(function() {
                calculateCharacterCount($mo(this));
            });
            $mo(".mowc_remaining_characters").keyup(function (a) {
                calculateCharacterCount(this);
            }),
            $mo("#ov_settings_button_float").click(function () {
                $mo("#ov_settings_button").trigger("click");
            }),
            $mo("input[name='check_btn']").click(function () {
                $mo("#mo_ln_form").submit();
            }),
            $mo("input[name='remove_accnt']").click(function () {
                $mo("#remove_accnt_form").submit();
            }),
            $mo(".form_preview").click(function () {
                window.open($mo(this).data("formlink"), "_blank");
            }),
            $mo("#mowc_feedback_cancel_btn").click(function (e) {
                mowc_otp_feedback_goback(), toggleSupportForm("hide");
            }),
            $mo(".registration_question").click(function () {
                $mo(this).next(".mo_registration_help_desc").slideToggle(400);
            }),
            $mo(".form_query").click(function () {
                $mo(
                    "#form_query_desc_".concat($mo(this).data("desc"))
                ).slideToggle(400);
            }),
            $mo("form[name='f']").submit(function () {
                $mo("#moblock").show();
            }),
            $mo(".mowc-toggle-div").click(function () {
                $mo(this).mowcToggleDiv();
            }),
            $mo(".mowc-formsettings-container").on(
                "click",
                "#wc_billing",
                function () {
                    $mo(this).is(":checked")
                        ? $mo("#wc_billing_options").show()
                        : $mo("#wc_billing_options").hide();
                }
            ),
            $mo(".mowc-formsettings-container").on(
                "click",
                "#wc_checkout_new",
                function () {
                    $mo(this).is(":checked")
                        ? $mo("#wc_checkout_new_options").show()
                        : $mo("#wc_checkout_new_options").hide();
                }
            ),
            $mo(".mowc-formsettings-container").on(
                "click",
                "#wc_checkout",
                function () {
                    $mo(this).is(":checked")
                        ? $mo("#wc_checkout_options").show()
                        : $mo("#wc_checkout_options").hide();
                }
            ),
            $mo(".mowc-formsettings-container").on(
                "click",
                "#wc_pv_default",
                function () {
                    $mo(this).is(":checked")
                        ? $mo("#wc_pv_default_options").show()
                        : $mo("#wc_pv_default_options").hide();
                }
            ),
            $mo(".mowc-formsettings-container").on(
                "click",
                "#wp_login",
                function () {
                    $mo(this).is(":checked")
                        ? $mo("#wp_login_options").show()
                        : $mo("#wp_login_options").hide();
                }
            ),
            $mo(".mowc-formsettings-container").on(
                "click",
                "#wc_default",
                function () {
                    $mo(this).is(":checked")
                        ? $mo("#wc_default_options").show()
                        : $mo("#wc_default_options").hide();
                }
            ),
            $mo(".mowc-formsettings-container").on(
                "click",
                "#wc_profile_form",
                function () {
                    $mo(this).is(":checked")
                        ? $mo("#wc_ac_default_options").show()
                        : $mo("#wc_ac_default_options").hide();
                }
            ),
            $mo("#wc_billing_phone_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_billing_option").removeClass("hidden");
                }
            ),
            $mo("#wc_billing_email_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_billing_option").addClass("hidden");
                }
            ),
            $mo("#wc_checkout_phone_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_checkout_option").removeClass("hidden");
                }
            ),
            $mo("#wc_checkout_email_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_checkout_option").addClass('hidden');
                         $mo("#wc_checkout_restrict_duplicates").prop("checked", false);
                }
            ),
            $mo("#wc_phone_pv_div").click(
                function () {
                         $mo("#wc_pv_phone_options").removeClass("hidden");
                }
            ),
            $mo("#wc_email_pv_div").click(
                function () {
                         $mo("#wc_pv_phone_options").addClass("hidden");
                         $mo("#wc_pv_restrict_duplicates").prop("checked", false);

                }
            ),
            $mo("#wc_phone_registration_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_registration_option").removeClass("hidden");
                         $mo("#wc_do_not_show_pop_up_option").removeClass("hidden");
                }
            ),
            $mo("#wc_email_registration_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_registration_option").addClass("hidden");
                         $mo("#wc_do_not_show_pop_up_option").removeClass("hidden");
                         $mo("#wc_registration_restrict_duplicates").prop("checked", false);
                }
            ),
            $mo("#wc_both_registration_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_registration_option").removeClass("hidden");
                         $mo("#wc_do_not_show_pop_up_option").addClass("hidden");
                         $mo("#wcreg_mo_view").prop("checked", false);
                }
            ),
            $mo("#wc_phone_login_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_login_option").removeClass("hidden");
                }
            ),
            $mo("#wc_email_login_div").click(
                function () {
                         $mo("#wc_restrict_duplicates_login_option").addClass("hidden");
                         $mo("#wp_login_reg").prop("checked", false);
                         $mo("#wp_login_admin").prop("checked", false);
                         $mo("#wp_login_duplicate").prop("checked", false);
                }
            ),
            $mo(".mo_otp_dropdown_note").click(function () {
                $mo("#".concat($mo(this).data("toggle"))).slideToggle(400);
            }),
            $mo(".mowc_registration_table_layout").on(
                "click",
                ".dropbtn",
                function () {
                    $mo(".modropdown-content").show();
                }
            ),
            $mo(".form_options").click(function () {
                var formData = $mo(this).data("form");
                if (void 0 !== formData) {
                    var formPrefix = formData.substr(0, formData.indexOf("_") + 1);
                    $mo(".".concat(formPrefix.concat("form"))).slideUp(400),
                        $mo("#".concat(formData.concat("_field"))).slideToggle(400);
                }
            }),
            $mo("#country_code").empty(),
            $mo("#country_code").append(
                $mo("#mo_country_code").find(":selected").data("countrycode")
            ),
            $mo("#mo_country_code").on("click", function () {
                var countryCode = $mo(this).find(":selected").data("countrycode");
                $mo("#country_code").empty(), $mo("#country_code").append(countryCode);
            }),
            $mo("#mo_wc_login").on("click", function () {
                // console.log(window.location.origin+window.location.pathname+"?page=mowcsettings");
                window.location.replace(window.location.origin+window.location.pathname+"?page=mowcsettings");
            }),
            $mo("#go_back_login").on("click", function () {
                // console.log(window.location.origin+window.location.pathname+"?page=mowcsettings");
                window.location.replace(window.location.origin+window.location.pathname+"?page=mowcsettings");
            }),
            $mo(
                "input[name=mo_customer_validation_formcraft_enable_type]"
            ).change(function () {
                $mo('input[name^="formcraft_form"]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="formcraft_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="formcraft_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="formcraft_form[verifyKey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="formcraft_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo(
                "input[name=mo_customer_validation_forminator_enable_type]"
            ).change(function () {
                $mo('input[name^="forminator_form"]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="forminator_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="forminator_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="forminator_form[verifyKey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="forminator_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo("input[name=mo_customer_validation_fm_enable_type]").change(
                function () {
                    $mo('input[name^="formmaker_form"]').each(function () {
                        $mo(this).val("");
                    });
                }
            ),
            $mo('input[name^="formmaker_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="formmaker_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="formmaker_form[verifyKey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="formmaker_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo(
                "input[name=mo_customer_validation_elementorproform_enable]"
            ).change(function () {
                $mo('input[name^="elementorproform_form  "]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="elementorproform_form[form]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="elementorproform_form[phonekey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="elementorproform_form[emailkey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="elementorproform_form[verifyKey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo(
                "input[name=mo_customer_validation_fcpremium_enable_type]"
            ).change(function () {
                $mo('input[name^="fcpremium_form"]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="fcpremium_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="fcpremium_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="fcpremium_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="fcpremium_form[verifyKey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo("input[name=mo_customer_validation_nja_enable_type]").change(
                function () {
                    $mo('input[name^="ninja_ajax_form"]').each(function () {
                        $mo(this).val("");
                    });
                }
            ),
            $mo('input[name^="ninja_ajax_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="ninja_ajax_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="ninja_ajax_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="ninja_ajax_form[verifyKey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo("input[name=mo_customer_validation_gf_contact_type]").change(
                function () {
                    $mo('input[name^="gravity_form"]').each(function () {
                        $mo(this).val("");
                    });
                }
            ),
            $mo('input[name^="gravity_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="gravity_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="gravity_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="gravity_form[verifyKey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo("input[name=mo_customer_validation_wpform_enable_type]").change(
                function () {
                    $mo('input[name^="wpform_form"]').each(function () {
                        $mo(this).val("");
                    });
                }
            ),
            $mo('input[name^="wpform_form[form]"]').change(function () {
                updateFormValues(this, 1);
            }),
            $mo('input[name^="wpform_form[phonekey]"]').change(function () {
                updateFormValues(this, 1);
            }),
            $mo('input[name^="wpform_form[emailkey]"]').change(function () {
                updateFormValues(this, 1);
            }),
            $mo('input[name^="wpform_form[verifyKey]"]').change(function () {
                updateFormValues(this, 1);
            }),
            $mo(
                "input[name=mo_customer_validation_caldera_enable_type]"
            ).change(function () {
                $mo('input[name^="caldera_form  "]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="caldera_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="caldera_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="caldera_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="caldera_form[verifyKey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo(
                "input[name=mo_customer_validation_user_reg_form_enable_type]"
            ).change(function () {
                $mo('input[name^="user_reg_form_form  "]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="user_reg_form_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="user_reg_form_form[phonekey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="user_reg_form_form[emailkey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="user_reg_form_form[verifyKey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo(
                "input[name=mo_customer_validation_everest_contact_enable_type]"
            ).change(function () {
                $mo('input[name^="everest_contact_form  "]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="everest_contact_form[form]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="everest_contact_form[phonekey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="everest_contact_form[emailkey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo('input[name^="everest_contact_form[verifyKey]"]').change(
                function () {
                    updateFormValues(this, 0);
                }
            ),
            $mo("input[name=mo_customer_validation_crf_default_enable]").change(
                function () {
                    $mo('input[name^="crf_form"]').each(function () {
                        $mo(this).val("");
                    });
                }
            ),
            $mo('input[name^="crf_form[form]"]').change(function () {
                updateFormValues(this, 1);
            }),
            $mo('input[name^="crf_form[phonekey]"]').change(function () {
                updateFormValues(this, 1);
            }),
            $mo('input[name^="crf_form[emailkey]"]').change(function () {
                updateFormValues(this, 1);
            }),
            $mo(".mo_registration_help_title").click(function (event) {
                event.preventDefault(),
                    $mo(this)
                        .next(".mo_registration_help_desc")
                        .slideToggle(400);
            }),
            $mo(
                "input[name=mo_customer_validation_bbp_restrict_duplicates]"
            ).click(function () {
                $mo(this).is(":checked")
                    ? $mo(
                          "input[name=mo_customer_validation_bbp_restrict_duplicates]"
                      ).prop("checked", !0)
                    : $mo(
                          "input[name=mo_customer_validation_bbp_restrict_duplicates]"
                      ).prop("checked", !1);
            }),
            $mo('input[name="mo_customer_validation_bbp_phone_key"]').change(
                function () {
                    updateFormValues(this, 1);
                }
            ),
            $mo(
                "input[name=mo_customer_validation_um_profile_restrict_duplicates]"
            ).click(function () {
                $mo(this).is(":checked")
                    ? $mo(
                          "input[name=mo_customer_validation_um_profile_restrict_duplicates]"
                      ).prop("checked", !0)
                    : $mo(
                          "input[name=mo_customer_validation_um_profile_restrict_duplicates]"
                      ).prop("checked", !1);
            }),
            $mo(
                "input[name=mo_customer_validation_wc_restrict_duplicates]"
            ).click(function () {
                $mo(this).is(":checked")
                    ? $mo(
                          "input[name=mo_customer_validation_wc_restrict_duplicates]"
                      ).prop("checked", !0)
                    : $mo(
                          "input[name=mo_customer_validation_wc_restrict_duplicates]"
                      ).prop("checked", !1);
            }),
            $mo(
                "input[name=mo_customer_validation_um_restrict_duplicates]"
            ).click(function () {
                $mo(this).is(":checked")
                    ? $mo(
                          "input[name=mo_customer_validation_um_restrict_duplicates]"
                      ).prop("checked", !0)
                    : $mo(
                          "input[name=mo_customer_validation_um_restrict_duplicates]"
                      ).prop("checked", !1);
            }),
            $mo(
                'input[name="mo_customer_validation_um_profile_phone_key"]'
            ).change(function () {
                updateFormValues(this, 1);
            }),
            $mo('input[name="mo_customer_validation_um_phone_key"]').change(
                function () {
                    updateFormValues(this, 1);
                }
            ),
            $mo("#um_both").change(function () {
                $mo(this).is(":checked") &&
                    $mo(
                        'input[name="mo_customer_validation_um_is_ajax_form"]'
                    ).is(":checked") &&
                    $mo(
                        'input[name="mo_customer_validation_um_is_ajax_form"]'
                    ).prop("checked", !1);
            }),
            $mo('input[name="mo_customer_validation_um_is_ajax_form"]').change(
                function () {
                    $mo(this).is(":checked") &&
                        $mo("#um_both").is(":checked") &&
                        ($mo("#um_both").prop("checked", !1),
                        $mo("#um_email").prop("checked", !0));
                }
            ),
            $mo(
                "input[name=mo_customer_validation_visual_form_enable_type]"
            ).change(function () {
                $mo('input[name^="visual_form"]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="visual_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="visual_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="visual_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo(
                "input[name=mo_customer_validation_frm_form_enable_type]"
            ).change(function () {
                $mo('input[name^="frm_form"]').each(function () {
                    $mo(this).val("");
                });
            }),
            $mo('input[name^="frm_form[form]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="frm_form[phonekey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="frm_form[verifyKey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo('input[name^="frm_form[emailkey]"]').change(function () {
                updateFormValues(this, 0);
            }),
            $mo("#lk_check1").change(function () {
                $mo("#lk_check2").is(":checked") &&
                    $mo("#lk_check1").is(":checked") &&
                    $mo("#activate_plugin").removeAttr("disabled");
            }),
            $mo("#lk_check2").change(function () {
                $mo("#lk_check2").is(":checked") &&
                    $mo("#lk_check1").is(":checked") &&
                    $mo("#activate_plugin").removeAttr("disabled");
            }),
            $mo(
                "input[name=mo_customer_validation_wp_reg_restrict_duplicates]"
            ).click(function () {
                $mo(this).is(":checked")
                    ? $mo(
                          "input[name=mo_customer_validation_wp_reg_restrict_duplicates]"
                      ).prop("checked", !0)
                    : $mo(
                          "input[name=mo_customer_validation_wp_reg_restrict_duplicates]"
                      ).prop("checked", !1);
            }),
            $mo(
                "input[name='mo_customer_validation_mrp_phone_field_key']"
            ).change(function () {
                updateFormValues(this, 1);
            }),
            $mo(".dropbtn").on("keyup", function () {
                var searchValue = $mo(this).val();
                $mo(".modropdown-content .search_box").each(function (index) {
                    ($row = $mo(this))
                        .find(".mo_search")
                        .data("value")
                        .toLowerCase()
                        .indexOf(searchValue.toLowerCase()) >= 0
                        ? $row.show()
                        : ($row.hide(),
                          $row
                              .find(".mo_search")
                              .data("value")
                              .indexOf("Can't") >= 0 && $row.show());
                });
            }),
            $mo(document).on("click", ".mo_search", function () {
                $mo(this).data("form"),
                    $mo(this).data("value"),
                    $mo("#moblock").show(),
                    $mo("#mo_forms .mo_otp_note").show(),
                    $mo("#mo_forms #form_details").hide(),
                    $mo("#mo_forms .mo_otp_note #text").hide(),
                    $mo("#mo_forms .mo_otp_note #loader").show();
            }),
            $mo("#mochoosecountry").on("change", function () {
                var sms_nonce = $mo("#mo_sms_pricing_nonce").val(),
                    country = $mo("#mochoosecountry").val();
                    document.getElementById("mosmspricing").innerHTML = "<option>loading....</option>";
                    $mo.ajax({
                        url: "admin-ajax.php",
                        type: "POST",
                        data: { target_country: country, security: sms_nonce, action: "miniorange_check_sms_pricing" },
                        crossDomain: !0,
                        dataType: "json",
                        success: function (pricingData) {
                            if(pricingData == null )
                            {   
                                document.getElementById("mosmspricing").innerHTML = "<option>Select a country to check pricing</option>";
                            }
                            else
                            {
                                $mo("#moloading").hide();
                                document.getElementById("mosmspricing").innerHTML = "";
                                var html = "";
                                for (const [key, value] of Object.entries(pricingData)) {
                                    html += "<option>" + key + " transactions - $" + value + "</option>";
                                }
                                document.getElementById("mosmspricing").innerHTML = html;
                            }  
                        },
                        error: function (jqXHR, textStatus, errorThrown) {},
                    });
            }),
            $mo("#custom_gateway_type").change(function () {
                var gatewayType = $mo(this).val(),
                    wpnonce = $mo("#_wpnonce").val();
                $mo("#moblock").show(),
                    $mo.ajax({
                        url: "admin-post.php",
                        type: "POST",
                        data: {
                            gateway_type: gatewayType,
                            action: "miniorange_get_gateway_config",
                            _wpnonce: wpnonce,
                        },
                        crossDomain: !0,
                        dataType: "json",
                        success: function (response) {
                            "success" === response.result &&
                                ($mo("#gateway_note").empty(),
                                $mo("#gateway_note").html(
                                    response.message
                                )),
                                $mo("#moblock").hide();
                        },
                        error: function (jqXHR, textStatus, errorThrown) {},
                    });
            }),
            $mo("#gateway_submit").click(function () {
                var testPhoneNumber = $mo("#mo_test_configuration_phone").val();
                $mo("#test_config_hide_response").show(),
                    $mo.ajax({
                        url: "admin-ajax.php",
                        type: "POST",
                        data: {
                            test_config_number: testPhoneNumber,
                            action: "miniorange_get_test_response",
                        },
                        crossDomain: !0,
                        dataType: "html",
                        success: function (responseHtml) {
                            $mo("#test_config_hide_response").css(
                                "display",
                                ""
                            ),
                                $mo("#test_config_response").val(responseHtml);
                        },
                        error: function (jqXHR, textStatus, errorThrown) {},
                    });
            }),
            $mo("#mo_backup_gateway").change(function () {
                var isBackupEnabled = !1;
                $mo(this).is(":checked") && (isBackupEnabled = !0),
                    $mo.ajax({
                        url: "admin-ajax.php",
                        type: "POST",
                        data: {
                            backup_gateway_enable: isBackupEnabled,
                            action: "miniorange_get_enable_bgateway",
                        },
                        crossDomain: !0,
                        dataType: "html",
                        success: function (response) {},
                        error: function (jqXHR, textStatus, errorThrown) {},
                    });
            }),
            $mo("#mo_generate_masterotp_for_user").click(function () {
                var currentTime = timeNow(master_otp_generation_time);
                $mo.ajax({
                    url: "admin-ajax.php",
                    type: "POST",
                    data: { cTime: currentTime, action: "miniorange_get_master_otp" },
                    crossDomain: !0,
                    dataType: "html",
                    success: function (masterOtp) {
                        $mo("#masterotp_user_textbox").val(masterOtp);
                    },
                    error: function (jqXHR, textStatus, errorThrown) {},
                });
            }),
            $mo(document).on("click", "#moAddGatewayParam", function () {
                $mo(".mo-gateway-body").append(
                    '<div class="mo-gateway-text-pair">                    <input class="mo-gateway-param" type="text" name="mo_post_param[]" placeholder="Parameter Name">                    <input class="mo-gateway-param" type="text" name="mo_post_value[]" placeholder="value">                    <input class="button button-primary mo-remove-button"                                type="button" id="moRemoveGatewayParam[]" name="moRemoveGatewayParam" value="x"/>                </div>'
                );
            }),
            jQuery(document).on(
                "click",
                "[name=moRemoveGatewayParam]",
                function () {
                    jQuery(this).parent().remove();
                }
            ),
            $mo(".show_configured_forms").click(function () {
                $mo("#moblock").show();
            }),
            $mo(".show_form_list").click(function () {
                $mo("#moblock").show();
            }),

              /*Code to Switch Between Sub Tabs*/
             $mo(".mowc-subtab-item").click(function(e){
                document.querySelectorAll(".mowc-subtab-item").forEach(occurance=>{
                    $mo(occurance).removeClass('mowc-subtab-item-active');
                });
                if(e.target.nodeName=='SPAN'){
                    $mo(e.target).parent().addClass("mowc-subtab-item-active");
                    var activeSubTab = $mo(e.target).attr('id');
                }
                else if(e.target.nodeName=='DIV'){
                    $mo(e.target).addClass("mowc-subtab-item-active");
                    var activeSubTab = $mo(e.target).children().attr('id');
                }        
                const url = new URL(window.location);
                url.searchParams.set('subpage', activeSubTab);
                window.history.pushState({}, '', url);
                changeActiveSubtab();
            });

            /*Code for Default Active Sub-Tab*/
            var subTab = getUrlParameter("subpage");
            if(subTab)
            {
                var activeSubTab = subTab;
                $mo("#"+activeSubTab).parent().addClass("mowc-subtab-item-active");
            } else
            {
                $mo($mo(".mowc-subtab-item")[0]).addClass("mowc-subtab-item-active");
            }

            function changeActiveSubtab()
            {
                $mo(".mowc-subpage-container").addClass("hidden");
                var subTab = getUrlParameter("subpage");
                $mo("#"+subTab+"Container").removeClass("hidden");
            }

            
        //get URL Parameter values
        function getUrlParameter(moParam) {
            var moPageURL = window.location.search.substring(1),
                moURLVariables = moPageURL.split('&'),
                moParameterName,
                i;

            for (i = 0; i < moURLVariables.length; i++) {
                moParameterName = moURLVariables[i].split('=');

                if (moParameterName[0] === moParam) {
                    return moParameterName[1] === undefined ? true : decodeURIComponent(moParameterName[1]);
                }
            }
            return false;
        }

            /*$mo(".show_support_form").click(function () {
                $mo(".mo-otp-help-button-text").hide(),
                    toggleSupportForm("toggle");
            }),
            $mo(".mo-otp-help-button-text").click(function () {
                $mo(".mo-otp-help-button-text").hide(),
                    toggleSupportForm("toggle");
            }),
            $mo(".mo_support_form_new_feature").click(function () {
                $mo(".mo-otp-help-button-text").hide(),
                    toggleSupportForm("toggle");
            }),*/
            $mo(".mo_otp_box").on("change", function () {
                $mo(".mo_otp_box").not(this).prop("checked", !1);
            }),
/*            $mo(".mo_customer_validation-modal-backdrop").click(function (a) {
                mo_otp_feedback_goback(), toggleSupportForm("hide");
            }),*/
            $mo(".feedback_radio").click(function (event) {
                mo_otp_feedback_show_extra(event, $mo(this));
            }),
            $mo(".feedback-modal").keypress(function (event) {
                27 === event.keyCode &&
                    (mo_otp_feedback_goback(), toggleSupportForm("hide"));
            }),
            $mo(
                'a[aria-label="Deactivate miniOrange OTP Verification and SMS Notification for WooCommerce"]'
            ).click(function (event) {
                mowc_show_feedback_form(event, !0, !0);
            }),
            $mo("#pmt_btn,#pmt_btn_addon").click(function () {
                $mo("html, body").animate(
                    { scrollTop: $mo("#otp_pay_method").offset().top - 50 },
                    500
                );
            }),
            $mo("#mo_firebase_gateway_plan").click(function () {
                $mo("html, body").animate(
                    {
                        scrollTop:
                            $mo("#mo_registration_firebase_layout").offset()
                                .top - 50,
                    },
                    500
                );
            }),
            $mo(".mo_support_form_new_firebase_feature").click(function () {
                var licensingUrl = $mo("#LicensingPlanButton").attr("href");
                window.location.href = licensingUrl + "#mo_registration_firebase_layout";
            }),
            $mo("#show_prem_addons_button").click(function () {
                var licensingUrl = $mo("#LicensingPlanButton").attr("href");
                window.location.href = licensingUrl + "&subpage=premaddons";
            }),
            $mo(
                "#show_custom_packages_button,#update_custom_packages_button"
            ).click(function () {
                var licensingUrl = $mo("#LicensingPlanButton").attr("href");
                window.location.href = licensingUrl + "&subpage=custpackage";
            }),
            $mo("#mowc_check_transactions").click(function () {
                $mo("form#mowc_check_transactions_form").submit();
            }),
            jQuery(document.body).on(
                "click",
                ".mo_notice .notice-dismiss",
                function (event) {
                    $mo.ajax({
                        url: "admin-ajax.php",
                        type: "POST",
                        data: { action: "mo_dismiss_notice" },
                        crossDomain: !0,
                        dataType: "json",
                        success: function () {
                            return !0;
                        },
                        error: function () {
                            return !1;
                        },
                    });
                }
            );
    });
