import fs from"node:fs";import path from"node:path";import Files from"../files/files.mjs";import{World}from"../packages/_module.mjs";export async function resetDemo(){const{game:o,options:e}=globalThis;if(!e.demoMode)return null;const r=e.demo;if(o.world){const e=o.world;await e.deactivate(null,{asAdmin:!0}),await e._disconnecting}const t=path.join(World.baseDir,r.worldName);await fs.promises.rm(t,{force:!0,recursive:!0}),await Files.extractArchive(r.sourceZip,t,{removeRoot:r.worldName}),World.resetPackages();const s=World.get(r.worldName);return s?(await s.setup(),setTimeout(resetDemo,1e3*r.resetSeconds),s):(global.logger.warn(`Could not load ${r.worldName}`),null)}