import { nothing, PropertyValueMap } from 'lit'; import { AppType } from '../types/app.types'; import { MessageType, MessagesResultType, MutateMessageProps } from '../types/messages.types'; import { InfiniteQueryController } from '../controllers/infinite-query-controller'; import { ReverseInfiniteScrollController } from '../controllers/infinite-scroll-controller'; import { MutationController } from '../controllers/mutation-controller'; import { Ref } from 'lit/directives/ref.js'; import { PollMutationType } from '../data/poll'; import { MarkConversationMutationType, UpdateConversationMutationType } from '../data/conversation'; import { WeavySubAppComponent } from '../classes/weavy-sub-app-component'; import { ShadowPartsController } from '../controllers/shadow-parts-controller'; import { QueryController } from '../controllers/query-controller'; import { MembersResultType } from '../types/members.types'; import { MetadataType } from '../types/lists.types'; import { TypingEventType } from '../types/typing.events'; import { MsgEditorSubmitEventType } from '../types/editor.events'; import { WyEditorMessage } from './wy-editor-message'; declare global { interface HTMLElementTagNameMap { "wy-conversation": WyConversation; } } /** * Displays a single conversation with a message editor and an optional start avatar. * * **Used sub components** * * - [``](./ui/wy-avatar.ts) * - [``](./ui/wy-avatar.ts) * - [``](./ui/wy-avatar.ts) * - [``](./ui/wy-button.ts) * - [``](./ui/wy-dropdown.ts) * - [``](./wy-empty.ts) * - [``](./wy-editor-message.ts) * - [``](./ui/wy-icon.ts) * - [``](./ui/wy-item.ts) * - [``](./wy-message.ts) * - [``](./wy-message-typing.ts) * - [``](./ui/wy-progress-circular.ts) * - [``](./ui/wy-skeleton.ts) * * @slot empty - Content in the empty state. * @slot footerbar - Content in the footerbar. * * @csspart wy-pager - Pager for message infinite scroll. * @csspart wy-pager-top - Pager styling for top placement. * @csspart wy-messages - Wrapper for the conversation messages. * @csspart wy-pane - Pane for the empty state. * @csspart wy-footerbar - The footerbar where the editor is placed. * @csspart wy-footerbar-sticky - Styles for making the footerbar sticky. * @csspart wy-footerbar-floating - Styles for making the footerbar floating. * @csspart wy-messages - Wrapper for the messages list. * @csspart wy-message-date-separator - Date separator shown between message days. * @csspart wy-banner - Unread marker toast wrapper. * @csspart wy-banner-action - Modifier part for the unread marker action. * @csspart wy-fade - Modifier part used when fading the unread marker. * @csspart wy-show - Modifier part used when the unread marker is shown. * * @fires {WyActionEventType} wy-action - Emitted when an embed action button is triggered. * @fires {WyPreviewOpenEventType} wy-preview-open - Fired when a preview overlay is about to open. * @fires {WyPreviewCloseEventType} wy-preview-close - Fired when a preview overlay is closed. */ export declare class WyConversation extends WeavySubAppComponent { #private; static styles: import('lit').CSSResult[]; /** * Controller for exporting named shadow parts. * * @internal */ protected exportParts: ShadowPartsController; /** * Conversation object provided to the component (overrides AppContext). * * @type {AppType | undefined} */ conversation?: AppType; /** * Id of the conversation to load and display. */ conversationId?: number; /** * Any Message to edit */ editMessage?: MessageType; /** * Whether to render the header area for the conversation. */ header: boolean; /** * Disables the message editor. Used by hosts such as `` when no conversation is selected, since a missing * conversation alone can't disable it: Messenger creates the conversation on the first submit. */ disabled: boolean; /** * Optional instructions passed to an AI agent for the conversation. */ agentInstructions?: string; /** * Placeholder text for the message editor. */ placeholder?: string; /** * Position of the unread marker in the message list. * * @internal */ lastReadMessagePosition: "above" | "below"; /** * The id of the last read message used for rendering the unread marker. * * @internal */ lastReadMessageId?: number; /** * Whether the "new messages" banner should be shown. * * @internal */ showNewMessages: boolean; /** * Temporarily set when creating a conversation (optimistic UI). * * @internal */ isCreatingConversation: boolean; /** * Whether to show read receipts (presence of receivers). * * @internal */ showReadReceipts: boolean; /** * Optional factory to create a conversation when sending the first message. * * @internal * @type {(payload: Omit) => Promise | undefined} */ createConversation?: (payload: Omit) => Promise; /** * Optional function to request metadata for a message before sending. * * @internal * @type {(payload: MutateMessageProps) => Promise | undefined} */ requestMetadata?: (payload: MutateMessageProps) => Promise; /** * Intersection observer used to detect when the bottom sentinel is visible (for marking/scrolling). * * @internal */ protected bottomObserver: IntersectionObserver | undefined; /** * Resize observer used to keep the viewport pinned to the bottom while * message content grows asynchronously (images, embeds, attachments). * * @internal */ protected contentResizeObserver: ResizeObserver | undefined; isPrivateChat(conversation?: AppType): boolean; /** * Whether this is a private chat with a user the authenticated user has blocked. * * Private chats only -- blocks govern directed contact, not shared spaces, so the server never sets `is_blocked` on * a group. The view has to act on it: the server still delivers realtime, so nothing quiets an open conversation * unless this component does. */ isBlocked(conversation?: AppType): boolean; isChatRoom(conversation?: AppType): boolean; /** * Infinite query controller for loading messages. * * @internal */ protected messagesQuery: InfiniteQueryController; /** * Query controller for loading members for the conversation. * * @internal */ protected membersQuery: QueryController; /** * Query controller for the ids of the users the viewer has blocked. * * Not per conversation -- the query key is shared, so every conversation and every message reads one cached answer. * * @internal */ protected blockedUsersQuery: QueryController; /** * Mutation for marking conversation as read/unread. * * @internal */ protected markConversationMutation?: MarkConversationMutationType; /** * Mutation for updating conversation properties (name/avatar). * * @internal */ protected updateConversationMutation?: UpdateConversationMutationType; /** * Mutation controller for poll votes used within this conversation. * * @internal */ protected pollMutation?: PollMutationType; /** * Controller for adding messages. * * @internal */ protected addMessageMutation: MutationController; /** * Reverse infinite scroll controller (loads newest messages at bottom). * * @internal */ protected infiniteScroll: ReverseInfiniteScrollController; /** * Ref to the top pager element used for loading older messages. * * @internal */ protected pagerRef: Ref; /** * Ref to the bottom sentinel element used for scrolling/marking behavior. * * @internal */ protected bottomRef: Ref; /** * Ref to the message editor instance. * * @internal */ protected editorRef: Ref; /** * Whether the viewport should stay pinned to bottom on updates. * * @internal */ protected shouldBeAtBottom: boolean; /** * Whether another user is currently typing. * * @internal */ protected isTyping: boolean; /** * Read-only helper returning whether the viewport is currently scrolled to the bottom. * * @internal */ get isAtBottom(): boolean; /** * Whether we still need to perform the initial scroll-to-bottom for the * current conversation (i.e. we just switched conversation and haven't yet * settled at the bottom). While true, the transitional scroll position must * not be allowed to disengage the auto-pin. * * @internal */ get needsInitialScroll(): boolean; /** * Scroll the conversation to the bottom. * * @param smooth - Whether to perform a smooth scroll. * @returns Promise * * @internal */ scrollToBottom(smooth?: boolean): Promise; /** * Handle typing indicator events from child components. * * @internal * @param e - Typing event */ protected handleTyping(e: TypingEventType): void; /** * Submit handler for the message editor. Adds a message and optionally creates a conversation first. * * @internal * @param e - Editor submit event * @returns Promise */ protected handleSubmit(e: MsgEditorSubmitEventType): Promise; protected handleEditLast(_e: CustomEvent): Promise; /** * Set the editor text programmatically. * * @param text - Text to set in the editor. * @returns Promise * * @internal */ setEditorText(text: string): Promise; /** * Set metadata on the editor instance. * * @param metadata - Optional metadata object. * @returns Promise * * @internal */ setEditorMetadata(metadata?: MetadataType): Promise; /** * Select all content in the editor. * * @internal */ selectAllInEditor(): Promise; /** * Move the editor cursor to the end of the content. * * @internal */ setCursorLastInEditor(): Promise; /** * Focus the editor input. * * @internal */ focusEditor(): Promise; /** * Sets the conversation title when the conversation is empty, based on message text. * * @internal * @param name - Title string to set. * @returns Promise */ setEmptyConversationTitle(name: string): Promise; /** * Realtime handler for 'message_created' events. * * Updates local cache and handles read/unread logic. * * @internal */ private handleRealtimeMessage; /** * Realtime handler for added reactions. Updates message reactions cache. * * @internal */ private handleRealtimeReactionAdded; /** * Realtime handler for added and removed poll votes. Refreshes the options of the voted message. * * @internal */ private handleRealtimeVote; /** * Realtime handler for removed reactions. Updates message reactions cache. * * @internal */ private handleRealtimeReactionDeleted; /** * Realtime handler for app marked events (read receipts). * * @internal */ private handleRealtimeMarked; /** * Mark the conversation as read. Respects visibility and component lifecycle. * * @param messageId - Optional message id to mark as read. * @returns Promise * * @internal */ markAsRead(messageId?: number): Promise; /** * Handler bound to document visibility/scroll events that triggers markAsRead when appropriate. * * @internal */ protected markAsReadHandler: () => void; protected willUpdate(changedProperties: PropertyValueMap): Promise; renderConversationHeader(): import('../../node_modules/lit-html/node/lit-html.js').TemplateResult<1> | typeof nothing; /** * Renders the notice shown in place of the messages in a blocked private chat. * * Carries the unblock action itself: `wy-chat` has no conversation list, so the header avatar would otherwise be the * only way out. The wording promises the history back, since hiding every message otherwise reads as data loss. * * @internal */ private renderBlocked; renderMessages(): import('../../node_modules/lit-html/node/lit-html.js').TemplateResult<1>; render(): import('../../node_modules/lit-html/node/lit-html.js').TemplateResult<1>; updated(): void; connectedCallback(): void; disconnectedCallback(): void; } //# sourceMappingURL=wy-conversation.d.ts.map