import type { IOidSet, TUpsModel } from './types.js';

/**
 * OID sets for different UPS models
 * Contains mappings between UPS models and their SNMP OIDs
 */
export class UpsOidSets {
  /**
   * OID sets for different UPS models
   */
  private static readonly UPS_OID_SETS: Record<TUpsModel, IOidSet> = {
    // Cyberpower OIDs for RMCARD205 (based on CyberPower_MIB_v2.11)
    cyberpower: {
      POWER_STATUS: '1.3.6.1.4.1.3808.1.1.1.4.1.1.0', // upsBaseOutputStatus (2=online, 3=on battery)
      BATTERY_CAPACITY: '1.3.6.1.4.1.3808.1.1.1.2.2.1.0', // upsAdvanceBatteryCapacity (percentage)
      BATTERY_RUNTIME: '1.3.6.1.4.1.3808.1.1.1.2.2.4.0', // upsAdvanceBatteryRunTimeRemaining (TimeTicks)
    },
    
    // APC OIDs
    apc: {
      POWER_STATUS: '1.3.6.1.4.1.318.1.1.1.4.1.1.0', // Power status (1=online, 2=on battery)
      BATTERY_CAPACITY: '1.3.6.1.4.1.318.1.1.1.2.2.1.0', // Battery capacity in percentage
      BATTERY_RUNTIME: '1.3.6.1.4.1.318.1.1.1.2.2.3.0', // Remaining runtime in minutes
    },
    
    // Eaton OIDs
    eaton: {
      POWER_STATUS: '1.3.6.1.4.1.534.1.4.4.0', // xupsOutputSource (3=normal/mains, 5=battery)
      BATTERY_CAPACITY: '1.3.6.1.4.1.534.1.2.4.0', // xupsBatCapacity (percentage)
      BATTERY_RUNTIME: '1.3.6.1.4.1.534.1.2.1.0', // xupsBatTimeRemaining (seconds)
    },
    
    // TrippLite OIDs
    tripplite: {
      POWER_STATUS: '1.3.6.1.4.1.850.1.1.3.1.1.1.0', // Power status
      BATTERY_CAPACITY: '1.3.6.1.4.1.850.1.1.3.2.4.1.0', // Battery capacity in percentage
      BATTERY_RUNTIME: '1.3.6.1.4.1.850.1.1.3.2.2.1.0', // Remaining runtime in minutes
    },
    
    // Liebert/Vertiv OIDs
    liebert: {
      POWER_STATUS: '1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.2.1', // Power status
      BATTERY_CAPACITY: '1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.4.1', // Battery capacity in percentage
      BATTERY_RUNTIME: '1.3.6.1.4.1.476.1.42.3.9.20.1.20.1.2.1.5.1', // Remaining runtime in minutes
    },
    
    // Custom OIDs (to be provided by the user)
    custom: {
      POWER_STATUS: '',
      BATTERY_CAPACITY: '',
      BATTERY_RUNTIME: '',
    }
  };

  /**
   * Get OID set for a specific UPS model
   * @param model UPS model name
   * @returns OID set for the model
   */
  public static getOidSet(model: TUpsModel): IOidSet {
    return this.UPS_OID_SETS[model];
  }

  /**
   * Get standard RFC 1628 OID set as fallback
   * @returns Standard OID set
   */
  public static getStandardOids(): Record<string, string> {
    return {
      'power status': '1.3.6.1.2.1.33.1.4.1.0',      // upsOutputSource
      'battery capacity': '1.3.6.1.2.1.33.1.2.4.0',  // upsEstimatedChargeRemaining
      'battery runtime': '1.3.6.1.2.1.33.1.2.3.0'    // upsEstimatedMinutesRemaining
    };
  }
}