"use client"; import { useRef } from "react"; export type Phase = "loading-first" | "ready" | "interacting"; export function PlayCanvas({ imageBase64, phase, pendingClick, onClick, }: { imageBase64: string | null; phase: Phase; pendingClick: { x: number; y: number } | null; onClick: (click: { x: number; y: number }) => void; }) { const ref = useRef(null); function handleClick(e: React.MouseEvent) { if (phase !== "ready" || !ref.current || !imageBase64) return; const rect = ref.current.getBoundingClientRect(); const x = (e.clientX - rect.left) / rect.width; const y = (e.clientY - rect.top) / rect.height; onClick({ x: Math.max(0, Math.min(1, x)), y: Math.max(0, Math.min(1, y)), }); } const interactive = phase === "ready" && !!imageBase64; const dimmed = phase === "interacting"; return (
{imageBase64 ? ( Generated frame ) : (

Painting · the · first · frame

)}
{pendingClick && ( <>
)}
1024 × 1536 · png {phase === "ready" ? "Tap · anywhere" : "···"}
); }