import { useState } from 'react' import { Pressable, StyleSheet, Text, View, type StyleProp, type ViewStyle, } from 'react-native' import Svg, { G, Path } from 'react-native-svg' import { X } from 'lucide-react-native' import { useTheme } from './theme-context' import { strings } from '../locales/i18n' import { formatQuoteDraftSnippet, formatQuoteText, formatTokens, messageQuoteRanges, parseMessageQuotes, quoteTextOf, type MessageQuoteRange, type ParsedMessageQuotes, } from './quote-helpers' export { formatQuoteDraftSnippet, formatQuoteText, formatTokens, messageQuoteRanges, parseMessageQuotes, quoteTextOf, type MessageQuoteRange, type ParsedMessageQuotes, } /** Exact upstream double-quote icon geometry from deepseek-harness QuotePreview. */ export function QuoteMarkIcon({ size = 14, color }: { readonly size?: number; readonly color?: string }) { const { colors } = useTheme() const iconColor = color ?? colors.primary return ( ) } export interface QuotePreviewRemoval { readonly label: string readonly onRemove: () => void } export interface QuotePreviewProps { readonly text: string readonly removal?: QuotePreviewRemoval readonly compact?: boolean readonly style?: StyleProp } /** * Shared compact presentation for draft and sent text quotes. * Upstream deepseek-harness: packages/client/ui-primitives/src/QuotePreview.tsx */ export function QuotePreview({ text, removal, compact = true, style }: QuotePreviewProps) { const { colors } = useTheme() const [expanded, setExpanded] = useState(false) const isCompact = compact && !expanded return ( setExpanded(prev => !prev)} > {text} {removal !== undefined && ( )} ) } const styles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', borderRadius: 8, borderWidth: 1, paddingHorizontal: 8, paddingVertical: 6, marginVertical: 3, maxWidth: '100%', }, contentPressable: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 6, minHeight: 24, }, marker: { alignItems: 'center', justifyContent: 'center', flexShrink: 0, width: 16, height: 16, }, text: { flex: 1, fontSize: 13, lineHeight: 18, }, removeButton: { width: 28, height: 28, alignItems: 'center', justifyContent: 'center', borderRadius: 14, marginLeft: 4, flexShrink: 0, }, }) /** * Figure 3: In-composer inline quote preview. * Displays inline at the top of the composer card with quote marks, * truncated text in primary/brand color, and a quick remove button. */ export function InlineQuotePreview({ text, onRemove, removalLabel, style, }: { readonly key?: string | number readonly text: string readonly onRemove?: () => void readonly removalLabel?: string readonly style?: StyleProp }) { const { colors } = useTheme() const snippet = formatQuoteDraftSnippet(text) return ( “{snippet}” {onRemove !== undefined && ( )} ) } const inlineStyles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 12, paddingTop: 8, paddingBottom: 2, }, quoteRow: { flexDirection: 'row', alignItems: 'center', gap: 6, flex: 1, marginRight: 8, }, quoteText: { fontSize: 14, fontWeight: '500', flex: 1, }, closeButton: { padding: 4, }, })