chordia-ui 3.4.4 → 3.4.6

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.
@@ -1,9 +1,9 @@
1
1
  import { jsxs as i, jsx as o, Fragment as Ee } from "react/jsx-runtime";
2
- import { forwardRef as Ge, useRef as P, useState as f, useCallback as te, useEffect as ne, useImperativeHandle as We } from "react";
2
+ import { forwardRef as Ge, useRef as L, useState as f, useCallback as ne, useEffect as _, useImperativeHandle as We } from "react";
3
3
  import { FileSignal as Me, RotateCcw as ze, Pause as He, Play as Ae, RotateCw as Pe, ChevronDown as $e, AudioLines as oe, PauseCircle as Be, PlayCircle as je } from "lucide-react";
4
- function re(g) {
5
- const d = Math.floor(g / 60), p = Math.round(g % 60);
6
- return `${d}:${p.toString().padStart(2, "0")}`;
4
+ function re(p) {
5
+ const d = Math.floor(p / 60), y = Math.round(p % 60);
6
+ return `${d}:${y.toString().padStart(2, "0")}`;
7
7
  }
8
8
  const Le = {
9
9
  Agent: [
@@ -22,144 +22,144 @@ const Le = {
22
22
  { start: 0.6, end: 0.66 },
23
23
  { start: 0.74, end: 0.8 }
24
24
  ]
25
- }, D = [
25
+ }, E = [
26
26
  { speaker: "Agent", type: "agent", time: "00:04", text: "Thanks for calling Miles Point S Pensau. This is Steve. How can I help you?" },
27
27
  { speaker: "Customer", type: "customer", time: "00:12", text: "Hi, Steve. This is Sandra with Botai Catering." },
28
28
  { speaker: "Agent", type: "agent", time: "00:18", text: "Hello. How are you?" },
29
29
  { speaker: "Customer", type: "customer", time: "00:20", text: "I'm doing really good. Hey. I brought my vans in last week, and I call it a beeping van, the one that beeps when you back up. Makes the crunchy noise. So I just took it on Saturday after, I think I had the, the Miles. I picked it up on Saturday morning, and I went to an event. So So I don't know if it's the tire or something, but makes it a little crunchy noise. Sometimes when I do the brake, but only if I turn the wheel too." },
30
30
  { speaker: "Agent", type: "agent", time: "00:21", text: "Oh, interesting. Okay. Can you swing by with it one of these days?" }
31
31
  ], _e = [1, 1.25, 1.5, 2];
32
- function ie(g) {
33
- if (!g)
32
+ function ie(p) {
33
+ if (!p)
34
34
  return 0;
35
- const d = g.split(":").map(Number);
35
+ const d = p.split(":").map(Number);
36
36
  return (d[0] || 0) * 60 + (d[1] || 0);
37
37
  }
38
- const Ke = Ge(function({
38
+ const qe = Ge(function({
39
39
  audioUrl: d,
40
- timelineSegments: p = [],
41
- durationSeconds: R = 0,
40
+ timelineSegments: y = [],
41
+ durationSeconds: G = 0,
42
42
  // Parent-managed audio props (optional — if not provided, component manages its own audio)
43
43
  currentTimeSeconds: ae,
44
- timelinePlaying: $,
44
+ timelinePlaying: X,
45
45
  playbackRate: se,
46
- onSeek: B,
46
+ onSeek: V,
47
47
  onTogglePlay: S,
48
- onSeekBack: j,
49
- onSeekForward: L,
50
- onSetPlaybackRate: _,
51
- audioRef: X,
48
+ onSeekBack: Y,
49
+ onSeekForward: q,
50
+ onSetPlaybackRate: K,
51
+ audioRef: Z,
52
52
  // Speaker names
53
- agentName: T = "Agent",
54
- customerName: E = "Customer",
53
+ agentName: W = "Agent",
54
+ customerName: M = "Customer",
55
55
  // Transcript props
56
- transcript: y,
56
+ transcript: m,
57
57
  highlightedTurns: le = /* @__PURE__ */ new Set(),
58
- activeTurnIndex: Y,
58
+ activeTurnIndex: w,
59
59
  activeDemoIndex: ce = 1,
60
60
  turnObservations: de = {},
61
- setExpandedSignals: G,
62
- onTurnPlayPause: q
61
+ setExpandedSignals: z,
62
+ onTurnPlayPause: J
63
63
  }, ue) {
64
- var ee;
65
- const K = P(null), u = P(null), k = P(null), [V, m] = f(!1), [W, Z] = f(0), [he, fe] = f(0), [ge, pe] = f(1), [w, ye] = f(null), [me, ve] = f(1), [be, I] = f(!1), [ke, J] = f(!1), [N, M] = f(ce), s = !!X, x = !d, l = d && !s, F = x ? be : s ? $ ?? !1 : V, xe = x ? w ?? 0 : s ? ae ?? 0 : W, z = x ? me : s ? se ?? 1 : ge, H = x ? R || 156 : s ? R : he || R || 0, A = te(() => {
64
+ var te;
65
+ const H = L(null), u = L(null), x = L(null), [N, v] = f(!1), [A, Q] = f(0), [he, fe] = f(0), [ge, pe] = f(1), [I, ye] = f(null), [me, ve] = f(1), [be, C] = f(!1), [ke, O] = f(!1), [D, P] = f(ce), s = !!Z, F = !d, l = d && !s, g = F ? be : s ? X ?? !1 : N, xe = F ? I ?? 0 : s ? ae ?? 0 : A, $ = F ? me : s ? se ?? 1 : ge, B = F ? G || 156 : s ? G : he || G || 0, j = ne(() => {
66
66
  const e = () => {
67
67
  const t = u.current;
68
- t && Z(t.currentTime), k.current = requestAnimationFrame(e);
68
+ t && Q(t.currentTime), x.current = requestAnimationFrame(e);
69
69
  };
70
- k.current = requestAnimationFrame(e);
71
- }, []), v = te(() => {
72
- k.current && (cancelAnimationFrame(k.current), k.current = null);
70
+ x.current = requestAnimationFrame(e);
71
+ }, []), b = ne(() => {
72
+ x.current && (cancelAnimationFrame(x.current), x.current = null);
73
73
  }, []);
74
- ne(() => () => v(), [v]), ne(() => {
74
+ _(() => () => b(), [b]), _(() => {
75
75
  if (!l)
76
76
  return;
77
77
  const e = u.current;
78
78
  if (!e)
79
79
  return;
80
80
  const t = () => fe(e.duration || 0), n = () => {
81
- m(!1), v();
81
+ v(!1), b();
82
82
  };
83
83
  return e.addEventListener("loadedmetadata", t), e.addEventListener("ended", n), () => {
84
84
  e.removeEventListener("loadedmetadata", t), e.removeEventListener("ended", n);
85
85
  };
86
- }, [l, v]);
87
- const Q = (e) => {
88
- for (let t = D.length - 1; t >= 0; t--) {
89
- const n = ie(D[t].time);
86
+ }, [l, b]);
87
+ const U = (e) => {
88
+ for (let t = E.length - 1; t >= 0; t--) {
89
+ const n = ie(E[t].time);
90
90
  if (e >= n)
91
91
  return t;
92
92
  }
93
93
  return 0;
94
- }, b = (e) => {
95
- const n = Math.max(0, Math.min(e, H || 156));
94
+ }, k = (e) => {
95
+ const n = Math.max(0, Math.min(e, B || 156));
96
96
  if (l) {
97
97
  const r = u.current;
98
- r && (r.currentTime = n), Z(n);
98
+ r && (r.currentTime = n), Q(n);
99
99
  } else
100
- s && B && B(n);
101
- ye(n), M(Q(n));
100
+ s && V && V(n);
101
+ ye(n), P(U(n));
102
102
  }, Fe = () => {
103
103
  if (l) {
104
104
  const e = u.current;
105
105
  if (!e)
106
106
  return;
107
- V ? (e.pause(), v(), m(!1)) : e.play().then(() => {
108
- m(!0), A();
107
+ N ? (e.pause(), b(), v(!1)) : e.play().then(() => {
108
+ v(!0), j();
109
109
  }).catch(() => {
110
110
  });
111
111
  } else
112
- s && S ? S() : I((e) => !e);
112
+ s && S ? S() : C((e) => !e);
113
113
  }, Se = () => {
114
- s && j ? j() : b(Math.max(0, (l ? W : w ?? 0) - 10));
114
+ s && Y ? Y() : k(Math.max(0, (l ? A : I ?? 0) - 10));
115
115
  }, we = () => {
116
- s && L ? L() : b(Math.min(H || 156, (l ? W : w ?? 0) + 10));
116
+ s && q ? q() : k(Math.min(B || 156, (l ? A : I ?? 0) + 10));
117
117
  }, Ie = (e) => {
118
118
  if (l) {
119
119
  const t = u.current;
120
120
  t && (t.playbackRate = e), pe(e);
121
121
  } else
122
- s && _ && _(e);
123
- ve(e), J(!1);
122
+ s && K && K(e);
123
+ ve(e), O(!1);
124
124
  };
125
125
  We(ue, () => ({
126
126
  seekTo: (e) => {
127
- if (b(e), s)
128
- !$ && S && S();
127
+ if (k(e), s)
128
+ !X && S && S();
129
129
  else if (l) {
130
130
  const n = u.current;
131
131
  n && n.play().then(() => {
132
- m(!0), A();
132
+ v(!0), j();
133
133
  }).catch(() => {
134
134
  });
135
135
  } else
136
- I(!0);
137
- const t = Q(e);
138
- M(t), setTimeout(() => {
136
+ C(!0);
137
+ const t = U(e);
138
+ P(t), setTimeout(() => {
139
139
  var r;
140
- const n = (r = K.current) == null ? void 0 : r.children;
140
+ const n = (r = H.current) == null ? void 0 : r.children;
141
141
  n != null && n[t] && n[t].scrollIntoView({ behavior: "smooth", block: "nearest" });
142
142
  }, 50);
143
143
  }
144
144
  }));
145
145
  const Ce = (e) => {
146
146
  var t;
147
- if (N === e && F) {
147
+ if (D === e && g) {
148
148
  if (l) {
149
149
  const n = u.current;
150
- n && n.pause(), v(), m(!1);
150
+ n && n.pause(), b(), v(!1);
151
151
  }
152
- I(!1);
152
+ C(!1);
153
153
  } else {
154
- const n = ie((t = D[e]) == null ? void 0 : t.time);
155
- if (M(e), b(n), l) {
154
+ const n = ie((t = E[e]) == null ? void 0 : t.time);
155
+ if (P(e), k(n), l) {
156
156
  const r = u.current;
157
157
  r && (r.currentTime = n, r.play().then(() => {
158
- m(!0), A();
158
+ v(!0), j();
159
159
  }).catch(() => {
160
160
  }));
161
161
  }
162
- I(!0);
162
+ C(!0);
163
163
  }
164
164
  }, De = (e, t) => {
165
165
  if (e == null)
@@ -169,26 +169,39 @@ const Ke = Ge(function({
169
169
  return `${a.toString().padStart(2, "0")}:${c.toString().padStart(2, "0")}`;
170
170
  };
171
171
  return `${n(e)}–${t != null ? n(t) : n(e)}`;
172
- }, O = (ee = y == null ? void 0 : y.messages) != null && ee.length ? y.messages.map((e, t) => {
172
+ }, R = (te = m == null ? void 0 : m.messages) != null && te.length ? m.messages.map((e, t) => {
173
173
  var n, r;
174
174
  return {
175
- actor: e.actor === "agent" ? ((n = y.actor_map) == null ? void 0 : n.agent) || "Agent" : ((r = y.actor_map) == null ? void 0 : r.customer) || "Customer",
175
+ actor: e.actor === "agent" ? ((n = m.actor_map) == null ? void 0 : n.agent) || "Agent" : ((r = m.actor_map) == null ? void 0 : r.customer) || "Customer",
176
176
  actorType: e.actor === "agent" ? "agent" : "customer",
177
177
  text: e.text || "",
178
178
  timeRange: De(e.start ?? e.start_ms, e.end ?? e.end_ms),
179
179
  isHighlighted: le.has(t),
180
- highlightColor: F && Y === t ? e.actor === "agent" ? "var(--rail-outcome)" : "var(--rail-discovery)" : void 0,
180
+ highlightColor: g && w === t ? e.actor === "agent" ? "var(--rail-outcome)" : "var(--rail-discovery)" : void 0,
181
181
  observations: (de[t] || []).map((a) => ({
182
182
  ...a,
183
183
  onClick: () => {
184
- G == null || G((c) => /* @__PURE__ */ new Set([...c, a.signalKey])), setTimeout(() => {
184
+ z == null || z((c) => /* @__PURE__ */ new Set([...c, a.signalKey])), setTimeout(() => {
185
185
  const c = document.getElementById(`signal-${a.signalKey}`);
186
186
  c && c.scrollIntoView({ behavior: "smooth", block: "nearest" });
187
187
  }, 100);
188
188
  }
189
189
  }))
190
190
  };
191
- }) : null, U = x ? w ?? 0 : xe, h = H || 156, C = h > 0 ? U / h * 100 : 0, Re = Math.round(U);
191
+ }) : null;
192
+ _(() => {
193
+ if (!g)
194
+ return;
195
+ const e = R ? w : D;
196
+ if (e == null || e < 0)
197
+ return;
198
+ const t = H.current;
199
+ if (!t)
200
+ return;
201
+ const n = t.children;
202
+ n != null && n[e] && n[e].scrollIntoView({ behavior: "smooth", block: "nearest" });
203
+ }, [w, D, g, R]);
204
+ const ee = F ? I ?? 0 : xe, h = B || 156, T = h > 0 ? ee / h * 100 : 0, Re = Math.round(ee);
192
205
  return /* @__PURE__ */ i("div", { style: {
193
206
  display: "flex",
194
207
  flexDirection: "column",
@@ -234,9 +247,9 @@ const Ke = Ge(function({
234
247
  color: "var(--Grey-Strong, #2E3236)",
235
248
  lineHeight: 1.2
236
249
  }, children: [
237
- T,
250
+ W,
238
251
  " / ",
239
- E
252
+ M
240
253
  ] }),
241
254
  /* @__PURE__ */ i("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
242
255
  /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 400, color: "var(--Grey-Muted, #808183)", lineHeight: 1.2 }, children: "10" }),
@@ -252,7 +265,7 @@ const Ke = Ge(function({
252
265
  display: "flex",
253
266
  alignItems: "center",
254
267
  justifyContent: "center"
255
- }, children: F ? /* @__PURE__ */ o(He, { size: 14, color: "#FFF", fill: "#FFF" }) : /* @__PURE__ */ o(Ae, { size: 14, color: "#FFF", fill: "#FFF", strokeWidth: 1.5, style: { marginLeft: 2 } }) }),
268
+ }, children: g ? /* @__PURE__ */ o(He, { size: 14, color: "#FFF", fill: "#FFF" }) : /* @__PURE__ */ o(Ae, { size: 14, color: "#FFF", fill: "#FFF", strokeWidth: 1.5, style: { marginLeft: 2 } }) }),
256
269
  /* @__PURE__ */ o("button", { onClick: we, style: { background: "none", border: "none", cursor: "pointer", padding: 0, display: "flex", alignItems: "center" }, children: /* @__PURE__ */ o(Pe, { size: 20, color: "#808183", strokeWidth: 1.5 }) }),
257
270
  /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 400, color: "var(--Grey-Muted, #808183)", lineHeight: 1.2 }, children: "10" })
258
271
  ] }),
@@ -260,7 +273,7 @@ const Ke = Ge(function({
260
273
  /* @__PURE__ */ i(
261
274
  "button",
262
275
  {
263
- onClick: () => J((e) => !e),
276
+ onClick: () => O((e) => !e),
264
277
  style: {
265
278
  background: "var(--Grey-White, #FFF)",
266
279
  border: "1px solid var(--Grey-absent, #D9D9D9)",
@@ -280,7 +293,7 @@ const Ke = Ge(function({
280
293
  gap: 4
281
294
  },
282
295
  children: [
283
- z,
296
+ $,
284
297
  "x",
285
298
  /* @__PURE__ */ o($e, { size: 12, color: "#808183" })
286
299
  ]
@@ -307,10 +320,10 @@ const Ke = Ge(function({
307
320
  width: "100%",
308
321
  padding: "8px 12px",
309
322
  border: "none",
310
- background: z === e ? "var(--surface-hover, #F3F7F7)" : "var(--Grey-White, #FFF)",
323
+ background: $ === e ? "var(--surface-hover, #F3F7F7)" : "var(--Grey-White, #FFF)",
311
324
  cursor: "pointer",
312
325
  fontSize: 13,
313
- fontWeight: z === e ? 600 : 400,
326
+ fontWeight: $ === e ? 600 : 400,
314
327
  color: "var(--Grey-Strong, #2E3236)",
315
328
  fontFamily: "var(--font-sans)",
316
329
  textAlign: "left"
@@ -339,7 +352,7 @@ const Ke = Ge(function({
339
352
  {
340
353
  onClick: (e) => {
341
354
  const t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = Math.max(0, Math.min(1, n / t.width));
342
- b(r * h);
355
+ k(r * h);
343
356
  },
344
357
  style: {
345
358
  flex: 1,
@@ -364,7 +377,7 @@ const Ke = Ge(function({
364
377
  left: 0,
365
378
  top: "50%",
366
379
  transform: "translateY(-50%)",
367
- width: `${C}%`,
380
+ width: `${T}%`,
368
381
  height: 4,
369
382
  borderRadius: 2,
370
383
  background: "var(--Green-Primary, #00925F)",
@@ -380,7 +393,7 @@ const Ke = Ge(function({
380
393
  xmlns: "http://www.w3.org/2000/svg",
381
394
  style: {
382
395
  position: "absolute",
383
- left: `${C}%`,
396
+ left: `${T}%`,
384
397
  top: "50%",
385
398
  transform: "translate(-50%, -50%)",
386
399
  pointerEvents: "none"
@@ -401,8 +414,8 @@ const Ke = Ge(function({
401
414
  )
402
415
  ] }),
403
416
  /* @__PURE__ */ i("div", { style: { position: "relative", paddingBottom: 30, cursor: "pointer" }, children: [
404
- [T, E].map((e, t) => {
405
- const n = t === 0, r = p != null && p.length ? p.filter((a) => n ? a.actor === T : a.actor === E).map((a) => ({
417
+ [W, M].map((e, t) => {
418
+ const n = t === 0, r = y != null && y.length ? y.filter((a) => n ? a.actor === W : a.actor === M).map((a) => ({
406
419
  start: h > 0 ? a.startTime / h : 0,
407
420
  end: h > 0 ? a.endTime / h : 0
408
421
  })) : Le[n ? "Agent" : "Customer"] || [];
@@ -426,7 +439,7 @@ const Ke = Ge(function({
426
439
  {
427
440
  onClick: (a) => {
428
441
  const c = a.currentTarget.getBoundingClientRect(), Te = Math.max(0, Math.min(1, (a.clientX - c.left) / c.width));
429
- b(Te * h);
442
+ k(Te * h);
430
443
  },
431
444
  style: {
432
445
  flex: 1,
@@ -471,7 +484,7 @@ const Ke = Ge(function({
471
484
  }, children: [
472
485
  /* @__PURE__ */ o("div", { style: {
473
486
  position: "absolute",
474
- left: `${C}%`,
487
+ left: `${T}%`,
475
488
  top: 0,
476
489
  height: 44,
477
490
  transform: "translateX(-50%)",
@@ -480,7 +493,7 @@ const Ke = Ge(function({
480
493
  } }),
481
494
  /* @__PURE__ */ o("div", { style: {
482
495
  position: "absolute",
483
- left: `${C}%`,
496
+ left: `${T}%`,
484
497
  bottom: 0,
485
498
  transform: "translateX(-50%)",
486
499
  background: "var(--Grey-Strong, #2E3236)",
@@ -495,7 +508,7 @@ const Ke = Ge(function({
495
508
  ] })
496
509
  ] }),
497
510
  l && /* @__PURE__ */ o("audio", { ref: u, preload: "auto", style: { display: "none" }, children: /* @__PURE__ */ o("source", { src: d, type: "audio/mpeg" }) }),
498
- s && d && /* @__PURE__ */ o("audio", { ref: X, preload: "auto", style: { display: "none" }, children: /* @__PURE__ */ o("source", { src: d, type: "audio/mpeg" }) })
511
+ s && d && /* @__PURE__ */ o("audio", { ref: Z, preload: "auto", style: { display: "none" }, children: /* @__PURE__ */ o("source", { src: d, type: "audio/mpeg" }) })
499
512
  ] })
500
513
  ] }),
501
514
  /* @__PURE__ */ i("div", { style: {
@@ -513,18 +526,18 @@ const Ke = Ge(function({
513
526
  color: "var(--Grey-Strong, #2E3236)",
514
527
  lineHeight: 1.2
515
528
  }, children: "Transcript" }) }),
516
- /* @__PURE__ */ o("div", { id: "transcript-container", ref: K, style: {
529
+ /* @__PURE__ */ o("div", { id: "transcript-container", ref: H, style: {
517
530
  display: "flex",
518
531
  flexDirection: "column",
519
532
  maxHeight: 600,
520
533
  overflowY: "auto"
521
- }, children: (O || D.map((e) => ({
534
+ }, children: (R || E.map((e) => ({
522
535
  actor: e.speaker,
523
536
  actorType: e.type,
524
537
  text: e.text,
525
538
  timeRange: e.time
526
539
  }))).map((e, t) => {
527
- const n = !!O, r = n ? F && Y === t : t === N && F, a = (e.actorType || e.type) === "customer";
540
+ const n = !!R, r = n ? g && w === t : t === D && g, a = (e.actorType || e.type) === "customer";
528
541
  return /* @__PURE__ */ i("div", { style: {
529
542
  display: "flex",
530
543
  padding: 16,
@@ -566,7 +579,7 @@ const Ke = Ge(function({
566
579
  "button",
567
580
  {
568
581
  onClick: () => {
569
- n && q ? q(e, t) : Ce(t);
582
+ n && J ? J(e, t) : Ce(t);
570
583
  },
571
584
  style: {
572
585
  background: "none",
@@ -595,6 +608,6 @@ const Ke = Ge(function({
595
608
  ] });
596
609
  });
597
610
  export {
598
- Ke as U
611
+ qe as U
599
612
  };
600
613
  //# sourceMappingURL=UpdatedInteractionRecording.es.js.map