JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html>
    <body>
        <svg xmlns="http://www.w3.org/2000/svg"
        id="svgDoc"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        style="position:absolute; width:100%; height:100%"
        xmlns:ev="http://www.w3.org/2001/xml-events" version="1.1"
        baseProfile="full"
        preserveAspectRatio="xMinYMin meet"
        viewBox="0 0 1400 700">  
            <rect id="box" width="100" height="100" x="500" y="500" fill="red"/>
                <rect width="50" height="50" x="800" y="300" fill="blue" />                              
        </svg>                    
    </body>
</html>

JavaScript

var svg = document.getElementById("svgDoc");
var rect = svg.getElementById("box");
var pt = svg.createSVGPoint();

svg.addEventListener("mousedown", alert_click, false);

function alert_click(evt) {
    var cursorpt = cursorPoint(evt, box);
    console.log("(" + cursorpt.x + ", " + cursorpt.y + ")");
}
    
function cursorPoint(evt, element) {
    pt.x = evt.clientX; 
    pt.y = evt.clientY;
    
    if (element === null)
        return pt.matrixTransform(svg.getScreenCTM().inverse());
    else
        return pt.matrixTransform(element.getScreenCTM().inverse());
}