/**
 * Presentation Types
 *
 * Shared types for RuntimePresentation and constructor.tsx components.
 * These types facilitate code sharing between the two main presentation components.
 */

import type { RuntimePage } from './runtime';

/**
 * Transition preview state for video transitions
 */
export interface TransitionPreviewState {
  targetPageId: string;
  videoUrl: string;
  storageKey: string;
  isReverse: boolean;
}

/**
 * Background state for page display
 */
export interface BackgroundState {
  imageUrl: string;
  videoUrl: string;
  audioUrl: string;
}

/**
 * Navigation target resolved from element click
 */
export interface NavigationTarget {
  page: RuntimePage;
  pageId: string;
  transitionVideoUrl?: string;
  isBack: boolean;
}

/**
 * API configuration for runtime requests
 */
export interface RuntimeApiConfig {
  headers: {
    'X-Runtime-Project-Slug'?: string;
    'X-Runtime-Environment'?: string;
  };
}

/**
 * Page data loader result
 */
export interface PageDataLoaderResult {
  project: RuntimeProject | null;
  pages: RuntimePage[];
  isLoading: boolean;
  error: string;
  reload: (preservePageId?: string) => Promise<void>;
}

/**
 * Runtime project for page data loader
 */
export interface RuntimeProject {
  id: string;
  name?: string;
  slug?: string;
  description?: string;
}

/**
 * Canvas element with navigation properties (for click handling)
 */
export interface NavigableElement {
  id: string;
  type: string;
  targetPageSlug?: string;
  targetPageId?: string;
  transitionVideoUrl?: string;
  navType?: 'forward' | 'back';
  navDisabled?: boolean;
}

/**
 * Transition phase from useTransitionPlayback
 */
export type TransitionPhase =
  | 'idle'
  | 'preparing'
  | 'playing'
  | 'reversing'
  | 'completed';

/**
 * Background transition options
 */
export interface BackgroundTransitionOptions {
  pendingTransitionComplete: boolean;
  isBackgroundReady: boolean;
  transitionVideoRef: React.RefObject<HTMLVideoElement | null>;
  pageSwitch: {
    clearPreviousBackground: () => void;
    isSwitching: boolean;
    isNewBgReady: boolean;
    previousBgImageUrl: string;
  };
  onCleanup: () => void;
}
