import { useState } from "react";
import Button from "@moduletrace/twui/layout/Button";
import Link from "@moduletrace/twui/layout/Link";
import Span from "@moduletrace/twui/layout/Span";
import { ChartColumn, Maximize2, SquareArrowOutUpRight } from "lucide-react";
import GraphicFrame from "@/src/components/general/graphic-frame";
import GraphicViewerModal from "@/src/components/general/graphic-viewer-modal";
import { AppData } from "@/src/data/app-data";
import { graphicPageHref } from "@/src/utils/graphic-url";
import useBotGraphic from "../(hooks)/use-bot-graphic";
type Props = {
graphic_id: number;
};
const ActionClassName =
"shrink-0 p-1! text-ink-secondary dark:text-ink-secondary hover:text-ink rounded-default-xs";
/**
* A graphic a bot made (`graphicRef`), shown where the bot named it: its
* title and the graphic itself, sized to fit (up to
* `AppData.BotGraphicInlineMaxHeight`), with ways to open it large or on
* its own page. Built from spans, since the ref sits in a paragraph.
* Anyone it wasn't made for sees its number only.
*/
export default function GraphicRefCard({ graphic_id }: Props) {
const { view, loading } = useBotGraphic({ graphic_id });
const [open, setOpen] = useState(false);
if (!view) {
return (
{loading
? `graphic ${graphic_id}`
: `graphic ${graphic_id} (not available)`}
);
}
return (
{view.title}
{open ? (
setOpen(false)}
/>
) : null}
);
}