import { useQueryClient } from "@tanstack/react-query"
import { useDarkMode } from "~/hooks/useDarkmode"
import { useMessageOption } from "~/hooks/useMessageOption"
import { PageAssitDatabase } from "@/db"
import { Select, Switch } from "antd"
import { SUPPORTED_LANGUAGES } from "~/utils/supporetd-languages"
import { MoonIcon, SunIcon } from "lucide-react"
import { SearchModeSettings } from "./search-mode"
import { useTranslation } from "react-i18next"
import { useI18n } from "@/hooks/useI18n"
import { TTSModeSettings } from "./tts-mode"
import {
exportPageAssistData,
importPageAssistData
} from "@/libs/export-import"
import { useStorage } from "@plasmohq/storage/hook"
export const GeneralSettings = () => {
const { clearChat, speechToTextLanguage, setSpeechToTextLanguage } =
useMessageOption()
const [copilotResumeLastChat, setCopilotResumeLastChat] = useStorage(
"copilotResumeLastChat",
false
)
const [restoreLastChatModel, setRestoreLastChatModel] = useStorage(
"restoreLastChatModel",
false
)
const [generateTitle, setGenerateTitle] = useStorage("titleGenEnabled", false)
const [hideCurrentChatModelSettings, setHideCurrentChatModelSettings] =
useStorage("hideCurrentChatModelSettings", false)
const [sendNotificationAfterIndexing, setSendNotificationAfterIndexing] =
useStorage("sendNotificationAfterIndexing", false)
const queryClient = useQueryClient()
const { mode, toggleDarkMode } = useDarkMode()
const { t } = useTranslation("settings")
const { changeLocale, locale, supportLanguage } = useI18n()
return (
{t("generalSettings.title")}
{t("generalSettings.settings.speechRecognitionLang.label")}
{t("generalSettings.settings.language.label")}
{t("generalSettings.settings.copilotResumeLastChat.label")}
setCopilotResumeLastChat(checked)}
/>
{t("generalSettings.settings.hideCurrentChatModelSettings.label")}
setHideCurrentChatModelSettings(checked)}
/>
{t("generalSettings.settings.restoreLastChatModel.label")}
setRestoreLastChatModel(checked)}
/>
{t("generalSettings.settings.sendNotificationAfterIndexing.label")}
{t("generalSettings.settings.generateTitle.label")}
setGenerateTitle(checked)}
/>
{t("generalSettings.settings.darkMode.label")}
{t("generalSettings.system.heading")}
{t("generalSettings.system.deleteChatHistory.label")}
{t("generalSettings.system.export.label")}
{t("generalSettings.system.import.label")}
{
if (e.target.files) {
importPageAssistData(e.target.files[0])
}
}}
/>
)
}