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-6RA7LJ3K.js";
5
+
6
+ // components/kit/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,163 @@
1
+ "use client";
2
+
3
+ // components/kit/thinking.tsx
4
+ import { useEffect, useId, useRef, useState } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ var cx = (...c) => c.filter(Boolean).join(" ");
7
+ var CURVE = "cubic-bezier(.16,1,.3,1)";
8
+ var MASK = "linear-gradient(90deg, transparent 32%, #000 50%, transparent 68%)";
9
+ var KEYFRAMES = `@keyframes asta-thinking-sweep { from { transform: translateX(-100%) } 70%, to { transform: translateX(100%) } }
10
+ @keyframes asta-thinking-counter { from { transform: translateX(100%) } 70%, to { transform: translateX(-100%) } }
11
+ @keyframes asta-thinking-in { from { opacity: 0; transform: translateY(4px) } }
12
+ @keyframes asta-thinking-pulse { 0%, 100% { opacity: .4 } 50% { opacity: 1 } }
13
+ @media (prefers-reduced-motion: reduce) { .asta-thinking-a, .asta-thinking-a * { animation: none !important; transition-duration: 0s !important } .asta-thinking-shine { display: none } }`;
14
+ var formatThinkingTime = (s) => s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${String(s % 60).padStart(2, "0")}s`;
15
+ function useElapsed(running, el) {
16
+ const [secs, setSecs] = useState(0);
17
+ const start = useRef(null);
18
+ useEffect(() => {
19
+ if (!running) return;
20
+ if (start.current === null) start.current = Date.now();
21
+ const node = el.current;
22
+ let seen = true;
23
+ let timer;
24
+ const tick = () => setSecs(Math.floor((Date.now() - (start.current ?? Date.now())) / 1e3));
25
+ const sync = () => {
26
+ clearInterval(timer);
27
+ timer = void 0;
28
+ tick();
29
+ if (seen && !document.hidden) timer = setInterval(tick, 1e3);
30
+ };
31
+ const io = node ? new IntersectionObserver(([e]) => {
32
+ seen = e.isIntersecting;
33
+ sync();
34
+ }) : null;
35
+ if (node) io?.observe(node);
36
+ document.addEventListener("visibilitychange", sync);
37
+ sync();
38
+ return () => {
39
+ clearInterval(timer);
40
+ io?.disconnect();
41
+ document.removeEventListener("visibilitychange", sync);
42
+ tick();
43
+ };
44
+ }, [running, el]);
45
+ useEffect(() => {
46
+ if (running) return;
47
+ return () => {
48
+ start.current = null;
49
+ };
50
+ }, [running]);
51
+ return secs;
52
+ }
53
+ function Shimmer({ text, on }) {
54
+ return /* @__PURE__ */ jsxs("span", { className: cx("relative inline-block truncate", on ? "text-mute" : "text-ink"), children: [
55
+ text,
56
+ on && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "asta-thinking-shine pointer-events-none absolute inset-0 overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "absolute inset-0 animate-[asta-thinking-sweep_2.2s_linear_infinite]", style: { maskImage: MASK, WebkitMaskImage: MASK }, children: /* @__PURE__ */ jsx("span", { className: "absolute inset-0 animate-[asta-thinking-counter_2.2s_linear_infinite] whitespace-nowrap text-ink", children: text }) }) })
57
+ ] });
58
+ }
59
+ function Spark({ live, className }) {
60
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", className: cx(className, "shrink-0", live ? "animate-[asta-thinking-pulse_1.6s_ease-in-out_infinite] text-brand" : "text-mute"), fill: "currentColor", "aria-hidden": true, children: [
61
+ /* @__PURE__ */ jsx("path", { d: "M8 1.5c.4 2.9 1.6 4.1 4.5 4.5-2.9.4-4.1 1.6-4.5 4.5-.4-2.9-1.6-4.1-4.5-4.5C6.4 5.6 7.6 4.4 8 1.5Z" }),
62
+ /* @__PURE__ */ jsx("path", { d: "M12.5 10c.2 1.4.8 2 2.2 2.2-1.4.2-2 .8-2.2 2.2-.2-1.4-.8-2-2.2-2.2 1.4-.2 2-.8 2.2-2.2Z", opacity: ".55" })
63
+ ] });
64
+ }
65
+ function Thinking({
66
+ status = "thinking",
67
+ steps = [],
68
+ summary,
69
+ seconds,
70
+ label = "Thinking",
71
+ open,
72
+ defaultOpen = false,
73
+ onOpenChange,
74
+ variant = "block",
75
+ size = "md",
76
+ className
77
+ }) {
78
+ const id = useId();
79
+ const root = useRef(null);
80
+ const live = status === "thinking";
81
+ const own = useElapsed(live && seconds === void 0, root);
82
+ const secs = seconds ?? own;
83
+ const [inner, setInner] = useState(defaultOpen);
84
+ const isOpen = open ?? inner;
85
+ const setOpen = (next) => {
86
+ if (open === void 0) setInner(next);
87
+ onOpenChange?.(next);
88
+ };
89
+ const [prev, setPrev] = useState(status);
90
+ if (prev !== status) {
91
+ setPrev(status);
92
+ if (!live && open === void 0) setInner(false);
93
+ }
94
+ const time = formatThinkingTime(secs);
95
+ const heading = live ? label : status === "stopped" ? `Stopped after ${time}` : `Thought for ${time}`;
96
+ const sm = size === "sm";
97
+ const inline = variant === "inline";
98
+ const canOpen = !inline && steps.length > 0;
99
+ const preview = live ? steps[steps.length - 1] : summary ?? steps[steps.length - 1];
100
+ const head = /* @__PURE__ */ jsxs(Fragment, { children: [
101
+ /* @__PURE__ */ jsx(Spark, { live, className: sm ? "h-3.5 w-3.5" : "h-4 w-4" }),
102
+ /* @__PURE__ */ jsx(Shimmer, { text: heading, on: live }),
103
+ live && /* @__PURE__ */ jsx("span", { className: "shrink-0 tabular-nums text-mute", children: time }),
104
+ canOpen && /* @__PURE__ */ jsx(
105
+ "svg",
106
+ {
107
+ viewBox: "0 0 16 16",
108
+ "aria-hidden": true,
109
+ className: cx("h-3.5 w-3.5 shrink-0 text-mute transition-transform duration-300", isOpen && "rotate-90"),
110
+ style: { transitionTimingFunction: CURVE },
111
+ fill: "none",
112
+ stroke: "currentColor",
113
+ strokeWidth: "1.7",
114
+ strokeLinecap: "round",
115
+ strokeLinejoin: "round",
116
+ children: /* @__PURE__ */ jsx("path", { d: "m6 4 4 4-4 4" })
117
+ }
118
+ )
119
+ ] });
120
+ return /* @__PURE__ */ jsxs(
121
+ "div",
122
+ {
123
+ ref: root,
124
+ className: cx("asta-thinking-a min-w-0 text-ink", inline ? "inline-flex max-w-full align-middle" : "flex w-full flex-col", sm ? "text-[12.5px]" : "text-[13.5px]", className),
125
+ children: [
126
+ /* @__PURE__ */ jsx("style", { href: "asta-thinking", precedence: "asta", children: KEYFRAMES }),
127
+ /* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: live ? `${label}\u2026` : heading.replace(/(\d+)s$/, "$1 seconds") }),
128
+ canOpen ? /* @__PURE__ */ jsx(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ "aria-expanded": isOpen,
133
+ "aria-controls": `${id}-panel`,
134
+ onClick: () => setOpen(!isOpen),
135
+ className: "-mx-1.5 flex min-w-0 max-w-full items-center gap-1.5 self-start rounded-md px-1.5 py-1 font-medium outline-none transition-colors duration-200 hover:bg-paper-2 focus-visible:ring-2 focus-visible:ring-brand/50",
136
+ children: head
137
+ }
138
+ ) : /* @__PURE__ */ jsx("span", { className: "flex min-w-0 items-center gap-1.5 py-1 font-medium", children: head }),
139
+ !inline && preview && !isOpen && /* @__PURE__ */ jsx("p", { title: preview, className: cx("asta-thinking-a truncate text-mute animate-[asta-thinking-in_.4s_cubic-bezier(.16,1,.3,1)_both]", sm ? "pl-5" : "pl-[22px]"), children: preview }, preview),
140
+ canOpen && /* @__PURE__ */ jsx(
141
+ "div",
142
+ {
143
+ id: `${id}-panel`,
144
+ inert: !isOpen,
145
+ className: cx("grid transition-[grid-template-rows,opacity] duration-300", isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"),
146
+ style: { transitionTimingFunction: CURVE },
147
+ children: /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx("ol", { "aria-label": "Reasoning", className: "ml-[7px] mt-1 flex flex-col gap-2 pb-1 pl-[14px] shadow-[inset_1px_0_0_color-mix(in_srgb,var(--ink)_12%,transparent)]", children: steps.map((s, i) => /* @__PURE__ */ jsxs("li", { className: "asta-thinking-a leading-relaxed text-ink-2 animate-[asta-thinking-in_.45s_cubic-bezier(.16,1,.3,1)_both]", children: [
148
+ s,
149
+ live && i === steps.length - 1 && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "ml-1.5 inline-block h-1.5 w-1.5 rounded-full bg-brand align-middle animate-[asta-thinking-pulse_1.2s_ease-in-out_infinite]" })
150
+ ] }, `${i}-${s}`)) }) })
151
+ }
152
+ )
153
+ ]
154
+ }
155
+ );
156
+ }
157
+ var thinking_default = Thinking;
158
+
159
+ export {
160
+ formatThinkingTime,
161
+ Thinking,
162
+ thinking_default
163
+ };