@liftitapp/wa-conversations 0.3.0 → 0.5.0
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.
- package/README.md +64 -2
- package/dist/element/index.js +617 -97
- package/dist/react/index.d.ts +391 -4
- package/dist/react/index.js +1826 -237
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/core/initials.ts
|
|
4
|
+
/**
|
|
5
|
+
* Las iniciales del avatar de una persona (diseño .pen de DEV-5053).
|
|
6
|
+
*
|
|
7
|
+
* 🔴 **Hay UNA sola función y vive acá, fuera de `list/` y de `thread/`, porque la usan los dos
|
|
8
|
+
* paneles**: la fila del inbox y el header del hilo. Dos implementaciones se desincronizan a la
|
|
9
|
+
* primera corrección de un caso raro, y la misma persona termina saliendo con iniciales distintas
|
|
10
|
+
* en la izquierda y en la derecha de la misma pantalla.
|
|
11
|
+
*
|
|
12
|
+
* 🔴 El `name` lo origina el perfil de WhatsApp de la persona: es entrada NO confiable. El
|
|
13
|
+
* resultado entra al DOM **sólo como hijo de texto**, que React escapa — jamás en un `className`,
|
|
14
|
+
* en un `style`, en un atributo estructural ni en un selector (mismo criterio T-03-02 que ya rige
|
|
15
|
+
* para `service_state`).
|
|
16
|
+
*
|
|
17
|
+
* La degradación es la misma regla que ya usa `ConversationRow`: sin nombre útil se cae al
|
|
18
|
+
* teléfono, jamás a la cadena `"null"` ni a un «(sin nombre)» inventado.
|
|
19
|
+
*/
|
|
20
|
+
/** Un token sirve si tiene al menos una letra: «—», «·» o un emoji suelto no son un nombre. */
|
|
21
|
+
const HAS_LETTER = /\p{L}/u;
|
|
22
|
+
function initials(name, phone) {
|
|
23
|
+
if (typeof name === "string") {
|
|
24
|
+
const letters = name.split(/\s+/).filter((token) => HAS_LETTER.test(token)).map((token) => Array.from(token).find((char) => HAS_LETTER.test(char))).filter((char) => char !== void 0);
|
|
25
|
+
const chosen = letters.length > 1 ? [letters[0], letters[letters.length - 1]] : letters.slice(0, 1);
|
|
26
|
+
if (chosen.length > 0) return chosen.join("").toLocaleUpperCase();
|
|
27
|
+
}
|
|
28
|
+
const digits = typeof phone === "string" ? phone.replace(/\D/g, "") : "";
|
|
29
|
+
if (digits !== "") return digits.slice(-2);
|
|
30
|
+
return "#";
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
3
33
|
//#region src/core/list/relative-time.ts
|
|
4
34
|
/**
|
|
5
35
|
* La hora de la fila del inbox, en español y **siempre relativa**.
|
|
@@ -58,29 +88,40 @@ function ConversationRow({ item, selected, onSelect }) {
|
|
|
58
88
|
className: "wa-list__row",
|
|
59
89
|
"aria-current": selected ? "true" : void 0,
|
|
60
90
|
onClick: () => onSelect(item),
|
|
61
|
-
children: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
92
|
+
className: "wa-list__avatar",
|
|
93
|
+
"aria-hidden": "true",
|
|
94
|
+
children: initials(item.name, item.phone)
|
|
95
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
96
|
+
className: "wa-list__middle",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsxs("span", {
|
|
99
|
+
className: "wa-list__head",
|
|
100
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
101
|
+
className: "wa-list__title",
|
|
102
|
+
children: item.name ?? item.phone
|
|
103
|
+
}), /* @__PURE__ */ jsx("time", {
|
|
104
|
+
className: "wa-list__time",
|
|
105
|
+
dateTime: item.last_message_at,
|
|
106
|
+
title: item.last_message_at,
|
|
107
|
+
children: relativeTime(item.last_message_at)
|
|
108
|
+
})]
|
|
109
|
+
}),
|
|
110
|
+
item.name !== null && /* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "wa-list__phone",
|
|
112
|
+
children: item.phone
|
|
113
|
+
}),
|
|
114
|
+
item.last_message !== null && /* @__PURE__ */ jsx("span", {
|
|
115
|
+
className: "wa-list__preview",
|
|
116
|
+
children: item.last_message
|
|
117
|
+
}),
|
|
118
|
+
item.service_state !== null && /* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: "wa-list__state",
|
|
120
|
+
title: item.service_state,
|
|
121
|
+
children: item.service_state
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
})]
|
|
84
125
|
})
|
|
85
126
|
});
|
|
86
127
|
}
|
|
@@ -100,8 +141,10 @@ function ConversationRow({ item, selected, onSelect }) {
|
|
|
100
141
|
* DOM: un selector de elemento suelto (`ul`, `button`, `input`) le pisaría los estilos al host, y
|
|
101
142
|
* `backoffice-v2-lite` no perdona eso. Tampoco hay `:host` acá — eso es del entry del elemento.
|
|
102
143
|
* - **Sin tokens del LMS, sin variables, sin `@import`, sin fuentes remotas** (C-04/LIST-05). El
|
|
103
|
-
* paquete monta en tres hosts con temas distintos
|
|
104
|
-
*
|
|
144
|
+
* paquete monta en tres hosts con temas distintos. La paleta de acá (índigo #4F5AED, grises
|
|
145
|
+
* #F4F5F7/#E4E7EE) NO es un tema inventado: viene del diseño aprobado de DEV-5053 (.pen), y
|
|
146
|
+
* sigue sin depender de tokens del host. `Inter` va sólo como primer nombre del font stack —
|
|
147
|
+
* si el host la carga se usa, si no cae a system-ui; cero `@import`.
|
|
105
148
|
* - **El layout angosto/ancho se selecciona por `[data-layout]`, no por `@media`.** El panel va
|
|
106
149
|
* embebido y el viewport miente sobre el ancho que realmente tiene (ver `useContainerLayout`).
|
|
107
150
|
*
|
|
@@ -115,7 +158,7 @@ const LIST_CSS = `
|
|
|
115
158
|
display: flex;
|
|
116
159
|
flex-direction: column;
|
|
117
160
|
min-height: 0;
|
|
118
|
-
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
161
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
119
162
|
font-size: 14px;
|
|
120
163
|
line-height: 1.5;
|
|
121
164
|
color: #1f2933;
|
|
@@ -144,34 +187,143 @@ const LIST_CSS = `
|
|
|
144
187
|
padding: 10px 12px;
|
|
145
188
|
border-bottom: 1px solid #e4e7eb;
|
|
146
189
|
}
|
|
147
|
-
|
|
190
|
+
/* Etiqueta sólo para lectores de pantalla: el buscador y las fechas se explican solos a la vista
|
|
191
|
+
(placeholder e icono), pero sin <label> asociado un input no tiene nombre accesible. */
|
|
192
|
+
.wa-list__sr-only {
|
|
193
|
+
position: absolute;
|
|
194
|
+
width: 1px;
|
|
195
|
+
height: 1px;
|
|
196
|
+
padding: 0;
|
|
197
|
+
margin: -1px;
|
|
198
|
+
border: 0;
|
|
199
|
+
clip-path: inset(50%);
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
white-space: nowrap;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* El buscador del diseño: campo relleno con la lupa adentro, no un input con etiqueta encima. */
|
|
205
|
+
.wa-list__search {
|
|
206
|
+
position: relative;
|
|
148
207
|
display: flex;
|
|
149
|
-
flex: 1 1
|
|
208
|
+
flex: 1 1 100%;
|
|
209
|
+
align-items: center;
|
|
150
210
|
min-width: 0;
|
|
151
|
-
flex-direction: column;
|
|
152
|
-
gap: 2px;
|
|
153
211
|
}
|
|
154
|
-
.wa-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
212
|
+
.wa-list__search-icon {
|
|
213
|
+
position: absolute;
|
|
214
|
+
left: 10px;
|
|
215
|
+
color: #8A93A3;
|
|
216
|
+
pointer-events: none;
|
|
159
217
|
}
|
|
160
|
-
.wa-
|
|
218
|
+
.wa-list__search input {
|
|
161
219
|
min-width: 0;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
border
|
|
220
|
+
width: 100%;
|
|
221
|
+
padding: 8px 10px 8px 30px;
|
|
222
|
+
border: 1px solid #E4E7EE;
|
|
223
|
+
border-radius: 8px;
|
|
165
224
|
font: inherit;
|
|
225
|
+
font-size: 13px;
|
|
166
226
|
color: inherit;
|
|
227
|
+
background: #F4F5F7;
|
|
228
|
+
}
|
|
229
|
+
.wa-list__search input::placeholder {
|
|
230
|
+
color: #8A93A3;
|
|
231
|
+
}
|
|
232
|
+
/* La X nativa del type=search: Chrome la pinta con su propio gris y su propio tamaño. */
|
|
233
|
+
.wa-list__search input::-webkit-search-cancel-button {
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
opacity: 0.5;
|
|
236
|
+
}
|
|
237
|
+
/* Los chips de preset de fecha (DEV-5053): fila propia, ancho completo del formulario. */
|
|
238
|
+
.wa-list__presets {
|
|
239
|
+
display: flex;
|
|
240
|
+
flex: 1 1 100%;
|
|
241
|
+
flex-wrap: wrap;
|
|
242
|
+
gap: 6px;
|
|
243
|
+
}
|
|
244
|
+
.wa-list__preset {
|
|
245
|
+
padding: 4px 12px;
|
|
246
|
+
border: 1px solid #E4E7EE;
|
|
247
|
+
border-radius: 999px;
|
|
248
|
+
font: inherit;
|
|
249
|
+
font-size: 12px;
|
|
250
|
+
color: #52606d;
|
|
167
251
|
background: #ffffff;
|
|
252
|
+
cursor: pointer;
|
|
253
|
+
}
|
|
254
|
+
.wa-list__preset:hover {
|
|
255
|
+
background: #f5f7fa;
|
|
256
|
+
}
|
|
257
|
+
/* El activo se marca por el MISMO atributo que lo anuncia a un lector de pantalla: si alguien
|
|
258
|
+
saca el aria-pressed, el resaltado se va con él y el bug se ve (mismo criterio que la fila). */
|
|
259
|
+
.wa-list__preset[aria-pressed='true'] {
|
|
260
|
+
border-color: #C9D2F5;
|
|
261
|
+
font-weight: 600;
|
|
262
|
+
color: #4F5AED;
|
|
263
|
+
background: #EEF1FE;
|
|
168
264
|
}
|
|
169
|
-
|
|
265
|
+
|
|
266
|
+
/* El rango en una sola fila. Los dos campos reparten el ancho para que la flecha quede al medio
|
|
267
|
+
sin posicionarla a mano. */
|
|
268
|
+
.wa-list__range {
|
|
170
269
|
display: flex;
|
|
171
|
-
|
|
270
|
+
flex: 1 1 100%;
|
|
271
|
+
align-items: center;
|
|
172
272
|
gap: 8px;
|
|
273
|
+
min-width: 0;
|
|
274
|
+
}
|
|
275
|
+
.wa-list__range-sep {
|
|
276
|
+
flex: 0 0 auto;
|
|
277
|
+
font-size: 12px;
|
|
278
|
+
color: #8A93A3;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* Domar el <input type="date">.
|
|
282
|
+
Un date input nativo se delata por tres cosas: la fuente del user-agent, el alto propio y el
|
|
283
|
+
icono azul del picker de Chrome. Las tres se pueden corregir; el CALENDARIO que se despliega al
|
|
284
|
+
hacer clic NO — lo pinta el navegador y ningún CSS lo alcanza. Eso es aceptable: es la ventana
|
|
285
|
+
que la persona ya conoce de su sistema, y reemplazarla exigiría un date picker propio, o sea
|
|
286
|
+
una dependencia (prohibido) o cientos de líneas de calendario a mano. */
|
|
287
|
+
.wa-list__date {
|
|
288
|
+
flex: 1 1 0;
|
|
289
|
+
min-width: 0;
|
|
290
|
+
padding: 7px 10px;
|
|
291
|
+
border: 1px solid #E4E7EE;
|
|
292
|
+
border-radius: 8px;
|
|
293
|
+
font: inherit;
|
|
294
|
+
font-size: 12.5px;
|
|
295
|
+
color: #52606d;
|
|
296
|
+
background: #ffffff;
|
|
297
|
+
}
|
|
298
|
+
.wa-list__date:hover {
|
|
299
|
+
border-color: #C9D2F5;
|
|
300
|
+
}
|
|
301
|
+
/* El indicador del picker: gris como el resto del formulario en vez del azul de Chrome. */
|
|
302
|
+
.wa-list__date::-webkit-calendar-picker-indicator {
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
opacity: 0.45;
|
|
305
|
+
}
|
|
306
|
+
.wa-list__date::-webkit-calendar-picker-indicator:hover {
|
|
307
|
+
opacity: 0.8;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* «Limpiar filtros»: enlace discreto, no un botón que compita con los chips. Sólo se renderiza
|
|
311
|
+
cuando hay filtros puestos, así que no necesita estado deshabilitado. */
|
|
312
|
+
.wa-list__clear {
|
|
313
|
+
flex: 0 0 auto;
|
|
314
|
+
padding: 0;
|
|
315
|
+
border: 0;
|
|
316
|
+
font: inherit;
|
|
317
|
+
font-size: 12px;
|
|
318
|
+
color: #6B7280;
|
|
319
|
+
background: none;
|
|
320
|
+
text-decoration: underline;
|
|
321
|
+
cursor: pointer;
|
|
173
322
|
}
|
|
174
|
-
.wa-
|
|
323
|
+
.wa-list__clear:hover {
|
|
324
|
+
color: #4F5AED;
|
|
325
|
+
}
|
|
326
|
+
|
|
175
327
|
.wa-list__more {
|
|
176
328
|
padding: 6px 10px;
|
|
177
329
|
border: 1px solid #cbd2d9;
|
|
@@ -181,7 +333,6 @@ const LIST_CSS = `
|
|
|
181
333
|
background: #ffffff;
|
|
182
334
|
cursor: pointer;
|
|
183
335
|
}
|
|
184
|
-
.wa-list__actions button:hover,
|
|
185
336
|
.wa-list__more:hover {
|
|
186
337
|
background: #f5f7fa;
|
|
187
338
|
}
|
|
@@ -202,72 +353,117 @@ const LIST_CSS = `
|
|
|
202
353
|
list-style: none;
|
|
203
354
|
}
|
|
204
355
|
|
|
356
|
+
/* La fila del diseño (.pen de DEV-5053): avatar a la izquierda y la columna de contenido a la
|
|
357
|
+
derecha. */
|
|
205
358
|
.wa-list__row {
|
|
206
359
|
display: flex;
|
|
207
|
-
flex-direction:
|
|
208
|
-
|
|
360
|
+
flex-direction: row;
|
|
361
|
+
align-items: center;
|
|
362
|
+
gap: 12px;
|
|
209
363
|
width: 100%;
|
|
210
|
-
padding:
|
|
364
|
+
padding: 12px 16px;
|
|
211
365
|
border: 0;
|
|
212
|
-
border-bottom: 1px solid #
|
|
366
|
+
border-bottom: 1px solid #EEF0F3;
|
|
213
367
|
font: inherit;
|
|
214
368
|
color: inherit;
|
|
215
369
|
text-align: left;
|
|
216
|
-
background:
|
|
370
|
+
background: #ffffff;
|
|
217
371
|
cursor: pointer;
|
|
218
372
|
}
|
|
219
373
|
.wa-list__row:hover {
|
|
220
|
-
background: #
|
|
374
|
+
background: #F7F8FC;
|
|
221
375
|
}
|
|
222
376
|
/* El seleccionado se marca por el MISMO atributo que lo anuncia a un lector de pantalla: si un día
|
|
223
377
|
alguien saca el aria-current, el resaltado se va con él y el bug se ve. */
|
|
224
378
|
.wa-list__row[aria-current='true'] {
|
|
225
|
-
background: #
|
|
379
|
+
background: #F5F7FE;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* El avatar de iniciales: círculo de 36px, índigo suave. Es decoración (\`aria-hidden\` en el
|
|
383
|
+
TSX): el nombre está al lado. Su CONTENIDO son las iniciales que devuelve initials(), como
|
|
384
|
+
texto — jamás en una clase ni en un selector. */
|
|
385
|
+
.wa-list__avatar {
|
|
386
|
+
display: flex;
|
|
387
|
+
flex: 0 0 auto;
|
|
388
|
+
align-items: center;
|
|
389
|
+
justify-content: center;
|
|
390
|
+
width: 36px;
|
|
391
|
+
height: 36px;
|
|
392
|
+
border-radius: 50%;
|
|
393
|
+
font-size: 13px;
|
|
394
|
+
font-weight: 700;
|
|
395
|
+
color: #4E5BEF;
|
|
396
|
+
background: #EEF1FE;
|
|
397
|
+
}
|
|
398
|
+
/* El sólido de la fila seleccionada cuelga del MISMO aria-current que el resaltado de la fila, y
|
|
399
|
+
no de una clase calculada en JS: un solo gancho para el resaltado y para el lector de pantalla. */
|
|
400
|
+
.wa-list__row[aria-current='true'] .wa-list__avatar {
|
|
401
|
+
color: #ffffff;
|
|
402
|
+
background: #4E5BEF;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/* La columna de contenido. \`min-width: 0\` es lo que deja que el ellipsis del título y del
|
|
406
|
+
preview funcione dentro de un flex item. */
|
|
407
|
+
.wa-list__middle {
|
|
408
|
+
display: flex;
|
|
409
|
+
flex: 1 1 0;
|
|
410
|
+
min-width: 0;
|
|
411
|
+
flex-direction: column;
|
|
412
|
+
gap: 3px;
|
|
226
413
|
}
|
|
227
414
|
|
|
228
415
|
.wa-list__head {
|
|
229
416
|
display: flex;
|
|
230
|
-
align-items:
|
|
417
|
+
align-items: center;
|
|
231
418
|
justify-content: space-between;
|
|
232
419
|
gap: 8px;
|
|
233
420
|
}
|
|
234
421
|
.wa-list__title {
|
|
235
422
|
overflow: hidden;
|
|
236
|
-
font-
|
|
423
|
+
font-size: 14px;
|
|
424
|
+
font-weight: 700;
|
|
425
|
+
color: #2D3340;
|
|
237
426
|
text-overflow: ellipsis;
|
|
238
427
|
white-space: nowrap;
|
|
239
428
|
}
|
|
240
429
|
.wa-list__time {
|
|
241
430
|
flex: 0 0 auto;
|
|
242
|
-
font-size:
|
|
243
|
-
color: #
|
|
431
|
+
font-size: 11px;
|
|
432
|
+
color: #8A91A0;
|
|
433
|
+
}
|
|
434
|
+
/* El teléfono de la fila, verbatim (E.164 con \`+\`): formatear exige lógica por país e \`Intl\`
|
|
435
|
+
está proscrito acá. */
|
|
436
|
+
.wa-list__phone {
|
|
437
|
+
overflow: hidden;
|
|
438
|
+
font-size: 11.5px;
|
|
439
|
+
color: #8A91A0;
|
|
440
|
+
text-overflow: ellipsis;
|
|
441
|
+
white-space: nowrap;
|
|
244
442
|
}
|
|
245
443
|
.wa-list__preview {
|
|
246
444
|
overflow: hidden;
|
|
247
|
-
|
|
445
|
+
font-size: 12.5px;
|
|
446
|
+
color: #5B6472;
|
|
248
447
|
text-overflow: ellipsis;
|
|
249
448
|
white-space: nowrap;
|
|
250
449
|
}
|
|
251
|
-
/* El estado del emisor es una cadena OPACA que escribe otro servicio: se pinta como texto
|
|
252
|
-
más. Nunca se interpola su valor en un selector ni en una clase
|
|
450
|
+
/* El estado del emisor es una cadena OPACA que escribe otro servicio: se pinta como texto dentro
|
|
451
|
+
de una pill y nada más. Nunca se interpola su valor en un selector ni en una clase
|
|
452
|
+
(C-01 / T-03-02) — la pill es cosmética del contenedor, no del valor. */
|
|
253
453
|
.wa-list__state {
|
|
254
454
|
align-self: flex-start;
|
|
455
|
+
max-width: 100%;
|
|
456
|
+
padding: 2px 8px;
|
|
457
|
+
border-radius: 999px;
|
|
255
458
|
font-size: 11px;
|
|
256
|
-
|
|
459
|
+
font-weight: 600;
|
|
460
|
+
color: #6B7280;
|
|
461
|
+
background: #F1F2F5;
|
|
257
462
|
word-break: break-word;
|
|
258
463
|
}
|
|
259
464
|
|
|
260
|
-
/* Angosto:
|
|
261
|
-
|
|
262
|
-
.wa-list[data-layout='narrow'] .wa-list__head {
|
|
263
|
-
display: contents;
|
|
264
|
-
}
|
|
265
|
-
.wa-list[data-layout='narrow'] .wa-list__time {
|
|
266
|
-
order: 1;
|
|
267
|
-
}
|
|
268
|
-
.wa-list[data-layout='narrow'] .wa-list__state {
|
|
269
|
-
order: 2;
|
|
270
|
-
}
|
|
465
|
+
/* Angosto: sólo se deja envolver el texto. El \`display: contents\` que antes sacaba al agrupador
|
|
466
|
+
del flujo ya no hace falta — la columna .wa-list__middle apila por sí sola. */
|
|
271
467
|
.wa-list[data-layout='narrow'] .wa-list__preview,
|
|
272
468
|
.wa-list[data-layout='narrow'] .wa-list__title {
|
|
273
469
|
white-space: normal;
|
|
@@ -380,6 +576,57 @@ function normalizeWindowState(state) {
|
|
|
380
576
|
* prototipo o colapsaría burbujas ajenas contra un método heredado. Un `Map` no tiene prototipo
|
|
381
577
|
* que consultar.
|
|
382
578
|
*/
|
|
579
|
+
/**
|
|
580
|
+
* Mergea lo que dice **el servidor** con las salientes que sólo existen **acá** (las burbujas
|
|
581
|
+
* optimistas del composer, DEV-4995). Portado del `mergeThread` del inbox de FlexOS, que ya pagó
|
|
582
|
+
* en producción los dos errores que este helper evita.
|
|
583
|
+
*
|
|
584
|
+
* El invariante: **un refetch no puede ni duplicar ni perder la burbuja del operador.**
|
|
585
|
+
*
|
|
586
|
+
* Las tres reglas, que no son estilo:
|
|
587
|
+
*
|
|
588
|
+
* 1. 🔴 **Los ids nulos se DESCARTAN del set de conocidos.** Un `new Set(server.map(m => m.id))`
|
|
589
|
+
* ingenuo mete `null` adentro; entonces la optimista —que tiene `id: null` por definición—
|
|
590
|
+
* "ya está en el servidor", se descarta, y el mensaje que el operador escribió desaparece de
|
|
591
|
+
* la pantalla mientras viaja. Perder la burbuja es peor que duplicarla: el operador la
|
|
592
|
+
* reescribe y la persona recibe dos.
|
|
593
|
+
* 2. 🔴 **Los huérfanos se detectan por `direction === 'out'`, JAMÁS por el id.** Local es lo que
|
|
594
|
+
* todavía no está confirmado: sólo una SALIENTE puede ser local (una entrante local no existe —
|
|
595
|
+
* las escribe el lifter y sólo llegan por el servidor). Filtrar por id en vez de por dirección
|
|
596
|
+
* arrastraría burbujas entrantes viejas que el servidor ya no manda —borradas, fuera de la
|
|
597
|
+
* ventana de retención— y las reviviría para siempre.
|
|
598
|
+
* 3. 🔴 **También se reconcilia por `client_message_id`** (E3 del contrato del hilo, 2026-08-18).
|
|
599
|
+
* Es la vía que cierra el agujero real: un refetch que llega ANTES de la respuesta del envío
|
|
600
|
+
* trae la saliente ya persistida —con wamid propio, que la burbuja optimista todavía no
|
|
601
|
+
* conoce—, y sin este campo las dos convivían hasta el 201. Es ADICIONAL a las otras dos, no
|
|
602
|
+
* un reemplazo: en las burbujas del bot y en las entrantes el campo es `null`, y ahí siguen
|
|
603
|
+
* mandando las reglas 1 y 2.
|
|
604
|
+
*
|
|
605
|
+
* Qué se conserva y qué no:
|
|
606
|
+
*
|
|
607
|
+
* - Una local **sin wamid y sin gemela en el servidor** siempre sobrevive: no hay con qué
|
|
608
|
+
* reconciliarla.
|
|
609
|
+
* - Una local **con wamid que el servidor ya trae** se descarta: gana la del servidor, que es la
|
|
610
|
+
* fresca (el estado avanza `pending -> sent -> delivered -> read`).
|
|
611
|
+
* - Una local **cuyo `client_message_id` el servidor ya trae** se descarta aunque no tenga wamid:
|
|
612
|
+
* es la misma burbuja, ya persistida.
|
|
613
|
+
* - Una local **con wamid que el servidor todavía NO trae** sobrevive: es la burbuja que devolvió
|
|
614
|
+
* el 201 antes de que el hilo se refresque.
|
|
615
|
+
*
|
|
616
|
+
* **No ordena**, igual que `dedupeByWamid`: el orden cronológico es de la vista (THREAD-01/DEC-N).
|
|
617
|
+
*/
|
|
618
|
+
function mergeThread(serverMessages, localMessages) {
|
|
619
|
+
const knownWamids = new Set(serverMessages.map((message) => message.id).filter((id) => typeof id === "string" && id !== ""));
|
|
620
|
+
const knownClientMessageIds = new Set(serverMessages.map((message) => message.client_message_id).filter((id) => typeof id === "string" && id !== ""));
|
|
621
|
+
const orphans = localMessages.filter((message) => {
|
|
622
|
+
if (message.direction !== "out") return false;
|
|
623
|
+
const clientMessageId = typeof message.client_message_id === "string" && message.client_message_id !== "" ? message.client_message_id : null;
|
|
624
|
+
if (clientMessageId !== null && knownClientMessageIds.has(clientMessageId)) return false;
|
|
625
|
+
const wamid = typeof message.id === "string" && message.id !== "" ? message.id : null;
|
|
626
|
+
return wamid === null || !knownWamids.has(wamid);
|
|
627
|
+
});
|
|
628
|
+
return dedupeByWamid([...serverMessages, ...orphans]);
|
|
629
|
+
}
|
|
383
630
|
function dedupeByWamid(messages) {
|
|
384
631
|
const deduped = [];
|
|
385
632
|
const positionByWamid = /* @__PURE__ */ new Map();
|
|
@@ -398,6 +645,159 @@ function dedupeByWamid(messages) {
|
|
|
398
645
|
return deduped;
|
|
399
646
|
}
|
|
400
647
|
//#endregion
|
|
648
|
+
//#region src/core/contract/operator-send.ts
|
|
649
|
+
/** El payload del cable es entrada NO confiable: se mira como diccionario, no como tipo. */
|
|
650
|
+
function asRecord$1(value) {
|
|
651
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
652
|
+
}
|
|
653
|
+
/** Un string útil, o `null`. El vacío es tan inútil como el ausente. */
|
|
654
|
+
function asNonEmptyString(value) {
|
|
655
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* El tope de Meta, no nuestro. Se aplica en el `maxLength` del textarea y se vuelve a verificar
|
|
659
|
+
* antes de enviar: un `maxLength` es una comodidad del navegador, no una garantía.
|
|
660
|
+
*/
|
|
661
|
+
const REPLY_TEXT_MAX_LENGTH = 4096;
|
|
662
|
+
/**
|
|
663
|
+
* Genera el `client_message_id` de un mensaje. Uno por mensaje, **estable entre reintentos del
|
|
664
|
+
* mismo mensaje** (regla 3 del contrato) — por eso lo genera el composer una sola vez y lo guarda,
|
|
665
|
+
* en vez de recalcularlo en cada envío.
|
|
666
|
+
*
|
|
667
|
+
* `crypto.randomUUID` no está garantizado en todo host (contextos no seguros, DOMs parciales de
|
|
668
|
+
* test), así que hay fallback. El id sólo tiene que ser único, no criptográfico: es una clave de
|
|
669
|
+
* idempotencia, no un secreto.
|
|
670
|
+
*/
|
|
671
|
+
function newClientMessageId() {
|
|
672
|
+
const webCrypto = globalThis.crypto;
|
|
673
|
+
if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
|
|
674
|
+
return `cmid-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* La burbuja optimista: la que el operador ve **antes** de que exista en ningún servidor.
|
|
678
|
+
*
|
|
679
|
+
* `id: null` es lo que la marca como no confirmada: sin wamid no hay con qué reconciliarla por ahí,
|
|
680
|
+
* y por eso dos optimistas nunca se colapsan entre sí.
|
|
681
|
+
*
|
|
682
|
+
* `client_message_id` es la OTRA mitad del merge, y la que cierra el agujero (E3 del contrato del
|
|
683
|
+
* hilo): un refetch que llegue antes de la respuesta del envío trae la saliente ya persistida CON
|
|
684
|
+
* este mismo id, así que `mergeThread` la reconoce por identidad en vez de dejarla huérfana y
|
|
685
|
+
* pintarla dos veces. Por eso la burbuja lo lleva desde que nace y no recién cuando la confirman.
|
|
686
|
+
*
|
|
687
|
+
* `sent_by_name` va `null` a propósito: el nombre del operador lo resuelve el servidor desde el
|
|
688
|
+
* token (el paquete no ve tokens ni identidades). Inventarlo acá sería escribir en el hilo un dato
|
|
689
|
+
* que nadie afirmó. Que la burbuja se pinte igual como del operador lo resuelve la vista, que sabe
|
|
690
|
+
* cuáles son suyas por identidad de objeto, no adivinando.
|
|
691
|
+
*/
|
|
692
|
+
function optimisticMessage(text, at, clientMessageId) {
|
|
693
|
+
return {
|
|
694
|
+
direction: "out",
|
|
695
|
+
body: text,
|
|
696
|
+
at,
|
|
697
|
+
status: "pending",
|
|
698
|
+
id: null,
|
|
699
|
+
client_message_id: clientMessageId,
|
|
700
|
+
message_type: "text",
|
|
701
|
+
media_id: null,
|
|
702
|
+
sent_by_name: null
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Estrecha el payload del 201/200 a un `ThreadMessage` del hilo v0.
|
|
707
|
+
*
|
|
708
|
+
* ⚠️ **Discrepancia real del contrato, y por qué este helper existe.** El documento dice que el
|
|
709
|
+
* 201 devuelve «un `ThreadMessage` completo, indistinguible de los que trae el hilo», pero su
|
|
710
|
+
* ejemplo trae `id: 8842` (la **pk numérica** de la fila), `wamid` y `occurred_at`, mientras que el
|
|
711
|
+
* `ThreadMessage` del [contrato del hilo
|
|
712
|
+
* v0](https://linear.app/liftit/document/contrato-del-hilo-de-conversaciones-v0-threadmessage-eb6e1ec3fc76)
|
|
713
|
+
* usa `id` = **el wamid** (string) y `at`. Los dos nombres se leen, con `wamid`/`at` ganando:
|
|
714
|
+
*
|
|
715
|
+
* - Si el servidor manda el shape del hilo, funciona.
|
|
716
|
+
* - Si manda el shape del ejemplo, funciona igual y `id` queda con el **wamid**, que es lo que el
|
|
717
|
+
* dedup necesita.
|
|
718
|
+
*
|
|
719
|
+
* Que `id` termine con la pk numérica sería el bug caro: la burbuja se mergearía contra un wamid
|
|
720
|
+
* que no es, o se quedaría de huérfana para siempre duplicándose en cada refetch.
|
|
721
|
+
*
|
|
722
|
+
* Un payload sin ninguno de los dos ids degrada a `id: null` — la burbuja se ve, con el estado que
|
|
723
|
+
* el servidor haya dicho, y el próximo refetch la reemplaza. Nunca lanza: un 201 deforme no puede
|
|
724
|
+
* hacerle perder al operador el mensaje que acaba de mandar.
|
|
725
|
+
*/
|
|
726
|
+
function normalizeReplyMessage(payload) {
|
|
727
|
+
const record = asRecord$1(payload);
|
|
728
|
+
return {
|
|
729
|
+
id: asNonEmptyString(record.wamid) ?? asNonEmptyString(record.id),
|
|
730
|
+
at: asNonEmptyString(record.at) ?? asNonEmptyString(record.occurred_at),
|
|
731
|
+
client_message_id: asNonEmptyString(record.client_message_id),
|
|
732
|
+
direction: "out",
|
|
733
|
+
body: typeof record.body === "string" ? record.body : null,
|
|
734
|
+
status: asNonEmptyString(record.status),
|
|
735
|
+
message_type: asNonEmptyString(record.message_type) ?? "text",
|
|
736
|
+
media_id: asNonEmptyString(record.media_id),
|
|
737
|
+
media_url: asNonEmptyString(record.media_url),
|
|
738
|
+
media_format: asNonEmptyString(record.media_format),
|
|
739
|
+
media_mime_type: asNonEmptyString(record.media_mime_type),
|
|
740
|
+
sent_by_name: asNonEmptyString(record.sent_by_name),
|
|
741
|
+
service_state: asNonEmptyString(record.service_state)
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
/** El código que se usa cuando el rechazo no trae cuerpo estructurado (red, CORS, 500 con HTML). */
|
|
745
|
+
const UNSTRUCTURED_ERROR_CODE = "unknown";
|
|
746
|
+
/**
|
|
747
|
+
* Traduce lo que rechazó el `fetcher` del host a la decisión del contrato.
|
|
748
|
+
*
|
|
749
|
+
* El `fetcher` es del host y puede rechazar con lo que quiera. Se buscan, en orden, las dos formas
|
|
750
|
+
* razonables: el cuerpo colgado del error (`error.body`, que es lo que lanza el default-fetcher del
|
|
751
|
+
* entry `./element` vía `WaFetchError`), o el propio valor rechazado siendo ya el cuerpo.
|
|
752
|
+
*
|
|
753
|
+
* Las dos lecturas por defecto, que son opuestas a propósito (DEC-U):
|
|
754
|
+
*
|
|
755
|
+
* - **Sin cuerpo estructurado ⇒ REINTENTABLE.** Un fallo de red pudo no llegar nunca al servidor, y
|
|
756
|
+
* el reintento es idempotente por `client_message_id`: no puede duplicar el mensaje.
|
|
757
|
+
* - **Con cuerpo estructurado pero SIN `retryable` ⇒ NO reintentable.** El contrato dice que
|
|
758
|
+
* `retryable` manda; si el servidor no lo mandó, no concedió la acción. Ofrecerla igual es
|
|
759
|
+
* exactamente el atajo que en FlexOS terminaba mandando plantillas facturadas.
|
|
760
|
+
*/
|
|
761
|
+
function readSendError(cause) {
|
|
762
|
+
const fromError = asRecord$1(asRecord$1(cause).body);
|
|
763
|
+
const direct = asRecord$1(cause);
|
|
764
|
+
const body = typeof fromError.error_code === "string" ? fromError : typeof direct.error_code === "string" ? direct : {};
|
|
765
|
+
const errorCode = asNonEmptyString(body.error_code);
|
|
766
|
+
if (errorCode === null) return {
|
|
767
|
+
errorCode: UNSTRUCTURED_ERROR_CODE,
|
|
768
|
+
retryable: true,
|
|
769
|
+
windowState: null,
|
|
770
|
+
serverMessage: null
|
|
771
|
+
};
|
|
772
|
+
return {
|
|
773
|
+
errorCode,
|
|
774
|
+
retryable: body.retryable === true,
|
|
775
|
+
windowState: body.window_state === void 0 || body.window_state === null ? null : normalizeWindowState(body.window_state),
|
|
776
|
+
serverMessage: asNonEmptyString(body.message)
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* El texto que ve el operador, indexado por `error_code` (DEC-T).
|
|
781
|
+
*
|
|
782
|
+
* Los textos son NUESTROS y no los del servidor: es lo que hace verificable la regla «decidir por
|
|
783
|
+
* `error_code`» — un test puede aseverar que el código produce este texto y no otro. El `message`
|
|
784
|
+
* del servidor sólo se usa si el código es desconocido, que es el único caso en que no tenemos nada
|
|
785
|
+
* mejor que decir.
|
|
786
|
+
*
|
|
787
|
+
* Ninguno de estos textos promete un reintento: eso lo decide `retryable`, y quien lo pinta es el
|
|
788
|
+
* composer.
|
|
789
|
+
*/
|
|
790
|
+
function sendFailureCopy(failure) {
|
|
791
|
+
switch (failure.errorCode) {
|
|
792
|
+
case "window_closed": return "La ventana de 24 h se cerró: no podemos escribirle hasta que la persona vuelva a escribir.";
|
|
793
|
+
case "window_unverified": return "No pudimos verificar la ventana de 24 h, así que no se envió nada. Reintentá: reintentar no envía ningún mensaje cobrado.";
|
|
794
|
+
case "takeover_unavailable": return "No se pudo pausar el bot, así que el mensaje no se envió. Reintentá en un momento.";
|
|
795
|
+
case "send_failed": return "WhatsApp rechazó el envío. El mensaje quedó registrado en el hilo como no entregado.";
|
|
796
|
+
case "write_forbidden": return "No tenés permiso para responder en esta conversación.";
|
|
797
|
+
default: return failure.serverMessage ?? "No se pudo enviar el mensaje.";
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
//#endregion
|
|
401
801
|
//#region src/core/data/fetcher.ts
|
|
402
802
|
/**
|
|
403
803
|
* La capa de datos del paquete: un único punto de entrada, y el host pone la función.
|
|
@@ -428,6 +828,32 @@ function dedupeByWamid(messages) {
|
|
|
428
828
|
* ⚠️ Si alguien "simplifica" el fetcher a una función que recibe un path, este archivo pierde su
|
|
429
829
|
* razón de existir y el requisito se rompe sin que ningún test de UI se ponga rojo.
|
|
430
830
|
*/
|
|
831
|
+
/**
|
|
832
|
+
* El rechazo ESTRUCTURADO de un `fetcher`: el status y —cuando el cuerpo era JSON— el cuerpo ya
|
|
833
|
+
* parseado.
|
|
834
|
+
*
|
|
835
|
+
* Existe por una razón concreta del contrato de envío: **el cliente decide por `error_code`, jamás
|
|
836
|
+
* por el status HTTP**, y un `throw new Error('409 ...')` deja el `error_code` adentro de un string
|
|
837
|
+
* del que habría que hacer parsing. `window_closed` y `window_unverified` comparten status y sólo
|
|
838
|
+
* se distinguen por el código; aplanarlos es lo que en FlexOS mandaba plantillas facturadas.
|
|
839
|
+
*
|
|
840
|
+
* El default-fetcher del entry `./element` la lanza. Un host con su propio `fetcher` puede lanzar lo
|
|
841
|
+
* que quiera: `readSendError` también reconoce un objeto con `error_code` colgado de `.body` o
|
|
842
|
+
* rechazado directo, y si no hay estructura degrada a "reintentable" (DEC-U).
|
|
843
|
+
*
|
|
844
|
+
* 🔴 **No lleva el texto enviado ni el teléfono** (regla 5 del contrato): son datos personales.
|
|
845
|
+
*/
|
|
846
|
+
var WaFetchError = class extends Error {
|
|
847
|
+
status;
|
|
848
|
+
/** El cuerpo parseado, si era JSON. `null` cuando no lo era o no se pudo leer. */
|
|
849
|
+
body;
|
|
850
|
+
constructor(status, message, body) {
|
|
851
|
+
super(message);
|
|
852
|
+
this.name = "WaFetchError";
|
|
853
|
+
this.status = status;
|
|
854
|
+
this.body = body;
|
|
855
|
+
}
|
|
856
|
+
};
|
|
431
857
|
/** El payload del backend es entrada NO confiable: se mira como diccionario, no como tipo. */
|
|
432
858
|
function asRecord(value) {
|
|
433
859
|
return typeof value === "object" && value !== null ? value : {};
|
|
@@ -463,7 +889,49 @@ async function loadThread(fetcher, request, options) {
|
|
|
463
889
|
window_state: normalizeWindowState(asNullableString(payload.window_state)),
|
|
464
890
|
window_expires_at: asNullableString(payload.window_expires_at),
|
|
465
891
|
phone_number_id: asString(payload.phone_number_id),
|
|
466
|
-
service: asString(payload.service)
|
|
892
|
+
service: asString(payload.service),
|
|
893
|
+
can_reply: payload.can_reply === true
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Envía el texto del operador por el `fetcher` del host y devuelve la burbuja **ya confirmada**
|
|
898
|
+
* (contrato de envío v0, 201 Created — o 200 OK si el `client_message_id` ya se había usado).
|
|
899
|
+
*
|
|
900
|
+
* Los dos casos de éxito devuelven el mismo cuerpo y esta capa no los distingue: no tiene por qué.
|
|
901
|
+
* El 200 es la respuesta a un doble clic, a un reintento de red o a dos pestañas abiertas, y en los
|
|
902
|
+
* dos casos lo correcto es lo mismo — **la burbuja del servidor REEMPLAZA a la optimista** (regla 4
|
|
903
|
+
* del contrato), no se acumulan.
|
|
904
|
+
*
|
|
905
|
+
* Los rechazos se dejan propagar TAL CUAL: quién los traduce a una decisión es `readSendError`
|
|
906
|
+
* (por `error_code`, nunca por status) y quién decide qué hacer es el composer. Acá no hay
|
|
907
|
+
* reintentos, ni traducción, ni logging — el `text` es dato personal.
|
|
908
|
+
*/
|
|
909
|
+
async function sendReply(fetcher, request, options) {
|
|
910
|
+
return normalizeReplyMessage(await fetcher({
|
|
911
|
+
resource: "reply",
|
|
912
|
+
...request
|
|
913
|
+
}, options));
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Libera el takeover por el `fetcher` del host (contrato de envío v0, 200 OK).
|
|
917
|
+
*
|
|
918
|
+
* 🔴 **Esto NO reactiva nada y NO abre la ventana**: sólo suelta la conversación para que el bot
|
|
919
|
+
* vuelva a manejarla. No manda plantillas y no le habla al bot — el relanzamiento en frío ya existe
|
|
920
|
+
* en `lms-mf-lifters`, en el header del drawer del embudo, y no se ejecuta desde acá. La ventana se
|
|
921
|
+
* abre cuando la persona conteste; el `window_state` del 200 llega `closed` a propósito, y quien lo
|
|
922
|
+
* lea como "ya puedo escribir" habilita un composer cuyo siguiente envío falla con `window_closed`.
|
|
923
|
+
*
|
|
924
|
+
* Es **idempotente**: liberar algo que no estaba tomado devuelve 200 igual.
|
|
925
|
+
*/
|
|
926
|
+
async function releaseConversation(fetcher, request, options) {
|
|
927
|
+
const payload = asRecord(await fetcher({
|
|
928
|
+
resource: "release",
|
|
929
|
+
...request
|
|
930
|
+
}, options));
|
|
931
|
+
return {
|
|
932
|
+
status: asString(payload.status),
|
|
933
|
+
released_at: asNullableString(payload.released_at),
|
|
934
|
+
window_state: asNullableString(payload.window_state)
|
|
467
935
|
};
|
|
468
936
|
}
|
|
469
937
|
/**
|
|
@@ -671,6 +1139,21 @@ function useConversations({ fetcher, filters = NO_FILTERS$1 }) {
|
|
|
671
1139
|
*/
|
|
672
1140
|
/** Identidad estable para "sin filtros": un `{}` nuevo por render reiniciaría la lista sin parar. */
|
|
673
1141
|
const NO_FILTERS = {};
|
|
1142
|
+
/**
|
|
1143
|
+
* El rango local `YYYY-MM-DD` de un preset: `to` = hoy, `from` = hoy − (days − 1) — el rango
|
|
1144
|
+
* INCLUYE hoy («7 días» son siete fechas contando la de hoy). Fechas locales con
|
|
1145
|
+
* `getFullYear/getMonth/getDate` + padStart, sin Intl (coherente con DEC-K/DEC-O). El formato es
|
|
1146
|
+
* el MISMO que ya producían los `<input type="date">`, así que DEC-J (los valores viajan tal
|
|
1147
|
+
* cual al descriptor) no cambia.
|
|
1148
|
+
*/
|
|
1149
|
+
function presetRange(days) {
|
|
1150
|
+
const format = (date) => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
1151
|
+
const now = /* @__PURE__ */ new Date();
|
|
1152
|
+
return {
|
|
1153
|
+
from: format(new Date(now.getFullYear(), now.getMonth(), now.getDate() - (days - 1))),
|
|
1154
|
+
to: format(now)
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
674
1157
|
function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
675
1158
|
const fieldId = useId();
|
|
676
1159
|
/**
|
|
@@ -683,6 +1166,11 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
683
1166
|
const [phone, setPhone] = useState("");
|
|
684
1167
|
const [from, setFrom] = useState("");
|
|
685
1168
|
const [to, setTo] = useState("");
|
|
1169
|
+
/**
|
|
1170
|
+
* El preset de fecha activo (DEV-5053). Vive ACÁ y no en `useConversations`: es estado del
|
|
1171
|
+
* formulario — el hook sigue viendo sólo la consulta aplicada, igual que con los date inputs.
|
|
1172
|
+
*/
|
|
1173
|
+
const [datePreset, setDatePreset] = useState(null);
|
|
686
1174
|
/** La consulta vigente. Su IDENTIDAD es lo que el hook mira para reiniciar la lista. */
|
|
687
1175
|
const [filters, setFilters] = useState(NO_FILTERS);
|
|
688
1176
|
const { items, status, error, hasMore, loadMore, retry, autoLoadExhausted } = useConversations({
|
|
@@ -701,10 +1189,45 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
701
1189
|
if (to !== "") next.to = to;
|
|
702
1190
|
setFilters(next);
|
|
703
1191
|
};
|
|
1192
|
+
/**
|
|
1193
|
+
* Un preset ≠ «Rango…» aplica AL CLIC: calcula el rango, sincroniza los date inputs (por si el
|
|
1194
|
+
* operador después abre «Rango…» para ajustar) y arma la consulta con el mismo criterio de
|
|
1195
|
+
* omisión de vacíos que `applyFilters`, conservando el teléfono tipeado.
|
|
1196
|
+
*/
|
|
1197
|
+
const applyPreset = (preset, days) => {
|
|
1198
|
+
setDatePreset(preset);
|
|
1199
|
+
const range = presetRange(days);
|
|
1200
|
+
setFrom(range.from);
|
|
1201
|
+
setTo(range.to);
|
|
1202
|
+
const next = {};
|
|
1203
|
+
if (phone.trim() !== "") next.phone = phone;
|
|
1204
|
+
next.from = range.from;
|
|
1205
|
+
next.to = range.to;
|
|
1206
|
+
setFilters(next);
|
|
1207
|
+
};
|
|
1208
|
+
/**
|
|
1209
|
+
* El rango aplica al cambiar cualquiera de las dos fechas, sin botón de confirmación. Recibe los
|
|
1210
|
+
* dos valores por parámetro y no del estado: `setFrom`/`setTo` son asíncronos, así que leer el
|
|
1211
|
+
* estado acá aplicaría el rango anterior — el clásico off-by-one-render.
|
|
1212
|
+
*
|
|
1213
|
+
* Un extremo vacío se omite (mismo criterio que `applyFilters`): media ventana es un filtro
|
|
1214
|
+
* legítimo, «desde el 1 de agosto» sin tope.
|
|
1215
|
+
*/
|
|
1216
|
+
const applyRange = (nextFrom, nextTo) => {
|
|
1217
|
+
setDatePreset("range");
|
|
1218
|
+
setFrom(nextFrom);
|
|
1219
|
+
setTo(nextTo);
|
|
1220
|
+
const next = {};
|
|
1221
|
+
if (phone.trim() !== "") next.phone = phone;
|
|
1222
|
+
if (nextFrom !== "") next.from = nextFrom;
|
|
1223
|
+
if (nextTo !== "") next.to = nextTo;
|
|
1224
|
+
setFilters(next);
|
|
1225
|
+
};
|
|
704
1226
|
const clearFilters = () => {
|
|
705
1227
|
setPhone("");
|
|
706
1228
|
setFrom("");
|
|
707
1229
|
setTo("");
|
|
1230
|
+
setDatePreset(null);
|
|
708
1231
|
setFilters(NO_FILTERS);
|
|
709
1232
|
};
|
|
710
1233
|
/**
|
|
@@ -740,51 +1263,117 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
740
1263
|
onSubmit: applyFilters,
|
|
741
1264
|
children: [
|
|
742
1265
|
/* @__PURE__ */ jsxs("div", {
|
|
743
|
-
className: "wa-
|
|
744
|
-
children: [
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
1266
|
+
className: "wa-list__search",
|
|
1267
|
+
children: [
|
|
1268
|
+
/* @__PURE__ */ jsx("label", {
|
|
1269
|
+
className: "wa-list__sr-only",
|
|
1270
|
+
htmlFor: `${fieldId}-phone`,
|
|
1271
|
+
children: "Buscar por nombre o teléfono"
|
|
1272
|
+
}),
|
|
1273
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
1274
|
+
className: "wa-list__search-icon",
|
|
1275
|
+
viewBox: "0 0 16 16",
|
|
1276
|
+
width: "14",
|
|
1277
|
+
height: "14",
|
|
1278
|
+
"aria-hidden": "true",
|
|
1279
|
+
focusable: "false",
|
|
1280
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
1281
|
+
cx: "7",
|
|
1282
|
+
cy: "7",
|
|
1283
|
+
r: "4.5",
|
|
1284
|
+
fill: "none",
|
|
1285
|
+
stroke: "currentColor",
|
|
1286
|
+
strokeWidth: "1.5"
|
|
1287
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
1288
|
+
d: "M10.5 10.5 14 14",
|
|
1289
|
+
stroke: "currentColor",
|
|
1290
|
+
strokeWidth: "1.5",
|
|
1291
|
+
strokeLinecap: "round"
|
|
1292
|
+
})]
|
|
1293
|
+
}),
|
|
1294
|
+
/* @__PURE__ */ jsx("input", {
|
|
1295
|
+
id: `${fieldId}-phone`,
|
|
1296
|
+
type: "search",
|
|
1297
|
+
placeholder: "Buscar por nombre o teléfono",
|
|
1298
|
+
value: phone,
|
|
1299
|
+
onChange: (event) => setPhone(event.target.value)
|
|
1300
|
+
})
|
|
1301
|
+
]
|
|
753
1302
|
}),
|
|
754
1303
|
/* @__PURE__ */ jsxs("div", {
|
|
755
|
-
className: "wa-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1304
|
+
className: "wa-list__presets",
|
|
1305
|
+
role: "group",
|
|
1306
|
+
"aria-label": "Filtrar por fecha",
|
|
1307
|
+
children: [
|
|
1308
|
+
/* @__PURE__ */ jsx("button", {
|
|
1309
|
+
type: "button",
|
|
1310
|
+
className: "wa-list__preset",
|
|
1311
|
+
"aria-pressed": datePreset === "today",
|
|
1312
|
+
onClick: () => applyPreset("today", 1),
|
|
1313
|
+
children: "Hoy"
|
|
1314
|
+
}),
|
|
1315
|
+
/* @__PURE__ */ jsx("button", {
|
|
1316
|
+
type: "button",
|
|
1317
|
+
className: "wa-list__preset",
|
|
1318
|
+
"aria-pressed": datePreset === "7d",
|
|
1319
|
+
onClick: () => applyPreset("7d", 7),
|
|
1320
|
+
children: "7 días"
|
|
1321
|
+
}),
|
|
1322
|
+
/* @__PURE__ */ jsx("button", {
|
|
1323
|
+
type: "button",
|
|
1324
|
+
className: "wa-list__preset",
|
|
1325
|
+
"aria-pressed": datePreset === "30d",
|
|
1326
|
+
onClick: () => applyPreset("30d", 30),
|
|
1327
|
+
children: "30 días"
|
|
1328
|
+
}),
|
|
1329
|
+
/* @__PURE__ */ jsx("button", {
|
|
1330
|
+
type: "button",
|
|
1331
|
+
className: "wa-list__preset",
|
|
1332
|
+
"aria-pressed": datePreset === "range",
|
|
1333
|
+
onClick: () => setDatePreset("range"),
|
|
1334
|
+
children: "Rango…"
|
|
1335
|
+
})
|
|
1336
|
+
]
|
|
765
1337
|
}),
|
|
766
|
-
/* @__PURE__ */ jsxs("div", {
|
|
767
|
-
className: "wa-
|
|
768
|
-
children: [
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
1338
|
+
datePreset === "range" && /* @__PURE__ */ jsxs("div", {
|
|
1339
|
+
className: "wa-list__range",
|
|
1340
|
+
children: [
|
|
1341
|
+
/* @__PURE__ */ jsx("label", {
|
|
1342
|
+
className: "wa-list__sr-only",
|
|
1343
|
+
htmlFor: `${fieldId}-from`,
|
|
1344
|
+
children: "Desde"
|
|
1345
|
+
}),
|
|
1346
|
+
/* @__PURE__ */ jsx("input", {
|
|
1347
|
+
id: `${fieldId}-from`,
|
|
1348
|
+
type: "date",
|
|
1349
|
+
className: "wa-list__date",
|
|
1350
|
+
value: from,
|
|
1351
|
+
onChange: (event) => applyRange(event.target.value, to)
|
|
1352
|
+
}),
|
|
1353
|
+
/* @__PURE__ */ jsx("span", {
|
|
1354
|
+
className: "wa-list__range-sep",
|
|
1355
|
+
"aria-hidden": "true",
|
|
1356
|
+
children: "→"
|
|
1357
|
+
}),
|
|
1358
|
+
/* @__PURE__ */ jsx("label", {
|
|
1359
|
+
className: "wa-list__sr-only",
|
|
1360
|
+
htmlFor: `${fieldId}-to`,
|
|
1361
|
+
children: "Hasta"
|
|
1362
|
+
}),
|
|
1363
|
+
/* @__PURE__ */ jsx("input", {
|
|
1364
|
+
id: `${fieldId}-to`,
|
|
1365
|
+
type: "date",
|
|
1366
|
+
className: "wa-list__date",
|
|
1367
|
+
value: to,
|
|
1368
|
+
onChange: (event) => applyRange(from, event.target.value)
|
|
1369
|
+
})
|
|
1370
|
+
]
|
|
777
1371
|
}),
|
|
778
|
-
/* @__PURE__ */
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
784
|
-
type: "button",
|
|
785
|
-
onClick: clearFilters,
|
|
786
|
-
children: "Limpiar"
|
|
787
|
-
})]
|
|
1372
|
+
hasFilters && /* @__PURE__ */ jsx("button", {
|
|
1373
|
+
type: "button",
|
|
1374
|
+
className: "wa-list__clear",
|
|
1375
|
+
onClick: clearFilters,
|
|
1376
|
+
children: "Limpiar filtros"
|
|
788
1377
|
})
|
|
789
1378
|
]
|
|
790
1379
|
}),
|
|
@@ -825,42 +1414,269 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
825
1414
|
});
|
|
826
1415
|
}
|
|
827
1416
|
//#endregion
|
|
828
|
-
//#region src/core/thread/
|
|
1417
|
+
//#region src/core/thread/Composer.tsx
|
|
829
1418
|
/**
|
|
830
|
-
* El
|
|
831
|
-
* meses en español hardcodeados, **sin `Intl`**.
|
|
1419
|
+
* El composer del operador — la mitad visible del takeover humano (DEV-4995).
|
|
832
1420
|
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
* paquete son en español, hardcodeados (si algún día hace falta i18n, es decisión del host,
|
|
836
|
-
* DEV-4990). El ISO completo vive en `dateTime`/`title` de cada burbuja, no acá.
|
|
1421
|
+
* Fuente de verdad del contrato — el documento, no este archivo:
|
|
1422
|
+
* https://linear.app/liftit/document/contrato-de-envio-del-operador-v0-reply-release-0633eeab82d5
|
|
837
1423
|
*
|
|
838
|
-
* Interno del hilo
|
|
1424
|
+
* Presentacional: todo el estado y toda la red viven en `useComposer`. Interno del hilo — NO sale al
|
|
1425
|
+
* barrel (mismo criterio que `MessageBubble` y `ConversationRow`).
|
|
1426
|
+
*
|
|
1427
|
+
* Las cuatro reglas de producto que este componente ES, y que no son estilo:
|
|
1428
|
+
*
|
|
1429
|
+
* 1. 🔴 **Sin `can_reply` no se pinta NADA** (COMP-01). Un operador de solo lectura ve el visor
|
|
1430
|
+
* exactamente como hoy, en vez de escribir un mensaje completo para enterarse recién al enviar
|
|
1431
|
+
* de que no podía. Es un `return null`, no un `disabled`.
|
|
1432
|
+
* 2. 🔴 **Solo texto** (decisión de David). No hay ni puede haber un `<input type="file">` acá: al
|
|
1433
|
+
* lifter no se le mandan imágenes ni documentos.
|
|
1434
|
+
* 3. 🔴 **`closed` y `unverified` NO son lo mismo** (COMP-04/COMP-05). `closed` REEMPLAZA el
|
|
1435
|
+
* composer por el panel frío; `unverified` sólo agrega un aviso y **deja el composer donde
|
|
1436
|
+
* está**, porque significa "no pude leer el estado", no "la conversación está fría". Aplanar los
|
|
1437
|
+
* dos es lo que en FlexOS terminaba mandando una plantilla facturada por un parpadeo de
|
|
1438
|
+
* Postgres. Si algún día alguien "simplifica" estas dos ramas en una, ese es el bug.
|
|
1439
|
+
* 4. 🔴 **El copy de la liberación es honesto** (COMP-06). `/release` **le devuelve la conversación
|
|
1440
|
+
* al bot** y no hace nada más: no manda plantillas, no reactiva a nadie y no habilita al
|
|
1441
|
+
* operador a seguir escribiendo. Si el texto sugiriera cualquiera de esas tres, el operador
|
|
1442
|
+
* haría clic esperando otra cosa. Y tras el 200 el composer **sigue bloqueado**: la ventana se
|
|
1443
|
+
* abre cuando la persona conteste, no acá.
|
|
1444
|
+
*
|
|
1445
|
+
* El relanzamiento **en frío con plantilla** existe, pero **no en este visor**: vive en el
|
|
1446
|
+
* header del drawer del embudo de `lms-mf-lifters`, que es donde el MF ya tiene cargado el
|
|
1447
|
+
* detalle del embudo. Acá se menciona para que el operador sepa a dónde ir — nunca se ejecuta.
|
|
839
1448
|
*/
|
|
840
|
-
/**
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
"
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1449
|
+
/**
|
|
1450
|
+
* El aviso de los envíos que no salieron.
|
|
1451
|
+
*
|
|
1452
|
+
* «Reintentar» aparece **sólo si el contrato lo permitió** (`retryable`): ofrecerlo con
|
|
1453
|
+
* `retryable: false` sería invitar al operador a repetir algo que el servidor ya dijo que no va a
|
|
1454
|
+
* aceptar. «Descartar» está siempre — el mensaje es suyo y puede decidir que no va.
|
|
1455
|
+
*/
|
|
1456
|
+
function FailureNotice({ composer }) {
|
|
1457
|
+
if (composer.failures.length === 0) return null;
|
|
1458
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1459
|
+
className: "wa-composer__failures",
|
|
1460
|
+
role: "alert",
|
|
1461
|
+
children: composer.failures.map((entry) => /* @__PURE__ */ jsxs("div", {
|
|
1462
|
+
className: "wa-composer__failure",
|
|
1463
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1464
|
+
className: "wa-composer__failure-text",
|
|
1465
|
+
children: entry.failure !== null ? sendFailureCopy(entry.failure) : "No se pudo enviar el mensaje."
|
|
1466
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1467
|
+
className: "wa-composer__failure-actions",
|
|
1468
|
+
children: [entry.failure?.retryable === true && /* @__PURE__ */ jsx("button", {
|
|
1469
|
+
type: "button",
|
|
1470
|
+
className: "wa-composer__failure-retry",
|
|
1471
|
+
onClick: () => composer.retry(entry.clientMessageId),
|
|
1472
|
+
children: "Reintentar"
|
|
1473
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1474
|
+
type: "button",
|
|
1475
|
+
onClick: () => composer.dismiss(entry.clientMessageId),
|
|
1476
|
+
children: "Descartar"
|
|
1477
|
+
})]
|
|
1478
|
+
})]
|
|
1479
|
+
}, entry.clientMessageId))
|
|
1480
|
+
});
|
|
858
1481
|
}
|
|
859
1482
|
/**
|
|
860
|
-
*
|
|
861
|
-
*
|
|
1483
|
+
* El bloque de «devolver la conversación al bot», que sólo existe con la ventana cerrada.
|
|
1484
|
+
*
|
|
1485
|
+
* Todo el texto de acá está escrito para que el operador entienda QUÉ está pidiendo antes de
|
|
1486
|
+
* pedirlo, y sobre todo qué NO está pidiendo: no se manda ninguna plantilla, no se reactiva a
|
|
1487
|
+
* nadie y no se habilita a seguir escribiendo. Cambiar estas frases por un «reactivar la
|
|
1488
|
+
* conversación» rompe COMP-06 aunque el código siga funcionando — y ahora además sería falso: el
|
|
1489
|
+
* endpoint ya no reactiva nada.
|
|
1490
|
+
*
|
|
1491
|
+
* La última frase apunta a dónde SÍ se relanza en frío (el header del drawer del embudo), porque
|
|
1492
|
+
* el operador que llega hasta acá con la ventana cerrada suele estar buscando exactamente eso.
|
|
862
1493
|
*/
|
|
863
|
-
function
|
|
1494
|
+
function ReleaseToBot({ composer }) {
|
|
1495
|
+
if (composer.releaseState === "released") return /* @__PURE__ */ jsx("p", {
|
|
1496
|
+
className: "wa-composer__released",
|
|
1497
|
+
role: "status",
|
|
1498
|
+
children: "Listo: la conversación volvió al bot. La ventana sigue cerrada — se abre cuando la persona responda. Si necesitás retomarla en frío, la plantilla se manda desde el header del drawer del embudo."
|
|
1499
|
+
});
|
|
1500
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1501
|
+
className: "wa-composer__release",
|
|
1502
|
+
children: [
|
|
1503
|
+
/* @__PURE__ */ jsxs("p", {
|
|
1504
|
+
className: "wa-composer__release-explain",
|
|
1505
|
+
children: [
|
|
1506
|
+
"Podés devolver la conversación al bot: se suelta el control y el bot vuelve a manejarla.",
|
|
1507
|
+
" ",
|
|
1508
|
+
/* @__PURE__ */ jsx("strong", { children: "No se le manda ningún mensaje a la persona y no te habilita a vos para seguir escribiendo" }),
|
|
1509
|
+
" — si responde, la ventana se abre y el composer vuelve solo. Para retomarla en frío con una plantilla, usá la acción del header del drawer del embudo."
|
|
1510
|
+
]
|
|
1511
|
+
}),
|
|
1512
|
+
composer.releaseState === "error" && composer.releaseFailure !== null && /* @__PURE__ */ jsx("p", {
|
|
1513
|
+
className: "wa-composer__release-error",
|
|
1514
|
+
role: "alert",
|
|
1515
|
+
children: sendFailureCopy(composer.releaseFailure)
|
|
1516
|
+
}),
|
|
1517
|
+
(composer.releaseState !== "error" || composer.releaseFailure?.retryable === true) && /* @__PURE__ */ jsx("button", {
|
|
1518
|
+
type: "button",
|
|
1519
|
+
className: "wa-composer__release-button",
|
|
1520
|
+
onClick: composer.release,
|
|
1521
|
+
disabled: composer.releaseState === "releasing",
|
|
1522
|
+
children: composer.releaseState === "releasing" ? "Devolviendo la conversación al bot…" : "Devolver la conversación al bot"
|
|
1523
|
+
})
|
|
1524
|
+
]
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
function Composer({ canReply, composer, onRetryWindow }) {
|
|
1528
|
+
const [draft, setDraft] = useState("");
|
|
1529
|
+
if (!canReply) return null;
|
|
1530
|
+
if (composer.windowState === "closed") return /* @__PURE__ */ jsxs("div", {
|
|
1531
|
+
className: "wa-composer wa-composer--closed",
|
|
1532
|
+
children: [
|
|
1533
|
+
/* @__PURE__ */ jsx(FailureNotice, { composer }),
|
|
1534
|
+
/* @__PURE__ */ jsx("span", {
|
|
1535
|
+
className: "wa-composer__lock",
|
|
1536
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
1537
|
+
width: 20,
|
|
1538
|
+
height: 20,
|
|
1539
|
+
viewBox: "0 0 20 20",
|
|
1540
|
+
fill: "none",
|
|
1541
|
+
stroke: "#8A91A0",
|
|
1542
|
+
strokeWidth: 1.6,
|
|
1543
|
+
strokeLinecap: "round",
|
|
1544
|
+
strokeLinejoin: "round",
|
|
1545
|
+
"aria-hidden": "true",
|
|
1546
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
1547
|
+
x: "4.5",
|
|
1548
|
+
y: "9",
|
|
1549
|
+
width: "11",
|
|
1550
|
+
height: "7.5",
|
|
1551
|
+
rx: "1.5"
|
|
1552
|
+
}), /* @__PURE__ */ jsx("path", { d: "M7 9V6.5a3 3 0 0 1 6 0V9" })]
|
|
1553
|
+
})
|
|
1554
|
+
}),
|
|
1555
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1556
|
+
role: "status",
|
|
1557
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1558
|
+
className: "wa-composer__cold-title",
|
|
1559
|
+
children: "La ventana de 24 horas está cerrada"
|
|
1560
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1561
|
+
className: "wa-composer__cold-explain",
|
|
1562
|
+
children: "WhatsApp solo permite responder hasta 24 h después del último mensaje del lifter. Se reabre cuando vuelva a escribir."
|
|
1563
|
+
})]
|
|
1564
|
+
}),
|
|
1565
|
+
/* @__PURE__ */ jsx(ReleaseToBot, { composer })
|
|
1566
|
+
]
|
|
1567
|
+
});
|
|
1568
|
+
const send = () => {
|
|
1569
|
+
const text = draft.trim();
|
|
1570
|
+
if (text === "") return;
|
|
1571
|
+
composer.send(text);
|
|
1572
|
+
setDraft("");
|
|
1573
|
+
};
|
|
1574
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1575
|
+
className: "wa-composer",
|
|
1576
|
+
children: [
|
|
1577
|
+
composer.windowState === "unverified" && /* @__PURE__ */ jsxs("div", {
|
|
1578
|
+
className: "wa-composer__unverified",
|
|
1579
|
+
role: "status",
|
|
1580
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1581
|
+
className: "wa-composer__unverified-text",
|
|
1582
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1583
|
+
className: "wa-composer__unverified-title",
|
|
1584
|
+
children: "No pudimos verificar si se puede responder"
|
|
1585
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1586
|
+
className: "wa-composer__unverified-explain",
|
|
1587
|
+
children: "Es un error temporal, no una ventana cerrada."
|
|
1588
|
+
})]
|
|
1589
|
+
}), onRetryWindow !== void 0 && /* @__PURE__ */ jsx("button", {
|
|
1590
|
+
type: "button",
|
|
1591
|
+
className: "wa-composer__retry-window",
|
|
1592
|
+
onClick: onRetryWindow,
|
|
1593
|
+
children: "Reintentar"
|
|
1594
|
+
})]
|
|
1595
|
+
}),
|
|
1596
|
+
/* @__PURE__ */ jsx(FailureNotice, { composer }),
|
|
1597
|
+
/* @__PURE__ */ jsxs("form", {
|
|
1598
|
+
className: "wa-composer__form",
|
|
1599
|
+
onSubmit: (event) => {
|
|
1600
|
+
event.preventDefault();
|
|
1601
|
+
send();
|
|
1602
|
+
},
|
|
1603
|
+
children: [/* @__PURE__ */ jsx("textarea", {
|
|
1604
|
+
className: "wa-composer__input",
|
|
1605
|
+
maxLength: REPLY_TEXT_MAX_LENGTH,
|
|
1606
|
+
rows: 2,
|
|
1607
|
+
value: draft,
|
|
1608
|
+
placeholder: "Escribí tu respuesta…",
|
|
1609
|
+
"aria-label": "Mensaje para la persona",
|
|
1610
|
+
onChange: (event) => setDraft(event.target.value),
|
|
1611
|
+
onKeyDown: (event) => {
|
|
1612
|
+
if (event.key !== "Enter" || event.shiftKey || event.nativeEvent.isComposing) return;
|
|
1613
|
+
event.preventDefault();
|
|
1614
|
+
send();
|
|
1615
|
+
}
|
|
1616
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1617
|
+
className: "wa-composer__hint-row",
|
|
1618
|
+
children: [
|
|
1619
|
+
/* @__PURE__ */ jsx("span", {
|
|
1620
|
+
className: "wa-composer__hint",
|
|
1621
|
+
children: "Al enviar, el bot se pausa 2 h y la conversación queda tomada por ti"
|
|
1622
|
+
}),
|
|
1623
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1624
|
+
className: "wa-composer__counter",
|
|
1625
|
+
children: [
|
|
1626
|
+
draft.length,
|
|
1627
|
+
"/",
|
|
1628
|
+
REPLY_TEXT_MAX_LENGTH
|
|
1629
|
+
]
|
|
1630
|
+
}),
|
|
1631
|
+
/* @__PURE__ */ jsx("button", {
|
|
1632
|
+
type: "submit",
|
|
1633
|
+
className: "wa-composer__send",
|
|
1634
|
+
disabled: draft.trim() === "",
|
|
1635
|
+
children: "Enviar"
|
|
1636
|
+
})
|
|
1637
|
+
]
|
|
1638
|
+
})]
|
|
1639
|
+
})
|
|
1640
|
+
]
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
//#endregion
|
|
1644
|
+
//#region src/core/thread/day-label.ts
|
|
1645
|
+
/**
|
|
1646
|
+
* El día del separador del hilo (DEC-O, coherente con DEC-K de la lista): día LOCAL del operador,
|
|
1647
|
+
* meses en español hardcodeados, **sin `Intl`**.
|
|
1648
|
+
*
|
|
1649
|
+
* Sin `Intl` no es capricho: `Intl` depende del locale del host y este componente monta en tres
|
|
1650
|
+
* hosts distintos — el mismo hilo diría "August 15" en uno y "15 de agosto" en otro. Los textos del
|
|
1651
|
+
* paquete son en español, hardcodeados (si algún día hace falta i18n, es decisión del host,
|
|
1652
|
+
* DEV-4990). El ISO completo vive en `dateTime`/`title` de cada burbuja, no acá.
|
|
1653
|
+
*
|
|
1654
|
+
* Interno del hilo: NO sale al barrel del core.
|
|
1655
|
+
*/
|
|
1656
|
+
/** Meses en español, índice 0-11 como `Date.getMonth()`. */
|
|
1657
|
+
const MONTHS = [
|
|
1658
|
+
"enero",
|
|
1659
|
+
"febrero",
|
|
1660
|
+
"marzo",
|
|
1661
|
+
"abril",
|
|
1662
|
+
"mayo",
|
|
1663
|
+
"junio",
|
|
1664
|
+
"julio",
|
|
1665
|
+
"agosto",
|
|
1666
|
+
"septiembre",
|
|
1667
|
+
"octubre",
|
|
1668
|
+
"noviembre",
|
|
1669
|
+
"diciembre"
|
|
1670
|
+
];
|
|
1671
|
+
function parseAt(at) {
|
|
1672
|
+
const date = new Date(at);
|
|
1673
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* La clave de agrupación por día LOCAL. `null` significa "no abre grupo nuevo": la burbuja sin
|
|
1677
|
+
* fecha (una optimista, o una fila corrupta) se pega al grupo vigente en vez de reventar el render.
|
|
1678
|
+
*/
|
|
1679
|
+
function dayKey(at) {
|
|
864
1680
|
if (typeof at !== "string") return null;
|
|
865
1681
|
const date = parseAt(at);
|
|
866
1682
|
if (date === null) return null;
|
|
@@ -975,6 +1791,26 @@ function MediaUnavailable() {
|
|
|
975
1791
|
children: "Adjunto no disponible"
|
|
976
1792
|
});
|
|
977
1793
|
}
|
|
1794
|
+
/** El icono de descarga (DEV-5053 / P6): flecha a bandeja, hereda color. La semántica la lleva
|
|
1795
|
+
* el anchor con su aria-label. */
|
|
1796
|
+
function DownloadGlyph() {
|
|
1797
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
1798
|
+
width: 16,
|
|
1799
|
+
height: 16,
|
|
1800
|
+
viewBox: "0 0 16 16",
|
|
1801
|
+
fill: "none",
|
|
1802
|
+
stroke: "currentColor",
|
|
1803
|
+
strokeWidth: 1.5,
|
|
1804
|
+
strokeLinecap: "round",
|
|
1805
|
+
strokeLinejoin: "round",
|
|
1806
|
+
"aria-hidden": "true",
|
|
1807
|
+
children: [
|
|
1808
|
+
/* @__PURE__ */ jsx("path", { d: "M8 2.5v7.5" }),
|
|
1809
|
+
/* @__PURE__ */ jsx("polyline", { points: "4.5,6.8 8,10.3 11.5,6.8" }),
|
|
1810
|
+
/* @__PURE__ */ jsx("path", { d: "M2.5 13.5h11" })
|
|
1811
|
+
]
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
978
1814
|
/**
|
|
979
1815
|
* Rama image: carga perezosa (no bloquea el render del hilo), miniatura clicable y lightbox
|
|
980
1816
|
* propio, sin dependencias nuevas. Primer intento: la `media_url` del mensaje si viene; si es
|
|
@@ -1050,36 +1886,56 @@ function ImageAttachment({ message, fetcher, mediaId }) {
|
|
|
1050
1886
|
});
|
|
1051
1887
|
if (state.kind === "unavailable") return /* @__PURE__ */ jsx(MediaUnavailable, {});
|
|
1052
1888
|
const alt = attachmentLabel(message, "Imagen adjunta");
|
|
1053
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1889
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1890
|
+
/* @__PURE__ */ jsx("button", {
|
|
1891
|
+
type: "button",
|
|
1892
|
+
className: "wa-thread__media-button",
|
|
1893
|
+
onClick: () => setOpen(true),
|
|
1894
|
+
"aria-label": "Ampliar imagen adjunta",
|
|
1895
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
1896
|
+
className: "wa-thread__media-img",
|
|
1897
|
+
src: state.url,
|
|
1898
|
+
alt,
|
|
1899
|
+
onError: handleImageError
|
|
1900
|
+
})
|
|
1901
|
+
}),
|
|
1902
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1903
|
+
className: "wa-thread__media-file",
|
|
1904
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1905
|
+
className: "wa-thread__media-name",
|
|
1906
|
+
children: attachmentLabel(message, "Imagen adjunta")
|
|
1907
|
+
}), /* @__PURE__ */ jsx(DownloadAttachment, {
|
|
1908
|
+
message,
|
|
1909
|
+
fetcher,
|
|
1910
|
+
mediaId,
|
|
1911
|
+
variant: "icon"
|
|
1912
|
+
})]
|
|
1913
|
+
}),
|
|
1914
|
+
open && /* @__PURE__ */ jsx("div", {
|
|
1915
|
+
className: "wa-thread__lightbox",
|
|
1916
|
+
role: "dialog",
|
|
1917
|
+
"aria-label": "Imagen ampliada",
|
|
1918
|
+
onClick: () => setOpen(false),
|
|
1919
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
1920
|
+
className: "wa-thread__lightbox-img",
|
|
1921
|
+
src: state.url,
|
|
1922
|
+
alt
|
|
1923
|
+
})
|
|
1073
1924
|
})
|
|
1074
|
-
|
|
1925
|
+
] });
|
|
1075
1926
|
}
|
|
1076
1927
|
/**
|
|
1077
1928
|
* Rama descarga ('pdf' y 'other'): un solo `<a>` plano. La url se resuelve AL MOMENTO del clic —
|
|
1078
1929
|
* así nunca está vencida; un anchor no puede detectar una firma expirada, y por eso acá no aplica
|
|
1079
1930
|
* el primer intento con `media_url`. El onClick intercepta, resuelve, setea el href y re-dispara
|
|
1080
1931
|
* el clic programático (el guard deja pasar esa segunda pasada hacia la navegación real).
|
|
1932
|
+
*
|
|
1933
|
+
* `variant` (DEV-5053 / P6): `'label'` es el comportamiento de siempre (el file_name como texto
|
|
1934
|
+
* del link); `'icon'` es el MISMO anchor —misma resolución al clic, mismo blindaje T-05-03,
|
|
1935
|
+
* mismo 404 terminal— pero con un SVG de descarga adentro y el nombre en el `aria-label`. Lo usa
|
|
1936
|
+
* la fila de archivo de la imagen.
|
|
1081
1937
|
*/
|
|
1082
|
-
function DownloadAttachment({ message, fetcher, mediaId }) {
|
|
1938
|
+
function DownloadAttachment({ message, fetcher, mediaId, variant = "label" }) {
|
|
1083
1939
|
const [unavailable, setUnavailable] = useState(false);
|
|
1084
1940
|
const anchorRef = useRef(null);
|
|
1085
1941
|
/** true sólo durante el clic programático post-resolución: esa pasada navega, no re-resuelve. */
|
|
@@ -1112,6 +1968,17 @@ function DownloadAttachment({ message, fetcher, mediaId }) {
|
|
|
1112
1968
|
});
|
|
1113
1969
|
};
|
|
1114
1970
|
if (unavailable) return /* @__PURE__ */ jsx(MediaUnavailable, {});
|
|
1971
|
+
if (variant === "icon") return /* @__PURE__ */ jsx("a", {
|
|
1972
|
+
ref: anchorRef,
|
|
1973
|
+
className: "wa-thread__media-download wa-thread__media-download--icon",
|
|
1974
|
+
href: "#",
|
|
1975
|
+
download: true,
|
|
1976
|
+
target: "_blank",
|
|
1977
|
+
rel: "noopener noreferrer",
|
|
1978
|
+
onClick: handleClick,
|
|
1979
|
+
"aria-label": `Descargar ${typeof message.file_name === "string" && message.file_name !== "" ? message.file_name : "adjunto"}`,
|
|
1980
|
+
children: /* @__PURE__ */ jsx(DownloadGlyph, {})
|
|
1981
|
+
});
|
|
1115
1982
|
return /* @__PURE__ */ jsx("a", {
|
|
1116
1983
|
ref: anchorRef,
|
|
1117
1984
|
className: "wa-thread__media-download",
|
|
@@ -1155,30 +2022,51 @@ function MediaAttachment({ message, fetcher }) {
|
|
|
1155
2022
|
/**
|
|
1156
2023
|
* El tick de una saliente. El vocabulario conocido y nada más: lo desconocido devuelve `null` y la
|
|
1157
2024
|
* burbuja simplemente no lleva tick (enum abierto — un status nuevo del cable no rompe el render).
|
|
1158
|
-
* `read` usa el MISMO
|
|
1159
|
-
* de estado, no tema del host.
|
|
2025
|
+
* `read` usa el MISMO check doble que `delivered` y se distingue por color vía `data-status`: es
|
|
2026
|
+
* semántica de estado, no tema del host.
|
|
1160
2027
|
*/
|
|
1161
2028
|
function tickFor(status) {
|
|
1162
2029
|
switch (status) {
|
|
1163
2030
|
case "pending": return {
|
|
1164
|
-
|
|
2031
|
+
kind: "clock",
|
|
1165
2032
|
label: "Pendiente"
|
|
1166
2033
|
};
|
|
1167
2034
|
case "sent": return {
|
|
1168
|
-
|
|
2035
|
+
kind: "check",
|
|
1169
2036
|
label: "Enviado"
|
|
1170
2037
|
};
|
|
1171
2038
|
case "delivered": return {
|
|
1172
|
-
|
|
2039
|
+
kind: "check-check",
|
|
1173
2040
|
label: "Entregado"
|
|
1174
2041
|
};
|
|
1175
2042
|
case "read": return {
|
|
1176
|
-
|
|
2043
|
+
kind: "check-check",
|
|
1177
2044
|
label: "Leído"
|
|
1178
2045
|
};
|
|
1179
2046
|
default: return null;
|
|
1180
2047
|
}
|
|
1181
2048
|
}
|
|
2049
|
+
/**
|
|
2050
|
+
* El glifo del tick (DEV-5053 / P5). `clock` sigue siendo texto («◷»); los checks son SVG inline
|
|
2051
|
+
* con `stroke="currentColor"`: heredan el gris del meta y el azul de `[data-status='read']` del
|
|
2052
|
+
* CSS — la distinción de color por data-status queda exactamente como antes. `aria-hidden`: la
|
|
2053
|
+
* semántica ya la lleva el span envolvente con su aria-label.
|
|
2054
|
+
*/
|
|
2055
|
+
function TickGlyph({ kind }) {
|
|
2056
|
+
if (kind === "clock") return /* @__PURE__ */ jsx(Fragment$1, { children: "◷" });
|
|
2057
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
2058
|
+
width: 16,
|
|
2059
|
+
height: 16,
|
|
2060
|
+
viewBox: "0 0 16 16",
|
|
2061
|
+
fill: "none",
|
|
2062
|
+
stroke: "currentColor",
|
|
2063
|
+
strokeWidth: 1.8,
|
|
2064
|
+
strokeLinecap: "round",
|
|
2065
|
+
strokeLinejoin: "round",
|
|
2066
|
+
"aria-hidden": "true",
|
|
2067
|
+
children: [/* @__PURE__ */ jsx("polyline", { points: "2.5,8.5 6,12 13,4.5" }), kind === "check-check" && /* @__PURE__ */ jsx("polyline", { points: "7,10.2 8.7,12 15.3,4.8" })]
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
1182
2070
|
/** La hora HH:MM local de la burbuja (DEC-O). `null` si el instante no existe o no parsea. */
|
|
1183
2071
|
function formatHour(at) {
|
|
1184
2072
|
if (typeof at !== "string") return null;
|
|
@@ -1186,29 +2074,34 @@ function formatHour(at) {
|
|
|
1186
2074
|
if (Number.isNaN(date.getTime())) return null;
|
|
1187
2075
|
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
1188
2076
|
}
|
|
1189
|
-
function MessageBubble({ message,
|
|
2077
|
+
function MessageBubble({ message, optimistic = false, fetcher }) {
|
|
1190
2078
|
const direction = message.direction === "out" ? "out" : "in";
|
|
1191
2079
|
const hour = formatHour(message.at);
|
|
1192
2080
|
const ctas = threadCtas(message);
|
|
1193
2081
|
const tick = direction === "out" ? tickFor(message.status) : null;
|
|
1194
2082
|
const failed = direction === "out" && message.status === "failed";
|
|
1195
2083
|
const author = typeof message.sent_by_name === "string" && message.sent_by_name.trim() !== "" ? message.sent_by_name : null;
|
|
1196
|
-
|
|
2084
|
+
/**
|
|
2085
|
+
* COMP-03: quién habló, de un golpe. Una saliente **con** `sent_by_name` la escribió una persona;
|
|
2086
|
+
* una saliente sin nombre la escribió la máquina. El operador tiene que poder distinguir qué dijo
|
|
2087
|
+
* el bot de qué dijo un humano sin leer el contenido, y por eso la diferencia es de color y no
|
|
2088
|
+
* sólo la línea del nombre — que puede quedar fuera de pantalla al scrollear.
|
|
2089
|
+
*
|
|
2090
|
+
* La optimista todavía no tiene nombre (lo pone el servidor) pero es del operador por
|
|
2091
|
+
* definición: la acaba de escribir él.
|
|
2092
|
+
*/
|
|
2093
|
+
const authorKind = direction === "out" ? author !== null || optimistic ? "operator" : "bot" : void 0;
|
|
1197
2094
|
const locationFallback = message.body === null && message.message_type === "location" ? message.location_name ?? "Ubicación compartida" : null;
|
|
1198
2095
|
return /* @__PURE__ */ jsxs("div", {
|
|
1199
2096
|
className: "wa-thread__bubble",
|
|
1200
2097
|
"data-direction": direction,
|
|
2098
|
+
"data-author": authorKind,
|
|
1201
2099
|
"data-failed": failed || void 0,
|
|
1202
2100
|
children: [
|
|
1203
2101
|
author !== null && /* @__PURE__ */ jsx("span", {
|
|
1204
2102
|
className: "wa-thread__author",
|
|
1205
2103
|
children: author
|
|
1206
2104
|
}),
|
|
1207
|
-
serviceState !== null && /* @__PURE__ */ jsx("span", {
|
|
1208
|
-
className: "wa-thread__state",
|
|
1209
|
-
title: serviceState,
|
|
1210
|
-
children: serviceState
|
|
1211
|
-
}),
|
|
1212
2105
|
message.body !== null && /* @__PURE__ */ jsx("p", {
|
|
1213
2106
|
className: "wa-thread__body",
|
|
1214
2107
|
children: message.body
|
|
@@ -1249,13 +2142,43 @@ function MessageBubble({ message, showServiceState, fetcher }) {
|
|
|
1249
2142
|
"data-status": message.status,
|
|
1250
2143
|
title: tick.label,
|
|
1251
2144
|
"aria-label": tick.label,
|
|
1252
|
-
children: tick.
|
|
2145
|
+
children: /* @__PURE__ */ jsx(TickGlyph, { kind: tick.kind })
|
|
1253
2146
|
})]
|
|
1254
2147
|
})
|
|
1255
2148
|
]
|
|
1256
2149
|
});
|
|
1257
2150
|
}
|
|
1258
2151
|
//#endregion
|
|
2152
|
+
//#region src/core/thread/service-state-labels.ts
|
|
2153
|
+
/**
|
|
2154
|
+
* Las etiquetas humanas de `service_state` para el HILO (DEV-5053 / P3). Interno del hilo —
|
|
2155
|
+
* NO sale al barrel.
|
|
2156
|
+
*
|
|
2157
|
+
* Este módulo supersede, SÓLO para el hilo, la regla «verbatim, mapeo prohibido» de THREAD-04/C-01:
|
|
2158
|
+
* DEV-5053 autorizó humanizar el paso del flujo en la píldora de transición y en el chip «Paso»
|
|
2159
|
+
* del header. La fila de la lista (`ConversationRow`) NO cambia: sigue pintando el valor crudo.
|
|
2160
|
+
*
|
|
2161
|
+
* La regla de seguridad del módulo es el FALLBACK VERBATIM: un valor sin entrada en la tabla se
|
|
2162
|
+
* devuelve EXACTAMENTE como llegó — un emisor que estrene un paso nuevo se lee crudo, nunca se
|
|
2163
|
+
* oculta ni se adivina. Y la etiqueta (humanizada o cruda) entra SOLO como hijo de texto, que
|
|
2164
|
+
* React escapa: jamás en className/style/selector (T-03-02 sigue vigente).
|
|
2165
|
+
*
|
|
2166
|
+
* Vocabulario inicial: el del fixture `contract/thread-v0.fixture.json` y el docstring de
|
|
2167
|
+
* `types.ts` — todos emitidos por `self_onboarding_whatsapp`.
|
|
2168
|
+
*/
|
|
2169
|
+
/** La tabla es-CO. Se consulta SOLO por clave propia: nada del prototipo puede colarse. */
|
|
2170
|
+
const SERVICE_STATE_LABELS = {
|
|
2171
|
+
collecting_vehicle_plate: "Placa del vehículo",
|
|
2172
|
+
collecting_vehicle_documents: "Documentos del vehículo",
|
|
2173
|
+
collecting_documents: "Documentos personales",
|
|
2174
|
+
existing_user_menu: "Menú de usuario registrado",
|
|
2175
|
+
activated: "Cuenta activada"
|
|
2176
|
+
};
|
|
2177
|
+
/** La etiqueta humana de un `service_state`, o el valor crudo VERBATIM si no hay entrada. */
|
|
2178
|
+
function serviceStateLabel(value) {
|
|
2179
|
+
return Object.prototype.hasOwnProperty.call(SERVICE_STATE_LABELS, value) ? SERVICE_STATE_LABELS[value] : value;
|
|
2180
|
+
}
|
|
2181
|
+
//#endregion
|
|
1259
2182
|
//#region src/core/thread/thread-styles.ts
|
|
1260
2183
|
/**
|
|
1261
2184
|
* El CSS del hilo, como string, para que viaje DENTRO del componente — mismas razones que
|
|
@@ -1266,8 +2189,11 @@ function MessageBubble({ message, showServiceState, fetcher }) {
|
|
|
1266
2189
|
*
|
|
1267
2190
|
* - 🔴 **Todos los selectores van prefijados con `.wa-thread`.** En el entry `./react` NO hay
|
|
1268
2191
|
* shadow DOM: un selector de elemento suelto le pisaría los estilos al host.
|
|
1269
|
-
* - **Sin tokens del LMS, sin variables, sin `@import`, sin fuentes remotas** (C-04).
|
|
1270
|
-
*
|
|
2192
|
+
* - **Sin tokens del LMS, sin variables, sin `@import`, sin fuentes remotas** (C-04). El paquete
|
|
2193
|
+
* monta en tres hosts con temas distintos. La paleta de acá (índigo #4F5AED/#EEF1FE, ámbar,
|
|
2194
|
+
* grises #F4F5F7/#E4E7EE) NO es un tema inventado: viene del diseño aprobado de DEV-5053
|
|
2195
|
+
* (.pen), y sigue sin depender de tokens del host. `Inter` va sólo como primer nombre del font
|
|
2196
|
+
* stack — si el host la carga se usa, si no cae a system-ui.
|
|
1271
2197
|
* - **El scroll del hilo VIVE en `.wa-thread__messages`** (`overflow-y: auto` + `min-height: 0`):
|
|
1272
2198
|
* es el contenedor que la paginación hacia atrás ancla en la Task 3 — moverlo de lugar rompe la
|
|
1273
2199
|
* compensación de `scrollTop`.
|
|
@@ -1279,11 +2205,11 @@ const THREAD_CSS = `
|
|
|
1279
2205
|
min-height: 0;
|
|
1280
2206
|
flex: 1 1 auto;
|
|
1281
2207
|
flex-direction: column;
|
|
1282
|
-
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
2208
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
1283
2209
|
font-size: 14px;
|
|
1284
2210
|
line-height: 1.5;
|
|
1285
|
-
color: #
|
|
1286
|
-
background: #
|
|
2211
|
+
color: #2D3340;
|
|
2212
|
+
background: #F7F6F2;
|
|
1287
2213
|
}
|
|
1288
2214
|
.wa-thread *,
|
|
1289
2215
|
.wa-thread *::before,
|
|
@@ -1297,8 +2223,8 @@ const THREAD_CSS = `
|
|
|
1297
2223
|
flex: 1 1 auto;
|
|
1298
2224
|
min-height: 0;
|
|
1299
2225
|
flex-direction: column;
|
|
1300
|
-
gap:
|
|
1301
|
-
padding:
|
|
2226
|
+
gap: 10px;
|
|
2227
|
+
padding: 14px;
|
|
1302
2228
|
overflow-y: auto;
|
|
1303
2229
|
}
|
|
1304
2230
|
|
|
@@ -1327,44 +2253,60 @@ const THREAD_CSS = `
|
|
|
1327
2253
|
.wa-thread__group {
|
|
1328
2254
|
display: flex;
|
|
1329
2255
|
flex-direction: column;
|
|
1330
|
-
gap:
|
|
2256
|
+
gap: 10px;
|
|
1331
2257
|
}
|
|
1332
2258
|
|
|
1333
|
-
/* Separador de día:
|
|
2259
|
+
/* Separador de día: una pill discreta y centrada (diseño .pen de DEV-5053). */
|
|
1334
2260
|
.wa-thread__day {
|
|
1335
2261
|
align-self: center;
|
|
1336
|
-
margin:
|
|
1337
|
-
padding:
|
|
1338
|
-
border-radius:
|
|
1339
|
-
font-size:
|
|
1340
|
-
|
|
1341
|
-
|
|
2262
|
+
margin: 4px 0;
|
|
2263
|
+
padding: 3px 10px;
|
|
2264
|
+
border-radius: 999px;
|
|
2265
|
+
font-size: 10.5px;
|
|
2266
|
+
font-weight: 600;
|
|
2267
|
+
color: #6B7280;
|
|
2268
|
+
background: #ECEDF1;
|
|
1342
2269
|
}
|
|
1343
2270
|
|
|
2271
|
+
/* El ancho sigue siendo relativo (75%) y no los 300px fijos del frame: el visor monta en tres
|
|
2272
|
+
hosts de ancho distinto y un ancho fijo rompe el modo angosto. */
|
|
1344
2273
|
.wa-thread__bubble {
|
|
1345
2274
|
display: flex;
|
|
1346
2275
|
max-width: 75%;
|
|
1347
2276
|
flex-direction: column;
|
|
1348
|
-
gap:
|
|
1349
|
-
padding:
|
|
1350
|
-
border-radius:
|
|
2277
|
+
gap: 4px;
|
|
2278
|
+
padding: 8px 10px;
|
|
2279
|
+
border-radius: 10px;
|
|
1351
2280
|
overflow-wrap: anywhere;
|
|
1352
2281
|
}
|
|
1353
|
-
/* Entrante: a la izquierda,
|
|
2282
|
+
/* Entrante: a la izquierda, blanca. Lo desconocido cae acá (enums abiertos). */
|
|
1354
2283
|
.wa-thread__bubble[data-direction='in'] {
|
|
1355
2284
|
align-self: flex-start;
|
|
1356
2285
|
background: #ffffff;
|
|
1357
|
-
border: 1px solid #
|
|
2286
|
+
border: 1px solid #EBEDF1;
|
|
1358
2287
|
}
|
|
1359
|
-
/* Saliente: a la derecha,
|
|
2288
|
+
/* Saliente: a la derecha, el verde del diseño. */
|
|
1360
2289
|
.wa-thread__bubble[data-direction='out'] {
|
|
1361
2290
|
align-self: flex-end;
|
|
1362
|
-
background: #
|
|
1363
|
-
border: 1px solid #
|
|
2291
|
+
background: #E9F6EC;
|
|
2292
|
+
border: 1px solid #DDEEE2;
|
|
2293
|
+
}
|
|
2294
|
+
/* COMP-03 reconciliado con el diseño (D-01): el verde de arriba es el de TODA saliente — el
|
|
2295
|
+
diseño sólo modela mensajes del bot, así que no trae un color para el humano. Lo que distingue
|
|
2296
|
+
a la persona es el acento índigo del borde izquierdo (el mismo acento de los avatares y del CTA
|
|
2297
|
+
navegable), que se ve de un golpe y sobrevive a que la línea del nombre se scrollee. Un relleno
|
|
2298
|
+
propio quedaría inventado y chocaría con la píldora de flujo, que ya usa ese par. */
|
|
2299
|
+
.wa-thread__bubble[data-direction='out'][data-author='operator'] {
|
|
2300
|
+
border-left: 3px solid #4E5BEF;
|
|
2301
|
+
}
|
|
2302
|
+
.wa-thread__bubble[data-direction='out'][data-author='operator'] .wa-thread__author {
|
|
2303
|
+
color: #4E5BEF;
|
|
1364
2304
|
}
|
|
1365
2305
|
|
|
1366
2306
|
.wa-thread__body {
|
|
1367
2307
|
margin: 0;
|
|
2308
|
+
font-size: 13px;
|
|
2309
|
+
color: #2D3340;
|
|
1368
2310
|
white-space: pre-wrap;
|
|
1369
2311
|
}
|
|
1370
2312
|
|
|
@@ -1372,18 +2314,24 @@ const THREAD_CSS = `
|
|
|
1372
2314
|
.wa-thread__meta {
|
|
1373
2315
|
display: flex;
|
|
1374
2316
|
align-self: flex-end;
|
|
1375
|
-
align-items:
|
|
2317
|
+
align-items: center;
|
|
2318
|
+
justify-content: flex-end;
|
|
1376
2319
|
gap: 4px;
|
|
1377
|
-
font-size:
|
|
1378
|
-
color: #
|
|
2320
|
+
font-size: 10.5px;
|
|
2321
|
+
color: #9AA1AE;
|
|
1379
2322
|
}
|
|
1380
2323
|
.wa-thread__hour {
|
|
1381
|
-
font-size:
|
|
1382
|
-
color: #
|
|
2324
|
+
font-size: 10.5px;
|
|
2325
|
+
color: #9AA1AE;
|
|
1383
2326
|
}
|
|
1384
2327
|
.wa-thread__tick {
|
|
2328
|
+
display: inline-flex;
|
|
2329
|
+
align-items: center;
|
|
1385
2330
|
letter-spacing: -0.12em;
|
|
1386
2331
|
}
|
|
2332
|
+
.wa-thread__tick svg {
|
|
2333
|
+
display: block;
|
|
2334
|
+
}
|
|
1387
2335
|
/* \`read\` se distingue por color: un azul genérico — semántica de estado, no tema del host. */
|
|
1388
2336
|
.wa-thread__tick[data-status='read'] {
|
|
1389
2337
|
color: #2f6fde;
|
|
@@ -1405,13 +2353,88 @@ const THREAD_CSS = `
|
|
|
1405
2353
|
color: #52606d;
|
|
1406
2354
|
}
|
|
1407
2355
|
|
|
1408
|
-
/*
|
|
1409
|
-
|
|
1410
|
-
.wa-
|
|
1411
|
-
align-self:
|
|
2356
|
+
/* La píldora de flujo (DEV-5053 / P4): centrada, pinta la TRANSICIÓN de service_state con la
|
|
2357
|
+
etiqueta humanizada. El valor jamás se interpola en un selector ni en una clase (THREAD-04). */
|
|
2358
|
+
.wa-thread__flow-pill {
|
|
2359
|
+
align-self: center;
|
|
2360
|
+
margin: 2px 0;
|
|
2361
|
+
padding: 3px 10px;
|
|
2362
|
+
border-radius: 999px;
|
|
2363
|
+
font-size: 10.5px;
|
|
2364
|
+
font-weight: 600;
|
|
2365
|
+
color: #5B63C7;
|
|
2366
|
+
background: #EEF1FE;
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
/* El header del hilo (DEV-5053): la identidad de la persona, SIEMPRE presente. Lo que aparece y
|
|
2370
|
+
desaparece con el flujo es la fila de chips, no el header. */
|
|
2371
|
+
.wa-thread__header {
|
|
2372
|
+
display: flex;
|
|
2373
|
+
flex: 0 0 auto;
|
|
2374
|
+
flex-direction: column;
|
|
2375
|
+
gap: 8px;
|
|
2376
|
+
padding: 14px 16px;
|
|
2377
|
+
border-bottom: 1px solid #EEF0F3;
|
|
2378
|
+
background: #ffffff;
|
|
2379
|
+
}
|
|
2380
|
+
.wa-thread__identity {
|
|
2381
|
+
display: flex;
|
|
2382
|
+
align-items: center;
|
|
2383
|
+
gap: 10px;
|
|
2384
|
+
}
|
|
2385
|
+
/* El avatar del header lleva el índigo SUAVE: el sólido está reservado a la fila seleccionada de
|
|
2386
|
+
la lista, que es donde significa "estás mirando ésta". */
|
|
2387
|
+
.wa-thread__avatar {
|
|
2388
|
+
display: flex;
|
|
2389
|
+
flex: 0 0 auto;
|
|
2390
|
+
align-items: center;
|
|
2391
|
+
justify-content: center;
|
|
2392
|
+
width: 36px;
|
|
2393
|
+
height: 36px;
|
|
2394
|
+
border-radius: 50%;
|
|
2395
|
+
font-size: 13px;
|
|
2396
|
+
font-weight: 700;
|
|
2397
|
+
color: #4E5BEF;
|
|
2398
|
+
background: #EEF1FE;
|
|
2399
|
+
}
|
|
2400
|
+
.wa-thread__who {
|
|
2401
|
+
display: flex;
|
|
2402
|
+
min-width: 0;
|
|
2403
|
+
flex: 1 1 auto;
|
|
2404
|
+
flex-direction: column;
|
|
2405
|
+
gap: 1px;
|
|
2406
|
+
}
|
|
2407
|
+
.wa-thread__name {
|
|
2408
|
+
overflow: hidden;
|
|
2409
|
+
font-size: 14px;
|
|
2410
|
+
font-weight: 700;
|
|
2411
|
+
color: #2D3340;
|
|
2412
|
+
text-overflow: ellipsis;
|
|
2413
|
+
white-space: nowrap;
|
|
2414
|
+
}
|
|
2415
|
+
/* Verbatim, E.164 con \`+\` (D-04): formatear exige lógica por país y un formateo equivocado
|
|
2416
|
+
mutila el dato con el que ops identifica personas. */
|
|
2417
|
+
.wa-thread__phone {
|
|
2418
|
+
overflow: hidden;
|
|
2419
|
+
font-size: 12px;
|
|
2420
|
+
color: #8A91A0;
|
|
2421
|
+
text-overflow: ellipsis;
|
|
2422
|
+
white-space: nowrap;
|
|
2423
|
+
}
|
|
2424
|
+
.wa-thread__chips {
|
|
2425
|
+
display: flex;
|
|
2426
|
+
flex-wrap: wrap;
|
|
2427
|
+
align-items: center;
|
|
2428
|
+
gap: 6px;
|
|
2429
|
+
}
|
|
2430
|
+
.wa-thread__step {
|
|
2431
|
+
display: inline-block;
|
|
2432
|
+
padding: 3px 8px;
|
|
2433
|
+
border-radius: 999px;
|
|
1412
2434
|
font-size: 11px;
|
|
1413
|
-
|
|
1414
|
-
|
|
2435
|
+
font-weight: 600;
|
|
2436
|
+
color: #6B7280;
|
|
2437
|
+
background: #F1F2F5;
|
|
1415
2438
|
}
|
|
1416
2439
|
|
|
1417
2440
|
/* El slot de media (DEV-4988): miniatura, link de descarga o el estado unavailable.
|
|
@@ -1456,6 +2479,28 @@ const THREAD_CSS = `
|
|
|
1456
2479
|
.wa-thread__media-download:hover {
|
|
1457
2480
|
text-decoration: underline;
|
|
1458
2481
|
}
|
|
2482
|
+
/* La fila de archivo bajo la miniatura (DEV-5053 / P6): nombre + icono de descarga, sin peso. */
|
|
2483
|
+
.wa-thread__media-file {
|
|
2484
|
+
display: flex;
|
|
2485
|
+
align-items: center;
|
|
2486
|
+
gap: 8px;
|
|
2487
|
+
padding-top: 4px;
|
|
2488
|
+
}
|
|
2489
|
+
.wa-thread__media-name {
|
|
2490
|
+
font-size: 12px;
|
|
2491
|
+
color: #52606d;
|
|
2492
|
+
word-break: break-word;
|
|
2493
|
+
}
|
|
2494
|
+
/* La variante icono del download: mismo anchor, cosmética de icono. */
|
|
2495
|
+
.wa-thread__media-download--icon {
|
|
2496
|
+
display: inline-flex;
|
|
2497
|
+
align-items: center;
|
|
2498
|
+
padding: 2px;
|
|
2499
|
+
border: none;
|
|
2500
|
+
color: #4F5AED;
|
|
2501
|
+
background: none;
|
|
2502
|
+
line-height: 0;
|
|
2503
|
+
}
|
|
1459
2504
|
.wa-thread__media-loading,
|
|
1460
2505
|
.wa-thread__media-unavailable {
|
|
1461
2506
|
font-size: 12px;
|
|
@@ -1479,28 +2524,36 @@ const THREAD_CSS = `
|
|
|
1479
2524
|
}
|
|
1480
2525
|
|
|
1481
2526
|
/* CTAs: los links y los inertes se pintan IGUAL de visibles — la diferencia es la navegabilidad,
|
|
1482
|
-
no la existencia (THREAD-03).
|
|
2527
|
+
no la existencia (THREAD-03). Sobre esa base, D-03 reparte los dos pills del diseño por el ÚNICO
|
|
2528
|
+
dato disponible: el índigo es el navegable (isCtaLink) y el gris el inerte. No hay campo en el
|
|
2529
|
+
contrato que diga cuál es "primario", y adivinarlo sería inventar jerarquía. */
|
|
1483
2530
|
.wa-thread__ctas {
|
|
1484
2531
|
display: flex;
|
|
1485
2532
|
flex-wrap: wrap;
|
|
1486
2533
|
gap: 6px;
|
|
1487
2534
|
}
|
|
1488
2535
|
.wa-thread__cta {
|
|
1489
|
-
padding:
|
|
1490
|
-
border: 1px solid #
|
|
1491
|
-
border-radius:
|
|
1492
|
-
font-size:
|
|
2536
|
+
padding: 4px 10px;
|
|
2537
|
+
border: 1px solid #E4E7EE;
|
|
2538
|
+
border-radius: 999px;
|
|
2539
|
+
font-size: 11.5px;
|
|
2540
|
+
font-weight: 600;
|
|
1493
2541
|
background: #ffffff;
|
|
1494
2542
|
}
|
|
1495
2543
|
.wa-thread__cta--link {
|
|
1496
|
-
color: #
|
|
2544
|
+
border-color: #C9D2F5;
|
|
2545
|
+
color: #4E5BEF;
|
|
1497
2546
|
text-decoration: none;
|
|
1498
2547
|
}
|
|
1499
2548
|
.wa-thread__cta--link:hover {
|
|
1500
2549
|
text-decoration: underline;
|
|
1501
2550
|
}
|
|
2551
|
+
/* El inerte NO tiene regla de hover y declara cursor: default a conciencia — un inerte que
|
|
2552
|
+
reacciona al puntero promete un clic que no existe. */
|
|
1502
2553
|
.wa-thread__cta--inert {
|
|
1503
|
-
color: #
|
|
2554
|
+
border-color: #E4E7EE;
|
|
2555
|
+
color: #6B7280;
|
|
2556
|
+
cursor: default;
|
|
1504
2557
|
}
|
|
1505
2558
|
|
|
1506
2559
|
.wa-thread__note {
|
|
@@ -1525,8 +2578,446 @@ const THREAD_CSS = `
|
|
|
1525
2578
|
background: #ffffff;
|
|
1526
2579
|
cursor: pointer;
|
|
1527
2580
|
}
|
|
2581
|
+
|
|
2582
|
+
/* ─── El composer del operador (DEV-4995) ─────────────────────────────────────
|
|
2583
|
+
Vive FUERA de .wa-thread__messages: el scroller es el hilo, y un composer adentro se iría
|
|
2584
|
+
scrolleando con las burbujas. Sin \`can_reply\` este bloque no se renderiza: no hay una variante
|
|
2585
|
+
"deshabilitada" del composer para el operador de solo lectura, que ve el visor como siempre. */
|
|
2586
|
+
.wa-composer {
|
|
2587
|
+
display: flex;
|
|
2588
|
+
flex: 0 0 auto;
|
|
2589
|
+
flex-direction: column;
|
|
2590
|
+
gap: 8px;
|
|
2591
|
+
padding: 10px 14px;
|
|
2592
|
+
border-top: 1px solid #EEF0F3;
|
|
2593
|
+
background: #ffffff;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
.wa-composer__form {
|
|
2597
|
+
display: flex;
|
|
2598
|
+
flex-direction: column;
|
|
2599
|
+
gap: 6px;
|
|
2600
|
+
}
|
|
2601
|
+
.wa-composer__input {
|
|
2602
|
+
padding: 9px 12px;
|
|
2603
|
+
border: 1px solid #E4E7EE;
|
|
2604
|
+
border-radius: 12px;
|
|
2605
|
+
font: inherit;
|
|
2606
|
+
font-size: 13px;
|
|
2607
|
+
color: #2D3340;
|
|
2608
|
+
background: #F4F5F7;
|
|
2609
|
+
resize: vertical;
|
|
2610
|
+
}
|
|
2611
|
+
.wa-composer__input:focus {
|
|
2612
|
+
border-color: #4F5AED;
|
|
2613
|
+
outline: 2px solid rgba(79, 90, 237, 0.25);
|
|
2614
|
+
outline-offset: 0;
|
|
2615
|
+
}
|
|
2616
|
+
/* DEV-5053 P2: hint del takeover a la izquierda; contador y Enviar a la derecha. */
|
|
2617
|
+
.wa-composer__hint-row {
|
|
2618
|
+
display: flex;
|
|
2619
|
+
align-items: center;
|
|
2620
|
+
justify-content: space-between;
|
|
2621
|
+
gap: 8px;
|
|
2622
|
+
}
|
|
2623
|
+
.wa-composer__hint {
|
|
2624
|
+
margin-right: auto;
|
|
2625
|
+
font-size: 10.5px;
|
|
2626
|
+
color: #9AA1AE;
|
|
2627
|
+
}
|
|
2628
|
+
.wa-composer__counter {
|
|
2629
|
+
flex: 0 0 auto;
|
|
2630
|
+
font-size: 10.5px;
|
|
2631
|
+
color: #C0C5CF;
|
|
2632
|
+
}
|
|
2633
|
+
.wa-composer__send {
|
|
2634
|
+
padding: 6px 16px;
|
|
2635
|
+
border: 1px solid #4F5AED;
|
|
2636
|
+
border-radius: 999px;
|
|
2637
|
+
font: inherit;
|
|
2638
|
+
color: #ffffff;
|
|
2639
|
+
background: #4F5AED;
|
|
2640
|
+
cursor: pointer;
|
|
2641
|
+
}
|
|
2642
|
+
.wa-composer__send:hover:not(:disabled) {
|
|
2643
|
+
border-color: #3F49D6;
|
|
2644
|
+
background: #3F49D6;
|
|
2645
|
+
}
|
|
2646
|
+
.wa-composer__send:disabled {
|
|
2647
|
+
border-color: #cbd2d9;
|
|
2648
|
+
color: #9aa5b1;
|
|
2649
|
+
background: #f5f7fa;
|
|
2650
|
+
cursor: default;
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
/* COMP-05 — \`unverified\`: un AVISO, no un bloqueo. Banner ámbar (DEV-5053) y no rojo a
|
|
2654
|
+
propósito: el estado no dice que la conversación esté fría, dice que no se pudo leer. */
|
|
2655
|
+
.wa-composer__unverified {
|
|
2656
|
+
display: flex;
|
|
2657
|
+
align-items: center;
|
|
2658
|
+
justify-content: space-between;
|
|
2659
|
+
gap: 10px;
|
|
2660
|
+
margin: 0;
|
|
2661
|
+
padding: 8px 12px;
|
|
2662
|
+
border: 1px solid #F5E7C8;
|
|
2663
|
+
border-radius: 8px;
|
|
2664
|
+
font-size: 12px;
|
|
2665
|
+
color: #8A5A10;
|
|
2666
|
+
background: #FFFBF2;
|
|
2667
|
+
}
|
|
2668
|
+
.wa-composer__unverified-text {
|
|
2669
|
+
display: flex;
|
|
2670
|
+
flex-direction: column;
|
|
2671
|
+
gap: 2px;
|
|
2672
|
+
}
|
|
2673
|
+
.wa-composer__unverified-title {
|
|
2674
|
+
margin: 0;
|
|
2675
|
+
font-weight: 600;
|
|
2676
|
+
}
|
|
2677
|
+
.wa-composer__unverified-explain {
|
|
2678
|
+
margin: 0;
|
|
2679
|
+
}
|
|
2680
|
+
.wa-composer__retry-window {
|
|
2681
|
+
flex: 0 0 auto;
|
|
2682
|
+
padding: 4px 14px;
|
|
2683
|
+
border: 1px solid #F5E7C8;
|
|
2684
|
+
border-radius: 999px;
|
|
2685
|
+
font: inherit;
|
|
2686
|
+
font-size: 12px;
|
|
2687
|
+
color: #8A5A10;
|
|
2688
|
+
background: #ffffff;
|
|
2689
|
+
cursor: pointer;
|
|
2690
|
+
}
|
|
2691
|
+
.wa-composer__retry-window:hover {
|
|
2692
|
+
background: #FFF7E8;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
/* COMP-04 — \`closed\`: acá NO hay textarea. La tarjeta centrada (DEV-5053) reemplaza al
|
|
2696
|
+
composer entero. */
|
|
2697
|
+
.wa-composer--closed {
|
|
2698
|
+
align-items: center;
|
|
2699
|
+
padding: 20px 16px;
|
|
2700
|
+
gap: 10px;
|
|
2701
|
+
text-align: center;
|
|
2702
|
+
background: #ffffff;
|
|
2703
|
+
}
|
|
2704
|
+
.wa-composer__lock {
|
|
2705
|
+
display: flex;
|
|
2706
|
+
align-items: center;
|
|
2707
|
+
justify-content: center;
|
|
2708
|
+
width: 48px;
|
|
2709
|
+
height: 48px;
|
|
2710
|
+
border-radius: 50%;
|
|
2711
|
+
background: #F4F5F7;
|
|
2712
|
+
}
|
|
2713
|
+
.wa-composer__cold-title {
|
|
2714
|
+
margin: 0;
|
|
2715
|
+
font-size: 14px;
|
|
2716
|
+
font-weight: 700;
|
|
2717
|
+
color: #1f2933;
|
|
2718
|
+
}
|
|
2719
|
+
.wa-composer__cold-explain {
|
|
2720
|
+
margin: 4px 0 0;
|
|
2721
|
+
font-size: 12px;
|
|
2722
|
+
color: #8A91A0;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
/* COMP-06 — devolver la conversación al bot. El texto explicativo NO es decoración: es lo que
|
|
2726
|
+
impide que el operador crea que se manda una plantilla o que va a seguir hablando él. */
|
|
2727
|
+
.wa-composer__release {
|
|
2728
|
+
display: flex;
|
|
2729
|
+
flex-direction: column;
|
|
2730
|
+
align-items: flex-start;
|
|
2731
|
+
gap: 8px;
|
|
2732
|
+
}
|
|
2733
|
+
.wa-composer__release-explain {
|
|
2734
|
+
margin: 0;
|
|
2735
|
+
font-size: 12px;
|
|
2736
|
+
color: #616e7c;
|
|
2737
|
+
}
|
|
2738
|
+
.wa-composer__release-error {
|
|
2739
|
+
margin: 0;
|
|
2740
|
+
font-size: 12px;
|
|
2741
|
+
color: #b3261e;
|
|
2742
|
+
}
|
|
2743
|
+
.wa-composer__release-button {
|
|
2744
|
+
padding: 6px 12px;
|
|
2745
|
+
border: 1px solid #cbd2d9;
|
|
2746
|
+
border-radius: 4px;
|
|
2747
|
+
font: inherit;
|
|
2748
|
+
font-size: 13px;
|
|
2749
|
+
color: inherit;
|
|
2750
|
+
background: #ffffff;
|
|
2751
|
+
cursor: pointer;
|
|
2752
|
+
}
|
|
2753
|
+
.wa-composer__release-button:hover:not(:disabled) {
|
|
2754
|
+
background: #f5f7fa;
|
|
2755
|
+
}
|
|
2756
|
+
.wa-composer__release-button:disabled {
|
|
2757
|
+
color: #9aa5b1;
|
|
2758
|
+
cursor: default;
|
|
2759
|
+
}
|
|
2760
|
+
.wa-composer__released {
|
|
2761
|
+
margin: 0;
|
|
2762
|
+
font-size: 12px;
|
|
2763
|
+
color: #52606d;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
/* El envío que no salió: el porqué y qué se puede hacer, junto a la caja donde se escribió. */
|
|
2767
|
+
.wa-composer__failures {
|
|
2768
|
+
display: flex;
|
|
2769
|
+
flex-direction: column;
|
|
2770
|
+
gap: 6px;
|
|
2771
|
+
}
|
|
2772
|
+
.wa-composer__failure {
|
|
2773
|
+
display: flex;
|
|
2774
|
+
flex-wrap: wrap;
|
|
2775
|
+
align-items: center;
|
|
2776
|
+
justify-content: space-between;
|
|
2777
|
+
gap: 8px;
|
|
2778
|
+
padding: 8px 10px;
|
|
2779
|
+
border: 1px solid #e5b9b6;
|
|
2780
|
+
border-radius: 6px;
|
|
2781
|
+
background: #fdf6f6;
|
|
2782
|
+
}
|
|
2783
|
+
.wa-composer__failure-text {
|
|
2784
|
+
margin: 0;
|
|
2785
|
+
font-size: 12px;
|
|
2786
|
+
color: #7d1f1a;
|
|
2787
|
+
}
|
|
2788
|
+
.wa-composer__failure-actions {
|
|
2789
|
+
display: flex;
|
|
2790
|
+
gap: 6px;
|
|
2791
|
+
}
|
|
2792
|
+
.wa-composer__failure-actions button {
|
|
2793
|
+
padding: 4px 10px;
|
|
2794
|
+
border: 1px solid #cbd2d9;
|
|
2795
|
+
border-radius: 4px;
|
|
2796
|
+
font: inherit;
|
|
2797
|
+
font-size: 12px;
|
|
2798
|
+
color: inherit;
|
|
2799
|
+
background: #ffffff;
|
|
2800
|
+
cursor: pointer;
|
|
2801
|
+
}
|
|
2802
|
+
.wa-composer__failure-actions button:hover {
|
|
2803
|
+
background: #f5f7fa;
|
|
2804
|
+
}
|
|
2805
|
+
/* DEV-5053 P7: el Reintentar del envío fallido es un pill blanco con borde y texto rojos. */
|
|
2806
|
+
.wa-composer__failure-actions button.wa-composer__failure-retry {
|
|
2807
|
+
padding: 4px 12px;
|
|
2808
|
+
border: 1px solid #F0C9C5;
|
|
2809
|
+
border-radius: 999px;
|
|
2810
|
+
color: #D93025;
|
|
2811
|
+
}
|
|
2812
|
+
.wa-composer__failure-actions button.wa-composer__failure-retry:hover {
|
|
2813
|
+
background: #FDF6F6;
|
|
2814
|
+
}
|
|
1528
2815
|
`;
|
|
1529
2816
|
//#endregion
|
|
2817
|
+
//#region src/core/thread/useComposer.ts
|
|
2818
|
+
/**
|
|
2819
|
+
* El estado del composer del operador (DEV-4995): la cola de salientes propias, su envío optimista,
|
|
2820
|
+
* la reconciliación contra lo que devuelve el servidor y la liberación del takeover.
|
|
2821
|
+
*
|
|
2822
|
+
* Fuente de verdad del contrato — el documento, no este archivo:
|
|
2823
|
+
* https://linear.app/liftit/document/contrato-de-envio-del-operador-v0-reply-release-0633eeab82d5
|
|
2824
|
+
*
|
|
2825
|
+
* 🔴 El hook **no arma URLs ni conoce la autenticación** (`CLAUDE.md`, DATA-05): recibe el
|
|
2826
|
+
* `WaFetcher` del host, igual que `useThread`. Acá no entra un `phoneNumberId`, ni un `apiUrl`, ni
|
|
2827
|
+
* un token.
|
|
2828
|
+
*
|
|
2829
|
+
* 🔴 **Nada de acá loguea** (regla 5 del contrato): el `text` y el teléfono son datos personales.
|
|
2830
|
+
* No hay un solo `console.*` en este archivo, y no puede haberlo.
|
|
2831
|
+
*
|
|
2832
|
+
* Las reglas del contrato que este hook hace cumplir, y dónde:
|
|
2833
|
+
*
|
|
2834
|
+
* 1. **Se decide por `error_code`, jamás por el status** → `readSendError`, en `send`/`release`.
|
|
2835
|
+
* 2. **`retryable` manda** → `retry()` NO reintenta lo que el contrato marcó no reintentable; la
|
|
2836
|
+
* vista tampoco ofrece el botón.
|
|
2837
|
+
* 3. **Un `client_message_id` por mensaje, estable entre reintentos del MISMO mensaje** → se genera
|
|
2838
|
+
* UNA vez en `send()` y `retry()` reusa el de la entrada, nunca uno nuevo.
|
|
2839
|
+
* 4. **La burbuja del 201/200 REEMPLAZA a la optimista** → la entrada de la cola cambia su
|
|
2840
|
+
* `message` por el del servidor; no se agrega otra.
|
|
2841
|
+
*
|
|
2842
|
+
* Y la que no está escrita en el contrato pero cuesta igual de cara: **la cola es de ESTA
|
|
2843
|
+
* conversación**. El estado guarda de qué `fetcher`+`phone` vino (DEC-G, el mismo patrón de
|
|
2844
|
+
* `useThread`) porque una burbuja pendiente que sobreviva a un cambio de hilo se pinta en la
|
|
2845
|
+
* conversación de otra persona.
|
|
2846
|
+
*/
|
|
2847
|
+
function emptyState(fetcher, phone) {
|
|
2848
|
+
return {
|
|
2849
|
+
fetcher,
|
|
2850
|
+
phone,
|
|
2851
|
+
outgoing: [],
|
|
2852
|
+
windowStateOverride: null,
|
|
2853
|
+
releaseState: "idle",
|
|
2854
|
+
releaseFailure: null
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
function useComposer({ fetcher, phone, windowState }) {
|
|
2858
|
+
const [state, setState] = useState(null);
|
|
2859
|
+
/**
|
|
2860
|
+
* Lo guardado sólo vale si vino de ESTA conversación. Derivado en render y no reseteado desde un
|
|
2861
|
+
* efecto (DEC-G): un `setState` síncrono en un efecto encadena renders y `react-hooks` lo marca.
|
|
2862
|
+
*/
|
|
2863
|
+
const current = state !== null && state.fetcher === fetcher && state.phone === phone ? state : null;
|
|
2864
|
+
/**
|
|
2865
|
+
* Aplica un cambio SÓLO si la conversación sigue siendo la misma. Es la guarda que evita que la
|
|
2866
|
+
* respuesta de un envío de la conversación anterior escriba en la que el operador está mirando
|
|
2867
|
+
* ahora — una promesa en vuelo no sabe que el hilo cambió.
|
|
2868
|
+
*/
|
|
2869
|
+
const patch = useCallback((change) => {
|
|
2870
|
+
setState((previous) => {
|
|
2871
|
+
if (previous === null || previous.fetcher !== fetcher || previous.phone !== phone) return previous;
|
|
2872
|
+
return change(previous);
|
|
2873
|
+
});
|
|
2874
|
+
}, [fetcher, phone]);
|
|
2875
|
+
/** Reescribe UNA entrada de la cola, identificada por su `client_message_id`. */
|
|
2876
|
+
const patchEntry = useCallback((clientMessageId, change) => {
|
|
2877
|
+
patch((previous) => ({
|
|
2878
|
+
...previous,
|
|
2879
|
+
outgoing: previous.outgoing.map((entry) => entry.clientMessageId === clientMessageId ? change(entry) : entry)
|
|
2880
|
+
}));
|
|
2881
|
+
}, [patch]);
|
|
2882
|
+
/**
|
|
2883
|
+
* El envío en sí. Se llama tanto desde `send()` como desde `retry()` con el MISMO
|
|
2884
|
+
* `client_message_id`: por contrato, el reintento no reenvía nada — devuelve 200 con la burbuja
|
|
2885
|
+
* que ya existía. Por eso reintentar es seguro incluso cuando el primer intento sí llegó.
|
|
2886
|
+
*/
|
|
2887
|
+
const dispatch = useCallback((entry) => {
|
|
2888
|
+
sendReply(fetcher, {
|
|
2889
|
+
phone,
|
|
2890
|
+
text: entry.text,
|
|
2891
|
+
clientMessageId: entry.clientMessageId
|
|
2892
|
+
}).then((confirmed) => {
|
|
2893
|
+
patchEntry(entry.clientMessageId, (previous) => ({
|
|
2894
|
+
...previous,
|
|
2895
|
+
status: "sent",
|
|
2896
|
+
message: confirmed,
|
|
2897
|
+
failure: null
|
|
2898
|
+
}));
|
|
2899
|
+
patch((previous) => ({
|
|
2900
|
+
...previous,
|
|
2901
|
+
windowStateOverride: "open"
|
|
2902
|
+
}));
|
|
2903
|
+
}, (cause) => {
|
|
2904
|
+
const failure = readSendError(cause);
|
|
2905
|
+
patchEntry(entry.clientMessageId, (previous) => ({
|
|
2906
|
+
...previous,
|
|
2907
|
+
status: "failed",
|
|
2908
|
+
message: {
|
|
2909
|
+
...previous.message,
|
|
2910
|
+
status: "failed"
|
|
2911
|
+
},
|
|
2912
|
+
failure
|
|
2913
|
+
}));
|
|
2914
|
+
if (failure.windowState !== null) patch((previous) => ({
|
|
2915
|
+
...previous,
|
|
2916
|
+
windowStateOverride: failure.windowState
|
|
2917
|
+
}));
|
|
2918
|
+
});
|
|
2919
|
+
}, [
|
|
2920
|
+
fetcher,
|
|
2921
|
+
phone,
|
|
2922
|
+
patch,
|
|
2923
|
+
patchEntry
|
|
2924
|
+
]);
|
|
2925
|
+
const send = useCallback((text) => {
|
|
2926
|
+
const trimmed = text.trim();
|
|
2927
|
+
if (trimmed === "" || trimmed.length > 4096) return;
|
|
2928
|
+
const clientMessageId = newClientMessageId();
|
|
2929
|
+
const entry = {
|
|
2930
|
+
clientMessageId,
|
|
2931
|
+
text: trimmed,
|
|
2932
|
+
status: "pending",
|
|
2933
|
+
message: optimisticMessage(trimmed, (/* @__PURE__ */ new Date()).toISOString(), clientMessageId),
|
|
2934
|
+
failure: null
|
|
2935
|
+
};
|
|
2936
|
+
setState((previous) => {
|
|
2937
|
+
const base = previous !== null && previous.fetcher === fetcher && previous.phone === phone ? previous : emptyState(fetcher, phone);
|
|
2938
|
+
return {
|
|
2939
|
+
...base,
|
|
2940
|
+
outgoing: [...base.outgoing, entry]
|
|
2941
|
+
};
|
|
2942
|
+
});
|
|
2943
|
+
dispatch(entry);
|
|
2944
|
+
}, [
|
|
2945
|
+
dispatch,
|
|
2946
|
+
fetcher,
|
|
2947
|
+
phone
|
|
2948
|
+
]);
|
|
2949
|
+
const retry = useCallback((clientMessageId) => {
|
|
2950
|
+
const entry = current?.outgoing.find((item) => item.clientMessageId === clientMessageId);
|
|
2951
|
+
if (entry === void 0 || entry.status !== "failed") return;
|
|
2952
|
+
if (entry.failure !== null && !entry.failure.retryable) return;
|
|
2953
|
+
const retried = {
|
|
2954
|
+
...entry,
|
|
2955
|
+
status: "pending",
|
|
2956
|
+
message: {
|
|
2957
|
+
...entry.message,
|
|
2958
|
+
status: "pending"
|
|
2959
|
+
},
|
|
2960
|
+
failure: null
|
|
2961
|
+
};
|
|
2962
|
+
patchEntry(clientMessageId, () => retried);
|
|
2963
|
+
dispatch(retried);
|
|
2964
|
+
}, [
|
|
2965
|
+
current,
|
|
2966
|
+
dispatch,
|
|
2967
|
+
patchEntry
|
|
2968
|
+
]);
|
|
2969
|
+
const dismiss = useCallback((clientMessageId) => {
|
|
2970
|
+
patch((previous) => ({
|
|
2971
|
+
...previous,
|
|
2972
|
+
outgoing: previous.outgoing.filter((entry) => entry.clientMessageId !== clientMessageId)
|
|
2973
|
+
}));
|
|
2974
|
+
}, [patch]);
|
|
2975
|
+
const release = useCallback(() => {
|
|
2976
|
+
if (current?.releaseState === "releasing") return;
|
|
2977
|
+
setState((previous) => {
|
|
2978
|
+
return {
|
|
2979
|
+
...previous !== null && previous.fetcher === fetcher && previous.phone === phone ? previous : emptyState(fetcher, phone),
|
|
2980
|
+
releaseState: "releasing",
|
|
2981
|
+
releaseFailure: null
|
|
2982
|
+
};
|
|
2983
|
+
});
|
|
2984
|
+
releaseConversation(fetcher, { phone }).then(() => {
|
|
2985
|
+
patch((previous) => ({
|
|
2986
|
+
...previous,
|
|
2987
|
+
releaseState: "released",
|
|
2988
|
+
releaseFailure: null,
|
|
2989
|
+
windowStateOverride: "closed"
|
|
2990
|
+
}));
|
|
2991
|
+
}, (cause) => {
|
|
2992
|
+
patch((previous) => ({
|
|
2993
|
+
...previous,
|
|
2994
|
+
releaseState: "error",
|
|
2995
|
+
releaseFailure: readSendError(cause)
|
|
2996
|
+
}));
|
|
2997
|
+
});
|
|
2998
|
+
}, [
|
|
2999
|
+
current,
|
|
3000
|
+
fetcher,
|
|
3001
|
+
patch,
|
|
3002
|
+
phone
|
|
3003
|
+
]);
|
|
3004
|
+
const outgoing = current?.outgoing ?? [];
|
|
3005
|
+
return {
|
|
3006
|
+
outgoing,
|
|
3007
|
+
localMessages: outgoing.map((entry) => entry.message),
|
|
3008
|
+
optimisticMessages: outgoing.filter((entry) => entry.status !== "sent").map((entry) => entry.message),
|
|
3009
|
+
failures: outgoing.filter((entry) => entry.status === "failed"),
|
|
3010
|
+
windowState: current?.windowStateOverride ?? windowState,
|
|
3011
|
+
sending: outgoing.some((entry) => entry.status === "pending"),
|
|
3012
|
+
send,
|
|
3013
|
+
retry,
|
|
3014
|
+
dismiss,
|
|
3015
|
+
releaseState: current?.releaseState ?? "idle",
|
|
3016
|
+
releaseFailure: current?.releaseFailure ?? null,
|
|
3017
|
+
release
|
|
3018
|
+
};
|
|
3019
|
+
}
|
|
3020
|
+
//#endregion
|
|
1530
3021
|
//#region src/core/thread/useThread.ts
|
|
1531
3022
|
/**
|
|
1532
3023
|
* El estado del hilo de conversación: pide el hilo por el `fetcher` del host y sostiene los estados
|
|
@@ -1608,6 +3099,7 @@ function useThread({ fetcher, phone }) {
|
|
|
1608
3099
|
phone,
|
|
1609
3100
|
messages,
|
|
1610
3101
|
windowState: normalizeWindowState(thread.window_state),
|
|
3102
|
+
canReply: thread.can_reply === true,
|
|
1611
3103
|
status: messages.length > 0 ? "ready" : "empty",
|
|
1612
3104
|
error: null,
|
|
1613
3105
|
olderCursor: thread.older_cursor,
|
|
@@ -1621,6 +3113,7 @@ function useThread({ fetcher, phone }) {
|
|
|
1621
3113
|
phone,
|
|
1622
3114
|
messages: [],
|
|
1623
3115
|
windowState: "unverified",
|
|
3116
|
+
canReply: false,
|
|
1624
3117
|
status: "error",
|
|
1625
3118
|
error: toError(cause),
|
|
1626
3119
|
olderCursor: null,
|
|
@@ -1695,7 +3188,7 @@ function useThread({ fetcher, phone }) {
|
|
|
1695
3188
|
finish
|
|
1696
3189
|
]);
|
|
1697
3190
|
const retry = useCallback(() => {
|
|
1698
|
-
if (current !== null && current.messages.length > 0) {
|
|
3191
|
+
if (current !== null && current.status === "error" && current.messages.length > 0) {
|
|
1699
3192
|
loadOlder();
|
|
1700
3193
|
return;
|
|
1701
3194
|
}
|
|
@@ -1707,6 +3200,7 @@ function useThread({ fetcher, phone }) {
|
|
|
1707
3200
|
status: current?.status ?? "loading",
|
|
1708
3201
|
error: current?.error ?? null,
|
|
1709
3202
|
windowState: current?.windowState ?? "unverified",
|
|
3203
|
+
canReply: current?.canReply ?? false,
|
|
1710
3204
|
hasOlder: current?.hasOlder ?? false,
|
|
1711
3205
|
loadOlder,
|
|
1712
3206
|
retry
|
|
@@ -1780,11 +3274,46 @@ function serviceStateTransitions(messages) {
|
|
|
1780
3274
|
return true;
|
|
1781
3275
|
});
|
|
1782
3276
|
}
|
|
1783
|
-
|
|
1784
|
-
|
|
3277
|
+
/**
|
|
3278
|
+
* El paso ACTUAL del flujo para el chip «Paso» del header (DEV-5053 / P3): el `service_state`
|
|
3279
|
+
* no-nulo/no-vacío del ÚLTIMO mensaje que lo tenga, sobre los mensajes ya ordenados (DEC-N).
|
|
3280
|
+
* `null` si ningún mensaje trae flujo — en ese caso el header se pinta igual (lleva la identidad
|
|
3281
|
+
* de la persona) y lo que falta es la fila de chips. Sin cambio de contrato: es una lectura
|
|
3282
|
+
* derivada de lo que el hilo ya trae.
|
|
3283
|
+
*/
|
|
3284
|
+
function currentServiceState(messages) {
|
|
3285
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
3286
|
+
const state = messages[index].service_state;
|
|
3287
|
+
if (typeof state === "string" && state !== "") return state;
|
|
3288
|
+
}
|
|
3289
|
+
return null;
|
|
3290
|
+
}
|
|
3291
|
+
function ConversationThread({ fetcher, phone, displayName, className }) {
|
|
3292
|
+
const { messages: serverMessages, status, error, windowState, canReply, hasOlder, loadOlder, retry } = useThread({
|
|
1785
3293
|
fetcher,
|
|
1786
3294
|
phone
|
|
1787
3295
|
});
|
|
3296
|
+
const composer = useComposer({
|
|
3297
|
+
fetcher,
|
|
3298
|
+
phone,
|
|
3299
|
+
windowState
|
|
3300
|
+
});
|
|
3301
|
+
/**
|
|
3302
|
+
* Lo que se pinta: lo del servidor MÁS las salientes que sólo existen acá (DEV-4995).
|
|
3303
|
+
*
|
|
3304
|
+
* El merge es `mergeThread` —portado del inbox de FlexOS— y su contrato es que **un refetch no
|
|
3305
|
+
* duplica ni pierde la burbuja del operador**: los ids nulos no entran al set de conocidos y los
|
|
3306
|
+
* huérfanos se detectan por `direction === 'out'`, nunca por el id. El orden sigue siendo de esta
|
|
3307
|
+
* vista (DEC-N), así que se reordena después del merge, no adentro.
|
|
3308
|
+
*/
|
|
3309
|
+
const messages = sortChronologically(mergeThread(serverMessages, composer.localMessages));
|
|
3310
|
+
/**
|
|
3311
|
+
* Cuáles de esas burbujas son las nuestras todavía sin confirmar. Se identifican por
|
|
3312
|
+
* **identidad de objeto**, no por heurística sobre el contenido: son literalmente los mismos
|
|
3313
|
+
* objetos que creó `useComposer`. Es lo que deja pintarlas como del operador sin inventarles un
|
|
3314
|
+
* `sent_by_name` que nadie afirmó (COMP-03).
|
|
3315
|
+
*/
|
|
3316
|
+
const optimistic = new Set(composer.optimisticMessages);
|
|
1788
3317
|
const messagesRef = useRef(null);
|
|
1789
3318
|
/** De qué consulta ya se hizo el scroll inicial: una vez por hilo, no en cada página. */
|
|
1790
3319
|
const scrolledForRef = useRef(null);
|
|
@@ -1832,6 +3361,9 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
1832
3361
|
}, [hasOlder, handleLoadOlder]);
|
|
1833
3362
|
const groups = groupByDay(messages);
|
|
1834
3363
|
const showServiceState = serviceStateTransitions(messages);
|
|
3364
|
+
const currentStep = currentServiceState(messages);
|
|
3365
|
+
/** El nombre útil: vacío o sólo espacios cuenta como ausente (D-02). */
|
|
3366
|
+
const name = typeof displayName === "string" && displayName.trim() !== "" ? displayName : null;
|
|
1835
3367
|
return /* @__PURE__ */ jsxs("div", {
|
|
1836
3368
|
className: className ? `wa-thread ${className}` : "wa-thread",
|
|
1837
3369
|
children: [
|
|
@@ -1853,6 +3385,33 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
1853
3385
|
className: "wa-thread__note",
|
|
1854
3386
|
children: "Sin mensajes en esta conversación."
|
|
1855
3387
|
}),
|
|
3388
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3389
|
+
className: "wa-thread__header",
|
|
3390
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3391
|
+
className: "wa-thread__identity",
|
|
3392
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3393
|
+
className: "wa-thread__avatar",
|
|
3394
|
+
"aria-hidden": "true",
|
|
3395
|
+
children: initials(name, phone)
|
|
3396
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
3397
|
+
className: "wa-thread__who",
|
|
3398
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3399
|
+
className: "wa-thread__name",
|
|
3400
|
+
children: name ?? phone
|
|
3401
|
+
}), name !== null && /* @__PURE__ */ jsx("span", {
|
|
3402
|
+
className: "wa-thread__phone",
|
|
3403
|
+
children: phone
|
|
3404
|
+
})]
|
|
3405
|
+
})]
|
|
3406
|
+
}), currentStep !== null && /* @__PURE__ */ jsx("div", {
|
|
3407
|
+
className: "wa-thread__chips",
|
|
3408
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
3409
|
+
className: "wa-thread__step",
|
|
3410
|
+
title: currentStep,
|
|
3411
|
+
children: ["Paso: ", serviceStateLabel(currentStep)]
|
|
3412
|
+
})
|
|
3413
|
+
})]
|
|
3414
|
+
}),
|
|
1856
3415
|
/* @__PURE__ */ jsxs("div", {
|
|
1857
3416
|
className: "wa-thread__messages",
|
|
1858
3417
|
ref: messagesRef,
|
|
@@ -1868,12 +3427,20 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
1868
3427
|
children: [group.label !== null && /* @__PURE__ */ jsx("div", {
|
|
1869
3428
|
className: "wa-thread__day",
|
|
1870
3429
|
children: group.label
|
|
1871
|
-
}), group.items.map(({ message, position }) => /* @__PURE__ */
|
|
3430
|
+
}), group.items.map(({ message, position }) => /* @__PURE__ */ jsxs(Fragment, { children: [showServiceState[position] && typeof message.service_state === "string" && message.service_state !== "" && /* @__PURE__ */ jsxs("div", {
|
|
3431
|
+
className: "wa-thread__flow-pill",
|
|
3432
|
+
children: ["El flujo pasó a ", serviceStateLabel(message.service_state)]
|
|
3433
|
+
}), /* @__PURE__ */ jsx(MessageBubble, {
|
|
1872
3434
|
message,
|
|
1873
|
-
|
|
3435
|
+
optimistic: optimistic.has(message),
|
|
1874
3436
|
fetcher
|
|
1875
|
-
}, message.id ?? `sin-wamid-${position}`))]
|
|
3437
|
+
})] }, message.id ?? `sin-wamid-${position}`))]
|
|
1876
3438
|
}, group.key ?? `sin-dia-${groupIndex}`))]
|
|
3439
|
+
}),
|
|
3440
|
+
/* @__PURE__ */ jsx(Composer, {
|
|
3441
|
+
canReply,
|
|
3442
|
+
composer,
|
|
3443
|
+
onRetryWindow: retry
|
|
1877
3444
|
})
|
|
1878
3445
|
]
|
|
1879
3446
|
});
|
|
@@ -1915,7 +3482,9 @@ const SHELL_CSS = `
|
|
|
1915
3482
|
height: 100%;
|
|
1916
3483
|
min-height: 0;
|
|
1917
3484
|
align-items: stretch;
|
|
1918
|
-
|
|
3485
|
+
/* Inter sólo como primer nombre (DEV-5053): si el host la carga se usa, si no cae a system-ui.
|
|
3486
|
+
Cero @import y cero fuentes remotas (C-04). */
|
|
3487
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
1919
3488
|
}
|
|
1920
3489
|
/* El ancho de la columna de la lista lo fija EL SHELL, no la lista: el data-layout de la lista
|
|
1921
3490
|
se mide de su propio ancho, así que un ancho derivado de él oscila (ver list-styles.ts). El
|
|
@@ -1923,7 +3492,7 @@ const SHELL_CSS = `
|
|
|
1923
3492
|
.wa-conversations[data-layout='wide'] > .wa-list {
|
|
1924
3493
|
width: 320px;
|
|
1925
3494
|
flex: 0 0 320px;
|
|
1926
|
-
border-right: 1px solid #
|
|
3495
|
+
border-right: 1px solid #EEF0F3;
|
|
1927
3496
|
}
|
|
1928
3497
|
.wa-conversations[data-layout='narrow'] > .wa-list {
|
|
1929
3498
|
flex: 1 1 auto;
|
|
@@ -1935,25 +3504,29 @@ const SHELL_CSS = `
|
|
|
1935
3504
|
flex: 1 1 auto;
|
|
1936
3505
|
flex-direction: column;
|
|
1937
3506
|
}
|
|
3507
|
+
/* El "Volver" toma la forma de pill del resto de la interfaz (diseño .pen de DEV-5053). */
|
|
1938
3508
|
.wa-conversations__back {
|
|
1939
3509
|
align-self: flex-start;
|
|
1940
3510
|
margin: 8px 12px 0;
|
|
1941
|
-
padding:
|
|
1942
|
-
border: 1px solid #
|
|
1943
|
-
border-radius:
|
|
3511
|
+
padding: 4px 12px;
|
|
3512
|
+
border: 1px solid #C9D2F5;
|
|
3513
|
+
border-radius: 999px;
|
|
1944
3514
|
font: inherit;
|
|
1945
|
-
|
|
3515
|
+
font-size: 11.5px;
|
|
3516
|
+
font-weight: 600;
|
|
3517
|
+
color: #4F5AED;
|
|
1946
3518
|
background: #ffffff;
|
|
1947
3519
|
cursor: pointer;
|
|
1948
3520
|
}
|
|
1949
3521
|
.wa-conversations__back:hover {
|
|
1950
|
-
background: #
|
|
3522
|
+
background: #EEF1FE;
|
|
1951
3523
|
}
|
|
1952
3524
|
.wa-conversations__empty {
|
|
1953
3525
|
margin: 0;
|
|
1954
3526
|
padding: 24px;
|
|
1955
3527
|
flex: 1 1 auto;
|
|
1956
|
-
|
|
3528
|
+
font-size: 13px;
|
|
3529
|
+
color: #8A91A0;
|
|
1957
3530
|
}
|
|
1958
3531
|
`;
|
|
1959
3532
|
function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
@@ -1969,6 +3542,15 @@ function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
|
1969
3542
|
* docstring de la prop — la reactividad post-mount es del key-swap del element).
|
|
1970
3543
|
*/
|
|
1971
3544
|
const [selectedPhone, setSelectedPhone] = useState(initialPhone ?? null);
|
|
3545
|
+
/**
|
|
3546
|
+
* El nombre de la conversación elegida, para el header del hilo (D-02). Vive acá porque el
|
|
3547
|
+
* `ConversationSummary` —el único lugar donde el contrato pone `name`— lo recibe ESTE shell en
|
|
3548
|
+
* su `onSelect`; el hilo no lo puede sacar de su propia respuesta.
|
|
3549
|
+
*
|
|
3550
|
+
* `initialPhone` siembra SÓLO el teléfono: sin summary no hay nombre que sembrar y no se
|
|
3551
|
+
* inventa uno. El header cae al teléfono, como la fila de la lista.
|
|
3552
|
+
*/
|
|
3553
|
+
const [selectedName, setSelectedName] = useState(null);
|
|
1972
3554
|
const rootClass = className ? `wa-conversations ${className}` : "wa-conversations";
|
|
1973
3555
|
if (fetcher === void 0) return /* @__PURE__ */ jsx("div", {
|
|
1974
3556
|
className: rootClass,
|
|
@@ -1984,18 +3566,25 @@ function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
|
1984
3566
|
!anchored && (layout === "wide" || selectedPhone === null) && /* @__PURE__ */ jsx(ConversationList, {
|
|
1985
3567
|
fetcher,
|
|
1986
3568
|
selectedPhone,
|
|
1987
|
-
onSelect: (item) =>
|
|
3569
|
+
onSelect: (item) => {
|
|
3570
|
+
setSelectedPhone(item.phone);
|
|
3571
|
+
setSelectedName(item.name);
|
|
3572
|
+
}
|
|
1988
3573
|
}),
|
|
1989
3574
|
selectedPhone !== null ? /* @__PURE__ */ jsxs("div", {
|
|
1990
3575
|
className: "wa-conversations__thread",
|
|
1991
3576
|
children: [layout === "narrow" && !anchored && /* @__PURE__ */ jsx("button", {
|
|
1992
3577
|
type: "button",
|
|
1993
3578
|
className: "wa-conversations__back",
|
|
1994
|
-
onClick: () =>
|
|
3579
|
+
onClick: () => {
|
|
3580
|
+
setSelectedPhone(null);
|
|
3581
|
+
setSelectedName(null);
|
|
3582
|
+
},
|
|
1995
3583
|
children: "Volver"
|
|
1996
3584
|
}), /* @__PURE__ */ jsx(ConversationThread, {
|
|
1997
3585
|
fetcher,
|
|
1998
|
-
phone: selectedPhone
|
|
3586
|
+
phone: selectedPhone,
|
|
3587
|
+
displayName: selectedName
|
|
1999
3588
|
})]
|
|
2000
3589
|
}) : layout === "wide" && /* @__PURE__ */ jsx("p", {
|
|
2001
3590
|
className: "wa-conversations__empty",
|
|
@@ -2014,4 +3603,4 @@ function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
|
2014
3603
|
*/
|
|
2015
3604
|
const WA_CONVERSATIONS_TAG = "wa-conversations";
|
|
2016
3605
|
//#endregion
|
|
2017
|
-
export { ConversationList, ConversationThread, NARROW_MAX_WIDTH, WA_CONVERSATIONS_TAG, WaConversations, dedupeByWamid, isCtaLink, loadConversations, loadThread, normalizeWindowState, threadCtas, useContainerLayout, useConversations, useThread };
|
|
3606
|
+
export { ConversationList, ConversationThread, NARROW_MAX_WIDTH, REPLY_TEXT_MAX_LENGTH, WA_CONVERSATIONS_TAG, WaConversations, WaFetchError, dedupeByWamid, isCtaLink, loadConversations, loadThread, mergeThread, newClientMessageId, normalizeReplyMessage, normalizeWindowState, readSendError, releaseConversation, sendFailureCopy, sendReply, threadCtas, useComposer, useContainerLayout, useConversations, useThread };
|