{#each timeMarkers as year} {formatYear(year)} {/each} {#each sorted as item, index} {@const yearValue = item.born || item.published || 0} {@const isItemBook = isBook(item)} {@const displayName = isItemBook ? item.title : item.name} {#if isItemBook} {@const xPos = yearToX(yearValue)} {@const isTop = item.placement === 'top'} {@const rowOffset = (item.row - 1) * (BAR_HEIGHT + BAR_GAP)} {@const yPos = isTop ? TIMELINE_Y - BAR_OFFSET - rowOffset - BAR_HEIGHT/2 : TIMELINE_Y + BAR_OFFSET + rowOffset + BAR_HEIGHT/2} { selectedPerson = item; tooltipX = e.clientX; tooltipY = e.clientY; e.stopPropagation(); }} > {displayName} {:else} {@const deathYear = item.died || new Date().getFullYear()} {@const xStart = yearToX(yearValue)} {@const xEnd = yearToX(deathYear)} {@const barWidth = Math.max(xEnd - xStart, 5)} {@const isTop = item.placement === 'top'} {@const rowOffset = (item.row - 1) * (BAR_HEIGHT + BAR_GAP)} {@const yPos = isTop ? TIMELINE_Y - BAR_OFFSET - rowOffset - BAR_HEIGHT : TIMELINE_Y + BAR_OFFSET + rowOffset} { selectedPerson = item; tooltipX = e.clientX; tooltipY = e.clientY; e.stopPropagation(); }} > {displayName} {/if} {/each}
{#if selectedPerson}
{selectedPerson.name

{selectedPerson.name || selectedPerson.title}

{#if selectedPerson.title} {selectedPerson.author}
{formatYear(selectedPerson.published)} {:else} {selectedPerson.born ? formatYear(selectedPerson.born) : ''} - {selectedPerson.died ? formatYear(selectedPerson.died) : 'present'} ({selectedPerson.died ? Math.abs(selectedPerson.died - selectedPerson.born) : Math.abs(new Date().getFullYear() - selectedPerson.born)} years) {/if}

{/if}