"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const dom = require("../../dom.js");
const color = require("../../../common/color.js");
const objects = require("../../../common/objects.js");
const strings = require("../../../common/strings.js");
require("./countBadge.css.js");
const defaultOpts = {
  badgeBackground: color.Color.fromHex("#4D4D4D"),
  badgeForeground: color.Color.fromHex("#FFFFFF")
};
class CountBadge {
  constructor(container, options) {
    this.count = 0;
    this.options = options || /* @__PURE__ */ Object.create(null);
    objects.mixin(this.options, defaultOpts, false);
    this.badgeBackground = this.options.badgeBackground;
    this.badgeForeground = this.options.badgeForeground;
    this.badgeBorder = this.options.badgeBorder;
    this.element = dom.append(container, dom.$(".monaco-count-badge"));
    this.countFormat = this.options.countFormat || "{0}";
    this.titleFormat = this.options.titleFormat || "";
    this.setCount(this.options.count || 0);
  }
  setCount(count) {
    this.count = count;
    this.render();
  }
  setTitleFormat(titleFormat) {
    this.titleFormat = titleFormat;
    this.render();
  }
  render() {
    this.element.textContent = strings.format(this.countFormat, this.count);
    this.element.title = strings.format(this.titleFormat, this.count);
    this.applyStyles();
  }
  style(styles) {
    this.badgeBackground = styles.badgeBackground;
    this.badgeForeground = styles.badgeForeground;
    this.badgeBorder = styles.badgeBorder;
    this.applyStyles();
  }
  applyStyles() {
    if (this.element) {
      const background = this.badgeBackground ? this.badgeBackground.toString() : "";
      const foreground = this.badgeForeground ? this.badgeForeground.toString() : "";
      const border = this.badgeBorder ? this.badgeBorder.toString() : "";
      this.element.style.backgroundColor = background;
      this.element.style.color = foreground;
      this.element.style.borderWidth = border ? "1px" : "";
      this.element.style.borderStyle = border ? "solid" : "";
      this.element.style.borderColor = border;
    }
  }
}
exports.CountBadge = CountBadge;
