'use strict';

/**
 * Dimmer state management inspired by Material UI's ModalManager (https://github.com/mui-org/material-ui)
 */
class DimmerManager {
  /**
   * Dimmer refs
   */
  dimmers;
  constructor() {
    this.dimmers = [];
  }
  add(dimmer) {
    let dimmerIndex = this.dimmers.indexOf(dimmer);
    if (dimmerIndex !== -1) {
      return dimmerIndex;
    }
    dimmerIndex = this.dimmers.length;
    this.dimmers.push(dimmer);
    return dimmerIndex;
  }
  remove(dimmer) {
    const dimmerIndex = this.dimmers.indexOf(dimmer);
    if (dimmerIndex !== -1) {
      this.dimmers.splice(dimmerIndex, 1);
    }
    return dimmerIndex;
  }
  isTop(dimmer) {
    return this.dimmers.length > 0 && this.dimmers[this.dimmers.length - 1] === dimmer;
  }
}

module.exports = DimmerManager;
//# sourceMappingURL=DimmerManager.js.map
