import type { Block } from "../../lib/block";
import { image as imageBlock } from "./image";
import { RESULT_PAD_X, RESULT_PAD_Y, resultFrame, ROW_HEIGHT, type ToolData } from "./tool-layout";
import { ToolView } from "./tool-view";
/** Tool call block. Fixed height when collapsed, expands to show result. */
function tool(data: ToolData, expanded = false, resultExpanded = false, settling = false): Block {
let images = expanded || settling ? imageResult(data) : undefined;
return {
key: `tool:${data.id}`,
measure(width) {
let result = resultFrame(data, expanded, resultExpanded, width);
let h = ROW_HEIGHT;
if (expanded && result.height > 0) h += result.height;
if (expanded && images) h += images.measure(width).height;
return { height: h, fit: width };
},
render(width) {
let result = resultFrame(data, expanded, resultExpanded, width);
return (