//#region src/preview/QualityUpgradeScheduler.d.ts
/**
 * QualityUpgradeScheduler: Centralized deadline-ordered work queue
 *
 * Coordinates main-quality segment fetching across multiple video elements.
 * Generic scheduler that doesn't understand media concepts (segments, renditions, etc.)
 * - only processes { key, deadlineMs, fetch, owner } tuples.
 *
 * Design principles:
 * - Deadline-based ordering: always process nearest deadline first
 * - Ground-truth cache validation: check cache before starting any fetch
 * - In-flight fetches never cancelled: they populate shared cache
 * - Event-driven: elements submit tasks only on state changes, not every frame
 */
interface UpgradeTask {
  /** Opaque dedup key (e.g. "${owner}:${segmentId}:${renditionId}") */
  key: string;
  /** Fetch function that populates the cache */
  fetch: (signal: AbortSignal) => Promise<void>;
  /** Timeline time when this segment will be needed */
  deadlineMs: number;
  /** Element ID, for bulk operations */
  owner: string;
}
interface UpgradeTaskStatus {
  key: string;
  owner: string;
  deadlineMs: number;
  status: "queued" | "active" | "completed" | "failed";
  error?: string;
}
interface OwnerProgress {
  queued: number;
  active: number;
  completed: number;
  failed: number;
}
declare class QualityUpgradeScheduler {
  #private;
  constructor(options: {
    requestFrameRender: () => void;
    maxConcurrent?: number;
    isCached?: (key: string) => boolean;
  });
  /**
   * Add tasks without affecting existing ones (additive).
   * Used for lookahead extension during playback.
   */
  enqueue(tasks: UpgradeTask[]): void;
  /**
   * Replace all queued tasks for an owner.
   * Used on seeks, trim changes, timeline position changes where old deadlines are stale.
   * Does NOT cancel in-flight tasks (they populate shared cache).
   */
  replaceForOwner(owner: string, tasks: UpgradeTask[]): void;
  /**
   * Cancel all tasks for an owner.
   * Removes queued tasks. Does NOT abort in-flight fetches.
   */
  cancelForOwner(owner: string): void;
  /**
   * Check whether a task is currently in-flight (started, not yet complete).
   */
  isActive(key: string): boolean;
  /**
   * Check whether a task is waiting in the queue (submitted but not yet started).
   */
  isPending(key: string): boolean;
  /**
   * Get snapshot of current queue state for debugging.
   */
  getQueueSnapshot(): UpgradeTaskStatus[];
  /**
   * Get progress for a specific owner.
   */
  getOwnerProgress(owner: string): OwnerProgress;
  /**
   * Dispose the scheduler - abort all in-flight work.
   */
  dispose(): void;
}
//#endregion
export { QualityUpgradeScheduler };
//# sourceMappingURL=QualityUpgradeScheduler.d.ts.map