/**
 * GroupDeal domain events — discriminated union.
 *
 * Each event corresponds to one workflow operation that may trigger a state
 * transition. Events carry only the data needed to drive the machine;
 * side-effectful payloads (e.g. outbox JSON) are built by the workflow.
 *
 * Pure module: no imports from @/server/db, do-client, or outbox-producer.
 */

export type GroupDealEvent =
  /** Reservation count crossed minGroupSize threshold (upward). */
  | { kind: 'threshold_met'; at: Date }
  /** Reservation count dropped below minGroupSize (downward from THRESHOLD_MET). */
  | { kind: 'threshold_lost'; at: Date }
  /** Window expired with count >= minGroupSize → execute immediately. */
  | { kind: 'window_expired_above_threshold'; at: Date }
  /** Window expired with 0 < count < minGroupSize → vendor decision. */
  | { kind: 'window_expired_below_threshold'; at: Date }
  /** Vendor chose to extend the deadline (max 1 time). */
  | { kind: 'vendor_extend'; newDeadline: Date; at: Date }
  /** Vendor honored a partial group deal. */
  | { kind: 'vendor_honor_partial'; at: Date }
  /** Admin or system forces a fail (covers cancelGroupDeal / failGroupDeal). */
  | { kind: 'fail_requested'; reason: string; at: Date }
  /** Partial decision deadline passed and vendor did not act — auto-fail. */
  | { kind: 'partial_decision_expired'; at: Date };
