(function ($) {
    'use strict';

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

        var mode = $form.find('input[name="maca_onboarding_content_mode"]:checked').val()
            || $form.data('contentMode')
            || 'files';

        $form.attr('data-content-mode', mode);
        $form.find('.maca-onboarding-branch').each(function () {
            var branchMode = $(this).data('mode');
            $(this).prop('hidden', branchMode !== mode);
        });
    }

    $(document).on('change', 'input[name="maca_onboarding_content_mode"]', syncMenuTypeBranches);
    $(syncMenuTypeBranches);
}(jQuery));
