import { StyleSheet, Text, View } from 'react-native' import { NATIVE_CHAT_RECEIPT_COPY, nativeChatReceiptAnswerHeading, nativeChatReceiptAnswers, nativeChatReceiptSubject, type NativeChatResolvedPrompt } from '../../../src/shared/native-chat-resolution-receipt' import { INLINE_TEXT_SELECTION } from '../components/inline-text-selection' import { colors, spacing, typography } from '../theme/mobile-theme' import { MobileNativeChatAwaitingInputRow } from './native-chat/transcript/MobileNativeChatAwaitingInputRow' import { scaledType } from './native-chat/transcript/mobile-native-chat-message-styles' import { MobileNativeChatMessageTime } from './native-chat/transcript/MobileNativeChatMessageTime' export function MobileNativeChatResolutionReceipt({ body, awaiting = true, fontScale }: { body: NativeChatResolvedPrompt /** False once the agent that asked has ended. */ awaiting?: boolean fontScale: number }): React.JSX.Element | null { const subject = nativeChatReceiptSubject(body) if (body.resolution.state === 'pending') { return body.kind === 'question' ? ( ) : null } const { resolution } = body const cancelled = resolution.state === 'cancelled' const answers = nativeChatReceiptAnswers(body) const outcome = [ cancelled ? NATIVE_CHAT_RECEIPT_COPY.cancelled : NATIVE_CHAT_RECEIPT_COPY.resolved, resolution.resolvedBy ? (cancelled ? NATIVE_CHAT_RECEIPT_COPY.cancelledBy : NATIVE_CHAT_RECEIPT_COPY.resolver ).replace('{{device}}', resolution.resolvedBy) : null ] const text = [styles.text, scaledType(typography.metaSize, fontScale, 5)] return ( {body.kind === 'question' ? ( ) : ( {body.displayName ?? body.title} )} {body.kind === 'approval' && body.detail ? ( {body.detail} ) : null} {answers.map((answer, index) => { const heading = nativeChatReceiptAnswerHeading(subject, answer) return ( {heading ? {heading} : null} {answer.answer === '' ? NATIVE_CHAT_RECEIPT_COPY.emptyAnswer : (answer.answer ?? NATIVE_CHAT_RECEIPT_COPY.unavailable)} ) })} {outcome.filter(Boolean).join(' ยท ')} ) } const styles = StyleSheet.create({ receipt: { gap: spacing.xs, paddingLeft: spacing.md, borderLeftWidth: StyleSheet.hairlineWidth, borderLeftColor: colors.borderSubtle }, text: { color: colors.textMuted }, title: { fontWeight: '600' }, outcome: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: spacing.sm } })