import sharp from 'sharp'
import toIco from 'to-ico'
import { readFileSync, writeFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, join } from 'node:path'
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
const pub = join(root, 'public')
const svg = readFileSync(join(pub, 'favicon.svg'))
// favicon.ico (16/32/48)
const pngs = await Promise.all(
[16, 32, 48].map((s) => sharp(svg, { density: 384 }).resize(s, s).png().toBuffer()),
)
writeFileSync(join(pub, 'favicon.ico'), await toIco(pngs))
// apple touch + pwa icon
await sharp(svg, { density: 512 }).resize(180, 180).png().toFile(join(pub, 'apple-touch-icon.png'))
await sharp(svg, { density: 512 }).resize(512, 512).png().toFile(join(pub, 'icon-512.png'))
// social card (og:image) — Quant Agent (wireframe globe)
const globe = (cx, cy, r, sw) =>
`
`
const og = ``
await sharp(Buffer.from(og)).png().toFile(join(pub, 'og.png'))
console.log('✓ icons + og generated')