(function ($) {
    'use strict';

    $(function () {
        var $form = $('.maca-payments-settings-form');
        if (!$form.length) {
            return;
        }

        var initialTab = $form.data('active-tab');
        $('.maca-payments-settings-panel').each(function () {
            var $panel = $(this);
            $panel.toggleClass('is-active', $panel.data('payments-tab') === initialTab);
        });

        $('.maca-payments-settings-tabs .nav-tab').on('click', function () {
            var tab = $(this).data('payments-tab');
            if (tab) {
                $('#maca_payments_tab').val(tab);
            }
        });
    });
})(jQuery);
