const { requestUserInput } = window.aparte;
const chat = document.querySelector('aparte-chat');
const options = [
{ value: 'md', label: 'Markdown', description: 'For the repository', recommended: true },
{ value: 'pdf', label: 'PDF', description: 'To send around' },
{ value: 'html', label: 'Web page', description: 'To publish' },
];
requestUserInput({
message: 'Which format should the report use?',
schema: { type: 'enum', options },
}).then((answer) => {
// The answer is the chosen value (or the words typed under "Other…"). Here it goes
// into the conversation by hand; with the plugin, a receipt in the reply keeps it.
if (answer.action !== 'accept') return;
const chosen = options.find((o) => o.value === answer.content);
const said = chosen ? chosen.label : String(answer.content);
chat.viewport.appendMessage({ id: 'u1', role: 'user', content: said, timestamp: Date.now() });
chat.viewport.appendMessage({
id: 'a1', role: 'assistant', timestamp: Date.now(),
content: 'Noted: the report will be written as ' + said + '.',
});
}).catch(() => {});