'use client';

/**
 * @djangocfg/ui-tools — Chat
 *
 * Decomposed, transport-agnostic chat. See @dev/@refactoring7-chat/ for design.
 */

// Types
export type {
  ChatRole,
  ChatMessage,
  ChatPersona,
  ChatToolCall,
  ChatAttachment,
  ChatSource,
  ChatDisplayMode,
  ChatUserContext,
  ChatAssistantContext,
  ChatPrefs,
  ChatConfig,
  ChatLabels,
  ChatTransport,
  ChatStreamEvent,
  CreateSessionOptions,
  SessionInfo,
  HistoryPage,
  StreamOptions,
  SendOptions,
} from './types';
export { DEFAULT_LABELS } from './types';

// Config
export {
  STORAGE_KEYS,
  CSS_VARS,
  DEFAULT_Z_INDEX,
  LIMITS,
  DEFAULT_SIDEBAR,
  HOTKEYS,
  CHAT_EVENT_NAME,
  type ChatEventDetail,
} from './config';

// Core (pure)
export {
  reducer,
  initialState,
  createId,
  createTokenBuffer,
  resolvePersona,
  deriveInitials,
  type ChatState,
  type ChatAction,
  type TokenBuffer,
} from './core';

// Transport
export {
  createHttpTransport,
  createMockTransport,
  parseSSE,
  TransportError,
  type HttpTransportConfig,
  type MockTransportOptions,
  type ParseSSEOptions,
} from './core/transport';

// Hooks
export {
  useChat,
  useChatComposer,
  useChatScroll,
  useChatHistory,
  useChatLayout,
  useChatAudio,
  type UseChatConfig,
  type UseChatReturn,
  type UseChatComposerOptions,
  type UseChatComposerReturn,
  type UseChatScrollOptions,
  type UseChatScrollReturn,
  type UseChatHistoryOptions,
  type UseChatLayoutConfig,
  type UseChatLayoutReturn,
} from './hooks';

// Audio
export type {
  ChatAudioEvent,
  ChatAudioSounds,
  ChatAudioConfig,
  UseChatAudioReturn,
} from './core/audio';
export { useChatAudioPrefs } from './core/audio';

// Tool-call payload dispatcher
export {
  dispatchToolPayload,
  isPlainObject,
  isLatLng,
  isGeoJSONFeatureCollection,
  isStringValue,
  type ToolPayloadMatcher,
  type ToolPayloadFallback,
} from './core/payload-dispatch';

// Lightbox helpers
export { useChatLightbox, type UseChatLightboxReturn, type ChatLightboxState } from './hooks';
export { collectImageAttachments } from './utils/collectImageAttachments';

// Dev logger (consola-based, namespace "chat:*")
export { getChatLogger, type ChatLogger, type ChatLogScope } from './core/logger';

// Context
export {
  ChatProvider,
  useChatContext,
  useChatContextOptional,
  type ChatContextValue,
  type ChatProviderProps,
} from './context';

// Components
export {
  ChatRoot,
  MessageList,
  MessageBubble,
  MessageActions,
  Composer,
  Sources,
  ToolCalls,
  Attachments,
  AttachmentsGrid,
  AttachmentsList,
  EmptyState,
  ErrorBanner,
  JumpToLatest,
  StreamingIndicator,
  AudioToggle,
  type ChatRootProps,
  type MessageListProps,
  type MessageBubbleProps,
  type MessageActionsProps,
  type ComposerProps,
  type SourcesProps,
  type ToolCallsProps,
  type ToolPayloadKind,
  type AttachmentsProps,
  type AttachmentsGridProps,
  type AttachmentsListProps,
  type AttachmentRenderer,
  type AttachmentRendererArgs,
  type AttachmentRendererMap,
  type EmptyStateProps,
  type ErrorBannerProps,
  type JumpToLatestProps,
  type StreamingIndicatorProps,
  type AudioToggleProps,
} from './components';

// Lazy preset
export { LazyChat } from './lazy';
