class Participant {
  final String id;
  final String tripId;
  final String displayName;
  final String deviceId;
  final bool isOwner;
  final int joinedAtUtc;

  Participant({
    required this.id,
    required this.tripId,
    required this.displayName,
    required this.deviceId,
    required this.isOwner,
    required this.joinedAtUtc,
  });

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'tripId': tripId,
      'displayName': displayName,
      'deviceId': deviceId,
      'isOwner': isOwner ? 1 : 0,
      'joinedAtUtc': joinedAtUtc,
    };
  }

  factory Participant.fromMap(Map<String, dynamic> map) {
    return Participant(
      id: map['id'] as String,
      tripId: map['tripId'] as String,
      displayName: map['displayName'] as String,
      deviceId: map['deviceId'] as String,
      isOwner: (map['isOwner'] as int) == 1,
      joinedAtUtc: map['joinedAtUtc'] as int,
    );
  }
}
