import {mkdir,copyFile,writeFile,readFile} from 'node:fs/promises';
import {createHash} from 'node:crypto';
import {slides} from '../presentations/less-prompting-more-shipping/slides.mjs';
const root='presentations/less-prompting-more-shipping';
const out=`static/${root}`;
await mkdir(`${out}/assets`,{recursive:true});
for(const [src,dest] of [['dist/reveal.js','reveal.js'],['dist/reveal.css','reveal.css'],['plugin/notes/notes.js','notes.js'],['LICENSE','REVEAL-LICENSE']]) await copyFile(`node_modules/reveal.js/${src}`,`${out}/assets/${dest}`);
for(const weight of [400,700,900]) await copyFile(`node_modules/@fontsource/lato/files/lato-latin-${weight}-normal.woff2`,`${out}/assets/lato-latin-${weight}-normal.woff2`);
await copyFile('node_modules/@fontsource/lato/LICENSE',`${out}/assets/LATO-LICENSE`);
await copyFile(`${root}/theme.css`,`${out}/theme.css`);
const esc=s=>s.replaceAll('&','&').replaceAll('<','<').replaceAll('>','>').replaceAll('"','"');
await writeFile(`${out}/index.html`,`
Less Prompting, More Shipping | Eldorado
${slides.map((s,i)=>`
ELDORADO / ${esc(s.section.toUpperCase())}
<${i?'h2':'h1'}>${s.title}${i?'h2':'h1'}>${s.body}`).join('\n')}
`);
await copyFile(`${root}/runtime.js`,`${out}/runtime.js`);
const sourceDocuments = await Promise.all([...new Set(slides.flatMap(s=>s.sources).filter(s=>!s.startsWith('PDF:')))].sort().map(async id=>{
const path=`docs/strategy/${id==='measurement'?'measurement/index':id}.mdx`;
return {id,path,route:`/strategy/${id}/`,sha256:createHash('sha256').update(await readFile(path)).digest('hex')};
}));
const assignmentQuestions = [
{question:'1. What you do',slides:['starting-point','influence','months-one-two','months-three-four','months-five-six','capacity']},
{question:'2. How you measure it',slides:['measures','misleading','qualification','experiment']},
{question:'3. What you achieve',slides:['six-month-target','month-six']},
{question:'4. What comes next',slides:['target','contributors','roadmap','learning-loop','beyond','authority']},
];
const diagramSources = await Promise.all(['diagrams/strategy-target.architecture.json','diagrams/strategy-target-mobile.architecture.json'].map(async path=>({path,sha256:createHash('sha256').update(await readFile(path)).digest('hex')})));
await writeFile(`${out}/source-map.json`,JSON.stringify({version:'1.1.0',assignmentQuestions,diagramSources,strategyRevision:'same-build; exact source hashes below; deployed revision in ../../revision.txt',strategyOrigins:{longTerm:'88a43757762114a506f57ed4b44484306cae1aaa',assignment:'fcaa84f3bf9058f4ede0a097d16d0e3571590a6b',horizonCorrection:'1557813737941901572'},sourceDocuments,assignment:'AI_Architect_Test_Task.pdf',talkMinutes:slides.filter(s=>s.track==='main').reduce((a,s)=>a+s.minutes,0),discussionMinutes:slides.filter(s=>s.track==='discussion').reduce((a,s)=>a+s.minutes,0),appendixMinutes:0,timingNote:'Revised presentation allocation; PDF specifies 50 total, not the split. The six-month Strategy page retains its earlier proposed outline.',slides:slides.map(({id,title,minutes,sources,section,track},i)=>({number:i+1,id,title,minutes,section,track,sources:[...new Set(sources)]}))},null,2));
console.log(`Built ${slides.length} local Reveal.js slides at ${out}`);