---
import Base from '../../layouts/Base.astro';
import SectionBanner from '../../components/SectionBanner.astro';
import RecordRow from '../../components/RecordRow.astro';
import CategoryNav from '../../components/CategoryNav.astro';
import SheetFilter from '../../components/SheetFilter.astro';
import SectionJump from '../../components/SectionJump.astro';
import { CATEGORIES } from '../../lib/taxonomy';
import { allSheets, allTools, sheetHref, isReportGuide, sheetFacets } from '../../lib/sheets';
import { url } from '../../lib/url';
/* Every sheet, once, under the shelf it canonically lives on. A cross-listed
sheet (`alsoIn`) appears on each of its shelves' own pages but only once
here, so the count in the banner is the count of sheets, not of listings. */
const sheets = await allSheets();
const tools = await allTools();
const shelves = CATEGORIES
.map((c) => ({ ...c, items: sheets.filter((s) => s.data.category === c.slug) }))
.filter((c) => c.items.length > 0);
const facetRows = shelves.flatMap((c) => c.items.map((s) => sheetFacets(s, c.slug)));
const groups = shelves.map((c) => ({ key: c.slug, label: c.title, count: c.items.length, accent: c.accent }));
const total = facetRows.length;
---
{String(ci + 1).padStart(2, '0')} ^: {c.items.length} {c.items.length === 1 ? 'sheet' : 'sheets'}