class OperationCodePair {
  final String operation;
  final String action;

  const OperationCodePair({required this.operation, required this.action});
}

OperationCodePair? parseOperationCodePair(String? code) {
  final normalized = code?.trim().toLowerCase();
  if (normalized == null || normalized.isEmpty) return null;

  final parts = normalized.split('.').where((part) => part.isNotEmpty).toList();
  if (parts.length >= 4 && (parts.first == 'hop' || parts.first == 'edge')) {
    return OperationCodePair(operation: parts[2], action: parts[3]);
  }
  if (parts.length >= 2) {
    return OperationCodePair(
      operation: parts[parts.length - 2],
      action: parts.last,
    );
  }
  return null;
}
