@fencyai/react 0.1.176 → 0.1.177

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/dist/index.js CHANGED
@@ -1,78 +1,79 @@
1
- import { jsxs as y, jsx as o, Fragment as E } from "react/jsx-runtime";
2
- import { createStream as ge, isStreamTimeoutEvent as he, isStreamNotFoundEvent as fe, isAgentTaskProgressItemUpdatedEvent as Se, createAgentTask as xe } from "@fencyai/js";
3
- import { createContext as ke, useState as I, useRef as A, useEffect as F, useCallback as z, useContext as be, useMemo as P } from "react";
4
- import { motion as C, useInView as ve, AnimatePresence as Te } from "motion/react";
5
- import we from "react-markdown";
6
- import { Prism as ce } from "react-syntax-highlighter";
7
- import Ce from "remark-gfm";
8
- import './assets/index.css';const de = ke(
1
+ import { jsxs as g, jsx as o, Fragment as F } from "react/jsx-runtime";
2
+ import { createStream as xe, isStreamTimeoutEvent as be, isStreamNotFoundEvent as ke, isAgentTaskProgressItemUpdatedEvent as ve, createAgentTask as Ce } from "@fencyai/js";
3
+ import we, { createContext as Ie, useState as E, useRef as D, useEffect as P, useCallback as O, useContext as Ee, useMemo as z } from "react";
4
+ import { z as a } from "zod";
5
+ import { motion as I, useInView as Me, AnimatePresence as Re } from "motion/react";
6
+ import Fe from "react-markdown";
7
+ import { Prism as ue } from "react-syntax-highlighter";
8
+ import Ae from "remark-gfm";
9
+ import './assets/index.css';const me = Ie(
9
10
  void 0
10
11
  );
11
- async function Ie(e, r) {
12
- const t = e.getReader();
13
- let n;
14
- for (; !(n = await t.read()).done; )
15
- r(n.value);
12
+ async function Pe(e, r) {
13
+ const n = e.getReader();
14
+ let t;
15
+ for (; !(t = await n.read()).done; )
16
+ r(t.value);
16
17
  }
17
- function Ee(e) {
18
- let r, t, n, i = !1;
19
- return function(a) {
20
- r === void 0 ? (r = a, t = 0, n = -1) : r = Re(r, a);
21
- const s = r.length;
18
+ function De(e) {
19
+ let r, n, t, i = !1;
20
+ return function(s) {
21
+ r === void 0 ? (r = s, n = 0, t = -1) : r = ze(r, s);
22
+ const c = r.length;
22
23
  let m = 0;
23
- for (; t < s; ) {
24
- i && (r[t] === 10 && (m = ++t), i = !1);
25
- let p = -1;
26
- for (; t < s && p === -1; ++t)
27
- switch (r[t]) {
24
+ for (; n < c; ) {
25
+ i && (r[n] === 10 && (m = ++n), i = !1);
26
+ let y = -1;
27
+ for (; n < c && y === -1; ++n)
28
+ switch (r[n]) {
28
29
  case 58:
29
- n === -1 && (n = t - m);
30
+ t === -1 && (t = n - m);
30
31
  break;
31
32
  case 13:
32
33
  i = !0;
33
34
  case 10:
34
- p = t;
35
+ y = n;
35
36
  break;
36
37
  }
37
- if (p === -1)
38
+ if (y === -1)
38
39
  break;
39
- e(r.subarray(m, p), n), m = t, n = -1;
40
+ e(r.subarray(m, y), t), m = n, t = -1;
40
41
  }
41
- m === s ? r = void 0 : m !== 0 && (r = r.subarray(m), t -= m);
42
+ m === c ? r = void 0 : m !== 0 && (r = r.subarray(m), n -= m);
42
43
  };
43
44
  }
44
- function Me(e, r, t) {
45
- let n = Z();
45
+ function Le(e, r, n) {
46
+ let t = re();
46
47
  const i = new TextDecoder();
47
- return function(a, s) {
48
- if (a.length === 0)
49
- t == null || t(n), n = Z();
50
- else if (s > 0) {
51
- const m = i.decode(a.subarray(0, s)), p = s + (a[s + 1] === 32 ? 2 : 1), c = i.decode(a.subarray(p));
48
+ return function(s, c) {
49
+ if (s.length === 0)
50
+ n == null || n(t), t = re();
51
+ else if (c > 0) {
52
+ const m = i.decode(s.subarray(0, c)), y = c + (s[c + 1] === 32 ? 2 : 1), d = i.decode(s.subarray(y));
52
53
  switch (m) {
53
54
  case "data":
54
- n.data = n.data ? n.data + `
55
- ` + c : c;
55
+ t.data = t.data ? t.data + `
56
+ ` + d : d;
56
57
  break;
57
58
  case "event":
58
- n.event = c;
59
+ t.event = d;
59
60
  break;
60
61
  case "id":
61
- e(n.id = c);
62
+ e(t.id = d);
62
63
  break;
63
64
  case "retry":
64
- const d = parseInt(c, 10);
65
- isNaN(d) || r(n.retry = d);
65
+ const u = parseInt(d, 10);
66
+ isNaN(u) || r(t.retry = u);
66
67
  break;
67
68
  }
68
69
  }
69
70
  };
70
71
  }
71
- function Re(e, r) {
72
- const t = new Uint8Array(e.length + r.length);
73
- return t.set(e), t.set(r, e.length), t;
72
+ function ze(e, r) {
73
+ const n = new Uint8Array(e.length + r.length);
74
+ return n.set(e), n.set(r, e.length), n;
74
75
  }
75
- function Z() {
76
+ function re() {
76
77
  return {
77
78
  data: "",
78
79
  event: "",
@@ -80,68 +81,68 @@ function Z() {
80
81
  retry: void 0
81
82
  };
82
83
  }
83
- var Fe = function(e, r) {
84
- var t = {};
85
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
84
+ var We = function(e, r) {
85
+ var n = {};
86
+ for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && r.indexOf(t) < 0 && (n[t] = e[t]);
86
87
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
87
- for (var i = 0, n = Object.getOwnPropertySymbols(e); i < n.length; i++)
88
- r.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[i]) && (t[n[i]] = e[n[i]]);
89
- return t;
88
+ for (var i = 0, t = Object.getOwnPropertySymbols(e); i < t.length; i++)
89
+ r.indexOf(t[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[i]) && (n[t[i]] = e[t[i]]);
90
+ return n;
90
91
  };
91
- const N = "text/event-stream", Ae = 1e3, ee = "last-event-id";
92
- function Le(e, r) {
93
- var { signal: t, headers: n, onopen: i, onmessage: l, onclose: a, onerror: s, openWhenHidden: m, fetch: p } = r, c = Fe(r, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
- return new Promise((d, u) => {
95
- const g = Object.assign({}, n);
96
- g.accept || (g.accept = N);
97
- let h;
98
- function f() {
99
- h.abort(), document.hidden || x();
92
+ const $ = "text/event-stream", Ne = 1e3, te = "last-event-id";
93
+ function Oe(e, r) {
94
+ var { signal: n, headers: t, onopen: i, onmessage: l, onclose: s, onerror: c, openWhenHidden: m, fetch: y } = r, d = We(r, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
95
+ return new Promise((u, p) => {
96
+ const h = Object.assign({}, t);
97
+ h.accept || (h.accept = $);
98
+ let f;
99
+ function S() {
100
+ f.abort(), document.hidden || w();
100
101
  }
101
- m || document.addEventListener("visibilitychange", f);
102
- let k = Ae, b = 0;
102
+ m || document.addEventListener("visibilitychange", S);
103
+ let x = Ne, b = 0;
103
104
  function v() {
104
- document.removeEventListener("visibilitychange", f), window.clearTimeout(b), h.abort();
105
+ document.removeEventListener("visibilitychange", S), window.clearTimeout(b), f.abort();
105
106
  }
106
- t == null || t.addEventListener("abort", () => {
107
- v(), d();
107
+ n == null || n.addEventListener("abort", () => {
108
+ v(), u();
108
109
  });
109
- const T = p ?? window.fetch, w = i ?? Pe;
110
- async function x() {
111
- var D;
112
- h = new AbortController();
110
+ const C = y ?? window.fetch, M = i ?? Be;
111
+ async function w() {
112
+ var k;
113
+ f = new AbortController();
113
114
  try {
114
- const W = await T(e, Object.assign(Object.assign({}, c), { headers: g, signal: h.signal }));
115
- await w(W), await Ie(W.body, Ee(Me((R) => {
116
- R ? g[ee] = R : delete g[ee];
117
- }, (R) => {
118
- k = R;
119
- }, l))), a == null || a(), v(), d();
115
+ const W = await C(e, Object.assign(Object.assign({}, d), { headers: h, signal: f.signal }));
116
+ await M(W), await Pe(W.body, De(Le((A) => {
117
+ A ? h[te] = A : delete h[te];
118
+ }, (A) => {
119
+ x = A;
120
+ }, l))), s == null || s(), v(), u();
120
121
  } catch (W) {
121
- if (!h.signal.aborted)
122
+ if (!f.signal.aborted)
122
123
  try {
123
- const R = (D = s == null ? void 0 : s(W)) !== null && D !== void 0 ? D : k;
124
- window.clearTimeout(b), b = window.setTimeout(x, R);
125
- } catch (R) {
126
- v(), u(R);
124
+ const A = (k = c == null ? void 0 : c(W)) !== null && k !== void 0 ? k : x;
125
+ window.clearTimeout(b), b = window.setTimeout(w, A);
126
+ } catch (A) {
127
+ v(), p(A);
127
128
  }
128
129
  }
129
130
  }
130
- x();
131
+ w();
131
132
  });
132
133
  }
133
- function Pe(e) {
134
+ function Be(e) {
134
135
  const r = e.headers.get("content-type");
135
- if (!(r != null && r.startsWith(N)))
136
- throw new Error(`Expected content-type to be ${N}, Actual: ${r}`);
136
+ if (!(r != null && r.startsWith($)))
137
+ throw new Error(`Expected content-type to be ${$}, Actual: ${r}`);
137
138
  }
138
- function re(e) {
139
- const r = atob(e), t = new Uint8Array(r.length);
140
- for (let n = 0; n < r.length; n++)
141
- t[n] = r.charCodeAt(n);
142
- return new TextDecoder("utf-8").decode(t);
139
+ function ne(e) {
140
+ const r = atob(e), n = new Uint8Array(r.length);
141
+ for (let t = 0; t < r.length; t++)
142
+ n[t] = r.charCodeAt(t);
143
+ return new TextDecoder("utf-8").decode(n);
143
144
  }
144
- function De() {
145
+ function je() {
145
146
  return `
146
147
  var connections = new Map();
147
148
 
@@ -287,10 +288,10 @@ self.onmessage = function (e) {
287
288
  };
288
289
  `.trim();
289
290
  }
290
- function ne(e) {
291
+ function oe(e) {
291
292
  return e instanceof Error ? e.message : typeof e == "string" ? e : "Unknown stream error";
292
293
  }
293
- class We {
294
+ class $e {
294
295
  constructor(r) {
295
296
  this.activeConnections = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.worker = null, this.workerBlobUrl = null, this.workerSupported = !1, this.fency = r, this.tryInitWorker();
296
297
  }
@@ -298,28 +299,28 @@ class We {
298
299
  try {
299
300
  if (typeof Worker > "u" || typeof Blob > "u" || typeof URL > "u" || typeof URL.createObjectURL != "function" || typeof ReadableStream > "u")
300
301
  return;
301
- const r = De(), t = new Blob([r], { type: "application/javascript" }), n = URL.createObjectURL(t), i = new Worker(n);
302
+ const r = je(), n = new Blob([r], { type: "application/javascript" }), t = URL.createObjectURL(n), i = new Worker(t);
302
303
  i.onmessage = (l) => {
303
304
  this.handleWorkerMessage(l.data);
304
305
  }, i.onerror = (l) => {
305
306
  console.error("Fency stream worker error:", l.message);
306
- }, this.worker = i, this.workerBlobUrl = n, this.workerSupported = !0;
307
+ }, this.worker = i, this.workerBlobUrl = t, this.workerSupported = !0;
307
308
  } catch {
308
309
  this.workerSupported = !1, this.worker = null, this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
309
310
  }
310
311
  }
311
312
  handleWorkerMessage(r) {
312
313
  if (!r || typeof r != "object") return;
313
- const t = r;
314
- switch (t.type) {
314
+ const n = r;
315
+ switch (n.type) {
315
316
  case "message":
316
- if (t.data && t.streamId) {
317
- const n = re(t.data);
318
- this.broadcast(n, t.streamId);
317
+ if (n.data && n.streamId) {
318
+ const t = ne(n.data);
319
+ this.broadcast(t, n.streamId);
319
320
  }
320
321
  break;
321
322
  case "error":
322
- t.streamId && (this.activeConnections.delete(t.streamId), this.broadcastError(t.streamId, t.error));
323
+ n.streamId && (this.activeConnections.delete(n.streamId), this.broadcastError(n.streamId, n.error));
323
324
  break;
324
325
  }
325
326
  }
@@ -328,50 +329,50 @@ class We {
328
329
  * Creates new connections and removes old ones.
329
330
  */
330
331
  updateStreams(r) {
331
- r.forEach((n) => {
332
- const i = n.stream.id;
333
- this.activeConnections.has(i) || this.connectStream(n);
332
+ r.forEach((t) => {
333
+ const i = t.stream.id;
334
+ this.activeConnections.has(i) || this.connectStream(t);
334
335
  });
335
- const t = new Set(r.map((n) => n.stream.id));
336
- this.activeConnections.forEach((n, i) => {
337
- t.has(i) || (n.abort(), this.activeConnections.delete(i));
336
+ const n = new Set(r.map((t) => t.stream.id));
337
+ this.activeConnections.forEach((t, i) => {
338
+ n.has(i) || (t.abort(), this.activeConnections.delete(i));
338
339
  });
339
340
  }
340
341
  connectStream(r) {
341
342
  this.workerSupported && this.worker ? this.connectStreamInWorker(r) : this.connectStreamOnMainThread(r);
342
343
  }
343
344
  connectStreamInWorker(r) {
344
- const t = r.stream.id, n = `${this.fency.baseUrl}/sse/streams/${t}`, i = new AbortController(), l = {
345
- accept: N,
345
+ const n = r.stream.id, t = `${this.fency.baseUrl}/sse/streams/${n}`, i = new AbortController(), l = {
346
+ accept: $,
346
347
  "X-Fency-Publishable-Key": this.fency.publishableKey,
347
348
  "X-Fency-Stream-Token": r.stream.token
348
349
  };
349
- this.activeConnections.set(t, {
350
+ this.activeConnections.set(n, {
350
351
  abort: () => {
351
- var a;
352
- i.abort(), (a = this.worker) == null || a.postMessage({ command: "disconnect", streamId: t });
352
+ var s;
353
+ i.abort(), (s = this.worker) == null || s.postMessage({ command: "disconnect", streamId: n });
353
354
  }
354
- }), this.startWorkerStream(t, n, l, i);
355
+ }), this.startWorkerStream(n, t, l, i);
355
356
  }
356
- async startWorkerStream(r, t, n, i) {
357
+ async startWorkerStream(r, n, t, i) {
357
358
  const l = this.worker;
358
359
  if (!l) return;
359
- const a = (s) => {
360
- i.signal.aborted || (this.activeConnections.delete(r), this.broadcastError(r, s));
360
+ const s = (c) => {
361
+ i.signal.aborted || (this.activeConnections.delete(r), this.broadcastError(r, c));
361
362
  };
362
363
  try {
363
- const s = await fetch(t, {
364
+ const c = await fetch(n, {
364
365
  method: "GET",
365
- headers: n,
366
+ headers: t,
366
367
  signal: i.signal
367
368
  });
368
- if (!s.ok) {
369
- s.status >= 400 && s.status < 500 && s.status !== 429 ? a(`Client error ${s.status}`) : a(`HTTP ${s.status}`);
369
+ if (!c.ok) {
370
+ c.status >= 400 && c.status < 500 && c.status !== 429 ? s(`Client error ${c.status}`) : s(`HTTP ${c.status}`);
370
371
  return;
371
372
  }
372
- const m = s.body;
373
+ const m = c.body;
373
374
  if (!m) {
374
- a("No response body");
375
+ s("No response body");
375
376
  return;
376
377
  }
377
378
  if (!this.activeConnections.has(r)) {
@@ -383,36 +384,36 @@ class We {
383
384
  { command: "start", streamId: r, readableStream: m },
384
385
  [m]
385
386
  );
386
- } catch (s) {
387
+ } catch (c) {
387
388
  if (i.signal.aborted) return;
388
- a(ne(s));
389
+ s(oe(c));
389
390
  }
390
391
  }
391
392
  connectStreamOnMainThread(r) {
392
- const t = r.stream.id, n = new AbortController();
393
- this.activeConnections.set(t, {
394
- abort: () => n.abort()
393
+ const n = r.stream.id, t = new AbortController();
394
+ this.activeConnections.set(n, {
395
+ abort: () => t.abort()
395
396
  });
396
- const i = `${this.fency.baseUrl}/sse/streams/${t}`, l = {
397
+ const i = `${this.fency.baseUrl}/sse/streams/${n}`, l = {
397
398
  "X-Fency-Publishable-Key": this.fency.publishableKey,
398
399
  "X-Fency-Stream-Token": r.stream.token
399
400
  };
400
- Le(i, {
401
+ Oe(i, {
401
402
  headers: l,
402
- signal: n.signal,
403
+ signal: t.signal,
403
404
  openWhenHidden: !0,
404
- onopen: async (a) => {
405
- if (!a.ok && a.status >= 400 && a.status < 500 && a.status !== 429)
406
- throw this.activeConnections.delete(t), new Error(`Client error ${a.status}`);
405
+ onopen: async (s) => {
406
+ if (!s.ok && s.status >= 400 && s.status < 500 && s.status !== 429)
407
+ throw this.activeConnections.delete(n), new Error(`Client error ${s.status}`);
407
408
  },
408
- onmessage: (a) => {
409
- if (a.data) {
410
- const s = re(a.data);
411
- this.broadcast(s, t);
409
+ onmessage: (s) => {
410
+ if (s.data) {
411
+ const c = ne(s.data);
412
+ this.broadcast(c, n);
412
413
  }
413
414
  },
414
- onerror: (a) => {
415
- throw console.error("EventSource error for stream", t, ":", a), this.activeConnections.delete(t), this.broadcastError(t, ne(a)), a;
415
+ onerror: (s) => {
416
+ throw console.error("EventSource error for stream", n, ":", s), this.activeConnections.delete(n), this.broadcastError(n, oe(s)), s;
416
417
  },
417
418
  onclose() {
418
419
  }
@@ -422,19 +423,19 @@ class We {
422
423
  * Subscribe to events from all active streams.
423
424
  * Returns an unsubscribe function.
424
425
  */
425
- subscribe(r, t) {
426
- return this.subscribers.set(r, t), () => {
426
+ subscribe(r, n) {
427
+ return this.subscribers.set(r, n), () => {
427
428
  this.subscribers.delete(r);
428
429
  };
429
430
  }
430
- broadcast(r, t) {
431
- this.subscribers.forEach((n) => {
432
- n.onMessage(r, t);
431
+ broadcast(r, n) {
432
+ this.subscribers.forEach((t) => {
433
+ t.onMessage(r, n);
433
434
  });
434
435
  }
435
- broadcastError(r, t) {
436
- this.subscribers.forEach((n) => {
437
- n.onError(r, t);
436
+ broadcastError(r, n) {
437
+ this.subscribers.forEach((t) => {
438
+ t.onError(r, n);
438
439
  });
439
440
  }
440
441
  /**
@@ -451,457 +452,714 @@ class We {
451
452
  this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null), this.workerSupported = !1, this.subscribers.clear();
452
453
  }
453
454
  }
454
- const ze = 48e4, Be = 3e5, te = (e) => {
455
+ const He = 48e4, Ue = 3e5, ae = (e) => {
455
456
  const r = Date.now();
456
- return e.filter((t) => r - t.createdAt < ze);
457
+ return e.filter((n) => r - n.createdAt < He);
457
458
  };
458
- function Vr({ fency: e, fetchCreateStreamClientToken: r, children: t }) {
459
- const [n, i] = I(
459
+ function Lt({ fency: e, fetchCreateStreamClientToken: r, children: n }) {
460
+ const [t, i] = E(
460
461
  null
461
- ), [l, a] = I(!0), [s, m] = I(null), [p, c] = I([]), d = A(null), u = A(null);
462
- F(() => {
463
- e.then((k) => {
464
- i(k), a(!1);
465
- }).catch((k) => {
466
- m(k), a(!1);
462
+ ), [l, s] = E(!0), [c, m] = E(null), [y, d] = E([]), u = D(null), p = D(null);
463
+ P(() => {
464
+ e.then((x) => {
465
+ i(x), s(!1);
466
+ }).catch((x) => {
467
+ m(x), s(!1);
467
468
  });
468
- }, [e]), F(() => {
469
- n && !u.current && (u.current = new We(n));
470
- }, [n]), F(() => {
471
- u.current && u.current.updateStreams(p);
472
- }, [p]), F(() => () => {
473
- var k;
474
- (k = u.current) == null || k.cleanup();
475
- }, []), F(() => {
476
- const k = setInterval(() => {
477
- c((b) => {
478
- const v = te(b);
469
+ }, [e]), P(() => {
470
+ t && !p.current && (p.current = new $e(t));
471
+ }, [t]), P(() => {
472
+ p.current && p.current.updateStreams(y);
473
+ }, [y]), P(() => () => {
474
+ var x;
475
+ (x = p.current) == null || x.cleanup();
476
+ }, []), P(() => {
477
+ const x = setInterval(() => {
478
+ d((b) => {
479
+ const v = ae(b);
479
480
  return v.length !== b.length ? v : b;
480
481
  });
481
482
  }, 6e4);
482
- return () => clearInterval(k);
483
+ return () => clearInterval(x);
483
484
  }, []);
484
- const g = z(
485
- async (k = Be) => {
486
- if (d.current)
487
- return d.current;
488
- const b = Date.now(), v = p.length > 0 ? p[p.length - 1] : null;
489
- if (v && b - v.createdAt < k)
485
+ const h = O(
486
+ async (x = Ue) => {
487
+ if (u.current)
488
+ return u.current;
489
+ const b = Date.now(), v = y.length > 0 ? y[y.length - 1] : null;
490
+ if (v && b - v.createdAt < x)
490
491
  return v.stream;
491
- const T = (async () => {
492
- if (!n)
492
+ const C = (async () => {
493
+ if (!t)
493
494
  throw new Error("Fency instance not initialized");
494
- const w = await r(), x = await ge({
495
- pk: n.publishableKey,
496
- baseUrl: n.baseUrl,
497
- clientToken: (w == null ? void 0 : w.clientToken) ?? ""
495
+ const M = await r(), w = await xe({
496
+ pk: t.publishableKey,
497
+ baseUrl: t.baseUrl,
498
+ clientToken: (M == null ? void 0 : M.clientToken) ?? ""
498
499
  });
499
- if (x.type === "success") {
500
- const D = {
501
- stream: x.stream,
500
+ if (w.type === "success") {
501
+ const k = {
502
+ stream: w.stream,
502
503
  createdAt: Date.now()
503
504
  };
504
- return c((W) => {
505
- const R = [...W, D];
506
- return te(R);
507
- }), d.current = null, x.stream;
505
+ return d((W) => {
506
+ const A = [...W, k];
507
+ return ae(A);
508
+ }), u.current = null, w.stream;
508
509
  } else
509
- throw d.current = null, new Error("Failed to create stream");
510
+ throw u.current = null, new Error("Failed to create stream");
510
511
  })();
511
- return d.current = T, T;
512
+ return u.current = C, C;
512
513
  },
513
- [n, p]
514
+ [t, y]
514
515
  );
515
- if (s)
516
- return /* @__PURE__ */ y("div", { children: [
516
+ if (c)
517
+ return /* @__PURE__ */ g("div", { children: [
517
518
  "Fency error: ",
518
- s.message
519
+ c.message
519
520
  ] });
520
- if (!n)
521
+ if (!t)
521
522
  return null;
522
- const h = p.length > 0 ? p[p.length - 1] : null, f = {
523
- fency: n,
523
+ const f = y.length > 0 ? y[y.length - 1] : null, S = {
524
+ fency: t,
524
525
  loading: l,
525
- error: s,
526
- activeStreams: p,
527
- latestStream: h,
528
- eventManager: u.current,
529
- getOrCreateStream: g
526
+ error: c,
527
+ activeStreams: y,
528
+ latestStream: f,
529
+ eventManager: p.current,
530
+ getOrCreateStream: h
530
531
  };
531
- return /* @__PURE__ */ o(de.Provider, { value: f, children: t });
532
+ return /* @__PURE__ */ o(me.Provider, { value: S, children: n });
532
533
  }
533
- function ue() {
534
- const e = be(de);
534
+ function pe() {
535
+ const e = Ee(me);
535
536
  if (e === void 0)
536
537
  throw new Error("useFencyContext must be used within a FencyProvider");
537
538
  return e;
538
539
  }
539
- const Oe = (e) => {
540
+ const ye = a.object({
541
+ role: a.enum(["SYSTEM", "USER", "ASSISTANT"]),
542
+ content: a.string()
543
+ }).passthrough(), Q = a.object({
544
+ memoryId: a.string(),
545
+ memoryTitle: a.string(),
546
+ memoryTypeId: a.string(),
547
+ memoryTypeName: a.string(),
548
+ matchingChunkScore: a.number(),
549
+ matchingChunk: a.object({
550
+ chunkNumber: a.number(),
551
+ pageNumbers: a.array(a.number()),
552
+ content: a.string()
553
+ }).passthrough(),
554
+ chunks: a.array(
555
+ a.object({
556
+ chunkNumber: a.number(),
557
+ pageNumbers: a.array(a.number()),
558
+ content: a.string(),
559
+ relation: a.enum([
560
+ "MATCH",
561
+ "CONTEXT_BEFORE",
562
+ "CONTEXT_AFTER"
563
+ ])
564
+ }).passthrough()
565
+ )
566
+ }).passthrough(), he = a.object({
567
+ memoryId: a.string(),
568
+ memoryTitle: a.string()
569
+ }).passthrough(), _e = a.object({
570
+ taskType: a.literal("StreamingChatCompletion"),
571
+ eventType: a.literal("Text"),
572
+ text: a.string()
573
+ }).passthrough(), Ge = a.object({
574
+ taskType: a.literal("StreamingChatCompletion"),
575
+ eventType: a.literal("Completed"),
576
+ response: a.object({
577
+ textResponse: a.string(),
578
+ messages: a.array(ye)
579
+ }).passthrough()
580
+ }).passthrough(), qe = a.object({
581
+ taskType: a.literal("StreamingChatCompletion"),
582
+ eventType: a.literal("Error"),
583
+ message: a.string()
584
+ }).passthrough(), Qe = a.object({
585
+ taskType: a.literal("StructuredChatCompletion"),
586
+ eventType: a.literal("Completed"),
587
+ response: a.object({
588
+ jsonResponse: a.string(),
589
+ messages: a.array(ye)
590
+ }).passthrough()
591
+ }).passthrough(), Ke = a.object({
592
+ taskType: a.literal("StructuredChatCompletion"),
593
+ eventType: a.literal("Error"),
594
+ message: a.string()
595
+ }).passthrough(), Xe = a.object({
596
+ taskType: a.literal("MemoryChat"),
597
+ eventType: a.literal("Text"),
598
+ text: a.string()
599
+ }).passthrough(), Ve = a.object({
600
+ taskType: a.literal("MemoryChat"),
601
+ eventType: a.literal("Thinking")
602
+ }).passthrough(), Ye = a.object({
603
+ taskType: a.literal("MemoryChat"),
604
+ eventType: a.literal("Search"),
605
+ queryDescription: a.string(),
606
+ memories: a.array(he).optional()
607
+ }).passthrough(), Je = a.object({
608
+ taskType: a.literal("MemoryChat"),
609
+ eventType: a.literal("FindMemories"),
610
+ titles: a.array(a.string())
611
+ }).passthrough(), Ze = a.object({
612
+ taskType: a.literal("MemoryChat"),
613
+ eventType: a.literal("FindMemoriesResult"),
614
+ memories: a.array(he)
615
+ }).passthrough(), er = a.enum([
616
+ "downloading",
617
+ "downloaded",
618
+ "analyzing",
619
+ "summarizing"
620
+ ]), rr = a.object({
621
+ taskType: a.literal("MemoryChat"),
622
+ eventType: a.literal("ScrapeWebsites"),
623
+ input: a.object({
624
+ query: a.string(),
625
+ urls: a.array(a.string())
626
+ }).passthrough(),
627
+ results: a.array(
628
+ a.object({
629
+ url: a.string(),
630
+ status: er.optional(),
631
+ summary: a.string().optional(),
632
+ error: a.string().optional()
633
+ }).passthrough()
634
+ ).optional()
635
+ }).passthrough(), tr = a.object({
636
+ taskType: a.literal("MemoryChat"),
637
+ eventType: a.literal("GoogleSearch"),
638
+ input: a.object({
639
+ query: a.string(),
640
+ countryCode: a.string().optional()
641
+ }).passthrough(),
642
+ results: a.array(
643
+ a.object({
644
+ rank: a.number(),
645
+ title: a.string(),
646
+ link: a.string(),
647
+ description: a.string()
648
+ }).passthrough()
649
+ ).optional()
650
+ }).passthrough(), nr = a.object({
651
+ taskType: a.literal("MemoryChat"),
652
+ eventType: a.literal("FindSources")
653
+ }).passthrough(), or = a.object({
654
+ taskType: a.literal("MemoryChat"),
655
+ eventType: a.literal("ExploreMemories"),
656
+ memories: a.array(
657
+ a.object({
658
+ memoryId: a.string(),
659
+ memoryTitle: a.string(),
660
+ result: a.string().optional(),
661
+ error: a.string().optional()
662
+ }).passthrough()
663
+ )
664
+ }).passthrough(), ar = a.object({
665
+ taskType: a.literal("MemoryChat"),
666
+ eventType: a.literal("ChunkResults"),
667
+ items: a.array(Q)
668
+ }).passthrough(), ir = a.object({
669
+ taskType: a.literal("MemoryChat"),
670
+ eventType: a.literal("SourcesResult"),
671
+ sources: a.array(
672
+ a.object({
673
+ memoryId: a.string(),
674
+ memoryTitle: a.string(),
675
+ memoryTypeId: a.string(),
676
+ memoryTypeName: a.string(),
677
+ pageNumbers: a.array(a.number())
678
+ }).passthrough()
679
+ )
680
+ }).passthrough(), sr = a.object({
681
+ taskType: a.literal("MemoryChat"),
682
+ eventType: a.literal("Completed"),
683
+ response: a.object({
684
+ textResponse: a.string(),
685
+ sources: a.array(
686
+ a.object({
687
+ memoryId: a.string(),
688
+ memoryTitle: a.string(),
689
+ memoryTypeId: a.string(),
690
+ memoryTypeName: a.string(),
691
+ pageNumbers: a.array(a.number())
692
+ }).passthrough()
693
+ )
694
+ }).passthrough()
695
+ }).passthrough(), lr = a.object({
696
+ taskType: a.literal("MemoryChat"),
697
+ eventType: a.literal("Error"),
698
+ message: a.string()
699
+ }).passthrough(), cr = a.object({
700
+ taskType: a.literal("MemorySearch"),
701
+ eventType: a.literal("GeneratingQueries"),
702
+ memoryTypes: a.array(
703
+ a.object({
704
+ memoryTypeId: a.string(),
705
+ memoryTypeName: a.string(),
706
+ reasoning: a.string().optional(),
707
+ reasoningCompleted: a.boolean().optional(),
708
+ queries: a.array(a.object({ query: a.string() }).passthrough()).optional()
709
+ }).passthrough()
710
+ )
711
+ }).passthrough(), dr = a.object({
712
+ taskType: a.literal("MemorySearch"),
713
+ eventType: a.literal("ExploreQueries"),
714
+ queries: a.array(
715
+ a.object({
716
+ query: a.string(),
717
+ memoryTypeId: a.string(),
718
+ memoryTypeName: a.string(),
719
+ result: a.object({
720
+ numberOfChunks: a.number(),
721
+ highestChunkScore: a.number(),
722
+ items: a.array(Q)
723
+ }).passthrough().optional(),
724
+ error: a.string().optional()
725
+ }).passthrough()
726
+ )
727
+ }).passthrough(), ur = a.object({
728
+ taskType: a.literal("MemorySearch"),
729
+ eventType: a.literal("SearchMemoryTypes"),
730
+ memoryTypes: a.array(
731
+ a.object({
732
+ memoryTypeId: a.string(),
733
+ memoryTypeName: a.string(),
734
+ result: a.object({
735
+ numberOfChunks: a.number(),
736
+ highestChunkScore: a.number()
737
+ }).passthrough().optional(),
738
+ error: a.string().optional()
739
+ }).passthrough()
740
+ )
741
+ }).passthrough(), mr = a.object({
742
+ taskType: a.literal("MemorySearch"),
743
+ eventType: a.literal("Completed"),
744
+ response: a.object({
745
+ query: a.string(),
746
+ items: a.array(Q)
747
+ }).passthrough()
748
+ }).passthrough(), pr = a.object({
749
+ taskType: a.literal("MemorySearch"),
750
+ eventType: a.literal("Error"),
751
+ message: a.string()
752
+ }).passthrough(), yr = a.union([
753
+ _e,
754
+ Ge,
755
+ qe,
756
+ Qe,
757
+ Ke,
758
+ Xe,
759
+ Ve,
760
+ Ye,
761
+ Je,
762
+ Ze,
763
+ rr,
764
+ tr,
765
+ nr,
766
+ or,
767
+ ar,
768
+ ir,
769
+ sr,
770
+ lr,
771
+ cr,
772
+ dr,
773
+ ur,
774
+ mr,
775
+ pr
776
+ ]);
777
+ function hr(e) {
778
+ const r = yr.safeParse(e);
779
+ return r.success ? r.data : (console.warn(
780
+ "[fency] Dropping unrecognized or malformed agent task event:",
781
+ r.error.format(),
782
+ e
783
+ ), null);
784
+ }
785
+ const gr = (e) => {
540
786
  try {
541
787
  const r = JSON.parse(e);
542
- return Ne(r);
788
+ return fr(r);
543
789
  } catch (r) {
544
790
  return console.error("Error parsing message:", r), null;
545
791
  }
546
- }, Ne = (e) => he(e) ? $e(e) : fe(e) ? He(e) : Se(e) ? Ue(e) : null, $e = (e) => ({
792
+ }, fr = (e) => be(e) ? Sr(e) : ke(e) ? Tr(e) : ve(e) ? xr(e) : null, Sr = (e) => ({
547
793
  type: "STREAM_TIMEOUT",
548
794
  streamId: e.streamId,
549
795
  timestamp: e.timestamp
550
- }), He = (e) => ({
796
+ }), Tr = (e) => ({
551
797
  type: "STREAM_NOT_FOUND",
552
798
  streamId: e.streamId,
553
799
  timestamp: e.timestamp
554
- }), Ue = (e) => ({
555
- type: "AGENT_TASK_PROGRESS_ITEM_UPDATED",
556
- streamId: e.streamId,
557
- agentTaskId: e.agentTaskId,
558
- progressItemId: e.progressItemId,
559
- timestamp: e.timestamp,
560
- createdAt: e.createdAt,
561
- data: JSON.parse(e.data)
562
- }), _e = (e) => {
563
- const r = ue(), [t, n] = I(null), i = A(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
564
- return F(() => {
800
+ }), xr = (e) => {
801
+ let r;
802
+ try {
803
+ r = JSON.parse(e.data);
804
+ } catch (t) {
805
+ return console.warn(
806
+ "[fency] Invalid JSON in AGENT_TASK_PROGRESS_ITEM_UPDATED data payload:",
807
+ t
808
+ ), null;
809
+ }
810
+ const n = hr(r);
811
+ return n === null ? null : {
812
+ type: "AGENT_TASK_PROGRESS_ITEM_UPDATED",
813
+ streamId: e.streamId,
814
+ agentTaskId: e.agentTaskId,
815
+ progressItemId: e.progressItemId,
816
+ timestamp: e.timestamp,
817
+ createdAt: e.createdAt,
818
+ data: n
819
+ };
820
+ }, br = (e) => {
821
+ const r = pe(), [n, t] = E(null), i = D(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
822
+ return P(() => {
565
823
  if (!r.eventManager) return;
566
- const a = {
567
- onMessage: (m, p) => {
568
- var d, u, g;
569
- const c = Oe(m);
570
- if (c)
571
- switch (c.type) {
824
+ const s = {
825
+ onMessage: (m, y) => {
826
+ var u, p, h;
827
+ const d = gr(m);
828
+ if (d)
829
+ switch (d.type) {
572
830
  case "STREAM_TIMEOUT":
573
- (d = e == null ? void 0 : e.onStreamTimeout) == null || d.call(e, c);
831
+ (u = e == null ? void 0 : e.onStreamTimeout) == null || u.call(e, d);
574
832
  break;
575
833
  case "STREAM_NOT_FOUND":
576
- (u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e, c);
834
+ (p = e == null ? void 0 : e.onStreamNotFound) == null || p.call(e, d);
577
835
  break;
578
836
  case "AGENT_TASK_PROGRESS_ITEM_UPDATED":
579
- (g = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || g.call(e, c);
837
+ (h = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || h.call(e, d);
580
838
  break;
581
839
  }
582
840
  },
583
- onError: (m, p) => {
584
- var c;
585
- (c = e == null ? void 0 : e.onStreamError) == null || c.call(e, {
841
+ onError: (m, y) => {
842
+ var d;
843
+ (d = e == null ? void 0 : e.onStreamError) == null || d.call(e, {
586
844
  streamId: m,
587
845
  error: {
588
846
  code: "UnknownError",
589
- message: p ?? "Unknown error in useStream"
847
+ message: y ?? "Unknown error in useStream"
590
848
  }
591
849
  });
592
850
  }
593
851
  };
594
852
  return r.eventManager.subscribe(
595
853
  i.current,
596
- a
854
+ s
597
855
  );
598
856
  }, [r.eventManager, e]), {
599
857
  createStream: async () => {
600
858
  try {
601
- const a = await r.getOrCreateStream();
602
- return n(a), {
859
+ const s = await r.getOrCreateStream();
860
+ return t(s), {
603
861
  type: "success",
604
- stream: a
862
+ stream: s
605
863
  };
606
- } catch (a) {
864
+ } catch (s) {
607
865
  return {
608
866
  type: "error",
609
867
  error: {
610
868
  code: "UnknownError",
611
- message: a instanceof Error ? a.message : "Failed to create stream"
869
+ message: s instanceof Error ? s.message : "Failed to create stream"
612
870
  }
613
871
  };
614
872
  }
615
873
  },
616
- stream: t
874
+ stream: n
617
875
  };
618
- }, Yr = (e) => {
619
- const r = ue(), [t, n] = I([]), i = A(/* @__PURE__ */ new Set()), l = A(/* @__PURE__ */ new Map()), a = z(
620
- (c, d) => {
621
- n((u) => {
622
- const g = [], h = u.map((f) => {
876
+ }, zt = (e) => {
877
+ const r = pe(), [n, t] = E([]), i = D(/* @__PURE__ */ new Set()), l = D(/* @__PURE__ */ new Map()), s = O(
878
+ (d, u) => {
879
+ t((p) => {
880
+ const h = [], f = p.map((S) => {
623
881
  var b;
624
- if (f.streamId !== c || !f.loading) return f;
625
- const k = (b = f.confirmedData) == null ? void 0 : b.taskId;
626
- return k && g.push(k), { ...f, loading: !1, error: d };
882
+ if (S.streamId !== d || !S.loading) return S;
883
+ const x = (b = S.confirmedData) == null ? void 0 : b.taskId;
884
+ return x && h.push(x), { ...S, loading: !1, error: u };
627
885
  });
628
- for (const f of g) {
629
- i.current.delete(f);
630
- const k = l.current.get(f);
631
- k && (l.current.delete(f), k({ type: "error", error: d }));
886
+ for (const S of h) {
887
+ i.current.delete(S);
888
+ const x = l.current.get(S);
889
+ x && (l.current.delete(S), x({ type: "error", error: u }));
632
890
  }
633
- return h;
891
+ return f;
634
892
  });
635
893
  },
636
894
  []
637
- ), { createStream: s } = _e({
638
- onAgentTaskProgressItemUpdated: (c) => {
639
- var g;
640
- if (!i.current.has(c.agentTaskId)) return;
641
- const d = c.data;
642
- if (d.taskType === "StreamingChatCompletion" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed" || d.taskType === "MemoryChat" && d.eventType === "Completed" || d.taskType === "MemorySearch" && d.eventType === "Completed") {
643
- const h = d.taskType === "MemorySearch" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed";
644
- n(
645
- h ? (k) => k.map((b) => {
646
- var w;
647
- if (((w = b.confirmedData) == null ? void 0 : w.taskId) !== c.agentTaskId)
895
+ ), { createStream: c } = br({
896
+ onAgentTaskProgressItemUpdated: (d) => {
897
+ var h;
898
+ if (!i.current.has(d.agentTaskId)) return;
899
+ const u = d.data;
900
+ if (u.taskType === "StreamingChatCompletion" && u.eventType === "Completed" || u.taskType === "StructuredChatCompletion" && u.eventType === "Completed" || u.taskType === "MemoryChat" && u.eventType === "Completed" || u.taskType === "MemorySearch" && u.eventType === "Completed") {
901
+ const f = u.taskType === "MemorySearch" && u.eventType === "Completed" || u.taskType === "StructuredChatCompletion" && u.eventType === "Completed";
902
+ t(
903
+ f ? (x) => x.map((b) => {
904
+ var M;
905
+ if (((M = b.confirmedData) == null ? void 0 : M.taskId) !== d.agentTaskId)
648
906
  return b;
649
- const T = b.progressItems.some(
650
- (x) => x.progressItemId === c.progressItemId
907
+ const C = b.progressItems.some(
908
+ (w) => w.progressItemId === d.progressItemId
651
909
  ) ? b.progressItems.map(
652
- (x) => x.progressItemId === c.progressItemId ? c : x
653
- ) : [...b.progressItems, c];
910
+ (w) => w.progressItemId === d.progressItemId ? d : w
911
+ ) : [...b.progressItems, d];
654
912
  return {
655
913
  ...b,
656
- progressItems: T,
914
+ progressItems: C,
657
915
  loading: !1
658
916
  };
659
- }) : (k) => k.map(
917
+ }) : (x) => x.map(
660
918
  (b) => {
661
919
  var v;
662
- return ((v = b.confirmedData) == null ? void 0 : v.taskId) === c.agentTaskId ? { ...b, loading: !1 } : b;
920
+ return ((v = b.confirmedData) == null ? void 0 : v.taskId) === d.agentTaskId ? { ...b, loading: !1 } : b;
663
921
  }
664
922
  )
665
923
  );
666
- const f = l.current.get(
667
- c.agentTaskId
924
+ const S = l.current.get(
925
+ d.agentTaskId
668
926
  );
669
- f && (l.current.delete(c.agentTaskId), f({
927
+ S && (l.current.delete(d.agentTaskId), S({
670
928
  type: "success",
671
- streamId: c.streamId,
672
- agentTaskId: c.agentTaskId,
673
- response: d
929
+ streamId: d.streamId,
930
+ agentTaskId: d.agentTaskId,
931
+ response: u
674
932
  }));
675
933
  return;
676
934
  }
677
- (g = e.onAgentTaskProgressItemUpdated) == null || g.call(e, c), n(
678
- (h) => h.map((f) => {
935
+ (h = e.onAgentTaskProgressItemUpdated) == null || h.call(e, d), t(
936
+ (f) => f.map((S) => {
679
937
  var v;
680
- if (((v = f.confirmedData) == null ? void 0 : v.taskId) !== c.agentTaskId)
681
- return f;
682
- const b = f.progressItems.some(
683
- (T) => T.progressItemId === c.progressItemId
684
- ) ? f.progressItems.map(
685
- (T) => T.progressItemId === c.progressItemId ? c : T
686
- ) : [...f.progressItems, c];
687
- return { ...f, progressItems: b };
938
+ if (((v = S.confirmedData) == null ? void 0 : v.taskId) !== d.agentTaskId)
939
+ return S;
940
+ const b = S.progressItems.some(
941
+ (C) => C.progressItemId === d.progressItemId
942
+ ) ? S.progressItems.map(
943
+ (C) => C.progressItemId === d.progressItemId ? d : C
944
+ ) : [...S.progressItems, d];
945
+ return { ...S, progressItems: b };
688
946
  })
689
947
  );
690
948
  },
691
- onStreamError: (c) => {
692
- var d;
693
- (d = e == null ? void 0 : e.onStreamError) == null || d.call(e, c), a(c.streamId, c.error);
949
+ onStreamError: (d) => {
950
+ var u;
951
+ (u = e == null ? void 0 : e.onStreamError) == null || u.call(e, d), s(d.streamId, d.error);
694
952
  },
695
- onStreamNotFound: (c) => {
696
- var d;
697
- (d = e == null ? void 0 : e.onStreamNotFound) == null || d.call(e, c), a(c.streamId, {
953
+ onStreamNotFound: (d) => {
954
+ var u;
955
+ (u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e, d), s(d.streamId, {
698
956
  code: "StreamNotFound",
699
957
  message: "Stream not found"
700
958
  });
701
959
  },
702
- onStreamTimeout: (c) => {
703
- var d;
704
- (d = e == null ? void 0 : e.onStreamTimeout) == null || d.call(e, c), a(c.streamId, {
960
+ onStreamTimeout: (d) => {
961
+ var u;
962
+ (u = e == null ? void 0 : e.onStreamTimeout) == null || u.call(e, d), s(d.streamId, {
705
963
  code: "StreamTimeout",
706
964
  message: "Stream timed out"
707
965
  });
708
966
  }
709
- }), m = z(
710
- async (c, d) => {
711
- var f;
712
- const u = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, g = (d == null ? void 0 : d.fetchCreateAgentTaskClientToken) ?? e.fetchCreateAgentTaskClientToken;
713
- if (g === void 0)
967
+ }), m = O(
968
+ async (d, u) => {
969
+ var S;
970
+ const p = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, h = (u == null ? void 0 : u.fetchCreateAgentTaskClientToken) ?? e.fetchCreateAgentTaskClientToken;
971
+ if (h === void 0)
714
972
  throw new Error(
715
973
  "fetchCreateAgentTaskClientToken must be provided either in useAgentTasks props or in createAgentTask options"
716
974
  );
717
- const h = await s();
718
- if (h.type === "success") {
719
- const k = (/* @__PURE__ */ new Date()).toISOString(), b = {
720
- taskKey: u,
721
- streamId: h.stream.id,
722
- triggeredAt: k,
975
+ const f = await c();
976
+ if (f.type === "success") {
977
+ const x = (/* @__PURE__ */ new Date()).toISOString(), b = {
978
+ taskKey: p,
979
+ streamId: f.stream.id,
980
+ triggeredAt: x,
723
981
  confirmedData: null,
724
982
  error: null,
725
- params: c,
983
+ params: d,
726
984
  progressItems: [],
727
985
  loading: !0,
728
- loadingText: d == null ? void 0 : d.loadingText
986
+ loadingText: u == null ? void 0 : u.loadingText
729
987
  };
730
- n((v) => [...v, b]), (f = d == null ? void 0 : d.onTaskRegistered) == null || f.call(d, b);
988
+ t((v) => [...v, b]), (S = u == null ? void 0 : u.onTaskRegistered) == null || S.call(u, b);
731
989
  try {
732
- const { clientToken: v } = await g(), T = await xe({
990
+ const { clientToken: v } = await h(), C = await Ce({
733
991
  pk: r.fency.publishableKey,
734
992
  baseUrl: r.fency.baseUrl,
735
993
  clientToken: v,
736
- streamToken: h.stream.token,
994
+ streamToken: f.stream.token,
737
995
  request: {
738
- streamingChatCompletionTask: c.type === "StreamingChatCompletion" ? {
739
- messages: c.messages,
740
- model: c.model,
741
- ...c.temperature !== void 0 ? {
742
- temperature: c.temperature
996
+ streamingChatCompletionTask: d.type === "StreamingChatCompletion" ? {
997
+ messages: d.messages,
998
+ model: d.model,
999
+ ...d.temperature !== void 0 ? {
1000
+ temperature: d.temperature
743
1001
  } : {},
744
- ...c.topP !== void 0 ? { topP: c.topP } : {}
1002
+ ...d.topP !== void 0 ? { topP: d.topP } : {}
745
1003
  } : void 0,
746
- structuredChatCompletionTask: c.type === "StructuredChatCompletion" ? {
747
- messages: c.messages,
748
- jsonSchema: c.jsonSchema,
749
- model: c.model,
750
- ...c.temperature !== void 0 ? {
751
- temperature: c.temperature
1004
+ structuredChatCompletionTask: d.type === "StructuredChatCompletion" ? {
1005
+ messages: d.messages,
1006
+ jsonSchema: d.jsonSchema,
1007
+ model: d.model,
1008
+ ...d.temperature !== void 0 ? {
1009
+ temperature: d.temperature
752
1010
  } : {},
753
- ...c.topP !== void 0 ? { topP: c.topP } : {}
1011
+ ...d.topP !== void 0 ? { topP: d.topP } : {}
754
1012
  } : void 0,
755
- memoryChatTask: c.type === "MemoryChat" ? {
756
- messages: c.messages,
757
- model: c.model,
758
- language: c.language ?? "en",
759
- chunkLimit: c.chunkLimit ?? 10,
760
- memoryScanLimit: c.memoryScanLimit ?? 3
1013
+ memoryChatTask: d.type === "MemoryChat" ? {
1014
+ messages: d.messages,
1015
+ model: d.model,
1016
+ language: d.language ?? "en",
1017
+ chunkLimit: d.chunkLimit ?? 10,
1018
+ memoryScanLimit: d.memoryScanLimit ?? 3
761
1019
  } : void 0,
762
- memorySearchTask: c.type === "MemorySearch" ? {
763
- query: c.query,
764
- model: c.model,
765
- language: c.language ?? "en",
766
- chunkLimit: c.chunkLimit ?? 10,
767
- contextExpansion: c.contextExpansion,
768
- ...c.queryExpansion != null ? {
769
- queryExpansion: c.queryExpansion
1020
+ memorySearchTask: d.type === "MemorySearch" ? {
1021
+ query: d.query,
1022
+ model: d.model,
1023
+ language: d.language ?? "en",
1024
+ chunkLimit: d.chunkLimit ?? 10,
1025
+ contextExpansion: d.contextExpansion,
1026
+ ...d.queryExpansion != null ? {
1027
+ queryExpansion: d.queryExpansion
770
1028
  } : {}
771
1029
  } : void 0
772
1030
  }
773
1031
  });
774
- if (T.type === "success" && T.agentTask)
1032
+ if (C.type === "success" && C.agentTask)
775
1033
  return i.current.add(
776
- T.agentTask.id
777
- ), n((w) => [
778
- ...w.filter((x) => x.taskKey !== u),
1034
+ C.agentTask.id
1035
+ ), t((M) => [
1036
+ ...M.filter((w) => w.taskKey !== p),
779
1037
  {
780
- taskKey: u,
781
- streamId: h.stream.id,
1038
+ taskKey: p,
1039
+ streamId: f.stream.id,
782
1040
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
783
- taskId: T.agentTask.id,
784
- createdAt: T.agentTask.createdAt,
1041
+ taskId: C.agentTask.id,
1042
+ createdAt: C.agentTask.createdAt,
785
1043
  error: null,
786
- params: c,
1044
+ params: d,
787
1045
  progressItems: [],
788
1046
  loading: !0,
789
- loadingText: d == null ? void 0 : d.loadingText,
1047
+ loadingText: u == null ? void 0 : u.loadingText,
790
1048
  confirmedData: {
791
- taskId: T.agentTask.id,
792
- createdAt: T.agentTask.createdAt
1049
+ taskId: C.agentTask.id,
1050
+ createdAt: C.agentTask.createdAt
793
1051
  }
794
1052
  }
795
1053
  ]), await new Promise(
796
- (w) => {
1054
+ (M) => {
797
1055
  l.current.set(
798
- T.agentTask.id,
799
- w
1056
+ C.agentTask.id,
1057
+ M
800
1058
  );
801
1059
  }
802
1060
  );
803
- if (T.type === "error")
804
- return n((w) => [
805
- ...w.filter((x) => x.taskKey !== u),
1061
+ if (C.type === "error")
1062
+ return t((M) => [
1063
+ ...M.filter((w) => w.taskKey !== p),
806
1064
  {
807
- taskKey: u,
1065
+ taskKey: p,
808
1066
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
809
- streamId: h.stream.id,
810
- params: c,
811
- error: T.error,
1067
+ streamId: f.stream.id,
1068
+ params: d,
1069
+ error: C.error,
812
1070
  progressItems: [],
813
1071
  loading: !1,
814
- loadingText: d == null ? void 0 : d.loadingText,
1072
+ loadingText: u == null ? void 0 : u.loadingText,
815
1073
  confirmedData: null
816
1074
  }
817
1075
  ]), {
818
1076
  type: "error",
819
- error: T.error
1077
+ error: C.error
820
1078
  };
821
1079
  {
822
- const w = {
1080
+ const M = {
823
1081
  message: "No response received",
824
1082
  code: "UnknownError"
825
1083
  };
826
- return n((x) => [
827
- ...x.filter((D) => D.taskKey !== u),
1084
+ return t((w) => [
1085
+ ...w.filter((k) => k.taskKey !== p),
828
1086
  {
829
- taskKey: u,
1087
+ taskKey: p,
830
1088
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
831
- streamId: h.stream.id,
832
- error: w,
833
- params: c,
1089
+ streamId: f.stream.id,
1090
+ error: M,
1091
+ params: d,
834
1092
  progressItems: [],
835
1093
  loading: !1,
836
- loadingText: d == null ? void 0 : d.loadingText,
1094
+ loadingText: u == null ? void 0 : u.loadingText,
837
1095
  confirmedData: null
838
1096
  }
839
1097
  ]), {
840
1098
  type: "error",
841
- error: w
1099
+ error: M
842
1100
  };
843
1101
  }
844
1102
  } catch (v) {
845
- const T = {
1103
+ const C = {
846
1104
  code: "UnknownError",
847
1105
  message: v instanceof Error ? v.message : "Unknown error during agent task creation"
848
1106
  };
849
- return n((w) => [
850
- ...w.filter((x) => x.taskKey !== u),
1107
+ return t((M) => [
1108
+ ...M.filter((w) => w.taskKey !== p),
851
1109
  {
852
- taskKey: u,
1110
+ taskKey: p,
853
1111
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
854
- streamId: h.stream.id,
855
- params: c,
856
- error: T,
1112
+ streamId: f.stream.id,
1113
+ params: d,
1114
+ error: C,
857
1115
  progressItems: [],
858
1116
  loading: !1,
859
- loadingText: d == null ? void 0 : d.loadingText,
1117
+ loadingText: u == null ? void 0 : u.loadingText,
860
1118
  confirmedData: null
861
1119
  }
862
1120
  ]), {
863
1121
  type: "error",
864
- error: T
1122
+ error: C
865
1123
  };
866
1124
  }
867
1125
  } else
868
- return console.error(h.error), h;
1126
+ return console.error(f.error), f;
869
1127
  },
870
1128
  [
871
1129
  r,
872
- s,
1130
+ c,
873
1131
  e.fetchCreateAgentTaskClientToken,
874
- a
1132
+ s
875
1133
  ]
876
- ), p = P(() => {
877
- if (t.length !== 0)
878
- return [...t].sort((c, d) => new Date(d.triggeredAt).getTime() - new Date(c.triggeredAt).getTime())[0];
879
- }, [t]);
880
- return F(() => () => {
1134
+ ), y = z(() => {
1135
+ if (n.length !== 0)
1136
+ return [...n].sort((d, u) => new Date(u.triggeredAt).getTime() - new Date(d.triggeredAt).getTime())[0];
1137
+ }, [n]);
1138
+ return P(() => () => {
881
1139
  i.current.clear(), l.current.clear();
882
1140
  }, []), {
883
- agentTasks: t,
1141
+ agentTasks: n,
884
1142
  createAgentTask: m,
885
- latest: p
1143
+ latest: y
886
1144
  };
887
1145
  };
888
- function Ge(e) {
889
- return e.progressItems.map((r, t) => {
890
- const n = e.progressItems[t + 1], i = n != null;
1146
+ function kr(e) {
1147
+ return e.progressItems.map((r, n) => {
1148
+ const t = e.progressItems[n + 1], i = t != null;
891
1149
  let l;
892
- if (n != null && n.createdAt) {
893
- const a = new Date(r.createdAt).getTime(), s = new Date(n.createdAt).getTime();
894
- l = Math.round((s - a) / 1e3);
1150
+ if (t != null && t.createdAt) {
1151
+ const s = new Date(r.createdAt).getTime(), c = new Date(t.createdAt).getTime();
1152
+ l = Math.round((c - s) / 1e3);
895
1153
  }
896
1154
  return {
897
1155
  item: r,
898
1156
  completed: i,
899
- isLatest: t === e.progressItems.length - 1,
1157
+ isLatest: n === e.progressItems.length - 1,
900
1158
  durationSeconds: l
901
1159
  };
902
1160
  });
903
1161
  }
904
- const me = {
1162
+ const ge = {
905
1163
  'code[class*="language-"]': {
906
1164
  color: "#f8f8f2",
907
1165
  background: "none",
@@ -1052,57 +1310,61 @@ const me = {
1052
1310
  italic: {
1053
1311
  fontStyle: "italic"
1054
1312
  }
1055
- }, oe = ({
1313
+ }, ie = ({
1056
1314
  text: e
1057
1315
  }) => /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
1058
- C.div,
1316
+ I.div,
1059
1317
  {
1060
1318
  className: "fency-markdown-body-raw",
1061
1319
  initial: { opacity: 0, y: -10 },
1062
1320
  animate: { opacity: 1, y: 0 },
1063
1321
  transition: { duration: 0.3, delay: 0 },
1064
1322
  children: /* @__PURE__ */ o(
1065
- we,
1323
+ Fe,
1066
1324
  {
1067
- remarkPlugins: [Ce],
1325
+ remarkPlugins: [Ae],
1068
1326
  components: {
1069
1327
  code(r) {
1070
- const { children: t, className: n, node: i, ref: l, ...a } = r, s = /language-(\w+)/.exec(n || "");
1071
- return s ? (
1328
+ const { children: n, className: t, node: i, ref: l, ...s } = r, c = /language-(\w+)/.exec(t || "");
1329
+ return c ? (
1072
1330
  // @ts-expect-error react-syntax-highlighter types incompatible with @types/react 18
1073
1331
  /* @__PURE__ */ o(
1074
- ce,
1332
+ ue,
1075
1333
  {
1076
- ...a,
1334
+ ...s,
1077
1335
  PreTag: "div",
1078
- children: String(t).replace(/\n$/, ""),
1079
- language: s[1],
1080
- style: me
1336
+ children: String(n).replace(/\n$/, ""),
1337
+ language: c[1],
1338
+ style: ge
1081
1339
  }
1082
1340
  )
1083
- ) : /* @__PURE__ */ o("code", { ...a, className: n, children: String(t) });
1341
+ ) : /* @__PURE__ */ o("code", { ...s, className: t, children: String(n) });
1084
1342
  }
1085
1343
  },
1086
1344
  children: e
1087
1345
  }
1088
1346
  )
1089
1347
  }
1090
- ) }), je = ({ data: e }) => {
1091
- const r = JSON.stringify(
1092
- JSON.parse(e.response.jsonResponse),
1093
- null,
1094
- 2
1095
- );
1348
+ ) }), vr = ({ data: e }) => {
1349
+ const r = e.response.jsonResponse;
1350
+ let n;
1351
+ try {
1352
+ n = JSON.stringify(JSON.parse(r), null, 2);
1353
+ } catch {
1354
+ console.warn(
1355
+ "[fency] StructuredChatCompletion jsonResponse is not valid JSON; showing raw string"
1356
+ ), n = r;
1357
+ }
1096
1358
  return /* @__PURE__ */ o("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ o(
1097
- C.div,
1359
+ I.div,
1098
1360
  {
1099
1361
  initial: { opacity: 0, y: -10 },
1100
1362
  animate: { opacity: 1, y: 0 },
1101
1363
  transition: { duration: 0.3, delay: 0 },
1102
- children: /* @__PURE__ */ o(ce, { language: "json", style: me, PreTag: "div", children: r })
1364
+ children: /* @__PURE__ */ o(ue, { language: "json", style: ge, PreTag: "div", children: n })
1103
1365
  }
1104
1366
  ) });
1105
- }, qe = {
1367
+ }, Cr = {
1106
1368
  en: {
1107
1369
  error: "Error",
1108
1370
  streaming: "Streaming...",
@@ -1173,7 +1435,12 @@ const me = {
1173
1435
  scrapedPage: "Scraped 1 page",
1174
1436
  scrapeFailedSuffix: " — {n} failed",
1175
1437
  scrapeOkCount: "{n} ok",
1176
- scrapeFailedCount: "{n} failed"
1438
+ scrapeFailedCount: "{n} failed",
1439
+ memoryChatThinking: "Thinking...",
1440
+ scrapeStatusDownloading: "Downloading…",
1441
+ scrapeStatusDownloaded: "Downloaded",
1442
+ scrapeStatusAnalyzing: "Analyzing document…",
1443
+ scrapeStatusSummarizing: "Summarizing…"
1177
1444
  },
1178
1445
  no: {
1179
1446
  error: "Feil",
@@ -1245,46 +1512,51 @@ const me = {
1245
1512
  scrapedPage: "Skrapet 1 side",
1246
1513
  scrapeFailedSuffix: " — {n} feilet",
1247
1514
  scrapeOkCount: "{n} ok",
1248
- scrapeFailedCount: "{n} feilet"
1515
+ scrapeFailedCount: "{n} feilet",
1516
+ memoryChatThinking: "Tenker…",
1517
+ scrapeStatusDownloading: "Laster ned…",
1518
+ scrapeStatusDownloaded: "Nedlastet",
1519
+ scrapeStatusAnalyzing: "Analyserer dokumentet…",
1520
+ scrapeStatusSummarizing: "Oppsummerer…"
1249
1521
  }
1250
1522
  };
1251
- function Qe(e) {
1252
- return qe[e];
1523
+ function wr(e) {
1524
+ return Cr[e];
1253
1525
  }
1254
- function S(e, r) {
1526
+ function T(e, r) {
1255
1527
  return Object.entries(r).reduce(
1256
- (t, [n, i]) => t.replace(`{${n}}`, String(i)),
1528
+ (n, [t, i]) => n.replace(`{${t}}`, String(i)),
1257
1529
  e
1258
1530
  );
1259
1531
  }
1260
- function q(e, r) {
1261
- const t = e.map((n) => `'${n}'`);
1262
- if (r != null && t.length >= 2) {
1263
- const n = t.pop();
1264
- return t.length > 0 ? `${t.join(", ")} ${r} ${n}` : n;
1532
+ function K(e, r) {
1533
+ const n = e.map((t) => `'${t}'`);
1534
+ if (r != null && n.length >= 2) {
1535
+ const t = n.pop();
1536
+ return n.length > 0 ? `${n.join(", ")} ${r} ${t}` : t;
1265
1537
  }
1266
- return t.join(", ");
1538
+ return n.join(", ");
1267
1539
  }
1268
- function M({
1540
+ function R({
1269
1541
  text: e,
1270
1542
  duration: r = 2,
1271
- delay: t = 0,
1272
- repeat: n = !0,
1543
+ delay: n = 0,
1544
+ repeat: t = !0,
1273
1545
  repeatDelay: i = 0.5,
1274
1546
  className: l,
1275
- startOnView: a = !1,
1276
- once: s = !1,
1547
+ startOnView: s = !1,
1548
+ once: c = !1,
1277
1549
  inViewMargin: m,
1278
- spread: p = 2,
1279
- color: c = "#999",
1280
- shimmerColor: d = "#000",
1281
- direction: u = "fromBottom"
1550
+ spread: y = 2,
1551
+ color: d = "#999",
1552
+ shimmerColor: u = "#000",
1553
+ direction: p = "fromBottom"
1282
1554
  }) {
1283
- const g = A(null), h = ve(g, { once: s, margin: m }), f = P(() => e.length * p, [e, p]), k = !a || h, b = u === "fromBottom" ? "100% center" : "-100% center", v = u === "fromBottom" ? "0% center" : "200% center";
1555
+ const h = D(null), f = Me(h, { once: c, margin: m }), S = z(() => e.length * y, [e, y]), x = !s || f, b = p === "fromBottom" ? "100% center" : "-100% center", v = p === "fromBottom" ? "0% center" : "200% center";
1284
1556
  return /* @__PURE__ */ o(
1285
- C.span,
1557
+ I.span,
1286
1558
  {
1287
- ref: g,
1559
+ ref: h,
1288
1560
  className: l,
1289
1561
  style: {
1290
1562
  position: "relative",
@@ -1295,9 +1567,9 @@ function M({
1295
1567
  color: "transparent",
1296
1568
  WebkitTextFillColor: "transparent",
1297
1569
  backgroundRepeat: "no-repeat, padding-box",
1298
- "--spread": `${f}px`,
1299
- "--base-color": c,
1300
- "--shimmer-color": d,
1570
+ "--spread": `${S}px`,
1571
+ "--base-color": d,
1572
+ "--shimmer-color": u,
1301
1573
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
1302
1574
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
1303
1575
  },
@@ -1305,60 +1577,60 @@ function M({
1305
1577
  backgroundPosition: b,
1306
1578
  opacity: 0
1307
1579
  },
1308
- animate: k ? {
1580
+ animate: x ? {
1309
1581
  backgroundPosition: v,
1310
1582
  opacity: 1
1311
1583
  } : {},
1312
1584
  transition: {
1313
1585
  backgroundPosition: {
1314
- repeat: n ? 1 / 0 : 0,
1586
+ repeat: t ? 1 / 0 : 0,
1315
1587
  duration: r,
1316
- delay: t,
1588
+ delay: n,
1317
1589
  repeatDelay: i,
1318
1590
  ease: "linear"
1319
1591
  },
1320
1592
  opacity: {
1321
1593
  duration: 0.3,
1322
- delay: t
1594
+ delay: n
1323
1595
  }
1324
1596
  },
1325
1597
  children: e
1326
1598
  }
1327
1599
  );
1328
1600
  }
1329
- const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1330
- const [i, l] = I(!1), s = (e.memories ?? []).map((k) => k.memoryTitle), m = s.length > 0, p = m && s.length > U, c = p && !i ? s.slice(0, U) : s, d = s.length - U, u = !p || i, g = `${n.searchingFor}'${e.queryDescription}'`, h = m ? `${n.searchingIn}${q(
1331
- c,
1332
- u ? n.and : void 0
1333
- )}` : "", f = m ? `${g}${h}` : `${n.searchingPrefix}${e.queryDescription}`;
1334
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1601
+ const _ = 5, Ir = ({ data: e, isLatest: r = !1, durationSeconds: n, t }) => {
1602
+ const [i, l] = E(!1), c = (e.memories ?? []).map((x) => x.memoryTitle), m = c.length > 0, y = m && c.length > _, d = y && !i ? c.slice(0, _) : c, u = c.length - _, p = !y || i, h = `${t.searchingFor}'${e.queryDescription}'`, f = m ? `${t.searchingIn}${K(
1603
+ d,
1604
+ p ? t.and : void 0
1605
+ )}` : "", S = m ? `${h}${f}` : `${t.searchingPrefix}${e.queryDescription}`;
1606
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
1335
1607
  /* @__PURE__ */ o(
1336
- C.div,
1608
+ I.div,
1337
1609
  {
1338
1610
  style: { color: "#666" },
1339
1611
  initial: { opacity: 0, y: -10 },
1340
1612
  animate: { opacity: 1, y: 0 },
1341
1613
  transition: { duration: 0.3, delay: 0 },
1342
- children: r && !t && !p ? /* @__PURE__ */ o(
1343
- M,
1614
+ children: r && !n && !y ? /* @__PURE__ */ o(
1615
+ R,
1344
1616
  {
1345
- text: f,
1617
+ text: S,
1346
1618
  duration: 2.5,
1347
1619
  repeat: !0,
1348
1620
  color: "#999",
1349
1621
  shimmerColor: "#000"
1350
1622
  }
1351
- ) : /* @__PURE__ */ y(E, { children: [
1352
- /* @__PURE__ */ o("span", { style: { color: "#666" }, children: m ? /* @__PURE__ */ y(E, { children: [
1353
- n.searchingFor,
1354
- /* @__PURE__ */ y("span", { style: { fontWeight: 600 }, children: [
1623
+ ) : /* @__PURE__ */ g(F, { children: [
1624
+ /* @__PURE__ */ o("span", { style: { color: "#666" }, children: m ? /* @__PURE__ */ g(F, { children: [
1625
+ t.searchingFor,
1626
+ /* @__PURE__ */ g("span", { style: { fontWeight: 600 }, children: [
1355
1627
  "'",
1356
1628
  e.queryDescription,
1357
1629
  "'"
1358
1630
  ] }),
1359
- h
1360
- ] }) : `${n.searchingPrefix}${e.queryDescription}` }),
1361
- p && !i && /* @__PURE__ */ y(E, { children: [
1631
+ f
1632
+ ] }) : `${t.searchingPrefix}${e.queryDescription}` }),
1633
+ y && !i && /* @__PURE__ */ g(F, { children: [
1362
1634
  " ",
1363
1635
  /* @__PURE__ */ o(
1364
1636
  "button",
@@ -1376,13 +1648,13 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1376
1648
  textDecoration: "underline",
1377
1649
  fontFamily: "inherit"
1378
1650
  },
1379
- children: S(n.moreMemories, {
1380
- n: d
1651
+ children: T(t.moreMemories, {
1652
+ n: u
1381
1653
  })
1382
1654
  }
1383
1655
  )
1384
1656
  ] }),
1385
- p && i && /* @__PURE__ */ y(E, { children: [
1657
+ y && i && /* @__PURE__ */ g(F, { children: [
1386
1658
  " ",
1387
1659
  /* @__PURE__ */ o(
1388
1660
  "button",
@@ -1400,14 +1672,14 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1400
1672
  textDecoration: "underline",
1401
1673
  fontFamily: "inherit"
1402
1674
  },
1403
- children: n.clickToCollapse
1675
+ children: t.clickToCollapse
1404
1676
  }
1405
1677
  )
1406
1678
  ] })
1407
1679
  ] })
1408
1680
  }
1409
1681
  ),
1410
- t !== void 0 && /* @__PURE__ */ o(
1682
+ n !== void 0 && /* @__PURE__ */ o(
1411
1683
  "div",
1412
1684
  {
1413
1685
  style: {
@@ -1416,18 +1688,18 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1416
1688
  marginTop: "4px",
1417
1689
  fontStyle: "italic"
1418
1690
  },
1419
- children: S(n.tookSeconds, { n: t })
1691
+ children: T(t.tookSeconds, { n })
1420
1692
  }
1421
1693
  )
1422
1694
  ] });
1423
- }, _ = 5, Xe = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1424
- const [i, l] = I(!1), a = e.titles, s = a.length > 0, m = s && a.length > _, p = m && !i ? a.slice(0, _) : a, c = a.length - _, d = !m || i, u = s ? `${n.findingMemoriesIn}${q(
1425
- p,
1426
- d ? n.and : void 0
1427
- )}` : n.findingMemories;
1428
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1695
+ }, G = 5, Er = ({ data: e, isLatest: r = !1, durationSeconds: n, t }) => {
1696
+ const [i, l] = E(!1), s = e.titles, c = s.length > 0, m = c && s.length > G, y = m && !i ? s.slice(0, G) : s, d = s.length - G, u = !m || i, p = c ? `${t.findingMemoriesIn}${K(
1697
+ y,
1698
+ u ? t.and : void 0
1699
+ )}` : t.findingMemories;
1700
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
1429
1701
  /* @__PURE__ */ o(
1430
- C.div,
1702
+ I.div,
1431
1703
  {
1432
1704
  style: {
1433
1705
  color: "#666"
@@ -1435,18 +1707,18 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1435
1707
  initial: { opacity: 0, y: -10 },
1436
1708
  animate: { opacity: 1, y: 0 },
1437
1709
  transition: { duration: 0.3, delay: 0 },
1438
- children: r && !t && !m ? /* @__PURE__ */ o(
1439
- M,
1710
+ children: r && !n && !m ? /* @__PURE__ */ o(
1711
+ R,
1440
1712
  {
1441
- text: u,
1713
+ text: p,
1442
1714
  duration: 2.5,
1443
1715
  repeat: !0,
1444
1716
  color: "#999",
1445
1717
  shimmerColor: "#000"
1446
1718
  }
1447
- ) : /* @__PURE__ */ y(E, { children: [
1448
- /* @__PURE__ */ o("span", { style: { color: "#666" }, children: u }),
1449
- m && !i && /* @__PURE__ */ y(E, { children: [
1719
+ ) : /* @__PURE__ */ g(F, { children: [
1720
+ /* @__PURE__ */ o("span", { style: { color: "#666" }, children: p }),
1721
+ m && !i && /* @__PURE__ */ g(F, { children: [
1450
1722
  " ",
1451
1723
  /* @__PURE__ */ o(
1452
1724
  "button",
@@ -1464,13 +1736,13 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1464
1736
  textDecoration: "underline",
1465
1737
  fontFamily: "inherit"
1466
1738
  },
1467
- children: S(n.moreMemories, {
1468
- n: c
1739
+ children: T(t.moreMemories, {
1740
+ n: d
1469
1741
  })
1470
1742
  }
1471
1743
  )
1472
1744
  ] }),
1473
- m && i && /* @__PURE__ */ y(E, { children: [
1745
+ m && i && /* @__PURE__ */ g(F, { children: [
1474
1746
  " ",
1475
1747
  /* @__PURE__ */ o(
1476
1748
  "button",
@@ -1488,14 +1760,14 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1488
1760
  textDecoration: "underline",
1489
1761
  fontFamily: "inherit"
1490
1762
  },
1491
- children: n.clickToCollapse
1763
+ children: t.clickToCollapse
1492
1764
  }
1493
1765
  )
1494
1766
  ] })
1495
1767
  ] })
1496
1768
  }
1497
1769
  ),
1498
- t !== void 0 && /* @__PURE__ */ o(
1770
+ n !== void 0 && /* @__PURE__ */ o(
1499
1771
  "div",
1500
1772
  {
1501
1773
  style: {
@@ -1504,31 +1776,31 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1504
1776
  marginTop: "4px",
1505
1777
  fontStyle: "italic"
1506
1778
  },
1507
- children: S(n.tookSeconds, { n: t })
1779
+ children: T(t.tookSeconds, { n })
1508
1780
  }
1509
1781
  )
1510
1782
  ] });
1511
- }, G = 5, Ve = ({ data: e, t: r }) => {
1512
- const [t, n] = I(!1), l = e.memories.map((g) => g.memoryTitle), a = l.length > 0, s = a && l.length > G, m = s && !t ? l.slice(0, G) : l, p = l.length - G, c = !s || t, d = l.length === 1 ? r.memoryFound : r.memoriesFoundPrefix, u = a ? `${d}${q(
1783
+ }, q = 5, Mr = ({ data: e, t: r }) => {
1784
+ const [n, t] = E(!1), l = e.memories.map((h) => h.memoryTitle), s = l.length > 0, c = s && l.length > q, m = c && !n ? l.slice(0, q) : l, y = l.length - q, d = !c || n, u = l.length === 1 ? r.memoryFound : r.memoriesFoundPrefix, p = s ? `${u}${K(
1513
1785
  m,
1514
- c ? r.and : void 0
1786
+ d ? r.and : void 0
1515
1787
  )}` : r.memoriesFound;
1516
1788
  return /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
1517
- C.div,
1789
+ I.div,
1518
1790
  {
1519
1791
  style: { color: "#666" },
1520
1792
  initial: { opacity: 0, y: -10 },
1521
1793
  animate: { opacity: 1, y: 0 },
1522
1794
  transition: { duration: 0.3, delay: 0 },
1523
- children: /* @__PURE__ */ y(E, { children: [
1524
- /* @__PURE__ */ o("span", { style: { color: "#666" }, children: u }),
1525
- s && !t && /* @__PURE__ */ y(E, { children: [
1795
+ children: /* @__PURE__ */ g(F, { children: [
1796
+ /* @__PURE__ */ o("span", { style: { color: "#666" }, children: p }),
1797
+ c && !n && /* @__PURE__ */ g(F, { children: [
1526
1798
  " ",
1527
1799
  /* @__PURE__ */ o(
1528
1800
  "button",
1529
1801
  {
1530
1802
  type: "button",
1531
- onClick: () => n(!0),
1803
+ onClick: () => t(!0),
1532
1804
  style: {
1533
1805
  background: "none",
1534
1806
  border: "none",
@@ -1540,19 +1812,19 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1540
1812
  textDecoration: "underline",
1541
1813
  fontFamily: "inherit"
1542
1814
  },
1543
- children: S(r.moreMemories, {
1544
- n: p
1815
+ children: T(r.moreMemories, {
1816
+ n: y
1545
1817
  })
1546
1818
  }
1547
1819
  )
1548
1820
  ] }),
1549
- s && t && /* @__PURE__ */ y(E, { children: [
1821
+ c && n && /* @__PURE__ */ g(F, { children: [
1550
1822
  " ",
1551
1823
  /* @__PURE__ */ o(
1552
1824
  "button",
1553
1825
  {
1554
1826
  type: "button",
1555
- onClick: () => n(!1),
1827
+ onClick: () => t(!1),
1556
1828
  style: {
1557
1829
  background: "none",
1558
1830
  border: "none",
@@ -1571,11 +1843,11 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1571
1843
  ] })
1572
1844
  }
1573
1845
  ) });
1574
- }, Ye = ({ isLatest: e = !1, durationSeconds: r, t }) => {
1575
- const n = t.addingSources;
1576
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1846
+ }, Rr = ({ isLatest: e = !1, durationSeconds: r, t: n }) => {
1847
+ const t = n.addingSources;
1848
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
1577
1849
  /* @__PURE__ */ o(
1578
- C.div,
1850
+ I.div,
1579
1851
  {
1580
1852
  style: {
1581
1853
  display: "flex",
@@ -1587,15 +1859,15 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1587
1859
  animate: { opacity: 1, y: 0 },
1588
1860
  transition: { duration: 0.3, delay: 0 },
1589
1861
  children: e && !r ? /* @__PURE__ */ o(
1590
- M,
1862
+ R,
1591
1863
  {
1592
- text: n,
1864
+ text: t,
1593
1865
  duration: 2.5,
1594
1866
  repeat: !0,
1595
1867
  color: "#999",
1596
1868
  shimmerColor: "#000"
1597
1869
  }
1598
- ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: n })
1870
+ ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: t })
1599
1871
  }
1600
1872
  ),
1601
1873
  r !== void 0 && /* @__PURE__ */ o(
@@ -1607,28 +1879,28 @@ const U = 5, Ke = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
1607
1879
  marginTop: "4px",
1608
1880
  fontStyle: "italic"
1609
1881
  },
1610
- children: S(t.tookSeconds, { n: r })
1882
+ children: T(n.tookSeconds, { n: r })
1611
1883
  }
1612
1884
  )
1613
1885
  ] });
1614
1886
  };
1615
- function Je(e, r) {
1887
+ function Fr(e, r) {
1616
1888
  if (e.length === 0) return "";
1617
1889
  if (e.length === 1)
1618
- return S(r.pageSingle, { n: e[0] });
1890
+ return T(r.pageSingle, { n: e[0] });
1619
1891
  if (e.length === 2)
1620
- return S(r.pageTwo, {
1892
+ return T(r.pageTwo, {
1621
1893
  a: e[0],
1622
1894
  b: e[1]
1623
1895
  });
1624
- const t = e[e.length - 1], n = e.slice(0, -1).join(", ");
1625
- return S(r.pageMultiple, { list: n, n: t });
1896
+ const n = e[e.length - 1], t = e.slice(0, -1).join(", ");
1897
+ return T(r.pageMultiple, { list: t, n });
1626
1898
  }
1627
- const Ze = ({ data: e, onSourceClick: r, t }) => {
1628
- const [n, i] = I(null);
1629
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1899
+ const Ar = ({ data: e, onSourceClick: r, t: n }) => {
1900
+ const [t, i] = E(null);
1901
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
1630
1902
  /* @__PURE__ */ o(
1631
- C.div,
1903
+ I.div,
1632
1904
  {
1633
1905
  style: {
1634
1906
  marginBottom: "10px",
@@ -1641,54 +1913,54 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1641
1913
  initial: { opacity: 0, y: -10 },
1642
1914
  animate: { opacity: 1, y: 0 },
1643
1915
  transition: { duration: 0.3, delay: 0 },
1644
- children: t.sources
1916
+ children: n.sources
1645
1917
  }
1646
1918
  ),
1647
- /* @__PURE__ */ o("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ o("span", { style: { fontSize: "13px", color: "#888" }, children: t.noSources }) : e.sources.map((l, a) => /* @__PURE__ */ o(
1648
- er,
1919
+ /* @__PURE__ */ o("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ o("span", { style: { fontSize: "13px", color: "#888" }, children: n.noSources }) : e.sources.map((l, s) => /* @__PURE__ */ o(
1920
+ Pr,
1649
1921
  {
1650
1922
  source: l,
1651
- index: a,
1652
- loadingMemoryId: n,
1923
+ index: s,
1924
+ loadingMemoryId: t,
1653
1925
  setLoadingMemoryId: i,
1654
1926
  onSourceClick: r,
1655
- t
1927
+ t: n
1656
1928
  },
1657
1929
  l.memoryId
1658
1930
  )) })
1659
1931
  ] });
1660
- }, er = ({
1932
+ }, Pr = ({
1661
1933
  source: e,
1662
1934
  index: r,
1663
- loadingMemoryId: t,
1664
- setLoadingMemoryId: n,
1935
+ loadingMemoryId: n,
1936
+ setLoadingMemoryId: t,
1665
1937
  onSourceClick: i,
1666
1938
  t: l
1667
1939
  }) => {
1668
- const [a, s] = I(!1), m = !!i, p = t === e.memoryId, c = e.pageNumbers ?? [], d = Je(c, l);
1669
- return /* @__PURE__ */ y(
1670
- C.div,
1940
+ const [s, c] = E(!1), m = !!i, y = n === e.memoryId, d = e.pageNumbers ?? [], u = Fr(d, l);
1941
+ return /* @__PURE__ */ g(
1942
+ I.div,
1671
1943
  {
1672
- "aria-busy": p,
1944
+ "aria-busy": y,
1673
1945
  initial: { opacity: 0, scale: 0.9 },
1674
1946
  animate: { opacity: 1, scale: 1 },
1675
1947
  transition: { duration: 0.25, delay: r * 0.05 },
1676
- onClick: m && !p ? async () => {
1677
- n(e.memoryId);
1948
+ onClick: m && !y ? async () => {
1949
+ t(e.memoryId);
1678
1950
  try {
1679
1951
  await i({
1680
1952
  memoryId: e.memoryId,
1681
1953
  memoryTitle: e.memoryTitle,
1682
1954
  memoryTypeId: e.memoryTypeId,
1683
1955
  memoryTypeName: e.memoryTypeName,
1684
- pageNumbers: [...c]
1956
+ pageNumbers: [...d]
1685
1957
  });
1686
1958
  } finally {
1687
- n(null);
1959
+ t(null);
1688
1960
  }
1689
1961
  } : void 0,
1690
- onMouseEnter: m && !p ? () => s(!0) : void 0,
1691
- onMouseLeave: m && !p ? () => s(!1) : void 0,
1962
+ onMouseEnter: m && !y ? () => c(!0) : void 0,
1963
+ onMouseLeave: m && !y ? () => c(!1) : void 0,
1692
1964
  style: {
1693
1965
  display: "inline-flex",
1694
1966
  flexDirection: "column",
@@ -1696,14 +1968,14 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1696
1968
  padding: "8px 12px",
1697
1969
  borderRadius: "6px",
1698
1970
  border: "1px solid #e0e0e0",
1699
- backgroundColor: a ? "#f5f5f5" : "transparent",
1700
- cursor: m && !p ? "pointer" : p ? "wait" : "default",
1971
+ backgroundColor: s ? "#f5f5f5" : "transparent",
1972
+ cursor: m && !y ? "pointer" : y ? "wait" : "default",
1701
1973
  transition: "background-color 0.15s ease",
1702
1974
  userSelect: "none",
1703
- pointerEvents: p ? "none" : void 0
1975
+ pointerEvents: y ? "none" : void 0
1704
1976
  },
1705
1977
  children: [
1706
- /* @__PURE__ */ y(
1978
+ /* @__PURE__ */ g(
1707
1979
  "span",
1708
1980
  {
1709
1981
  style: {
@@ -1715,7 +1987,7 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1715
1987
  gap: 8
1716
1988
  },
1717
1989
  children: [
1718
- p && /* @__PURE__ */ o(
1990
+ y && /* @__PURE__ */ o(
1719
1991
  "span",
1720
1992
  {
1721
1993
  className: "explore-memory-loader explore-memory-loader--callback",
@@ -1726,16 +1998,16 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1726
1998
  ]
1727
1999
  }
1728
2000
  ),
1729
- d && /* @__PURE__ */ o("span", { style: { fontSize: "12px", color: "#666" }, children: d })
2001
+ u && /* @__PURE__ */ o("span", { style: { fontSize: "12px", color: "#666" }, children: u })
1730
2002
  ]
1731
2003
  }
1732
2004
  );
1733
2005
  }, L = ({
1734
2006
  color: e = "#78b13f",
1735
2007
  size: r = 24,
1736
- borderWidth: t = 7
2008
+ borderWidth: n = 7
1737
2009
  }) => {
1738
- const n = r * 0.5;
2010
+ const t = r * 0.5;
1739
2011
  return /* @__PURE__ */ o(
1740
2012
  "span",
1741
2013
  {
@@ -1743,26 +2015,26 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1743
2015
  display: "inline-block",
1744
2016
  transform: "rotate(45deg)",
1745
2017
  height: r,
1746
- width: n,
1747
- borderBottom: `${t}px solid ${e}`,
1748
- borderRight: `${t}px solid ${e}`
2018
+ width: t,
2019
+ borderBottom: `${n}px solid ${e}`,
2020
+ borderRight: `${n}px solid ${e}`
1749
2021
  }
1750
2022
  }
1751
2023
  );
1752
- }, O = ({
2024
+ }, j = ({
1753
2025
  color: e = "#333",
1754
2026
  size: r = 32,
1755
- lineWidth: t = 2
2027
+ lineWidth: n = 2
1756
2028
  }) => {
1757
- const n = r + 1, i = (r - t) / 2, l = (r - n) / 2, a = {
2029
+ const t = r + 1, i = (r - n) / 2, l = (r - t) / 2, s = {
1758
2030
  position: "absolute",
1759
2031
  left: i,
1760
2032
  top: l,
1761
- width: t,
1762
- height: n,
2033
+ width: n,
2034
+ height: t,
1763
2035
  backgroundColor: e
1764
2036
  };
1765
- return /* @__PURE__ */ y(
2037
+ return /* @__PURE__ */ g(
1766
2038
  "span",
1767
2039
  {
1768
2040
  style: {
@@ -1776,7 +2048,7 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1776
2048
  "span",
1777
2049
  {
1778
2050
  style: {
1779
- ...a,
2051
+ ...s,
1780
2052
  transform: "rotate(45deg)"
1781
2053
  }
1782
2054
  }
@@ -1785,7 +2057,7 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1785
2057
  "span",
1786
2058
  {
1787
2059
  style: {
1788
- ...a,
2060
+ ...s,
1789
2061
  transform: "rotate(-45deg)"
1790
2062
  }
1791
2063
  }
@@ -1794,26 +2066,26 @@ const Ze = ({ data: e, onSourceClick: r, t }) => {
1794
2066
  }
1795
2067
  );
1796
2068
  };
1797
- function rr({
2069
+ function Dr({
1798
2070
  memory: e,
1799
2071
  completed: r
1800
2072
  }) {
1801
- return e.error != null ? /* @__PURE__ */ o(O, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : r ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2073
+ return e.error != null ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : r ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
1802
2074
  }
1803
- const ie = 80;
1804
- function nr({
2075
+ const se = 80;
2076
+ function Lr({
1805
2077
  memory: e,
1806
2078
  completed: r,
1807
- t
2079
+ t: n
1808
2080
  }) {
1809
- const [n, i] = I(!1), l = e.result ?? e.error, a = l != null && l.length > ie, s = l != null ? n || !a ? l : `${l.slice(0, ie)}...` : void 0, m = a, p = e.error != null;
1810
- return /* @__PURE__ */ y(
1811
- C.div,
2081
+ const [t, i] = E(!1), l = e.result ?? e.error, s = l != null && l.length > se, c = l != null ? t || !s ? l : `${l.slice(0, se)}...` : void 0, m = s, y = e.error != null;
2082
+ return /* @__PURE__ */ g(
2083
+ I.div,
1812
2084
  {
1813
2085
  initial: { opacity: 0 },
1814
2086
  animate: { opacity: 1 },
1815
2087
  transition: { duration: 0.25 },
1816
- onClick: m ? () => i((c) => !c) : void 0,
2088
+ onClick: m ? () => i((d) => !d) : void 0,
1817
2089
  style: {
1818
2090
  paddingTop: "12px",
1819
2091
  paddingBottom: "12px",
@@ -1836,10 +2108,10 @@ function nr({
1836
2108
  flexShrink: 0,
1837
2109
  width: 32
1838
2110
  },
1839
- children: /* @__PURE__ */ o(rr, { memory: e, completed: r })
2111
+ children: /* @__PURE__ */ o(Dr, { memory: e, completed: r })
1840
2112
  }
1841
2113
  ),
1842
- /* @__PURE__ */ y(
2114
+ /* @__PURE__ */ g(
1843
2115
  "div",
1844
2116
  {
1845
2117
  style: {
@@ -1856,16 +2128,16 @@ function nr({
1856
2128
  children: e.memoryTitle
1857
2129
  }
1858
2130
  ),
1859
- s != null && /* @__PURE__ */ o(
2131
+ c != null && /* @__PURE__ */ o(
1860
2132
  "span",
1861
2133
  {
1862
2134
  style: {
1863
2135
  fontSize: 12,
1864
- color: p ? "#c62828" : "#666",
2136
+ color: y ? "#c62828" : "#666",
1865
2137
  lineHeight: 1.4,
1866
- whiteSpace: n ? "pre-wrap" : void 0
2138
+ whiteSpace: t ? "pre-wrap" : void 0
1867
2139
  },
1868
- children: s
2140
+ children: c
1869
2141
  }
1870
2142
  ),
1871
2143
  m && /* @__PURE__ */ o(
@@ -1876,7 +2148,7 @@ function nr({
1876
2148
  color: "#999",
1877
2149
  marginTop: 2
1878
2150
  },
1879
- children: n ? t.clickToCollapse : t.clickToExpand
2151
+ children: t ? n.clickToCollapse : n.clickToExpand
1880
2152
  }
1881
2153
  )
1882
2154
  ]
@@ -1886,102 +2158,102 @@ function nr({
1886
2158
  }
1887
2159
  );
1888
2160
  }
1889
- const tr = ({ data: e, completed: r, t }) => /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: e.memories.map((n) => /* @__PURE__ */ o(
1890
- nr,
2161
+ const zr = ({ data: e, completed: r, t: n }) => /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: e.memories.map((t) => /* @__PURE__ */ o(
2162
+ Lr,
1891
2163
  {
1892
- memory: n,
2164
+ memory: t,
1893
2165
  completed: r,
1894
- t
2166
+ t: n
1895
2167
  },
1896
- n.memoryId
2168
+ t.memoryId
1897
2169
  )) });
1898
- function or(e, r) {
1899
- const t = Math.min(e.length, r.length);
1900
- for (let n = t; n >= 0; n--)
1901
- if (e.slice(-n) === r.slice(0, n)) return n;
2170
+ function Wr(e, r) {
2171
+ const n = Math.min(e.length, r.length);
2172
+ for (let t = n; t >= 0; t--)
2173
+ if (e.slice(-t) === r.slice(0, t)) return t;
1902
2174
  return 0;
1903
2175
  }
1904
- const ir = `
2176
+ const Nr = `
1905
2177
 
1906
2178
  `;
1907
- function Q(e) {
1908
- var t, n;
2179
+ function X(e) {
2180
+ var n, t;
1909
2181
  if (e.length === 0) return "";
1910
- let r = ((t = e[0]) == null ? void 0 : t.content) ?? "";
2182
+ let r = ((n = e[0]) == null ? void 0 : n.content) ?? "";
1911
2183
  for (let i = 1; i < e.length; i++) {
1912
- const l = ((n = e[i]) == null ? void 0 : n.content) ?? "";
2184
+ const l = ((t = e[i]) == null ? void 0 : t.content) ?? "";
1913
2185
  if (l === "") continue;
1914
2186
  if (r === "") {
1915
2187
  r = l;
1916
2188
  continue;
1917
2189
  }
1918
- const a = or(r, l);
1919
- a === 0 ? r += ir + l : r += l.slice(a);
2190
+ const s = Wr(r, l);
2191
+ s === 0 ? r += Nr + l : r += l.slice(s);
1920
2192
  }
1921
2193
  return r;
1922
2194
  }
1923
- function K(e, r) {
2195
+ function V(e, r) {
1924
2196
  if (e.length === 0) return "";
1925
2197
  if (e.length === 1)
1926
- return S(r.memorySearchPagesSingle, {
2198
+ return T(r.memorySearchPagesSingle, {
1927
2199
  n: e[0]
1928
2200
  });
1929
2201
  if (e.length === 2)
1930
- return S(r.memorySearchPagesTwo, {
2202
+ return T(r.memorySearchPagesTwo, {
1931
2203
  a: e[0],
1932
2204
  b: e[1]
1933
2205
  });
1934
- const t = e[e.length - 1], n = e.slice(0, -1).join(", ");
1935
- return S(r.memorySearchPagesMultiple, {
1936
- list: n,
1937
- n: t
2206
+ const n = e[e.length - 1], t = e.slice(0, -1).join(", ");
2207
+ return T(r.memorySearchPagesMultiple, {
2208
+ list: t,
2209
+ n
1938
2210
  });
1939
2211
  }
1940
- function X(e) {
2212
+ function Y(e) {
1941
2213
  const r = /* @__PURE__ */ new Set();
1942
- for (const t of e)
1943
- for (const n of t.pageNumbers) r.add(n);
1944
- return [...r].sort((t, n) => t - n);
2214
+ for (const n of e)
2215
+ for (const t of n.pageNumbers) r.add(t);
2216
+ return [...r].sort((n, t) => n - t);
1945
2217
  }
1946
- function V(e) {
2218
+ function J(e) {
1947
2219
  const r = e.memoryTypeName.trim();
1948
2220
  if (r !== "") return r;
1949
2221
  if (e.memoryTypeId !== "") return e.memoryTypeId;
1950
2222
  }
1951
- function pe(e) {
2223
+ function fe(e) {
1952
2224
  return e.chunks.filter((r) => r.relation === "MATCH").length;
1953
2225
  }
1954
- function ar(e, r) {
1955
- let t = 0, n = 0;
1956
- for (const a of e)
1957
- t += pe(a), a.matchingChunkScore > n && (n = a.matchingChunkScore);
1958
- const i = t === 1 ? r.chunkFound : S(r.chunksFound, { n: t }), l = S(r.scoreLabel, {
1959
- n: n.toFixed(2)
2226
+ function Or(e, r) {
2227
+ let n = 0, t = 0;
2228
+ for (const s of e)
2229
+ n += fe(s), s.matchingChunkScore > t && (t = s.matchingChunkScore);
2230
+ const i = n === 1 ? r.chunkFound : T(r.chunksFound, { n }), l = T(r.scoreLabel, {
2231
+ n: t.toFixed(2)
1960
2232
  });
1961
2233
  return `${i} - ${l}`;
1962
2234
  }
1963
- function sr(e) {
1964
- const r = [], t = /* @__PURE__ */ new Map();
1965
- return e.forEach((n, i) => {
1966
- let l = t.get(n.memoryId);
2235
+ function Br(e) {
2236
+ const r = [], n = /* @__PURE__ */ new Map();
2237
+ return e.forEach((t, i) => {
2238
+ let l = n.get(t.memoryId);
1967
2239
  if (l == null) {
1968
- r.push(n.memoryId);
1969
- const a = n.memoryTitle !== "" ? n.memoryTitle : n.memoryId;
2240
+ r.push(t.memoryId);
2241
+ const s = t.memoryTitle !== "" ? t.memoryTitle : t.memoryId;
1970
2242
  l = {
1971
- memoryId: n.memoryId,
1972
- memoryTitle: a,
2243
+ memoryId: t.memoryId,
2244
+ memoryTitle: s,
1973
2245
  items: []
1974
- }, t.set(n.memoryId, l);
2246
+ }, n.set(t.memoryId, l);
1975
2247
  }
1976
- l.items.push({ item: n, flatIndex: i });
1977
- }), r.map((n) => t.get(n));
2248
+ l.items.push({ item: t, flatIndex: i });
2249
+ }), r.map((t) => n.get(t));
1978
2250
  }
1979
- function lr({
2251
+ function jr({
1980
2252
  items: e,
1981
2253
  onSearchResultClick: r,
1982
- t
2254
+ t: n
1983
2255
  }) {
1984
- const [n, i] = I(null), l = !!r;
2256
+ const [t, i] = E(null), l = !!r;
1985
2257
  return /* @__PURE__ */ o(
1986
2258
  "div",
1987
2259
  {
@@ -1993,25 +2265,25 @@ function lr({
1993
2265
  paddingTop: 8,
1994
2266
  borderTop: "1px solid #f0f0f0"
1995
2267
  },
1996
- children: e.map((a, s) => {
1997
- const m = X(
1998
- a.chunks
1999
- ), p = [
2000
- V(a),
2001
- S(t.scoreLabel, {
2002
- n: a.matchingChunkScore.toFixed(2)
2268
+ children: e.map((s, c) => {
2269
+ const m = Y(
2270
+ s.chunks
2271
+ ), y = [
2272
+ J(s),
2273
+ T(n.scoreLabel, {
2274
+ n: s.matchingChunkScore.toFixed(2)
2003
2275
  }),
2004
- m.length > 0 ? K(m, t) : t.pagesNotAvailable
2276
+ m.length > 0 ? V(m, n) : n.pagesNotAvailable
2005
2277
  ].filter(
2006
- (g) => g != null && g !== ""
2007
- ), c = {
2008
- memoryId: a.memoryId,
2009
- memoryTitle: a.memoryTitle,
2010
- memoryTypeId: a.memoryTypeId,
2011
- memoryTypeName: a.memoryTypeName,
2278
+ (h) => h != null && h !== ""
2279
+ ), d = {
2280
+ memoryId: s.memoryId,
2281
+ memoryTitle: s.memoryTitle,
2282
+ memoryTypeId: s.memoryTypeId,
2283
+ memoryTypeName: s.memoryTypeName,
2012
2284
  pageNumbers: m
2013
- }, d = `${a.memoryId}-${s}`, u = n === d;
2014
- return /* @__PURE__ */ y(
2285
+ }, u = `${s.memoryId}-${c}`, p = t === u;
2286
+ return /* @__PURE__ */ g(
2015
2287
  "div",
2016
2288
  {
2017
2289
  style: {
@@ -2019,13 +2291,13 @@ function lr({
2019
2291
  flexDirection: "row",
2020
2292
  alignItems: "flex-start",
2021
2293
  gap: "12px",
2022
- paddingTop: s > 0 ? 12 : 0,
2023
- paddingBottom: s < e.length - 1 ? 12 : 0,
2024
- borderBottom: s < e.length - 1 ? "1px solid #eee" : void 0,
2294
+ paddingTop: c > 0 ? 12 : 0,
2295
+ paddingBottom: c < e.length - 1 ? 12 : 0,
2296
+ borderBottom: c < e.length - 1 ? "1px solid #eee" : void 0,
2025
2297
  minWidth: 0
2026
2298
  },
2027
2299
  children: [
2028
- /* @__PURE__ */ y(
2300
+ /* @__PURE__ */ g(
2029
2301
  "div",
2030
2302
  {
2031
2303
  style: {
@@ -2046,7 +2318,7 @@ function lr({
2046
2318
  whiteSpace: "pre-wrap",
2047
2319
  wordBreak: "break-word"
2048
2320
  },
2049
- children: Q(a.chunks)
2321
+ children: X(s.chunks)
2050
2322
  }
2051
2323
  ),
2052
2324
  /* @__PURE__ */ o(
@@ -2058,23 +2330,23 @@ function lr({
2058
2330
  color: "#94a3b8",
2059
2331
  lineHeight: 1.35
2060
2332
  },
2061
- children: p.join(" · ")
2333
+ children: y.join(" · ")
2062
2334
  }
2063
2335
  )
2064
2336
  ]
2065
2337
  }
2066
2338
  ),
2067
- l && /* @__PURE__ */ y(
2339
+ l && /* @__PURE__ */ g(
2068
2340
  "button",
2069
2341
  {
2070
2342
  type: "button",
2071
- "aria-busy": u,
2072
- disabled: u,
2343
+ "aria-busy": p,
2344
+ disabled: p,
2073
2345
  onClick: async () => {
2074
- i(d);
2346
+ i(u);
2075
2347
  try {
2076
2348
  await r(
2077
- c
2349
+ d
2078
2350
  );
2079
2351
  } finally {
2080
2352
  i(null);
@@ -2090,42 +2362,42 @@ function lr({
2090
2362
  background: "#eff6ff",
2091
2363
  border: "1px solid #bfdbfe",
2092
2364
  borderRadius: 6,
2093
- cursor: u ? "wait" : "pointer",
2365
+ cursor: p ? "wait" : "pointer",
2094
2366
  fontFamily: "inherit",
2095
2367
  display: "inline-flex",
2096
2368
  alignItems: "center",
2097
2369
  gap: 8
2098
2370
  },
2099
2371
  children: [
2100
- u && /* @__PURE__ */ o(
2372
+ p && /* @__PURE__ */ o(
2101
2373
  "span",
2102
2374
  {
2103
2375
  className: "explore-memory-loader explore-memory-loader--callback",
2104
2376
  "aria-hidden": !0
2105
2377
  }
2106
2378
  ),
2107
- t.viewButton
2379
+ n.viewButton
2108
2380
  ]
2109
2381
  }
2110
2382
  )
2111
2383
  ]
2112
2384
  },
2113
- d
2385
+ u
2114
2386
  );
2115
2387
  })
2116
2388
  }
2117
2389
  );
2118
2390
  }
2119
- function cr({
2391
+ function $r({
2120
2392
  group: e,
2121
2393
  t: r,
2122
- expanded: t,
2123
- onToggle: n,
2394
+ expanded: n,
2395
+ onToggle: t,
2124
2396
  onSearchResultClick: i
2125
2397
  }) {
2126
- const l = e.items.map((s) => s.item), a = l.some((s) => s.chunks.length > 0);
2127
- return /* @__PURE__ */ y(
2128
- C.div,
2398
+ const l = e.items.map((c) => c.item), s = l.some((c) => c.chunks.length > 0);
2399
+ return /* @__PURE__ */ g(
2400
+ I.div,
2129
2401
  {
2130
2402
  initial: { opacity: 0 },
2131
2403
  animate: { opacity: 1 },
@@ -2155,7 +2427,7 @@ function cr({
2155
2427
  children: /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 })
2156
2428
  }
2157
2429
  ),
2158
- /* @__PURE__ */ y(
2430
+ /* @__PURE__ */ g(
2159
2431
  "div",
2160
2432
  {
2161
2433
  style: {
@@ -2178,7 +2450,7 @@ function cr({
2178
2450
  children: e.memoryTitle
2179
2451
  }
2180
2452
  ),
2181
- /* @__PURE__ */ y(
2453
+ /* @__PURE__ */ g(
2182
2454
  "div",
2183
2455
  {
2184
2456
  style: {
@@ -2198,14 +2470,14 @@ function cr({
2198
2470
  color: "#666",
2199
2471
  whiteSpace: "nowrap"
2200
2472
  },
2201
- children: ar(l, r)
2473
+ children: Or(l, r)
2202
2474
  }
2203
2475
  ),
2204
- a && /* @__PURE__ */ o(
2476
+ s && /* @__PURE__ */ o(
2205
2477
  "button",
2206
2478
  {
2207
2479
  type: "button",
2208
- onClick: n,
2480
+ onClick: t,
2209
2481
  style: {
2210
2482
  border: "none",
2211
2483
  background: "none",
@@ -2216,14 +2488,14 @@ function cr({
2216
2488
  textDecoration: "underline",
2217
2489
  fontFamily: "inherit"
2218
2490
  },
2219
- children: t ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
2491
+ children: n ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
2220
2492
  }
2221
2493
  )
2222
2494
  ]
2223
2495
  }
2224
2496
  ),
2225
- t && a && /* @__PURE__ */ o(
2226
- lr,
2497
+ n && s && /* @__PURE__ */ o(
2498
+ jr,
2227
2499
  {
2228
2500
  items: l,
2229
2501
  onSearchResultClick: i,
@@ -2237,26 +2509,26 @@ function cr({
2237
2509
  }
2238
2510
  );
2239
2511
  }
2240
- function dr(e, r) {
2241
- return e === 1 ? r.chunkFound : S(r.chunksFound, { n: e });
2512
+ function Hr(e, r) {
2513
+ return e === 1 ? r.chunkFound : T(r.chunksFound, { n: e });
2242
2514
  }
2243
- const ur = ({
2515
+ const Ur = ({
2244
2516
  data: e,
2245
2517
  onSearchResultClick: r,
2246
- t
2518
+ t: n
2247
2519
  }) => {
2248
- const n = e.items, i = n.reduce(
2249
- (u, g) => u + pe(g),
2520
+ const t = e.items, i = t.reduce(
2521
+ (p, h) => p + fe(h),
2250
2522
  0
2251
- ), l = new Set(n.map((u) => u.memoryId)).size, [a, s] = I({}), m = z((u) => {
2252
- s((g) => ({
2253
- ...g,
2254
- [u]: !g[u]
2523
+ ), l = new Set(t.map((p) => p.memoryId)).size, [s, c] = E({}), m = O((p) => {
2524
+ c((h) => ({
2525
+ ...h,
2526
+ [p]: !h[p]
2255
2527
  }));
2256
- }, []), p = P(() => sr(n), [n]), c = l === 1 ? t.memoryChatChunkResultsInOneMemory : S(t.memoryChatChunkResultsInMemories, {
2528
+ }, []), y = z(() => Br(t), [t]), d = l === 1 ? n.memoryChatChunkResultsInOneMemory : T(n.memoryChatChunkResultsInMemories, {
2257
2529
  n: l
2258
- }), d = `${dr(i, t)} ${c}`;
2259
- return n.length === 0 ? /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: /* @__PURE__ */ o(
2530
+ }), u = `${Hr(i, n)} ${d}`;
2531
+ return t.length === 0 ? /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: /* @__PURE__ */ o(
2260
2532
  "div",
2261
2533
  {
2262
2534
  style: {
@@ -2264,19 +2536,19 @@ const ur = ({
2264
2536
  color: "#94a3b8",
2265
2537
  paddingTop: 4
2266
2538
  },
2267
- children: t.memorySearchExploreNoResults
2539
+ children: n.memorySearchExploreNoResults
2268
2540
  }
2269
- ) }) : /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
2270
- p.map((u) => /* @__PURE__ */ o(
2271
- cr,
2541
+ ) }) : /* @__PURE__ */ g("div", { style: { padding: "10px" }, children: [
2542
+ y.map((p) => /* @__PURE__ */ o(
2543
+ $r,
2272
2544
  {
2273
- group: u,
2274
- t,
2275
- expanded: a[u.memoryId] === !0,
2276
- onToggle: () => m(u.memoryId),
2545
+ group: p,
2546
+ t: n,
2547
+ expanded: s[p.memoryId] === !0,
2548
+ onToggle: () => m(p.memoryId),
2277
2549
  onSearchResultClick: r
2278
2550
  },
2279
- u.memoryId
2551
+ p.memoryId
2280
2552
  )),
2281
2553
  /* @__PURE__ */ o(
2282
2554
  "div",
@@ -2287,69 +2559,24 @@ const ur = ({
2287
2559
  marginTop: "4px",
2288
2560
  fontStyle: "italic"
2289
2561
  },
2290
- children: d
2291
- }
2292
- )
2293
- ] });
2294
- }, mr = ({
2295
- data: e,
2296
- isLatest: r = !1,
2297
- durationSeconds: t,
2298
- t: n
2299
- }) => {
2300
- const i = e.countryCode != null && e.countryCode !== "" ? S(n.googleSearchingForWithCountry, {
2301
- query: e.query,
2302
- country: e.countryCode
2303
- }) : S(n.googleSearchingFor, {
2304
- query: e.query
2305
- });
2306
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
2307
- /* @__PURE__ */ o(
2308
- C.div,
2309
- {
2310
- style: { color: "#666" },
2311
- initial: { opacity: 0, y: -10 },
2312
- animate: { opacity: 1, y: 0 },
2313
- transition: { duration: 0.3, delay: 0 },
2314
- children: r && !t ? /* @__PURE__ */ o(
2315
- M,
2316
- {
2317
- text: i,
2318
- duration: 2.5,
2319
- repeat: !0,
2320
- color: "#999",
2321
- shimmerColor: "#000"
2322
- }
2323
- ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: i })
2324
- }
2325
- ),
2326
- t !== void 0 && /* @__PURE__ */ o(
2327
- "div",
2328
- {
2329
- style: {
2330
- fontSize: "12px",
2331
- color: "#999",
2332
- marginTop: "4px",
2333
- fontStyle: "italic"
2334
- },
2335
- children: S(n.tookSeconds, { n: t })
2562
+ children: u
2336
2563
  }
2337
2564
  )
2338
2565
  ] });
2339
- }, ae = 80;
2340
- function pr(e) {
2566
+ }, le = 80;
2567
+ function _r(e) {
2341
2568
  try {
2342
2569
  return new URL(e).hostname;
2343
2570
  } catch {
2344
2571
  return e;
2345
2572
  }
2346
2573
  }
2347
- function yr({
2574
+ function Gr({
2348
2575
  item: e,
2349
2576
  t: r
2350
2577
  }) {
2351
- const [t, n] = I(!1), i = e.description ?? "", l = i.length > ae, a = i.length === 0 ? void 0 : t || !l ? i : `${i.slice(0, ae)}...`;
2352
- return /* @__PURE__ */ y(
2578
+ const [n, t] = E(!1), i = e.description ?? "", l = i.length > le, s = i.length === 0 ? void 0 : n || !l ? i : `${i.slice(0, le)}...`;
2579
+ return /* @__PURE__ */ g(
2353
2580
  "div",
2354
2581
  {
2355
2582
  style: {
@@ -2372,16 +2599,16 @@ function yr({
2372
2599
  textDecoration: "none",
2373
2600
  wordBreak: "break-word"
2374
2601
  },
2375
- onMouseEnter: (s) => {
2376
- s.currentTarget.style.color = "#2563eb";
2602
+ onMouseEnter: (c) => {
2603
+ c.currentTarget.style.color = "#2563eb";
2377
2604
  },
2378
- onMouseLeave: (s) => {
2379
- s.currentTarget.style.color = "#1f2937";
2605
+ onMouseLeave: (c) => {
2606
+ c.currentTarget.style.color = "#1f2937";
2380
2607
  },
2381
2608
  children: e.title
2382
2609
  }
2383
2610
  ),
2384
- /* @__PURE__ */ y(
2611
+ /* @__PURE__ */ g(
2385
2612
  "span",
2386
2613
  {
2387
2614
  style: {
@@ -2392,24 +2619,24 @@ function yr({
2392
2619
  children: [
2393
2620
  e.rank,
2394
2621
  ". ",
2395
- pr(e.link)
2622
+ _r(e.link)
2396
2623
  ]
2397
2624
  }
2398
2625
  ),
2399
- a != null && /* @__PURE__ */ y(E, { children: [
2626
+ s != null && /* @__PURE__ */ g(F, { children: [
2400
2627
  /* @__PURE__ */ o(
2401
2628
  "span",
2402
2629
  {
2403
- onClick: l ? () => n((s) => !s) : void 0,
2630
+ onClick: l ? () => t((c) => !c) : void 0,
2404
2631
  style: {
2405
2632
  fontSize: 13,
2406
2633
  color: "#666",
2407
2634
  lineHeight: 1.5,
2408
- whiteSpace: t ? "pre-wrap" : void 0,
2635
+ whiteSpace: n ? "pre-wrap" : void 0,
2409
2636
  wordBreak: "break-word",
2410
2637
  cursor: l ? "pointer" : "default"
2411
2638
  },
2412
- children: a
2639
+ children: s
2413
2640
  }
2414
2641
  ),
2415
2642
  l && /* @__PURE__ */ o(
@@ -2420,7 +2647,7 @@ function yr({
2420
2647
  color: "#999",
2421
2648
  marginTop: 2
2422
2649
  },
2423
- children: t ? r.clickToCollapse : r.clickToExpand
2650
+ children: n ? r.clickToCollapse : r.clickToExpand
2424
2651
  }
2425
2652
  )
2426
2653
  ] })
@@ -2428,11 +2655,57 @@ function yr({
2428
2655
  }
2429
2656
  );
2430
2657
  }
2431
- const gr = ({ data: e, t: r }) => {
2432
- const [t, n] = I(!1), i = P(
2433
- () => [...e.items].sort((s, m) => s.rank - m.rank),
2434
- [e.items]
2435
- ), l = i.length, a = l === 1 ? r.googleResultFound : S(r.googleResultsFound, { n: l });
2658
+ function qr({
2659
+ data: e,
2660
+ isLatest: r,
2661
+ durationSeconds: n,
2662
+ t
2663
+ }) {
2664
+ const i = e.input.countryCode, l = e.input.query, s = i != null && i !== "" ? T(t.googleSearchingForWithCountry, {
2665
+ query: l,
2666
+ country: i
2667
+ }) : T(t.googleSearchingFor, {
2668
+ query: l
2669
+ });
2670
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
2671
+ /* @__PURE__ */ o(
2672
+ I.div,
2673
+ {
2674
+ style: { color: "#666" },
2675
+ initial: { opacity: 0, y: -10 },
2676
+ animate: { opacity: 1, y: 0 },
2677
+ transition: { duration: 0.3, delay: 0 },
2678
+ children: r && !n ? /* @__PURE__ */ o(
2679
+ R,
2680
+ {
2681
+ text: s,
2682
+ duration: 2.5,
2683
+ repeat: !0,
2684
+ color: "#999",
2685
+ shimmerColor: "#000"
2686
+ }
2687
+ ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: s })
2688
+ }
2689
+ ),
2690
+ n !== void 0 && /* @__PURE__ */ o(
2691
+ "div",
2692
+ {
2693
+ style: {
2694
+ fontSize: "12px",
2695
+ color: "#999",
2696
+ marginTop: "4px",
2697
+ fontStyle: "italic"
2698
+ },
2699
+ children: T(t.tookSeconds, { n })
2700
+ }
2701
+ )
2702
+ ] });
2703
+ }
2704
+ function Qr({
2705
+ data: e,
2706
+ t: r
2707
+ }) {
2708
+ const [n, t] = E(!1), i = z(() => [...e.results ?? []].sort((m, y) => m.rank - y.rank), [e.results]), l = i.length, s = l === 1 ? r.googleResultFound : T(r.googleResultsFound, { n: l });
2436
2709
  return l === 0 ? /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: /* @__PURE__ */ o(
2437
2710
  "div",
2438
2711
  {
@@ -2443,9 +2716,9 @@ const gr = ({ data: e, t: r }) => {
2443
2716
  },
2444
2717
  children: r.memorySearchExploreNoResults
2445
2718
  }
2446
- ) }) : /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
2447
- /* @__PURE__ */ y(
2448
- C.div,
2719
+ ) }) : /* @__PURE__ */ g("div", { style: { padding: "10px" }, children: [
2720
+ /* @__PURE__ */ g(
2721
+ I.div,
2449
2722
  {
2450
2723
  initial: { opacity: 0 },
2451
2724
  animate: { opacity: 1 },
@@ -2467,14 +2740,14 @@ const gr = ({ data: e, t: r }) => {
2467
2740
  color: "#666",
2468
2741
  whiteSpace: "nowrap"
2469
2742
  },
2470
- children: a
2743
+ children: s
2471
2744
  }
2472
2745
  ),
2473
2746
  /* @__PURE__ */ o(
2474
2747
  "button",
2475
2748
  {
2476
2749
  type: "button",
2477
- onClick: () => n((s) => !s),
2750
+ onClick: () => t((c) => !c),
2478
2751
  style: {
2479
2752
  border: "none",
2480
2753
  background: "none",
@@ -2485,13 +2758,13 @@ const gr = ({ data: e, t: r }) => {
2485
2758
  textDecoration: "underline",
2486
2759
  fontFamily: "inherit"
2487
2760
  },
2488
- children: t ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
2761
+ children: n ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
2489
2762
  }
2490
2763
  )
2491
2764
  ]
2492
2765
  }
2493
2766
  ),
2494
- t && /* @__PURE__ */ o(
2767
+ n && /* @__PURE__ */ o(
2495
2768
  "div",
2496
2769
  {
2497
2770
  style: {
@@ -2502,7 +2775,7 @@ const gr = ({ data: e, t: r }) => {
2502
2775
  paddingTop: 8,
2503
2776
  borderTop: "1px solid #f0f0f0"
2504
2777
  },
2505
- children: i.map((s, m) => /* @__PURE__ */ o(
2778
+ children: i.map((c, m) => /* @__PURE__ */ o(
2506
2779
  "div",
2507
2780
  {
2508
2781
  style: {
@@ -2511,79 +2784,78 @@ const gr = ({ data: e, t: r }) => {
2511
2784
  borderBottom: m < i.length - 1 ? "1px solid #eee" : void 0,
2512
2785
  minWidth: 0
2513
2786
  },
2514
- children: /* @__PURE__ */ o(yr, { item: s, t: r })
2787
+ children: /* @__PURE__ */ o(Gr, { item: c, t: r })
2515
2788
  },
2516
- `${s.link}-${s.rank}-${m}`
2789
+ `${c.link}-${c.rank}-${m}`
2517
2790
  ))
2518
2791
  }
2519
2792
  )
2520
2793
  ] });
2521
- }, hr = ({
2794
+ }
2795
+ const Kr = ({
2522
2796
  data: e,
2523
2797
  isLatest: r = !1,
2524
- durationSeconds: t,
2525
- t: n
2526
- }) => {
2527
- const i = e.urls.length, l = i === 1 ? S(n.scrapingPage, { query: e.query }) : S(n.scrapingPages, { n: i, query: e.query });
2528
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
2529
- /* @__PURE__ */ o(
2530
- C.div,
2531
- {
2532
- style: { color: "#666" },
2533
- initial: { opacity: 0, y: -10 },
2534
- animate: { opacity: 1, y: 0 },
2535
- transition: { duration: 0.3, delay: 0 },
2536
- children: r && !t ? /* @__PURE__ */ o(
2537
- M,
2538
- {
2539
- text: l,
2540
- duration: 2.5,
2541
- repeat: !0,
2542
- color: "#999",
2543
- shimmerColor: "#000"
2544
- }
2545
- ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: l })
2546
- }
2547
- ),
2548
- t !== void 0 && /* @__PURE__ */ o(
2549
- "div",
2550
- {
2551
- style: {
2552
- fontSize: "12px",
2553
- color: "#999",
2554
- marginTop: "4px",
2555
- fontStyle: "italic"
2556
- },
2557
- children: S(n.tookSeconds, { n: t })
2558
- }
2559
- )
2560
- ] });
2561
- }, se = 80, Y = 12, J = 1.4, fr = Math.ceil(
2562
- Y * J
2563
- ), Sr = Math.ceil(
2564
- 5 * Y * J
2798
+ durationSeconds: n,
2799
+ t
2800
+ }) => e.results === void 0 ? /* @__PURE__ */ o(
2801
+ qr,
2802
+ {
2803
+ data: e,
2804
+ isLatest: r,
2805
+ durationSeconds: n,
2806
+ t
2807
+ }
2808
+ ) : /* @__PURE__ */ o(Qr, { data: e, t });
2809
+ function Se(e, r) {
2810
+ if (e.error != null)
2811
+ return null;
2812
+ switch (e.status) {
2813
+ case "downloading":
2814
+ return r.scrapeStatusDownloading;
2815
+ case "downloaded":
2816
+ return r.scrapeStatusDownloaded;
2817
+ case "analyzing":
2818
+ return r.scrapeStatusAnalyzing;
2819
+ case "summarizing":
2820
+ return r.scrapeStatusSummarizing;
2821
+ default:
2822
+ return null;
2823
+ }
2824
+ }
2825
+ function Xr(e) {
2826
+ var r;
2827
+ return e.error != null ? !0 : e.status != null ? !1 : (((r = e.summary) == null ? void 0 : r.length) ?? 0) > 0;
2828
+ }
2829
+ const ce = 80, Z = 12, ee = 1.4, Vr = Math.ceil(
2830
+ Z * ee
2831
+ ), Yr = Math.ceil(
2832
+ 5 * Z * ee
2565
2833
  );
2566
- function ye(e, r = 48) {
2834
+ function Te(e, r = 48) {
2567
2835
  try {
2568
- const t = new URL(e), n = t.pathname.length > r ? `${t.pathname.slice(0, r)}…` : t.pathname, i = n === "/" ? "" : n;
2569
- return `${t.hostname}${i}${t.search ? "…" : ""}`;
2836
+ const n = new URL(e), t = n.pathname.length > r ? `${n.pathname.slice(0, r)}…` : n.pathname, i = t === "/" ? "" : t;
2837
+ return `${n.hostname}${i}${n.search ? "…" : ""}`;
2570
2838
  } catch {
2571
2839
  return e.length > 64 ? `${e.slice(0, 64)}…` : e;
2572
2840
  }
2573
2841
  }
2574
- function xr({ item: e }) {
2575
- return e.error != null ? /* @__PURE__ */ o(O, { color: "#c62828", size: 15, lineWidth: 2 }) : e.summary != null && e.summary !== "" ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 });
2842
+ function Jr({ item: e }) {
2843
+ return e.error != null ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : e.summary != null && e.summary !== "" ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : e.status != null ? /* @__PURE__ */ o("span", { className: "explore-memory-loader" }) : /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 });
2576
2844
  }
2577
- function kr({ item: e }) {
2578
- return e.error != null ? /* @__PURE__ */ o(O, { color: "#c62828", size: 15, lineWidth: 2 }) : e.summary != null && e.summary !== "" ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2845
+ function Zr({ item: e }) {
2846
+ return e.error != null ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : e.summary != null && e.summary !== "" ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : e.status != null ? /* @__PURE__ */ o("span", { className: "explore-memory-loader" }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2579
2847
  }
2580
- function br({ item: e }) {
2581
- const r = e.error ?? e.summary ?? "", t = r.length > 0, n = e.error != null, i = A(null), l = e.summary != null && e.summary !== "", a = n || l;
2582
- return F(() => {
2583
- const s = i.current;
2584
- s != null && t && (s.scrollTop = s.scrollHeight);
2585
- }, [r, t]), /* @__PURE__ */ y(
2586
- C.div,
2848
+ function et({
2849
+ item: e,
2850
+ t: r,
2851
+ isLatest: n = !1
2852
+ }) {
2853
+ const t = e.error ?? e.summary ?? "", i = t.length > 0, l = e.error != null, s = D(null), c = e.summary != null && e.summary !== "", m = Se(e, r), y = l || c || !i && m != null, d = e.error == null && (e.summary == null || e.summary === "");
2854
+ return P(() => {
2855
+ const u = s.current;
2856
+ u != null && i && (u.scrollTop = u.scrollHeight);
2857
+ }, [t, i]), /* @__PURE__ */ g(
2858
+ I.div,
2587
2859
  {
2588
2860
  initial: { opacity: 0 },
2589
2861
  animate: { opacity: 1 },
@@ -2591,7 +2863,7 @@ function br({ item: e }) {
2591
2863
  style: {
2592
2864
  display: "flex",
2593
2865
  flexDirection: "row",
2594
- alignItems: a ? "flex-start" : "center",
2866
+ alignItems: d ? "center" : y ? "flex-start" : "center",
2595
2867
  gap: "10px",
2596
2868
  minWidth: 0
2597
2869
  },
@@ -2605,12 +2877,12 @@ function br({ item: e }) {
2605
2877
  justifyContent: "center",
2606
2878
  flexShrink: 0,
2607
2879
  width: 32,
2608
- ...a ? { paddingTop: 2 } : {}
2880
+ ...d || !y ? {} : { paddingTop: 2 }
2609
2881
  },
2610
- children: /* @__PURE__ */ o(kr, { item: e })
2882
+ children: /* @__PURE__ */ o(Zr, { item: e })
2611
2883
  }
2612
2884
  ),
2613
- /* @__PURE__ */ y(
2885
+ /* @__PURE__ */ g(
2614
2886
  "div",
2615
2887
  {
2616
2888
  style: {
@@ -2634,16 +2906,26 @@ function br({ item: e }) {
2634
2906
  textDecoration: "none",
2635
2907
  wordBreak: "break-all"
2636
2908
  },
2637
- onMouseEnter: (s) => {
2638
- s.currentTarget.style.textDecoration = "underline";
2909
+ onMouseEnter: (u) => {
2910
+ u.currentTarget.style.textDecoration = "underline";
2639
2911
  },
2640
- onMouseLeave: (s) => {
2641
- s.currentTarget.style.textDecoration = "none";
2912
+ onMouseLeave: (u) => {
2913
+ u.currentTarget.style.textDecoration = "none";
2642
2914
  },
2643
- children: ye(e.url)
2915
+ children: Te(e.url)
2644
2916
  }
2645
2917
  ),
2646
- t && /* @__PURE__ */ o(
2918
+ !i && m != null && /* @__PURE__ */ o("div", { style: { fontSize: 12, color: "#888", minHeight: 18 }, children: n ? /* @__PURE__ */ o(
2919
+ R,
2920
+ {
2921
+ text: m,
2922
+ duration: 2.5,
2923
+ repeat: !0,
2924
+ color: "#999",
2925
+ shimmerColor: "#000"
2926
+ }
2927
+ ) : /* @__PURE__ */ o("span", { style: { color: "#888" }, children: m }) }),
2928
+ i && /* @__PURE__ */ o(
2647
2929
  "div",
2648
2930
  {
2649
2931
  style: {
@@ -2655,20 +2937,20 @@ function br({ item: e }) {
2655
2937
  children: /* @__PURE__ */ o(
2656
2938
  "div",
2657
2939
  {
2658
- ref: i,
2940
+ ref: s,
2659
2941
  style: {
2660
- minHeight: fr,
2661
- maxHeight: Sr,
2942
+ minHeight: Vr,
2943
+ maxHeight: Yr,
2662
2944
  height: "auto",
2663
2945
  overflowY: "auto",
2664
2946
  overflowX: "hidden",
2665
- fontSize: Y,
2666
- lineHeight: J,
2947
+ fontSize: Z,
2948
+ lineHeight: ee,
2667
2949
  whiteSpace: "pre-wrap",
2668
2950
  wordBreak: "break-word",
2669
- color: n ? "#c62828" : "#888"
2951
+ color: l ? "#c62828" : "#888"
2670
2952
  },
2671
- children: r
2953
+ children: t
2672
2954
  }
2673
2955
  )
2674
2956
  }
@@ -2680,13 +2962,13 @@ function br({ item: e }) {
2680
2962
  }
2681
2963
  );
2682
2964
  }
2683
- function vr({
2965
+ function rt({
2684
2966
  item: e,
2685
2967
  t: r
2686
2968
  }) {
2687
- const [t, n] = I(!1), i = e.error ?? e.summary ?? "", l = e.error != null, a = i.length > se, s = i.length === 0 ? void 0 : t || !a ? i : `${i.slice(0, se)}...`;
2688
- return /* @__PURE__ */ y(
2689
- C.div,
2969
+ const [n, t] = E(!1), i = e.error ?? e.summary ?? "", l = e.error != null, s = i.length > ce, c = i.length === 0 ? void 0 : n || !s ? i : `${i.slice(0, ce)}...`, m = Se(e, r), y = e.error == null && (e.summary == null || e.summary === "") && e.status != null;
2970
+ return /* @__PURE__ */ g(
2971
+ I.div,
2690
2972
  {
2691
2973
  initial: { opacity: 0 },
2692
2974
  animate: { opacity: 1 },
@@ -2694,7 +2976,7 @@ function vr({
2694
2976
  style: {
2695
2977
  display: "flex",
2696
2978
  flexDirection: "row",
2697
- alignItems: "flex-start",
2979
+ alignItems: y ? "center" : "flex-start",
2698
2980
  gap: "10px",
2699
2981
  minWidth: 0
2700
2982
  },
@@ -2708,12 +2990,12 @@ function vr({
2708
2990
  justifyContent: "center",
2709
2991
  flexShrink: 0,
2710
2992
  width: 32,
2711
- paddingTop: 2
2993
+ ...y ? {} : { paddingTop: 2 }
2712
2994
  },
2713
- children: /* @__PURE__ */ o(xr, { item: e })
2995
+ children: /* @__PURE__ */ o(Jr, { item: e })
2714
2996
  }
2715
2997
  ),
2716
- /* @__PURE__ */ y(
2998
+ /* @__PURE__ */ g(
2717
2999
  "div",
2718
3000
  {
2719
3001
  style: {
@@ -2737,32 +3019,43 @@ function vr({
2737
3019
  textDecoration: "none",
2738
3020
  wordBreak: "break-all"
2739
3021
  },
2740
- onMouseEnter: (m) => {
2741
- m.currentTarget.style.textDecoration = "underline";
3022
+ onMouseEnter: (d) => {
3023
+ d.currentTarget.style.textDecoration = "underline";
2742
3024
  },
2743
- onMouseLeave: (m) => {
2744
- m.currentTarget.style.textDecoration = "none";
3025
+ onMouseLeave: (d) => {
3026
+ d.currentTarget.style.textDecoration = "none";
2745
3027
  },
2746
- children: ye(e.url)
3028
+ children: Te(e.url)
2747
3029
  }
2748
3030
  ),
2749
- s != null && /* @__PURE__ */ y(E, { children: [
3031
+ c == null && m != null && /* @__PURE__ */ o(
3032
+ "span",
3033
+ {
3034
+ style: {
3035
+ fontSize: 12,
3036
+ color: "#888",
3037
+ lineHeight: 1.4
3038
+ },
3039
+ children: m
3040
+ }
3041
+ ),
3042
+ c != null && /* @__PURE__ */ g(F, { children: [
2750
3043
  /* @__PURE__ */ o(
2751
3044
  "span",
2752
3045
  {
2753
- onClick: a ? () => n((m) => !m) : void 0,
3046
+ onClick: s ? () => t((d) => !d) : void 0,
2754
3047
  style: {
2755
3048
  fontSize: 12,
2756
3049
  color: l ? "#c62828" : "#666",
2757
3050
  lineHeight: 1.4,
2758
- whiteSpace: t ? "pre-wrap" : void 0,
3051
+ whiteSpace: n ? "pre-wrap" : void 0,
2759
3052
  wordBreak: "break-word",
2760
- cursor: a ? "pointer" : "default"
3053
+ cursor: s ? "pointer" : "default"
2761
3054
  },
2762
- children: s
3055
+ children: c
2763
3056
  }
2764
3057
  ),
2765
- a && /* @__PURE__ */ o(
3058
+ s && /* @__PURE__ */ o(
2766
3059
  "span",
2767
3060
  {
2768
3061
  style: {
@@ -2770,7 +3063,7 @@ function vr({
2770
3063
  color: "#999",
2771
3064
  marginTop: 2
2772
3065
  },
2773
- children: t ? r.clickToCollapse : r.clickToExpand
3066
+ children: n ? r.clickToCollapse : r.clickToExpand
2774
3067
  }
2775
3068
  )
2776
3069
  ] })
@@ -2781,7 +3074,7 @@ function vr({
2781
3074
  }
2782
3075
  );
2783
3076
  }
2784
- function le(e, r) {
3077
+ function de(e, r) {
2785
3078
  return /* @__PURE__ */ o(
2786
3079
  "div",
2787
3080
  {
@@ -2793,33 +3086,74 @@ function le(e, r) {
2793
3086
  paddingTop: 8,
2794
3087
  borderTop: "1px solid #f0f0f0"
2795
3088
  },
2796
- children: e.map((t, n) => /* @__PURE__ */ o(
3089
+ children: e.map((n, t) => /* @__PURE__ */ o(
2797
3090
  "div",
2798
3091
  {
2799
3092
  style: {
2800
- paddingTop: n > 0 ? 12 : 0,
2801
- paddingBottom: n < e.length - 1 ? 12 : 0,
2802
- borderBottom: n < e.length - 1 ? "1px solid #eee" : void 0,
3093
+ paddingTop: t > 0 ? 12 : 0,
3094
+ paddingBottom: t < e.length - 1 ? 12 : 0,
3095
+ borderBottom: t < e.length - 1 ? "1px solid #eee" : void 0,
2803
3096
  minWidth: 0
2804
3097
  },
2805
- children: r(t, n)
3098
+ children: r(n, t)
2806
3099
  },
2807
- `${t.url}-${n}`
3100
+ `${n.url}-${t}`
2808
3101
  ))
2809
3102
  }
2810
3103
  );
2811
3104
  }
2812
- const Tr = ({
3105
+ function tt({
2813
3106
  data: e,
2814
- isLatest: r = !1,
3107
+ isLatest: r,
3108
+ durationSeconds: n,
2815
3109
  t
2816
- }) => {
2817
- const [n, i] = I(!1), l = e.items, { successCount: a, errorCount: s } = P(() => {
2818
- let u = 0, g = 0;
2819
- for (const h of l)
2820
- h.error != null ? g += 1 : u += 1;
2821
- return { successCount: u, errorCount: g };
2822
- }, [l]), m = l.length, p = m === 1 ? t.scrapedPage : S(t.scrapedPages, { n: m }), c = S(t.scrapeOkCount, { n: a }), d = s > 0 ? `${p} - ${c}, ${S(t.scrapeFailedCount, { n: s })}` : `${p} - ${c}`;
3110
+ }) {
3111
+ const i = e.input.urls, l = e.input.query, s = i.length, c = s === 1 ? T(t.scrapingPage, { query: l }) : T(t.scrapingPages, { n: s, query: l });
3112
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
3113
+ /* @__PURE__ */ o(
3114
+ I.div,
3115
+ {
3116
+ style: { color: "#666" },
3117
+ initial: { opacity: 0, y: -10 },
3118
+ animate: { opacity: 1, y: 0 },
3119
+ transition: { duration: 0.3, delay: 0 },
3120
+ children: r && !n ? /* @__PURE__ */ o(
3121
+ R,
3122
+ {
3123
+ text: c,
3124
+ duration: 2.5,
3125
+ repeat: !0,
3126
+ color: "#999",
3127
+ shimmerColor: "#000"
3128
+ }
3129
+ ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: c })
3130
+ }
3131
+ ),
3132
+ n !== void 0 && /* @__PURE__ */ o(
3133
+ "div",
3134
+ {
3135
+ style: {
3136
+ fontSize: "12px",
3137
+ color: "#999",
3138
+ marginTop: "4px",
3139
+ fontStyle: "italic"
3140
+ },
3141
+ children: T(t.tookSeconds, { n })
3142
+ }
3143
+ )
3144
+ ] });
3145
+ }
3146
+ function nt({
3147
+ data: e,
3148
+ isLatest: r = !1,
3149
+ t: n
3150
+ }) {
3151
+ const [t, i] = E(!1), l = e.results ?? [], { successCount: s, errorCount: c } = z(() => {
3152
+ let f = 0, S = 0;
3153
+ for (const x of l)
3154
+ x.error != null ? S += 1 : f += 1;
3155
+ return { successCount: f, errorCount: S };
3156
+ }, [l]), m = l.length, y = e.input.query, d = l.length > 0 && l.every((f) => Xr(f)), u = r && !d ? m === 1 ? T(n.scrapingPage, { query: y }) : T(n.scrapingPages, { n: m, query: y }) : m === 1 ? n.scrapedPage : T(n.scrapedPages, { n: m }), p = T(n.scrapeOkCount, { n: s }), h = c > 0 ? `${u} - ${p}, ${T(n.scrapeFailedCount, { n: c })}` : `${u} - ${p}`;
2823
3157
  return m === 0 ? /* @__PURE__ */ o("div", { style: { padding: "10px" }, children: /* @__PURE__ */ o(
2824
3158
  "div",
2825
3159
  {
@@ -2828,11 +3162,11 @@ const Tr = ({
2828
3162
  color: "#94a3b8",
2829
3163
  paddingTop: 4
2830
3164
  },
2831
- children: t.memorySearchExploreNoResults
3165
+ children: n.memorySearchExploreNoResults
2832
3166
  }
2833
- ) }) : r ? /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
3167
+ ) }) : r ? /* @__PURE__ */ g("div", { style: { padding: "10px" }, children: [
2834
3168
  /* @__PURE__ */ o(
2835
- C.div,
3169
+ I.div,
2836
3170
  {
2837
3171
  initial: { opacity: 0 },
2838
3172
  animate: { opacity: 1 },
@@ -2845,22 +3179,38 @@ const Tr = ({
2845
3179
  gap: "6px 12px",
2846
3180
  minWidth: 0
2847
3181
  },
2848
- children: /* @__PURE__ */ o(
3182
+ children: r && !d ? /* @__PURE__ */ o(
3183
+ R,
3184
+ {
3185
+ text: h,
3186
+ duration: 2.5,
3187
+ repeat: !0,
3188
+ color: "#999",
3189
+ shimmerColor: "#000"
3190
+ }
3191
+ ) : /* @__PURE__ */ o(
2849
3192
  "span",
2850
3193
  {
2851
3194
  style: {
2852
3195
  fontSize: 12,
2853
3196
  color: "#666"
2854
3197
  },
2855
- children: d
3198
+ children: h
2856
3199
  }
2857
3200
  )
2858
3201
  }
2859
3202
  ),
2860
- le(l, (u) => /* @__PURE__ */ o(br, { item: u }))
2861
- ] }) : /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
2862
- /* @__PURE__ */ y(
2863
- C.div,
3203
+ de(l, (f) => /* @__PURE__ */ o(
3204
+ et,
3205
+ {
3206
+ item: f,
3207
+ t: n,
3208
+ isLatest: r
3209
+ }
3210
+ ))
3211
+ ] }) : /* @__PURE__ */ g("div", { style: { padding: "10px" }, children: [
3212
+ /* @__PURE__ */ g(
3213
+ I.div,
2864
3214
  {
2865
3215
  initial: { opacity: 0 },
2866
3216
  animate: { opacity: 1 },
@@ -2881,14 +3231,14 @@ const Tr = ({
2881
3231
  fontSize: 12,
2882
3232
  color: "#666"
2883
3233
  },
2884
- children: d
3234
+ children: h
2885
3235
  }
2886
3236
  ),
2887
3237
  /* @__PURE__ */ o(
2888
3238
  "button",
2889
3239
  {
2890
3240
  type: "button",
2891
- onClick: () => i((u) => !u),
3241
+ onClick: () => i((f) => !f),
2892
3242
  style: {
2893
3243
  border: "none",
2894
3244
  background: "none",
@@ -2899,31 +3249,87 @@ const Tr = ({
2899
3249
  textDecoration: "underline",
2900
3250
  fontFamily: "inherit"
2901
3251
  },
2902
- children: n ? t.memorySearchHideExploreResults : t.memorySearchViewExploreResults
3252
+ children: t ? n.memorySearchHideExploreResults : n.memorySearchViewExploreResults
2903
3253
  }
2904
3254
  )
2905
3255
  ]
2906
3256
  }
2907
3257
  ),
2908
- n && le(l, (u) => /* @__PURE__ */ o(vr, { item: u, t }))
3258
+ t && de(l, (f) => /* @__PURE__ */ o(rt, { item: f, t: n }))
3259
+ ] });
3260
+ }
3261
+ const ot = ({ data: e, isLatest: r = !1, durationSeconds: n, t }) => e.results === void 0 ? /* @__PURE__ */ o(
3262
+ tt,
3263
+ {
3264
+ data: e,
3265
+ isLatest: r,
3266
+ durationSeconds: n,
3267
+ t
3268
+ }
3269
+ ) : /* @__PURE__ */ o(
3270
+ nt,
3271
+ {
3272
+ data: e,
3273
+ isLatest: r,
3274
+ t
3275
+ }
3276
+ ), at = (e) => {
3277
+ const { isLatest: r = !1, durationSeconds: n, t } = e, i = t.memoryChatThinking;
3278
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
3279
+ /* @__PURE__ */ o(
3280
+ I.div,
3281
+ {
3282
+ style: {
3283
+ display: "flex",
3284
+ alignItems: "center",
3285
+ gap: "10px",
3286
+ color: "#666"
3287
+ },
3288
+ initial: { opacity: 0, y: -10 },
3289
+ animate: { opacity: 1, y: 0 },
3290
+ transition: { duration: 0.3, delay: 0 },
3291
+ children: r && !n ? /* @__PURE__ */ o(
3292
+ R,
3293
+ {
3294
+ text: i,
3295
+ duration: 2.5,
3296
+ repeat: !0,
3297
+ color: "#999",
3298
+ shimmerColor: "#000"
3299
+ }
3300
+ ) : /* @__PURE__ */ o("span", { style: { color: "#666" }, children: i })
3301
+ }
3302
+ ),
3303
+ n !== void 0 && /* @__PURE__ */ o(
3304
+ "div",
3305
+ {
3306
+ style: {
3307
+ fontSize: "12px",
3308
+ color: "#999",
3309
+ marginTop: "4px",
3310
+ fontStyle: "italic"
3311
+ },
3312
+ children: T(t.tookSeconds, { n })
3313
+ }
3314
+ )
2909
3315
  ] });
2910
3316
  };
2911
- function wr({ item: e }) {
2912
- return e.error != null ? /* @__PURE__ */ o(O, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
3317
+ function it({ item: e }) {
3318
+ return e.error != null ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
2913
3319
  }
2914
- function Cr(e, r) {
2915
- return S(r.searchingInMemoriesOfType, {
3320
+ function st(e, r) {
3321
+ return T(r.searchingInMemoriesOfType, {
2916
3322
  name: e.memoryTypeName
2917
3323
  });
2918
3324
  }
2919
- function Ir({
3325
+ function lt({
2920
3326
  item: e,
2921
3327
  t: r,
2922
- showShimmerForPrimary: t
3328
+ showShimmerForPrimary: n
2923
3329
  }) {
2924
- const n = e.result != null, i = e.error != null, l = Cr(e, r);
2925
- return /* @__PURE__ */ y(
2926
- C.div,
3330
+ const t = e.result != null, i = e.error != null, l = st(e, r);
3331
+ return /* @__PURE__ */ g(
3332
+ I.div,
2927
3333
  {
2928
3334
  initial: { opacity: 0 },
2929
3335
  animate: { opacity: 1 },
@@ -2949,10 +3355,10 @@ function Ir({
2949
3355
  flexShrink: 0,
2950
3356
  width: 32
2951
3357
  },
2952
- children: /* @__PURE__ */ o(wr, { item: e })
3358
+ children: /* @__PURE__ */ o(it, { item: e })
2953
3359
  }
2954
3360
  ),
2955
- /* @__PURE__ */ y(
3361
+ /* @__PURE__ */ g(
2956
3362
  "div",
2957
3363
  {
2958
3364
  style: {
@@ -2963,8 +3369,8 @@ function Ir({
2963
3369
  flex: 1
2964
3370
  },
2965
3371
  children: [
2966
- /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: !n && !i && t ? /* @__PURE__ */ o(
2967
- M,
3372
+ /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: !t && !i && n ? /* @__PURE__ */ o(
3373
+ R,
2968
3374
  {
2969
3375
  text: l,
2970
3376
  duration: 2.5,
@@ -2973,14 +3379,14 @@ function Ir({
2973
3379
  shimmerColor: "#000"
2974
3380
  }
2975
3381
  ) : l }),
2976
- n && /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#666" }, children: e.result.numberOfChunks === 1 ? S(
3382
+ t && /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#666" }, children: e.result.numberOfChunks === 1 ? T(
2977
3383
  r.memorySearchTypeResultSummaryOne,
2978
3384
  {
2979
3385
  score: e.result.highestChunkScore.toFixed(
2980
3386
  2
2981
3387
  )
2982
3388
  }
2983
- ) : S(
3389
+ ) : T(
2984
3390
  r.memorySearchTypeResultSummary,
2985
3391
  {
2986
3392
  count: e.result.numberOfChunks,
@@ -2997,33 +3403,33 @@ function Ir({
2997
3403
  }
2998
3404
  );
2999
3405
  }
3000
- const Er = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
3001
- const i = P(() => {
3406
+ const ct = ({ data: e, isLatest: r = !1, durationSeconds: n, t }) => {
3407
+ const i = z(() => {
3002
3408
  let l = -1;
3003
- return e.memoryTypes.forEach((a, s) => {
3004
- a.result == null && a.error == null && (l = s);
3409
+ return e.memoryTypes.forEach((s, c) => {
3410
+ s.result == null && s.error == null && (l = c);
3005
3411
  }), l;
3006
3412
  }, [e.memoryTypes]);
3007
- return /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
3008
- r && !t && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
3009
- M,
3413
+ return /* @__PURE__ */ g("div", { style: { padding: "10px" }, children: [
3414
+ r && !n && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
3415
+ R,
3010
3416
  {
3011
- text: n.searchingMemoryTypes,
3417
+ text: t.searchingMemoryTypes,
3012
3418
  duration: 2.5,
3013
3419
  repeat: !0,
3014
3420
  color: "#999",
3015
3421
  shimmerColor: "#000"
3016
3422
  }
3017
- ) : e.memoryTypes.map((l, a) => /* @__PURE__ */ o(
3018
- Ir,
3423
+ ) : e.memoryTypes.map((l, s) => /* @__PURE__ */ o(
3424
+ lt,
3019
3425
  {
3020
3426
  item: l,
3021
- t: n,
3022
- showShimmerForPrimary: a === i && r
3427
+ t,
3428
+ showShimmerForPrimary: s === i && r
3023
3429
  },
3024
3430
  l.memoryTypeId
3025
3431
  )),
3026
- t !== void 0 && /* @__PURE__ */ o(
3432
+ n !== void 0 && /* @__PURE__ */ o(
3027
3433
  "div",
3028
3434
  {
3029
3435
  style: {
@@ -3032,45 +3438,45 @@ const Er = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
3032
3438
  marginTop: "4px",
3033
3439
  fontStyle: "italic"
3034
3440
  },
3035
- children: S(n.tookSeconds, { n: t })
3441
+ children: T(t.tookSeconds, { n })
3036
3442
  }
3037
3443
  )
3038
3444
  ] });
3039
- }, $ = 12, H = 1.45, Mr = Math.ceil(
3040
- $ * H
3041
- ), Rr = Math.ceil(
3042
- 5 * $ * H
3445
+ }, H = 12, U = 1.45, dt = Math.ceil(
3446
+ H * U
3447
+ ), ut = Math.ceil(
3448
+ 5 * H * U
3043
3449
  );
3044
3450
  function B(e) {
3045
3451
  return e.queries != null && e.queries.length > 0;
3046
3452
  }
3047
- function Fr(e) {
3453
+ function mt(e) {
3048
3454
  const r = e.reasoning;
3049
3455
  return (r == null || r === "") && !B(e);
3050
3456
  }
3051
- function Ar(e) {
3457
+ function pt(e) {
3052
3458
  if (B(e)) return 3;
3053
3459
  const r = e.reasoning;
3054
3460
  return r == null || r === "" ? 1 : e.reasoningCompleted === !0 ? 2 : 1;
3055
3461
  }
3056
- function Lr({ phase: e }) {
3462
+ function yt({ phase: e }) {
3057
3463
  return e === 3 ? /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ o("span", { className: "explore-memory-loader" });
3058
3464
  }
3059
- function Pr({
3465
+ function ht({
3060
3466
  item: e,
3061
3467
  t: r,
3062
- isActiveRow: t
3468
+ isActiveRow: n
3063
3469
  }) {
3064
- const n = Fr(e), i = Ar(e), l = e.reasoning, a = l != null && l.length > 0, s = A(null), [m, p] = I(!1), c = n && t, d = i === 2 && t && !B(e);
3065
- F(() => {
3066
- const h = s.current;
3067
- h != null && i === 1 && a && (h.scrollTop = h.scrollHeight);
3068
- }, [l, i, a]);
3069
- const u = S(r.searchingInMemoriesOfType, {
3470
+ const t = mt(e), i = pt(e), l = e.reasoning, s = l != null && l.length > 0, c = D(null), [m, y] = E(!1), d = t && n, u = i === 2 && n && !B(e);
3471
+ P(() => {
3472
+ const f = c.current;
3473
+ f != null && i === 1 && s && (f.scrollTop = f.scrollHeight);
3474
+ }, [l, i, s]);
3475
+ const p = T(r.searchingInMemoriesOfType, {
3070
3476
  name: e.memoryTypeName
3071
- }), g = !n && i === 3;
3072
- return /* @__PURE__ */ y(
3073
- C.div,
3477
+ }), h = !t && i === 3;
3478
+ return /* @__PURE__ */ g(
3479
+ I.div,
3074
3480
  {
3075
3481
  initial: { opacity: 0 },
3076
3482
  animate: { opacity: 1 },
@@ -3081,7 +3487,7 @@ function Pr({
3081
3487
  borderBottom: "1px solid #eee",
3082
3488
  display: "flex",
3083
3489
  flexDirection: "row",
3084
- alignItems: g ? "flex-start" : "center",
3490
+ alignItems: h ? "flex-start" : "center",
3085
3491
  gap: "10px",
3086
3492
  minWidth: 0
3087
3493
  },
@@ -3095,12 +3501,12 @@ function Pr({
3095
3501
  justifyContent: "center",
3096
3502
  flexShrink: 0,
3097
3503
  width: 32,
3098
- ...g ? { paddingTop: 2 } : {}
3504
+ ...h ? { paddingTop: 2 } : {}
3099
3505
  },
3100
- children: /* @__PURE__ */ o(Lr, { phase: n ? 1 : i })
3506
+ children: /* @__PURE__ */ o(yt, { phase: t ? 1 : i })
3101
3507
  }
3102
3508
  ),
3103
- /* @__PURE__ */ y(
3509
+ /* @__PURE__ */ g(
3104
3510
  "div",
3105
3511
  {
3106
3512
  style: {
@@ -3111,17 +3517,17 @@ function Pr({
3111
3517
  flex: 1
3112
3518
  },
3113
3519
  children: [
3114
- /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: c ? /* @__PURE__ */ o(
3115
- M,
3520
+ /* @__PURE__ */ o("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: d ? /* @__PURE__ */ o(
3521
+ R,
3116
3522
  {
3117
- text: u,
3523
+ text: p,
3118
3524
  duration: 2.5,
3119
3525
  repeat: !0,
3120
3526
  color: "#999",
3121
3527
  shimmerColor: "#000"
3122
3528
  }
3123
3529
  ) : e.memoryTypeName }),
3124
- i === 1 && a && !B(e) && /* @__PURE__ */ y("div", { style: { minWidth: 0 }, children: [
3530
+ i === 1 && s && !B(e) && /* @__PURE__ */ g("div", { style: { minWidth: 0 }, children: [
3125
3531
  /* @__PURE__ */ o(
3126
3532
  "span",
3127
3533
  {
@@ -3147,16 +3553,16 @@ function Pr({
3147
3553
  children: /* @__PURE__ */ o(
3148
3554
  "div",
3149
3555
  {
3150
- ref: s,
3556
+ ref: c,
3151
3557
  className: "memory-search-generating-reasoning-viewport",
3152
3558
  style: {
3153
- minHeight: Mr,
3154
- maxHeight: Rr,
3559
+ minHeight: dt,
3560
+ maxHeight: ut,
3155
3561
  height: "auto",
3156
3562
  overflowY: "auto",
3157
3563
  overflowX: "hidden",
3158
- fontSize: $,
3159
- lineHeight: H,
3564
+ fontSize: H,
3565
+ lineHeight: U,
3160
3566
  whiteSpace: "pre-wrap",
3161
3567
  wordBreak: "break-word",
3162
3568
  color: "#888"
@@ -3167,8 +3573,8 @@ function Pr({
3167
3573
  }
3168
3574
  )
3169
3575
  ] }),
3170
- i === 2 && d && /* @__PURE__ */ o("div", { style: { fontSize: 12 }, children: /* @__PURE__ */ o(
3171
- M,
3576
+ i === 2 && u && /* @__PURE__ */ o("div", { style: { fontSize: 12 }, children: /* @__PURE__ */ o(
3577
+ R,
3172
3578
  {
3173
3579
  text: r.memorySearchGeneratingQueriesPending,
3174
3580
  duration: 2.5,
@@ -3177,8 +3583,8 @@ function Pr({
3177
3583
  shimmerColor: "#000"
3178
3584
  }
3179
3585
  ) }),
3180
- i === 3 && /* @__PURE__ */ y(E, { children: [
3181
- /* @__PURE__ */ y("div", { style: { minWidth: 0 }, children: [
3586
+ i === 3 && /* @__PURE__ */ g(F, { children: [
3587
+ /* @__PURE__ */ g("div", { style: { minWidth: 0 }, children: [
3182
3588
  /* @__PURE__ */ o(
3183
3589
  "span",
3184
3590
  {
@@ -3200,7 +3606,7 @@ function Pr({
3200
3606
  flexDirection: "column",
3201
3607
  gap: 6
3202
3608
  },
3203
- children: e.queries.map((h, f) => /* @__PURE__ */ o(
3609
+ children: e.queries.map((f, S) => /* @__PURE__ */ o(
3204
3610
  "div",
3205
3611
  {
3206
3612
  style: {
@@ -3209,19 +3615,19 @@ function Pr({
3209
3615
  lineHeight: 1.5,
3210
3616
  wordBreak: "break-word"
3211
3617
  },
3212
- children: h.query
3618
+ children: f.query
3213
3619
  },
3214
- f
3620
+ S
3215
3621
  ))
3216
3622
  }
3217
3623
  )
3218
3624
  ] }),
3219
- a && /* @__PURE__ */ y(E, { children: [
3625
+ s && /* @__PURE__ */ g(F, { children: [
3220
3626
  /* @__PURE__ */ o(
3221
3627
  "button",
3222
3628
  {
3223
3629
  type: "button",
3224
- onClick: () => p((h) => !h),
3630
+ onClick: () => y((f) => !f),
3225
3631
  style: {
3226
3632
  alignSelf: "flex-start",
3227
3633
  border: "none",
@@ -3239,8 +3645,8 @@ function Pr({
3239
3645
  "div",
3240
3646
  {
3241
3647
  style: {
3242
- fontSize: $,
3243
- lineHeight: H,
3648
+ fontSize: H,
3649
+ lineHeight: U,
3244
3650
  whiteSpace: "pre-wrap",
3245
3651
  wordBreak: "break-word",
3246
3652
  color: "#888",
@@ -3260,33 +3666,33 @@ function Pr({
3260
3666
  }
3261
3667
  );
3262
3668
  }
3263
- const Dr = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
3264
- const i = P(() => {
3669
+ const gt = ({ data: e, isLatest: r = !1, durationSeconds: n, t }) => {
3670
+ const i = z(() => {
3265
3671
  let l = -1;
3266
- return e.memoryTypes.forEach((a, s) => {
3267
- B(a) || (l = s);
3672
+ return e.memoryTypes.forEach((s, c) => {
3673
+ B(s) || (l = c);
3268
3674
  }), l;
3269
3675
  }, [e.memoryTypes]);
3270
- return /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
3271
- r && !t && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
3272
- M,
3676
+ return /* @__PURE__ */ g("div", { style: { padding: "10px" }, children: [
3677
+ r && !n && e.memoryTypes.length === 0 ? /* @__PURE__ */ o(
3678
+ R,
3273
3679
  {
3274
- text: n.memorySearchGeneratingQueries,
3680
+ text: t.memorySearchGeneratingQueries,
3275
3681
  duration: 2.5,
3276
3682
  repeat: !0,
3277
3683
  color: "#999",
3278
3684
  shimmerColor: "#000"
3279
3685
  }
3280
- ) : e.memoryTypes.map((l, a) => /* @__PURE__ */ o(
3281
- Pr,
3686
+ ) : e.memoryTypes.map((l, s) => /* @__PURE__ */ o(
3687
+ ht,
3282
3688
  {
3283
3689
  item: l,
3284
- t: n,
3285
- isActiveRow: a === i && r
3690
+ t,
3691
+ isActiveRow: s === i && r
3286
3692
  },
3287
3693
  l.memoryTypeId
3288
3694
  )),
3289
- t !== void 0 && /* @__PURE__ */ o(
3695
+ n !== void 0 && /* @__PURE__ */ o(
3290
3696
  "div",
3291
3697
  {
3292
3698
  style: {
@@ -3295,20 +3701,20 @@ const Dr = ({ data: e, isLatest: r = !1, durationSeconds: t, t: n }) => {
3295
3701
  marginTop: "4px",
3296
3702
  fontStyle: "italic"
3297
3703
  },
3298
- children: S(n.tookSeconds, { n: t })
3704
+ children: T(t.tookSeconds, { n })
3299
3705
  }
3300
3706
  )
3301
3707
  ] });
3302
3708
  };
3303
- function Wr(e) {
3304
- return e.some((n) => n.result == null && n.error == null) ? /* @__PURE__ */ o("span", { className: "explore-memory-loader" }) : e.some((n) => n.error != null) ? /* @__PURE__ */ o(O, { color: "#c62828", size: 15, lineWidth: 2 }) : /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 });
3709
+ function ft(e) {
3710
+ return e.some((t) => t.result == null && t.error == null) ? /* @__PURE__ */ o("span", { className: "explore-memory-loader" }) : e.some((t) => t.error != null) ? /* @__PURE__ */ o(j, { color: "#c62828", size: 15, lineWidth: 2 }) : /* @__PURE__ */ o(L, { color: "#999", size: 15, borderWidth: 2 });
3305
3711
  }
3306
- function zr(e, r) {
3712
+ function St(e, r) {
3307
3713
  if (e.error != null)
3308
3714
  return /* @__PURE__ */ o("span", { style: { fontSize: 12, color: "#c62828", whiteSpace: "nowrap" }, children: e.error });
3309
3715
  if (e.result == null)
3310
3716
  return /* @__PURE__ */ o("span", { style: { flexShrink: 0, fontSize: 12 }, children: /* @__PURE__ */ o(
3311
- M,
3717
+ R,
3312
3718
  {
3313
3719
  text: r.searching,
3314
3720
  duration: 2.5,
@@ -3317,22 +3723,22 @@ function zr(e, r) {
3317
3723
  shimmerColor: "#000"
3318
3724
  }
3319
3725
  ) });
3320
- const t = e.result, n = t.numberOfChunks === 1 ? r.chunkFound : S(r.chunksFound, { n: t.numberOfChunks }), i = S(r.scoreLabel, {
3321
- n: t.highestChunkScore.toFixed(2)
3726
+ const n = e.result, t = n.numberOfChunks === 1 ? r.chunkFound : T(r.chunksFound, { n: n.numberOfChunks }), i = T(r.scoreLabel, {
3727
+ n: n.highestChunkScore.toFixed(2)
3322
3728
  });
3323
- return /* @__PURE__ */ y("span", { style: { fontSize: 12, color: "#666", whiteSpace: "nowrap" }, children: [
3324
- n,
3729
+ return /* @__PURE__ */ g("span", { style: { fontSize: 12, color: "#666", whiteSpace: "nowrap" }, children: [
3730
+ t,
3325
3731
  " · ",
3326
3732
  i
3327
3733
  ] });
3328
3734
  }
3329
- function Br({
3735
+ function Tt({
3330
3736
  items: e,
3331
3737
  queryRow: r,
3332
- onExploreQueryResultClick: t,
3333
- t: n
3738
+ onExploreQueryResultClick: n,
3739
+ t
3334
3740
  }) {
3335
- const [i, l] = I(null);
3741
+ const [i, l] = E(null);
3336
3742
  if (e.length === 0)
3337
3743
  return /* @__PURE__ */ o(
3338
3744
  "div",
@@ -3342,10 +3748,10 @@ function Br({
3342
3748
  color: "#94a3b8",
3343
3749
  paddingTop: 4
3344
3750
  },
3345
- children: n.memorySearchExploreNoResults
3751
+ children: t.memorySearchExploreNoResults
3346
3752
  }
3347
3753
  );
3348
- const a = !!t;
3754
+ const s = !!n;
3349
3755
  return /* @__PURE__ */ o(
3350
3756
  "div",
3351
3757
  {
@@ -3357,26 +3763,26 @@ function Br({
3357
3763
  paddingTop: 8,
3358
3764
  borderTop: "1px solid #f0f0f0"
3359
3765
  },
3360
- children: e.map((s, m) => {
3361
- const p = s.memoryTitle !== "" ? s.memoryTitle : s.memoryId, c = X(
3362
- s.chunks
3363
- ), d = [
3364
- V(s),
3365
- S(n.scoreLabel, {
3366
- n: s.matchingChunkScore.toFixed(2)
3766
+ children: e.map((c, m) => {
3767
+ const y = c.memoryTitle !== "" ? c.memoryTitle : c.memoryId, d = Y(
3768
+ c.chunks
3769
+ ), u = [
3770
+ J(c),
3771
+ T(t.scoreLabel, {
3772
+ n: c.matchingChunkScore.toFixed(2)
3367
3773
  }),
3368
- c.length > 0 ? K(c, n) : n.pagesNotAvailable
3774
+ d.length > 0 ? V(d, t) : t.pagesNotAvailable
3369
3775
  ].filter(
3370
- (f) => f != null && f !== ""
3371
- ), u = {
3372
- memoryId: s.memoryId,
3373
- memoryTitle: s.memoryTitle,
3374
- pageNumbers: c,
3776
+ (S) => S != null && S !== ""
3777
+ ), p = {
3778
+ memoryId: c.memoryId,
3779
+ memoryTitle: c.memoryTitle,
3780
+ pageNumbers: d,
3375
3781
  memoryTypeId: r.memoryTypeId,
3376
3782
  memoryTypeName: r.memoryTypeName,
3377
3783
  query: r.query
3378
- }, g = `${r.query}::${s.memoryId}::${m}`, h = i === g;
3379
- return /* @__PURE__ */ y(
3784
+ }, h = `${r.query}::${c.memoryId}::${m}`, f = i === h;
3785
+ return /* @__PURE__ */ g(
3380
3786
  "div",
3381
3787
  {
3382
3788
  style: {
@@ -3390,7 +3796,7 @@ function Br({
3390
3796
  minWidth: 0
3391
3797
  },
3392
3798
  children: [
3393
- /* @__PURE__ */ y(
3799
+ /* @__PURE__ */ g(
3394
3800
  "div",
3395
3801
  {
3396
3802
  style: {
@@ -3409,7 +3815,7 @@ function Br({
3409
3815
  fontWeight: 600,
3410
3816
  color: "#333"
3411
3817
  },
3412
- children: p
3818
+ children: y
3413
3819
  }
3414
3820
  ),
3415
3821
  /* @__PURE__ */ o(
@@ -3422,8 +3828,8 @@ function Br({
3422
3828
  whiteSpace: "pre-wrap",
3423
3829
  wordBreak: "break-word"
3424
3830
  },
3425
- children: Q(
3426
- s.chunks
3831
+ children: X(
3832
+ c.chunks
3427
3833
  )
3428
3834
  }
3429
3835
  ),
@@ -3436,23 +3842,23 @@ function Br({
3436
3842
  color: "#94a3b8",
3437
3843
  lineHeight: 1.35
3438
3844
  },
3439
- children: d.join(" · ")
3845
+ children: u.join(" · ")
3440
3846
  }
3441
3847
  )
3442
3848
  ]
3443
3849
  }
3444
3850
  ),
3445
- a && /* @__PURE__ */ y(
3851
+ s && /* @__PURE__ */ g(
3446
3852
  "button",
3447
3853
  {
3448
3854
  type: "button",
3449
- "aria-busy": h,
3450
- disabled: h,
3855
+ "aria-busy": f,
3856
+ disabled: f,
3451
3857
  onClick: async () => {
3452
- l(g);
3858
+ l(h);
3453
3859
  try {
3454
- await t(
3455
- u
3860
+ await n(
3861
+ p
3456
3862
  );
3457
3863
  } finally {
3458
3864
  l(null);
@@ -3468,56 +3874,56 @@ function Br({
3468
3874
  background: "#eff6ff",
3469
3875
  border: "1px solid #bfdbfe",
3470
3876
  borderRadius: 6,
3471
- cursor: h ? "wait" : "pointer",
3877
+ cursor: f ? "wait" : "pointer",
3472
3878
  fontFamily: "inherit",
3473
3879
  display: "inline-flex",
3474
3880
  alignItems: "center",
3475
3881
  gap: 8
3476
3882
  },
3477
3883
  children: [
3478
- h && /* @__PURE__ */ o(
3884
+ f && /* @__PURE__ */ o(
3479
3885
  "span",
3480
3886
  {
3481
3887
  className: "explore-memory-loader explore-memory-loader--callback",
3482
3888
  "aria-hidden": !0
3483
3889
  }
3484
3890
  ),
3485
- n.viewButton
3891
+ t.viewButton
3486
3892
  ]
3487
3893
  }
3488
3894
  )
3489
3895
  ]
3490
3896
  },
3491
- `${s.memoryId}-${m}`
3897
+ `${c.memoryId}-${m}`
3492
3898
  );
3493
3899
  })
3494
3900
  }
3495
3901
  );
3496
3902
  }
3497
- function Or(e) {
3498
- const r = [], t = /* @__PURE__ */ new Map();
3499
- return e.forEach((n, i) => {
3500
- let l = t.get(n.memoryTypeId);
3501
- l == null && (r.push(n.memoryTypeId), l = {
3502
- memoryTypeId: n.memoryTypeId,
3503
- memoryTypeName: n.memoryTypeName,
3903
+ function xt(e) {
3904
+ const r = [], n = /* @__PURE__ */ new Map();
3905
+ return e.forEach((t, i) => {
3906
+ let l = n.get(t.memoryTypeId);
3907
+ l == null && (r.push(t.memoryTypeId), l = {
3908
+ memoryTypeId: t.memoryTypeId,
3909
+ memoryTypeName: t.memoryTypeName,
3504
3910
  items: []
3505
- }, t.set(n.memoryTypeId, l)), l.items.push({ item: n, flatIndex: i });
3506
- }), r.map((n) => t.get(n));
3911
+ }, n.set(t.memoryTypeId, l)), l.items.push({ item: t, flatIndex: i });
3912
+ }), r.map((t) => n.get(t));
3507
3913
  }
3508
- function Nr({
3914
+ function bt({
3509
3915
  group: e,
3510
3916
  t: r,
3511
- isLatest: t,
3512
- expandedRows: n,
3917
+ isLatest: n,
3918
+ expandedRows: t,
3513
3919
  toggleExpanded: i,
3514
3920
  onExploreQueryResultClick: l
3515
3921
  }) {
3516
- const a = e.items.map((m) => m.item), s = a.some(
3922
+ const s = e.items.map((m) => m.item), c = s.some(
3517
3923
  (m) => m.result == null && m.error == null
3518
3924
  );
3519
- return /* @__PURE__ */ y(
3520
- C.div,
3925
+ return /* @__PURE__ */ g(
3926
+ I.div,
3521
3927
  {
3522
3928
  initial: { opacity: 0 },
3523
3929
  animate: { opacity: 1 },
@@ -3528,7 +3934,7 @@ function Nr({
3528
3934
  borderBottom: "1px solid #eee",
3529
3935
  display: "flex",
3530
3936
  flexDirection: "row",
3531
- alignItems: s ? "center" : "flex-start",
3937
+ alignItems: c ? "center" : "flex-start",
3532
3938
  gap: "10px",
3533
3939
  minWidth: 0
3534
3940
  },
@@ -3542,12 +3948,12 @@ function Nr({
3542
3948
  justifyContent: "center",
3543
3949
  flexShrink: 0,
3544
3950
  width: 32,
3545
- ...s ? {} : { paddingTop: 2 }
3951
+ ...c ? {} : { paddingTop: 2 }
3546
3952
  },
3547
- children: Wr(a)
3953
+ children: ft(s)
3548
3954
  }
3549
3955
  ),
3550
- /* @__PURE__ */ y(
3956
+ /* @__PURE__ */ g(
3551
3957
  "div",
3552
3958
  {
3553
3959
  style: {
@@ -3565,15 +3971,15 @@ function Nr({
3565
3971
  fontSize: 12,
3566
3972
  color: "#888"
3567
3973
  },
3568
- children: S(r.memorySearchExploreQueryTypeLabel, {
3974
+ children: T(r.memorySearchExploreQueryTypeLabel, {
3569
3975
  name: e.memoryTypeName
3570
3976
  })
3571
3977
  }
3572
3978
  ),
3573
- e.items.map(({ item: m, flatIndex: p }) => {
3574
- var f;
3575
- const c = m.result != null, d = m.error != null, u = t && !c && !d, g = n[p] === !0, h = ((f = m.result) == null ? void 0 : f.items) ?? [];
3576
- return /* @__PURE__ */ y(
3979
+ e.items.map(({ item: m, flatIndex: y }) => {
3980
+ var S;
3981
+ const d = m.result != null, u = m.error != null, p = n && !d && !u, h = t[y] === !0, f = ((S = m.result) == null ? void 0 : S.items) ?? [];
3982
+ return /* @__PURE__ */ g(
3577
3983
  "div",
3578
3984
  {
3579
3985
  style: {
@@ -3583,7 +3989,7 @@ function Nr({
3583
3989
  minWidth: 0
3584
3990
  },
3585
3991
  children: [
3586
- /* @__PURE__ */ y(
3992
+ /* @__PURE__ */ g(
3587
3993
  "div",
3588
3994
  {
3589
3995
  style: {
@@ -3606,8 +4012,8 @@ function Nr({
3606
4012
  flex: "1 1 12rem",
3607
4013
  minWidth: 0
3608
4014
  },
3609
- children: u ? /* @__PURE__ */ o(
3610
- M,
4015
+ children: p ? /* @__PURE__ */ o(
4016
+ R,
3611
4017
  {
3612
4018
  text: m.query,
3613
4019
  duration: 2.5,
@@ -3618,7 +4024,7 @@ function Nr({
3618
4024
  ) : m.query
3619
4025
  }
3620
4026
  ),
3621
- /* @__PURE__ */ y(
4027
+ /* @__PURE__ */ g(
3622
4028
  "div",
3623
4029
  {
3624
4030
  style: {
@@ -3629,12 +4035,12 @@ function Nr({
3629
4035
  flexShrink: 0
3630
4036
  },
3631
4037
  children: [
3632
- zr(m, r),
3633
- c && /* @__PURE__ */ o(
4038
+ St(m, r),
4039
+ d && /* @__PURE__ */ o(
3634
4040
  "button",
3635
4041
  {
3636
4042
  type: "button",
3637
- onClick: () => i(p),
4043
+ onClick: () => i(y),
3638
4044
  style: {
3639
4045
  border: "none",
3640
4046
  background: "none",
@@ -3645,7 +4051,7 @@ function Nr({
3645
4051
  textDecoration: "underline",
3646
4052
  fontFamily: "inherit"
3647
4053
  },
3648
- children: g ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
4054
+ children: h ? r.memorySearchHideExploreResults : r.memorySearchViewExploreResults
3649
4055
  }
3650
4056
  )
3651
4057
  ]
@@ -3654,10 +4060,10 @@ function Nr({
3654
4060
  ]
3655
4061
  }
3656
4062
  ),
3657
- c && g && /* @__PURE__ */ o(
3658
- Br,
4063
+ d && h && /* @__PURE__ */ o(
4064
+ Tt,
3659
4065
  {
3660
- items: h,
4066
+ items: f,
3661
4067
  queryRow: m,
3662
4068
  onExploreQueryResultClick: l,
3663
4069
  t: r
@@ -3665,7 +4071,7 @@ function Nr({
3665
4071
  )
3666
4072
  ]
3667
4073
  },
3668
- `${e.memoryTypeId}-${p}-${m.query}`
4074
+ `${e.memoryTypeId}-${y}-${m.query}`
3669
4075
  );
3670
4076
  })
3671
4077
  ]
@@ -3675,27 +4081,27 @@ function Nr({
3675
4081
  }
3676
4082
  );
3677
4083
  }
3678
- const $r = ({
4084
+ const kt = ({
3679
4085
  data: e,
3680
4086
  isLatest: r = !1,
3681
- durationSeconds: t,
3682
- onExploreQueryResultClick: n,
4087
+ durationSeconds: n,
4088
+ onExploreQueryResultClick: t,
3683
4089
  t: i
3684
4090
  }) => {
3685
- const [l, a] = I(
4091
+ const [l, s] = E(
3686
4092
  {}
3687
- ), s = z((p) => {
3688
- a((c) => ({
3689
- ...c,
3690
- [p]: !c[p]
4093
+ ), c = O((y) => {
4094
+ s((d) => ({
4095
+ ...d,
4096
+ [y]: !d[y]
3691
4097
  }));
3692
- }, []), m = P(
3693
- () => Or(e.queries),
4098
+ }, []), m = z(
4099
+ () => xt(e.queries),
3694
4100
  [e.queries]
3695
4101
  );
3696
- return /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
3697
- r && !t && e.queries.length === 0 ? /* @__PURE__ */ o(
3698
- M,
4102
+ return /* @__PURE__ */ g("div", { style: { padding: "10px" }, children: [
4103
+ r && !n && e.queries.length === 0 ? /* @__PURE__ */ o(
4104
+ R,
3699
4105
  {
3700
4106
  text: i.memorySearchExploringQueries,
3701
4107
  duration: 2.5,
@@ -3703,19 +4109,19 @@ const $r = ({
3703
4109
  color: "#999",
3704
4110
  shimmerColor: "#000"
3705
4111
  }
3706
- ) : m.map((p) => /* @__PURE__ */ o(
3707
- Nr,
4112
+ ) : m.map((y) => /* @__PURE__ */ o(
4113
+ bt,
3708
4114
  {
3709
- group: p,
4115
+ group: y,
3710
4116
  t: i,
3711
4117
  isLatest: r,
3712
4118
  expandedRows: l,
3713
- toggleExpanded: s,
3714
- onExploreQueryResultClick: n
4119
+ toggleExpanded: c,
4120
+ onExploreQueryResultClick: t
3715
4121
  },
3716
- p.memoryTypeId
4122
+ y.memoryTypeId
3717
4123
  )),
3718
- t !== void 0 && /* @__PURE__ */ o(
4124
+ n !== void 0 && /* @__PURE__ */ o(
3719
4125
  "div",
3720
4126
  {
3721
4127
  style: {
@@ -3724,15 +4130,15 @@ const $r = ({
3724
4130
  marginTop: "4px",
3725
4131
  fontStyle: "italic"
3726
4132
  },
3727
- children: S(i.tookSeconds, { n: t })
4133
+ children: T(i.tookSeconds, { n })
3728
4134
  }
3729
4135
  )
3730
4136
  ] });
3731
- }, Hr = ({ data: e, onSearchResultClick: r, t }) => {
3732
- const n = e.response.items, i = !!r, [l, a] = I(null);
3733
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
4137
+ }, vt = ({ data: e, onSearchResultClick: r, t: n }) => {
4138
+ const t = e.response.items, i = !!r, [l, s] = E(null);
4139
+ return /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: [
3734
4140
  /* @__PURE__ */ o(
3735
- C.div,
4141
+ I.div,
3736
4142
  {
3737
4143
  style: {
3738
4144
  marginBottom: "12px",
@@ -3743,7 +4149,7 @@ const $r = ({
3743
4149
  initial: { opacity: 0, y: -6 },
3744
4150
  animate: { opacity: 1, y: 0 },
3745
4151
  transition: { duration: 0.25 },
3746
- children: t.resultsHeading
4152
+ children: n.resultsHeading
3747
4153
  }
3748
4154
  ),
3749
4155
  /* @__PURE__ */ o(
@@ -3754,26 +4160,26 @@ const $r = ({
3754
4160
  flexDirection: "column",
3755
4161
  gap: 0
3756
4162
  },
3757
- children: n.map((s, m) => {
3758
- const p = s.memoryTitle !== "" ? s.memoryTitle : s.memoryId, c = X(
3759
- s.chunks
3760
- ), d = [
3761
- V(s),
3762
- S(t.scoreLabel, {
3763
- n: s.matchingChunkScore.toFixed(2)
4163
+ children: t.map((c, m) => {
4164
+ const y = c.memoryTitle !== "" ? c.memoryTitle : c.memoryId, d = Y(
4165
+ c.chunks
4166
+ ), u = [
4167
+ J(c),
4168
+ T(n.scoreLabel, {
4169
+ n: c.matchingChunkScore.toFixed(2)
3764
4170
  }),
3765
- c.length > 0 ? K(c, t) : t.pagesNotAvailable
4171
+ d.length > 0 ? V(d, n) : n.pagesNotAvailable
3766
4172
  ].filter(
3767
- (f) => f != null && f !== ""
3768
- ), u = {
3769
- memoryId: s.memoryId,
3770
- memoryTitle: s.memoryTitle,
3771
- memoryTypeId: s.memoryTypeId,
3772
- memoryTypeName: s.memoryTypeName,
3773
- pageNumbers: c
3774
- }, g = `${s.memoryId}-${m}`, h = l === g;
3775
- return /* @__PURE__ */ y(
3776
- C.div,
4173
+ (S) => S != null && S !== ""
4174
+ ), p = {
4175
+ memoryId: c.memoryId,
4176
+ memoryTitle: c.memoryTitle,
4177
+ memoryTypeId: c.memoryTypeId,
4178
+ memoryTypeName: c.memoryTypeName,
4179
+ pageNumbers: d
4180
+ }, h = `${c.memoryId}-${m}`, f = l === h;
4181
+ return /* @__PURE__ */ g(
4182
+ I.div,
3777
4183
  {
3778
4184
  initial: { opacity: 0 },
3779
4185
  animate: { opacity: 1 },
@@ -3785,11 +4191,11 @@ const $r = ({
3785
4191
  gap: "12px",
3786
4192
  paddingTop: "12px",
3787
4193
  paddingBottom: "12px",
3788
- borderBottom: m < n.length - 1 ? "1px solid #eee" : void 0,
4194
+ borderBottom: m < t.length - 1 ? "1px solid #eee" : void 0,
3789
4195
  minWidth: 0
3790
4196
  },
3791
4197
  children: [
3792
- /* @__PURE__ */ y(
4198
+ /* @__PURE__ */ g(
3793
4199
  "div",
3794
4200
  {
3795
4201
  style: {
@@ -3808,7 +4214,7 @@ const $r = ({
3808
4214
  fontWeight: 600,
3809
4215
  color: "#333"
3810
4216
  },
3811
- children: p
4217
+ children: y
3812
4218
  }
3813
4219
  ),
3814
4220
  /* @__PURE__ */ o(
@@ -3821,7 +4227,7 @@ const $r = ({
3821
4227
  whiteSpace: "pre-wrap",
3822
4228
  wordBreak: "break-word"
3823
4229
  },
3824
- children: Q(s.chunks)
4230
+ children: X(c.chunks)
3825
4231
  }
3826
4232
  ),
3827
4233
  /* @__PURE__ */ o(
@@ -3833,24 +4239,24 @@ const $r = ({
3833
4239
  color: "#94a3b8",
3834
4240
  lineHeight: 1.35
3835
4241
  },
3836
- children: d.join(" · ")
4242
+ children: u.join(" · ")
3837
4243
  }
3838
4244
  )
3839
4245
  ]
3840
4246
  }
3841
4247
  ),
3842
- i && /* @__PURE__ */ y(
4248
+ i && /* @__PURE__ */ g(
3843
4249
  "button",
3844
4250
  {
3845
4251
  type: "button",
3846
- "aria-busy": h,
3847
- disabled: h,
4252
+ "aria-busy": f,
4253
+ disabled: f,
3848
4254
  onClick: async () => {
3849
- a(g);
4255
+ s(h);
3850
4256
  try {
3851
- await r(u);
4257
+ await r(p);
3852
4258
  } finally {
3853
- a(null);
4259
+ s(null);
3854
4260
  }
3855
4261
  },
3856
4262
  style: {
@@ -3863,34 +4269,34 @@ const $r = ({
3863
4269
  background: "#eff6ff",
3864
4270
  border: "1px solid #bfdbfe",
3865
4271
  borderRadius: 6,
3866
- cursor: h ? "wait" : "pointer",
4272
+ cursor: f ? "wait" : "pointer",
3867
4273
  fontFamily: "inherit",
3868
4274
  display: "inline-flex",
3869
4275
  alignItems: "center",
3870
4276
  gap: 8
3871
4277
  },
3872
4278
  children: [
3873
- h && /* @__PURE__ */ o(
4279
+ f && /* @__PURE__ */ o(
3874
4280
  "span",
3875
4281
  {
3876
4282
  className: "explore-memory-loader explore-memory-loader--callback",
3877
4283
  "aria-hidden": !0
3878
4284
  }
3879
4285
  ),
3880
- t.viewButton
4286
+ n.viewButton
3881
4287
  ]
3882
4288
  }
3883
4289
  )
3884
4290
  ]
3885
4291
  },
3886
- `${s.memoryId}-${m}`
4292
+ `${c.memoryId}-${m}`
3887
4293
  );
3888
4294
  })
3889
4295
  }
3890
4296
  )
3891
4297
  ] });
3892
- }, j = ({ message: e }) => /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
3893
- C.div,
4298
+ }, N = ({ message: e }) => /* @__PURE__ */ o("div", { style: { padding: "16px" }, children: /* @__PURE__ */ o(
4299
+ I.div,
3894
4300
  {
3895
4301
  initial: { opacity: 0, y: -10 },
3896
4302
  animate: { opacity: 1, y: 0 },
@@ -3912,180 +4318,215 @@ const $r = ({
3912
4318
  }
3913
4319
  )
3914
4320
  }
3915
- ) }), Ur = ({
4321
+ ) });
4322
+ class Ct extends we.Component {
4323
+ constructor(r) {
4324
+ super(r), this.state = { hasError: !1 };
4325
+ }
4326
+ static getDerivedStateFromError() {
4327
+ return { hasError: !0 };
4328
+ }
4329
+ componentDidCatch(r, n) {
4330
+ console.error(
4331
+ "[fency] Progress item render failed:",
4332
+ this.props.progressItemId,
4333
+ r,
4334
+ n.componentStack
4335
+ );
4336
+ }
4337
+ render() {
4338
+ return this.state.hasError ? null : this.props.children;
4339
+ }
4340
+ }
4341
+ const wt = ({
3916
4342
  progressViewItems: e,
3917
4343
  loading: r,
3918
- error: t,
3919
- loadingText: n,
4344
+ error: n,
4345
+ loadingText: t,
3920
4346
  t: i,
3921
4347
  onSourceClick: l,
3922
- onSearchResultClick: a,
3923
- onExploreQueryResultClick: s
4348
+ onSearchResultClick: s,
4349
+ onExploreQueryResultClick: c
3924
4350
  }) => {
3925
- const m = A(null);
3926
- F(() => {
4351
+ const m = D(null);
4352
+ P(() => {
3927
4353
  m.current && (m.current.scrollTop = m.current.scrollHeight);
3928
4354
  }, [e.length]);
3929
- const p = (d) => {
3930
- const u = d.item.data;
3931
- if (u.taskType === "StreamingChatCompletion" && u.eventType === "Text")
3932
- return /* @__PURE__ */ o(oe, { text: u.text });
3933
- if (u.taskType === "StructuredChatCompletion" && u.eventType === "Completed")
3934
- return /* @__PURE__ */ o(je, { data: u });
3935
- if (u.taskType === "MemoryChat")
3936
- switch (u.eventType) {
4355
+ const y = (u) => {
4356
+ const p = u.item.data;
4357
+ if (p.taskType === "StreamingChatCompletion" && p.eventType === "Text")
4358
+ return /* @__PURE__ */ o(ie, { text: p.text });
4359
+ if (p.taskType === "StructuredChatCompletion" && p.eventType === "Completed")
4360
+ return /* @__PURE__ */ o(vr, { data: p });
4361
+ if (p.taskType === "MemoryChat")
4362
+ switch (p.eventType) {
3937
4363
  case "Text":
3938
- return /* @__PURE__ */ o(oe, { text: u.text });
4364
+ return /* @__PURE__ */ o(ie, { text: p.text });
4365
+ case "Thinking":
4366
+ return /* @__PURE__ */ o(
4367
+ at,
4368
+ {
4369
+ data: p,
4370
+ isLatest: u.isLatest,
4371
+ durationSeconds: u.durationSeconds,
4372
+ t: i
4373
+ }
4374
+ );
3939
4375
  case "FindMemories":
3940
4376
  return /* @__PURE__ */ o(
3941
- Xe,
4377
+ Er,
3942
4378
  {
3943
- data: u,
3944
- isLatest: d.isLatest,
3945
- durationSeconds: d.durationSeconds,
4379
+ data: p,
4380
+ isLatest: u.isLatest,
4381
+ durationSeconds: u.durationSeconds,
3946
4382
  t: i
3947
4383
  }
3948
4384
  );
3949
4385
  case "FindMemoriesResult":
3950
4386
  return /* @__PURE__ */ o(
3951
- Ve,
4387
+ Mr,
3952
4388
  {
3953
- data: u,
4389
+ data: p,
3954
4390
  t: i
3955
4391
  }
3956
4392
  );
3957
4393
  case "Search":
3958
4394
  return /* @__PURE__ */ o(
3959
- Ke,
4395
+ Ir,
3960
4396
  {
3961
- data: u,
3962
- isLatest: d.isLatest,
3963
- durationSeconds: d.durationSeconds,
4397
+ data: p,
4398
+ isLatest: u.isLatest,
4399
+ durationSeconds: u.durationSeconds,
3964
4400
  t: i
3965
4401
  }
3966
4402
  );
3967
4403
  case "FindSources":
3968
4404
  return /* @__PURE__ */ o(
3969
- Ye,
4405
+ Rr,
3970
4406
  {
3971
- data: u,
3972
- isLatest: d.isLatest,
3973
- durationSeconds: d.durationSeconds,
4407
+ data: p,
4408
+ isLatest: u.isLatest,
4409
+ durationSeconds: u.durationSeconds,
3974
4410
  t: i
3975
4411
  }
3976
4412
  );
3977
4413
  case "SourcesResult":
3978
4414
  return /* @__PURE__ */ o(
3979
- Ze,
4415
+ Ar,
3980
4416
  {
3981
- data: u,
4417
+ data: p,
3982
4418
  onSourceClick: l,
3983
4419
  t: i
3984
4420
  }
3985
4421
  );
3986
4422
  case "ExploreMemories":
3987
4423
  return /* @__PURE__ */ o(
3988
- tr,
4424
+ zr,
3989
4425
  {
3990
- data: u,
3991
- completed: d.completed,
3992
- isLatest: d.isLatest,
4426
+ data: p,
4427
+ completed: u.completed,
4428
+ isLatest: u.isLatest,
3993
4429
  t: i
3994
4430
  }
3995
4431
  );
3996
4432
  case "ChunkResults":
3997
4433
  return /* @__PURE__ */ o(
3998
- ur,
4434
+ Ur,
3999
4435
  {
4000
- data: u,
4001
- onSearchResultClick: a,
4436
+ data: p,
4437
+ onSearchResultClick: s,
4002
4438
  t: i
4003
4439
  }
4004
4440
  );
4005
4441
  case "GoogleSearch":
4006
4442
  return /* @__PURE__ */ o(
4007
- mr,
4008
- {
4009
- data: u,
4010
- isLatest: d.isLatest,
4011
- durationSeconds: d.durationSeconds,
4012
- t: i
4013
- }
4014
- );
4015
- case "GoogleSearchResult":
4016
- return /* @__PURE__ */ o(gr, { data: u, t: i });
4017
- case "Scrape":
4018
- return /* @__PURE__ */ o(
4019
- hr,
4443
+ Kr,
4020
4444
  {
4021
- data: u,
4022
- isLatest: d.isLatest,
4023
- durationSeconds: d.durationSeconds,
4445
+ data: p,
4446
+ isLatest: u.isLatest,
4447
+ durationSeconds: u.durationSeconds,
4024
4448
  t: i
4025
4449
  }
4026
4450
  );
4027
- case "ScrapeResult":
4451
+ case "ScrapeWebsites":
4028
4452
  return /* @__PURE__ */ o(
4029
- Tr,
4453
+ ot,
4030
4454
  {
4031
- data: u,
4032
- isLatest: d.isLatest,
4455
+ data: p,
4456
+ isLatest: u.isLatest,
4457
+ durationSeconds: u.durationSeconds,
4033
4458
  t: i
4034
4459
  }
4035
4460
  );
4036
4461
  case "Completed":
4037
4462
  return null;
4463
+ default: {
4464
+ const h = p;
4465
+ return h.eventType === "Error" && "message" in h ? /* @__PURE__ */ o(N, { message: h.message }) : (console.warn(
4466
+ "[fency] Unknown MemoryChat eventType (no UI):",
4467
+ h.eventType,
4468
+ h
4469
+ ), null);
4470
+ }
4038
4471
  }
4039
- if (u.taskType === "MemorySearch")
4040
- switch (u.eventType) {
4472
+ if (p.taskType === "MemorySearch")
4473
+ switch (p.eventType) {
4041
4474
  case "GeneratingQueries":
4042
4475
  return /* @__PURE__ */ o(
4043
- Dr,
4476
+ gt,
4044
4477
  {
4045
- data: u,
4046
- isLatest: d.isLatest,
4047
- durationSeconds: d.durationSeconds,
4478
+ data: p,
4479
+ isLatest: u.isLatest,
4480
+ durationSeconds: u.durationSeconds,
4048
4481
  t: i
4049
4482
  }
4050
4483
  );
4051
4484
  case "ExploreQueries":
4052
4485
  return /* @__PURE__ */ o(
4053
- $r,
4486
+ kt,
4054
4487
  {
4055
- data: u,
4056
- isLatest: d.isLatest,
4057
- durationSeconds: d.durationSeconds,
4058
- onExploreQueryResultClick: s,
4488
+ data: p,
4489
+ isLatest: u.isLatest,
4490
+ durationSeconds: u.durationSeconds,
4491
+ onExploreQueryResultClick: c,
4059
4492
  t: i
4060
4493
  }
4061
4494
  );
4062
4495
  case "SearchMemoryTypes":
4063
4496
  return /* @__PURE__ */ o(
4064
- Er,
4497
+ ct,
4065
4498
  {
4066
- data: u,
4067
- isLatest: d.isLatest,
4068
- durationSeconds: d.durationSeconds,
4499
+ data: p,
4500
+ isLatest: u.isLatest,
4501
+ durationSeconds: u.durationSeconds,
4069
4502
  t: i
4070
4503
  }
4071
4504
  );
4072
4505
  case "Completed":
4073
4506
  return /* @__PURE__ */ o(
4074
- Hr,
4507
+ vt,
4075
4508
  {
4076
- data: u,
4077
- onSearchResultClick: a,
4509
+ data: p,
4510
+ onSearchResultClick: s,
4078
4511
  t: i
4079
4512
  }
4080
4513
  );
4514
+ default: {
4515
+ const h = p;
4516
+ return h.eventType === "Error" && "message" in h ? /* @__PURE__ */ o(N, { message: h.message }) : (console.warn(
4517
+ "[fency] Unknown MemorySearch eventType (no UI):",
4518
+ h.eventType,
4519
+ h
4520
+ ), null);
4521
+ }
4081
4522
  }
4082
- return u.taskType === "StreamingChatCompletion" && u.eventType === "Completed" ? null : u.eventType === "Error" && "message" in u ? /* @__PURE__ */ o(j, { message: u.message }) : null;
4523
+ return p.taskType === "StreamingChatCompletion" && p.eventType === "Completed" ? null : p.eventType === "Error" && "message" in p ? /* @__PURE__ */ o(N, { message: p.message }) : null;
4083
4524
  };
4084
4525
  if (e.length === 0)
4085
- return t ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(j, { message: t.message }) }) : r ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(
4086
- M,
4526
+ return n ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(N, { message: n.message }) }) : r ? /* @__PURE__ */ o("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ o(
4527
+ R,
4087
4528
  {
4088
- text: n ?? i.processingYourTask,
4529
+ text: t ?? i.processingYourTask,
4089
4530
  duration: 1.5,
4090
4531
  repeat: !0,
4091
4532
  repeatDelay: 0,
@@ -4093,68 +4534,76 @@ const $r = ({
4093
4534
  shimmerColor: "#000"
4094
4535
  }
4095
4536
  ) }) : null;
4096
- const c = e.filter((d, u) => {
4097
- const g = d.item.data;
4098
- return g.taskType === "MemoryChat" && g.eventType === "ExploreMemories" ? !e.slice(u + 1).some(
4099
- (x) => x.item.data.taskType === "MemoryChat" && x.item.data.eventType === "ExploreMemories"
4100
- ) : g.taskType === "MemorySearch" && g.eventType === "GeneratingQueries" ? !e.slice(u + 1).some(
4101
- (x) => x.item.data.taskType === "MemorySearch" && x.item.data.eventType === "GeneratingQueries"
4102
- ) : g.taskType === "MemorySearch" && g.eventType === "ExploreQueries" ? !e.slice(u + 1).some(
4103
- (x) => x.item.data.taskType === "MemorySearch" && x.item.data.eventType === "ExploreQueries"
4104
- ) : g.taskType === "MemoryChat" && g.eventType === "ChunkResults" ? !e.slice(u + 1).some(
4105
- (x) => x.item.data.taskType === "MemoryChat" && x.item.data.eventType === "ChunkResults"
4106
- ) : g.taskType === "MemoryChat" && g.eventType === "GoogleSearch" ? !e.slice(u + 1).some(
4107
- (x) => x.item.data.taskType === "MemoryChat" && x.item.data.eventType === "GoogleSearch"
4108
- ) : g.taskType === "MemoryChat" && g.eventType === "Scrape" ? !e.slice(u + 1).some(
4109
- (x) => x.item.data.taskType === "MemoryChat" && x.item.data.eventType === "Scrape"
4537
+ const d = e.filter((u, p) => {
4538
+ const h = u.item.data;
4539
+ return h.taskType === "MemoryChat" && h.eventType === "ExploreMemories" ? !e.slice(p + 1).some(
4540
+ (k) => k.item.data.taskType === "MemoryChat" && k.item.data.eventType === "ExploreMemories"
4541
+ ) : h.taskType === "MemorySearch" && h.eventType === "GeneratingQueries" ? !e.slice(p + 1).some(
4542
+ (k) => k.item.data.taskType === "MemorySearch" && k.item.data.eventType === "GeneratingQueries"
4543
+ ) : h.taskType === "MemorySearch" && h.eventType === "ExploreQueries" ? !e.slice(p + 1).some(
4544
+ (k) => k.item.data.taskType === "MemorySearch" && k.item.data.eventType === "ExploreQueries"
4545
+ ) : h.taskType === "MemoryChat" && h.eventType === "ChunkResults" ? !e.slice(p + 1).some(
4546
+ (k) => k.item.data.taskType === "MemoryChat" && k.item.data.eventType === "ChunkResults"
4547
+ ) : h.taskType === "MemoryChat" && h.eventType === "GoogleSearch" ? !e.slice(p + 1).some(
4548
+ (k) => k.item.data.taskType === "MemoryChat" && k.item.data.eventType === "GoogleSearch"
4549
+ ) : h.taskType === "MemoryChat" && h.eventType === "Thinking" ? !e.slice(p + 1).some(
4550
+ (k) => k.item.data.taskType === "MemoryChat" && k.item.data.eventType === "Thinking"
4551
+ ) : h.taskType === "MemoryChat" && h.eventType === "ScrapeWebsites" ? !e.slice(p + 1).some(
4552
+ (k) => k.item.data.taskType === "MemoryChat" && k.item.data.eventType === "ScrapeWebsites"
4110
4553
  ) : !0;
4111
4554
  });
4112
- return /* @__PURE__ */ y("div", { id: "agent-task-progress-verbose", ref: m, children: [
4113
- /* @__PURE__ */ o(Te, { children: c.map((d, u) => /* @__PURE__ */ o(
4114
- C.div,
4555
+ return /* @__PURE__ */ g("div", { id: "agent-task-progress-verbose", ref: m, children: [
4556
+ /* @__PURE__ */ o(Re, { children: d.map((u, p) => /* @__PURE__ */ o(
4557
+ I.div,
4115
4558
  {
4116
- id: `agent-task-progress-item-${d.item.progressItemId}`,
4559
+ id: `agent-task-progress-item-${u.item.progressItemId}`,
4117
4560
  initial: { opacity: 0, y: -20 },
4118
4561
  animate: { opacity: 1, y: 0 },
4119
4562
  transition: {
4120
4563
  duration: 0.4,
4121
- delay: u * 0.1,
4564
+ delay: p * 0.1,
4122
4565
  ease: "easeOut"
4123
4566
  },
4124
- children: p(d)
4567
+ children: /* @__PURE__ */ o(
4568
+ Ct,
4569
+ {
4570
+ progressItemId: u.item.progressItemId,
4571
+ children: y(u)
4572
+ }
4573
+ )
4125
4574
  },
4126
- d.item.progressItemId
4575
+ u.item.progressItemId
4127
4576
  )) }),
4128
- t ? /* @__PURE__ */ o("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ o(j, { message: t.message }) }) : null
4577
+ n ? /* @__PURE__ */ o("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ o(N, { message: n.message }) }) : null
4129
4578
  ] });
4130
- }, Jr = ({
4579
+ }, Wt = ({
4131
4580
  agentTask: e,
4132
4581
  language: r,
4133
- onSourceClick: t,
4134
- onSearchResultClick: n,
4582
+ onSourceClick: n,
4583
+ onSearchResultClick: t,
4135
4584
  onExploreQueryResultClick: i
4136
4585
  }) => {
4137
- const l = Ge(e), a = (e.params.type === "MemoryChat" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : r ?? "en", s = Qe(a);
4586
+ const l = kr(e), s = (e.params.type === "MemoryChat" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : r ?? "en", c = wr(s);
4138
4587
  return /* @__PURE__ */ o(
4139
- Ur,
4588
+ wt,
4140
4589
  {
4141
4590
  progressViewItems: l,
4142
4591
  loading: e.loading,
4143
4592
  error: e.error,
4144
4593
  loadingText: e.loadingText,
4145
- t: s,
4146
- onSourceClick: t,
4147
- onSearchResultClick: n,
4594
+ t: c,
4595
+ onSourceClick: n,
4596
+ onSearchResultClick: t,
4148
4597
  onExploreQueryResultClick: i
4149
4598
  }
4150
4599
  );
4151
4600
  };
4152
4601
  export {
4153
- Jr as AgentTaskProgress,
4602
+ Wt as AgentTaskProgress,
4154
4603
  L as Checkmark,
4155
- Vr as FencyProvider,
4156
- Hr as MemorySearchCompletedResults,
4157
- We as StreamEventManager,
4158
- O as XMark,
4159
- Yr as useAgentTasks
4604
+ Lt as FencyProvider,
4605
+ vt as MemorySearchCompletedResults,
4606
+ $e as StreamEventManager,
4607
+ j as XMark,
4608
+ zt as useAgentTasks
4160
4609
  };