@papermap/papermap 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,920 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React$1 from 'react';
3
+ import React__default, { RefObject } from 'react';
4
+ import * as class_variance_authority_types from 'class-variance-authority/types';
5
+ import { VariantProps } from 'class-variance-authority';
6
+ import * as zustand from 'zustand';
7
+ import * as axios from 'axios';
8
+ import { AxiosInstance } from 'axios';
9
+ import { Layout } from 'react-grid-layout';
10
+
11
+ interface PapermapChatProps {
12
+ token?: string;
13
+ workspaceId?: string;
14
+ dashboardId?: string;
15
+ apiUrl?: string;
16
+ /**
17
+ * Called whenever the toolbar height changes (including multiline expansion).
18
+ * Host apps can use this to add bottom padding/margin to their chart area,
19
+ * mirroring how the main app dashboard layout reacts to toolbar height.
20
+ */
21
+ onToolbarHeightChange?: (height: number) => void;
22
+ placeholder?: string;
23
+ shortcutKey?: string;
24
+ autoFade?: boolean;
25
+ fadeDelay?: number;
26
+ className?: string;
27
+ /**
28
+ * Controls whether the fixed bottom chat toolbar (input + quick actions) is rendered.
29
+ * Defaults to `true`.
30
+ */
31
+ showToolbar?: boolean;
32
+ }
33
+ declare function PapermapChat({ token, workspaceId, dashboardId, apiUrl, onToolbarHeightChange, showToolbar, ...uiProps }: PapermapChatProps): react_jsx_runtime.JSX.Element;
34
+
35
+ type TChartMeta$1 = {
36
+ title?: string;
37
+ subtitle?: string;
38
+ description?: string;
39
+ footer?: string;
40
+ showLegend?: boolean;
41
+ variant?: string;
42
+ [key: string]: any;
43
+ };
44
+ type TChartResponse = {
45
+ llm_data_chat_id: string;
46
+ name: string;
47
+ dashboard_id?: string;
48
+ chart_response?: {
49
+ chart_type: string;
50
+ error?: boolean;
51
+ data: any[];
52
+ response_type: string;
53
+ text_response?: string;
54
+ schema_hints: {
55
+ x_key: string;
56
+ y_key: string;
57
+ label_key: string;
58
+ };
59
+ visualization_config: {
60
+ colors: string[];
61
+ width: number;
62
+ height: number;
63
+ title?: string;
64
+ [key: string]: any;
65
+ };
66
+ };
67
+ meta: TChartMeta$1;
68
+ pin: boolean;
69
+ status?: string;
70
+ isFetching?: boolean;
71
+ isLoading?: boolean;
72
+ };
73
+ interface ChartDataPoint {
74
+ type: string;
75
+ count: number;
76
+ }
77
+ interface SchemaHints {
78
+ x_key: string;
79
+ y_key: string;
80
+ label_key: string;
81
+ }
82
+ interface VisualizationConfig {
83
+ colors: string[];
84
+ width: number;
85
+ height: number;
86
+ title: string;
87
+ [key: string]: any;
88
+ }
89
+ interface ChartResponse {
90
+ response_type: string;
91
+ text_response: string;
92
+ status: string | null;
93
+ data: ChartDataPoint[];
94
+ code: string | null;
95
+ chart_type: string;
96
+ schema_hints: SchemaHints;
97
+ visualization_config: VisualizationConfig;
98
+ }
99
+ type ConversationHistory = Omit<TChartResponse, 'chart_response'> & {
100
+ created_at: string;
101
+ latest_user_name?: string | null;
102
+ };
103
+
104
+ interface PapermapChartCardProps {
105
+ /**
106
+ * Connection details for API calls. Optional when the card is rendered inside
107
+ * `PapermapProvider` with the same values (or use props to override provider defaults).
108
+ */
109
+ token?: string;
110
+ workspaceId?: string;
111
+ dashboardId?: string;
112
+ apiUrl?: string;
113
+ /**
114
+ * Stable id owned by the host (layout slot, widget key, etc.). It is **not** a backend chat id.
115
+ * On successful load, the card persists `{ id, chatId }` to localStorage; on later mounts, that
116
+ * `chatId` is used for API fetches (see `resolveChartFetchChatId` in `chart-card-storage`).
117
+ */
118
+ id?: string;
119
+ /**
120
+ * Called after chart state is successfully loaded or when a preloaded `chart` prop
121
+ * is applied with a valid `llm_data_chat_id`. Errors from the host callback are caught
122
+ * and logged only.
123
+ */
124
+ onSave?: (chart: TChartResponse) => void;
125
+ /**
126
+ * The chat ID to load a chart for. When provided, the component will
127
+ * fetch the latest chart for this chat on mount (overrides `id` → localStorage map).
128
+ */
129
+ chartId?: string;
130
+ /**
131
+ * Pre-loaded chart data. When provided, the component will render this
132
+ * chart instead of fetching from the API.
133
+ */
134
+ chart?: TChartResponse;
135
+ /**
136
+ * Visual theme for the chart card. When set, renders in the specified
137
+ * mode independent of the host app. Omit to inherit the host page's theme.
138
+ */
139
+ theme?: 'light' | 'dark';
140
+ /**
141
+ * Called when the user clicks the edit button on the chart card.
142
+ * In streaming variant, if not provided, the built-in StreamingChartDialog opens.
143
+ */
144
+ onEditClick?: (chartId: string) => void;
145
+ /**
146
+ * Called when the user confirms chart deletion.
147
+ */
148
+ onDelete?: (chartId: string) => void;
149
+ /**
150
+ * Called when the pin state of the chart changes.
151
+ */
152
+ onPinChange?: (chartId: string, pinned: boolean) => void;
153
+ /**
154
+ * When true, suppress destructive actions like delete.
155
+ * (Used by viewer mode dashboards.)
156
+ */
157
+ isViewer?: boolean;
158
+ /**
159
+ * When true, the chart card will be rendered in wide mode suitable for
160
+ * table-type charts that need more horizontal space.
161
+ */
162
+ wide?: boolean;
163
+ /** Hide the chart variation selector. Defaults to true. */
164
+ hideVariants?: boolean;
165
+ /** Show the toolbar with edit/delete/maximize buttons. Defaults to true. */
166
+ showToolbar?: boolean;
167
+ /** When true, chart toolbar actions are visually disabled during layout editing. */
168
+ isEditMode?: boolean;
169
+ /** When true, show resize affordance and disable toolbar actions. */
170
+ /** Optional stable identifier for standalone resize handle instrumentation. */
171
+ className?: string;
172
+ /**
173
+ * Card variant. When `"streaming"`, clicking the edit icon opens an
174
+ * expanded chart+conversation view (StreamingChartDialog) instead of
175
+ * just calling onEditClick or opening the toolbar chat.
176
+ */
177
+ variant?: 'default' | 'streaming';
178
+ }
179
+ declare function PapermapChartCard({ token: tokenProp, workspaceId: workspaceIdProp, dashboardId: dashboardIdProp, apiUrl: apiUrlProp, id, onSave, chartId, chart: chartProp, theme, onEditClick, onDelete, isViewer, wide, hideVariants, showToolbar, isEditMode, className, variant, }: PapermapChartCardProps): react_jsx_runtime.JSX.Element;
180
+
181
+ declare function ChatAssistant(): react_jsx_runtime.JSX.Element;
182
+
183
+ interface AgentThought {
184
+ type: 'agent_thought';
185
+ content: string;
186
+ is_complete: boolean;
187
+ iteration: number;
188
+ timestamp: string;
189
+ }
190
+ interface FinalResponse {
191
+ type: 'final_response';
192
+ response_data: {
193
+ response_type: string;
194
+ generated_text: string;
195
+ chart_type?: string;
196
+ data?: any[];
197
+ pandas_code?: string;
198
+ thoughts?: string;
199
+ [key: string]: any;
200
+ };
201
+ llm_data_id: string;
202
+ total_iterations: number;
203
+ total_duration_ms: number;
204
+ token_usage?: {
205
+ prompt_tokens: number;
206
+ completion_tokens: number;
207
+ total_tokens: number;
208
+ };
209
+ timestamp: string;
210
+ }
211
+ interface ToolCall {
212
+ tool_name: string;
213
+ tool_display_name: string;
214
+ args_preview: string;
215
+ status: 'announced' | 'streaming' | 'ready' | 'executing' | 'success' | 'error';
216
+ output?: string;
217
+ code?: string;
218
+ isStreamingArgs?: boolean;
219
+ hasPrivateArgs?: boolean;
220
+ hasPrivateOutput?: boolean;
221
+ duration_ms?: number;
222
+ error_message?: string;
223
+ tool_call_id?: string;
224
+ timestamp: string;
225
+ }
226
+ interface TimelineEvent {
227
+ type: 'thought' | 'tool';
228
+ timestamp: string;
229
+ iteration?: number;
230
+ thoughtData?: AgentThought;
231
+ toolData?: ToolCall;
232
+ }
233
+ interface StreamState {
234
+ thoughts: AgentThought[];
235
+ toolCalls: ToolCall[];
236
+ timeline: TimelineEvent[];
237
+ currentPhase: string;
238
+ error: string | null;
239
+ finalResponse: any | null;
240
+ isComplete: boolean;
241
+ isConnected: boolean;
242
+ isStreaming: boolean;
243
+ }
244
+
245
+ declare function StreamingTimeline({ timeline, collapseThreshold, recentFullCount, }: {
246
+ timeline: TimelineEvent[];
247
+ collapseThreshold?: number;
248
+ recentFullCount?: number;
249
+ }): react_jsx_runtime.JSX.Element | null;
250
+
251
+ interface AgentThoughtDisplayProps {
252
+ thoughts: AgentThought[];
253
+ className?: string;
254
+ showOnlyLast?: boolean;
255
+ maxThoughts?: number;
256
+ }
257
+ declare function AgentThoughtDisplay({ thoughts, className, showOnlyLast, maxThoughts }: AgentThoughtDisplayProps): react_jsx_runtime.JSX.Element | null;
258
+
259
+ interface ToolCallDisplayProps {
260
+ toolCalls: ToolCall[];
261
+ className?: string;
262
+ showAll?: boolean;
263
+ isLatest?: boolean;
264
+ }
265
+ declare function ToolCallDisplay({ toolCalls, className, showAll, isLatest, }: ToolCallDisplayProps): react_jsx_runtime.JSX.Element | null;
266
+
267
+ declare function RecentConversations(): react_jsx_runtime.JSX.Element;
268
+
269
+ declare function ChartHistory(): react_jsx_runtime.JSX.Element;
270
+
271
+ declare function SavedMemory(): react_jsx_runtime.JSX.Element;
272
+
273
+ interface TChartMeta {
274
+ title?: string;
275
+ subtitle?: string;
276
+ footer?: string;
277
+ variant?: string;
278
+ showLegend?: boolean;
279
+ }
280
+ interface ChartViewProps {
281
+ data: any[];
282
+ chartMeta: TChartMeta;
283
+ error?: boolean;
284
+ chartType: string;
285
+ variant?: string;
286
+ className?: string;
287
+ containerClassName?: string;
288
+ visualizationConfig?: Record<string, any>;
289
+ previewMode?: boolean;
290
+ onMetaChange?: (key: 'title' | 'description' | 'footer' | 'subtitle', value: string) => void;
291
+ chartId?: string;
292
+ onClose?: () => void;
293
+ isDialog?: boolean;
294
+ onMaximize?: () => void;
295
+ showIcons?: boolean;
296
+ hideTitleAndSubtitle?: boolean;
297
+ hideVariants?: boolean;
298
+ pin?: boolean;
299
+ /** Called when the user clicks the edit action on the chart header. */
300
+ onEditClick?: () => void;
301
+ /**
302
+ * Override the built-in save-to-dashboard handler. When provided, this
303
+ * callback is invoked instead of the internal pin+meta-update logic.
304
+ */
305
+ onSaveToDashboard?: () => void;
306
+ /**
307
+ * Render the save button as a compact pill in the chart header instead
308
+ * of the default bottom-left outline button. Used in streaming layouts.
309
+ */
310
+ compactSave?: boolean;
311
+ }
312
+ declare function ChartView(props: ChartViewProps): react_jsx_runtime.JSX.Element;
313
+
314
+ interface ChartDialogProps {
315
+ token?: string;
316
+ workspaceId?: string;
317
+ dashboardId?: string;
318
+ apiUrl?: string;
319
+ isOpen: boolean;
320
+ onOpenChange: (open: boolean) => void;
321
+ title?: string;
322
+ data: any[];
323
+ chartId: string;
324
+ chartMeta: TChartMeta;
325
+ chartType: string;
326
+ visualizationConfig: Record<string, any>;
327
+ onMetaChange: (key: 'title' | 'description' | 'footer' | 'subtitle', value: string) => void;
328
+ variant?: string;
329
+ onClose?: () => void;
330
+ }
331
+ declare function ChartDialog(props: ChartDialogProps): react_jsx_runtime.JSX.Element;
332
+
333
+ interface StreamingChartDialogProps {
334
+ isOpen: boolean;
335
+ onOpenChange: (open: boolean) => void;
336
+ chartId: string;
337
+ onClose?: () => void;
338
+ /** After a successful Save-to-dashboard (pin) from this dialog; errors from the host are caught and logged. */
339
+ onSave?: (chart: TChartResponse) => void;
340
+ }
341
+ declare function StreamingChartDialog({ isOpen, onOpenChange, chartId, onClose, onSave, }: StreamingChartDialogProps): React$1.ReactPortal;
342
+
343
+ interface DataTableProps {
344
+ data: any[];
345
+ dashboardTheme?: any;
346
+ }
347
+ declare function DataTable({ data, dashboardTheme }: DataTableProps): react_jsx_runtime.JSX.Element;
348
+
349
+ declare const buttonVariants: (props?: ({
350
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
351
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
352
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
353
+ interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
354
+ asChild?: boolean;
355
+ loading?: boolean;
356
+ }
357
+
358
+ type ButtonWithTooltipProps = {
359
+ onClick: () => void;
360
+ children: React__default.ReactNode;
361
+ tooltipText: string;
362
+ className?: string;
363
+ } & ButtonProps;
364
+ declare function ButtonWithTooltip({ onClick, children, tooltipText, className, ...props }: ButtonWithTooltipProps): react_jsx_runtime.JSX.Element;
365
+
366
+ interface BookmarkButtonProps {
367
+ isBookmarked: boolean;
368
+ onToggle: () => void;
369
+ isLoading?: boolean;
370
+ }
371
+ declare function BookmarkButton({ isBookmarked, onToggle, isLoading }: BookmarkButtonProps): react_jsx_runtime.JSX.Element;
372
+
373
+ interface BranchButtonProps {
374
+ onBranch: () => void;
375
+ isLoading?: boolean;
376
+ tooltipText?: string;
377
+ }
378
+ declare function BranchButton({ onBranch, isLoading, tooltipText }: BranchButtonProps): react_jsx_runtime.JSX.Element;
379
+
380
+ interface FeedbackButtonsProps {
381
+ onFeedback: (type: 'positive' | 'negative') => void;
382
+ className?: string;
383
+ isLoading?: boolean;
384
+ selectedFeedback?: 'positive' | 'negative' | null;
385
+ loadingType?: 'positive' | 'negative' | null;
386
+ }
387
+ declare function FeedbackButtons({ onFeedback, className, isLoading, selectedFeedback, loadingType, }: FeedbackButtonsProps): react_jsx_runtime.JSX.Element;
388
+
389
+ declare function ModelSelector(): react_jsx_runtime.JSX.Element;
390
+
391
+ interface StreamingChatPanelProps {
392
+ className?: string;
393
+ /**
394
+ * When true, message rows use full available width below `sm`. Use in the streaming chart
395
+ * dialog when the chart column is hidden so chat isn’t artificially narrow.
396
+ */
397
+ expandMessageColumnOnMobile?: boolean;
398
+ /** Auto-focuses the prompt input when this panel mounts (used by dialog hosts). */
399
+ autoFocusInput?: boolean;
400
+ /** Optional action rendered beside submit button in the input row. */
401
+ inputAction?: React__default.ReactNode;
402
+ }
403
+ declare function StreamingChatPanel({ className, expandMessageColumnOnMobile, autoFocusInput, inputAction, }: StreamingChatPanelProps): react_jsx_runtime.JSX.Element;
404
+
405
+ interface LogoStandAloneProps {
406
+ className?: string;
407
+ }
408
+ declare const LogoStandAlone: ({ className }: LogoStandAloneProps) => react_jsx_runtime.JSX.Element;
409
+
410
+ interface MorphGradientProps {
411
+ className?: string;
412
+ }
413
+ declare function MorphGradient({ className }: MorphGradientProps): react_jsx_runtime.JSX.Element | null;
414
+
415
+ type StreamChartWithSSEData = {
416
+ prompt: string;
417
+ workspace_id: string;
418
+ chat_id: string;
419
+ request_id: string;
420
+ llm_model?: string;
421
+ use_search?: boolean;
422
+ stream_execution?: boolean;
423
+ };
424
+ type EditMessageWithSSEData = StreamChartWithSSEData & {
425
+ llm_data_id: string;
426
+ };
427
+ declare function createStreamingService(client: AxiosInstance): {
428
+ streamChartWithSSE: (data: StreamChartWithSSEData) => Promise<axios.AxiosResponse<any, any>>;
429
+ editMessageWithSSE: (data: EditMessageWithSSEData) => Promise<axios.AxiosResponse<any, any>>;
430
+ cancelChartRequest: (request_id: string, reason?: string) => Promise<any>;
431
+ };
432
+
433
+ type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
434
+ type TLayout = Layout & {
435
+ resizeHandles?: ResizeHandle[];
436
+ };
437
+ type PapermapGridDashboardLayouts = {
438
+ [key: string]: TLayout[];
439
+ };
440
+ interface DashboardTheme {
441
+ primary: string;
442
+ secondary: string;
443
+ interactive: string;
444
+ container: string;
445
+ module: string;
446
+ accent: string;
447
+ outline: string;
448
+ dialog: string;
449
+ fontFamily: string;
450
+ borderRadius: number;
451
+ cardBg?: string;
452
+ dashboardBg?: string;
453
+ cardIcons?: string;
454
+ cardText?: string;
455
+ cardTitle?: string;
456
+ buttonPrimary?: string;
457
+ buttonSecondary?: string;
458
+ buttonText?: string;
459
+ }
460
+
461
+ declare function createChartService(client: AxiosInstance): {
462
+ getDashboards: (params: {
463
+ workspace_id: string;
464
+ }) => Promise<any>;
465
+ updateDashboardLayout: (dashboardId: string, layout: TLayout[]) => Promise<any>;
466
+ createChat: (data: {
467
+ name: string;
468
+ dashboard_id: string;
469
+ }) => Promise<any>;
470
+ getCharts: (params: {
471
+ dashboard_id: string;
472
+ page?: number;
473
+ per_page?: number;
474
+ pin?: boolean;
475
+ }) => Promise<any>;
476
+ getConversations: (params: {
477
+ chat_id: string;
478
+ per_page?: number;
479
+ page?: number;
480
+ }) => Promise<any>;
481
+ getLatestChart: (chat_id: string) => Promise<any>;
482
+ getConversationHistory: (params: {
483
+ dashboard_id?: string;
484
+ per_page?: number;
485
+ page?: number;
486
+ }) => Promise<any>;
487
+ deleteChart: (chatId: string) => Promise<any>;
488
+ getChartHistory: (params: {
489
+ chat_id: string;
490
+ per_page?: number;
491
+ page?: number;
492
+ }) => Promise<any>;
493
+ getChartById: (chartId: string) => Promise<any>;
494
+ updateChartMeta: (chatId: string, meta: Record<string, any>) => Promise<any>;
495
+ updateChartPin: (chatId: string, pin: boolean) => Promise<any>;
496
+ bookmarkConversation: (data: {
497
+ llm_data_id: string;
498
+ dashboard_id: string;
499
+ }) => Promise<any>;
500
+ removeBookmark: (bookmarkId: string) => Promise<any>;
501
+ updateResponseLabel: (llm_data_id: string, label: "positive" | "negative") => Promise<any>;
502
+ branchConversation: (dashboard_id: string, llm_data_id: string) => Promise<any>;
503
+ getModels: () => Promise<any>;
504
+ generateProactiveDashboard: (payload: {
505
+ workspace_id: string;
506
+ dashboard_id?: string;
507
+ color_scheme?: string;
508
+ }) => Promise<any>;
509
+ };
510
+
511
+ declare function createWorkspaceService(client: AxiosInstance): {
512
+ getWorkspace: (workspaceId: string) => Promise<any>;
513
+ updateWorkspace: (workspaceId: string, workspace: Record<string, any>) => Promise<any>;
514
+ };
515
+
516
+ type PapermapHttpServices = {
517
+ authHeaders: Record<string, string>;
518
+ streamingSvc: ReturnType<typeof createStreamingService>;
519
+ chartSvc: ReturnType<typeof createChartService>;
520
+ workspaceSvc: ReturnType<typeof createWorkspaceService>;
521
+ baseUrl: string;
522
+ };
523
+ declare function createPapermapServices(config: {
524
+ token: string;
525
+ apiUrl?: string;
526
+ }): PapermapHttpServices;
527
+
528
+ interface Message {
529
+ id?: string;
530
+ llm_data_id?: string;
531
+ content: string;
532
+ role: 'user' | 'assistant' | 'error' | 'branch';
533
+ status?: 'thinking' | 'done';
534
+ thought?: string;
535
+ code?: string;
536
+ openThought?: boolean;
537
+ bookmarked?: boolean;
538
+ bookmark_id?: string;
539
+ is_inherited?: boolean;
540
+ is_rundown?: boolean;
541
+ rundown_turn_label?: string;
542
+ noIcons?: boolean;
543
+ feedback?: 'positive' | 'negative' | null;
544
+ progress_events?: {
545
+ event_type?: string;
546
+ data?: Record<string, any>;
547
+ }[];
548
+ originalContent?: string;
549
+ [key: string]: any;
550
+ }
551
+
552
+ declare const CHAT_MODAL_TAB: {
553
+ readonly CHAT: "CHAT";
554
+ readonly SAVED_MEMORY: "SAVED_MEMORY";
555
+ readonly RECENT_CONVERSATIONS: "RECENT_CONVERSATIONS";
556
+ readonly CHAT_HISTORY: "CHAT_HISTORY";
557
+ };
558
+ type ChatModalTabType = (typeof CHAT_MODAL_TAB)[keyof typeof CHAT_MODAL_TAB];
559
+ interface PapermapStoreConfig {
560
+ token: string;
561
+ workspaceId: string;
562
+ dashboardId: string;
563
+ apiUrl?: string;
564
+ /**
565
+ * Optional: use your own state (e.g. Redux) to control the selected model.
566
+ * When provided, this value is used as the initial model instead of sessionStorage.
567
+ */
568
+ initialModel?: string | null;
569
+ /**
570
+ * Optional: called whenever the selected model changes.
571
+ * Ideal place to dispatch a Redux action in the host app.
572
+ */
573
+ onModelChange?: (model: string | null) => void;
574
+ }
575
+ type Services = PapermapHttpServices;
576
+ interface Refs {
577
+ inputRef: {
578
+ current: HTMLInputElement | null;
579
+ };
580
+ textareaRef: {
581
+ current: HTMLTextAreaElement | null;
582
+ };
583
+ scrollRef: {
584
+ current: HTMLDivElement | null;
585
+ };
586
+ messagesEndRef: {
587
+ current: HTMLDivElement | null;
588
+ };
589
+ activeChatIdRef: {
590
+ current: string | null;
591
+ };
592
+ loadedConversationChatIdRef: {
593
+ current: string | null;
594
+ };
595
+ }
596
+ interface PapermapState {
597
+ messages: Message[];
598
+ isLoading: boolean;
599
+ isBranching: boolean;
600
+ isFocused: boolean;
601
+ isOpen: boolean;
602
+ inputValue: string;
603
+ isMultiline: boolean;
604
+ chatId: string | null;
605
+ editChatId: string | null;
606
+ currentRequestId: string | null;
607
+ chatModalTab: ChatModalTabType;
608
+ browserUse: boolean;
609
+ selectedModel: string | null;
610
+ viewExecution: boolean;
611
+ chartData: any[];
612
+ allMeta: TChartMeta$1;
613
+ selectedChartType: string;
614
+ chartVisuals: Record<string, any>;
615
+ totalPages: number;
616
+ currentPage: number;
617
+ isLoadingMore: boolean;
618
+ useSSEStreaming: boolean;
619
+ sseRequestId: string | null;
620
+ sseChatId: string | null;
621
+ sseThoughts: AgentThought[];
622
+ sseToolCalls: ToolCall[];
623
+ sseTimeline: TimelineEvent[];
624
+ ssePhase: string | undefined;
625
+ sseIsConnected: boolean;
626
+ sseIsStreaming: boolean;
627
+ sseIsComplete: boolean;
628
+ sseError: string | null;
629
+ }
630
+ interface PapermapActions {
631
+ setMessages: (messages: Message[] | ((prev: Message[]) => Message[])) => void;
632
+ setIsLoading: (v: boolean) => void;
633
+ setIsBranching: (v: boolean) => void;
634
+ setIsFocused: (v: boolean) => void;
635
+ setIsOpen: (v: boolean) => void;
636
+ setInputValue: (v: string | ((prev: string) => string)) => void;
637
+ setIsMultiline: (v: boolean) => void;
638
+ setIsLoadingMore: (v: boolean) => void;
639
+ setChatId: (v: string | null) => void;
640
+ setEditChatId: (v: string | null) => void;
641
+ setChatModalTab: (v: ChatModalTabType) => void;
642
+ setBrowserUse: (v: boolean) => void;
643
+ updateBrowserUse: (v: boolean) => void;
644
+ setSelectedModel: (v: string | null) => void;
645
+ setViewExecution: (v: boolean) => void;
646
+ updateChartData: (data: any[]) => void;
647
+ updateAllMeta: (meta: TChartMeta$1) => void;
648
+ updateChartType: (v: string) => void;
649
+ updateChartVisuals: (v: Record<string, any>) => void;
650
+ updateLatestChart: (result: any) => void;
651
+ clearLatestChart: () => void;
652
+ setUseSSEStreaming: (v: boolean) => void;
653
+ setSseRequestId: (v: string | null) => void;
654
+ setSseChatId: (v: string | null) => void;
655
+ clearStreamingState: () => void;
656
+ syncSseDisplay: (data: {
657
+ thoughts: AgentThought[];
658
+ toolCalls: ToolCall[];
659
+ timeline: TimelineEvent[];
660
+ phase: string | undefined;
661
+ isConnected: boolean;
662
+ isStreaming: boolean;
663
+ isComplete: boolean;
664
+ error: string | null;
665
+ }) => void;
666
+ shouldShowSSE: () => boolean;
667
+ handleSubmit: (userMessage: string) => Promise<void>;
668
+ handleCancel: () => Promise<void>;
669
+ handleNewChat: () => void;
670
+ handleScroll: (event: React.UIEvent<HTMLDivElement>) => Promise<void>;
671
+ scrollToBottom: () => void;
672
+ loadConversations: () => Promise<void>;
673
+ getRefs: () => Refs;
674
+ getServices: () => Services;
675
+ getConfig: () => PapermapStoreConfig;
676
+ }
677
+ type PapermapStore = PapermapState & PapermapActions;
678
+ declare function createPapermapStore(config: PapermapStoreConfig, injectedServices?: PapermapHttpServices): zustand.StoreApi<PapermapStore>;
679
+ type PapermapStoreApi = ReturnType<typeof createPapermapStore>;
680
+ interface OpenPapermapChatAssistantOptions {
681
+ /** When provided, opens the assistant in edit mode for this chart/chat. */
682
+ editChartId?: string | null;
683
+ /**
684
+ * Full chart to prime the store with (like main app openEditChartModal).
685
+ * When provided, sets meta, chart data, type, and visuals immediately so
686
+ * variant and chart display correctly before loadConversations/getLatestChart run.
687
+ */
688
+ chart?: TChartResponse | null;
689
+ /**
690
+ * When true, do not open/focus the floating PapermapChat assistant.
691
+ * This is useful for streaming variants that render their own embedded
692
+ * chart+conversation panel instead of the global UI.
693
+ */
694
+ suppressOpen?: boolean;
695
+ }
696
+ /**
697
+ * Opens the chart assistant (chat modal) from outside React, e.g. when the user
698
+ * clicks the Edit Chart icon. Call with the store API from a component that has
699
+ * access to it (e.g. via usePapermapStoreApi). Optionally pass editChartId to
700
+ * open in edit mode for that chart.
701
+ *
702
+ * When chart is provided (e.g. from ChartCard), primes the store like the main
703
+ * app openEditChartModal: setMessages([]), updateAllMeta(chart.meta),
704
+ * updateChartData/Type/Visuals(chart.chart_response), then set editChatId and open.
705
+ * ConversationLoader still runs loadConversations() for messages; variant shows
706
+ * immediately from chart.meta.
707
+ */
708
+ declare function openPapermapChatAssistant(storeApi: PapermapStoreApi, options?: OpenPapermapChatAssistantOptions): void;
709
+
710
+ type PapermapConnectionValue = {
711
+ token: string;
712
+ workspaceId: string;
713
+ dashboardId: string;
714
+ apiUrl?: string;
715
+ services: PapermapHttpServices;
716
+ };
717
+ interface PapermapProviderProps extends PapermapStoreConfig {
718
+ children: React__default.ReactNode;
719
+ }
720
+ declare function PapermapProvider({ children, token, workspaceId, dashboardId, apiUrl, initialModel, onModelChange, }: PapermapProviderProps): react_jsx_runtime.JSX.Element;
721
+ declare function usePapermapStore<T>(selector: (state: PapermapStore) => T): T;
722
+ /**
723
+ * Access the raw store API (for refs, services, imperative calls).
724
+ * Does NOT subscribe to re-renders -- use usePapermapStore for reactive state.
725
+ */
726
+ declare function usePapermapStoreApi(): PapermapStoreApi;
727
+ /**
728
+ * Like usePapermapStoreApi but returns null when outside a provider.
729
+ * Use this to detect if a component is already inside a PapermapProvider
730
+ * (e.g. to avoid nesting a second provider and share the same store).
731
+ */
732
+ declare function usePapermapStoreApiOptional(): PapermapStoreApi | null;
733
+ declare function usePapermapConnection(): PapermapConnectionValue;
734
+ declare function usePapermapConnectionOptional(): PapermapConnectionValue | null;
735
+
736
+ interface KeyboardShortcutHandlers {
737
+ onToggle?: () => void;
738
+ onEscape?: () => void;
739
+ shortcutKey?: string;
740
+ }
741
+ declare function useKeyboardShortcuts({ onToggle, onEscape, shortcutKey, }: KeyboardShortcutHandlers): void;
742
+
743
+ declare function useAutoResize(textareaRef: RefObject<HTMLTextAreaElement | null>, minHeight?: number, maxHeight?: number): {
744
+ resize: () => void;
745
+ };
746
+
747
+ declare function useAutoFade(enabled: boolean, delay?: number, suppressWhen?: boolean): {
748
+ isFaded: boolean;
749
+ resetFadeTimer: () => void;
750
+ };
751
+
752
+ interface UseAnalyticsStreamOptions {
753
+ onComplete?: (data: any) => void;
754
+ onError?: (error: string) => void;
755
+ onThought?: (thought: AgentThought) => void;
756
+ onToolCall?: (toolCall: ToolCall) => void;
757
+ }
758
+ /**
759
+ * Adapted from papermap's useAnalyticsStream.
760
+ * Instead of Redux for auth, receives `authHeaders` and `apiUrl` directly.
761
+ */
762
+ declare function useAnalyticsStream(requestId: string | null, authHeaders: Record<string, string>, apiUrl: string, options?: UseAnalyticsStreamOptions): {
763
+ disconnect: () => void;
764
+ markRequestAsCompleted: (reqId: string) => void;
765
+ thoughts: AgentThought[];
766
+ toolCalls: ToolCall[];
767
+ timeline: TimelineEvent[];
768
+ currentPhase: string;
769
+ error: string | null;
770
+ finalResponse: any | null;
771
+ isComplete: boolean;
772
+ isConnected: boolean;
773
+ isStreaming: boolean;
774
+ };
775
+
776
+ interface DecodedToken {
777
+ api_key_id: string;
778
+ workspace_id: string;
779
+ valid_until: number;
780
+ signature: string;
781
+ dashboard_id?: string;
782
+ tenant_id?: string;
783
+ }
784
+ declare function decodeToken(token: string): DecodedToken;
785
+ declare function buildAuthHeaders(decoded: DecodedToken): Record<string, string>;
786
+ declare function createApiClient(token: string, apiUrl?: string): {
787
+ client: axios.AxiosInstance;
788
+ decoded: DecodedToken;
789
+ authHeaders: Record<string, string>;
790
+ };
791
+
792
+ interface PapermapGridDashboardProps {
793
+ token?: string;
794
+ workspaceId?: string;
795
+ dashboardId?: string;
796
+ apiUrl?: string;
797
+ charts?: TChartResponse[];
798
+ layouts?: PapermapGridDashboardLayouts;
799
+ onLayoutsChange?: (layouts: PapermapGridDashboardLayouts) => void;
800
+ isEditMode?: boolean;
801
+ showToolbar?: boolean;
802
+ showScreenshot?: boolean;
803
+ showGenerateDashboard?: boolean;
804
+ editLayout?: boolean;
805
+ isViewer?: boolean;
806
+ onEditChart?: (chartId: string) => void;
807
+ onDeleteChart?: (chartId: string) => void;
808
+ onPinChange?: (chartId: string, pinned: boolean) => void;
809
+ onGenerateDashboard?: () => void;
810
+ isGenerating?: boolean;
811
+ onTakeScreenshot?: () => void;
812
+ onThemeModalOpen?: () => void;
813
+ /**
814
+ * Custom content inside the theme dialog. When omitted, the built-in
815
+ * `ThemeCustomizationSettings` UI is used; save updates local theme and calls
816
+ * `onDashboardThemeChange` when provided.
817
+ */
818
+ renderThemeModal?: (close: () => void) => React__default.ReactNode;
819
+ /**
820
+ * Called after a successful save from the built-in theme modal (or local-only save when
821
+ * `persistWorkspaceTheme` is false). `undefined` means the user saved the app-default preset.
822
+ */
823
+ onDashboardThemeChange?: (theme: DashboardTheme | undefined) => void;
824
+ /**
825
+ * When true (default), saving from the built-in theme UI GET/PUTs workspace `meta.theme`
826
+ * for this `dashboardId`, matching the main Papermap app.
827
+ */
828
+ persistWorkspaceTheme?: boolean;
829
+ /** Custom dashboard theme. Sets CSS variables and scoped overrides on the grid container. */
830
+ dashboardTheme?: DashboardTheme;
831
+ showHeader?: boolean;
832
+ enableFetch?: boolean;
833
+ showChatAssistant?: boolean;
834
+ variant?: 'default' | 'streaming';
835
+ }
836
+ declare function PapermapGridDashboard({ token, workspaceId, dashboardId, apiUrl, ...rest }: PapermapGridDashboardProps): react_jsx_runtime.JSX.Element;
837
+
838
+ type ThemePreset = 'default' | 'lime' | 'blue' | 'green' | 'purple' | 'ocean' | 'sunset' | 'dark' | 'minimal';
839
+
840
+ type ThemeSaveMeta = {
841
+ selectedPreset: ThemePreset | 'custom';
842
+ };
843
+ interface ThemeCustomizationSettingsProps {
844
+ /** Current theme to edit. Falls back to the default preset when omitted. */
845
+ initialTheme?: DashboardTheme;
846
+ /**
847
+ * Called when the user clicks Save. `selectedPreset` is `'default` when saving
848
+ * app default theme (workspace should drop this dashboard from `meta.theme`).
849
+ */
850
+ onSave?: (theme: DashboardTheme, meta: ThemeSaveMeta) => void | Promise<void>;
851
+ /** Called when the user clicks Close / X without saving. */
852
+ onClose?: () => void;
853
+ /** Show a saving spinner while the host persists. */
854
+ isSaving?: boolean;
855
+ }
856
+ declare function ThemeCustomizationSettings({ initialTheme, onSave, onClose, isSaving, }: ThemeCustomizationSettingsProps): react_jsx_runtime.JSX.Element;
857
+
858
+ declare const defaultTheme: DashboardTheme;
859
+ declare const themePresets: Record<ThemePreset, DashboardTheme>;
860
+ declare const themePresetList: ThemePreset[];
861
+ declare const presetDisplayNames: Record<ThemePreset, string>;
862
+
863
+ /**
864
+ * Same resolution order as main-app `useDashboardTheme` (embedded + in-app dashboard):
865
+ * 1. `meta.apply_theme_to_all_dashboards` + `meta.default_theme`
866
+ * 2. `meta.theme[dashboardId]` (falls back to `default_dashboard` when `dashboardId` is empty)
867
+ */
868
+ declare function resolveDashboardThemeFromWorkspace(workspace: {
869
+ meta?: Record<string, any>;
870
+ default_dashboard?: string;
871
+ } | null | undefined, dashboardId: string): DashboardTheme | undefined;
872
+
873
+ /**
874
+ * Persistent link between a host-owned stable id (`id` on {@link PapermapChartCard})
875
+ * and the Papermap backend `chat_id` (`llm_data_chat_id`).
876
+ *
877
+ * Stored in localStorage under a single key to avoid per-card key explosion and to allow
878
+ * future schema upgrades (version field) without breaking hosts.
879
+ */
880
+ declare const CHART_CARD_CHAT_MAP_KEY = "papermap.plugin.chartCardChatMap";
881
+ type ChartCardStorageNamespace = {
882
+ workspaceId?: string;
883
+ dashboardId?: string;
884
+ };
885
+ /** Canonical link record returned to callers and accepted on upsert. */
886
+ type ChartCardIdLink = {
887
+ /** Host key (stable widget / layout / route id). */
888
+ id: string;
889
+ /** Backend chat id used exclusively for chart API calls — never use `id` as a chat id. */
890
+ chatId: string;
891
+ };
892
+ /**
893
+ * Returns the persisted link for `id` only if a valid `{ chatId }` entry exists.
894
+ * Does not interpret `id` as a chat id.
895
+ */
896
+ declare function getChartCardIdLink(id: string, namespace?: ChartCardStorageNamespace): ChartCardIdLink | null;
897
+ /**
898
+ * Saves or updates the mapping `id` → `chatId`. Call after loads that yield a reliable backend chat id.
899
+ */
900
+ declare function upsertChartCardIdLink(link: ChartCardIdLink, namespace?: ChartCardStorageNamespace): void;
901
+ /**
902
+ * Removes the entry for `id`. If `expectedChatId` is set, removal happens only when it matches
903
+ * the stored chat id (avoids clearing another conversation after stale swaps).
904
+ */
905
+ declare function removeChartCardIdLink(id: string, expectedChatId?: string, namespace?: ChartCardStorageNamespace): void;
906
+ /**
907
+ * Resolves which **chat id** to pass to chart HTTP APIs.
908
+ *
909
+ * Order (host override first):
910
+ * 1. `chartId` prop — treated as an explicit backend chat id.
911
+ * 2. Persisted link for `cardId` — only `entry.chatId` is used for fetch; `cardId` itself is never sent as chat id.
912
+ */
913
+ declare function resolveChartFetchChatId(params: {
914
+ chartIdProp?: string;
915
+ cardId?: string;
916
+ workspaceId?: string;
917
+ dashboardId?: string;
918
+ }): string | undefined;
919
+
920
+ export { type AgentThought, AgentThoughtDisplay, BookmarkButton, BranchButton, ButtonWithTooltip, CHART_CARD_CHAT_MAP_KEY, CHAT_MODAL_TAB, type ChartCardIdLink, type ChartCardStorageNamespace, ChartDialog, ChartHistory, type ChartResponse, ChartView, ChatAssistant, type ChatModalTabType, type ConversationHistory, type DashboardTheme, DataTable, type DecodedToken, FeedbackButtons, type FinalResponse, LogoStandAlone, type Message, ModelSelector, MorphGradient, type OpenPapermapChatAssistantOptions, type PapermapActions, PapermapChartCard, type PapermapChartCardProps, PapermapChat, type PapermapChatProps, PapermapProvider as PapermapConfigProvider, type PapermapConnectionValue, PapermapGridDashboard, type PapermapGridDashboardLayouts, type TLayout as PapermapGridLayoutItem, type PapermapHttpServices, PapermapProvider, type PapermapState, type PapermapStore, type PapermapStoreApi, type PapermapStoreConfig, RecentConversations, SavedMemory, type StreamState, StreamingChartDialog, StreamingChatPanel, StreamingTimeline, type TChartMeta$1 as TChartMeta, type TChartResponse, ThemeCustomizationSettings, type ThemeCustomizationSettingsProps, type ThemePreset, type ThemeSaveMeta, type TimelineEvent, type ToolCall, ToolCallDisplay, buildAuthHeaders, createApiClient, createPapermapServices, createPapermapStore, decodeToken, defaultTheme, getChartCardIdLink, openPapermapChatAssistant, presetDisplayNames, removeChartCardIdLink, resolveChartFetchChatId, resolveDashboardThemeFromWorkspace, themePresetList, themePresets, upsertChartCardIdLink, useAnalyticsStream, useAutoFade, useAutoResize, useKeyboardShortcuts, usePapermapConnection, usePapermapConnectionOptional, usePapermapStore, usePapermapStoreApi, usePapermapStoreApiOptional };