/**
 * MITRE ATT&CK Reference Data
 *
 * Shared constants for all 14 ATT&CK Enterprise tactics.
 * Canonical source of tactic IDs, names, and abbreviations
 * consumed by tenant-ui, threat-library, and web-components.
 *
 * @countermeasure/web-components/security/mitre-data
 */

/** A single MITRE ATT&CK tactic definition */
export interface MitreTacticDef {
  /** ATT&CK tactic ID (e.g. TA0001) */
  readonly id: string
  /** Full tactic name (e.g. "Initial Access") */
  readonly name: string
  /** Abbreviated name for compact UIs (e.g. "Initial") */
  readonly shortName: string
}

/**
 * All 14 MITRE ATT&CK Enterprise tactics in kill-chain order.
 *
 * Order follows the official ATT&CK matrix:
 * Reconnaissance -> Resource Development -> Initial Access -> ... -> Impact
 */
export const MITRE_TACTICS: readonly MitreTacticDef[] = [
  { id: 'TA0043', name: 'Reconnaissance', shortName: 'Recon' },
  { id: 'TA0042', name: 'Resource Development', shortName: 'Resource' },
  { id: 'TA0001', name: 'Initial Access', shortName: 'Initial' },
  { id: 'TA0002', name: 'Execution', shortName: 'Exec' },
  { id: 'TA0003', name: 'Persistence', shortName: 'Persist' },
  { id: 'TA0004', name: 'Privilege Escalation', shortName: 'PrivEsc' },
  { id: 'TA0005', name: 'Defense Evasion', shortName: 'DefEvas' },
  { id: 'TA0006', name: 'Credential Access', shortName: 'Creds' },
  { id: 'TA0007', name: 'Discovery', shortName: 'Disc' },
  { id: 'TA0008', name: 'Lateral Movement', shortName: 'LatMov' },
  { id: 'TA0009', name: 'Collection', shortName: 'Collect' },
  { id: 'TA0011', name: 'Command and Control', shortName: 'C2' },
  { id: 'TA0010', name: 'Exfiltration', shortName: 'Exfil' },
  { id: 'TA0040', name: 'Impact', shortName: 'Impact' },
] as const

/**
 * Map of full tactic name to its short abbreviation.
 *
 * Example: `TACTIC_SHORT_NAMES['Defense Evasion']` -> `'DefEvas'`
 */
export const TACTIC_SHORT_NAMES: Readonly<Record<string, string>> = Object.fromEntries(
  MITRE_TACTICS.map(t => [t.name, t.shortName])
)

/**
 * Map of full tactic name to its ATT&CK ID.
 *
 * Example: `TACTIC_IDS_BY_NAME['Initial Access']` -> `'TA0001'`
 */
export const TACTIC_IDS_BY_NAME: Readonly<Record<string, string>> = Object.fromEntries(
  MITRE_TACTICS.map(t => [t.name, t.id])
)
