@adatechnology/conversations-ui 0.1.0-rc.2 → 0.1.0-rc.20

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.
Files changed (99) hide show
  1. package/dist/{chunk-ZDURDZTM.js → chunk-2AYDBWNE.js} +14 -0
  2. package/dist/chunk-OIDAIVCH.js +1985 -0
  3. package/dist/flows/index.d.ts +14 -2
  4. package/dist/flows/index.js +117 -39
  5. package/dist/index.d.ts +729 -136
  6. package/dist/index.js +1418 -1104
  7. package/dist/preview/index.d.ts +373 -0
  8. package/dist/preview/index.js +1247 -0
  9. package/dist/styles.css +198 -0
  10. package/dist/types-O7kMP1Yn.d.ts +416 -0
  11. package/package.json +10 -3
  12. package/src/AudioRecorderButton.test.tsx +30 -0
  13. package/src/AudioRecorderButton.tsx +248 -0
  14. package/src/Avatar.tsx +30 -4
  15. package/src/ChannelIcon.tsx +87 -0
  16. package/src/ConversationContextPanel.tsx +127 -0
  17. package/src/ConversationDocumentsPanel.tsx +425 -0
  18. package/src/ConversationHeader.tsx +257 -0
  19. package/src/ConversationListItem.tsx +54 -7
  20. package/src/ConversationLocalesProvider.tsx +16 -0
  21. package/src/ConversationRow.tsx +137 -0
  22. package/src/DateDivider.tsx +16 -3
  23. package/src/DocumentsLibrary.tsx +322 -0
  24. package/src/EmojiPicker.tsx +69 -55
  25. package/src/FileIcon.test.ts +83 -0
  26. package/src/FileIcon.tsx +88 -11
  27. package/src/InteractiveMessage.test.tsx +41 -0
  28. package/src/InteractiveMessage.tsx +143 -0
  29. package/src/Lightbox.tsx +18 -3
  30. package/src/MediaRenderer.tsx +64 -21
  31. package/src/MessageBubble.tsx +54 -5
  32. package/src/MessageComposer.test.tsx +35 -0
  33. package/src/MessageComposer.tsx +146 -19
  34. package/src/RichMessageComposer.test.tsx +83 -0
  35. package/src/RichMessageComposer.tsx +380 -0
  36. package/src/Wallpaper.test.tsx +21 -0
  37. package/src/Wallpaper.tsx +54 -6
  38. package/src/WhatsAppMessageEditor.tsx +28 -4
  39. package/src/WindowExpiredNotice.tsx +57 -0
  40. package/src/audioRecorderFormat.test.ts +67 -0
  41. package/src/conversationChannel.test.ts +53 -0
  42. package/src/conversationChannel.ts +146 -0
  43. package/src/conversationTranscript.test.ts +65 -0
  44. package/src/conversationTranscript.ts +64 -0
  45. package/src/conversationWindow.test.ts +90 -0
  46. package/src/conversationWindow.ts +78 -0
  47. package/src/documentTypeLabel.test.ts +57 -0
  48. package/src/emojiCatalog.test.ts +35 -0
  49. package/src/emojiCatalog.ts +189 -0
  50. package/src/flows/FlowGroupHeader.tsx +12 -2
  51. package/src/flows/FlowMapCanvas.tsx +17 -14
  52. package/src/flows/FlowMapNode.tsx +3 -1
  53. package/src/flows/FlowNodeCard.tsx +22 -4
  54. package/src/flows/FlowNodePanel.tsx +132 -35
  55. package/src/flows/FlowPalette.tsx +6 -2
  56. package/src/flows/FlowWhatsAppPreview.tsx +14 -3
  57. package/src/flows/flowGraph.ts +5 -5
  58. package/src/flows/labels.ts +5 -0
  59. package/src/hooks/useConversationActions.ts +56 -0
  60. package/src/hooks/useConversationDocuments.ts +15 -9
  61. package/src/hooks/useConversationList.ts +15 -9
  62. package/src/hooks/useConversationMessages.ts +2 -2
  63. package/src/index.ts +129 -16
  64. package/src/lib/cn.test.ts +29 -0
  65. package/src/lib/cn.ts +15 -0
  66. package/src/lib/createMediaUrlResolver.ts +33 -0
  67. package/src/lib/paginated.test.ts +33 -0
  68. package/src/lib/paginated.ts +26 -0
  69. package/src/lib/phone.ts +34 -0
  70. package/src/preview/ConversationPreview.tsx +325 -0
  71. package/src/preview/MediaTypesPreview.tsx +87 -0
  72. package/src/preview/conversationPreviewFailures.test.ts +64 -0
  73. package/src/preview/createMockConversationsApi.ts +271 -0
  74. package/src/preview/createMockSSEProvider.ts +40 -0
  75. package/src/preview/createPreviewBridgeClient.test.ts +92 -0
  76. package/src/preview/createPreviewBridgeClient.ts +88 -0
  77. package/src/preview/createPreviewWebhookClient.test.ts +105 -0
  78. package/src/preview/createPreviewWebhookClient.ts +131 -0
  79. package/src/preview/index.ts +61 -0
  80. package/src/preview/mediaTypeOf.test.ts +15 -0
  81. package/src/preview/mockDocumentsSearch.test.ts +57 -0
  82. package/src/preview/mockEventSource.ts +53 -0
  83. package/src/preview/preview.test.ts +177 -0
  84. package/src/preview/previewFileSamples.test.ts +151 -0
  85. package/src/preview/previewFileSamples.ts +74 -0
  86. package/src/preview/previewFixtures.ts +440 -0
  87. package/src/preview/previewMediaSource.test.ts +62 -0
  88. package/src/preview/previewMediaSource.ts +91 -0
  89. package/src/preview/previewStore.ts +193 -0
  90. package/src/preview/startPreviewScript.ts +60 -0
  91. package/src/providers/types.ts +163 -11
  92. package/src/quickReply.test.ts +58 -0
  93. package/src/settings/WhatsAppCreateTemplateForm.tsx +3 -1
  94. package/src/settings/WhatsAppTemplatesSettings.tsx +106 -0
  95. package/src/styles.css +136 -0
  96. package/src/types.ts +46 -1
  97. package/src/useDarkMode.ts +26 -0
  98. package/src/useIsNarrow.ts +29 -0
  99. package/src/useWaitingNotifications.ts +74 -29
package/dist/index.d.ts CHANGED
@@ -1,55 +1,7 @@
1
1
  import * as react from 'react';
2
- import react__default, { ReactNode, FormEvent } from 'react';
3
-
4
- interface ConversationsUIConfig {
5
- apiBaseUrl: string;
6
- theme?: ConversationsTheme;
7
- features?: ConversationsFeatures;
8
- }
9
- interface ConversationsTheme {
10
- primaryColor?: string;
11
- backgroundColor?: string;
12
- bubbleSent?: string;
13
- bubbleReceived?: string;
14
- textPrimary?: string;
15
- textSecondary?: string;
16
- }
17
- interface ConversationsFeatures {
18
- audio?: boolean;
19
- documents?: boolean;
20
- emoji?: boolean;
21
- darkMode?: boolean;
22
- }
23
- interface MessagePayload {
24
- id: string;
25
- type: 'text' | 'image' | 'video' | 'audio' | 'document' | 'sticker' | 'template';
26
- content?: string;
27
- caption?: string;
28
- mediaUrl?: string;
29
- base64?: string;
30
- uploadId?: string;
31
- mediaId?: string;
32
- mimeType?: string;
33
- filename?: string;
34
- sizeBytes?: number;
35
- direction: 'inbound' | 'outbound';
36
- sender: 'bot' | 'customer' | 'agent';
37
- timestamp: string;
38
- status?: 'sent' | 'delivered' | 'read' | 'failed';
39
- readAt?: string;
40
- agentName?: string | null;
41
- templateName?: string;
42
- isFirstInGroup?: boolean;
43
- isLastInGroup?: boolean;
44
- }
45
-
46
- type ResolveMediaUrl = (message: MessagePayload) => Promise<string | null>;
47
- interface MediaRendererProps {
48
- message: MessagePayload;
49
- onLightbox: (src: string) => void;
50
- onResolveUrl?: ResolveMediaUrl;
51
- }
52
- declare function MediaRenderer({ message, onLightbox, onResolveUrl }: MediaRendererProps): react.JSX.Element | null;
2
+ import react__default, { ReactNode, CSSProperties, FormEvent } from 'react';
3
+ import { G as MessagePayload, K as ResolveMediaUrl, z as InteractiveSelection, x as InteractivePayload, r as ConversationsFeatures, o as ConversationSummary, j as ConversationChannel, L as ListConversationsParams, q as ConversationsApi, S as SSEProvider, B as ListDocumentsParams, k as ConversationDocument, p as ConversationTemplate } from './types-O7kMP1Yn.js';
4
+ export { A as AudioRecorderButton, a as AudioRecorderButtonLabels, b as AudioRecorderButtonProps, C as CHANNEL_CAPABILITIES, c as CHANNEL_FILTER_ALL, d as CONVERSATION_CHANNEL, e as ChannelCapabilities, f as ChannelFilter, g as ChannelFilterOption, h as CompanyDocument, i as CompanyDocumentPage, l as ConversationDocumentPage, m as ConversationEventSource, n as ConversationPage, s as ConversationsTheme, t as ConversationsUIConfig, D as DEFAULT_AUDIO_RECORDER_BUTTON_LABELS, u as DEFAULT_CONVERSATION_CHANNEL, v as DEFAULT_MAX_RECORDING_MILLISECONDS, F as FormatContactHandleParams, H as HANDLE_KIND, w as HandleKind, I as InteractiveOption, y as InteractiveSection, M as MediaRenderer, E as MediaRendererProps, R as REOPEN_MECHANISM, J as ReopenMechanism, N as capabilitiesOf, O as channelFiltersFor, P as contactFlag, Q as formatContactHandle } from './types-O7kMP1Yn.js';
53
5
 
54
6
  interface MessageBubbleProps {
55
7
  message: MessagePayload;
@@ -59,15 +11,40 @@ interface MessageBubbleProps {
59
11
  isSelecting?: boolean;
60
12
  isSelected?: boolean;
61
13
  onToggleSelect?: () => void;
14
+ /**
15
+ * Como buscar a mídia da mensagem. Ausente, o balão usa o `ConversationsApi` do
16
+ * `ConversationsProvider` — passe apenas para sobrescrever (cache próprio, CDN, proxy do host).
17
+ */
62
18
  onResolveMediaUrl?: ResolveMediaUrl;
19
+ /**
20
+ * Toque numa opção do menu interativo. Ausente, as opções aparecem desabilitadas — que é o certo
21
+ * no histórico da inbox: o operador vê o que foi oferecido, sem responder no lugar do cliente.
22
+ */
23
+ onInteractiveSelect?: (selection: InteractiveSelection) => void;
24
+ className?: string;
63
25
  }
64
- declare function MessageBubble({ message, isMine, senderName, isFirstInGroup, isSelecting, isSelected, onToggleSelect, onResolveMediaUrl, }: MessageBubbleProps): react.JSX.Element;
26
+ declare function MessageBubble({ message, isMine, senderName, isFirstInGroup, isSelecting, isSelected, onToggleSelect, onResolveMediaUrl, onInteractiveSelect, className, }: MessageBubbleProps): react.JSX.Element;
27
+
28
+ interface InteractiveMessageLabels {
29
+ /** Fallback do rótulo do botão que abre a lista, quando o payload não traz um. */
30
+ openList: string;
31
+ }
32
+ declare const DEFAULT_INTERACTIVE_MESSAGE_LABELS: InteractiveMessageLabels;
33
+ interface InteractiveMessageProps {
34
+ payload: InteractivePayload;
35
+ onSelect?: (selection: InteractiveSelection) => void;
36
+ labels?: Partial<InteractiveMessageLabels>;
37
+ className?: string;
38
+ }
39
+ declare function InteractiveMessage({ payload, onSelect, labels, className }: InteractiveMessageProps): react.JSX.Element;
65
40
 
66
41
  interface ConversationWallpaperProps {
67
42
  children?: ReactNode;
68
43
  className?: string;
44
+ /** Ajusta ou substitui o fundo padrão — para produto com identidade visual própria. */
45
+ style?: CSSProperties;
69
46
  }
70
- declare function ConversationWallpaper({ children, className }: ConversationWallpaperProps): react.JSX.Element;
47
+ declare function ConversationWallpaper({ children, className, style }: ConversationWallpaperProps): react.JSX.Element;
71
48
 
72
49
  interface ConversationLocales {
73
50
  bubble: {
@@ -82,6 +59,14 @@ interface ConversationLocales {
82
59
  viewImage: string;
83
60
  listenAudio: string;
84
61
  viewVideo: string;
62
+ moderationFlagged: string;
63
+ mediaLoading: string;
64
+ mediaRetry: string;
65
+ mediaError: string;
66
+ mediaUnavailable: string;
67
+ imageAlt: string;
68
+ untitledDocument: string;
69
+ downloadFile: string;
85
70
  };
86
71
  selection: {
87
72
  select: string;
@@ -107,13 +92,69 @@ interface AudioPlayerProps {
107
92
  }
108
93
  declare function AudioPlayer({ src, isMine }: AudioPlayerProps): react.JSX.Element;
109
94
 
95
+ interface EmojiPickerLabels {
96
+ search: string;
97
+ noResults: string;
98
+ }
99
+ declare const DEFAULT_EMOJI_PICKER_LABELS: EmojiPickerLabels;
110
100
  interface EmojiPickerProps {
111
101
  onSelect: (emoji: string) => void;
102
+ labels?: Partial<EmojiPickerLabels>;
112
103
  className?: string;
113
104
  }
114
- declare const EmojiPicker: ({ onSelect, className }: EmojiPickerProps) => react.JSX.Element;
105
+ declare const EmojiPicker: ({ onSelect, labels, className }: EmojiPickerProps) => react.JSX.Element;
115
106
 
107
+ /**
108
+ * Catálogo de emojis com palavras-chave em português, usado pela busca do seletor.
109
+ *
110
+ * Fica em módulo próprio (e não dentro do `EmojiPicker`) porque a busca precisa varrer TODAS as
111
+ * categorias, não só a aberta — o índice é montado uma vez, no carregamento, e não a cada tecla.
112
+ *
113
+ * As palavras-chave são de busca, não legendas: incluem sinônimos e formas sem acento, porque quem
114
+ * digita rápido escreve "coracao" e "polegar" com a mesma frequência que a forma correta.
115
+ */
116
+ type EmojiEntry = {
117
+ readonly emoji: string;
118
+ readonly keywords: readonly string[];
119
+ };
120
+ type EmojiCategory = {
121
+ readonly name: string;
122
+ readonly entries: readonly EmojiEntry[];
123
+ };
124
+ declare const EMOJI_CATEGORIES: readonly EmojiCategory[];
125
+ /**
126
+ * Busca por prefixo de palavra-chave, não por substring: "ca" traz "casa" e "cartão", mas "sa" não
127
+ * traz "casa" — casar no meio da palavra devolvia resultado que ninguém consegue explicar.
128
+ */
129
+ declare function searchEmojis(query: string): readonly EmojiEntry[];
130
+
131
+ /**
132
+ * Mensagem pronta que o atendente cola no campo com um clique.
133
+ *
134
+ * `text` aceita string com `{{variavel}}` ou função: a string cobre o caso comum (copy fixa com o
135
+ * nome do cliente no meio) sem o host escrever código, e a função cobre o que precisa de lógica —
136
+ * escolher texto por produto, pluralizar, formatar moeda.
137
+ */
138
+ interface QuickReply {
139
+ key: string;
140
+ /** O que aparece no chip, emoji incluso: `👋 Saudação`. */
141
+ label: string;
142
+ text: string | ((variables: Readonly<Record<string, string>>) => string);
143
+ }
144
+ /**
145
+ * Troca `{{nome}}` pelos valores passados. Variável ausente vira string vazia, e não o literal
146
+ * `{{nome}}`: mandar "Olá {{nome}}!" para o cliente é pior que mandar "Olá !".
147
+ */
148
+ declare function applyQuickReplyVariables(template: string, variables?: Readonly<Record<string, string>>): string;
149
+ declare function resolveQuickReply(quickReply: QuickReply, variables?: Readonly<Record<string, string>>): string;
150
+ interface MessageComposerLabels {
151
+ emoji: string;
152
+ attach: string;
153
+ send: string;
154
+ }
155
+ declare const DEFAULT_MESSAGE_COMPOSER_LABELS: MessageComposerLabels;
116
156
  interface MessageComposerProps {
157
+ labels?: Partial<MessageComposerLabels>;
117
158
  onSend: (text: string) => void;
118
159
  onAttach?: (file: File) => void;
119
160
  value?: string;
@@ -123,10 +164,122 @@ interface MessageComposerProps {
123
164
  maxLength?: number;
124
165
  disabled?: boolean;
125
166
  acceptedFileTypes?: string;
167
+ /**
168
+ * Ocupa o lugar do botão de enviar enquanto não há nada para enviar — é onde o WhatsApp põe o
169
+ * microfone. Fora do campo, o botão vira um bloco solto ao lado do pill e quebra a barra.
170
+ */
171
+ idleAction?: ReactNode;
172
+ /** Mensagens prontas exibidas acima do campo. Vazio ou ausente, a faixa não é renderizada. */
173
+ quickReplies?: readonly QuickReply[];
174
+ /** Valores para `{{variavel}}` — tipicamente nome do cliente, produto, protocolo. */
175
+ quickReplyVariables?: Readonly<Record<string, string>>;
176
+ className?: string;
177
+ classNames?: Partial<MessageComposerClassNames>;
126
178
  }
127
- declare const MessageComposer: ({ onSend, onAttach, value: externalValue, onChange: externalOnChange, features, placeholder, maxLength, disabled, acceptedFileTypes, }: MessageComposerProps) => react.JSX.Element;
179
+ interface MessageComposerClassNames {
180
+ root: string;
181
+ quickReplies: string;
182
+ quickReply: string;
183
+ field: string;
184
+ }
185
+ /**
186
+ * Exatamente o que a Meta aceita em mensagem de mídia — imagem, sticker, áudio, vídeo e a lista
187
+ * fechada de documentos. Oferecer no seletor um formato que o WhatsApp recusa (`.zip`, `.rtf`)
188
+ * empurra a falha para depois do envio, quando já não dá para explicar ao operador o que houve.
189
+ * Produto com regra própria passa `acceptedFileTypes`.
190
+ */
191
+ declare const DEFAULT_ACCEPTED_FILE_TYPES: string;
192
+ declare const MessageComposer: ({ onSend, onAttach, value: externalValue, onChange: externalOnChange, quickReplies, quickReplyVariables, features, placeholder, maxLength, disabled, acceptedFileTypes, idleAction, className, classNames, labels, }: MessageComposerProps) => react.JSX.Element;
128
193
 
194
+ /** Cada ação que a barra sabe oferecer. `toolbar` decide quais delas aparecem. */
195
+ declare const RICH_COMPOSER_ACTION: {
196
+ readonly BOLD: "bold";
197
+ readonly ITALIC: "italic";
198
+ readonly STRIKETHROUGH: "strikethrough";
199
+ readonly MONOSPACE: "monospace";
200
+ readonly EMOJI: "emoji";
201
+ readonly ATTACH: "attach";
202
+ readonly VARIABLES: "variables";
203
+ };
204
+ type RichComposerAction = (typeof RICH_COMPOSER_ACTION)[keyof typeof RICH_COMPOSER_ACTION];
205
+ /** Texto das dicas. O host troca só o que quiser; o resto fica no padrão. */
206
+ interface RichComposerTooltips {
207
+ bold: string;
208
+ italic: string;
209
+ strikethrough: string;
210
+ monospace: string;
211
+ emoji: string;
212
+ attach: string;
213
+ send: string;
214
+ variables: string;
215
+ }
216
+ declare const DEFAULT_RICH_COMPOSER_TOOLTIPS: RichComposerTooltips;
217
+ /**
218
+ * Um valor que o operador pode inserir no texto sem digitar. `value` é o que entra no campo — pode
219
+ * ser o dado já resolvido ("Anderson") ou um marcador a resolver depois ("{{nome}}"): quem decide é
220
+ * o host, porque só ele sabe se a substituição acontece aqui ou no envio.
221
+ */
222
+ interface RichComposerVariable {
223
+ id: string;
224
+ label: string;
225
+ value: string;
226
+ /** Prévia do que será inserido, para o operador conferir antes de tocar. */
227
+ tooltip?: string;
228
+ }
229
+ /** Uma resposta rápida: o que o operador lê no chip e o que cai no campo ao tocar nele. */
230
+ interface RichComposerQuickReply {
231
+ id: string;
232
+ label: string;
233
+ text: string;
234
+ /** Dica ao passar o mouse. Sem isto, o chip não tem `title` — rótulo curto já se explica. */
235
+ tooltip?: string;
236
+ }
237
+ /** Handle imperativo: `contentEditable` controlado pelo React perde o cursor a cada tecla. */
238
+ interface RichMessageComposerHandle {
239
+ setContent: (text: string) => void;
240
+ clear: () => void;
241
+ focus: () => void;
242
+ }
243
+ interface RichMessageComposerProps {
244
+ /** Texto na notação do WhatsApp (`*negrito*`), não HTML. */
245
+ value: string;
246
+ onChange: (value: string) => void;
247
+ onSend: () => void;
248
+ onAttachFiles?: (files: FileList) => void;
249
+ quickReplies?: RichComposerQuickReply[];
250
+ /** Variáveis que o operador pode inserir no texto. Vazio ou ausente, o botão não aparece. */
251
+ variables?: RichComposerVariable[];
252
+ /**
253
+ * Quais ações aparecem. Ausente, todas aparecem — menos as que não têm como funcionar (anexo sem
254
+ * `onAttachFiles` some sozinho, porque botão que não faz nada é pior que botão nenhum).
255
+ */
256
+ toolbar?: Partial<Record<RichComposerAction, boolean>>;
257
+ tooltips?: Partial<RichComposerTooltips>;
258
+ placeholder?: string;
259
+ disabled?: boolean;
260
+ isSending?: boolean;
261
+ /** Ocupa o lugar do enviar enquanto não há nada para enviar — onde o WhatsApp põe o microfone. */
262
+ idleAction?: ReactNode;
263
+ /** Prévia dos anexos já escolhidos, desenhada pelo host acima da barra. */
264
+ attachmentsPreview?: ReactNode;
265
+ acceptedFileTypes?: string;
266
+ className?: string;
267
+ }
268
+ declare const RichMessageComposer: react.ForwardRefExoticComponent<RichMessageComposerProps & react.RefAttributes<RichMessageComposerHandle>>;
269
+
270
+ interface WhatsAppMessageEditorLabels {
271
+ bold: string;
272
+ /** Tooltip da negrito — traz a sintaxe do WhatsApp junto, por isso é separado do `aria-label`. */
273
+ boldHint: string;
274
+ italic: string;
275
+ italicHint: string;
276
+ strikethrough: string;
277
+ strikethroughHint: string;
278
+ insertPlaceholder: (token: string) => string;
279
+ }
280
+ declare const DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS: WhatsAppMessageEditorLabels;
129
281
  interface WhatsAppMessageEditorProps {
282
+ labels?: Partial<WhatsAppMessageEditorLabels>;
130
283
  value: string;
131
284
  onChange: (value: string) => void;
132
285
  placeholder?: string;
@@ -135,7 +288,7 @@ interface WhatsAppMessageEditorProps {
135
288
  previewLabel?: string;
136
289
  emptyPreviewText?: string;
137
290
  }
138
- declare function WhatsAppMessageEditor({ value, onChange, placeholder, placeholders, rows, previewLabel, emptyPreviewText, }: WhatsAppMessageEditorProps): react.JSX.Element;
291
+ declare function WhatsAppMessageEditor({ value, onChange, placeholder, placeholders, rows, previewLabel, emptyPreviewText, labels, }: WhatsAppMessageEditorProps): react.JSX.Element;
139
292
 
140
293
  interface SimpleEmojiPickerProps {
141
294
  onSelect: (emoji: string) => void;
@@ -145,89 +298,58 @@ interface SimpleEmojiPickerProps {
145
298
  }
146
299
  declare function SimpleEmojiPicker({ onSelect, label, pickerWidth, pickerMaxHeight }: SimpleEmojiPickerProps): react.JSX.Element;
147
300
 
301
+ interface DateDividerClassNames {
302
+ root: string;
303
+ label: string;
304
+ }
148
305
  interface DateDividerProps {
149
306
  iso: string;
307
+ className?: string;
308
+ classNames?: Partial<DateDividerClassNames>;
150
309
  }
151
- declare function DateDivider({ iso }: DateDividerProps): react.JSX.Element;
310
+ declare function DateDivider({ iso, className, classNames }: DateDividerProps): react.JSX.Element;
152
311
 
312
+ interface AvatarLabels {
313
+ /** Lido por leitor de tela quando não há nome nem imagem — a silhueta genérica. */
314
+ unnamedContact: string;
315
+ }
153
316
  interface AvatarProps {
154
317
  name?: string | null;
155
318
  avatarUrl?: string;
156
319
  size?: 'sm' | 'md' | 'lg';
157
320
  className?: string;
321
+ labels?: Partial<AvatarLabels>;
158
322
  }
159
- declare function Avatar({ name, avatarUrl, size, className }: AvatarProps): react.JSX.Element;
160
-
161
- interface ConversationsApi {
162
- fetchMessages(conversationId: string, params?: {
163
- limit?: number;
164
- before?: string;
165
- }): Promise<MessagePayload[]>;
166
- fetchConversations(params?: {
167
- page?: number;
168
- limit?: number;
169
- waitingHuman?: boolean;
170
- search?: string;
171
- }): Promise<ConversationSummary[]>;
172
- sendMessage(conversationId: string, text: string): Promise<MessagePayload>;
173
- sendMedia(conversationId: string, data: {
174
- base64: string;
175
- mimeType: string;
176
- filename: string;
177
- caption?: string;
178
- }): Promise<MessagePayload>;
179
- sendTemplate(conversationId: string, data: {
180
- templateName: string;
181
- languageCode?: string;
182
- bodyParams?: string[];
183
- }): Promise<void>;
184
- markRead(conversationId: string): Promise<void>;
185
- getContext(conversationId: string): Promise<Record<string, unknown>>;
186
- getDocuments(conversationId: string, params?: {
187
- search?: string;
188
- page?: number;
189
- }): Promise<ConversationDocument[]>;
190
- getDocumentUrl(uploadId: string): Promise<string>;
191
- getMediaProxyUrl(mediaId: string): Promise<{
192
- mimeType: string;
193
- data: string;
194
- }>;
195
- }
196
- interface SSEProvider {
197
- connectConversationStream(conversationId: string): EventSource;
198
- connectGlobalStream(): EventSource;
199
- }
200
- interface ConversationSummary {
201
- id: string;
202
- whatsappNumber: string;
203
- clientName?: string;
204
- lastContent?: string;
205
- lastDirection?: 'inbound' | 'outbound';
206
- lastAt: string;
207
- lastInboundAt: string | null;
208
- mode: 'bot' | 'human';
209
- assignedUserId: string | null;
210
- waitingHuman: boolean;
211
- unread: number;
212
- currentState: string;
213
- }
214
- interface ConversationDocument {
215
- id: string;
216
- filename: string;
217
- mimeType: string;
218
- sizeBytes: number;
219
- source: string;
220
- linkedAt: string;
221
- }
323
+ declare const DEFAULT_AVATAR_LABELS: AvatarLabels;
324
+ declare function Avatar({ name, avatarUrl, size, className, labels }: AvatarProps): react.JSX.Element;
222
325
 
326
+ interface ConversationListItemLabels {
327
+ /** Tooltip do ponto vermelho: a janela de atendimento de 24h já fechou. */
328
+ expiredWindow: string;
329
+ /** Tooltip do ponto laranja: a janela de atendimento está perto de fechar. */
330
+ warningWindow: string;
331
+ }
332
+ declare const DEFAULT_CONVERSATION_LIST_ITEM_LABELS: ConversationListItemLabels;
223
333
  interface ConversationListItemProps {
224
334
  conversation: ConversationSummary;
335
+ labels?: Partial<ConversationListItemLabels>;
225
336
  active?: boolean;
226
337
  selected?: boolean;
227
338
  onClick?: () => void;
228
339
  onSelect?: (id: string) => void;
340
+ /**
341
+ * Desliga a borda inferior quando o item é composto dentro de outra linha (ver `ConversationRow`):
342
+ * com ela ligada, a borda corta a própria linha ao meio, separando o item do rodapé de status.
343
+ */
344
+ showDivider?: boolean;
345
+ /**
346
+ * Desliga o fundo de selecionado. Par do `showDivider`: quando o item é composto dentro de uma
347
+ * linha maior, quem pinta o realce é a linha — senão só o bloco do item fica cinza e o resto
348
+ * (checkbox, pills, barra lateral) continua branco, como se metade da linha estivesse selecionada.
349
+ */
350
+ highlightActive?: boolean;
229
351
  }
230
- declare const ConversationListItem: ({ conversation, active, selected, onClick, onSelect, }: ConversationListItemProps) => react.JSX.Element;
352
+ declare const ConversationListItem: ({ conversation, active, selected, onClick, onSelect, showDivider, highlightActive, labels, }: ConversationListItemProps) => react.JSX.Element;
231
353
 
232
354
  type ToastType = 'success' | 'error' | 'info';
233
355
  interface ToastContextValue {
@@ -247,12 +369,19 @@ interface StatusTicksProps {
247
369
  }
248
370
  declare function StatusTicks({ status, title }: StatusTicksProps): react.JSX.Element;
249
371
 
372
+ interface LightboxLabels {
373
+ /** Texto alternativo quando a imagem não tem legenda — sem ele o leitor de tela anuncia a URL. */
374
+ imageAlt: string;
375
+ close: string;
376
+ }
250
377
  interface LightboxProps {
251
378
  imageUrl: string;
252
379
  caption?: string;
253
380
  onClose: () => void;
381
+ labels?: Partial<LightboxLabels>;
254
382
  }
255
- declare function Lightbox({ imageUrl, caption, onClose }: LightboxProps): react.JSX.Element;
383
+ declare const DEFAULT_LIGHTBOX_LABELS: LightboxLabels;
384
+ declare function Lightbox({ imageUrl, caption, onClose, labels }: LightboxProps): react.JSX.Element;
256
385
 
257
386
  interface FileIconProps {
258
387
  filename?: string;
@@ -279,16 +408,413 @@ interface MessageTailProps {
279
408
  }
280
409
  declare function MessageTail({ isOutbound }: MessageTailProps): react.JSX.Element;
281
410
 
411
+ /**
412
+ * Janela de sessão: o intervalo em que o canal aceita mensagem livre do atendente. No WhatsApp são
413
+ * 24h desde o último contato do cliente; fora dela só template. Cada canal tem a sua regra — e há
414
+ * canal sem janela nenhuma — então a política vem de `capabilitiesOf`, não de constante fixa.
415
+ *
416
+ * Mora no SDK porque é regra de plataforma, não de produto: todo projeto que usa este pacote
417
+ * precisa dela para saber o que o atendente ainda consegue fazer.
418
+ */
419
+
420
+ declare const CONVERSATION_WINDOW: {
421
+ readonly ALL: "all";
422
+ readonly FRESH: "fresh";
423
+ readonly WARNING: "warning";
424
+ readonly CRITICAL: "critical";
425
+ readonly EXPIRED: "expired";
426
+ };
427
+ type ConversationWindow = (typeof CONVERSATION_WINDOW)[keyof typeof CONVERSATION_WINDOW];
428
+ declare const WINDOW_FILTERS: readonly [{
429
+ readonly value: "all";
430
+ readonly label: "Todas";
431
+ readonly dotClass: "";
432
+ }, {
433
+ readonly value: "fresh";
434
+ readonly label: "<12h";
435
+ readonly dotClass: "bg-green-500";
436
+ }, {
437
+ readonly value: "warning";
438
+ readonly label: "12-21h";
439
+ readonly dotClass: "bg-yellow-500";
440
+ }, {
441
+ readonly value: "critical";
442
+ readonly label: "21-24h";
443
+ readonly dotClass: "bg-red-500";
444
+ }, {
445
+ readonly value: "expired";
446
+ readonly label: ">24h";
447
+ readonly dotClass: "bg-gray-400";
448
+ }];
449
+ type WindowOfParams = {
450
+ readonly lastInboundAt: string | null;
451
+ readonly now: number;
452
+ /** Ausente = `whatsapp`. */
453
+ readonly channel?: ConversationChannel | undefined;
454
+ };
455
+ /**
456
+ * Sem `lastInboundAt` o cliente nunca escreveu, então não há janela aberta — classificar como
457
+ * expirada é o comportamento seguro: evita o atendente tentar texto livre e receber recusa.
458
+ *
459
+ * Canal sem janela de sessão (chat de site) é sempre `fresh`: ali nada expira, e marcar expirado
460
+ * bloquearia o composer inventando um limite que a plataforma não impõe.
461
+ */
462
+ declare function windowOf(params: WindowOfParams): ConversationWindow;
463
+ declare function formatStalledFor(lastAt: string, now: number): string;
464
+
465
+ type ConversationRowClassNames = {
466
+ root: string;
467
+ windowBar: string;
468
+ };
469
+ type ConversationRowProps = {
470
+ conversation: ConversationSummary;
471
+ active: boolean;
472
+ selected: boolean;
473
+ now: number;
474
+ busy: boolean;
475
+ onOpen: () => void;
476
+ onToggleSelected: () => void;
477
+ onTakeover: () => void;
478
+ className?: string;
479
+ classNames?: Partial<ConversationRowClassNames>;
480
+ };
481
+ declare function ConversationRow({ conversation, active, selected, now, busy, onOpen, onToggleSelected, onTakeover, className, classNames, }: ConversationRowProps): react.JSX.Element;
482
+
483
+ declare const CHANNEL_BRAND_COLOR: Readonly<Record<ConversationChannel, string>>;
484
+ interface ChannelIconProps {
485
+ channel?: ConversationChannel | undefined;
486
+ size?: number;
487
+ className?: string;
488
+ }
489
+ declare function ChannelIcon({ channel, size, className }: ChannelIconProps): react.JSX.Element;
490
+
491
+ interface ConversationHeaderLabels {
492
+ botMode: string;
493
+ humanMode: string;
494
+ returnToBot: string;
495
+ finish: string;
496
+ takeover: string;
497
+ download: string;
498
+ documents: string;
499
+ back: string;
500
+ moreActions: string;
501
+ }
502
+ declare const DEFAULT_CONVERSATION_HEADER_LABELS: ConversationHeaderLabels;
503
+ /**
504
+ * Partes estilizáveis do cabeçalho. Cada chave recebe classes que o `cn` funde por cima da base, e
505
+ * conflito de utilitário (padding, gap, borda) fica com o valor do produto.
506
+ */
507
+ interface ConversationHeaderClassNames {
508
+ root: string;
509
+ identity: string;
510
+ name: string;
511
+ meta: string;
512
+ actions: string;
513
+ desktopActions: string;
514
+ mobileMenu: string;
515
+ }
516
+ /**
517
+ * Utilitário extra que o host pendura no cabeçalho — ícone no desktop, item de menu no celular,
518
+ * como os nativos. Entra por aqui, e não por um slot de ReactNode, porque é isso que preserva o
519
+ * comportamento responsivo: um nó solto viraria um quarto ícone em 375px, sem área de toque.
520
+ */
521
+ interface ConversationHeaderUtility {
522
+ key: string;
523
+ /** Emoji, para casar com os utilitários nativos do cabeçalho. */
524
+ icon: string;
525
+ label: string;
526
+ run: () => void;
527
+ active?: boolean;
528
+ }
529
+ interface ConversationHeaderProps {
530
+ conversation: ConversationSummary;
531
+ busy?: boolean;
532
+ onTakeover?: () => void;
533
+ onReturnToBot?: () => void;
534
+ onFinish?: () => void;
535
+ onDownload?: () => void;
536
+ onOpenDocuments?: () => void;
537
+ documentsOpen?: boolean;
538
+ /** Ações do produto que não existem no contrato do pacote (ex.: ferramentas de dev). */
539
+ extraUtilities?: readonly ConversationHeaderUtility[];
540
+ onBack?: () => void;
541
+ labels?: Partial<ConversationHeaderLabels>;
542
+ className?: string;
543
+ classNames?: Partial<ConversationHeaderClassNames>;
544
+ }
545
+ declare function ConversationHeader({ conversation, busy, onTakeover, onReturnToBot, onFinish, onDownload, onOpenDocuments, documentsOpen, extraUtilities, onBack, labels: labelsOverride, className, classNames, }: ConversationHeaderProps): react.JSX.Element;
546
+
547
+ /**
548
+ * "Suas Seleções": o que o bot já coletou na conversa. Para o atendente que assume no meio, é a
549
+ * diferença entre ler o transcript inteiro e ver o estado em duas linhas.
550
+ *
551
+ * O pacote não interpreta o contexto — ele é `Record<string, unknown>` e cada produto nomeia as
552
+ * próprias chaves. O host traduz para `entries`; aqui só se decide como mostrar.
553
+ */
554
+ interface ConversationContextEntry {
555
+ key: string;
556
+ label: string;
557
+ value?: string | undefined;
558
+ icon?: string;
559
+ }
560
+ interface ConversationContextPanelLabels {
561
+ title: string;
562
+ empty: string;
563
+ collapse: string;
564
+ expand: string;
565
+ }
566
+ declare const DEFAULT_CONVERSATION_CONTEXT_LABELS: ConversationContextPanelLabels;
567
+ interface ConversationContextPanelClassNames {
568
+ root: string;
569
+ toggle: string;
570
+ counter: string;
571
+ body: string;
572
+ }
573
+ interface ConversationContextPanelProps {
574
+ entries: readonly ConversationContextEntry[];
575
+ /**
576
+ * Estado inicial. Ausente, abre sozinho no desktop quando há algum dado preenchido.
577
+ *
578
+ * Existe porque "abre sozinho" nem sempre é o que o produto quer: com 1 de 6 campos preenchidos o
579
+ * painel ocupa altura mostrando quase só travessões, e empurra a conversa — que é o que se veio ver.
580
+ */
581
+ defaultOpen?: boolean;
582
+ labels?: Partial<ConversationContextPanelLabels>;
583
+ className?: string;
584
+ classNames?: Partial<ConversationContextPanelClassNames>;
585
+ }
586
+ declare function ConversationContextPanel({ entries, defaultOpen, labels: labelsOverride, className, classNames, }: ConversationContextPanelProps): react.JSX.Element;
587
+
588
+ interface WindowExpiredNoticeLabels {
589
+ title: string;
590
+ description: string;
591
+ sendTemplate: string;
592
+ }
593
+ declare const DEFAULT_WINDOW_EXPIRED_LABELS: WindowExpiredNoticeLabels;
594
+ interface WindowExpiredNoticeProps {
595
+ onSendTemplate?: () => void;
596
+ disabled?: boolean;
597
+ labels?: Partial<WindowExpiredNoticeLabels>;
598
+ className?: string;
599
+ }
600
+ declare function WindowExpiredNotice({ onSendTemplate, disabled, labels: labelsOverride, className, }: WindowExpiredNoticeProps): react.JSX.Element;
601
+ /**
602
+ * Só a faixa `expired` bloqueia: 21-24h ainda aceita texto livre e merece alerta, não impedimento.
603
+ */
604
+ declare function isWindowBlocking(window: ConversationWindow): boolean;
605
+
606
+ /**
607
+ * Biblioteca de arquivos de TODAS as conversas — a tela de Documentos do painel, fora do
608
+ * atendimento.
609
+ *
610
+ * Distinta do `ConversationDocumentsPanel`: aquele parte de uma conversa aberta e vive dentro dela;
611
+ * esta varre a empresa e por isso mostra de qual conversa cada arquivo veio, com o número
612
+ * clicável. Sem essa referência, uma lista global de anexos não responde nenhuma pergunta.
613
+ */
614
+ interface DocumentsLibraryLabels {
615
+ title: string;
616
+ searchPlaceholder: string;
617
+ empty: string;
618
+ noResults: string;
619
+ loading: string;
620
+ failure: string;
621
+ view: string;
622
+ download: string;
623
+ openConversation: string;
624
+ sourceFilterAll: string;
625
+ sourceFilterCustomer: string;
626
+ sourceFilterTeam: string;
627
+ sortMostRecent: string;
628
+ sortOldest: string;
629
+ clearFilters: string;
630
+ total: (count: number) => string;
631
+ page: (current: number, last: number) => string;
632
+ }
633
+ declare const DEFAULT_DOCUMENTS_LIBRARY_LABELS: DocumentsLibraryLabels;
634
+ interface DocumentsLibraryClassNames {
635
+ root: string;
636
+ title: string;
637
+ filters: string;
638
+ search: string;
639
+ sourceSelect: string;
640
+ sortButton: string;
641
+ clearButton: string;
642
+ status: string;
643
+ list: string;
644
+ item: string;
645
+ conversationLink: string;
646
+ filename: string;
647
+ meta: string;
648
+ pagination: string;
649
+ }
650
+ interface DocumentsLibraryProps {
651
+ /** Itens por página. O total vem do servidor. */
652
+ perPage?: number;
653
+ /** Abrir a conversa de origem. Ausente, o número aparece como texto e não como link. */
654
+ onOpenConversation?: (conversationId: string) => void;
655
+ labels?: Partial<DocumentsLibraryLabels>;
656
+ className?: string;
657
+ classNames?: Partial<DocumentsLibraryClassNames>;
658
+ }
659
+ declare function DocumentsLibrary({ perPage, onOpenConversation, labels: labelsOverride, className, classNames, }: DocumentsLibraryProps): react.JSX.Element | null;
660
+
661
+ /**
662
+ * Arquivos trocados na conversa. Sai do transcript e vira lista própria porque anexo é o que o
663
+ * atendente mais precisa reencontrar depois — rolar meses de mensagens para achar um comprovante é
664
+ * o caso que a busca por documento existe para eliminar.
665
+ *
666
+ * Usa `useConversationDocuments`, então funciona com qualquer `ConversationsApi`. Host sem
667
+ * biblioteca de documentos cai no estado vazio, sem quebrar.
668
+ */
669
+ /** Origens que o filtro oferece. `all` não é origem — é a ausência de filtro. */
670
+ declare const DOCUMENT_SOURCE_FILTER: {
671
+ readonly ALL: "all";
672
+ readonly CUSTOMER: "customer";
673
+ readonly TEAM: "team";
674
+ };
675
+ type DocumentSourceFilter = (typeof DOCUMENT_SOURCE_FILTER)[keyof typeof DOCUMENT_SOURCE_FILTER];
676
+ interface ConversationDocumentsPanelLabels {
677
+ toggle: string;
678
+ title: string;
679
+ searchPlaceholder: string;
680
+ empty: string;
681
+ /** Distinto de `empty`: sem resultado POR CAUSA do filtro, e não conversa sem anexo nenhum. */
682
+ noResults: string;
683
+ loading: string;
684
+ failure: string;
685
+ download: string;
686
+ view: string;
687
+ sourceFilterAll: string;
688
+ sourceFilterCustomer: string;
689
+ sourceFilterTeam: string;
690
+ sortMostRecent: string;
691
+ sortOldest: string;
692
+ clearFilters: string;
693
+ selectAll: string;
694
+ downloadSelected: (count: number) => string;
695
+ archiveFailed: string;
696
+ total: (count: number) => string;
697
+ page: (current: number, last: number) => string;
698
+ }
699
+ declare const DEFAULT_CONVERSATION_DOCUMENTS_LABELS: ConversationDocumentsPanelLabels;
700
+ /**
701
+ * Partes estilizáveis do painel, no mesmo contrato do `ConversationHeader`: `cn` funde por cima da
702
+ * base e conflito de utilitário (padding, tamanho de fonte, borda) fica com o valor do produto.
703
+ *
704
+ * `status` cobre carregando/erro/vazio de uma vez — são a mesma linha de texto auxiliar, e slots
705
+ * separados só multiplicariam chave para quem quer mudar a cor de aviso.
706
+ */
707
+ interface ConversationDocumentsPanelClassNames {
708
+ root: string;
709
+ body: string;
710
+ title: string;
711
+ filters: string;
712
+ search: string;
713
+ sourceSelect: string;
714
+ sortButton: string;
715
+ clearButton: string;
716
+ status: string;
717
+ list: string;
718
+ item: string;
719
+ sourceBadge: string;
720
+ filename: string;
721
+ meta: string;
722
+ viewButton: string;
723
+ downloadButton: string;
724
+ pagination: string;
725
+ selectionBar: string;
726
+ checkbox: string;
727
+ }
728
+ interface ConversationDocumentsPanelProps {
729
+ conversationId: string;
730
+ /** Controlado de fora porque o gatilho vive no cabeçalho, junto das outras ações da conversa. */
731
+ open: boolean;
732
+ /** Itens por página. O total vem do servidor; sem paginação no host, a barra não aparece. */
733
+ perPage?: number;
734
+ labels?: Partial<ConversationDocumentsPanelLabels>;
735
+ className?: string;
736
+ classNames?: Partial<ConversationDocumentsPanelClassNames>;
737
+ }
738
+ declare function ConversationDocumentsPanel({ conversationId, open, perPage, labels: labelsOverride, className, classNames, }: ConversationDocumentsPanelProps): react.JSX.Element | null;
739
+
740
+ /**
741
+ * Serialização do transcript para download. Fica no pacote porque o formato de um histórico de
742
+ * WhatsApp legível não é regra de negócio de ninguém — e porque o host que já tem as mensagens em
743
+ * tela não deveria precisar de rota nova só para salvar um arquivo.
744
+ *
745
+ * Funções puras, separadas do disparo do download: é o que permite testá-las sem DOM.
746
+ */
747
+
748
+ type BuildTranscriptTextParams = {
749
+ readonly messages: readonly MessagePayload[];
750
+ readonly whatsappNumber: string;
751
+ readonly clientName?: string | undefined;
752
+ };
753
+ /**
754
+ * Formato próximo ao export nativo do WhatsApp (`[data hora] Autor: texto`), que é o que pessoas e
755
+ * ferramentas de suporte já sabem ler.
756
+ */
757
+ declare function buildTranscriptText(params: BuildTranscriptTextParams): string;
758
+ declare function buildTranscriptFilename(whatsappNumber: string, generatedAt: Date): string;
759
+ /**
760
+ * Dispara o download no navegador. `revokeObjectURL` no fim não é higiene opcional: sem ele cada
761
+ * export retém o blob inteiro em memória até a aba fechar.
762
+ */
763
+ declare function downloadTextFile(filename: string, content: string): void;
764
+
765
+ /**
766
+ * Leitura passiva do tema do host: observa a classe `dark` no `<html>` e não escreve nada.
767
+ *
768
+ * Existe porque `useDarkMode` é um controlador — ele grava a classe e persiste a preferência. Um
769
+ * componente que só precisa escolher cor não pode usá-lo: bastava renderizar o mapa de fluxos
770
+ * para o app inteiro do host trocar de tema, seguindo o `prefers-color-scheme` do sistema em vez
771
+ * da configuração da aplicação.
772
+ */
773
+ declare function useIsDarkTheme(): boolean;
282
774
  declare function useDarkMode(): {
283
775
  isDark: boolean;
284
776
  toggle: () => void;
285
777
  };
286
778
 
779
+ /**
780
+ * Detecta tela estreita para decisões que CSS não resolve — como abrir ou não um painel por padrão.
781
+ *
782
+ * O breakpoint é o mesmo das classes `cv-only-*` e `.cv-back` (1024px). Duplicado aqui porque
783
+ * JavaScript não lê media query do stylesheet; se um dia divergirem, o sintoma é painel abrindo
784
+ * numa largura onde o resto da UI já mudou de modo.
785
+ */
786
+ declare const NARROW_MAX_WIDTH_PX = 1023;
787
+ declare function useIsNarrow(): boolean;
788
+
789
+ interface UseWaitingNotificationsLabels {
790
+ /** Título da notificação do sistema. Recebe a conversa para o host escolher nome × número. */
791
+ title: (conversation: ConversationSummary) => string;
792
+ body: (conversation: ConversationSummary) => string;
793
+ }
794
+ interface UseWaitingNotificationsParams {
795
+ /**
796
+ * Repassado cru ao `fetchConversations`. É o que permite filtrar não lidas **no servidor** em
797
+ * vez de baixar a lista inteira e contar no cliente: um painel com milhares de conversas não
798
+ * pode paginar 50 por vez atrás de quem tem `unread > 0`.
799
+ */
800
+ readonly params?: ListConversationsParams;
801
+ readonly intervalMs?: number;
802
+ /** Desliga o polling sem desmontar quem chama — útil com a aba em segundo plano. */
803
+ readonly enabled?: boolean;
804
+ readonly icon?: string;
805
+ readonly labels?: Partial<UseWaitingNotificationsLabels>;
806
+ }
287
807
  interface UseWaitingNotificationsResult {
288
808
  unreadCount: number;
289
809
  conversations: ConversationSummary[];
810
+ /**
811
+ * Releitura sob demanda. Existe porque o polling é o piso, não o mecanismo: quem já recebe SSE
812
+ * ou acabou de marcar tudo como lido sabe da mudança antes do próximo tick, e esperar 10s para
813
+ * o contador acompanhar faz a interface parecer travada.
814
+ */
815
+ refresh: () => Promise<void>;
290
816
  }
291
- declare function useWaitingNotifications(): UseWaitingNotificationsResult;
817
+ declare function useWaitingNotifications(params?: UseWaitingNotificationsParams): UseWaitingNotificationsResult;
292
818
 
293
819
  interface ConversationsContextValue {
294
820
  api: ConversationsApi;
@@ -370,6 +896,7 @@ interface WhatsAppCreateTemplateFormLabels {
370
896
  sectionDescription: string;
371
897
  nameLabel: string;
372
898
  nameHint: string;
899
+ namePlaceholder: string;
373
900
  categoryLabel: string;
374
901
  languageLabel: string;
375
902
  headerLabel: string;
@@ -435,6 +962,41 @@ interface WelcomeFarewellFormProps {
435
962
  }
436
963
  declare function WelcomeFarewellForm({ welcomeMessage, onWelcomeMessageChange, farewellMessage, onFarewellMessageChange, onSave, saving, saveSuccess, welcomePlaceholders, farewellPlaceholders, labels: labelsOverride, }: WelcomeFarewellFormProps): react.JSX.Element;
437
964
 
965
+ declare const TEMPLATE_SETTINGS_TAB: {
966
+ readonly SELECT: "select";
967
+ readonly CREATE: "create";
968
+ };
969
+ type TemplateSettingsTab = (typeof TEMPLATE_SETTINGS_TAB)[keyof typeof TEMPLATE_SETTINGS_TAB];
970
+ interface WhatsAppTemplatesSettingsLabels {
971
+ selectTab: string;
972
+ createTab: string;
973
+ }
974
+ declare const DEFAULT_TEMPLATES_SETTINGS_LABELS: WhatsAppTemplatesSettingsLabels;
975
+ interface WhatsAppTemplatesSettingsProps {
976
+ templates: WhatsAppTemplateSummary[];
977
+ loadingTemplates?: boolean;
978
+ templatesError?: boolean;
979
+ onRefreshTemplates?: () => void;
980
+ selectedTemplateName: string;
981
+ onSelectTemplate: (name: string, template: WhatsAppTemplateSummary | undefined) => void;
982
+ variables: string[];
983
+ onVariablesChange: (variables: string[]) => void;
984
+ availableVariables?: WhatsAppTemplateVariableSuggestion[];
985
+ saving?: boolean;
986
+ saveSuccess?: boolean;
987
+ onSave: (event: FormEvent) => void;
988
+ /** Ausente = host não sabe criar template; a aba de criação nem aparece. */
989
+ create?: {
990
+ value: WhatsAppCreateTemplateState;
991
+ onChange: (value: WhatsAppCreateTemplateState) => void;
992
+ onSubmit: (event: FormEvent) => void;
993
+ submitting?: boolean;
994
+ result?: WhatsAppCreateTemplateResult | null;
995
+ };
996
+ labels?: Partial<WhatsAppTemplatesSettingsLabels>;
997
+ }
998
+ declare function WhatsAppTemplatesSettings({ labels: labelsOverride, create, ...settingsProps }: WhatsAppTemplatesSettingsProps): react.JSX.Element;
999
+
438
1000
  interface TopicItem {
439
1001
  key: string;
440
1002
  label: string;
@@ -472,7 +1034,7 @@ interface UseConversationMessagesResult {
472
1034
  caption?: string;
473
1035
  }) => Promise<MessagePayload>;
474
1036
  sendTemplate: (data: {
475
- templateName: string;
1037
+ templateName?: string;
476
1038
  languageCode?: string;
477
1039
  bodyParams?: string[];
478
1040
  }) => Promise<void>;
@@ -483,14 +1045,11 @@ declare function useConversationMessages(conversationId: string, params?: {
483
1045
  before?: string;
484
1046
  }): UseConversationMessagesResult;
485
1047
 
486
- interface UseConversationListParams {
487
- page?: number;
488
- limit?: number;
489
- waitingHuman?: boolean;
490
- search?: string;
491
- }
1048
+ type UseConversationListParams = ListConversationsParams;
492
1049
  interface UseConversationListResult {
493
1050
  conversations: ConversationSummary[];
1051
+ /** Total no servidor. Cai para o tamanho da página quando a API devolve só o array. */
1052
+ total: number;
494
1053
  loading: boolean;
495
1054
  error: Error | undefined;
496
1055
  refetch: () => Promise<void>;
@@ -505,22 +1064,42 @@ interface UseConversationContextResult {
505
1064
  }
506
1065
  declare function useConversationContext(conversationId: string): UseConversationContextResult;
507
1066
 
508
- interface UseConversationDocumentsParams {
509
- search?: string;
510
- page?: number;
511
- }
1067
+ type UseConversationDocumentsParams = ListDocumentsParams;
512
1068
  interface UseConversationDocumentsResult {
513
1069
  documents: ConversationDocument[];
1070
+ /** Total no servidor. Cai para o tamanho da página quando a API devolve só o array. */
1071
+ total: number;
514
1072
  loading: boolean;
515
1073
  error: Error | undefined;
516
1074
  refetch: () => Promise<void>;
517
1075
  }
518
- declare function useConversationDocuments(conversationId: string, params?: UseConversationDocumentsParams): UseConversationDocumentsResult;
1076
+ declare function useConversationDocuments(conversationId: string | undefined, params?: UseConversationDocumentsParams): UseConversationDocumentsResult;
519
1077
 
520
1078
  type ConversationRealtimeHandler = (event: MessageEvent) => void;
521
1079
  declare function useConversationRealtime(conversationId: string | undefined, onEvent: ConversationRealtimeHandler): void;
522
1080
  declare function useGlobalRealtime(onEvent: ConversationRealtimeHandler): void;
523
1081
 
1082
+ interface UseConversationActionsResult {
1083
+ /** `undefined` quando a API do host não implementa a operação — a UI esconde a afordância. */
1084
+ takeover: (() => Promise<void>) | undefined;
1085
+ release: (() => Promise<void>) | undefined;
1086
+ finalize: (() => Promise<void>) | undefined;
1087
+ }
1088
+ /**
1089
+ * Ações de atendimento de UMA conversa, já ligadas ao id.
1090
+ *
1091
+ * Separado de `useConversationMessages` porque assumir e devolver conversa também acontece a
1092
+ * partir da lista, onde nenhuma thread está aberta — embutir nas mensagens obrigaria a carregar
1093
+ * a thread inteira só para desenhar um botão na linha.
1094
+ */
1095
+ declare function useConversationActions(conversationId: string): UseConversationActionsResult;
1096
+ interface UseInboxActionsResult {
1097
+ markAllRead: (() => Promise<void>) | undefined;
1098
+ listTemplates: (() => Promise<ConversationTemplate[]>) | undefined;
1099
+ }
1100
+ /** Ações que valem para a caixa inteira, sem conversa selecionada. */
1101
+ declare function useInboxActions(): UseInboxActionsResult;
1102
+
524
1103
  declare function parseWhatsAppFormatting(text: string): ReactNode[];
525
1104
  declare function waToHTML(text: string): string;
526
1105
  declare function htmlToWA(html: string): string;
@@ -530,6 +1109,8 @@ declare function formatPhone(number: string): string;
530
1109
  declare function phoneInitials(number: string): string;
531
1110
 
532
1111
  declare function formatTimestamp(timestamp: string): string;
1112
+ declare function formatDateTime(iso: string): string;
1113
+ declare function isSameDay(a: Date, b: Date): boolean;
533
1114
  declare function formatFileSize(bytes: number): string;
534
1115
 
535
1116
  interface AsyncResourceState<T> {
@@ -539,4 +1120,16 @@ interface AsyncResourceState<T> {
539
1120
  refetch: () => Promise<void>;
540
1121
  }
541
1122
 
542
- export { type AsyncResourceState, AudioPlayer, type AudioPlayerProps, Avatar, type AvatarProps, type ConversationDocument, ConversationListItem, type ConversationListItemProps, type ConversationLocales, ConversationLocalesProvider, type ConversationLocalesProviderProps, type ConversationRealtimeHandler, type ConversationSummary, ConversationWallpaper, type ConversationWallpaperProps, type ConversationsApi, type ConversationsFeatures, ConversationsProvider, type ConversationsTheme, type ConversationsUIConfig, DateDivider, type DateDividerProps, EmojiPicker, type EmojiPickerProps, FileIcon, type FileIconProps, Lightbox, type LightboxProps, MediaRenderer, type MediaRendererProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, type MessagePayload, MessageTail, MessageText, type MessageTextProps, MessageTimestamp, type ResolveMediaUrl, type SSEProvider, SimpleEmojiPicker, type SimpleEmojiPickerProps, StatusTicks, type StatusTicksProps, ToastProvider, type TopicItem, TopicsForm, type TopicsFormLabels, type TopicsFormProps, type UseConversationContextResult, type UseConversationDocumentsParams, type UseConversationDocumentsResult, type UseConversationListParams, type UseConversationListResult, type UseConversationMessagesResult, WelcomeFarewellForm, type WelcomeFarewellFormLabels, type WelcomeFarewellFormProps, WhatsAppCreateTemplateForm, type WhatsAppCreateTemplateFormLabels, type WhatsAppCreateTemplateFormProps, type WhatsAppCreateTemplateResult, type WhatsAppCreateTemplateState, WhatsAppMessageEditor, type WhatsAppMessageEditorProps, type WhatsAppTemplateHeaderType, WhatsAppTemplateSettingsForm, type WhatsAppTemplateSettingsFormLabels, type WhatsAppTemplateSettingsFormProps, type WhatsAppTemplateSummary, type WhatsAppTemplateVariableSuggestion, formatFileSize, formatPhone, formatTimestamp, htmlToWA, parseWhatsAppFormatting, phoneInitials, toast, useConversationContext, useConversationDocuments, useConversationList, useConversationLocales, useConversationMessages, useConversationRealtime, useConversations, useDarkMode, useGlobalRealtime, useToast, useWaitingNotifications, waToHTML, waToHTMLInline };
1123
+ /**
1124
+ * Resolve a mídia de uma mensagem numa URL exibível, usando só o `ConversationsApi`.
1125
+ *
1126
+ * Mora no pacote, e não em cada host, porque a regra não tem nada de específico de produto: é a
1127
+ * tradução de `uploadId`/`mediaId` pelos dois métodos que o próprio contrato já declara. Deixá-la no
1128
+ * host significava que todo projeto que adotasse o SDK reescreveria as mesmas oito linhas — e, na
1129
+ * prática, ninguém escrevia: o `MediaRenderer` só busca mídia pela porta `onResolveMediaUrl`, então
1130
+ * onde nada era injetado foto, vídeo e áudio ficavam no placeholder para sempre.
1131
+ */
1132
+
1133
+ declare function createMediaUrlResolver(api: Pick<ConversationsApi, 'getDocumentUrl' | 'getMediaProxyUrl'>): ResolveMediaUrl;
1134
+
1135
+ export { type AsyncResourceState, AudioPlayer, type AudioPlayerProps, Avatar, type AvatarLabels, type AvatarProps, type BuildTranscriptTextParams, CHANNEL_BRAND_COLOR, CONVERSATION_WINDOW, ChannelIcon, type ChannelIconProps, ConversationChannel, type ConversationContextEntry, ConversationContextPanel, type ConversationContextPanelClassNames, type ConversationContextPanelLabels, type ConversationContextPanelProps, ConversationDocument, ConversationDocumentsPanel, type ConversationDocumentsPanelClassNames, type ConversationDocumentsPanelLabels, type ConversationDocumentsPanelProps, ConversationHeader, type ConversationHeaderClassNames, type ConversationHeaderLabels, type ConversationHeaderProps, type ConversationHeaderUtility, ConversationListItem, type ConversationListItemLabels, type ConversationListItemProps, type ConversationLocales, ConversationLocalesProvider, type ConversationLocalesProviderProps, type ConversationRealtimeHandler, ConversationRow, type ConversationRowClassNames, type ConversationRowProps, ConversationSummary, ConversationTemplate, ConversationWallpaper, type ConversationWallpaperProps, type ConversationWindow, ConversationsApi, ConversationsFeatures, ConversationsProvider, DEFAULT_ACCEPTED_FILE_TYPES, DEFAULT_AVATAR_LABELS, DEFAULT_CONVERSATION_CONTEXT_LABELS, DEFAULT_CONVERSATION_DOCUMENTS_LABELS, DEFAULT_CONVERSATION_HEADER_LABELS, DEFAULT_CONVERSATION_LIST_ITEM_LABELS, DEFAULT_DOCUMENTS_LIBRARY_LABELS, DEFAULT_EMOJI_PICKER_LABELS, DEFAULT_INTERACTIVE_MESSAGE_LABELS, DEFAULT_LIGHTBOX_LABELS, DEFAULT_MESSAGE_COMPOSER_LABELS, DEFAULT_RICH_COMPOSER_TOOLTIPS, DEFAULT_TEMPLATES_SETTINGS_LABELS, DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS, DEFAULT_WINDOW_EXPIRED_LABELS, DOCUMENT_SOURCE_FILTER, DateDivider, type DateDividerClassNames, type DateDividerProps, type DocumentSourceFilter, DocumentsLibrary, type DocumentsLibraryClassNames, type DocumentsLibraryLabels, type DocumentsLibraryProps, EMOJI_CATEGORIES, type EmojiCategory, type EmojiEntry, EmojiPicker, type EmojiPickerLabels, type EmojiPickerProps, FileIcon, type FileIconProps, InteractiveMessage, type InteractiveMessageLabels, type InteractiveMessageProps, InteractivePayload, InteractiveSelection, Lightbox, type LightboxLabels, type LightboxProps, ListConversationsParams, ListDocumentsParams, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerClassNames, type MessageComposerLabels, type MessageComposerProps, MessagePayload, MessageTail, MessageText, type MessageTextProps, MessageTimestamp, NARROW_MAX_WIDTH_PX, type QuickReply, RICH_COMPOSER_ACTION, ResolveMediaUrl, type RichComposerAction, type RichComposerQuickReply, type RichComposerTooltips, type RichComposerVariable, RichMessageComposer, type RichMessageComposerHandle, type RichMessageComposerProps, SSEProvider, SimpleEmojiPicker, type SimpleEmojiPickerProps, StatusTicks, type StatusTicksProps, TEMPLATE_SETTINGS_TAB, type TemplateSettingsTab, ToastProvider, type TopicItem, TopicsForm, type TopicsFormLabels, type TopicsFormProps, type UseConversationActionsResult, type UseConversationContextResult, type UseConversationDocumentsParams, type UseConversationDocumentsResult, type UseConversationListParams, type UseConversationListResult, type UseConversationMessagesResult, type UseInboxActionsResult, type UseWaitingNotificationsLabels, type UseWaitingNotificationsParams, type UseWaitingNotificationsResult, WINDOW_FILTERS, WelcomeFarewellForm, type WelcomeFarewellFormLabels, type WelcomeFarewellFormProps, WhatsAppCreateTemplateForm, type WhatsAppCreateTemplateFormLabels, type WhatsAppCreateTemplateFormProps, type WhatsAppCreateTemplateResult, type WhatsAppCreateTemplateState, WhatsAppMessageEditor, type WhatsAppMessageEditorLabels, type WhatsAppMessageEditorProps, type WhatsAppTemplateHeaderType, WhatsAppTemplateSettingsForm, type WhatsAppTemplateSettingsFormLabels, type WhatsAppTemplateSettingsFormProps, type WhatsAppTemplateSummary, type WhatsAppTemplateVariableSuggestion, WhatsAppTemplatesSettings, type WhatsAppTemplatesSettingsLabels, type WhatsAppTemplatesSettingsProps, WindowExpiredNotice, type WindowExpiredNoticeLabels, type WindowExpiredNoticeProps, type WindowOfParams, applyQuickReplyVariables, buildTranscriptFilename, buildTranscriptText, createMediaUrlResolver, downloadTextFile, formatDateTime, formatFileSize, formatPhone, formatStalledFor, formatTimestamp, htmlToWA, isSameDay, isWindowBlocking, parseWhatsAppFormatting, phoneInitials, resolveQuickReply, searchEmojis, toast, useConversationActions, useConversationContext, useConversationDocuments, useConversationList, useConversationLocales, useConversationMessages, useConversationRealtime, useConversations, useDarkMode, useGlobalRealtime, useInboxActions, useIsDarkTheme, useIsNarrow, useToast, useWaitingNotifications, waToHTML, waToHTMLInline, windowOf };