"use strict";

import { XmppListenerManager } from '../networking/xmpp/listenerManager';
export class XmppMemoryMonitor {
  static monitoringInterval = null;
  static warningThreshold = 10;
  static criticalThreshold = 20;
  static startMonitoring(intervalMs = 5000) {
    if (this.monitoringInterval) {
      this.stopMonitoring();
    }
    this.monitoringInterval = setInterval(() => {
      const count = XmppListenerManager.getActiveListenerCount();
      if (count >= this.criticalThreshold) {
        console.warn(`[XmppMemoryMonitor] CRITICAL: ${count} active XMPP listeners detected!`);
        XmppListenerManager.logActiveListeners();
      } else if (count >= this.warningThreshold) {
        console.warn(`[XmppMemoryMonitor] WARNING: ${count} active XMPP listeners detected`);
      } else if (process.env.NODE_ENV === 'development') {
        console.log(`[XmppMemoryMonitor] Active XMPP listeners: ${count}`);
      }
    }, intervalMs);
    console.log('[XmppMemoryMonitor] Started monitoring XMPP listeners');
  }
  static stopMonitoring() {
    if (this.monitoringInterval) {
      clearInterval(this.monitoringInterval);
      this.monitoringInterval = null;
      console.log('[XmppMemoryMonitor] Stopped monitoring XMPP listeners');
    }
  }
  static setThresholds(warning, critical) {
    this.warningThreshold = warning;
    this.criticalThreshold = critical;
  }
  static getCurrentCount() {
    return XmppListenerManager.getActiveListenerCount();
  }
  static forceCleanup() {
    console.warn('[XmppMemoryMonitor] Force cleaning up all XMPP listeners');
    XmppListenerManager.clearAllListeners();
  }
  static getListenerInfo() {
    return XmppListenerManager.getActiveListenersInfo();
  }
}
//# sourceMappingURL=xmppMemoryMonitor.js.map