class RecordingContext {
  const RecordingContext({
    required this.eventTitle,
    required this.matchName,
    required this.group,
    required this.venue,
    required this.time,
    required this.playerName,
    required this.playerPhone,
    this.laneNo,
    this.status,
  });

  const RecordingContext.empty()
    : eventTitle = '',
      matchName = '',
      group = '',
      venue = '',
      time = '',
      playerName = '',
      playerPhone = '',
      laneNo = null,
      status = null;

  final String eventTitle;
  final String matchName;
  final String group;
  final String venue;
  final String time;
  final String playerName;
  final String playerPhone;
  final String? laneNo;
  final String? status;

  String get title => '$matchName $group';

  String get address => venue;

  String get displayName {
    final parts = [
      playerName,
      matchName,
      group,
      if (laneNo != null && laneNo!.trim().isNotEmpty) laneNo!,
    ];
    return parts.map(_sanitize).where((part) => part.isNotEmpty).join('_');
  }

  static String _sanitize(String value) {
    return value
        .trim()
        .replaceAll(RegExp(r'[\\/:*?"<>|]'), '_')
        .replaceAll(RegExp(r'\s+'), '_');
  }
}
