jQuery detect mouseup on top of an element when the click started on a different element

I’m trying to detect when the mouse is released over a certain html element. I would like the mouseup event to fire no matter where the dragging started initially. Here is my attempt, which behaves very weirdly (sometimes it fires, sometimes not, sometimes I get two alerts):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>

        .box{
            background: rgb(255, 0, 0);
            width: 200px;
            aspect-ratio: 1;
        }

        .cube{
            background: #222;
            width: 200px;
            aspect-ratio: 1;
        }

    </style>

</head>
<body>

    <div class="box"></div>

    <div class="cube"></div>

    <script src="jquery-3.6.0.min.js"></script>
    <script src="jquery-ui.min.js"></script>

    <script>

        $( "body" ).click(function() {
          $( ".cube").mouseup(function(){
            alert('mouseup')
          });
        });


    </script>

    
</body>
</html>