jQuery(document).ready(function ($) {
    // Debug functionality for testing uploads
    if (typeof cloud_uploads_vars !== 'undefined') {
        console.log('Cloud Uploads Debug Mode Active');

        // Monitor media uploads
        $(document).on('click', '.media-modal .media-button-insert', function () {
            console.log('Media upload completed - checking S3 sync...');

            // Check if any new attachments were uploaded
            setTimeout(function () {
                $.ajax({
                    url: cloud_uploads_vars.ajax_url,
                    type: 'POST',
                    data: {
                        action: 'cloud_uploads_get_stats',
                        nonce: cloud_uploads_vars.nonce
                    },
                    success: function (response) {
                        console.log('Cloud Uploads Stats:', response.data);
                    }
                });
            }, 3000);
        });
    }
});