import type { IBrotherSensorDefinition } from './brother.types.js';

export const brotherDomain = 'brother';
export const brotherDefaultPort = 161;
export const brotherDefaultCommunity = 'public';
export const brotherDefaultTimeoutMs = 20000;
export const brotherPrinterTypes = ['laser', 'ink'] as const;

export const brotherOids = {
  charset: '1.3.6.1.2.1.43.7.1.1.4.1.1',
  counters: '1.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.10.0',
  firmware: '1.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.17.0',
  mac: '1.3.6.1.2.1.2.2.1.6.1',
  maintenance: '1.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.8.0',
  model: '1.3.6.1.4.1.2435.2.3.9.1.1.7.0',
  nextcare: '1.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.11.0',
  pageCounter: '1.3.6.1.2.1.43.10.2.1.4.1.1',
  serial: '1.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.1.0',
  status: '1.3.6.1.4.1.2435.2.3.9.4.2.1.5.4.5.2.0',
  uptime: '1.3.6.1.2.1.1.3.0',
} as const;

export const brotherCounterValues: Record<string, string> = {
  '00': 'page_counter',
  '01': 'bw_counter',
  '02': 'color_counter',
  '06': 'duplex_unit_pages_counter',
  '12': 'black_counter',
  '13': 'cyan_counter',
  '14': 'magenta_counter',
  '15': 'yellow_counter',
  '16': 'image_counter',
};

export const brotherLaserMaintenanceValues: Record<string, string> = {
  '11': 'drum_counter',
  '31': 'black_toner_status',
  '32': 'cyan_toner_status',
  '33': 'magenta_toner_status',
  '34': 'yellow_toner_status',
  '41': 'drum_remaining_life',
  '63': 'drum_status',
  '69': 'belt_unit_remaining_life',
  '6a': 'fuser_remaining_life',
  '6b': 'laser_remaining_life',
  '6c': 'pf_kit_mp_remaining_life',
  '6d': 'pf_kit_1_remaining_life',
  '6f': 'black_toner_remaining',
  '70': 'cyan_toner_remaining',
  '71': 'magenta_toner_remaining',
  '72': 'yellow_toner_remaining',
  '73': 'cyan_drum_counter',
  '74': 'magenta_drum_counter',
  '75': 'yellow_drum_counter',
  '79': 'cyan_drum_remaining_life',
  '7a': 'magenta_drum_remaining_life',
  '7b': 'yellow_drum_remaining_life',
  '7e': 'black_drum_counter',
  '80': 'black_drum_remaining_life',
  '81': 'black_toner',
  '82': 'cyan_toner',
  '83': 'magenta_toner',
  '84': 'yellow_toner',
  a1: 'black_toner_remaining',
  a2: 'cyan_toner_remaining',
  a3: 'magenta_toner_remaining',
  a4: 'yellow_toner_remaining',
};

export const brotherInkMaintenanceValues: Record<string, string> = {
  '31': 'black_ink_status',
  '32': 'cyan_ink_status',
  '33': 'magenta_ink_status',
  '34': 'yellow_ink_status',
  '6f': 'black_ink_remaining',
  '70': 'cyan_ink_remaining',
  '71': 'magenta_ink_remaining',
  '72': 'yellow_ink_remaining',
  '81': 'black_ink',
  '82': 'cyan_ink',
  '83': 'magenta_ink',
  '84': 'yellow_ink',
  a1: 'black_ink_remaining',
  a2: 'cyan_ink_remaining',
  a3: 'magenta_ink_remaining',
  a4: 'yellow_ink_remaining',
};

export const brotherLaserNextcareValues: Record<string, string> = {
  '73': 'laser_unit_remaining_pages',
  '77': 'pf_kit_1_remaining_pages',
  '82': 'drum_remaining_pages',
  '86': 'pf_kit_mp_remaining_pages',
  '88': 'belt_unit_remaining_pages',
  '89': 'fuser_unit_remaining_pages',
  a4: 'black_drum_remaining_pages',
  a5: 'cyan_drum_remaining_pages',
  a6: 'magenta_drum_remaining_pages',
  a7: 'yellow_drum_remaining_pages',
};

export const brotherPercentSensorKeys = new Set([
  'belt_unit_remaining_life',
  'black_drum_remaining_life',
  'black_ink_remaining',
  'black_toner_remaining',
  'cyan_drum_remaining_life',
  'cyan_ink_remaining',
  'cyan_toner_remaining',
  'drum_remaining_life',
  'fuser_remaining_life',
  'laser_remaining_life',
  'magenta_drum_remaining_life',
  'magenta_ink_remaining',
  'magenta_toner_remaining',
  'pf_kit_1_remaining_life',
  'pf_kit_mp_remaining_life',
  'yellow_drum_remaining_life',
  'yellow_ink_remaining',
  'yellow_toner_remaining',
]);

export const brotherSensorDefinitions: IBrotherSensorDefinition[] = [
  { key: 'status', name: 'Status', entityCategory: 'diagnostic' },
  { key: 'page_counter', name: 'Page Counter', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'bw_counter', name: 'B/W Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'color_counter', name: 'Color Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'duplex_unit_pages_counter', name: 'Duplex Unit Page Counter', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'drum_remaining_life', name: 'Drum Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'drum_remaining_pages', name: 'Drum Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'drum_counter', name: 'Drum Page Counter', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'black_drum_remaining_life', name: 'Black Drum Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'black_drum_remaining_pages', name: 'Black Drum Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'black_drum_counter', name: 'Black Drum Page Counter', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'cyan_drum_remaining_life', name: 'Cyan Drum Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'cyan_drum_remaining_pages', name: 'Cyan Drum Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'cyan_drum_counter', name: 'Cyan Drum Page Counter', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'magenta_drum_remaining_life', name: 'Magenta Drum Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'magenta_drum_remaining_pages', name: 'Magenta Drum Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'magenta_drum_counter', name: 'Magenta Drum Page Counter', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'yellow_drum_remaining_life', name: 'Yellow Drum Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'yellow_drum_remaining_pages', name: 'Yellow Drum Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'yellow_drum_counter', name: 'Yellow Drum Page Counter', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'belt_unit_remaining_life', name: 'Belt Unit Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'belt_unit_remaining_pages', name: 'Belt Unit Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'fuser_remaining_life', name: 'Fuser Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'fuser_unit_remaining_pages', name: 'Fuser Unit Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'laser_remaining_life', name: 'Laser Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'laser_unit_remaining_pages', name: 'Laser Unit Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'pf_kit_1_remaining_life', name: 'PF Kit 1 Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'pf_kit_1_remaining_pages', name: 'PF Kit 1 Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'pf_kit_mp_remaining_life', name: 'PF Kit MP Remaining Life', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'pf_kit_mp_remaining_pages', name: 'PF Kit MP Remaining Pages', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'black_toner_remaining', name: 'Black Toner Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'cyan_toner_remaining', name: 'Cyan Toner Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'magenta_toner_remaining', name: 'Magenta Toner Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'yellow_toner_remaining', name: 'Yellow Toner Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'black_ink_remaining', name: 'Black Ink Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'cyan_ink_remaining', name: 'Cyan Ink Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'magenta_ink_remaining', name: 'Magenta Ink Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'yellow_ink_remaining', name: 'Yellow Ink Remaining', unit: '%', stateClass: 'measurement', entityCategory: 'diagnostic' },
  { key: 'uptime', name: 'Uptime', deviceClass: 'timestamp', entityCategory: 'diagnostic', enabledDefault: false },
];
