"use client";
import { DictationField, type DictationFieldProps } from "@bitbaum/chatkit/react";
import "@bitbaum/chatkit/styles.css";
import { useTranslations } from "next-intl";
import { Link } from "@/i18n/navigation";
import { API, ROUTES } from "@/lib/routes";
/**
* Every place a person types words that is not a conversation: chatkit's
* DictationField, so the microphone, the 16px text and the take-back are the
* package's. Speech goes to /api/transcribe, and — as in the composer — the
* field says before the first take that a voice cannot be anonymised.
*/
export function TextBox({
hint,
voice,
voiceNote = true,
...props
}: DictationFieldProps & {
/** `false` where the page shows `` once for several fields. */
voiceNote?: boolean;
}) {
const t = useTranslations("Chat");
const speaks = voice !== false && voiceNote;
return (
{hint}
{hint && speaks ? " " : null}
{speaks && }
>
) : undefined
}
labels={{
voice: t("voice"),
voiceStop: t("voiceStop"),
cancelRecording: t("cancelRecording"),
confirmRecording: t("confirmRecording"),
listening: t("listening"),
transcribing: t("transcribing"),
dismiss: t("dismiss"),
retryTake: t("retryTake"),
dictation: {
mic: t("dictMic"),
silence: t("dictSilence"),
unavailable: t("dictUnavailable"),
fileTooLarge: t("dictFileTooLarge"),
},
...props.labels,
}}
/>
);
}
function VoiceNoteWords() {
const t = useTranslations("Chat");
return (
<>
{t("voiceNote")}{" "}
{t("voiceWhy")}
>
);
}
/** The speech note, once, under a group of fields that each pass `voiceNote={false}`. */
export function VoiceNote() {
return (