import type { OpenChatOptions } from '../../lib/chat/openChat'; import type { Connector, WidgetRenderState } from '../../types'; /** * ChatTrigger connector. * * This connector reads the sibling `chat` widget's render state to expose * `open` (whether the chat is open), `toggleOpen` (to toggle it), `openChat` * (to open it and optionally submit a message) and `isChatBusy`. Custom entry * points — a hero CTA, a keyboard shortcut, an "ask about this product" link — * go through the same connector as the built-in trigger button. * * It also acts as a presence marker in the widget tree * (`$$type: 'ais.chatTrigger'`, `opensChat: true`). The `connectChat` * connector's entry-point validation looks for widgets with `opensChat` * to confirm that a trigger is mounted, and warns otherwise. */ export type ChatTriggerConnectorParams = Record; export type ChatTriggerRenderState = { /** * Whether the sibling chat widget is currently open. */ open: boolean; /** * Toggle the sibling chat widget open/closed. */ toggleOpen: () => void; /** * Opens the sibling chat widget, optionally submitting a message to it. * Without a message, the chat is opened and its input focused. Returns * `true` when a message was submitted. */ openChat: (options?: OpenChatOptions) => boolean; /** * Whether the chat is submitting or streaming a message, and so can't accept * a new one. `false` until the chat has initialized. */ isChatBusy: boolean; widgetParams: ChatTriggerConnectorParams; }; export type ChatTriggerWidgetDescription = { $$type: 'ais.chatTrigger'; renderState: ChatTriggerRenderState; indexRenderState: { chatTrigger: WidgetRenderState; }; }; export type ChatTriggerConnector = Connector; declare const connectChatTrigger: ChatTriggerConnector; export default connectChatTrigger;