{#if mailState.currentEmail.attachments && mailState.currentEmail.attachments.length > 0}
{#each mailState.currentEmail.attachments as att}
{@const base64 = arrayBufferToBase64(att.data)}
{@const isImage = att.contentType.startsWith(CONTENT_TYPES.IMAGE)}
{@const isPdf =
att.contentType === CONTENT_TYPES.PDF ||
att.filename.toLowerCase().endsWith('.pdf')}
{@const isEml = att.filename.toLowerCase().endsWith('.eml')}
{@const isPecSig = isPecSignature(att.filename, mailState.currentEmail.isPec)}
{@const isPecCert = isPecCertificate(att.filename, mailState.currentEmail.isPec)}
{#if isImage}
{:else if isPdf}
{:else if isEml}
{:else if isPecSig}
{att.filename}
{:else if isPecCert}
{att.filename}
{:else}
{#if isImage}
{:else}
{/if}
{att.filename}
{/if}
{/each}
{:else}
{m.mail_no_attachments()}
{/if}