teodor-new-chat-ui 4.3.247 → 4.3.248

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
@@ -2,7 +2,7 @@ var om = Object.defineProperty;
2
2
  var sm = (e, t, n) => t in e ? om(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var cl = (e, t, n) => sm(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import * as v from "react";
5
- import z, { createContext as co, useContext as xs, useRef as Qe, useCallback as Ce, useReducer as im, useEffect as Et, useMemo as lt, useState as ge, useLayoutEffect as am, createElement as Do, useImperativeHandle as lm } from "react";
5
+ import z, { createContext as co, useContext as xs, useRef as Qe, useCallback as Ce, useReducer as im, useEffect as It, useMemo as lt, useState as ge, useLayoutEffect as am, createElement as Do, useImperativeHandle as lm } from "react";
6
6
  import { Square as cm, Send as um, ChevronRight as Xc, Check as ca, Circle as dm, X as vr, ExternalLink as fm, Download as pm, Image as hm, FileText as ul, Loader as ua, Bot as si, Wrench as mm, User as gm, Paperclip as ji, ChevronUp as da, ChevronDown as ys, ChevronLeft as xm, Copy as dl, Edit as fl, RotateCcw as _i, Info as ym, Loader2 as zr, Edit3 as Jc, Plus as vm, FileSpreadsheet as wm, MessageSquarePlus as bm, MessageSquare as Sm, Calendar as Cm, Trash2 as Tm, Settings as km, Server as Rm, EyeOff as Em, Eye as Im, Layout as Nm, MessageCircle as Am, Save as jm } from "lucide-react";
7
7
  import { Slot as _m, createSlot as Tr } from "@radix-ui/react-slot";
8
8
  import { cva as vs } from "class-variance-authority";
@@ -469,13 +469,13 @@ function Dm() {
469
469
  return Ze(R, $e, Ot, Ye, we, mt.current, Ue);
470
470
  }
471
471
  }
472
- var Pt = g.ReactCurrentOwner, jt = g.ReactDebugCurrentFrame;
472
+ var At = g.ReactCurrentOwner, Tt = g.ReactDebugCurrentFrame;
473
473
  function V(R) {
474
474
  if (R) {
475
475
  var K = R._owner, ie = de(R.type, R._source, K ? K.type : null);
476
- jt.setExtraStackFrame(ie);
476
+ Tt.setExtraStackFrame(ie);
477
477
  } else
478
- jt.setExtraStackFrame(null);
478
+ Tt.setExtraStackFrame(null);
479
479
  }
480
480
  var ve;
481
481
  ve = !1;
@@ -484,8 +484,8 @@ function Dm() {
484
484
  }
485
485
  function ht() {
486
486
  {
487
- if (Pt.current) {
488
- var R = F(Pt.current.type);
487
+ if (At.current) {
488
+ var R = F(At.current.type);
489
489
  if (R)
490
490
  return `
491
491
 
@@ -497,7 +497,7 @@ Check the render method of \`` + R + "`.";
497
497
  function gt(R) {
498
498
  return "";
499
499
  }
500
- var Tt = {};
500
+ var kt = {};
501
501
  function _e(R) {
502
502
  {
503
503
  var K = ht();
@@ -516,11 +516,11 @@ Check the top-level render call using <` + ie + ">.");
516
516
  return;
517
517
  R._store.validated = !0;
518
518
  var ie = _e(K);
519
- if (Tt[ie])
519
+ if (kt[ie])
520
520
  return;
521
- Tt[ie] = !0;
521
+ kt[ie] = !0;
522
522
  var we = "";
523
- R && R._owner && R._owner !== Pt.current && (we = " It was passed a child from " + F(R._owner.type) + "."), V(R), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', ie, we), V(null);
523
+ R && R._owner && R._owner !== At.current && (we = " It was passed a child from " + F(R._owner.type) + "."), V(R), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', ie, we), V(null);
524
524
  }
525
525
  }
526
526
  function ut(R, K) {
@@ -542,7 +542,7 @@ Check the top-level render call using <` + ie + ">.");
542
542
  }
543
543
  }
544
544
  }
545
- function kt(R) {
545
+ function Rt(R) {
546
546
  {
547
547
  var K = R.type;
548
548
  if (K == null || typeof K == "string")
@@ -621,7 +621,7 @@ React keys must be passed directly to JSX without using spread:
621
621
  <%s key={someKey} {...props} />`, Dr, Nn, G, Nn), Jn[Nn + Dr] = !0;
622
622
  }
623
623
  }
624
- return R === r ? Dn(vt) : kt(vt), vt;
624
+ return R === r ? Dn(vt) : Rt(vt), vt;
625
625
  }
626
626
  }
627
627
  function ti(R, K, ie) {
@@ -2349,26 +2349,26 @@ function Su(e) {
2349
2349
  return Su(or(e, o));
2350
2350
  }, n;
2351
2351
  }
2352
- const It = Su(ho);
2353
- It.Axios = nr;
2354
- It.CanceledError = Ar;
2355
- It.CancelToken = lx;
2356
- It.isCancel = hu;
2357
- It.VERSION = wu;
2358
- It.toFormData = Ts;
2359
- It.AxiosError = Pe;
2360
- It.Cancel = It.CanceledError;
2361
- It.all = function(t) {
2352
+ const Nt = Su(ho);
2353
+ Nt.Axios = nr;
2354
+ Nt.CanceledError = Ar;
2355
+ Nt.CancelToken = lx;
2356
+ Nt.isCancel = hu;
2357
+ Nt.VERSION = wu;
2358
+ Nt.toFormData = Ts;
2359
+ Nt.AxiosError = Pe;
2360
+ Nt.Cancel = Nt.CanceledError;
2361
+ Nt.all = function(t) {
2362
2362
  return Promise.all(t);
2363
2363
  };
2364
- It.spread = cx;
2365
- It.isAxiosError = ux;
2366
- It.mergeConfig = or;
2367
- It.AxiosHeaders = Yt;
2368
- It.formToJSON = (e) => pu(_.isHTMLForm(e) ? new FormData(e) : e);
2369
- It.getAdapter = vu.getAdapter;
2370
- It.HttpStatusCode = Fi;
2371
- It.default = It;
2364
+ Nt.spread = cx;
2365
+ Nt.isAxiosError = ux;
2366
+ Nt.mergeConfig = or;
2367
+ Nt.AxiosHeaders = Yt;
2368
+ Nt.formToJSON = (e) => pu(_.isHTMLForm(e) ? new FormData(e) : e);
2369
+ Nt.getAdapter = vu.getAdapter;
2370
+ Nt.HttpStatusCode = Fi;
2371
+ Nt.default = Nt;
2372
2372
  const {
2373
2373
  Axios: QT,
2374
2374
  AxiosError: ek,
@@ -2386,7 +2386,7 @@ const {
2386
2386
  formToJSON: fk,
2387
2387
  getAdapter: pk,
2388
2388
  mergeConfig: hk
2389
- } = It, jl = typeof window < "u" ? window.__API_BASE_URL__ : void 0, _l = jl ? _n(jl) : void 0;
2389
+ } = Nt, jl = typeof window < "u" ? window.__API_BASE_URL__ : void 0, _l = jl ? _n(jl) : void 0;
2390
2390
  function _n(e) {
2391
2391
  const n = (e != null && e.trim() ? e.trim() : "/api/chat").replace(/\/+$/, "");
2392
2392
  return n ? n.endsWith("/chat") ? n : `${n}/chat` : "/api/chat";
@@ -2402,7 +2402,7 @@ function zi(e) {
2402
2402
  function fx(e) {
2403
2403
  return $i.add(e), () => $i.delete(e);
2404
2404
  }
2405
- const px = 3e4, hx = 9e4, ln = It.create({
2405
+ const px = 3e4, hx = 9e4, ln = Nt.create({
2406
2406
  // Only set baseURL when configured — do NOT fall back to localhost. Falling back causes
2407
2407
  // noisy network requests to the frontend Dev server when the backend isn't configured.
2408
2408
  ..._l ? { baseURL: _l } : {},
@@ -2618,7 +2618,7 @@ function Ur(e) {
2618
2618
  }
2619
2619
  function ku(e, t) {
2620
2620
  if (!ma(e)) return null;
2621
- const n = e.values ?? { messages: [] }, r = Array.isArray(n == null ? void 0 : n.messages) ? n.messages : [], { messages: o, ...s } = n, i = Object.keys(s).length ? s : null, a = e.tasks, l = Array.isArray(a) ? a.filter((E) => !!E && typeof E == "object").map((E) => ({ ...E })) : a === null ? null : void 0, c = r.map((E, I) => jx(E, I)).filter((E) => !!E), d = qt(e.config), f = qt(d == null ? void 0 : d.configurable), p = Nt(f, ["checkpoint_id", "checkpointId"]), h = Nt(f, ["checkpoint_ns", "checkpointNs"]), m = qt(e == null ? void 0 : e.parentConfig), x = qt(m == null ? void 0 : m.configurable), y = Nt(x, ["checkpoint_id", "checkpointId"]) ?? null, g = Nt(x, ["checkpoint_ns", "checkpointNs"]) ?? null, w = e == null ? void 0 : e.createdAt, b = typeof w == "string" && w.trim() ? w : new Date(Date.now() - t).toISOString(), T = c[c.length - 1] ?? null, C = qt(e == null ? void 0 : e.metadata), S = Nt(C, ["branch_label", "branchLabel"]), k = Nt(x, ["checkpoint_id", "checkpointId"]), N = Array.isArray(e.next) ? [...e.next] : (e == null ? void 0 : e.next) === null ? null : void 0;
2621
+ const n = e.values ?? { messages: [] }, r = Array.isArray(n == null ? void 0 : n.messages) ? n.messages : [], { messages: o, ...s } = n, i = Object.keys(s).length ? s : null, a = e.tasks, l = Array.isArray(a) ? a.filter((E) => !!E && typeof E == "object").map((E) => ({ ...E })) : a === null ? null : void 0, c = r.map((E, I) => jx(E, I)).filter((E) => !!E), d = qt(e.config), f = qt(d == null ? void 0 : d.configurable), p = jt(f, ["checkpoint_id", "checkpointId"]), h = jt(f, ["checkpoint_ns", "checkpointNs"]), m = qt(e == null ? void 0 : e.parentConfig), x = qt(m == null ? void 0 : m.configurable), y = jt(x, ["checkpoint_id", "checkpointId"]) ?? null, g = jt(x, ["checkpoint_ns", "checkpointNs"]) ?? null, w = e == null ? void 0 : e.createdAt, b = typeof w == "string" && w.trim() ? w : new Date(Date.now() - t).toISOString(), T = c[c.length - 1] ?? null, C = qt(e == null ? void 0 : e.metadata), S = jt(C, ["branch_label", "branchLabel"]), k = jt(x, ["checkpoint_id", "checkpointId"]), N = Array.isArray(e.next) ? [...e.next] : (e == null ? void 0 : e.next) === null ? null : void 0;
2622
2622
  return {
2623
2623
  messages: c,
2624
2624
  checkpointId: p ?? null,
@@ -2734,7 +2734,7 @@ function Ax(e, t) {
2734
2734
  }
2735
2735
  const n = qt(e);
2736
2736
  if (!n) return null;
2737
- const r = Nt(n, ["id", "task_id", "taskId"]) ?? t, o = Nt(n, ["name"]) ?? "task", s = Array.isArray(n.interrupts) ? n.interrupts : void 0, i = Object.prototype.hasOwnProperty.call(n, "state") ? n.state : void 0;
2737
+ const r = jt(n, ["id", "task_id", "taskId"]) ?? t, o = jt(n, ["name"]) ?? "task", s = Array.isArray(n.interrupts) ? n.interrupts : void 0, i = Object.prototype.hasOwnProperty.call(n, "state") ? n.state : void 0;
2738
2738
  return { id: r, name: o, interrupts: s, state: i };
2739
2739
  }
2740
2740
  function Wr(e, t, n = 0, r = /* @__PURE__ */ new Set()) {
@@ -2787,7 +2787,7 @@ function Ru(e, t) {
2787
2787
  if (!e)
2788
2788
  return null;
2789
2789
  if (typeof e == "object" && !Array.isArray(e)) {
2790
- const n = e, r = Nt(n, ["type", "event", "kind"]), o = Nt(n, ["id", "interrupt_id", "interruptId", "value_id"]) ?? (r && r.toLowerCase().includes("interrupt") ? t : void 0);
2790
+ const n = e, r = jt(n, ["type", "event", "kind"]), o = jt(n, ["id", "interrupt_id", "interruptId", "value_id"]) ?? (r && r.toLowerCase().includes("interrupt") ? t : void 0);
2791
2791
  if (!(Object.prototype.hasOwnProperty.call(n, "value") || Object.prototype.hasOwnProperty.call(n, "data") || Object.prototype.hasOwnProperty.call(n, "payload")) && !(r && r.toLowerCase().includes("interrupt")))
2792
2792
  return null;
2793
2793
  const i = Object.prototype.hasOwnProperty.call(n, "value") ? n.value : Object.prototype.hasOwnProperty.call(n, "data") ? n.data : Object.prototype.hasOwnProperty.call(n, "payload") ? n.payload : n, a = o && o.trim() ? o : t;
@@ -2819,7 +2819,7 @@ function jx(e, t) {
2819
2819
  ).toLowerCase(), i = bx[s];
2820
2820
  if (!i)
2821
2821
  return null;
2822
- const a = o.id ?? o.message_id ?? o.run_id ?? null, l = typeof a == "string" && a.trim() ? a : `history-${i}-${t}`, c = qt(o.additional_kwargs) ?? qt(o.additionalKwargs), d = qt(o.response_metadata) ?? qt(o.responseMetadata), f = Nt(c, ["createdAt", "created_at"]) ?? Nt(o, ["created_at", "createdAt"]), p = Nt(c, ["checkpointId", "checkpoint_id"]), h = Nt(c, ["checkpointNs", "checkpoint_ns"]), m = _x(o.content), x = {
2822
+ const a = o.id ?? o.message_id ?? o.run_id ?? null, l = typeof a == "string" && a.trim() ? a : `history-${i}-${t}`, c = qt(o.additional_kwargs) ?? qt(o.additionalKwargs), d = qt(o.response_metadata) ?? qt(o.responseMetadata), f = jt(c, ["createdAt", "created_at"]) ?? jt(o, ["created_at", "createdAt"]), p = jt(c, ["checkpointId", "checkpoint_id"]), h = jt(c, ["checkpointNs", "checkpoint_ns"]), m = _x(o.content), x = {
2823
2823
  id: l,
2824
2824
  role: i,
2825
2825
  content: m
@@ -2863,13 +2863,13 @@ function Ml(e) {
2863
2863
  return o.trim() ? { type: "text", text: o } : null;
2864
2864
  }
2865
2865
  if (n === "image" || n === "image_url") {
2866
- const o = Nt(t, ["url", "src"]);
2866
+ const o = jt(t, ["url", "src"]);
2867
2867
  if (!o) return null;
2868
2868
  const s = { type: "image_url", url: o };
2869
2869
  return typeof t.mimeType == "string" && (s.mimeType = t.mimeType), typeof t.alt == "string" && (s.alt = t.alt), s;
2870
2870
  }
2871
2871
  if (n === "file") {
2872
- const o = Nt(t, ["url"]);
2872
+ const o = jt(t, ["url"]);
2873
2873
  if (!o) return null;
2874
2874
  const s = { type: "file", url: o };
2875
2875
  return typeof t.mimeType == "string" && (s.mimeType = t.mimeType), typeof t.name == "string" && (s.name = t.name), typeof t.size == "number" && (s.size = t.size), typeof t.sourceType == "string" && (s.sourceType = t.sourceType), s;
@@ -2887,7 +2887,7 @@ function Ml(e) {
2887
2887
  ...t
2888
2888
  };
2889
2889
  if (n === "tool") {
2890
- const o = Nt(t, ["text", "content"]);
2890
+ const o = jt(t, ["text", "content"]);
2891
2891
  if (o)
2892
2892
  return { type: "text", text: o };
2893
2893
  }
@@ -2896,7 +2896,7 @@ function Ml(e) {
2896
2896
  }
2897
2897
  function Eu(e, t) {
2898
2898
  var s;
2899
- const n = Nt(e, ["id", "call_id"]) ?? t, r = Nt(e, ["name"]) ?? Nt(qt(e.function), ["name"]);
2899
+ const n = jt(e, ["id", "call_id"]) ?? t, r = jt(e, ["name"]) ?? jt(qt(e.function), ["name"]);
2900
2900
  if (!n || !r) return null;
2901
2901
  const o = Mx(e.args ?? e.arguments ?? ((s = qt(e.function)) == null ? void 0 : s.arguments));
2902
2902
  return { type: "tool_call", id: n, name: r, args: o };
@@ -2929,7 +2929,7 @@ function qt(e) {
2929
2929
  if (!(!e || typeof e != "object" || Array.isArray(e)))
2930
2930
  return { ...e };
2931
2931
  }
2932
- function Nt(e, t) {
2932
+ function jt(e, t) {
2933
2933
  if (e)
2934
2934
  for (const n of t) {
2935
2935
  const r = e[n];
@@ -3061,7 +3061,7 @@ function Bx(e = []) {
3061
3061
  }, [i]), l = Ce((d) => {
3062
3062
  r.current.push(d), a();
3063
3063
  }, [a]);
3064
- Et(() => () => {
3064
+ It(() => () => {
3065
3065
  o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), s.current !== null && clearTimeout(s.current), r.current = [];
3066
3066
  }, []);
3067
3067
  const c = lt(() => ({
@@ -3434,14 +3434,14 @@ function Kx(e = {}) {
3434
3434
  if (r)
3435
3435
  We = { Authorization: `Bearer ${r}` };
3436
3436
  else if (typeof window < "u") {
3437
- const Fe = window.__AUTH_TOKEN__, Pt = ((pe = window.localStorage) == null ? void 0 : pe.getItem("authToken")) || null;
3438
- let jt = null;
3437
+ const Fe = window.__AUTH_TOKEN__, At = ((pe = window.localStorage) == null ? void 0 : pe.getItem("authToken")) || null;
3438
+ let Tt = null;
3439
3439
  try {
3440
3440
  const ve = (Re = window.localStorage) == null ? void 0 : Re.getItem("chat-settings");
3441
- ve && (jt = ((Ee = JSON.parse(ve)) == null ? void 0 : Ee.apiKey) || null);
3441
+ ve && (Tt = ((Ee = JSON.parse(ve)) == null ? void 0 : Ee.apiKey) || null);
3442
3442
  } catch {
3443
3443
  }
3444
- const V = Fe || Pt || jt || null;
3444
+ const V = Fe || At || Tt || null;
3445
3445
  V && (We = { Authorization: `Bearer ${V}` });
3446
3446
  }
3447
3447
  } catch {
@@ -3506,11 +3506,11 @@ function Kx(e = {}) {
3506
3506
  }
3507
3507
  }, 5e3), tt = 1024 * 1024;
3508
3508
  try {
3509
- const Ze = Je.headers.get("X-Thread-Id") || Je.headers.get("x-thread-id"), Fe = Je.headers.get("X-Thread-Created") || Je.headers.get("x-thread-created"), Pt = Ze ?? null, jt = String(Fe ?? "").toLowerCase() === "true";
3509
+ const Ze = Je.headers.get("X-Thread-Id") || Je.headers.get("x-thread-id"), Fe = Je.headers.get("X-Thread-Created") || Je.headers.get("x-thread-created"), At = Ze ?? null, Tt = String(Fe ?? "").toLowerCase() === "true";
3510
3510
  for (S.current && !S.current.threadId && (S.current = {
3511
3511
  ...S.current,
3512
- threadId: Pt
3513
- }), (q = A == null ? void 0 : A.onOpen) == null || q.call(A, { threadId: Pt, created: jt }); ; ) {
3512
+ threadId: At
3513
+ }), (q = A == null ? void 0 : A.onOpen) == null || q.call(A, { threadId: At, created: Tt }); ; ) {
3514
3514
  const { value: V, done: ve } = await ot.read();
3515
3515
  if (ve) break;
3516
3516
  mt += St.decode(V, { stream: !0 }), mt.length > tt && (mt = "", console.warn("Stream buffer reset: exceeded 1MB"));
@@ -3522,14 +3522,14 @@ function Kx(e = {}) {
3522
3522
  mt = mt.slice(xe + 2);
3523
3523
  const gt = Gx(ht);
3524
3524
  if (!gt) continue;
3525
- let Tt;
3525
+ let kt;
3526
3526
  try {
3527
- Tt = JSON.parse(gt);
3527
+ kt = JSON.parse(gt);
3528
3528
  } catch {
3529
3529
  console.debug("[use-chat] malformed SSE:", gt.slice(0, 200));
3530
3530
  continue;
3531
3531
  }
3532
- const _e = qx(Tt) ? Tt.data : Tt;
3532
+ const _e = qx(kt) ? kt.data : kt;
3533
3533
  He = Date.now();
3534
3534
  const Vt = _e.seq;
3535
3535
  if (Vt !== void 0) {
@@ -3545,9 +3545,9 @@ function Kx(e = {}) {
3545
3545
  preview: (() => {
3546
3546
  var ut;
3547
3547
  try {
3548
- return _e.type === "message_delta" ? { deltaTypes: (ut = _e.delta) == null ? void 0 : ut.map((kt) => kt.type), textLen: (_e.delta || []).filter((kt) => kt.type === "text").map((kt) => String(kt.text || "").length) } : _e.content || _e.delta ? { hasContent: !0 } : {};
3549
- } catch (kt) {
3550
- return { err: String(kt) };
3548
+ return _e.type === "message_delta" ? { deltaTypes: (ut = _e.delta) == null ? void 0 : ut.map((Rt) => Rt.type), textLen: (_e.delta || []).filter((Rt) => Rt.type === "text").map((Rt) => String(Rt.text || "").length) } : _e.content || _e.delta ? { hasContent: !0 } : {};
3549
+ } catch (Rt) {
3550
+ return { err: String(Rt) };
3551
3551
  }
3552
3552
  })()
3553
3553
  }), _e.type === "checkpoint")
@@ -3555,8 +3555,8 @@ function Kx(e = {}) {
3555
3555
  else if (_e.type === "state_history") {
3556
3556
  E.current = _e;
3557
3557
  try {
3558
- const kt = Ur(_e).latest;
3559
- kt && (k.current = kt.checkpointId ?? null, N.current = kt.checkpointNs ?? null, m(kt.checkpointId ?? null));
3558
+ const Rt = Ur(_e).latest;
3559
+ Rt && (k.current = Rt.checkpointId ?? null, N.current = Rt.checkpointNs ?? null, m(Rt.checkpointId ?? null));
3560
3560
  } catch (ut) {
3561
3561
  console.warn("[use-chat] Failed to hydrate state_history payload", ut);
3562
3562
  }
@@ -3569,7 +3569,7 @@ function Kx(e = {}) {
3569
3569
  if (_e.type === "token" && e.autoAppendAssistant !== !1)
3570
3570
  ct.push(_e.content), Ae();
3571
3571
  else if (_e.type === "message_delta") {
3572
- const ut = _e.delta.filter((kt) => kt.type === "text").map((kt) => kt.text).join("");
3572
+ const ut = _e.delta.filter((Rt) => Rt.type === "text").map((Rt) => Rt.text).join("");
3573
3573
  ut && e.autoAppendAssistant !== !1 && (ct.push(ut), Ae());
3574
3574
  } else if (_e.type === "heartbeat") {
3575
3575
  console.debug("[use-chat] heartbeat received");
@@ -3638,7 +3638,7 @@ function Kx(e = {}) {
3638
3638
  },
3639
3639
  [t, n, r, e.autoAppendAssistant]
3640
3640
  );
3641
- return Et(() => () => {
3641
+ return It(() => () => {
3642
3642
  var j;
3643
3643
  T.current = !1, (j = b.current) == null || j.abort();
3644
3644
  }, []), {
@@ -3876,7 +3876,7 @@ function Xx({
3876
3876
  checkpointMetadataCache: l
3877
3877
  }) {
3878
3878
  const { api: c, baseUrl: d } = Tu(), f = lt(() => _n(d), [d]), [p, h] = ge([]), [m, x] = ge(t), [y, g] = ge(!1), [w, b] = ge(null), [T, C] = ge(!1), [S, k] = ge(null), { state: N, seed: E, prepend: I, pushUser: O, onEvent: L } = Bx(), [F, j] = ge(!1), [$, A] = ge(!1), [B, D] = ge(null), [M, Z] = ge([]), [J, pe] = ge(!1), Re = l ?? Lx(), { setCacheForThread: Ee } = Re, W = Qe(m), ee = Qe(null), q = Qe(null);
3879
- Et(() => {
3879
+ It(() => {
3880
3880
  W.current = m;
3881
3881
  }, [m]);
3882
3882
  const P = Qe(), { startStream: H, stop: te, isStreaming: se, error: re, setAuthToken: De } = Yx({
@@ -3964,7 +3964,7 @@ function Xx({
3964
3964
  },
3965
3965
  [c, E, s, ze]
3966
3966
  );
3967
- Et(() => {
3967
+ It(() => {
3968
3968
  P.current = Be;
3969
3969
  }, [Be]);
3970
3970
  const We = Ce(
@@ -4049,9 +4049,9 @@ function Xx({
4049
4049
  },
4050
4050
  [N.lastCheckpointId, N.lastCheckpointNs, H]
4051
4051
  );
4052
- Et(() => {
4052
+ It(() => {
4053
4053
  Y();
4054
- }, [Y]), Et(() => {
4054
+ }, [Y]), It(() => {
4055
4055
  var le, ne;
4056
4056
  if (!(!o || !m || T)) {
4057
4057
  if (q.current === m) {
@@ -4060,7 +4060,7 @@ function Xx({
4060
4060
  }
4061
4061
  ee.current !== m && (ee.current = m, n ? (console.log("[ChatSessionProvider] Loading thread with checkpoint:", n), (le = P.current) == null || le.call(P, m, n)) : (console.log("[ChatSessionProvider] Loading thread with latest checkpoint"), (ne = P.current) == null || ne.call(P, m)));
4062
4062
  }
4063
- }, [o, m, T, n, r]), Et(() => {
4063
+ }, [o, m, T, n, r]), It(() => {
4064
4064
  a == null || a(m);
4065
4065
  }, [m, a]);
4066
4066
  const St = Ce(
@@ -4068,7 +4068,13 @@ function Xx({
4068
4068
  let Ae = W.current;
4069
4069
  const He = (le == null ? void 0 : le.text) ?? "";
4070
4070
  if (!Ae && !He) return;
4071
- !Ae && He && (Ae = `thread-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, q.current = Ae, x(Ae));
4071
+ if (!Ae && He) {
4072
+ const At = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), Tt = Array.from(
4073
+ { length: 4 },
4074
+ () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")
4075
+ ).join("").slice(0, 16);
4076
+ Ae = `${At}${Tt}`, q.current = Ae, x(Ae);
4077
+ }
4072
4078
  const { contentParts: Oe } = await wx(
4073
4079
  c,
4074
4080
  (le == null ? void 0 : le.attachments) ?? []
@@ -8119,7 +8125,7 @@ function Me(e, t) {
8119
8125
  function $a(e) {
8120
8126
  e(Pr);
8121
8127
  }
8122
- function Rt(e) {
8128
+ function Et(e) {
8123
8129
  return e(vf);
8124
8130
  }
8125
8131
  function he(e, t) {
@@ -8286,7 +8292,7 @@ function x0(e) {
8286
8292
  };
8287
8293
  return n(e);
8288
8294
  }
8289
- function At(...e) {
8295
+ function _t(...e) {
8290
8296
  const t = Ve(), n = new Array(e.length);
8291
8297
  let r = 0;
8292
8298
  const o = Math.pow(2, e.length) - 1;
@@ -8334,7 +8340,7 @@ const y0 = {
8334
8340
  return {
8335
8341
  log: X((t, n, r = 1) => {
8336
8342
  var o;
8337
- const s = (o = v0().VIRTUOSO_LOG_LEVEL) != null ? o : Rt(e);
8343
+ const s = (o = v0().VIRTUOSO_LOG_LEVEL) != null ? o : Et(e);
8338
8344
  r >= s && console[y0[r]](
8339
8345
  "%creact-virtuoso: %c%s %o",
8340
8346
  "color: #0253b3; font-weight: bold",
@@ -8524,7 +8530,7 @@ function gn(e, t, n = "k") {
8524
8530
  return gn(e.l, t, n);
8525
8531
  }
8526
8532
  function Zt(e, t, n) {
8527
- return ft(e) ? Rf(t, n, 1) : t === e.k ? _t(e, { k: t, v: n }) : t < e.k ? xc(_t(e, { l: Zt(e.l, t, n) })) : xc(_t(e, { r: Zt(e.r, t, n) }));
8533
+ return ft(e) ? Rf(t, n, 1) : t === e.k ? Pt(e, { k: t, v: n }) : t < e.k ? xc(Pt(e, { l: Zt(e.l, t, n) })) : xc(Pt(e, { r: Zt(e.r, t, n) }));
8528
8534
  }
8529
8535
  function Sr() {
8530
8536
  return no;
@@ -8545,9 +8551,9 @@ function Xi(e, t) {
8545
8551
  return r;
8546
8552
  {
8547
8553
  const [s, i] = kf(r);
8548
- return Vo(_t(e, { k: s, l: Tf(r), v: i }));
8554
+ return Vo(Pt(e, { k: s, l: Tf(r), v: i }));
8549
8555
  }
8550
- } else return t < n ? Vo(_t(e, { l: Xi(r, t) })) : Vo(_t(e, { r: Xi(o, t) }));
8556
+ } else return t < n ? Vo(Pt(e, { l: Xi(r, t) })) : Vo(Pt(e, { r: Xi(o, t) }));
8551
8557
  }
8552
8558
  function tr(e) {
8553
8559
  return ft(e) ? [] : [...tr(e.l), { k: e.k, v: e.v }, ...tr(e.r)];
@@ -8565,12 +8571,12 @@ function Vo(e) {
8565
8571
  return e;
8566
8572
  if (n > r.lvl + 1) {
8567
8573
  if (Ci(t))
8568
- return Ef(_t(e, { lvl: n - 1 }));
8574
+ return Ef(Pt(e, { lvl: n - 1 }));
8569
8575
  if (!ft(t) && !ft(t.r))
8570
- return _t(t.r, {
8571
- l: _t(t, { r: t.r.l }),
8576
+ return Pt(t.r, {
8577
+ l: Pt(t, { r: t.r.l }),
8572
8578
  lvl: n,
8573
- r: _t(e, {
8579
+ r: Pt(e, {
8574
8580
  l: t.r.r,
8575
8581
  lvl: n - 1
8576
8582
  })
@@ -8578,22 +8584,22 @@ function Vo(e) {
8578
8584
  throw new Error("Unexpected empty nodes");
8579
8585
  } else {
8580
8586
  if (Ci(e))
8581
- return Zi(_t(e, { lvl: n - 1 }));
8587
+ return Zi(Pt(e, { lvl: n - 1 }));
8582
8588
  if (!ft(r) && !ft(r.l)) {
8583
8589
  const o = r.l, s = Ci(o) ? r.lvl - 1 : r.lvl;
8584
- return _t(o, {
8585
- l: _t(e, {
8590
+ return Pt(o, {
8591
+ l: Pt(e, {
8586
8592
  lvl: n - 1,
8587
8593
  r: o.l
8588
8594
  }),
8589
8595
  lvl: o.lvl + 1,
8590
- r: Zi(_t(r, { l: o.r, lvl: s }))
8596
+ r: Zi(Pt(r, { l: o.r, lvl: s }))
8591
8597
  });
8592
8598
  } else
8593
8599
  throw new Error("Unexpected empty nodes");
8594
8600
  }
8595
8601
  }
8596
- function _t(e, t) {
8602
+ function Pt(e, t) {
8597
8603
  return Rf(
8598
8604
  t.k !== void 0 ? t.k : e.k,
8599
8605
  t.v !== void 0 ? t.v : e.v,
@@ -8603,7 +8609,7 @@ function _t(e, t) {
8603
8609
  );
8604
8610
  }
8605
8611
  function Tf(e) {
8606
- return ft(e.r) ? e.l : Vo(_t(e, { r: Tf(e.r) }));
8612
+ return ft(e.r) ? e.l : Vo(Pt(e, { r: Tf(e.r) }));
8607
8613
  }
8608
8614
  function Ci(e) {
8609
8615
  return ft(e) || e.lvl > e.r.lvl;
@@ -8619,11 +8625,11 @@ function xc(e) {
8619
8625
  }
8620
8626
  function Ef(e) {
8621
8627
  const { l: t } = e;
8622
- return !ft(t) && t.lvl === e.lvl ? _t(t, { r: _t(e, { l: t.r }) }) : e;
8628
+ return !ft(t) && t.lvl === e.lvl ? Pt(t, { r: Pt(e, { l: t.r }) }) : e;
8623
8629
  }
8624
8630
  function Zi(e) {
8625
8631
  const { lvl: t, r: n } = e;
8626
- return !ft(n) && !ft(n.r) && n.lvl === t && n.r.lvl === t ? _t(n, { l: _t(e, { r: n.l }), lvl: t + 1 }) : e;
8632
+ return !ft(n) && !ft(n.r) && n.lvl === t && n.r.lvl === t ? Pt(n, { l: Pt(e, { r: n.l }), lvl: t + 1 }) : e;
8627
8633
  }
8628
8634
  function S0(e) {
8629
8635
  return Cf(e, ({ k: t, v: n }) => ({ index: t, value: n }));
@@ -8858,7 +8864,7 @@ const P0 = {
8858
8864
  he(
8859
8865
  U(
8860
8866
  d,
8861
- Te((C) => C !== void 0 && ft(Rt(x).sizeTree)),
8867
+ Te((C) => C !== void 0 && ft(Et(x).sizeTree)),
8862
8868
  ce((C) => [{ endIndex: 0, size: C, startIndex: 0 }])
8863
8869
  ),
8864
8870
  n
@@ -8887,11 +8893,11 @@ const P0 = {
8887
8893
  ce((C) => C.diff)
8888
8894
  ),
8889
8895
  (C) => {
8890
- const { groupIndices: S } = Rt(x);
8896
+ const { groupIndices: S } = Et(x);
8891
8897
  if (C > 0)
8892
8898
  Me(t, !0), Me(s, C + yc(C, S));
8893
8899
  else if (C < 0) {
8894
- const k = Rt(y);
8900
+ const k = Et(y);
8895
8901
  k.length > 0 && (C -= yc(-C, k)), Me(i, C);
8896
8902
  }
8897
8903
  }
@@ -8983,7 +8989,7 @@ const P0 = {
8983
8989
  if (ft(S.sizeTree))
8984
8990
  return S;
8985
8991
  let N = Sr();
8986
- const E = Rt(y);
8992
+ const E = Et(y);
8987
8993
  let I = 0, O = 0, L = 0;
8988
8994
  for (; I < -C; ) {
8989
8995
  L = E[O];
@@ -9063,7 +9069,7 @@ const _f = nt(
9063
9069
  e
9064
9070
  ), he(
9065
9071
  U(
9066
- At(o, t, r),
9072
+ _t(o, t, r),
9067
9073
  Te(([l, c]) => Us(c)),
9068
9074
  ce(([l, c, d]) => gn(c.groupOffsetTree, Math.max(l - d, 0), "v")[0]),
9069
9075
  xt(),
@@ -9083,7 +9089,7 @@ const _f = nt(
9083
9089
  )
9084
9090
  );
9085
9091
  return it(t, (r) => {
9086
- r && Rt(e)("props updated", {}, Xt.DEBUG);
9092
+ r && Et(e)("props updated", {}, Xt.DEBUG);
9087
9093
  }), { didMount: n, propsReady: t };
9088
9094
  },
9089
9095
  yt(qn),
@@ -9196,7 +9202,7 @@ const wo = nt(
9196
9202
  c
9197
9203
  ), it(
9198
9204
  U(
9199
- At(t, i),
9205
+ _t(t, i),
9200
9206
  Le(a, n, e, c),
9201
9207
  Te(([[, d], f, { sizeTree: p }, h, m]) => d && (!ft(p) || Fa(h)) && !f && !m),
9202
9208
  Le(l)
@@ -9244,7 +9250,7 @@ const io = "up", Vr = "down", L0 = "none", F0 = {
9244
9250
  );
9245
9251
  he(
9246
9252
  U(
9247
- At(Se(o), Se(f)),
9253
+ _t(Se(o), Se(f)),
9248
9254
  ce(([w, b]) => w <= b),
9249
9255
  xt()
9250
9256
  ),
@@ -9252,7 +9258,7 @@ const io = "up", Vr = "down", L0 = "none", F0 = {
9252
9258
  ), he(U(a, An(50)), c);
9253
9259
  const m = en(
9254
9260
  U(
9255
- At(r, Se(s), Se(t), Se(e), Se(d)),
9261
+ _t(r, Se(s), Se(t), Se(e), Se(d)),
9256
9262
  Cn((w, [{ scrollHeight: b, scrollTop: T }, C, S, k, N]) => {
9257
9263
  const E = T + C - b > -N, I = {
9258
9264
  scrollHeight: b,
@@ -9325,7 +9331,7 @@ const io = "up", Vr = "down", L0 = "none", F0 = {
9325
9331
  ce(({ scrollTop: w }) => w),
9326
9332
  xt(),
9327
9333
  Cn(
9328
- (w, b) => Rt(h) ? { direction: w.direction, prevScrollTop: b } : { direction: b < w.prevScrollTop ? io : Vr, prevScrollTop: b },
9334
+ (w, b) => Et(h) ? { direction: w.direction, prevScrollTop: b } : { direction: b < w.prevScrollTop ? io : Vr, prevScrollTop: b },
9329
9335
  { direction: Vr, prevScrollTop: 0 }
9330
9336
  ),
9331
9337
  ce((w) => w.direction)
@@ -9375,7 +9381,7 @@ const Va = nt(
9375
9381
  ([{ deviation: e, fixedHeaderHeight: t, headerHeight: n, scrollTop: r, viewportHeight: o }]) => {
9376
9382
  const s = Ve(), i = X(0), a = X(0), l = X(0), c = Ht(
9377
9383
  U(
9378
- At(
9384
+ _t(
9379
9385
  Se(r),
9380
9386
  Se(o),
9381
9387
  Se(n),
@@ -9524,7 +9530,7 @@ const hr = nt(
9524
9530
  he(s.topItemsIndexes, x);
9525
9531
  const w = Ht(
9526
9532
  U(
9527
- At(
9533
+ _t(
9528
9534
  h,
9529
9535
  m,
9530
9536
  Se(l, oo),
@@ -9555,7 +9561,7 @@ const hr = nt(
9555
9561
  j,
9556
9562
  $
9557
9563
  ]) => {
9558
- const A = E, { offsetTree: B, sizeTree: D } = A, M = Rt(y);
9564
+ const A = E, { offsetTree: B, sizeTree: D } = A, M = Et(y);
9559
9565
  if (N === 0)
9560
9566
  return { ...Ti, totalCount: N };
9561
9567
  if (S === 0 && k === 0)
@@ -9688,7 +9694,7 @@ const hr = nt(
9688
9694
  ([{ fixedFooterHeight: e, fixedHeaderHeight: t, footerHeight: n, headerHeight: r }, { listState: o }]) => {
9689
9695
  const s = Ve(), i = Ht(
9690
9696
  U(
9691
- At(n, e, r, t, o),
9697
+ _t(n, e, r, t, o),
9692
9698
  ce(([a, l, c, d, f]) => a + l + c + d + f.offsetBottom + f.bottom)
9693
9699
  ),
9694
9700
  0
@@ -9701,7 +9707,7 @@ const hr = nt(
9701
9707
  ([{ viewportHeight: e }, { totalListHeight: t }]) => {
9702
9708
  const n = X(!1), r = Ht(
9703
9709
  U(
9704
- At(n, e, t),
9710
+ _t(n, e, t),
9705
9711
  Te(([o]) => o),
9706
9712
  ce(([, o, s]) => Math.max(0, o - s)),
9707
9713
  An(0),
@@ -9747,7 +9753,7 @@ const hr = nt(
9747
9753
  Te(($) => !$),
9748
9754
  // skips the initial publish of false, and the cleanup call.
9749
9755
  // but if scrollingInProgress is true, we skip the initial publish.
9750
- ar(Rt(i) ? 1 : 2)
9756
+ ar(Et(i) ? 1 : 2)
9751
9757
  ),
9752
9758
  k
9753
9759
  ) : k && k(), j;
@@ -9788,7 +9794,7 @@ const U0 = (e, t) => typeof e == "function" ? Cc(e(t)) : t && Cc(e), W0 = nt(
9788
9794
  }
9789
9795
  it(
9790
9796
  U(
9791
- At(U(Se(t), ar(1)), l),
9797
+ _t(U(Se(t), ar(1)), l),
9792
9798
  Le(Se(m), s, a, f),
9793
9799
  ce(([[C, S], k, N, E, I]) => {
9794
9800
  let O = S && E, L = "auto";
@@ -9797,22 +9803,22 @@ const U0 = (e, t) => typeof e == "function" ? Cc(e(t)) : t && Cc(e), W0 = nt(
9797
9803
  Te(({ shouldFollow: C }) => C)
9798
9804
  ),
9799
9805
  ({ followOutputBehavior: C, totalCount: S }) => {
9800
- y && (y(), y = null), Rt(n) ? requestAnimationFrame(() => {
9801
- Rt(d)("following output to ", { totalCount: S }, Xt.DEBUG), g(C);
9806
+ y && (y(), y = null), Et(n) ? requestAnimationFrame(() => {
9807
+ Et(d)("following output to ", { totalCount: S }, Xt.DEBUG), g(C);
9802
9808
  }) : y = pn(e, () => {
9803
- Rt(d)("following output to ", { totalCount: S }, Xt.DEBUG), g(C), y = null;
9809
+ Et(d)("following output to ", { totalCount: S }, Xt.DEBUG), g(C), y = null;
9804
9810
  });
9805
9811
  }
9806
9812
  );
9807
9813
  function w(C) {
9808
9814
  const S = pn(o, (k) => {
9809
- C && !k.atBottom && k.notAtBottomBecause === "SIZE_INCREASED" && !y && (Rt(d)("scrolling to bottom due to increased size", {}, Xt.DEBUG), g("auto"));
9815
+ C && !k.atBottom && k.notAtBottomBecause === "SIZE_INCREASED" && !y && (Et(d)("scrolling to bottom due to increased size", {}, Xt.DEBUG), g("auto"));
9810
9816
  });
9811
9817
  setTimeout(S, 100);
9812
9818
  }
9813
9819
  it(
9814
9820
  U(
9815
- At(Se(m), t, c),
9821
+ _t(Se(m), t, c),
9816
9822
  Te(([C, , S]) => C && S),
9817
9823
  Cn(
9818
9824
  ({ value: C }, [, S]) => ({ refreshed: C === S, value: S }),
@@ -9822,11 +9828,11 @@ const U0 = (e, t) => typeof e == "function" ? Cc(e(t)) : t && Cc(e), W0 = nt(
9822
9828
  Le(m, t)
9823
9829
  ),
9824
9830
  ([, C]) => {
9825
- Rt(a) && w(C !== !1);
9831
+ Et(a) && w(C !== !1);
9826
9832
  }
9827
9833
  ), it(x, () => {
9828
- w(Rt(m) !== !1);
9829
- }), it(At(Se(m), o), ([C, S]) => {
9834
+ w(Et(m) !== !1);
9835
+ }), it(_t(Se(m), o), ([C, S]) => {
9830
9836
  C && !S.atBottom && S.notAtBottomBecause === "VIEWPORT_HEIGHT_DECREASING" && g("auto");
9831
9837
  });
9832
9838
  const b = X(null), T = Ve();
@@ -9844,17 +9850,17 @@ const U0 = (e, t) => typeof e == "function" ? Cc(e(t)) : t && Cc(e), W0 = nt(
9844
9850
  T
9845
9851
  ), it(
9846
9852
  U(
9847
- At(U(T, ar(1)), l),
9853
+ _t(U(T, ar(1)), l),
9848
9854
  Le(Se(b), a, f, p),
9849
9855
  ce(([[C, S], k, N, E, I]) => S && N && (k == null ? void 0 : k({ context: I, totalCount: C, scrollingInProgress: E }))),
9850
9856
  Te((C) => !!C),
9851
9857
  An(0)
9852
9858
  ),
9853
9859
  (C) => {
9854
- y && (y(), y = null), Rt(n) ? requestAnimationFrame(() => {
9855
- Rt(d)("scrolling into view", {}), Me(h, C);
9860
+ y && (y(), y = null), Et(n) ? requestAnimationFrame(() => {
9861
+ Et(d)("scrolling into view", {}), Me(h, C);
9856
9862
  }) : y = pn(e, () => {
9857
- Rt(d)("scrolling into view", {}), Me(h, C), y = null;
9863
+ Et(d)("scrolling into view", {}), Me(h, C), y = null;
9858
9864
  });
9859
9865
  }
9860
9866
  ), { autoscrollToBottom: x, followOutput: m, scrollIntoViewOnChange: b };
@@ -9934,7 +9940,7 @@ const U0 = (e, t) => typeof e == "function" ? Cc(e(t)) : t && Cc(e), W0 = nt(
9934
9940
  ),
9935
9941
  t
9936
9942
  ), it(
9937
- U(At(t, e, n), Le(r)),
9943
+ U(_t(t, e, n), Le(r)),
9938
9944
  ([[o, s, i], a]) => {
9939
9945
  o && a && a.change && a.change(s, i);
9940
9946
  }
@@ -9946,7 +9952,7 @@ const U0 = (e, t) => typeof e == "function" ? Cc(e(t)) : t && Cc(e), W0 = nt(
9946
9952
  const n = Ve(), r = Ve(), o = Ve(), s = X(!1), i = X(void 0);
9947
9953
  return he(
9948
9954
  U(
9949
- At(n, r),
9955
+ _t(n, r),
9950
9956
  ce(([{ scrollHeight: a, scrollTop: l, viewportHeight: c }, { offsetTop: d }]) => ({
9951
9957
  scrollHeight: a,
9952
9958
  scrollTop: Math.max(0, l - d),
@@ -10060,7 +10066,7 @@ const X0 = zf(() => /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.tes
10060
10066
  b && X0() ? Me(e, w - g) : y(-g);
10061
10067
  }), it(
10062
10068
  U(
10063
- At(Ht(s, !1), e, m),
10069
+ _t(Ht(s, !1), e, m),
10064
10070
  Te(([g, w, b]) => !g && !b && w !== 0),
10065
10071
  ce(([g, w]) => w),
10066
10072
  An(1)
@@ -10286,11 +10292,11 @@ function Hf(e, t, n) {
10286
10292
  );
10287
10293
  return z.useSyncExternalStore(
10288
10294
  w,
10289
- () => Rt(g),
10290
- () => Rt(g)
10295
+ () => Et(g),
10296
+ () => Et(g)
10291
10297
  );
10292
10298
  }, m = (y) => {
10293
- const g = z.useContext(a)[y], [w, b] = z.useState(hc(Rt, g));
10299
+ const g = z.useContext(a)[y], [w, b] = z.useState(hc(Et, g));
10294
10300
  return _o(
10295
10301
  () => it(g, (T) => {
10296
10302
  T !== w && b(pc(T));
@@ -10774,7 +10780,7 @@ const TS = /* @__PURE__ */ nt(
10774
10780
  }
10775
10781
  ), it(
10776
10782
  U(
10777
- At(m, Z, I, E, M, J),
10783
+ _t(m, Z, I, E, M, J),
10778
10784
  Te(([P, H, te, se, , re]) => P && !H && te.height !== 0 && se.height !== 0 && !re)
10779
10785
  ),
10780
10786
  ([, , , , P]) => {
@@ -10810,7 +10816,7 @@ const TS = /* @__PURE__ */ nt(
10810
10816
  f
10811
10817
  ), he(
10812
10818
  U(
10813
- At(
10819
+ _t(
10814
10820
  Se(E, Po),
10815
10821
  Se(I, Po),
10816
10822
  Se($, (P, H) => P && P.column === H.column && P.row === H.row),
@@ -10826,7 +10832,7 @@ const TS = /* @__PURE__ */ nt(
10826
10832
  A
10827
10833
  ), he(
10828
10834
  U(
10829
- At(
10835
+ _t(
10830
10836
  Se(S),
10831
10837
  r,
10832
10838
  Se($, CS),
@@ -10877,7 +10883,7 @@ const TS = /* @__PURE__ */ nt(
10877
10883
  S
10878
10884
  ), he(
10879
10885
  U(
10880
- At(E, I, N, $),
10886
+ _t(E, I, N, $),
10881
10887
  Te(([P, H, { items: te }]) => te.length > 0 && H.height !== 0 && P.height !== 0),
10882
10888
  ce(([P, H, { items: te }, se]) => {
10883
10889
  const { bottom: re, top: De } = Ac(P, se, H, te);
@@ -10898,7 +10904,7 @@ const TS = /* @__PURE__ */ nt(
10898
10904
  );
10899
10905
  const Ee = en(
10900
10906
  U(
10901
- At(N, S),
10907
+ _t(N, S),
10902
10908
  Te(([{ items: P }]) => P.length > 0),
10903
10909
  Le(Re),
10904
10910
  Te(([[P, H], te]) => {
@@ -11804,7 +11810,7 @@ function oC({ isOpen: e, onClose: t, fileId: n, fileName: r, mimeType: o }) {
11804
11810
  }
11805
11811
  }
11806
11812
  }, [n]);
11807
- Et(() => {
11813
+ It(() => {
11808
11814
  e && n && p();
11809
11815
  }, [e, n, p]);
11810
11816
  const h = async () => {
@@ -13566,7 +13572,7 @@ function zc(e) {
13566
13572
  }
13567
13573
  function RC({ className: e }) {
13568
13574
  const [t, n] = ge(0);
13569
- return Et(() => {
13575
+ return It(() => {
13570
13576
  const r = setInterval(() => n((o) => (o + 1) % 4), 500);
13571
13577
  return () => clearInterval(r);
13572
13578
  }, []), /* @__PURE__ */ u.jsxs(
@@ -13830,7 +13836,7 @@ const Bc = z.memo(function({
13830
13836
  if (V.type === "interrupt") {
13831
13837
  const xe = V, ht = Mo(
13832
13838
  (xe == null ? void 0 : xe.id) ?? (xe == null ? void 0 : xe.interrupt_id)
13833
- ), gt = !!(ke && ht && ht === ke), Tt = gt ? Ne ?? (xe == null ? void 0 : xe.value) : xe == null ? void 0 : xe.value, _e = ht ? { ...xe, id: ht, interrupt_id: ht } : xe;
13839
+ ), gt = !!(ke && ht && ht === ke), kt = gt ? Ne ?? (xe == null ? void 0 : xe.value) : xe == null ? void 0 : xe.value, _e = ht ? { ...xe, id: ht, interrupt_id: ht } : xe;
13834
13840
  return /* @__PURE__ */ u.jsx(
13835
13841
  EC,
13836
13842
  {
@@ -13839,7 +13845,7 @@ const Bc = z.memo(function({
13839
13845
  onReject: St,
13840
13846
  disabled: w,
13841
13847
  isActive: gt,
13842
- payload: Tt
13848
+ payload: kt
13843
13849
  },
13844
13850
  ve
13845
13851
  );
@@ -13905,7 +13911,7 @@ const Bc = z.memo(function({
13905
13911
  k(ve, xe);
13906
13912
  },
13907
13913
  [E, k]
13908
- ), Fe = z.useMemo(() => Oe ? ne.findIndex((V) => V.id === Oe) : -1, [Oe, ne]), Pt = z.useMemo(() => Fe < 0 ? null : ne[Fe] ?? null, [Fe, ne]), jt = z.useCallback((V) => {
13914
+ ), Fe = z.useMemo(() => Oe ? ne.findIndex((V) => V.id === Oe) : -1, [Oe, ne]), At = z.useMemo(() => Fe < 0 ? null : ne[Fe] ?? null, [Fe, ne]), Tt = z.useCallback((V) => {
13909
13915
  const ve = [];
13910
13916
  if (V.step !== null && ve.push(`Step ${V.step}`), V.source && ve.push(V.source), !V.createdAt)
13911
13917
  return ve.length ? ve.join(" • ") : V.id.slice(0, 8);
@@ -13962,7 +13968,7 @@ const Bc = z.memo(function({
13962
13968
  )
13963
13969
  ] }),
13964
13970
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2", children: [
13965
- tt && Pt && Fe >= 0 && /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
13971
+ tt && At && Fe >= 0 && /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
13966
13972
  /* @__PURE__ */ u.jsx(
13967
13973
  "button",
13968
13974
  {
@@ -13987,7 +13993,7 @@ const Bc = z.memo(function({
13987
13993
  " / ",
13988
13994
  ne.length
13989
13995
  ] }),
13990
- /* @__PURE__ */ u.jsx("span", { className: "text-muted-foreground", children: jt(Pt) })
13996
+ /* @__PURE__ */ u.jsx("span", { className: "text-muted-foreground", children: Tt(At) })
13991
13997
  ] }),
13992
13998
  /* @__PURE__ */ u.jsx(
13993
13999
  "button",
@@ -14672,14 +14678,14 @@ function Ai({
14672
14678
  interrupt: O,
14673
14679
  metadata: L
14674
14680
  } = ya(), { isStreaming: F, error: j, connectionState: $, submit: A, stop: B } = Jx(), D = g ?? y ?? null, M = (E == null ? void 0 : E.id) ?? null, Z = (E == null ? void 0 : E.namespace) ?? null, J = (L == null ? void 0 : L.assemblingMessageId) ?? null, pe = O, [Re, Ee] = ge(!1);
14675
- Et(() => {
14681
+ It(() => {
14676
14682
  pe || Ee(!1);
14677
14683
  }, [pe]);
14678
14684
  const W = Ce(() => {
14679
14685
  Ee(!0);
14680
14686
  }, []), ee = Ce(() => {
14681
14687
  Ee(!1);
14682
- }, []), q = !!pe || Re, [P, H] = ge(null), [te, se] = ge(""), [re, De] = ge(null), [Y, de] = ge(null), [ke, Ne] = ge([]), [ze, Be] = ge(0), [We, qe] = ge(0), [Ge, et] = ge(!1), [Je, ot] = ge(null), [St, mt] = ge(null), [ct, Ct] = ge(!1), [le, ne] = ge(null), [Ae, He] = ge(!1), Oe = Qe(!1), [tt, Ze] = ge(() => Uc.value), Fe = Qe(tt), Pt = Qe(null), jt = Ce((G) => {
14688
+ }, []), q = !!pe || Re, [P, H] = ge(null), [te, se] = ge(""), [re, De] = ge(null), [Y, de] = ge(null), [ke, Ne] = ge([]), [ze, Be] = ge(0), [We, qe] = ge(0), [Ge, et] = ge(!1), [Je, ot] = ge(null), [St, mt] = ge(null), [ct, Ct] = ge(!1), [le, ne] = ge(null), [Ae, He] = ge(!1), Oe = Qe(!1), [tt, Ze] = ge(() => Uc.value), Fe = Qe(tt), At = Qe(null), Tt = Ce((G) => {
14683
14689
  Uc.value = G, Ze(G);
14684
14690
  }, []), [V, ve] = ge(!1), xe = Qe(null), ht = Ce((G) => {
14685
14691
  if (!Array.isArray(G))
@@ -14701,7 +14707,7 @@ function Ai({
14701
14707
  return typeof ae == "number" ? ae : null;
14702
14708
  },
14703
14709
  []
14704
- ), Tt = Ce(
14710
+ ), kt = Ce(
14705
14711
  (G, oe) => {
14706
14712
  if (!G || typeof G != "object") return null;
14707
14713
  const ae = G[oe];
@@ -14745,7 +14751,7 @@ function Ai({
14745
14751
  for (const ae of _e) {
14746
14752
  const be = ae.checkpointId ?? null;
14747
14753
  if (!be) continue;
14748
- const dt = gt(ae.metadata, "step"), Xe = Tt(ae.metadata, "source"), rt = {
14754
+ const dt = gt(ae.metadata, "step"), Xe = kt(ae.metadata, "source"), rt = {
14749
14755
  id: be,
14750
14756
  step: dt,
14751
14757
  source: Xe,
@@ -14764,15 +14770,15 @@ function Ai({
14764
14770
  return (dt.createdAt ?? "").localeCompare(Xe);
14765
14771
  });
14766
14772
  return { checkpointMetaById: G, checkpointIndexByKey: oe };
14767
- }, [_e, gt, Tt]), kt = lt(() => {
14773
+ }, [_e, gt, kt]), Rt = lt(() => {
14768
14774
  var Xe;
14769
14775
  if (!_e.length) return [];
14770
14776
  const G = [..._e].reverse(), oe = (rt, Mt) => {
14771
14777
  const tn = rt.checkpointId ?? null;
14772
14778
  if (!tn) return null;
14773
- const Zn = Tt(rt.metadata, "source");
14774
- Tt(rt.metadata, "next");
14775
- const { text: ll, messageId: nm } = ht(rt.messages), oi = ll && ll.replace(/\s+/g, " ").trim() || Tt(rt.metadata, "title") || Tt(rt.metadata, "label") || Mt || Zn || "Checkpoint", rm = oi.length > 60 ? `${oi.slice(0, 57)}…` : oi;
14779
+ const Zn = kt(rt.metadata, "source");
14780
+ kt(rt.metadata, "next");
14781
+ const { text: ll, messageId: nm } = ht(rt.messages), oi = ll && ll.replace(/\s+/g, " ").trim() || kt(rt.metadata, "title") || kt(rt.metadata, "label") || Mt || Zn || "Checkpoint", rm = oi.length > 60 ? `${oi.slice(0, 57)}…` : oi;
14776
14782
  return {
14777
14783
  id: tn,
14778
14784
  label: rm,
@@ -14780,11 +14786,11 @@ function Ai({
14780
14786
  createdAt: rt.createdAt ?? null,
14781
14787
  step: gt(rt.metadata, "step"),
14782
14788
  source: Zn ?? null,
14783
- next: Tt(rt.metadata, "next")
14789
+ next: kt(rt.metadata, "next")
14784
14790
  };
14785
14791
  }, ae = [], be = /* @__PURE__ */ new Set();
14786
14792
  for (const rt of G) {
14787
- const Mt = ((Xe = Tt(rt.metadata, "source")) == null ? void 0 : Xe.toLowerCase()) ?? null;
14793
+ const Mt = ((Xe = kt(rt.metadata, "source")) == null ? void 0 : Xe.toLowerCase()) ?? null;
14788
14794
  if (!(Mt === "input" || Mt === "user_input" || Mt === "user")) continue;
14789
14795
  const Zn = oe(rt, "User input");
14790
14796
  Zn && !be.has(Zn.id) && (ae.push(Zn), be.add(Zn.id));
@@ -14796,42 +14802,42 @@ function Ai({
14796
14802
  }
14797
14803
  const dt = _e.find((rt) => {
14798
14804
  var tn;
14799
- return (((tn = Tt(rt.metadata, "source")) == null ? void 0 : tn.toLowerCase()) ?? null) === "loop";
14805
+ return (((tn = kt(rt.metadata, "source")) == null ? void 0 : tn.toLowerCase()) ?? null) === "loop";
14800
14806
  });
14801
14807
  if (dt) {
14802
14808
  const rt = oe(dt, "Latest loop");
14803
14809
  rt && !be.has(rt.id) && (ae.push(rt), be.add(rt.id));
14804
14810
  }
14805
14811
  return ae;
14806
- }, [_e, ht, gt, Tt]), Dn = Qe(null), Jn = Qe(null), Ln = Ce(() => {
14812
+ }, [_e, ht, gt, kt]), Dn = Qe(null), Jn = Qe(null), Ln = Ce(() => {
14807
14813
  Dn.current && (Dn.current.value = ""), Jn.current && (Jn.current.value = ""), Be((G) => G + 1), qe((G) => G + 1);
14808
14814
  }, []), ti = Ce(
14809
14815
  (G) => {
14810
- jt(G);
14816
+ Tt(G);
14811
14817
  },
14812
- [jt]
14818
+ [Tt]
14813
14819
  ), So = Qe(!1);
14814
- Et(() => {
14820
+ It(() => {
14815
14821
  So.current && !F && (Ne([]), Ln()), So.current = F;
14816
14822
  }, [F, Ln]);
14817
14823
  const [ni, ri] = ge("desktop");
14818
- Et(() => {
14824
+ It(() => {
14819
14825
  const G = () => {
14820
14826
  const oe = window.innerWidth;
14821
14827
  ri(oe < 640 ? "phone" : oe < 1024 ? "tablet" : "desktop");
14822
14828
  };
14823
14829
  return G(), window.addEventListener("resize", G), () => window.removeEventListener("resize", G);
14824
- }, []), Et(() => {
14830
+ }, []), It(() => {
14825
14831
  He(!1), Oe.current = !1;
14826
- }, [D]), Et(() => {
14832
+ }, [D]), It(() => {
14827
14833
  Fe.current = tt;
14828
- }, [tt]), Et(() => {
14834
+ }, [tt]), It(() => {
14829
14835
  if (!P) {
14830
- Pt.current = null;
14836
+ At.current = null;
14831
14837
  return;
14832
14838
  }
14833
- Pt.current === null && (Pt.current = Fe.current), jt(te ?? "");
14834
- }, [te, P, jt]);
14839
+ At.current === null && (At.current = Fe.current), Tt(te ?? "");
14840
+ }, [te, P, Tt]);
14835
14841
  const R = Ce(async () => {
14836
14842
  if (!(!b || T || !Ae))
14837
14843
  try {
@@ -14840,7 +14846,7 @@ function Ai({
14840
14846
  console.warn("loadOlder failed", G);
14841
14847
  }
14842
14848
  }, [b, Ae, T, S]);
14843
- Et(() => {
14849
+ It(() => {
14844
14850
  (async () => {
14845
14851
  if (!x.baseUrl) {
14846
14852
  ne(null);
@@ -14853,7 +14859,7 @@ function Ai({
14853
14859
  console.warn("Failed to fetch default message:", oe), ne(null);
14854
14860
  }
14855
14861
  })();
14856
- }, [x.baseUrl]), Et(() => {
14862
+ }, [x.baseUrl]), It(() => {
14857
14863
  j && !ct && (m == null || m(j));
14858
14864
  }, [j, ct, m]);
14859
14865
  const K = (G) => {
@@ -14891,7 +14897,7 @@ function Ai({
14891
14897
  checkpointId: ae,
14892
14898
  checkpointNs: be
14893
14899
  }
14894
- ), p == null || p(oe), jt(""), de(null), Ne([]), Ln(), H(null), se(""), De(null);
14900
+ ), p == null || p(oe), Tt(""), de(null), Ne([]), Ln(), H(null), se(""), De(null);
14895
14901
  } catch (ae) {
14896
14902
  const be = (ae == null ? void 0 : ae.message) || "Failed to send message";
14897
14903
  de(be), m == null || m(be);
@@ -14899,15 +14905,15 @@ function Ai({
14899
14905
  }
14900
14906
  }, we = z.useCallback(
14901
14907
  (G, oe, ae) => {
14902
- c && (Pt.current = tt, H(G), se(oe), jt(oe), de(null), De({
14908
+ c && (At.current = tt, H(G), se(oe), Tt(oe), de(null), De({
14903
14909
  checkpointId: (ae == null ? void 0 : ae.checkpointId) ?? null,
14904
14910
  checkpointNs: (ae == null ? void 0 : ae.checkpointNs) ?? null
14905
14911
  }));
14906
14912
  },
14907
- [tt, c, jt]
14913
+ [tt, c, Tt]
14908
14914
  ), Ye = z.useCallback(() => {
14909
- H(null), se(""), De(null), de(null), jt(Pt.current ?? tt), Pt.current = null;
14910
- }, [tt, jt]), at = Ce(
14915
+ H(null), se(""), De(null), de(null), Tt(At.current ?? tt), At.current = null;
14916
+ }, [tt, Tt]), at = Ce(
14911
14917
  (G, oe, ae) => {
14912
14918
  we(G, oe, ae);
14913
14919
  },
@@ -15076,7 +15082,7 @@ function Ai({
15076
15082
  checkpointIndexByKey: ut,
15077
15083
  activeCheckpointId: M,
15078
15084
  onSelectCheckpoint: Kt,
15079
- timelineCheckpoints: kt
15085
+ timelineCheckpoints: Rt
15080
15086
  }
15081
15087
  ),
15082
15088
  ($ === "reconnecting" || $ === "connecting") && /* @__PURE__ */ u.jsx("div", { className: "pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60", children: /* @__PURE__ */ u.jsxs("span", { className: "flex items-center gap-2", children: [
@@ -15802,14 +15808,14 @@ function Kc({
15802
15808
  isLoading: m,
15803
15809
  actions: x
15804
15810
  } = xa(), { loadThread: y } = ya(), { createThread: g, deleteThread: w, renameThread: b } = x, [T, C] = ge(Array.isArray(f) ? f : []), S = Qe(T.length > 0), k = Qe(null), N = Qe(0), [E, I] = ge(null), [O, L] = ge(""), [F, j] = ge(!1);
15805
- Et(() => {
15811
+ It(() => {
15806
15812
  const W = Array.isArray(f) ? f : [];
15807
15813
  if (W.length > 0) {
15808
15814
  S.current = !0, C(W);
15809
15815
  return;
15810
15816
  }
15811
15817
  m || (S.current = !1, C(W));
15812
- }, [f, m]), Et(() => {
15818
+ }, [f, m]), It(() => {
15813
15819
  if (!k.current) return;
15814
15820
  const W = k.current.querySelector(
15815
15821
  "[data-radix-scroll-area-viewport]"
@@ -17276,10 +17282,10 @@ const HT = {
17276
17282
  };
17277
17283
  function Tk({ settings: e, onSettingsChange: t, className: n = "" }) {
17278
17284
  const [r, o] = ge(!1), [s, i] = ge(!1), [a, l] = ge(e), [c, d] = ge(!1), { toast: f } = Xa();
17279
- Et(() => {
17285
+ It(() => {
17280
17286
  const y = JSON.stringify(a) !== JSON.stringify(e);
17281
17287
  d(y);
17282
- }, [a, e]), Et(() => {
17288
+ }, [a, e]), It(() => {
17283
17289
  l(e);
17284
17290
  }, [e]);
17285
17291
  const p = () => {