asta-ui 0.9.4 → 0.9.6

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.
Files changed (130) hide show
  1. package/css/asta.css +2 -2
  2. package/css/asta.js +1461 -1
  3. package/css/components.css +1900 -138
  4. package/css/runtime/agent.css +136 -0
  5. package/css/runtime/agent.js +173 -0
  6. package/css/runtime/assist.css +79 -0
  7. package/css/runtime/assist.js +799 -0
  8. package/css/runtime/controls.css +48 -0
  9. package/css/runtime/controls.js +482 -0
  10. package/css/src/agent.css +484 -0
  11. package/css/src/assist.css +598 -0
  12. package/css/src/controls.css +424 -0
  13. package/css/tokens.css +16 -0
  14. package/dist/agent-plan.d.ts +2 -0
  15. package/dist/agent-plan.js +11 -0
  16. package/dist/agent-team.d.ts +2 -0
  17. package/dist/agent-team.js +7 -0
  18. package/dist/api-keys.d.ts +2 -0
  19. package/dist/api-keys.js +10 -0
  20. package/dist/autonomy-dial.d.ts +2 -0
  21. package/dist/autonomy-dial.js +7 -0
  22. package/dist/base/agent-plan.d.ts +2 -0
  23. package/dist/base/agent-plan.js +11 -0
  24. package/dist/base/agent-team.d.ts +2 -0
  25. package/dist/base/agent-team.js +7 -0
  26. package/dist/base/api-keys.d.ts +2 -0
  27. package/dist/base/api-keys.js +10 -0
  28. package/dist/base/autonomy-dial.d.ts +2 -0
  29. package/dist/base/autonomy-dial.js +7 -0
  30. package/dist/base/change-ledger.d.ts +2 -0
  31. package/dist/base/change-ledger.js +7 -0
  32. package/dist/base/citations.d.ts +2 -0
  33. package/dist/base/citations.js +9 -0
  34. package/dist/base/context-meter.d.ts +2 -0
  35. package/dist/base/context-meter.js +14 -0
  36. package/dist/base/fallback-chain.d.ts +2 -0
  37. package/dist/base/fallback-chain.js +7 -0
  38. package/dist/base/model-picker.d.ts +2 -0
  39. package/dist/base/model-picker.js +9 -0
  40. package/dist/base/prompt-composer.d.ts +2 -0
  41. package/dist/base/prompt-composer.js +9 -0
  42. package/dist/base/scrub-input.d.ts +2 -0
  43. package/dist/base/scrub-input.js +13 -0
  44. package/dist/base/thinking.d.ts +2 -0
  45. package/dist/base/thinking.js +11 -0
  46. package/dist/base/tool-approval.d.ts +2 -0
  47. package/dist/base/tool-approval.js +9 -0
  48. package/dist/base/trace-waterfall.d.ts +2 -0
  49. package/dist/base/trace-waterfall.js +9 -0
  50. package/dist/base.js +202 -134
  51. package/dist/change-ledger.d.ts +2 -0
  52. package/dist/change-ledger.js +7 -0
  53. package/dist/chunk-24O5V2PQ.js +253 -0
  54. package/dist/chunk-44DNL43W.js +490 -0
  55. package/dist/chunk-45IXJ7W7.js +245 -0
  56. package/dist/chunk-ANL6VX4X.js +326 -0
  57. package/dist/chunk-DNROUJ62.js +432 -0
  58. package/dist/chunk-F4CWSZXK.js +226 -0
  59. package/dist/chunk-GBOJUMMY.js +163 -0
  60. package/dist/chunk-H4NFBYKY.js +275 -0
  61. package/dist/chunk-KFPGQ5RT.js +321 -0
  62. package/dist/chunk-OIIMYSVT.js +342 -0
  63. package/dist/chunk-TL32C2SQ.js +221 -0
  64. package/dist/chunk-UBTYMAKF.js +240 -0
  65. package/dist/chunk-W6YVDJHX.js +235 -0
  66. package/dist/chunk-XYQI4ZYV.js +314 -0
  67. package/dist/citations.d.ts +2 -0
  68. package/dist/citations.js +9 -0
  69. package/dist/context-meter.d.ts +2 -0
  70. package/dist/context-meter.js +14 -0
  71. package/dist/fallback-chain.d.ts +2 -0
  72. package/dist/fallback-chain.js +7 -0
  73. package/dist/index.js +202 -134
  74. package/dist/model-picker.d.ts +2 -0
  75. package/dist/model-picker.js +9 -0
  76. package/dist/prompt-composer.d.ts +2 -0
  77. package/dist/prompt-composer.js +9 -0
  78. package/dist/scrub-input.d.ts +2 -0
  79. package/dist/scrub-input.js +13 -0
  80. package/dist/thinking.d.ts +2 -0
  81. package/dist/thinking.js +11 -0
  82. package/dist/tool-approval.d.ts +2 -0
  83. package/dist/tool-approval.js +9 -0
  84. package/dist/trace-waterfall.d.ts +2 -0
  85. package/dist/trace-waterfall.js +9 -0
  86. package/dist/types/components/kit/agent-plan.d.ts +34 -0
  87. package/dist/types/components/kit/api-keys.d.ts +62 -0
  88. package/dist/types/components/kit/citations.d.ts +34 -0
  89. package/dist/types/components/kit/context-meter.d.ts +38 -0
  90. package/dist/types/components/kit/model-picker.d.ts +46 -0
  91. package/dist/types/components/kit/prompt-composer.d.ts +61 -0
  92. package/dist/types/components/kit/scrub-input.d.ts +44 -0
  93. package/dist/types/components/kit/thinking.d.ts +28 -0
  94. package/dist/types/components/kit/tool-approval.d.ts +43 -0
  95. package/dist/types/components/kit/trace-waterfall.d.ts +44 -0
  96. package/dist/types/components/lab/blocks/AgentTeam.d.ts +2 -0
  97. package/dist/types/components/lab/blocks/AutonomyDial.d.ts +2 -0
  98. package/dist/types/components/lab/blocks/ChangeLedger.d.ts +2 -0
  99. package/dist/types/components/lab/blocks/FallbackChain.d.ts +2 -0
  100. package/dist/types/packages/asta-ui/src/agent-plan.d.ts +2 -0
  101. package/dist/types/packages/asta-ui/src/agent-team.d.ts +2 -0
  102. package/dist/types/packages/asta-ui/src/api-keys.d.ts +2 -0
  103. package/dist/types/packages/asta-ui/src/autonomy-dial.d.ts +2 -0
  104. package/dist/types/packages/asta-ui/src/base/agent-plan.d.ts +2 -0
  105. package/dist/types/packages/asta-ui/src/base/agent-team.d.ts +2 -0
  106. package/dist/types/packages/asta-ui/src/base/api-keys.d.ts +2 -0
  107. package/dist/types/packages/asta-ui/src/base/autonomy-dial.d.ts +2 -0
  108. package/dist/types/packages/asta-ui/src/base/change-ledger.d.ts +2 -0
  109. package/dist/types/packages/asta-ui/src/base/citations.d.ts +2 -0
  110. package/dist/types/packages/asta-ui/src/base/context-meter.d.ts +2 -0
  111. package/dist/types/packages/asta-ui/src/base/fallback-chain.d.ts +2 -0
  112. package/dist/types/packages/asta-ui/src/base/model-picker.d.ts +2 -0
  113. package/dist/types/packages/asta-ui/src/base/prompt-composer.d.ts +2 -0
  114. package/dist/types/packages/asta-ui/src/base/scrub-input.d.ts +2 -0
  115. package/dist/types/packages/asta-ui/src/base/thinking.d.ts +2 -0
  116. package/dist/types/packages/asta-ui/src/base/tool-approval.d.ts +2 -0
  117. package/dist/types/packages/asta-ui/src/base/trace-waterfall.d.ts +2 -0
  118. package/dist/types/packages/asta-ui/src/base.d.ts +25 -1
  119. package/dist/types/packages/asta-ui/src/change-ledger.d.ts +2 -0
  120. package/dist/types/packages/asta-ui/src/citations.d.ts +2 -0
  121. package/dist/types/packages/asta-ui/src/context-meter.d.ts +2 -0
  122. package/dist/types/packages/asta-ui/src/fallback-chain.d.ts +2 -0
  123. package/dist/types/packages/asta-ui/src/index.d.ts +25 -1
  124. package/dist/types/packages/asta-ui/src/model-picker.d.ts +2 -0
  125. package/dist/types/packages/asta-ui/src/prompt-composer.d.ts +2 -0
  126. package/dist/types/packages/asta-ui/src/scrub-input.d.ts +2 -0
  127. package/dist/types/packages/asta-ui/src/thinking.d.ts +2 -0
  128. package/dist/types/packages/asta-ui/src/tool-approval.d.ts +2 -0
  129. package/dist/types/packages/asta-ui/src/trace-waterfall.d.ts +2 -0
  130. package/package.json +1 -1
@@ -0,0 +1,490 @@
1
+ "use client";
2
+
3
+ // components/kit/prompt-composer.tsx
4
+ import { useEffect, useId, useMemo, useRef, useState } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ var cx = (...c) => c.filter(Boolean).join(" ");
7
+ var KEYFRAMES = `@keyframes asta-pc-orbit { from { transform: translate(-50%, -50%) rotate(0turn) } to { transform: translate(-50%, -50%) rotate(1turn) } }
8
+ @keyframes asta-pc-fade { from { opacity: 0 } }
9
+ @keyframes asta-pc-chip { from { opacity: 0; transform: scale(.92) } }
10
+ .asta-pc-ring { -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude }
11
+ .asta-pc-field:focus { outline: none }
12
+ @media (prefers-reduced-motion: reduce) {
13
+ .asta-pc, .asta-pc * { animation: none !important; transition-duration: 0s !important }
14
+ .asta-pc-spin { background: color-mix(in srgb, var(--brand) 60%, transparent) !important }
15
+ }`;
16
+ var EASE = "cubic-bezier(.16,1,.3,1)";
17
+ var GLYPH = {
18
+ file: "M9 2.5H5A1.5 1.5 0 0 0 3.5 4v8A1.5 1.5 0 0 0 5 13.5h6a1.5 1.5 0 0 0 1.5-1.5V6L9 2.5ZM9 2.5V6h3.5",
19
+ doc: "M4.5 2.5h7a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1ZM6 6h4M6 8.5h4M6 11h2.5",
20
+ person: "M8 8a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM3.5 13.5c.6-2.2 2.3-3.5 4.5-3.5s3.9 1.3 4.5 3.5",
21
+ command: "m10 3-4 10"
22
+ };
23
+ var svg = (d, cls = "h-3.5 w-3.5") => `<svg viewBox="0 0 16 16" class="${cls} shrink-0" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
24
+ function Icon({ d, className = "h-4 w-4" }) {
25
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: cx("shrink-0", className), fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
26
+ }
27
+ var CHIP = "mx-px inline-flex items-center gap-1 whitespace-nowrap rounded-[5px] px-1.5 align-baseline text-[0.93em] font-medium leading-[1.5] [animation:asta-pc-chip_.2s_cubic-bezier(.16,1,.3,1)]";
28
+ var CHIP_MENTION = "bg-[color-mix(in_srgb,var(--brand)_11%,transparent)] text-brand";
29
+ var CHIP_COMMAND = "bg-ink text-paper";
30
+ var GROUPS = [
31
+ { type: "file", label: "Files" },
32
+ { type: "person", label: "People" },
33
+ { type: "doc", label: "Docs" }
34
+ ];
35
+ var size = (n) => n < 1024 ? `${n} B` : n < 1024 ** 2 ? `${Math.round(n / 1024)} KB` : `${(n / 1024 ** 2).toFixed(1)} MB`;
36
+ var initials = (s) => s.split(/\s+/).map((w) => w[0]).join("").slice(0, 2).toUpperCase();
37
+ function PromptComposer({
38
+ onSend,
39
+ onStop,
40
+ running = false,
41
+ mentions = [],
42
+ commands = [],
43
+ model,
44
+ placeholder = "Ask Astabyte to do something\u2026",
45
+ label = "Message",
46
+ accept,
47
+ maxFileSize = 20 * 1024 ** 2,
48
+ disabled,
49
+ className
50
+ }) {
51
+ const [empty, setEmpty] = useState(true);
52
+ const [menu, setMenu] = useState(null);
53
+ const [active, setActive] = useState(0);
54
+ const [files, setFiles] = useState([]);
55
+ const [error, setError] = useState("");
56
+ const [status, setStatus] = useState("");
57
+ const [drag, setDrag] = useState(false);
58
+ const [onScreen, setOnScreen] = useState(true);
59
+ const root = useRef(null);
60
+ const ed = useRef(null);
61
+ const picker = useRef(null);
62
+ const trig = useRef(null);
63
+ const dismissed = useRef(null);
64
+ const seq = useRef(0);
65
+ const uid = useId();
66
+ useEffect(() => {
67
+ const el = root.current;
68
+ if (!el) return;
69
+ let seen = true;
70
+ const sync2 = () => setOnScreen(seen && !document.hidden);
71
+ const io = new IntersectionObserver(([e]) => {
72
+ seen = e.isIntersecting;
73
+ sync2();
74
+ });
75
+ io.observe(el);
76
+ document.addEventListener("visibilitychange", sync2);
77
+ return () => {
78
+ io.disconnect();
79
+ document.removeEventListener("visibilitychange", sync2);
80
+ };
81
+ }, []);
82
+ const items = useMemo(() => {
83
+ if (!menu) return [];
84
+ const q = menu.query.toLowerCase();
85
+ if (menu.kind === "/") return commands.filter((c) => c.label.toLowerCase().includes(q)).map((item) => ({ kind: "/", item }));
86
+ const hit = mentions.filter((m) => `${m.label} ${m.hint ?? ""}`.toLowerCase().includes(q));
87
+ return GROUPS.flatMap((g) => hit.filter((m) => m.type === g.type)).map((item) => ({ kind: "@", item }));
88
+ }, [menu, mentions, commands]);
89
+ const act = Math.min(active, Math.max(items.length - 1, 0));
90
+ const sync = () => {
91
+ const el = ed.current;
92
+ if (el) setEmpty(!el.textContent && !el.querySelector("[data-token]"));
93
+ };
94
+ const read = () => {
95
+ const parts = [];
96
+ let buf = "";
97
+ const flush = () => {
98
+ if (buf) parts.push({ type: "text", text: buf });
99
+ buf = "";
100
+ };
101
+ const walk = (node) => {
102
+ node.childNodes.forEach((c) => {
103
+ if (c.nodeType === 3) buf += c.data;
104
+ else if (c instanceof HTMLElement && c.dataset.token) {
105
+ flush();
106
+ const id = c.dataset.id;
107
+ if (c.dataset.token === "/") {
108
+ const item = commands.find((x) => x.id === id) ?? { id, label: c.dataset.label ?? id };
109
+ parts.push({ type: "command", item });
110
+ } else {
111
+ const item = mentions.find((x) => x.id === id) ?? { id, label: c.dataset.label ?? id, type: "doc" };
112
+ parts.push({ type: "mention", item });
113
+ }
114
+ } else if (c.nodeName === "BR") buf += "\n";
115
+ else if (c instanceof HTMLElement) {
116
+ if (buf && !buf.endsWith("\n")) buf += "\n";
117
+ walk(c);
118
+ }
119
+ });
120
+ };
121
+ if (ed.current) walk(ed.current);
122
+ flush();
123
+ const text = parts.map((p) => p.type === "text" ? p.text : p.type === "mention" ? `@${p.item.label}` : `/${p.item.label}`).join("").replace(/ /g, " ").trim();
124
+ return { text, parts };
125
+ };
126
+ const detect = () => {
127
+ const sel = getSelection();
128
+ const n = sel?.anchorNode;
129
+ if (!sel || !sel.isCollapsed || !n || n.nodeType !== 3 || !ed.current?.contains(n)) return setMenu(null);
130
+ const before = n.data.slice(0, sel.anchorOffset);
131
+ const m = before.match(/(?:^|\s)([@/])([^\s@/]{0,30})$/);
132
+ const kind = m?.[1];
133
+ if (!m || !kind || !(kind === "@" ? mentions : commands).length) {
134
+ trig.current = null;
135
+ return setMenu(null);
136
+ }
137
+ const start = sel.anchorOffset - m[2].length - 1;
138
+ if (dismissed.current?.node === n && dismissed.current.start === start) return setMenu(null);
139
+ trig.current = { node: n, start };
140
+ const r = document.createRange();
141
+ r.setStart(n, start);
142
+ r.setEnd(n, start + 1);
143
+ const box = root.current.getBoundingClientRect();
144
+ const w = Math.min(320, box.width);
145
+ const x = Math.max(0, Math.min(r.getBoundingClientRect().left - box.left - 10, box.width - w));
146
+ if (!menu || menu.kind !== kind || menu.query !== m[2]) setActive(0);
147
+ setMenu({ kind, query: m[2], x });
148
+ };
149
+ const place = (node, offset) => {
150
+ const sel = getSelection();
151
+ const r = document.createRange();
152
+ r.setStart(node, offset);
153
+ r.collapse(true);
154
+ sel?.removeAllRanges();
155
+ sel?.addRange(r);
156
+ };
157
+ const insert = (it) => {
158
+ const t = trig.current;
159
+ const sel = getSelection();
160
+ if (!it || !t || !sel?.anchorNode) return;
161
+ const r = document.createRange();
162
+ r.setStart(t.node, t.start);
163
+ r.setEnd(sel.anchorNode, sel.anchorOffset);
164
+ r.deleteContents();
165
+ const chip = document.createElement("span");
166
+ chip.contentEditable = "false";
167
+ chip.dataset.token = it.kind;
168
+ chip.dataset.id = it.item.id;
169
+ chip.dataset.label = it.item.label;
170
+ chip.className = cx(CHIP, it.kind === "/" ? CHIP_COMMAND : CHIP_MENTION);
171
+ chip.innerHTML = svg(GLYPH[it.kind === "/" ? "command" : it.item.type], "h-3 w-3");
172
+ chip.append(it.item.label);
173
+ r.insertNode(chip);
174
+ const space = document.createTextNode(" ");
175
+ chip.after(space);
176
+ place(space, 1);
177
+ trig.current = null;
178
+ setMenu(null);
179
+ sync();
180
+ setStatus(`Added ${it.kind === "/" ? `command /${it.item.label}` : it.item.label}.`);
181
+ };
182
+ const nextToken = (dir) => {
183
+ const sel = getSelection();
184
+ if (!sel?.isCollapsed || !sel.anchorNode) return null;
185
+ const n = sel.anchorNode;
186
+ const off = sel.anchorOffset;
187
+ let sib;
188
+ if (n.nodeType === 3) {
189
+ if (dir < 0 ? off > 0 : off < n.length) return null;
190
+ sib = dir < 0 ? n.previousSibling : n.nextSibling;
191
+ } else sib = n.childNodes[dir < 0 ? off - 1 : off] ?? null;
192
+ while (sib && sib.nodeType === 3 && !sib.length) sib = dir < 0 ? sib.previousSibling : sib.nextSibling;
193
+ return sib instanceof HTMLElement && sib.dataset.token ? sib : null;
194
+ };
195
+ const addFiles = (list) => {
196
+ const ok = [];
197
+ let msg = "";
198
+ for (const file of Array.from(list)) {
199
+ if (file.size > maxFileSize) msg = `${file.name} is ${size(file.size)}. Attach files under ${size(maxFileSize)}.`;
200
+ else ok.push({ id: `f${seq.current++}`, file });
201
+ }
202
+ setError(msg);
203
+ if (ok.length) {
204
+ setFiles((f) => [...f, ...ok]);
205
+ setStatus(`Attached ${ok.map((f) => f.file.name).join(", ")}.`);
206
+ }
207
+ };
208
+ const send = () => {
209
+ if (running || disabled) return;
210
+ const msg = read();
211
+ if (!msg.text && !files.length) return;
212
+ onSend({ ...msg, files: files.map((f) => f.file) });
213
+ if (ed.current) ed.current.innerHTML = "";
214
+ setFiles([]);
215
+ setError("");
216
+ setMenu(null);
217
+ sync();
218
+ ed.current?.focus();
219
+ };
220
+ const onKey = (e) => {
221
+ if (e.nativeEvent.isComposing) return;
222
+ if (menu) {
223
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
224
+ e.preventDefault();
225
+ if (items.length) setActive((act + (e.key === "ArrowDown" ? 1 : -1) + items.length) % items.length);
226
+ return;
227
+ }
228
+ if ((e.key === "Enter" || e.key === "Tab") && items.length) {
229
+ e.preventDefault();
230
+ return insert(items[act]);
231
+ }
232
+ if (e.key === "Escape") {
233
+ e.preventDefault();
234
+ dismissed.current = trig.current;
235
+ return setMenu(null);
236
+ }
237
+ }
238
+ if (e.key === "Enter" && !e.shiftKey) {
239
+ e.preventDefault();
240
+ return send();
241
+ }
242
+ if (e.key === "Escape" && running) {
243
+ e.preventDefault();
244
+ return onStop?.();
245
+ }
246
+ if (e.key === "Backspace" || e.key === "Delete") {
247
+ const tok = nextToken(e.key === "Backspace" ? -1 : 1);
248
+ if (!tok) return;
249
+ e.preventDefault();
250
+ const parent = tok.parentNode;
251
+ const at = Array.prototype.indexOf.call(parent.childNodes, tok);
252
+ tok.remove();
253
+ place(parent, at);
254
+ sync();
255
+ setStatus(`Removed ${tok.dataset.label}.`);
256
+ }
257
+ };
258
+ const onPaste = (e) => {
259
+ if (e.clipboardData.files.length) {
260
+ e.preventDefault();
261
+ return addFiles(e.clipboardData.files);
262
+ }
263
+ e.preventDefault();
264
+ const text = e.clipboardData.getData("text/plain");
265
+ if (!document.execCommand("insertText", false, text)) {
266
+ const sel = getSelection();
267
+ const r = sel?.rangeCount ? sel.getRangeAt(0) : null;
268
+ if (!r) return;
269
+ r.deleteContents();
270
+ const node = document.createTextNode(text);
271
+ r.insertNode(node);
272
+ place(node, node.length);
273
+ }
274
+ sync();
275
+ };
276
+ const onDrop = (e) => {
277
+ setDrag(false);
278
+ if (!e.dataTransfer.files.length || disabled) return;
279
+ e.preventDefault();
280
+ addFiles(e.dataTransfer.files);
281
+ };
282
+ const canSend = !empty || files.length > 0;
283
+ const listId = `${uid}-menu`;
284
+ const optId = (i) => `${uid}-o-${i}`;
285
+ const groupOf = (it) => it.kind === "/" ? "Commands" : GROUPS.find((g) => g.type === it.item.type).label;
286
+ return /* @__PURE__ */ jsxs("div", { ref: root, className: cx("asta-pc relative w-full", className), children: [
287
+ /* @__PURE__ */ jsx("style", { href: "asta-prompt-composer", precedence: "asta", children: KEYFRAMES }),
288
+ /* @__PURE__ */ jsx("p", { className: "sr-only", "aria-live": "polite", children: status }),
289
+ menu && /* @__PURE__ */ jsxs(
290
+ "div",
291
+ {
292
+ id: listId,
293
+ role: "listbox",
294
+ "aria-label": menu.kind === "@" ? "Mention" : "Commands",
295
+ onPointerDown: (e) => e.preventDefault(),
296
+ className: "absolute bottom-full z-50 mb-2 max-h-[280px] w-[320px] max-w-full overflow-y-auto overscroll-contain rounded-xl bg-paper p-1.5 shadow-[0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent),0_16px_40px_-12px_rgb(0_0_0/0.25),0_4px_10px_-6px_rgb(0_0_0/0.1)] [scrollbar-width:thin]",
297
+ style: { left: menu.x, animation: `asta-pc-fade .12s ${EASE}` },
298
+ children: [
299
+ items.length === 0 && /* @__PURE__ */ jsxs("p", { className: "px-2.5 py-5 text-center text-[12.5px] text-mute", children: [
300
+ "Nothing matches \u201C",
301
+ menu.query,
302
+ "\u201D"
303
+ ] }),
304
+ items.map((it, i) => {
305
+ const group = groupOf(it);
306
+ const head = i === 0 || group !== groupOf(items[i - 1]);
307
+ const person = it.kind === "@" && it.item.type === "person";
308
+ return /* @__PURE__ */ jsxs("div", { role: "presentation", children: [
309
+ head && /* @__PURE__ */ jsx("p", { role: "presentation", className: "px-2.5 pt-2 pb-1 font-mono text-[10.5px] uppercase tracking-wider text-mute", children: group }),
310
+ /* @__PURE__ */ jsxs(
311
+ "div",
312
+ {
313
+ id: optId(i),
314
+ role: "option",
315
+ "aria-selected": i === act,
316
+ onPointerMove: () => i !== act && setActive(i),
317
+ onClick: () => insert(it),
318
+ className: cx("flex h-9 cursor-pointer select-none items-center gap-2.5 rounded-lg px-2.5 text-[13.5px] transition-colors duration-100", i === act ? "bg-paper-2 text-ink" : "text-ink-2"),
319
+ children: [
320
+ person ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "grid h-5 w-5 shrink-0 place-items-center rounded-full bg-ink text-[9px] font-semibold text-paper", children: initials(it.item.label) }) : /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("grid h-5 w-5 shrink-0 place-items-center rounded-[5px]", it.kind === "/" ? "bg-ink text-paper" : "bg-paper-2 text-ink-2"), children: /* @__PURE__ */ jsx(Icon, { d: GLYPH[it.kind === "/" ? "command" : it.item.type], className: "h-3 w-3" }) }),
321
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
322
+ it.kind === "/" && "/",
323
+ it.item.label
324
+ ] }),
325
+ it.item.hint && /* @__PURE__ */ jsx("span", { className: "max-w-[45%] shrink-0 truncate text-[12px] text-mute", children: it.item.hint })
326
+ ]
327
+ }
328
+ )
329
+ ] }, `${it.kind}${it.item.id}`);
330
+ })
331
+ ]
332
+ }
333
+ ),
334
+ /* @__PURE__ */ jsxs(
335
+ "form",
336
+ {
337
+ onSubmit: (e) => {
338
+ e.preventDefault();
339
+ send();
340
+ },
341
+ onDragOver: (e) => {
342
+ if (!disabled && e.dataTransfer.types.includes("Files")) {
343
+ e.preventDefault();
344
+ setDrag(true);
345
+ }
346
+ },
347
+ onDragLeave: (e) => !e.currentTarget.contains(e.relatedTarget) && setDrag(false),
348
+ onDrop,
349
+ className: cx(
350
+ "relative flex flex-col rounded-[14px] bg-paper transition-shadow duration-200",
351
+ "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_12%,transparent),0_1px_2px_rgb(0_0_0/0.04),0_8px_24px_-16px_rgb(0_0_0/0.18)]",
352
+ !running && "focus-within:shadow-[inset_0_0_0_1px_var(--brand),0_0_0_3px_color-mix(in_srgb,var(--brand)_14%,transparent)]",
353
+ drag && "shadow-[inset_0_0_0_1.5px_var(--brand),0_0_0_4px_color-mix(in_srgb,var(--brand)_14%,transparent)]",
354
+ disabled && "opacity-50"
355
+ ),
356
+ children: [
357
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("asta-pc-ring pointer-events-none absolute -inset-px overflow-hidden rounded-[15px] p-[1.5px] transition-opacity duration-500", running ? "opacity-100" : "opacity-0"), children: /* @__PURE__ */ jsx(
358
+ "span",
359
+ {
360
+ className: "asta-pc-spin absolute left-1/2 top-1/2 aspect-square w-[220%]",
361
+ style: {
362
+ background: "conic-gradient(from 0deg, transparent 0 52%, color-mix(in srgb, var(--brand) 25%, transparent) 70%, var(--brand) 92%, transparent 100%)",
363
+ animation: `asta-pc-orbit 2.6s linear infinite ${running && onScreen ? "running" : "paused"}`,
364
+ transform: "translate(-50%, -50%)"
365
+ }
366
+ }
367
+ ) }),
368
+ files.length > 0 && /* @__PURE__ */ jsx("ul", { "aria-label": "Attached files", className: "flex flex-wrap gap-1.5 px-3 pt-3", children: files.map(({ id, file }) => /* @__PURE__ */ jsxs("li", { className: "flex h-9 max-w-full items-center gap-2 rounded-lg bg-paper-2 pl-2 pr-1 text-[12.5px]", style: { animation: `asta-pc-chip .22s ${EASE}` }, children: [
369
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "grid h-6 w-6 shrink-0 place-items-center rounded-md bg-paper text-ink-2", children: /* @__PURE__ */ jsx(Icon, { d: GLYPH.file, className: "h-3.5 w-3.5" }) }),
370
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate font-medium text-ink sm:max-w-[180px]", children: file.name }),
371
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 tabular-nums text-mute", children: size(file.size) }),
372
+ /* @__PURE__ */ jsx(
373
+ "button",
374
+ {
375
+ type: "button",
376
+ "aria-label": `Remove ${file.name}`,
377
+ onClick: () => {
378
+ setFiles((f) => f.filter((x) => x.id !== id));
379
+ setStatus(`Removed ${file.name}.`);
380
+ ed.current?.focus();
381
+ },
382
+ className: "grid h-7 w-7 shrink-0 place-items-center rounded-md text-mute outline-none transition-colors hover:bg-paper hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50",
383
+ children: /* @__PURE__ */ jsx(Icon, { d: "m4.5 4.5 7 7M11.5 4.5l-7 7", className: "h-3 w-3" })
384
+ }
385
+ )
386
+ ] }, id)) }),
387
+ /* @__PURE__ */ jsxs("div", { className: "relative px-4 pt-3.5", children: [
388
+ empty && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute left-4 top-3.5 truncate pr-4 text-[16px] leading-relaxed text-mute sm:text-[14.5px]", children: placeholder }),
389
+ /* @__PURE__ */ jsx(
390
+ "div",
391
+ {
392
+ ref: ed,
393
+ role: "textbox",
394
+ "aria-multiline": "true",
395
+ "aria-label": label,
396
+ "aria-placeholder": placeholder,
397
+ "aria-disabled": disabled || void 0,
398
+ "aria-autocomplete": "list",
399
+ "aria-controls": menu ? listId : void 0,
400
+ "aria-activedescendant": menu && items.length ? optId(act) : void 0,
401
+ contentEditable: !disabled,
402
+ suppressContentEditableWarning: true,
403
+ spellCheck: true,
404
+ enterKeyHint: "send",
405
+ onInput: () => {
406
+ sync();
407
+ detect();
408
+ },
409
+ onKeyDown: onKey,
410
+ onKeyUp: (e) => (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home" || e.key === "End") && detect(),
411
+ onClick: detect,
412
+ onBlur: () => setMenu(null),
413
+ onPaste,
414
+ className: "asta-pc-field max-h-[200px] min-h-[52px] overflow-y-auto whitespace-pre-wrap break-words pb-2 text-[16px] leading-relaxed text-ink outline-none sm:text-[14.5px] [scrollbar-width:thin]"
415
+ }
416
+ )
417
+ ] }),
418
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 px-2 pb-2", children: [
419
+ /* @__PURE__ */ jsx(
420
+ "input",
421
+ {
422
+ ref: picker,
423
+ type: "file",
424
+ multiple: true,
425
+ accept,
426
+ tabIndex: -1,
427
+ className: "sr-only",
428
+ "aria-hidden": true,
429
+ onChange: (e) => {
430
+ if (e.target.files) addFiles(e.target.files);
431
+ e.target.value = "";
432
+ }
433
+ }
434
+ ),
435
+ /* @__PURE__ */ jsx(
436
+ "button",
437
+ {
438
+ type: "button",
439
+ disabled,
440
+ "aria-label": "Attach files",
441
+ title: "Attach files",
442
+ onClick: () => picker.current?.click(),
443
+ className: "grid h-8 w-8 shrink-0 place-items-center rounded-md text-ink-2 outline-none transition-colors duration-150 hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50 disabled:opacity-45",
444
+ children: /* @__PURE__ */ jsx(Icon, { d: "M13 7.5 8.2 12.3a3 3 0 0 1-4.3-4.2l5-5a2 2 0 0 1 2.8 2.8l-5 5a1 1 0 0 1-1.4-1.4L9.8 5" })
445
+ }
446
+ ),
447
+ model,
448
+ /* @__PURE__ */ jsx("span", { className: "ml-auto" }),
449
+ running ? /* @__PURE__ */ jsxs(
450
+ "button",
451
+ {
452
+ type: "button",
453
+ onClick: onStop,
454
+ "aria-label": "Stop the agent",
455
+ className: "flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-ink pl-2.5 pr-3 text-[13px] font-medium text-paper outline-none transition-transform duration-150 active:scale-95 focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:ring-offset-2 focus-visible:ring-offset-paper",
456
+ style: { animation: `asta-pc-chip .22s ${EASE}` },
457
+ children: [
458
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-2.5 w-2.5 rounded-[2px] bg-current" }),
459
+ "Stop"
460
+ ]
461
+ },
462
+ "stop"
463
+ ) : /* @__PURE__ */ jsx(
464
+ "button",
465
+ {
466
+ type: "submit",
467
+ disabled: !canSend || disabled,
468
+ "aria-label": "Send message",
469
+ className: "grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-brand text-white outline-none transition-[opacity,transform] duration-150 active:scale-95 disabled:opacity-35 focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:ring-offset-2 focus-visible:ring-offset-paper",
470
+ style: { animation: `asta-pc-chip .22s ${EASE}` },
471
+ children: /* @__PURE__ */ jsx(Icon, { d: "M8 13V3M3.5 7.5 8 3l4.5 4.5" })
472
+ },
473
+ "send"
474
+ )
475
+ ] })
476
+ ]
477
+ }
478
+ ),
479
+ /* @__PURE__ */ jsx("p", { className: cx("mt-2 flex min-h-[18px] items-center gap-1.5 px-1 text-[12px]", error ? "font-medium text-ink" : "text-mute"), role: error ? "alert" : void 0, children: error ? /* @__PURE__ */ jsxs(Fragment, { children: [
480
+ /* @__PURE__ */ jsx(Icon, { d: "M8 2.5 14 13H2zM8 6.5v3M8 11.2h.01", className: "h-3.5 w-3.5" }),
481
+ error
482
+ ] }) : running ? "Astabyte is working. Press Esc or Stop to end the run." : /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Enter to send \xB7 Shift + Enter for a new line \xB7 @ to mention \xB7 / for commands" }) })
483
+ ] });
484
+ }
485
+ var prompt_composer_default = PromptComposer;
486
+
487
+ export {
488
+ PromptComposer,
489
+ prompt_composer_default
490
+ };