import { DRAG_ACTIVATION_DISTANCE_PX } from "../../ui/control-timing"; import { ChannelSettingsDialog } from "./ChannelSettingsDialog"; import { ChannelAction } from "./ChannelAction"; import { useCopy } from "../../ui/copy"; import { useEffect, useRef, useState, type ReactNode } from "react"; import "./channel-image-dialog.css"; /** The caller keeps the image URL alive; this surface only owns its presentation. */ export function ChannelImageDialog({ src, name, description, progress, original, onClose }: { src: string; name: string; description?: string; progress?: ReactNode; original?: { busy: boolean; disabled?: boolean; onLoad(): void; onCancel(): void }; onClose(): void; }) { const { t } = useCopy(); const [zoomed, setZoomed] = useState(false); const [failedSource, setFailedSource] = useState(); const failed = failedSource === src; const drag = useRef<{ x: number; y: number; left: number; top: number } | null>(null); const moved = useRef(false); useEffect(() => { setZoomed(false); setFailedSource(undefined); drag.current = null; moved.current = false; }, [src]); const zoomLabel = t(zoomed ? "channel.imageDialog.fit" : "channel.imageDialog.actualSize"); return
{failed ?

{t("channel.imageDialog.loadFailed")}

: }
{!failed && setZoomed(value => !value)} />} {description &&

{description}

} {original && } {progress}
; }