"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const lifecycle = require("../../../../base/common/lifecycle.js");
const editorExtensions = require("../../../browser/editorExtensions.js");
const range = require("../../../common/core/range.js");
const colorDetector = require("./colorDetector.js");
const colorHoverParticipant = require("./colorHoverParticipant.js");
const hover = require("../../hover/browser/hover.js");
const hoverTypes = require("../../hover/browser/hoverTypes.js");
class ColorContribution extends lifecycle.Disposable {
  constructor(_editor) {
    super();
    this._editor = _editor;
    this._register(_editor.onMouseDown((e) => this.onMouseDown(e)));
  }
  dispose() {
    super.dispose();
  }
  onMouseDown(mouseEvent) {
    const target = mouseEvent.target;
    if (target.type !== 6) {
      return;
    }
    if (!target.detail.injectedText) {
      return;
    }
    if (target.detail.injectedText.options.attachedData !== colorDetector.ColorDecorationInjectedTextMarker) {
      return;
    }
    if (!target.range) {
      return;
    }
    const hoverController = this._editor.getContribution(hover.ModesHoverController.ID);
    if (!hoverController) {
      return;
    }
    if (!hoverController.isColorPickerVisible()) {
      const range$1 = new range.Range(target.range.startLineNumber, target.range.startColumn + 1, target.range.endLineNumber, target.range.endColumn + 1);
      hoverController.showContentHover(range$1, 1, false);
    }
  }
}
ColorContribution.ID = "editor.contrib.colorContribution";
editorExtensions.registerEditorContribution(ColorContribution.ID, ColorContribution);
hoverTypes.HoverParticipantRegistry.register(colorHoverParticipant.ColorHoverParticipant);
exports.ColorContribution = ColorContribution;
