import * as react_jsx_runtime from 'react/jsx-runtime';
import { UIMessage } from 'ai';
import { ComponentType, FormEvent } from 'react';

/**
 * AI Chat plugin localization strings
 */
interface AiChatLocalization {
    CHAT_PLACEHOLDER: string;
    CHAT_SEND_BUTTON: string;
    CHAT_EMPTY_STATE: string;
    CHAT_LOADING: string;
    CHAT_ERROR: string;
    CHAT_RETRY: string;
    CHAT_GENERIC_ERROR_TITLE: string;
    CHAT_GENERIC_ERROR_MESSAGE: string;
    CHAT_PAGE_NOT_FOUND_TITLE: string;
    CHAT_PAGE_NOT_FOUND_DESCRIPTION: string;
    SIDEBAR_TITLE: string;
    SIDEBAR_NEW_CHAT: string;
    SIDEBAR_NO_CONVERSATIONS: string;
    SIDEBAR_SEARCH_PLACEHOLDER: string;
    CONVERSATION_RENAME: string;
    CONVERSATION_RENAME_PLACEHOLDER: string;
    CONVERSATION_RENAME_SAVE: string;
    CONVERSATION_RENAME_CANCEL: string;
    CONVERSATION_DELETE: string;
    CONVERSATION_DELETE_CONFIRM_TITLE: string;
    CONVERSATION_DELETE_CONFIRM_DESCRIPTION: string;
    CONVERSATION_DELETE_CONFIRM_BUTTON: string;
    CONVERSATION_DELETE_CANCEL: string;
    IMAGE_UPLOAD_BUTTON: string;
    IMAGE_UPLOAD_UPLOADING: string;
    IMAGE_UPLOAD_ERROR_NOT_IMAGE: string;
    IMAGE_UPLOAD_ERROR_TOO_LARGE: string;
    IMAGE_UPLOAD_SUCCESS: string;
    IMAGE_UPLOAD_FAILURE: string;
    FILE_UPLOAD_BUTTON: string;
    FILE_UPLOAD_ERROR_TOO_LARGE: string;
    FILE_UPLOAD_SUCCESS: string;
    FILE_UPLOAD_FAILURE: string;
    TIME_JUST_NOW: string;
    TIME_MINUTES_AGO: string;
    TIME_HOURS_AGO: string;
    TIME_YESTERDAY: string;
    TIME_DAYS_AGO: string;
    MESSAGE_COPY: string;
    MESSAGE_COPIED: string;
    MESSAGE_RETRY: string;
    MESSAGE_EDIT: string;
    MESSAGE_SAVE: string;
    MESSAGE_CANCEL: string;
    A11Y_USER_MESSAGE: string;
    A11Y_ASSISTANT_MESSAGE: string;
    A11Y_COPY_CODE: string;
    A11Y_CODE_COPIED: string;
}

/**
 * Plugin mode for AI Chat
 * - 'authenticated': Conversations persisted with userId (default)
 * - 'public': Stateless chat, no persistence (ideal for public chatbots)
 */
type AiChatMode = "authenticated" | "public";
/**
 * State of a tool call execution
 */
type ToolCallState = "input-streaming" | "input-available" | "output-available" | "output-error";
/**
 * Props passed to custom tool call renderer components
 */
interface ToolCallProps<TInput = unknown, TOutput = unknown> {
    /** Unique identifier for this tool call */
    toolCallId: string;
    /** Name of the tool being called */
    toolName: string;
    /** Current state of the tool call execution */
    state: ToolCallState;
    /** Input arguments passed to the tool (may be partial during streaming) */
    input: TInput | undefined;
    /** Output from the tool (only available when state is 'output-available') */
    output: TOutput | undefined;
    /** Error message (only available when state is 'output-error') */
    errorText?: string;
    /** Whether the tool call is currently in progress */
    isLoading: boolean;
}
/**
 * A component that renders a custom UI for a specific tool call.
 * Return `null` to fall back to the default tool call accordion.
 */
type ToolCallRenderer<TInput = unknown, TOutput = unknown> = ComponentType<ToolCallProps<TInput, TOutput>>;
/**
 * Allowed file type categories for uploads
 */
type AllowedFileType = "image" | "text" | "pdf" | "markdown" | "csv" | "json";
/**
 * Default allowed file types (images only for best AI model compatibility)
 * Consumers can expand this by passing allowedFileTypes in overrides
 */
declare const DEFAULT_ALLOWED_FILE_TYPES: AllowedFileType[];
/**
 * Context passed to lifecycle hooks
 */
interface RouteContext {
    /** Current route path */
    path: string;
    /** Route parameters (e.g., { id: "abc123" }) */
    params?: Record<string, string>;
    /** Whether rendering on server (true) or client (false) */
    isSSR: boolean;
    /** Additional context properties */
    [key: string]: any;
}
/**
 * Overridable components and functions for the AI Chat plugin
 *
 * External consumers can provide their own implementations of these
 * to customize the behavior for their framework (Next.js, React Router, etc.)
 */
interface AiChatPluginOverrides {
    /**
     * Plugin mode - should match backend config
     * @default 'authenticated'
     */
    mode?: AiChatMode;
    /**
     * API base URL
     */
    apiBaseURL: string;
    /**
     * API base path
     */
    apiBasePath: string;
    /**
     * Navigation function for programmatic navigation
     */
    navigate: (path: string) => void | Promise<void>;
    /**
     * Refresh function to invalidate server-side cache (e.g., Next.js router.refresh())
     */
    refresh?: () => void | Promise<void>;
    /**
     * Link component for navigation
     */
    Link?: ComponentType<React.ComponentProps<"a"> & Record<string, any>>;
    /**
     * Image component for displaying images
     */
    Image?: ComponentType<React.ImgHTMLAttributes<HTMLImageElement> & Record<string, any>>;
    /**
     * Function used to upload a file and return its URL.
     * Called for images, PDFs, text files, and other supported file types.
     */
    uploadFile?: (file: File) => Promise<string>;
    /**
     * Allowed file types for upload.
     * By default, all types are enabled: image, text, pdf, markdown, csv, json
     * Set to empty array to disable file uploads entirely.
     * @default ['image', 'text', 'pdf', 'markdown', 'csv', 'json']
     */
    allowedFileTypes?: AllowedFileType[];
    /**
     * Localization object for the AI Chat plugin
     */
    localization?: Partial<AiChatLocalization>;
    /**
     * Optional headers to pass with API requests (e.g., for SSR auth)
     */
    headers?: HeadersInit;
    /**
     * Whether to show the attribution
     * @default true
     */
    showAttribution?: boolean;
    /**
     * Suggested prompts to display in the empty chat state.
     * When provided, these appear as clickable buttons that populate the input field.
     *
     * @example
     * ```tsx
     * chatSuggestions: [
     *   "What can you help me with?",
     *   "Tell me about your features",
     *   "How do I get started?",
     * ]
     * ```
     */
    chatSuggestions?: string[];
    /**
     * Custom renderers for tool calls. Keys should match tool names.
     * Each renderer receives ToolCallProps and can return custom UI.
     *
     * @example
     * ```tsx
     * toolRenderers: {
     *   getWeather: ({ toolName, input, output, state, isLoading }) => (
     *     <WeatherCard location={input?.location} weather={output} loading={isLoading} />
     *   ),
     *   searchDocs: ({ input, output, isLoading }) => (
     *     <SearchResults query={input?.query} results={output} loading={isLoading} />
     *   ),
     * }
     * ```
     */
    toolRenderers?: Record<string, ToolCallRenderer>;
    /**
     * Called when a route is rendered
     * @param routeName - Name of the route (e.g., 'chat', 'chatConversation')
     * @param context - Route context with path, params, etc.
     */
    onRouteRender?: (routeName: string, context: RouteContext) => void | Promise<void>;
    /**
     * Called when a route encounters an error
     * @param routeName - Name of the route
     * @param error - The error that occurred
     * @param context - Route context
     */
    onRouteError?: (routeName: string, error: Error, context: RouteContext) => void | Promise<void>;
    /**
     * Called before the chat page is rendered
     * Return false to prevent rendering (e.g., for authorization)
     * @param context - Route context
     */
    onBeforeChatPageRendered?: (context: RouteContext) => boolean;
    /**
     * Called before a conversation page is rendered
     * Return false to prevent rendering (e.g., for authorization)
     * @param id - The conversation ID
     * @param context - Route context
     */
    onBeforeConversationPageRendered?: (id: string, context: RouteContext) => boolean;
}

interface ChatInterfaceProps {
    apiPath?: string;
    initialMessages?: UIMessage[];
    id?: string;
    /** Variant: 'full' for full-page layout, 'widget' for embedded widget */
    variant?: "full" | "widget";
    className?: string;
    /** Called whenever messages change (for persistence). Only fires in public mode. */
    onMessagesChange?: (messages: UIMessage[]) => void;
}
declare function ChatInterface({ apiPath, initialMessages, id, variant, className, onMessagesChange, }: ChatInterfaceProps): react_jsx_runtime.JSX.Element;

interface ChatLayoutBaseProps {
    /** API base URL */
    apiBaseURL: string;
    /** API base path */
    apiBasePath: string;
    /** Current conversation ID (if viewing existing conversation) */
    conversationId?: string;
    /** Additional class name for the container */
    className?: string;
    /** Whether to show the sidebar */
    showSidebar?: boolean;
    /** Initial messages to populate the chat (useful for localStorage persistence in public mode) */
    initialMessages?: UIMessage[];
    /** Called whenever messages change (for persistence). Only fires in public mode. */
    onMessagesChange?: (messages: UIMessage[]) => void;
}
interface ChatLayoutWidgetProps extends ChatLayoutBaseProps {
    /** Widget mode: compact embeddable panel with a floating trigger button */
    layout: "widget";
    /** Height of the widget panel. Default: `"600px"` */
    widgetHeight?: string | number;
    /** Width of the widget panel. Default: `"380px"` */
    widgetWidth?: string | number;
    /**
     * Whether the widget panel starts open. Default: `false`.
     * Set to `true` when embedding inside an already-open container such as a
     * Next.js intercepting-route modal — the panel will be immediately visible
     * without the user needing to click the trigger button.
     */
    defaultOpen?: boolean;
    /**
     * Whether to render the built-in floating trigger button. Default: `true`.
     * Set to `false` when you control open/close externally (e.g. a Next.js
     * parallel-route slot, a custom button, or a `router.back()` dismiss action)
     * so that the built-in button does not appear alongside your own UI.
     */
    showTrigger?: boolean;
}
interface ChatLayoutFullProps extends ChatLayoutBaseProps {
    /** Full-page mode with sidebar navigation (default) */
    layout?: "full";
}
/** Props for the ChatLayout component */
type ChatLayoutProps = ChatLayoutWidgetProps | ChatLayoutFullProps;
/**
 * ChatLayout component that provides a full-page chat experience with sidebar
 * or a compact widget mode for embedding.
 */
declare function ChatLayout(props: ChatLayoutProps): react_jsx_runtime.JSX.Element;

interface ChatSidebarProps {
    currentConversationId?: string;
    onNewChat?: () => void;
    className?: string;
}
declare function ChatSidebar({ currentConversationId, onNewChat, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;

interface ChatMessageProps {
    message: UIMessage;
    isStreaming?: boolean;
    variant?: "default" | "compact";
    /** Callback when user wants to retry/regenerate an AI response */
    onRetry?: () => void;
    /** Callback when user edits their message - receives the new text */
    onEdit?: (newText: string) => void;
    /** Whether retry is currently in progress */
    isRetrying?: boolean;
}
declare function ChatMessage({ message, isStreaming, variant, onRetry, onEdit, isRetrying, }: ChatMessageProps): react_jsx_runtime.JSX.Element;

/** Represents an attached file with metadata */
interface AttachedFile {
    /** Data URL or uploaded URL */
    url: string;
    /** MIME type of the file */
    mediaType: string;
    /** Original filename */
    filename: string;
}
interface ChatInputProps {
    input?: string;
    handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
    handleSubmit: (e: FormEvent<HTMLFormElement>, files?: AttachedFile[]) => void;
    isLoading: boolean;
    placeholder?: string;
    variant?: "default" | "compact";
    /** Callback when files are attached (for controlled mode) */
    onFilesAttached?: (files: AttachedFile[]) => void;
    /** Attached files (for controlled mode) */
    attachedFiles?: AttachedFile[];
}
declare function ChatInput({ input, handleInputChange, handleSubmit, isLoading, placeholder, variant, onFilesAttached, attachedFiles: controlledFiles, }: ChatInputProps): react_jsx_runtime.JSX.Element;

/**
 * Default tool call display component.
 * Shows an accordion with tool name, status, inputs, and outputs.
 */
declare function ToolCallDisplay({ toolCallId, toolName, state, input, output, errorText, isLoading, }: ToolCallProps): react_jsx_runtime.JSX.Element;

export { ChatInterface as C, DEFAULT_ALLOWED_FILE_TYPES as D, ChatLayout as e, ChatSidebar as g, ChatMessage as h, ChatInput as i, ToolCallDisplay as j };
export type { AiChatMode as A, ToolCallProps as T, AiChatPluginOverrides as a, AllowedFileType as b, ToolCallState as c, ToolCallRenderer as d, ChatLayoutProps as f };
