import re


def clean_progress_output(output):
    """Return output cleaned from \\r, \\n, and ANSI escape sequences"""
    return re.sub(
        r"""(?x)      # Matches:
        \n|\r|        # 1. newlines or carriage returns, or
        (\x1b\[|\x9b) # 2. ANSI control sequence introducer ("ESC[" or single
                      #    byte \x9b) +
        [^@-_]*[@-_]| #    private mode characters + command character, or
        \x1b[@-_]     # 3. ANSI control codes without sequence introducer
                      #    ("ESC"  + single command character)
        """,
        '', output)