import { useMemo } from "react"; import { Toggle } from "@/components/buttons/Toggle"; import { Icon, Icons } from "@/components/Icon"; import { useCaptions } from "@/components/player/hooks/useCaptions"; import { Menu } from "@/components/player/internals/ContextMenu"; import { getLanguageFromIETF } from "@/components/player/utils/language"; import { useOverlayRouter } from "@/hooks/useOverlayRouter"; import { usePlayerStore } from "@/stores/player/store"; import { qualityToString } from "@/stores/player/utils/qualities"; import { useSubtitleStore } from "@/stores/subtitles"; import { providers } from "@/utils/providers"; export function SettingsMenu({ id }: { id: string }) { const router = useOverlayRouter(id); const currentQuality = usePlayerStore((s) => s.currentQuality); const selectedCaptionLanguage = usePlayerStore( (s) => s.caption.selected?.language ); const subtitlesEnabled = useSubtitleStore((s) => s.enabled); const currentSourceId = usePlayerStore((s) => s.sourceId); const sourceName = useMemo(() => { if (!currentSourceId) return "..."; return providers.getMetadata(currentSourceId)?.name ?? "..."; }, [currentSourceId]); const { toggleLastUsed } = useCaptions(); const selectedLanguagePretty = selectedCaptionLanguage ? getLanguageFromIETF(selectedCaptionLanguage) ?? "unknown" : undefined; const source = usePlayerStore((s) => s.source); return (