teodor-new-chat-ui 3.0.2 → 3.0.3

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
@@ -1293,10 +1293,10 @@ const Xa = (e) => {
1293
1293
  );
1294
1294
  }
1295
1295
  N = N || "text";
1296
- let Q = await p[S.findKey(p, N) || "text"](D, g);
1296
+ let ee = await p[S.findKey(p, N) || "text"](D, g);
1297
1297
  return !T && M && M(), await new Promise((q, ae) => {
1298
1298
  Ga(q, ae, {
1299
- data: Q,
1299
+ data: ee,
1300
1300
  headers: Ie.from(D.headers),
1301
1301
  status: D.status,
1302
1302
  statusText: D.statusText,
@@ -1969,14 +1969,14 @@ function sp(e = {}) {
1969
1969
  if (r)
1970
1970
  M = { Authorization: `Bearer ${r}` };
1971
1971
  else if (typeof window < "u") {
1972
- const Q = window.__AUTH_TOKEN__, q = ((L = window.localStorage) == null ? void 0 : L.getItem("authToken")) || null;
1972
+ const ee = window.__AUTH_TOKEN__, q = ((L = window.localStorage) == null ? void 0 : L.getItem("authToken")) || null;
1973
1973
  let ae = null;
1974
1974
  try {
1975
1975
  const j = (P = window.localStorage) == null ? void 0 : P.getItem("chat-settings");
1976
1976
  j && (ae = (($ = JSON.parse(j)) == null ? void 0 : $.apiKey) || null);
1977
1977
  } catch {
1978
1978
  }
1979
- const F = Q || q || ae || null;
1979
+ const F = ee || q || ae || null;
1980
1980
  F && (M = { Authorization: `Bearer ${F}` });
1981
1981
  }
1982
1982
  } catch {
@@ -1998,7 +1998,7 @@ function sp(e = {}) {
1998
1998
  throw N && console.debug("[use-chat] non-OK response", H.status, T == null ? void 0 : T.slice(0, 500)), new Error(`stream ${H.status}${T ? ": " + T : ""}`);
1999
1999
  }
2000
2000
  try {
2001
- const T = H.headers.get("X-Thread-Id") || H.headers.get("x-thread-id"), Q = H.headers.get("X-Thread-Created") || H.headers.get("x-thread-created"), q = T ?? null, ae = String(Q ?? "").toLowerCase() === "true";
2001
+ const T = H.headers.get("X-Thread-Id") || H.headers.get("x-thread-id"), ee = H.headers.get("X-Thread-Created") || H.headers.get("x-thread-created"), q = T ?? null, ae = String(ee ?? "").toLowerCase() === "true";
2002
2002
  try {
2003
2003
  (K = R == null ? void 0 : R.onOpen) == null || K.call(R, { threadId: q, created: ae });
2004
2004
  } catch (F) {
@@ -2010,8 +2010,8 @@ function sp(e = {}) {
2010
2010
  const O = H.body.getReader(), G = new TextDecoder();
2011
2011
  let D = "";
2012
2012
  for (; ; ) {
2013
- const { value: T, done: Q } = await O.read();
2014
- if (Q) break;
2013
+ const { value: T, done: ee } = await O.read();
2014
+ if (ee) break;
2015
2015
  D += G.decode(T, { stream: !0 });
2016
2016
  let q;
2017
2017
  for (; (q = D.indexOf(`
@@ -2284,7 +2284,7 @@ function Bn({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
2284
2284
  Y === "replace" ? x(he) : Y === "prepend" && he.length && y(he), B((X == null ? void 0 : X.nextCursor) ?? null), L(!!(X != null && X.hasMore)), H((Fe) => (X == null ? void 0 : X.checkpointId) ?? Fe ?? void 0);
2285
2285
  },
2286
2286
  [x, y]
2287
- ), [G, D] = re([]), [T, Q] = re(null), q = be(async () => {
2287
+ ), [G, D] = re([]), [T, ee] = re(null), q = be(async () => {
2288
2288
  const X = await l.listThreads();
2289
2289
  D(X);
2290
2290
  }, [l]);
@@ -2311,7 +2311,7 @@ function Bn({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
2311
2311
  checkpointNs: he,
2312
2312
  limit: N
2313
2313
  });
2314
- Q(X), O(Fe, "replace");
2314
+ ee(X), O(Fe, "replace");
2315
2315
  } finally {
2316
2316
  F.current = null;
2317
2317
  }
@@ -2356,7 +2356,7 @@ function Bn({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
2356
2356
  const Y = await l.createThread(X);
2357
2357
  return await q(), await j(Y.threadId), Y.threadId;
2358
2358
  }, [l, q, j]), V = be(async (X) => {
2359
- await l.deleteThread(X), await q(), T === X && (Q(null), _([]), L(!1), B(null), H(void 0));
2359
+ await l.deleteThread(X), await q(), T === X && (ee(null), _([]), L(!1), B(null), H(void 0));
2360
2360
  }, [l, q, T, _]), Z = be(async (X, Y) => {
2361
2361
  await l.updateThread(X, Y), await q();
2362
2362
  }, [l, q]), J = be(async (X, Y) => {
@@ -2374,8 +2374,8 @@ function Bn({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
2374
2374
  try {
2375
2375
  const tt = $e.result;
2376
2376
  let Nn = "";
2377
- const I = new Uint8Array(tt), ee = I.byteLength;
2378
- for (let le = 0; le < ee; le++) Nn += String.fromCharCode(I[le]);
2377
+ const I = new Uint8Array(tt), Q = I.byteLength;
2378
+ for (let le = 0; le < Q; le++) Nn += String.fromCharCode(I[le]);
2379
2379
  ye(btoa(Nn));
2380
2380
  } catch (tt) {
2381
2381
  Ne(tt);
@@ -2451,12 +2451,12 @@ function Bn({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
2451
2451
  {
2452
2452
  onError: (se) => console.warn("stream error", se),
2453
2453
  onOpen: ({ threadId: se, created: ye }) => {
2454
- !T && se && (Q(se), ye && q().catch(() => {
2454
+ !T && se && (ee(se), ye && q().catch(() => {
2455
2455
  }));
2456
2456
  }
2457
2457
  }
2458
2458
  );
2459
- }, [T, C, p, R, w.lastCheckpointId, l, t == null ? void 0 : t.uploadPath, q, Q]), pe = be(
2459
+ }, [T, C, p, R, w.lastCheckpointId, l, t == null ? void 0 : t.uploadPath, q, ee]), pe = be(
2460
2460
  async (X) => {
2461
2461
  if (!T) throw new Error("No active thread");
2462
2462
  if (P || !k) return;
@@ -2484,7 +2484,7 @@ function Bn({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
2484
2484
  api: l,
2485
2485
  threads: G,
2486
2486
  currentThreadId: T,
2487
- setCurrentThreadId: Q,
2487
+ setCurrentThreadId: ee,
2488
2488
  messages: w.messages,
2489
2489
  isStreaming: f,
2490
2490
  error: d,
@@ -3051,7 +3051,7 @@ function Mp({
3051
3051
  } catch (W) {
3052
3052
  console.error("Failed to copy:", W);
3053
3053
  }
3054
- }, Q = () => {
3054
+ }, ee = () => {
3055
3055
  if (!g) return;
3056
3056
  const W = K ? Tt(e.content) : M;
3057
3057
  g(e.id, W);
@@ -3299,7 +3299,7 @@ function Mp({
3299
3299
  {
3300
3300
  variant: "ghost",
3301
3301
  size: "sm",
3302
- onClick: Q,
3302
+ onClick: ee,
3303
3303
  className: A("h-6 w-6 p-0 hover:bg-foreground/10", B, P && "h-5 w-5"),
3304
3304
  children: /* @__PURE__ */ c(Es, { className: A(B, P ? "h-3 w-3" : "h-4 w-4") })
3305
3305
  }
@@ -3356,7 +3356,7 @@ function Mp({
3356
3356
  {
3357
3357
  variant: "ghost",
3358
3358
  size: "sm",
3359
- onClick: Q,
3359
+ onClick: ee,
3360
3360
  className: A("h-6 w-6 p-0 hover:bg-background/50 text-current", P && "h-5 w-5"),
3361
3361
  children: /* @__PURE__ */ c(Es, { className: A("text-current", P ? "h-3 w-3" : "h-4 w-4") })
3362
3362
  }
@@ -4294,7 +4294,7 @@ const Ch = (e) => ({
4294
4294
  T === "y";
4295
4295
  }
4296
4296
  return !0;
4297
- }).map((D) => [D.placement, D.overflows.filter((T) => T > 0).reduce((T, Q) => T + Q, 0)]).sort((D, T) => D[1] - T[1])[0]) == null ? void 0 : B[0];
4297
+ }).map((D) => [D.placement, D.overflows.filter((T) => T > 0).reduce((T, ee) => T + ee, 0)]).sort((D, T) => D[1] - T[1])[0]) == null ? void 0 : B[0];
4298
4298
  G && (O = G);
4299
4299
  break;
4300
4300
  }
@@ -5135,7 +5135,7 @@ function fm(e) {
5135
5135
  middleware: m
5136
5136
  };
5137
5137
  $.current && (D.platform = $.current), lm(_.current, N.current, D).then((T) => {
5138
- const Q = {
5138
+ const ee = {
5139
5139
  ...T,
5140
5140
  // The floating element's position may be recomputed while it's closed
5141
5141
  // but still mounted (such as when transitioning out). To ensure
@@ -5143,8 +5143,8 @@ function fm(e) {
5143
5143
  // setting it to `true` when `open === false` (must be specified).
5144
5144
  isPositioned: K.current !== !1
5145
5145
  };
5146
- M.current && !nr(k.current, Q) && (k.current = Q, lr.flushSync(() => {
5147
- p(Q);
5146
+ M.current && !nr(k.current, ee) && (k.current = ee, lr.flushSync(() => {
5147
+ p(ee);
5148
5148
  }));
5149
5149
  });
5150
5150
  }, [m, t, n, $, K]);
@@ -5180,17 +5180,17 @@ function fm(e) {
5180
5180
  };
5181
5181
  if (!O.floating)
5182
5182
  return D;
5183
- const T = ha(O.floating, d.x), Q = ha(O.floating, d.y);
5183
+ const T = ha(O.floating, d.x), ee = ha(O.floating, d.y);
5184
5184
  return i ? {
5185
5185
  ...D,
5186
- transform: "translate(" + T + "px, " + Q + "px)",
5186
+ transform: "translate(" + T + "px, " + ee + "px)",
5187
5187
  ...Ei(O.floating) >= 1.5 && {
5188
5188
  willChange: "transform"
5189
5189
  }
5190
5190
  } : {
5191
5191
  position: n,
5192
5192
  left: T,
5193
- top: Q
5193
+ top: ee
5194
5194
  };
5195
5195
  }, [n, i, O.floating, d.x, d.y]);
5196
5196
  return u.useMemo(() => ({
@@ -5351,7 +5351,7 @@ var Qo = "PopperContent", [Em, Nm] = Ti(Qo), Oi = u.forwardRef(
5351
5351
  Am({ arrowWidth: N, arrowHeight: k }),
5352
5352
  m && wm({ strategy: "referenceHidden", ...B })
5353
5353
  ]
5354
- }), [T, Q] = Di(O), q = we(g);
5354
+ }), [T, ee] = Di(O), q = we(g);
5355
5355
  ve(() => {
5356
5356
  G && (q == null || q());
5357
5357
  }, [G, q]);
@@ -5395,7 +5395,7 @@ var Qo = "PopperContent", [Em, Nm] = Ti(Qo), Oi = u.forwardRef(
5395
5395
  te.div,
5396
5396
  {
5397
5397
  "data-side": T,
5398
- "data-align": Q,
5398
+ "data-align": ee,
5399
5399
  ...h,
5400
5400
  ref: y,
5401
5401
  style: {
@@ -6289,10 +6289,10 @@ var De = "MenuContent", [Fg, is] = Nt(De), nc = u.forwardRef(
6289
6289
  ...h
6290
6290
  } = e, b = Rt(De, n), w = yn(De, n), x = Nr(n), y = Zi(n), C = _g(n), [R, _] = u.useState(null), N = u.useRef(null), k = ie(t, N, b.onContentChange), L = u.useRef(0), P = u.useRef(""), $ = u.useRef(0), K = u.useRef(null), B = u.useRef("right"), M = u.useRef(0), H = g ? Er : u.Fragment, O = g ? { as: Ug, allowPinchZoom: !0 } : void 0, G = (T) => {
6291
6291
  var z, W;
6292
- const Q = P.current + T, q = C().filter((oe) => !oe.disabled), ae = document.activeElement, F = (z = q.find((oe) => oe.ref.current === ae)) == null ? void 0 : z.textValue, j = q.map((oe) => oe.textValue), ce = Zg(j, Q, F), fe = (W = q.find((oe) => oe.textValue === ce)) == null ? void 0 : W.ref.current;
6292
+ const ee = P.current + T, q = C().filter((oe) => !oe.disabled), ae = document.activeElement, F = (z = q.find((oe) => oe.ref.current === ae)) == null ? void 0 : z.textValue, j = q.map((oe) => oe.textValue), ce = Zg(j, ee, F), fe = (W = q.find((oe) => oe.textValue === ce)) == null ? void 0 : W.ref.current;
6293
6293
  (function oe(V) {
6294
6294
  P.current = V, window.clearTimeout(L.current), V !== "" && (L.current = window.setTimeout(() => oe(""), 1e3));
6295
- })(Q), fe && setTimeout(() => fe.focus());
6295
+ })(ee), fe && setTimeout(() => fe.focus());
6296
6296
  };
6297
6297
  u.useEffect(() => () => window.clearTimeout(L.current), []), jo();
6298
6298
  const D = u.useCallback((T) => {
@@ -6312,8 +6312,8 @@ var De = "MenuContent", [Fg, is] = Nt(De), nc = u.forwardRef(
6312
6312
  ),
6313
6313
  onItemLeave: u.useCallback(
6314
6314
  (T) => {
6315
- var Q;
6316
- D(T) || ((Q = N.current) == null || Q.focus(), _(null));
6315
+ var ee;
6316
+ D(T) || ((ee = N.current) == null || ee.focus(), _(null));
6317
6317
  },
6318
6318
  [D]
6319
6319
  ),
@@ -6333,8 +6333,8 @@ var De = "MenuContent", [Fg, is] = Nt(De), nc = u.forwardRef(
6333
6333
  asChild: !0,
6334
6334
  trapped: o,
6335
6335
  onMountAutoFocus: U(s, (T) => {
6336
- var Q;
6337
- T.preventDefault(), (Q = N.current) == null || Q.focus({ preventScroll: !0 });
6336
+ var ee;
6337
+ T.preventDefault(), (ee = N.current) == null || ee.focus({ preventScroll: !0 });
6338
6338
  }),
6339
6339
  onUnmountAutoFocus: a,
6340
6340
  children: /* @__PURE__ */ c(
@@ -6388,8 +6388,8 @@ var De = "MenuContent", [Fg, is] = Nt(De), nc = u.forwardRef(
6388
6388
  onPointerMove: U(
6389
6389
  e.onPointerMove,
6390
6390
  cn((T) => {
6391
- const Q = T.target, q = M.current !== T.clientX;
6392
- if (T.currentTarget.contains(Q) && q) {
6391
+ const ee = T.target, q = M.current !== T.clientX;
6392
+ if (T.currentTarget.contains(ee) && q) {
6393
6393
  const ae = T.clientX > M.current ? "right" : "left";
6394
6394
  B.current = ae, M.current = T.clientX;
6395
6395
  }
@@ -7061,11 +7061,11 @@ function Vn({
7061
7061
  isLoadingHistory: k,
7062
7062
  loadOlderMessages: L,
7063
7063
  api: P
7064
- } = ri(), [$, K] = re(""), [B, M] = re(null), [H, O] = re(null), [G, D] = re([]), [T, Q] = re(!1), [q, ae] = re(null), [F, j] = re(null), [ce, fe] = re(!1), [z, W] = re([]), [oe, V] = re(null), Z = Te(null), J = Te(null), pe = Te(null), Se = Te(null), X = Te(null), Y = Te(!1), he = Te(!0), Fe = Te(0), Ee = Te(null), [xn, Gt] = re("desktop");
7064
+ } = ri(), [$, K] = re(""), [B, M] = re(null), [H, O] = re(null), [G, D] = re([]), [T, ee] = re(!1), [q, ae] = re(null), [F, j] = re(null), [ce, fe] = re(!1), [z, W] = re([]), [oe, V] = re(null), Z = Te(null), J = Te(null), pe = Te(null), Se = Te(null), X = Te(null), Y = Te(!1), he = Te(!0), Fe = Te(0), Ee = Te(null), [xn, Gt] = re("desktop");
7065
7065
  ge(() => {
7066
7066
  const I = () => {
7067
- const ee = window.innerWidth;
7068
- Gt(ee < 640 ? "phone" : ee < 1024 ? "tablet" : "desktop");
7067
+ const Q = window.innerWidth;
7068
+ Gt(Q < 640 ? "phone" : Q < 1024 ? "tablet" : "desktop");
7069
7069
  };
7070
7070
  return I(), window.addEventListener("resize", I), () => window.removeEventListener("resize", I);
7071
7071
  }, []), ge(() => {
@@ -7074,12 +7074,12 @@ function Vn({
7074
7074
  W([]), V(null), Ee.current = null;
7075
7075
  return;
7076
7076
  }
7077
- const ee = {
7077
+ const Q = {
7078
7078
  threadId: m,
7079
7079
  checkpointId: y ?? null
7080
7080
  }, le = Ee.current;
7081
- if (!(le && le.threadId === ee.threadId && le.checkpointId === ee.checkpointId))
7082
- return Ee.current = ee, C(m).then((ue) => {
7081
+ if (!(le && le.threadId === Q.threadId && le.checkpointId === Q.checkpointId))
7082
+ return Ee.current = Q, C(m).then((ue) => {
7083
7083
  if (I) return;
7084
7084
  const Be = ((ue == null ? void 0 : ue.checkpoints) ?? []).slice().sort((st, Rn) => new Date(Rn.createdAt).getTime() - new Date(st.createdAt).getTime());
7085
7085
  W(Be), V((st) => {
@@ -7098,7 +7098,7 @@ function Vn({
7098
7098
  if (!N || k) return;
7099
7099
  const I = X.current;
7100
7100
  if (!I) return;
7101
- const ee = I.scrollHeight, le = I.scrollTop;
7101
+ const Q = I.scrollHeight, le = I.scrollTop;
7102
7102
  Y.current = !0;
7103
7103
  try {
7104
7104
  await L();
@@ -7112,7 +7112,7 @@ function Vn({
7112
7112
  return;
7113
7113
  }
7114
7114
  const Be = ue.scrollHeight;
7115
- ue.scrollTop = le + (Be - ee);
7115
+ ue.scrollTop = le + (Be - Q);
7116
7116
  const st = Be - ue.scrollTop - ue.clientHeight;
7117
7117
  he.current = st <= 32, Y.current = !1;
7118
7118
  });
@@ -7121,12 +7121,12 @@ function Vn({
7121
7121
  ge(() => {
7122
7122
  const I = X.current;
7123
7123
  if (!I) return;
7124
- const ee = () => {
7124
+ const Q = () => {
7125
7125
  I.scrollTop <= 80 && ht();
7126
7126
  const Be = I.scrollHeight - I.scrollTop - I.clientHeight;
7127
7127
  he.current = Be <= 80;
7128
7128
  };
7129
- return I.addEventListener("scroll", ee), () => I.removeEventListener("scroll", ee);
7129
+ return I.addEventListener("scroll", Q), () => I.removeEventListener("scroll", Q);
7130
7130
  }, [ht]), ge(() => {
7131
7131
  v.length < Fe.current && (he.current = !0), Fe.current = v.length;
7132
7132
  }, [v.length]), ge(() => {
@@ -7143,33 +7143,36 @@ function Vn({
7143
7143
  return `Message too long (${I.length}/${_t} characters)`;
7144
7144
  try {
7145
7145
  return qp(I), null;
7146
- } catch (ee) {
7147
- return (ee == null ? void 0 : ee.message) || "Invalid message";
7146
+ } catch (Q) {
7147
+ return (Q == null ? void 0 : Q.message) || "Invalid message";
7148
7148
  }
7149
7149
  }, qt = (I) => {
7150
- const ee = I.content || [], le = ee.filter((ue) => ue.type === "text").map((ue) => ue.text).join("");
7150
+ const Q = I.content || [], le = Q.filter((ue) => ue.type === "text").map((ue) => ue.text).join("");
7151
7151
  if (le) return le;
7152
7152
  try {
7153
- return JSON.stringify(ee, null, 2);
7153
+ return JSON.stringify(Q, null, 2);
7154
7154
  } catch {
7155
- return String(ee);
7155
+ return String(Q);
7156
7156
  }
7157
7157
  }, Sn = async () => {
7158
7158
  const I = $.trim();
7159
- if (!I && G.length === 0) return;
7160
- const ee = Br(I);
7161
- if (ee) {
7162
- O(ee);
7163
- return;
7164
- }
7165
- try {
7166
- await w(I, { checkpointId: oe || y || void 0, payloadExtras: B ? { edit: !0, originalMessageId: B } : void 0, attachments: G }), f == null || f(I), K(""), O(null), D([]), M(null), J.current && (J.current.style.height = "auto");
7167
- } catch (le) {
7168
- const ue = (le == null ? void 0 : le.message) || "Failed to send message";
7169
- O(ue), p == null || p(ue);
7159
+ if (!(!I && G.length === 0)) {
7160
+ if (I) {
7161
+ const Q = Br(I);
7162
+ if (Q) {
7163
+ O(Q);
7164
+ return;
7165
+ }
7166
+ }
7167
+ try {
7168
+ await w(I, { checkpointId: oe || y || void 0, payloadExtras: B ? { edit: !0, originalMessageId: B } : void 0, attachments: G }), f == null || f(I), K(""), O(null), D([]), M(null), J.current && (J.current.style.height = "auto");
7169
+ } catch (Q) {
7170
+ const le = (Q == null ? void 0 : Q.message) || "Failed to send message";
7171
+ O(le), p == null || p(le);
7172
+ }
7170
7173
  }
7171
- }, Cn = (I, ee) => {
7172
- i && (M(I), K(ee), O(null), setTimeout(() => {
7174
+ }, Cn = (I, Q) => {
7175
+ i && (M(I), K(Q), O(null), setTimeout(() => {
7173
7176
  J.current && (J.current.focus(), J.current.style.height = "auto", J.current.style.height = J.current.scrollHeight + "px");
7174
7177
  }, 0));
7175
7178
  }, Xt = () => {
@@ -7177,26 +7180,26 @@ function Vn({
7177
7180
  }, Ur = (I) => {
7178
7181
  I.key === "Enter" && !I.shiftKey ? (I.preventDefault(), Sn()) : I.key === "Escape" && B && (I.preventDefault(), Xt());
7179
7182
  }, Hr = (I) => {
7180
- const ee = Array.from(I.target.files || []);
7181
- D((le) => [...le, ...ee]);
7182
- }, En = (I) => D((ee) => ee.filter((le, ue) => I !== ue)), se = async (I) => {
7183
- const ee = (I.target.files || [])[0];
7184
- if (ee) {
7185
- ae(null), j(null), Q(!0);
7183
+ const Q = Array.from(I.target.files || []);
7184
+ D((le) => [...le, ...Q]);
7185
+ }, En = (I) => D((Q) => Q.filter((le, ue) => I !== ue)), se = async (I) => {
7186
+ const Q = (I.target.files || [])[0];
7187
+ if (Q) {
7188
+ ae(null), j(null), ee(!0);
7186
7189
  try {
7187
- const le = await P.uploadExcel(ee), ue = le.sheets.map((st) => `${st.sheetName} -> ${st.tableName}`).join(", "), Be = ue ? `Uploaded ${ee.name} (${le.sheets.length} sheet${le.sheets.length === 1 ? "" : "s"}: ${ue})` : `Uploaded ${ee.name}`;
7188
- j(Be), d == null || d({ file: ee, response: le });
7190
+ const le = await P.uploadExcel(Q), ue = le.sheets.map((st) => `${st.sheetName} -> ${st.tableName}`).join(", "), Be = ue ? `Uploaded ${Q.name} (${le.sheets.length} sheet${le.sheets.length === 1 ? "" : "s"}: ${ue})` : `Uploaded ${Q.name}`;
7191
+ j(Be), d == null || d({ file: Q, response: le });
7189
7192
  } catch (le) {
7190
7193
  const ue = le instanceof Error ? le.message : "Failed to upload Excel file";
7191
7194
  console.error("Excel upload failed", le), ae(ue), p == null || p(ue);
7192
7195
  } finally {
7193
- Q(!1), I.target.value = "";
7196
+ ee(!1), I.target.value = "";
7194
7197
  }
7195
7198
  }
7196
7199
  }, ye = (I) => {
7197
7200
  if (!I) return "Unknown";
7198
- const ee = Date.parse(I);
7199
- return Number.isNaN(ee) ? I : new Date(ee).toLocaleString();
7201
+ const Q = Date.parse(I);
7202
+ return Number.isNaN(Q) ? I : new Date(Q).toLocaleString();
7200
7203
  }, Ne = async (I) => {
7201
7204
  if (m) {
7202
7205
  if (!I) {
@@ -7229,8 +7232,8 @@ function Vn({
7229
7232
  className: "border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",
7230
7233
  value: oe ?? "",
7231
7234
  onChange: (I) => {
7232
- const ee = I.target.value || null;
7233
- Ne(ee);
7235
+ const Q = I.target.value || null;
7236
+ Ne(Q);
7234
7237
  },
7235
7238
  children: [
7236
7239
  /* @__PURE__ */ c("option", { value: "", children: "Latest" }),
@@ -7251,11 +7254,11 @@ function Vn({
7251
7254
  children: [
7252
7255
  v.length === 0 ? /* @__PURE__ */ c("div", { className: "flex items-center justify-center py-8 text-muted-foreground", children: "No messages yet. Start a conversation!" }) : /* @__PURE__ */ E(Ae, { children: [
7253
7256
  (k || !N) && /* @__PURE__ */ c("div", { className: "flex justify-center py-2 text-xs text-muted-foreground", children: k ? /* @__PURE__ */ c(Rs, { className: "h-4 w-4 animate-spin" }) : "You've reached the beginning" }),
7254
- v.map((I, ee) => /* @__PURE__ */ c(
7257
+ v.map((I, Q) => /* @__PURE__ */ c(
7255
7258
  Mp,
7256
7259
  {
7257
7260
  message: I,
7258
- messageIndex: ee,
7261
+ messageIndex: Q,
7259
7262
  isStreamingMessage: g && h === I.id,
7260
7263
  streamingDebounceMs: o,
7261
7264
  isEditing: B === I.id,
@@ -7272,7 +7275,7 @@ function Vn({
7272
7275
  },
7273
7276
  onCancelEdit: Xt
7274
7277
  },
7275
- I.id || ee
7278
+ I.id || Q
7276
7279
  ))
7277
7280
  ] }),
7278
7281
  /* @__PURE__ */ c("div", { ref: Z })
@@ -7308,7 +7311,7 @@ function Vn({
7308
7311
  className: "hidden"
7309
7312
  }
7310
7313
  ),
7311
- G.length > 0 && /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-2", children: G.map((I, ee) => /* @__PURE__ */ E("div", { className: "flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100", children: [
7314
+ G.length > 0 && /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-2", children: G.map((I, Q) => /* @__PURE__ */ E("div", { className: "flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100", children: [
7312
7315
  /* @__PURE__ */ c(Ts, { size: 14 }),
7313
7316
  /* @__PURE__ */ c("span", { className: "truncate max-w-[150px]", children: I.name }),
7314
7317
  /* @__PURE__ */ c(
@@ -7316,13 +7319,13 @@ function Vn({
7316
7319
  {
7317
7320
  variant: "ghost",
7318
7321
  size: "sm",
7319
- onClick: () => En(ee),
7322
+ onClick: () => En(Q),
7320
7323
  className: "h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400",
7321
7324
  "aria-label": `Remove ${I.name}`,
7322
7325
  children: /* @__PURE__ */ c(en, { size: 12 })
7323
7326
  }
7324
7327
  )
7325
- ] }, ee)) })
7328
+ ] }, Q)) })
7326
7329
  ] }),
7327
7330
  a && /* @__PURE__ */ E(Ae, { children: [
7328
7331
  /* @__PURE__ */ c(
@@ -8048,7 +8051,7 @@ function Ro({
8048
8051
  }
8049
8052
  }, T = () => {
8050
8053
  L(null), $("");
8051
- }, Q = (F, j) => {
8054
+ }, ee = (F, j) => {
8052
8055
  F.key === "Enter" ? D(j) : F.key === "Escape" && T();
8053
8056
  }, q = (F) => {
8054
8057
  if (!F) return "";
@@ -8088,7 +8091,7 @@ function Ro({
8088
8091
  children: [
8089
8092
  /* @__PURE__ */ E("div", { className: "flex items-center justify-between", children: [
8090
8093
  /* @__PURE__ */ c("div", { className: "flex-1 min-w-0", children: k === F.threadId ? /* @__PURE__ */ E("div", { className: "flex items-center gap-2", onClick: (j) => j.stopPropagation(), children: [
8091
- /* @__PURE__ */ c(ln, { value: P, onChange: (j) => $(j.target.value), onKeyDown: (j) => Q(j, F.threadId), className: "h-6 text-sm", autoFocus: !0 }),
8094
+ /* @__PURE__ */ c(ln, { value: P, onChange: (j) => $(j.target.value), onKeyDown: (j) => ee(j, F.threadId), className: "h-6 text-sm", autoFocus: !0 }),
8092
8095
  /* @__PURE__ */ c(de, { variant: "ghost", size: "sm", onClick: () => D(F.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ c(Lo, { size: 12 }) }),
8093
8096
  /* @__PURE__ */ c(de, { variant: "ghost", size: "sm", onClick: T, className: "h-6 w-6 p-0", children: /* @__PURE__ */ c(en, { size: 12 }) })
8094
8097
  ] }) : /* @__PURE__ */ E(Ae, { children: [
@@ -9837,7 +9840,7 @@ var Ue = 10, [xu, pt] = Kt(Et), Ow = "SelectContentImpl", kw = Dt("SelectContent
9837
9840
  window.removeEventListener("blur", z), window.removeEventListener("resize", z);
9838
9841
  };
9839
9842
  }, [D]);
9840
- const [Q, q] = Bu((z) => {
9843
+ const [ee, q] = Bu((z) => {
9841
9844
  const W = K().filter((Z) => !Z.disabled), oe = W.find((Z) => Z.ref.current === document.activeElement), V = Uu(W, z, oe);
9842
9845
  V && setTimeout(() => V.ref.current.focus());
9843
9846
  }), ae = u.useCallback(
@@ -9879,7 +9882,7 @@ var Ue = 10, [xu, pt] = Kt(Et), Ow = "SelectContentImpl", kw = Dt("SelectContent
9879
9882
  selectedItemText: P,
9880
9883
  position: r,
9881
9884
  isPositioned: B,
9882
- searchRef: Q,
9885
+ searchRef: ee,
9883
9886
  children: /* @__PURE__ */ c(Er, { as: kw, allowPinchZoom: !0, children: /* @__PURE__ */ c(
9884
9887
  br,
9885
9888
  {
@@ -9965,7 +9968,7 @@ var Mw = "SelectItemAlignedPosition", Cu = u.forwardRef((e, t) => {
9965
9968
  ]);
9966
9969
  i.style.minWidth = Se + "px", i.style.right = he + "px";
9967
9970
  }
9968
- const $ = m(), K = window.innerHeight - Ue * 2, B = h.scrollHeight, M = window.getComputedStyle(f), H = parseInt(M.borderTopWidth, 10), O = parseInt(M.paddingTop, 10), G = parseInt(M.borderBottomWidth, 10), D = parseInt(M.paddingBottom, 10), T = H + O + B + D + G, Q = Math.min(b.offsetHeight * 5, T), q = window.getComputedStyle(h), ae = parseInt(q.paddingTop, 10), F = parseInt(q.paddingBottom, 10), j = N.top + N.height / 2 - Ue, ce = K - j, fe = b.offsetHeight / 2, z = b.offsetTop + fe, W = H + O + z, oe = T - W;
9971
+ const $ = m(), K = window.innerHeight - Ue * 2, B = h.scrollHeight, M = window.getComputedStyle(f), H = parseInt(M.borderTopWidth, 10), O = parseInt(M.paddingTop, 10), G = parseInt(M.borderBottomWidth, 10), D = parseInt(M.paddingBottom, 10), T = H + O + B + D + G, ee = Math.min(b.offsetHeight * 5, T), q = window.getComputedStyle(h), ae = parseInt(q.paddingTop, 10), F = parseInt(q.paddingBottom, 10), j = N.top + N.height / 2 - Ue, ce = K - j, fe = b.offsetHeight / 2, z = b.offsetTop + fe, W = H + O + z, oe = T - W;
9969
9972
  if (W <= j) {
9970
9973
  const Z = $.length > 0 && b === $[$.length - 1].ref.current;
9971
9974
  i.style.bottom = "0px";
@@ -9985,7 +9988,7 @@ var Mw = "SelectItemAlignedPosition", Cu = u.forwardRef((e, t) => {
9985
9988
  ) + oe;
9986
9989
  i.style.height = pe + "px", h.scrollTop = W - j + h.offsetTop;
9987
9990
  }
9988
- i.style.margin = `${Ue}px 0`, i.style.minHeight = Q + "px", i.style.maxHeight = K + "px", r == null || r(), requestAnimationFrame(() => v.current = !0);
9991
+ i.style.margin = `${Ue}px 0`, i.style.minHeight = ee + "px", i.style.maxHeight = K + "px", r == null || r(), requestAnimationFrame(() => v.current = !0);
9989
9992
  }
9990
9993
  }, [
9991
9994
  m,