'use client';
import { useMemo } from 'react';
import { useShallow } from 'zustand/react/shallow';
import { useCombatStore, usePrestigeStore } from '@/lib/game/stores';
import { FLOOR_ELEM_CYCLE } from '@/lib/game/constants';
import { getGuardianForFloor, getAllGuardianFloors } from '@/lib/game/data/guardian-encounters';
import { Card, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { ScrollArea } from '@/components/ui/scroll-area';
import { SectionHeader } from '@/components/ui/section-header';
import { DebugName } from '@/components/game/debug/debug-context';
import {
getCounterElement, getElementColor, fmtArmor, fmtShield, fmtBarrier, fmtRegen,
PreparationTips, GuardianRoster, FloorProgressBar,
} from './SpireSummaryTab.helpers';
// ─── Top Stats Row ───────────────────────────────────────────────────────────
function TopStatsRow({ maxFloorReached, totalFloorsCleared, defeatedCount, insight }: {
maxFloorReached: number; totalFloorsCleared: number; defeatedCount: number; insight: number;
}) {
return (
);
}
function StatCell({ value, label, color, isFmt }: { value: number; label: string; color: string; isFmt?: boolean }) {
return (
{isFmt ? value : value}
{label}
);
}
// ─── Next Guardian Card ──────────────────────────────────────────────────────
function NextGuardianCard({ nextGuardian, nextGuardianData }: { nextGuardian: number; nextGuardianData: ReturnType }) {
if (!nextGuardianData) return null;
const counterElement = getCounterElement(nextGuardianData.element[0]);
const nextFloorElement = FLOOR_ELEM_CYCLE[(nextGuardian - 1) % FLOOR_ELEM_CYCLE.length];
return (
{nextGuardian}
{nextGuardianData.name}
{nextGuardianData.element.join(' + ')}
Health: {nextGuardianData.hp}
{fmtArmor(nextGuardianData.armor)}
{fmtShield(nextGuardianData.shield)}
{fmtBarrier(nextGuardianData.barrier)}
{fmtRegen(nextGuardianData.healthRegen, nextGuardianData.healthRegenIsPercent)}
0.15)} />
);
}
// ─── Main Component ───────────────────────────────────────────────────────────
export function SpireSummaryTab() {
const { maxFloorReached, clearedFloors, enterSpireMode } = useCombatStore(useShallow((s) => ({
maxFloorReached: s.maxFloorReached,
clearedFloors: s.clearedFloors,
enterSpireMode: s.enterSpireMode,
})));
const { insight } = usePrestigeStore(useShallow((s) => ({ insight: s.insight })));
const defeatedGuardians = useMemo(() => getAllGuardianFloors().filter((floor) => clearedFloors[floor]), [clearedFloors]);
const nextGuardian = useMemo(() => getAllGuardianFloors().find((floor) => !clearedFloors[floor]) || null, [clearedFloors]);
const nextGuardianData = nextGuardian ? getGuardianForFloor(nextGuardian) : null;
const totalFloorsCleared = useMemo(() => Object.values(clearedFloors).filter(Boolean).length, [clearedFloors]);
return (
{nextGuardianData && nextGuardian && }
);
}
SpireSummaryTab.displayName = 'SpireSummaryTab';