import { useState, type CSSProperties } from "react"; import { Spinner } from "@tutti-os/ui-system"; import { ImageIcon, X } from "lucide-react"; import { ZoomableImage } from "../../../app/renderer/components/ZoomableImage"; import { cn } from "../../../app/renderer/lib/utils"; import type { AgentComposerDraftImage } from "../model/agentGuiNodeTypes"; import { DRAFT_IMAGE_PREVIEW_BASE_HEIGHT_PX, DRAFT_IMAGE_PREVIEW_MAX_RATIO, DRAFT_IMAGE_PREVIEW_MAX_WIDTH_PX, DRAFT_IMAGE_PREVIEW_MIN_RATIO, DRAFT_IMAGE_PREVIEW_MIN_WIDTH_PX } from "./AgentComposerChrome"; export function AgentComposerDraftImagePreview({ image, removeLabel, onRemove }: { image: AgentComposerDraftImage; removeLabel: string; onRemove: (id: string) => void; }): React.JSX.Element { const [aspectRatio, setAspectRatio] = useState(1); const previewWidth = Math.round( Math.min( DRAFT_IMAGE_PREVIEW_MAX_WIDTH_PX, Math.max( DRAFT_IMAGE_PREVIEW_MIN_WIDTH_PX, aspectRatio * DRAFT_IMAGE_PREVIEW_BASE_HEIGHT_PX ) ) ); const previewStyle = { aspectRatio: String(aspectRatio), width: `${previewWidth}px` } satisfies CSSProperties; return (