import { Suspense, useState } from "react"
import type { Tweet } from "react-tweet/api"
import {
type TwitterComponents,
TweetContainer,
TweetHeader,
TweetInReplyTo,
TweetBody,
TweetMedia,
TweetInfo,
QuotedTweet,
TweetNotFound,
TweetSkeleton,
enrichTweet,
} from "react-tweet"
import { Badge } from "@repo/ui/components/badge"
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@repo/ui/components/alert-dialog"
import { Brain, Trash2 } from "lucide-react"
import { colors } from "@repo/ui/memory-graph/constants"
import { getPastelBackgroundColor } from "../memories-utils"
type MyTweetProps = {
tweet: Tweet
components?: TwitterComponents
}
const MyTweet = ({ tweet: t, components }: MyTweetProps) => {
const parsedTweet = typeof t === "string" ? JSON.parse(t) : t
const tweet = enrichTweet(parsedTweet)
return (
{tweet.in_reply_to_status_id_str && }
{tweet.mediaDetails?.length ? (
) : null}
{tweet.quoted_tweet && }
)
}
const TweetContent = ({
components,
tweet,
}: {
components: TwitterComponents
tweet: Tweet
}) => {
if (!tweet) {
const NotFound = components?.TweetNotFound || TweetNotFound
return
}
return
}
const CustomTweet = ({
fallback = ,
...props
}: {
components: TwitterComponents
tweet: Tweet
fallback?: React.ReactNode
}) => (
)
export const TweetCard = ({
data,
activeMemories,
onDelete,
}: {
data: Tweet
activeMemories?: Array<{ id: string; isForgotten?: boolean }>
onDelete?: () => void
}) => {
const [isDialogOpen, setIsDialogOpen] = useState(false)
return (
{onDelete && (
{
e.stopPropagation()
}}
style={{
color: colors.text.muted,
backgroundColor: "rgba(255, 255, 255, 0.1)",
backdropFilter: "blur(4px)",
}}
type="button"
>
e.stopPropagation()}>
Delete Document
Are you sure you want to delete this document and all its
related memories? This action cannot be undone.
{
e.stopPropagation()
}}
>
Cancel
{
e.stopPropagation()
onDelete()
}}
>
Delete
)}
{activeMemories && activeMemories.length > 0 && (
{activeMemories.length}{" "}
{activeMemories.length === 1 ? "memory" : "memories"}
)}
)
}
TweetCard.displayName = "TweetCard"