import type { ComponentType } from "react";
import type {
  SlideTemplateKey,
  SlideTemplateProps
} from "@gnommo/slide-contracts";

export interface LectureDefinition {
  id: string;
  title: string;
  version: string;
  durationSec: number;
  segments: VideoSegment[];
  slides: Slide[];
}

export type PresentationDefinition = LectureDefinition;

export interface VideoSegment {
  id: string;
  src: string;
  startTimeSec: number;
  durationSec: number;
  poster?: string;
}

export type SlideDisplayMode = "square" | "fullscreen";
export type SlideOrientation =
  | "any"
  | "mobile-portrait"
  | "mobile-landscape"
  | "desktop";

export interface Slide {
  id: string;
  startTimeSec: number | null;
  endTimeSec?: number | null;
  displayMode: SlideDisplayMode;
  glitchSlides: GlitchSlide[];
}

export interface GlitchSlide {
  id: string;
  score: number;
  componentKey: SlideTemplateKey;
  authorName?: string;
  props: SlideTemplateProps;
  latexString?: string;
  orientation?: SlideOrientation;
  preloadAssets?: string[];
  interactionMode?: "static" | "draggable" | "interactive-3d";
}

export type SlideComponentProps = SlideTemplateProps;

export interface SlideRuntimeProps {
  lectureId: string;
  slideId: string;
  glitchSlideId: string;
  displayMode: SlideDisplayMode;
  props: SlideComponentProps;
  latexString?: string;
  paused: boolean;
  onMediaLoadingChange?: (isLoading: boolean) => void;
  onInteractionStart?: () => void;
  onInteractionEnd?: () => void;
}

export interface SlideComponentModule {
  default: ComponentType<SlideRuntimeProps>;
}

export type SlideRegistry = Record<string, () => Promise<SlideComponentModule>>;
