import type { DomainEvent } from '@core/shared/domain/DomainEvent';

/**
 * Domain Event: RaceEventStewardingClosed
 *
 * Fired when the stewarding window closes for a race event.
 * This triggers final results notifications to drivers with any penalty adjustments.
 */
export interface RaceEventStewardingClosedEventData {
  raceEventId: string;
  leagueId: string;
  seasonId: string;
  closedAt: Date;
  driverIds: string[]; // Drivers who participated in the race event
  hadPenaltiesApplied: boolean; // Whether any penalties were applied during stewarding
}

export class RaceEventStewardingClosedEvent implements DomainEvent<RaceEventStewardingClosedEventData> {
  readonly eventType = 'RaceEventStewardingClosed';
  readonly aggregateId: string;
  readonly eventData: RaceEventStewardingClosedEventData;
  readonly occurredAt: Date;

  constructor(data: RaceEventStewardingClosedEventData) {
    this.aggregateId = data.raceEventId;
    this.eventData = { ...data };
    this.occurredAt = new Date();
  }
}