{#each pages as p}
{#each ['header', 'footer'] as const as zone}
{#each zoneBackgrounds(zone, p) as bg}

{/each}
{/each}
{/each}
{#each pages as p}
{#each ['header', 'footer'] as const as zone}
{#if !(hfActive === zone && editingPage === p)}
{@const html = zoneHtml(zone, p)}
startEdit(zone, p)}
role="button"
tabindex="-1"
use:patchFields={[p, numPages, html, chapterStarts]}
use:layOutTabs={[p, numPages, html, chapterStarts]}
>
{@html html}
{/if}
{/each}
{/each}
{#if hfActive}
{@const box = activeZoneBox(hfActive, editingPage)}
{@const index = sectionOf(editingPage)}
{@const variant = variantFor(editingPage, index)}
{hfActive === 'header'
? (variant === 'first' ? t().hf.firstPageHeader : variant === 'even' ? t().hf.evenPageHeader : t().hf.headerLabel)
: (variant === 'first' ? t().hf.firstPageFooter : variant === 'even' ? t().hf.evenPageFooter : t().hf.footerLabel)}{sets.length >
1
? ` · ${t().hf.section} ${index + 1}`
: ''}
{t().hf.insert}
{/if}