import { useState } from "preact/hooks"; import { RUNTIME_BYTES, loadBrain, onMobileData } from "../app/brain.ts"; import { exportBadEgg, getEgg, hatchPet, replaceBadEgg } from "../app/commands.ts"; import { CFG, NAME_IDEAS } from "../app/config.ts"; import { brain, store } from "../app/store.ts"; import { fmtMB, pick } from "../app/utils.ts"; export function Setup() { const { state: s, badEgg } = store; const [owner, setOwner] = useState(s.owner); const [name, setName] = useState(() => pick(NAME_IDEAS)); const ownerStep = !s.owner || !s.egg; const progress = brain.progress; const note = brain.state === "ready" ? "The egg is wiggling! Name your pet to hatch it." : brain.state === "error" ? `The egg needs its brain, which could not load: ${brain.error}` : brain.state === "warming" ? "Almost there… something is stirring inside." : progress ? `Your egg is warming up while its brain downloads: ${fmtMB(progress.loaded)} of ${fmtMB(progress.total)}.` : "Your egg is warming up…"; return ( ); }