/**
 * relay-web esbuild bundler (T1). Bundles each static entry page's TS to public/build/.
 * Browser target, ESM, sourcemaps — mirrors the base app's `build:web` conventions without
 * importing public/. No inline script anywhere (strict-CSP friendly); every HTML page loads
 * its bundle via <script type="module" src="build/<name>.js">.
 */
import { build } from 'esbuild'
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'

const here = dirname(fileURLToPath(import.meta.url))

/** Entry map: bundle name -> source module. Add a line per new HTML page. */
const ENTRIES = {
  index: resolve(here, 'src/entry/index-page.ts'),
  dashboard: resolve(here, 'src/entry/dashboard-page.ts'),
  pair: resolve(here, 'src/entry/pair-page.ts'),
  manage: resolve(here, 'src/entry/manage-page.ts'),
}

await build({
  entryPoints: ENTRIES,
  outdir: resolve(here, 'public/build'),
  bundle: true,
  format: 'esm',
  platform: 'browser',
  target: ['es2022'],
  sourcemap: true,
  logLevel: 'info',
})
