import { useEffect, useMemo, useRef, useState } from "react"; import { toast } from "../dialogs"; import { useT } from "../i18n"; import { navigate } from "../router"; import { fill, loadTemplates, placeholders, type Template, type TemplateLists } from "../templates"; import { Icon } from "./Icon"; /** Choose a prompt template, fill its placeholders, return the text. */ export function TemplatePicker({ onPick, onClose }: { onPick: (text: string) => void; onClose: () => void }) { const t = useT(); const [lists, setLists] = useState(); const [q, setQ] = useState(""); const [active, setActive] = useState(0); const [chosen, setChosen] = useState