import { createContext, useCallback, useContext, useEffect, useRef, useState, type PropsWithChildren, } from "react"; import { createPortal } from "react-dom"; import { X } from "lucide-react"; import type { Attachment } from "../../../types/post"; import { AttachmentDownloadPill } from "../AttachmentDownloadPill"; import { MessageInlineVideo } from "../MessageInlineVideo"; type OnClose = (finalTime: number) => void; type PlayerState = { attachment: Attachment; currentTime: number; onClose?: OnClose; /** Post the video belongs to, needed for the download pill. */ postId?: string; } | null; type Ctx = { /** * Open the fullscreen player. `onClose` (optional) is invoked with the * playhead at the moment the user dismisses the overlay, so callers can * sync the original inline `