"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseTrackingTooltip = void 0;
var tslib_1 = require("tslib");
var Overlay_1 = tslib_1.__importDefault(require("ol/Overlay"));
var HIDDEN_CLASS_NAME = "tooltip-hidden";
var MouseTrackingTooltip = /** @class */ (function () {
    function MouseTrackingTooltip(map, contextMenuTest) {
        this.map = map;
        this.isContextMenuOpen = contextMenuTest;
        this.map.getViewport().addEventListener("mouseout", this.onMouseOut.bind(this));
        this.tooltipElement = document.createElement("div");
        this.tooltipElement.className = 'tooltip';
        this.tooltip = new Overlay_1.default({
            element: this.tooltipElement,
            offset: [15, 0],
            positioning: "center-left"
        });
        this.map.addOverlay(this.tooltip);
        this.text = null;
        this.tooltipElement.classList.add(HIDDEN_CLASS_NAME);
    }
    MouseTrackingTooltip.prototype.dispose = function () {
        this.tooltip.dispose();
    };
    MouseTrackingTooltip.prototype.onMouseMove = function (e) {
        if (this.isContextMenuOpen())
            return;
        this.tooltip.setPosition(e.coordinate);
        if (this.text)
            this.tooltipElement.classList.remove(HIDDEN_CLASS_NAME);
        else
            this.tooltipElement.classList.add(HIDDEN_CLASS_NAME);
    };
    MouseTrackingTooltip.prototype.onMouseOut = function () {
        this.tooltipElement.classList.add(HIDDEN_CLASS_NAME);
    };
    MouseTrackingTooltip.prototype.setText = function (prompt) {
        this.text = prompt;
        this.tooltipElement.innerHTML = this.text;
    };
    MouseTrackingTooltip.prototype.clear = function () {
        this.text = null;
        this.tooltipElement.innerHTML = "";
    };
    MouseTrackingTooltip.prototype.destroy = function () {
        if (this.tooltipElement && this.tooltipElement.parentNode) {
            this.tooltipElement.parentNode.removeChild(this.tooltipElement);
        }
    };
    return MouseTrackingTooltip;
}());
exports.MouseTrackingTooltip = MouseTrackingTooltip;
//# sourceMappingURL=mouse.js.map