@duskmoon-dev/components 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,14 @@
1
1
  "use client";
2
2
 
3
- // src/components/chat/Chat.tsx
4
- import {
5
- forwardRef as forwardRef5,
6
- useId as useId3,
7
- useLayoutEffect as useLayoutEffect4,
8
- useRef as useRef5,
9
- useState as useState3
10
- } from "react";
11
-
12
- // src/components/chat/ChatComposer.tsx
3
+ // src/components/chat/ChatRequest.tsx
13
4
  import {
14
- forwardRef as forwardRef3,
5
+ forwardRef,
15
6
  useId,
16
- useLayoutEffect as useLayoutEffect3,
17
- useRef as useRef4,
18
- useState as useState2
7
+ useImperativeHandle,
8
+ useLayoutEffect,
9
+ useRef
19
10
  } from "react";
20
11
 
21
- // src/components/chat/composer/ComposerShell.tsx
22
- import { forwardRef, useEffect, useRef as useRef2, useState } from "react";
23
-
24
- // src/components/button/Button.tsx
25
- import React from "react";
26
- import { createPortal } from "react-dom";
27
-
28
12
  // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
29
13
  function r(e) {
30
14
  var t, f, n = "";
@@ -50,6 +34,185 @@ function clsx() {
50
34
  function cn(...inputs) {
51
35
  return clsx(inputs);
52
36
  }
37
+ // src/components/chat/ChatRequest.tsx
38
+ import { jsx, jsxs } from "react/jsx-runtime";
39
+ var stateLabels = {
40
+ pending: "Awaiting approval",
41
+ approved: "Approved",
42
+ "approved-for-session": "Approved for this session",
43
+ declined: "Declined",
44
+ expired: "Expired",
45
+ "answer-elsewhere": "Answer elsewhere"
46
+ };
47
+ var ChatRequest = forwardRef(({
48
+ title,
49
+ state = "pending",
50
+ pending = false,
51
+ statusLabel,
52
+ actions = [],
53
+ explanation,
54
+ children,
55
+ className,
56
+ onFocusCapture,
57
+ onBlurCapture,
58
+ ...props
59
+ }, ref) => {
60
+ const id = useId();
61
+ const root = useRef(null);
62
+ const focusedAction = useRef(null);
63
+ useImperativeHandle(ref, () => root.current, []);
64
+ useLayoutEffect(() => {
65
+ const element = root.current;
66
+ const action = focusedAction.current;
67
+ if (element && action && !element.contains(action) && document.activeElement === document.body) {
68
+ element.focus({ preventScroll: true });
69
+ focusedAction.current = null;
70
+ }
71
+ });
72
+ return /* @__PURE__ */ jsxs("div", {
73
+ ...props,
74
+ ref: root,
75
+ className: cn("chat-approval", className),
76
+ "data-state": state,
77
+ role: props.role ?? "group",
78
+ tabIndex: props.tabIndex ?? -1,
79
+ "aria-labelledby": props["aria-labelledby"] ?? `${id}-title`,
80
+ "aria-busy": pending,
81
+ onFocusCapture: (event) => {
82
+ const target = event.target;
83
+ focusedAction.current = target.closest("[data-chat-request-action]");
84
+ onFocusCapture?.(event);
85
+ },
86
+ onBlurCapture: (event) => {
87
+ if (event.relatedTarget)
88
+ focusedAction.current = null;
89
+ onBlurCapture?.(event);
90
+ },
91
+ children: [
92
+ /* @__PURE__ */ jsxs("div", {
93
+ className: "chat-approval-header",
94
+ children: [
95
+ /* @__PURE__ */ jsx("div", {
96
+ id: `${id}-title`,
97
+ className: "chat-approval-title",
98
+ children: title
99
+ }),
100
+ /* @__PURE__ */ jsx("span", {
101
+ className: "chat-approval-status",
102
+ role: "status",
103
+ "aria-live": "polite",
104
+ "aria-atomic": "true",
105
+ children: statusLabel ?? (state === "pending" && pending ? "Decision pending" : stateLabels[state])
106
+ })
107
+ ]
108
+ }),
109
+ children != null || explanation != null ? /* @__PURE__ */ jsxs("div", {
110
+ className: "chat-approval-details",
111
+ children: [
112
+ children,
113
+ explanation
114
+ ]
115
+ }) : null,
116
+ state === "pending" && actions.length > 0 ? /* @__PURE__ */ jsx("div", {
117
+ className: "chat-approval-actions",
118
+ children: actions.map((action) => /* @__PURE__ */ jsx("button", {
119
+ type: "button",
120
+ "data-chat-request-action": "",
121
+ className: cn("btn btn-sm", action.tone === "primary" && "btn-primary", action.tone === "danger" && "btn-error"),
122
+ "aria-label": action.ariaLabel,
123
+ disabled: pending || action.disabled,
124
+ onClick: action.onSelect,
125
+ children: action.label
126
+ }, action.id))
127
+ }) : null
128
+ ]
129
+ });
130
+ });
131
+ ChatRequest.displayName = "Chat.Request";
132
+
133
+ // src/components/chat/ChatComposerContext.tsx
134
+ import { forwardRef as forwardRef2 } from "react";
135
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
136
+ var ChatComposerContext = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx2("div", {
137
+ role: "group",
138
+ "aria-label": "Composer context",
139
+ ...props,
140
+ ref,
141
+ className: cn("chat-composer-context", className)
142
+ }));
143
+ ChatComposerContext.displayName = "Chat.ComposerContext";
144
+ var ChatComposerContextItem = forwardRef2(({ icon, action, children, className, ...props }, ref) => /* @__PURE__ */ jsxs2("span", {
145
+ ...props,
146
+ ref,
147
+ className: cn("chat-composer-context-item", className),
148
+ children: [
149
+ icon ? /* @__PURE__ */ jsx2("span", {
150
+ className: "chat-composer-context-icon",
151
+ "aria-hidden": "true",
152
+ children: icon
153
+ }) : null,
154
+ /* @__PURE__ */ jsx2("span", {
155
+ className: "chat-composer-context-label",
156
+ children
157
+ }),
158
+ action ? /* @__PURE__ */ jsx2("button", {
159
+ type: "button",
160
+ className: "btn btn-ghost btn-xs",
161
+ "aria-label": action.label,
162
+ title: action.label,
163
+ disabled: action.disabled,
164
+ onClick: action.onClick,
165
+ children: action.children ?? action.label
166
+ }) : null
167
+ ]
168
+ }));
169
+ ChatComposerContextItem.displayName = "Chat.ComposerContextItem";
170
+ var ChatComposerContextEnd = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ */ jsx2("span", {
171
+ ...props,
172
+ ref,
173
+ className: cn("chat-composer-context-end", className)
174
+ }));
175
+ ChatComposerContextEnd.displayName = "Chat.ComposerContextEnd";
176
+ var connectionLabels = {
177
+ connected: "Connected",
178
+ connecting: "Connecting",
179
+ disconnected: "Disconnected"
180
+ };
181
+ var ChatComposerConnection = forwardRef2(({ state, label, className, ...props }, ref) => /* @__PURE__ */ jsx2("span", {
182
+ role: "status",
183
+ ...props,
184
+ ref,
185
+ "data-state": state,
186
+ className: cn("chat-composer-connection", className),
187
+ children: label ?? connectionLabels[state]
188
+ }));
189
+ ChatComposerConnection.displayName = "Chat.ComposerConnection";
190
+
191
+ // src/components/chat/Chat.tsx
192
+ import {
193
+ forwardRef as forwardRef7,
194
+ useId as useId4,
195
+ useLayoutEffect as useLayoutEffect5,
196
+ useRef as useRef6,
197
+ useState as useState3
198
+ } from "react";
199
+
200
+ // src/components/chat/ChatComposer.tsx
201
+ import {
202
+ forwardRef as forwardRef5,
203
+ useId as useId2,
204
+ useLayoutEffect as useLayoutEffect4,
205
+ useRef as useRef5,
206
+ useState as useState2
207
+ } from "react";
208
+
209
+ // src/components/chat/composer/ComposerShell.tsx
210
+ import { forwardRef as forwardRef3, useEffect, useRef as useRef3, useState } from "react";
211
+
212
+ // src/components/button/Button.tsx
213
+ import React3 from "react";
214
+ import { createPortal } from "react-dom";
215
+
53
216
  // src/classes/button.ts
54
217
  var buttonBaseClass = "btn";
55
218
  var buttonColorClasses = {
@@ -97,7 +260,7 @@ function getButtonClasses({
97
260
  }
98
261
 
99
262
  // src/components/button/Button.tsx
100
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
263
+ import { jsx as jsx3, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
101
264
  function isPromiseLike(value) {
102
265
  return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
103
266
  }
@@ -118,18 +281,18 @@ function Button({
118
281
  onClick,
119
282
  ...props
120
283
  }) {
121
- const buttonRef = React.useRef(null);
122
- const popoverRef = React.useRef(null);
123
- const cancelRef = React.useRef(null);
124
- const approvalRef = React.useRef("idle");
125
- const pendingRef = React.useRef(false);
126
- const actionRef = React.useRef(0);
127
- const operationRef = React.useRef(0);
128
- const mountedRef = React.useRef(false);
129
- const [portalTarget, setPortalTarget] = React.useState(null);
130
- const [confirmLoading, setConfirmLoading] = React.useState(false);
131
- const [confirmError, setConfirmError] = React.useState(false);
132
- const generatedId = React.useId().replace(/:/g, "");
284
+ const buttonRef = React3.useRef(null);
285
+ const popoverRef = React3.useRef(null);
286
+ const cancelRef = React3.useRef(null);
287
+ const approvalRef = React3.useRef("idle");
288
+ const pendingRef = React3.useRef(false);
289
+ const actionRef = React3.useRef(0);
290
+ const operationRef = React3.useRef(0);
291
+ const mountedRef = React3.useRef(false);
292
+ const [portalTarget, setPortalTarget] = React3.useState(null);
293
+ const [confirmLoading, setConfirmLoading] = React3.useState(false);
294
+ const [confirmError, setConfirmError] = React3.useState(false);
295
+ const generatedId = React3.useId().replace(/:/g, "");
133
296
  const popoverId = `button-confirm-${generatedId}`;
134
297
  const titleId = `${popoverId}-title`;
135
298
  const descriptionId = `${popoverId}-description`;
@@ -140,7 +303,7 @@ function Button({
140
303
  const hasTitle = title !== undefined && title !== null && title !== false && title !== "";
141
304
  const content = confirmation?.component ?? confirmation?.message ?? confirmation?.description;
142
305
  const hasContent = content !== undefined && content !== null && content !== false && content !== "";
143
- const mergedRef = React.useCallback((node) => {
306
+ const mergedRef = React3.useCallback((node) => {
144
307
  buttonRef.current = node;
145
308
  if (!node) {
146
309
  if (typeof ref === "function")
@@ -162,14 +325,14 @@ function Button({
162
325
  ref.current = null;
163
326
  };
164
327
  }, [ref]);
165
- React.useEffect(() => {
328
+ React3.useEffect(() => {
166
329
  mountedRef.current = true;
167
330
  return () => {
168
331
  mountedRef.current = false;
169
332
  operationRef.current += 1;
170
333
  };
171
334
  }, []);
172
- React.useEffect(() => {
335
+ React3.useEffect(() => {
173
336
  operationRef.current += 1;
174
337
  approvalRef.current = "idle";
175
338
  setConfirmError(false);
@@ -277,9 +440,9 @@ function Button({
277
440
  size: "sm",
278
441
  isLoading: confirmLoading
279
442
  });
280
- return /* @__PURE__ */ jsxs(Fragment, {
443
+ return /* @__PURE__ */ jsxs3(Fragment, {
281
444
  children: [
282
- /* @__PURE__ */ jsxs("button", {
445
+ /* @__PURE__ */ jsxs3("button", {
283
446
  ref: confirm ? mergedRef : ref,
284
447
  className: classes,
285
448
  disabled: disabled || isLoading,
@@ -291,24 +454,24 @@ function Button({
291
454
  "aria-controls": confirm ? popoverId : props["aria-controls"],
292
455
  onClick: confirm ? handleClick : onClick,
293
456
  children: [
294
- isLoading && /* @__PURE__ */ jsx("span", {
457
+ isLoading && /* @__PURE__ */ jsx3("span", {
295
458
  className: "btn-spinner"
296
459
  }),
297
- !isLoading && leftIcon && /* @__PURE__ */ jsx("span", {
460
+ !isLoading && leftIcon && /* @__PURE__ */ jsx3("span", {
298
461
  className: "btn-icon-left",
299
462
  children: leftIcon
300
463
  }),
301
- /* @__PURE__ */ jsx("span", {
464
+ /* @__PURE__ */ jsx3("span", {
302
465
  className: "btn-content",
303
466
  children
304
467
  }),
305
- !isLoading && rightIcon && /* @__PURE__ */ jsx("span", {
468
+ !isLoading && rightIcon && /* @__PURE__ */ jsx3("span", {
306
469
  className: "btn-icon-right",
307
470
  children: rightIcon
308
471
  })
309
472
  ]
310
473
  }),
311
- confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs("form", {
474
+ confirm && portalTarget && createPortal(/* @__PURE__ */ jsxs3("form", {
312
475
  id: popoverId,
313
476
  ref: popoverRef,
314
477
  popover: "auto",
@@ -329,28 +492,28 @@ function Button({
329
492
  }
330
493
  },
331
494
  children: [
332
- hasTitle && /* @__PURE__ */ jsx("div", {
495
+ hasTitle && /* @__PURE__ */ jsx3("div", {
333
496
  className: "popover-header",
334
- children: /* @__PURE__ */ jsx("h3", {
497
+ children: /* @__PURE__ */ jsx3("h3", {
335
498
  id: titleId,
336
499
  className: "popover-title",
337
500
  children: title
338
501
  })
339
502
  }),
340
- hasContent && /* @__PURE__ */ jsx("div", {
503
+ hasContent && /* @__PURE__ */ jsx3("div", {
341
504
  id: descriptionId,
342
505
  className: "popover-body",
343
506
  children: content
344
507
  }),
345
- confirmError && /* @__PURE__ */ jsx("div", {
508
+ confirmError && /* @__PURE__ */ jsx3("div", {
346
509
  role: "alert",
347
510
  className: "popover-body",
348
511
  children: "The action failed. Please try again."
349
512
  }),
350
- /* @__PURE__ */ jsxs("div", {
513
+ /* @__PURE__ */ jsxs3("div", {
351
514
  className: "popover-footer",
352
515
  children: [
353
- /* @__PURE__ */ jsx("button", {
516
+ /* @__PURE__ */ jsx3("button", {
354
517
  ref: cancelRef,
355
518
  type: "button",
356
519
  className: "btn btn-text btn-sm",
@@ -359,7 +522,7 @@ function Button({
359
522
  disabled: confirmLoading,
360
523
  children: confirmation?.cancelText ?? "Cancel"
361
524
  }),
362
- /* @__PURE__ */ jsx("button", {
525
+ /* @__PURE__ */ jsx3("button", {
363
526
  type: "submit",
364
527
  className: confirmClasses,
365
528
  disabled: disabled || isLoading || confirmLoading,
@@ -374,8 +537,8 @@ function Button({
374
537
  });
375
538
  }
376
539
  // src/components/chat/composer/CompletionList.tsx
377
- import React2, { useLayoutEffect, useRef } from "react";
378
- import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
540
+ import React4, { useLayoutEffect as useLayoutEffect2, useRef as useRef2 } from "react";
541
+ import { jsx as jsx4, jsxs as jsxs4, Fragment as Fragment2 } from "react/jsx-runtime";
379
542
  function completionOptionId(composerId, candidateId) {
380
543
  return `${composerId}-option-${encodeURIComponent(candidateId)}`;
381
544
  }
@@ -391,12 +554,12 @@ function CompletionList({
391
554
  status,
392
555
  onDismiss
393
556
  }) {
394
- const surface = useRef(null);
395
- useLayoutEffect(() => {
557
+ const surface = useRef2(null);
558
+ useLayoutEffect2(() => {
396
559
  if (compact)
397
560
  surface.current?.showPopover?.();
398
561
  }, [compact]);
399
- useLayoutEffect(() => {
562
+ useLayoutEffect2(() => {
400
563
  const tray = surface.current;
401
564
  const option = tray?.querySelector('[aria-selected="true"]');
402
565
  if (!compact || !tray || !option)
@@ -410,20 +573,20 @@ function CompletionList({
410
573
  else if (selected.bottom > bottom)
411
574
  tray.scrollTop += selected.bottom - bottom;
412
575
  }, [compact, activeId, candidates]);
413
- const list = candidates.length ? /* @__PURE__ */ jsx2("ul", {
576
+ const list = candidates.length ? /* @__PURE__ */ jsx4("ul", {
414
577
  id: `${composerId}-completions`,
415
578
  role: "listbox",
416
579
  "aria-label": label,
417
580
  className: compact ? "chat-composer-completion-list" : "chat-composer-completions",
418
- children: candidates.map((item, index) => /* @__PURE__ */ jsxs2(React2.Fragment, {
581
+ children: candidates.map((item, index) => /* @__PURE__ */ jsxs4(React4.Fragment, {
419
582
  children: [
420
- item.group && candidates[index - 1]?.group !== item.group ? /* @__PURE__ */ jsx2("li", {
583
+ item.group && candidates[index - 1]?.group !== item.group ? /* @__PURE__ */ jsx4("li", {
421
584
  role: "presentation",
422
585
  className: "chat-composer-group",
423
586
  "aria-hidden": "true",
424
587
  children: item.group
425
588
  }) : null,
426
- /* @__PURE__ */ jsxs2("li", {
589
+ /* @__PURE__ */ jsxs4("li", {
427
590
  id: completionOptionId(composerId, item.id),
428
591
  className: compact ? "chat-composer-option chat-composer-option-compact" : "chat-composer-option",
429
592
  role: "option",
@@ -442,22 +605,22 @@ function CompletionList({
442
605
  }
443
606
  },
444
607
  children: [
445
- compact && item.icon ? /* @__PURE__ */ jsx2("span", {
608
+ compact && item.icon ? /* @__PURE__ */ jsx4("span", {
446
609
  className: "chat-composer-option-icon",
447
610
  "aria-hidden": "true",
448
611
  children: item.icon
449
612
  }) : null,
450
- /* @__PURE__ */ jsx2("span", {
613
+ /* @__PURE__ */ jsx4("span", {
451
614
  className: compact ? "chat-composer-label" : undefined,
452
615
  title: item.label,
453
616
  children: item.label
454
617
  }),
455
- item.description ? /* @__PURE__ */ jsx2("span", {
618
+ item.description ? /* @__PURE__ */ jsx4("span", {
456
619
  className: compact ? "chat-composer-description chat-composer-option-description" : "chat-composer-description",
457
620
  title: typeof item.description === "string" ? item.description : undefined,
458
621
  children: item.description
459
622
  }) : null,
460
- compact && item.sourceLabel ? /* @__PURE__ */ jsx2("span", {
623
+ compact && item.sourceLabel ? /* @__PURE__ */ jsx4("span", {
461
624
  className: "chat-composer-description chat-composer-option-source",
462
625
  children: item.sourceLabel
463
626
  }) : null
@@ -466,7 +629,7 @@ function CompletionList({
466
629
  ]
467
630
  }, item.id))
468
631
  }) : null;
469
- return compact ? /* @__PURE__ */ jsxs2("div", {
632
+ return compact ? /* @__PURE__ */ jsxs4("div", {
470
633
  ref: surface,
471
634
  popover: "auto",
472
635
  className: "chat-composer-completions chat-composer-completions-compact",
@@ -480,7 +643,7 @@ function CompletionList({
480
643
  list,
481
644
  status
482
645
  ]
483
- }) : /* @__PURE__ */ jsxs2(Fragment2, {
646
+ }) : /* @__PURE__ */ jsxs4(Fragment2, {
484
647
  children: [
485
648
  header,
486
649
  status,
@@ -490,9 +653,9 @@ function CompletionList({
490
653
  }
491
654
 
492
655
  // src/components/chat/composer/ComposerShell.tsx
493
- import { jsx as jsx3, jsxs as jsxs3, Fragment as Fragment3 } from "react/jsx-runtime";
656
+ import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment3 } from "react/jsx-runtime";
494
657
  function AttachmentPreview({ file }) {
495
- const imageRef = useRef2(null);
658
+ const imageRef = useRef3(null);
496
659
  useEffect(() => {
497
660
  const image = imageRef.current;
498
661
  if (!image || !file.type.startsWith("image/") || !URL.createObjectURL)
@@ -506,7 +669,7 @@ function AttachmentPreview({ file }) {
506
669
  URL.revokeObjectURL(objectUrl);
507
670
  };
508
671
  }, [file]);
509
- return file.type.startsWith("image/") ? /* @__PURE__ */ jsx3("img", {
672
+ return file.type.startsWith("image/") ? /* @__PURE__ */ jsx5("img", {
510
673
  ref: imageRef,
511
674
  className: "chat-composer-preview",
512
675
  alt: file.name,
@@ -516,7 +679,7 @@ function AttachmentPreview({ file }) {
516
679
  function ComposerIcon({
517
680
  action
518
681
  }) {
519
- return /* @__PURE__ */ jsx3("svg", {
682
+ return /* @__PURE__ */ jsx5("svg", {
520
683
  width: "18",
521
684
  height: "18",
522
685
  viewBox: "0 0 24 24",
@@ -527,11 +690,11 @@ function ComposerIcon({
527
690
  strokeLinejoin: "round",
528
691
  "aria-hidden": "true",
529
692
  focusable: "false",
530
- children: action === "attach" ? /* @__PURE__ */ jsx3("path", {
693
+ children: action === "attach" ? /* @__PURE__ */ jsx5("path", {
531
694
  d: "M12 5v14M5 12h14"
532
- }) : action === "send" ? /* @__PURE__ */ jsx3("path", {
695
+ }) : action === "send" ? /* @__PURE__ */ jsx5("path", {
533
696
  d: "m5 12 7-7 7 7M12 5v14"
534
- }) : action === "stop" ? /* @__PURE__ */ jsx3("rect", {
697
+ }) : action === "stop" ? /* @__PURE__ */ jsx5("rect", {
535
698
  x: "6",
536
699
  y: "6",
537
700
  width: "12",
@@ -539,9 +702,9 @@ function ComposerIcon({
539
702
  rx: "1",
540
703
  fill: "currentColor",
541
704
  stroke: "none"
542
- }) : action === "retry" ? /* @__PURE__ */ jsx3("path", {
705
+ }) : action === "retry" ? /* @__PURE__ */ jsx5("path", {
543
706
  d: "M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7"
544
- }) : /* @__PURE__ */ jsx3("path", {
707
+ }) : /* @__PURE__ */ jsx5("path", {
545
708
  d: "m6 6 12 12M6 18 18 6"
546
709
  })
547
710
  });
@@ -559,11 +722,12 @@ function ExtraActions({
559
722
  }) {
560
723
  return typeof children === "function" ? children(context) : children;
561
724
  }
562
- var ComposerShell = forwardRef(({
725
+ var ComposerShell = forwardRef3(({
563
726
  editor,
564
727
  composerId,
565
728
  compact = false,
566
729
  addMenu,
730
+ context,
567
731
  entries,
568
732
  renderAttachment,
569
733
  removeAttachment,
@@ -605,9 +769,9 @@ var ComposerShell = forwardRef(({
605
769
  const addAnchor = `--composer-add-${composerId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
606
770
  const completionAnchor = `--composer-completions-${composerId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
607
771
  const thumbnails = compact && entries.length > 0 && !renderAttachment && entries.every(({ file, previewUrl, state, status, progress, retry, cancel }) => (previewUrl || file?.type.startsWith("image/") && typeof URL.createObjectURL === "function") && (!state || state === "ready") && !status && progress === undefined && !retry && !cancel);
608
- const attachmentAction = onAttachmentsChange ? /* @__PURE__ */ jsxs3(Fragment3, {
772
+ const attachmentAction = onAttachmentsChange ? /* @__PURE__ */ jsxs5(Fragment3, {
609
773
  children: [
610
- /* @__PURE__ */ jsx3("input", {
774
+ /* @__PURE__ */ jsx5("input", {
611
775
  ref: pickerRef,
612
776
  type: "file",
613
777
  accept,
@@ -622,7 +786,7 @@ var ComposerShell = forwardRef(({
622
786
  addAttachments(files, "picker");
623
787
  }
624
788
  }),
625
- /* @__PURE__ */ jsx3(Button, {
789
+ /* @__PURE__ */ jsx5(Button, {
626
790
  type: "button",
627
791
  color: "base",
628
792
  appearance: "ghost",
@@ -632,15 +796,15 @@ var ComposerShell = forwardRef(({
632
796
  title: attachLabel,
633
797
  disabled,
634
798
  onClick: openAttachments,
635
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
799
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
636
800
  action: "attach"
637
801
  })
638
802
  })
639
803
  ]
640
804
  }) : null;
641
- const actionContent = /* @__PURE__ */ jsxs3(Fragment3, {
805
+ const actionContent = /* @__PURE__ */ jsxs5(Fragment3, {
642
806
  children: [
643
- /* @__PURE__ */ jsx3(ExtraActions, {
807
+ /* @__PURE__ */ jsx5(ExtraActions, {
644
808
  context: {
645
809
  submit: () => {
646
810
  submit();
@@ -653,7 +817,7 @@ var ComposerShell = forwardRef(({
653
817
  },
654
818
  children
655
819
  }),
656
- generating && onStop && (!compact || !eligible) ? /* @__PURE__ */ jsx3(Button, {
820
+ generating && onStop && (!compact || !eligible) ? /* @__PURE__ */ jsx5(Button, {
657
821
  type: "button",
658
822
  color: compact ? "primary" : undefined,
659
823
  size: "sm",
@@ -662,11 +826,11 @@ var ComposerShell = forwardRef(({
662
826
  title: stopLabel,
663
827
  disabled,
664
828
  onClick: onStop,
665
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
829
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
666
830
  action: "stop"
667
831
  })
668
832
  }) : null,
669
- !compact || !generating || !onStop || eligible ? /* @__PURE__ */ jsx3(Button, {
833
+ !compact || !generating || !onStop || eligible ? /* @__PURE__ */ jsx5(Button, {
670
834
  type: "button",
671
835
  color: "primary",
672
836
  size: "sm",
@@ -678,19 +842,19 @@ var ComposerShell = forwardRef(({
678
842
  onClick: () => {
679
843
  submit();
680
844
  },
681
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
845
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
682
846
  action: "send"
683
847
  })
684
848
  }) : null
685
849
  ]
686
850
  });
687
851
  function renderToolbar(menuContent) {
688
- return compact ? /* @__PURE__ */ jsxs3("div", {
852
+ return compact ? /* @__PURE__ */ jsxs5("div", {
689
853
  className: "chat-composer-toolbar chat-composer-toolbar-compact",
690
854
  children: [
691
- onAttachmentsChange || addMenu || menuContent ? /* @__PURE__ */ jsxs3(Fragment3, {
855
+ onAttachmentsChange || addMenu || menuContent ? /* @__PURE__ */ jsxs5(Fragment3, {
692
856
  children: [
693
- /* @__PURE__ */ jsx3(Button, {
857
+ /* @__PURE__ */ jsx5(Button, {
694
858
  type: "button",
695
859
  color: "base",
696
860
  appearance: "ghost",
@@ -703,11 +867,11 @@ var ComposerShell = forwardRef(({
703
867
  "aria-controls": addId,
704
868
  "aria-expanded": addOpen,
705
869
  style: { anchorName: addAnchor },
706
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
870
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
707
871
  action: "attach"
708
872
  })
709
873
  }),
710
- /* @__PURE__ */ jsxs3("div", {
874
+ /* @__PURE__ */ jsxs5("div", {
711
875
  id: addId,
712
876
  popover: "auto",
713
877
  role: "group",
@@ -716,13 +880,13 @@ var ComposerShell = forwardRef(({
716
880
  style: { positionAnchor: addAnchor },
717
881
  onToggle: (event) => setAddOpen(event.currentTarget.matches(":popover-open")),
718
882
  children: [
719
- /* @__PURE__ */ jsx3("div", {
883
+ /* @__PURE__ */ jsx5("div", {
720
884
  className: "chat-composer-group",
721
885
  children: "Add"
722
886
  }),
723
- onAttachmentsChange ? /* @__PURE__ */ jsxs3(Fragment3, {
887
+ onAttachmentsChange ? /* @__PURE__ */ jsxs5(Fragment3, {
724
888
  children: [
725
- /* @__PURE__ */ jsx3("input", {
889
+ /* @__PURE__ */ jsx5("input", {
726
890
  ref: pickerRef,
727
891
  type: "file",
728
892
  accept,
@@ -737,7 +901,7 @@ var ComposerShell = forwardRef(({
737
901
  addAttachments(files, "picker");
738
902
  }
739
903
  }),
740
- /* @__PURE__ */ jsxs3("button", {
904
+ /* @__PURE__ */ jsxs5("button", {
741
905
  type: "button",
742
906
  className: "popover-menu-item",
743
907
  disabled,
@@ -746,10 +910,10 @@ var ComposerShell = forwardRef(({
746
910
  openAttachments();
747
911
  },
748
912
  children: [
749
- /* @__PURE__ */ jsx3(ComposerIcon, {
913
+ /* @__PURE__ */ jsx5(ComposerIcon, {
750
914
  action: "attach"
751
915
  }),
752
- /* @__PURE__ */ jsx3("span", {
916
+ /* @__PURE__ */ jsx5("span", {
753
917
  children: "Files"
754
918
  })
755
919
  ]
@@ -762,12 +926,12 @@ var ComposerShell = forwardRef(({
762
926
  })
763
927
  ]
764
928
  }) : null,
765
- /* @__PURE__ */ jsx3("div", {
929
+ /* @__PURE__ */ jsx5("div", {
766
930
  className: "chat-composer-actions",
767
931
  children: actionContent
768
932
  })
769
933
  ]
770
- }) : /* @__PURE__ */ jsxs3("div", {
934
+ }) : /* @__PURE__ */ jsxs5("div", {
771
935
  className: "chat-composer-actions",
772
936
  children: [
773
937
  attachmentAction,
@@ -775,10 +939,10 @@ var ComposerShell = forwardRef(({
775
939
  ]
776
940
  });
777
941
  }
778
- return /* @__PURE__ */ jsxs3("div", {
942
+ return /* @__PURE__ */ jsxs5("div", {
779
943
  ...props,
780
944
  ref,
781
- className: cn("chat-composer", className),
945
+ className: cn("chat-composer", compact && "chat-composer-compact", className),
782
946
  style: compact ? {
783
947
  ...props.style,
784
948
  anchorName: props.style?.anchorName && props.style.anchorName !== "none" ? `${props.style.anchorName}, ${completionAnchor}` : completionAnchor
@@ -807,7 +971,8 @@ var ComposerShell = forwardRef(({
807
971
  }
808
972
  },
809
973
  children: [
810
- entries.length > 0 ? /* @__PURE__ */ jsx3("ul", {
974
+ context,
975
+ entries.length > 0 ? /* @__PURE__ */ jsx5("ul", {
811
976
  role: "list",
812
977
  className: cn("chat-composer-attachments", thumbnails && "chat-composer-thumbnails"),
813
978
  "aria-label": "Attachments",
@@ -823,38 +988,38 @@ var ComposerShell = forwardRef(({
823
988
  cancel
824
989
  }) => {
825
990
  const name = file?.name ?? entryName ?? "Attachment";
826
- return /* @__PURE__ */ jsx3("li", {
991
+ return /* @__PURE__ */ jsx5("li", {
827
992
  className: cn("chat-composer-attachment", thumbnails && "chat-composer-attachment-tile"),
828
993
  "data-state": state,
829
- children: renderAttachment && file ? /* @__PURE__ */ jsx3(AttachmentContent, {
994
+ children: renderAttachment && file ? /* @__PURE__ */ jsx5(AttachmentContent, {
830
995
  file,
831
996
  renderAttachment,
832
997
  context: {
833
998
  remove: () => removeAttachment(id),
834
999
  disabled: disabled || !onAttachmentsChange
835
1000
  }
836
- }) : /* @__PURE__ */ jsxs3(Fragment3, {
1001
+ }) : /* @__PURE__ */ jsxs5(Fragment3, {
837
1002
  children: [
838
- previewUrl ? /* @__PURE__ */ jsx3("img", {
1003
+ previewUrl ? /* @__PURE__ */ jsx5("img", {
839
1004
  className: "chat-composer-preview",
840
1005
  src: previewUrl,
841
1006
  alt: name
842
- }) : file ? /* @__PURE__ */ jsx3(AttachmentPreview, {
1007
+ }) : file ? /* @__PURE__ */ jsx5(AttachmentPreview, {
843
1008
  file
844
1009
  }) : null,
845
- !thumbnails ? /* @__PURE__ */ jsxs3("div", {
1010
+ !thumbnails ? /* @__PURE__ */ jsxs5("div", {
846
1011
  className: "chat-composer-attachment-info",
847
1012
  children: [
848
- /* @__PURE__ */ jsx3("span", {
1013
+ /* @__PURE__ */ jsx5("span", {
849
1014
  className: "chat-composer-filename",
850
1015
  title: name,
851
1016
  children: name
852
1017
  }),
853
- status ? /* @__PURE__ */ jsx3("span", {
1018
+ status ? /* @__PURE__ */ jsx5("span", {
854
1019
  className: "chat-composer-description",
855
1020
  children: status
856
1021
  }) : null,
857
- progress !== undefined ? /* @__PURE__ */ jsx3("progress", {
1022
+ progress !== undefined ? /* @__PURE__ */ jsx5("progress", {
858
1023
  className: "progress",
859
1024
  value: progress,
860
1025
  max: 1,
@@ -862,7 +1027,7 @@ var ComposerShell = forwardRef(({
862
1027
  }) : null
863
1028
  ]
864
1029
  }) : null,
865
- retry ? /* @__PURE__ */ jsx3(Button, {
1030
+ retry ? /* @__PURE__ */ jsx5(Button, {
866
1031
  type: "button",
867
1032
  size: "sm",
868
1033
  shape: "circle",
@@ -870,11 +1035,11 @@ var ComposerShell = forwardRef(({
870
1035
  onClick: retry,
871
1036
  "aria-label": `Retry ${name}`,
872
1037
  title: `Retry ${name}`,
873
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
1038
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
874
1039
  action: "retry"
875
1040
  })
876
1041
  }) : null,
877
- cancel ? /* @__PURE__ */ jsx3(Button, {
1042
+ cancel ? /* @__PURE__ */ jsx5(Button, {
878
1043
  type: "button",
879
1044
  size: "sm",
880
1045
  shape: "circle",
@@ -882,11 +1047,11 @@ var ComposerShell = forwardRef(({
882
1047
  onClick: cancel,
883
1048
  "aria-label": `Cancel ${name}`,
884
1049
  title: `Cancel ${name}`,
885
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
1050
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
886
1051
  action: "remove"
887
1052
  })
888
1053
  }) : null,
889
- onAttachmentsChange ? /* @__PURE__ */ jsx3(Button, {
1054
+ onAttachmentsChange ? /* @__PURE__ */ jsx5(Button, {
890
1055
  type: "button",
891
1056
  size: thumbnails ? "xs" : "sm",
892
1057
  shape: "circle",
@@ -897,7 +1062,7 @@ var ComposerShell = forwardRef(({
897
1062
  "aria-label": `Remove ${name}`,
898
1063
  title: `Remove ${name}`,
899
1064
  onClick: () => removeAttachment(id),
900
- children: /* @__PURE__ */ jsx3(ComposerIcon, {
1065
+ children: /* @__PURE__ */ jsx5(ComposerIcon, {
901
1066
  action: "remove"
902
1067
  })
903
1068
  }) : null
@@ -907,7 +1072,7 @@ var ComposerShell = forwardRef(({
907
1072
  })
908
1073
  }) : null,
909
1074
  editor,
910
- showCompletion || completionHeader || completionStatus ? /* @__PURE__ */ jsx3(CompletionList, {
1075
+ showCompletion || completionHeader || completionStatus ? /* @__PURE__ */ jsx5(CompletionList, {
911
1076
  composerId,
912
1077
  label: completion?.label ?? "Suggestions",
913
1078
  candidates: showCompletion ? candidates : [],
@@ -920,7 +1085,7 @@ var ComposerShell = forwardRef(({
920
1085
  onDismiss: dismissCompletion
921
1086
  }) : null,
922
1087
  statusContent,
923
- hasError ? /* @__PURE__ */ jsx3("div", {
1088
+ hasError ? /* @__PURE__ */ jsx5("div", {
924
1089
  id: `${composerId}-error`,
925
1090
  role: "alert",
926
1091
  className: "chat-composer-error chat-composer-status",
@@ -935,10 +1100,10 @@ ComposerShell.displayName = "ComposerShell";
935
1100
 
936
1101
  // src/components/chat/composer/PlainEditor.tsx
937
1102
  import {
938
- forwardRef as forwardRef2,
939
- useImperativeHandle,
940
- useLayoutEffect as useLayoutEffect2,
941
- useRef as useRef3
1103
+ forwardRef as forwardRef4,
1104
+ useImperativeHandle as useImperativeHandle2,
1105
+ useLayoutEffect as useLayoutEffect3,
1106
+ useRef as useRef4
942
1107
  } from "react";
943
1108
 
944
1109
  // src/classes/input.ts
@@ -1027,8 +1192,8 @@ function getTextAreaCountClasses({ exceeded }) {
1027
1192
  }
1028
1193
 
1029
1194
  // src/components/chat/composer/PlainEditor.tsx
1030
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1031
- var PlainEditor = forwardRef2(({
1195
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1196
+ var PlainEditor = forwardRef4(({
1032
1197
  value,
1033
1198
  disabled,
1034
1199
  minRows,
@@ -1044,8 +1209,8 @@ var PlainEditor = forwardRef2(({
1044
1209
  onChange,
1045
1210
  onKeyDown
1046
1211
  }, ref) => {
1047
- const editorRef = useRef3(null);
1048
- const composingRef = useRef3(false);
1212
+ const editorRef = useRef4(null);
1213
+ const composingRef = useRef4(false);
1049
1214
  const minimumRows = Math.max(1, Math.floor(minRows));
1050
1215
  const maximumRows = Math.max(minimumRows, Math.floor(maxRows));
1051
1216
  const { showCount, ...nativeProps } = textareaProps ?? {};
@@ -1053,7 +1218,7 @@ var PlainEditor = forwardRef2(({
1053
1218
  delete nativeProps.status;
1054
1219
  delete nativeProps.variant;
1055
1220
  delete nativeProps.resize;
1056
- useImperativeHandle(ref, () => ({
1221
+ useImperativeHandle2(ref, () => ({
1057
1222
  focus: () => editorRef.current?.focus(),
1058
1223
  select: (start, end) => editorRef.current?.setSelectionRange(start, end),
1059
1224
  selection: (currentValue) => ({
@@ -1062,10 +1227,10 @@ var PlainEditor = forwardRef2(({
1062
1227
  selectionEnd: editorRef.current?.selectionEnd ?? currentValue.length
1063
1228
  })
1064
1229
  }), []);
1065
- useLayoutEffect2(() => {
1230
+ useLayoutEffect3(() => {
1066
1231
  composingRef.current = false;
1067
1232
  }, [generation]);
1068
- useLayoutEffect2(() => {
1233
+ useLayoutEffect3(() => {
1069
1234
  const editor = editorRef.current;
1070
1235
  if (!editor)
1071
1236
  return;
@@ -1093,7 +1258,7 @@ var PlainEditor = forwardRef2(({
1093
1258
  window.removeEventListener("resize", measure);
1094
1259
  };
1095
1260
  }, [value, minimumRows, maximumRows, textareaProps?.style]);
1096
- const control = /* @__PURE__ */ jsx4("textarea", {
1261
+ const control = /* @__PURE__ */ jsx6("textarea", {
1097
1262
  ...nativeProps,
1098
1263
  ref: editorRef,
1099
1264
  className: cn("chat-composer-editor", textareaProps?.className),
@@ -1123,11 +1288,11 @@ var PlainEditor = forwardRef2(({
1123
1288
  onKeyDown(event);
1124
1289
  }
1125
1290
  });
1126
- return showCount ? /* @__PURE__ */ jsxs4("span", {
1291
+ return showCount ? /* @__PURE__ */ jsxs6("span", {
1127
1292
  className: textAreaWrapperClass,
1128
1293
  children: [
1129
1294
  control,
1130
- /* @__PURE__ */ jsxs4("span", {
1295
+ /* @__PURE__ */ jsxs6("span", {
1131
1296
  className: getTextAreaCountClasses({
1132
1297
  exceeded: textareaProps?.maxLength !== undefined && value.length > textareaProps.maxLength
1133
1298
  }),
@@ -1777,8 +1942,8 @@ function createComposerAttachmentController(options) {
1777
1942
  }
1778
1943
 
1779
1944
  // src/components/chat/ChatComposer.tsx
1780
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1781
- var ChatComposer = forwardRef3(({
1945
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1946
+ var ChatComposer = forwardRef5(({
1782
1947
  value,
1783
1948
  onValueChange,
1784
1949
  onSubmit,
@@ -1792,6 +1957,7 @@ var ChatComposer = forwardRef3(({
1792
1957
  allowAttachmentOnly = false,
1793
1958
  compact = false,
1794
1959
  addMenu,
1960
+ context,
1795
1961
  disabled = false,
1796
1962
  busy = false,
1797
1963
  generating = false,
@@ -1812,26 +1978,26 @@ var ChatComposer = forwardRef3(({
1812
1978
  className,
1813
1979
  ...props
1814
1980
  }, ref) => {
1815
- const id = useId();
1816
- const editorRef = useRef4(null);
1817
- const pickerRef = useRef4(null);
1818
- const mountedRef = useRef4(false);
1819
- const submittingRef = useRef4(false);
1820
- const revisionRef = useRef4(0);
1821
- const observedValueRef = useRef4(value);
1822
- const entriesRef = useRef4([]);
1823
- const nextEntryRef = useRef4(0);
1824
- const scopeRef = useRef4({
1981
+ const id = useId2();
1982
+ const editorRef = useRef5(null);
1983
+ const pickerRef = useRef5(null);
1984
+ const mountedRef = useRef5(false);
1985
+ const submittingRef = useRef5(false);
1986
+ const revisionRef = useRef5(0);
1987
+ const observedValueRef = useRef5(value);
1988
+ const entriesRef = useRef5([]);
1989
+ const nextEntryRef = useRef5(0);
1990
+ const scopeRef = useRef5({
1825
1991
  contextKey: scope?.contextKey,
1826
1992
  conversationId: scope?.conversationId
1827
1993
  });
1828
- const generationRef = useRef4(0);
1994
+ const generationRef = useRef5(0);
1829
1995
  const [submitting, setSubmitting] = useState2(false);
1830
1996
  const [submitError, setSubmitError] = useState2();
1831
1997
  const [attachmentRejections, setAttachmentRejections] = useState2([]);
1832
1998
  const [activeId, setActiveId] = useState2();
1833
1999
  const [dismissed, setDismissed] = useState2(false);
1834
- const latestRef = useRef4({
2000
+ const latestRef = useRef5({
1835
2001
  value,
1836
2002
  onValueChange,
1837
2003
  attachments,
@@ -1842,13 +2008,13 @@ var ChatComposer = forwardRef3(({
1842
2008
  const scopeChanged = scopeRef.current.contextKey !== scope?.contextKey || scopeRef.current.conversationId !== scope?.conversationId;
1843
2009
  const generation = generationRef.current + (scopeChanged ? 1 : 0);
1844
2010
  const occurrences = reconcileAttachments(scopeChanged ? [] : entriesRef.current, attachments, nextEntryRef.current);
1845
- useLayoutEffect3(() => {
2011
+ useLayoutEffect4(() => {
1846
2012
  mountedRef.current = true;
1847
2013
  return () => {
1848
2014
  mountedRef.current = false;
1849
2015
  };
1850
2016
  }, []);
1851
- useLayoutEffect3(() => {
2017
+ useLayoutEffect4(() => {
1852
2018
  if (scopeChanged) {
1853
2019
  scopeRef.current = {
1854
2020
  contextKey: scope?.contextKey,
@@ -1864,7 +2030,7 @@ var ChatComposer = forwardRef3(({
1864
2030
  revisionRef.current++;
1865
2031
  }
1866
2032
  }, [scopeChanged, scope?.contextKey, scope?.conversationId, generation]);
1867
- useLayoutEffect3(() => {
2033
+ useLayoutEffect4(() => {
1868
2034
  if (observedValueRef.current !== value) {
1869
2035
  revisionRef.current++;
1870
2036
  observedValueRef.current = value;
@@ -1892,8 +2058,8 @@ var ChatComposer = forwardRef3(({
1892
2058
  const candidates = completion?.items ?? [];
1893
2059
  const { enabled, active } = legacyCompletion(candidates, activeId);
1894
2060
  const showCompletion = !disabled && !dismissed && candidates.length > 0;
1895
- const visibleError = error ?? submitError ?? (attachmentRejections.length ? /* @__PURE__ */ jsx5("ul", {
1896
- children: attachmentRejections.map((item, index) => /* @__PURE__ */ jsxs5("li", {
2061
+ const visibleError = error ?? submitError ?? (attachmentRejections.length ? /* @__PURE__ */ jsx7("ul", {
2062
+ children: attachmentRejections.map((item, index) => /* @__PURE__ */ jsxs7("li", {
1897
2063
  children: [
1898
2064
  item.metadata.name,
1899
2065
  ": ",
@@ -1983,13 +2149,14 @@ var ChatComposer = forwardRef3(({
1983
2149
  }
1984
2150
  }
1985
2151
  }
1986
- return /* @__PURE__ */ jsx5(ComposerShell, {
2152
+ return /* @__PURE__ */ jsx7(ComposerShell, {
1987
2153
  ...props,
1988
2154
  ref,
1989
2155
  className,
1990
2156
  composerId: id,
1991
2157
  compact,
1992
2158
  addMenu,
2159
+ context,
1993
2160
  entries: occurrences.entries,
1994
2161
  renderAttachment,
1995
2162
  removeAttachment: (entryId) => {
@@ -2020,7 +2187,7 @@ var ChatComposer = forwardRef3(({
2020
2187
  openAttachments,
2021
2188
  submit,
2022
2189
  onStop,
2023
- editor: /* @__PURE__ */ jsx5(PlainEditor, {
2190
+ editor: /* @__PURE__ */ jsx7(PlainEditor, {
2024
2191
  ref: editorRef,
2025
2192
  value,
2026
2193
  disabled,
@@ -2072,7 +2239,7 @@ var ChatComposer = forwardRef3(({
2072
2239
  ChatComposer.displayName = "Chat.Composer";
2073
2240
 
2074
2241
  // src/components/chat/ChatPrimitives.tsx
2075
- import { forwardRef as forwardRef4, useId as useId2 } from "react";
2242
+ import { forwardRef as forwardRef6, useId as useId3 } from "react";
2076
2243
 
2077
2244
  // src/classes/chat.ts
2078
2245
  var chatBaseClass = "chat";
@@ -2149,69 +2316,69 @@ function getChatToolClasses({
2149
2316
  }
2150
2317
 
2151
2318
  // src/components/chat/ChatPrimitives.tsx
2152
- import { jsx as jsx6, jsxs as jsxs6, Fragment as Fragment4 } from "react/jsx-runtime";
2153
- var ChatAgent = forwardRef4(({ timeline, className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2319
+ import { jsx as jsx8, jsxs as jsxs8, Fragment as Fragment4 } from "react/jsx-runtime";
2320
+ var ChatAgent = forwardRef6(({ timeline, className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2154
2321
  ...props,
2155
2322
  ref,
2156
2323
  "data-chat-tl": timeline ?? props["data-chat-tl"],
2157
2324
  className: getChatClasses({ className: cn("chat-agent", className) })
2158
2325
  }));
2159
2326
  ChatAgent.displayName = "Chat.Agent";
2160
- var ChatContent = forwardRef4(({ streaming, className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2327
+ var ChatContent = forwardRef6(({ streaming, className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2161
2328
  ...props,
2162
2329
  ref,
2163
2330
  className: cn("chat-content", streaming && "chat-streaming", className)
2164
2331
  }));
2165
2332
  ChatContent.displayName = "Chat.Content";
2166
- var ChatWork = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("details", {
2333
+ var ChatWork = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("details", {
2167
2334
  ...props,
2168
2335
  ref,
2169
2336
  className: cn("chat-work", className)
2170
2337
  }));
2171
2338
  ChatWork.displayName = "Chat.Work";
2172
- var ChatWorkSummary = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("summary", {
2339
+ var ChatWorkSummary = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("summary", {
2173
2340
  ...props,
2174
2341
  ref,
2175
2342
  className: cn("chat-work-summary", className)
2176
2343
  }));
2177
2344
  ChatWorkSummary.displayName = "Chat.WorkSummary";
2178
- var ChatWorkBody = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2345
+ var ChatWorkBody = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2179
2346
  ...props,
2180
2347
  ref,
2181
2348
  className: cn("chat-work-body", className)
2182
2349
  }));
2183
2350
  ChatWorkBody.displayName = "Chat.WorkBody";
2184
- var ChatInputArea = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2351
+ var ChatInputArea = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2185
2352
  ...props,
2186
2353
  ref,
2187
2354
  className: cn("chat-input-area", className)
2188
2355
  }));
2189
2356
  ChatInputArea.displayName = "Chat.InputArea";
2190
- var ChatComposerForm = forwardRef4(({ color, ghost, className, ...props }, ref) => /* @__PURE__ */ jsx6("form", {
2357
+ var ChatComposerForm = forwardRef6(({ color, ghost, className, ...props }, ref) => /* @__PURE__ */ jsx8("form", {
2191
2358
  ...props,
2192
2359
  ref,
2193
2360
  className: cn("chat-composer", color && `chat-composer-${color}`, ghost && "chat-composer-ghost", className)
2194
2361
  }));
2195
2362
  ChatComposerForm.displayName = "Chat.ComposerForm";
2196
- var ChatComposerInput = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("textarea", {
2363
+ var ChatComposerInput = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("textarea", {
2197
2364
  ...props,
2198
2365
  ref,
2199
2366
  className: cn("chat-composer-input", className)
2200
2367
  }));
2201
2368
  ChatComposerInput.displayName = "Chat.ComposerInput";
2202
- var ChatComposerActions = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("div", {
2369
+ var ChatComposerActions = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("div", {
2203
2370
  ...props,
2204
2371
  ref,
2205
2372
  className: cn("chat-composer-actions", className)
2206
2373
  }));
2207
2374
  ChatComposerActions.displayName = "Chat.ComposerActions";
2208
- var ChatComposerHint = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx6("kbd", {
2375
+ var ChatComposerHint = forwardRef6(({ className, ...props }, ref) => /* @__PURE__ */ jsx8("kbd", {
2209
2376
  ...props,
2210
2377
  ref,
2211
2378
  className: cn("chat-composer-hint", className)
2212
2379
  }));
2213
2380
  ChatComposerHint.displayName = "Chat.ComposerHint";
2214
- var ChatQueue = forwardRef4(({
2381
+ var ChatQueue = forwardRef6(({
2215
2382
  items,
2216
2383
  activeId = items[0]?.id,
2217
2384
  pendingIds = [],
@@ -2225,23 +2392,23 @@ var ChatQueue = forwardRef4(({
2225
2392
  className,
2226
2393
  ...props
2227
2394
  }, ref) => {
2228
- const titleId = `${useId2()}-queue-title`;
2229
- return /* @__PURE__ */ jsxs6("section", {
2395
+ const titleId = `${useId3()}-queue-title`;
2396
+ return /* @__PURE__ */ jsxs8("section", {
2230
2397
  ...props,
2231
2398
  ref,
2232
2399
  hidden: hidden || items.length === 0,
2233
2400
  "aria-labelledby": props["aria-labelledby"] ?? (props["aria-label"] ? undefined : titleId),
2234
2401
  className: cn("chat-queue", className),
2235
2402
  children: [
2236
- /* @__PURE__ */ jsxs6("div", {
2403
+ /* @__PURE__ */ jsxs8("div", {
2237
2404
  className: "chat-queue-header sr-only",
2238
2405
  children: [
2239
- /* @__PURE__ */ jsx6("h3", {
2406
+ /* @__PURE__ */ jsx8("h3", {
2240
2407
  className: "chat-queue-title",
2241
2408
  id: titleId,
2242
2409
  children: label
2243
2410
  }),
2244
- /* @__PURE__ */ jsxs6("span", {
2411
+ /* @__PURE__ */ jsxs8("span", {
2245
2412
  className: "chat-queue-count",
2246
2413
  children: [
2247
2414
  items.length,
@@ -2250,57 +2417,57 @@ var ChatQueue = forwardRef4(({
2250
2417
  })
2251
2418
  ]
2252
2419
  }),
2253
- /* @__PURE__ */ jsx6("ol", {
2420
+ /* @__PURE__ */ jsx8("ol", {
2254
2421
  className: "chat-queue-list",
2255
2422
  role: "list",
2256
2423
  tabIndex: 0,
2257
2424
  "aria-label": label,
2258
2425
  children: items.map((item, index) => {
2259
2426
  const pending = pendingIds.includes(item.id);
2260
- return /* @__PURE__ */ jsxs6("li", {
2427
+ return /* @__PURE__ */ jsxs8("li", {
2261
2428
  className: cn("chat-queue-item", item.id === activeId && "chat-queue-item-active"),
2262
2429
  "aria-busy": pending || undefined,
2263
2430
  children: [
2264
- /* @__PURE__ */ jsx6("svg", {
2431
+ /* @__PURE__ */ jsx8("svg", {
2265
2432
  className: "chat-queue-icon",
2266
2433
  viewBox: "0 0 24 24",
2267
2434
  fill: "none",
2268
2435
  stroke: "currentColor",
2269
2436
  "aria-hidden": "true",
2270
2437
  focusable: "false",
2271
- children: /* @__PURE__ */ jsx6("path", {
2438
+ children: /* @__PURE__ */ jsx8("path", {
2272
2439
  d: "m8 6 4 4-4 4M12 10H5m10-4h4m-4 6h4m-4 6h4"
2273
2440
  })
2274
2441
  }),
2275
- /* @__PURE__ */ jsxs6("span", {
2442
+ /* @__PURE__ */ jsxs8("span", {
2276
2443
  className: "chat-queue-number sr-only",
2277
2444
  children: [
2278
2445
  "#",
2279
2446
  index + 1
2280
2447
  ]
2281
2448
  }),
2282
- item.attachment ? /* @__PURE__ */ jsx6("img", {
2449
+ item.attachment ? /* @__PURE__ */ jsx8("img", {
2283
2450
  className: "chat-queue-attachment",
2284
2451
  src: item.attachment.src,
2285
2452
  alt: item.attachment.alt
2286
2453
  }) : null,
2287
- /* @__PURE__ */ jsx6("div", {
2454
+ /* @__PURE__ */ jsx8("div", {
2288
2455
  className: "chat-queue-content",
2289
2456
  title: item.text,
2290
2457
  children: renderItemContent ? renderItemContent(item, index) : item.text
2291
2458
  }),
2292
- /* @__PURE__ */ jsx6("div", {
2459
+ /* @__PURE__ */ jsx8("div", {
2293
2460
  className: "chat-actions chat-queue-actions",
2294
- children: renderItemActions ? renderItemActions(item, index, pending) : /* @__PURE__ */ jsxs6(Fragment4, {
2461
+ children: renderItemActions ? renderItemActions(item, index, pending) : /* @__PURE__ */ jsxs8(Fragment4, {
2295
2462
  children: [
2296
- /* @__PURE__ */ jsx6("button", {
2463
+ /* @__PURE__ */ jsx8("button", {
2297
2464
  className: "btn btn-ghost btn-sm btn-circle btn-icon btn-icon-sm chat-queue-steer",
2298
2465
  type: "button",
2299
2466
  disabled: pending || steerDisabled,
2300
2467
  "aria-label": `Steer waiting message ${index + 1}`,
2301
2468
  title: `Steer waiting message ${index + 1}`,
2302
2469
  onClick: () => onSteer(item.id),
2303
- children: /* @__PURE__ */ jsx6("svg", {
2470
+ children: /* @__PURE__ */ jsx8("svg", {
2304
2471
  width: "16",
2305
2472
  height: "16",
2306
2473
  style: { flexShrink: 0 },
@@ -2309,19 +2476,19 @@ var ChatQueue = forwardRef4(({
2309
2476
  stroke: "currentColor",
2310
2477
  "aria-hidden": "true",
2311
2478
  focusable: "false",
2312
- children: /* @__PURE__ */ jsx6("path", {
2479
+ children: /* @__PURE__ */ jsx8("path", {
2313
2480
  d: "m15 4 5 5-5 5M20 9h-9a6 6 0 0 0-6 6v4"
2314
2481
  })
2315
2482
  })
2316
2483
  }),
2317
- /* @__PURE__ */ jsx6("button", {
2484
+ /* @__PURE__ */ jsx8("button", {
2318
2485
  className: "btn btn-ghost btn-sm btn-circle btn-icon btn-icon-sm chat-queue-remove",
2319
2486
  type: "button",
2320
2487
  disabled: pending,
2321
2488
  "aria-label": `Remove waiting message ${index + 1}`,
2322
2489
  title: `Remove waiting message ${index + 1}`,
2323
2490
  onClick: () => onRemove(item.id),
2324
- children: /* @__PURE__ */ jsx6("svg", {
2491
+ children: /* @__PURE__ */ jsx8("svg", {
2325
2492
  width: "16",
2326
2493
  height: "16",
2327
2494
  style: { flexShrink: 0 },
@@ -2330,7 +2497,7 @@ var ChatQueue = forwardRef4(({
2330
2497
  stroke: "currentColor",
2331
2498
  "aria-hidden": "true",
2332
2499
  focusable: "false",
2333
- children: /* @__PURE__ */ jsx6("path", {
2500
+ children: /* @__PURE__ */ jsx8("path", {
2334
2501
  d: "M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7m4-7v7"
2335
2502
  })
2336
2503
  })
@@ -2348,20 +2515,20 @@ var ChatQueue = forwardRef4(({
2348
2515
  ChatQueue.displayName = "Chat.Queue";
2349
2516
 
2350
2517
  // src/components/chat/Chat.tsx
2351
- import { jsx as jsx7, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-runtime";
2352
- var ChatAvatar = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2518
+ import { jsx as jsx9, jsxs as jsxs9, Fragment as Fragment5 } from "react/jsx-runtime";
2519
+ var ChatAvatar = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2353
2520
  ...props,
2354
2521
  ref,
2355
2522
  className: cn(chatAvatarClass, className)
2356
2523
  }));
2357
2524
  ChatAvatar.displayName = "Chat.Avatar";
2358
- var ChatHeader = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2525
+ var ChatHeader = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2359
2526
  ...props,
2360
2527
  ref,
2361
2528
  className: cn(chatHeaderClass, className)
2362
2529
  }));
2363
2530
  ChatHeader.displayName = "Chat.Header";
2364
- var ChatBubble = forwardRef5(({
2531
+ var ChatBubble = forwardRef7(({
2365
2532
  color,
2366
2533
  size = "md",
2367
2534
  filled,
@@ -2374,15 +2541,15 @@ var ChatBubble = forwardRef5(({
2374
2541
  children,
2375
2542
  ...props
2376
2543
  }, ref) => {
2377
- const contentId = `${useId3()}-content`;
2378
- const contentRef = useRef5(null);
2379
- const toggleRef = useRef5(null);
2380
- const collapseRequestedRef = useRef5(false);
2544
+ const contentId = `${useId4()}-content`;
2545
+ const contentRef = useRef6(null);
2546
+ const toggleRef = useRef6(null);
2547
+ const collapseRequestedRef = useRef6(false);
2381
2548
  const [overflows, setOverflows] = useState3(false);
2382
2549
  const [internalExpanded, setInternalExpanded] = useState3(defaultExpanded);
2383
2550
  const requestedExpanded = expanded ?? internalExpanded;
2384
2551
  const isExpanded = overflows && requestedExpanded;
2385
- useLayoutEffect4(() => {
2552
+ useLayoutEffect5(() => {
2386
2553
  const content = contentRef.current;
2387
2554
  if (!collapsible || !content) {
2388
2555
  collapseRequestedRef.current = false;
@@ -2424,16 +2591,16 @@ var ChatBubble = forwardRef5(({
2424
2591
  mutation?.disconnect();
2425
2592
  };
2426
2593
  }, [collapsible, children, requestedExpanded, expanded, onExpandedChange]);
2427
- const body = /* @__PURE__ */ jsxs7(Fragment5, {
2594
+ const body = /* @__PURE__ */ jsxs9(Fragment5, {
2428
2595
  children: [
2429
2596
  children,
2430
- streaming ? /* @__PURE__ */ jsx7("span", {
2597
+ streaming ? /* @__PURE__ */ jsx9("span", {
2431
2598
  className: "chat-bubble-content chat-bubble-streaming",
2432
2599
  "aria-hidden": "true"
2433
2600
  }) : null
2434
2601
  ]
2435
2602
  });
2436
- return /* @__PURE__ */ jsx7("div", {
2603
+ return /* @__PURE__ */ jsx9("div", {
2437
2604
  ...props,
2438
2605
  ref,
2439
2606
  className: getChatBubbleClasses({
@@ -2443,16 +2610,16 @@ var ChatBubble = forwardRef5(({
2443
2610
  streaming,
2444
2611
  className: cn(collapsible && "chat-bubble-collapsible", className)
2445
2612
  }),
2446
- children: collapsible ? /* @__PURE__ */ jsxs7(Fragment5, {
2613
+ children: collapsible ? /* @__PURE__ */ jsxs9(Fragment5, {
2447
2614
  children: [
2448
- /* @__PURE__ */ jsx7("div", {
2615
+ /* @__PURE__ */ jsx9("div", {
2449
2616
  ref: contentRef,
2450
2617
  className: "chat-bubble-content",
2451
2618
  id: contentId,
2452
2619
  tabIndex: -1,
2453
2620
  children: body
2454
2621
  }),
2455
- /* @__PURE__ */ jsx7("button", {
2622
+ /* @__PURE__ */ jsx9("button", {
2456
2623
  ref: toggleRef,
2457
2624
  type: "button",
2458
2625
  className: "btn btn-ghost btn-xs chat-bubble-toggle",
@@ -2471,55 +2638,55 @@ var ChatBubble = forwardRef5(({
2471
2638
  });
2472
2639
  });
2473
2640
  ChatBubble.displayName = "Chat.Bubble";
2474
- var ChatFooter = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2641
+ var ChatFooter = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2475
2642
  ...props,
2476
2643
  ref,
2477
2644
  className: cn(chatFooterClass, className)
2478
2645
  }));
2479
2646
  ChatFooter.displayName = "Chat.Footer";
2480
- var ChatStatus = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2647
+ var ChatStatus = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2481
2648
  ...props,
2482
2649
  ref,
2483
2650
  className: cn(chatStatusClass, className)
2484
2651
  }));
2485
2652
  ChatStatus.displayName = "Chat.Status";
2486
- var ChatStatusItem = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("span", {
2653
+ var ChatStatusItem = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("span", {
2487
2654
  ...props,
2488
2655
  ref,
2489
2656
  className: cn(chatStatusItemClass, className)
2490
2657
  }));
2491
2658
  ChatStatusItem.displayName = "Chat.StatusItem";
2492
- var ChatStatusValue = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("span", {
2659
+ var ChatStatusValue = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("span", {
2493
2660
  ...props,
2494
2661
  ref,
2495
2662
  className: cn(chatStatusValueClass, className)
2496
2663
  }));
2497
2664
  ChatStatusValue.displayName = "Chat.StatusValue";
2498
- var ChatActions = forwardRef5(({ hover, className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2665
+ var ChatActions = forwardRef7(({ hover, className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2499
2666
  ...props,
2500
2667
  ref,
2501
2668
  className: cn(chatActionsClass, hover && chatActionsHoverClass, className)
2502
2669
  }));
2503
2670
  ChatActions.displayName = "Chat.Actions";
2504
- var ChatScroll = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2671
+ var ChatScroll = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2505
2672
  ...props,
2506
2673
  ref,
2507
2674
  className: cn(chatScrollClass, className)
2508
2675
  }));
2509
2676
  ChatScroll.displayName = "Chat.Scroll";
2510
- var ChatScrollBody = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2677
+ var ChatScrollBody = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2511
2678
  ...props,
2512
2679
  ref,
2513
2680
  className: cn(chatScrollBodyClass, className)
2514
2681
  }));
2515
2682
  ChatScrollBody.displayName = "Chat.ScrollBody";
2516
- var ChatScrollTrack = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2683
+ var ChatScrollTrack = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2517
2684
  ...props,
2518
2685
  ref,
2519
2686
  className: cn(chatScrollTrackClass, className)
2520
2687
  }));
2521
2688
  ChatScrollTrack.displayName = "Chat.ScrollTrack";
2522
- var ChatScrollIndicator = forwardRef5(({ targetId, timeline, type = "button", className, onClick, ...props }, ref) => /* @__PURE__ */ jsx7("button", {
2689
+ var ChatScrollIndicator = forwardRef7(({ targetId, timeline, type = "button", className, onClick, ...props }, ref) => /* @__PURE__ */ jsx9("button", {
2523
2690
  ...props,
2524
2691
  ref,
2525
2692
  type,
@@ -2541,59 +2708,59 @@ var ChatScrollIndicator = forwardRef5(({ targetId, timeline, type = "button", cl
2541
2708
  }
2542
2709
  }));
2543
2710
  ChatScrollIndicator.displayName = "Chat.ScrollIndicator";
2544
- var ChatReasoning = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("details", {
2711
+ var ChatReasoning = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("details", {
2545
2712
  ...props,
2546
2713
  ref,
2547
2714
  className: cn(chatReasoningClass, className)
2548
2715
  }));
2549
2716
  ChatReasoning.displayName = "Chat.Reasoning";
2550
- var ChatTool = forwardRef5(({ status, className, ...props }, ref) => /* @__PURE__ */ jsx7("details", {
2717
+ var ChatTool = forwardRef7(({ status, className, ...props }, ref) => /* @__PURE__ */ jsx9("details", {
2551
2718
  ...props,
2552
2719
  ref,
2553
2720
  className: getChatToolClasses({ status, className })
2554
2721
  }));
2555
2722
  ChatTool.displayName = "Chat.Tool";
2556
- var ChatToolHeader = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("summary", {
2723
+ var ChatToolHeader = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("summary", {
2557
2724
  ...props,
2558
2725
  ref,
2559
2726
  className: cn(chatToolHeaderClass, className)
2560
2727
  }));
2561
2728
  ChatToolHeader.displayName = "Chat.ToolHeader";
2562
- var ChatToolStatus = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("span", {
2729
+ var ChatToolStatus = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("span", {
2563
2730
  ...props,
2564
2731
  ref,
2565
2732
  className: cn(chatToolStatusClass, className)
2566
2733
  }));
2567
2734
  ChatToolStatus.displayName = "Chat.ToolStatus";
2568
- var ChatToolCall = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2735
+ var ChatToolCall = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2569
2736
  ...props,
2570
2737
  ref,
2571
2738
  className: cn(chatToolCallClass, className)
2572
2739
  }));
2573
2740
  ChatToolCall.displayName = "Chat.ToolCall";
2574
- var ChatToolResult = forwardRef5(({ className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2741
+ var ChatToolResult = forwardRef7(({ className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2575
2742
  ...props,
2576
2743
  ref,
2577
2744
  className: cn(chatToolResultClass, className)
2578
2745
  }));
2579
2746
  ChatToolResult.displayName = "Chat.ToolResult";
2580
- var ChatTyping = forwardRef5(({
2747
+ var ChatTyping = forwardRef7(({
2581
2748
  className,
2582
2749
  role = "status",
2583
2750
  "aria-label": ariaLabel = "Assistant is typing",
2584
2751
  ...props
2585
- }, ref) => /* @__PURE__ */ jsx7("span", {
2752
+ }, ref) => /* @__PURE__ */ jsx9("span", {
2586
2753
  ...props,
2587
2754
  ref,
2588
2755
  role,
2589
2756
  "aria-label": ariaLabel,
2590
2757
  className: cn(chatTypingClass, className),
2591
- children: /* @__PURE__ */ jsx7("span", {
2758
+ children: /* @__PURE__ */ jsx9("span", {
2592
2759
  "aria-hidden": "true"
2593
2760
  })
2594
2761
  }));
2595
2762
  ChatTyping.displayName = "Chat.Typing";
2596
- var ChatRoot = forwardRef5(({ placement = "start", timeline, className, ...props }, ref) => /* @__PURE__ */ jsx7("div", {
2763
+ var ChatRoot = forwardRef7(({ placement = "start", timeline, className, ...props }, ref) => /* @__PURE__ */ jsx9("div", {
2597
2764
  ...props,
2598
2765
  ref,
2599
2766
  "data-chat-tl": timeline ?? props["data-chat-tl"],
@@ -2602,6 +2769,11 @@ var ChatRoot = forwardRef5(({ placement = "start", timeline, className, ...props
2602
2769
  ChatRoot.displayName = "Chat";
2603
2770
  var Chat = Object.assign(ChatRoot, {
2604
2771
  Composer: ChatComposer,
2772
+ ComposerContext: ChatComposerContext,
2773
+ ComposerContextItem: ChatComposerContextItem,
2774
+ ComposerContextEnd: ChatComposerContextEnd,
2775
+ ComposerConnection: ChatComposerConnection,
2776
+ Request: ChatRequest,
2605
2777
  Agent: ChatAgent,
2606
2778
  Content: ChatContent,
2607
2779
  Work: ChatWork,
@@ -2634,16 +2806,16 @@ var Chat = Object.assign(ChatRoot, {
2634
2806
  Typing: ChatTyping
2635
2807
  });
2636
2808
  // src/components/chat/ChatSessionComposer.tsx
2637
- import { forwardRef as forwardRef8 } from "react";
2809
+ import { forwardRef as forwardRef10 } from "react";
2638
2810
 
2639
2811
  // src/components/chat/composer/SemanticComposer.tsx
2640
2812
  import {
2641
- forwardRef as forwardRef7,
2642
- useId as useId7,
2813
+ forwardRef as forwardRef9,
2814
+ useId as useId8,
2643
2815
  useCallback as useCallback2,
2644
- useImperativeHandle as useImperativeHandle3,
2645
- useLayoutEffect as useLayoutEffect10,
2646
- useRef as useRef7,
2816
+ useImperativeHandle as useImperativeHandle4,
2817
+ useLayoutEffect as useLayoutEffect11,
2818
+ useRef as useRef8,
2647
2819
  useState as useState8,
2648
2820
  useSyncExternalStore as useSyncExternalStore5
2649
2821
  } from "react";
@@ -2651,14 +2823,14 @@ import {
2651
2823
  // src/components/chat/composer/useComposerAttachments.ts
2652
2824
  import {
2653
2825
  useEffect as useEffect2,
2654
- useLayoutEffect as useLayoutEffect5,
2826
+ useLayoutEffect as useLayoutEffect6,
2655
2827
  useState as useState4,
2656
2828
  useSyncExternalStore
2657
2829
  } from "react";
2658
2830
  function useComposerAttachments(options) {
2659
2831
  const [controller] = useState4(() => createComposerAttachmentController(options));
2660
2832
  const snapshot = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
2661
- useLayoutEffect5(() => {
2833
+ useLayoutEffect6(() => {
2662
2834
  controller.configure(options);
2663
2835
  });
2664
2836
  useEffect2(() => () => {
@@ -2668,7 +2840,7 @@ function useComposerAttachments(options) {
2668
2840
  }
2669
2841
 
2670
2842
  // src/components/chat/composer/useComposerProviders.ts
2671
- import { useLayoutEffect as useLayoutEffect6, useState as useState5, useSyncExternalStore as useSyncExternalStore2 } from "react";
2843
+ import { useLayoutEffect as useLayoutEffect7, useState as useState5, useSyncExternalStore as useSyncExternalStore2 } from "react";
2672
2844
 
2673
2845
  // src/components/chat/composer/providers.ts
2674
2846
  var nextController = 0;
@@ -3042,18 +3214,18 @@ class ComposerProviderController {
3042
3214
  function useComposerProviders(context) {
3043
3215
  const [controller] = useState5(() => new ComposerProviderController);
3044
3216
  const snapshot = useSyncExternalStore2(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
3045
- useLayoutEffect6(() => {
3217
+ useLayoutEffect7(() => {
3046
3218
  controller.activate();
3047
3219
  return () => controller.dispose();
3048
3220
  }, [controller]);
3049
- useLayoutEffect6(() => {
3221
+ useLayoutEffect7(() => {
3050
3222
  controller.update(context);
3051
3223
  });
3052
3224
  return { controller, snapshot };
3053
3225
  }
3054
3226
 
3055
3227
  // src/components/chat/composer/useComposerSession.ts
3056
- import { useId as useId4, useLayoutEffect as useLayoutEffect7, useState as useState6, useSyncExternalStore as useSyncExternalStore3 } from "react";
3228
+ import { useId as useId5, useLayoutEffect as useLayoutEffect8, useState as useState6, useSyncExternalStore as useSyncExternalStore3 } from "react";
3057
3229
 
3058
3230
  // src/components/chat/composer/session.ts
3059
3231
  function sameComposerScope(a, b) {
@@ -3246,6 +3418,16 @@ function snapshotComposerReceipt(input, submission) {
3246
3418
  throw new TypeError("Unsupported receipt fields");
3247
3419
  return value;
3248
3420
  }
3421
+ function createSubmissionId() {
3422
+ const webCrypto = globalThis.crypto;
3423
+ if (typeof webCrypto.randomUUID === "function")
3424
+ return webCrypto.randomUUID();
3425
+ const bytes = webCrypto.getRandomValues(new Uint8Array(16));
3426
+ bytes[6] = bytes[6] & 15 | 64;
3427
+ bytes[8] = bytes[8] & 63 | 128;
3428
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
3429
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
3430
+ }
3249
3431
  function createComposerSessionController(initial, identity) {
3250
3432
  let context = initial;
3251
3433
  let disposed = false;
@@ -3368,7 +3550,7 @@ function createComposerSessionController(initial, identity) {
3368
3550
  const action = composerActionEligibility(context, intent);
3369
3551
  if (disposed || state.submitting || !action.allowed)
3370
3552
  return;
3371
- const clientSubmissionId = identity.nextSubmissionId?.() ?? crypto.randomUUID();
3553
+ const clientSubmissionId = identity.nextSubmissionId?.() ?? createSubmissionId();
3372
3554
  const common = {
3373
3555
  protocolVersion: 1,
3374
3556
  clientSubmissionId,
@@ -3459,14 +3641,14 @@ function createComposerSessionController(initial, identity) {
3459
3641
 
3460
3642
  // src/components/chat/composer/useComposerSession.ts
3461
3643
  function useComposerSession(context) {
3462
- const instanceId = useId4();
3644
+ const instanceId = useId5();
3463
3645
  const [controller] = useState6(() => createComposerSessionController(context, { instanceId }));
3464
3646
  const snapshot = useSyncExternalStore3(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
3465
- useLayoutEffect7(() => {
3647
+ useLayoutEffect8(() => {
3466
3648
  controller.activate();
3467
3649
  return () => controller.dispose();
3468
3650
  }, [controller]);
3469
- useLayoutEffect7(() => {
3651
+ useLayoutEffect8(() => {
3470
3652
  controller.update(context);
3471
3653
  });
3472
3654
  return { controller, snapshot };
@@ -3474,25 +3656,25 @@ function useComposerSession(context) {
3474
3656
 
3475
3657
  // src/components/chat/composer/PlainSemanticEditor.tsx
3476
3658
  import {
3477
- forwardRef as forwardRef6,
3478
- useId as useId5,
3479
- useImperativeHandle as useImperativeHandle2,
3659
+ forwardRef as forwardRef8,
3660
+ useId as useId6,
3661
+ useImperativeHandle as useImperativeHandle3,
3480
3662
  useCallback,
3481
- useLayoutEffect as useLayoutEffect8,
3482
- useRef as useRef6
3663
+ useLayoutEffect as useLayoutEffect9,
3664
+ useRef as useRef7
3483
3665
  } from "react";
3484
- import { jsx as jsx8 } from "react/jsx-runtime";
3666
+ import { jsx as jsx10 } from "react/jsx-runtime";
3485
3667
  function isPlainComposerDocument(document2) {
3486
3668
  return !document2.command && document2.content.every((node) => node.type === "text");
3487
3669
  }
3488
- var PlainSemanticEditor = forwardRef6((props, ref) => {
3489
- const editor = useRef6(null);
3490
- const originId = useId5();
3491
- const latest = useRef6(props);
3492
- const revision = useRef6(props.value.revision);
3493
- const pendingCaret = useRef6(undefined);
3670
+ var PlainSemanticEditor = forwardRef8((props, ref) => {
3671
+ const editor = useRef7(null);
3672
+ const originId = useId6();
3673
+ const latest = useRef7(props);
3674
+ const revision = useRef7(props.value.revision);
3675
+ const pendingCaret = useRef7(undefined);
3494
3676
  const text = props.value.document.content.map((node) => node.type === "text" ? node.text : "").join("");
3495
- useLayoutEffect8(() => {
3677
+ useLayoutEffect9(() => {
3496
3678
  latest.current = props;
3497
3679
  revision.current = Math.max(revision.current, props.value.revision);
3498
3680
  const caret = pendingCaret.current;
@@ -3503,7 +3685,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3503
3685
  pendingCaret.current = undefined;
3504
3686
  }
3505
3687
  });
3506
- useLayoutEffect8(() => {
3688
+ useLayoutEffect9(() => {
3507
3689
  latest.current.onReady?.(true);
3508
3690
  return () => latest.current.onReady?.(false);
3509
3691
  }, []);
@@ -3543,7 +3725,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3543
3725
  }
3544
3726
  return latest.current.value.document.content.length ? null : { nodeIndex: 0, start: 0, end: 0 };
3545
3727
  }
3546
- useImperativeHandle2(ref, () => ({
3728
+ useImperativeHandle3(ref, () => ({
3547
3729
  focus: () => editor.current?.focus(),
3548
3730
  selection,
3549
3731
  insertText: (value) => {
@@ -3583,7 +3765,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3583
3765
  return true;
3584
3766
  }
3585
3767
  }), [change]);
3586
- return /* @__PURE__ */ jsx8(PlainEditor, {
3768
+ return /* @__PURE__ */ jsx10(PlainEditor, {
3587
3769
  ref: editor,
3588
3770
  value: text,
3589
3771
  disabled: !!props.disabled,
@@ -3621,7 +3803,7 @@ var PlainSemanticEditor = forwardRef6((props, ref) => {
3621
3803
  PlainSemanticEditor.displayName = "PlainSemanticEditor";
3622
3804
 
3623
3805
  // src/components/chat/composer/PreservedDraft.tsx
3624
- import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
3806
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
3625
3807
  function PreservedDraft({
3626
3808
  input,
3627
3809
  reason,
@@ -3635,27 +3817,27 @@ function PreservedDraft({
3635
3817
  } catch (cause) {
3636
3818
  exportError = cause instanceof Error ? cause.message : "Unsupported data";
3637
3819
  }
3638
- return /* @__PURE__ */ jsxs8("section", {
3820
+ return /* @__PURE__ */ jsxs10("section", {
3639
3821
  className: "chat-composer-status",
3640
3822
  "data-state": state,
3641
3823
  "aria-label": "Preserved draft",
3642
3824
  children: [
3643
- /* @__PURE__ */ jsxs8("p", {
3825
+ /* @__PURE__ */ jsxs10("p", {
3644
3826
  role: state === "error" ? "alert" : "status",
3645
3827
  children: [
3646
3828
  reason,
3647
3829
  " Your draft is preserved."
3648
3830
  ]
3649
3831
  }),
3650
- /* @__PURE__ */ jsx9("pre", {
3832
+ /* @__PURE__ */ jsx11("pre", {
3651
3833
  children: document2.status === "compatible" ? exportComposerText(document2.value) : json ?? "The application retains the original incompatible input."
3652
3834
  }),
3653
- json ? /* @__PURE__ */ jsx9("a", {
3835
+ json ? /* @__PURE__ */ jsx11("a", {
3654
3836
  download: "composer-draft.json",
3655
3837
  href: `data:application/json;charset=utf-8,${encodeURIComponent(json)}`,
3656
3838
  children: "Export preserved draft"
3657
3839
  }) : null,
3658
- exportError ? /* @__PURE__ */ jsxs8("p", {
3840
+ exportError ? /* @__PURE__ */ jsxs10("p", {
3659
3841
  children: [
3660
3842
  "JSON export unavailable: ",
3661
3843
  exportError,
@@ -3667,10 +3849,10 @@ function PreservedDraft({
3667
3849
  }
3668
3850
 
3669
3851
  // src/components/chat/composer/DraftLifecycle.tsx
3670
- import { useId as useId6 } from "react";
3852
+ import { useId as useId7 } from "react";
3671
3853
 
3672
3854
  // src/components/chat/composer/useComposerDraft.ts
3673
- import { useLayoutEffect as useLayoutEffect9, useState as useState7, useSyncExternalStore as useSyncExternalStore4 } from "react";
3855
+ import { useLayoutEffect as useLayoutEffect10, useState as useState7, useSyncExternalStore as useSyncExternalStore4 } from "react";
3674
3856
 
3675
3857
  // src/components/chat/composer/drafts.ts
3676
3858
  function error2(cause, code) {
@@ -4036,18 +4218,18 @@ function createComposerDraftController(context) {
4036
4218
  function useComposerDraft(context) {
4037
4219
  const [controller] = useState7(() => createComposerDraftController(context));
4038
4220
  const snapshot = useSyncExternalStore4(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
4039
- useLayoutEffect9(() => {
4221
+ useLayoutEffect10(() => {
4040
4222
  controller.activate();
4041
4223
  return () => controller.dispose();
4042
4224
  }, [controller]);
4043
- useLayoutEffect9(() => {
4225
+ useLayoutEffect10(() => {
4044
4226
  controller.update(context);
4045
4227
  });
4046
4228
  return { controller, snapshot };
4047
4229
  }
4048
4230
 
4049
4231
  // src/components/chat/composer/DraftLifecycle.tsx
4050
- import { jsx as jsx10, jsxs as jsxs9, Fragment as Fragment6 } from "react/jsx-runtime";
4232
+ import { jsx as jsx12, jsxs as jsxs11, Fragment as Fragment6 } from "react/jsx-runtime";
4051
4233
  function DraftLifecycle({
4052
4234
  adapter,
4053
4235
  scope,
@@ -4060,7 +4242,7 @@ function DraftLifecycle({
4060
4242
  compact = false,
4061
4243
  children
4062
4244
  }) {
4063
- const originId = `${useId6()}-draft`;
4245
+ const originId = `${useId7()}-draft`;
4064
4246
  function restore(draft) {
4065
4247
  attachments.restore(draft.attachments);
4066
4248
  onDocumentChange({
@@ -4083,24 +4265,24 @@ function DraftLifecycle({
4083
4265
  });
4084
4266
  const blocked = disabled || snapshot.saving || snapshot.status === "idle" || snapshot.status === "loading" || snapshot.restorePending || snapshot.status === "incompatible" && !snapshot.overwriteAllowed || snapshot.status === "error" && snapshot.errorOperation !== "save";
4085
4267
  const status = snapshot.status === "loading" ? "Loading stored draft…" : snapshot.saving ? "Saving draft…" : snapshot.lastSavedRevision === value.revision ? "Draft saved by host storage." : snapshot.loaded?.applied ? "Stored draft restored." : "Draft storage is provided by the host.";
4086
- const feedback = /* @__PURE__ */ jsxs9(Fragment6, {
4268
+ const feedback = /* @__PURE__ */ jsxs11(Fragment6, {
4087
4269
  children: [
4088
- /* @__PURE__ */ jsx10("div", {
4270
+ /* @__PURE__ */ jsx12("div", {
4089
4271
  role: "status",
4090
4272
  className: compact ? "sr-only" : undefined,
4091
4273
  children: status
4092
4274
  }),
4093
- snapshot.error ? /* @__PURE__ */ jsx10("p", {
4275
+ snapshot.error ? /* @__PURE__ */ jsx12("p", {
4094
4276
  role: "alert",
4095
4277
  children: snapshot.error.message
4096
4278
  }) : null,
4097
- snapshot.incompatible ? /* @__PURE__ */ jsxs9(Fragment6, {
4279
+ snapshot.incompatible ? /* @__PURE__ */ jsxs11(Fragment6, {
4098
4280
  children: [
4099
- /* @__PURE__ */ jsx10(PreservedDraft, {
4281
+ /* @__PURE__ */ jsx12(PreservedDraft, {
4100
4282
  input: snapshot.incompatible.input,
4101
4283
  reason: snapshot.incompatible.reason
4102
4284
  }),
4103
- !snapshot.overwriteAllowed ? /* @__PURE__ */ jsx10("button", {
4285
+ !snapshot.overwriteAllowed ? /* @__PURE__ */ jsx12("button", {
4104
4286
  type: "button",
4105
4287
  disabled,
4106
4288
  onClick: () => {
@@ -4111,14 +4293,14 @@ function DraftLifecycle({
4111
4293
  }) : null
4112
4294
  ]
4113
4295
  }) : null,
4114
- snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs9(Fragment6, {
4296
+ snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs11(Fragment6, {
4115
4297
  children: [
4116
- /* @__PURE__ */ jsx10(PreservedDraft, {
4298
+ /* @__PURE__ */ jsx12(PreservedDraft, {
4117
4299
  input: snapshot.loaded.draft,
4118
4300
  reason: "A stored draft arrived after editing. Your current draft is preserved.",
4119
4301
  state: "pending"
4120
4302
  }),
4121
- /* @__PURE__ */ jsx10("button", {
4303
+ /* @__PURE__ */ jsx12("button", {
4122
4304
  type: "button",
4123
4305
  disabled,
4124
4306
  onClick: () => {
@@ -4131,9 +4313,9 @@ function DraftLifecycle({
4131
4313
  }) : null
4132
4314
  ]
4133
4315
  });
4134
- const actions = compact ? /* @__PURE__ */ jsxs9(Fragment6, {
4316
+ const actions = compact ? /* @__PURE__ */ jsxs11(Fragment6, {
4135
4317
  children: [
4136
- /* @__PURE__ */ jsxs9("button", {
4318
+ /* @__PURE__ */ jsxs11("button", {
4137
4319
  type: "button",
4138
4320
  className: "popover-menu-item",
4139
4321
  title: status,
@@ -4143,7 +4325,7 @@ function DraftLifecycle({
4143
4325
  event.currentTarget.closest("[popover]")?.hidePopover?.();
4144
4326
  },
4145
4327
  children: [
4146
- /* @__PURE__ */ jsx10("svg", {
4328
+ /* @__PURE__ */ jsx12("svg", {
4147
4329
  width: "18",
4148
4330
  height: "18",
4149
4331
  viewBox: "0 0 24 24",
@@ -4154,16 +4336,16 @@ function DraftLifecycle({
4154
4336
  strokeLinejoin: "round",
4155
4337
  "aria-hidden": "true",
4156
4338
  focusable: "false",
4157
- children: /* @__PURE__ */ jsx10("path", {
4339
+ children: /* @__PURE__ */ jsx12("path", {
4158
4340
  d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12l4 4v12a2 2 0 0 1-2 2ZM7 3v6h10V3M7 21v-8h10v8"
4159
4341
  })
4160
4342
  }),
4161
- /* @__PURE__ */ jsx10("span", {
4343
+ /* @__PURE__ */ jsx12("span", {
4162
4344
  children: "Save draft"
4163
4345
  })
4164
4346
  ]
4165
4347
  }),
4166
- /* @__PURE__ */ jsxs9("button", {
4348
+ /* @__PURE__ */ jsxs11("button", {
4167
4349
  type: "button",
4168
4350
  className: "popover-menu-item",
4169
4351
  title: "Reload stored draft",
@@ -4173,7 +4355,7 @@ function DraftLifecycle({
4173
4355
  event.currentTarget.closest("[popover]")?.hidePopover?.();
4174
4356
  },
4175
4357
  children: [
4176
- /* @__PURE__ */ jsx10("svg", {
4358
+ /* @__PURE__ */ jsx12("svg", {
4177
4359
  width: "18",
4178
4360
  height: "18",
4179
4361
  viewBox: "0 0 24 24",
@@ -4184,25 +4366,25 @@ function DraftLifecycle({
4184
4366
  strokeLinejoin: "round",
4185
4367
  "aria-hidden": "true",
4186
4368
  focusable: "false",
4187
- children: /* @__PURE__ */ jsx10("path", {
4369
+ children: /* @__PURE__ */ jsx12("path", {
4188
4370
  d: "M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7"
4189
4371
  })
4190
4372
  }),
4191
- /* @__PURE__ */ jsx10("span", {
4373
+ /* @__PURE__ */ jsx12("span", {
4192
4374
  children: "Reload stored draft"
4193
4375
  })
4194
4376
  ]
4195
4377
  })
4196
4378
  ]
4197
- }) : /* @__PURE__ */ jsxs9(Fragment6, {
4379
+ }) : /* @__PURE__ */ jsxs11(Fragment6, {
4198
4380
  children: [
4199
- /* @__PURE__ */ jsx10("button", {
4381
+ /* @__PURE__ */ jsx12("button", {
4200
4382
  type: "button",
4201
4383
  disabled: blocked,
4202
4384
  onClick: () => void controller.save(),
4203
4385
  children: "Save draft"
4204
4386
  }),
4205
- /* @__PURE__ */ jsx10("button", {
4387
+ /* @__PURE__ */ jsx12("button", {
4206
4388
  type: "button",
4207
4389
  disabled: disabled || snapshot.status === "loading" || snapshot.saving,
4208
4390
  onClick: () => void controller.reload(),
@@ -4210,7 +4392,7 @@ function DraftLifecycle({
4210
4392
  })
4211
4393
  ]
4212
4394
  });
4213
- return compact ? children(feedback, actions) : children(/* @__PURE__ */ jsxs9("div", {
4395
+ return compact ? children(feedback, actions) : children(/* @__PURE__ */ jsxs11("div", {
4214
4396
  className: "chat-composer-status",
4215
4397
  "aria-label": "Draft storage",
4216
4398
  children: [
@@ -4221,8 +4403,8 @@ function DraftLifecycle({
4221
4403
  }
4222
4404
 
4223
4405
  // src/components/chat/composer/SemanticComposer.tsx
4224
- import { jsx as jsx11, jsxs as jsxs10, Fragment as Fragment7 } from "react/jsx-runtime";
4225
- var SemanticComposer = forwardRef7(({
4406
+ import { jsx as jsx13, jsxs as jsxs12, Fragment as Fragment7 } from "react/jsx-runtime";
4407
+ var SemanticComposer = forwardRef9(({
4226
4408
  Editor,
4227
4409
  structured,
4228
4410
  value,
@@ -4243,6 +4425,7 @@ var SemanticComposer = forwardRef7(({
4243
4425
  allowAttachmentOnly = false,
4244
4426
  compact = false,
4245
4427
  addMenu,
4428
+ context: composerContext,
4246
4429
  onStop,
4247
4430
  label = "Message",
4248
4431
  attachLabel = "Attach files",
@@ -4260,24 +4443,24 @@ var SemanticComposer = forwardRef7(({
4260
4443
  onKeyDownCapture,
4261
4444
  ...rootProps
4262
4445
  }, forwardedRef) => {
4263
- const id = useId7();
4264
- const editor = useRef7(null);
4265
- const picker = useRef7(null);
4446
+ const id = useId8();
4447
+ const editor = useRef8(null);
4448
+ const picker = useRef8(null);
4266
4449
  const [readiness, setReadiness] = useState8({ generation: 0, ready: false });
4267
4450
  const [editorFailure, setEditorFailure] = useState8();
4268
4451
  const [localFailure, setLocalFailure] = useState8();
4269
4452
  const [selection, setSelection] = useState8(null);
4270
- const observed = useRef7({ scope: { ...scope }, draftKey, generation: 0 });
4453
+ const observed = useRef8({ scope: { ...scope }, draftKey, generation: 0 });
4271
4454
  const changedScope = !sameComposerScope(observed.current.scope, scope) || observed.current.draftKey !== draftKey;
4272
4455
  const generation = observed.current.generation + (changedScope ? 1 : 0);
4273
- const alive = useRef7(false);
4274
- useLayoutEffect10(() => {
4456
+ const alive = useRef8(false);
4457
+ useLayoutEffect11(() => {
4275
4458
  alive.current = true;
4276
4459
  return () => {
4277
4460
  alive.current = false;
4278
4461
  };
4279
4462
  }, []);
4280
- useLayoutEffect10(() => {
4463
+ useLayoutEffect11(() => {
4281
4464
  if (changedScope)
4282
4465
  observed.current = { scope: { ...scope }, draftKey, generation };
4283
4466
  }, [
@@ -4378,7 +4561,7 @@ var SemanticComposer = forwardRef7(({
4378
4561
  const showCompletion = popup && candidates.length > 0;
4379
4562
  const visibleError = error ?? localError ?? session.snapshot.error?.message;
4380
4563
  const hasError = visibleError !== undefined && visibleError !== null && visibleError !== false;
4381
- useImperativeHandle3(forwardedRef, () => ({
4564
+ useImperativeHandle4(forwardedRef, () => ({
4382
4565
  focus: () => editor.current?.focus(),
4383
4566
  selection: () => editor.current?.selection() ?? null,
4384
4567
  insertReference: (node) => {
@@ -4435,12 +4618,13 @@ var SemanticComposer = forwardRef7(({
4435
4618
  editor.current?.focus();
4436
4619
  }
4437
4620
  const compactImages = compact && attachmentsCurrent && attachments.entries.length > 0 && attachments.entries.every((entry) => entry.state.status === "ready" && entry.metadata.mediaType.startsWith("image/") && !!attachments.controller.previewUrl(entry.entryId));
4438
- return /* @__PURE__ */ jsx11(ComposerShell, {
4621
+ return /* @__PURE__ */ jsx13(ComposerShell, {
4439
4622
  ...rootProps,
4440
4623
  className,
4441
4624
  composerId: id,
4442
4625
  compact,
4443
4626
  addMenu,
4627
+ context: composerContext,
4444
4628
  entries: (attachmentsCurrent ? attachments.entries : []).map((entry) => ({
4445
4629
  id: entry.entryId,
4446
4630
  name: entry.metadata.name,
@@ -4497,34 +4681,34 @@ var SemanticComposer = forwardRef7(({
4497
4681
  showCompletion,
4498
4682
  selectCompletion: selectCandidate,
4499
4683
  dismissCompletion: () => completion.controller.dismiss(),
4500
- completionHeader: completion.snapshot.breadcrumbs.length ? /* @__PURE__ */ jsxs10("nav", {
4684
+ completionHeader: completion.snapshot.breadcrumbs.length ? /* @__PURE__ */ jsxs12("nav", {
4501
4685
  "aria-label": "Suggestion folders",
4502
4686
  className: "chat-composer-breadcrumb",
4503
4687
  children: [
4504
- /* @__PURE__ */ jsx11("button", {
4688
+ /* @__PURE__ */ jsx13("button", {
4505
4689
  type: "button",
4506
4690
  onMouseDown: (event) => event.preventDefault(),
4507
4691
  onClick: () => completion.controller.back(0),
4508
4692
  children: "All results"
4509
4693
  }),
4510
- completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsx11("button", {
4694
+ completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsx13("button", {
4511
4695
  type: "button",
4512
4696
  onMouseDown: (event) => event.preventDefault(),
4513
4697
  onClick: () => completion.controller.back(index + 1),
4514
4698
  children: crumb.label
4515
4699
  }, crumb.refId)),
4516
- /* @__PURE__ */ jsx11("span", {
4700
+ /* @__PURE__ */ jsx13("span", {
4517
4701
  className: "chat-composer-hint",
4518
4702
  children: "Alt+Left returns to the parent folder."
4519
4703
  })
4520
4704
  ]
4521
4705
  }) : null,
4522
- completionStatus: popup && completion.snapshot.status !== "ready" ? /* @__PURE__ */ jsxs10("div", {
4706
+ completionStatus: popup && completion.snapshot.status !== "ready" ? /* @__PURE__ */ jsxs12("div", {
4523
4707
  role: "status",
4524
4708
  className: "chat-composer-status",
4525
4709
  children: [
4526
4710
  completion.snapshot.status === "loading" ? "Loading suggestions…" : completion.snapshot.status === "empty" ? "No suggestions" : completion.snapshot.error?.message ?? "Some suggestions could not be loaded",
4527
- completion.snapshot.status === "error" ? /* @__PURE__ */ jsx11("button", {
4711
+ completion.snapshot.status === "error" ? /* @__PURE__ */ jsx13("button", {
4528
4712
  type: "button",
4529
4713
  onClick: () => completion.controller.retry(),
4530
4714
  children: "Retry suggestions"
@@ -4533,78 +4717,78 @@ var SemanticComposer = forwardRef7(({
4533
4717
  }) : null,
4534
4718
  visibleError,
4535
4719
  hasError,
4536
- statusContent: /* @__PURE__ */ jsxs10(Fragment7, {
4720
+ statusContent: /* @__PURE__ */ jsxs12(Fragment7, {
4537
4721
  children: [
4538
- attachmentsCurrent && attachments.rejections.length ? /* @__PURE__ */ jsxs10("div", {
4722
+ attachmentsCurrent && attachments.rejections.length ? /* @__PURE__ */ jsxs12("div", {
4539
4723
  role: "alert",
4540
4724
  className: "chat-composer-status",
4541
4725
  "data-state": "error",
4542
4726
  children: [
4543
- attachments.rejections.map((item, index) => /* @__PURE__ */ jsxs10("p", {
4727
+ attachments.rejections.map((item, index) => /* @__PURE__ */ jsxs12("p", {
4544
4728
  children: [
4545
4729
  item.metadata.name,
4546
4730
  ": ",
4547
4731
  item.error.message
4548
4732
  ]
4549
4733
  }, `${index}-${item.metadata.name}`)),
4550
- /* @__PURE__ */ jsx11("button", {
4734
+ /* @__PURE__ */ jsx13("button", {
4551
4735
  type: "button",
4552
4736
  onClick: () => attachments.controller.clearRejections(),
4553
4737
  children: "Dismiss attachment errors"
4554
4738
  })
4555
4739
  ]
4556
4740
  }) : null,
4557
- recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => compact && attempt.status === "pending" ? /* @__PURE__ */ jsx11("p", {
4741
+ recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => compact && attempt.status === "pending" ? /* @__PURE__ */ jsx13("p", {
4558
4742
  role: "status",
4559
4743
  className: "sr-only",
4560
4744
  "data-state": "pending",
4561
4745
  children: "Awaiting admission"
4562
- }, attempt.snapshot.clientSubmissionId) : /* @__PURE__ */ jsxs10("details", {
4746
+ }, attempt.snapshot.clientSubmissionId) : /* @__PURE__ */ jsxs12("details", {
4563
4747
  className: "chat-composer-status",
4564
4748
  "data-state": attempt.status,
4565
4749
  children: [
4566
- /* @__PURE__ */ jsx11("summary", {
4750
+ /* @__PURE__ */ jsx13("summary", {
4567
4751
  children: attempt.status === "unknown" ? "Submission outcome unknown — draft retained" : "Awaiting admission"
4568
4752
  }),
4569
- /* @__PURE__ */ jsx11("p", {
4753
+ /* @__PURE__ */ jsx13("p", {
4570
4754
  children: attempt.snapshot.clientSubmissionId
4571
4755
  }),
4572
- attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */ jsx11("p", {
4756
+ attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */ jsx13("p", {
4573
4757
  children: attempt.receipt.error.message
4574
4758
  }) : null,
4575
- host.reconcile ? /* @__PURE__ */ jsx11("button", {
4759
+ host.reconcile ? /* @__PURE__ */ jsx13("button", {
4576
4760
  type: "button",
4577
4761
  onClick: () => {
4578
4762
  session.controller.reconcile(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
4579
4763
  },
4580
4764
  children: "Check submission status"
4581
4765
  }) : null,
4582
- attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */ jsx11("button", {
4766
+ attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */ jsx13("button", {
4583
4767
  type: "button",
4584
4768
  onClick: () => {
4585
4769
  session.controller.retry(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
4586
4770
  },
4587
4771
  children: "Request authorized retry"
4588
4772
  }) : null,
4589
- /* @__PURE__ */ jsx11(PreservedDraft, {
4773
+ /* @__PURE__ */ jsx13(PreservedDraft, {
4590
4774
  input: attempt.snapshot.document,
4591
4775
  reason: "Submitted snapshot",
4592
4776
  state: attempt.status === "unknown" ? "unknown" : "pending"
4593
4777
  })
4594
4778
  ]
4595
4779
  }, attempt.snapshot.clientSubmissionId)),
4596
- session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */ jsx11(PreservedDraft, {
4780
+ session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */ jsx13(PreservedDraft, {
4597
4781
  input: attempt,
4598
4782
  reason: "The host could not retain this submission. Export its recovery record before leaving."
4599
4783
  }, attempt.snapshot.clientSubmissionId)),
4600
- session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */ jsx11("div", {
4784
+ session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */ jsx13("div", {
4601
4785
  role: "status",
4602
4786
  className: compact ? "sr-only" : "chat-composer-status",
4603
4787
  children: session.snapshot.lastReceipt.operation === "command" ? "Command completed" : `Admitted: ${session.snapshot.lastReceipt.delivery} (${session.snapshot.lastReceipt.persistence})`
4604
4788
  }) : null
4605
4789
  ]
4606
4790
  }),
4607
- renderFooter: (renderToolbar) => draftAdapter && attachmentsCurrent && read.status === "compatible" ? /* @__PURE__ */ jsx11(DraftLifecycle, {
4791
+ renderFooter: (renderToolbar) => draftAdapter && attachmentsCurrent && read.status === "compatible" ? /* @__PURE__ */ jsx13(DraftLifecycle, {
4608
4792
  compact,
4609
4793
  adapter: draftAdapter,
4610
4794
  scope,
@@ -4614,7 +4798,7 @@ var SemanticComposer = forwardRef7(({
4614
4798
  attachments: attachments.controller,
4615
4799
  onDocumentChange,
4616
4800
  disabled: disabled || runtime.status === "read_only",
4617
- children: (feedback, actions) => /* @__PURE__ */ jsxs10(Fragment7, {
4801
+ children: (feedback, actions) => /* @__PURE__ */ jsxs12(Fragment7, {
4618
4802
  children: [
4619
4803
  feedback,
4620
4804
  renderToolbar(actions)
@@ -4630,7 +4814,7 @@ var SemanticComposer = forwardRef7(({
4630
4814
  },
4631
4815
  submit,
4632
4816
  onStop,
4633
- editor: editAvailable ? /* @__PURE__ */ jsx11(Editor, {
4817
+ editor: editAvailable ? /* @__PURE__ */ jsx13(Editor, {
4634
4818
  ref: editor,
4635
4819
  value,
4636
4820
  instanceGeneration: generation,
@@ -4683,7 +4867,7 @@ var SemanticComposer = forwardRef7(({
4683
4867
  submit();
4684
4868
  }
4685
4869
  }
4686
- }, generation) : /* @__PURE__ */ jsx11(PreservedDraft, {
4870
+ }, generation) : /* @__PURE__ */ jsx13(PreservedDraft, {
4687
4871
  input: value.document,
4688
4872
  reason: editorError?.message ?? (read.status === "incompatible" ? read.reason : "This draft requires the optional rich editor.")
4689
4873
  }),
@@ -4693,8 +4877,8 @@ var SemanticComposer = forwardRef7(({
4693
4877
  SemanticComposer.displayName = "SemanticComposer";
4694
4878
 
4695
4879
  // src/components/chat/ChatSessionComposer.tsx
4696
- import { jsx as jsx12 } from "react/jsx-runtime";
4697
- var ChatSessionComposer = forwardRef8((props, ref) => /* @__PURE__ */ jsx12(SemanticComposer, {
4880
+ import { jsx as jsx14 } from "react/jsx-runtime";
4881
+ var ChatSessionComposer = forwardRef10((props, ref) => /* @__PURE__ */ jsx14(SemanticComposer, {
4698
4882
  ...props,
4699
4883
  ref,
4700
4884
  Editor: PlainSemanticEditor,
@@ -4702,8 +4886,8 @@ var ChatSessionComposer = forwardRef8((props, ref) => /* @__PURE__ */ jsx12(Sema
4702
4886
  }));
4703
4887
  ChatSessionComposer.displayName = "ChatSessionComposer";
4704
4888
  // src/components/chat/ChatAuthoritativeQueue.tsx
4705
- import { useId as useId8, useLayoutEffect as useLayoutEffect11, useRef as useRef8, useState as useState9 } from "react";
4706
- import { jsx as jsx13, jsxs as jsxs11, Fragment as Fragment8 } from "react/jsx-runtime";
4889
+ import { useId as useId9, useLayoutEffect as useLayoutEffect12, useRef as useRef9, useState as useState9 } from "react";
4890
+ import { jsx as jsx15, jsxs as jsxs13, Fragment as Fragment8 } from "react/jsx-runtime";
4707
4891
  function scopeKey(projection) {
4708
4892
  return JSON.stringify([
4709
4893
  projection.scope.contextKey,
@@ -4720,7 +4904,7 @@ function QueueActionIcon({
4720
4904
  save: "m5 12 4 4L19 6",
4721
4905
  cancel: "m6 6 12 12M6 18 18 6"
4722
4906
  };
4723
- return /* @__PURE__ */ jsx13("svg", {
4907
+ return /* @__PURE__ */ jsx15("svg", {
4724
4908
  width: "16",
4725
4909
  height: "16",
4726
4910
  viewBox: "0 0 24 24",
@@ -4731,7 +4915,7 @@ function QueueActionIcon({
4731
4915
  strokeLinejoin: "round",
4732
4916
  "aria-hidden": "true",
4733
4917
  focusable: "false",
4734
- children: /* @__PURE__ */ jsx13("path", {
4918
+ children: /* @__PURE__ */ jsx15("path", {
4735
4919
  d: paths[action]
4736
4920
  })
4737
4921
  });
@@ -4746,29 +4930,29 @@ function DocumentEditorSlot({
4746
4930
  renderEditor,
4747
4931
  ...editor
4748
4932
  }) {
4749
- return /* @__PURE__ */ jsx13(Fragment8, {
4933
+ return /* @__PURE__ */ jsx15(Fragment8, {
4750
4934
  children: renderEditor(editor)
4751
4935
  });
4752
4936
  }
4753
4937
  function ChatAuthoritativeQueue(props) {
4754
- return /* @__PURE__ */ jsx13(QueueSession, {
4938
+ return /* @__PURE__ */ jsx15(QueueSession, {
4755
4939
  ...props
4756
4940
  }, scopeKey(props.projection));
4757
4941
  }
4758
4942
  function QueueSession(props) {
4759
- const latest = useRef8(props);
4760
- const watermark = useRef8(props.projection.revision);
4761
- useLayoutEffect11(() => {
4943
+ const latest = useRef9(props);
4944
+ const watermark = useRef9(props.projection.revision);
4945
+ useLayoutEffect12(() => {
4762
4946
  latest.current = props;
4763
4947
  watermark.current = Math.max(watermark.current, props.projection.revision);
4764
4948
  });
4765
- const requests = useRef8(new Map);
4766
- const counter = useRef8(0);
4767
- const instanceId = useId8();
4949
+ const requests = useRef9(new Map);
4950
+ const counter = useRef9(0);
4951
+ const instanceId = useId9();
4768
4952
  const [pending, setPending] = useState9([]);
4769
4953
  const [message, setMessage] = useState9();
4770
4954
  const [edit, setEdit] = useState9();
4771
- useLayoutEffect11(() => {
4955
+ useLayoutEffect12(() => {
4772
4956
  const active = requests.current;
4773
4957
  return () => {
4774
4958
  for (const controller of active.values())
@@ -4837,10 +5021,10 @@ function QueueSession(props) {
4837
5021
  }
4838
5022
  const noop = () => {};
4839
5023
  const editAllowed = Boolean(edit && props.projection.items.some((item) => item.id === edit.item.id && canEdit(item, props) && (!edit.text || safeText(item))));
4840
- return /* @__PURE__ */ jsxs11("div", {
5024
+ return /* @__PURE__ */ jsxs13("div", {
4841
5025
  className: props.className,
4842
5026
  children: [
4843
- /* @__PURE__ */ jsx13(ChatQueue, {
5027
+ /* @__PURE__ */ jsx15(ChatQueue, {
4844
5028
  label: props.label,
4845
5029
  items: props.projection.items.map((item) => ({
4846
5030
  id: item.id,
@@ -4852,9 +5036,9 @@ function QueueSession(props) {
4852
5036
  renderItemActions: (row, index, busy) => {
4853
5037
  const item = props.projection.items[index];
4854
5038
  const editable = canEdit(item, props);
4855
- return /* @__PURE__ */ jsxs11(Fragment8, {
5039
+ return /* @__PURE__ */ jsxs13(Fragment8, {
4856
5040
  children: [
4857
- editable ? /* @__PURE__ */ jsx13("button", {
5041
+ editable ? /* @__PURE__ */ jsx15("button", {
4858
5042
  type: "button",
4859
5043
  className: "btn btn-ghost btn-sm btn-square",
4860
5044
  disabled: busy,
@@ -4866,11 +5050,11 @@ function QueueSession(props) {
4866
5050
  document: snapshotComposerDocument(item.document),
4867
5051
  text: safeText(item)
4868
5052
  }),
4869
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5053
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4870
5054
  action: "edit"
4871
5055
  })
4872
5056
  }) : null,
4873
- props.capabilities.promote && item.capabilities.promote ? /* @__PURE__ */ jsx13("button", {
5057
+ props.capabilities.promote && item.capabilities.promote ? /* @__PURE__ */ jsx15("button", {
4874
5058
  type: "button",
4875
5059
  className: "btn btn-ghost btn-sm btn-square chat-queue-steer",
4876
5060
  disabled: busy || !props.targetTurnId,
@@ -4883,18 +5067,18 @@ function QueueSession(props) {
4883
5067
  targetTurnId: props.targetTurnId
4884
5068
  }, row.id);
4885
5069
  },
4886
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5070
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4887
5071
  action: "steer"
4888
5072
  })
4889
5073
  }) : null,
4890
- props.capabilities.remove && item.capabilities.remove ? /* @__PURE__ */ jsx13("button", {
5074
+ props.capabilities.remove && item.capabilities.remove ? /* @__PURE__ */ jsx15("button", {
4891
5075
  type: "button",
4892
5076
  className: "btn btn-ghost btn-sm btn-square chat-queue-remove",
4893
5077
  disabled: busy,
4894
5078
  "aria-label": `Remove waiting message ${index + 1}`,
4895
5079
  title: `Remove waiting message ${index + 1}`,
4896
5080
  onClick: () => void mutate({ operation: "remove" }, row.id),
4897
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5081
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4898
5082
  action: "remove"
4899
5083
  })
4900
5084
  }) : null
@@ -4902,13 +5086,13 @@ function QueueSession(props) {
4902
5086
  });
4903
5087
  }
4904
5088
  }),
4905
- edit ? /* @__PURE__ */ jsx13("div", {
5089
+ edit ? /* @__PURE__ */ jsx15("div", {
4906
5090
  className: "chat-composer",
4907
5091
  role: "group",
4908
5092
  "aria-label": "Edit queued message",
4909
- children: edit.text ? /* @__PURE__ */ jsxs11(Fragment8, {
5093
+ children: edit.text ? /* @__PURE__ */ jsxs13(Fragment8, {
4910
5094
  children: [
4911
- /* @__PURE__ */ jsx13("textarea", {
5095
+ /* @__PURE__ */ jsx15("textarea", {
4912
5096
  className: "chat-composer-input",
4913
5097
  "aria-label": "Queued message",
4914
5098
  value: exportComposerText(edit.document),
@@ -4923,35 +5107,35 @@ function QueueSession(props) {
4923
5107
  }
4924
5108
  })
4925
5109
  }),
4926
- /* @__PURE__ */ jsxs11("div", {
5110
+ /* @__PURE__ */ jsxs13("div", {
4927
5111
  className: "chat-composer-actions",
4928
5112
  children: [
4929
- /* @__PURE__ */ jsx13("button", {
5113
+ /* @__PURE__ */ jsx15("button", {
4930
5114
  className: "btn btn-sm btn-square",
4931
5115
  type: "button",
4932
5116
  "aria-label": "Save queued message",
4933
5117
  title: "Save queued message",
4934
5118
  disabled: pending.includes(edit.item.id) || !editAllowed,
4935
5119
  onClick: () => void mutate({ operation: "edit", document: edit.document }, edit.item.id, edit.revision),
4936
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5120
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4937
5121
  action: "save"
4938
5122
  })
4939
5123
  }),
4940
- /* @__PURE__ */ jsx13("button", {
5124
+ /* @__PURE__ */ jsx15("button", {
4941
5125
  className: "btn btn-ghost btn-sm btn-square",
4942
5126
  type: "button",
4943
5127
  "aria-label": "Cancel",
4944
5128
  title: "Cancel",
4945
5129
  disabled: pending.includes(edit.item.id),
4946
5130
  onClick: () => setEdit(undefined),
4947
- children: /* @__PURE__ */ jsx13(QueueActionIcon, {
5131
+ children: /* @__PURE__ */ jsx15(QueueActionIcon, {
4948
5132
  action: "cancel"
4949
5133
  })
4950
5134
  })
4951
5135
  ]
4952
5136
  })
4953
5137
  ]
4954
- }) : props.renderDocumentEditor && editAllowed ? /* @__PURE__ */ jsx13(DocumentEditorSlot, {
5138
+ }) : props.renderDocumentEditor && editAllowed ? /* @__PURE__ */ jsx15(DocumentEditorSlot, {
4955
5139
  renderEditor: props.renderDocumentEditor,
4956
5140
  item: edit.item,
4957
5141
  value: edit.document,
@@ -4962,14 +5146,14 @@ function QueueSession(props) {
4962
5146
  onSave: () => void mutate({ operation: "edit", document: edit.document }, edit.item.id, edit.revision),
4963
5147
  onCancel: () => setEdit(undefined),
4964
5148
  pending: pending.includes(edit.item.id)
4965
- }) : /* @__PURE__ */ jsxs11(Fragment8, {
5149
+ }) : /* @__PURE__ */ jsxs13(Fragment8, {
4966
5150
  children: [
4967
- /* @__PURE__ */ jsx13(PreservedDraft, {
5151
+ /* @__PURE__ */ jsx15(PreservedDraft, {
4968
5152
  input: edit.document,
4969
5153
  reason: "This queued message is no longer editable. Your replacement draft is preserved.",
4970
5154
  state: "pending"
4971
5155
  }),
4972
- /* @__PURE__ */ jsx13("button", {
5156
+ /* @__PURE__ */ jsx15("button", {
4973
5157
  type: "button",
4974
5158
  onClick: () => setEdit(undefined),
4975
5159
  children: "Discard queued edit"
@@ -4977,7 +5161,7 @@ function QueueSession(props) {
4977
5161
  ]
4978
5162
  })
4979
5163
  }) : null,
4980
- message ? /* @__PURE__ */ jsx13("p", {
5164
+ message ? /* @__PURE__ */ jsx15("p", {
4981
5165
  className: message.error ? "chat-composer-error" : "chat-composer-status",
4982
5166
  role: message.error ? "alert" : "status",
4983
5167
  children: message.text
@@ -4986,17 +5170,297 @@ function QueueSession(props) {
4986
5170
  });
4987
5171
  }
4988
5172
  // src/components/chat/ComposerSettings.tsx
4989
- import { useId as useId10, useLayoutEffect as useLayoutEffect12, useRef as useRef10, useState as useState11 } from "react";
5173
+ import { useId as useId12, useLayoutEffect as useLayoutEffect13, useRef as useRef12, useState as useState12 } from "react";
5174
+
5175
+ // src/components/chat/ComposerSettingsMenus.tsx
5176
+ import React15, { useId as useId10, useRef as useRef10, useState as useState10 } from "react";
5177
+ import { jsx as jsx16, jsxs as jsxs14, Fragment as Fragment9 } from "react/jsx-runtime";
5178
+ function ComposerSettingsMenus(props) {
5179
+ const groups = props.groups ?? props.settings.map((setting) => ({
5180
+ id: setting.id,
5181
+ label: setting.label,
5182
+ settingIds: [setting.id]
5183
+ }));
5184
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5185
+ children: [
5186
+ groups.map((group) => /* @__PURE__ */ jsx16(SettingsMenu, {
5187
+ ...props,
5188
+ group
5189
+ }, group.id)),
5190
+ /* @__PURE__ */ jsx16("span", {
5191
+ className: "sr-only",
5192
+ role: "status",
5193
+ children: props.busy ? "Change pending" : Object.values(props.feedback).filter(Boolean).join(". ")
5194
+ })
5195
+ ]
5196
+ });
5197
+ }
5198
+ function OrderedSetting({
5199
+ setting,
5200
+ disabled,
5201
+ choose
5202
+ }) {
5203
+ const current = Math.max(0, setting.choices.findIndex((choice) => choice.value === setting.value));
5204
+ const [draft, setDraft] = useState10();
5205
+ const value = draft ?? current;
5206
+ const commit = () => {
5207
+ if (draft !== undefined)
5208
+ choose(setting.choices[draft].value);
5209
+ setDraft(undefined);
5210
+ };
5211
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5212
+ children: [
5213
+ /* @__PURE__ */ jsxs14("div", {
5214
+ className: "chat-composer-menu-row",
5215
+ children: [
5216
+ /* @__PURE__ */ jsx16("strong", {
5217
+ children: setting.choices[value]?.label
5218
+ }),
5219
+ setting.defaultValue !== undefined ? /* @__PURE__ */ jsx16("button", {
5220
+ type: "button",
5221
+ className: "btn btn-ghost btn-xs",
5222
+ "aria-label": `Reset ${setting.label.toLowerCase()}`,
5223
+ disabled: disabled || setting.value === setting.defaultValue || !setting.choices.some((choice) => choice.value === setting.defaultValue && !choice.unavailableReason),
5224
+ onClick: () => choose(setting.defaultValue),
5225
+ children: "Reset"
5226
+ }) : null
5227
+ ]
5228
+ }),
5229
+ /* @__PURE__ */ jsxs14("label", {
5230
+ className: "chat-composer-menu-field",
5231
+ children: [
5232
+ /* @__PURE__ */ jsx16("span", {
5233
+ className: "sr-only",
5234
+ children: setting.label
5235
+ }),
5236
+ /* @__PURE__ */ jsx16("input", {
5237
+ type: "range",
5238
+ className: "range range-sm",
5239
+ min: 0,
5240
+ max: Math.max(0, setting.choices.length - 1),
5241
+ step: 1,
5242
+ value,
5243
+ "aria-valuetext": setting.choices[value]?.label,
5244
+ disabled: disabled || !setting.choices.length,
5245
+ onChange: (event) => setDraft(Number(event.currentTarget.value)),
5246
+ onPointerUp: commit,
5247
+ onKeyUp: (event) => {
5248
+ if ([
5249
+ "ArrowLeft",
5250
+ "ArrowRight",
5251
+ "ArrowUp",
5252
+ "ArrowDown",
5253
+ "Home",
5254
+ "End",
5255
+ "PageUp",
5256
+ "PageDown"
5257
+ ].includes(event.key))
5258
+ commit();
5259
+ },
5260
+ onBlur: commit,
5261
+ onPointerCancel: () => setDraft(undefined)
5262
+ })
5263
+ ]
5264
+ }),
5265
+ /* @__PURE__ */ jsxs14("div", {
5266
+ className: "chat-composer-menu-row chat-composer-description",
5267
+ children: [
5268
+ /* @__PURE__ */ jsx16("span", {
5269
+ children: setting.choices[0]?.label
5270
+ }),
5271
+ /* @__PURE__ */ jsx16("span", {
5272
+ children: setting.choices.at(-1)?.label
5273
+ })
5274
+ ]
5275
+ })
5276
+ ]
5277
+ });
5278
+ }
5279
+ function SettingsMenu({
5280
+ group,
5281
+ ...props
5282
+ }) {
5283
+ const id = useId10();
5284
+ const anchor = `--settings-${id.replace(/[^a-zA-Z0-9_-]/g, "")}`;
5285
+ const panel = useRef10(null);
5286
+ const trigger = useRef10(null);
5287
+ const [open, setOpen] = useState10(false);
5288
+ const settings = group.settingIds.flatMap((key) => props.settings.filter((setting) => setting.id === key));
5289
+ const warning = settings.some((setting) => setting.choices.find((choice) => choice.value === setting.value)?.tone === "warning");
5290
+ function choose(setting, value) {
5291
+ if (props.busy || setting.unavailableReason || setting.choices.find((choice) => choice.value === value)?.unavailableReason)
5292
+ return;
5293
+ props.request(setting.id, value);
5294
+ panel.current?.querySelectorAll("[popover]").forEach((element) => element.hidePopover?.());
5295
+ panel.current?.hidePopover?.();
5296
+ trigger.current?.focus({ preventScroll: true });
5297
+ }
5298
+ function choices(setting) {
5299
+ return setting.choices.map((choice) => /* @__PURE__ */ jsxs14("button", {
5300
+ type: "button",
5301
+ className: cn("popover-menu-item chat-composer-menu-option", choice.tone === "warning" && "chat-composer-menu-option-warning"),
5302
+ "aria-pressed": setting.value === choice.value,
5303
+ disabled: props.busy || !!setting.unavailableReason || !!choice.unavailableReason,
5304
+ onClick: () => choose(setting, choice.value),
5305
+ children: [
5306
+ choice.icon,
5307
+ /* @__PURE__ */ jsxs14("span", {
5308
+ className: "chat-composer-label",
5309
+ children: [
5310
+ choice.label,
5311
+ choice.description ? /* @__PURE__ */ jsx16("span", {
5312
+ className: "chat-composer-description",
5313
+ children: choice.description
5314
+ }) : null,
5315
+ choice.unavailableReason ? /* @__PURE__ */ jsx16("span", {
5316
+ className: "chat-composer-description",
5317
+ children: choice.unavailableReason
5318
+ }) : null
5319
+ ]
5320
+ }),
5321
+ setting.value === choice.value ? /* @__PURE__ */ jsx16("span", {
5322
+ "aria-hidden": "true",
5323
+ children: "✓"
5324
+ }) : null
5325
+ ]
5326
+ }, choice.value));
5327
+ }
5328
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5329
+ children: [
5330
+ /* @__PURE__ */ jsxs14("button", {
5331
+ ref: trigger,
5332
+ type: "button",
5333
+ className: cn("btn btn-ghost btn-sm chat-composer-config", group.appearance && `chat-composer-${group.appearance}`, props.className),
5334
+ "data-active": group.appearance === "access" ? warning : undefined,
5335
+ "aria-label": `${group.label}: ${settings.map((setting) => setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value).join(", ")}`,
5336
+ title: group.label,
5337
+ popoverTarget: id,
5338
+ "aria-controls": id,
5339
+ "aria-expanded": open,
5340
+ disabled: settings.every((setting) => !!setting.unavailableReason),
5341
+ "aria-busy": props.busy || undefined,
5342
+ style: { anchorName: anchor },
5343
+ children: [
5344
+ group.icon,
5345
+ /* @__PURE__ */ jsx16("span", {
5346
+ className: "chat-composer-label",
5347
+ children: settings.map((setting, index) => /* @__PURE__ */ jsxs14(React15.Fragment, {
5348
+ children: [
5349
+ index ? " " : null,
5350
+ /* @__PURE__ */ jsx16("span", {
5351
+ className: setting.ordered ? "chat-composer-effort" : undefined,
5352
+ children: setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value
5353
+ })
5354
+ ]
5355
+ }, setting.id))
5356
+ }),
5357
+ /* @__PURE__ */ jsx16("span", {
5358
+ "aria-hidden": "true",
5359
+ children: "⌄"
5360
+ })
5361
+ ]
5362
+ }),
5363
+ /* @__PURE__ */ jsx16("div", {
5364
+ id,
5365
+ ref: panel,
5366
+ popover: "auto",
5367
+ role: "group",
5368
+ "aria-label": group.appearance === "model" ? `Composer ${group.label.toLowerCase()}` : group.label,
5369
+ className: cn("popover popover-menu chat-composer-menu", group.appearance === "model" && "chat-composer-menu-end"),
5370
+ style: { positionAnchor: anchor },
5371
+ onToggle: (event) => setOpen(event.newState === "open"),
5372
+ children: settings.map((setting) => /* @__PURE__ */ jsxs14(React15.Fragment, {
5373
+ children: [
5374
+ setting.ordered ? /* @__PURE__ */ jsx16(OrderedSetting, {
5375
+ setting,
5376
+ disabled: props.busy || !!setting.unavailableReason,
5377
+ choose: (value) => choose(setting, value)
5378
+ }, `${setting.id}-${setting.value}-${props.revision}`) : group.nestedSettingIds?.includes(setting.id) ? /* @__PURE__ */ jsx16(NestedSetting, {
5379
+ id: `${id}-${setting.id}`,
5380
+ setting,
5381
+ disabled: props.busy || !!setting.unavailableReason,
5382
+ anchor,
5383
+ children: choices(setting)
5384
+ }) : /* @__PURE__ */ jsxs14(Fragment9, {
5385
+ children: [
5386
+ /* @__PURE__ */ jsx16("div", {
5387
+ className: "chat-composer-group",
5388
+ children: setting.label
5389
+ }),
5390
+ choices(setting)
5391
+ ]
5392
+ }),
5393
+ setting.unavailableReason ? /* @__PURE__ */ jsx16("p", {
5394
+ className: "chat-composer-description",
5395
+ children: setting.unavailableReason
5396
+ }) : null
5397
+ ]
5398
+ }, setting.id))
5399
+ })
5400
+ ]
5401
+ });
5402
+ }
5403
+ function NestedSetting({
5404
+ id,
5405
+ setting,
5406
+ disabled,
5407
+ anchor,
5408
+ children
5409
+ }) {
5410
+ const [open, setOpen] = useState10(false);
5411
+ return /* @__PURE__ */ jsxs14(Fragment9, {
5412
+ children: [
5413
+ /* @__PURE__ */ jsxs14("button", {
5414
+ type: "button",
5415
+ className: "popover-menu-item",
5416
+ "aria-label": `Choose a ${setting.label.toLowerCase()}: ${setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value}`,
5417
+ disabled,
5418
+ popoverTarget: id,
5419
+ "aria-controls": id,
5420
+ "aria-expanded": open,
5421
+ children: [
5422
+ /* @__PURE__ */ jsx16("span", {
5423
+ className: "chat-composer-label",
5424
+ children: setting.choices.find((choice) => choice.value === setting.value)?.label ?? setting.value
5425
+ }),
5426
+ /* @__PURE__ */ jsx16("span", {
5427
+ "aria-hidden": "true",
5428
+ children: "›"
5429
+ })
5430
+ ]
5431
+ }),
5432
+ /* @__PURE__ */ jsxs14("div", {
5433
+ id,
5434
+ popover: "auto",
5435
+ role: "group",
5436
+ "aria-label": `Choose a ${setting.label.toLowerCase()}`,
5437
+ className: "popover popover-menu chat-composer-menu chat-composer-menu-end",
5438
+ style: { positionAnchor: anchor },
5439
+ onToggle: (event) => setOpen(event.newState === "open"),
5440
+ children: [
5441
+ /* @__PURE__ */ jsxs14("div", {
5442
+ className: "chat-composer-group",
5443
+ children: [
5444
+ "Select ",
5445
+ setting.label.toLowerCase()
5446
+ ]
5447
+ }),
5448
+ children
5449
+ ]
5450
+ })
5451
+ ]
5452
+ });
5453
+ }
4990
5454
 
4991
5455
  // src/components/select/Select.tsx
4992
- import React13, {
4993
- forwardRef as forwardRef9,
5456
+ import React16, {
5457
+ forwardRef as forwardRef11,
4994
5458
  useCallback as useCallback3,
4995
5459
  useEffect as useEffect3,
4996
- useId as useId9,
5460
+ useId as useId11,
4997
5461
  useMemo,
4998
- useRef as useRef9,
4999
- useState as useState10
5462
+ useRef as useRef11,
5463
+ useState as useState11
5000
5464
  } from "react";
5001
5465
 
5002
5466
  // src/classes/select.ts
@@ -5053,7 +5517,7 @@ function getSelectOptionClasses({
5053
5517
  }
5054
5518
 
5055
5519
  // src/components/select/Select.tsx
5056
- import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
5520
+ import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
5057
5521
  function isGroup(option) {
5058
5522
  return "options" in option;
5059
5523
  }
@@ -5078,8 +5542,8 @@ function normalizeMultiValue(value) {
5078
5542
  }
5079
5543
  function optionsFromChildren(children) {
5080
5544
  const result = [];
5081
- React13.Children.forEach(children, (child) => {
5082
- if (!React13.isValidElement(child)) {
5545
+ React16.Children.forEach(children, (child) => {
5546
+ if (!React16.isValidElement(child)) {
5083
5547
  return;
5084
5548
  }
5085
5549
  if (child.type === Option) {
@@ -5129,19 +5593,19 @@ function filterOptions(options, searchValue, filterOption) {
5129
5593
  function renderValue(option) {
5130
5594
  return option ? optionLabel(option) : null;
5131
5595
  }
5132
- var Option = forwardRef9(({ children, ...props }, ref) => /* @__PURE__ */ jsx14("div", {
5596
+ var Option = forwardRef11(({ children, ...props }, ref) => /* @__PURE__ */ jsx17("div", {
5133
5597
  ...props,
5134
5598
  ref,
5135
5599
  children
5136
5600
  }));
5137
5601
  Option.displayName = "Select.Option";
5138
- var OptGroup = forwardRef9(({ children, ...props }, ref) => /* @__PURE__ */ jsx14("div", {
5602
+ var OptGroup = forwardRef11(({ children, ...props }, ref) => /* @__PURE__ */ jsx17("div", {
5139
5603
  ...props,
5140
5604
  ref,
5141
5605
  children
5142
5606
  }));
5143
5607
  OptGroup.displayName = "Select.OptGroup";
5144
- var SelectRoot = forwardRef9(({
5608
+ var SelectRoot = forwardRef11(({
5145
5609
  allowClear,
5146
5610
  "aria-describedby": ariaDescribedBy,
5147
5611
  "aria-errormessage": ariaErrorMessage,
@@ -5170,16 +5634,16 @@ var SelectRoot = forwardRef9(({
5170
5634
  value,
5171
5635
  ...props
5172
5636
  }, ref) => {
5173
- const generatedId = useId9();
5637
+ const generatedId = useId11();
5174
5638
  const cleanId = generatedId.replace(/[^a-zA-Z0-9_-]/g, "");
5175
5639
  const triggerId = id || `select-${cleanId}`;
5176
5640
  const dropdownId = `select-dropdown-${cleanId}`;
5177
5641
  const anchorName = `--dm-select-${cleanId}`;
5178
- const [internalOpen, setInternalOpen] = useState10(Boolean(defaultOpen));
5642
+ const [internalOpen, setInternalOpen] = useState11(Boolean(defaultOpen));
5179
5643
  const isControlled = openProp !== undefined;
5180
5644
  const isOpen = isControlled ? Boolean(openProp) : internalOpen;
5181
- const containerRef = useRef9(null);
5182
- const dropdownRef = useRef9(null);
5645
+ const containerRef = useRef11(null);
5646
+ const dropdownRef = useRef11(null);
5183
5647
  const setOpenState = useCallback3((nextOpen) => {
5184
5648
  if (!isControlled) {
5185
5649
  setInternalOpen(nextOpen);
@@ -5224,8 +5688,8 @@ var SelectRoot = forwardRef9(({
5224
5688
  const multiple = mode === "multiple" || mode === "tags";
5225
5689
  const sourceOptions = useMemo(() => options ?? optionsFromChildren(children), [children, options]);
5226
5690
  const flatOptions = useMemo(() => flattenOptions(sourceOptions), [sourceOptions]);
5227
- const [searchValue, setSearchValue] = useState10("");
5228
- const [internalValue, setInternalValue] = useState10(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
5691
+ const [searchValue, setSearchValue] = useState11("");
5692
+ const [internalValue, setInternalValue] = useState11(multiple ? normalizeMultiValue(defaultValue) : normalizeSingleValue(defaultValue));
5229
5693
  const controlled = value !== undefined;
5230
5694
  const currentValue = controlled ? value : internalValue;
5231
5695
  const selectedValues = multiple ? normalizeMultiValue(currentValue) : normalizeSingleValue(currentValue) === undefined ? [] : [normalizeSingleValue(currentValue)];
@@ -5282,7 +5746,7 @@ var SelectRoot = forwardRef9(({
5282
5746
  }
5283
5747
  function renderOption(option) {
5284
5748
  const selected = selectedKeys.has(valueKey(option.value));
5285
- return /* @__PURE__ */ jsx14("button", {
5749
+ return /* @__PURE__ */ jsx17("button", {
5286
5750
  type: "button",
5287
5751
  role: "option",
5288
5752
  "aria-selected": selected,
@@ -5301,11 +5765,11 @@ var SelectRoot = forwardRef9(({
5301
5765
  if (!isGroup(option)) {
5302
5766
  return renderOption(option);
5303
5767
  }
5304
- return /* @__PURE__ */ jsxs12("div", {
5768
+ return /* @__PURE__ */ jsxs15("div", {
5305
5769
  className: cn(selectGroupClass, option.className),
5306
5770
  role: "group",
5307
5771
  children: [
5308
- /* @__PURE__ */ jsx14("div", {
5772
+ /* @__PURE__ */ jsx17("div", {
5309
5773
  className: selectGroupLabelClass,
5310
5774
  children: option.label
5311
5775
  }),
@@ -5322,11 +5786,11 @@ var SelectRoot = forwardRef9(({
5322
5786
  ref.current = node;
5323
5787
  }
5324
5788
  };
5325
- const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx14("span", {
5789
+ const selection = multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsx17("span", {
5326
5790
  className: selectTagClass,
5327
5791
  children: renderValue(option)
5328
5792
  }, valueKey(option.value))) : renderValue(selectedOptions[0]);
5329
- return /* @__PURE__ */ jsxs12("div", {
5793
+ return /* @__PURE__ */ jsxs15("div", {
5330
5794
  ...props,
5331
5795
  ref: setRefs,
5332
5796
  className: getSelectContainerClasses({
@@ -5337,7 +5801,7 @@ var SelectRoot = forwardRef9(({
5337
5801
  className
5338
5802
  }),
5339
5803
  children: [
5340
- /* @__PURE__ */ jsxs12("button", {
5804
+ /* @__PURE__ */ jsxs15("button", {
5341
5805
  type: "button",
5342
5806
  id: triggerId,
5343
5807
  className: getSelectClasses({ size, status, disabled }),
@@ -5358,17 +5822,17 @@ var SelectRoot = forwardRef9(({
5358
5822
  setOpenState(!isOpen);
5359
5823
  },
5360
5824
  children: [
5361
- /* @__PURE__ */ jsx14("span", {
5825
+ /* @__PURE__ */ jsx17("span", {
5362
5826
  className: selectSelectionClass,
5363
- children: hasValue ? selection : /* @__PURE__ */ jsx14("span", {
5827
+ children: hasValue ? selection : /* @__PURE__ */ jsx17("span", {
5364
5828
  className: selectPlaceholderClass,
5365
5829
  children: placeholder
5366
5830
  })
5367
5831
  }),
5368
- /* @__PURE__ */ jsx14("span", {
5832
+ /* @__PURE__ */ jsx17("span", {
5369
5833
  className: selectIconClass,
5370
5834
  "aria-hidden": "true",
5371
- children: /* @__PURE__ */ jsx14("svg", {
5835
+ children: /* @__PURE__ */ jsx17("svg", {
5372
5836
  width: "16",
5373
5837
  height: "16",
5374
5838
  viewBox: "0 0 24 24",
@@ -5378,19 +5842,19 @@ var SelectRoot = forwardRef9(({
5378
5842
  strokeLinecap: "round",
5379
5843
  strokeLinejoin: "round",
5380
5844
  "aria-hidden": "true",
5381
- children: /* @__PURE__ */ jsx14("path", {
5845
+ children: /* @__PURE__ */ jsx17("path", {
5382
5846
  d: "m6 9 6 6 6-6"
5383
5847
  })
5384
5848
  })
5385
5849
  })
5386
5850
  ]
5387
5851
  }),
5388
- allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx14("button", {
5852
+ allowClear && hasValue && !disabled && !loading ? /* @__PURE__ */ jsx17("button", {
5389
5853
  type: "button",
5390
5854
  className: selectClearClass,
5391
5855
  "aria-label": "Clear selection",
5392
5856
  onClick: clearValue,
5393
- children: /* @__PURE__ */ jsx14("svg", {
5857
+ children: /* @__PURE__ */ jsx17("svg", {
5394
5858
  width: "14",
5395
5859
  height: "14",
5396
5860
  viewBox: "0 0 24 24",
@@ -5399,12 +5863,12 @@ var SelectRoot = forwardRef9(({
5399
5863
  strokeWidth: "2",
5400
5864
  strokeLinecap: "round",
5401
5865
  "aria-hidden": "true",
5402
- children: /* @__PURE__ */ jsx14("path", {
5866
+ children: /* @__PURE__ */ jsx17("path", {
5403
5867
  d: "m6 6 12 12M6 18 18 6"
5404
5868
  })
5405
5869
  })
5406
5870
  }) : null,
5407
- isOpen ? /* @__PURE__ */ jsxs12("div", {
5871
+ isOpen ? /* @__PURE__ */ jsxs15("div", {
5408
5872
  id: dropdownId,
5409
5873
  ref: dropdownRef,
5410
5874
  popover: "auto",
@@ -5421,7 +5885,7 @@ var SelectRoot = forwardRef9(({
5421
5885
  }
5422
5886
  },
5423
5887
  children: [
5424
- searchable ? /* @__PURE__ */ jsx14("input", {
5888
+ searchable ? /* @__PURE__ */ jsx17("input", {
5425
5889
  className: selectSearchClass,
5426
5890
  value: searchValue,
5427
5891
  placeholder: typeof placeholder === "string" ? placeholder : undefined,
@@ -5433,7 +5897,7 @@ var SelectRoot = forwardRef9(({
5433
5897
  }
5434
5898
  }
5435
5899
  }) : null,
5436
- visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx14("div", {
5900
+ visibleOptions.length > 0 ? renderOptions(visibleOptions) : /* @__PURE__ */ jsx17("div", {
5437
5901
  className: selectEmptyClass,
5438
5902
  children: "No data"
5439
5903
  })
@@ -5448,25 +5912,25 @@ Select.Option = Option;
5448
5912
  Select.OptGroup = OptGroup;
5449
5913
 
5450
5914
  // src/components/chat/ComposerSettings.tsx
5451
- import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
5915
+ import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
5452
5916
  function ComposerSettings(props) {
5453
- return /* @__PURE__ */ jsx15(SettingsSession, {
5917
+ return /* @__PURE__ */ jsx18(SettingsSession, {
5454
5918
  ...props
5455
5919
  }, props.scopeKey);
5456
5920
  }
5457
5921
  function SettingsSession(props) {
5458
- const latest = useRef10(props);
5459
- const watermark = useRef10(props.revision);
5460
- useLayoutEffect12(() => {
5922
+ const latest = useRef12(props);
5923
+ const watermark = useRef12(props.revision);
5924
+ useLayoutEffect13(() => {
5461
5925
  latest.current = props;
5462
5926
  watermark.current = Math.max(watermark.current, props.revision);
5463
5927
  });
5464
- const requests = useRef10(new Map);
5465
- const nextId = useRef10(0);
5466
- const instanceId = useId10();
5467
- const [pending, setPending] = useState11([]);
5468
- const [feedback, setFeedback] = useState11({});
5469
- useLayoutEffect12(() => {
5928
+ const requests = useRef12(new Map);
5929
+ const nextId = useRef12(0);
5930
+ const instanceId = useId12();
5931
+ const [pending, setPending] = useState12([]);
5932
+ const [feedback, setFeedback] = useState12({});
5933
+ useLayoutEffect13(() => {
5470
5934
  const active = requests.current;
5471
5935
  return () => {
5472
5936
  for (const controller of active.values())
@@ -5526,7 +5990,14 @@ function SettingsSession(props) {
5526
5990
  }
5527
5991
  }
5528
5992
  }
5529
- return /* @__PURE__ */ jsx15("div", {
5993
+ if (props.variant === "menu")
5994
+ return /* @__PURE__ */ jsx18(ComposerSettingsMenus, {
5995
+ ...props,
5996
+ busy: pending.length > 0,
5997
+ feedback,
5998
+ request
5999
+ });
6000
+ return /* @__PURE__ */ jsx18("div", {
5530
6001
  className: cn("chat-composer-toolbar", props.className),
5531
6002
  role: "group",
5532
6003
  "aria-label": props.label ?? "Composer settings",
@@ -5534,9 +6005,9 @@ function SettingsSession(props) {
5534
6005
  const busy = pending.length > 0;
5535
6006
  const descriptionId = `${instanceId}-${setting.id}-description`;
5536
6007
  const description = busy ? "Change pending" : feedback[setting.id] || setting.unavailableReason;
5537
- return /* @__PURE__ */ jsxs13("div", {
6008
+ return /* @__PURE__ */ jsxs16("div", {
5538
6009
  children: [
5539
- /* @__PURE__ */ jsx15(Select, {
6010
+ /* @__PURE__ */ jsx18(Select, {
5540
6011
  "aria-label": setting.label,
5541
6012
  "aria-describedby": description ? descriptionId : undefined,
5542
6013
  value: setting.value,
@@ -5552,7 +6023,7 @@ function SettingsSession(props) {
5552
6023
  request(setting.id, value);
5553
6024
  }
5554
6025
  }),
5555
- description ? /* @__PURE__ */ jsx15("p", {
6026
+ description ? /* @__PURE__ */ jsx18("p", {
5556
6027
  id: descriptionId,
5557
6028
  className: "chat-composer-status",
5558
6029
  role: "status",
@@ -5572,6 +6043,10 @@ export {
5572
6043
  ChatBubble,
5573
6044
  ChatComposer,
5574
6045
  ChatComposerActions,
6046
+ ChatComposerConnection,
6047
+ ChatComposerContext,
6048
+ ChatComposerContextEnd,
6049
+ ChatComposerContextItem,
5575
6050
  ChatComposerForm,
5576
6051
  ChatComposerHint,
5577
6052
  ChatComposerInput,
@@ -5581,6 +6056,7 @@ export {
5581
6056
  ChatInputArea,
5582
6057
  ChatQueue,
5583
6058
  ChatReasoning,
6059
+ ChatRequest,
5584
6060
  ChatScroll,
5585
6061
  ChatScrollBody,
5586
6062
  ChatScrollIndicator,