export function part(demo) {
	document.body.innerHTML = `<style>body{margin: 6vh 10vw 2vh 10vw;color:#FFF;background-color:#000;}#Typer{font:3.5vw AtariLo;height:90vh;overflow:hidden;background:repeating-conic-gradient(#808080 0% 25%, transparent 0% 50%) 50% / 4px 4px;}
	@keyframes opaIn{0%{opacity:0}100%{opacity:1}}
	@keyframes opaOut{0%{opacity:1}100%{opacity:0}}
	.L{animation:opaIn .5s linear 0s normal forwards;}
	</style>
	<pre id="Typer"></pre>`
	const spd = 15
	typer(document.getElementById('Typer'), [
		{c: '', s: spd, t:''},
		{c: '', s: spd, t:' Thanks for playing!'},
		{c: '', s: spd, t:''},
		{c: '', s: spd, t:'  Shadow Party 2025  '},
		{c: '', s: spd, t:''},
		{c: '', s: spd, t:'      3 - 6 July     '},
		{c: '', s: spd, t:''},
		{c: '', s: spd, t:'  Givry-en-Argonne   '},
		{c: '', s: spd, t:'       France        '},
		{c: '', s: spd, t:''},
		{c: '', s: spd, t:'   shadow-party.org  '},
		{c: '', s: spd, t:'discord.gg/2mEc4pXvWb'},
		{c: '', s: spd, t:'                     '},
		{c: '', s: 2, t:'.................CU@🔥'},
	])
	//setTimeout(()=>{demo.next()},45*1000)
}

let typeLines = []
function typer(dest, lines) {
	typeLines = lines
	typeLine(dest)
}
function typeLine(dest) {
	if (typeLines.length == 0) return
	const line = typeLines.splice(0,1)[0]
	// start of line
	dest.insertAdjacentHTML('beforeEnd', '<span class="'+line.c+'">')

	function typeLetter(dest, line) {
		//console.log('typeLetter', line)
		if (line.t.length == 0) {
			dest.insertAdjacentHTML('beforeEnd', '</span></br>')
			typeLine(dest)
			return
		}
		let letter = line.t.substring(0, 1)
		// letter can also have class so its a HTML tag, just look for <
		if (letter == '<') {
			let till = line.t.indexOf('>')+1				// end of opening tag
			till += line.t.substring(till).indexOf('>')+1	// end of closing tag
			letter = line.t.substring(0,till)
			line.t = line.t.substring(till)
			dest.insertAdjacentHTML('beforeEnd', letter)
		} else {
			line.t = line.t.substring(1)
			dest.insertAdjacentHTML('beforeEnd', ['<span class="',line.c,'"><span class="L">',letter,'</span>'].join('') )
		}
		dest.scrollTo(0, 9000)
		setTimeout(()=>{
			typeLetter(dest, line)
		},1000/line.s)

	}
	typeLetter(dest, line)
}