/**
 * Prints ready-to-open local links for every seeded room: TV display (with a signed TV token),
 * phone join link, and host dashboard. Development helper:
 *   cd apps/web && npx tsx scripts/dev-links.ts
 */
import path from 'node:path';
import { getDb } from '@pintrush/db';
import { joinUrl, tvUrl } from '../lib/server/tokens';

try {
  process.loadEnvFile(path.resolve(import.meta.dirname, '../../../.env'));
} catch {
  // optional
}

const site = process.env.NEXT_PUBLIC_SITE_URL ?? 'http://localhost:3000';
const db = getDb();
const venues = await db.venue.findMany({ include: { rooms: { where: { status: 'ACTIVE' } } }, orderBy: { name: 'asc' } });
for (const v of venues) {
  console.log(`\n${v.name}  (join code ${v.joinCode})`);
  for (const r of v.rooms) {
    console.log(`  room "${r.name}"  id ${r.id}`);
    console.log(`    TV     ${await tvUrl(site, r)}`);
    console.log(`    Phone  ${joinUrl(site, v.joinCode, r.id)}`);
  }
}
console.log(`\nHost dashboard  ${site}/host   ·   Admin  ${site}/admin`);
await db.$disconnect();
