"use client"; import { useId, useState } from "react"; import { safeParseProgramRepr } from "../lib/programRepr"; interface Props { text: string; onTextChange: (next: string) => void; onDraw: (repr: string, label: string) => void; } const PLACEHOLDER = "Combine(Reduce(Select(M,[g05347,g00048]),mean),Reduce(Select(M,[g06271]),max),sub)"; export default function PasteToDraw({ text, onTextChange, onDraw }: Props) { const [error, setError] = useState(null); const [showFormat, setShowFormat] = useState(false); const panelId = useId(); function draw() { const trimmed = text.trim(); if (!trimmed) { setError("Paste a program first."); return; } const { ok, error: pErr } = safeParseProgramRepr(trimmed); if (!ok) { setError(`Couldn't parse: ${pErr}`); return; } setError(null); onDraw(trimmed, "pasted program"); } return (