import { useMemo } from "react" import { View, Text, TouchableOpacity, ScrollView, StyleSheet, Keyboard, Platform } from "react-native" import { Ionicons } from "@expo/vector-icons" import { useTranslation } from "react-i18next" export interface SlashCommand { trigger: string title: string description?: string icon: string type: "builtin" | "custom" } interface Props { query: string commands: SlashCommand[] isDark: boolean onSelect: (cmd: SlashCommand) => void } export function SlashPopover({ query, commands, isDark, onSelect }: Props) { const { t } = useTranslation() const filtered = useMemo(() => { const q = query.toLowerCase() return commands.filter((c) => c.trigger.toLowerCase().startsWith(q) || c.title.toLowerCase().includes(q)) }, [query, commands]) if (filtered.length === 0) return null return ( {filtered.map((cmd) => ( onSelect(cmd)}> /{cmd.trigger} {cmd.description && ( {cmd.description} )} {cmd.type === "custom" && ( {t("chat.slashPopover.customBadge")} )} ))} ) } const s = StyleSheet.create({ popover: { backgroundColor: "#ffffff", borderTopWidth: 1, borderTopColor: "#e5e5e5", maxHeight: 220, }, popoverDark: { backgroundColor: "#1a1a1a", borderTopColor: "#2a2a2a" }, scroll: { paddingVertical: 4 }, item: { flexDirection: "row", alignItems: "center", gap: 10, paddingHorizontal: 16, paddingVertical: 10, }, itemDark: {}, textCol: { flex: 1 }, trigger: { fontSize: 14, fontWeight: "600", color: "#0a0a0a" }, textWhite: { color: "#ffffff" }, desc: { fontSize: 12, color: "#999999", marginTop: 1 }, metaDark: { color: "#666666" }, badge: { backgroundColor: "#f3e8ff", paddingHorizontal: 6, paddingVertical: 2, borderRadius: 4, }, badgeDark: { backgroundColor: "#2a1a3e" }, badgeText: { fontSize: 10, color: "#8b5cf6", fontWeight: "600" }, })