@adatechnology/conversations-ui 0.1.0-rc.0 → 0.1.0-rc.10

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 (83) hide show
  1. package/dist/{chunk-ZDURDZTM.js → chunk-2AYDBWNE.js} +14 -0
  2. package/dist/chunk-FWNAWAJP.js +1743 -0
  3. package/dist/flows/index.js +3 -3
  4. package/dist/index.d.ts +619 -136
  5. package/dist/index.js +1064 -1024
  6. package/dist/preview/index.d.ts +330 -0
  7. package/dist/preview/index.js +1281 -0
  8. package/dist/styles.css +198 -0
  9. package/dist/types-B5C1DLu1.d.ts +365 -0
  10. package/package.json +10 -3
  11. package/src/Avatar.tsx +30 -4
  12. package/src/ChannelIcon.tsx +87 -0
  13. package/src/ConversationContextPanel.tsx +106 -0
  14. package/src/ConversationDocumentsPanel.tsx +425 -0
  15. package/src/ConversationHeader.tsx +257 -0
  16. package/src/ConversationListItem.tsx +54 -7
  17. package/src/ConversationLocalesProvider.tsx +16 -0
  18. package/src/ConversationRow.tsx +137 -0
  19. package/src/DateDivider.tsx +16 -3
  20. package/src/DocumentsLibrary.tsx +322 -0
  21. package/src/EmojiPicker.tsx +69 -55
  22. package/src/FileIcon.test.ts +83 -0
  23. package/src/FileIcon.tsx +88 -11
  24. package/src/InteractiveMessage.test.tsx +41 -0
  25. package/src/InteractiveMessage.tsx +143 -0
  26. package/src/Lightbox.tsx +18 -3
  27. package/src/MediaRenderer.tsx +14 -11
  28. package/src/MessageBubble.tsx +54 -5
  29. package/src/MessageComposer.test.tsx +35 -0
  30. package/src/MessageComposer.tsx +73 -19
  31. package/src/Wallpaper.test.tsx +21 -0
  32. package/src/Wallpaper.tsx +54 -6
  33. package/src/WhatsAppMessageEditor.tsx +28 -4
  34. package/src/WindowExpiredNotice.tsx +57 -0
  35. package/src/conversationChannel.test.ts +53 -0
  36. package/src/conversationChannel.ts +146 -0
  37. package/src/conversationTranscript.test.ts +65 -0
  38. package/src/conversationTranscript.ts +64 -0
  39. package/src/conversationWindow.test.ts +90 -0
  40. package/src/conversationWindow.ts +78 -0
  41. package/src/emojiCatalog.test.ts +35 -0
  42. package/src/emojiCatalog.ts +189 -0
  43. package/src/flows/FlowMapCanvas.tsx +2 -2
  44. package/src/hooks/useConversationActions.ts +56 -0
  45. package/src/hooks/useConversationDocuments.ts +15 -9
  46. package/src/hooks/useConversationList.ts +15 -9
  47. package/src/hooks/useConversationMessages.ts +2 -2
  48. package/src/index.ts +112 -16
  49. package/src/lib/cn.test.ts +29 -0
  50. package/src/lib/cn.ts +15 -0
  51. package/src/lib/createMediaUrlResolver.ts +33 -0
  52. package/src/lib/paginated.test.ts +33 -0
  53. package/src/lib/paginated.ts +26 -0
  54. package/src/lib/phone.ts +34 -0
  55. package/src/preview/AudioRecorderButton.tsx +125 -0
  56. package/src/preview/ConversationPreview.tsx +315 -0
  57. package/src/preview/MediaTypesPreview.tsx +87 -0
  58. package/src/preview/audioRecorderFormat.test.ts +67 -0
  59. package/src/preview/conversationPreviewFailures.test.ts +64 -0
  60. package/src/preview/createMockConversationsApi.ts +271 -0
  61. package/src/preview/createMockSSEProvider.ts +40 -0
  62. package/src/preview/createPreviewWebhookClient.test.ts +105 -0
  63. package/src/preview/createPreviewWebhookClient.ts +126 -0
  64. package/src/preview/index.ts +54 -0
  65. package/src/preview/mediaTypeOf.test.ts +15 -0
  66. package/src/preview/mockDocumentsSearch.test.ts +57 -0
  67. package/src/preview/mockEventSource.ts +53 -0
  68. package/src/preview/preview.test.ts +177 -0
  69. package/src/preview/previewFileSamples.test.ts +151 -0
  70. package/src/preview/previewFileSamples.ts +74 -0
  71. package/src/preview/previewFixtures.ts +440 -0
  72. package/src/preview/previewMediaSource.test.ts +62 -0
  73. package/src/preview/previewMediaSource.ts +91 -0
  74. package/src/preview/previewStore.ts +193 -0
  75. package/src/preview/startPreviewScript.ts +60 -0
  76. package/src/providers/types.ts +163 -11
  77. package/src/settings/WhatsAppCreateTemplateForm.tsx +3 -1
  78. package/src/settings/WhatsAppTemplatesSettings.tsx +106 -0
  79. package/src/styles.css +136 -0
  80. package/src/types.ts +46 -1
  81. package/src/useDarkMode.ts +26 -0
  82. package/src/useIsNarrow.ts +29 -0
  83. 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 { y as MessagePayload, A as ResolveMediaUrl, v as InteractiveSelection, t as InteractivePayload, p as ConversationsFeatures, m as ConversationSummary, h as ConversationChannel, L as ListConversationsParams, o as ConversationsApi, S as SSEProvider, w as ListDocumentsParams, i as ConversationDocument, n as ConversationTemplate } from './types-B5C1DLu1.js';
4
+ export { C as CHANNEL_CAPABILITIES, a as CHANNEL_FILTER_ALL, b as CONVERSATION_CHANNEL, c as ChannelCapabilities, d as ChannelFilter, e as ChannelFilterOption, f as CompanyDocument, g as CompanyDocumentPage, j as ConversationDocumentPage, k as ConversationEventSource, l as ConversationPage, q as ConversationsTheme, r as ConversationsUIConfig, D as DEFAULT_CONVERSATION_CHANNEL, F as FormatContactHandleParams, H as HANDLE_KIND, s as HandleKind, I as InteractiveOption, u as InteractiveSection, M as MediaRenderer, x as MediaRendererProps, R as REOPEN_MECHANISM, z as ReopenMechanism, B as capabilitiesOf, E as channelFiltersFor, G as contactFlag, J as formatContactHandle } from './types-B5C1DLu1.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,50 @@ 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;
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[];
115
130
 
131
+ interface MessageComposerLabels {
132
+ emoji: string;
133
+ attach: string;
134
+ send: string;
135
+ }
136
+ declare const DEFAULT_MESSAGE_COMPOSER_LABELS: MessageComposerLabels;
116
137
  interface MessageComposerProps {
138
+ labels?: Partial<MessageComposerLabels>;
117
139
  onSend: (text: string) => void;
118
140
  onAttach?: (file: File) => void;
119
141
  value?: string;
@@ -123,10 +145,40 @@ interface MessageComposerProps {
123
145
  maxLength?: number;
124
146
  disabled?: boolean;
125
147
  acceptedFileTypes?: string;
148
+ /**
149
+ * Ocupa o lugar do botão de enviar enquanto não há nada para enviar — é onde o WhatsApp põe o
150
+ * microfone. Fora do campo, o botão vira um bloco solto ao lado do pill e quebra a barra.
151
+ */
152
+ idleAction?: ReactNode;
153
+ className?: string;
154
+ classNames?: Partial<MessageComposerClassNames>;
155
+ }
156
+ interface MessageComposerClassNames {
157
+ root: string;
158
+ field: string;
126
159
  }
127
- declare const MessageComposer: ({ onSend, onAttach, value: externalValue, onChange: externalOnChange, features, placeholder, maxLength, disabled, acceptedFileTypes, }: MessageComposerProps) => react.JSX.Element;
160
+ /**
161
+ * Exatamente o que a Meta aceita em mensagem de mídia — imagem, sticker, áudio, vídeo e a lista
162
+ * fechada de documentos. Oferecer no seletor um formato que o WhatsApp recusa (`.zip`, `.rtf`)
163
+ * empurra a falha para depois do envio, quando já não dá para explicar ao operador o que houve.
164
+ * Produto com regra própria passa `acceptedFileTypes`.
165
+ */
166
+ declare const DEFAULT_ACCEPTED_FILE_TYPES: string;
167
+ declare const MessageComposer: ({ onSend, onAttach, value: externalValue, onChange: externalOnChange, features, placeholder, maxLength, disabled, acceptedFileTypes, idleAction, className, classNames, labels, }: MessageComposerProps) => react.JSX.Element;
128
168
 
169
+ interface WhatsAppMessageEditorLabels {
170
+ bold: string;
171
+ /** Tooltip da negrito — traz a sintaxe do WhatsApp junto, por isso é separado do `aria-label`. */
172
+ boldHint: string;
173
+ italic: string;
174
+ italicHint: string;
175
+ strikethrough: string;
176
+ strikethroughHint: string;
177
+ insertPlaceholder: (token: string) => string;
178
+ }
179
+ declare const DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS: WhatsAppMessageEditorLabels;
129
180
  interface WhatsAppMessageEditorProps {
181
+ labels?: Partial<WhatsAppMessageEditorLabels>;
130
182
  value: string;
131
183
  onChange: (value: string) => void;
132
184
  placeholder?: string;
@@ -135,7 +187,7 @@ interface WhatsAppMessageEditorProps {
135
187
  previewLabel?: string;
136
188
  emptyPreviewText?: string;
137
189
  }
138
- declare function WhatsAppMessageEditor({ value, onChange, placeholder, placeholders, rows, previewLabel, emptyPreviewText, }: WhatsAppMessageEditorProps): react.JSX.Element;
190
+ declare function WhatsAppMessageEditor({ value, onChange, placeholder, placeholders, rows, previewLabel, emptyPreviewText, labels, }: WhatsAppMessageEditorProps): react.JSX.Element;
139
191
 
140
192
  interface SimpleEmojiPickerProps {
141
193
  onSelect: (emoji: string) => void;
@@ -145,89 +197,58 @@ interface SimpleEmojiPickerProps {
145
197
  }
146
198
  declare function SimpleEmojiPicker({ onSelect, label, pickerWidth, pickerMaxHeight }: SimpleEmojiPickerProps): react.JSX.Element;
147
199
 
200
+ interface DateDividerClassNames {
201
+ root: string;
202
+ label: string;
203
+ }
148
204
  interface DateDividerProps {
149
205
  iso: string;
206
+ className?: string;
207
+ classNames?: Partial<DateDividerClassNames>;
150
208
  }
151
- declare function DateDivider({ iso }: DateDividerProps): react.JSX.Element;
209
+ declare function DateDivider({ iso, className, classNames }: DateDividerProps): react.JSX.Element;
152
210
 
211
+ interface AvatarLabels {
212
+ /** Lido por leitor de tela quando não há nome nem imagem — a silhueta genérica. */
213
+ unnamedContact: string;
214
+ }
153
215
  interface AvatarProps {
154
216
  name?: string | null;
155
217
  avatarUrl?: string;
156
218
  size?: 'sm' | 'md' | 'lg';
157
219
  className?: string;
220
+ labels?: Partial<AvatarLabels>;
158
221
  }
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
- }
222
+ declare const DEFAULT_AVATAR_LABELS: AvatarLabels;
223
+ declare function Avatar({ name, avatarUrl, size, className, labels }: AvatarProps): react.JSX.Element;
222
224
 
225
+ interface ConversationListItemLabels {
226
+ /** Tooltip do ponto vermelho: a janela de atendimento de 24h já fechou. */
227
+ expiredWindow: string;
228
+ /** Tooltip do ponto laranja: a janela de atendimento está perto de fechar. */
229
+ warningWindow: string;
230
+ }
231
+ declare const DEFAULT_CONVERSATION_LIST_ITEM_LABELS: ConversationListItemLabels;
223
232
  interface ConversationListItemProps {
224
233
  conversation: ConversationSummary;
234
+ labels?: Partial<ConversationListItemLabels>;
225
235
  active?: boolean;
226
236
  selected?: boolean;
227
237
  onClick?: () => void;
228
238
  onSelect?: (id: string) => void;
239
+ /**
240
+ * Desliga a borda inferior quando o item é composto dentro de outra linha (ver `ConversationRow`):
241
+ * com ela ligada, a borda corta a própria linha ao meio, separando o item do rodapé de status.
242
+ */
243
+ showDivider?: boolean;
244
+ /**
245
+ * Desliga o fundo de selecionado. Par do `showDivider`: quando o item é composto dentro de uma
246
+ * linha maior, quem pinta o realce é a linha — senão só o bloco do item fica cinza e o resto
247
+ * (checkbox, pills, barra lateral) continua branco, como se metade da linha estivesse selecionada.
248
+ */
249
+ highlightActive?: boolean;
229
250
  }
230
- declare const ConversationListItem: ({ conversation, active, selected, onClick, onSelect, }: ConversationListItemProps) => react.JSX.Element;
251
+ declare const ConversationListItem: ({ conversation, active, selected, onClick, onSelect, showDivider, highlightActive, labels, }: ConversationListItemProps) => react.JSX.Element;
231
252
 
232
253
  type ToastType = 'success' | 'error' | 'info';
233
254
  interface ToastContextValue {
@@ -247,12 +268,19 @@ interface StatusTicksProps {
247
268
  }
248
269
  declare function StatusTicks({ status, title }: StatusTicksProps): react.JSX.Element;
249
270
 
271
+ interface LightboxLabels {
272
+ /** Texto alternativo quando a imagem não tem legenda — sem ele o leitor de tela anuncia a URL. */
273
+ imageAlt: string;
274
+ close: string;
275
+ }
250
276
  interface LightboxProps {
251
277
  imageUrl: string;
252
278
  caption?: string;
253
279
  onClose: () => void;
280
+ labels?: Partial<LightboxLabels>;
254
281
  }
255
- declare function Lightbox({ imageUrl, caption, onClose }: LightboxProps): react.JSX.Element;
282
+ declare const DEFAULT_LIGHTBOX_LABELS: LightboxLabels;
283
+ declare function Lightbox({ imageUrl, caption, onClose, labels }: LightboxProps): react.JSX.Element;
256
284
 
257
285
  interface FileIconProps {
258
286
  filename?: string;
@@ -279,16 +307,404 @@ interface MessageTailProps {
279
307
  }
280
308
  declare function MessageTail({ isOutbound }: MessageTailProps): react.JSX.Element;
281
309
 
310
+ /**
311
+ * Janela de sessão: o intervalo em que o canal aceita mensagem livre do atendente. No WhatsApp são
312
+ * 24h desde o último contato do cliente; fora dela só template. Cada canal tem a sua regra — e há
313
+ * canal sem janela nenhuma — então a política vem de `capabilitiesOf`, não de constante fixa.
314
+ *
315
+ * Mora no SDK porque é regra de plataforma, não de produto: todo projeto que usa este pacote
316
+ * precisa dela para saber o que o atendente ainda consegue fazer.
317
+ */
318
+
319
+ declare const CONVERSATION_WINDOW: {
320
+ readonly ALL: "all";
321
+ readonly FRESH: "fresh";
322
+ readonly WARNING: "warning";
323
+ readonly CRITICAL: "critical";
324
+ readonly EXPIRED: "expired";
325
+ };
326
+ type ConversationWindow = (typeof CONVERSATION_WINDOW)[keyof typeof CONVERSATION_WINDOW];
327
+ declare const WINDOW_FILTERS: readonly [{
328
+ readonly value: "all";
329
+ readonly label: "Todas";
330
+ readonly dotClass: "";
331
+ }, {
332
+ readonly value: "fresh";
333
+ readonly label: "<12h";
334
+ readonly dotClass: "bg-green-500";
335
+ }, {
336
+ readonly value: "warning";
337
+ readonly label: "12-21h";
338
+ readonly dotClass: "bg-yellow-500";
339
+ }, {
340
+ readonly value: "critical";
341
+ readonly label: "21-24h";
342
+ readonly dotClass: "bg-red-500";
343
+ }, {
344
+ readonly value: "expired";
345
+ readonly label: ">24h";
346
+ readonly dotClass: "bg-gray-400";
347
+ }];
348
+ type WindowOfParams = {
349
+ readonly lastInboundAt: string | null;
350
+ readonly now: number;
351
+ /** Ausente = `whatsapp`. */
352
+ readonly channel?: ConversationChannel | undefined;
353
+ };
354
+ /**
355
+ * Sem `lastInboundAt` o cliente nunca escreveu, então não há janela aberta — classificar como
356
+ * expirada é o comportamento seguro: evita o atendente tentar texto livre e receber recusa.
357
+ *
358
+ * Canal sem janela de sessão (chat de site) é sempre `fresh`: ali nada expira, e marcar expirado
359
+ * bloquearia o composer inventando um limite que a plataforma não impõe.
360
+ */
361
+ declare function windowOf(params: WindowOfParams): ConversationWindow;
362
+ declare function formatStalledFor(lastAt: string, now: number): string;
363
+
364
+ type ConversationRowClassNames = {
365
+ root: string;
366
+ windowBar: string;
367
+ };
368
+ type ConversationRowProps = {
369
+ conversation: ConversationSummary;
370
+ active: boolean;
371
+ selected: boolean;
372
+ now: number;
373
+ busy: boolean;
374
+ onOpen: () => void;
375
+ onToggleSelected: () => void;
376
+ onTakeover: () => void;
377
+ className?: string;
378
+ classNames?: Partial<ConversationRowClassNames>;
379
+ };
380
+ declare function ConversationRow({ conversation, active, selected, now, busy, onOpen, onToggleSelected, onTakeover, className, classNames, }: ConversationRowProps): react.JSX.Element;
381
+
382
+ declare const CHANNEL_BRAND_COLOR: Readonly<Record<ConversationChannel, string>>;
383
+ interface ChannelIconProps {
384
+ channel?: ConversationChannel | undefined;
385
+ size?: number;
386
+ className?: string;
387
+ }
388
+ declare function ChannelIcon({ channel, size, className }: ChannelIconProps): react.JSX.Element;
389
+
390
+ interface ConversationHeaderLabels {
391
+ botMode: string;
392
+ humanMode: string;
393
+ returnToBot: string;
394
+ finish: string;
395
+ takeover: string;
396
+ download: string;
397
+ documents: string;
398
+ back: string;
399
+ moreActions: string;
400
+ }
401
+ declare const DEFAULT_CONVERSATION_HEADER_LABELS: ConversationHeaderLabels;
402
+ /**
403
+ * Partes estilizáveis do cabeçalho. Cada chave recebe classes que o `cn` funde por cima da base, e
404
+ * conflito de utilitário (padding, gap, borda) fica com o valor do produto.
405
+ */
406
+ interface ConversationHeaderClassNames {
407
+ root: string;
408
+ identity: string;
409
+ name: string;
410
+ meta: string;
411
+ actions: string;
412
+ desktopActions: string;
413
+ mobileMenu: string;
414
+ }
415
+ /**
416
+ * Utilitário extra que o host pendura no cabeçalho — ícone no desktop, item de menu no celular,
417
+ * como os nativos. Entra por aqui, e não por um slot de ReactNode, porque é isso que preserva o
418
+ * comportamento responsivo: um nó solto viraria um quarto ícone em 375px, sem área de toque.
419
+ */
420
+ interface ConversationHeaderUtility {
421
+ key: string;
422
+ /** Emoji, para casar com os utilitários nativos do cabeçalho. */
423
+ icon: string;
424
+ label: string;
425
+ run: () => void;
426
+ active?: boolean;
427
+ }
428
+ interface ConversationHeaderProps {
429
+ conversation: ConversationSummary;
430
+ busy?: boolean;
431
+ onTakeover?: () => void;
432
+ onReturnToBot?: () => void;
433
+ onFinish?: () => void;
434
+ onDownload?: () => void;
435
+ onOpenDocuments?: () => void;
436
+ documentsOpen?: boolean;
437
+ /** Ações do produto que não existem no contrato do pacote (ex.: ferramentas de dev). */
438
+ extraUtilities?: readonly ConversationHeaderUtility[];
439
+ onBack?: () => void;
440
+ labels?: Partial<ConversationHeaderLabels>;
441
+ className?: string;
442
+ classNames?: Partial<ConversationHeaderClassNames>;
443
+ }
444
+ declare function ConversationHeader({ conversation, busy, onTakeover, onReturnToBot, onFinish, onDownload, onOpenDocuments, documentsOpen, extraUtilities, onBack, labels: labelsOverride, className, classNames, }: ConversationHeaderProps): react.JSX.Element;
445
+
446
+ /**
447
+ * "Suas Seleções": o que o bot já coletou na conversa. Para o atendente que assume no meio, é a
448
+ * diferença entre ler o transcript inteiro e ver o estado em duas linhas.
449
+ *
450
+ * O pacote não interpreta o contexto — ele é `Record<string, unknown>` e cada produto nomeia as
451
+ * próprias chaves. O host traduz para `entries`; aqui só se decide como mostrar.
452
+ */
453
+ interface ConversationContextEntry {
454
+ key: string;
455
+ label: string;
456
+ value?: string | undefined;
457
+ icon?: string;
458
+ }
459
+ interface ConversationContextPanelLabels {
460
+ title: string;
461
+ empty: string;
462
+ }
463
+ declare const DEFAULT_CONVERSATION_CONTEXT_LABELS: ConversationContextPanelLabels;
464
+ interface ConversationContextPanelClassNames {
465
+ root: string;
466
+ toggle: string;
467
+ counter: string;
468
+ body: string;
469
+ }
470
+ interface ConversationContextPanelProps {
471
+ entries: readonly ConversationContextEntry[];
472
+ labels?: Partial<ConversationContextPanelLabels>;
473
+ className?: string;
474
+ classNames?: Partial<ConversationContextPanelClassNames>;
475
+ }
476
+ declare function ConversationContextPanel({ entries, labels: labelsOverride, className, classNames, }: ConversationContextPanelProps): react.JSX.Element;
477
+
478
+ interface WindowExpiredNoticeLabels {
479
+ title: string;
480
+ description: string;
481
+ sendTemplate: string;
482
+ }
483
+ declare const DEFAULT_WINDOW_EXPIRED_LABELS: WindowExpiredNoticeLabels;
484
+ interface WindowExpiredNoticeProps {
485
+ onSendTemplate?: () => void;
486
+ disabled?: boolean;
487
+ labels?: Partial<WindowExpiredNoticeLabels>;
488
+ className?: string;
489
+ }
490
+ declare function WindowExpiredNotice({ onSendTemplate, disabled, labels: labelsOverride, className, }: WindowExpiredNoticeProps): react.JSX.Element;
491
+ /**
492
+ * Só a faixa `expired` bloqueia: 21-24h ainda aceita texto livre e merece alerta, não impedimento.
493
+ */
494
+ declare function isWindowBlocking(window: ConversationWindow): boolean;
495
+
496
+ /**
497
+ * Biblioteca de arquivos de TODAS as conversas — a tela de Documentos do painel, fora do
498
+ * atendimento.
499
+ *
500
+ * Distinta do `ConversationDocumentsPanel`: aquele parte de uma conversa aberta e vive dentro dela;
501
+ * esta varre a empresa e por isso mostra de qual conversa cada arquivo veio, com o número
502
+ * clicável. Sem essa referência, uma lista global de anexos não responde nenhuma pergunta.
503
+ */
504
+ interface DocumentsLibraryLabels {
505
+ title: string;
506
+ searchPlaceholder: string;
507
+ empty: string;
508
+ noResults: string;
509
+ loading: string;
510
+ failure: string;
511
+ view: string;
512
+ download: string;
513
+ openConversation: string;
514
+ sourceFilterAll: string;
515
+ sourceFilterCustomer: string;
516
+ sourceFilterTeam: string;
517
+ sortMostRecent: string;
518
+ sortOldest: string;
519
+ clearFilters: string;
520
+ total: (count: number) => string;
521
+ page: (current: number, last: number) => string;
522
+ }
523
+ declare const DEFAULT_DOCUMENTS_LIBRARY_LABELS: DocumentsLibraryLabels;
524
+ interface DocumentsLibraryClassNames {
525
+ root: string;
526
+ title: string;
527
+ filters: string;
528
+ search: string;
529
+ sourceSelect: string;
530
+ sortButton: string;
531
+ clearButton: string;
532
+ status: string;
533
+ list: string;
534
+ item: string;
535
+ conversationLink: string;
536
+ filename: string;
537
+ meta: string;
538
+ pagination: string;
539
+ }
540
+ interface DocumentsLibraryProps {
541
+ /** Itens por página. O total vem do servidor. */
542
+ perPage?: number;
543
+ /** Abrir a conversa de origem. Ausente, o número aparece como texto e não como link. */
544
+ onOpenConversation?: (conversationId: string) => void;
545
+ labels?: Partial<DocumentsLibraryLabels>;
546
+ className?: string;
547
+ classNames?: Partial<DocumentsLibraryClassNames>;
548
+ }
549
+ declare function DocumentsLibrary({ perPage, onOpenConversation, labels: labelsOverride, className, classNames, }: DocumentsLibraryProps): react.JSX.Element | null;
550
+
551
+ /**
552
+ * Arquivos trocados na conversa. Sai do transcript e vira lista própria porque anexo é o que o
553
+ * atendente mais precisa reencontrar depois — rolar meses de mensagens para achar um comprovante é
554
+ * o caso que a busca por documento existe para eliminar.
555
+ *
556
+ * Usa `useConversationDocuments`, então funciona com qualquer `ConversationsApi`. Host sem
557
+ * biblioteca de documentos cai no estado vazio, sem quebrar.
558
+ */
559
+ /** Origens que o filtro oferece. `all` não é origem — é a ausência de filtro. */
560
+ declare const DOCUMENT_SOURCE_FILTER: {
561
+ readonly ALL: "all";
562
+ readonly CUSTOMER: "customer";
563
+ readonly TEAM: "team";
564
+ };
565
+ type DocumentSourceFilter = (typeof DOCUMENT_SOURCE_FILTER)[keyof typeof DOCUMENT_SOURCE_FILTER];
566
+ interface ConversationDocumentsPanelLabels {
567
+ toggle: string;
568
+ title: string;
569
+ searchPlaceholder: string;
570
+ empty: string;
571
+ /** Distinto de `empty`: sem resultado POR CAUSA do filtro, e não conversa sem anexo nenhum. */
572
+ noResults: string;
573
+ loading: string;
574
+ failure: string;
575
+ download: string;
576
+ view: string;
577
+ sourceFilterAll: string;
578
+ sourceFilterCustomer: string;
579
+ sourceFilterTeam: string;
580
+ sortMostRecent: string;
581
+ sortOldest: string;
582
+ clearFilters: string;
583
+ selectAll: string;
584
+ downloadSelected: (count: number) => string;
585
+ archiveFailed: string;
586
+ total: (count: number) => string;
587
+ page: (current: number, last: number) => string;
588
+ }
589
+ declare const DEFAULT_CONVERSATION_DOCUMENTS_LABELS: ConversationDocumentsPanelLabels;
590
+ /**
591
+ * Partes estilizáveis do painel, no mesmo contrato do `ConversationHeader`: `cn` funde por cima da
592
+ * base e conflito de utilitário (padding, tamanho de fonte, borda) fica com o valor do produto.
593
+ *
594
+ * `status` cobre carregando/erro/vazio de uma vez — são a mesma linha de texto auxiliar, e slots
595
+ * separados só multiplicariam chave para quem quer mudar a cor de aviso.
596
+ */
597
+ interface ConversationDocumentsPanelClassNames {
598
+ root: string;
599
+ body: string;
600
+ title: string;
601
+ filters: string;
602
+ search: string;
603
+ sourceSelect: string;
604
+ sortButton: string;
605
+ clearButton: string;
606
+ status: string;
607
+ list: string;
608
+ item: string;
609
+ sourceBadge: string;
610
+ filename: string;
611
+ meta: string;
612
+ viewButton: string;
613
+ downloadButton: string;
614
+ pagination: string;
615
+ selectionBar: string;
616
+ checkbox: string;
617
+ }
618
+ interface ConversationDocumentsPanelProps {
619
+ conversationId: string;
620
+ /** Controlado de fora porque o gatilho vive no cabeçalho, junto das outras ações da conversa. */
621
+ open: boolean;
622
+ /** Itens por página. O total vem do servidor; sem paginação no host, a barra não aparece. */
623
+ perPage?: number;
624
+ labels?: Partial<ConversationDocumentsPanelLabels>;
625
+ className?: string;
626
+ classNames?: Partial<ConversationDocumentsPanelClassNames>;
627
+ }
628
+ declare function ConversationDocumentsPanel({ conversationId, open, perPage, labels: labelsOverride, className, classNames, }: ConversationDocumentsPanelProps): react.JSX.Element | null;
629
+
630
+ /**
631
+ * Serialização do transcript para download. Fica no pacote porque o formato de um histórico de
632
+ * WhatsApp legível não é regra de negócio de ninguém — e porque o host que já tem as mensagens em
633
+ * tela não deveria precisar de rota nova só para salvar um arquivo.
634
+ *
635
+ * Funções puras, separadas do disparo do download: é o que permite testá-las sem DOM.
636
+ */
637
+
638
+ type BuildTranscriptTextParams = {
639
+ readonly messages: readonly MessagePayload[];
640
+ readonly whatsappNumber: string;
641
+ readonly clientName?: string | undefined;
642
+ };
643
+ /**
644
+ * Formato próximo ao export nativo do WhatsApp (`[data hora] Autor: texto`), que é o que pessoas e
645
+ * ferramentas de suporte já sabem ler.
646
+ */
647
+ declare function buildTranscriptText(params: BuildTranscriptTextParams): string;
648
+ declare function buildTranscriptFilename(whatsappNumber: string, generatedAt: Date): string;
649
+ /**
650
+ * Dispara o download no navegador. `revokeObjectURL` no fim não é higiene opcional: sem ele cada
651
+ * export retém o blob inteiro em memória até a aba fechar.
652
+ */
653
+ declare function downloadTextFile(filename: string, content: string): void;
654
+
655
+ /**
656
+ * Leitura passiva do tema do host: observa a classe `dark` no `<html>` e não escreve nada.
657
+ *
658
+ * Existe porque `useDarkMode` é um controlador — ele grava a classe e persiste a preferência. Um
659
+ * componente que só precisa escolher cor não pode usá-lo: bastava renderizar o mapa de fluxos
660
+ * para o app inteiro do host trocar de tema, seguindo o `prefers-color-scheme` do sistema em vez
661
+ * da configuração da aplicação.
662
+ */
663
+ declare function useIsDarkTheme(): boolean;
282
664
  declare function useDarkMode(): {
283
665
  isDark: boolean;
284
666
  toggle: () => void;
285
667
  };
286
668
 
669
+ /**
670
+ * Detecta tela estreita para decisões que CSS não resolve — como abrir ou não um painel por padrão.
671
+ *
672
+ * O breakpoint é o mesmo das classes `cv-only-*` e `.cv-back` (1024px). Duplicado aqui porque
673
+ * JavaScript não lê media query do stylesheet; se um dia divergirem, o sintoma é painel abrindo
674
+ * numa largura onde o resto da UI já mudou de modo.
675
+ */
676
+ declare const NARROW_MAX_WIDTH_PX = 1023;
677
+ declare function useIsNarrow(): boolean;
678
+
679
+ interface UseWaitingNotificationsLabels {
680
+ /** Título da notificação do sistema. Recebe a conversa para o host escolher nome × número. */
681
+ title: (conversation: ConversationSummary) => string;
682
+ body: (conversation: ConversationSummary) => string;
683
+ }
684
+ interface UseWaitingNotificationsParams {
685
+ /**
686
+ * Repassado cru ao `fetchConversations`. É o que permite filtrar não lidas **no servidor** em
687
+ * vez de baixar a lista inteira e contar no cliente: um painel com milhares de conversas não
688
+ * pode paginar 50 por vez atrás de quem tem `unread > 0`.
689
+ */
690
+ readonly params?: ListConversationsParams;
691
+ readonly intervalMs?: number;
692
+ /** Desliga o polling sem desmontar quem chama — útil com a aba em segundo plano. */
693
+ readonly enabled?: boolean;
694
+ readonly icon?: string;
695
+ readonly labels?: Partial<UseWaitingNotificationsLabels>;
696
+ }
287
697
  interface UseWaitingNotificationsResult {
288
698
  unreadCount: number;
289
699
  conversations: ConversationSummary[];
700
+ /**
701
+ * Releitura sob demanda. Existe porque o polling é o piso, não o mecanismo: quem já recebe SSE
702
+ * ou acabou de marcar tudo como lido sabe da mudança antes do próximo tick, e esperar 10s para
703
+ * o contador acompanhar faz a interface parecer travada.
704
+ */
705
+ refresh: () => Promise<void>;
290
706
  }
291
- declare function useWaitingNotifications(): UseWaitingNotificationsResult;
707
+ declare function useWaitingNotifications(params?: UseWaitingNotificationsParams): UseWaitingNotificationsResult;
292
708
 
293
709
  interface ConversationsContextValue {
294
710
  api: ConversationsApi;
@@ -370,6 +786,7 @@ interface WhatsAppCreateTemplateFormLabels {
370
786
  sectionDescription: string;
371
787
  nameLabel: string;
372
788
  nameHint: string;
789
+ namePlaceholder: string;
373
790
  categoryLabel: string;
374
791
  languageLabel: string;
375
792
  headerLabel: string;
@@ -435,6 +852,41 @@ interface WelcomeFarewellFormProps {
435
852
  }
436
853
  declare function WelcomeFarewellForm({ welcomeMessage, onWelcomeMessageChange, farewellMessage, onFarewellMessageChange, onSave, saving, saveSuccess, welcomePlaceholders, farewellPlaceholders, labels: labelsOverride, }: WelcomeFarewellFormProps): react.JSX.Element;
437
854
 
855
+ declare const TEMPLATE_SETTINGS_TAB: {
856
+ readonly SELECT: "select";
857
+ readonly CREATE: "create";
858
+ };
859
+ type TemplateSettingsTab = (typeof TEMPLATE_SETTINGS_TAB)[keyof typeof TEMPLATE_SETTINGS_TAB];
860
+ interface WhatsAppTemplatesSettingsLabels {
861
+ selectTab: string;
862
+ createTab: string;
863
+ }
864
+ declare const DEFAULT_TEMPLATES_SETTINGS_LABELS: WhatsAppTemplatesSettingsLabels;
865
+ interface WhatsAppTemplatesSettingsProps {
866
+ templates: WhatsAppTemplateSummary[];
867
+ loadingTemplates?: boolean;
868
+ templatesError?: boolean;
869
+ onRefreshTemplates?: () => void;
870
+ selectedTemplateName: string;
871
+ onSelectTemplate: (name: string, template: WhatsAppTemplateSummary | undefined) => void;
872
+ variables: string[];
873
+ onVariablesChange: (variables: string[]) => void;
874
+ availableVariables?: WhatsAppTemplateVariableSuggestion[];
875
+ saving?: boolean;
876
+ saveSuccess?: boolean;
877
+ onSave: (event: FormEvent) => void;
878
+ /** Ausente = host não sabe criar template; a aba de criação nem aparece. */
879
+ create?: {
880
+ value: WhatsAppCreateTemplateState;
881
+ onChange: (value: WhatsAppCreateTemplateState) => void;
882
+ onSubmit: (event: FormEvent) => void;
883
+ submitting?: boolean;
884
+ result?: WhatsAppCreateTemplateResult | null;
885
+ };
886
+ labels?: Partial<WhatsAppTemplatesSettingsLabels>;
887
+ }
888
+ declare function WhatsAppTemplatesSettings({ labels: labelsOverride, create, ...settingsProps }: WhatsAppTemplatesSettingsProps): react.JSX.Element;
889
+
438
890
  interface TopicItem {
439
891
  key: string;
440
892
  label: string;
@@ -472,7 +924,7 @@ interface UseConversationMessagesResult {
472
924
  caption?: string;
473
925
  }) => Promise<MessagePayload>;
474
926
  sendTemplate: (data: {
475
- templateName: string;
927
+ templateName?: string;
476
928
  languageCode?: string;
477
929
  bodyParams?: string[];
478
930
  }) => Promise<void>;
@@ -483,14 +935,11 @@ declare function useConversationMessages(conversationId: string, params?: {
483
935
  before?: string;
484
936
  }): UseConversationMessagesResult;
485
937
 
486
- interface UseConversationListParams {
487
- page?: number;
488
- limit?: number;
489
- waitingHuman?: boolean;
490
- search?: string;
491
- }
938
+ type UseConversationListParams = ListConversationsParams;
492
939
  interface UseConversationListResult {
493
940
  conversations: ConversationSummary[];
941
+ /** Total no servidor. Cai para o tamanho da página quando a API devolve só o array. */
942
+ total: number;
494
943
  loading: boolean;
495
944
  error: Error | undefined;
496
945
  refetch: () => Promise<void>;
@@ -505,22 +954,42 @@ interface UseConversationContextResult {
505
954
  }
506
955
  declare function useConversationContext(conversationId: string): UseConversationContextResult;
507
956
 
508
- interface UseConversationDocumentsParams {
509
- search?: string;
510
- page?: number;
511
- }
957
+ type UseConversationDocumentsParams = ListDocumentsParams;
512
958
  interface UseConversationDocumentsResult {
513
959
  documents: ConversationDocument[];
960
+ /** Total no servidor. Cai para o tamanho da página quando a API devolve só o array. */
961
+ total: number;
514
962
  loading: boolean;
515
963
  error: Error | undefined;
516
964
  refetch: () => Promise<void>;
517
965
  }
518
- declare function useConversationDocuments(conversationId: string, params?: UseConversationDocumentsParams): UseConversationDocumentsResult;
966
+ declare function useConversationDocuments(conversationId: string | undefined, params?: UseConversationDocumentsParams): UseConversationDocumentsResult;
519
967
 
520
968
  type ConversationRealtimeHandler = (event: MessageEvent) => void;
521
969
  declare function useConversationRealtime(conversationId: string | undefined, onEvent: ConversationRealtimeHandler): void;
522
970
  declare function useGlobalRealtime(onEvent: ConversationRealtimeHandler): void;
523
971
 
972
+ interface UseConversationActionsResult {
973
+ /** `undefined` quando a API do host não implementa a operação — a UI esconde a afordância. */
974
+ takeover: (() => Promise<void>) | undefined;
975
+ release: (() => Promise<void>) | undefined;
976
+ finalize: (() => Promise<void>) | undefined;
977
+ }
978
+ /**
979
+ * Ações de atendimento de UMA conversa, já ligadas ao id.
980
+ *
981
+ * Separado de `useConversationMessages` porque assumir e devolver conversa também acontece a
982
+ * partir da lista, onde nenhuma thread está aberta — embutir nas mensagens obrigaria a carregar
983
+ * a thread inteira só para desenhar um botão na linha.
984
+ */
985
+ declare function useConversationActions(conversationId: string): UseConversationActionsResult;
986
+ interface UseInboxActionsResult {
987
+ markAllRead: (() => Promise<void>) | undefined;
988
+ listTemplates: (() => Promise<ConversationTemplate[]>) | undefined;
989
+ }
990
+ /** Ações que valem para a caixa inteira, sem conversa selecionada. */
991
+ declare function useInboxActions(): UseInboxActionsResult;
992
+
524
993
  declare function parseWhatsAppFormatting(text: string): ReactNode[];
525
994
  declare function waToHTML(text: string): string;
526
995
  declare function htmlToWA(html: string): string;
@@ -530,6 +999,8 @@ declare function formatPhone(number: string): string;
530
999
  declare function phoneInitials(number: string): string;
531
1000
 
532
1001
  declare function formatTimestamp(timestamp: string): string;
1002
+ declare function formatDateTime(iso: string): string;
1003
+ declare function isSameDay(a: Date, b: Date): boolean;
533
1004
  declare function formatFileSize(bytes: number): string;
534
1005
 
535
1006
  interface AsyncResourceState<T> {
@@ -539,4 +1010,16 @@ interface AsyncResourceState<T> {
539
1010
  refetch: () => Promise<void>;
540
1011
  }
541
1012
 
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 };
1013
+ /**
1014
+ * Resolve a mídia de uma mensagem numa URL exibível, usando só o `ConversationsApi`.
1015
+ *
1016
+ * Mora no pacote, e não em cada host, porque a regra não tem nada de específico de produto: é a
1017
+ * tradução de `uploadId`/`mediaId` pelos dois métodos que o próprio contrato já declara. Deixá-la no
1018
+ * host significava que todo projeto que adotasse o SDK reescreveria as mesmas oito linhas — e, na
1019
+ * prática, ninguém escrevia: o `MediaRenderer` só busca mídia pela porta `onResolveMediaUrl`, então
1020
+ * onde nada era injetado foto, vídeo e áudio ficavam no placeholder para sempre.
1021
+ */
1022
+
1023
+ declare function createMediaUrlResolver(api: Pick<ConversationsApi, 'getDocumentUrl' | 'getMediaProxyUrl'>): ResolveMediaUrl;
1024
+
1025
+ 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_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, ResolveMediaUrl, 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, buildTranscriptFilename, buildTranscriptText, createMediaUrlResolver, downloadTextFile, formatDateTime, formatFileSize, formatPhone, formatStalledFor, formatTimestamp, htmlToWA, isSameDay, isWindowBlocking, parseWhatsAppFormatting, phoneInitials, searchEmojis, toast, useConversationActions, useConversationContext, useConversationDocuments, useConversationList, useConversationLocales, useConversationMessages, useConversationRealtime, useConversations, useDarkMode, useGlobalRealtime, useInboxActions, useIsDarkTheme, useIsNarrow, useToast, useWaitingNotifications, waToHTML, waToHTMLInline, windowOf };