"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseCoordinates = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var i18n_1 = require("../api/i18n");
var string_1 = require("../utils/string");
var dompurify_1 = require("dompurify");
function formatCoordinates(props) {
    var coords = props.coords, decimals = props.decimals, format = props.format, units = props.units;
    if (coords == null) {
        return null; //TODO: Use value indicated by EmptyText extension property
    }
    var x = coords[0], y = coords[1];
    var sfmt = format || "X: {x}, Y: {y} {units}";
    var str = (0, i18n_1.fmt)(sfmt, {
        x: "".concat(decimals != null ? x.toFixed(decimals) : x),
        y: "".concat(decimals != null ? y.toFixed(decimals) : y),
        units: units || ""
    });
    return React.createElement("span", { dangerouslySetInnerHTML: { __html: (0, dompurify_1.sanitize)((0, string_1.strTrim)(str)) } });
}
/**
 * Displays tracked mouse coordinates
 * @param props
 */
var MouseCoordinates = function (props) {
    return React.createElement("div", { className: "status-bar-component component-mouse-coordinates", style: props.style }, formatCoordinates(props));
};
exports.MouseCoordinates = MouseCoordinates;
//# sourceMappingURL=mouse-coordinates.js.map