"use client"; import { useEffect, useState } from "react"; import { AnimatedPetSprite } from "@/components/pet/animated-pet-sprite"; import { ParallaxRoomBackground } from "@/components/pet/parallax-room-background"; import { PetStyleLink } from "@/components/pet/pet-style-link"; import { PixelGauge } from "@/components/pet/pixel-gauge"; import type { AvatarCustomization } from "@/lib/avatar-customization-storage"; import { defaultAvatarCondition, type AvatarCondition, } from "@/lib/avatar-state"; import { getAvatarConditionForToday } from "@/lib/daily-quiz-storage"; import { normalizeRoomBackgroundId, type RoomBackgroundId, } from "@/lib/room-backgrounds"; import { cn } from "@/lib/utils"; type PetHabitatProps = { customization: AvatarCustomization; className?: string; fillViewport?: boolean; }; const MOOD_LABELS = { happy: "HAPPY", neutral: "OKAY", tired: "SLEEPY", } as const; export function PetHabitat({ customization, className, fillViewport = false, }: PetHabitatProps) { const [condition, setCondition] = useState( defaultAvatarCondition, ); const [isReady, setIsReady] = useState(false); const roomId = normalizeRoomBackgroundId(customization.roomBackground); useEffect(() => { async function loadStatus() { setCondition((await getAvatarConditionForToday()) ?? defaultAvatarCondition); setIsReady(true); } void loadStatus(); }, []); const shellClassName = cn( "tamagotchi-shell overflow-hidden p-3 sm:p-4", fillViewport && "tamagotchi-shell-fill", className, ); const lcdClassName = cn( "tamagotchi-lcd relative", fillViewport ? "tamagotchi-lcd-pet-fill" : "tamagotchi-lcd-pet-match", ); if (!isReady) { return (

Waking up pet...

); } return (

{customization.name}

{MOOD_LABELS[condition.mood]}

); }