{#if isOwnProfile && $userStore.signedIn}
Notifications
{#each ["to-me", "from-me", "public-messages"] as mode} {@const modeLabel = mode === "to-me" ? "To Me" : mode === "from-me" ? "From Me" : "Public Messages"} {/each}
{#if loading}
Loading {notificationMode === "public-messages" ? "public messages" : "notifications"}...
{:else if error}

Error loading {notificationMode === "public-messages" ? "public messages" : "notifications"}: {error}

{:else if notificationMode === "public-messages"} {#if publicMessages.length === 0}

No public messages found.

{:else}
{#if filteredByUser}
Filtered by user: {authorProfiles.get(filteredByUser)?.displayName || authorProfiles.get(filteredByUser)?.name || `${filteredByUser.slice(0, 8)}...${filteredByUser.slice(-4)}`}
{/if}
{#each filteredMessages.slice(0, 100) as message} {@const authorProfile = authorProfiles.get(message.pubkey)} {@const isFromUser = message.pubkey === $userStore.pubkey}
{#if authorProfile?.picture} Author avatar (e.target as HTMLImageElement).style.display = 'none'} /> {:else}
{(authorProfile?.displayName || authorProfile?.name || message.pubkey.slice(0, 1)).toUpperCase()}
{/if} {#if !isFromUser}
{/if}
{isFromUser ? 'Your Message' : 'Public Message'} {message.created_at ? formatDate(message.created_at) : "Unknown date"}
{authorProfile?.displayName || authorProfile?.name || `${message.pubkey.slice(0, 8)}...${message.pubkey.slice(-4)}`} {#if authorProfile?.name && authorProfile?.displayName && authorProfile.name !== authorProfile.displayName} (@{authorProfile.name}) {/if}
{#if message.getMatchingTags("q").length > 0}
{@html renderQuotedContent(message)}
{/if} {#if message.content}
{#await parseContent(message.content) then parsedContent} {@html parsedContent} {:catch} {@html message.content} {/await}
{/if}
{/each}
{#if filteredMessages.length > 100}
Showing 100 of {filteredMessages.length} messages {filteredByUser ? `(filtered)` : ''}. Scroll to see more.
{/if}
{/if} {:else} {#if notifications.length === 0}

No notifications {notificationMode === "to-me" ? "received" : "sent"} found.

{:else}
{#each notifications.slice(0, 100) as notification} {@const authorProfile = authorProfiles.get(notification.pubkey)}
{#if authorProfile?.picture} Author avatar (e.target as HTMLImageElement).style.display = 'none'} /> {:else}
{(authorProfile?.displayName || authorProfile?.name || notification.pubkey.slice(0, 1)).toUpperCase()}
{/if}
{getNotificationType(notification)} {notification.created_at ? formatDate(notification.created_at) : "Unknown date"}
{authorProfile?.displayName || authorProfile?.name || `${notification.pubkey.slice(0, 8)}...${notification.pubkey.slice(-4)}`} {#if authorProfile?.name && authorProfile?.displayName && authorProfile.name !== authorProfile.displayName} (@{authorProfile.name}) {/if}
{#if notification.content}
{truncateContent(notification.content)}
{/if}
{/each} {#if notifications.length > 100}
Showing 100 of {notifications.length} notifications {notificationMode === "to-me" ? "received" : "sent"}. Scroll to see more.
{/if}
{/if} {/if}

{replyToMessage ? 'Reply to Message' : 'New Public Message'}

{#if quotedContent}
Replying to:
{#await parseContent(quotedContent) then parsedContent} {@html parsedContent} {:catch} {@html quotedContent} {/await}
{/if}
Sending to {selectedRecipients.length} recipient{selectedRecipients.length !== 1 ? 's' : ''}:
{#if selectedRecipients.length === 0}

No recipients selected. Click "Edit Recipients" to add recipients.

{:else}
{#each selectedRecipients as recipient} {recipient.displayName || recipient.name || `${recipient.pubkey?.slice(0, 8)}...`} {/each}
{/if}
{#if selectedRecipients.length > 0 && newMessageRelays.length > 0}
Publishing to {newMessageRelays.length} relay{newMessageRelays.length !== 1 ? 's' : ''}:
{#each newMessageRelays as relay}
{relay}
{/each}
{/if}

Select Recipients

{#if recipientLoading}
{/if}
{#if recipientResults.length > 0}
    {#each recipientResults as profile} {@const isAlreadySelected = selectedRecipients.some(r => r.pubkey === profile.pubkey)} {/each}
{:else if recipientSearch.trim()}
No results found
{:else}
Enter a search term to find users
{/if}
{/if}