"use client"; import { cn } from "@/lib/utils"; import type { Card, Rank, Suit } from "@/lib/minigames/poker"; import { mapCardToSvg, useCardStyle } from "./cardStyle"; const RANK_LABELS: Record = { 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "10", 11: "J", 12: "Q", 13: "K", 14: "A", }; const SUIT_SYMBOLS: Record = { s: "♠", h: "♥", d: "♦", c: "♣", }; const RED_SUITS = new Set(["h", "d"]); interface CardViewProps { readonly card: Card | null; readonly faceUp?: boolean; readonly size?: "mini" | "sm" | "md"; readonly dealIndex?: number; readonly className?: string; readonly highlighted?: boolean; readonly dimmed?: boolean; } export function CardView({ card, faceUp = true, size = "md", dealIndex = 0, className, highlighted = false, dimmed = false, }: CardViewProps) { const { style: cardStyle } = useCardStyle(); const lightFace = cardStyle === "light"; const classicFace = cardStyle === "classic"; const revealed = card !== null && faceUp; const redSuitClass = lightFace ? "text-rose-600" : "text-rose-400"; const label = card ? `${RANK_LABELS[card.rank]} of ${ card.suit === "s" ? "spades" : card.suit === "h" ? "hearts" : card.suit === "d" ? "diamonds" : "clubs" }` : "Face-down card"; return ( 0 && "poker-card-deal", highlighted && "relative z-10 brightness-110 ring-2 ring-amber-300 shadow-lg shadow-amber-300/35", dimmed && "opacity-40", className, )} style={dealIndex > 0 ? { animationDelay: `${dealIndex * 60}ms` } : undefined} aria-label={label} > {card && classicFace && ( )} {card && !classicFace && ( <> {RANK_LABELS[card.rank]} {SUIT_SYMBOLS[card.suit]} {size !== "mini" && ( {SUIT_SYMBOLS[card.suit]} )} )} ); }