/** * Chat Wrapper * * Extends LazyFeature to handle lazy-loading the chat widget script. * The actual chat logic is in LazyLoadedChat which is loaded on demand. * * ## Initialization Modes (Intercom-like flexibility) * * 1. **Snippet-only (dashboard configured)**: * Just add the vTilt snippet - widget auto-configures from project settings. * ```js * vt.init('token', { api_host: '...' }) * // Chat widget appears based on dashboard settings * ``` * * 2. **Code-configured (optional overrides)**: * Override dashboard settings with code for advanced customization. * ```js * vt.init('token', { * api_host: '...', * chat: { * enabled: true, * position: 'bottom-left', * greeting: 'Custom greeting!' * } * }) * ``` * * Code config always takes precedence over dashboard settings. * * @see docs/patterns/tracker-feature-lifecycle.md */ import type { VTilt } from "../../vtilt"; import type { VTiltConfig } from "../../types"; import { LazyFeature } from "../../feature"; import { type ChatConfig, type ChatChannelSummary, type ChatWidgetView, type LazyLoadedChatInterface, type SendChatMessageContent, type SendChatMessageOptions } from "../../utils/globals"; import type { MessageCallback, TypingCallback, ConnectionCallback, Unsubscribe } from "./types"; export declare const CHAT_LOADING: "loading"; export declare class ChatWrapper extends LazyFeature { readonly name = "Chat"; readonly scriptName = "chat"; private _serverConfig; private _configFetched; private _loadError; private _bubbleDragHandle; private _pendingMessages; private _pendingCallbacks; private _messageCallbacks; private _typingCallbacks; private _connectionCallbacks; /** True after vt.showChat() so preloaded widget stays visible after replacing the lightweight bubble. */ private _bubbleExplicitShow; private _unreadPollIntervalId; constructor(instance: VTilt, config?: ChatConfig); static extractConfig(config: VTiltConfig): ChatConfig; get isEnabled(): boolean; /** * Chat has a custom start flow: fetch server settings, show bubble, * lazy-load full widget on user interaction. */ startIfEnabled(): void; stop(): void; onConfigUpdate(config: VTiltConfig): void; protected _createLoaded(): LazyLoadedChatInterface; protected _onLoaded(loaded: LazyLoadedChatInterface): void; private _startAsync; get isOpen(): boolean; get isConnected(): boolean; get isLoading(): boolean; get unreadCount(): number; get channel(): import("./types").ChatChannel | null; get channels(): ChatChannelSummary[]; get currentView(): ChatWidgetView; open(): void; close(): void; toggle(): void; show(): void; hide(): void; getChannels(): void; selectChannel(channelId: string): void; createChannel(): void; goToChannelList(): void; sendMessage(content: SendChatMessageContent, options?: SendChatMessageOptions): Promise; markAsRead(): void; registerWidget(definition: Parameters>[0]): void; onMessage(callback: MessageCallback): Unsubscribe; onTyping(callback: TypingCallback): Unsubscribe; onConnectionChange(callback: ConnectionCallback): Unsubscribe; private _isBubbleDraggable; getMergedConfig(): ChatConfig; /** Apply corner + inset to the lightweight bubble and/or loaded shadow host. */ private _syncBubbleLayout; destroy(): void; private _fetchServerSettings; private _fetchUnreadForBubble; private _showBubble; private _onVisibilityChange; private _shouldPollUnread; private _startUnreadPoll; private _stopUnreadPoll; private _schedulePreload; private _lazyLoadAndThen; }