import { useRef } from "react";
import { Pico8Console, Pico8ConsoleImperatives } from "../pico8-client/Pico8Console"

export const PicoPortal = () => {
	const emptyCartData: number[] = new Array(32786).fill(0);
	const cart = {name: "empty", rom: emptyCartData};
	// const picoRef = useRef<Pico8ConsoleImperatives>(null);

	return <div>
		<Pico8Console
			ref={(ref) => {
				if (!ref) {
					return;
				}
				const handle = ref.getPicoConsoleHandle();
				if (!handle) {
					return;
				}
				handle.buttons.subscribe((buttons) => {
					console.log(buttons);
				});
			}}
			carts={[cart]}
		/>
	</div>
}