define('bitbucket/internal/mirroring/setup', [
    'jquery'
], function(
    $
) {
    'use strict';

    return {
        onReady: function () {
            var $upstream = $("#upstreamUrl").closest(".field-group");
            var $cloudNext = $("#cloudNext").closest(".field-group");

            function updateUi(isServer) {
                $upstream.toggleClass('hidden', !isServer);
                $cloudNext.toggleClass('hidden', isServer);
            }

            $("#upstreamType").find('input').on('change', function () {
                var val = $(this).val();
                var isServer = val === 'server';
                updateUi(isServer);
            });
        }
    };
});

jQuery(document).ready(function () {
    require('bitbucket/internal/mirroring/setup').onReady();
});