teodor-new-chat-ui 4.3.67 → 4.3.68

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.esm.js CHANGED
@@ -136,18 +136,18 @@ function lg() {
136
136
  }
137
137
  return null;
138
138
  }
139
- var N = Object.assign, j = 0, B, re, W, $, G, ee, ae;
140
- function z() {
139
+ var N = Object.assign, j = 0, z, re, W, $, G, ee, ae;
140
+ function B() {
141
141
  }
142
- z.__reactDisabledLog = !0;
142
+ B.__reactDisabledLog = !0;
143
143
  function se() {
144
144
  {
145
145
  if (j === 0) {
146
- B = console.log, re = console.info, W = console.warn, $ = console.error, G = console.group, ee = console.groupCollapsed, ae = console.groupEnd;
146
+ z = console.log, re = console.info, W = console.warn, $ = console.error, G = console.group, ee = console.groupCollapsed, ae = console.groupEnd;
147
147
  var R = {
148
148
  configurable: !0,
149
149
  enumerable: !0,
150
- value: z,
150
+ value: B,
151
151
  writable: !0
152
152
  };
153
153
  Object.defineProperties(console, {
@@ -173,7 +173,7 @@ function lg() {
173
173
  };
174
174
  Object.defineProperties(console, {
175
175
  log: N({}, R, {
176
- value: B
176
+ value: z
177
177
  }),
178
178
  info: N({}, R, {
179
179
  value: re
@@ -1882,22 +1882,22 @@ const zu = (e) => {
1882
1882
  duplex: "half"
1883
1883
  }), ae;
1884
1884
  if (P.isFormData(m) && (ae = ee.headers.get("content-type")) && A.setContentType(ae), ee.body) {
1885
- const [z, se] = Wl(
1885
+ const [B, se] = Wl(
1886
1886
  j,
1887
1887
  fs(Vl(S))
1888
1888
  );
1889
- m = ql(ee.body, Gl, z, se);
1889
+ m = ql(ee.body, Gl, B, se);
1890
1890
  }
1891
1891
  }
1892
1892
  P.isString(_) || (_ = _ ? "include" : "omit");
1893
- const B = s && "credentials" in n.prototype, re = {
1893
+ const z = s && "credentials" in n.prototype, re = {
1894
1894
  ...M,
1895
1895
  signal: q,
1896
1896
  method: v.toUpperCase(),
1897
1897
  headers: A.normalize().toJSON(),
1898
1898
  body: m,
1899
1899
  duplex: "half",
1900
- credentials: B ? _ : void 0
1900
+ credentials: z ? _ : void 0
1901
1901
  };
1902
1902
  O = s && new n(y, re);
1903
1903
  let W = await (s ? F(O, M) : F(y, re));
@@ -1907,12 +1907,12 @@ const zu = (e) => {
1907
1907
  ["status", "statusText", "headers"].forEach((Ne) => {
1908
1908
  ee[Ne] = W[Ne];
1909
1909
  });
1910
- const ae = P.toFiniteNumber(W.headers.get("content-length")), [z, se] = C && Wl(
1910
+ const ae = P.toFiniteNumber(W.headers.get("content-length")), [B, se] = C && Wl(
1911
1911
  ae,
1912
1912
  fs(Vl(C), !0)
1913
1913
  ) || [];
1914
1914
  W = new r(
1915
- ql(W.body, Gl, z, () => {
1915
+ ql(W.body, Gl, B, () => {
1916
1916
  se && se(), N && N();
1917
1917
  }),
1918
1918
  ee
@@ -1930,13 +1930,13 @@ const zu = (e) => {
1930
1930
  request: O
1931
1931
  });
1932
1932
  });
1933
- } catch (B) {
1934
- throw N && N(), B && B.name === "TypeError" && /Load failed|fetch/i.test(B.message) ? Object.assign(
1933
+ } catch (z) {
1934
+ throw N && N(), z && z.name === "TypeError" && /Load failed|fetch/i.test(z.message) ? Object.assign(
1935
1935
  new je("Network Error", je.ERR_NETWORK, x, O),
1936
1936
  {
1937
- cause: B.cause || B
1937
+ cause: z.cause || z
1938
1938
  }
1939
- ) : je.from(B, B && B.code, x, O);
1939
+ ) : je.from(z, z && z.code, x, O);
1940
1940
  }
1941
1941
  };
1942
1942
  }, _x = /* @__PURE__ */ new Map(), Bu = (e) => {
@@ -3304,32 +3304,43 @@ function yy(e = {}) {
3304
3304
  p(""), y(null), f(null);
3305
3305
  }, []), M = be(async () => {
3306
3306
  const O = k.current;
3307
- if (!(!O || !O.threadId))
3308
- try {
3309
- console.debug("[use-chat] cancelActiveRun ->", O.threadId);
3310
- const N = {
3311
- ...O.headers,
3312
- Accept: "application/json",
3313
- "Content-Type": "application/json"
3314
- };
3315
- await fetch(t + r, {
3316
- method: "POST",
3317
- headers: N,
3318
- body: JSON.stringify({ threadId: O.threadId }),
3319
- credentials: a
3320
- });
3321
- } catch (N) {
3322
- console.warn("[use-chat] cancel request failed:", N);
3307
+ if (!O || !O.threadId) {
3308
+ console.warn("[use-chat] cancelActiveRun: no active run context or threadId", { ctx: O });
3309
+ return;
3310
+ }
3311
+ try {
3312
+ console.debug("[use-chat] cancelActiveRun -> sending cancel request for thread", O.threadId);
3313
+ const N = {
3314
+ ...O.headers,
3315
+ Accept: "application/json",
3316
+ "Content-Type": "application/json"
3317
+ }, j = await fetch(t + r, {
3318
+ method: "POST",
3319
+ headers: N,
3320
+ body: JSON.stringify({ threadId: O.threadId }),
3321
+ credentials: a
3322
+ });
3323
+ if (console.debug("[use-chat] cancelActiveRun: response status", j.status), j.ok)
3324
+ console.debug("[use-chat] cancel request succeeded");
3325
+ else {
3326
+ const z = await j.text().catch(() => "");
3327
+ console.warn("[use-chat] cancel request returned non-OK status:", j.status, z);
3323
3328
  }
3329
+ } catch (N) {
3330
+ console.warn("[use-chat] cancel request failed:", N);
3331
+ }
3324
3332
  }, [t, r, a]), F = be(() => {
3325
- var O;
3326
- console.debug("[use-chat] stop() invoked"), M(), (O = T.current) == null || O.abort(), T.current = null, k.current = null, c(!1), b(!1), S.current = 0, m(0);
3333
+ console.debug("[use-chat] stop() invoked"), Promise.resolve(M()).catch(() => {
3334
+ }).then(() => {
3335
+ var O;
3336
+ console.debug("[use-chat] stop() - cancel completed or failed, now aborting"), (O = T.current) == null || O.abort();
3337
+ }), T.current = null, k.current = null, c(!1), b(!1), S.current = 0, m(0);
3327
3338
  }, [M]), q = be(
3328
3339
  (O, N, j) => {
3329
3340
  T.current && (T.current.abort(), T.current = null), c(!0), f(null), e.autoAppendAssistant !== !1 && p("");
3330
- const B = new AbortController();
3331
- return T.current = B, (async () => {
3332
- var W, $, G, ee, ae, z, se, Ne, Ie;
3341
+ const z = new AbortController();
3342
+ return T.current = z, (async () => {
3343
+ var W, $, G, ee, ae, B, se, Ne, Ie;
3333
3344
  const re = (K) => {
3334
3345
  var D;
3335
3346
  try {
@@ -3384,7 +3395,7 @@ function yy(e = {}) {
3384
3395
  method: "POST",
3385
3396
  headers: te,
3386
3397
  body: JSON.stringify(O),
3387
- signal: B.signal,
3398
+ signal: z.signal,
3388
3399
  credentials: a
3389
3400
  });
3390
3401
  if (k.current = {
@@ -3419,7 +3430,7 @@ function yy(e = {}) {
3419
3430
  var He;
3420
3431
  if (Date.now() - Oe > 6e4) {
3421
3432
  const Z = "Stream idle timeout";
3422
- f(Z), B.abort(), (He = j == null ? void 0 : j.onError) == null || He.call(j, Z);
3433
+ f(Z), z.abort(), (He = j == null ? void 0 : j.onError) == null || He.call(j, Z);
3423
3434
  }
3424
3435
  }, 5e3), Ot = 1024 * 1024;
3425
3436
  try {
@@ -3454,7 +3465,7 @@ function yy(e = {}) {
3454
3465
  console.debug("[use-chat] drop duplicate/out-of-order event", { seq: Mt, lastProcessedSeq: Ze, type: Je.type });
3455
3466
  continue;
3456
3467
  }
3457
- Ze > 0 && Mt > Ze + 1 && ((z = j == null ? void 0 : j.onGap) == null || z.call(j, { from: Ze, to: Mt })), Ze = Mt, S.current = Mt, m(Mt);
3468
+ Ze > 0 && Mt > Ze + 1 && ((B = j == null ? void 0 : j.onGap) == null || B.call(j, { from: Ze, to: Mt })), Ze = Mt, S.current = Mt, m(Mt);
3458
3469
  }
3459
3470
  console.debug("[use-chat] received event", {
3460
3471
  seq: Je.seq,
@@ -3504,7 +3515,7 @@ function yy(e = {}) {
3504
3515
  } finally {
3505
3516
  c(!1), b(!1), T.current = null, S.current = 0, m(0), k.current = null;
3506
3517
  }
3507
- })(), { close: () => B.abort() };
3518
+ })(), { close: () => z.abort() };
3508
3519
  },
3509
3520
  [t, n, o, e.autoAppendAssistant]
3510
3521
  );
@@ -3903,12 +3914,12 @@ function zy({
3903
3914
  Ti(f, (I = l.getAuthToken) == null ? void 0 : I.call(l))
3904
3915
  );
3905
3916
  return zo(E);
3906
- }), C = ct(() => Ri(b), [b]), [S, k] = xe(t), [A, _] = xe(!1), [M, F] = xe(!1), [q, O] = xe(null), [N, j] = xe(null), [B, re] = xe(null), [W, $] = xe([]), G = be(() => {
3917
+ }), C = ct(() => Ri(b), [b]), [S, k] = xe(t), [A, _] = xe(!1), [M, F] = xe(!1), [q, O] = xe(null), [N, j] = xe(null), [z, re] = xe(null), [W, $] = xe([]), G = be(() => {
3907
3918
  const E = ki(m);
3908
3919
  Lo(() => {
3909
3920
  T(zo(E));
3910
3921
  });
3911
- }, [m]), [ee, ae] = xe(!1), [z, se] = xe(!1), [Ne, Ie] = xe(null), [K, D] = xe(void 0), [X, te] = xe(void 0), [ce, ie] = xe(void 0), {
3922
+ }, [m]), [ee, ae] = xe(!1), [B, se] = xe(!1), [Ne, Ie] = xe(null), [K, D] = xe(void 0), [X, te] = xe(void 0), [ce, ie] = xe(void 0), {
3912
3923
  state: de,
3913
3924
  dispatch: Be,
3914
3925
  seed: Ge,
@@ -4035,8 +4046,8 @@ function zy({
4035
4046
  dn.current = C.length;
4036
4047
  }, [C.length]), lt(() => {
4037
4048
  const E = de.pendingInterrupt ?? ky(de.messages);
4038
- cc(B, E) || re(E ?? null);
4039
- }, [B, de.messages, de.pendingInterrupt]);
4049
+ cc(z, E) || re(E ?? null);
4050
+ }, [z, de.messages, de.pendingInterrupt]);
4040
4051
  const Dt = be(async () => {
4041
4052
  const E = dn.current > 0;
4042
4053
  E || _(!0);
@@ -4419,7 +4430,7 @@ function zy({
4419
4430
  }, [$e]), he = be(
4420
4431
  async () => {
4421
4432
  if (!Oe.current) throw new Error("No active thread");
4422
- if (z || !ee) return;
4433
+ if (B || !ee) return;
4423
4434
  const E = Ne;
4424
4435
  if (E) {
4425
4436
  se(!0);
@@ -4455,7 +4466,7 @@ function zy({
4455
4466
  X,
4456
4467
  ce,
4457
4468
  Ne,
4458
- z,
4469
+ B,
4459
4470
  vt,
4460
4471
  et
4461
4472
  ]
@@ -4598,7 +4609,7 @@ function zy({
4598
4609
  messages: de.messages.slice(),
4599
4610
  nextCursor: Ne ?? null,
4600
4611
  nextCursorNs: ce ?? null,
4601
- interrupt: de.pendingInterrupt ?? B ?? null
4612
+ interrupt: de.pendingInterrupt ?? z ?? null
4602
4613
  }), Y = ve.current.get(E), ne = Y == null ? void 0 : Y.snapshot, le = !ne || ne.messages.length !== I.messages.length || ne.messages.some((Me, tt) => {
4603
4614
  var wt;
4604
4615
  return (Me == null ? void 0 : Me.id) !== ((wt = I.messages[tt]) == null ? void 0 : wt.id);
@@ -4626,7 +4637,7 @@ function zy({
4626
4637
  de.lastCheckpointNs,
4627
4638
  de.messages,
4628
4639
  de.pendingInterrupt,
4629
- B,
4640
+ z,
4630
4641
  x
4631
4642
  ]);
4632
4643
  const nn = ct(
@@ -4667,7 +4678,7 @@ function zy({
4667
4678
  return {
4668
4679
  threadId: S,
4669
4680
  messages: de.messages,
4670
- interrupt: B,
4681
+ interrupt: z,
4671
4682
  checkpoint: {
4672
4683
  id: de.lastCheckpointId ?? null,
4673
4684
  namespace: de.lastCheckpointNs ?? null
@@ -4675,7 +4686,7 @@ function zy({
4675
4686
  checkpoints: W,
4676
4687
  metadata: Y,
4677
4688
  isLoading: M,
4678
- isHistoryLoading: z,
4689
+ isHistoryLoading: B,
4679
4690
  error: N,
4680
4691
  hasMore: ee,
4681
4692
  loadOlder: he,
@@ -4691,9 +4702,9 @@ function zy({
4691
4702
  Le,
4692
4703
  pn,
4693
4704
  S,
4694
- B,
4695
- ee,
4696
4705
  z,
4706
+ ee,
4707
+ B,
4697
4708
  M,
4698
4709
  he,
4699
4710
  $e,
@@ -4847,15 +4858,15 @@ function Uy({
4847
4858
  k();
4848
4859
  }, [k, m]);
4849
4860
  const A = U.useCallback(
4850
- (j, { fromUser: B }) => {
4851
- x || v(j), B && (a == null || a(j));
4861
+ (j, { fromUser: z }) => {
4862
+ x || v(j), z && (a == null || a(j));
4852
4863
  },
4853
4864
  [x, a]
4854
4865
  ), _ = U.useCallback(
4855
4866
  async (j) => {
4856
4867
  j && j.preventDefault();
4857
- const B = (m ?? "").trim();
4858
- if (!B && !p)
4868
+ const z = (m ?? "").trim();
4869
+ if (!z && !p)
4859
4870
  return;
4860
4871
  const re = ++C.current;
4861
4872
  S.current = {
@@ -4864,10 +4875,10 @@ function Uy({
4864
4875
  }, b(() => {
4865
4876
  var W, $, G;
4866
4877
  try {
4867
- const ee = l(B);
4878
+ const ee = l(z);
4868
4879
  ee && typeof ee.then == "function" ? ee.then(() => {
4869
- var ae, z;
4870
- ((ae = S.current) == null ? void 0 : ae.id) === re && S.current.shouldClear && (x || (v(""), T.current && (T.current.style.height = "auto"), a == null || a(""))), ((z = S.current) == null ? void 0 : z.id) === re && (S.current = null);
4880
+ var ae, B;
4881
+ ((ae = S.current) == null ? void 0 : ae.id) === re && S.current.shouldClear && (x || (v(""), T.current && (T.current.style.height = "auto"), a == null || a(""))), ((B = S.current) == null ? void 0 : B.id) === re && (S.current = null);
4871
4882
  }).catch(() => {
4872
4883
  var ae;
4873
4884
  ((ae = S.current) == null ? void 0 : ae.id) === re && (S.current = null);
@@ -4879,8 +4890,8 @@ function Uy({
4879
4890
  },
4880
4891
  [m, l, p, x, a]
4881
4892
  ), M = U.useCallback((j) => {
4882
- const B = j.target.value;
4883
- A(B, { fromUser: !0 }), S.current && (S.current.shouldClear = !1), T.current && (T.current.style.height = "auto", T.current.style.height = `${T.current.scrollHeight}px`);
4893
+ const z = j.target.value;
4894
+ A(z, { fromUser: !0 }), S.current && (S.current.shouldClear = !1), T.current && (T.current.style.height = "auto", T.current.style.height = `${T.current.scrollHeight}px`);
4884
4895
  }, [A]), F = U.useCallback(
4885
4896
  (j) => {
4886
4897
  j.key === "Enter" && !j.shiftKey ? (j.preventDefault(), _()) : j.key === "Escape" && t && (j.preventDefault(), c == null || c());
@@ -5782,7 +5793,7 @@ const pv = {
5782
5793
  }
5783
5794
  const O = fr(S.sizeTree);
5784
5795
  return F !== C && O.shift(), O.reduce(
5785
- (N, { k: j, v: B }) => {
5796
+ (N, { k: j, v: z }) => {
5786
5797
  let re = N.ranges;
5787
5798
  return N.prevSize !== 0 && (re = [
5788
5799
  ...N.ranges,
@@ -5793,7 +5804,7 @@ const pv = {
5793
5804
  }
5794
5805
  ]), {
5795
5806
  prevIndex: j + C,
5796
- prevSize: B,
5807
+ prevSize: z,
5797
5808
  ranges: re
5798
5809
  };
5799
5810
  },
@@ -5981,18 +5992,18 @@ const No = Xe(
5981
5992
  O,
5982
5993
  N
5983
5994
  ]) => {
5984
- const j = vd(T), { align: B, behavior: re, offset: W } = j, $ = k - 1, G = xd(j, C, $);
5995
+ const j = vd(T), { align: z, behavior: re, offset: W } = j, $ = k - 1, G = xd(j, C, $);
5985
5996
  let ee = yo(G, C.offsetTree, q) + _;
5986
- B === "end" ? (ee += O + xn(C.sizeTree, G)[1] - S + N, G === $ && (ee += M)) : B === "center" ? ee += (O + xn(C.sizeTree, G)[1] - S + N) / 2 : ee -= A, W && (ee += W);
5987
- const ae = (z) => {
5988
- b(), z ? (F("retrying to scroll to", { location: T }, qt.DEBUG), Pe(p, T)) : (Pe(x, !0), F("list did not change, scroll successful", {}, qt.DEBUG));
5997
+ z === "end" ? (ee += O + xn(C.sizeTree, G)[1] - S + N, G === $ && (ee += M)) : z === "center" ? ee += (O + xn(C.sizeTree, G)[1] - S + N) / 2 : ee -= A, W && (ee += W);
5998
+ const ae = (B) => {
5999
+ b(), B ? (F("retrying to scroll to", { location: T }, qt.DEBUG), Pe(p, T)) : (Pe(x, !0), F("list did not change, scroll successful", {}, qt.DEBUG));
5989
6000
  };
5990
6001
  if (b(), re === "smooth") {
5991
- let z = !1;
6002
+ let B = !1;
5992
6003
  w = rt(t, (se) => {
5993
- z = z || se;
6004
+ B = B || se;
5994
6005
  }), v = gn(d, () => {
5995
- ae(z);
6006
+ ae(B);
5996
6007
  });
5997
6008
  } else
5998
6009
  v = gn(V(t, xv(150)), ae);
@@ -6411,18 +6422,18 @@ const kr = Xe(
6411
6422
  N,
6412
6423
  j
6413
6424
  ]) => {
6414
- const B = _, { offsetTree: re, sizeTree: W } = B, $ = bt(v);
6425
+ const z = _, { offsetTree: re, sizeTree: W } = z, $ = bt(v);
6415
6426
  if (A === 0)
6416
6427
  return { ...Ai, totalCount: A };
6417
6428
  if (S === 0 && k === 0)
6418
6429
  return $ === 0 ? { ...Ai, totalCount: A } : bd($, M, _, O, N, j || []);
6419
6430
  if (st(W))
6420
6431
  return $ > 0 ? null : os(
6421
- bv(Ka(M, A), B, j),
6432
+ bv(Ka(M, A), z, j),
6422
6433
  [],
6423
6434
  A,
6424
6435
  N,
6425
- B,
6436
+ z,
6426
6437
  O
6427
6438
  );
6428
6439
  const G = [];
@@ -6436,11 +6447,11 @@ const kr = Xe(
6436
6447
  }
6437
6448
  }
6438
6449
  if (!F)
6439
- return os([], G, A, N, B, O);
6450
+ return os([], G, A, N, z, O);
6440
6451
  const ee = q.length > 0 ? q[q.length - 1] + 1 : 0, ae = cv(re, S, k, ee);
6441
6452
  if (ae.length === 0)
6442
6453
  return null;
6443
- const z = A - 1, se = Hs([], (Ne) => {
6454
+ const B = A - 1, se = Hs([], (Ne) => {
6444
6455
  for (const Ie of ae) {
6445
6456
  const K = Ie.value;
6446
6457
  let D = K.offset, X = Ie.start;
@@ -6451,12 +6462,12 @@ const kr = Xe(
6451
6462
  D += ie * te + ie * N;
6452
6463
  }
6453
6464
  X < ee && (D += (ee - X) * te, X = ee);
6454
- const ce = Math.min(Ie.end, z);
6465
+ const ce = Math.min(Ie.end, B);
6455
6466
  for (let ie = X; ie <= ce && !(D >= k); ie++)
6456
6467
  Ne.push({ data: j == null ? void 0 : j[ie], index: ie, offset: D, size: te }), D += te + N;
6457
6468
  }
6458
6469
  });
6459
- return os(se, G, A, N, B, O);
6470
+ return os(se, G, A, N, z, O);
6460
6471
  }
6461
6472
  ),
6462
6473
  //@ts-expect-error filter needs to be fixed
@@ -7299,14 +7310,14 @@ const Dv = /* @__PURE__ */ Xe(() => {
7299
7310
  ref: v,
7300
7311
  style: O,
7301
7312
  children: (e ? t.topItems : t.items).map((N) => {
7302
- const j = N.originalIndex, B = A(j + t.firstItemIndex, N.data, c);
7313
+ const j = N.originalIndex, z = A(j + t.firstItemIndex, N.data, c);
7303
7314
  return _ ? /* @__PURE__ */ Jo(
7304
7315
  T,
7305
7316
  {
7306
7317
  ...zt(T, c),
7307
7318
  height: N.size,
7308
7319
  index: N.index,
7309
- key: B,
7320
+ key: z,
7310
7321
  type: N.type || "item",
7311
7322
  ...N.type === "group" ? {} : { groupIndex: N.groupIndex }
7312
7323
  }
@@ -7317,7 +7328,7 @@ const Dv = /* @__PURE__ */ Xe(() => {
7317
7328
  "data-index": j,
7318
7329
  "data-item-index": N.index,
7319
7330
  "data-known-size": N.size,
7320
- key: B,
7331
+ key: z,
7321
7332
  style: $v
7322
7333
  },
7323
7334
  d(N.index, c)
@@ -7330,7 +7341,7 @@ const Dv = /* @__PURE__ */ Xe(() => {
7330
7341
  "data-item-group-index": N.groupIndex,
7331
7342
  "data-item-index": N.index,
7332
7343
  "data-known-size": N.size,
7333
- key: B,
7344
+ key: z,
7334
7345
  style: y ? zv : Pd
7335
7346
  },
7336
7347
  M ? l(N.index, N.groupIndex, N.data, c) : l(N.index, N.data, c)
@@ -7618,7 +7629,7 @@ const sw = /* @__PURE__ */ Xe(
7618
7629
  { customScrollParent: v, useWindowScroll: m, windowScrollContainerState: w, windowScrollTo: b, windowViewportRect: T },
7619
7630
  C
7620
7631
  ]) => {
7621
- const S = J(0), k = J(0), A = J(Ec), _ = J({ height: 0, width: 0 }), M = J({ height: 0, width: 0 }), F = Ke(), q = Ke(), O = J(0), N = J(null), j = J({ column: 0, row: 0 }), B = Ke(), re = Ke(), W = J(!1), $ = J(0), G = J(!0), ee = J(!1), ae = J(!1);
7632
+ const S = J(0), k = J(0), A = J(Ec), _ = J({ height: 0, width: 0 }), M = J({ height: 0, width: 0 }), F = Ke(), q = Ke(), O = J(0), N = J(null), j = J({ column: 0, row: 0 }), z = Ke(), re = Ke(), W = J(!1), $ = J(0), G = J(!0), ee = J(!1), ae = J(!1);
7622
7633
  rt(
7623
7634
  V(
7624
7635
  x,
@@ -7679,7 +7690,7 @@ const sw = /* @__PURE__ */ Xe(
7679
7690
  viewport: D
7680
7691
  }))
7681
7692
  ),
7682
- B
7693
+ z
7683
7694
  ), ye(
7684
7695
  V(
7685
7696
  Ct(
@@ -7743,20 +7754,20 @@ const sw = /* @__PURE__ */ Xe(
7743
7754
  ),
7744
7755
  t
7745
7756
  );
7746
- const z = J(!1);
7757
+ const B = J(!1);
7747
7758
  ye(
7748
7759
  V(
7749
7760
  c,
7750
- Fe(z),
7761
+ Fe(B),
7751
7762
  pe(([D, X]) => X || D !== 0)
7752
7763
  ),
7753
- z
7764
+ B
7754
7765
  );
7755
7766
  const se = Zt(
7756
7767
  V(
7757
7768
  Ct(A, S),
7758
7769
  Ee(([{ items: D }]) => D.length > 0),
7759
- Fe(z),
7770
+ Fe(B),
7760
7771
  Ee(([[D, X], te]) => {
7761
7772
  const ce = D.items[D.items.length - 1].index === X - 1;
7762
7773
  return (te || D.bottom > 0 && D.itemHeight > 0 && D.offsetBottom === 0 && D.items.length === X) && ce;
@@ -7848,7 +7859,7 @@ const sw = /* @__PURE__ */ Xe(
7848
7859
  propsReady: y,
7849
7860
  rangeChanged: Ie,
7850
7861
  startReached: Ne,
7851
- stateChanged: B,
7862
+ stateChanged: z,
7852
7863
  stateRestoreInProgress: W,
7853
7864
  ...C
7854
7865
  };
@@ -11585,13 +11596,13 @@ const k0 = U.memo(function({
11585
11596
  onInterruptActionStart: b,
11586
11597
  onInterruptActionEnd: T
11587
11598
  }) {
11588
- const [C, S] = xe(!1), [k, A] = xe("preview"), [_, M] = xe(!1), { currentThreadId: F } = Fa(), { respondToInterrupt: q } = $a(), O = l === "phone" || l === "half-screen", N = t.role, j = N === "tool", B = !(r && N !== "user"), {
11599
+ const [C, S] = xe(!1), [k, A] = xe("preview"), [_, M] = xe(!1), { currentThreadId: F } = Fa(), { respondToInterrupt: q } = $a(), O = l === "phone" || l === "half-screen", N = t.role, j = N === "tool", z = !(r && N !== "user"), {
11589
11600
  uploadingFiles: re,
11590
11601
  handleFileClick: W,
11591
11602
  fileViewerOpen: $,
11592
11603
  currentFileInfo: G,
11593
11604
  closeFileViewer: ee
11594
- } = E0({ allowFileOpen: B, currentThreadId: F }), ae = U.useMemo(() => {
11605
+ } = E0({ allowFileOpen: z, currentThreadId: F }), ae = U.useMemo(() => {
11595
11606
  switch (N) {
11596
11607
  case "user":
11597
11608
  return "text-[hsl(var(--chat-bubble-user-text))]";
@@ -11604,7 +11615,7 @@ const k0 = U.memo(function({
11604
11615
  default:
11605
11616
  return "text-[hsl(var(--chat-bubble-ai-text))]";
11606
11617
  }
11607
- }, [N]), z = ct(() => b0(t.content), [t.content]), se = ct(() => Lf(t.content), [t.content]), Ne = ct(
11618
+ }, [N]), B = ct(() => b0(t.content), [t.content]), se = ct(() => Lf(t.content), [t.content]), Ne = ct(
11608
11619
  () => t.content.filter((Z) => Z.type === "image_url"),
11609
11620
  [t.content]
11610
11621
  ), Ie = ct(
@@ -11614,7 +11625,7 @@ const k0 = U.memo(function({
11614
11625
  () => t.content.filter((Z) => Z.type === "interrupt"),
11615
11626
  [t.content]
11616
11627
  ), D = (m == null ? void 0 : m.id) ?? (m == null ? void 0 : m.interrupt_id), X = Yo(D), te = m == null ? void 0 : m.value, ce = ct(() => S0(t.content), [t.content]), ie = U.useCallback(async () => {
11617
- const Z = j ? ce : z;
11628
+ const Z = j ? ce : B;
11618
11629
  async function ve(we) {
11619
11630
  if (navigator.clipboard && typeof navigator.clipboard.writeText == "function") {
11620
11631
  await navigator.clipboard.writeText(we);
@@ -11636,11 +11647,11 @@ const k0 = U.memo(function({
11636
11647
  } catch (we) {
11637
11648
  console.error("Failed to copy:", we);
11638
11649
  }
11639
- }, [j, ce, z, v]), de = U.useCallback(() => {
11650
+ }, [j, ce, B, v]), de = U.useCallback(() => {
11640
11651
  if (!p) return;
11641
- const Z = j ? ce : z;
11652
+ const Z = j ? ce : B;
11642
11653
  p(t.id, Z);
11643
- }, [p, t.id, j, ce, z]), Be = U.useCallback(() => {
11654
+ }, [p, t.id, j, ce, B]), Be = U.useCallback(() => {
11644
11655
  x == null || x(n);
11645
11656
  }, [x, n]), Ge = U.useCallback(() => {
11646
11657
  const ve = oe(O ? "h-3 w-3" : "h-4 w-4", "opacity-60 flex-shrink-0", ae);
@@ -11816,7 +11827,7 @@ const k0 = U.memo(function({
11816
11827
  /* @__PURE__ */ u.jsx(Ki, { className: "h-4 w-4 text-muted-foreground" }),
11817
11828
  /* @__PURE__ */ u.jsx("span", { className: "text-sm text-muted-foreground", children: "File upload" })
11818
11829
  ] }), []), Ot = U.useCallback(() => {
11819
- const Z = z.trim().length > 0 || Ne.length > 0 || Ie.length > 0 || K.length > 0;
11830
+ const Z = B.trim().length > 0 || Ne.length > 0 || Ie.length > 0 || K.length > 0;
11820
11831
  if (!j && Ie.length > 0 && !r)
11821
11832
  return It();
11822
11833
  if (!j && !Z && !r)
@@ -11838,7 +11849,7 @@ const k0 = U.memo(function({
11838
11849
  ] }) : ve;
11839
11850
  }
11840
11851
  }, [
11841
- z,
11852
+ B,
11842
11853
  Ne.length,
11843
11854
  Ie.length,
11844
11855
  K.length,
@@ -12263,8 +12274,8 @@ const tu = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, $f = U.forwa
12263
12274
  let ee;
12264
12275
  const ae = w.value;
12265
12276
  if (ae && typeof ae == "object" && !Array.isArray(ae)) {
12266
- const z = ae.title;
12267
- typeof z == "string" && z.trim() && (ee = z.trim());
12277
+ const B = ae.title;
12278
+ typeof B == "string" && B.trim() && (ee = B.trim());
12268
12279
  }
12269
12280
  return {
12270
12281
  id: `interrupt-${G}`,
@@ -12279,7 +12290,7 @@ const tu = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, $f = U.forwa
12279
12290
  }
12280
12291
  ]
12281
12292
  };
12282
- }, [w, O]), j = ct(() => N ? [...e, N] : e, [e, N]), B = ct(() => S ? j : j.filter((G) => (G == null ? void 0 : G.role) !== "tool"), [j, S]), re = be((G) => {
12293
+ }, [w, O]), j = ct(() => N ? [...e, N] : e, [e, N]), z = ct(() => S ? j : j.filter((G) => (G == null ? void 0 : G.role) !== "tool"), [j, S]), re = be((G) => {
12283
12294
  q(G), v && v(!G), m && m(G);
12284
12295
  }, [v, m]), W = ct(() => {
12285
12296
  if (a)
@@ -12294,7 +12305,7 @@ const tu = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, $f = U.forwa
12294
12305
  }
12295
12306
  };
12296
12307
  }, [a]), $ = ct(() => !x || y ? !1 : F ? "auto" : !1, [F, x, y]);
12297
- return B.length === 0 ? /* @__PURE__ */ u.jsx("div", { className: f, style: h, children: /* @__PURE__ */ u.jsx("div", { className: "flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto", children: p || "No messages yet. Start a conversation!" }) }) : /* @__PURE__ */ u.jsx("div", { className: f, style: h, children: /* @__PURE__ */ u.jsx(
12308
+ return z.length === 0 ? /* @__PURE__ */ u.jsx("div", { className: f, style: h, children: /* @__PURE__ */ u.jsx("div", { className: "flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto", children: p || "No messages yet. Start a conversation!" }) }) : /* @__PURE__ */ u.jsx("div", { className: f, style: h, children: /* @__PURE__ */ u.jsx(
12298
12309
  ew,
12299
12310
  {
12300
12311
  ref: (G) => {
@@ -12303,7 +12314,7 @@ const tu = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, $f = U.forwa
12303
12314
  scrollerRef: (G) => {
12304
12315
  _.current = G instanceof HTMLDivElement ? G : null;
12305
12316
  },
12306
- data: B,
12317
+ data: z,
12307
12318
  followOutput: $,
12308
12319
  overscan: 200,
12309
12320
  increaseViewportBy: { top: 100, bottom: 200 },
@@ -12724,17 +12735,17 @@ const K0 = (e) => ({
12724
12735
  }, p = hl(o), x = fl(p), y = await i.getDimensions(c), v = p === "y", m = v ? "top" : "left", w = v ? "bottom" : "right", b = v ? "clientHeight" : "clientWidth", T = s.reference[x] + s.reference[p] - h[p] - s.floating[x], C = h[p] - s.reference[p], S = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(c));
12725
12736
  let k = S ? S[b] : 0;
12726
12737
  (!k || !await (i.isElement == null ? void 0 : i.isElement(S))) && (k = a.floating[b] || s.floating[x]);
12727
- const A = T / 2 - C / 2, _ = k / 2 - y[x] / 2 - 1, M = er(f[m], _), F = er(f[w], _), q = M, O = k - y[x] - F, N = k / 2 - y[x] / 2 + A, j = ma(q, N, O), B = !l.arrow && qr(o) != null && N !== j && s.reference[x] / 2 - (N < q ? M : F) - y[x] / 2 < 0, re = B ? N < q ? N - q : N - O : 0;
12738
+ const A = T / 2 - C / 2, _ = k / 2 - y[x] / 2 - 1, M = er(f[m], _), F = er(f[w], _), q = M, O = k - y[x] - F, N = k / 2 - y[x] / 2 + A, j = ma(q, N, O), z = !l.arrow && qr(o) != null && N !== j && s.reference[x] / 2 - (N < q ? M : F) - y[x] / 2 < 0, re = z ? N < q ? N - q : N - O : 0;
12728
12739
  return {
12729
12740
  [p]: h[p] + re,
12730
12741
  data: {
12731
12742
  [p]: j,
12732
12743
  centerOffset: N - j - re,
12733
- ...B && {
12744
+ ...z && {
12734
12745
  alignmentOffset: re
12735
12746
  }
12736
12747
  },
12737
- reset: B
12748
+ reset: z
12738
12749
  };
12739
12750
  }
12740
12751
  }), q0 = function(e) {
@@ -12787,8 +12798,8 @@ const K0 = (e) => ({
12787
12798
  placement: j
12788
12799
  }
12789
12800
  };
12790
- let B = (q = M.filter((re) => re.overflows[0] <= 0).sort((re, W) => re.overflows[1] - W.overflows[1])[0]) == null ? void 0 : q.placement;
12791
- if (!B)
12801
+ let z = (q = M.filter((re) => re.overflows[0] <= 0).sort((re, W) => re.overflows[1] - W.overflows[1])[0]) == null ? void 0 : q.placement;
12802
+ if (!z)
12792
12803
  switch (p) {
12793
12804
  case "bestFit": {
12794
12805
  var O;
@@ -12801,17 +12812,17 @@ const K0 = (e) => ({
12801
12812
  }
12802
12813
  return !0;
12803
12814
  }).map((W) => [W.placement, W.overflows.filter(($) => $ > 0).reduce(($, G) => $ + G, 0)]).sort((W, $) => W[1] - $[1])[0]) == null ? void 0 : O[0];
12804
- re && (B = re);
12815
+ re && (z = re);
12805
12816
  break;
12806
12817
  }
12807
12818
  case "initialPlacement":
12808
- B = a;
12819
+ z = a;
12809
12820
  break;
12810
12821
  }
12811
- if (o !== B)
12822
+ if (o !== z)
12812
12823
  return {
12813
12824
  reset: {
12814
- placement: B
12825
+ placement: z
12815
12826
  }
12816
12827
  };
12817
12828
  }
@@ -13675,7 +13686,7 @@ function MS(e) {
13675
13686
  floating: k,
13676
13687
  setReference: w,
13677
13688
  setFloating: b
13678
- }), [w, b]), B = g.useMemo(() => ({
13689
+ }), [w, b]), z = g.useMemo(() => ({
13679
13690
  reference: T,
13680
13691
  floating: C
13681
13692
  }), [T, C]), re = g.useMemo(() => {
@@ -13684,13 +13695,13 @@ function MS(e) {
13684
13695
  left: 0,
13685
13696
  top: 0
13686
13697
  };
13687
- if (!B.floating)
13698
+ if (!z.floating)
13688
13699
  return W;
13689
- const $ = fu(B.floating, d.x), G = fu(B.floating, d.y);
13700
+ const $ = fu(z.floating, d.x), G = fu(z.floating, d.y);
13690
13701
  return a ? {
13691
13702
  ...W,
13692
13703
  transform: "translate(" + $ + "px, " + G + "px)",
13693
- ...Xf(B.floating) >= 1.5 && {
13704
+ ...Xf(z.floating) >= 1.5 && {
13694
13705
  willChange: "transform"
13695
13706
  }
13696
13707
  } : {
@@ -13698,14 +13709,14 @@ function MS(e) {
13698
13709
  left: $,
13699
13710
  top: G
13700
13711
  };
13701
- }, [n, a, B.floating, d.x, d.y]);
13712
+ }, [n, a, z.floating, d.x, d.y]);
13702
13713
  return g.useMemo(() => ({
13703
13714
  ...d,
13704
13715
  update: O,
13705
13716
  refs: j,
13706
- elements: B,
13717
+ elements: z,
13707
13718
  floatingStyles: re
13708
- }), [d, O, j, B, re]);
13719
+ }), [d, O, j, z, re]);
13709
13720
  }
13710
13721
  const DS = (e) => {
13711
13722
  function t(n) {
@@ -13827,7 +13838,7 @@ var yl = "PopperContent", [qS, GS] = Qf(yl), oh = g.forwardRef(
13827
13838
  boundary: F.filter(XS),
13828
13839
  // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
13829
13840
  altBoundary: q
13830
- }, { refs: N, floatingStyles: j, placement: B, isPositioned: re, middlewareData: W } = MS({
13841
+ }, { refs: N, floatingStyles: j, placement: z, isPositioned: re, middlewareData: W } = MS({
13831
13842
  // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
13832
13843
  strategy: "fixed",
13833
13844
  placement: _,
@@ -13857,11 +13868,11 @@ var yl = "PopperContent", [qS, GS] = Qf(yl), oh = g.forwardRef(
13857
13868
  JS({ arrowWidth: k, arrowHeight: A }),
13858
13869
  h && HS({ strategy: "referenceHidden", ...O })
13859
13870
  ]
13860
- }), [$, G] = ah(B), ee = Pt(x);
13871
+ }), [$, G] = ah(z), ee = Pt(x);
13861
13872
  Et(() => {
13862
13873
  re && (ee == null || ee());
13863
13874
  }, [re, ee]);
13864
- const ae = (K = W.arrow) == null ? void 0 : K.x, z = (D = W.arrow) == null ? void 0 : D.y, se = ((X = W.arrow) == null ? void 0 : X.centerOffset) !== 0, [Ne, Ie] = g.useState();
13875
+ const ae = (K = W.arrow) == null ? void 0 : K.x, B = (D = W.arrow) == null ? void 0 : D.y, se = ((X = W.arrow) == null ? void 0 : X.centerOffset) !== 0, [Ne, Ie] = g.useState();
13865
13876
  return Et(() => {
13866
13877
  m && Ie(window.getComputedStyle(m).zIndex);
13867
13878
  }, [m]), /* @__PURE__ */ u.jsx(
@@ -13895,7 +13906,7 @@ var yl = "PopperContent", [qS, GS] = Qf(yl), oh = g.forwardRef(
13895
13906
  placedSide: $,
13896
13907
  onArrowChange: C,
13897
13908
  arrowX: ae,
13898
- arrowY: z,
13909
+ arrowY: B,
13899
13910
  shouldHideArrow: se,
13900
13911
  children: /* @__PURE__ */ u.jsx(
13901
13912
  Ae.div,
@@ -14053,9 +14064,9 @@ var rC = g.forwardRef((e, t) => {
14053
14064
  if (A.target === A.currentTarget && _ && !m) {
14054
14065
  const M = new CustomEvent(Wi, ZS);
14055
14066
  if (A.currentTarget.dispatchEvent(M), !M.defaultPrevented) {
14056
- const F = T().filter((B) => B.focusable), q = F.find((B) => B.active), O = F.find((B) => B.id === y), j = [q, O, ...F].filter(
14067
+ const F = T().filter((z) => z.focusable), q = F.find((z) => z.active), O = F.find((z) => z.id === y), j = [q, O, ...F].filter(
14057
14068
  Boolean
14058
- ).map((B) => B.ref.current);
14069
+ ).map((z) => z.ref.current);
14059
14070
  xh(j, d);
14060
14071
  }
14061
14072
  }
@@ -14265,9 +14276,9 @@ var ln = "MenuContent", [wC, bl] = Er(ln), Th = g.forwardRef(
14265
14276
  onDismiss: p,
14266
14277
  disableOutsideScroll: x,
14267
14278
  ...y
14268
- } = e, v = Ir(ln, n), m = Do(ln, n), w = li(n), b = wh(n), T = pC(n), [C, S] = g.useState(null), k = g.useRef(null), A = We(t, k, v.onContentChange), _ = g.useRef(0), M = g.useRef(""), F = g.useRef(0), q = g.useRef(null), O = g.useRef("right"), N = g.useRef(0), j = x ? Js : g.Fragment, B = x ? { as: CC, allowPinchZoom: !0 } : void 0, re = ($) => {
14279
+ } = e, v = Ir(ln, n), m = Do(ln, n), w = li(n), b = wh(n), T = pC(n), [C, S] = g.useState(null), k = g.useRef(null), A = We(t, k, v.onContentChange), _ = g.useRef(0), M = g.useRef(""), F = g.useRef(0), q = g.useRef(null), O = g.useRef("right"), N = g.useRef(0), j = x ? Js : g.Fragment, z = x ? { as: CC, allowPinchZoom: !0 } : void 0, re = ($) => {
14269
14280
  var K, D;
14270
- const G = M.current + $, ee = T().filter((X) => !X.disabled), ae = document.activeElement, z = (K = ee.find((X) => X.ref.current === ae)) == null ? void 0 : K.textValue, se = ee.map((X) => X.textValue), Ne = MC(se, G, z), Ie = (D = ee.find((X) => X.textValue === Ne)) == null ? void 0 : D.ref.current;
14281
+ const G = M.current + $, ee = T().filter((X) => !X.disabled), ae = document.activeElement, B = (K = ee.find((X) => X.ref.current === ae)) == null ? void 0 : K.textValue, se = ee.map((X) => X.textValue), Ne = MC(se, G, B), Ie = (D = ee.find((X) => X.textValue === Ne)) == null ? void 0 : D.ref.current;
14271
14282
  (function X(te) {
14272
14283
  M.current = te, window.clearTimeout(_.current), te !== "" && (_.current = window.setTimeout(() => X(""), 1e3));
14273
14284
  })(G), Ie && setTimeout(() => Ie.focus());
@@ -14305,7 +14316,7 @@ var ln = "MenuContent", [wC, bl] = Er(ln), Th = g.forwardRef(
14305
14316
  onPointerGraceIntentChange: g.useCallback(($) => {
14306
14317
  q.current = $;
14307
14318
  }, []),
14308
- children: /* @__PURE__ */ u.jsx(j, { ...B, children: /* @__PURE__ */ u.jsx(
14319
+ children: /* @__PURE__ */ u.jsx(j, { ...z, children: /* @__PURE__ */ u.jsx(
14309
14320
  Gs,
14310
14321
  {
14311
14322
  asChild: !0,
@@ -14352,8 +14363,8 @@ var ln = "MenuContent", [wC, bl] = Er(ln), Th = g.forwardRef(
14352
14363
  ref: A,
14353
14364
  style: { outline: "none", ...y.style },
14354
14365
  onKeyDown: ge(y.onKeyDown, ($) => {
14355
- const ee = $.target.closest("[data-radix-menu-content]") === $.currentTarget, ae = $.ctrlKey || $.altKey || $.metaKey, z = $.key.length === 1;
14356
- ee && ($.key === "Tab" && $.preventDefault(), !ae && z && re($.key));
14366
+ const ee = $.target.closest("[data-radix-menu-content]") === $.currentTarget, ae = $.ctrlKey || $.altKey || $.metaKey, B = $.key.length === 1;
14367
+ ee && ($.key === "Tab" && $.preventDefault(), !ae && B && re($.key));
14357
14368
  const se = k.current;
14358
14369
  if ($.target !== se || !dC.includes($.key)) return;
14359
14370
  $.preventDefault();
@@ -15042,14 +15053,14 @@ function Vi({
15042
15053
  checkpoints: M,
15043
15054
  interrupt: F,
15044
15055
  metadata: q
15045
- } = $a(), { isStreaming: O, error: N, submit: j, stop: B } = By(), re = m ?? v ?? null, W = (_ == null ? void 0 : _.id) ?? null, $ = (_ == null ? void 0 : _.namespace) ?? null, G = (q == null ? void 0 : q.assemblingMessageId) ?? null, ee = F, [ae, z] = xe(!1);
15056
+ } = $a(), { isStreaming: O, error: N, submit: j, stop: z } = By(), re = m ?? v ?? null, W = (_ == null ? void 0 : _.id) ?? null, $ = (_ == null ? void 0 : _.namespace) ?? null, G = (q == null ? void 0 : q.assemblingMessageId) ?? null, ee = F, [ae, B] = xe(!1);
15046
15057
  lt(() => {
15047
- ee || z(!1);
15058
+ ee || B(!1);
15048
15059
  }, [ee]);
15049
15060
  const se = be(() => {
15050
- z(!0);
15061
+ B(!0);
15051
15062
  }, []), Ne = be(() => {
15052
- z(!1);
15063
+ B(!1);
15053
15064
  }, []), Ie = !!ee || ae, [K, D] = xe(null), [X, te] = xe(""), [ce, ie] = xe(null), [de, Be] = xe([]), [Ge, Ze] = xe(0), [Ye, ft] = xe(0), [Qe, Oe] = xe(!1), [It, Ot] = xe(null), [He, Z] = xe(null), [ve, we] = xe(!1), [qe, ht] = xe(null), [mt, At] = xe(!1), yt = De(!1), [at, Je] = xe(() => pu.value), Mt = De(at), vt = De(null), et = be((L) => {
15054
15065
  pu.value = L, Je(L);
15055
15066
  }, []), [qn, Gt] = xe(!1), dn = be(
@@ -15449,7 +15460,7 @@ function Vi({
15449
15460
  maxLength: us,
15450
15461
  onSend: pn,
15451
15462
  onCancelEdit: cr,
15452
- onStop: B,
15463
+ onStop: z,
15453
15464
  allowEmptySend: de.length > 0,
15454
15465
  textareaClassName: `resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${K ? "border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50" : ""} ${ce ? "border-red-400" : ""} ${f.textarea || ""}`
15455
15466
  }
@@ -16037,77 +16048,77 @@ function gu({
16037
16048
  actions: x
16038
16049
  } = Fa(), { loadThread: y } = $a(), { createThread: v, deleteThread: m, renameThread: w } = x, [b, T] = xe(Array.isArray(f) ? f : []), C = De(b.length > 0), S = De(null), k = De(0), [A, _] = xe(null), [M, F] = xe(""), [q, O] = xe(!1);
16039
16050
  lt(() => {
16040
- const z = Array.isArray(f) ? f : [];
16041
- if (z.length > 0) {
16042
- C.current = !0, T(z);
16051
+ const B = Array.isArray(f) ? f : [];
16052
+ if (B.length > 0) {
16053
+ C.current = !0, T(B);
16043
16054
  return;
16044
16055
  }
16045
- p || (C.current = !1, T(z));
16056
+ p || (C.current = !1, T(B));
16046
16057
  }, [f, p]), lt(() => {
16047
16058
  if (!S.current) return;
16048
- const z = S.current.querySelector(
16059
+ const B = S.current.querySelector(
16049
16060
  "[data-radix-scroll-area-viewport]"
16050
16061
  );
16051
- if (!z) return;
16062
+ if (!B) return;
16052
16063
  let se = null, Ne = null;
16053
16064
  return se = requestAnimationFrame(() => {
16054
16065
  Ne = requestAnimationFrame(() => {
16055
- z.scrollTop = k.current;
16066
+ B.scrollTop = k.current;
16056
16067
  });
16057
16068
  }), () => {
16058
16069
  se !== null && cancelAnimationFrame(se), Ne !== null && cancelAnimationFrame(Ne);
16059
16070
  };
16060
16071
  }, [b]);
16061
- const N = async (z) => {
16072
+ const N = async (B) => {
16062
16073
  try {
16063
- await y(z), a == null || a(z), l == null || l(z);
16074
+ await y(B), a == null || a(B), l == null || l(B);
16064
16075
  } catch (se) {
16065
16076
  console.error("Failed to select thread:", se);
16066
16077
  }
16067
16078
  }, j = async () => {
16068
16079
  try {
16069
16080
  O(!0);
16070
- const z = await v();
16071
- c == null || c(z), a == null || a(z);
16072
- } catch (z) {
16073
- console.error("Failed to create thread:", z);
16081
+ const B = await v();
16082
+ c == null || c(B), a == null || a(B);
16083
+ } catch (B) {
16084
+ console.error("Failed to create thread:", B);
16074
16085
  } finally {
16075
16086
  O(!1);
16076
16087
  }
16077
- }, B = async (z, se) => {
16088
+ }, z = async (B, se) => {
16078
16089
  if (se.stopPropagation(), !!confirm("Delete this thread?")) {
16079
16090
  if (S.current) {
16080
16091
  const Ne = S.current.querySelector("[data-radix-scroll-area-viewport]");
16081
16092
  Ne && (k.current = Ne.scrollTop);
16082
16093
  }
16083
16094
  try {
16084
- await m(z), d == null || d(z);
16095
+ await m(B), d == null || d(B);
16085
16096
  } catch (Ne) {
16086
16097
  console.error("Failed to delete thread:", Ne);
16087
16098
  }
16088
16099
  }
16089
- }, re = (z, se) => {
16090
- se.stopPropagation(), _(z.threadId), F(z.title || `Thread ${z.threadId.slice(0, 8)}`);
16091
- }, W = async (z) => {
16100
+ }, re = (B, se) => {
16101
+ se.stopPropagation(), _(B.threadId), F(B.title || `Thread ${B.threadId.slice(0, 8)}`);
16102
+ }, W = async (B) => {
16092
16103
  if (M.trim())
16093
16104
  try {
16094
- await w(z, M.trim()), _(null), F("");
16105
+ await w(B, M.trim()), _(null), F("");
16095
16106
  } catch (se) {
16096
16107
  console.error("Failed to update title:", se);
16097
16108
  }
16098
16109
  }, $ = () => {
16099
16110
  _(null), F("");
16100
- }, G = (z, se) => {
16101
- z.key === "Enter" ? W(se) : z.key === "Escape" && $();
16102
- }, ee = (z) => {
16103
- if (!z) return "";
16111
+ }, G = (B, se) => {
16112
+ B.key === "Enter" ? W(se) : B.key === "Escape" && $();
16113
+ }, ee = (B) => {
16114
+ if (!B) return "";
16104
16115
  try {
16105
- const se = new Date(z), Ie = (/* @__PURE__ */ new Date()).getTime() - se.getTime(), K = Math.floor(Ie / (1e3 * 60 * 60 * 24));
16116
+ const se = new Date(B), Ie = (/* @__PURE__ */ new Date()).getTime() - se.getTime(), K = Math.floor(Ie / (1e3 * 60 * 60 * 24));
16106
16117
  return K === 0 ? se.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : K === 1 ? "Yesterday" : K < 7 ? `${K} days ago` : se.toLocaleDateString();
16107
16118
  } catch {
16108
16119
  return "";
16109
16120
  }
16110
- }, ae = (z) => z.title || `Thread ${z.threadId.slice(0, 8)}`;
16121
+ }, ae = (B) => B.title || `Thread ${B.threadId.slice(0, 8)}`;
16111
16122
  return /* @__PURE__ */ u.jsxs("div", { className: `flex flex-col h-full ${e} ${s.container || ""}`, children: [
16112
16123
  t && /* @__PURE__ */ u.jsx("div", { className: s.header || "flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end", children: /* @__PURE__ */ u.jsx(
16113
16124
  nt,
@@ -16133,32 +16144,32 @@ function gu({
16133
16144
  ] }) : b.length === 0 ? /* @__PURE__ */ u.jsxs("div", { className: "text-center py-8 text-slate-400", children: [
16134
16145
  /* @__PURE__ */ u.jsx(Gm, { className: "w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500" }),
16135
16146
  /* @__PURE__ */ u.jsx("p", { className: "text-sm text-slate-500", children: "No conversations yet" })
16136
- ] }) : b.slice().sort((z, se) => new Date(se.updatedAt || se.createdAt || "").getTime() - new Date(z.updatedAt || z.createdAt || "").getTime()).map((z) => /* @__PURE__ */ u.jsxs(
16147
+ ] }) : b.slice().sort((B, se) => new Date(se.updatedAt || se.createdAt || "").getTime() - new Date(B.updatedAt || B.createdAt || "").getTime()).map((B) => /* @__PURE__ */ u.jsxs(
16137
16148
  "div",
16138
16149
  {
16139
- onClick: () => N(z.threadId),
16140
- className: `group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i ?? h) === z.threadId ? `${s.activeThread || "bg-slate-600 border-slate-500"} ` : `${s.threadItem || "bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem || ""} text-gray-900 dark:text-slate-100`,
16150
+ onClick: () => N(B.threadId),
16151
+ className: `group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i ?? h) === B.threadId ? `${s.activeThread || "bg-slate-600 border-slate-500"} ` : `${s.threadItem || "bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem || ""} text-gray-900 dark:text-slate-100`,
16141
16152
  children: [
16142
16153
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center justify-between", children: [
16143
- /* @__PURE__ */ u.jsx("div", { className: "flex-1 min-w-0", children: A === z.threadId ? /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2", onClick: (se) => se.stopPropagation(), children: [
16144
- /* @__PURE__ */ u.jsx(Is, { value: M, onChange: (se) => F(se.target.value), onKeyDown: (se) => G(se, z.threadId), className: "h-6 text-sm", autoFocus: !0 }),
16145
- /* @__PURE__ */ u.jsx(nt, { variant: "ghost", size: "sm", onClick: () => W(z.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(_a, { size: 12 }) }),
16154
+ /* @__PURE__ */ u.jsx("div", { className: "flex-1 min-w-0", children: A === B.threadId ? /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2", onClick: (se) => se.stopPropagation(), children: [
16155
+ /* @__PURE__ */ u.jsx(Is, { value: M, onChange: (se) => F(se.target.value), onKeyDown: (se) => G(se, B.threadId), className: "h-6 text-sm", autoFocus: !0 }),
16156
+ /* @__PURE__ */ u.jsx(nt, { variant: "ghost", size: "sm", onClick: () => W(B.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(_a, { size: 12 }) }),
16146
16157
  /* @__PURE__ */ u.jsx(nt, { variant: "ghost", size: "sm", onClick: $, className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(Or, { size: 12 }) })
16147
16158
  ] }) : /* @__PURE__ */ u.jsxs(u.Fragment, { children: [
16148
- /* @__PURE__ */ u.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: ae(z) }),
16159
+ /* @__PURE__ */ u.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: ae(B) }),
16149
16160
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1", children: [
16150
16161
  /* @__PURE__ */ u.jsx(Ym, { size: 10 }),
16151
- /* @__PURE__ */ u.jsx("span", { children: ee(z.updatedAt || z.createdAt) })
16162
+ /* @__PURE__ */ u.jsx("span", { children: ee(B.updatedAt || B.createdAt) })
16152
16163
  ] })
16153
16164
  ] }) }),
16154
16165
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2", children: [
16155
- r && A !== z.threadId && /* @__PURE__ */ u.jsx(nt, { variant: "ghost", size: "sm", onClick: (se) => re(z, se), className: "h-6 w-6 p-0", title: "Edit title", children: /* @__PURE__ */ u.jsx(wu, { size: 12 }) }),
16166
+ r && A !== B.threadId && /* @__PURE__ */ u.jsx(nt, { variant: "ghost", size: "sm", onClick: (se) => re(B, se), className: "h-6 w-6 p-0", title: "Edit title", children: /* @__PURE__ */ u.jsx(wu, { size: 12 }) }),
16156
16167
  n && /* @__PURE__ */ u.jsx(
16157
16168
  nt,
16158
16169
  {
16159
16170
  variant: "ghost",
16160
16171
  size: "sm",
16161
- onClick: (se) => B(z.threadId, se),
16172
+ onClick: (se) => z(B.threadId, se),
16162
16173
  className: "h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",
16163
16174
  title: "Delete thread",
16164
16175
  children: /* @__PURE__ */ u.jsx(Xm, { size: 12 })
@@ -16166,10 +16177,10 @@ function gu({
16166
16177
  )
16167
16178
  ] })
16168
16179
  ] }),
16169
- i === z.threadId && /* @__PURE__ */ u.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r" })
16180
+ i === B.threadId && /* @__PURE__ */ u.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r" })
16170
16181
  ]
16171
16182
  },
16172
- z.threadId
16183
+ B.threadId
16173
16184
  )) })
16174
16185
  }
16175
16186
  )
@@ -16494,7 +16505,7 @@ var ek = [" ", "Enter", "ArrowUp", "ArrowDown"], tk = [" ", "Enter"], Sr = "Sele
16494
16505
  defaultProp: a,
16495
16506
  onChange: l,
16496
16507
  caller: Sr
16497
- }), F = g.useRef(null), q = v ? x || !!v.closest("form") : !0, [O, N] = g.useState(/* @__PURE__ */ new Set()), j = Array.from(O).map((B) => B.props.value).join(";");
16508
+ }), F = g.useRef(null), q = v ? x || !!v.closest("form") : !0, [O, N] = g.useState(/* @__PURE__ */ new Set()), j = Array.from(O).map((z) => z.props.value).join(";");
16498
16509
  return /* @__PURE__ */ u.jsx(lh, { ...y, children: /* @__PURE__ */ u.jsxs(
16499
16510
  rk,
16500
16511
  {
@@ -16519,13 +16530,13 @@ var ek = [" ", "Enter", "ArrowUp", "ArrowDown"], tk = [" ", "Enter"], Sr = "Sele
16519
16530
  ok,
16520
16531
  {
16521
16532
  scope: e.__scopeSelect,
16522
- onNativeOptionAdd: g.useCallback((B) => {
16523
- N((re) => new Set(re).add(B));
16533
+ onNativeOptionAdd: g.useCallback((z) => {
16534
+ N((re) => new Set(re).add(z));
16524
16535
  }, []),
16525
- onNativeOptionRemove: g.useCallback((B) => {
16536
+ onNativeOptionRemove: g.useCallback((z) => {
16526
16537
  N((re) => {
16527
16538
  const W = new Set(re);
16528
- return W.delete(B), W;
16539
+ return W.delete(z), W;
16529
16540
  });
16530
16541
  }, []),
16531
16542
  children: n
@@ -16540,7 +16551,7 @@ var ek = [" ", "Enter", "ArrowUp", "ArrowDown"], tk = [" ", "Enter"], Sr = "Sele
16540
16551
  name: d,
16541
16552
  autoComplete: f,
16542
16553
  value: _,
16543
- onChange: (B) => M(B.target.value),
16554
+ onChange: (z) => M(z.target.value),
16544
16555
  disabled: h,
16545
16556
  form: x,
16546
16557
  children: [
@@ -16669,7 +16680,7 @@ var mn = 10, [Yp, ir] = Yr(Cr), lk = "SelectContentImpl", ck = $r("SelectContent
16669
16680
  g.useEffect(() => {
16670
16681
  if (b) return ol(b);
16671
16682
  }, [b]), rl();
16672
- const B = g.useCallback(
16683
+ const z = g.useCallback(
16673
16684
  (K) => {
16674
16685
  const [D, ...X] = q().map((ie) => ie.ref.current), [te] = X.slice(-1), ce = document.activeElement;
16675
16686
  for (const ie of K)
@@ -16677,8 +16688,8 @@ var mn = 10, [Yp, ir] = Yr(Cr), lk = "SelectContentImpl", ck = $r("SelectContent
16677
16688
  },
16678
16689
  [q, C]
16679
16690
  ), re = g.useCallback(
16680
- () => B([A, b]),
16681
- [B, A, b]
16691
+ () => z([A, b]),
16692
+ [z, A, b]
16682
16693
  );
16683
16694
  g.useEffect(() => {
16684
16695
  O && re();
@@ -16715,7 +16726,7 @@ var mn = 10, [Yp, ir] = Yr(Cr), lk = "SelectContentImpl", ck = $r("SelectContent
16715
16726
  (w.value !== void 0 && w.value === D || te) && (_(K), te && (j.current = !0));
16716
16727
  },
16717
16728
  [w.value]
16718
- ), z = g.useCallback(() => b == null ? void 0 : b.focus(), [b]), se = g.useCallback(
16729
+ ), B = g.useCallback(() => b == null ? void 0 : b.focus(), [b]), se = g.useCallback(
16719
16730
  (K, D, X) => {
16720
16731
  const te = !j.current && !X;
16721
16732
  (w.value !== void 0 && w.value === D || te) && F(K);
@@ -16742,7 +16753,7 @@ var mn = 10, [Yp, ir] = Yr(Cr), lk = "SelectContentImpl", ck = $r("SelectContent
16742
16753
  onViewportChange: S,
16743
16754
  itemRefCallback: ae,
16744
16755
  selectedItem: A,
16745
- onItemLeave: z,
16756
+ onItemLeave: B,
16746
16757
  itemTextRefCallback: se,
16747
16758
  focusSelectedItem: re,
16748
16759
  selectedItemText: M,
@@ -16798,7 +16809,7 @@ var mn = 10, [Yp, ir] = Yr(Cr), lk = "SelectContentImpl", ck = $r("SelectContent
16798
16809
  const ce = K.target, ie = te.indexOf(ce);
16799
16810
  te = te.slice(ie + 1);
16800
16811
  }
16801
- setTimeout(() => B(te)), K.preventDefault();
16812
+ setTimeout(() => z(te)), K.preventDefault();
16802
16813
  }
16803
16814
  })
16804
16815
  }
@@ -16834,14 +16845,14 @@ var uk = "SelectItemAlignedPosition", Jp = g.forwardRef((e, t) => {
16834
16845
  ]);
16835
16846
  a.style.minWidth = Be + "px", a.style.right = Ye + "px";
16836
16847
  }
16837
- const F = h(), q = window.innerHeight - mn * 2, O = y.scrollHeight, N = window.getComputedStyle(c), j = parseInt(N.borderTopWidth, 10), B = parseInt(N.paddingTop, 10), re = parseInt(N.borderBottomWidth, 10), W = parseInt(N.paddingBottom, 10), $ = j + B + O + W + re, G = Math.min(v.offsetHeight * 5, $), ee = window.getComputedStyle(y), ae = parseInt(ee.paddingTop, 10), z = parseInt(ee.paddingBottom, 10), se = k.top + k.height / 2 - mn, Ne = q - se, Ie = v.offsetHeight / 2, K = v.offsetTop + Ie, D = j + B + K, X = $ - D;
16848
+ const F = h(), q = window.innerHeight - mn * 2, O = y.scrollHeight, N = window.getComputedStyle(c), j = parseInt(N.borderTopWidth, 10), z = parseInt(N.paddingTop, 10), re = parseInt(N.borderBottomWidth, 10), W = parseInt(N.paddingBottom, 10), $ = j + z + O + W + re, G = Math.min(v.offsetHeight * 5, $), ee = window.getComputedStyle(y), ae = parseInt(ee.paddingTop, 10), B = parseInt(ee.paddingBottom, 10), se = k.top + k.height / 2 - mn, Ne = q - se, Ie = v.offsetHeight / 2, K = v.offsetTop + Ie, D = j + z + K, X = $ - D;
16838
16849
  if (D <= se) {
16839
16850
  const ce = F.length > 0 && v === F[F.length - 1].ref.current;
16840
16851
  a.style.bottom = "0px";
16841
16852
  const ie = c.clientHeight - y.offsetTop - y.offsetHeight, de = Math.max(
16842
16853
  Ne,
16843
16854
  Ie + // viewport might have padding bottom, include it to avoid a scrollable viewport
16844
- (ce ? z : 0) + ie + re
16855
+ (ce ? B : 0) + ie + re
16845
16856
  ), Be = D + de;
16846
16857
  a.style.height = Be + "px";
16847
16858
  } else {