import { getCachedThreadContextEvents } from '@/lib/navigation-related-events' import { useSmartNoteNavigation } from '@/PageManager' import { ExtendedKind } from '@/constants' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' import { notificationReactionSummaryKey, useNotificationReactionDisplay } from '@/hooks/useNotificationReactionDisplay' import { DISCUSSION_DOWNVOTE_DISPLAY, DISCUSSION_UPVOTE_DISPLAY } from '@/lib/discussion-votes' import { getZapInfoFromEvent } from '@/lib/event-metadata' import { getMoneroTipInfo } from '@/lib/monero-tip' import { isMentioningMutedUsers, isNip18RepostKind, isNip25ReactionKind } from '@/lib/event' import { getWebExternalReactionTargetUrl } from '@/lib/rss-article' import { relayHintsFromEventTags } from '@/lib/relay-list-builder' import { toNote } from '@/lib/link' import { cn } from '@/lib/utils' import { useContentPolicyOptional } from '@/providers/ContentPolicyProvider' import storage from '@/services/local-storage.service' import { useMuteList } from '@/contexts/mute-list-context' import { muteSetHas } from '@/lib/mute-set' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { Event, kinds } from 'nostr-tools' import { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import Collapsible from '../Collapsible' import MarkdownArticle from '../Note/MarkdownArticle/MarkdownArticle' import ReactionEmojiDisplay from '../Note/ReactionEmojiDisplay' import NoteAuthorMetaLine from '../NoteAuthorMetaLine' import NoteOptions from '../NoteOptions' import NoteStats from '../NoteStats' import ParentNotePreview from '../ParentNotePreview' import WebPreview from '../WebPreview' import UserAvatar from '../UserAvatar' import Superchat from '../Note/Superchat' import Zap from '../Note/Zap' import MoneroTip from '../Note/MoneroTip' export default function ReplyNote({ event, parentEventId, onClickParent = () => {}, onClickReply, highlight = false, duplicateWebPreviewCleanedUrlHints, foregroundStats = false }: { event: Event parentEventId?: string onClickParent?: () => void onClickReply?: (event: Event) => void highlight?: boolean duplicateWebPreviewCleanedUrlHints?: string[] foregroundStats?: boolean }) { const { t } = useTranslation() const { isSmallScreen } = useScreenSize() const { navigateToNote } = useSmartNoteNavigation() const { mutePubkeySet } = useMuteList() const hideContentMentioningMutedUsers = useContentPolicyOptional()?.hideContentMentioningMutedUsers ?? storage.getHideContentMentioningMutedUsers() const [showMuted, setShowMuted] = useState(false) const reactionDisplay = useNotificationReactionDisplay(event) const webReactionParentUrl = useMemo( () => event.kind === ExtendedKind.EXTERNAL_REACTION ? getWebExternalReactionTargetUrl(event) : undefined, [event] ) const parentFetchRelayHints = useMemo(() => relayHintsFromEventTags(event), [event]) const headerUserId = useMemo(() => { if (event.kind === kinds.Zap) { const info = getZapInfoFromEvent(event) return info?.senderPubkey ?? event.pubkey } if ( event.kind === ExtendedKind.MONERO_TIP_DISCLOSURE || event.kind === ExtendedKind.MONERO_TIP_RECEIPT ) { const info = getMoneroTipInfo(event) return info?.senderPubkey ?? event.pubkey } return event.pubkey }, [event]) const show = useMemo(() => { if (showMuted) { return true } if (muteSetHas(mutePubkeySet, event.pubkey)) { return false } if (hideContentMentioningMutedUsers && isMentioningMutedUsers(event, mutePubkeySet)) { return false } return true }, [showMuted, mutePubkeySet, event, hideContentMentioningMutedUsers]) return (