import { type RefObject } from "react"; import { type IAnalyticalBackend, type IUserWorkspaceSettings } from "@gooddata/sdk-backend-spi"; import type { GenAIObjectType, IColorPalette, IGenAIUserContext } from "@gooddata/sdk-model"; import { type ChatAssistantMessageEvent, type ChatClosedEvent, type ChatCopyToClipboardEvent, type ChatDefinitionReceivedEvent, type ChatEvent, type ChatFeedbackErrorEvent, type ChatFeedbackEvent, type ChatOpenedEvent, type ChatResetEvent, type ChatSaveVisualizationErrorEvent, type ChatSaveVisualizationSuccessEvent, type ChatUserMessageEvent } from "../store/events.js"; import { type GenAIAssistantDisplayMode, type LinkHandlerEvent } from "./ConfigContext.js"; /** * Discriminated union of GenAI chat events surfaced to a caller via {@link IGenAIChatDialogConnectedProps.onEvent}. * * @remarks * Each consuming application maps these to its own telemetry sink and toast strings (the message ids differ * per app — e.g. the host's `messages.genAi.*` vs KD's `gd.gen-ai.feedback.*`), so this connected wrapper * deliberately does NOT render toasts itself; it only normalizes the raw chat events into this union. * * @internal */ export type GenAIChatConnectedEvent = { name: "opened"; payload: ChatOpenedEvent; } | { name: "closed"; payload: ChatClosedEvent; } | { name: "reset"; payload: ChatResetEvent; } | { name: "user-message"; payload: ChatUserMessageEvent; } | { name: "assistant-message"; payload: ChatAssistantMessageEvent; } | { name: "feedback"; payload: ChatFeedbackEvent; } | { name: "feedback-error"; payload: ChatFeedbackErrorEvent; } | { name: "save-visualization-success"; payload: ChatSaveVisualizationSuccessEvent; } | { name: "save-visualization-error"; payload: ChatSaveVisualizationErrorEvent; } | { name: "copy-to-clipboard"; payload: ChatCopyToClipboardEvent; } | { name: "definition-received"; payload: ChatDefinitionReceivedEvent; }; /** * Props for {@link GenAIChatDialogConnected}. * * @internal */ export interface IGenAIChatDialogConnectedProps { /** Backend; defaults to the ambient `BackendProvider` when omitted. */ backend?: IAnalyticalBackend; /** Workspace; defaults to the ambient `WorkspaceProvider` when omitted. */ workspace?: string; locale?: string; canManage?: boolean; canAnalyze?: boolean; canFullControl?: boolean; settings?: IUserWorkspaceSettings; /** Open-state is fully controlled by the caller (props, not redux). */ isOpen: boolean; /** * Whether the Gen AI chat dialog is disabled. * * @remarks * Defaults to true. The shell application is expected to explicitly enable the dialog by setting this to false. * This default prevents the dialog from briefly appearing (blinking) before the application state is fully * initialized. */ isDisabled?: boolean; onOpen: () => void; onClose: () => void; /** * Display mode of the Gen AI chat. * * @remarks * Defaults to "modal". The "inline" mode is used when the chat is embedded within another component. */ displayMode?: GenAIAssistantDisplayMode; /** A question to seed into the chat when it opens. */ askedQuestion?: string | null; /** * Monotonic counter bumped on every ask. Keying the seeding effect on it re-seeds the chat * (clear thread + send message) even when `askedQuestion` is identical to the previous ask. */ askSeq?: number; /** Context of the user's location when the question was asked, sent alongside the seeded question. */ userContext?: IGenAIUserContext; /** * Ambient user context kept in sync by the host (e.g. the open dashboard and its live filter * state). Unlike the one-shot `userContext` it persists across messages: it is attached to * every message that carries no one-shot context and drives the context indicator in the chat. * Pass `undefined` to clear it (e.g. when the user leaves the dashboard). */ ambientUserContext?: IGenAIUserContext; /** * Whether the ambient user context is currently loading. */ ambientUserContextLoading?: boolean; /** * Agent ID to use for the seeded question. If not provided, the default agent will be used. */ agentId?: string; /** When true, the seeded question is appended to the existing thread instead of clearing it first. */ appendToChat?: boolean; /** When true, the user context is replaced instead of merged with the existing one. */ replaceUserContext?: boolean; /** Object-search tag scope reflecting the caller's current view. */ includeTags?: string[]; excludeTags?: string[]; /** Override the derived object types (default: dashboard, visualization, + metric when `canManage`). */ objectTypes?: GenAIObjectType[]; /** Normalized chat events for telemetry/toasts; mapped per-consumer. */ onEvent?: (event: GenAIChatConnectedEvent) => void; /** Escape hatch firing for every raw chat event (e.g. a catch-all telemetry sink). */ onAnyEvent?: (event: ChatEvent) => void; dialogPosition?: "left" | "right"; className?: string; colorPalette?: IColorPalette; /** Defaults to `true`; embedded callers pass `false` to intercept link clicks. */ allowNativeLinks?: boolean; /** Override the default open-in-tab / same-tab navigation link handling. */ onLinkClick?: (linkClickEvent: LinkHandlerEvent) => string | undefined; /** Element (or id) focus returns to on close. */ returnFocusTo?: RefObject | string; } /** * A "connected" wrapper over {@link GenAIChatDialog} that centralizes the wiring every consumer otherwise * duplicates: object-type derivation, the dispatcher-based seeding flow (clear thread / set user context / * agentic-vs-classic message keyed on `enableAiAgenticConversations`), default link handling, and normalizing * raw chat events into the {@link GenAIChatConnectedEvent} union. * * Consumers supply their own data sources (backend/workspace/permissions), open-state, telemetry sink and * toast strings — keeping per-app i18n out of this shared component. * * @internal */ export declare function GenAIChatDialogConnected({ backend, workspace, locale, canManage, canAnalyze, canFullControl, settings, agentId, isOpen, isDisabled, displayMode, onOpen, onClose, askedQuestion, askSeq, userContext, ambientUserContext, ambientUserContextLoading, appendToChat, replaceUserContext, includeTags, excludeTags, objectTypes: objectTypesOverride, onEvent, onAnyEvent, dialogPosition, className, colorPalette, allowNativeLinks, onLinkClick, returnFocusTo, }: IGenAIChatDialogConnectedProps): import("react/jsx-runtime").JSX.Element; //# sourceMappingURL=GenAIChatDialogConnected.d.ts.map