import type { ActiveClipPlaybackInfo, Clip, ClipVisualTransform, PlayState, PreviewAspectRatio, PreviewMediaSource, PreviewSourceResolver, TextPreviewFontConfig, TimeMs } from '../models/types';
import type { SourceMediaRegistry } from '../resources/sourceMediaRegistry';
import type { ResourceCacheManager } from '../resources/resourceCache';
import type { DiagnosticsCenter, DiagnosticEmitInput } from '../../utils/diagnostics';
export interface TimelinePreviewSyncPayload {
    activeClips: ActiveClipPlaybackInfo[];
    nextClips: ActiveClipPlaybackInfo[];
    firstVideoClip: ActiveClipPlaybackInfo | null;
    autoAspectRatioClip: ActiveClipPlaybackInfo | null;
    currentTime: TimeMs;
    playState: PlayState;
    speed: number;
    interactionMode?: 'steady' | 'seek' | 'scrub';
    primarySelectedClipId?: string | null;
    syncRequestId?: number;
}
export interface TimelinePreviewBackendCallbacks {
    onBufferingStateChange?: (isBuffering: boolean) => void;
    onSourceLoadingChange?: (pending: number) => void;
    onSyncProcessed?: (syncRequestId?: number) => void;
    onRuntimeStateChange?: (state: PreviewRuntimeState) => void;
    onAspectRatioChange?: (aspectRatio: PreviewAspectRatio) => void;
    onPreviewClipSelect?: (clipId: string) => void;
    onVisualTransformCommit?: (clipId: string, visualTransform: ClipVisualTransform) => void;
    onPendingPreviewRetry?: () => void;
    onRuntimeError?: (error: unknown) => void;
}
export interface PreviewPendingState {
    mode: 'seek' | 'scrub';
    targetTime: TimeMs;
    loadingPending: number;
    isBuffering: boolean;
    errorMessage: string | null;
}
export type PreviewRuntimePhase = 'idle' | 'awaiting-sync' | 'awaiting-media' | 'ready' | 'failed';
export type PreviewSlotPhase = 'idle' | 'binding' | 'primed' | 'active' | 'recovering' | 'failed';
export interface PreviewSlotDiagnostic {
    trackId: string;
    role: 'current' | 'preload';
    kind: ActiveClipPlaybackInfo['trackType'];
    clipId: string | null;
    desiredSource: string | null;
    actualSource: string | null;
    phase: PreviewSlotPhase;
    retryCount: number;
    errorMessage: string | null;
}
export interface PreviewRuntimeState {
    syncRequestId?: number;
    phase: PreviewRuntimePhase;
    loadingCount: number;
    isBuffering: boolean;
    errorMessage: string | null;
    slots: PreviewSlotDiagnostic[];
}
export interface TimelinePreviewBackend {
    attach(container: HTMLElement): void;
    detach(): void;
    sync(payload: TimelinePreviewSyncPayload): void;
    applyAspectRatio(aspectRatio: PreviewAspectRatio): void;
    getAspectRatio(): PreviewAspectRatio;
    setPendingState?(state: PreviewPendingState | null): void;
    hasPreview(): boolean;
    destroy(): void;
}
export interface PreviewBackendClockState {
    currentTime: TimeMs;
    playState: PlayState;
    speed: number;
}
export interface TimelinePreviewBackendOptions {
    callbacks?: TimelinePreviewBackendCallbacks;
    previewSourceResolver?: PreviewSourceResolver;
    textPreviewFont?: TextPreviewFontConfig | null;
    sourceMediaRegistry?: SourceMediaRegistry;
    resourceCacheManager?: ResourceCacheManager | null;
    diagnostics?: DiagnosticsCenter;
    getDiagnosticsContext?: () => Partial<DiagnosticEmitInput>;
    rootClassName?: string;
    frameClassName?: string;
    slotClassNamePrefix?: string;
}
export type ResolvedPreviewMediaSource = PreviewMediaSource & {
    clipId: Clip['id'];
};
