{#if canWrite}
{m.docs_btn_new()}
{/if}
{#if error}
{error}
{:else if documents.length > 0}
{#each documents as doc (doc.id)}
{doc.title || doc.originalFilename}
{doc.documentDate ? formatDate(doc.documentDate) : '—'}
{#if doc.location}
{doc.location}
{/if}
{m.docs_list_from()}
{#if doc.sender}
{doc.sender.firstName} {doc.sender.lastName}
{:else}
{m.docs_list_unknown()}
{/if}
{m.docs_list_to()}
{#if doc.receivers && doc.receivers.length > 0}
{doc.receivers.map((p) => p.firstName + ' ' + p.lastName).join(', ')}
{:else}
{m.docs_list_unknown()}
{/if}
{#if doc.tags && doc.tags.length > 0}
{#each doc.tags as tag (tag.id)}
{ e.preventDefault(); e.stopPropagation(); goto(`/?tag=${encodeURIComponent(tag.name)}`); }} > {tag.name}
{/each}
{/if}
{/each}
{:else}
{m.docs_empty_heading()}
{m.docs_empty_text()}
goto('/')} class="mt-6 text-sm font-bold tracking-wide text-accent uppercase transition hover:text-ink" > {m.docs_empty_btn_clear()}
{/if}