@itechchoice/prime-chatkit 0.1.0-alpha.8 → 0.1.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! PrimeChatKit – proprietary, see LICENSE. Contains affectUI Pro components – licensed under https://www.affectui.com/license, not under this package's terms. Don't copy them out of this package. */
2
2
  import { jsxs as d, jsx as i, Fragment as Me } from "react/jsx-runtime";
3
- import { useContext as Ht, createContext as ht, useSyncExternalStore as Ya, useMemo as je, useCallback as Ne, useRef as q, useState as I, useEffect as se, useLayoutEffect as ke, useId as qe, isValidElement as Va, Fragment as Ga, memo as Nt, useImperativeHandle as Qa, createElement as Za } from "react";
3
+ import { useContext as Ht, createContext as ht, useSyncExternalStore as Ya, useMemo as je, useCallback as Ne, useRef as U, useState as A, useEffect as se, useLayoutEffect as ke, useId as qe, isValidElement as Va, Fragment as Ga, memo as Nt, useImperativeHandle as Qa, createElement as Za } from "react";
4
4
  import { Clock01Icon as Ka, Alert02Icon as Wt, Mic01Icon as Ja, Video01Icon as Xa, Refresh01Icon as en, Tick02Icon as la, ArrowRight01Icon as tn, Briefcase01Icon as an, StarIcon as nn, SparklesIcon as on, Idea01Icon as rn, Compass01Icon as sn, HelpCircleIcon as cn, ChartLineData01Icon as ln, Analytics01Icon as dn, ArrowLeft01Icon as un, PencilEdit02Icon as pn, HistoryIcon as hn, PictureInPictureOnIcon as mn, Layout2ColumnIcon as fn, Cancel01Icon as gn } from "@hugeicons/core-free-icons";
5
5
  import { HugeiconsIcon as it } from "@hugeicons/react";
6
6
  import da, { defaultUrlTransform as ua } from "react-markdown";
@@ -112,50 +112,50 @@ const wn = 1440, yi = 1280, _n = 768, bn = 620, _t = 480, ki = 720, Qt = 64, kt
112
112
  } catch {
113
113
  }
114
114
  }, Nn = (e, t, o) => {
115
- const n = q(null), [a, r] = I(
115
+ const n = U(null), [a, r] = A(
116
116
  typeof window < "u" ? window.innerWidth : 0
117
- ), [c, u] = I(
117
+ ), [c, u] = A(
118
118
  typeof window < "u" ? window.innerHeight : 0
119
- ), [s, l] = I(Qt), [x, _] = I(null), [v, w] = I(null), [m, k] = I(null), [y, f] = I(!1), [b, M] = I(!1), [j, V] = I(!1), [L, F] = I(!1), P = q(null), O = q(null), T = q(null), B = q(null), ee = q(null), z = q(null), H = q(null), Z = q(null), K = q(null), te = q(!1), X = q(null), oe = t || "auto", $ = (oe === "auto" && a >= wn || oe === "split" && a >= yi ? "split" : "dock") === "split", Y = e && $, p = !$ && a >= _n, A = Ne(() => {
120
- const S = X.current;
121
- S && (window.removeEventListener("pointermove", S.handlePointerMove), window.removeEventListener("pointerup", S.handlePointerUp), S.pointerTarget?.hasPointerCapture?.(S.pointerId) && S.pointerTarget.releasePointerCapture(S.pointerId), document.body.classList.remove("chatkit-dragging"), document.body.classList.remove("chatkit-dock-resizing"), Z.current && typeof window < "u" && (window.cancelAnimationFrame(Z.current), Z.current = null), X.current = null, V(!1), F(!1));
122
- }, []), C = je(() => {
123
- const S = `${Math.max(0, s)}px`, ae = {
124
- [oi]: S,
125
- [xi[oi]]: S
119
+ ), [s, l] = A(Qt), [x, _] = A(null), [b, w] = A(null), [m, k] = A(null), [v, f] = A(!1), [y, L] = A(!1), [z, H] = A(!1), [C, P] = A(!1), F = U(null), D = U(null), T = U(null), B = U(null), ee = U(null), M = U(null), W = U(null), Z = U(null), K = U(null), te = U(!1), X = U(null), oe = t || "auto", E = (oe === "auto" && a >= wn || oe === "split" && a >= yi ? "split" : "dock") === "split", V = e && E, p = !E && a >= _n, S = Ne(() => {
120
+ const $ = X.current;
121
+ $ && (window.removeEventListener("pointermove", $.handlePointerMove), window.removeEventListener("pointerup", $.handlePointerUp), $.pointerTarget?.hasPointerCapture?.($.pointerId) && $.pointerTarget.releasePointerCapture($.pointerId), document.body.classList.remove("chatkit-dragging"), document.body.classList.remove("chatkit-dock-resizing"), Z.current && typeof window < "u" && (window.cancelAnimationFrame(Z.current), Z.current = null), X.current = null, H(!1), P(!1));
122
+ }, []), N = je(() => {
123
+ const $ = `${Math.max(0, s)}px`, ae = {
124
+ [oi]: $,
125
+ [xi[oi]]: $
126
126
  };
127
- return p && m && !$ && (ae.top = `${m.y}px`, ae.left = `${m.x}px`, ae.width = `${m.width}px`, ae.height = `${m.height}px`, ae.right = "auto", ae.bottom = "auto"), ae;
128
- }, [m, s, p, $]), h = Ne(() => {
127
+ return p && m && !E && (ae.top = `${m.y}px`, ae.left = `${m.x}px`, ae.width = `${m.width}px`, ae.height = `${m.height}px`, ae.right = "auto", ae.bottom = "auto"), ae;
128
+ }, [m, s, p, E]), h = Ne(() => {
129
129
  if (typeof window > "u") return;
130
- const S = document.querySelector('[data-role="app-header"]');
131
- if (!S) {
130
+ const $ = document.querySelector('[data-role="app-header"]');
131
+ if (!$) {
132
132
  l(Qt);
133
133
  return;
134
134
  }
135
- const ae = S.getBoundingClientRect();
135
+ const ae = $.getBoundingClientRect();
136
136
  l(ae?.height || Qt);
137
137
  }, []);
138
138
  se(() => {
139
139
  if (typeof window > "u") return;
140
- const S = () => {
140
+ const $ = () => {
141
141
  r(window.innerWidth || 0), u(window.innerHeight || 0), h();
142
142
  };
143
- return S(), window.addEventListener("resize", S), () => window.removeEventListener("resize", S);
143
+ return $(), window.addEventListener("resize", $), () => window.removeEventListener("resize", $);
144
144
  }, [h]), se(() => {
145
- if (!$ || a <= 0)
145
+ if (!E || a <= 0)
146
146
  return;
147
- const S = _t, ae = Math.min(
148
- Math.max(Math.round(a * Ci), S),
147
+ const $ = _t, ae = Math.min(
148
+ Math.max(Math.round(a * Ci), $),
149
149
  ki
150
150
  ), fe = _t;
151
- P.current = S, O.current = ae, T.current = fe, w(fe), _((ue) => ue ? Math.min(ae, Math.max(fe, ue)) : S);
152
- }, [$, a]), se(() => {
151
+ F.current = $, D.current = ae, T.current = fe, w(fe), _((ue) => ue ? Math.min(ae, Math.max(fe, ue)) : $);
152
+ }, [E, a]), se(() => {
153
153
  if (!p) {
154
- A(), k(null);
154
+ S(), k(null);
155
155
  return;
156
156
  }
157
- k((S) => {
158
- const ae = S || Cn() || Mn({
157
+ k(($) => {
158
+ const ae = $ || Cn() || Mn({
159
159
  viewportWidth: a,
160
160
  viewportHeight: c,
161
161
  headerHeight: s
@@ -166,74 +166,74 @@ const wn = 1440, yi = 1280, _n = 768, bn = 620, _t = 480, ki = 720, Qt = 64, kt
166
166
  headerHeight: s
167
167
  });
168
168
  });
169
- }, [s, p, A, c, a]), se(() => {
169
+ }, [s, p, S, c, a]), se(() => {
170
170
  K.current = m, p && m && vt(n.current, m);
171
171
  }, [m, p]), se(() => {
172
172
  if (typeof document > "u") return;
173
- const S = document.documentElement;
174
- return Y && x && v ? (bt(S, st, `${x}px`), bt(S, zt, `${v}px`)) : (St(S, st), St(S, zt)), () => {
175
- St(S, st), St(S, zt);
173
+ const $ = document.documentElement;
174
+ return V && x && b ? (bt($, st, `${x}px`), bt($, zt, `${b}px`)) : (St($, st), St($, zt)), () => {
175
+ St($, st), St($, zt);
176
176
  };
177
- }, [Y, v, x]), se(() => {
178
- Y || (f(!1), M(!1));
179
- }, [Y]), se(() => {
177
+ }, [V, b, x]), se(() => {
178
+ V || (f(!1), L(!1));
179
+ }, [V]), se(() => {
180
180
  if (typeof document > "u") return;
181
- const S = "ai-split-active";
182
- return Y ? document.body.classList.add(S) : document.body.classList.remove(S), () => document.body.classList.remove(S);
183
- }, [Y]), se(() => {
181
+ const $ = "ai-split-active";
182
+ return V ? document.body.classList.add($) : document.body.classList.remove($), () => document.body.classList.remove($);
183
+ }, [V]), se(() => {
184
184
  if (typeof document > "u" || typeof window > "u")
185
185
  return;
186
- if (!Y) {
186
+ if (!V) {
187
187
  te.current = !1;
188
188
  return;
189
189
  }
190
- const S = document.documentElement, ae = window.getComputedStyle(S), fe = Mi(ae.getPropertyValue("--app-sidebar-width"), 0), ue = Mi(ae.getPropertyValue("--app-shell-gutter"), 0), ge = x || P.current || _t;
190
+ const $ = document.documentElement, ae = window.getComputedStyle($), fe = Mi(ae.getPropertyValue("--app-sidebar-width"), 0), ue = Mi(ae.getPropertyValue("--app-shell-gutter"), 0), ge = x || F.current || _t;
191
191
  a - ge - fe - ue < bn && !te.current && (te.current = !0, o("dock"));
192
- }, [Y, x, a, o]);
193
- const N = Ne(() => {
194
- e && ($ ? o("dock") : a >= yi ? o("split") : o("dock"));
195
- }, [e, $, a, o]), G = Ne((S) => {
196
- if (!Y || S.button !== 0) return;
197
- S.preventDefault(), S.stopPropagation();
198
- const ae = S.clientX, fe = O.current || Math.min(
192
+ }, [V, x, a, o]);
193
+ const I = Ne(() => {
194
+ e && (E ? o("dock") : a >= yi ? o("split") : o("dock"));
195
+ }, [e, E, a, o]), Q = Ne(($) => {
196
+ if (!V || $.button !== 0) return;
197
+ $.preventDefault(), $.stopPropagation();
198
+ const ae = $.clientX, fe = D.current || Math.min(
199
199
  Math.max(Math.round(a * Ci), _t),
200
200
  ki
201
- ), ue = T.current || _t, ge = x || P.current || fe, _e = S.currentTarget;
202
- _e?.setPointerCapture?.(S.pointerId), B.current = {
201
+ ), ue = T.current || _t, ge = x || F.current || fe, _e = $.currentTarget;
202
+ _e?.setPointerCapture?.($.pointerId), B.current = {
203
203
  startX: ae,
204
204
  startWidth: ge,
205
205
  maxWidth: fe,
206
206
  minWidth: ue,
207
- pointerId: S.pointerId,
207
+ pointerId: $.pointerId,
208
208
  pointerTarget: _e
209
- }, z.current = ge, f(!0), M(!0), document.body.classList.add("chatkit-resizing");
209
+ }, M.current = ge, f(!0), L(!0), document.body.classList.add("chatkit-resizing");
210
210
  const we = document.documentElement;
211
211
  bt(we, zt, `${ue}px`);
212
212
  const he = (ce) => {
213
213
  if (!B.current) return;
214
214
  const { startX: xe, startWidth: pe, maxWidth: ve, minWidth: Ce } = B.current, J = xe - ce.clientX, ze = Math.min(ve, Math.max(Ce, pe + J));
215
- z.current = ze, !H.current && (H.current = window.requestAnimationFrame(() => {
216
- H.current = null, bt(we, st, `${z.current}px`);
215
+ M.current = ze, !W.current && (W.current = window.requestAnimationFrame(() => {
216
+ W.current = null, bt(we, st, `${M.current}px`);
217
217
  }));
218
- }, Q = (ce) => {
218
+ }, G = (ce) => {
219
219
  const xe = B.current;
220
- B.current = null, M(!1), document.body.classList.remove("chatkit-resizing"), H.current && (window.cancelAnimationFrame(H.current), H.current = null), z.current && (bt(we, st, `${z.current}px`), _(z.current)), xe?.pointerTarget?.hasPointerCapture?.(xe.pointerId) && xe.pointerTarget.releasePointerCapture(xe.pointerId);
220
+ B.current = null, L(!1), document.body.classList.remove("chatkit-resizing"), W.current && (window.cancelAnimationFrame(W.current), W.current = null), M.current && (bt(we, st, `${M.current}px`), _(M.current)), xe?.pointerTarget?.hasPointerCapture?.(xe.pointerId) && xe.pointerTarget.releasePointerCapture(xe.pointerId);
221
221
  const pe = xe?.pointerTarget?.getBoundingClientRect?.(), ve = pe && ce.clientX >= pe.left && ce.clientX <= pe.right && ce.clientY >= pe.top && ce.clientY <= pe.bottom;
222
- f(!!ve), window.removeEventListener("pointermove", he), window.removeEventListener("pointerup", Q), ee.current = null;
222
+ f(!!ve), window.removeEventListener("pointermove", he), window.removeEventListener("pointerup", G), ee.current = null;
223
223
  };
224
224
  ee.current = {
225
- pointerId: S.pointerId,
225
+ pointerId: $.pointerId,
226
226
  pointerTarget: _e,
227
227
  handlePointerMove: he,
228
- handlePointerUp: Q
229
- }, window.addEventListener("pointermove", he), window.addEventListener("pointerup", Q);
230
- }, [Y, x, a]), g = Ne((S) => {
231
- if (!p || !m || S.button !== 0 || S.target instanceof Element && S.target.closest('button, a, input, textarea, select, [role="button"]'))
228
+ handlePointerUp: G
229
+ }, window.addEventListener("pointermove", he), window.addEventListener("pointerup", G);
230
+ }, [V, x, a]), g = Ne(($) => {
231
+ if (!p || !m || $.button !== 0 || $.target instanceof Element && $.target.closest('button, a, input, textarea, select, [role="button"]'))
232
232
  return;
233
- S.preventDefault(), S.stopPropagation(), A();
234
- const ae = S.currentTarget;
235
- ae?.setPointerCapture?.(S.pointerId);
236
- const fe = S.clientX - m.x, ue = S.clientY - m.y, ge = (we) => {
233
+ $.preventDefault(), $.stopPropagation(), S();
234
+ const ae = $.currentTarget;
235
+ ae?.setPointerCapture?.($.pointerId);
236
+ const fe = $.clientX - m.x, ue = $.clientY - m.y, ge = (we) => {
237
237
  const he = Ot(
238
238
  {
239
239
  ...m,
@@ -247,27 +247,27 @@ const wn = 1440, yi = 1280, _n = 768, bn = 620, _t = 480, ki = 720, Qt = 64, kt
247
247
  }));
248
248
  }, _e = () => {
249
249
  const we = K.current;
250
- Z.current && (window.cancelAnimationFrame(Z.current), Z.current = null), vt(n.current, we), we && (Ni(we), k(we)), A();
250
+ Z.current && (window.cancelAnimationFrame(Z.current), Z.current = null), vt(n.current, we), we && (Ni(we), k(we)), S();
251
251
  };
252
252
  X.current = {
253
253
  mode: "drag",
254
- pointerId: S.pointerId,
254
+ pointerId: $.pointerId,
255
255
  pointerTarget: ae,
256
256
  handlePointerMove: ge,
257
257
  handlePointerUp: _e
258
- }, V(!0), document.body.classList.add("chatkit-dragging"), window.addEventListener("pointermove", ge), window.addEventListener("pointerup", _e);
259
- }, [m, s, p, A, c, a]), D = Ne((S) => {
260
- if (!p || !m || S.button !== 0)
258
+ }, H(!0), document.body.classList.add("chatkit-dragging"), window.addEventListener("pointermove", ge), window.addEventListener("pointerup", _e);
259
+ }, [m, s, p, S, c, a]), O = Ne(($) => {
260
+ if (!p || !m || $.button !== 0)
261
261
  return;
262
- S.preventDefault(), S.stopPropagation(), A();
263
- const ae = S.currentTarget;
264
- ae?.setPointerCapture?.(S.pointerId);
265
- const fe = S.clientX, ue = S.clientY, ge = m.width, _e = m.height, we = (Q) => {
262
+ $.preventDefault(), $.stopPropagation(), S();
263
+ const ae = $.currentTarget;
264
+ ae?.setPointerCapture?.($.pointerId);
265
+ const fe = $.clientX, ue = $.clientY, ge = m.width, _e = m.height, we = (G) => {
266
266
  const ce = Ot(
267
267
  {
268
268
  ...m,
269
- width: ge + (Q.clientX - fe),
270
- height: _e + (Q.clientY - ue)
269
+ width: ge + (G.clientX - fe),
270
+ height: _e + (G.clientY - ue)
271
271
  },
272
272
  { viewportWidth: a, viewportHeight: c, headerHeight: s }
273
273
  );
@@ -275,42 +275,42 @@ const wn = 1440, yi = 1280, _n = 768, bn = 620, _t = 480, ki = 720, Qt = 64, kt
275
275
  Z.current = null, vt(n.current, K.current);
276
276
  }));
277
277
  }, he = () => {
278
- const Q = K.current;
279
- Z.current && (window.cancelAnimationFrame(Z.current), Z.current = null), vt(n.current, Q), Q && (Ni(Q), k(Q)), A();
278
+ const G = K.current;
279
+ Z.current && (window.cancelAnimationFrame(Z.current), Z.current = null), vt(n.current, G), G && (Ni(G), k(G)), S();
280
280
  };
281
281
  X.current = {
282
282
  mode: "resize",
283
- pointerId: S.pointerId,
283
+ pointerId: $.pointerId,
284
284
  pointerTarget: ae,
285
285
  handlePointerMove: we,
286
286
  handlePointerUp: he
287
- }, F(!0), document.body.classList.add("chatkit-dock-resizing"), window.addEventListener("pointermove", we), window.addEventListener("pointerup", he);
288
- }, [m, s, p, A, c, a]);
287
+ }, P(!0), document.body.classList.add("chatkit-dock-resizing"), window.addEventListener("pointermove", we), window.addEventListener("pointerup", he);
288
+ }, [m, s, p, S, c, a]);
289
289
  se(() => () => {
290
- const S = ee.current;
291
- S && (window.removeEventListener("pointermove", S.handlePointerMove), window.removeEventListener("pointerup", S.handlePointerUp), S.pointerTarget.hasPointerCapture?.(S.pointerId) && S.pointerTarget.releasePointerCapture(S.pointerId), ee.current = null), B.current = null, z.current = null, H.current && typeof window < "u" && (window.cancelAnimationFrame(H.current), H.current = null), Z.current && typeof window < "u" && window.cancelAnimationFrame(Z.current), document.body.classList.remove("chatkit-resizing"), document.body.classList.remove("chatkit-dragging"), document.body.classList.remove("chatkit-dock-resizing"), A();
292
- }, [A]);
290
+ const $ = ee.current;
291
+ $ && (window.removeEventListener("pointermove", $.handlePointerMove), window.removeEventListener("pointerup", $.handlePointerUp), $.pointerTarget.hasPointerCapture?.($.pointerId) && $.pointerTarget.releasePointerCapture($.pointerId), ee.current = null), B.current = null, M.current = null, W.current && typeof window < "u" && (window.cancelAnimationFrame(W.current), W.current = null), Z.current && typeof window < "u" && window.cancelAnimationFrame(Z.current), document.body.classList.remove("chatkit-resizing"), document.body.classList.remove("chatkit-dragging"), document.body.classList.remove("chatkit-dock-resizing"), S();
292
+ }, [S]);
293
293
  const R = Ne(() => {
294
- Y && f(!0);
295
- }, [Y]), U = Ne(() => {
294
+ V && f(!0);
295
+ }, [V]), q = Ne(() => {
296
296
  B.current || f(!1);
297
297
  }, []);
298
298
  return {
299
- isSplitLayout: $,
300
- isSplitActive: Y,
301
- isResizeReady: y,
302
- isResizing: b,
299
+ isSplitLayout: E,
300
+ isSplitActive: V,
301
+ isResizeReady: v,
302
+ isResizing: y,
303
303
  isDockInteractive: p,
304
- isDockDragging: j,
305
- isDockResizing: L,
304
+ isDockDragging: z,
305
+ isDockResizing: C,
306
306
  shellRef: n,
307
- shellStyle: C,
308
- toggleLayout: N,
309
- handleResizeStart: G,
307
+ shellStyle: N,
308
+ toggleLayout: I,
309
+ handleResizeStart: Q,
310
310
  handleResizeEnter: R,
311
- handleResizeLeave: U,
311
+ handleResizeLeave: q,
312
312
  handleDockDragStart: g,
313
- handleDockResizeStart: D
313
+ handleDockResizeStart: O
314
314
  };
315
315
  };
316
316
  function In({
@@ -325,25 +325,25 @@ function In({
325
325
  }) {
326
326
  const s = e && t, l = e && !t, x = Nn(s, o, n), {
327
327
  isSplitLayout: _,
328
- isSplitActive: v,
328
+ isSplitActive: b,
329
329
  isDockInteractive: w,
330
330
  isDockDragging: m,
331
331
  isDockResizing: k,
332
- shellRef: y,
332
+ shellRef: v,
333
333
  shellStyle: f,
334
- handleResizeStart: b,
335
- handleResizeEnter: M,
336
- handleResizeLeave: j,
337
- handleDockResizeStart: V
334
+ handleResizeStart: y,
335
+ handleResizeEnter: L,
336
+ handleResizeLeave: z,
337
+ handleDockResizeStart: H
338
338
  } = x;
339
339
  return /* @__PURE__ */ d(
340
340
  "div",
341
341
  {
342
- ref: y,
342
+ ref: v,
343
343
  className: [
344
344
  "abc-prime-dock",
345
345
  s && "abc-prime-dock--open",
346
- v && "abc-prime-dock--split",
346
+ b && "abc-prime-dock--split",
347
347
  l && "abc-prime-dock--minimized",
348
348
  w && "abc-prime-dock--dock-interactive",
349
349
  m && "abc-prime-dock--dragging",
@@ -352,16 +352,16 @@ function In({
352
352
  ].filter(Boolean).join(" "),
353
353
  style: f,
354
354
  children: [
355
- v && /* @__PURE__ */ i(
355
+ b && /* @__PURE__ */ i(
356
356
  "div",
357
357
  {
358
358
  className: "abc-prime-dock__resize-handle",
359
359
  role: "separator",
360
360
  "aria-orientation": "vertical",
361
361
  "aria-label": r.resizeHandle,
362
- onPointerDown: b,
363
- onPointerEnter: M,
364
- onPointerLeave: j
362
+ onPointerDown: y,
363
+ onPointerEnter: L,
364
+ onPointerLeave: z
365
365
  }
366
366
  ),
367
367
  /* @__PURE__ */ d("div", { className: "abc-prime-dock__panel", children: [
@@ -371,7 +371,7 @@ function In({
371
371
  {
372
372
  type: "button",
373
373
  className: "abc-prime-dock__resize-corner",
374
- onPointerDown: V,
374
+ onPointerDown: H,
375
375
  "aria-label": r.resizeCorner
376
376
  }
377
377
  )
@@ -499,75 +499,75 @@ function En({
499
499
  onAttach: x,
500
500
  // PrimeChatKit LOCAL ⑨ start
501
501
  onAdd: _,
502
- addItems: v,
502
+ addItems: b,
503
503
  voice: w = !0,
504
504
  // PrimeChatKit LOCAL ⑨ end
505
505
  approval: m = "ask",
506
506
  onApprovalChange: k,
507
- onLearnMore: y,
507
+ onLearnMore: v,
508
508
  folders: f = Ln,
509
- folder: b,
510
- onFolderChange: M,
511
- apps: j = Tn,
512
- connectedApps: V = ["gmail"],
513
- onAppsChange: L,
514
- foot: F,
515
- tray: P = !0
509
+ folder: y,
510
+ onFolderChange: L,
511
+ apps: z = Tn,
512
+ connectedApps: H = ["gmail"],
513
+ onAppsChange: C,
514
+ foot: P,
515
+ tray: F = !0
516
516
  }) {
517
- const O = { ...ya, ...r }, T = Sn(O), B = Dn(O), [ee, z] = I(m === !1 ? "ask" : m), [H, Z] = I(!1), [K, te] = I(!1), [X, oe] = I(""), [re, W] = I(b ?? null), [$, Y] = I(V), [p, A] = I(c[0]), [C, h] = I(null), N = (E) => {
518
- a && E === "add" || h((le) => le === E ? null : E);
519
- }, G = (E) => (le) => {
520
- a && E === "add" || le.key !== "ArrowDown" && le.key !== "ArrowUp" || (le.preventDefault(), h(E));
521
- }, [g, D] = I(!1), [R, U] = I(""), [S, ae] = I(Dt), [fe, ue] = I("");
517
+ const D = { ...ya, ...r }, T = Sn(D), B = Dn(D), [ee, M] = A(m === !1 ? "ask" : m), [W, Z] = A(!1), [K, te] = A(!1), [X, oe] = A(""), [re, Y] = A(y ?? null), [E, V] = A(H), [p, S] = A(c[0]), [N, h] = A(null), I = (j) => {
518
+ a && j === "add" || h((le) => le === j ? null : j);
519
+ }, Q = (j) => (le) => {
520
+ a && j === "add" || le.key !== "ArrowDown" && le.key !== "ArrowUp" || (le.preventDefault(), h(j));
521
+ }, [g, O] = A(!1), [R, q] = A(""), [$, ae] = A(Dt), [fe, ue] = A("");
522
522
  se(() => {
523
- a && (h(null), D(!1), U(""), ae(Dt()), ue(""));
523
+ a && (h(null), O(!1), q(""), ae(Dt()), ue(""));
524
524
  }, [a]);
525
- const ge = q(null), _e = q(null), we = q(null), [he, Q] = I(Ii);
525
+ const ge = U(null), _e = U(null), we = U(null), [he, G] = A(Ii);
526
526
  ke(() => {
527
- const E = _e.current;
528
- if (!E) return;
529
- const le = E.style.height;
530
- E.style.height = "0px";
531
- const Oe = Math.max(E.scrollHeight, R ? we.current?.scrollHeight ?? 0 : 0);
532
- E.style.height = le;
533
- const We = parseFloat(getComputedStyle(E).lineHeight) || 1;
534
- Q(Math.min(On, Math.max(Ii, Math.round(Oe / We))));
527
+ const j = _e.current;
528
+ if (!j) return;
529
+ const le = j.style.height;
530
+ j.style.height = "0px";
531
+ const Oe = Math.max(j.scrollHeight, R ? we.current?.scrollHeight ?? 0 : 0);
532
+ j.style.height = le;
533
+ const We = parseFloat(getComputedStyle(j).lineHeight) || 1;
534
+ G(Math.min(On, Math.max(Ii, Math.round(Oe / We))));
535
535
  }, [X, R]);
536
- const ce = q(null), xe = q(null), pe = q(null), ve = q(null), Ce = q(null), J = q(0), [ze, Yt] = I(!1), It = (E) => {
537
- const le = re === E ? null : E;
538
- W(le), h(null), ue(le ? O.workingIn(le) : O.noFolder), M?.(le), ve.current?.focus();
539
- }, Lt = (E) => {
540
- const le = !$.includes(E), Oe = le ? [...$, E] : $.filter((We) => We !== E);
541
- Y(Oe), h(null), ue(O.appConnection(j.find((We) => We.id === E)?.name, le)), L?.(Oe), (P ? Ce : pe).current?.focus();
542
- }, Tt = (E) => {
543
- E !== ee && Z(!0), z(E), h(null), ue(O.selected(T.find((le) => le.id === E)?.label)), k?.(E), xe.current?.focus();
544
- }, At = (E) => {
536
+ const ce = U(null), xe = U(null), pe = U(null), ve = U(null), Ce = U(null), J = U(0), [ze, Yt] = A(!1), It = (j) => {
537
+ const le = re === j ? null : j;
538
+ Y(le), h(null), ue(le ? D.workingIn(le) : D.noFolder), L?.(le), ve.current?.focus();
539
+ }, Lt = (j) => {
540
+ const le = !E.includes(j), Oe = le ? [...E, j] : E.filter((We) => We !== j);
541
+ V(Oe), h(null), ue(D.appConnection(z.find((We) => We.id === j)?.name, le)), C?.(Oe), (F ? Ce : pe).current?.focus();
542
+ }, Tt = (j) => {
543
+ j !== ee && Z(!0), M(j), h(null), ue(D.selected(T.find((le) => le.id === j)?.label)), k?.(j), xe.current?.focus();
544
+ }, At = (j) => {
545
545
  if (!a) {
546
- if (E === "apps") return h("apps");
547
- if (h(null), E === "plan" && (ue(K ? O.planOff : O.planOn), te(!K)), x?.(E), E === "folder" && f.length > 0 && !F) return h("folder");
546
+ if (j === "apps") return h("apps");
547
+ if (h(null), j === "plan" && (ue(K ? D.planOff : D.planOn), te(!K)), x?.(j), j === "folder" && f.length > 0 && !P) return h("folder");
548
548
  pe.current?.focus();
549
549
  }
550
- }, ft = (E) => {
551
- E.id !== p?.id && Yt(!0), A(E), h(null), ue(O.selected(E.name)), l?.(E), ce.current?.focus();
550
+ }, ft = (j) => {
551
+ j.id !== p?.id && Yt(!0), S(j), h(null), ue(D.selected(j.name)), l?.(j), ce.current?.focus();
552
552
  };
553
553
  ke(() => {
554
- const E = ce.current;
555
- if (!E) return;
556
- const le = E.offsetWidth, Oe = J.current;
557
- J.current = le, !(!ze || !Oe || Math.abs(Oe - le) < 0.5) && (window.matchMedia("(prefers-reduced-motion: reduce)").matches || E.animate([{ width: `${Oe}px` }, { width: `${le}px` }], {
554
+ const j = ce.current;
555
+ if (!j) return;
556
+ const le = j.offsetWidth, Oe = J.current;
557
+ J.current = le, !(!ze || !Oe || Math.abs(Oe - le) < 0.5) && (window.matchMedia("(prefers-reduced-motion: reduce)").matches || j.animate([{ width: `${Oe}px` }, { width: `${le}px` }], {
558
558
  duration: 460,
559
559
  easing: "cubic-bezier(0.25, 1, 0.5, 1)"
560
560
  }));
561
561
  }, [p?.id]), se(() => {
562
- w === !1 && (D(!1), U(""), ae(Dt()), ue(""));
562
+ w === !1 && (O(!1), q(""), ae(Dt()), ue(""));
563
563
  }, [w]), se(() => {
564
564
  if (!g || w === !1) return;
565
- const E = u.split(/\s+/).filter(Boolean);
565
+ const j = u.split(/\s+/).filter(Boolean);
566
566
  let le = 0;
567
567
  const Oe = window.setInterval(() => {
568
- le = Math.min(E.length, le + 1), U(E.slice(0, le).join(" "));
568
+ le = Math.min(j.length, le + 1), q(j.slice(0, le).join(" "));
569
569
  }, 320), We = window.setInterval(() => {
570
- const Ha = le < E.length && Math.random() > 0.3 ? 0.3 + Math.random() * 0.7 : 0;
570
+ const Ha = le < j.length && Math.random() > 0.3 ? 0.3 + Math.random() * 0.7 : 0;
571
571
  ae((Wa) => [...Wa.slice(1), Ha]);
572
572
  }, 120);
573
573
  return () => {
@@ -575,41 +575,41 @@ function En({
575
575
  };
576
576
  }, [g, u, w]);
577
577
  const Vt = () => {
578
- a || w !== !1 && (h(null), U(""), ae(Dt()), D(!0), ue(O.recording));
579
- }, gt = (E) => {
580
- D(!1), E && R ? (oe((le) => le.trim() ? `${le.trimEnd()} ${R}` : R), ue(O.recordingAdded)) : ue(O.recordingDiscarded), U(""), _e.current?.focus();
578
+ a || w !== !1 && (h(null), q(""), ae(Dt()), O(!0), ue(D.recording));
579
+ }, gt = (j) => {
580
+ O(!1), j && R ? (oe((le) => le.trim() ? `${le.trimEnd()} ${R}` : R), ue(D.recordingAdded)) : ue(D.recordingDiscarded), q(""), _e.current?.focus();
581
581
  }, He = e && !!t, xt = !He && !a && !o && X.trim().length > 0, ie = () => {
582
- xt && (s?.(X.trim(), { model: p?.id ?? "" }), oe(""), ue(O.messageSent), _e.current?.focus());
583
- }, Le = (E) => {
584
- E.key === "Enter" && !E.shiftKey && !E.nativeEvent.isComposing && (E.preventDefault(), ie());
585
- }, Xe = (E) => {
586
- E.key === "Escape" && g && (E.preventDefault(), gt(!1));
587
- }, tt = (E) => {
588
- E.target.closest("button, textarea, input") || (E.preventDefault(), _e.current?.focus());
589
- }, nt = T.find((E) => E.id === ee) ?? T.find((E) => E.id === "ask"), wt = (E) => (le) => {
590
- h(null), le && E.current?.focus();
591
- }, Gt = B.map((E) => ({
592
- title: E.title,
582
+ xt && (s?.(X.trim(), { model: p?.id ?? "" }), oe(""), ue(D.messageSent), _e.current?.focus());
583
+ }, Le = (j) => {
584
+ j.key === "Enter" && !j.shiftKey && !j.nativeEvent.isComposing && (j.preventDefault(), ie());
585
+ }, Xe = (j) => {
586
+ j.key === "Escape" && g && (j.preventDefault(), gt(!1));
587
+ }, tt = (j) => {
588
+ j.target.closest("button, textarea, input") || (j.preventDefault(), _e.current?.focus());
589
+ }, nt = T.find((j) => j.id === ee) ?? T.find((j) => j.id === "ask"), wt = (j) => (le) => {
590
+ h(null), le && j.current?.focus();
591
+ }, Gt = B.map((j) => ({
592
+ title: j.title,
593
593
  // Without the tray, filter the replacement's ID (apps), not the original folder ID.
594
- rows: E.rows.flatMap((le) => {
595
- if (!P && le.id === "folder") {
596
- const Oe = j.find(() => !0);
594
+ rows: j.rows.flatMap((le) => {
595
+ if (!F && le.id === "folder") {
596
+ const Oe = z.find(() => !0);
597
597
  if (!Oe) return [];
598
598
  const We = Oe.Logo;
599
- return [{ id: "apps", label: O.connectApps, description: $.length ? O.connectedCount($.length) : void 0, icon: /* @__PURE__ */ i(We, {}) }];
599
+ return [{ id: "apps", label: D.connectApps, description: E.length ? D.connectedCount(E.length) : void 0, icon: /* @__PURE__ */ i(We, {}) }];
600
600
  }
601
601
  return [{
602
602
  id: le.id,
603
603
  label: le.label,
604
- description: le.id === "plan" && K ? O.planOffDescription : le.description,
604
+ description: le.id === "plan" && K ? D.planOffDescription : le.description,
605
605
  icon: /* @__PURE__ */ i(le.Icon, {}),
606
606
  checked: le.id === "plan" ? K : void 0
607
607
  }];
608
- }).filter((le) => v === void 0 || v.includes(le.id))
609
- })).filter((E) => E.rows.length > 0);
608
+ }).filter((le) => b === void 0 || b.includes(le.id))
609
+ })).filter((j) => j.rows.length > 0);
610
610
  return (
611
611
  // PrimeChatKit LOCAL ⑫ start
612
- /* @__PURE__ */ d("div", { className: "ui-ccc", "data-tray": P ? void 0 : "off", "data-disabled": a || void 0, children: [
612
+ /* @__PURE__ */ d("div", { className: "ui-ccc", "data-tray": F ? void 0 : "off", "data-disabled": a || void 0, children: [
613
613
  /* @__PURE__ */ i("style", { href: "ui-chat-composer-clean", precedence: "default", children: ao }),
614
614
  /* @__PURE__ */ d(
615
615
  "section",
@@ -618,7 +618,7 @@ function En({
618
618
  className: "ui-ccc__body",
619
619
  "data-recording": g,
620
620
  style: { "--ui-ccc-lines": he },
621
- "aria-label": O.composer,
621
+ "aria-label": D.composer,
622
622
  onKeyDown: Xe,
623
623
  children: [
624
624
  /* @__PURE__ */ d("div", { className: "ui-ccc__write", onPointerDown: tt, children: [
@@ -629,10 +629,10 @@ function En({
629
629
  ref: _e,
630
630
  className: "ui-ccc__message",
631
631
  value: X,
632
- onChange: (E) => oe(E.target.value),
632
+ onChange: (j) => oe(j.target.value),
633
633
  onKeyDown: Le,
634
- placeholder: n ?? O.placeholder,
635
- "aria-label": O.message,
634
+ placeholder: n ?? D.placeholder,
635
+ "aria-label": D.message,
636
636
  spellCheck: !1,
637
637
  readOnly: g,
638
638
  disabled: a,
@@ -653,12 +653,12 @@ function En({
653
653
  ref: pe,
654
654
  type: "button",
655
655
  className: "ui-ccc__icon-btn",
656
- "aria-label": O.add,
656
+ "aria-label": D.add,
657
657
  "aria-haspopup": _ ? void 0 : "menu",
658
- "aria-expanded": _ ? void 0 : C === "add",
658
+ "aria-expanded": _ ? void 0 : N === "add",
659
659
  disabled: a || !_ && Gt.length === 0,
660
- onClick: _ ?? (() => N("add")),
661
- onKeyDown: _ ? void 0 : G("add"),
660
+ onClick: _ ?? (() => I("add")),
661
+ onKeyDown: _ ? void 0 : Q("add"),
662
662
  children: /* @__PURE__ */ i(Rn, {})
663
663
  }
664
664
  ),
@@ -670,10 +670,10 @@ function En({
670
670
  className: "ui-ccc__approval",
671
671
  "data-tone": nt.tone,
672
672
  "aria-haspopup": "listbox",
673
- "aria-expanded": C === "approval",
674
- onClick: () => N("approval"),
675
- onKeyDown: G("approval"),
676
- children: /* @__PURE__ */ d("span", { className: "ui-ccc__approval-face", "data-morph": H || void 0, children: [
673
+ "aria-expanded": N === "approval",
674
+ onClick: () => I("approval"),
675
+ onKeyDown: Q("approval"),
676
+ children: /* @__PURE__ */ d("span", { className: "ui-ccc__approval-face", "data-morph": W || void 0, children: [
677
677
  /* @__PURE__ */ i("span", { className: "ui-ccc__approval-icon", "aria-hidden": "true", children: /* @__PURE__ */ i(nt.Icon, {}) }),
678
678
  /* @__PURE__ */ i("span", { className: "ui-ccc__approval-text", children: nt.label })
679
679
  ] }, nt.id)
@@ -689,9 +689,9 @@ function En({
689
689
  type: "button",
690
690
  className: "ui-ccc__model",
691
691
  "aria-haspopup": "listbox",
692
- "aria-expanded": C === "model",
693
- onClick: () => N("model"),
694
- onKeyDown: G("model"),
692
+ "aria-expanded": N === "model",
693
+ onClick: () => I("model"),
694
+ onKeyDown: Q("model"),
695
695
  children: [
696
696
  /* @__PURE__ */ d("span", { className: "ui-ccc__model-face", "data-morph": ze || void 0, children: [
697
697
  p.Logo && p.id !== "auto" && /* @__PURE__ */ i("span", { className: "ui-ccc__model-logo", "aria-hidden": "true", children: /* @__PURE__ */ i(p.Logo, {}) }),
@@ -701,18 +701,18 @@ function En({
701
701
  ]
702
702
  }
703
703
  ),
704
- w !== !1 && /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__icon-btn", "aria-label": O.voiceInput, onClick: Vt, disabled: a, children: /* @__PURE__ */ i(Vn, {}) }),
705
- /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__send", "data-stop": He || void 0, "aria-label": He ? O.stop : O.sendMessage, disabled: !He && !xt, onClick: He ? t : ie, children: He ? /* @__PURE__ */ i(Qn, {}) : /* @__PURE__ */ i(Zn, {}) })
704
+ w !== !1 && /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__icon-btn", "aria-label": D.voiceInput, onClick: Vt, disabled: a, children: /* @__PURE__ */ i(Vn, {}) }),
705
+ /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__send", "data-stop": He || void 0, "aria-label": He ? D.stop : D.sendMessage, disabled: !He && !xt, onClick: He ? t : ie, children: He ? /* @__PURE__ */ i(Qn, {}) : /* @__PURE__ */ i(Zn, {}) })
706
706
  ] }),
707
707
  w !== !1 && /* @__PURE__ */ d("div", { className: "ui-ccc__group ui-ccc__group--end ui-ccc__group--voice", inert: !g, children: [
708
- /* @__PURE__ */ i("span", { className: "ui-ccc__trace", "aria-hidden": "true", children: S.map((E, le) => /* @__PURE__ */ i("span", { style: { height: Math.max(2, E * 16) } }, le)) }),
709
- /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__button", "aria-label": O.discardRecording, onClick: () => gt(!1), children: /* @__PURE__ */ i(io, {}) }),
710
- /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__send", "aria-label": O.useRecording, onClick: () => gt(!0), children: /* @__PURE__ */ i(Ma, {}) })
708
+ /* @__PURE__ */ i("span", { className: "ui-ccc__trace", "aria-hidden": "true", children: $.map((j, le) => /* @__PURE__ */ i("span", { style: { height: Math.max(2, j * 16) } }, le)) }),
709
+ /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__button", "aria-label": D.discardRecording, onClick: () => gt(!1), children: /* @__PURE__ */ i(io, {}) }),
710
+ /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__send", "aria-label": D.useRecording, onClick: () => gt(!0), children: /* @__PURE__ */ i(Ma, {}) })
711
711
  ] })
712
712
  ] })
713
713
  ] })
714
714
  ] }),
715
- P ? F ? /* @__PURE__ */ i("div", { className: "ui-ccc__foot", "data-custom": "", children: F }) : /* @__PURE__ */ d("div", { className: "ui-ccc__foot", children: [
715
+ F ? P ? /* @__PURE__ */ i("div", { className: "ui-ccc__foot", "data-custom": "", children: P }) : /* @__PURE__ */ d("div", { className: "ui-ccc__foot", children: [
716
716
  f.length > 0 && /* @__PURE__ */ d(
717
717
  "button",
718
718
  {
@@ -720,28 +720,28 @@ function En({
720
720
  type: "button",
721
721
  className: "ui-ccc__row ui-ccc__row--folder",
722
722
  "aria-haspopup": "listbox",
723
- "aria-expanded": C === "folder",
724
- onClick: () => N("folder"),
725
- onKeyDown: G("folder"),
723
+ "aria-expanded": N === "folder",
724
+ onClick: () => I("folder"),
725
+ onKeyDown: Q("folder"),
726
726
  children: [
727
727
  /* @__PURE__ */ i("span", { className: "ui-ccc__folder", "aria-hidden": "true", children: /* @__PURE__ */ i(Kn, {}) }),
728
- /* @__PURE__ */ i("span", { className: "ui-ccc__row-label", title: re ?? void 0, dir: "auto", children: re ?? O.workInFolder })
728
+ /* @__PURE__ */ i("span", { className: "ui-ccc__row-label", title: re ?? void 0, dir: "auto", children: re ?? D.workInFolder })
729
729
  ]
730
730
  }
731
731
  ),
732
- j.length > 0 && /* @__PURE__ */ d(
732
+ z.length > 0 && /* @__PURE__ */ d(
733
733
  "button",
734
734
  {
735
735
  ref: Ce,
736
736
  type: "button",
737
737
  className: "ui-ccc__row ui-ccc__row--apps",
738
738
  "aria-haspopup": "menu",
739
- "aria-expanded": C === "apps",
740
- onClick: () => N("apps"),
741
- onKeyDown: G("apps"),
739
+ "aria-expanded": N === "apps",
740
+ onClick: () => I("apps"),
741
+ onKeyDown: Q("apps"),
742
742
  children: [
743
- O.connectApps,
744
- /* @__PURE__ */ i("span", { className: "ui-ccc__logos", "aria-hidden": "true", children: j.slice(0, 3).map((E) => /* @__PURE__ */ i("span", { className: "ui-ccc__logo", children: /* @__PURE__ */ i(E.Logo, {}) }, E.id)) })
743
+ D.connectApps,
744
+ /* @__PURE__ */ i("span", { className: "ui-ccc__logos", "aria-hidden": "true", children: z.slice(0, 3).map((j) => /* @__PURE__ */ i("span", { className: "ui-ccc__logo", children: /* @__PURE__ */ i(j.Logo, {}) }, j.id)) })
745
745
  ]
746
746
  }
747
747
  )
@@ -749,9 +749,9 @@ function En({
749
749
  !_ && !a && Gt.length > 0 && /* @__PURE__ */ i(
750
750
  yt,
751
751
  {
752
- open: C === "add",
752
+ open: N === "add",
753
753
  role: "menu",
754
- label: O.addToChat,
754
+ label: D.addToChat,
755
755
  inline: !0,
756
756
  wide: !0,
757
757
  sections: Gt,
@@ -764,58 +764,58 @@ function En({
764
764
  m !== !1 && /* @__PURE__ */ i(
765
765
  yt,
766
766
  {
767
- open: C === "approval",
768
- label: O.approvalQuestion,
767
+ open: N === "approval",
768
+ label: D.approvalQuestion,
769
769
  head: /* @__PURE__ */ d(Me, { children: [
770
- /* @__PURE__ */ i("span", { children: O.approvalQuestion }),
771
- /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__menu-link", onClick: y, children: O.learnMore })
770
+ /* @__PURE__ */ i("span", { children: D.approvalQuestion }),
771
+ /* @__PURE__ */ i("button", { type: "button", className: "ui-ccc__menu-link", onClick: v, children: D.learnMore })
772
772
  ] }),
773
773
  width: 468,
774
774
  align: "start",
775
- sections: [{ rows: T.map((E) => ({ id: E.id, label: E.label, description: E.description, icon: /* @__PURE__ */ i(E.Icon, {}), tone: E.tone, checked: E.id === ee })) }],
775
+ sections: [{ rows: T.map((j) => ({ id: j.id, label: j.label, description: j.description, icon: /* @__PURE__ */ i(j.Icon, {}), tone: j.tone, checked: j.id === ee })) }],
776
776
  anchor: xe,
777
777
  container: ge,
778
- onPick: (E) => Tt(E),
778
+ onPick: (j) => Tt(j),
779
779
  onClose: wt(xe)
780
780
  }
781
781
  ),
782
782
  p && /* @__PURE__ */ i(
783
783
  yt,
784
784
  {
785
- open: C === "model",
786
- label: O.selectModel,
787
- sections: [{ rows: c.map((E) => ({ id: E.id, label: E.name, description: E.description, icon: E.Logo && /* @__PURE__ */ i(E.Logo, {}), checked: E.id === p.id })) }],
785
+ open: N === "model",
786
+ label: D.selectModel,
787
+ sections: [{ rows: c.map((j) => ({ id: j.id, label: j.name, description: j.description, icon: j.Logo && /* @__PURE__ */ i(j.Logo, {}), checked: j.id === p.id })) }],
788
788
  anchor: ce,
789
789
  container: ge,
790
- onPick: (E) => ft(c.find((le) => le.id === E) ?? p),
790
+ onPick: (j) => ft(c.find((le) => le.id === j) ?? p),
791
791
  onClose: wt(ce)
792
792
  }
793
793
  ),
794
- P && !F && f.length > 0 && /* @__PURE__ */ i(
794
+ F && !P && f.length > 0 && /* @__PURE__ */ i(
795
795
  yt,
796
796
  {
797
- open: C === "folder",
798
- label: O.workInFolder,
797
+ open: N === "folder",
798
+ label: D.workInFolder,
799
799
  align: "start",
800
- sections: [{ title: O.workInFolder, rows: f.map((E) => ({ id: E, label: E, icon: /* @__PURE__ */ i(ka, {}), checked: E === re })) }],
800
+ sections: [{ title: D.workInFolder, rows: f.map((j) => ({ id: j, label: j, icon: /* @__PURE__ */ i(ka, {}), checked: j === re })) }],
801
801
  anchor: ve,
802
802
  container: ge,
803
803
  onPick: It,
804
804
  onClose: wt(ve)
805
805
  }
806
806
  ),
807
- (!P || !F) && j.length > 0 && /* @__PURE__ */ i(
807
+ (!F || !P) && z.length > 0 && /* @__PURE__ */ i(
808
808
  yt,
809
809
  {
810
- open: C === "apps",
810
+ open: N === "apps",
811
811
  role: "menu",
812
- label: O.apps,
813
- align: P ? void 0 : "start",
814
- sections: [{ title: O.apps, rows: j.map((E) => ({ id: E.id, label: E.name, icon: /* @__PURE__ */ i(E.Logo, {}), checked: $.includes(E.id) })) }],
815
- anchor: P ? Ce : pe,
812
+ label: D.apps,
813
+ align: F ? void 0 : "start",
814
+ sections: [{ title: D.apps, rows: z.map((j) => ({ id: j.id, label: j.name, icon: /* @__PURE__ */ i(j.Logo, {}), checked: E.includes(j.id) })) }],
815
+ anchor: F ? Ce : pe,
816
816
  container: ge,
817
817
  onPick: Lt,
818
- onClose: wt(P ? Ce : pe)
818
+ onClose: wt(F ? Ce : pe)
819
819
  }
820
820
  )
821
821
  ]
@@ -848,12 +848,12 @@ function yt({
848
848
  wide: l = !1,
849
849
  inline: x = !1,
850
850
  onPick: _,
851
- onClose: v
851
+ onClose: b
852
852
  }) {
853
- const w = qe(), m = q(null), k = q([]), y = a.flatMap((W) => W.rows), [f, b] = I(0), [M, j] = I({ top: 0, left: 0, width: s, up: !0, fromTop: 0, fromLeft: 0, fromRadius: 0 }), [V, L] = I({ y: 0, h: 0, glide: !1 }), [F, P] = I(!1), O = q(!1), [T, B] = I(!1), [ee, z] = I(!1), [H, Z] = I(!1), K = () => {
854
- const W = m.current;
855
- W && Z(W.scrollTop + W.clientHeight < W.scrollHeight - 2);
856
- }, [te, X] = I(!0);
853
+ const w = qe(), m = U(null), k = U([]), v = a.flatMap((Y) => Y.rows), [f, y] = A(0), [L, z] = A({ top: 0, left: 0, width: s, up: !0, fromTop: 0, fromLeft: 0, fromRadius: 0 }), [H, C] = A({ y: 0, h: 0, glide: !1 }), [P, F] = A(!1), D = U(!1), [T, B] = A(!1), [ee, M] = A(!1), [W, Z] = A(!1), K = () => {
854
+ const Y = m.current;
855
+ Y && Z(Y.scrollTop + Y.clientHeight < Y.scrollHeight - 2);
856
+ }, [te, X] = A(!0);
857
857
  ke(() => {
858
858
  if (!e) {
859
859
  B(!1);
@@ -865,41 +865,41 @@ function yt({
865
865
  return;
866
866
  }
867
867
  if (!r.current || !c.current || !m.current) return;
868
- const W = r.current.getBoundingClientRect(), $ = c.current.getBoundingClientRect(), Y = jn(c.current), p = $.width / (c.current.offsetWidth || $.width) || 1, A = Math.min(l ? c.current.offsetWidth : s, (Y.right - Y.left) / p - 16);
869
- m.current.style.width = `${A}px`, m.current.style.maxHeight = "";
870
- const C = A * p, h = m.current.offsetHeight * p, N = 8 * p, G = l ? -6 * p : 0, g = 8 * p, D = l ? $ : W, R = D.top + G - (Y.top + g), U = Y.bottom - g - (D.bottom + N), S = l ? R >= Math.min(h, 160 * p) || R >= U : R >= h || R >= U, ae = Math.min(h, Math.max(0, S ? R : U)), fe = (he, Q, ce) => Math.max(Q, Math.min(he, ce)), ue = fe(S ? D.top + G - ae : D.bottom + N, Y.top + g, Y.bottom - g - ae), ge = fe(l ? $.left : u === "start" ? W.left : W.right - C, Y.left + g, Y.right - g - C), _e = fe(W.left - ge, 0, C - 1) / p, we = (S ? fe(ae - W.height, 0, ae - 1) : 0) / p;
871
- m.current.style.maxHeight = `${ae / p}px`, j({ top: (ue - $.top) / p, left: (ge - $.left) / p, width: A, up: S, fromTop: we, fromLeft: _e, fromRadius: 6 }), b(Math.max(0, y.findIndex((he) => he.checked))), P(!1), z(!0);
868
+ const Y = r.current.getBoundingClientRect(), E = c.current.getBoundingClientRect(), V = jn(c.current), p = E.width / (c.current.offsetWidth || E.width) || 1, S = Math.min(l ? c.current.offsetWidth : s, (V.right - V.left) / p - 16);
869
+ m.current.style.width = `${S}px`, m.current.style.maxHeight = "";
870
+ const N = S * p, h = m.current.offsetHeight * p, I = 8 * p, Q = l ? -6 * p : 0, g = 8 * p, O = l ? E : Y, R = O.top + Q - (V.top + g), q = V.bottom - g - (O.bottom + I), $ = l ? R >= Math.min(h, 160 * p) || R >= q : R >= h || R >= q, ae = Math.min(h, Math.max(0, $ ? R : q)), fe = (he, G, ce) => Math.max(G, Math.min(he, ce)), ue = fe($ ? O.top + Q - ae : O.bottom + I, V.top + g, V.bottom - g - ae), ge = fe(l ? E.left : u === "start" ? Y.left : Y.right - N, V.left + g, V.right - g - N), _e = fe(Y.left - ge, 0, N - 1) / p, we = ($ ? fe(ae - Y.height, 0, ae - 1) : 0) / p;
871
+ m.current.style.maxHeight = `${ae / p}px`, z({ top: (ue - E.top) / p, left: (ge - E.left) / p, width: S, up: $, fromTop: we, fromLeft: _e, fromRadius: 6 }), y(Math.max(0, v.findIndex((he) => he.checked))), F(!1), M(!0);
872
872
  }, [e, te]), ke(() => {
873
- !e || T || !m.current || (getComputedStyle(m.current).clipPath, z(!1), B(!0));
874
- }, [M]), se(() => {
875
- T && (m.current?.focus({ preventScroll: !0 }), m.current?.matches(":focus-visible") && P(!0)), K();
873
+ !e || T || !m.current || (getComputedStyle(m.current).clipPath, M(!1), B(!0));
874
+ }, [L]), se(() => {
875
+ T && (m.current?.focus({ preventScroll: !0 }), m.current?.matches(":focus-visible") && F(!0)), K();
876
876
  }, [T]), ke(() => {
877
- const W = k.current[f];
878
- W && L({ y: W.offsetTop, h: W.offsetHeight, glide: O.current && F });
879
- const $ = m.current;
880
- W && $ && e && (W.offsetTop < $.scrollTop ? $.scrollTop = W.offsetTop - 4 : W.offsetTop + W.offsetHeight > $.scrollTop + $.clientHeight && ($.scrollTop = W.offsetTop + W.offsetHeight - $.clientHeight + 4)), O.current = F;
881
- }, [f, e, F]), se(() => {
877
+ const Y = k.current[f];
878
+ Y && C({ y: Y.offsetTop, h: Y.offsetHeight, glide: D.current && P });
879
+ const E = m.current;
880
+ Y && E && e && (Y.offsetTop < E.scrollTop ? E.scrollTop = Y.offsetTop - 4 : Y.offsetTop + Y.offsetHeight > E.scrollTop + E.clientHeight && (E.scrollTop = Y.offsetTop + Y.offsetHeight - E.clientHeight + 4)), D.current = P;
881
+ }, [f, e, P]), se(() => {
882
882
  if (!e) return;
883
- const W = ($) => {
884
- const Y = $.target;
885
- m.current?.contains(Y) || r.current?.contains(Y) || v(!1);
883
+ const Y = (E) => {
884
+ const V = E.target;
885
+ m.current?.contains(V) || r.current?.contains(V) || b(!1);
886
886
  };
887
- return document.addEventListener("pointerdown", W), () => document.removeEventListener("pointerdown", W);
888
- }, [e, v, r]);
889
- const oe = (W) => {
890
- const $ = W.target === m.current, Y = m.current?.querySelector(".ui-ccc__menu-head :is(a, button)");
891
- if (W.key === "Tab" && Y && $ !== W.shiftKey) {
892
- W.preventDefault(), ($ ? Y : m.current)?.focus({ preventScroll: !0 });
887
+ return document.addEventListener("pointerdown", Y), () => document.removeEventListener("pointerdown", Y);
888
+ }, [e, b, r]);
889
+ const oe = (Y) => {
890
+ const E = Y.target === m.current, V = m.current?.querySelector(".ui-ccc__menu-head :is(a, button)");
891
+ if (Y.key === "Tab" && V && E !== Y.shiftKey) {
892
+ Y.preventDefault(), (E ? V : m.current)?.focus({ preventScroll: !0 });
893
893
  return;
894
894
  }
895
- if (!$ && W.key !== "Tab" && W.key !== "Escape") return;
896
- const p = y.length - 1, A = {
895
+ if (!E && Y.key !== "Tab" && Y.key !== "Escape") return;
896
+ const p = v.length - 1, S = {
897
897
  ArrowDown: Math.min(p, f + 1),
898
898
  ArrowUp: Math.max(0, f - 1),
899
899
  Home: 0,
900
900
  End: p
901
901
  };
902
- W.key in A ? (W.preventDefault(), b(A[W.key]), P(!0)) : W.key === "Enter" || W.key === " " ? (W.preventDefault(), _(y[f].id)) : W.key === "Escape" ? (W.preventDefault(), W.stopPropagation(), v(!0)) : W.key === "Tab" && (r.current?.focus({ preventScroll: !0 }), v(!1));
902
+ Y.key in S ? (Y.preventDefault(), y(S[Y.key]), F(!0)) : Y.key === "Enter" || Y.key === " " ? (Y.preventDefault(), _(v[f].id)) : Y.key === "Escape" ? (Y.preventDefault(), Y.stopPropagation(), b(!0)) : Y.key === "Tab" && (r.current?.focus({ preventScroll: !0 }), b(!1));
903
903
  };
904
904
  let re = -1;
905
905
  return /* @__PURE__ */ i(
@@ -908,18 +908,18 @@ function yt({
908
908
  className: "ui-ccc__menu",
909
909
  "data-open": T,
910
910
  "data-placing": ee,
911
- "data-up": M.up,
911
+ "data-up": L.up,
912
912
  "data-inline": x || void 0,
913
- "data-above": l && M.up || void 0,
913
+ "data-above": l && L.up || void 0,
914
914
  style: {
915
915
  display: te ? "none" : void 0,
916
- top: M.top,
917
- left: M.left,
918
- width: M.width,
919
- "--from-top": `${M.fromTop}px`,
920
- "--from-left": `${M.fromLeft}px`,
921
- "--from-bottom": M.up ? "0px" : `calc(100% - ${M.fromRadius * 2}px)`,
922
- "--from-radius": `${M.fromRadius}px`
916
+ top: L.top,
917
+ left: L.left,
918
+ width: L.width,
919
+ "--from-top": `${L.fromTop}px`,
920
+ "--from-left": `${L.fromLeft}px`,
921
+ "--from-bottom": L.up ? "0px" : `calc(100% - ${L.fromRadius * 2}px)`,
922
+ "--from-radius": `${L.fromRadius}px`
923
923
  },
924
924
  inert: !T,
925
925
  children: /* @__PURE__ */ d(
@@ -932,54 +932,54 @@ function yt({
932
932
  "aria-label": o,
933
933
  "aria-activedescendant": `${w}-${f}`,
934
934
  onKeyDown: oe,
935
- onPointerLeave: () => P(!1),
935
+ onPointerLeave: () => F(!1),
936
936
  onScroll: K,
937
- "data-more": H || void 0,
937
+ "data-more": W || void 0,
938
938
  children: [
939
939
  /* @__PURE__ */ i(
940
940
  "span",
941
941
  {
942
942
  className: "ui-ccc__menu-fill",
943
943
  "aria-hidden": "true",
944
- "data-glide": V.glide,
945
- style: { transform: `translateY(${V.y}px)`, height: V.h, opacity: F ? 1 : 0 }
944
+ "data-glide": H.glide,
945
+ style: { transform: `translateY(${H.y}px)`, height: H.h, opacity: P ? 1 : 0 }
946
946
  }
947
947
  ),
948
948
  n && /* @__PURE__ */ i("div", { className: "ui-ccc__menu-head", children: n }),
949
- a.map((W, $) => /* @__PURE__ */ d("div", { className: "ui-ccc__menu-section", role: "group", "aria-label": W.title, children: [
950
- W.title && /* @__PURE__ */ i("div", { className: "ui-ccc__menu-title", "aria-hidden": "true", children: W.title }),
951
- W.rows.map((Y) => {
949
+ a.map((Y, E) => /* @__PURE__ */ d("div", { className: "ui-ccc__menu-section", role: "group", "aria-label": Y.title, children: [
950
+ Y.title && /* @__PURE__ */ i("div", { className: "ui-ccc__menu-title", "aria-hidden": "true", children: Y.title }),
951
+ Y.rows.map((V) => {
952
952
  const p = ++re;
953
953
  return /* @__PURE__ */ d(
954
954
  "div",
955
955
  {
956
- ref: (A) => {
957
- k.current[p] = A;
956
+ ref: (S) => {
957
+ k.current[p] = S;
958
958
  },
959
959
  id: `${w}-${p}`,
960
- role: t === "listbox" ? "option" : Y.checked === void 0 ? "menuitem" : "menuitemcheckbox",
961
- "aria-selected": t === "listbox" ? !!Y.checked : void 0,
962
- "aria-checked": t === "menu" && Y.checked !== void 0 ? Y.checked : void 0,
963
- "data-checked": Y.checked || void 0,
964
- "data-tone": Y.tone,
960
+ role: t === "listbox" ? "option" : V.checked === void 0 ? "menuitem" : "menuitemcheckbox",
961
+ "aria-selected": t === "listbox" ? !!V.checked : void 0,
962
+ "aria-checked": t === "menu" && V.checked !== void 0 ? V.checked : void 0,
963
+ "data-checked": V.checked || void 0,
964
+ "data-tone": V.tone,
965
965
  className: "ui-ccc__option",
966
966
  onPointerEnter: () => {
967
- b(p), P(!0);
967
+ y(p), F(!0);
968
968
  },
969
- onClick: () => _(Y.id),
969
+ onClick: () => _(V.id),
970
970
  children: [
971
- /* @__PURE__ */ i("span", { className: "ui-ccc__option-logo", "aria-hidden": "true", children: Y.icon }),
971
+ /* @__PURE__ */ i("span", { className: "ui-ccc__option-logo", "aria-hidden": "true", children: V.icon }),
972
972
  /* @__PURE__ */ d("span", { className: "ui-ccc__option-text", children: [
973
- /* @__PURE__ */ i("span", { className: "ui-ccc__option-name", title: Y.label, dir: "auto", children: Y.label }),
974
- Y.description && /* @__PURE__ */ i("span", { className: "ui-ccc__option-desc", dir: "auto", children: Y.description })
973
+ /* @__PURE__ */ i("span", { className: "ui-ccc__option-name", title: V.label, dir: "auto", children: V.label }),
974
+ V.description && /* @__PURE__ */ i("span", { className: "ui-ccc__option-desc", dir: "auto", children: V.description })
975
975
  ] }),
976
976
  /* @__PURE__ */ i("span", { className: "ui-ccc__option-check", "aria-hidden": "true", children: /* @__PURE__ */ i(Ma, {}) })
977
977
  ]
978
978
  },
979
- Y.id
979
+ V.id
980
980
  );
981
981
  })
982
- ] }, $))
982
+ ] }, E))
983
983
  ]
984
984
  }
985
985
  )
@@ -1752,27 +1752,27 @@ function oo({
1752
1752
  onApprove: l,
1753
1753
  onDeny: x,
1754
1754
  onEdit: _,
1755
- expiresIn: v,
1755
+ expiresIn: b,
1756
1756
  onExpire: w,
1757
1757
  allowAlways: m = !0,
1758
1758
  alwaysLabel: k = "Always allow this action",
1759
- approveLabel: y = "Approve",
1759
+ approveLabel: v = "Approve",
1760
1760
  denyLabel: f = "Deny",
1761
- editLabel: b = "Edit",
1762
- shortcuts: M = !0,
1763
- label: j,
1764
- actions: V = "card",
1765
- className: L
1761
+ editLabel: y = "Edit",
1762
+ shortcuts: L = !0,
1763
+ label: z,
1764
+ actions: H = "card",
1765
+ className: C
1766
1766
  }) {
1767
- const F = qe(), [P, O] = I(s), T = u ?? P, B = T !== "pending", [ee, z] = I(!1), [H, Z] = I(!1), [K, te] = I("user"), [X, oe] = I(() => B ? Date.now() : null), [re, W] = I(""), [$, Y] = I(!1), [p, A] = I(!1), [C, h] = I("⌘"), [N, G] = I(T), [g, D] = I(!1), [R, U] = I(!1);
1768
- N !== T && (G(T), T === "pending" ? (D(!1), U(!0), z(!1), Z(!1), te("user"), oe(null), W("")) : (D(N === "pending"), U(!1), oe(Date.now()), W(`${T === "approved" ? "Approved" : K === "timeout" ? "Expired" : "Denied"}: ${e}`)));
1769
- const S = q(null), ae = q(null), fe = q(null), ue = q(!1);
1767
+ const P = qe(), [F, D] = A(s), T = u ?? F, B = T !== "pending", [ee, M] = A(!1), [W, Z] = A(!1), [K, te] = A("user"), [X, oe] = A(() => B ? Date.now() : null), [re, Y] = A(""), [E, V] = A(!1), [p, S] = A(!1), [N, h] = A("⌘"), [I, Q] = A(T), [g, O] = A(!1), [R, q] = A(!1);
1768
+ I !== T && (Q(T), T === "pending" ? (O(!1), q(!0), M(!1), Z(!1), te("user"), oe(null), Y("")) : (O(I === "pending"), q(!1), oe(Date.now()), Y(`${T === "approved" ? "Approved" : K === "timeout" ? "Expired" : "Denied"}: ${e}`)));
1769
+ const $ = U(null), ae = U(null), fe = U(null), ue = U(!1);
1770
1770
  se(() => {
1771
1771
  const ie = navigator.userAgentData?.platform ?? navigator.platform ?? "";
1772
1772
  /mac|iphone|ipad|ipod/i.test(ie || navigator.userAgent) || h("Ctrl");
1773
1773
  }, []);
1774
1774
  const ge = async () => {
1775
- if (B || H) return;
1775
+ if (B || W) return;
1776
1776
  const ie = l?.({ always: ee });
1777
1777
  if (ie && typeof ie.then == "function") {
1778
1778
  Z(!0);
@@ -1784,24 +1784,24 @@ function oo({
1784
1784
  }
1785
1785
  Z(!1);
1786
1786
  }
1787
- u === void 0 && O("approved");
1787
+ u === void 0 && D("approved");
1788
1788
  }, _e = (ie = "user") => {
1789
- B || H && ie === "user" || (te(ie), ie === "timeout" && w?.(), x?.({ reason: ie }), u === void 0 && O("denied"));
1789
+ B || W && ie === "user" || (te(ie), ie === "timeout" && w?.(), x?.({ reason: ie }), u === void 0 && D("denied"));
1790
1790
  }, we = (ie) => {
1791
- B || H || ie.defaultPrevented || (ie.key === "Enter" && (ie.metaKey || ie.ctrlKey) ? (ie.preventDefault(), ge()) : ie.key === "Escape" && (ie.preventDefault(), _e("user")));
1792
- }, he = typeof v == "number" && Number.isFinite(v) && v > 0 ? v * 1e3 : 0, Q = q(he), [ce, xe] = I(Math.ceil(he / 1e3)), pe = q(() => {
1791
+ B || W || ie.defaultPrevented || (ie.key === "Enter" && (ie.metaKey || ie.ctrlKey) ? (ie.preventDefault(), ge()) : ie.key === "Escape" && (ie.preventDefault(), _e("user")));
1792
+ }, he = typeof b == "number" && Number.isFinite(b) && b > 0 ? b * 1e3 : 0, G = U(he), [ce, xe] = A(Math.ceil(he / 1e3)), pe = U(() => {
1793
1793
  });
1794
1794
  ke(() => {
1795
1795
  pe.current = () => _e("timeout");
1796
1796
  }), se(() => {
1797
- T === "pending" && (Q.current = he, xe(Math.ceil(he / 1e3)));
1797
+ T === "pending" && (G.current = he, xe(Math.ceil(he / 1e3)));
1798
1798
  }, [T, he]);
1799
- const ve = $ || p || H;
1799
+ const ve = E || p || W;
1800
1800
  se(() => {
1801
1801
  if (!he || B || ve) return;
1802
1802
  let ie = performance.now(), Le = 0;
1803
1803
  const Xe = (tt) => {
1804
- if (Q.current -= tt - ie, ie = tt, xe(Math.max(0, Math.ceil(Q.current / 1e3))), Q.current <= 0) {
1804
+ if (G.current -= tt - ie, ie = tt, xe(Math.max(0, Math.ceil(G.current / 1e3))), G.current <= 0) {
1805
1805
  pe.current();
1806
1806
  return;
1807
1807
  }
@@ -1809,16 +1809,16 @@ function oo({
1809
1809
  };
1810
1810
  return Le = requestAnimationFrame(Xe), () => cancelAnimationFrame(Le);
1811
1811
  }, [he, B, ve]);
1812
- const Ce = q(0), J = q(!1), ze = q(!1);
1812
+ const Ce = U(0), J = U(!1), ze = U(!1);
1813
1813
  se(() => {
1814
- const ie = S.current;
1814
+ const ie = $.current;
1815
1815
  if (!ie || typeof ResizeObserver > "u") return;
1816
1816
  const Le = new ResizeObserver(() => {
1817
1817
  J.current || (Ce.current = ie.offsetHeight);
1818
1818
  });
1819
1819
  return Le.observe(ie), () => Le.disconnect();
1820
1820
  }, []), ke(() => {
1821
- const ie = S.current;
1821
+ const ie = $.current;
1822
1822
  if (!ie) return;
1823
1823
  if (!ze.current) {
1824
1824
  ze.current = !0, Ce.current = ie.offsetHeight;
@@ -1838,20 +1838,20 @@ function oo({
1838
1838
  window.clearTimeout(nt), ie.style.height = "", J.current = !1;
1839
1839
  };
1840
1840
  }, [B]);
1841
- const [, Yt] = I(0);
1841
+ const [, Yt] = A(0);
1842
1842
  se(() => {
1843
1843
  if (!B) return;
1844
1844
  const ie = window.setInterval(() => Yt((Le) => Le + 1), 3e4);
1845
1845
  return () => window.clearInterval(ie);
1846
1846
  }, [B]);
1847
- const It = `${F}-title`, Lt = `${F}-row`, Tt = `${F}-desc`, At = `${F}-timer`, ft = r ?? c, Vt = T === "approved" ? "Approved" : K === "timeout" ? "Expired" : "Denied", gt = [t ? Tt : null, he && !B ? At : null].filter(Boolean).join(" "), He = m && /* @__PURE__ */ d("label", { className: "ui-apc__always", children: [
1847
+ const It = `${P}-title`, Lt = `${P}-row`, Tt = `${P}-desc`, At = `${P}-timer`, ft = r ?? c, Vt = T === "approved" ? "Approved" : K === "timeout" ? "Expired" : "Denied", gt = [t ? Tt : null, he && !B ? At : null].filter(Boolean).join(" "), He = m && /* @__PURE__ */ d("label", { className: "ui-apc__always", children: [
1848
1848
  /* @__PURE__ */ d("span", { className: "ui-apc__box", children: [
1849
- /* @__PURE__ */ i("input", { type: "checkbox", checked: ee, disabled: H, onChange: (ie) => z(ie.target.checked) }),
1849
+ /* @__PURE__ */ i("input", { type: "checkbox", checked: ee, disabled: W, onChange: (ie) => M(ie.target.checked) }),
1850
1850
  /* @__PURE__ */ i("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ i("path", { d: "M4 8.3 6.8 11 12 5.2" }) })
1851
1851
  ] }),
1852
1852
  /* @__PURE__ */ i("span", { className: "ui-apc__always-label", children: k })
1853
1853
  ] }), xt = /* @__PURE__ */ d("div", { className: "ui-apc__foot", children: [
1854
- V === "card" && He,
1854
+ H === "card" && He,
1855
1855
  he > 0 && /* @__PURE__ */ d("span", { className: "ui-apc__expires", "data-paused": ve || void 0, "data-low": ce <= 10 || void 0, "aria-hidden": "true", children: [
1856
1856
  /* @__PURE__ */ d("svg", { viewBox: "0 0 16 16", children: [
1857
1857
  /* @__PURE__ */ i("circle", { cx: "8", cy: "8", r: "6" }),
@@ -1866,9 +1866,9 @@ function oo({
1866
1866
  {
1867
1867
  type: "button",
1868
1868
  className: "ui-apc__btn ui-apc__btn--ghost",
1869
- "aria-disabled": H || void 0,
1870
- onClick: () => !H && _(),
1871
- children: b
1869
+ "aria-disabled": W || void 0,
1870
+ onClick: () => !W && _(),
1871
+ children: y
1872
1872
  }
1873
1873
  ),
1874
1874
  /* @__PURE__ */ d(
@@ -1877,11 +1877,11 @@ function oo({
1877
1877
  type: "button",
1878
1878
  className: "ui-apc__btn ui-apc__btn--quiet ui-apc__deny",
1879
1879
  "aria-keyshortcuts": "Escape",
1880
- "aria-disabled": H || void 0,
1880
+ "aria-disabled": W || void 0,
1881
1881
  onClick: () => _e("user"),
1882
1882
  children: [
1883
1883
  f,
1884
- M && /* @__PURE__ */ i("kbd", { className: "ui-apc__kbd", "aria-hidden": "true", children: "Esc" })
1884
+ L && /* @__PURE__ */ i("kbd", { className: "ui-apc__kbd", "aria-hidden": "true", children: "Esc" })
1885
1885
  ]
1886
1886
  }
1887
1887
  ),
@@ -1892,13 +1892,13 @@ function oo({
1892
1892
  type: "button",
1893
1893
  className: "ui-apc__btn ui-apc__btn--primary ui-apc__approve",
1894
1894
  "aria-keyshortcuts": "Meta+Enter Control+Enter",
1895
- "aria-disabled": H || void 0,
1895
+ "aria-disabled": W || void 0,
1896
1896
  onClick: () => {
1897
1897
  ge();
1898
1898
  },
1899
1899
  children: [
1900
- y,
1901
- H ? /* @__PURE__ */ i("svg", { className: "ui-apc__spinner", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ i("circle", { cx: "8", cy: "8", r: "6" }) }) : M && /* @__PURE__ */ i("kbd", { className: "ui-apc__kbd", "aria-hidden": "true", children: C === "⌘" ? "⌘↵" : "Ctrl ↵" })
1900
+ v,
1901
+ W ? /* @__PURE__ */ i("svg", { className: "ui-apc__spinner", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ i("circle", { cx: "8", cy: "8", r: "6" }) }) : L && /* @__PURE__ */ i("kbd", { className: "ui-apc__kbd", "aria-hidden": "true", children: N === "⌘" ? "⌘↵" : "Ctrl ↵" })
1902
1902
  ]
1903
1903
  }
1904
1904
  )
@@ -1907,26 +1907,26 @@ function oo({
1907
1907
  return /* @__PURE__ */ d(
1908
1908
  "div",
1909
1909
  {
1910
- ref: S,
1911
- className: ["ui-apc", L].filter(Boolean).join(" "),
1910
+ ref: $,
1911
+ className: ["ui-apc", C].filter(Boolean).join(" "),
1912
1912
  role: "group",
1913
1913
  "aria-labelledby": B ? Lt : It,
1914
1914
  "aria-describedby": gt || void 0,
1915
- "aria-busy": H || void 0,
1915
+ "aria-busy": W || void 0,
1916
1916
  "data-status": T,
1917
- "data-busy": H || void 0,
1918
- "data-label": j ? "" : void 0,
1919
- "data-actions": V,
1917
+ "data-busy": W || void 0,
1918
+ "data-label": z ? "" : void 0,
1919
+ "data-actions": H,
1920
1920
  onKeyDown: we,
1921
- onPointerEnter: () => Y(!0),
1922
- onPointerLeave: () => Y(!1),
1923
- onFocus: () => A(!0),
1921
+ onPointerEnter: () => V(!0),
1922
+ onPointerLeave: () => V(!1),
1923
+ onFocus: () => S(!0),
1924
1924
  onBlur: (ie) => {
1925
- ie.currentTarget.contains(ie.relatedTarget) || A(!1);
1925
+ ie.currentTarget.contains(ie.relatedTarget) || S(!1);
1926
1926
  },
1927
1927
  children: [
1928
1928
  /* @__PURE__ */ i("style", { href: "ui-approval-card-clean", precedence: "default", children: lo }),
1929
- j && /* @__PURE__ */ i("div", { className: "ui-apc__label", title: typeof j == "string" ? j : void 0, children: j }),
1929
+ z && /* @__PURE__ */ i("div", { className: "ui-apc__label", title: typeof z == "string" ? z : void 0, children: z }),
1930
1930
  (!B || g) && /* @__PURE__ */ d(
1931
1931
  "div",
1932
1932
  {
@@ -1936,7 +1936,7 @@ function oo({
1936
1936
  inert: g,
1937
1937
  "aria-hidden": g || void 0,
1938
1938
  onAnimationEnd: (ie) => {
1939
- ie.target === ie.currentTarget && (g && D(!1), R && U(!1));
1939
+ ie.target === ie.currentTarget && (g && O(!1), R && q(!1));
1940
1940
  },
1941
1941
  children: [
1942
1942
  /* @__PURE__ */ d("div", { className: "ui-apc__card", children: [
@@ -1962,10 +1962,10 @@ function oo({
1962
1962
  /* @__PURE__ */ i("dd", { dir: "auto", children: ie.value })
1963
1963
  ] }, ie.label + Le)) }) : null
1964
1964
  ] }),
1965
- V === "tray" && He,
1966
- V === "card" && xt
1965
+ H === "tray" && He,
1966
+ H === "card" && xt
1967
1967
  ] }),
1968
- V === "tray" && xt,
1968
+ H === "tray" && xt,
1969
1969
  he > 0 && /* @__PURE__ */ i("span", { className: "ui-apc__sr", id: g ? void 0 : At, children: `Expires in ${so(ce)} unless approved. The timer pauses while the card is hovered or focused.` })
1970
1970
  ]
1971
1971
  }
@@ -2650,35 +2650,35 @@ function uo({
2650
2650
  defaultOpen: l = !1,
2651
2651
  open: x,
2652
2652
  onOpenChange: _,
2653
- openOnError: v = !0,
2653
+ openOnError: b = !0,
2654
2654
  onRetry: w,
2655
2655
  maxCodeHeight: m = 220,
2656
2656
  className: k,
2657
- labels: y
2657
+ labels: v
2658
2658
  }) {
2659
- const f = { ...Ca, ...y }, b = qe(), [M, j] = I(l), V = x ?? M, L = (H) => {
2660
- x === void 0 && j(H), _?.(H);
2661
- }, [F, P] = I(n), [O, T] = I(!1);
2662
- n !== F && (P(n), x === void 0 && v && (n === "error" && !M ? (j(!0), T(!0)) : F === "error" && O && (j(!1), T(!1))));
2663
- const B = go(n === "running", u, !1), ee = n === "running" ? B ?? 0 : s ?? B, z = n === "running" ? f.running(e) : n === "success" ? f.finished(e) : f.failedAnnouncement(e, c);
2659
+ const f = { ...Ca, ...v }, y = qe(), [L, z] = A(l), H = x ?? L, C = (W) => {
2660
+ x === void 0 && z(W), _?.(W);
2661
+ }, [P, F] = A(n), [D, T] = A(!1);
2662
+ n !== P && (F(n), x === void 0 && b && (n === "error" && !L ? (z(!0), T(!0)) : P === "error" && D && (z(!1), T(!1))));
2663
+ const B = go(n === "running", u, !1), ee = n === "running" ? B ?? 0 : s ?? B, M = n === "running" ? f.running(e) : n === "success" ? f.finished(e) : f.failedAnnouncement(e, c);
2664
2664
  return /* @__PURE__ */ d(
2665
2665
  "div",
2666
2666
  {
2667
2667
  className: ["ui-tclc", k].filter(Boolean).join(" "),
2668
2668
  "data-status": n,
2669
- "data-open": V || void 0,
2669
+ "data-open": H || void 0,
2670
2670
  children: [
2671
2671
  /* @__PURE__ */ i("style", { href: "ui-tool-call-clean", precedence: "default", children: yo }),
2672
- /* @__PURE__ */ i("span", { className: "ui-tclc-sr", role: "status", "aria-live": "polite", children: z }),
2672
+ /* @__PURE__ */ i("span", { className: "ui-tclc-sr", role: "status", "aria-live": "polite", children: M }),
2673
2673
  /* @__PURE__ */ d(
2674
2674
  "button",
2675
2675
  {
2676
2676
  type: "button",
2677
2677
  className: "ui-tclc__head",
2678
- "aria-expanded": V,
2679
- "aria-controls": `${b}-body`,
2678
+ "aria-expanded": H,
2679
+ "aria-controls": `${y}-body`,
2680
2680
  onClick: () => {
2681
- T(!1), L(!V);
2681
+ T(!1), C(!H);
2682
2682
  },
2683
2683
  children: [
2684
2684
  /* @__PURE__ */ i("span", { className: "ui-tclc__icon", "aria-hidden": "true", children: o ?? /* @__PURE__ */ i(fo, {}) }),
@@ -2699,7 +2699,7 @@ function uo({
2699
2699
  ]
2700
2700
  }
2701
2701
  ),
2702
- /* @__PURE__ */ i("div", { className: "ui-tclc__body", id: `${b}-body`, inert: !V, children: /* @__PURE__ */ i("div", { className: "ui-tclc__clip", children: /* @__PURE__ */ d("div", { className: "ui-tclc__sections", children: [
2702
+ /* @__PURE__ */ i("div", { className: "ui-tclc__body", id: `${y}-body`, inert: !H, children: /* @__PURE__ */ i("div", { className: "ui-tclc__clip", children: /* @__PURE__ */ d("div", { className: "ui-tclc__sections", children: [
2703
2703
  n === "error" && /* @__PURE__ */ d("div", { className: "ui-tclc__error", children: [
2704
2704
  /* @__PURE__ */ i(Di, {}),
2705
2705
  /* @__PURE__ */ i("p", { className: "ui-tclc__error-text", dir: "auto", children: c ?? f.error }),
@@ -2724,16 +2724,16 @@ function uo({
2724
2724
  }
2725
2725
  const Ai = 640;
2726
2726
  function Si({ label: e, copyLabel: t, labels: o, value: n, cap: a }) {
2727
- const { text: r, json: c } = wo(n), u = q(null), [s, l] = I(!1), [x, _] = I(0);
2727
+ const { text: r, json: c } = wo(n), u = U(null), [s, l] = A(!1), [x, _] = A(0);
2728
2728
  ke(() => {
2729
2729
  const w = u.current, m = w?.firstElementChild;
2730
2730
  if (!w || !m) return;
2731
2731
  const k = () => _(w.scrollHeight);
2732
2732
  k();
2733
- const y = new ResizeObserver(k);
2734
- return y.observe(m), () => y.disconnect();
2733
+ const v = new ResizeObserver(k);
2734
+ return v.observe(m), () => v.disconnect();
2735
2735
  }, [r]);
2736
- const v = x > a + 24;
2736
+ const b = x > a + 24;
2737
2737
  return /* @__PURE__ */ d("div", { className: "ui-tclc__section", children: [
2738
2738
  /* @__PURE__ */ d("div", { className: "ui-tclc__section-head", children: [
2739
2739
  /* @__PURE__ */ i("span", { className: "ui-tclc__label", children: e }),
@@ -2744,17 +2744,17 @@ function Si({ label: e, copyLabel: t, labels: o, value: n, cap: a }) {
2744
2744
  {
2745
2745
  ref: u,
2746
2746
  className: "ui-tclc__code",
2747
- "data-capped": v && !s || void 0,
2748
- "data-scroll": v && s && x > Ai || void 0,
2749
- style: v ? { maxHeight: s ? Math.min(x, Ai) : a } : void 0,
2747
+ "data-capped": b && !s || void 0,
2748
+ "data-scroll": b && s && x > Ai || void 0,
2749
+ style: b ? { maxHeight: s ? Math.min(x, Ai) : a } : void 0,
2750
2750
  children: /* @__PURE__ */ i("code", { children: c ? bo(r) : r })
2751
2751
  }
2752
2752
  ),
2753
- v && /* @__PURE__ */ i("button", { type: "button", className: "ui-tclc__more", "aria-expanded": s, onClick: () => l(!s), children: s ? o.showLess : o.showAll })
2753
+ b && /* @__PURE__ */ i("button", { type: "button", className: "ui-tclc__more", "aria-expanded": s, onClick: () => l(!s), children: s ? o.showLess : o.showAll })
2754
2754
  ] });
2755
2755
  }
2756
2756
  function po({ text: e, label: t, labels: o }) {
2757
- const [n, a] = I(!1);
2757
+ const [n, a] = A(!1);
2758
2758
  return se(() => {
2759
2759
  if (!n) return;
2760
2760
  const r = window.setTimeout(() => a(!1), 1400);
@@ -2797,7 +2797,7 @@ function fo() {
2797
2797
  return /* @__PURE__ */ i("svg", { viewBox: "0 0 16 16", children: /* @__PURE__ */ i("path", { d: "M10.2 2.4a3.5 3.5 0 0 0-4.3 4.6L2.6 10.3a1.4 1.4 0 0 0 2 2L7.9 9a3.5 3.5 0 0 0 4.6-4.3l-2 2-1.6-.4-.4-1.6 1.7-2.3Z" }) });
2798
2798
  }
2799
2799
  function go(e, t, o) {
2800
- const n = q(null), a = q(0), [r, c] = I(null);
2800
+ const n = U(null), a = U(0), [r, c] = A(null);
2801
2801
  return se(() => {
2802
2802
  if (!e) {
2803
2803
  n.current !== null && (a.current += Date.now() - n.current, n.current = null, c(a.current));
@@ -3353,16 +3353,16 @@ function Ae({
3353
3353
  onPointerEnter: l,
3354
3354
  type: x = "button",
3355
3355
  ref: _,
3356
- ...v
3356
+ ...b
3357
3357
  }) {
3358
- const w = typeof r == "string" ? r : void 0, m = r != null && r !== !1 && r !== "", k = !m && !!(n || a), y = ko.includes(e) ? e : "primary", f = zo.includes(t) ? t : "md", b = q(null), M = q(0), [j, V] = I(!1);
3359
- se(() => V(!0), []);
3360
- const L = w ?? "label", F = o && n ? "spinner" : Oi(n), P = Oi(a), O = `${L}|${F}|${P}`, T = q(O);
3358
+ const w = typeof r == "string" ? r : void 0, m = r != null && r !== !1 && r !== "", k = !m && !!(n || a), v = ko.includes(e) ? e : "primary", f = zo.includes(t) ? t : "md", y = U(null), L = U(0), [z, H] = A(!1);
3359
+ se(() => H(!0), []);
3360
+ const C = w ?? "label", P = o && n ? "spinner" : Oi(n), F = Oi(a), D = `${C}|${P}|${F}`, T = U(D);
3361
3361
  return ke(() => {
3362
- const B = b.current;
3362
+ const B = y.current;
3363
3363
  if (!B) return;
3364
- const ee = B.getBoundingClientRect().width, z = M.current, H = T.current !== O;
3365
- M.current = ee, T.current = O, !(!H || !z || Math.abs(z - ee) < 0.5) && (window.matchMedia("(prefers-reduced-motion: reduce)").matches || B.animate([{ width: `${z}px` }, { width: `${ee}px` }], {
3364
+ const ee = B.getBoundingClientRect().width, M = L.current, W = T.current !== D;
3365
+ L.current = ee, T.current = D, !(!W || !M || Math.abs(M - ee) < 0.5) && (window.matchMedia("(prefers-reduced-motion: reduce)").matches || B.animate([{ width: `${M}px` }, { width: `${ee}px` }], {
3366
3366
  duration: 480,
3367
3367
  easing: "cubic-bezier(0.25, 1, 0.5, 1)"
3368
3368
  }));
@@ -3373,15 +3373,15 @@ function Ae({
3373
3373
  {
3374
3374
  type: x,
3375
3375
  className: ["ui-buttonc", c].filter(Boolean).join(" "),
3376
- "data-variant": y,
3376
+ "data-variant": v,
3377
3377
  "data-size": f,
3378
3378
  "data-loading": o || void 0,
3379
3379
  "data-icon-only": k || void 0,
3380
3380
  "data-icon-left": !k && !!n || void 0,
3381
3381
  "data-icon-right": !k && !!a || void 0,
3382
- "data-ready": j || void 0,
3382
+ "data-ready": z || void 0,
3383
3383
  ref: (B) => {
3384
- b.current = B, typeof _ == "function" ? _(B) : _ && (_.current = B);
3384
+ y.current = B, typeof _ == "function" ? _(B) : _ && (_.current = B);
3385
3385
  },
3386
3386
  disabled: u,
3387
3387
  "aria-busy": o || void 0,
@@ -3395,13 +3395,13 @@ function Ae({
3395
3395
  },
3396
3396
  onPointerEnter: (B) => {
3397
3397
  const ee = B.currentTarget.querySelector(".ui-buttonc__label");
3398
- ee && w && !v.title && (ee.title = ee.scrollWidth > ee.clientWidth + 1 ? w : ""), l?.(B);
3398
+ ee && w && !b.title && (ee.title = ee.scrollWidth > ee.clientWidth + 1 ? w : ""), l?.(B);
3399
3399
  },
3400
- ...v,
3400
+ ...b,
3401
3401
  children: [
3402
- n && /* @__PURE__ */ i("span", { className: "ui-buttonc__icon", "aria-hidden": "true", onErrorCapture: $i, children: o ? /* @__PURE__ */ i(Mo, {}) : n }, `icon-${F}`),
3403
- m && /* @__PURE__ */ i("span", { className: "ui-buttonc__label", "data-text": w, dir: "auto", children: r }, `label-${L}`),
3404
- a && /* @__PURE__ */ i("span", { className: "ui-buttonc__icon", "aria-hidden": "true", onErrorCapture: $i, children: a }, `icon-right-${P}`)
3402
+ n && /* @__PURE__ */ i("span", { className: "ui-buttonc__icon", "aria-hidden": "true", onErrorCapture: $i, children: o ? /* @__PURE__ */ i(Mo, {}) : n }, `icon-${P}`),
3403
+ m && /* @__PURE__ */ i("span", { className: "ui-buttonc__label", "data-text": w, dir: "auto", children: r }, `label-${C}`),
3404
+ a && /* @__PURE__ */ i("span", { className: "ui-buttonc__icon", "aria-hidden": "true", onErrorCapture: $i, children: a }, `icon-right-${F}`)
3405
3405
  ]
3406
3406
  }
3407
3407
  )
@@ -3766,7 +3766,7 @@ const No = (
3766
3766
  other: "Other"
3767
3767
  }, Io = () => typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
3768
3768
  function $t({ id: e, children: t, className: o }) {
3769
- const n = q({ id: e, node: t }), [a, r] = I(e), [c, u] = I(null);
3769
+ const n = U({ id: e, node: t }), [a, r] = A(e), [c, u] = A(null);
3770
3770
  return a !== e && (r(e), u(n.current)), n.current = { id: e, node: t }, se(() => {
3771
3771
  if (!c) return;
3772
3772
  const s = window.setTimeout(() => u(null), 300);
@@ -3801,67 +3801,67 @@ function Ao({
3801
3801
  onFeedback: l,
3802
3802
  reasons: x,
3803
3803
  onSpeak: _,
3804
- speaking: v,
3804
+ speaking: b,
3805
3805
  speakDuration: w,
3806
3806
  quiet: m = !0,
3807
3807
  label: k,
3808
- labels: y,
3808
+ labels: v,
3809
3809
  className: f
3810
3810
  }) {
3811
- const b = { ...ri, ...y }, M = x ?? [b.notAccurate, b.tooLong, b.didNotFollow, b.other], j = (J) => J === b.other || J === ri.other, V = qe(), L = To(t), F = Math.max(1, Kt(typeof o == "number" ? o : Array.isArray(o) ? o.length : 1, 1)), [P, O] = I(() => Math.min(F - 1, Math.max(0, Kt(a, F - 1)))), [T, B] = I(F), [ee, z] = I(null), [H, Z] = I(!1), [K, te] = I(null), [X, oe] = I(""), [re, W] = I(!1);
3812
- T !== F && (F > T && (O(F - 1), z(null), Z(!1)), B(F));
3813
- const $ = Math.min(F - 1, Math.max(0, Kt(n, P))), Y = (J) => {
3814
- const ze = Math.min(F - 1, Math.max(0, J));
3815
- ze !== $ && (n === void 0 && O(ze), r?.(ze), C(b.version(ze + 1, F)));
3816
- }, [p, A] = I(""), C = (J) => A((ze) => ze === J ? `${J} ` : J), [h, N] = I(0);
3811
+ const y = { ...ri, ...v }, L = x ?? [y.notAccurate, y.tooLong, y.didNotFollow, y.other], z = (J) => J === y.other || J === ri.other, H = qe(), C = To(t), P = Math.max(1, Kt(typeof o == "number" ? o : Array.isArray(o) ? o.length : 1, 1)), [F, D] = A(() => Math.min(P - 1, Math.max(0, Kt(a, P - 1)))), [T, B] = A(P), [ee, M] = A(null), [W, Z] = A(!1), [K, te] = A(null), [X, oe] = A(""), [re, Y] = A(!1);
3812
+ T !== P && (P > T && (D(P - 1), M(null), Z(!1)), B(P));
3813
+ const E = Math.min(P - 1, Math.max(0, Kt(n, F))), V = (J) => {
3814
+ const ze = Math.min(P - 1, Math.max(0, J));
3815
+ ze !== E && (n === void 0 && D(ze), r?.(ze), N(y.version(ze + 1, P)));
3816
+ }, [p, S] = A(""), N = (J) => S((ze) => ze === J ? `${J} ` : J), [h, I] = A(0);
3817
3817
  se(() => {
3818
3818
  if (!h) return;
3819
- const J = window.setTimeout(() => N(0), 1600);
3819
+ const J = window.setTimeout(() => I(0), 1600);
3820
3820
  return () => window.clearTimeout(J);
3821
3821
  }, [h]);
3822
- const G = () => {
3822
+ const Q = () => {
3823
3823
  try {
3824
3824
  e !== void 0 && navigator.clipboard?.writeText(e).catch(() => {
3825
3825
  });
3826
3826
  } catch {
3827
3827
  }
3828
- c?.(e), N(Date.now()), C(b.copied);
3829
- }, [g, D] = I(0), R = () => {
3830
- D((J) => J + 1), u?.(), C(b.regenerating);
3831
- }, U = () => {
3828
+ c?.(e), I(Date.now()), N(y.copied);
3829
+ }, [g, O] = A(0), R = () => {
3830
+ O((J) => J + 1), u?.(), N(y.regenerating);
3831
+ }, q = () => {
3832
3832
  if (ee === "up") {
3833
- z(null), l?.(null);
3833
+ M(null), l?.(null);
3834
3834
  return;
3835
3835
  }
3836
- z("up"), Z(!1), l?.("up"), C(b.markedGood);
3837
- }, S = () => {
3836
+ M("up"), Z(!1), l?.("up"), N(y.markedGood);
3837
+ }, $ = () => {
3838
3838
  if (ee === "down") {
3839
- z(null), Z(!1), l?.(null);
3839
+ M(null), Z(!1), l?.(null);
3840
3840
  return;
3841
3841
  }
3842
- z("down"), Z(!0), W(!1), te(null), oe(""), l?.("down"), C(b.markedBad);
3842
+ M("down"), Z(!0), Y(!1), te(null), oe(""), l?.("down"), N(y.markedBad);
3843
3843
  }, ae = () => {
3844
- !K || re || (l?.("down", j(K) && X.trim() || K), W(!0), C(b.thanksFeedback));
3844
+ !K || re || (l?.("down", z(K) && X.trim() || K), Y(!0), N(y.thanksFeedback));
3845
3845
  };
3846
3846
  se(() => {
3847
3847
  if (!re) return;
3848
3848
  const J = window.setTimeout(() => Z(!1), Io() ? 1200 : 1500);
3849
3849
  return () => window.clearTimeout(J);
3850
3850
  }, [re]);
3851
- const fe = q(null), ue = () => {
3851
+ const fe = U(null), ue = () => {
3852
3852
  Z(!1), fe.current?.focus();
3853
- }, [ge, _e] = I(!1), we = v ?? ge, he = e ? e.trim().split(/\s+/).length : 0, Q = typeof w == "number" && w > 0 ? w : Math.max(2600, he * 380);
3853
+ }, [ge, _e] = A(!1), we = b ?? ge, he = e ? e.trim().split(/\s+/).length : 0, G = typeof w == "number" && w > 0 ? w : Math.max(2600, he * 380);
3854
3854
  se(() => {
3855
- if (v !== void 0 || !ge) return;
3855
+ if (b !== void 0 || !ge) return;
3856
3856
  const J = window.setTimeout(() => {
3857
- _e(!1), _?.(!1), C(b.finishedReading);
3858
- }, Q);
3857
+ _e(!1), _?.(!1), N(y.finishedReading);
3858
+ }, G);
3859
3859
  return () => window.clearTimeout(J);
3860
- }, [ge, v, Q]);
3860
+ }, [ge, b, G]);
3861
3861
  const ce = () => {
3862
3862
  const J = !we;
3863
- v === void 0 && _e(J), _?.(J), C(J ? b.readingAloud : b.stoppedReading);
3864
- }, xe = !!h || H || we || s, pe = (J) => /* @__PURE__ */ d("span", { className: "ui-mac__item", "data-flash": J.flash ? "" : void 0, children: [
3863
+ b === void 0 && _e(J), _?.(J), N(J ? y.readingAloud : y.stoppedReading);
3864
+ }, xe = !!h || W || we || s, pe = (J) => /* @__PURE__ */ d("span", { className: "ui-mac__item", "data-flash": J.flash ? "" : void 0, children: [
3865
3865
  /* @__PURE__ */ i(
3866
3866
  "button",
3867
3867
  {
@@ -3878,11 +3878,11 @@ function Ao({
3878
3878
  }
3879
3879
  ),
3880
3880
  /* @__PURE__ */ i("span", { className: "ui-mac__tip", "aria-hidden": "true", children: /* @__PURE__ */ i($t, { id: J.tip, children: J.tip }) })
3881
- ] }, J.key), ve = L.map((J) => J === "copy" ? pe({
3881
+ ] }, J.key), ve = C.map((J) => J === "copy" ? pe({
3882
3882
  key: "copy",
3883
- tip: h ? b.copied : b.copy,
3884
- labelText: h ? b.copied : b.copyMessage,
3885
- onClick: G,
3883
+ tip: h ? y.copied : y.copy,
3884
+ labelText: h ? y.copied : y.copyMessage,
3885
+ onClick: Q,
3886
3886
  flash: !!h,
3887
3887
  extra: { "data-done": h ? "" : void 0 },
3888
3888
  children: /* @__PURE__ */ d("span", { className: "ui-mac__icon ui-mac__morph", children: [
@@ -3892,29 +3892,29 @@ function Ao({
3892
3892
  }) : J === "regenerate" ? /* @__PURE__ */ d("span", { className: "ui-mac__regen", children: [
3893
3893
  pe({
3894
3894
  key: "regenerate",
3895
- tip: s ? b.writing : b.regenerate,
3896
- labelText: b.regenerateResponse,
3895
+ tip: s ? y.writing : y.regenerate,
3896
+ labelText: y.regenerateResponse,
3897
3897
  onClick: R,
3898
3898
  extra: { "data-busy": s ? "" : void 0 },
3899
3899
  children: /* @__PURE__ */ i("span", { className: "ui-mac__icon", children: /* @__PURE__ */ i("span", { className: "ui-mac__spin", "data-spin": g ? "" : void 0, children: /* @__PURE__ */ i(Ye, { d: Ve.redo }) }, g) })
3900
3900
  }),
3901
- /* @__PURE__ */ i("span", { className: "ui-mac__versions", "data-open": F > 1 ? "" : void 0, inert: F < 2, children: /* @__PURE__ */ d("span", { className: "ui-mac__versions-clip", role: "group", "aria-label": b.versions, children: [
3901
+ /* @__PURE__ */ i("span", { className: "ui-mac__versions", "data-open": P > 1 ? "" : void 0, inert: P < 2, children: /* @__PURE__ */ d("span", { className: "ui-mac__versions-clip", role: "group", "aria-label": y.versions, children: [
3902
3902
  /* @__PURE__ */ i(
3903
3903
  "button",
3904
3904
  {
3905
3905
  type: "button",
3906
3906
  className: "ui-mac__step",
3907
3907
  "data-dir": "prev",
3908
- "aria-label": b.previousVersion,
3909
- disabled: $ === 0,
3910
- onClick: () => Y($ - 1),
3908
+ "aria-label": y.previousVersion,
3909
+ disabled: E === 0,
3910
+ onClick: () => V(E - 1),
3911
3911
  children: /* @__PURE__ */ i(Ye, { d: Ve.next, solid: !0 })
3912
3912
  }
3913
3913
  ),
3914
- /* @__PURE__ */ d("span", { className: "ui-mac__count", "aria-label": b.version($ + 1, F), children: [
3915
- /* @__PURE__ */ i($t, { id: String($), className: "ui-mac__count-now", children: Ft($ + 1) }),
3914
+ /* @__PURE__ */ d("span", { className: "ui-mac__count", "aria-label": y.version(E + 1, P), children: [
3915
+ /* @__PURE__ */ i($t, { id: String(E), className: "ui-mac__count-now", children: Ft(E + 1) }),
3916
3916
  /* @__PURE__ */ i("span", { "aria-hidden": "true", children: "/" }),
3917
- /* @__PURE__ */ i($t, { id: String(F), children: Ft(F) })
3917
+ /* @__PURE__ */ i($t, { id: String(P), children: Ft(P) })
3918
3918
  ] }),
3919
3919
  /* @__PURE__ */ i(
3920
3920
  "button",
@@ -3922,9 +3922,9 @@ function Ao({
3922
3922
  type: "button",
3923
3923
  className: "ui-mac__step",
3924
3924
  "data-dir": "next",
3925
- "aria-label": b.nextVersion,
3926
- disabled: $ >= F - 1,
3927
- onClick: () => Y($ + 1),
3925
+ "aria-label": y.nextVersion,
3926
+ disabled: E >= P - 1,
3927
+ onClick: () => V(E + 1),
3928
3928
  children: /* @__PURE__ */ i(Ye, { d: Ve.next, solid: !0 })
3929
3929
  }
3930
3930
  )
@@ -3932,27 +3932,27 @@ function Ao({
3932
3932
  ] }, "regenerate") : J === "feedback" ? /* @__PURE__ */ d(Ga, { children: [
3933
3933
  pe({
3934
3934
  key: "up",
3935
- tip: ee === "up" ? b.thanks : b.goodResponse,
3936
- labelText: b.goodResponse,
3935
+ tip: ee === "up" ? y.thanks : y.goodResponse,
3936
+ labelText: y.goodResponse,
3937
3937
  pressed: ee === "up",
3938
- onClick: U,
3938
+ onClick: q,
3939
3939
  children: /* @__PURE__ */ i("span", { className: "ui-mac__icon ui-mac__thumb", children: /* @__PURE__ */ i(Ye, { d: Ve.thumb, solid: !0 }) })
3940
3940
  }),
3941
3941
  pe({
3942
3942
  key: "down",
3943
- tip: b.badResponse,
3944
- labelText: b.badResponse,
3943
+ tip: y.badResponse,
3944
+ labelText: y.badResponse,
3945
3945
  pressed: ee === "down",
3946
- expanded: H,
3947
- controls: `${V}-feedback`,
3948
- onClick: S,
3946
+ expanded: W,
3947
+ controls: `${H}-feedback`,
3948
+ onClick: $,
3949
3949
  refEl: fe,
3950
3950
  children: /* @__PURE__ */ i("span", { className: "ui-mac__icon ui-mac__thumb", children: /* @__PURE__ */ i(Ye, { d: Ve.thumb, solid: !0 }) })
3951
3951
  })
3952
3952
  ] }, "feedback") : pe({
3953
3953
  key: "speak",
3954
- tip: we ? b.stop : b.readAloud,
3955
- labelText: we ? b.stopReading : b.readAloud,
3954
+ tip: we ? y.stop : y.readAloud,
3955
+ labelText: we ? y.stopReading : y.readAloud,
3956
3956
  pressed: we,
3957
3957
  onClick: ce,
3958
3958
  children: /* @__PURE__ */ d("span", { className: "ui-mac__icon ui-mac__morph", children: [
@@ -3975,14 +3975,14 @@ function Ao({
3975
3975
  "data-active": xe ? "" : void 0,
3976
3976
  children: [
3977
3977
  /* @__PURE__ */ i("style", { href: "ui-message-actions-clean", precedence: "default", children: So }),
3978
- /* @__PURE__ */ i("div", { className: "ui-mac__bar", role: "group", "aria-label": k ?? b.label, children: ve }),
3979
- L.includes("feedback") && /* @__PURE__ */ i("div", { id: `${V}-feedback`, className: "ui-mac__fold", "data-open": H ? "" : void 0, inert: !H, children: /* @__PURE__ */ i("div", { className: "ui-mac__clip", children: /* @__PURE__ */ d("div", { className: "ui-mac__panel", role: "group", "aria-labelledby": `${V}-ask`, onKeyDown: Ce, children: [
3978
+ /* @__PURE__ */ i("div", { className: "ui-mac__bar", role: "group", "aria-label": k ?? y.label, children: ve }),
3979
+ C.includes("feedback") && /* @__PURE__ */ i("div", { id: `${H}-feedback`, className: "ui-mac__fold", "data-open": W ? "" : void 0, inert: !W, children: /* @__PURE__ */ i("div", { className: "ui-mac__clip", children: /* @__PURE__ */ d("div", { className: "ui-mac__panel", role: "group", "aria-labelledby": `${H}-ask`, onKeyDown: Ce, children: [
3980
3980
  /* @__PURE__ */ d("div", { className: "ui-mac__panel-head", children: [
3981
- /* @__PURE__ */ i("span", { id: `${V}-ask`, className: "ui-mac__ask", children: b.whatWentWrong }),
3982
- /* @__PURE__ */ i("button", { type: "button", className: "ui-mac__close", "aria-label": b.closeFeedback, onClick: ue, children: /* @__PURE__ */ i(Ye, { d: Ve.close }) })
3981
+ /* @__PURE__ */ i("span", { id: `${H}-ask`, className: "ui-mac__ask", children: y.whatWentWrong }),
3982
+ /* @__PURE__ */ i("button", { type: "button", className: "ui-mac__close", "aria-label": y.closeFeedback, onClick: ue, children: /* @__PURE__ */ i(Ye, { d: Ve.close }) })
3983
3983
  ] }),
3984
3984
  /* @__PURE__ */ d("div", { className: "ui-mac__chips", children: [
3985
- (Array.isArray(M) ? M : []).map((J, ze) => /* @__PURE__ */ i(
3985
+ (Array.isArray(L) ? L : []).map((J, ze) => /* @__PURE__ */ i(
3986
3986
  "button",
3987
3987
  {
3988
3988
  type: "button",
@@ -4007,19 +4007,19 @@ function Ao({
4007
4007
  onClick: ae,
4008
4008
  children: /* @__PURE__ */ i($t, { id: re ? "sent" : "send", children: re ? /* @__PURE__ */ d(Me, { children: [
4009
4009
  /* @__PURE__ */ i(Ye, { d: Ve.tick }),
4010
- b.thanks
4011
- ] }) : b.send })
4010
+ y.thanks
4011
+ ] }) : y.send })
4012
4012
  }
4013
4013
  )
4014
4014
  ] }),
4015
- Array.isArray(M) && M.some(j) && /* @__PURE__ */ i("div", { className: "ui-mac__fold", "data-open": j(K) && !re ? "" : void 0, inert: !j(K) || re, children: /* @__PURE__ */ i("div", { className: "ui-mac__clip", children: /* @__PURE__ */ i(
4015
+ Array.isArray(L) && L.some(z) && /* @__PURE__ */ i("div", { className: "ui-mac__fold", "data-open": z(K) && !re ? "" : void 0, inert: !z(K) || re, children: /* @__PURE__ */ i("div", { className: "ui-mac__clip", children: /* @__PURE__ */ i(
4016
4016
  "input",
4017
4017
  {
4018
4018
  className: "ui-mac__input",
4019
4019
  value: X,
4020
- placeholder: b.morePlaceholder,
4020
+ placeholder: y.morePlaceholder,
4021
4021
  dir: "auto",
4022
- "aria-label": b.moreLabel,
4022
+ "aria-label": y.moreLabel,
4023
4023
  onChange: (J) => oe(J.target.value),
4024
4024
  onKeyDown: (J) => {
4025
4025
  J.key === "Enter" && ae();
@@ -4487,7 +4487,7 @@ function ji({ text: e, query: t }) {
4487
4487
  const Ri = (e) => {
4488
4488
  e.currentTarget.dataset.broken = "";
4489
4489
  }, Bo = Nt(function({ cmd: t, domId: o, selected: n, ran: a, mod: r, q: c, on: u }) {
4490
- const s = t.n ? [r, String(t.n)] : t.keys, l = q(null);
4490
+ const s = t.n ? [r, String(t.n)] : t.keys, l = U(null);
4491
4491
  ke(() => {
4492
4492
  t.editing && (l.current?.focus(), l.current?.select());
4493
4493
  }, [t.editing]);
@@ -4507,8 +4507,8 @@ const Ri = (e) => {
4507
4507
  tabIndex: -1,
4508
4508
  onMouseMove: () => u.current.move(t),
4509
4509
  onClick: () => u.current.run(t),
4510
- onKeyDown: x ? (v) => {
4511
- (v.key === "ArrowLeft" || v.key === "Escape") && (v.preventDefault(), v.stopPropagation(), u.current.focusRow(t));
4510
+ onKeyDown: x ? (b) => {
4511
+ (b.key === "ArrowLeft" || b.key === "Escape") && (b.preventDefault(), b.stopPropagation(), u.current.focusRow(t));
4512
4512
  } : void 0,
4513
4513
  children: [
4514
4514
  t.logo ? /* @__PURE__ */ i("span", { className: "ui-cmc__logo", "data-letter": Ei(t.label), onErrorCapture: Ri, children: t.logo }) : /* @__PURE__ */ i("span", { className: "ui-cmc__icon", "data-letter": Ei(t.label), onErrorCapture: Ri, children: t.icon }),
@@ -4521,31 +4521,31 @@ const Ri = (e) => {
4521
4521
  dir: "auto",
4522
4522
  "aria-label": t.label,
4523
4523
  defaultValue: t.label,
4524
- onClick: (v) => v.stopPropagation(),
4525
- onKeyDown: (v) => {
4526
- v.stopPropagation(), !v.nativeEvent.isComposing && (v.key === "Enter" ? (v.preventDefault(), u.current.editSubmit(t, v.currentTarget.value)) : v.key === "Escape" && (v.preventDefault(), u.current.editCancel(t)));
4524
+ onClick: (b) => b.stopPropagation(),
4525
+ onKeyDown: (b) => {
4526
+ b.stopPropagation(), !b.nativeEvent.isComposing && (b.key === "Enter" ? (b.preventDefault(), u.current.editSubmit(t, b.currentTarget.value)) : b.key === "Escape" && (b.preventDefault(), u.current.editCancel(t)));
4527
4527
  }
4528
4528
  }
4529
4529
  ) : /* @__PURE__ */ i("span", { className: "ui-cmc__name", dir: "auto", title: t.label, children: /* @__PURE__ */ i(ji, { text: t.label, query: c }) }),
4530
4530
  t.hint && /* @__PURE__ */ i("span", { className: "ui-cmc__hint", dir: "auto", title: t.hint, children: /* @__PURE__ */ i(ji, { text: t.hint, query: c }) })
4531
4531
  ] }),
4532
- !t.editing && t.actions?.length ? /* @__PURE__ */ i("span", { className: "ui-cmc__actions", children: t.actions.map((v) => /* @__PURE__ */ i(
4532
+ !t.editing && t.actions?.length ? /* @__PURE__ */ i("span", { className: "ui-cmc__actions", children: t.actions.map((b) => /* @__PURE__ */ i(
4533
4533
  "button",
4534
4534
  {
4535
4535
  type: "button",
4536
- "data-action": v.id,
4537
- "aria-label": v.label,
4538
- title: v.label,
4536
+ "data-action": b.id,
4537
+ "aria-label": b.label,
4538
+ title: b.label,
4539
4539
  tabIndex: n ? 0 : -1,
4540
4540
  onFocus: () => u.current.move(t),
4541
4541
  onClick: (w) => {
4542
- w.stopPropagation(), u.current.action(t, v.id);
4542
+ w.stopPropagation(), u.current.action(t, b.id);
4543
4543
  },
4544
- children: v.icon ?? v.label
4544
+ children: b.icon ?? b.label
4545
4545
  },
4546
- v.id
4546
+ b.id
4547
4547
  )) }) : null,
4548
- s && /* @__PURE__ */ i("span", { className: "ui-cmc__keys", "aria-hidden": "true", children: s.map((v, w) => /* @__PURE__ */ i("kbd", { children: v }, w)) })
4548
+ s && /* @__PURE__ */ i("span", { className: "ui-cmc__keys", "aria-hidden": "true", children: s.map((b, w) => /* @__PURE__ */ i("kbd", { children: b }, w)) })
4549
4549
  ]
4550
4550
  }
4551
4551
  )
@@ -4566,61 +4566,61 @@ function qo({
4566
4566
  onRun: l,
4567
4567
  onClose: x,
4568
4568
  autoFocus: _,
4569
- className: v
4569
+ className: b
4570
4570
  }) {
4571
- const w = je(() => ({ ...Do, ...u }), [u]), m = "ui-cmc" + qe().replace(/[^a-zA-Z0-9_-]/g, ""), k = q(null), y = q(null), f = q(null), [b, M] = I(0), [j, V] = I(""), [L, F] = I(null), [P, O] = I(null), [T, B] = I(null), [ee, z] = I(!0), H = Uo() ? "⌘" : "Ctrl", Z = je(
4572
- () => (e ?? []).filter(Boolean).map((h, N) => ({
4573
- key: `g${N}`,
4571
+ const w = je(() => ({ ...Do, ...u }), [u]), m = "ui-cmc" + qe().replace(/[^a-zA-Z0-9_-]/g, ""), k = U(null), v = U(null), f = U(null), [y, L] = A(0), [z, H] = A(""), [C, P] = A(null), [F, D] = A(null), [T, B] = A(null), [ee, M] = A(!0), W = Uo() ? "⌘" : "Ctrl", Z = je(
4572
+ () => (e ?? []).filter(Boolean).map((h, I) => ({
4573
+ key: `g${I}`,
4574
4574
  id: h.id,
4575
4575
  label: String(h.label ?? ""),
4576
- commands: (Array.isArray(h.commands) ? h.commands : []).filter(Boolean).map((G, g) => {
4577
- const D = String(G.label ?? ""), R = G.hint == null || G.hint === "" ? void 0 : String(G.hint);
4578
- return { row: { ...G, label: D, hint: R, key: `${N}-${g}`, n: 0 }, text: Pt(`${D} ${R ?? ""} ${G.keywords ?? ""}`) };
4576
+ commands: (Array.isArray(h.commands) ? h.commands : []).filter(Boolean).map((Q, g) => {
4577
+ const O = String(Q.label ?? ""), R = Q.hint == null || Q.hint === "" ? void 0 : String(Q.hint);
4578
+ return { row: { ...Q, label: O, hint: R, key: `${I}-${g}`, n: 0 }, text: Pt(`${O} ${R ?? ""} ${Q.keywords ?? ""}`) };
4579
4579
  })
4580
4580
  })),
4581
4581
  [e]
4582
- ), K = j.trim(), te = je(() => {
4583
- const h = Pt(K), N = Z.map((G) => ({
4584
- ...G,
4585
- commands: G.commands.filter((g) => !h || g.text.includes(h)).map((g, D) => G.id === "suggestions" && D < 5 ? { ...g.row, n: D + 1 } : g.row)
4586
- })).filter((G) => G.commands.length);
4587
- return r && h && N.unshift({ key: "ask", id: "ask-about", label: w.assistant, commands: [{ key: "ask", n: 0, id: "ask-about", label: w.ask(K), logo: /* @__PURE__ */ i(Na, {}) }] }), N;
4588
- }, [Z, K, r, w]), X = je(() => te.flatMap((h) => h.commands), [te]), oe = X.filter((h) => h.n), re = X.find((h) => h.key === L) ?? X[0], W = q(!1);
4582
+ ), K = z.trim(), te = je(() => {
4583
+ const h = Pt(K), I = Z.map((Q) => ({
4584
+ ...Q,
4585
+ commands: Q.commands.filter((g) => !h || g.text.includes(h)).map((g, O) => Q.id === "suggestions" && O < 5 ? { ...g.row, n: O + 1 } : g.row)
4586
+ })).filter((Q) => Q.commands.length);
4587
+ return r && h && I.unshift({ key: "ask", id: "ask-about", label: w.assistant, commands: [{ key: "ask", n: 0, id: "ask-about", label: w.ask(K), logo: /* @__PURE__ */ i(Na, {}) }] }), I;
4588
+ }, [Z, K, r, w]), X = je(() => te.flatMap((h) => h.commands), [te]), oe = X.filter((h) => h.n), re = X.find((h) => h.key === C) ?? X[0], Y = U(!1);
4589
4589
  ke(() => {
4590
- const h = y.current, N = h?.querySelector(`[data-key="${re?.key}"]`);
4591
- if (!h || !N) return B(null);
4592
- if (B({ y: N.offsetTop, h: N.offsetHeight }), !W.current) return;
4593
- W.current = !1;
4594
- const G = 8, g = N.previousElementSibling?.classList.contains("ui-cmc__label") ? N.previousElementSibling.offsetHeight : 0, D = N.offsetTop - G - g, R = N.offsetTop + N.offsetHeight + G;
4595
- D < h.scrollTop ? h.scrollTop = D : R > h.scrollTop + h.clientHeight && (h.scrollTop = R - h.clientHeight);
4590
+ const h = v.current, I = h?.querySelector(`[data-key="${re?.key}"]`);
4591
+ if (!h || !I) return B(null);
4592
+ if (B({ y: I.offsetTop, h: I.offsetHeight }), !Y.current) return;
4593
+ Y.current = !1;
4594
+ const Q = 8, g = I.previousElementSibling?.classList.contains("ui-cmc__label") ? I.previousElementSibling.offsetHeight : 0, O = I.offsetTop - Q - g, R = I.offsetTop + I.offsetHeight + Q;
4595
+ O < h.scrollTop ? h.scrollTop = O : R > h.scrollTop + h.clientHeight && (h.scrollTop = R - h.clientHeight);
4596
4596
  }, [re?.key, X.length]), ke(() => {
4597
- const h = y.current, N = f.current;
4598
- if (!h || !N) return;
4599
- const G = () => {
4600
- const D = getComputedStyle(h), R = parseFloat(D.paddingTop) + parseFloat(D.paddingBottom), U = parseFloat(D.maxHeight) || 1 / 0;
4601
- M(Math.min(N.offsetHeight + R, U));
4597
+ const h = v.current, I = f.current;
4598
+ if (!h || !I) return;
4599
+ const Q = () => {
4600
+ const O = getComputedStyle(h), R = parseFloat(O.paddingTop) + parseFloat(O.paddingBottom), q = parseFloat(O.maxHeight) || 1 / 0;
4601
+ L(Math.min(I.offsetHeight + R, q));
4602
4602
  };
4603
- G();
4604
- const g = new ResizeObserver(G);
4605
- return g.observe(N), () => g.disconnect();
4603
+ Q();
4604
+ const g = new ResizeObserver(Q);
4605
+ return g.observe(I), () => g.disconnect();
4606
4606
  }, []), se(() => {
4607
4607
  if (!c) return;
4608
- const h = (N) => {
4609
- (N.metaKey || N.ctrlKey) && N.key.toLowerCase() === "k" && (N.preventDefault(), k.current?.focus(), k.current?.select());
4608
+ const h = (I) => {
4609
+ (I.metaKey || I.ctrlKey) && I.key.toLowerCase() === "k" && (I.preventDefault(), k.current?.focus(), k.current?.select());
4610
4610
  };
4611
4611
  return window.addEventListener("keydown", h), () => window.removeEventListener("keydown", h);
4612
4612
  }, [c]), se(() => {
4613
- _ && !y.current?.querySelector(".ui-cmc__edit") && k.current?.focus();
4613
+ _ && !v.current?.querySelector(".ui-cmc__edit") && k.current?.focus();
4614
4614
  }, [_]), se(() => {
4615
- if (!P) return;
4616
- const h = window.setTimeout(() => O(null), 1800);
4615
+ if (!F) return;
4616
+ const h = window.setTimeout(() => D(null), 1800);
4617
4617
  return () => window.clearTimeout(h);
4618
- }, [P]);
4619
- const $ = (h) => {
4620
- h.editing || (F(h.key), O({ id: h.key, label: h.key === "ask" ? w.asked(K) : w.ran(h.label) }), h.key === "ask" ? l?.("ask", K) : l?.(h.id));
4621
- }, Y = (h) => {
4622
- F(h.key), z(!0), k.current?.focus({ preventScroll: !0 });
4623
- }, p = q({ move: () => {
4618
+ }, [F]);
4619
+ const E = (h) => {
4620
+ h.editing || (P(h.key), D({ id: h.key, label: h.key === "ask" ? w.asked(K) : w.ran(h.label) }), h.key === "ask" ? l?.("ask", K) : l?.(h.id));
4621
+ }, V = (h) => {
4622
+ P(h.key), M(!0), k.current?.focus({ preventScroll: !0 });
4623
+ }, p = U({ move: () => {
4624
4624
  }, run: () => {
4625
4625
  }, action: () => {
4626
4626
  }, editSubmit: () => {
@@ -4629,53 +4629,53 @@ function qo({
4629
4629
  } });
4630
4630
  p.current = {
4631
4631
  move: (h) => {
4632
- z(!0), h.key !== re?.key && F(h.key);
4632
+ M(!0), h.key !== re?.key && P(h.key);
4633
4633
  },
4634
4634
  run: (h) => {
4635
- $(h), k.current?.focus({ preventScroll: !0 });
4635
+ E(h), k.current?.focus({ preventScroll: !0 });
4636
4636
  },
4637
4637
  // PrimeChatKit LOCAL ⑭ start
4638
- action: (h, N) => {
4639
- Y(h), o?.(h.id, N);
4638
+ action: (h, I) => {
4639
+ V(h), o?.(h.id, I);
4640
4640
  },
4641
- editSubmit: (h, N) => {
4642
- n?.(h.id, N), Y(h);
4641
+ editSubmit: (h, I) => {
4642
+ n?.(h.id, I), V(h);
4643
4643
  },
4644
4644
  editCancel: (h) => {
4645
- a?.(h.id), Y(h);
4645
+ a?.(h.id), V(h);
4646
4646
  },
4647
- focusRow: Y
4647
+ focusRow: V
4648
4648
  // PrimeChatKit LOCAL ⑭ end
4649
4649
  };
4650
- const A = (h) => {
4650
+ const S = (h) => {
4651
4651
  if (!X.length || !re) return;
4652
- W.current = !0, z(!0);
4653
- const N = X.findIndex((G) => G.key === re.key);
4654
- F(X[(N + h + X.length) % X.length].key);
4655
- }, C = (h) => {
4652
+ Y.current = !0, M(!0);
4653
+ const I = X.findIndex((Q) => Q.key === re.key);
4654
+ P(X[(I + h + X.length) % X.length].key);
4655
+ }, N = (h) => {
4656
4656
  if (h.key === "ArrowRight" && re?.actions?.length && !re.editing) {
4657
- const N = y.current?.querySelector(`[data-key="${re.key}"] [data-action]`);
4658
- N && (h.preventDefault(), z(!0), N.focus());
4657
+ const I = v.current?.querySelector(`[data-key="${re.key}"] [data-action]`);
4658
+ I && (h.preventDefault(), M(!0), I.focus());
4659
4659
  return;
4660
4660
  }
4661
4661
  if (h.key === "ArrowDown" || h.key === "ArrowUp")
4662
- h.preventDefault(), A(h.key === "ArrowDown" ? 1 : -1);
4662
+ h.preventDefault(), S(h.key === "ArrowDown" ? 1 : -1);
4663
4663
  else if (h.key === "Enter" && re)
4664
- h.preventDefault(), $(re);
4664
+ h.preventDefault(), E(re);
4665
4665
  else if (h.key === "Tab" && te.length > 1) {
4666
4666
  h.preventDefault();
4667
- const N = te.findIndex((g) => g.commands.some((D) => D.key === re?.key)), G = h.shiftKey ? N <= 0 ? te.length - 1 : N - 1 : (N + 1) % te.length;
4668
- W.current = !0, z(!0), F(te[G].commands[0].key);
4667
+ const I = te.findIndex((g) => g.commands.some((O) => O.key === re?.key)), Q = h.shiftKey ? I <= 0 ? te.length - 1 : I - 1 : (I + 1) % te.length;
4668
+ Y.current = !0, M(!0), P(te[Q].commands[0].key);
4669
4669
  } else if (h.key === "Escape")
4670
- j ? V("") : x?.();
4670
+ z ? H("") : x?.();
4671
4671
  else if ((h.metaKey || h.ctrlKey) && /^[1-5]$/.test(h.key)) {
4672
- const N = oe[Number(h.key) - 1];
4673
- N && (h.preventDefault(), $(N));
4672
+ const I = oe[Number(h.key) - 1];
4673
+ I && (h.preventDefault(), E(I));
4674
4674
  }
4675
4675
  };
4676
4676
  return (
4677
4677
  // PrimeChatKit LOCAL ⑭ start
4678
- /* @__PURE__ */ d("div", { className: ["ui-cmc", v].filter(Boolean).join(" "), "data-fill": s || void 0, children: [
4678
+ /* @__PURE__ */ d("div", { className: ["ui-cmc", b].filter(Boolean).join(" "), "data-fill": s || void 0, children: [
4679
4679
  /* @__PURE__ */ i("style", { href: "ui-command-menu-clean", precedence: "default", children: Ho }),
4680
4680
  /* @__PURE__ */ d("div", { className: "ui-cmc__card", children: [
4681
4681
  /* @__PURE__ */ d("label", { className: "ui-cmc__search", children: [
@@ -4687,7 +4687,7 @@ function qo({
4687
4687
  "input",
4688
4688
  {
4689
4689
  ref: k,
4690
- value: j,
4690
+ value: z,
4691
4691
  dir: "auto",
4692
4692
  placeholder: t ?? w.placeholder,
4693
4693
  "aria-label": w.command,
@@ -4696,9 +4696,9 @@ function qo({
4696
4696
  "aria-controls": `${m}-list`,
4697
4697
  "aria-activedescendant": re ? `${m}-${re.key}` : void 0,
4698
4698
  onChange: (h) => {
4699
- V(h.target.value), F(null);
4699
+ H(h.target.value), P(null);
4700
4700
  },
4701
- onKeyDown: C
4701
+ onKeyDown: N
4702
4702
  }
4703
4703
  ),
4704
4704
  /* @__PURE__ */ i("kbd", { className: "ui-cmc__enter", "aria-hidden": "true", children: /* @__PURE__ */ i("svg", { viewBox: "0 0 16 16", children: /* @__PURE__ */ i("path", { d: "M12.5 4v3a2 2 0 0 1-2 2h-7M6 6.5 3.5 9 6 11.5" }) }) })
@@ -4706,46 +4706,46 @@ function qo({
4706
4706
  /* @__PURE__ */ d(
4707
4707
  "div",
4708
4708
  {
4709
- ref: y,
4709
+ ref: v,
4710
4710
  id: `${m}-list`,
4711
4711
  className: "ui-cmc__list",
4712
4712
  role: "listbox",
4713
4713
  "aria-label": w.commands,
4714
- style: !s && b ? { height: b } : void 0,
4715
- onMouseLeave: () => z(!1),
4714
+ style: !s && y ? { height: y } : void 0,
4715
+ onMouseLeave: () => M(!1),
4716
4716
  children: [
4717
4717
  T && /* @__PURE__ */ i("span", { className: "ui-cmc__pill", "data-lit": ee || void 0, style: { transform: `translateY(${T.y}px)`, height: T.h }, "aria-hidden": "true" }),
4718
4718
  /* @__PURE__ */ i("div", { ref: f, className: "ui-cmc__inner", children: te.map((h) => /* @__PURE__ */ d("div", { role: "group", "aria-label": h.label, className: "ui-cmc__group", children: [
4719
4719
  h.key !== "ask" && h.label && /* @__PURE__ */ i("span", { className: "ui-cmc__label", dir: "auto", children: h.label }),
4720
- h.commands.map((N) => /* @__PURE__ */ i(
4720
+ h.commands.map((I) => /* @__PURE__ */ i(
4721
4721
  Bo,
4722
4722
  {
4723
- cmd: N,
4724
- domId: `${m}-${N.key}`,
4725
- selected: N.key === re?.key,
4726
- ran: P?.id === N.key,
4727
- mod: H,
4723
+ cmd: I,
4724
+ domId: `${m}-${I.key}`,
4725
+ selected: I.key === re?.key,
4726
+ ran: F?.id === I.key,
4727
+ mod: W,
4728
4728
  q: K,
4729
4729
  on: p
4730
4730
  },
4731
- N.key
4731
+ I.key
4732
4732
  ))
4733
4733
  ] }, h.key)) })
4734
4734
  ]
4735
4735
  }
4736
4736
  ),
4737
4737
  /* @__PURE__ */ d("footer", { className: "ui-cmc__foot", "aria-live": "polite", children: [
4738
- P ? /* @__PURE__ */ d("span", { className: "ui-cmc__done", children: [
4738
+ F ? /* @__PURE__ */ d("span", { className: "ui-cmc__done", children: [
4739
4739
  /* @__PURE__ */ i("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ i("path", { d: "m3.5 8.5 3 3 6-7" }) }),
4740
- /* @__PURE__ */ i("span", { className: "ui-cmc__done-text", children: P.label })
4741
- ] }, P.label) : /* @__PURE__ */ d("span", { className: "ui-cmc__tip", children: [
4740
+ /* @__PURE__ */ i("span", { className: "ui-cmc__done-text", children: F.label })
4741
+ ] }, F.label) : /* @__PURE__ */ d("span", { className: "ui-cmc__tip", children: [
4742
4742
  /* @__PURE__ */ i("kbd", { children: "Tab" }),
4743
4743
  " ",
4744
4744
  w.jumpSections
4745
4745
  ] }),
4746
4746
  c && /* @__PURE__ */ d("span", { className: "ui-cmc__foot-right", children: [
4747
4747
  /* @__PURE__ */ d("span", { className: "ui-cmc__keys", children: [
4748
- /* @__PURE__ */ i("kbd", { children: H }),
4748
+ /* @__PURE__ */ i("kbd", { children: W }),
4749
4749
  /* @__PURE__ */ i("kbd", { children: "K" })
4750
4750
  ] }),
4751
4751
  w.open
@@ -5482,21 +5482,21 @@ function nr({
5482
5482
  askState: l,
5483
5483
  onTask: x,
5484
5484
  onAsk: _,
5485
- onRetry: v,
5485
+ onRetry: b,
5486
5486
  // PrimeChatKit LOCAL ③ start
5487
5487
  onCopy: w,
5488
5488
  onRegenerate: m,
5489
5489
  onFeedback: k,
5490
- feedbackReasons: y
5490
+ feedbackReasons: v
5491
5491
  // PrimeChatKit LOCAL ③ end
5492
5492
  }) {
5493
- const f = Yo(), b = e.parts.length - 1, M = e.parts.filter((L) => L.kind === "text"), j = M.map((L) => L.text).join(`
5493
+ const f = Yo(), y = e.parts.length - 1, L = e.parts.filter((C) => C.kind === "text"), z = L.map((C) => C.text).join(`
5494
5494
 
5495
- `), V = ["copy"];
5496
- return m && V.push("regenerate"), k && V.push("feedback"), // PrimeChatKit LOCAL ③ start
5495
+ `), H = ["copy"];
5496
+ return m && H.push("regenerate"), k && H.push("feedback"), // PrimeChatKit LOCAL ③ start
5497
5497
  /* @__PURE__ */ d("div", { className: "ui-th-agent", "data-ui-message": e.id, "data-streaming": e.streaming || void 0, children: [
5498
5498
  c ? /* @__PURE__ */ d("span", { className: "ui-th-who", children: [
5499
- r ? /* @__PURE__ */ i("span", { className: "ui-th-avatar", "data-image": "", "aria-hidden": "true", children: /* @__PURE__ */ i("img", { src: r, alt: "" }) }) : /* @__PURE__ */ i("span", { className: "ui-th-avatar", "data-busy": e.streaming || void 0, "aria-hidden": "true", children: ur.map((L, F) => /* @__PURE__ */ i("i", { "data-on": L || void 0, style: { animationDelay: `${pr[F]}ms` } }, F)) }),
5499
+ r ? /* @__PURE__ */ i("span", { className: "ui-th-avatar", "data-image": "", "aria-hidden": "true", children: /* @__PURE__ */ i("img", { src: r, alt: "" }) }) : /* @__PURE__ */ i("span", { className: "ui-th-avatar", "data-busy": e.streaming || void 0, "aria-hidden": "true", children: ur.map((C, P) => /* @__PURE__ */ i("i", { "data-on": C || void 0, style: { animationDelay: `${pr[P]}ms` } }, P)) }),
5500
5500
  s.orchestrator,
5501
5501
  /* @__PURE__ */ i("time", { className: "ui-th-who__time ui-th-num", dateTime: new Date(e.at).toISOString(), children: a.format(e.at) })
5502
5502
  ] }) : /* @__PURE__ */ d("span", { className: "ui-th-sr", children: [
@@ -5504,48 +5504,48 @@ function nr({
5504
5504
  ":"
5505
5505
  ] }),
5506
5506
  t,
5507
- e.parts.map((L, F) => {
5508
- const P = `${L.kind}-${F}`;
5509
- switch (L.kind) {
5507
+ e.parts.map((C, P) => {
5508
+ const F = `${C.kind}-${P}`;
5509
+ switch (C.kind) {
5510
5510
  // PrimeChatKit LOCAL ② start
5511
5511
  case "text":
5512
5512
  return /* @__PURE__ */ d("div", { className: "ui-th-text", dir: "auto", children: [
5513
- /* @__PURE__ */ i(ut, { text: L.text }),
5514
- e.streaming && F === b && /* @__PURE__ */ i("span", { className: "ui-th-caret", "aria-hidden": "true" })
5515
- ] }, P);
5513
+ /* @__PURE__ */ i(ut, { text: C.text }),
5514
+ e.streaming && P === y && /* @__PURE__ */ i("span", { className: "ui-th-caret", "aria-hidden": "true" })
5515
+ ] }, F);
5516
5516
  // PrimeChatKit LOCAL ② end
5517
5517
  // PrimeChatKit LOCAL ㉘ start
5518
5518
  case "note":
5519
- return /* @__PURE__ */ i("div", { className: "ui-th-note", dir: "auto", children: /* @__PURE__ */ i(ut, { text: L.text }) }, P);
5519
+ return /* @__PURE__ */ i("div", { className: "ui-th-note", dir: "auto", children: /* @__PURE__ */ i(ut, { text: C.text }) }, F);
5520
5520
  // PrimeChatKit LOCAL ㉘ end
5521
5521
  case "tools":
5522
- return /* @__PURE__ */ i(or, { tools: L.tools, now: u, labels: s, phase: o, liveOpen: n }, L.id);
5522
+ return /* @__PURE__ */ i(or, { tools: C.tools, now: u, labels: s, phase: o, liveOpen: n }, C.id);
5523
5523
  // PrimeChatKit LOCAL ㉕ end
5524
5524
  case "task":
5525
- return /* @__PURE__ */ i(cr, { task: L.task, labels: s, onOpen: () => x(L.task.id) }, P);
5525
+ return /* @__PURE__ */ i(cr, { task: C.task, labels: s, onOpen: () => x(C.task.id) }, F);
5526
5526
  case "decision":
5527
- return /* @__PURE__ */ i(lr, { ask: L.ask, state: l(L.ask.id), labels: s, onClick: () => _(L.ask.id) }, P);
5527
+ return /* @__PURE__ */ i(lr, { ask: C.ask, state: l(C.ask.id), labels: s, onClick: () => _(C.ask.id) }, F);
5528
5528
  case "artifacts":
5529
- return /* @__PURE__ */ i("div", { className: "ui-th-files", children: /* @__PURE__ */ i(Vo, { names: L.names, onOpen: (O) => tr(f, O, s.title) }) }, P);
5529
+ return /* @__PURE__ */ i("div", { className: "ui-th-files", children: /* @__PURE__ */ i(Vo, { names: C.names, onOpen: (D) => tr(f, D, s.title) }) }, F);
5530
5530
  case "error":
5531
- return /* @__PURE__ */ i(dr, { text: L.text, labels: s, onRetry: L.retry ? v : void 0 }, P);
5531
+ return /* @__PURE__ */ i(dr, { text: C.text, labels: s, onRetry: C.retry ? b : void 0 }, F);
5532
5532
  }
5533
5533
  }),
5534
- e.streaming && e.parts[b]?.kind !== "text" && e.parts[b]?.kind !== "tools" && /* @__PURE__ */ i("span", { className: "ui-th-caret ui-th-caret--alone", "aria-hidden": "true" }),
5534
+ e.streaming && e.parts[y]?.kind !== "text" && e.parts[y]?.kind !== "tools" && /* @__PURE__ */ i("span", { className: "ui-th-caret ui-th-caret--alone", "aria-hidden": "true" }),
5535
5535
  e.stopped && /* @__PURE__ */ d("span", { className: "ui-th-stopped", children: [
5536
5536
  /* @__PURE__ */ i("span", { className: "ui-th-stopped__mark", "aria-hidden": "true" }),
5537
5537
  s.stopped
5538
5538
  ] }),
5539
- !e.streaming && M.length > 0 && /* @__PURE__ */ i(
5539
+ !e.streaming && L.length > 0 && /* @__PURE__ */ i(
5540
5540
  Ao,
5541
5541
  {
5542
5542
  labels: s.messageActions,
5543
- text: j,
5544
- actions: V,
5545
- onCopy: w ? () => w(e.id, j) : void 0,
5543
+ text: z,
5544
+ actions: H,
5545
+ onCopy: w ? () => w(e.id, z) : void 0,
5546
5546
  onRegenerate: m ? () => m(e.id) : void 0,
5547
- onFeedback: k ? (...L) => k(e.id, ...L) : void 0,
5548
- reasons: y
5547
+ onFeedback: k ? (...C) => k(e.id, ...C) : void 0,
5548
+ reasons: v
5549
5549
  }
5550
5550
  )
5551
5551
  ] });
@@ -5557,9 +5557,9 @@ function _i({ size: e = 14 }) {
5557
5557
  ] });
5558
5558
  }
5559
5559
  function or({ tools: e, now: t, labels: o, phase: n, liveOpen: a = !0 }) {
5560
- const r = e.filter((V) => V.status === "running").length, c = e.filter((V) => V.status === "failed").length, u = e.some((V) => V.status === "stopped"), s = n === "working" ? !1 : n === "writing" ? !0 : r === 0, [l, x] = I(null), [_, v] = I(n);
5561
- _ !== n && (v(n), a && (n === "working" || n === "writing") && x(null));
5562
- const [w, m] = I(!1), k = q(!s);
5560
+ const r = e.filter((H) => H.status === "running").length, c = e.filter((H) => H.status === "failed").length, u = e.some((H) => H.status === "stopped"), s = n === "working" ? !1 : n === "writing" ? !0 : r === 0, [l, x] = A(null), [_, b] = A(n);
5561
+ _ !== n && (b(n), a && (n === "working" || n === "writing") && x(null));
5562
+ const [w, m] = A(!1), k = U(!s);
5563
5563
  se(() => {
5564
5564
  if (n === "writing") {
5565
5565
  k.current = !1, m(!1);
@@ -5571,21 +5571,21 @@ function or({ tools: e, now: t, labels: o, phase: n, liveOpen: a = !0 }) {
5571
5571
  }
5572
5572
  if (!k.current) return;
5573
5573
  k.current = !1, m(!0);
5574
- const V = window.setTimeout(() => m(!1), 650);
5575
- return () => window.clearTimeout(V);
5574
+ const H = window.setTimeout(() => m(!1), 650);
5575
+ return () => window.clearTimeout(H);
5576
5576
  }, [s, n]);
5577
- const y = a ? n === "working" || (l ?? (n === "writing" ? !1 : !s || w || c > 0)) : l ?? c > 0, f = Math.max(0, ...e.map((V) => V.ms ?? 0)), b = e.length, M = s ? u ? o.toolsStopped(e.filter((V) => V.status === "done").length, b) : c ? o.toolsFailed(b, c) : o.toolsRan(b, o.duration(f)) : o.toolsRunning(b), j = `ui-th-tools-${qe().replace(/:/g, "")}`;
5578
- return /* @__PURE__ */ d("div", { className: "ui-th-tools", "data-open": y, "data-state": s ? c ? "failed" : "done" : "running", children: [
5579
- /* @__PURE__ */ d("button", { type: "button", className: "ui-th-tools__head", "aria-expanded": y, "aria-controls": j, onClick: () => x(!y), children: [
5577
+ const v = a ? n === "working" || (l ?? (n === "writing" ? !1 : !s || w || c > 0)) : l ?? c > 0, f = Math.max(0, ...e.map((H) => H.ms ?? 0)), y = e.length, L = s ? u ? o.toolsStopped(e.filter((H) => H.status === "done").length, y) : c ? o.toolsFailed(y, c) : o.toolsRan(y, o.duration(f)) : o.toolsRunning(y), z = `ui-th-tools-${qe().replace(/:/g, "")}`;
5578
+ return /* @__PURE__ */ d("div", { className: "ui-th-tools", "data-open": v, "data-state": s ? c ? "failed" : "done" : "running", children: [
5579
+ /* @__PURE__ */ d("button", { type: "button", className: "ui-th-tools__head", "aria-expanded": v, "aria-controls": z, onClick: () => x(!v), children: [
5580
5580
  /* @__PURE__ */ i("span", { className: "ui-th-tools__glyph", "aria-hidden": "true", children: s ? c ? /* @__PURE__ */ i(Be, { icon: Wt, size: 14 }) : /* @__PURE__ */ i(Be, { icon: la, size: 14, stroke: 2.2 }) : /* @__PURE__ */ i(_i, {}) }),
5581
- /* @__PURE__ */ i("span", { className: "ui-th-tools__title", "data-shimmer": !s || void 0, "data-text": M, children: M }, s ? "done" : "run"),
5581
+ /* @__PURE__ */ i("span", { className: "ui-th-tools__title", "data-shimmer": !s || void 0, "data-text": L, children: L }, s ? "done" : "run"),
5582
5582
  /* @__PURE__ */ i("span", { className: "ui-th-tools__chev", "aria-hidden": "true", children: /* @__PURE__ */ i(Be, { icon: tn, size: 12 }) })
5583
5583
  ] }),
5584
- /* @__PURE__ */ i("div", { className: "ui-th-tools__wrap", id: j, inert: !y, children: /* @__PURE__ */ i("ul", { className: "ui-th-tools__list", children: e.map((V) => /* @__PURE__ */ i(rr, { tool: V, now: t, labels: o }, V.id)) }) })
5584
+ /* @__PURE__ */ i("div", { className: "ui-th-tools__wrap", id: z, inert: !v, children: /* @__PURE__ */ i("ul", { className: "ui-th-tools__list", children: e.map((H) => /* @__PURE__ */ i(rr, { tool: H, now: t, labels: o }, H.id)) }) })
5585
5585
  ] });
5586
5586
  }
5587
5587
  function rr({ tool: e, now: t, labels: o }) {
5588
- const [n, a] = I(!1), r = `ui-th-tool-${qe().replace(/:/g, "")}`, c = e.args !== void 0 || e.result !== void 0 || e.error !== void 0, u = /* @__PURE__ */ d(Me, { children: [
5588
+ const [n, a] = A(!1), r = `ui-th-tool-${qe().replace(/:/g, "")}`, c = e.args !== void 0 || e.result !== void 0 || e.error !== void 0, u = /* @__PURE__ */ d(Me, { children: [
5589
5589
  /* @__PURE__ */ i("span", { className: "ui-th-tool__mark", "aria-hidden": "true", children: e.status === "running" ? /* @__PURE__ */ i(_i, { size: 12 }) : e.status === "failed" ? /* @__PURE__ */ i(Be, { icon: Wt, size: 12 }) : e.status === "stopped" ? /* @__PURE__ */ i("span", { className: "ui-th-tool__stop" }) : /* @__PURE__ */ i(Be, { icon: la, size: 12, stroke: 2.4 }) }),
5590
5590
  e.icon && /* @__PURE__ */ i("span", { className: "ui-th-tool__icon", "aria-hidden": "true", children: /* @__PURE__ */ i(Be, { icon: e.icon, size: 13 }) }),
5591
5591
  /* @__PURE__ */ d("span", { className: "ui-th-tool__label", dir: "auto", title: e.label, children: [
@@ -6339,49 +6339,49 @@ const gr = (
6339
6339
  e.map((t, o) => /* @__PURE__ */ i("rect", { "data-tone": t.tone ?? "soft", x: t.x, y: t.y, width: t.w, height: t.h, rx: t.r ?? 2 }, o))
6340
6340
  ] });
6341
6341
  function Ta({ decisions: e, onDecide: t, onLater: o, defaultFolded: n = !1, reveal: a, labels: r, className: c }) {
6342
- const u = { ...xr, ...r }, [s, l] = I(() => /* @__PURE__ */ new Set());
6342
+ const u = { ...xr, ...r }, [s, l] = A(() => /* @__PURE__ */ new Set());
6343
6343
  se(() => {
6344
- l(($) => {
6345
- if (!$.size) return $;
6346
- const Y = new Set(e.map((A) => A.id)), p = new Set([...$].filter((A) => Y.has(A)));
6347
- return p.size === $.size ? $ : p;
6344
+ l((E) => {
6345
+ if (!E.size) return E;
6346
+ const V = new Set(e.map((S) => S.id)), p = new Set([...E].filter((S) => V.has(S)));
6347
+ return p.size === E.size ? E : p;
6348
6348
  });
6349
6349
  }, [e]);
6350
- const x = e.filter(($) => !s.has($.id)), _ = x.filter(($) => !$.readOnly), [v, w] = I({}), [m, k] = I(null), [y, f] = I(n), [b, M] = I({}), [j, V] = I(!1), [L, F] = I(""), P = Math.max(0, x.findIndex(($) => $.id === m)), O = x[P] ?? null, T = q(O);
6351
- O && (T.current = O);
6352
- const B = O ?? T.current, ee = O ? y && !O.readOnly ? "min" : "full" : "none", z = q(null), H = q(null), Z = q(!1);
6353
- Z.current = typeof document < "u" && !!z.current?.contains(document.activeElement);
6354
- const K = ($) => F((Y) => Y === $ ? `${$} ` : $);
6350
+ const x = e.filter((E) => !s.has(E.id)), _ = x.filter((E) => !E.readOnly), [b, w] = A({}), [m, k] = A(null), [v, f] = A(n), [y, L] = A({}), [z, H] = A(!1), [C, P] = A(""), F = Math.max(0, x.findIndex((E) => E.id === m)), D = x[F] ?? null, T = U(D);
6351
+ D && (T.current = D);
6352
+ const B = D ?? T.current, ee = D ? v && !D.readOnly ? "min" : "full" : "none", M = U(null), W = U(null), Z = U(!1);
6353
+ Z.current = typeof document < "u" && !!M.current?.contains(document.activeElement);
6354
+ const K = (E) => P((V) => V === E ? `${E} ` : E);
6355
6355
  ke(() => {
6356
- const $ = Z.current && ee !== "none" && (!document.activeElement || document.activeElement === document.body), Y = H.current ?? ($ ? ee === "min" ? "show" : "row" : null);
6357
- if (H.current = null, !Y) return;
6358
- const p = z.current;
6359
- (Y === "show" && p?.querySelector(".ui-dcc__show") || (Y === "prev" || Y === "next") && p?.querySelector(`.ui-dcc__page[data-step="${Y}"]`) || // No options: the field for your own words takes the focus
6356
+ const E = Z.current && ee !== "none" && (!document.activeElement || document.activeElement === document.body), V = W.current ?? (E ? ee === "min" ? "show" : "row" : null);
6357
+ if (W.current = null, !V) return;
6358
+ const p = M.current;
6359
+ (V === "show" && p?.querySelector(".ui-dcc__show") || (V === "prev" || V === "next") && p?.querySelector(`.ui-dcc__page[data-step="${V}"]`) || // No options: the field for your own words takes the focus
6360
6360
  p?.querySelector('[role="option"][tabindex="0"], .ui-dcc__input'))?.focus({ preventScroll: !0 });
6361
6361
  });
6362
- const te = q(a);
6362
+ const te = U(a);
6363
6363
  se(() => {
6364
6364
  if (a === te.current) return;
6365
- te.current = a, f(!1), H.current = "row", V(!0);
6366
- const $ = window.setTimeout(() => V(!1), 700);
6367
- return () => window.clearTimeout($);
6365
+ te.current = a, f(!1), W.current = "row", H(!0);
6366
+ const E = window.setTimeout(() => H(!1), 700);
6367
+ return () => window.clearTimeout(E);
6368
6368
  }, [a]);
6369
- const X = ($, Y) => {
6370
- if ($.readOnly || s.has($.id)) return;
6369
+ const X = (E, V) => {
6370
+ if (E.readOnly || s.has(E.id)) return;
6371
6371
  const p = _.length - 1;
6372
- w(({ [$.id]: C, ...h }) => h);
6373
- const A = x[P + 1] ?? x[P - 1] ?? null;
6374
- l((C) => new Set(C).add($.id)), k(A?.id ?? null), M(({ [$.id]: C, ...h }) => h), K(`${u.answered}: ${_r($, Y, u)}. ${p ? u.waiting(p) : u.allDone}`), t?.($.id, Y);
6372
+ w(({ [E.id]: N, ...h }) => h);
6373
+ const S = x[F + 1] ?? x[F - 1] ?? null;
6374
+ l((N) => new Set(N).add(E.id)), k(S?.id ?? null), L(({ [E.id]: N, ...h }) => h), K(`${u.answered}: ${_r(E, V, u)}. ${p ? u.waiting(p) : u.allDone}`), t?.(E.id, V);
6375
6375
  }, oe = () => {
6376
- !O || O.readOnly || (f(!0), H.current = "show", K(`${u.later} – ${u.waiting(_.length)}`), o?.(O.id));
6376
+ !D || D.readOnly || (f(!0), W.current = "show", K(`${u.later} – ${u.waiting(_.length)}`), o?.(D.id));
6377
6377
  }, re = () => {
6378
- f(!1), H.current = "row";
6379
- }, W = ($) => {
6380
- x.length < 2 || (z.current?.contains(document.activeElement) && (H.current = $ < 0 ? "prev" : "next"), k(x[(P + $ + x.length) % x.length].id));
6378
+ f(!1), W.current = "row";
6379
+ }, Y = (E) => {
6380
+ x.length < 2 || (M.current?.contains(document.activeElement) && (W.current = E < 0 ? "prev" : "next"), k(x[(F + E + x.length) % x.length].id));
6381
6381
  };
6382
- return /* @__PURE__ */ d("div", { ref: z, className: ["ui-dcc", c].filter(Boolean).join(" "), "data-mode": ee, children: [
6382
+ return /* @__PURE__ */ d("div", { ref: M, className: ["ui-dcc", c].filter(Boolean).join(" "), "data-mode": ee, children: [
6383
6383
  /* @__PURE__ */ i("style", { href: "ui-decision-card-clean", precedence: "default", children: Mr }),
6384
- /* @__PURE__ */ i("span", { className: "ui-dcc__sr", role: "status", "aria-live": "polite", children: L }),
6384
+ /* @__PURE__ */ i("span", { className: "ui-dcc__sr", role: "status", "aria-live": "polite", children: C }),
6385
6385
  /* @__PURE__ */ i("div", { className: "ui-dcc__wrap", inert: ee === "none", children: /* @__PURE__ */ i("div", { className: "ui-dcc__inner", children: ee === "min" ? /* @__PURE__ */ i("div", { className: "ui-dcc__box ui-dcc__box--min", children: /* @__PURE__ */ d("div", { className: "ui-dcc__head", children: [
6386
6386
  /* @__PURE__ */ i("span", { className: "ui-dcc__badge", children: u.needsYou }),
6387
6387
  /* @__PURE__ */ i("span", { className: "ui-dcc__task ui-dcc__num", children: u.waiting(_.length) }),
@@ -6394,16 +6394,16 @@ function Ta({ decisions: e, onDecide: t, onLater: o, defaultFolded: n = !1, reve
6394
6394
  d: B,
6395
6395
  L: u,
6396
6396
  count: _.length,
6397
- index: _.findIndex(($) => $.id === B.id),
6397
+ index: _.findIndex((E) => E.id === B.id),
6398
6398
  pageCount: x.length,
6399
- selected: v[B.id] ?? [],
6400
- onSelect: ($) => w((Y) => ({ ...Y, [B.id]: $ })),
6401
- pulse: j,
6402
- draft: b[B.id] ?? "",
6403
- onDraft: ($) => M((Y) => ({ ...Y, [B.id]: $ })),
6404
- onAnswer: ($) => X(B, $),
6399
+ selected: b[B.id] ?? [],
6400
+ onSelect: (E) => w((V) => ({ ...V, [B.id]: E })),
6401
+ pulse: z,
6402
+ draft: y[B.id] ?? "",
6403
+ onDraft: (E) => L((V) => ({ ...V, [B.id]: E })),
6404
+ onAnswer: (E) => X(B, E),
6405
6405
  onLater: oe,
6406
- onPage: W
6406
+ onPage: Y
6407
6407
  },
6408
6408
  B.id
6409
6409
  )
@@ -6425,54 +6425,54 @@ function zr({
6425
6425
  onDraft: l,
6426
6426
  onAnswer: x,
6427
6427
  onLater: _,
6428
- onPage: v
6428
+ onPage: b
6429
6429
  }) {
6430
- const w = `ui-dcc-q-${qe().replace(/:/g, "")}`, m = wr(n, a), k = n.kind === "pick", [y, f] = I(() => Math.max(0, m.findIndex((z) => z.recommended))), b = q(null), M = q(null), [j, V] = I(null), L = n.own !== !1 && !n.readOnly, F = t.length >= (n.multiple?.max ?? 1 / 0), P = t.length >= (n.multiple?.min ?? 0) && t.length <= (n.multiple?.max ?? 1 / 0), O = (z) => {
6430
+ const w = `ui-dcc-q-${qe().replace(/:/g, "")}`, m = wr(n, a), k = n.kind === "pick", [v, f] = A(() => Math.max(0, m.findIndex((M) => M.recommended))), y = U(null), L = U(null), [z, H] = A(null), C = n.own !== !1 && !n.readOnly, P = t.length >= (n.multiple?.max ?? 1 / 0), F = t.length >= (n.multiple?.min ?? 0) && t.length <= (n.multiple?.max ?? 1 / 0), D = (M) => {
6431
6431
  if (!n.readOnly) {
6432
- if (!n.multiple) return x(z.answer);
6433
- t.includes(z.id) ? o(t.filter((H) => H !== z.id)) : F || o([...t, z.id]);
6432
+ if (!n.multiple) return x(M.answer);
6433
+ t.includes(M.id) ? o(t.filter((W) => W !== M.id)) : P || o([...t, M.id]);
6434
6434
  }
6435
- }, T = (z) => {
6436
- f(z), b.current?.querySelector(`[data-row="${z}"]`)?.focus();
6435
+ }, T = (M) => {
6436
+ f(M), y.current?.querySelector(`[data-row="${M}"]`)?.focus();
6437
6437
  }, B = () => {
6438
- if (!L) return;
6439
- const z = n.validate?.(s.trim()) ?? null;
6440
- if (V(z), z) return M.current?.focus();
6441
- const H = s.trim();
6442
- if (!H) return M.current?.focus();
6443
- x({ text: H });
6438
+ if (!C) return;
6439
+ const M = n.validate?.(s.trim()) ?? null;
6440
+ if (H(M), M) return L.current?.focus();
6441
+ const W = s.trim();
6442
+ if (!W) return L.current?.focus();
6443
+ x({ text: W });
6444
6444
  };
6445
- return /* @__PURE__ */ d("div", { ref: b, className: "ui-dcc__box", role: "group", "aria-labelledby": w, "data-pulse": u || void 0, onKeyDown: (z) => {
6446
- if (n.readOnly || z.metaKey || z.ctrlKey || z.altKey || z.nativeEvent.isComposing) return;
6447
- if (z.key === "Escape")
6448
- return z.preventDefault(), _();
6449
- if (z.target.getAttribute("role") !== "option") return;
6450
- const H = /^[1-9]$/.test(z.key) ? Number(z.key) : 0;
6451
- if (H >= 1 && H <= m.length)
6452
- return z.preventDefault(), O(m[H - 1]);
6453
- if (L && z.key === "ArrowDown" && y === m.length - 1)
6454
- return z.preventDefault(), M.current?.focus();
6445
+ return /* @__PURE__ */ d("div", { ref: y, className: "ui-dcc__box", role: "group", "aria-labelledby": w, "data-pulse": u || void 0, onKeyDown: (M) => {
6446
+ if (n.readOnly || M.metaKey || M.ctrlKey || M.altKey || M.nativeEvent.isComposing) return;
6447
+ if (M.key === "Escape")
6448
+ return M.preventDefault(), _();
6449
+ if (M.target.getAttribute("role") !== "option") return;
6450
+ const W = /^[1-9]$/.test(M.key) ? Number(M.key) : 0;
6451
+ if (W >= 1 && W <= m.length)
6452
+ return M.preventDefault(), D(m[W - 1]);
6453
+ if (C && M.key === "ArrowDown" && v === m.length - 1)
6454
+ return M.preventDefault(), L.current?.focus();
6455
6455
  const Z = k ? ["ArrowRight", "ArrowDown"] : ["ArrowDown"], K = k ? ["ArrowLeft", "ArrowUp"] : ["ArrowUp"];
6456
- Z.includes(z.key) ? (z.preventDefault(), T(Math.min(m.length - 1, y + 1))) : K.includes(z.key) ? (z.preventDefault(), T(Math.max(0, y - 1))) : z.key === "Home" ? (z.preventDefault(), T(0)) : z.key === "End" ? (z.preventDefault(), T(m.length - 1)) : (z.key === "Enter" || z.key === " ") && (z.preventDefault(), O(m[y]));
6456
+ Z.includes(M.key) ? (M.preventDefault(), T(Math.min(m.length - 1, v + 1))) : K.includes(M.key) ? (M.preventDefault(), T(Math.max(0, v - 1))) : M.key === "Home" ? (M.preventDefault(), T(0)) : M.key === "End" ? (M.preventDefault(), T(m.length - 1)) : (M.key === "Enter" || M.key === " ") && (M.preventDefault(), D(m[v]));
6457
6457
  }, children: [
6458
6458
  /* @__PURE__ */ d("div", { className: "ui-dcc__head", children: [
6459
6459
  /* @__PURE__ */ i("span", { className: "ui-dcc__badge", children: a.needsYou }),
6460
6460
  /* @__PURE__ */ i("span", { className: "ui-dcc__task", dir: "auto", children: n.task }),
6461
6461
  /* @__PURE__ */ d("span", { className: "ui-dcc__tools", children: [
6462
6462
  e > 1 && /* @__PURE__ */ d("span", { className: "ui-dcc__pager", children: [
6463
- /* @__PURE__ */ i("button", { type: "button", className: "ui-dcc__page", "data-step": "prev", "aria-label": a.previous, onClick: () => v(-1), children: /* @__PURE__ */ i(br, {}) }),
6463
+ /* @__PURE__ */ i("button", { type: "button", className: "ui-dcc__page", "data-step": "prev", "aria-label": a.previous, onClick: () => b(-1), children: /* @__PURE__ */ i(br, {}) }),
6464
6464
  !n.readOnly && r > 1 && /* @__PURE__ */ i("span", { className: "ui-dcc__num ui-dcc__count", style: { minWidth: `${a.of(r, r).length}ch` }, children: a.of(c + 1, r) }),
6465
- /* @__PURE__ */ i("button", { type: "button", className: "ui-dcc__page", "data-step": "next", "aria-label": a.next, onClick: () => v(1), children: /* @__PURE__ */ i(vr, {}) })
6465
+ /* @__PURE__ */ i("button", { type: "button", className: "ui-dcc__page", "data-step": "next", "aria-label": a.next, onClick: () => b(1), children: /* @__PURE__ */ i(vr, {}) })
6466
6466
  ] }),
6467
6467
  !n.readOnly && /* @__PURE__ */ i("button", { type: "button", className: "ui-dcc__link", "aria-keyshortcuts": "Escape", onClick: _, children: a.later })
6468
6468
  ] })
6469
6469
  ] }),
6470
6470
  /* @__PURE__ */ d("div", { className: "ui-dcc__body", children: [
6471
6471
  n.body !== void 0 ? /* @__PURE__ */ i("div", { id: w, className: "ui-dcc__q", "data-rich": "", dir: "auto", children: n.body }) : /* @__PURE__ */ i("p", { id: w, className: "ui-dcc__q", dir: "auto", children: n.question }),
6472
- !n.readOnly && n.facts && n.facts.length > 0 && /* @__PURE__ */ i("dl", { className: "ui-dcc__facts", children: n.facts.slice(0, 3).map((z, H) => /* @__PURE__ */ d("div", { children: [
6473
- /* @__PURE__ */ i("dt", { title: z.label, children: z.label }),
6474
- /* @__PURE__ */ i("dd", { dir: "auto", children: z.value })
6475
- ] }, H)) }),
6472
+ !n.readOnly && n.facts && n.facts.length > 0 && /* @__PURE__ */ i("dl", { className: "ui-dcc__facts", children: n.facts.slice(0, 3).map((M, W) => /* @__PURE__ */ d("div", { children: [
6473
+ /* @__PURE__ */ i("dt", { title: M.label, children: M.label }),
6474
+ /* @__PURE__ */ i("dd", { dir: "auto", children: M.value })
6475
+ ] }, W)) }),
6476
6476
  !n.readOnly && /* @__PURE__ */ i(
6477
6477
  "div",
6478
6478
  {
@@ -6483,70 +6483,70 @@ function zr({
6483
6483
  "aria-orientation": k ? "horizontal" : "vertical",
6484
6484
  "data-many": k && m.length > 3 ? "" : void 0,
6485
6485
  style: k ? { "--ui-dcc-cols": Math.max(3, m.length) } : void 0,
6486
- children: m.map((z, H) => /* @__PURE__ */ d(
6486
+ children: m.map((M, W) => /* @__PURE__ */ d(
6487
6487
  "button",
6488
6488
  {
6489
6489
  type: "button",
6490
6490
  role: "option",
6491
6491
  className: k ? "ui-dcc__tile" : "ui-dcc__opt",
6492
- "data-row": H,
6493
- "aria-selected": n.multiple ? t.includes(z.id) : H === y,
6494
- "aria-disabled": n.multiple && F && !t.includes(z.id) || void 0,
6495
- "aria-keyshortcuts": H < 9 ? String(H + 1) : void 0,
6496
- tabIndex: H === y ? 0 : -1,
6497
- onFocus: () => f(H),
6498
- onClick: () => O(z),
6492
+ "data-row": W,
6493
+ "aria-selected": n.multiple ? t.includes(M.id) : W === v,
6494
+ "aria-disabled": n.multiple && P && !t.includes(M.id) || void 0,
6495
+ "aria-keyshortcuts": W < 9 ? String(W + 1) : void 0,
6496
+ tabIndex: W === v ? 0 : -1,
6497
+ onFocus: () => f(W),
6498
+ onClick: () => D(M),
6499
6499
  children: [
6500
- k && /* @__PURE__ */ i("span", { className: "ui-dcc__frame", "aria-hidden": "true", children: z.preview ?? (z.blocks ? /* @__PURE__ */ i(kr, { blocks: z.blocks }) : null) }),
6501
- k && z.recommended && /* @__PURE__ */ i("span", { className: "ui-dcc__tag ui-dcc__tag--tile", children: a.recommended }),
6500
+ k && /* @__PURE__ */ i("span", { className: "ui-dcc__frame", "aria-hidden": "true", children: M.preview ?? (M.blocks ? /* @__PURE__ */ i(kr, { blocks: M.blocks }) : null) }),
6501
+ k && M.recommended && /* @__PURE__ */ i("span", { className: "ui-dcc__tag ui-dcc__tag--tile", children: a.recommended }),
6502
6502
  /* @__PURE__ */ d("span", { className: "ui-dcc__row", children: [
6503
- /* @__PURE__ */ i("span", { className: "ui-dcc__key ui-dcc__num", "aria-hidden": "true", children: H + 1 }),
6503
+ /* @__PURE__ */ i("span", { className: "ui-dcc__key ui-dcc__num", "aria-hidden": "true", children: W + 1 }),
6504
6504
  /* @__PURE__ */ d("span", { className: "ui-dcc__text", children: [
6505
- /* @__PURE__ */ i("span", { className: "ui-dcc__title", dir: "auto", children: z.title }),
6506
- !k && z.summary && /* @__PURE__ */ i("span", { className: "ui-dcc__summary", dir: "auto", children: z.summary })
6505
+ /* @__PURE__ */ i("span", { className: "ui-dcc__title", dir: "auto", children: M.title }),
6506
+ !k && M.summary && /* @__PURE__ */ i("span", { className: "ui-dcc__summary", dir: "auto", children: M.summary })
6507
6507
  ] }),
6508
- z.recommended && /* @__PURE__ */ i("span", { className: "ui-dcc__tag ui-dcc__tag--row", children: a.recommended })
6508
+ M.recommended && /* @__PURE__ */ i("span", { className: "ui-dcc__tag ui-dcc__tag--row", children: a.recommended })
6509
6509
  ] })
6510
6510
  ]
6511
6511
  },
6512
- z.id
6512
+ M.id
6513
6513
  ))
6514
6514
  }
6515
6515
  ),
6516
- L && /* @__PURE__ */ d("div", { className: "ui-dcc__own", onClick: (z) => z.target === z.currentTarget && M.current?.focus(), children: [
6516
+ C && /* @__PURE__ */ d("div", { className: "ui-dcc__own", onClick: (M) => M.target === M.currentTarget && L.current?.focus(), children: [
6517
6517
  n.body !== void 0 && /* @__PURE__ */ i("span", { id: `${w}-own`, className: "ui-dcc__sr", children: a.own.replace(/…$/, "") }),
6518
6518
  /* @__PURE__ */ i("span", { className: "ui-dcc__key ui-dcc__num", "aria-hidden": "true", children: m.length + 1 }),
6519
6519
  /* @__PURE__ */ i(
6520
6520
  "input",
6521
6521
  {
6522
- ref: M,
6522
+ ref: L,
6523
6523
  className: "ui-dcc__input",
6524
6524
  value: s,
6525
6525
  placeholder: n.placeholder ?? a.own,
6526
6526
  inputMode: n.inputMode,
6527
- "aria-invalid": !!j || void 0,
6528
- "aria-describedby": j ? `${w}-error` : void 0,
6527
+ "aria-invalid": !!z || void 0,
6528
+ "aria-describedby": z ? `${w}-error` : void 0,
6529
6529
  "aria-label": n.body !== void 0 ? void 0 : `${a.own.replace(/…$/, "")}: ${n.question}`,
6530
6530
  "aria-labelledby": n.body !== void 0 ? `${w}-own ${w}` : void 0,
6531
6531
  dir: "auto",
6532
- onChange: (z) => {
6533
- V(null), l(z.target.value);
6532
+ onChange: (M) => {
6533
+ H(null), l(M.target.value);
6534
6534
  },
6535
- onKeyDown: (z) => {
6536
- z.nativeEvent.isComposing || (z.key === "Enter" ? (z.preventDefault(), B()) : z.key === "ArrowUp" && !s && (z.preventDefault(), T(m.length - 1)));
6535
+ onKeyDown: (M) => {
6536
+ M.nativeEvent.isComposing || (M.key === "Enter" ? (M.preventDefault(), B()) : M.key === "ArrowUp" && !s && (M.preventDefault(), T(m.length - 1)));
6537
6537
  }
6538
6538
  }
6539
6539
  ),
6540
6540
  /* @__PURE__ */ i("button", { type: "button", className: "ui-dcc__send", "aria-label": a.send, title: a.send, "aria-disabled": !s.trim() || void 0, "data-shown": s.trim() ? "" : void 0, tabIndex: s.trim() ? 0 : -1, onClick: B, children: /* @__PURE__ */ i(yr, {}) })
6541
6541
  ] }),
6542
- L && j && /* @__PURE__ */ i("p", { id: `${w}-error`, className: "ui-dcc__q", role: "alert", children: j }),
6542
+ C && z && /* @__PURE__ */ i("p", { id: `${w}-error`, className: "ui-dcc__q", role: "alert", children: z }),
6543
6543
  !n.readOnly && n.multiple && /* @__PURE__ */ i(
6544
6544
  "button",
6545
6545
  {
6546
6546
  type: "button",
6547
6547
  className: "ui-dcc__link",
6548
- disabled: !P,
6549
- onClick: () => P && x({ options: m.filter((z) => t.includes(z.id)).map((z) => z.id) }),
6548
+ disabled: !F,
6549
+ onClick: () => F && x({ options: m.filter((M) => t.includes(M.id)).map((M) => M.id) }),
6550
6550
  children: a.confirm
6551
6551
  }
6552
6552
  )
@@ -6851,27 +6851,27 @@ function $r({
6851
6851
  autoplay: u = !1,
6852
6852
  className: s
6853
6853
  }) {
6854
- const [l, x] = I([]), [_, v] = I(0), [w, m] = I(""), [, k] = I(0), y = q(null), f = q(null), b = q(null), M = q(0), j = q(l);
6855
- j.current = l;
6856
- const V = qe();
6857
- Qa(e, () => ({ pick: () => y.current?.click() }), []);
6858
- const L = { ...Aa, ...t }, F = o?.map((g) => g.replace(/^\./, "").toLowerCase()), P = F?.length ? L.acceptedTypes(F) : L.anyFile, O = Number.isFinite(n) && n > 0 ? n : 1 / 0, T = c ?? (O < 1 / 0 ? L.hint(P, Et(O, L)) : P);
6854
+ const [l, x] = A([]), [_, b] = A(0), [w, m] = A(""), [, k] = A(0), v = U(null), f = U(null), y = U(null), L = U(0), z = U(l);
6855
+ z.current = l;
6856
+ const H = qe();
6857
+ Qa(e, () => ({ pick: () => v.current?.click() }), []);
6858
+ const C = { ...Aa, ...t }, P = o?.map((g) => g.replace(/^\./, "").toLowerCase()), F = P?.length ? C.acceptedTypes(P) : C.anyFile, D = Number.isFinite(n) && n > 0 ? n : 1 / 0, T = c ?? (D < 1 / 0 ? C.hint(F, Et(D, C)) : F);
6859
6859
  se(() => {
6860
- r?.(l.filter((g) => !g.removing).map(({ id: g, name: D, size: R, status: U, progress: S, error: ae, file: fe }) => ({ id: g, name: D, size: R, status: U, progress: S, error: ae, file: fe })));
6860
+ r?.(l.filter((g) => !g.removing).map(({ id: g, name: O, size: R, status: q, progress: $, error: ae, file: fe }) => ({ id: g, name: O, size: R, status: q, progress: $, error: ae, file: fe })));
6861
6861
  }, [l]), ke(() => {
6862
- const g = f.current, D = b.current;
6863
- if (!g || !D) return;
6864
- const R = () => g.style.height = `${D.offsetHeight}px`;
6862
+ const g = f.current, O = y.current;
6863
+ if (!g || !O) return;
6864
+ const R = () => g.style.height = `${O.offsetHeight}px`;
6865
6865
  R();
6866
- const U = new ResizeObserver(R);
6867
- return U.observe(D), () => U.disconnect();
6866
+ const q = new ResizeObserver(R);
6867
+ return q.observe(O), () => q.disconnect();
6868
6868
  }, []);
6869
- const B = (g, D) => x((R) => R.map((U) => U.id === g ? { ...U, ...D } : U)), ee = (g) => {
6870
- const D = Ar();
6869
+ const B = (g, O) => x((R) => R.map((q) => q.id === g ? { ...q, ...O } : q)), ee = (g) => {
6870
+ const O = Ar();
6871
6871
  let R;
6872
- F?.length && !F.includes(Bt(g.name)) ? R = L.unsupportedType(Bt(g.name)) : g.size > O && (R = L.tooLarge(Et(O, L)));
6873
- const U = {
6874
- id: D,
6872
+ P?.length && !P.includes(Bt(g.name)) ? R = C.unsupportedType(Bt(g.name)) : g.size > D && (R = C.tooLarge(Et(D, C)));
6873
+ const q = {
6874
+ id: O,
6875
6875
  name: g.name,
6876
6876
  size: Ct(g.size),
6877
6877
  file: g.file,
@@ -6882,88 +6882,88 @@ function $r({
6882
6882
  startedAt: performance.now(),
6883
6883
  duration: Lr(Ct(g.size))
6884
6884
  };
6885
- x((S) => [...S, U]), R ? m(L.errorAnnouncement(g.name, R)) : a && g.file && z(U);
6886
- }, z = (g) => {
6885
+ x(($) => [...$, q]), R ? m(C.errorAnnouncement(g.name, R)) : a && g.file && M(q);
6886
+ }, M = (g) => {
6887
6887
  a(
6888
6888
  g.file,
6889
- (D) => x((R) => R.map((U) => U.id === g.id && U.status === "uploading" ? { ...U, progress: Math.max(U.progress, Nr(D)) } : U))
6889
+ (O) => x((R) => R.map((q) => q.id === g.id && q.status === "uploading" ? { ...q, progress: Math.max(q.progress, Nr(O)) } : q))
6890
6890
  ).then(() => {
6891
- B(g.id, { status: "done", progress: 1 }), m(L.uploadedAnnouncement(g.name));
6892
- }).catch((D) => {
6893
- const R = D instanceof Error && D.message ? D.message : L.uploadFailed;
6894
- B(g.id, { status: "error", error: R, retryable: !0 }), m(L.errorAnnouncement(g.name, R));
6891
+ B(g.id, { status: "done", progress: 1 }), m(C.uploadedAnnouncement(g.name));
6892
+ }).catch((O) => {
6893
+ const R = O instanceof Error && O.message ? O.message : C.uploadFailed;
6894
+ B(g.id, { status: "error", error: R, retryable: !0 }), m(C.errorAnnouncement(g.name, R));
6895
6895
  });
6896
- }, H = (g) => Array.from(g).forEach((D) => ee({ name: D.name, size: D.size, file: D })), Z = l.some((g) => g.status === "uploading" && (!a || !g.file));
6896
+ }, W = (g) => Array.from(g).forEach((O) => ee({ name: O.name, size: O.size, file: O })), Z = l.some((g) => g.status === "uploading" && (!a || !g.file));
6897
6897
  se(() => {
6898
6898
  if (!Z) return;
6899
6899
  const g = window.setInterval(() => {
6900
- const D = performance.now();
6900
+ const O = performance.now();
6901
6901
  x(
6902
- (R) => R.map((U) => {
6903
- if (U.status !== "uploading" || a && U.file) return U;
6904
- const S = Math.min(1, (D - U.startedAt) / U.duration), ae = Math.max(U.progress, S < 1 ? S * (0.92 + Math.random() * 0.08) : 1);
6905
- return U.failAt !== void 0 && ae >= U.failAt ? (m(L.failedAnnouncement(U.name)), { ...U, progress: U.failAt, status: "error", error: L.connectionLost, retryable: !0 }) : ae >= 1 ? (m(L.uploadedAnnouncement(U.name)), { ...U, progress: 1, status: "done" }) : { ...U, progress: ae };
6902
+ (R) => R.map((q) => {
6903
+ if (q.status !== "uploading" || a && q.file) return q;
6904
+ const $ = Math.min(1, (O - q.startedAt) / q.duration), ae = Math.max(q.progress, $ < 1 ? $ * (0.92 + Math.random() * 0.08) : 1);
6905
+ return q.failAt !== void 0 && ae >= q.failAt ? (m(C.failedAnnouncement(q.name)), { ...q, progress: q.failAt, status: "error", error: C.connectionLost, retryable: !0 }) : ae >= 1 ? (m(C.uploadedAnnouncement(q.name)), { ...q, progress: 1, status: "done" }) : { ...q, progress: ae };
6906
6906
  })
6907
6907
  );
6908
6908
  }, 90);
6909
6909
  return () => clearInterval(g);
6910
6910
  }, [Z, a]), se(() => {
6911
- if (!l.some((D) => D.status === "uploading")) return;
6912
- const g = window.setInterval(() => k((D) => D + 1), 500);
6911
+ if (!l.some((O) => O.status === "uploading")) return;
6912
+ const g = window.setInterval(() => k((O) => O + 1), 500);
6913
6913
  return () => clearInterval(g);
6914
6914
  }, [l]), se(() => {
6915
6915
  if (!u) return;
6916
6916
  const g = [
6917
- window.setTimeout(() => v(Ui.length), 700),
6917
+ window.setTimeout(() => b(Ui.length), 700),
6918
6918
  window.setTimeout(() => {
6919
- v(0), Ui.forEach((D, R) => window.setTimeout(() => ee(D), R * 140));
6919
+ b(0), Ui.forEach((O, R) => window.setTimeout(() => ee(O), R * 140));
6920
6920
  }, 1900)
6921
6921
  ];
6922
6922
  return () => g.forEach(clearTimeout);
6923
6923
  }, [u]);
6924
6924
  const K = (g) => {
6925
- B(g.id, { status: "uploading", progress: 0, error: void 0, retryable: !1, failAt: void 0, startedAt: performance.now() }), a && g.file && z({ ...g });
6925
+ B(g.id, { status: "uploading", progress: 0, error: void 0, retryable: !1, failAt: void 0, startedAt: performance.now() }), a && g.file && M({ ...g });
6926
6926
  }, te = (g) => {
6927
- B(g, { removing: !0 }), window.setTimeout(() => x((D) => D.filter((R) => R.id !== g)), 480);
6928
- }, X = () => j.current.filter((g) => g.status !== "uploading").forEach((g) => te(g.id)), oe = (g) => Array.from(g.dataTransfer.types).includes("Files"), re = (g) => {
6929
- oe(g) && (g.preventDefault(), M.current += 1, v(Math.max(1, g.dataTransfer.items.length)));
6930
- }, W = (g) => {
6931
- oe(g) && (g.preventDefault(), g.dataTransfer.dropEffect = "copy");
6932
- }, $ = () => {
6933
- M.current = Math.max(0, M.current - 1), M.current || v(0);
6927
+ B(g, { removing: !0 }), window.setTimeout(() => x((O) => O.filter((R) => R.id !== g)), 480);
6928
+ }, X = () => z.current.filter((g) => g.status !== "uploading").forEach((g) => te(g.id)), oe = (g) => Array.from(g.dataTransfer.types).includes("Files"), re = (g) => {
6929
+ oe(g) && (g.preventDefault(), L.current += 1, b(Math.max(1, g.dataTransfer.items.length)));
6934
6930
  }, Y = (g) => {
6935
- oe(g) && (g.preventDefault(), M.current = 0, v(0), H(g.dataTransfer.files));
6936
- }, p = l.filter((g) => !g.removing), A = p.filter((g) => g.status === "uploading"), C = p.filter((g) => g.status === "done"), h = p.filter((g) => g.status === "error"), N = performance.now();
6937
- let G = null;
6931
+ oe(g) && (g.preventDefault(), g.dataTransfer.dropEffect = "copy");
6932
+ }, E = () => {
6933
+ L.current = Math.max(0, L.current - 1), L.current || b(0);
6934
+ }, V = (g) => {
6935
+ oe(g) && (g.preventDefault(), L.current = 0, b(0), W(g.dataTransfer.files));
6936
+ }, p = l.filter((g) => !g.removing), S = p.filter((g) => g.status === "uploading"), N = p.filter((g) => g.status === "done"), h = p.filter((g) => g.status === "error"), I = performance.now();
6937
+ let Q = null;
6938
6938
  if (p.length)
6939
- if (A.length) {
6940
- const g = A.reduce((U, S) => U + S.size, 0), D = A.reduce((U, S) => U + S.size * S.progress, 0), R = L.uploading(A.length, p.length);
6941
- G = /* @__PURE__ */ d("span", { className: "ui-dzc__summary", children: [
6939
+ if (S.length) {
6940
+ const g = S.reduce((q, $) => q + $.size, 0), O = S.reduce((q, $) => q + $.size * $.progress, 0), R = C.uploading(S.length, p.length);
6941
+ Q = /* @__PURE__ */ d("span", { className: "ui-dzc__summary", children: [
6942
6942
  /* @__PURE__ */ i("span", { className: "ui-dzc__shimmer", "data-text": R, children: R }),
6943
6943
  /* @__PURE__ */ i("span", { className: "ui-dzc__dot", children: "·" }),
6944
- Pi(D, g, L)
6944
+ Pi(O, g, C)
6945
6945
  ] });
6946
6946
  } else
6947
- G = /* @__PURE__ */ d("span", { className: "ui-dzc__summary ui-dzc__summary-done", children: [
6947
+ Q = /* @__PURE__ */ d("span", { className: "ui-dzc__summary ui-dzc__summary-done", children: [
6948
6948
  h.length ? /* @__PURE__ */ i(ct, { d: lt.alertCircle, solid: !0, className: "ui-dzc__warn" }) : /* @__PURE__ */ i(ct, { d: lt.checkCircle, solid: !0, className: "ui-dzc__ok" }),
6949
- h.length ? L.partiallyUploaded(C.length, p.length) : L.allUploaded(C.length)
6949
+ h.length ? C.partiallyUploaded(N.length, p.length) : C.allUploaded(N.length)
6950
6950
  ] });
6951
6951
  return /* @__PURE__ */ d("div", { className: ["ui-dzc", s].filter(Boolean).join(" "), children: [
6952
6952
  /* @__PURE__ */ i("style", { href: "ui-dropzone-clean", precedence: "default", children: Or }),
6953
6953
  /* @__PURE__ */ d("div", { className: "ui-dzc__card", children: [
6954
- /* @__PURE__ */ i("div", { ref: f, className: "ui-dzc__body", children: /* @__PURE__ */ d("div", { ref: b, className: "ui-dzc__inner", children: [
6954
+ /* @__PURE__ */ i("div", { ref: f, className: "ui-dzc__body", children: /* @__PURE__ */ d("div", { ref: y, className: "ui-dzc__inner", children: [
6955
6955
  /* @__PURE__ */ i(
6956
6956
  "input",
6957
6957
  {
6958
- ref: y,
6959
- id: V,
6958
+ ref: v,
6959
+ id: H,
6960
6960
  type: "file",
6961
6961
  multiple: !0,
6962
6962
  accept: o?.join(","),
6963
6963
  className: "ui-dzc__input",
6964
6964
  tabIndex: -1,
6965
6965
  onChange: (g) => {
6966
- g.target.files && H(g.target.files), g.target.value = "";
6966
+ g.target.files && W(g.target.files), g.target.value = "";
6967
6967
  }
6968
6968
  }
6969
6969
  ),
@@ -6973,25 +6973,25 @@ function $r({
6973
6973
  type: "button",
6974
6974
  className: "ui-dzc__area",
6975
6975
  "data-dragging": _ > 0 || void 0,
6976
- "aria-describedby": `${V}-hint`,
6977
- onClick: () => y.current?.click(),
6976
+ "aria-describedby": `${H}-hint`,
6977
+ onClick: () => v.current?.click(),
6978
6978
  onDragEnter: re,
6979
- onDragOver: W,
6980
- onDragLeave: $,
6981
- onDrop: Y,
6979
+ onDragOver: Y,
6980
+ onDragLeave: E,
6981
+ onDrop: V,
6982
6982
  children: [
6983
- /* @__PURE__ */ i(Dr, { labels: L }),
6984
- /* @__PURE__ */ i("span", { className: "ui-dzc__title", children: _ ? L.release(_) : /* @__PURE__ */ d(Me, { children: [
6983
+ /* @__PURE__ */ i(Dr, { labels: C }),
6984
+ /* @__PURE__ */ i("span", { className: "ui-dzc__title", children: _ ? C.release(_) : /* @__PURE__ */ d(Me, { children: [
6985
6985
  /* @__PURE__ */ d("span", { className: "ui-dzc__for-mouse", children: [
6986
- L.dropFiles,
6987
- /* @__PURE__ */ i("span", { className: "ui-dzc__browse", children: L.browse })
6986
+ C.dropFiles,
6987
+ /* @__PURE__ */ i("span", { className: "ui-dzc__browse", children: C.browse })
6988
6988
  ] }),
6989
6989
  /* @__PURE__ */ d("span", { className: "ui-dzc__for-touch", children: [
6990
- L.tapTo,
6991
- /* @__PURE__ */ i("span", { className: "ui-dzc__browse", children: L.chooseFiles })
6990
+ C.tapTo,
6991
+ /* @__PURE__ */ i("span", { className: "ui-dzc__browse", children: C.chooseFiles })
6992
6992
  ] })
6993
6993
  ] }) }, _ ? "drop" : "idle"),
6994
- /* @__PURE__ */ i("span", { className: "ui-dzc__hint", id: `${V}-hint`, children: T })
6994
+ /* @__PURE__ */ i("span", { className: "ui-dzc__hint", id: `${H}-hint`, children: T })
6995
6995
  ]
6996
6996
  }
6997
6997
  ),
@@ -6999,9 +6999,9 @@ function $r({
6999
6999
  "ul",
7000
7000
  {
7001
7001
  className: "ui-dzc__list",
7002
- "aria-label": L.uploads,
7002
+ "aria-label": C.uploads,
7003
7003
  children: l.map((g) => {
7004
- const D = g.status === "uploading" ? (1 - g.progress) * (N - g.startedAt) / Math.max(0.05, g.progress) / 1e3 : 0;
7004
+ const O = g.status === "uploading" ? (1 - g.progress) * (I - g.startedAt) / Math.max(0.05, g.progress) / 1e3 : 0;
7005
7005
  return /* @__PURE__ */ i("li", { className: "ui-dzc__row", "data-status": g.status, "data-removing": g.removing || void 0, children: /* @__PURE__ */ d("div", { className: "ui-dzc__row-inner", children: [
7006
7006
  /* @__PURE__ */ i(Sr, { name: g.name }),
7007
7007
  /* @__PURE__ */ d("div", { className: "ui-dzc__info", children: [
@@ -7014,18 +7014,18 @@ function $r({
7014
7014
  "span",
7015
7015
  {
7016
7016
  className: "ui-dzc__done",
7017
- "aria-label": L.uploaded,
7017
+ "aria-label": C.uploaded,
7018
7018
  children: /* @__PURE__ */ i(ct, { d: lt.checkCircle, solid: !0 })
7019
7019
  }
7020
7020
  )
7021
7021
  ] }),
7022
7022
  /* @__PURE__ */ d("div", { className: "ui-dzc__meta", children: [
7023
7023
  g.status === "uploading" && /* @__PURE__ */ d(Me, { children: [
7024
- Pi(g.size * g.progress, g.size, L),
7024
+ Pi(g.size * g.progress, g.size, C),
7025
7025
  /* @__PURE__ */ i("span", { className: "ui-dzc__dot", children: "·" }),
7026
- g.progress < 0.04 ? L.starting : Cr(D, L)
7026
+ g.progress < 0.04 ? C.starting : Cr(O, C)
7027
7027
  ] }),
7028
- g.status === "done" && Et(g.size, L),
7028
+ g.status === "done" && Et(g.size, C),
7029
7029
  g.status === "error" && /* @__PURE__ */ i("span", { className: "ui-dzc__error", dir: "auto", children: g.error })
7030
7030
  ] }, g.status),
7031
7031
  (g.status !== "error" || g.retryable) && /* @__PURE__ */ i(
@@ -7034,7 +7034,7 @@ function $r({
7034
7034
  className: "ui-dzc__bar",
7035
7035
  "data-hidden": g.status === "done" || void 0,
7036
7036
  role: "progressbar",
7037
- "aria-label": L.uploadProgress(g.name),
7037
+ "aria-label": C.uploadProgress(g.name),
7038
7038
  "aria-valuemin": 0,
7039
7039
  "aria-valuemax": 100,
7040
7040
  "aria-valuenow": Math.round(g.progress * 100),
@@ -7048,7 +7048,7 @@ function $r({
7048
7048
  {
7049
7049
  type: "button",
7050
7050
  className: "ui-dzc__icon-btn ui-dzc__retry",
7051
- "aria-label": L.retry(g.name),
7051
+ "aria-label": C.retry(g.name),
7052
7052
  onClick: () => K(g),
7053
7053
  children: /* @__PURE__ */ i(ct, { d: lt.retry })
7054
7054
  }
@@ -7058,7 +7058,7 @@ function $r({
7058
7058
  {
7059
7059
  type: "button",
7060
7060
  className: "ui-dzc__icon-btn",
7061
- "aria-label": L.remove(g.name),
7061
+ "aria-label": C.remove(g.name),
7062
7062
  onClick: () => te(g.id),
7063
7063
  children: /* @__PURE__ */ i(ct, { d: lt.close })
7064
7064
  }
@@ -7070,8 +7070,8 @@ function $r({
7070
7070
  )
7071
7071
  ] }) }),
7072
7072
  /* @__PURE__ */ d("div", { className: "ui-dzc__foot", children: [
7073
- G ?? /* @__PURE__ */ i("span", { className: "ui-dzc__foot-idle", children: L.noFiles }),
7074
- (C.length > 0 || h.length > 0) && !A.length && /* @__PURE__ */ i("button", { type: "button", className: "ui-dzc__clear", onClick: X, children: L.clear })
7073
+ Q ?? /* @__PURE__ */ i("span", { className: "ui-dzc__foot-idle", children: C.noFiles }),
7074
+ (N.length > 0 || h.length > 0) && !S.length && /* @__PURE__ */ i("button", { type: "button", className: "ui-dzc__clear", onClick: X, children: C.clear })
7075
7075
  ] })
7076
7076
  ] }),
7077
7077
  /* @__PURE__ */ i("span", { className: "ui-dzc__live", "aria-live": "polite", children: w })
@@ -7376,34 +7376,34 @@ function Sa({
7376
7376
  variant: u = "pill",
7377
7377
  className: s
7378
7378
  }) {
7379
- const l = Array.isArray(e) ? e.map((Z) => String(Z ?? "")) : [], x = l.length ? l : qi.slice(0, 1), _ = Number.isFinite(t) && t > 0 ? Math.max(t, 200) : 2200, [v, w] = I(0), [m, k] = I(() => Date.now()), [y, f] = I(null), b = y ?? Math.max(1, Math.round((Date.now() - m) / 1e3));
7380
- a && y === null && f(b), !a && y !== null && (f(null), k(Date.now()), w(0)), se(() => {
7379
+ const l = Array.isArray(e) ? e.map((Z) => String(Z ?? "")) : [], x = l.length ? l : qi.slice(0, 1), _ = Number.isFinite(t) && t > 0 ? Math.max(t, 200) : 2200, [b, w] = A(0), [m, k] = A(() => Date.now()), [v, f] = A(null), y = v ?? Math.max(1, Math.round((Date.now() - m) / 1e3));
7380
+ a && v === null && f(y), !a && v !== null && (f(null), k(Date.now()), w(0)), se(() => {
7381
7381
  if (a || o !== void 0 && Number.isFinite(o) || x.length < 2) return;
7382
7382
  const Z = window.setInterval(() => {
7383
7383
  w((K) => K + 1 < x.length ? K + 1 : n ? 0 : K);
7384
7384
  }, _);
7385
7385
  return () => window.clearInterval(Z);
7386
7386
  }, [a, o, x.length, _, n]);
7387
- const M = o !== void 0 && Number.isFinite(o) ? Math.floor(o) : v, j = Math.min(Math.max(M, 0), Math.max(x.length - 1, 0)), V = String((a ? typeof r == "function" ? r(b) : r : x[j]) ?? ""), [L, F] = I({ key: 0, text: V }), [P, O] = I(null);
7388
- V !== L.text && (O(L), F({ key: L.key + 1, text: V }));
7389
- const T = q(null), B = q(null), ee = q(null), z = q(!1), H = q(() => {
7387
+ const L = o !== void 0 && Number.isFinite(o) ? Math.floor(o) : b, z = Math.min(Math.max(L, 0), Math.max(x.length - 1, 0)), H = String((a ? typeof r == "function" ? r(y) : r : x[z]) ?? ""), [C, P] = A({ key: 0, text: H }), [F, D] = A(null);
7388
+ H !== C.text && (D(C), P({ key: C.key + 1, text: H }));
7389
+ const T = U(null), B = U(null), ee = U(null), M = U(!1), W = U(() => {
7390
7390
  });
7391
- return H.current = () => {
7391
+ return W.current = () => {
7392
7392
  const Z = T.current, K = B.current, te = ee.current;
7393
7393
  if (!Z || !K || !te) return;
7394
7394
  const X = te.scrollWidth + 1, oe = Z.parentElement, re = { width: K.style.width, transition: K.style.transition };
7395
7395
  K.style.transition = "none", K.style.width = `${X}px`;
7396
- const W = oe ? getComputedStyle(oe) : null, $ = oe && W ? oe.clientWidth - parseFloat(W.paddingLeft) - parseFloat(W.paddingRight) : 0, Y = oe ? Math.floor($ - (Z.offsetWidth - K.offsetWidth)) : X;
7396
+ const Y = oe ? getComputedStyle(oe) : null, E = oe && Y ? oe.clientWidth - parseFloat(Y.paddingLeft) - parseFloat(Y.paddingRight) : 0, V = oe ? Math.floor(E - (Z.offsetWidth - K.offsetWidth)) : X;
7397
7397
  K.style.width = re.width, K.getBoundingClientRect(), K.style.transition = re.transition;
7398
- const p = Y > 0 && X > Y;
7399
- Z.toggleAttribute("data-cut", p), K.style.width = `${p ? Y : X}px`;
7398
+ const p = V > 0 && X > V;
7399
+ Z.toggleAttribute("data-cut", p), K.style.width = `${p ? V : X}px`;
7400
7400
  }, ke(() => {
7401
7401
  const Z = B.current;
7402
- Z && (z.current || (Z.style.transition = "none"), H.current(), z.current || (Z.getBoundingClientRect(), Z.style.transition = "", z.current = !0));
7403
- }, [L.key]), se(() => {
7402
+ Z && (M.current || (Z.style.transition = "none"), W.current(), M.current || (Z.getBoundingClientRect(), Z.style.transition = "", M.current = !0));
7403
+ }, [C.key]), se(() => {
7404
7404
  const Z = T.current?.parentElement;
7405
7405
  if (!Z || typeof ResizeObserver > "u") return;
7406
- const K = new ResizeObserver(() => H.current());
7406
+ const K = new ResizeObserver(() => W.current());
7407
7407
  return K.observe(Z), () => K.disconnect();
7408
7408
  }, []), /* @__PURE__ */ d(
7409
7409
  "span",
@@ -7433,28 +7433,28 @@ function Sa({
7433
7433
  /* @__PURE__ */ i("svg", { className: "ui-tlc__check", viewBox: "0 0 16 16", children: /* @__PURE__ */ i("path", { d: "M3.5 8.4 6.6 11.3 12.5 4.9", pathLength: 1 }) })
7434
7434
  ] }),
7435
7435
  /* @__PURE__ */ d("span", { ref: B, className: "ui-tlc__text", children: [
7436
- P && /* @__PURE__ */ i(
7436
+ F && /* @__PURE__ */ i(
7437
7437
  "span",
7438
7438
  {
7439
7439
  className: "ui-tlc__label ui-tlc__label--out",
7440
7440
  "aria-hidden": "true",
7441
7441
  dir: "auto",
7442
- onAnimationEnd: () => O(null),
7443
- children: P.text
7442
+ onAnimationEnd: () => D(null),
7443
+ children: F.text
7444
7444
  },
7445
- P.key
7445
+ F.key
7446
7446
  ),
7447
7447
  /* @__PURE__ */ i(
7448
7448
  "span",
7449
7449
  {
7450
7450
  ref: ee,
7451
- className: ["ui-tlc__label", L.key > 0 && "ui-tlc__label--in", !a && "ui-tlc__shine"].filter(Boolean).join(" "),
7452
- "data-text": L.text,
7453
- title: L.text,
7451
+ className: ["ui-tlc__label", C.key > 0 && "ui-tlc__label--in", !a && "ui-tlc__shine"].filter(Boolean).join(" "),
7452
+ "data-text": C.text,
7453
+ title: C.text,
7454
7454
  dir: "auto",
7455
- children: L.text
7455
+ children: C.text
7456
7456
  },
7457
- L.key
7457
+ C.key
7458
7458
  )
7459
7459
  ] })
7460
7460
  ]
@@ -7735,7 +7735,7 @@ Nt(function({
7735
7735
  sources: s,
7736
7736
  chip: l
7737
7737
  }) {
7738
- const x = new Set(r ? r.split(",").map(Number) : []), _ = (v) => v.map((w) => {
7738
+ const x = new Set(r ? r.split(",").map(Number) : []), _ = (b) => b.map((w) => {
7739
7739
  if (w.i >= n) return null;
7740
7740
  const m = a && w.i === n - 1 ? /* @__PURE__ */ i("span", { className: "ui-ansc__caret", "aria-hidden": "true" }) : null;
7741
7741
  if (w.kind === "word")
@@ -7743,16 +7743,16 @@ Nt(function({
7743
7743
  w.text,
7744
7744
  m
7745
7745
  ] }, w.i);
7746
- const k = s[w.ids[0]], y = w.ids.map((f) => s[f].title).join(", ");
7746
+ const k = s[w.ids[0]], v = w.ids.map((f) => s[f].title).join(", ");
7747
7747
  return /* @__PURE__ */ d("span", { className: "ui-ansc__w", children: [
7748
7748
  /* @__PURE__ */ d(
7749
7749
  "button",
7750
7750
  {
7751
7751
  type: "button",
7752
7752
  className: "ui-ansc__cite",
7753
- title: y,
7753
+ title: v,
7754
7754
  "data-lit": w.ids.some((f) => x.has(f)) || void 0,
7755
- "aria-label": t.source(y),
7755
+ "aria-label": t.source(v),
7756
7756
  "aria-describedby": c === w.ids ? u : void 0,
7757
7757
  onMouseEnter: (f) => l.open(w.ids, f.currentTarget),
7758
7758
  onMouseLeave: l.close,
@@ -7770,7 +7770,7 @@ Nt(function({
7770
7770
  ] }, w.i);
7771
7771
  });
7772
7772
  return o.kind === "p" ? /* @__PURE__ */ i("p", { dir: "auto", children: _(o.tokens) }) : /* @__PURE__ */ i("ul", { children: o.items.map(
7773
- (v, w) => v[0] && v[0].i < n ? /* @__PURE__ */ i("li", { dir: "auto", children: _(v) }, w) : null
7773
+ (b, w) => b[0] && b[0].i < n ? /* @__PURE__ */ i("li", { dir: "auto", children: _(b) }, w) : null
7774
7774
  ) });
7775
7775
  });
7776
7776
  const Ie = {
@@ -8440,11 +8440,11 @@ function ja(e = "zh-CN") {
8440
8440
  return e.toLowerCase().startsWith("zh") ? us : ps;
8441
8441
  }
8442
8442
  function hs({ sessions: e, currentId: t, locale: o, onOpen: n, onRename: a, onDelete: r, onClose: c }) {
8443
- const [u, s] = I(), [l, x] = I();
8443
+ const [u, s] = A(), [l, x] = A();
8444
8444
  se(() => {
8445
8445
  s(void 0), x(void 0);
8446
8446
  }, [t]);
8447
- const _ = cs(o), v = e?.items ?? [], w = Fr(v, { now: Date.now(), copy: _, editingId: u, confirmingId: l });
8447
+ const _ = cs(o), b = e?.items ?? [], w = Fr(b, { now: Date.now(), copy: _, editingId: u, confirmingId: l });
8448
8448
  return e?.error && w.unshift({ id: "history-error", label: "", commands: [{ id: "history-error", label: _.errorText(e.error.code) }] }), /* @__PURE__ */ i(
8449
8449
  qo,
8450
8450
  {
@@ -8454,10 +8454,10 @@ function hs({ sessions: e, currentId: t, locale: o, onOpen: n, onRename: a, onDe
8454
8454
  hotkey: !1,
8455
8455
  autoFocus: !0,
8456
8456
  labels: ds(o),
8457
- placeholder: v.length ? _.search : e?.loading ? _.loading : _.empty,
8457
+ placeholder: b.length ? _.search : e?.loading ? _.loading : _.empty,
8458
8458
  onClose: c,
8459
8459
  onRun: (m) => {
8460
- v.some((k) => k.id === m) && n(m);
8460
+ b.some((k) => k.id === m) && n(m);
8461
8461
  },
8462
8462
  onAction: (m, k) => {
8463
8463
  k === "rename" ? (x(void 0), s(m)) : k === "delete" ? (s(void 0), x(m)) : k === "confirm-delete" ? (x(void 0), r(m)) : k === "cancel" && x(void 0);
@@ -8720,7 +8720,7 @@ function ys(e, t, o = Date.now()) {
8720
8720
  const s = de(a.capabilityName) ?? de(a.toolName) ?? "tool";
8721
8721
  if (s === "runtime-capability-discovery") break;
8722
8722
  const l = de(a.occurrenceId) ?? de(a.callId) ?? `${s}-${r.turns.length}-${o}`;
8723
- if (r.turns.some((v) => v.tools.some((w) => w.id === l))) break;
8723
+ if (r.turns.some((b) => b.tools.some((w) => w.id === l))) break;
8724
8724
  const x = a.input ?? Ue(a.arguments) ?? void 0, _ = {
8725
8725
  id: l,
8726
8726
  callId: de(a.callId),
@@ -8731,25 +8731,25 @@ function ys(e, t, o = Date.now()) {
8731
8731
  startedAt: o,
8732
8732
  args: x
8733
8733
  };
8734
- r = ot(r, rt(a, r), (v) => ({ ...v, tools: [...v.tools, _] }));
8734
+ r = ot(r, rt(a, r), (b) => ({ ...b, tools: [...b.tools, _] }));
8735
8735
  break;
8736
8736
  }
8737
8737
  case "TOOL_EXECUTION_COMPLETED":
8738
8738
  case "CAPABILITY_RESULT": {
8739
- const s = de(a.capabilityName) ?? de(a.toolName) ?? "tool", l = de(a.occurrenceId) ?? de(a.callId), x = String(a.status ?? "").toUpperCase() !== "SUCCESS", _ = Pa(a.result), v = x ? de(a.errorMessage) ?? _.error ?? "Failed" : void 0, w = (y) => ({
8740
- ...y,
8739
+ const s = de(a.capabilityName) ?? de(a.toolName) ?? "tool", l = de(a.occurrenceId) ?? de(a.callId), x = String(a.status ?? "").toUpperCase() !== "SUCCESS", _ = Pa(a.result), b = x ? de(a.errorMessage) ?? _.error ?? "Failed" : void 0, w = (v) => ({
8740
+ ...v,
8741
8741
  status: x || _.ok === !1 ? "error" : "success",
8742
- durationMs: me(a.durationMs) ?? o - y.startedAt,
8742
+ durationMs: me(a.durationMs) ?? o - v.startedAt,
8743
8743
  result: _.value,
8744
- error: v ?? (_.ok === !1 ? _.error ?? "Failed" : void 0)
8745
- }), m = (y) => y.id === l || y.callId && y.callId === de(a.callId), k = r.turns.find((y) => y.tools.some(m))?.iteration ?? rt(a, r);
8746
- r = ot(r, k, (y) => {
8747
- const f = y.tools.findIndex(m);
8744
+ error: b ?? (_.ok === !1 ? _.error ?? "Failed" : void 0)
8745
+ }), m = (v) => v.id === l || v.callId && v.callId === de(a.callId), k = r.turns.find((v) => v.tools.some(m))?.iteration ?? rt(a, r);
8746
+ r = ot(r, k, (v) => {
8747
+ const f = v.tools.findIndex(m);
8748
8748
  if (f !== -1) {
8749
- const M = y.tools.slice();
8750
- return M[f] = w(M[f]), { ...y, tools: M };
8749
+ const L = v.tools.slice();
8750
+ return L[f] = w(L[f]), { ...v, tools: L };
8751
8751
  }
8752
- const b = {
8752
+ const y = {
8753
8753
  id: l ?? `${s}-${o}`,
8754
8754
  callId: de(a.callId),
8755
8755
  capability: s,
@@ -8757,7 +8757,7 @@ function ys(e, t, o = Date.now()) {
8757
8757
  status: "running",
8758
8758
  startedAt: o
8759
8759
  };
8760
- return { ...y, tools: [...y.tools, w(b)] };
8760
+ return { ...v, tools: [...v.tools, w(y)] };
8761
8761
  });
8762
8762
  break;
8763
8763
  }
@@ -8851,40 +8851,40 @@ function ks(e, t, o = {}) {
8851
8851
  });
8852
8852
  const s = [...r.turns].sort((w, m) => w.iteration - m.iteration);
8853
8853
  for (const w of s) {
8854
- const m = Gi(r, w) ? w.text.split(/\r?\n/).map((y) => y.trim()).find((y) => y.length > 0) : void 0, k = Array.from(m ?? "");
8854
+ const m = Gi(r, w) ? w.text.split(/\r?\n/).map((v) => v.trim()).find((v) => v.length > 0) : void 0, k = Array.from(m ?? "");
8855
8855
  c.push({
8856
8856
  id: `${a}:turn:${w.iteration}`,
8857
8857
  label: m ? k.length > 80 ? `${k.slice(0, 80).join("")}…` : m : t.thinking(w.iteration),
8858
8858
  status: w.model?.status === "running" ? "running" : "done",
8859
8859
  ms: w.model?.durationMs
8860
8860
  });
8861
- for (const y of o.processView === "replies" ? [] : w.tools)
8861
+ for (const v of o.processView === "replies" ? [] : w.tools)
8862
8862
  c.push({
8863
- id: y.id,
8864
- label: y.summary || t.toolFallback(y.name),
8865
- name: y.name,
8866
- args: y.args,
8867
- result: y.result,
8868
- error: y.error,
8869
- startedAt: y.startedAt,
8870
- ms: y.durationMs,
8871
- status: y.status === "success" ? "done" : y.status === "error" ? "failed" : r.status === "running" ? "running" : r.status === "cancelled" ? "stopped" : "done"
8863
+ id: v.id,
8864
+ label: v.summary || t.toolFallback(v.name),
8865
+ name: v.name,
8866
+ args: v.args,
8867
+ result: v.result,
8868
+ error: v.error,
8869
+ startedAt: v.startedAt,
8870
+ ms: v.durationMs,
8871
+ status: v.status === "success" ? "done" : v.status === "error" ? "failed" : r.status === "running" ? "running" : r.status === "cancelled" ? "stopped" : "done"
8872
8872
  });
8873
8873
  }
8874
8874
  const l = [];
8875
8875
  if (c.length && l.push({ kind: "tools", id: `${a}:process`, tools: c }), o.processView === "replies" && (r.status === "running" || r.status === "waiting")) {
8876
8876
  let w = "";
8877
8877
  for (const m of s) {
8878
- const k = ws(m.thinking).trim(), y = Gi(r, m) ? m.text.trim() : "";
8879
- k && (w = k), y && (w = y);
8878
+ const k = ws(m.thinking).trim(), v = Gi(r, m) ? m.text.trim() : "";
8879
+ k && (w = k), v && (w = v);
8880
8880
  }
8881
8881
  w && l.push({ kind: "note", text: w });
8882
8882
  }
8883
- const { body: x, sources: _ } = bs(vi(r)), v = x.trim();
8884
- v && l.push({ kind: "text", text: v }), _.length && l.push({ kind: "artifacts", names: _.map((w) => w.label) });
8883
+ const { body: x, sources: _ } = bs(vi(r)), b = x.trim();
8884
+ b && l.push({ kind: "text", text: b }), _.length && l.push({ kind: "artifacts", names: _.map((w) => w.label) });
8885
8885
  for (const w of r.asks)
8886
8886
  l.push({ kind: "decision", ask: { id: w.id, question: w.question, task: w.header ?? "", kind: "decision" } });
8887
- return r.status === "failed" ? l.push({ kind: "error", text: t.failedAnswer, retry: !0 }) : r.status === "completed" && !v && vs(r) === 0 && l.push({ kind: "error", text: t.emptyAnswer }), { id: a, role: "agent", at: n.createdAt, parts: l, streaming: r.status === "running", stopped: r.status === "cancelled" };
8887
+ return r.status === "failed" ? l.push({ kind: "error", text: t.failedAnswer, retry: !0 }) : r.status === "completed" && !b && vs(r) === 0 && l.push({ kind: "error", text: t.emptyAnswer }), { id: a, role: "agent", at: n.createdAt, parts: l, streaming: r.status === "running", stopped: r.status === "cancelled" };
8888
8888
  });
8889
8889
  }
8890
8890
  function zs(e) {
@@ -8899,21 +8899,21 @@ function zs(e) {
8899
8899
  }
8900
8900
  const Ms = ht(null);
8901
8901
  function Cs({ title: e, meta: t, icon: o, onClose: n, children: a, placement: r = "inside", size: c = "default", labels: u }) {
8902
- const s = Ht(Ms), l = q(null), x = s?.previewRef ?? l, _ = q(null), v = q(null), [w, m] = I(!1);
8902
+ const s = Ht(Ms), l = U(null), x = s?.previewRef ?? l, _ = U(null), b = U(null), [w, m] = A(!1);
8903
8903
  ke(() => {
8904
8904
  if (r !== "viewport") return;
8905
8905
  const f = [];
8906
- for (let j = v.current?.parentElement; j; j = j.parentElement) f.push(j);
8907
- const b = () => m(f.some((j) => j.matches('.dark, [data-theme="dark"]')));
8908
- b();
8909
- const M = new MutationObserver(b);
8910
- return f.forEach((j) => M.observe(j, { attributes: !0, attributeFilter: ["class", "data-theme"] })), () => M.disconnect();
8906
+ for (let z = b.current?.parentElement; z; z = z.parentElement) f.push(z);
8907
+ const y = () => m(f.some((z) => z.matches('.dark, [data-theme="dark"]')));
8908
+ y();
8909
+ const L = new MutationObserver(y);
8910
+ return f.forEach((z) => L.observe(z, { attributes: !0, attributeFilter: ["class", "data-theme"] })), () => L.disconnect();
8911
8911
  }, [r]), se(() => (_.current = s?.opener.current ?? (document.activeElement instanceof HTMLElement ? document.activeElement : null), x.current?.querySelector(".ui-crsc__preview-close")?.focus({ preventScroll: !0 }), () => {
8912
8912
  _.current?.focus({ preventScroll: !0 });
8913
8913
  }), []);
8914
8914
  const k = () => {
8915
8915
  n(), _.current?.focus({ preventScroll: !0 });
8916
- }, y = /* @__PURE__ */ d(Me, { children: [
8916
+ }, v = /* @__PURE__ */ d(Me, { children: [
8917
8917
  /* @__PURE__ */ i("style", { href: "ui-collaboration-stream-clean", precedence: "default", children: Is }),
8918
8918
  /* @__PURE__ */ i(
8919
8919
  "div",
@@ -8937,8 +8937,8 @@ function Cs({ title: e, meta: t, icon: o, onClose: n, children: a, placement: r
8937
8937
  if (f.key === "Escape")
8938
8938
  f.preventDefault(), f.stopPropagation(), k();
8939
8939
  else if (f.key === "Tab") {
8940
- const b = [...x.current?.querySelectorAll("button, [tabindex='0']") ?? []], M = b.indexOf(document.activeElement);
8941
- (f.shiftKey ? M <= 0 : M === b.length - 1) && (f.preventDefault(), b[f.shiftKey ? b.length - 1 : 0]?.focus());
8940
+ const y = [...x.current?.querySelectorAll("button, [tabindex='0']") ?? []], L = y.indexOf(document.activeElement);
8941
+ (f.shiftKey ? L <= 0 : L === y.length - 1) && (f.preventDefault(), y[f.shiftKey ? y.length - 1 : 0]?.focus());
8942
8942
  }
8943
8943
  },
8944
8944
  children: [
@@ -8958,9 +8958,9 @@ function Cs({ title: e, meta: t, icon: o, onClose: n, children: a, placement: r
8958
8958
  )
8959
8959
  ] });
8960
8960
  return r === "viewport" ? /* @__PURE__ */ d(Me, { children: [
8961
- /* @__PURE__ */ i("span", { ref: v, hidden: !0 }),
8962
- typeof document < "u" && xn(y, document.body)
8963
- ] }) : y;
8961
+ /* @__PURE__ */ i("span", { ref: b, hidden: !0 }),
8962
+ typeof document < "u" && xn(v, document.body)
8963
+ ] }) : v;
8964
8964
  }
8965
8965
  const Ns = (
8966
8966
  /* css */
@@ -9309,7 +9309,7 @@ function As({ files: e, getAttachmentUrls: t, onDownload: o, copy: n }) {
9309
9309
  )) });
9310
9310
  }
9311
9311
  function Ss({ file: e, getUrls: t, onDownload: o, closeLabel: n }) {
9312
- const [a, r] = I(), [c, u] = I(!1), [s, l] = I(), x = q(null), _ = q(0), v = q(0), w = hi(t).urls.get(e.id), m = !w || Date.now() - w.fetchedAt >= jt;
9312
+ const [a, r] = A(), [c, u] = A(!1), [s, l] = A(), x = U(null), _ = U(0), b = U(0), w = hi(t).urls.get(e.id), m = !w || Date.now() - w.fetchedAt >= jt;
9313
9313
  se(() => {
9314
9314
  const f = ++_.current;
9315
9315
  return l(void 0), u(!1), () => {
@@ -9317,8 +9317,8 @@ function Ss({ file: e, getUrls: t, onDownload: o, closeLabel: n }) {
9317
9317
  };
9318
9318
  }, [t, e.id]), se(() => {
9319
9319
  let f = !0;
9320
- return Ls(t, e.id).then((b) => {
9321
- f && r({ getUrls: t, id: e.id, url: b });
9320
+ return Ls(t, e.id).then((y) => {
9321
+ f && r({ getUrls: t, id: e.id, url: y });
9322
9322
  }).catch(() => {
9323
9323
  f && r(void 0);
9324
9324
  }), () => {
@@ -9326,15 +9326,15 @@ function Ss({ file: e, getUrls: t, onDownload: o, closeLabel: n }) {
9326
9326
  };
9327
9327
  }, [t, e.id, m]);
9328
9328
  const k = async () => {
9329
- const f = _.current, b = ++v.current;
9329
+ const f = _.current, y = ++b.current;
9330
9330
  try {
9331
- const M = hi(t), j = M.urls.get(e.id), V = j && Date.now() - j.fetchedAt < jt ? j.url : await Ba(t, e.id);
9332
- if (_.current !== f || v.current !== b) return;
9333
- (!j || Date.now() - j.fetchedAt >= jt) && (M.urls.set(e.id, { url: V, fetchedAt: Date.now() }), r({ getUrls: t, id: e.id, url: V })), x.current?.focus({ preventScroll: !0 }), l(V);
9331
+ const L = hi(t), z = L.urls.get(e.id), H = z && Date.now() - z.fetchedAt < jt ? z.url : await Ba(t, e.id);
9332
+ if (_.current !== f || b.current !== y) return;
9333
+ (!z || Date.now() - z.fetchedAt >= jt) && (L.urls.set(e.id, { url: H, fetchedAt: Date.now() }), r({ getUrls: t, id: e.id, url: H })), x.current?.focus({ preventScroll: !0 }), l(H);
9334
9334
  } catch {
9335
- _.current === f && v.current === b && u(!0);
9335
+ _.current === f && b.current === y && u(!0);
9336
9336
  }
9337
- }, y = a?.getUrls === t && a.id === e.id && !c ? a.url : void 0;
9337
+ }, v = a?.getUrls === t && a.id === e.id && !c ? a.url : void 0;
9338
9338
  return /* @__PURE__ */ d(Me, { children: [
9339
9339
  /* @__PURE__ */ i(
9340
9340
  Ae,
@@ -9342,16 +9342,16 @@ function Ss({ file: e, getUrls: t, onDownload: o, closeLabel: n }) {
9342
9342
  ref: x,
9343
9343
  variant: "ghost",
9344
9344
  size: "sm",
9345
- "aria-label": y ? e.name : void 0,
9346
- "aria-haspopup": y ? "dialog" : void 0,
9347
- style: y ? { height: "auto", padding: 0 } : void 0,
9345
+ "aria-label": v ? e.name : void 0,
9346
+ "aria-haspopup": v ? "dialog" : void 0,
9347
+ style: v ? { height: "auto", padding: 0 } : void 0,
9348
9348
  onClick: () => {
9349
- y ? k() : o(e.id);
9349
+ v ? k() : o(e.id);
9350
9350
  },
9351
- children: y ? /* @__PURE__ */ i(
9351
+ children: v ? /* @__PURE__ */ i(
9352
9352
  "img",
9353
9353
  {
9354
- src: y,
9354
+ src: v,
9355
9355
  alt: e.name,
9356
9356
  width: 64,
9357
9357
  height: 64,
@@ -9391,7 +9391,7 @@ function Ds(e, t, o, n = {}) {
9391
9391
  return vi(e) ? t.writing : t.thinking;
9392
9392
  }
9393
9393
  function $s({ run: e, live: t, copy: o, hideTools: n }) {
9394
- const a = e.status === "running", [r, c] = I(Date.now);
9394
+ const a = e.status === "running", [r, c] = A(Date.now);
9395
9395
  if (se(() => {
9396
9396
  if (!a) return;
9397
9397
  c(Date.now());
@@ -9445,12 +9445,12 @@ function js(e) {
9445
9445
  return /* @__PURE__ */ i(Rs, { ...e }, `${e.suspension.taskId}:${e.suspension.id}`);
9446
9446
  }
9447
9447
  function Rs({ suspension: e, locale: t, onAnswer: o, error: n, onCancel: a, onNavigate: r }) {
9448
- const [c, u] = I(Zi), [s, l] = I(0), x = ja(t), _ = li(t), v = n?.code === "resume-failed", w = e.kind === "approval" ? e.toolName?.split(":").at(-1) : void 0;
9448
+ const [c, u] = A(Zi), [s, l] = A(0), x = ja(t), _ = li(t), b = n?.code === "resume-failed", w = e.kind === "approval" ? e.toolName?.split(":").at(-1) : void 0;
9449
9449
  if (e.kind === "approval" && !e.readOnly) return /* @__PURE__ */ i(
9450
9450
  oo,
9451
9451
  {
9452
9452
  title: w ? _.approvalQuestion(w) : _.approvalQuestionGeneric,
9453
- description: v ? _.errorText(n.code, n.status) : _.approvalTask,
9453
+ description: b ? _.errorText(n.code, n.status) : _.approvalTask,
9454
9454
  details: [
9455
9455
  ...w ? [{ label: _.factTool, value: w }] : [],
9456
9456
  ...e.capability ? [{ label: _.factCapability, value: e.capability }] : []
@@ -9487,35 +9487,35 @@ function Rs({ suspension: e, locale: t, onAnswer: o, error: n, onCancel: a, onNa
9487
9487
  }];
9488
9488
  } else
9489
9489
  m = e.steps.filter((f) => !Rt(c, f.id)).map((f) => {
9490
- const b = { id: `${e.id}:${f.id}`, question: f.question, body: /* @__PURE__ */ i(ut, { text: f.question }), task: f.header ?? e.title ?? _.questionsTask };
9490
+ const y = { id: `${e.id}:${f.id}`, question: f.question, body: /* @__PURE__ */ i(ut, { text: f.question }), task: f.header ?? e.title ?? _.questionsTask };
9491
9491
  switch (f.type) {
9492
9492
  case "single":
9493
9493
  case "multi":
9494
9494
  return {
9495
- ...b,
9496
- options: f.options?.map((M) => ({ id: M.id, title: M.label, summary: M.description })),
9495
+ ...y,
9496
+ options: f.options?.map((L) => ({ id: L.id, title: L.label, summary: L.description })),
9497
9497
  own: f.type === "single" && !!f.customField,
9498
9498
  ...f.type === "multi" ? { multiple: { min: f.minItems, max: f.maxItems } } : {}
9499
9499
  };
9500
9500
  case "boolean":
9501
- return { ...b, options: [{ id: "true", title: x.questions.yes }, { id: "false", title: x.questions.no }], own: !1 };
9501
+ return { ...y, options: [{ id: "true", title: x.questions.yes }, { id: "false", title: x.questions.no }], own: !1 };
9502
9502
  case "number":
9503
9503
  return {
9504
- ...b,
9504
+ ...y,
9505
9505
  inputMode: f.integer ? "numeric" : "decimal",
9506
9506
  placeholder: x.questions.numberPlaceholder,
9507
- validate: (M) => {
9508
- const j = Number(M);
9509
- return !M.trim() || !Number.isFinite(j) ? x.questions.invalidNumber : f.integer && !Number.isInteger(j) ? x.questions.invalidInteger : null;
9507
+ validate: (L) => {
9508
+ const z = Number(L);
9509
+ return !L.trim() || !Number.isFinite(z) ? x.questions.invalidNumber : f.integer && !Number.isInteger(z) ? x.questions.invalidInteger : null;
9510
9510
  }
9511
9511
  };
9512
9512
  case "text":
9513
- return { ...b, options: f.required ? [] : [{ id: "__skip", title: _.skip }] };
9513
+ return { ...y, options: f.required ? [] : [{ id: "__skip", title: _.skip }] };
9514
9514
  }
9515
9515
  });
9516
- const k = e.kind === "questions" && e.steps.every((f) => Rt(c, f.id)), y = e.kind === "wait" || e.kind === "approval";
9516
+ const k = e.kind === "questions" && e.steps.every((f) => Rt(c, f.id)), v = e.kind === "wait" || e.kind === "approval";
9517
9517
  return /* @__PURE__ */ d(Me, { children: [
9518
- k && v ? /* @__PURE__ */ d(Me, { children: [
9518
+ k && b ? /* @__PURE__ */ d(Me, { children: [
9519
9519
  /* @__PURE__ */ i(Ae, { size: "sm", onClick: () => o?.({ kind: "questions", ...c }), children: x.questions.resubmit }),
9520
9520
  /* @__PURE__ */ i(Ae, { variant: "secondary", size: "sm", onClick: () => {
9521
9521
  u(Zi()), l((f) => f + 1);
@@ -9524,15 +9524,15 @@ function Rs({ suspension: e, locale: t, onAnswer: o, error: n, onCancel: a, onNa
9524
9524
  Ta,
9525
9525
  {
9526
9526
  decisions: m,
9527
- labels: y ? { ...x.decision, needsYou: x.questions.waiting } : x.decision,
9528
- onDecide: (f, b) => {
9527
+ labels: v ? { ...x.decision, needsYou: x.questions.waiting } : x.decision,
9528
+ onDecide: (f, y) => {
9529
9529
  if (e.kind === "link") {
9530
- /^\/(?!\/)/.test(e.url) && r ? r(e.url) : window.open(e.url, "_blank", "noopener,noreferrer"), l((j) => j + 1);
9530
+ /^\/(?!\/)/.test(e.url) && r ? r(e.url) : window.open(e.url, "_blank", "noopener,noreferrer"), l((z) => z + 1);
9531
9531
  return;
9532
9532
  }
9533
9533
  if (e.kind !== "questions") return;
9534
- const M = Es(e, c, f, b);
9535
- M && (u(M), e.steps.every((j) => Rt(M, j.id)) && o?.({ kind: "questions", ...M }));
9534
+ const L = Es(e, c, f, y);
9535
+ L && (u(L), e.steps.every((z) => Rt(L, z.id)) && o?.({ kind: "questions", ...L }));
9536
9536
  }
9537
9537
  },
9538
9538
  s
@@ -9541,36 +9541,36 @@ function Rs({ suspension: e, locale: t, onAnswer: o, error: n, onCancel: a, onNa
9541
9541
  ] });
9542
9542
  }
9543
9543
  function Fs({ messages: e, older: t, active: o = !0 }) {
9544
- const n = q(null), a = q(null), r = q(!0), c = q(0), u = q(o), s = q(null), l = e.find(() => !0)?.id, x = q(l), _ = q(!1), [v, w] = I(!1), m = Ne(() => {
9545
- const b = n.current;
9546
- b && o && r.current && !s.current && (b.scrollTop = Math.max(0, b.scrollHeight - b.clientHeight), c.current = b.scrollTop);
9547
- }, [o]), k = Ne(() => {
9548
- r.current = !0, w(!1), m();
9549
- }, [m]), y = Ne(() => {
9550
- const b = n.current;
9551
- !o || !b || !t?.hasMore || t.loading || s.current || (r.current = !1, s.current = { firstId: l, height: b.scrollHeight, sawLoading: !1 }, w(!0), t.onLoad());
9552
- }, [o, l, t]), f = Ne(() => {
9553
- const b = n.current;
9554
- if (!o || !b) return;
9555
- const M = b.scrollTop !== c.current, j = b.scrollTop < c.current;
9556
- c.current = b.scrollTop, M && b.scrollHeight - b.clientHeight - b.scrollTop <= 24 ? r.current = !0 : j && (r.current = !1), w(!r.current), j && b.scrollTop <= 48 && y();
9544
+ const n = U(null), a = U(null), r = U(!0), c = U(0), u = U(o), s = U(null), l = e.find(() => !0)?.id, x = U(l), _ = [...e].reverse().find((z) => z.role === "user")?.id, b = U(_), w = U(!1), [m, k] = A(!1), v = Ne(() => {
9545
+ const z = n.current;
9546
+ z && o && r.current && !s.current && (z.scrollTop = Math.max(0, z.scrollHeight - z.clientHeight), c.current = z.scrollTop);
9547
+ }, [o]), f = Ne(() => {
9548
+ r.current = !0, k(!1), v();
9549
+ }, [v]), y = Ne(() => {
9550
+ const z = n.current;
9551
+ !o || !z || !t?.hasMore || t.loading || s.current || (r.current = !1, s.current = { firstId: l, height: z.scrollHeight, sawLoading: !1 }, k(!0), t.onLoad());
9552
+ }, [o, l, t]), L = Ne(() => {
9553
+ const z = n.current;
9554
+ if (!o || !z) return;
9555
+ const H = z.scrollTop !== c.current, C = z.scrollTop < c.current;
9556
+ c.current = z.scrollTop, H && z.scrollHeight - z.clientHeight - z.scrollTop <= 24 ? r.current = !0 : C && (r.current = !1), k(!r.current), C && z.scrollTop <= 48 && y();
9557
9557
  }, [o, y]);
9558
9558
  return ke(() => {
9559
- const b = n.current, M = o && !u.current;
9559
+ const z = n.current, H = o && !u.current;
9560
9560
  u.current = o, t || (s.current = null);
9561
- const j = x.current;
9562
- if (j !== void 0 && (l === void 0 || j !== l && !s.current) && (r.current = !0, w(!1), c.current = 0, _.current = !0, e.length || (s.current = null)), x.current = l, !o || !b) return;
9563
- const L = _.current;
9564
- _.current = !1, M && !L && (b.scrollTop = c.current);
9565
- const F = s.current;
9566
- F && (F.firstId !== l ? ((F.firstId === void 0 || e.some((P) => P.id === F.firstId)) && (b.scrollTop += b.scrollHeight - F.height, c.current = b.scrollTop, r.current = !1, w(!0)), s.current = null) : t?.loading ? F.sawLoading = !0 : F.sawLoading && (s.current = null)), (!M || L) && m();
9561
+ const C = x.current;
9562
+ if (C !== void 0 && (l === void 0 || C !== l && !s.current) && (r.current = !0, k(!1), c.current = 0, w.current = !0, e.length || (s.current = null)), x.current = l, b.current !== void 0 && _ !== void 0 && b.current !== _ && (r.current = !0, k(!1)), b.current = _, !o || !z) return;
9563
+ const F = w.current;
9564
+ w.current = !1, H && !F && (z.scrollTop = c.current);
9565
+ const D = s.current;
9566
+ D && (D.firstId !== l ? ((D.firstId === void 0 || e.some((T) => T.id === D.firstId)) && (z.scrollTop += z.scrollHeight - D.height, c.current = z.scrollTop, r.current = !1, k(!0)), s.current = null) : t?.loading ? D.sawLoading = !0 : D.sawLoading && (s.current = null)), (!H || F) && v();
9567
9567
  }), ke(() => {
9568
- const b = new ResizeObserver(m);
9569
- return a.current && b.observe(a.current), n.current && b.observe(n.current), () => b.disconnect();
9570
- }, [m]), { viewport: n, content: a, away: v, onScroll: f, jump: k, loadOlder: y };
9568
+ const z = new ResizeObserver(v);
9569
+ return a.current && z.observe(a.current), n.current && z.observe(n.current), () => z.disconnect();
9570
+ }, [v]), { viewport: n, content: a, away: m, onScroll: L, jump: f, loadOlder: y };
9571
9571
  }
9572
9572
  function Ps(e, t) {
9573
- const o = q(/* @__PURE__ */ new Set()), n = q([]), [a, r] = I([]), [c, u] = I(!1), [s, l] = I(0);
9573
+ const o = U(/* @__PURE__ */ new Set()), n = U([]), [a, r] = A([]), [c, u] = A(!1), [s, l] = A(0);
9574
9574
  return se(() => {
9575
9575
  const m = o.current;
9576
9576
  return () => {
@@ -9581,36 +9581,36 @@ function Ps(e, t) {
9581
9581
  setOpen: u,
9582
9582
  generation: s,
9583
9583
  onUpload: async (m, k) => {
9584
- const y = [...o.current].find((b) => b.file === m && n.current.some((M) => M.id === b.itemId && M.status === "error"));
9585
- y && (y.controller.abort(), o.current.delete(y));
9586
- const f = { file: m, controller: new AbortController(), itemId: y?.itemId };
9584
+ const v = [...o.current].find((y) => y.file === m && n.current.some((L) => L.id === y.itemId && L.status === "error"));
9585
+ v && (v.controller.abort(), o.current.delete(v));
9586
+ const f = { file: m, controller: new AbortController(), itemId: v?.itemId };
9587
9587
  o.current.add(f);
9588
9588
  try {
9589
9589
  if (!e) throw new Error(t);
9590
- const b = await e(m, (M) => {
9591
- f.controller.signal.aborted || k(M);
9590
+ const y = await e(m, (L) => {
9591
+ f.controller.signal.aborted || k(L);
9592
9592
  }, f.controller.signal);
9593
- f.controller.signal.throwIfAborted(), f.result = b;
9593
+ f.controller.signal.throwIfAborted(), f.result = y;
9594
9594
  } catch {
9595
9595
  throw new Error(t);
9596
9596
  }
9597
9597
  },
9598
9598
  onChange: (m) => {
9599
- m.some((k) => !n.current.some((y) => y.id === k.id)) && u(!0);
9599
+ m.some((k) => !n.current.some((v) => v.id === k.id)) && u(!0);
9600
9600
  for (const k of m) {
9601
9601
  if (!k.file || [...o.current].some((f) => f.itemId === k.id)) continue;
9602
- const y = [...o.current].find((f) => f.itemId === void 0 && f.file === k.file);
9603
- y && (y.itemId = k.id);
9602
+ const v = [...o.current].find((f) => f.itemId === void 0 && f.file === k.file);
9603
+ v && (v.itemId = k.id);
9604
9604
  }
9605
9605
  for (const k of o.current)
9606
- k.itemId !== void 0 && !m.some((y) => y.id === k.itemId) && (k.controller.abort(), o.current.delete(k));
9606
+ k.itemId !== void 0 && !m.some((v) => v.id === k.itemId) && (k.controller.abort(), o.current.delete(k));
9607
9607
  n.current = m, r(m);
9608
9608
  },
9609
9609
  reset: () => {
9610
9610
  o.current.forEach((m) => m.controller.abort()), o.current.clear(), n.current = [], r([]), l((m) => m + 1), u(!1);
9611
9611
  },
9612
9612
  completed: () => n.current.flatMap((m) => {
9613
- const k = [...o.current].find((y) => y.itemId === m.id);
9613
+ const k = [...o.current].find((v) => v.itemId === m.id);
9614
9614
  return m.status === "done" && k?.result && !k.controller.signal.aborted ? [k.result] : [];
9615
9615
  }),
9616
9616
  uploading: a.some((m) => m.status === "uploading"),
@@ -9618,7 +9618,7 @@ function Ps(e, t) {
9618
9618
  };
9619
9619
  }
9620
9620
  function Bs(e) {
9621
- const t = q(/* @__PURE__ */ new Map()), o = q(!1), [n, a] = I(!1);
9621
+ const t = U(/* @__PURE__ */ new Map()), o = U(!1), [n, a] = A(!1);
9622
9622
  return se(() => {
9623
9623
  o.current = !0;
9624
9624
  const c = t.current;
@@ -9659,64 +9659,64 @@ function qs({
9659
9659
  onAnswerSuspension: l,
9660
9660
  onCancelSuspension: x,
9661
9661
  error: _,
9662
- locale: v = "zh-CN",
9662
+ locale: b = "zh-CN",
9663
9663
  credits: w,
9664
9664
  branding: m,
9665
9665
  onSend: k,
9666
- onStop: y,
9666
+ onStop: v,
9667
9667
  onNewChat: f,
9668
- layout: b = "split",
9669
- onToggleLayout: M,
9670
- onClose: j,
9671
- onCreditsClick: V,
9672
- onHeaderPointerDown: L,
9673
- processView: F,
9674
- onRegenerate: P,
9675
- onFeedback: O,
9668
+ layout: y = "split",
9669
+ onToggleLayout: L,
9670
+ onClose: z,
9671
+ onCreditsClick: H,
9672
+ onHeaderPointerDown: C,
9673
+ processView: P,
9674
+ onRegenerate: F,
9675
+ onFeedback: D,
9676
9676
  onNavigate: T,
9677
9677
  upload: B,
9678
9678
  attachmentLimits: ee,
9679
- getAttachmentUrls: z,
9680
- className: H
9679
+ getAttachmentUrls: M,
9680
+ className: W
9681
9681
  }) {
9682
- const [Z, K] = I("chat"), te = ja(v), X = Jr(v), oe = Qr(v), re = li(v), W = m?.title ?? "VIA", $ = je(() => {
9683
- const Q = Jo(oe.locale);
9682
+ const [Z, K] = A("chat"), te = ja(b), X = Jr(b), oe = Qr(b), re = li(b), Y = m?.title ?? "VIA", E = je(() => {
9683
+ const G = Jo(oe.locale);
9684
9684
  return {
9685
- ...Q,
9685
+ ...G,
9686
9686
  ...oe.labels,
9687
- orchestrator: W,
9688
- composer: { ...Q.composer, ...oe.labels.composer },
9689
- messageActions: { ...Q.messageActions, ...oe.labels.messageActions },
9690
- toolCall: { ...Q.toolCall, ...oe.labels.toolCall }
9687
+ orchestrator: Y,
9688
+ composer: { ...G.composer, ...oe.labels.composer },
9689
+ messageActions: { ...G.messageActions, ...oe.labels.messageActions },
9690
+ toolCall: { ...G.toolCall, ...oe.labels.toolCall }
9691
9691
  };
9692
- }, [oe.locale, oe.labels, W]), Y = je(() => new Intl.DateTimeFormat(oe.locale, { hour: "2-digit", minute: "2-digit" }), [oe.locale]), p = c !== void 0 && !c.ready;
9692
+ }, [oe.locale, oe.labels, Y]), V = je(() => new Intl.DateTimeFormat(oe.locale, { hour: "2-digit", minute: "2-digit" }), [oe.locale]), p = c !== void 0 && !c.ready;
9693
9693
  Z === "history" && (p || !n) && K("chat");
9694
- const A = r?.available === !1, C = p || A || !!s, h = Ps(B, te.attachments.dropzone.uploadFailed), N = q(null), G = Bs(z), g = h.uploading || h.failed, D = C ? void 0 : P, R = [...e].reverse().find((Q) => Q.role === "assistant"), U = !p && !!n && Z === "history", S = je(() => ks(e, oe.copy, { processView: F }).map((Q) => {
9695
- if (Q.role !== "agent") return Q;
9696
- const ce = s ? Q.parts.filter((pe) => pe.kind !== "decision") : Q.parts, xe = _ && Q.id === R?.id && Ki.has(_.code) ? ce.map((pe) => pe.kind === "error" ? { ...pe, retry: !1 } : pe) : ce;
9694
+ const S = r?.available === !1, N = p || S || !!s, h = Ps(B, te.attachments.dropzone.uploadFailed), I = U(null), Q = Bs(M), g = h.uploading || h.failed, O = N ? void 0 : F, R = [...e].reverse().find((G) => G.role === "assistant"), q = !p && !!n && Z === "history", $ = je(() => ks(e, oe.copy, { processView: P }).map((G) => {
9695
+ if (G.role !== "agent") return G;
9696
+ const ce = s ? G.parts.filter((pe) => pe.kind !== "decision") : G.parts, xe = _ && G.id === R?.id && Ki.has(_.code) ? ce.map((pe) => pe.kind === "error" ? { ...pe, retry: !1 } : pe) : ce;
9697
9697
  return {
9698
- ...Q,
9699
- parts: _ && Q.id === R?.id ? [...xe, { kind: "error", text: re.errorText(_.code, _.status), retry: Ki.has(_.code) }] : xe
9698
+ ...G,
9699
+ parts: _ && G.id === R?.id ? [...xe, { kind: "error", text: re.errorText(_.code, _.status), retry: Ki.has(_.code) }] : xe
9700
9700
  };
9701
- }), [e, oe.copy, F, s, _, R?.id, re]), ae = S.some((Q) => Q.role === "agent" && Q.parts.some((ce) => ce.kind === "tools" && ce.tools.some((xe) => xe.status === "running"))), [fe, ue] = I(Date.now);
9701
+ }), [e, oe.copy, P, s, _, R?.id, re]), ae = $.some((G) => G.role === "agent" && G.parts.some((ce) => ce.kind === "tools" && ce.tools.some((xe) => xe.status === "running"))), [fe, ue] = A(Date.now);
9702
9702
  se(() => {
9703
9703
  if (!ae || p) return;
9704
9704
  ue(Date.now());
9705
- const Q = window.setInterval(() => ue(Date.now()), 1e3);
9706
- return () => window.clearInterval(Q);
9705
+ const G = window.setInterval(() => ue(Date.now()), 1e3);
9706
+ return () => window.clearInterval(G);
9707
9707
  }, [ae, p]);
9708
- const ge = je(() => zs(e), [e]), _e = R?.run.status === "running", we = R?.run.status === "waiting" ? te.live.waiting : _e ? te.live.working : o ? W : void 0, he = Fs({ messages: e, older: p || t ? void 0 : u, active: !U && !p && !t });
9709
- return /* @__PURE__ */ d(fr, { className: ["prime-blocks", H].filter(Boolean).join(" "), children: [
9708
+ const ge = je(() => zs(e), [e]), _e = R?.run.status === "running", we = R?.run.status === "waiting" ? te.live.waiting : _e ? te.live.working : o ? Y : void 0, he = Fs({ messages: e, older: p || t ? void 0 : u, active: !q && !p && !t });
9709
+ return /* @__PURE__ */ d(fr, { className: ["prime-blocks", W].filter(Boolean).join(" "), children: [
9710
9710
  /* @__PURE__ */ i("style", { href: "prime-blocks-layout", precedence: "default", children: Hs }),
9711
9711
  /* @__PURE__ */ d(
9712
9712
  "header",
9713
9713
  {
9714
- className: ["prime-blocks__header", L && "abc-prime-dock__header"].filter(Boolean).join(" "),
9715
- onPointerDown: L ? (Q) => {
9716
- Q.target instanceof Element && Q.target.closest('button, a, input, textarea, select, [role="button"]') || L(Q);
9714
+ className: ["prime-blocks__header", C && "abc-prime-dock__header"].filter(Boolean).join(" "),
9715
+ onPointerDown: C ? (G) => {
9716
+ G.target instanceof Element && G.target.closest('button, a, input, textarea, select, [role="button"]') || C(G);
9717
9717
  } : void 0,
9718
9718
  children: [
9719
- U ? /* @__PURE__ */ d("div", { className: "prime-blocks__history-heading", children: [
9719
+ q ? /* @__PURE__ */ d("div", { className: "prime-blocks__history-heading", children: [
9720
9720
  /* @__PURE__ */ i(
9721
9721
  Ae,
9722
9722
  {
@@ -9730,38 +9730,38 @@ function qs({
9730
9730
  ),
9731
9731
  /* @__PURE__ */ i("span", { className: "prime-blocks__title", title: X.historyTitle, children: X.historyTitle })
9732
9732
  ] }) : /* @__PURE__ */ d("div", { className: "prime-blocks__titles", children: [
9733
- /* @__PURE__ */ i("span", { className: "prime-blocks__title", title: o || W, children: o || W }),
9733
+ /* @__PURE__ */ i("span", { className: "prime-blocks__title", title: o || Y, children: o || Y }),
9734
9734
  we && /* @__PURE__ */ i("span", { className: "prime-blocks__subtitle ui-th-who__time", children: we })
9735
9735
  ] }),
9736
9736
  /* @__PURE__ */ d("div", { className: "prime-blocks__actions", children: [
9737
- w !== void 0 && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", onClick: V, children: X.credits(w, oe.locale) }),
9737
+ w !== void 0 && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", onClick: H, children: X.credits(w, oe.locale) }),
9738
9738
  f && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", "aria-label": X.newChat, title: X.newChat, icon: /* @__PURE__ */ i(it, { icon: pn, size: 16 }), onClick: () => {
9739
9739
  f(), K("chat");
9740
9740
  } }),
9741
- n && !p && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", "aria-label": X.history, title: X.history, "aria-pressed": U, icon: /* @__PURE__ */ i(it, { icon: hn, size: 16 }), onClick: () => {
9742
- U ? K("chat") : (K("history"), n.onLoad());
9741
+ n && !p && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", "aria-label": X.history, title: X.history, "aria-pressed": q, icon: /* @__PURE__ */ i(it, { icon: hn, size: 16 }), onClick: () => {
9742
+ q ? K("chat") : (K("history"), n.onLoad());
9743
9743
  } }),
9744
- M && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", "aria-label": X.switchLayout, title: b === "split" ? X.layoutFloat : X.layoutSplit, icon: /* @__PURE__ */ i(it, { icon: b === "split" ? mn : fn, size: 16 }), onClick: M }),
9745
- j && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", "aria-label": X.close, title: X.close, icon: /* @__PURE__ */ i(it, { icon: gn, size: 16 }), onClick: j })
9744
+ L && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", "aria-label": X.switchLayout, title: y === "split" ? X.layoutFloat : X.layoutSplit, icon: /* @__PURE__ */ i(it, { icon: y === "split" ? mn : fn, size: 16 }), onClick: L }),
9745
+ z && /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", "aria-label": X.close, title: X.close, icon: /* @__PURE__ */ i(it, { icon: gn, size: 16 }), onClick: z })
9746
9746
  ] })
9747
9747
  ]
9748
9748
  }
9749
9749
  ),
9750
- U && /* @__PURE__ */ i("div", { className: "prime-blocks__history", children: /* @__PURE__ */ i(
9750
+ q && /* @__PURE__ */ i("div", { className: "prime-blocks__history", children: /* @__PURE__ */ i(
9751
9751
  hs,
9752
9752
  {
9753
9753
  sessions: n.sessions,
9754
9754
  currentId: n.currentId,
9755
- locale: v,
9756
- onOpen: (Q) => {
9757
- n.onOpen(Q), K("chat");
9755
+ locale: b,
9756
+ onOpen: (G) => {
9757
+ n.onOpen(G), K("chat");
9758
9758
  },
9759
9759
  onRename: n.onRename,
9760
9760
  onDelete: n.onDelete,
9761
9761
  onClose: () => K("chat")
9762
9762
  }
9763
9763
  ) }),
9764
- /* @__PURE__ */ d("div", { className: "prime-blocks__conversation", hidden: U, children: [
9764
+ /* @__PURE__ */ d("div", { className: "prime-blocks__conversation", hidden: q, children: [
9765
9765
  /* @__PURE__ */ i("div", { ref: he.viewport, className: "prime-blocks__messages", role: "region", "aria-label": te.conversation, onScroll: he.onScroll, children: /* @__PURE__ */ i("div", { ref: he.content, className: "prime-blocks__column", "data-loading": t || void 0, "data-start": !t && (p || !e.length && a) ? "" : void 0, children: t ? /* @__PURE__ */ i("div", { className: "prime-blocks__loading", children: /* @__PURE__ */ i(Sa, { variant: "plain", phases: [X.loadingSession], phase: 0 }) }) : p ? /* @__PURE__ */ i("div", { className: "prime-blocks__start", children: /* @__PURE__ */ i(Fi, { start: {
9766
9766
  greeting: X.provisionTitle,
9767
9767
  body: c.lastFailedReason ?? void 0,
@@ -9773,103 +9773,103 @@ function qs({
9773
9773
  greeting: a.greeting || X.startGreeting,
9774
9774
  body: X.startBody,
9775
9775
  avatar: m?.avatar ?? ei,
9776
- prompts: a.prompts?.map((Q, ce) => ({ id: String(ce), label: Q.label, icon: Vi(Q.icon) ?? Vi("sparkle") })),
9777
- disabled: C
9778
- }, onStartPrompt: (Q) => {
9779
- const ce = a.prompts?.find((xe, pe) => String(pe) === Q);
9780
- !C && ce && k(ce.prompt, []);
9776
+ prompts: a.prompts?.map((G, ce) => ({ id: String(ce), label: G.label, icon: Vi(G.icon) ?? Vi("sparkle") })),
9777
+ disabled: N
9778
+ }, onStartPrompt: (G) => {
9779
+ const ce = a.prompts?.find((xe, pe) => String(pe) === G);
9780
+ !N && ce && k(ce.prompt, []);
9781
9781
  } }) }),
9782
- /* @__PURE__ */ i(La.Provider, { value: (Q, ce) => {
9783
- if (Q.startsWith("attachment://")) {
9782
+ /* @__PURE__ */ i(La.Provider, { value: (G, ce) => {
9783
+ if (G.startsWith("attachment://")) {
9784
9784
  ce.preventDefault();
9785
- const xe = Q.slice(13);
9786
- xe && G.download(xe);
9785
+ const xe = G.slice(13);
9786
+ xe && Q.download(xe);
9787
9787
  return;
9788
9788
  }
9789
- !T || !/^\/(?!\/)/.test(Q) || (ce.preventDefault(), T(Q));
9790
- }, children: S.map((Q) => {
9791
- if (Q.role === "user") {
9792
- const { attachments: ve, ...Ce } = Q, J = e.find((ze) => ze.id === Q.id && ze.role === "user");
9793
- return /* @__PURE__ */ d("div", { "data-ui-message": Q.id, className: "prime-blocks__user", children: [
9794
- /* @__PURE__ */ i(ir, { message: Ce, labels: $, onRetry: ii }),
9789
+ !T || !/^\/(?!\/)/.test(G) || (ce.preventDefault(), T(G));
9790
+ }, children: $.map((G) => {
9791
+ if (G.role === "user") {
9792
+ const { attachments: ve, ...Ce } = G, J = e.find((ze) => ze.id === G.id && ze.role === "user");
9793
+ return /* @__PURE__ */ d("div", { "data-ui-message": G.id, className: "prime-blocks__user", children: [
9794
+ /* @__PURE__ */ i(ir, { message: Ce, labels: E, onRetry: ii }),
9795
9795
  J?.role === "user" && !!J.attachments?.length && /* @__PURE__ */ i(
9796
9796
  As,
9797
9797
  {
9798
9798
  files: J.attachments,
9799
- getAttachmentUrls: z,
9800
- onDownload: G.download,
9799
+ getAttachmentUrls: M,
9800
+ onDownload: Q.download,
9801
9801
  copy: te.attachments
9802
9802
  }
9803
9803
  )
9804
- ] }, Q.id);
9804
+ ] }, G.id);
9805
9805
  }
9806
- const ce = e.find((ve) => ve.id === Q.id && ve.role === "assistant"), xe = ce?.role === "assistant" ? ce.run : void 0, pe = xe?.status === "running" ? Q.parts.some((ve) => ve.kind === "text") ? "writing" : "working" : "done";
9806
+ const ce = e.find((ve) => ve.id === G.id && ve.role === "assistant"), xe = ce?.role === "assistant" ? ce.run : void 0, pe = xe?.status === "running" ? G.parts.some((ve) => ve.kind === "text") ? "writing" : "working" : "done";
9807
9807
  return /* @__PURE__ */ i(
9808
9808
  nr,
9809
9809
  {
9810
- message: Q,
9811
- labels: $,
9810
+ message: G,
9811
+ labels: E,
9812
9812
  phase: pe,
9813
- liveOpen: F !== "replies",
9814
- status: xe && /* @__PURE__ */ i($s, { run: xe, live: te.live, copy: oe.copy, hideTools: F === "replies" }),
9813
+ liveOpen: P !== "replies",
9814
+ status: xe && /* @__PURE__ */ i($s, { run: xe, live: te.live, copy: oe.copy, hideTools: P === "replies" }),
9815
9815
  orchestratorAvatar: m?.avatar ?? ei,
9816
9816
  first: !0,
9817
9817
  now: fe,
9818
- clock: Y,
9819
- onRetry: D ? () => D(Q.id) : void 0,
9820
- onRegenerate: D,
9821
- onFeedback: O ? (ve, Ce, J) => O(ve, Ce, J) : void 0,
9818
+ clock: V,
9819
+ onRetry: O ? () => O(G.id) : void 0,
9820
+ onRegenerate: O,
9821
+ onFeedback: D ? (ve, Ce, J) => D(ve, Ce, J) : void 0,
9822
9822
  feedbackReasons: te.feedbackReasons,
9823
9823
  askState: Us,
9824
9824
  onTask: ii,
9825
9825
  onAsk: ii
9826
9826
  },
9827
- Q.id
9827
+ G.id
9828
9828
  );
9829
9829
  }) })
9830
9830
  ] }) }) }),
9831
9831
  /* @__PURE__ */ d("div", { className: "prime-blocks__footer", children: [
9832
9832
  !p && !t && /* @__PURE__ */ d(Me, { children: [
9833
9833
  he.away && /* @__PURE__ */ i("div", { className: "prime-blocks__latest", children: /* @__PURE__ */ i(Ae, { variant: "secondary", size: "sm", onClick: he.jump, children: te.latest }) }),
9834
- _ && !R && !(s && _.code === "resume-failed") && /* @__PURE__ */ i("div", { className: "prime-blocks__status", children: /* @__PURE__ */ i("div", { role: "alert", children: li(v).errorText(_.code, _.status) }) }),
9835
- s ? /* @__PURE__ */ i(js, { suspension: s, locale: v, onAnswer: l, error: _, onCancel: x, onNavigate: T }, `${s.taskId}:${s.id}`) : ge.length > 0 && /* @__PURE__ */ i(Ta, { decisions: Os(ge), labels: te.decision, onDecide: (Q, ce) => {
9836
- if (!(C || typeof ce == "string"))
9834
+ _ && !R && !(s && _.code === "resume-failed") && /* @__PURE__ */ i("div", { className: "prime-blocks__status", children: /* @__PURE__ */ i("div", { role: "alert", children: li(b).errorText(_.code, _.status) }) }),
9835
+ s ? /* @__PURE__ */ i(js, { suspension: s, locale: b, onAnswer: (G) => (he.jump(), l?.(G)), error: _, onCancel: x, onNavigate: T }, `${s.taskId}:${s.id}`) : ge.length > 0 && /* @__PURE__ */ i(Ta, { decisions: Os(ge), labels: te.decision, onDecide: (G, ce) => {
9836
+ if (!(N || typeof ce == "string"))
9837
9837
  if (ce.option !== void 0) {
9838
- const xe = ge.find((pe) => pe.id === Q)?.options?.find((pe) => pe.id === ce.option);
9838
+ const xe = ge.find((pe) => pe.id === G)?.options?.find((pe) => pe.id === ce.option);
9839
9839
  xe && k(xe.title, []);
9840
9840
  } else ce.text !== void 0 && k(ce.text, []);
9841
9841
  } }),
9842
- (A || s) && /* @__PURE__ */ i("div", { role: "status", children: A ? r.message || X.unavailable : te.pendingQuestion })
9842
+ (S || s) && /* @__PURE__ */ i("div", { role: "status", children: S ? r.message || X.unavailable : te.pendingQuestion })
9843
9843
  ] }),
9844
- G.failed && /* @__PURE__ */ i("div", { className: "prime-blocks__status", role: "alert", children: te.attachments.downloadFailed }),
9845
- B && /* @__PURE__ */ d("div", { hidden: !h.open || C, inert: C, children: [
9844
+ Q.failed && /* @__PURE__ */ i("div", { className: "prime-blocks__status", role: "alert", children: te.attachments.downloadFailed }),
9845
+ B && /* @__PURE__ */ d("div", { hidden: !h.open || N, inert: N, children: [
9846
9846
  /* @__PURE__ */ i(
9847
9847
  $r,
9848
9848
  {
9849
9849
  labels: te.attachments.dropzone,
9850
- picker: N,
9851
- accept: ee?.allowedExtensions.map((Q) => `.${Q.replace(/^\.+/, "")}`),
9850
+ picker: I,
9851
+ accept: ee?.allowedExtensions.map((G) => `.${G.replace(/^\.+/, "")}`),
9852
9852
  maxSize: ee?.maxSizeBytes,
9853
9853
  onUpload: h.onUpload,
9854
9854
  onChange: h.onChange
9855
9855
  },
9856
9856
  h.generation
9857
9857
  ),
9858
- /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", disabled: C, onClick: () => h.setOpen(!1), children: te.attachments.collapse })
9858
+ /* @__PURE__ */ i(Ae, { variant: "ghost", size: "sm", disabled: N, onClick: () => h.setOpen(!1), children: te.attachments.collapse })
9859
9859
  ] }),
9860
- !C && g && /* @__PURE__ */ i("div", { role: "status", children: h.uploading ? te.attachments.waitUploads : te.attachments.fixUploads }),
9860
+ !N && g && /* @__PURE__ */ i("div", { role: "status", children: h.uploading ? te.attachments.waitUploads : te.attachments.fixUploads }),
9861
9861
  /* @__PURE__ */ i(
9862
9862
  En,
9863
9863
  {
9864
9864
  addItems: [],
9865
9865
  approval: !1,
9866
9866
  voice: !1,
9867
- disabled: C,
9867
+ disabled: N,
9868
9868
  sendDisabled: g,
9869
9869
  running: _e,
9870
- onStop: y,
9870
+ onStop: v,
9871
9871
  onAdd: B ? () => {
9872
- C || N.current?.pick();
9872
+ N || I.current?.pick();
9873
9873
  } : void 0,
9874
9874
  models: [],
9875
9875
  folders: [],
@@ -9877,8 +9877,8 @@ function qs({
9877
9877
  tray: !1,
9878
9878
  placeholder: X.placeholder,
9879
9879
  labels: { ...oe.labels.composer, stop: te.stop },
9880
- onSend: (Q) => {
9881
- C || g || (k(Q, h.completed()), h.reset());
9880
+ onSend: (G) => {
9881
+ N || g || (k(G, h.completed()), h.reset());
9882
9882
  }
9883
9883
  }
9884
9884
  )
@@ -9914,14 +9914,14 @@ const Hs = `
9914
9914
  .prime-blocks__status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
9915
9915
  `, Ji = /* @__PURE__ */ new WeakMap();
9916
9916
  function Ws({ enabled: e, panelMode: t, panelVisible: o }) {
9917
- const n = mt(), { controller: a, client: r } = gi(), { state: c } = xa(), { showPanel: u, hidePanel: s, setPanelMode: l } = wa(), [x, _] = I();
9917
+ const n = mt(), { controller: a, client: r } = gi(), { state: c } = xa(), { showPanel: u, hidePanel: s, setPanelMode: l } = wa(), [x, _] = A();
9918
9918
  return se(() => {
9919
- let v = !0, w = Ji.get(r);
9919
+ let b = !0, w = Ji.get(r);
9920
9920
  return w || (w = r.getAttachmentLimits().catch(() => {
9921
9921
  }), Ji.set(r, w)), w.then((m) => {
9922
- v && m && _({ client: r, limits: m });
9922
+ b && m && _({ client: r, limits: m });
9923
9923
  }), () => {
9924
- v = !1;
9924
+ b = !1;
9925
9925
  };
9926
9926
  }, [r]), /* @__PURE__ */ i(
9927
9927
  In,
@@ -9932,7 +9932,7 @@ function Ws({ enabled: e, panelMode: t, panelVisible: o }) {
9932
9932
  labels: os(n.locale),
9933
9933
  onRestore: u,
9934
9934
  onPanelModeChange: l,
9935
- children: (v) => /* @__PURE__ */ i(
9935
+ children: (b) => /* @__PURE__ */ i(
9936
9936
  qs,
9937
9937
  {
9938
9938
  messages: c.messages,
@@ -9940,7 +9940,7 @@ function Ws({ enabled: e, panelMode: t, panelVisible: o }) {
9940
9940
  error: c.error,
9941
9941
  title: c.title,
9942
9942
  loading: c.phase === "loading",
9943
- layout: v.isSplitLayout ? "split" : "float",
9943
+ layout: b.isSplitLayout ? "split" : "float",
9944
9944
  history: {
9945
9945
  sessions: c.sessions,
9946
9946
  currentId: c.sessionId,
@@ -9972,24 +9972,24 @@ function Ws({ enabled: e, panelMode: t, panelVisible: o }) {
9972
9972
  onCancelSuspension: a.cancelSuspension,
9973
9973
  onStop: a.stop,
9974
9974
  onNewChat: a.newChat,
9975
- onToggleLayout: v.toggleLayout,
9975
+ onToggleLayout: b.toggleLayout,
9976
9976
  onClose: s,
9977
- onHeaderPointerDown: v.isDockInteractive && !v.isSplitLayout ? v.handleDockDragStart : void 0,
9977
+ onHeaderPointerDown: b.isDockInteractive && !b.isSplitLayout ? b.handleDockDragStart : void 0,
9978
9978
  onRegenerate: (w) => {
9979
- const m = c.messages.findIndex((y) => y.id === w && y.role === "assistant");
9979
+ const m = c.messages.findIndex((v) => v.id === w && v.role === "assistant");
9980
9980
  if (m < 0) return;
9981
- const k = c.messages.slice(0, m).reverse().find((y) => y.role === "user");
9981
+ const k = c.messages.slice(0, m).reverse().find((v) => v.role === "user");
9982
9982
  k && a.send(k.text).catch(() => {
9983
9983
  });
9984
9984
  },
9985
9985
  onFeedback: (w, m, k) => {
9986
9986
  if (m === null) return;
9987
- const y = c.messages.find((b) => b.id === w && b.role === "assistant");
9988
- if (!y || y.role !== "assistant") return;
9989
- const f = y.run.taskId;
9987
+ const v = c.messages.find((y) => y.id === w && y.role === "assistant");
9988
+ if (!v || v.role !== "assistant") return;
9989
+ const f = v.run.taskId;
9990
9990
  r.submitFeedback({
9991
9991
  taskId: f,
9992
- messageId: /^\d+$/.test(y.id) ? y.id : f,
9992
+ messageId: /^\d+$/.test(v.id) ? v.id : f,
9993
9993
  rating: m === "up" ? 1 : -1,
9994
9994
  ...k ? { comment: k } : {}
9995
9995
  }).catch(() => {
@@ -10095,8 +10095,8 @@ function Gs(e) {
10095
10095
  ...Object.keys(l).length > 0 ? { params: l } : {}
10096
10096
  }));
10097
10097
  return {
10098
- items: (Array.isArray(x.items) ? x.items : []).flatMap((v) => {
10099
- const w = Te(v), m = Ze(w.id);
10098
+ items: (Array.isArray(x.items) ? x.items : []).flatMap((b) => {
10099
+ const w = Te(b), m = Ze(w.id);
10100
10100
  return m === void 0 ? [] : [{
10101
10101
  id: m,
10102
10102
  title: be(w.title),
@@ -10113,16 +10113,16 @@ function Gs(e) {
10113
10113
  const _ = {
10114
10114
  ...l.limit !== void 0 ? { limit: l.limit } : {},
10115
10115
  ...l.before !== void 0 ? { before: l.before } : {}
10116
- }, v = Te(await t({
10116
+ }, b = Te(await t({
10117
10117
  method: "get",
10118
10118
  url: x,
10119
10119
  showLoading: !1,
10120
10120
  ...Object.keys(_).length > 0 ? { params: _ } : {}
10121
- })), w = Array.isArray(v.messages) ? v.messages : [];
10121
+ })), w = Array.isArray(b.messages) ? b.messages : [];
10122
10122
  return {
10123
- id: Ze(v.id) ?? s,
10124
- title: be(v.title),
10125
- hasMore: w.length > 0 && v.hasMore === !0,
10123
+ id: Ze(b.id) ?? s,
10124
+ title: be(b.title),
10125
+ hasMore: w.length > 0 && b.hasMore === !0,
10126
10126
  records: w
10127
10127
  };
10128
10128
  },
@@ -10174,7 +10174,7 @@ function Gs(e) {
10174
10174
  if (Ze(s.sessionId) === void 0) throw new $e("invalid-session-id");
10175
10175
  const { file: l, onProgress: x } = s, _ = new FormData();
10176
10176
  l.name !== void 0 ? _.append("file", l, l.name) : _.append("file", l);
10177
- const v = Te(await t({
10177
+ const b = Te(await t({
10178
10178
  method: "post",
10179
10179
  url: `${a}/threads/${encodeURIComponent(s.sessionId)}/attachments`,
10180
10180
  data: _,
@@ -10182,19 +10182,19 @@ function Gs(e) {
10182
10182
  showLoading: !1,
10183
10183
  ...s.signal !== void 0 ? { signal: s.signal } : {},
10184
10184
  ...x !== void 0 ? {
10185
- onUploadProgress: ({ loaded: k, total: y }) => {
10186
- y !== void 0 && y > 0 && Number.isFinite(y) && Number.isFinite(k) && x(Math.max(0, Math.min(1, k / y)));
10185
+ onUploadProgress: ({ loaded: k, total: v }) => {
10186
+ v !== void 0 && v > 0 && Number.isFinite(v) && Number.isFinite(k) && x(Math.max(0, Math.min(1, k / v)));
10187
10187
  }
10188
10188
  } : {}
10189
- })), w = De(v.id) ?? De(v.attachmentId);
10189
+ })), w = De(b.id) ?? De(b.attachmentId);
10190
10190
  if (w === void 0) throw new $e("missing-attachment-id");
10191
10191
  const m = {
10192
10192
  id: w,
10193
- name: De(v.filename) ?? De(v.fileName) ?? De(v.name) ?? l.name ?? "",
10194
- mimeType: De(v.contentType) ?? De(v.mimeType) ?? De(l.type),
10195
- size: be(v.size),
10196
- status: be(v.status),
10197
- ready: v.markdownAvailable === !0 || v.ingestionStatus === "indexed" || v.ingestionStatus === "parsed"
10193
+ name: De(b.filename) ?? De(b.fileName) ?? De(b.name) ?? l.name ?? "",
10194
+ mimeType: De(b.contentType) ?? De(b.mimeType) ?? De(l.type),
10195
+ size: be(b.size),
10196
+ status: be(b.status),
10197
+ ready: b.markdownAvailable === !0 || b.ingestionStatus === "indexed" || b.ingestionStatus === "parsed"
10198
10198
  };
10199
10199
  return x?.(1), m;
10200
10200
  },
@@ -10267,7 +10267,7 @@ function Gs(e) {
10267
10267
  }
10268
10268
  },
10269
10269
  async resumeTask(s, l) {
10270
- const x = Object.fromEntries(Object.entries(l.identity ?? {}).filter(([, v]) => De(v) !== void 0)), _ = Te(await t({
10270
+ const x = Object.fromEntries(Object.entries(l.identity ?? {}).filter(([, b]) => De(b) !== void 0)), _ = Te(await t({
10271
10271
  method: "post",
10272
10272
  url: `${c(s)}/resume`,
10273
10273
  showLoading: !1,
@@ -10288,38 +10288,38 @@ function Gs(e) {
10288
10288
  };
10289
10289
  },
10290
10290
  async subscribeTaskEvents(s) {
10291
- const { cursor: l, onEvent: x, signal: _, delays: v = [1e3, 2e3, 4e3] } = s;
10291
+ const { cursor: l, onEvent: x, signal: _, delays: b = [1e3, 2e3, 4e3] } = s;
10292
10292
  if (_?.aborted) return { kind: "aborted" };
10293
10293
  const w = `${c(s.taskId)}/events`;
10294
- let m, k = 0, y = !1;
10294
+ let m, k = 0, v = !1;
10295
10295
  const f = () => {
10296
10296
  m?.cancel().catch(() => {
10297
10297
  });
10298
- }, b = (M) => _ ? new Promise((j, V) => {
10299
- const L = () => V(_.reason);
10300
- _.addEventListener("abort", L, { once: !0 }), M.then(
10301
- (F) => {
10302
- _.removeEventListener("abort", L), j(F);
10298
+ }, y = (L) => _ ? new Promise((z, H) => {
10299
+ const C = () => H(_.reason);
10300
+ _.addEventListener("abort", C, { once: !0 }), L.then(
10301
+ (P) => {
10302
+ _.removeEventListener("abort", C), z(P);
10303
10303
  },
10304
- (F) => {
10305
- _.removeEventListener("abort", L), V(F);
10304
+ (P) => {
10305
+ _.removeEventListener("abort", C), H(P);
10306
10306
  }
10307
- ), _.aborted && (_.removeEventListener("abort", L), L());
10308
- }) : M;
10307
+ ), _.aborted && (_.removeEventListener("abort", C), C());
10308
+ }) : L;
10309
10309
  _?.addEventListener("abort", f, { once: !0 });
10310
10310
  try {
10311
10311
  for (; !_?.aborted; ) {
10312
- const M = at(l());
10313
- let j = { kind: "lost" };
10312
+ const L = at(l());
10313
+ let z = { kind: "lost" };
10314
10314
  try {
10315
- const F = await b(Promise.resolve(o?.(w) ?? {}));
10315
+ const P = await y(Promise.resolve(o?.(w) ?? {}));
10316
10316
  if (_?.aborted) return { kind: "aborted" };
10317
- const P = new Headers({ Accept: "text/event-stream", ...F });
10318
- P.delete("Last-Event-ID");
10319
- const O = at(l());
10320
- O !== void 0 && P.set("Last-Event-ID", O);
10321
- const T = await b((n ?? globalThis.fetch)(`${r}${w}`, {
10322
- headers: P,
10317
+ const F = new Headers({ Accept: "text/event-stream", ...P });
10318
+ F.delete("Last-Event-ID");
10319
+ const D = at(l());
10320
+ D !== void 0 && F.set("Last-Event-ID", D);
10321
+ const T = await y((n ?? globalThis.fetch)(`${r}${w}`, {
10322
+ headers: F,
10323
10323
  credentials: "include",
10324
10324
  signal: _
10325
10325
  }));
@@ -10329,10 +10329,10 @@ function Gs(e) {
10329
10329
  m = T.body.getReader();
10330
10330
  const B = new TextDecoder(), ee = Ys();
10331
10331
  for (; !_?.aborted; ) {
10332
- const { value: z, done: H } = await b(m.read());
10332
+ const { value: M, done: W } = await y(m.read());
10333
10333
  if (_?.aborted) return { kind: "aborted" };
10334
- const Z = ee.push(H ? B.decode() : B.decode(z, { stream: !0 }));
10335
- H && Z.push(...ee.flush());
10334
+ const Z = ee.push(W ? B.decode() : B.decode(M, { stream: !0 }));
10335
+ W && Z.push(...ee.flush());
10336
10336
  for (const K of Z) {
10337
10337
  if (_?.aborted) return { kind: "aborted" };
10338
10338
  x(K);
@@ -10340,37 +10340,37 @@ function Gs(e) {
10340
10340
  if (te === "RUN_FINISHED")
10341
10341
  return m.cancel().catch(() => {
10342
10342
  }), { kind: "finished" };
10343
- te === "TASK_SUSPENDED" && (y = !0), te === "TASK_RESUMED" && (y = !1);
10343
+ te === "TASK_SUSPENDED" && (v = !0), te === "TASK_RESUMED" && (v = !1);
10344
10344
  }
10345
- if (H) {
10346
- if (y) return { kind: "suspended" };
10345
+ if (W) {
10346
+ if (v) return { kind: "suspended" };
10347
10347
  break;
10348
10348
  }
10349
10349
  }
10350
10350
  }
10351
10351
  } else {
10352
- if (j.status = T.status, j.message = await b(T.text()), _?.aborted) return { kind: "aborted" };
10353
- if (T.status < 500 || T.status >= 600) return j;
10352
+ if (z.status = T.status, z.message = await y(T.text()), _?.aborted) return { kind: "aborted" };
10353
+ if (T.status < 500 || T.status >= 600) return z;
10354
10354
  }
10355
- } catch (F) {
10355
+ } catch (P) {
10356
10356
  if (_?.aborted) return { kind: "aborted" };
10357
- const P = typeof F == "string" ? F : be(Te(F).message);
10358
- if (P !== void 0 && (j.message = P), j.status !== void 0 && (j.status < 500 || j.status >= 600)) return j;
10357
+ const F = typeof P == "string" ? P : be(Te(P).message);
10358
+ if (F !== void 0 && (z.message = F), z.status !== void 0 && (z.status < 500 || z.status >= 600)) return z;
10359
10359
  } finally {
10360
10360
  m?.releaseLock(), m = void 0;
10361
10361
  }
10362
10362
  if (_?.aborted) return { kind: "aborted" };
10363
- const V = at(l());
10364
- if (V !== void 0 && (M === void 0 || bi(V, M)) && (k = 0), k >= v.length) return j;
10365
- let L;
10363
+ const H = at(l());
10364
+ if (H !== void 0 && (L === void 0 || bi(H, L)) && (k = 0), k >= b.length) return z;
10365
+ let C;
10366
10366
  try {
10367
- await b(new Promise((F) => {
10368
- L = setTimeout(F, v[k]);
10367
+ await y(new Promise((P) => {
10368
+ C = setTimeout(P, b[k]);
10369
10369
  }));
10370
10370
  } catch {
10371
10371
  return { kind: "aborted" };
10372
10372
  } finally {
10373
- clearTimeout(L);
10373
+ clearTimeout(C);
10374
10374
  }
10375
10375
  k++;
10376
10376
  }
@@ -10557,8 +10557,8 @@ function oa(e) {
10557
10557
  if (!n || !t) return;
10558
10558
  const a = o.interaction == null ? void 0 : Se(o.interaction), r = Se(o.promptPayload), c = {};
10559
10559
  for (const f of ["requestId", "sessionId", "checkpointId", "checkpointDigest"]) {
10560
- const b = Ee(o[f]);
10561
- b !== void 0 && (c[f] = b);
10560
+ const y = Ee(o[f]);
10561
+ y !== void 0 && (c[f] = y);
10562
10562
  }
10563
10563
  const u = {
10564
10564
  id: n,
@@ -10594,27 +10594,27 @@ function oa(e) {
10594
10594
  ...typeof a?.waitingOn == "string" ? { waitingOn: a.waitingOn } : {}
10595
10595
  };
10596
10596
  if (x !== "FORM" || !a && !Object.keys(r).length) return;
10597
- const _ = Se(a ? a.requestedSchema : o.resumeSchema), v = Se(_.properties);
10597
+ const _ = Se(a ? a.requestedSchema : o.resumeSchema), b = Se(_.properties);
10598
10598
  let w = s.steps;
10599
10599
  if (w === void 0 && Array.isArray(s.options)) {
10600
- const f = Object.entries(v).find(([M, j]) => !M.endsWith("_custom") && Array.isArray(Se(j).oneOf));
10600
+ const f = Object.entries(b).find(([L, z]) => !L.endsWith("_custom") && Array.isArray(Se(z).oneOf));
10601
10601
  if (!f) return;
10602
- const [b] = f;
10603
- w = [{ ...s, id: b }];
10602
+ const [y] = f;
10603
+ w = [{ ...s, id: y }];
10604
10604
  }
10605
10605
  const m = /* @__PURE__ */ new Map();
10606
10606
  if (Array.isArray(w)) for (const f of w) {
10607
- const b = Se(f), M = Ee(b.id);
10608
- M && Object.hasOwn(v, M) && m.set(M, b);
10607
+ const y = Se(f), L = Ee(y.id);
10608
+ L && Object.hasOwn(b, L) && m.set(L, y);
10609
10609
  }
10610
- const k = /* @__PURE__ */ new Set([...m.keys(), ...Object.keys(v)]), y = [];
10610
+ const k = /* @__PURE__ */ new Set([...m.keys(), ...Object.keys(b)]), v = [];
10611
10611
  for (const f of k) {
10612
10612
  if (f.endsWith("_custom")) continue;
10613
- const b = tc(f, m.get(f) ?? {}, _);
10614
- if (!b) return;
10615
- y.push(b);
10613
+ const y = tc(f, m.get(f) ?? {}, _);
10614
+ if (!y) return;
10615
+ v.push(y);
10616
10616
  }
10617
- return y.length ? { ...l, kind: "questions", steps: y } : void 0;
10617
+ return v.length ? { ...l, kind: "questions", steps: v } : void 0;
10618
10618
  }
10619
10619
  function ic(e, t) {
10620
10620
  if (t === void 0) return;
@@ -10704,28 +10704,28 @@ function oc(e) {
10704
10704
  lastFailedReason: null,
10705
10705
  expiresAt: null
10706
10706
  });
10707
- let u = !1, s = 0, l = 0, x = null, _ = null, v, w, m = 0, k = 0, y = new AbortController(), f, b, M;
10708
- const j = /* @__PURE__ */ new Set(), V = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new WeakSet(), P = (p) => !u && p === y && !p.signal.aborted, O = () => r && c.provisioning?.ready !== !0;
10707
+ let u = !1, s = 0, l = 0, x = null, _ = null, b, w, m = 0, k = 0, v = new AbortController(), f, y, L;
10708
+ const z = /* @__PURE__ */ new Set(), H = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new WeakSet(), F = (p) => !u && p === v && !p.signal.aborted, D = () => r && c.provisioning?.ready !== !0;
10709
10709
  function T(p) {
10710
10710
  if (!u) {
10711
10711
  c = { ...c, ...p };
10712
- for (const A of [...j]) {
10712
+ for (const S of [...z]) {
10713
10713
  if (u) break;
10714
- A();
10714
+ S();
10715
10715
  }
10716
10716
  }
10717
10717
  }
10718
10718
  function B(p) {
10719
- return c.messages.find((A) => A.id === p.messageId && A.role === "assistant");
10719
+ return c.messages.find((S) => S.id === p.messageId && S.role === "assistant");
10720
10720
  }
10721
- function ee(p, A) {
10722
- return c.messages.map((C) => C.id === p && C.role === "assistant" ? { ...C, run: A } : C);
10721
+ function ee(p, S) {
10722
+ return c.messages.map((N) => N.id === p && N.role === "assistant" ? { ...N, run: S } : N);
10723
10723
  }
10724
- function z() {
10725
- return y.abort(), f?.stream.abort(), f = void 0, b = void 0, M = void 0, y = new AbortController(), y;
10724
+ function M() {
10725
+ return v.abort(), f?.stream.abort(), f = void 0, y = void 0, L = void 0, v = new AbortController(), v;
10726
10726
  }
10727
- function H() {
10728
- u || (l++, z(), c = {
10727
+ function W() {
10728
+ u || (l++, M(), c = {
10729
10729
  ...ra(),
10730
10730
  ...c.provisioning ? { provisioning: c.provisioning } : {},
10731
10731
  ...c.sessions ? { sessions: c.sessions } : {}
@@ -10734,37 +10734,37 @@ function oc(e) {
10734
10734
  async function Z(p) {
10735
10735
  if (u) return;
10736
10736
  if (x = p, p === null) {
10737
- v = void 0, _ = null, H();
10737
+ b = void 0, _ = null, W();
10738
10738
  return;
10739
10739
  }
10740
- if (O()) {
10741
- v = p;
10740
+ if (D()) {
10741
+ b = p;
10742
10742
  return;
10743
10743
  }
10744
- v = void 0;
10745
- const A = Js(p);
10746
- if (A === null || A === _) return;
10747
- _ = A;
10748
- const C = w;
10744
+ b = void 0;
10745
+ const S = Js(p);
10746
+ if (S === null || S === _) return;
10747
+ _ = S;
10748
+ const N = w;
10749
10749
  w = void 0;
10750
10750
  const h = ++l;
10751
- if (!(C !== void 0 && C > Date.now()))
10751
+ if (!(N !== void 0 && N > Date.now()))
10752
10752
  try {
10753
- const N = await t.getScopeSession(p);
10753
+ const I = await t.getScopeSession(p);
10754
10754
  if (u || h !== l) return;
10755
- N === null ? H() : await W(N);
10756
- } catch (N) {
10757
- !u && h === l && (_ = null, T({ error: { code: "scope-failed", status: Fe(N) } }));
10755
+ I === null ? W() : await Y(I);
10756
+ } catch (I) {
10757
+ !u && h === l && (_ = null, T({ error: { code: "scope-failed", status: Fe(I) } }));
10758
10758
  }
10759
10759
  }
10760
10760
  async function K(p) {
10761
- const A = ++m;
10761
+ const S = ++m;
10762
10762
  if (p && T({ provisioning: { ...c.provisioning, triggering: !0, error: void 0 } }), u) return;
10763
- let C;
10763
+ let N;
10764
10764
  try {
10765
- C = await (p ? t.triggerProvisioning() : t.getProvisioning());
10765
+ N = await (p ? t.triggerProvisioning() : t.getProvisioning());
10766
10766
  } catch (h) {
10767
- !u && A === m && T({ provisioning: {
10767
+ !u && S === m && T({ provisioning: {
10768
10768
  ...c.provisioning,
10769
10769
  triggering: !1,
10770
10770
  ...p ? {} : { checked: !0, ready: !1 },
@@ -10772,193 +10772,193 @@ function oc(e) {
10772
10772
  } });
10773
10773
  return;
10774
10774
  }
10775
- if (!(u || A !== m) && (T({ provisioning: { ...C, checked: !0, triggering: !1 } }), !u && c.provisioning?.ready && v)) {
10776
- const h = v;
10777
- v = void 0, await Z(h);
10775
+ if (!(u || S !== m) && (T({ provisioning: { ...N, checked: !0, triggering: !1 } }), !u && c.provisioning?.ready && b)) {
10776
+ const h = b;
10777
+ b = void 0, await Z(h);
10778
10778
  }
10779
10779
  }
10780
- function te(p, A, C) {
10780
+ function te(p, S, N) {
10781
10781
  const h = {
10782
10782
  messageId: p,
10783
- taskId: C,
10784
- view: A,
10783
+ taskId: N,
10784
+ view: S,
10785
10785
  stream: new AbortController(),
10786
10786
  ready: sa(),
10787
10787
  finished: sa(),
10788
10788
  finalReceived: !1
10789
10789
  };
10790
- return C && h.ready.resolve(), f = h, h;
10790
+ return N && h.ready.resolve(), f = h, h;
10791
10791
  }
10792
- async function X(p, A) {
10793
- !P(A) || !c.sessionId || V.has(p) || (V.add(p), await W(c.sessionId, !0));
10792
+ async function X(p, S) {
10793
+ !F(S) || !c.sessionId || H.has(p) || (H.add(p), await Y(c.sessionId, !0));
10794
10794
  }
10795
10795
  async function oe(p) {
10796
- if (!P(p.view) || f !== p || !p.taskId) return;
10797
- let A;
10796
+ if (!F(p.view) || f !== p || !p.taskId) return;
10797
+ let S;
10798
10798
  try {
10799
- A = await t.subscribeTaskEvents({
10799
+ S = await t.subscribeTaskEvents({
10800
10800
  taskId: p.taskId,
10801
10801
  cursor: () => B(p)?.run.lastEventId,
10802
10802
  signal: p.stream.signal,
10803
- onEvent: (C) => {
10804
- if (!P(p.view) || f !== p || p.stream.signal.aborted) return;
10803
+ onEvent: (N) => {
10804
+ if (!F(p.view) || f !== p || p.stream.signal.aborted) return;
10805
10805
  const h = B(p);
10806
10806
  if (!h) return;
10807
- const N = ys(h.run, C);
10808
- C.event.toUpperCase() === "FINAL_MESSAGE_COMPLETED" && N.run !== h.run && (p.finalReceived = !0), (N.run !== h.run || N.title !== void 0) && T({
10809
- messages: N.run === h.run ? c.messages : ee(h.id, N.run),
10810
- ...N.title !== void 0 ? { title: N.title } : {}
10807
+ const I = ys(h.run, N);
10808
+ N.event.toUpperCase() === "FINAL_MESSAGE_COMPLETED" && I.run !== h.run && (p.finalReceived = !0), (I.run !== h.run || I.title !== void 0) && T({
10809
+ messages: I.run === h.run ? c.messages : ee(h.id, I.run),
10810
+ ...I.title !== void 0 ? { title: I.title } : {}
10811
10811
  });
10812
10812
  }
10813
10813
  });
10814
- } catch (C) {
10815
- A = p.stream.signal.aborted ? { kind: "aborted" } : { kind: "lost", status: Fe(C) };
10814
+ } catch (N) {
10815
+ S = p.stream.signal.aborted ? { kind: "aborted" } : { kind: "lost", status: Fe(N) };
10816
10816
  }
10817
- p.end = A, A.kind === "finished" && p.finished.resolve(), await re(p);
10817
+ p.end = S, S.kind === "finished" && p.finished.resolve(), await re(p);
10818
10818
  }
10819
10819
  async function re(p) {
10820
- const A = p.end;
10821
- if (!(!P(p.view) || f !== p || !p.taskId || !A || A.kind === "aborted") && c.phase !== "stopping")
10822
- if (A.kind === "lost")
10823
- T({ phase: "idle", connection: "lost", error: { code: "stream-lost", status: A.status } }), f === p && await X(p.taskId, p.view);
10824
- else if (A.kind === "suspended") {
10825
- const C = () => P(p.view) && f === p && c.phase !== "stopping";
10820
+ const S = p.end;
10821
+ if (!(!F(p.view) || f !== p || !p.taskId || !S || S.kind === "aborted") && c.phase !== "stopping")
10822
+ if (S.kind === "lost")
10823
+ T({ phase: "idle", connection: "lost", error: { code: "stream-lost", status: S.status } }), f === p && await X(p.taskId, p.view);
10824
+ else if (S.kind === "suspended") {
10825
+ const N = () => F(p.view) && f === p && c.phase !== "stopping";
10826
10826
  try {
10827
10827
  const h = await Re(t.getTask(p.taskId), p.view.signal);
10828
- if (!h || !C()) return;
10829
- const N = at(h.eventWatermark);
10830
- if (L.set(p.taskId, N), (h.status === "RUNNING" || h.status === "CREATED") && !F.has(p)) {
10831
- const G = B(p);
10832
- if (!G) return;
10833
- const g = G.run.lastEventId, D = N && (!g || bi(N, g)) ? N : g;
10834
- F.add(p), p.end = void 0, T({
10828
+ if (!h || !N()) return;
10829
+ const I = at(h.eventWatermark);
10830
+ if (C.set(p.taskId, I), (h.status === "RUNNING" || h.status === "CREATED") && !P.has(p)) {
10831
+ const Q = B(p);
10832
+ if (!Q) return;
10833
+ const g = Q.run.lastEventId, O = I && (!g || bi(I, g)) ? I : g;
10834
+ P.add(p), p.end = void 0, T({
10835
10835
  phase: "running",
10836
10836
  suspension: void 0,
10837
- messages: ee(G.id, { ...G.run, status: "running", suspension: void 0, lastEventId: D })
10838
- }), C() && await oe(p);
10837
+ messages: ee(Q.id, { ...Q.run, status: "running", suspension: void 0, lastEventId: O })
10838
+ }), N() && await oe(p);
10839
10839
  return;
10840
10840
  }
10841
10841
  T({ phase: "idle", suspension: oa(h) });
10842
10842
  } catch {
10843
- C() && T({ phase: "idle", error: { code: "suspension-failed" } });
10843
+ N() && T({ phase: "idle", error: { code: "suspension-failed" } });
10844
10844
  }
10845
10845
  } else
10846
- T({ phase: "idle" }), f === p && A.kind === "finished" && (!p.finalReceived || B(p)?.run.answer.final !== !0) && await X(p.taskId, p.view);
10846
+ T({ phase: "idle" }), f === p && S.kind === "finished" && (!p.finalReceived || B(p)?.run.answer.final !== !0) && await X(p.taskId, p.view);
10847
10847
  }
10848
- async function W(p, A = !1, C = !0) {
10848
+ async function Y(p, S = !1, N = !0) {
10849
10849
  if (u) return;
10850
- const h = z(), N = () => P(h);
10851
- if (T({ phase: "loading", loadingOlder: !1, suspension: void 0, ...A ? {} : { error: void 0, connection: "online" } }), !!N())
10850
+ const h = M(), I = () => F(h);
10851
+ if (T({ phase: "loading", loadingOlder: !1, suspension: void 0, ...S ? {} : { error: void 0, connection: "online" } }), !!I())
10852
10852
  try {
10853
- const G = await Re(t.getSessionPage(p, { limit: o }), h.signal);
10854
- if (!G || !N()) return;
10855
- const g = aa(G.records);
10856
- if (T({ sessionId: G.id, title: G.title, messages: g, hasMore: G.hasMore }), !N()) return;
10857
- const D = C ? [...g].reverse().find((U) => U.role === "assistant" && (U.run.status === "running" || U.run.status === "waiting")) : void 0;
10858
- if (!D) {
10853
+ const Q = await Re(t.getSessionPage(p, { limit: o }), h.signal);
10854
+ if (!Q || !I()) return;
10855
+ const g = aa(Q.records);
10856
+ if (T({ sessionId: Q.id, title: Q.title, messages: g, hasMore: Q.hasMore }), !I()) return;
10857
+ const O = N ? [...g].reverse().find((q) => q.role === "assistant" && (q.run.status === "running" || q.run.status === "waiting")) : void 0;
10858
+ if (!O) {
10859
10859
  T({ phase: "idle" });
10860
10860
  return;
10861
10861
  }
10862
10862
  let R;
10863
10863
  try {
10864
- R = await Re(t.getTask(D.run.taskId), h.signal);
10864
+ R = await Re(t.getTask(O.run.taskId), h.signal);
10865
10865
  } catch {
10866
- N() && T({ phase: "idle", error: { code: "suspension-failed" } });
10866
+ I() && T({ phase: "idle", error: { code: "suspension-failed" } });
10867
10867
  return;
10868
10868
  }
10869
- if (!R || !N()) return;
10870
- if (L.set(D.run.taskId, at(R.eventWatermark)), R.status === "RUNNING" || R.status === "CREATED") {
10871
- const U = te(D.id, h, D.run.taskId);
10872
- T({ messages: ee(D.id, pi(D.run.taskId)), phase: "running" }), oe(U);
10869
+ if (!R || !I()) return;
10870
+ if (C.set(O.run.taskId, at(R.eventWatermark)), R.status === "RUNNING" || R.status === "CREATED") {
10871
+ const q = te(O.id, h, O.run.taskId);
10872
+ T({ messages: ee(O.id, pi(O.run.taskId)), phase: "running" }), oe(q);
10873
10873
  } else R.status === "SUSPENDED" || R.status === "WAITING_APPROVAL" ? T({
10874
- messages: ee(D.id, {
10875
- ...D.run,
10874
+ messages: ee(O.id, {
10875
+ ...O.run,
10876
10876
  status: "waiting",
10877
- lastEventId: D.run.lastEventId ?? at(R.eventWatermark)
10877
+ lastEventId: O.run.lastEventId ?? at(R.eventWatermark)
10878
10878
  }),
10879
10879
  phase: "idle",
10880
10880
  suspension: oa(R)
10881
- }) : (T({ phase: "idle" }), !f && ni(R.status) && await X(D.run.taskId, h));
10882
- } catch (G) {
10883
- if (!N()) return;
10884
- Fe(G) === 404 ? (H(), T({ error: { code: "session-gone" } })) : T({ phase: "idle", error: { code: "session-failed", status: Fe(G) } });
10881
+ }) : (T({ phase: "idle" }), !f && ni(R.status) && await X(O.run.taskId, h));
10882
+ } catch (Q) {
10883
+ if (!I()) return;
10884
+ Fe(Q) === 404 ? (W(), T({ error: { code: "session-gone" } })) : T({ phase: "idle", error: { code: "session-failed", status: Fe(Q) } });
10885
10885
  }
10886
10886
  }
10887
- async function $(p, A) {
10888
- if (u || b || c.phase !== "idle" || c.suspension !== p) return;
10889
- const C = [...c.messages].reverse().find((D) => D.role === "assistant" && D.run.taskId === p.taskId);
10890
- if (!C) return;
10891
- const h = y;
10892
- b = p;
10893
- const N = () => P(h) && b === p && c.suspension === p;
10894
- if (T({ error: void 0 }), !N()) return;
10895
- let G;
10887
+ async function E(p, S) {
10888
+ if (u || y || c.phase !== "idle" || c.suspension !== p) return;
10889
+ const N = [...c.messages].reverse().find((O) => O.role === "assistant" && O.run.taskId === p.taskId);
10890
+ if (!N) return;
10891
+ const h = v;
10892
+ y = p;
10893
+ const I = () => F(h) && y === p && c.suspension === p;
10894
+ if (T({ error: void 0 }), !I()) return;
10895
+ let Q;
10896
10896
  try {
10897
- G = await Re(t.resumeTask(p.taskId, {
10897
+ Q = await Re(t.resumeTask(p.taskId, {
10898
10898
  suspensionId: p.id,
10899
- ...A,
10899
+ ...S,
10900
10900
  identity: p.identity,
10901
10901
  signal: h.signal
10902
10902
  }), h.signal);
10903
- } catch (D) {
10904
- N() && T({ error: { code: "resume-failed", status: Fe(D) } }), b === p && (b = void 0);
10903
+ } catch (O) {
10904
+ I() && T({ error: { code: "resume-failed", status: Fe(O) } }), y === p && (y = void 0);
10905
10905
  return;
10906
10906
  }
10907
- if (!N()) return;
10908
- if (b = void 0, G?.status && ni(G.status)) {
10909
- T({ suspension: void 0, phase: "idle" }), P(h) && c.sessionId && await W(c.sessionId, !0);
10907
+ if (!I()) return;
10908
+ if (y = void 0, Q?.status && ni(Q.status)) {
10909
+ T({ suspension: void 0, phase: "idle" }), F(h) && c.sessionId && await Y(c.sessionId, !0);
10910
10910
  return;
10911
10911
  }
10912
- const g = te(C.id, h, p.taskId);
10912
+ const g = te(N.id, h, p.taskId);
10913
10913
  T({
10914
10914
  suspension: void 0,
10915
10915
  phase: "running",
10916
10916
  connection: "online",
10917
10917
  error: void 0,
10918
- messages: ee(C.id, {
10919
- ...C.run,
10918
+ messages: ee(N.id, {
10919
+ ...N.run,
10920
10920
  status: "running",
10921
10921
  suspension: void 0,
10922
- lastEventId: C.run.lastEventId || L.get(p.taskId)
10922
+ lastEventId: N.run.lastEventId || C.get(p.taskId)
10923
10923
  })
10924
10924
  }), await oe(g);
10925
10925
  }
10926
- function Y(p) {
10927
- return new Promise((A) => {
10928
- let C = !1, h, N;
10929
- const G = p.view.signal, g = (U) => {
10930
- C || (C = !0, clearTimeout(h), clearTimeout(N), G.removeEventListener("abort", D), A(U));
10931
- }, D = () => g("aborted"), R = async () => {
10932
- if (!(C || !P(p.view) || !p.taskId)) {
10926
+ function V(p) {
10927
+ return new Promise((S) => {
10928
+ let N = !1, h, I;
10929
+ const Q = p.view.signal, g = (q) => {
10930
+ N || (N = !0, clearTimeout(h), clearTimeout(I), Q.removeEventListener("abort", O), S(q));
10931
+ }, O = () => g("aborted"), R = async () => {
10932
+ if (!(N || !F(p.view) || !p.taskId)) {
10933
10933
  try {
10934
- const U = await t.getTask(p.taskId);
10935
- if (ni(U.status)) {
10934
+ const q = await t.getTask(p.taskId);
10935
+ if (ni(q.status)) {
10936
10936
  g("finished");
10937
10937
  return;
10938
10938
  }
10939
10939
  } catch {
10940
10940
  }
10941
- C || (h = setTimeout(() => {
10941
+ N || (h = setTimeout(() => {
10942
10942
  R();
10943
10943
  }, n.intervalMs));
10944
10944
  }
10945
10945
  };
10946
- if (G.addEventListener("abort", D, { once: !0 }), G.aborted) {
10947
- D();
10946
+ if (Q.addEventListener("abort", O, { once: !0 }), Q.aborted) {
10947
+ O();
10948
10948
  return;
10949
10949
  }
10950
10950
  if (p.end?.kind === "finished") {
10951
10951
  g("finished");
10952
10952
  return;
10953
10953
  }
10954
- p.finished.promise.then(() => g("finished")), N = setTimeout(() => g("timeout"), n.timeoutMs), R();
10954
+ p.finished.promise.then(() => g("finished")), I = setTimeout(() => g("timeout"), n.timeoutMs), R();
10955
10955
  });
10956
10956
  }
10957
10957
  return r && K(!1), {
10958
10958
  getState: () => c,
10959
10959
  subscribe(p) {
10960
- return u || j.add(p), () => {
10961
- j.delete(p);
10960
+ return u || z.add(p), () => {
10961
+ z.delete(p);
10962
10962
  };
10963
10963
  },
10964
10964
  setScope: Z,
@@ -10969,130 +10969,130 @@ function oc(e) {
10969
10969
  !r || u || c.provisioning?.ready || c.provisioning?.triggering || await K(!0);
10970
10970
  },
10971
10971
  async openSession(p) {
10972
- u || O() || (l++, await W(p));
10972
+ u || D() || (l++, await Y(p));
10973
10973
  },
10974
10974
  async loadSessions() {
10975
- if (u || O()) return;
10976
- const p = ++k, A = () => !u && !O() && p === k;
10977
- if (T({ sessions: { items: c.sessions?.items ?? [], loading: !0 } }), !!A())
10975
+ if (u || D()) return;
10976
+ const p = ++k, S = () => !u && !D() && p === k;
10977
+ if (T({ sessions: { items: c.sessions?.items ?? [], loading: !0 } }), !!S())
10978
10978
  try {
10979
- const C = await t.listSessions({ page: 1, size: 50 });
10980
- A() && T({ sessions: { items: C.items, loading: !1 } });
10981
- } catch (C) {
10982
- A() && T({ sessions: {
10979
+ const N = await t.listSessions({ page: 1, size: 50 });
10980
+ S() && T({ sessions: { items: N.items, loading: !1 } });
10981
+ } catch (N) {
10982
+ S() && T({ sessions: {
10983
10983
  items: c.sessions?.items ?? [],
10984
10984
  loading: !1,
10985
- error: { code: "sessions-failed", status: Fe(C) }
10985
+ error: { code: "sessions-failed", status: Fe(N) }
10986
10986
  } });
10987
10987
  }
10988
10988
  },
10989
- async renameSession(p, A) {
10990
- if (u || O()) return;
10991
- const C = A.trim(), h = c.sessions?.items.find((R) => R.id === p);
10992
- if (!h || !C || C === h.title) return;
10993
- const N = y, G = c.title, g = c.sessionId === p, D = { ...h, title: C };
10989
+ async renameSession(p, S) {
10990
+ if (u || D()) return;
10991
+ const N = S.trim(), h = c.sessions?.items.find((R) => R.id === p);
10992
+ if (!h || !N || N === h.title) return;
10993
+ const I = v, Q = c.title, g = c.sessionId === p, O = { ...h, title: N };
10994
10994
  if (T({
10995
- sessions: { ...c.sessions, error: void 0, items: c.sessions.items.map((R) => R.id === p ? D : R) },
10996
- ...g ? { title: C } : {}
10997
- }), !(u || O()))
10995
+ sessions: { ...c.sessions, error: void 0, items: c.sessions.items.map((R) => R.id === p ? O : R) },
10996
+ ...g ? { title: N } : {}
10997
+ }), !(u || D()))
10998
10998
  try {
10999
- await t.renameSession(p, C);
10999
+ await t.renameSession(p, N);
11000
11000
  } catch (R) {
11001
- if (u || O() || !c.sessions) return;
11001
+ if (u || D() || !c.sessions) return;
11002
11002
  T({
11003
11003
  sessions: {
11004
11004
  ...c.sessions,
11005
11005
  // Roll back only this optimistic row, preserving unrelated changes and newer list reads.
11006
- items: c.sessions.items.map((U) => U === D ? h : U),
11006
+ items: c.sessions.items.map((q) => q === O ? h : q),
11007
11007
  error: { code: "rename-failed", status: Fe(R) }
11008
11008
  },
11009
- ...g && P(N) && c.sessionId === p && c.title === C ? { title: G } : {}
11009
+ ...g && F(I) && c.sessionId === p && c.title === N ? { title: Q } : {}
11010
11010
  });
11011
11011
  }
11012
11012
  },
11013
11013
  async deleteSession(p) {
11014
- if (u || O()) return;
11015
- let A, C;
11014
+ if (u || D()) return;
11015
+ let S, N;
11016
11016
  try {
11017
- A = await t.deleteSession(p);
11017
+ S = await t.deleteSession(p);
11018
11018
  } catch (h) {
11019
- A = !1, C = Fe(h);
11019
+ S = !1, N = Fe(h);
11020
11020
  }
11021
- if (!(u || O())) {
11022
- if (!A) {
11023
- c.sessions && T({ sessions: { ...c.sessions, error: { code: "delete-failed", status: C } } });
11021
+ if (!(u || D())) {
11022
+ if (!S) {
11023
+ c.sessions && T({ sessions: { ...c.sessions, error: { code: "delete-failed", status: N } } });
11024
11024
  return;
11025
11025
  }
11026
- c.sessions && T({ sessions: { ...c.sessions, error: void 0, items: c.sessions.items.filter((h) => h.id !== p) } }), c.sessionId === p && H();
11026
+ c.sessions && T({ sessions: { ...c.sessions, error: void 0, items: c.sessions.items.filter((h) => h.id !== p) } }), c.sessionId === p && W();
11027
11027
  }
11028
11028
  },
11029
- newChat: H,
11029
+ newChat: W,
11030
11030
  async loadOlder() {
11031
- if (u || O() || !c.sessionId || !c.hasMore || c.loadingOlder || c.phase === "loading") return;
11031
+ if (u || D() || !c.sessionId || !c.hasMore || c.loadingOlder || c.phase === "loading") return;
11032
11032
  const p = c.messages.find((h) => /^\d+$/.test(h.id))?.id;
11033
11033
  if (!p) return;
11034
- const A = y, C = c.sessionId;
11035
- if (T({ loadingOlder: !0 }), !!P(A))
11034
+ const S = v, N = c.sessionId;
11035
+ if (T({ loadingOlder: !0 }), !!F(S))
11036
11036
  try {
11037
- const h = await Re(t.getSessionPage(C, { limit: o, before: p }), A.signal);
11038
- if (!h || !P(A)) return;
11037
+ const h = await Re(t.getSessionPage(N, { limit: o, before: p }), S.signal);
11038
+ if (!h || !F(S)) return;
11039
11039
  T({ messages: qa([...aa(h.records), ...c.messages]), hasMore: h.hasMore, loadingOlder: !1 });
11040
11040
  } catch (h) {
11041
- P(A) && T({ loadingOlder: !1, error: { code: "history-failed", status: Fe(h) } });
11041
+ F(S) && T({ loadingOlder: !1, error: { code: "history-failed", status: Fe(h) } });
11042
11042
  }
11043
11043
  },
11044
- async send(p, A) {
11045
- if (u || O()) return;
11046
- if (c.phase !== "idle" || b) throw new $e("busy");
11047
- const C = Xs(x);
11044
+ async send(p, S) {
11045
+ if (u || D()) return;
11046
+ if (c.phase !== "idle" || y) throw new $e("busy");
11047
+ const N = Xs(x);
11048
11048
  let h;
11049
11049
  try {
11050
11050
  const R = a?.();
11051
11051
  typeof R == "string" && R && (h = R);
11052
11052
  } catch {
11053
11053
  }
11054
- const N = y, G = String(++s), g = te(`local:a:${G}`, N), D = Date.now();
11054
+ const I = v, Q = String(++s), g = te(`local:a:${Q}`, I), O = Date.now();
11055
11055
  if (T({
11056
11056
  messages: [
11057
11057
  ...c.messages,
11058
11058
  {
11059
- id: `local:u:${G}`,
11059
+ id: `local:u:${Q}`,
11060
11060
  role: "user",
11061
11061
  text: p,
11062
- createdAt: D,
11063
- attachments: A?.attachments?.map(({ id: R, name: U, mimeType: S, size: ae }) => ({ id: R, name: U, mimeType: S, size: me(ae) }))
11062
+ createdAt: O,
11063
+ attachments: S?.attachments?.map(({ id: R, name: q, mimeType: $, size: ae }) => ({ id: R, name: q, mimeType: $, size: me(ae) }))
11064
11064
  },
11065
- { id: g.messageId, role: "assistant", createdAt: D, run: pi("") }
11065
+ { id: g.messageId, role: "assistant", createdAt: O, run: pi("") }
11066
11066
  ],
11067
11067
  phase: "running",
11068
11068
  connection: "online",
11069
11069
  error: void 0,
11070
11070
  suspension: void 0
11071
- }), !!P(N)) {
11071
+ }), !!F(I)) {
11072
11072
  try {
11073
- if (M && await Re(M, N.signal), !P(N)) return;
11073
+ if (L && await Re(L, I.signal), !F(I)) return;
11074
11074
  const R = Object.fromEntries(Object.entries({
11075
- ...C,
11075
+ ...N,
11076
11076
  ...h !== void 0 ? { pageTraceId: h } : {},
11077
- ...A?.requestMetadata,
11078
- ...A?.attachments ? { attachments: A.attachments.map(({ id: fe, name: ue, mimeType: ge, size: _e }) => ({
11077
+ ...S?.requestMetadata,
11078
+ ...S?.attachments ? { attachments: S.attachments.map(({ id: fe, name: ue, mimeType: ge, size: _e }) => ({
11079
11079
  attachmentId: fe,
11080
11080
  fileName: ue,
11081
11081
  status: "READY",
11082
11082
  ...ge !== void 0 ? { contentType: ge } : {},
11083
11083
  ..._e !== void 0 ? { size: _e } : {}
11084
11084
  })) } : {}
11085
- }).filter(([, fe]) => fe !== void 0)), U = Object.keys(R).length > 0 ? R : void 0, S = await Re(t.createTask({ sessionId: c.sessionId, message: p, requestMetadata: U, signal: N.signal }), N.signal);
11086
- if (!S || !P(N)) return;
11087
- g.taskId = S.taskId;
11085
+ }).filter(([, fe]) => fe !== void 0)), q = Object.keys(R).length > 0 ? R : void 0, $ = await Re(t.createTask({ sessionId: c.sessionId, message: p, requestMetadata: q, signal: I.signal }), I.signal);
11086
+ if (!$ || !F(I)) return;
11087
+ g.taskId = $.taskId;
11088
11088
  const ae = B(g);
11089
11089
  if (!ae) return;
11090
- T({ messages: ee(ae.id, { ...ae.run, taskId: S.taskId }), sessionId: S.sessionId ?? c.sessionId });
11090
+ T({ messages: ee(ae.id, { ...ae.run, taskId: $.taskId }), sessionId: $.sessionId ?? c.sessionId });
11091
11091
  } catch (R) {
11092
- if (!P(N)) return;
11093
- const U = B(g);
11092
+ if (!F(I)) return;
11093
+ const q = B(g);
11094
11094
  T({
11095
- ...U ? { messages: ee(U.id, { ...U.run, status: "failed", error: "create-task-failed" }) } : {},
11095
+ ...q ? { messages: ee(q.id, { ...q.run, status: "failed", error: "create-task-failed" }) } : {},
11096
11096
  phase: "idle",
11097
11097
  error: { code: "create-task-failed", status: Fe(R) }
11098
11098
  });
@@ -11104,72 +11104,72 @@ function oc(e) {
11104
11104
  }
11105
11105
  },
11106
11106
  async answer(p) {
11107
- const A = c.suspension;
11108
- if (u || O() || !A || b || c.phase !== "idle") return;
11109
- let C;
11107
+ const S = c.suspension;
11108
+ if (u || D() || !S || y || c.phase !== "idle") return;
11109
+ let N;
11110
11110
  try {
11111
- C = ac(A, p);
11111
+ N = ac(S, p);
11112
11112
  } catch (h) {
11113
11113
  T({ error: { code: h instanceof Error ? h.message : "invalid-answer" } });
11114
11114
  return;
11115
11115
  }
11116
- await $(A, C);
11116
+ await E(S, N);
11117
11117
  },
11118
11118
  async cancelSuspension() {
11119
- u || O() || c.suspension && await $(c.suspension, { action: "CANCEL", payload: {} });
11119
+ u || D() || c.suspension && await E(c.suspension, { action: "CANCEL", payload: {} });
11120
11120
  },
11121
11121
  async stop() {
11122
11122
  if (u || c.phase !== "running" || !f) return;
11123
11123
  const p = f;
11124
- if (T({ phase: "stopping", error: void 0 }), await Re(p.ready.promise, p.view.signal), !P(p.view) || !p.taskId) return;
11125
- let A;
11124
+ if (T({ phase: "stopping", error: void 0 }), await Re(p.ready.promise, p.view.signal), !F(p.view) || !p.taskId) return;
11125
+ let S;
11126
11126
  try {
11127
- A = await Re(t.cancelTask(p.taskId), p.view.signal);
11127
+ S = await Re(t.cancelTask(p.taskId), p.view.signal);
11128
11128
  } catch {
11129
- A = !1;
11129
+ S = !1;
11130
11130
  }
11131
- if (!P(p.view)) return;
11132
- if (A === !1) {
11131
+ if (!F(p.view)) return;
11132
+ if (S === !1) {
11133
11133
  T({ phase: "running", error: { code: "cancel-rejected" } }), await re(p);
11134
11134
  return;
11135
11135
  }
11136
- const C = await Y(p);
11137
- !P(p.view) || C === "aborted" || (p.stream.abort(), C === "timeout" && T({ error: { code: "stop-timeout" } }), P(p.view) && (c.sessionId ? await W(c.sessionId, !0, !1) : T({ phase: "idle" })));
11136
+ const N = await V(p);
11137
+ !F(p.view) || N === "aborted" || (p.stream.abort(), N === "timeout" && T({ error: { code: "stop-timeout" } }), F(p.view) && (c.sessionId ? await Y(c.sessionId, !0, !1) : T({ phase: "idle" })));
11138
11138
  },
11139
- async upload(p, A, C) {
11139
+ async upload(p, S, N) {
11140
11140
  if (u) return new Promise(() => {
11141
11141
  });
11142
- if (O()) throw new $e("not-provisioned");
11143
- const h = y;
11144
- if (C?.aborted) throw new $e("aborted");
11145
- let N = c.sessionId;
11146
- if (!N) {
11147
- if (!M) {
11148
- const D = Re(t.createSession({ signal: h.signal }), h.signal).then((R) => {
11149
- if (!(!R || !P(h)))
11142
+ if (D()) throw new $e("not-provisioned");
11143
+ const h = v;
11144
+ if (N?.aborted) throw new $e("aborted");
11145
+ let I = c.sessionId;
11146
+ if (!I) {
11147
+ if (!L) {
11148
+ const O = Re(t.createSession({ signal: h.signal }), h.signal).then((R) => {
11149
+ if (!(!R || !F(h)))
11150
11150
  return T({ sessionId: R.sessionId }), R.sessionId;
11151
11151
  });
11152
- M = D, D.finally(() => {
11153
- M === D && (M = void 0);
11152
+ L = O, O.finally(() => {
11153
+ L === O && (L = void 0);
11154
11154
  }).catch(() => {
11155
11155
  });
11156
11156
  }
11157
- N = await Re(M, C ?? h.signal);
11157
+ I = await Re(L, N ?? h.signal);
11158
11158
  }
11159
- if (!N || !P(h) || C?.aborted) throw new $e("aborted");
11160
- const G = C ? AbortSignal.any([h.signal, C]) : h.signal, g = await Re(t.uploadAttachment({
11161
- sessionId: N,
11159
+ if (!I || !F(h) || N?.aborted) throw new $e("aborted");
11160
+ const Q = N ? AbortSignal.any([h.signal, N]) : h.signal, g = await Re(t.uploadAttachment({
11161
+ sessionId: I,
11162
11162
  file: p,
11163
- signal: G,
11164
- onProgress: A ? (D) => {
11165
- P(h) && !G.aborted && A(D);
11163
+ signal: Q,
11164
+ onProgress: S ? (O) => {
11165
+ F(h) && !Q.aborted && S(O);
11166
11166
  } : void 0
11167
- }), G);
11168
- if (!g || !P(h) || G.aborted) throw new $e("aborted");
11167
+ }), Q);
11168
+ if (!g || !F(h) || Q.aborted) throw new $e("aborted");
11169
11169
  return g;
11170
11170
  },
11171
11171
  dispose() {
11172
- u || (u = !0, l++, j.clear(), z());
11172
+ u || (u = !0, l++, z.clear(), M());
11173
11173
  }
11174
11174
  };
11175
11175
  }
@@ -11194,7 +11194,7 @@ function cc(e = {}) {
11194
11194
  };
11195
11195
  }
11196
11196
  function zc(e) {
11197
- const t = cc(e), o = JSON.stringify(t.startScreen.prompts.map(({ icon: y, label: f, prompt: b }) => [y, f, b])), n = je(() => t, [
11197
+ const t = cc(e), o = JSON.stringify(t.startScreen.prompts.map(({ icon: v, label: f, prompt: y }) => [v, f, y])), n = je(() => t, [
11198
11198
  t.locale,
11199
11199
  t.getTraceId,
11200
11200
  t.onNavigate,
@@ -11219,26 +11219,26 @@ function zc(e) {
11219
11219
  t.panel?.visible,
11220
11220
  t.panel?.mode,
11221
11221
  t.processView
11222
- ]), a = q(n.getTraceId);
11222
+ ]), a = U(n.getTraceId);
11223
11223
  ke(() => {
11224
11224
  a.current = n.getTraceId;
11225
11225
  }, [n.getTraceId]);
11226
- const [r, c] = I(null), { http: u } = e;
11226
+ const [r, c] = A(null), { http: u } = e;
11227
11227
  se(() => {
11228
- let y = !1, f;
11228
+ let v = !1, f;
11229
11229
  return queueMicrotask(() => {
11230
- if (y) return;
11231
- const b = Gs(u);
11232
- f = oc({ client: b, getTraceId: () => a.current(), provisioning: !0 }), c({ http: u, client: b, controller: f });
11230
+ if (v) return;
11231
+ const y = Gs(u);
11232
+ f = oc({ client: y, getTraceId: () => a.current(), provisioning: !0 }), c({ http: u, client: y, controller: f });
11233
11233
  }), () => {
11234
- y = !0, f?.dispose();
11234
+ v = !0, f?.dispose();
11235
11235
  };
11236
11236
  }, [u]);
11237
11237
  const s = r?.http === u ? r : null, { scopeType: l, scopeId: x, pending: _ } = n.scope;
11238
11238
  ke(() => {
11239
11239
  s && s.controller.setScope({ scopeType: l, scopeId: x || void 0, pending: _ });
11240
11240
  }, [s, l, x, _]);
11241
- const [v, w] = I({ enabled: !0, visible: !0, mode: "auto" }), m = Ne((y) => w((f) => ({ ...f, ...y })), []), k = je(() => ({ panel: v, patch: m }), [v, m]);
11241
+ const [b, w] = A({ enabled: !0, visible: !0, mode: "auto" }), m = Ne((v) => w((f) => ({ ...f, ...v })), []), k = je(() => ({ panel: b, patch: m }), [b, m]);
11242
11242
  return /* @__PURE__ */ i(ma.Provider, { value: n, children: /* @__PURE__ */ i(ga.Provider, { value: k, children: s && /* @__PURE__ */ i(fa.Provider, { value: s, children: e.children }) }) });
11243
11243
  }
11244
11244
  export {