asta-ui 0.9.5 → 0.9.7

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 (144) 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/navbar.js +1 -1
  41. package/dist/base/prompt-composer.d.ts +2 -0
  42. package/dist/base/prompt-composer.js +9 -0
  43. package/dist/base/scrub-input.d.ts +2 -0
  44. package/dist/base/scrub-input.js +13 -0
  45. package/dist/base/sidebar.js +1 -1
  46. package/dist/base/thinking.d.ts +2 -0
  47. package/dist/base/thinking.js +11 -0
  48. package/dist/base/tool-approval.d.ts +2 -0
  49. package/dist/base/tool-approval.js +9 -0
  50. package/dist/base/trace-waterfall.d.ts +2 -0
  51. package/dist/base/trace-waterfall.js +9 -0
  52. package/dist/base.js +204 -136
  53. package/dist/change-ledger.d.ts +2 -0
  54. package/dist/change-ledger.js +7 -0
  55. package/dist/chunk-24O5V2PQ.js +253 -0
  56. package/dist/chunk-44DNL43W.js +490 -0
  57. package/dist/chunk-45IXJ7W7.js +245 -0
  58. package/dist/chunk-ANL6VX4X.js +326 -0
  59. package/dist/chunk-DNROUJ62.js +432 -0
  60. package/dist/{chunk-2EBWWZPS.js → chunk-DWPGFNNF.js} +38 -9
  61. package/dist/{chunk-CACW5LH3.js → chunk-EAHHWF3V.js} +38 -9
  62. package/dist/chunk-F4CWSZXK.js +226 -0
  63. package/dist/chunk-FT66LAUZ.js +388 -0
  64. package/dist/chunk-GBOJUMMY.js +163 -0
  65. package/dist/chunk-H4NFBYKY.js +275 -0
  66. package/dist/chunk-KFPGQ5RT.js +321 -0
  67. package/dist/chunk-OIIMYSVT.js +342 -0
  68. package/dist/chunk-SUWA7DM6.js +388 -0
  69. package/dist/chunk-TL32C2SQ.js +221 -0
  70. package/dist/chunk-UBTYMAKF.js +240 -0
  71. package/dist/chunk-W6YVDJHX.js +235 -0
  72. package/dist/chunk-XYQI4ZYV.js +314 -0
  73. package/dist/citations.d.ts +2 -0
  74. package/dist/citations.js +9 -0
  75. package/dist/context-meter.d.ts +2 -0
  76. package/dist/context-meter.js +14 -0
  77. package/dist/fallback-chain.d.ts +2 -0
  78. package/dist/fallback-chain.js +7 -0
  79. package/dist/index.js +204 -136
  80. package/dist/model-picker.d.ts +2 -0
  81. package/dist/model-picker.js +9 -0
  82. package/dist/navbar.js +1 -1
  83. package/dist/prompt-composer.d.ts +2 -0
  84. package/dist/prompt-composer.js +9 -0
  85. package/dist/scrub-input.d.ts +2 -0
  86. package/dist/scrub-input.js +13 -0
  87. package/dist/sidebar.js +1 -1
  88. package/dist/thinking.d.ts +2 -0
  89. package/dist/thinking.js +11 -0
  90. package/dist/tool-approval.d.ts +2 -0
  91. package/dist/tool-approval.js +9 -0
  92. package/dist/trace-waterfall.d.ts +2 -0
  93. package/dist/trace-waterfall.js +9 -0
  94. package/dist/types/components/kit/agent-plan.d.ts +34 -0
  95. package/dist/types/components/kit/api-keys.d.ts +62 -0
  96. package/dist/types/components/kit/base/navbar.d.ts +4 -1
  97. package/dist/types/components/kit/base/sidebar.d.ts +29 -7
  98. package/dist/types/components/kit/citations.d.ts +34 -0
  99. package/dist/types/components/kit/context-meter.d.ts +38 -0
  100. package/dist/types/components/kit/model-picker.d.ts +46 -0
  101. package/dist/types/components/kit/navbar.d.ts +4 -1
  102. package/dist/types/components/kit/prompt-composer.d.ts +61 -0
  103. package/dist/types/components/kit/scrub-input.d.ts +44 -0
  104. package/dist/types/components/kit/sidebar.d.ts +29 -7
  105. package/dist/types/components/kit/thinking.d.ts +28 -0
  106. package/dist/types/components/kit/tool-approval.d.ts +43 -0
  107. package/dist/types/components/kit/trace-waterfall.d.ts +44 -0
  108. package/dist/types/components/lab/blocks/AgentTeam.d.ts +2 -0
  109. package/dist/types/components/lab/blocks/AutonomyDial.d.ts +2 -0
  110. package/dist/types/components/lab/blocks/ChangeLedger.d.ts +2 -0
  111. package/dist/types/components/lab/blocks/FallbackChain.d.ts +2 -0
  112. package/dist/types/packages/asta-ui/src/agent-plan.d.ts +2 -0
  113. package/dist/types/packages/asta-ui/src/agent-team.d.ts +2 -0
  114. package/dist/types/packages/asta-ui/src/api-keys.d.ts +2 -0
  115. package/dist/types/packages/asta-ui/src/autonomy-dial.d.ts +2 -0
  116. package/dist/types/packages/asta-ui/src/base/agent-plan.d.ts +2 -0
  117. package/dist/types/packages/asta-ui/src/base/agent-team.d.ts +2 -0
  118. package/dist/types/packages/asta-ui/src/base/api-keys.d.ts +2 -0
  119. package/dist/types/packages/asta-ui/src/base/autonomy-dial.d.ts +2 -0
  120. package/dist/types/packages/asta-ui/src/base/change-ledger.d.ts +2 -0
  121. package/dist/types/packages/asta-ui/src/base/citations.d.ts +2 -0
  122. package/dist/types/packages/asta-ui/src/base/context-meter.d.ts +2 -0
  123. package/dist/types/packages/asta-ui/src/base/fallback-chain.d.ts +2 -0
  124. package/dist/types/packages/asta-ui/src/base/model-picker.d.ts +2 -0
  125. package/dist/types/packages/asta-ui/src/base/prompt-composer.d.ts +2 -0
  126. package/dist/types/packages/asta-ui/src/base/scrub-input.d.ts +2 -0
  127. package/dist/types/packages/asta-ui/src/base/thinking.d.ts +2 -0
  128. package/dist/types/packages/asta-ui/src/base/tool-approval.d.ts +2 -0
  129. package/dist/types/packages/asta-ui/src/base/trace-waterfall.d.ts +2 -0
  130. package/dist/types/packages/asta-ui/src/base.d.ts +26 -2
  131. package/dist/types/packages/asta-ui/src/change-ledger.d.ts +2 -0
  132. package/dist/types/packages/asta-ui/src/citations.d.ts +2 -0
  133. package/dist/types/packages/asta-ui/src/context-meter.d.ts +2 -0
  134. package/dist/types/packages/asta-ui/src/fallback-chain.d.ts +2 -0
  135. package/dist/types/packages/asta-ui/src/index.d.ts +26 -2
  136. package/dist/types/packages/asta-ui/src/model-picker.d.ts +2 -0
  137. package/dist/types/packages/asta-ui/src/prompt-composer.d.ts +2 -0
  138. package/dist/types/packages/asta-ui/src/scrub-input.d.ts +2 -0
  139. package/dist/types/packages/asta-ui/src/thinking.d.ts +2 -0
  140. package/dist/types/packages/asta-ui/src/tool-approval.d.ts +2 -0
  141. package/dist/types/packages/asta-ui/src/trace-waterfall.d.ts +2 -0
  142. package/package.json +1 -1
  143. package/dist/chunk-MVE7RJJ6.js +0 -322
  144. package/dist/chunk-TBMUSER2.js +0 -322
@@ -0,0 +1,388 @@
1
+ "use client";
2
+ import {
3
+ Avatar
4
+ } from "./chunk-IVCHYE55.js";
5
+
6
+ // components/kit/base/sidebar.tsx
7
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ var cx = (...c) => c.filter(Boolean).join(" ");
10
+ var EASE = "ease-[cubic-bezier(.16,1,.3,1)]";
11
+ var RING = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent)]";
12
+ var HOVER = "hover:bg-[color-mix(in_srgb,var(--ink)_4%,transparent)]";
13
+ var ON = "bg-[color-mix(in_srgb,var(--ink)_6%,transparent)]";
14
+ var Icon = ({ d, className = "" }) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: cx("h-4 w-4", className), fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
15
+ function Logo({ w, size = "sm" }) {
16
+ return /* @__PURE__ */ jsx(
17
+ "span",
18
+ {
19
+ "aria-hidden": true,
20
+ className: cx(
21
+ "flex shrink-0 items-center justify-center overflow-hidden bg-brand font-semibold text-paper [&>*]:h-full [&>*]:w-full",
22
+ size === "sm" ? "h-5 w-5 rounded-[5px] text-[11px]" : "h-7 w-7 rounded-[7px] text-[12.5px]"
23
+ ),
24
+ children: w.logo ?? w.name.charAt(0)
25
+ }
26
+ );
27
+ }
28
+ function Label({ hidden, children, className }) {
29
+ return /* @__PURE__ */ jsx(
30
+ "span",
31
+ {
32
+ className: cx(
33
+ "min-w-0 flex-1 overflow-hidden whitespace-nowrap text-left transition-[opacity,transform] duration-300",
34
+ EASE,
35
+ hidden ? "pointer-events-none -translate-x-1 opacity-0" : "translate-x-0 opacity-100 delay-75",
36
+ className
37
+ ),
38
+ children
39
+ }
40
+ );
41
+ }
42
+ function Tip({ children }) {
43
+ return /* @__PURE__ */ jsx(
44
+ "span",
45
+ {
46
+ "aria-hidden": true,
47
+ className: cx(
48
+ "pointer-events-none absolute left-[calc(100%+10px)] top-1/2 z-20 -translate-x-1 -translate-y-1/2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[12px] text-paper opacity-0 transition-[opacity,translate] duration-200",
49
+ "group-hover/item:translate-x-0 group-hover/item:opacity-100 group-focus-visible/item:translate-x-0 group-focus-visible/item:opacity-100",
50
+ EASE
51
+ ),
52
+ children
53
+ }
54
+ );
55
+ }
56
+ var itemCls = "group/item relative flex h-9 w-full items-center rounded-lg text-[14px] outline-none transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-brand/50";
57
+ function Row({ it, on, collapsed, onClick, flat }) {
58
+ return /* @__PURE__ */ jsxs(
59
+ "button",
60
+ {
61
+ type: "button",
62
+ "data-sb-id": flat ? void 0 : it.id,
63
+ "aria-current": on ? "page" : void 0,
64
+ "aria-label": collapsed ? it.label : void 0,
65
+ onClick,
66
+ className: cx(itemCls, on ? cx("text-ink", flat && ON) : cx("text-ink-2 hover:text-ink", HOVER)),
67
+ children: [
68
+ /* @__PURE__ */ jsxs("span", { className: cx("relative flex w-10 shrink-0 justify-center transition-colors duration-200 [&_svg]:h-[18px] [&_svg]:w-[18px]", on ? "text-ink" : "text-mute group-hover/item:text-ink"), children: [
69
+ it.icon,
70
+ !!it.badge && /* @__PURE__ */ jsx(
71
+ "span",
72
+ {
73
+ className: cx(
74
+ "absolute right-2 top-0 h-1.5 w-1.5 rounded-full bg-brand shadow-[0_0_0_2px_var(--paper-2)] transition-[opacity,transform] duration-300",
75
+ EASE,
76
+ collapsed ? "scale-100 opacity-100" : "scale-50 opacity-0"
77
+ )
78
+ }
79
+ )
80
+ ] }),
81
+ /* @__PURE__ */ jsx(Label, { hidden: collapsed, className: "relative", children: it.label }),
82
+ !!it.badge && /* @__PURE__ */ jsx(
83
+ "span",
84
+ {
85
+ className: cx(
86
+ "relative mr-2 rounded-md bg-[color-mix(in_srgb,var(--ink)_6%,transparent)] px-1.5 text-[11.5px] tabular-nums leading-5 text-mute transition-opacity duration-300",
87
+ collapsed ? "opacity-0" : "opacity-100"
88
+ ),
89
+ children: it.badge
90
+ }
91
+ ),
92
+ collapsed && /* @__PURE__ */ jsx(Tip, { children: it.label })
93
+ ]
94
+ }
95
+ );
96
+ }
97
+ function Sidebar({
98
+ brand,
99
+ groups,
100
+ footer = [],
101
+ promo,
102
+ cta,
103
+ workspaces = [],
104
+ defaultWorkspace,
105
+ onWorkspaceChange,
106
+ active: activeProp,
107
+ defaultActive,
108
+ onNavigate,
109
+ collapsed: collapsedProp,
110
+ defaultCollapsed = false,
111
+ onCollapsedChange,
112
+ user,
113
+ className
114
+ }) {
115
+ const [activeState, setActive] = useState(defaultActive ?? groups[0]?.items[0]?.id ?? "");
116
+ const [collapsedState, setCollapsed] = useState(defaultCollapsed);
117
+ const [workspace, setWorkspace] = useState(defaultWorkspace ?? workspaces[0]?.id);
118
+ const [menu, setMenu] = useState(false);
119
+ const [promoOpen, setPromoOpen] = useState(true);
120
+ const active = activeProp ?? activeState;
121
+ const collapsed = collapsedProp ?? collapsedState;
122
+ const current = workspaces.find((w) => w.id === workspace) ?? workspaces[0];
123
+ const nav = useRef(null);
124
+ const indicator = useRef(null);
125
+ const placed = useRef(false);
126
+ const switcher = useRef(null);
127
+ const trigger = useRef(null);
128
+ useLayoutEffect(() => {
129
+ const ind = indicator.current;
130
+ const el = nav.current?.querySelector(`[data-sb-id="${CSS.escape(active)}"]`);
131
+ if (!ind) return;
132
+ if (!el) {
133
+ ind.style.opacity = "0";
134
+ return;
135
+ }
136
+ if (!placed.current) ind.style.transition = "none";
137
+ ind.style.transform = `translateY(${el.offsetTop}px)`;
138
+ ind.style.opacity = "1";
139
+ if (!placed.current) {
140
+ void ind.offsetHeight;
141
+ ind.style.transition = "";
142
+ placed.current = true;
143
+ }
144
+ }, [active]);
145
+ useEffect(() => {
146
+ if (!menu) return;
147
+ switcher.current?.querySelector("[role=menuitemradio][aria-checked=true]")?.focus();
148
+ const down = (e) => {
149
+ if (!switcher.current?.contains(e.target)) setMenu(false);
150
+ };
151
+ document.addEventListener("pointerdown", down);
152
+ return () => document.removeEventListener("pointerdown", down);
153
+ }, [menu]);
154
+ const navigate = (id) => {
155
+ setActive(id);
156
+ onNavigate?.(id);
157
+ };
158
+ const toggle = () => {
159
+ setCollapsed(!collapsed);
160
+ onCollapsedChange?.(!collapsed);
161
+ };
162
+ const pick = (id) => {
163
+ setWorkspace(id);
164
+ onWorkspaceChange?.(id);
165
+ setMenu(false);
166
+ trigger.current?.focus();
167
+ };
168
+ const rove = (e, selector, root) => {
169
+ const els = [...root?.querySelectorAll(selector) ?? []];
170
+ const i = els.indexOf(document.activeElement);
171
+ const next = { ArrowDown: i + 1, ArrowUp: i - 1, Home: 0, End: els.length - 1 }[e.key];
172
+ if (next === void 0 || !els.length) return;
173
+ e.preventDefault();
174
+ els[(next + els.length) % els.length]?.focus();
175
+ };
176
+ return /* @__PURE__ */ jsxs(
177
+ "aside",
178
+ {
179
+ "aria-label": "Sidebar",
180
+ "data-collapsed": collapsed || void 0,
181
+ className: cx(
182
+ "relative flex h-full shrink-0 flex-col bg-paper-2 px-3 py-3 shadow-[inset_-1px_0_0_color-mix(in_srgb,var(--ink)_8%,transparent)] transition-[width] duration-500",
183
+ EASE,
184
+ collapsed ? "w-16" : "w-[248px]",
185
+ className
186
+ ),
187
+ children: [
188
+ /* @__PURE__ */ jsx("style", { href: "asta-sidebar", precedence: "asta", children: `
189
+ @keyframes kit-sb-pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
190
+ @keyframes kit-sb-fade { from { opacity: 0; } to { opacity: 1; } }
191
+ @media (prefers-reduced-motion: reduce) { .kit-sb, .kit-sb * { animation: none !important; transition-duration: 0s !important; } }
192
+ ` }),
193
+ /* @__PURE__ */ jsxs("div", { className: "kit-sb flex min-h-0 flex-1 flex-col", children: [
194
+ /* @__PURE__ */ jsxs("div", { className: "flex h-11 shrink-0 items-center", children: [
195
+ /* @__PURE__ */ jsx(Label, { hidden: collapsed, className: "pl-3 text-[19px] font-semibold tracking-[-0.03em] text-ink", children: brand ?? current?.name }),
196
+ /* @__PURE__ */ jsxs(
197
+ "button",
198
+ {
199
+ type: "button",
200
+ "aria-pressed": collapsed,
201
+ "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
202
+ onClick: toggle,
203
+ className: cx(
204
+ "group/item relative flex h-9 w-10 shrink-0 items-center justify-center rounded-lg text-mute outline-none transition-colors duration-200 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50",
205
+ HOVER
206
+ ),
207
+ children: [
208
+ /* @__PURE__ */ jsx(Icon, { d: "M2.5 3.5h11v9h-11zM6 3.5v9M10.5 6.5 9 8l1.5 1.5", className: cx("transition-transform duration-500", EASE, collapsed && "-scale-x-100") }),
209
+ collapsed && /* @__PURE__ */ jsx(Tip, { children: "Expand" })
210
+ ]
211
+ }
212
+ )
213
+ ] }),
214
+ /* @__PURE__ */ jsx(
215
+ "nav",
216
+ {
217
+ "aria-label": "Main",
218
+ className: cx("-mx-1 mt-3 min-h-0 flex-1 px-1 [scrollbar-width:none]", collapsed ? "overflow-visible" : "overflow-y-auto overscroll-contain [mask-image:linear-gradient(to_bottom,black_calc(100%-20px),transparent)]"),
219
+ onKeyDown: (e) => rove(e, "[data-sb-id]", nav.current),
220
+ children: /* @__PURE__ */ jsxs("div", { ref: nav, className: "relative pb-2", children: [
221
+ /* @__PURE__ */ jsx(
222
+ "span",
223
+ {
224
+ ref: indicator,
225
+ "aria-hidden": true,
226
+ className: cx("absolute inset-x-0 top-0 h-9 rounded-lg opacity-0 transition-[transform,opacity] duration-500", ON, EASE)
227
+ }
228
+ ),
229
+ groups.map((g, gi) => /* @__PURE__ */ jsxs("div", { className: cx(gi > 0 && "mt-5"), children: [
230
+ g.label && /* @__PURE__ */ jsxs("div", { className: "relative flex h-8 items-center px-3", "aria-hidden": collapsed || void 0, children: [
231
+ /* @__PURE__ */ jsx("span", { className: cx("text-[13px] text-mute transition-opacity duration-300", collapsed ? "opacity-0" : "opacity-100"), children: g.label }),
232
+ /* @__PURE__ */ jsx(
233
+ "span",
234
+ {
235
+ className: cx(
236
+ "absolute left-1/2 h-px w-3 -translate-x-1/2 bg-[color-mix(in_srgb,var(--ink)_14%,transparent)] transition-opacity duration-300",
237
+ collapsed ? "opacity-100" : "opacity-0"
238
+ )
239
+ }
240
+ )
241
+ ] }),
242
+ /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-0.5", children: g.items.map((it) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Row, { it, on: it.id === active, collapsed, onClick: () => navigate(it.id) }) }, it.id)) })
243
+ ] }, g.label ?? gi))
244
+ ] })
245
+ }
246
+ ),
247
+ promo && promoOpen && !collapsed && /* @__PURE__ */ jsxs(
248
+ "div",
249
+ {
250
+ className: cx("group/promo relative mt-3 min-w-[222px] shrink-0 rounded-xl bg-paper p-4", RING, promo.onClick && "transition-colors hover:bg-[color-mix(in_srgb,var(--ink)_2%,var(--paper))]"),
251
+ style: { animation: "kit-sb-fade .3s .25s cubic-bezier(.16,1,.3,1) both" },
252
+ children: [
253
+ promo.icon && /* @__PURE__ */ jsx("span", { className: "mb-3 flex h-8 w-8 items-center justify-center rounded-full bg-paper-2 text-mute [&_svg]:h-4 [&_svg]:w-4", children: promo.icon }),
254
+ promo.onClick ? /* @__PURE__ */ jsx("button", { type: "button", onClick: promo.onClick, className: "block text-left text-[14px] font-medium text-ink outline-none after:absolute after:inset-0 after:rounded-xl focus-visible:after:ring-2 focus-visible:after:ring-brand/50", children: promo.title }) : /* @__PURE__ */ jsx("p", { className: "text-[14px] font-medium text-ink", children: promo.title }),
255
+ promo.text && /* @__PURE__ */ jsx("p", { className: "mt-1 text-[13px] leading-snug text-mute", children: promo.text }),
256
+ promo.onDismiss && /* @__PURE__ */ jsx(
257
+ "button",
258
+ {
259
+ type: "button",
260
+ "aria-label": `Dismiss ${promo.title}`,
261
+ onClick: () => {
262
+ setPromoOpen(false);
263
+ promo.onDismiss?.();
264
+ },
265
+ className: "absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center rounded-md text-mute outline-none transition-colors hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50",
266
+ children: /* @__PURE__ */ jsx(Icon, { d: "M4.5 4.5l7 7M11.5 4.5l-7 7", className: "h-3.5 w-3.5" })
267
+ }
268
+ )
269
+ ]
270
+ }
271
+ ),
272
+ footer.length > 0 && /* @__PURE__ */ jsx("ul", { className: "mt-2 flex shrink-0 flex-col gap-0.5", children: footer.map((it) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Row, { it, on: it.id === active, collapsed, onClick: () => navigate(it.id), flat: true }) }, it.id)) }),
273
+ cta && /* @__PURE__ */ jsxs(
274
+ "button",
275
+ {
276
+ type: "button",
277
+ onClick: cta.onClick,
278
+ "aria-label": collapsed ? cta.label : void 0,
279
+ className: cx(itemCls, "mt-2 h-10 shrink-0 overflow-visible bg-paper font-medium text-ink", RING, "hover:bg-[color-mix(in_srgb,var(--ink)_3%,var(--paper))]"),
280
+ children: [
281
+ /* @__PURE__ */ jsx(
282
+ "span",
283
+ {
284
+ "aria-hidden": true,
285
+ className: cx(
286
+ "pointer-events-none absolute inset-y-0 right-0 w-3/5 rounded-r-lg bg-[repeating-linear-gradient(-45deg,color-mix(in_srgb,var(--ink)_9%,transparent)_0_1px,transparent_1px_6px)] [mask-image:linear-gradient(to_right,transparent,black)] transition-opacity duration-300",
287
+ collapsed ? "opacity-0" : "opacity-100"
288
+ )
289
+ }
290
+ ),
291
+ /* @__PURE__ */ jsx("span", { className: "relative flex w-10 shrink-0 justify-center", children: /* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-ink text-paper [&_svg]:h-3 [&_svg]:w-3", children: cta.icon ?? /* @__PURE__ */ jsx(Icon, { d: "M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z" }) }) }),
292
+ /* @__PURE__ */ jsx(Label, { hidden: collapsed, className: "relative", children: /* @__PURE__ */ jsx("span", { className: "block text-center", children: cta.label }) }),
293
+ !collapsed && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "w-10 shrink-0" }),
294
+ collapsed && /* @__PURE__ */ jsx(Tip, { children: cta.label })
295
+ ]
296
+ }
297
+ ),
298
+ current && /* @__PURE__ */ jsxs("div", { ref: switcher, className: "relative mt-2 shrink-0", children: [
299
+ /* @__PURE__ */ jsxs(
300
+ "button",
301
+ {
302
+ ref: trigger,
303
+ type: "button",
304
+ "aria-haspopup": "menu",
305
+ "aria-expanded": menu,
306
+ "aria-label": collapsed ? `Workspace: ${current.name}` : void 0,
307
+ onClick: () => setMenu((v) => !v),
308
+ onKeyDown: (e) => {
309
+ if (e.key === "ArrowUp" && !menu) {
310
+ e.preventDefault();
311
+ setMenu(true);
312
+ }
313
+ },
314
+ className: cx(itemCls, "h-10 text-ink", HOVER, "aria-expanded:bg-[color-mix(in_srgb,var(--ink)_5%,transparent)]"),
315
+ children: [
316
+ /* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: /* @__PURE__ */ jsx(Logo, { w: current }) }),
317
+ /* @__PURE__ */ jsx(Label, { hidden: collapsed, className: "truncate", children: current.name }),
318
+ /* @__PURE__ */ jsx(
319
+ Icon,
320
+ {
321
+ d: "m5.5 6 2.5-2.5L10.5 6M5.5 10l2.5 2.5 2.5-2.5",
322
+ className: cx("mr-2 shrink-0 text-mute transition-opacity duration-300", collapsed ? "opacity-0" : "opacity-100")
323
+ }
324
+ ),
325
+ collapsed && /* @__PURE__ */ jsx(Tip, { children: current.name })
326
+ ]
327
+ }
328
+ ),
329
+ menu && /* @__PURE__ */ jsxs(
330
+ "div",
331
+ {
332
+ role: "menu",
333
+ "aria-label": "Switch workspace",
334
+ onKeyDown: (e) => {
335
+ if (e.key === "Escape" || e.key === "Tab") {
336
+ if (e.key === "Escape") e.preventDefault();
337
+ setMenu(false);
338
+ trigger.current?.focus();
339
+ } else rove(e, "[role=menuitemradio]", e.currentTarget);
340
+ },
341
+ className: "absolute bottom-[calc(100%+6px)] left-0 z-30 w-[232px] origin-bottom-left rounded-xl bg-paper p-1.5 shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent),0_16px_36px_-14px_rgb(0_0_0/0.3)]",
342
+ style: { animation: "kit-sb-pop .28s cubic-bezier(.16,1,.3,1) both" },
343
+ children: [
344
+ /* @__PURE__ */ jsx("p", { className: "px-2 pb-1.5 pt-1 text-[11.5px] text-mute", children: "Workspaces" }),
345
+ workspaces.map((w) => {
346
+ const on = w.id === current.id;
347
+ return /* @__PURE__ */ jsxs(
348
+ "button",
349
+ {
350
+ type: "button",
351
+ role: "menuitemradio",
352
+ "aria-checked": on,
353
+ onClick: () => pick(w.id),
354
+ className: "flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 text-left outline-none transition-colors hover:bg-paper-2 focus-visible:bg-paper-2",
355
+ children: [
356
+ /* @__PURE__ */ jsx(Logo, { w, size: "md" }),
357
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col leading-tight", children: [
358
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[13.5px] text-ink", children: w.name }),
359
+ w.plan && /* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: w.plan })
360
+ ] }),
361
+ on && /* @__PURE__ */ jsx(Icon, { d: "M3.5 8.5l3 3 6-7", className: "shrink-0 text-brand" })
362
+ ]
363
+ },
364
+ w.id
365
+ );
366
+ })
367
+ ]
368
+ }
369
+ )
370
+ ] }),
371
+ user && /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-12 shrink-0 items-center rounded-lg", children: [
372
+ /* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: /* @__PURE__ */ jsx(Avatar, { name: user.name, src: user.src, size: "sm" }) }),
373
+ /* @__PURE__ */ jsxs(Label, { hidden: collapsed, className: "flex flex-col pl-1 leading-tight", children: [
374
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[13px] font-medium text-ink", children: user.name }),
375
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: user.email })
376
+ ] })
377
+ ] })
378
+ ] })
379
+ ]
380
+ }
381
+ );
382
+ }
383
+ var sidebar_default = Sidebar;
384
+
385
+ export {
386
+ Sidebar,
387
+ sidebar_default
388
+ };
@@ -0,0 +1,221 @@
1
+ "use client";
2
+
3
+ // components/lab/blocks/AgentTeam.tsx
4
+ import { useEffect, useRef, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ var EASE = "cubic-bezier(.16,1,.3,1)";
7
+ var RING = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent)]";
8
+ var LINE = "bg-[color-mix(in_srgb,var(--ink)_16%,transparent)]";
9
+ var GOAL = "Draft the Q3 launch brief";
10
+ var AGENTS = [
11
+ { role: "Research", task: "Compare pricing on 6 rival sites", unit: "sources", total: 6, end: 3300, found: "Rivals charge 12\u201318% more for teams" },
12
+ { role: "Data", task: "Pull trial-to-paid for Q3", unit: "queries", total: 4, end: 2300, found: "Trial-to-paid reached 9.4% in October" },
13
+ { role: "Writing", task: "Draft the headline and key messages", unit: "drafts", total: 3, end: 4300, found: "Headline plus 3 key messages drafted" }
14
+ ];
15
+ var INIT = { phase: "plan", prog: AGENTS.map(() => 0), done: [] };
16
+ var STEPS = (() => {
17
+ const events = [{ at: 1e3, f: (s) => ({ ...s, phase: "split" }) }];
18
+ const WORK = 1500;
19
+ AGENTS.forEach((a, i) => {
20
+ for (let k = 1; k <= a.total; k++)
21
+ events.push({ at: WORK + a.end * k / a.total, f: (s) => ({ ...s, prog: s.prog.map((p, j) => j === i ? k : p) }) });
22
+ events.push({ at: WORK + a.end + 450, f: (s) => ({ ...s, done: [...s.done, i] }) });
23
+ });
24
+ const last = Math.max(...events.map((e) => e.at));
25
+ events.push({ at: last + 900, f: (s) => ({ ...s, phase: "merge" }) });
26
+ events.sort((a, b) => a.at - b.at);
27
+ return events.map((e, i) => [e.at - (i ? events[i - 1].at : 0), e.f]);
28
+ })();
29
+ var Check = ({ className = "" }) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className, fill: "none", stroke: "currentColor", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M3.5 8.5l3 3 6-7" }) });
30
+ function AgentTeam() {
31
+ const [s, setS] = useState(INIT);
32
+ const [fade, setFade] = useState(false);
33
+ const [hover, setHover] = useState(false);
34
+ const [focusIn, setFocusIn] = useState(false);
35
+ const [visible, setVisible] = useState(true);
36
+ const [run, setRun] = useState(0);
37
+ const root = useRef(null);
38
+ const k = useRef(0);
39
+ const paused = hover || focusIn || !visible;
40
+ useEffect(() => {
41
+ const el = root.current;
42
+ if (!el) return;
43
+ let seen = true;
44
+ const sync = () => setVisible(seen && !document.hidden);
45
+ const io = new IntersectionObserver(([e]) => {
46
+ seen = e.isIntersecting;
47
+ sync();
48
+ });
49
+ io.observe(el);
50
+ document.addEventListener("visibilitychange", sync);
51
+ return () => {
52
+ io.disconnect();
53
+ document.removeEventListener("visibilitychange", sync);
54
+ };
55
+ }, []);
56
+ useEffect(() => {
57
+ if (paused) return;
58
+ const t = [];
59
+ let alive = true;
60
+ const later = (ms, f) => t.push(setTimeout(() => alive && f(), ms));
61
+ const step = () => {
62
+ if (k.current >= STEPS.length) {
63
+ later(4200, () => setFade(true));
64
+ later(4700, () => {
65
+ k.current = 0;
66
+ setS(INIT);
67
+ });
68
+ later(4800, () => setFade(false));
69
+ later(5e3, step);
70
+ return;
71
+ }
72
+ const [wait, f] = STEPS[k.current];
73
+ later(wait, () => {
74
+ k.current++;
75
+ setS(f);
76
+ step();
77
+ });
78
+ };
79
+ step();
80
+ return () => {
81
+ alive = false;
82
+ t.forEach(clearTimeout);
83
+ };
84
+ }, [paused, run]);
85
+ const restart = () => {
86
+ k.current = 0;
87
+ setS(INIT);
88
+ setHover(false);
89
+ setFocusIn(false);
90
+ root.current?.focus();
91
+ setRun((r) => r + 1);
92
+ };
93
+ const toggle = () => setHover((h) => !h);
94
+ const out = s.phase !== "plan";
95
+ const merged = s.phase === "merge";
96
+ const running = AGENTS.length - s.done.length;
97
+ const status = s.phase === "plan" ? "Planning" : merged ? "Done \xB7 41 s" : s.done.length ? `${s.done.length} of 3 reported` : "3 running";
98
+ return /* @__PURE__ */ jsxs(
99
+ "div",
100
+ {
101
+ ref: root,
102
+ role: "group",
103
+ tabIndex: 0,
104
+ "aria-label": `Agent team. Goal: ${GOAL}. ${status}. ${hover ? "Paused" : "Live"}. Press space to ${hover ? "resume" : "pause"}`,
105
+ onPointerEnter: (e) => e.pointerType === "mouse" && setHover(true),
106
+ onPointerLeave: (e) => e.pointerType === "mouse" && setHover(false),
107
+ onPointerUp: (e) => e.pointerType !== "mouse" && !e.target.closest("button") && toggle(),
108
+ onFocus: (e) => setFocusIn(e.target !== e.currentTarget),
109
+ onBlur: (e) => !e.currentTarget.contains(e.relatedTarget) && setFocusIn(false),
110
+ onKeyDown: (e) => {
111
+ if (e.target === e.currentTarget && (e.key === " " || e.key === "Enter")) {
112
+ e.preventDefault();
113
+ toggle();
114
+ }
115
+ },
116
+ className: "flex h-full w-full items-center justify-center px-5 pb-5 pt-11 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand/50",
117
+ style: { containerType: "size" },
118
+ children: [
119
+ /* @__PURE__ */ jsx("style", { href: "asta-agentteam", precedence: "asta", children: `
120
+ @keyframes lab-at-dot { 0%, 100% { opacity: .25 } 40% { opacity: 1 } }
121
+ @keyframes lab-at-pop { from { transform: scale(.9); opacity: 0 } to { transform: none; opacity: 1 } }
122
+ @keyframes lab-at-in { from { transform: translateY(6px); opacity: 0 } to { transform: none; opacity: 1 } }
123
+ .lab-at-dot { animation: lab-at-dot 1.1s ${EASE} infinite }
124
+ .lab-at-pop { animation: lab-at-pop .45s ${EASE} both }
125
+ .lab-at-in { animation: lab-at-in .5s ${EASE} both }
126
+ @media (prefers-reduced-motion: reduce) { .lab-at-dot, .lab-at-pop, .lab-at-in { animation: none } .lab-at-move { transition: none !important } }
127
+ ` }),
128
+ /* @__PURE__ */ jsxs(
129
+ "div",
130
+ {
131
+ className: `flex w-full max-w-[520px] flex-col rounded-[14px] bg-paper p-[clamp(10px,3.4cqmin,16px)] ${RING} shadow-[0_18px_40px_-28px_rgb(0_0_0/0.35)]`,
132
+ style: { opacity: fade ? 0 : 1, transition: `opacity .45s ${EASE}` },
133
+ children: [
134
+ /* @__PURE__ */ jsxs("div", { className: "relative z-10 flex items-center gap-2.5 rounded-[11px] bg-paper-2 p-[clamp(8px,2.6cqmin,11px)]", children: [
135
+ /* @__PURE__ */ jsx("span", { className: "grid h-8 w-8 shrink-0 place-items-center rounded-[8px] bg-brand text-paper", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-4 w-4", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M8 1.5c.4 3.2 1.4 4.6 4.8 5.2v.6C9.4 7.9 8.4 9.3 8 12.5h-.1c-.4-3.2-1.4-4.6-4.8-5.2v-.6C6.5 6.1 7.5 4.7 7.9 1.5zM12.6 10.5c.2 1.4.7 2 2 2.3-1.3.3-1.8.9-2 2.3-.2-1.4-.7-2-2-2.3 1.3-.3 1.8-.9 2-2.3z" }) }) }),
136
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 leading-tight", children: [
137
+ /* @__PURE__ */ jsx("span", { className: "block text-[11px] text-mute", children: "Lead agent" }),
138
+ /* @__PURE__ */ jsx("span", { className: "block truncate text-[13.5px] font-medium tracking-[-0.01em] text-ink", children: GOAL })
139
+ ] }),
140
+ /* @__PURE__ */ jsxs(
141
+ "span",
142
+ {
143
+ className: `lab-at-pop flex shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-[11px] tabular-nums ${merged ? "bg-brand text-paper" : "bg-paper text-ink-2"}`,
144
+ "aria-live": "polite",
145
+ children: [
146
+ s.phase === "plan" && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "flex gap-[3px]", children: [0, 1, 2].map((d) => /* @__PURE__ */ jsx("span", { className: "lab-at-dot h-1 w-1 rounded-full bg-current", style: { animationDelay: `${d * 160}ms` } }, d)) }),
147
+ merged && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }),
148
+ status
149
+ ]
150
+ },
151
+ status
152
+ )
153
+ ] }),
154
+ /* @__PURE__ */ jsxs("div", { className: "relative h-[clamp(12px,4.5cqh,22px)]", "aria-hidden": true, children: [
155
+ /* @__PURE__ */ jsx("span", { className: `lab-at-move absolute left-1/2 top-0 h-1/2 w-px origin-top ${LINE}`, style: { transform: `scaleY(${out && !merged ? 1 : 0})`, transition: `transform .35s ${EASE}` } }),
156
+ /* @__PURE__ */ jsx("span", { className: `lab-at-move absolute left-[16.67%] right-[16.67%] top-1/2 h-px ${LINE}`, style: { transform: `scaleX(${out && !merged ? 1 : 0})`, transition: `transform .45s ${EASE} ${out && !merged ? ".12s" : "0s"}` } }),
157
+ AGENTS.map((a, i) => /* @__PURE__ */ jsxs("span", { className: "absolute top-1/2 h-1/2 w-px", style: { left: `${16.67 + i * 33.33}%` }, children: [
158
+ /* @__PURE__ */ jsx("span", { className: `lab-at-move absolute inset-0 origin-top ${LINE}`, style: { transform: `scaleY(${out && !merged ? 1 : 0})`, transition: `transform .3s ${EASE} ${out && !merged ? ".3s" : "0s"}` } }),
159
+ /* @__PURE__ */ jsx("span", { className: "lab-at-move absolute inset-0 origin-bottom bg-brand", style: { transform: `scaleY(${s.done.includes(i) && !merged ? 1 : 0})`, transition: `transform .4s ${EASE}` } })
160
+ ] }, a.role))
161
+ ] }),
162
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
163
+ /* @__PURE__ */ jsx("ol", { className: "grid min-h-[100px] grid-cols-3 gap-[clamp(6px,2cqw,10px)]", "aria-label": "Subagents", children: AGENTS.map((a, i) => {
164
+ const done = s.done.includes(i);
165
+ const p = s.prog[i] / a.total;
166
+ const shown = out && !merged;
167
+ return /* @__PURE__ */ jsxs(
168
+ "li",
169
+ {
170
+ className: `lab-at-move flex min-w-0 flex-col gap-[max(4px,1.4cqh)] rounded-[11px] bg-paper p-[clamp(7px,2.4cqmin,11px)] ${RING}`,
171
+ style: {
172
+ transform: shown ? "none" : `translate(${(1 - i) * 100}%, ${merged ? "-40%" : "-55%"}) scale(.9)`,
173
+ opacity: shown ? 1 : 0,
174
+ transition: `transform .6s ${EASE} ${shown ? `${i * 70}ms` : "0ms"}, opacity .45s ${EASE} ${shown ? `${i * 70}ms` : "0ms"}`
175
+ },
176
+ children: [
177
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-1", children: [
178
+ /* @__PURE__ */ jsx("span", { className: "truncate font-mono text-[10px] uppercase tracking-wider text-ink-2", children: a.role }),
179
+ /* @__PURE__ */ jsx("span", { className: `grid h-3.5 w-3.5 shrink-0 place-items-center rounded-full ${done ? "bg-brand text-paper" : RING}`, style: { transition: `background-color .3s ${EASE}` }, children: done && /* @__PURE__ */ jsx(Check, { className: "lab-at-pop h-2 w-2" }) })
180
+ ] }),
181
+ /* @__PURE__ */ jsx("span", { className: "line-clamp-2 text-[12px] leading-snug text-ink", children: a.task }),
182
+ /* @__PURE__ */ jsxs("span", { className: "mt-auto flex flex-col gap-1", children: [
183
+ /* @__PURE__ */ jsx("span", { className: "h-1 overflow-hidden rounded-full bg-paper-2", children: /* @__PURE__ */ jsx("span", { className: "lab-at-move block h-full origin-left rounded-full bg-brand", style: { transform: `scaleX(${p})`, transition: `transform .5s ${EASE}` } }) }),
184
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[10.5px] tabular-nums text-mute", children: done ? "Reported" : `${s.prog[i]}/${a.total} ${a.unit}` })
185
+ ] })
186
+ ]
187
+ },
188
+ a.role
189
+ );
190
+ }) }),
191
+ merged && /* @__PURE__ */ jsxs("div", { className: "lab-at-pop absolute inset-0 flex flex-col gap-[max(4px,1.2cqh)] rounded-[11px] bg-paper p-[clamp(8px,2.6cqmin,12px)] shadow-[inset_0_0_0_1.5px_var(--brand),0_14px_30px_-20px_rgb(0_0_0/0.5)]", children: [
192
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
193
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[13px] font-medium tracking-[-0.01em] text-ink", children: "Launch brief ready" }),
194
+ /* @__PURE__ */ jsx(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ onClick: restart,
199
+ className: "shrink-0 rounded-[7px] bg-paper-2 px-2 py-1 text-[11px] font-medium text-ink outline-none hover:bg-[color-mix(in_srgb,var(--ink)_10%,var(--paper-2))] focus-visible:ring-2 focus-visible:ring-brand/60",
200
+ children: "Run it again"
201
+ }
202
+ )
203
+ ] }),
204
+ /* @__PURE__ */ jsx("ul", { className: "flex min-h-0 flex-col gap-[max(2px,0.8cqh)]", children: s.done.map((i, n) => /* @__PURE__ */ jsxs("li", { className: "lab-at-in flex min-w-0 items-baseline gap-2 text-[11.5px] leading-snug", style: { animationDelay: `${120 + n * 90}ms` }, children: [
205
+ /* @__PURE__ */ jsx("span", { className: "w-[54px] shrink-0 font-mono text-[9.5px] uppercase tracking-wider text-mute", children: AGENTS[i].role }),
206
+ /* @__PURE__ */ jsx("span", { className: "truncate text-ink", children: AGENTS[i].found })
207
+ ] }, i)) })
208
+ ] })
209
+ ] }),
210
+ /* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: merged ? "All three reports merged into the summary" : running < 3 ? `${s.done.length} of 3 subagents reported` : "" })
211
+ ]
212
+ }
213
+ )
214
+ ]
215
+ }
216
+ );
217
+ }
218
+
219
+ export {
220
+ AgentTeam
221
+ };