var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { InjectVegaTelemetrySlimmer } from 'vega-slimmer/core';
import { VegaIconManagerRuntimeMetricsPayloadDefinition } from '../../constants/runtime-metrics-payload-definition/public-api/IconManager/runtime-metrics-payload-definition';
import { createPublicAPIRuntimeMetricsSlimmer } from '../slimmers/runtime-metrics/create-public-api-runtime-metrics-slimmer';
/**
 * Internal icon manager controller.
 */
class IconManager {
  constructor() {
    this.vegaPublicAPIRuntimeMetricsSlimmer = createPublicAPIRuntimeMetricsSlimmer(IconManager, ['register', 'getIcon', 'hasIcon'], VegaIconManagerRuntimeMetricsPayloadDefinition);
    this.icons = new Map();
  }
  /**
   * Registers the icons into the map.
   *
   * @param {Record<string, string>} icons - icon records
   * @vegaVersion 2.13.0
   */
  register(icons) {
    for (const key in icons) {
      if (!this.icons.has(key)) {
        this.icons.set(key, icons[key]);
      }
    }
  }
  /**
   * Get an internal icon by name
   *
   * @param {string} name - The name of the icon
   * @returns {Nullable<IconPayload>} returns the icon svg or null if not found
   * @vegaVersion 2.13.0
   */
  getIcon(name) {
    return this.icons.get(name);
  }
  /**
   *  Check if the icon manager has an icon by name
   *
   * @param {string} name - The name of the icon
   * @returns {boolean} returns true if the icon exists
   * @vegaVersion 2.13.0
   */
  hasIcon(name) {
    return this.icons.has(name);
  }
}
__decorate([
  InjectVegaTelemetrySlimmer()
], IconManager.prototype, "vegaPublicAPIRuntimeMetricsSlimmer", void 0);
export const VegaIconManager = new IconManager();
