import { useEffect, useId, useState, useSyncExternalStore } from "react"; import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"; import { useCellValue } from "@mdxeditor/gurx"; import { SidecarCard } from "../card"; import { widgets$ } from "../widget-options"; import type { FormEvent } from "react"; import type { Research } from "@chopin/protocol"; import type { ResearchNode } from "@chopin/dialect"; import type { ResearchStore } from "../widget-options"; const STAGES: Record = { queued: "Queued", searching: "Searching", analyzing: "Analyzing", writing: "Writing", publishing: "Publishing", ready: "Research ready", failed: "Research failed", cancelled: "Research cancelled", }; export type ResearchComposerProps = { error?: string; onCancel: () => void; onChange: (value: string) => void; onSubmit: () => void; question: string; submitting?: boolean; }; export function ResearchComposer( { error, onCancel, onChange, onSubmit, question, submitting }: ResearchComposerProps, ) { let id = useId(); let submit = (event: FormEvent) => { event.preventDefault(); onSubmit(); }; return (