// Loads the game page in jsdom with the animation loop disabled, so tests can drive the simulation
// directly through the game's globals (ACT, S, R, dayTick…). The page is assembled from src/ once per
// test process (scripts/lib/page.js), so tests always run what is in src/, never a stale build.
// It is the page players get; {agent: true} loads the development page instead, with the agent facade
// (src/agent/) the MCP server drives. Only the tests of that facade ask for it, so core code that leans on
// it fails here rather than in production.
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const { JSDOM, VirtualConsole } = require('jsdom');
const { assemble } = require('../scripts/lib/page');
const PAGE = {};
const page = (dev) => PAGE[dev] || (PAGE[dev] = assemble({ dev }).html);
// The page's inline scripts, taken out of the HTML once per process and compiled once. jsdom's HTML parser is slow
// on 2 MB of script text (it was more than half of every load()), so the DOM is built from the rest of the page and
// the scripts then run in its window, in order, the same way jsdom runs them (vm.Script.runInContext). Only plain
// ';
});
// With scripting on, the parser keeps a