'use strict';

require('./global-slimmer-registry-b3bce7e0.js');
const createPublicApiRuntimeMetricsSlimmer = require('./create-public-api-runtime-metrics-slimmer-9cb09fb2.js');

const VegaIconManagerRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'IS_REGISTER_METHOD_CALLED',
    payloadDescription: 'Indicate if the method register of public API IconManager is called',
    /**
     * Indicate whether the method is collected when the method been called .
     *
     * @param {string} scope - The class name of public api
     * @param {string} methodName - The method name called by the public api
     * @returns {boolean} A boolean value
     */
    canAccept: (scope, methodName) => scope === 'IconManager' && methodName === 'register',
    /**
     * The function checks if the method name is load.
     *
     * @returns {boolean} A boolean value
     */
    payloadValue: () => {
      return true;
    },
  },
  {
    payloadKey: 'IS_GETICON_METHOD_CALLED',
    payloadDescription: 'Indicate if the method getIcon of public API IconManager is called',
    /**
     * Indicate whether the method is collected when the method been called .
     *
     * @param {string} scope - The class name of public api
     * @param {string} methodName - The method name called by the public api
     * @returns {boolean} A boolean value
     */
    canAccept: (scope, methodName) => scope === 'IconManager' && methodName === 'getIcon',
    /**
     * The function checks if the method is been called.
     *
     * @returns {boolean} A boolean value
     */
    payloadValue: () => {
      return true;
    },
  },
  {
    payloadKey: 'IS_HASICON_METHOD_CALLED',
    payloadDescription: 'Indicate if the method hasIcon of public API IconManager is called',
    /**
     * Indicate whether the method is collected when the method been called .
     *
     * @param {string} scope - The class name of public api
     * @param {string} methodName - The method name called by the public api
     * @returns {boolean} A boolean value
     */
    canAccept: (scope, methodName) => scope === 'IconManager' && methodName === 'hasIcon',
    /**
     * The function checks if the method name is unLoadAll.
     *
     * @returns {boolean} A boolean value
     */
    payloadValue: () => {
      return true;
    },
  },
];

var __decorate = (undefined && undefined.__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;
};
/**
 * Internal icon manager controller.
 */
class IconManager {
  constructor() {
    this.vegaPublicAPIRuntimeMetricsSlimmer = createPublicApiRuntimeMetricsSlimmer.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([
  createPublicApiRuntimeMetricsSlimmer.InjectVegaTelemetrySlimmer()
], IconManager.prototype, "vegaPublicAPIRuntimeMetricsSlimmer", void 0);
const VegaIconManager = new IconManager();

exports.VegaIconManager = VegaIconManager;
