export const ERROR_CODES = {
  // Authentication & Authorization
  INVALID_CREDENTIALS: 'AUTH_001',
  TOKEN_EXPIRED: 'AUTH_002',
  TOKEN_INVALID: 'AUTH_003',
  INVALID_TOKEN: 'AUTH_003', // Alias
  UNAUTHORIZED: 'AUTH_004',
  FORBIDDEN: 'AUTH_005',
  API_KEY_INVALID: 'AUTH_006',
  INVALID_API_KEY: 'AUTH_006', // Alias
  SESSION_EXPIRED: 'AUTH_007',
  INSUFFICIENT_PERMISSIONS: 'AUTH_008',

  // User Management
  USER_NOT_FOUND: 'USER_001',
  USER_ALREADY_EXISTS: 'USER_002',
  USER_INACTIVE: 'USER_003',
  USER_DELETED: 'USER_004',
  INVALID_USER_DATA: 'USER_005',

  // Applicant Management
  APPLICANT_NOT_FOUND: 'APPL_001',
  APPLICANT_ALREADY_EXISTS: 'APPL_002',
  INVALID_APPLICANT_DATA: 'APPL_003',

  // Document Management
  DOCUMENT_NOT_FOUND: 'DOC_001',
  DOCUMENT_ALREADY_VERIFIED: 'DOC_002',
  DOCUMENT_EXPIRED: 'DOC_003',
  INVALID_FILE_TYPE: 'DOC_004',
  FILE_SIZE_EXCEEDED: 'DOC_005',
  DOCUMENT_CORRUPTED: 'DOC_006',
  DUPLICATE_DOCUMENT: 'DOC_007',

  // Blockchain Operations
  BLOCKCHAIN_CONNECTION_ERROR: 'CHAIN_001',
  CONTRACT_CALL_ERROR: 'CHAIN_002',
  TRANSACTION_FAILED: 'CHAIN_003',
  INVALID_CONTRACT_ADDRESS: 'CHAIN_004',
  INSUFFICIENT_GAS: 'CHAIN_005',
  TRANSACTION_TIMEOUT: 'CHAIN_006',
  BLOCKCHAIN_NOT_AVAILABLE: 'CHAIN_007',

  // Storage Operations
  STORAGE_ERROR: 'STOR_001',
  STORAGE_NOT_FOUND: 'STOR_002',
  STORAGE_QUOTA_EXCEEDED: 'STOR_003',
  STORAGE_UPLOAD_FAILED: 'STOR_004',
  STORAGE_ACCESS_DENIED: 'STOR_005',

  // Database Operations
  DATABASE_ERROR: 'DB_001',
  DATABASE_CONNECTION_ERROR: 'DB_002',
  TRANSACTION_ERROR: 'DB_003',
  CONSTRAINT_VIOLATION: 'DB_004',

  // Validation Errors
  VALIDATION_ERROR: 'VAL_001',
  INVALID_INPUT: 'VAL_002',
  MISSING_REQUIRED_FIELD: 'VAL_003',
  INVALID_EMAIL: 'VAL_004',
  INVALID_DATE: 'VAL_005',

  // Rate Limiting
  RATE_LIMIT_EXCEEDED: 'RATE_001',
  TOO_MANY_REQUESTS: 'RATE_002',

  // Server Errors
  INTERNAL_SERVER_ERROR: 'SERVER_001',
  INTERNAL_ERROR: 'SERVER_001', // Alias
  SERVICE_UNAVAILABLE: 'SERVER_002',
  TIMEOUT: 'SERVER_003',
  NOT_IMPLEMENTED: 'SERVER_004',
  NOT_FOUND: 'SERVER_005',

  // Queue Operations
  QUEUE_ERROR: 'QUEUE_001',
  JOB_FAILED: 'QUEUE_002',
  JOB_NOT_FOUND: 'QUEUE_003',

  // Email Operations
  EMAIL_SEND_ERROR: 'EMAIL_001',
  INVALID_EMAIL_ADDRESS: 'EMAIL_002',

  // Department Management
  DEPARTMENT_NOT_FOUND: 'DEPT_001',
  DEPARTMENT_ALREADY_EXISTS: 'DEPT_002',
  INVALID_DEPARTMENT_DATA: 'DEPT_003',

  // Audit & Logging
  AUDIT_RECORD_ERROR: 'AUDIT_001',
  LOG_ERROR: 'LOG_001',
};

export const ERROR_MESSAGES: Record<string, string> = {
  [ERROR_CODES.INVALID_CREDENTIALS]: 'Invalid email or password',
  [ERROR_CODES.TOKEN_EXPIRED]: 'Token has expired',
  [ERROR_CODES.TOKEN_INVALID]: 'Invalid or malformed token',
  [ERROR_CODES.UNAUTHORIZED]: 'Unauthorized access',
  [ERROR_CODES.FORBIDDEN]: 'Forbidden resource',
  [ERROR_CODES.API_KEY_INVALID]: 'Invalid API key',
  [ERROR_CODES.SESSION_EXPIRED]: 'Session has expired',
  [ERROR_CODES.INSUFFICIENT_PERMISSIONS]: 'Insufficient permissions',

  [ERROR_CODES.USER_NOT_FOUND]: 'User not found',
  [ERROR_CODES.USER_ALREADY_EXISTS]: 'User already exists',
  [ERROR_CODES.USER_INACTIVE]: 'User account is inactive',
  [ERROR_CODES.USER_DELETED]: 'User account has been deleted',
  [ERROR_CODES.INVALID_USER_DATA]: 'Invalid user data provided',

  [ERROR_CODES.APPLICANT_NOT_FOUND]: 'Applicant not found',
  [ERROR_CODES.APPLICANT_ALREADY_EXISTS]: 'Applicant already exists',
  [ERROR_CODES.INVALID_APPLICANT_DATA]: 'Invalid applicant data provided',

  [ERROR_CODES.DOCUMENT_NOT_FOUND]: 'Document not found',
  [ERROR_CODES.DOCUMENT_ALREADY_VERIFIED]: 'Document is already verified',
  [ERROR_CODES.DOCUMENT_EXPIRED]: 'Document has expired',
  [ERROR_CODES.INVALID_FILE_TYPE]: 'Invalid file type',
  [ERROR_CODES.FILE_SIZE_EXCEEDED]: 'File size exceeds maximum limit',
  [ERROR_CODES.DOCUMENT_CORRUPTED]: 'Document appears to be corrupted',
  [ERROR_CODES.DUPLICATE_DOCUMENT]: 'Document already exists',

  [ERROR_CODES.BLOCKCHAIN_CONNECTION_ERROR]: 'Failed to connect to blockchain network',
  [ERROR_CODES.CONTRACT_CALL_ERROR]: 'Smart contract call failed',
  [ERROR_CODES.TRANSACTION_FAILED]: 'Blockchain transaction failed',
  [ERROR_CODES.INVALID_CONTRACT_ADDRESS]: 'Invalid smart contract address',
  [ERROR_CODES.INSUFFICIENT_GAS]: 'Insufficient gas for transaction',
  [ERROR_CODES.TRANSACTION_TIMEOUT]: 'Blockchain transaction timeout',
  [ERROR_CODES.BLOCKCHAIN_NOT_AVAILABLE]: 'Blockchain network is not available',

  [ERROR_CODES.STORAGE_ERROR]: 'Storage operation failed',
  [ERROR_CODES.STORAGE_NOT_FOUND]: 'File not found in storage',
  [ERROR_CODES.STORAGE_QUOTA_EXCEEDED]: 'Storage quota exceeded',
  [ERROR_CODES.STORAGE_UPLOAD_FAILED]: 'File upload failed',
  [ERROR_CODES.STORAGE_ACCESS_DENIED]: 'Access to storage denied',

  [ERROR_CODES.DATABASE_ERROR]: 'Database operation failed',
  [ERROR_CODES.DATABASE_CONNECTION_ERROR]: 'Failed to connect to database',
  [ERROR_CODES.TRANSACTION_ERROR]: 'Database transaction error',
  [ERROR_CODES.CONSTRAINT_VIOLATION]: 'Database constraint violation',

  [ERROR_CODES.VALIDATION_ERROR]: 'Validation error',
  [ERROR_CODES.INVALID_INPUT]: 'Invalid input provided',
  [ERROR_CODES.MISSING_REQUIRED_FIELD]: 'Missing required field',
  [ERROR_CODES.INVALID_EMAIL]: 'Invalid email format',
  [ERROR_CODES.INVALID_DATE]: 'Invalid date format',

  [ERROR_CODES.RATE_LIMIT_EXCEEDED]: 'Rate limit exceeded',
  [ERROR_CODES.TOO_MANY_REQUESTS]: 'Too many requests',

  [ERROR_CODES.INTERNAL_SERVER_ERROR]: 'Internal server error',
  [ERROR_CODES.SERVICE_UNAVAILABLE]: 'Service unavailable',
  [ERROR_CODES.TIMEOUT]: 'Operation timeout',
  [ERROR_CODES.NOT_IMPLEMENTED]: 'Feature not implemented',
  [ERROR_CODES.NOT_FOUND]: 'Resource not found',

  [ERROR_CODES.QUEUE_ERROR]: 'Queue operation failed',
  [ERROR_CODES.JOB_FAILED]: 'Job execution failed',
  [ERROR_CODES.JOB_NOT_FOUND]: 'Job not found',

  [ERROR_CODES.EMAIL_SEND_ERROR]: 'Failed to send email',
  [ERROR_CODES.INVALID_EMAIL_ADDRESS]: 'Invalid email address',

  [ERROR_CODES.DEPARTMENT_NOT_FOUND]: 'Department not found',
  [ERROR_CODES.DEPARTMENT_ALREADY_EXISTS]: 'Department already exists',
  [ERROR_CODES.INVALID_DEPARTMENT_DATA]: 'Invalid department data',

  [ERROR_CODES.AUDIT_RECORD_ERROR]: 'Failed to record audit log',
  [ERROR_CODES.LOG_ERROR]: 'Logging error',
};
